@wrongstack/webui 0.297.0 → 0.298.1

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 (546) hide show
  1. package/dist/assets/AgentRosterView-C26RCdot.js +11 -0
  2. package/dist/assets/{AnalyticsDashboard-CkceglT6.js → AnalyticsDashboard-CEjjV3bX.js} +1 -1
  3. package/dist/assets/AudienceMemoryPanel-CnfZC8x0.js +3 -0
  4. package/dist/assets/{ChangesView-DouwIaDk.js → ChangesView-D0BiTbs8.js} +1 -1
  5. package/dist/assets/ChronicleDashboard-BZ4XOcvf.js +1 -0
  6. package/dist/assets/CodeEditor-BlqaT56D.js +1 -0
  7. package/dist/assets/CodeMap-Bj5tjjW5.js +1 -0
  8. package/dist/assets/{CronJobsPanel-CAImDL8t.js → CronJobsPanel-F6nhZtfg.js} +1 -1
  9. package/dist/assets/DeadCodeScanPanel-C9sLNUUc.js +2 -0
  10. package/dist/assets/{DebugDashboard-DLNPZIEI.js → DebugDashboard-D8BLcLjI.js} +1 -1
  11. package/dist/assets/{DesignGalleryView-D0azMq2e.js → DesignGalleryView-B8mE5nGy.js} +1 -1
  12. package/dist/assets/GoalView-DIx7Zr4a.js +1 -0
  13. package/dist/assets/KanbanView-DshzDwq1.js +3 -0
  14. package/dist/assets/MailboxDetailView-BJXpXjtm.js +1 -0
  15. package/dist/assets/MemoryManager-B-S5oREO.js +1 -0
  16. package/dist/assets/{ModelPicker-CN-UD3lc.js → ModelPicker-CNHhT2SO.js} +1 -1
  17. package/dist/assets/OfficeMapPanel-CBN9uG80.js +4 -0
  18. package/dist/assets/{ProcessMonitor-ButM8C0T.js → ProcessMonitor-Cc8LsfTh.js} +1 -1
  19. package/dist/assets/QueuePanel-B0NXFwEt.js +1 -0
  20. package/dist/assets/{RefreshDebugView-DVvWsh9A.js → RefreshDebugView-DLst_piS.js} +1 -1
  21. package/dist/assets/SageTabs-NwMcr4Pq.js +2 -0
  22. package/dist/assets/SddHub-CpRHXmjm.js +2 -0
  23. package/dist/assets/SessionsDashboard-C5dXb0iJ.js +1 -0
  24. package/dist/assets/SetupScreen-B81fcNgP.js +1 -0
  25. package/dist/assets/SkillDetailView-BTvgE_MD.js +3 -0
  26. package/dist/assets/{SpecsView-BJs_okSx.js → SpecsView-DhuaZcOl.js} +1 -1
  27. package/dist/assets/TechStackView-BXmfl2qY.js +1 -0
  28. package/dist/assets/{TerminalPanel-W2V0X7b9.js → TerminalPanel-DjruTcb6.js} +1 -1
  29. package/dist/assets/{Toaster-CbcX_Cou.js → Toaster-BmyghnqJ.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-uGqXvobk.js → button-BMECp1cg.js} +1 -1
  38. package/dist/assets/{chat-Du7n7HZ7.js → chat-CRmMDzCb.js} +1 -1
  39. package/dist/assets/{chat-VkTBQmmx.js → chat-CwnuX7tG.js} +1 -1
  40. package/dist/assets/{chat-BJzPxfyr.js → chat-DLn1hY01.js} +1 -1
  41. package/dist/assets/{chat-IRKmQ6we.js → chat-DSEq1Bdz.js} +1 -1
  42. package/dist/assets/{chat-C7ybebfi.js → chat-DxLD17ER.js} +1 -1
  43. package/dist/assets/{chat-BRBVFl4h.js → chat-DzPxYALH.js} +1 -1
  44. package/dist/assets/{chat-Bkom8vQo.js → chat-OunddzYy.js} +1 -1
  45. package/dist/assets/chat-store-B2CjP2Zl.js +17 -0
  46. package/dist/assets/{codemap-activity-store-DP3mCZu1.js → codemap-activity-store-Cz0_AHqt.js} +1 -1
  47. package/dist/assets/codemap-index-store-B-XLZpJu.js +1 -0
  48. package/dist/assets/common-BfVFjVhf.js +1 -0
  49. package/dist/assets/common-C5hY-d_0.js +1 -0
  50. package/dist/assets/{dialog-CT1PTjzK.js → dialog-BJef9ZZo.js} +1 -1
  51. package/dist/assets/{empty-state-CdyXy96A.js → empty-state-BGzRrNXI.js} +1 -1
  52. package/dist/assets/{i18n-1BkaqMgr.js → i18n-2wGPPdl_.js} +2 -2
  53. package/dist/assets/index-DeA8UyiB.css +1 -0
  54. package/dist/assets/index-x6-rLl5H.js +132 -0
  55. package/dist/assets/{input-B-VCX2sG.js → input-Bd10nfMj.js} +1 -1
  56. package/dist/assets/{mailbox-store-DVoNbOZr.js → mailbox-store-D3omLzBk.js} +1 -1
  57. package/dist/assets/markdown-sSmz-Ua_.js +44 -0
  58. package/dist/assets/progress-ring-BEULkQ1r.js +1 -0
  59. package/dist/assets/{roster-ws-DXm0krqH.js → roster-ws-BmV_3U6w.js} +1 -1
  60. package/dist/assets/session-store-ZMNU48xK.js +1 -0
  61. package/dist/assets/settings-BF0lRxlj.js +1 -0
  62. package/dist/assets/settings-CP6cwqHD.js +1 -0
  63. package/dist/assets/settings-D0rWEhMg.js +1 -0
  64. package/dist/assets/settings-DFCaP02p.js +1 -0
  65. package/dist/assets/settings-DHix1ZPL.js +1 -0
  66. package/dist/assets/{settings-DEmKlLmn.js → settings-eEzjNzsC.js} +1 -1
  67. package/dist/assets/settings-kp_aIgcX.js +1 -0
  68. package/dist/assets/{shared-jvJxtKc5.js → shared-CrX8iE-U.js} +1 -1
  69. package/dist/assets/stores-DyQOSkkD.js +7 -0
  70. package/dist/assets/ui-store-di6oY7cy.js +1 -0
  71. package/dist/assets/useWebSocket-BVFPigcY.js +28 -0
  72. package/dist/assets/{utils-CN2sfDVP.js → utils-CwJvjOcH.js} +1 -1
  73. package/dist/assets/{vendor-2VBBgNb5.js → vendor-BTTkQ9Tn.js} +28 -28
  74. package/dist/assets/{view-navigation-Cgy5xh9q.js → view-navigation-BMRzqGbq.js} +1 -1
  75. package/dist/assets/ws-client-B0-KwuTK.js +1 -0
  76. package/dist/components/ChatInput/refine-panel-host.d.ts +9 -1
  77. package/dist/components/DeadCodeScanPanel/DeadCodeScanPanel.d.ts +1 -3
  78. package/dist/components/MemoryManager/MemoryInjectorPanel.d.ts +19 -0
  79. package/dist/components/PanelSuspense.d.ts +8 -0
  80. package/dist/components/SettingsPanel/DisplaySection.d.ts +20 -0
  81. package/dist/components/SettingsPanel/PluginToggleList.d.ts +11 -1
  82. package/dist/components/ViewRouter.d.ts +12 -0
  83. package/dist/components/WorkbenchTopbar.d.ts +53 -0
  84. package/dist/components/codemap-model.d.ts +2 -0
  85. package/dist/hooks/useViewport.d.ts +38 -0
  86. package/dist/hooks/useWebSocket.d.ts +1 -0
  87. package/dist/hooks/ws-handlers/misc-handlers.d.ts +1 -0
  88. package/dist/index.html +25 -26
  89. package/dist/index.js +58857 -57378
  90. package/dist/lib/sage-block.d.ts +18 -23
  91. package/dist/lib/view-navigation.d.ts +1 -1
  92. package/dist/lib/ws-client.d.ts +16 -8
  93. package/dist/providers.json +10 -0
  94. package/dist/stores/chat-store.d.ts +36 -3
  95. package/dist/stores/config-store.d.ts +0 -2
  96. package/dist/stores/local-prefs.d.ts +22 -2
  97. package/dist/stores/session-store.d.ts +3 -0
  98. package/dist/stores/types.d.ts +2 -1
  99. package/dist/stores/ui-store.d.ts +8 -1
  100. package/dist/types/client-message.d.ts +1 -0
  101. package/dist/types/connections.d.ts +7 -1
  102. package/dist/types/server-message.d.ts +11 -0
  103. package/dist/types/system.d.ts +4 -0
  104. package/package.json +11 -9
  105. package/dist/App.d.ts.map +0 -1
  106. package/dist/assets/AgentRosterView-Cje2NBtU.js +0 -11
  107. package/dist/assets/AudienceMemoryPanel-DB-8ISNP.js +0 -3
  108. package/dist/assets/ChronicleDashboard-B4Khm6hu.js +0 -1
  109. package/dist/assets/CodeEditor-CrKbA5s8.js +0 -1
  110. package/dist/assets/CodeMap-Dz8yNlUe.js +0 -1
  111. package/dist/assets/DeadCodeScanPanel-C5ehBTQF.js +0 -2
  112. package/dist/assets/GoalView-gtQRK78W.js +0 -1
  113. package/dist/assets/KanbanView-BXKe19EI.js +0 -3
  114. package/dist/assets/LazyMarkdown-BGwFjYKr.js +0 -3
  115. package/dist/assets/MailboxDetailView-D4fXipos.js +0 -1
  116. package/dist/assets/MemoryManager-D_rquas9.js +0 -1
  117. package/dist/assets/OfficeMapPanel-CJFrTNmg.js +0 -4
  118. package/dist/assets/QueuePanel-C5oihwYM.js +0 -1
  119. package/dist/assets/SageTabs-C9vAgvCD.js +0 -2
  120. package/dist/assets/SddHub-D_nsWjuM.js +0 -2
  121. package/dist/assets/SessionsDashboard-DdwU3Ma5.js +0 -1
  122. package/dist/assets/SetupScreen-CQCfLdPI.js +0 -1
  123. package/dist/assets/SkillDetailView-mVxi-9jo.js +0 -3
  124. package/dist/assets/TechStackView-BZ4M7TYc.js +0 -1
  125. package/dist/assets/chat-store-CM1dMeuY.js +0 -17
  126. package/dist/assets/codemap-index-store-DyAe3ZYJ.js +0 -1
  127. package/dist/assets/common-D8_r1x8x.js +0 -1
  128. package/dist/assets/common-suUxW9sA.js +0 -1
  129. package/dist/assets/index-BPfIz78e.js +0 -131
  130. package/dist/assets/index-BlceaIyu.css +0 -1
  131. package/dist/assets/markdown-L6DLSM7f.js +0 -44
  132. package/dist/assets/progress-ring-CFOvGxw7.js +0 -1
  133. package/dist/assets/session-store-BsNYnfOc.js +0 -1
  134. package/dist/assets/settings-C5F2tQ7C.js +0 -1
  135. package/dist/assets/settings-Cdk8i_p6.js +0 -1
  136. package/dist/assets/settings-D6wFOw5n.js +0 -1
  137. package/dist/assets/settings-DCEOkxYE.js +0 -1
  138. package/dist/assets/settings-DsflqNn0.js +0 -1
  139. package/dist/assets/settings-skShEZ2B.js +0 -1
  140. package/dist/assets/stores-mpa0202y.js +0 -6
  141. package/dist/assets/ui-store-CS-njcmT.js +0 -1
  142. package/dist/assets/useWebSocket-Dh3aAFDE.js +0 -28
  143. package/dist/assets/ws-client-WVGn8ORh.js +0 -1
  144. package/dist/components/AgentOfficeDetails.d.ts.map +0 -1
  145. package/dist/components/AgentOfficeView/model.d.ts.map +0 -1
  146. package/dist/components/AgentOfficeView.d.ts.map +0 -1
  147. package/dist/components/AgentRosterCatalogTab.d.ts.map +0 -1
  148. package/dist/components/AgentRosterChrome.d.ts.map +0 -1
  149. package/dist/components/AgentRosterLiveTab.d.ts.map +0 -1
  150. package/dist/components/AgentRosterSelfLearningTab.d.ts.map +0 -1
  151. package/dist/components/AgentRosterView.d.ts.map +0 -1
  152. package/dist/components/AgentRuntimePolicyEditor.d.ts.map +0 -1
  153. package/dist/components/AgentTranscript.d.ts.map +0 -1
  154. package/dist/components/AgentsMonitor.d.ts.map +0 -1
  155. package/dist/components/AgentsPage/format.d.ts.map +0 -1
  156. package/dist/components/AgentsPage.d.ts.map +0 -1
  157. package/dist/components/AnalyticsDashboard.d.ts.map +0 -1
  158. package/dist/components/AudienceMemoryPanel.d.ts.map +0 -1
  159. package/dist/components/AutonomyPicker.d.ts.map +0 -1
  160. package/dist/components/AvailabilityCalendarEditor.d.ts.map +0 -1
  161. package/dist/components/BoardView.d.ts.map +0 -1
  162. package/dist/components/ChangesView.d.ts.map +0 -1
  163. package/dist/components/ChatInput/code-detect.d.ts.map +0 -1
  164. package/dist/components/ChatInput/draft-token-counter.d.ts.map +0 -1
  165. package/dist/components/ChatInput/file-mention-picker.d.ts.map +0 -1
  166. package/dist/components/ChatInput/image-attach-control.d.ts.map +0 -1
  167. package/dist/components/ChatInput/image-attachments.d.ts.map +0 -1
  168. package/dist/components/ChatInput/queued-messages.d.ts.map +0 -1
  169. package/dist/components/ChatInput/refine-panel-host.d.ts.map +0 -1
  170. package/dist/components/ChatInput/slash-commands.d.ts.map +0 -1
  171. package/dist/components/ChatInput/slash-popup.d.ts.map +0 -1
  172. package/dist/components/ChatInput/slash-routing.d.ts.map +0 -1
  173. package/dist/components/ChatInput/stop-controls.d.ts.map +0 -1
  174. package/dist/components/ChatInput/use-paste-drop.d.ts.map +0 -1
  175. package/dist/components/ChatInput.d.ts.map +0 -1
  176. package/dist/components/ChatView/ThinkingBubble.d.ts.map +0 -1
  177. package/dist/components/ChatView/index.d.ts.map +0 -1
  178. package/dist/components/ChatView/utils.d.ts.map +0 -1
  179. package/dist/components/ChatView.d.ts.map +0 -1
  180. package/dist/components/CheckpointTimeline.d.ts.map +0 -1
  181. package/dist/components/ChipMultiSelect.d.ts.map +0 -1
  182. package/dist/components/ChronicleDashboard.d.ts.map +0 -1
  183. package/dist/components/ChroniclePipelineStrip.d.ts.map +0 -1
  184. package/dist/components/CodeEditor.d.ts.map +0 -1
  185. package/dist/components/CodeMap.d.ts.map +0 -1
  186. package/dist/components/CodeMapActivityDrawer.d.ts.map +0 -1
  187. package/dist/components/CodeMapActivityHelpers.d.ts.map +0 -1
  188. package/dist/components/CodeMapActivityStreamPanel.d.ts.map +0 -1
  189. package/dist/components/CodeMapCanvasSurface.d.ts.map +0 -1
  190. package/dist/components/CodeMapCanvasToolbar.d.ts.map +0 -1
  191. package/dist/components/CodeMapConfig.d.ts.map +0 -1
  192. package/dist/components/CodeMapDirectoryTree.d.ts.map +0 -1
  193. package/dist/components/CodeMapFlowState.d.ts.map +0 -1
  194. package/dist/components/CodeMapHeader.d.ts.map +0 -1
  195. package/dist/components/CodeMapLiveOverlay.d.ts.map +0 -1
  196. package/dist/components/CodeMapRelationInspector.d.ts.map +0 -1
  197. package/dist/components/CodeMapRelations.d.ts.map +0 -1
  198. package/dist/components/CodeMapSearchResults.d.ts.map +0 -1
  199. package/dist/components/CodeMapSelectedNodeSummary.d.ts.map +0 -1
  200. package/dist/components/CodeMapTreeSidebar.d.ts.map +0 -1
  201. package/dist/components/CodeMapVisuals.d.ts.map +0 -1
  202. package/dist/components/CollabPanel.d.ts.map +0 -1
  203. package/dist/components/CommandPalette/export-utils.d.ts.map +0 -1
  204. package/dist/components/CommandPalette/index.d.ts.map +0 -1
  205. package/dist/components/CommandPalette.d.ts.map +0 -1
  206. package/dist/components/ConfirmDialog.d.ts.map +0 -1
  207. package/dist/components/ConfirmModal.d.ts.map +0 -1
  208. package/dist/components/ConnectionBanner.d.ts.map +0 -1
  209. package/dist/components/ContextBar.d.ts.map +0 -1
  210. package/dist/components/ContextBreakdownModal.d.ts.map +0 -1
  211. package/dist/components/ContextDashboard.d.ts.map +0 -1
  212. package/dist/components/ContextMemoryMonitor.d.ts.map +0 -1
  213. package/dist/components/ContextModePicker.d.ts.map +0 -1
  214. package/dist/components/CostChip.d.ts.map +0 -1
  215. package/dist/components/CronJobsPanel.d.ts.map +0 -1
  216. package/dist/components/CronTrigger.d.ts.map +0 -1
  217. package/dist/components/CustomRosterPanel.d.ts.map +0 -1
  218. package/dist/components/DeadCodeScanPanel/DeadCodeScanPanel.d.ts.map +0 -1
  219. package/dist/components/DebugDashboard.d.ts.map +0 -1
  220. package/dist/components/DependencyGraph.d.ts.map +0 -1
  221. package/dist/components/DesignGalleryView.d.ts.map +0 -1
  222. package/dist/components/DiffView.d.ts.map +0 -1
  223. package/dist/components/ErrorBoundary.d.ts.map +0 -1
  224. package/dist/components/FallbackEditor.d.ts.map +0 -1
  225. package/dist/components/FileActivityDrawer.d.ts.map +0 -1
  226. package/dist/components/FileExplorer.d.ts.map +0 -1
  227. package/dist/components/FilePicker.d.ts.map +0 -1
  228. package/dist/components/FileReferenceChip.d.ts.map +0 -1
  229. package/dist/components/FleetMonitor.d.ts.map +0 -1
  230. package/dist/components/FleetPanel.d.ts.map +0 -1
  231. package/dist/components/GoalPanel.d.ts.map +0 -1
  232. package/dist/components/GoalView.d.ts.map +0 -1
  233. package/dist/components/InspectorPanel.d.ts.map +0 -1
  234. package/dist/components/KanbanAgentRunPanel.d.ts.map +0 -1
  235. package/dist/components/KanbanBoardChrome.d.ts.map +0 -1
  236. package/dist/components/KanbanBoardSidebar.d.ts.map +0 -1
  237. package/dist/components/KanbanBoardState.d.ts.map +0 -1
  238. package/dist/components/KanbanBoundaryEditor.d.ts.map +0 -1
  239. package/dist/components/KanbanCleanerAlert.d.ts.map +0 -1
  240. package/dist/components/KanbanColumnView.d.ts.map +0 -1
  241. package/dist/components/KanbanDecompositionPanel.d.ts.map +0 -1
  242. package/dist/components/KanbanQueueHealthBar.d.ts.map +0 -1
  243. package/dist/components/KanbanRunControls.d.ts.map +0 -1
  244. package/dist/components/KanbanTaskActivityRecorder.d.ts.map +0 -1
  245. package/dist/components/KanbanTaskCompletionChecks.d.ts.map +0 -1
  246. package/dist/components/KanbanTaskFields.d.ts.map +0 -1
  247. package/dist/components/KanbanTaskInspector.d.ts.map +0 -1
  248. package/dist/components/KanbanTaskOptions.d.ts.map +0 -1
  249. package/dist/components/KanbanTaskTree.d.ts.map +0 -1
  250. package/dist/components/KanbanVerificationDashboard.d.ts.map +0 -1
  251. package/dist/components/KanbanView.d.ts.map +0 -1
  252. package/dist/components/KanbanViewModeTabs.d.ts.map +0 -1
  253. package/dist/components/MailboxDetailView.d.ts.map +0 -1
  254. package/dist/components/MailboxPanel.d.ts.map +0 -1
  255. package/dist/components/MemoryManager/DeleteMemoryDialog.d.ts.map +0 -1
  256. package/dist/components/MemoryManager/MemoryDetail.d.ts.map +0 -1
  257. package/dist/components/MemoryManager/MemoryDrawer.d.ts.map +0 -1
  258. package/dist/components/MemoryManager/MemoryEditor.d.ts.map +0 -1
  259. package/dist/components/MemoryManager/MemoryFilters.d.ts.map +0 -1
  260. package/dist/components/MemoryManager/MemoryGraph.d.ts.map +0 -1
  261. package/dist/components/MemoryManager/MemoryInjectorTrace.d.ts +0 -3
  262. package/dist/components/MemoryManager/MemoryInjectorTrace.d.ts.map +0 -1
  263. package/dist/components/MemoryManager/MemoryLifecycleTrace.d.ts.map +0 -1
  264. package/dist/components/MemoryManager/MemoryList.d.ts.map +0 -1
  265. package/dist/components/MemoryManager/MemoryManagerEmpty.d.ts.map +0 -1
  266. package/dist/components/MemoryManager/SageTabs.d.ts.map +0 -1
  267. package/dist/components/MemoryManager/index.d.ts.map +0 -1
  268. package/dist/components/MemoryManager/selectors.d.ts.map +0 -1
  269. package/dist/components/MemoryManager/shared.d.ts.map +0 -1
  270. package/dist/components/MessageBubble/AttachmentGallery.d.ts.map +0 -1
  271. package/dist/components/MessageBubble/CopyButton.d.ts.map +0 -1
  272. package/dist/components/MessageBubble/ErrorBody.d.ts.map +0 -1
  273. package/dist/components/MessageBubble/LazyMarkdown.d.ts.map +0 -1
  274. package/dist/components/MessageBubble/StreamingMarkdown.d.ts.map +0 -1
  275. package/dist/components/MessageBubble/ToolInputView.d.ts.map +0 -1
  276. package/dist/components/MessageBubble/ToolLedgerCard.d.ts.map +0 -1
  277. package/dist/components/MessageBubble/index.d.ts.map +0 -1
  278. package/dist/components/MessageBubble/utils.d.ts.map +0 -1
  279. package/dist/components/MessageBubble.d.ts.map +0 -1
  280. package/dist/components/ModePicker.d.ts.map +0 -1
  281. package/dist/components/ModelPickDialog.d.ts.map +0 -1
  282. package/dist/components/ModelPicker.d.ts.map +0 -1
  283. package/dist/components/ModelSelectDialog.d.ts.map +0 -1
  284. package/dist/components/MonacoDiffView.d.ts.map +0 -1
  285. package/dist/components/NextStepsBar.d.ts.map +0 -1
  286. package/dist/components/OfficeMapCanvas/CanvasPanels.d.ts.map +0 -1
  287. package/dist/components/OfficeMapCanvas/Hud.d.ts.map +0 -1
  288. package/dist/components/OfficeMapCanvas/Overlays.d.ts.map +0 -1
  289. package/dist/components/OfficeMapCanvas/SelectedNodeDetailPanel.d.ts.map +0 -1
  290. package/dist/components/OfficeMapCanvas/edges.d.ts.map +0 -1
  291. package/dist/components/OfficeMapCanvas/nodes.d.ts.map +0 -1
  292. package/dist/components/OfficeMapCanvas/resolve.d.ts.map +0 -1
  293. package/dist/components/OfficeMapCanvas/use-recently-finished.d.ts.map +0 -1
  294. package/dist/components/OfficeMapCanvas/utils.d.ts.map +0 -1
  295. package/dist/components/OfficeMapCanvas.d.ts.map +0 -1
  296. package/dist/components/OfficeMapPanel.d.ts.map +0 -1
  297. package/dist/components/OfficeMapSettingsPanel.d.ts.map +0 -1
  298. package/dist/components/PhasePanel.d.ts.map +0 -1
  299. package/dist/components/PlanPanel.d.ts.map +0 -1
  300. package/dist/components/ProcessMonitor.d.ts.map +0 -1
  301. package/dist/components/PromptLibraryModal.d.ts.map +0 -1
  302. package/dist/components/ProviderWaitingRoom.d.ts.map +0 -1
  303. package/dist/components/QueuePanel.d.ts.map +0 -1
  304. package/dist/components/QuickModelSwitcher.d.ts.map +0 -1
  305. package/dist/components/QuickModelSwitcher.filter.d.ts.map +0 -1
  306. package/dist/components/RefinePanel.d.ts.map +0 -1
  307. package/dist/components/RefreshDebugView.d.ts.map +0 -1
  308. package/dist/components/SageMemoryCard.d.ts +0 -19
  309. package/dist/components/SageMemoryCard.d.ts.map +0 -1
  310. package/dist/components/SddActivityFeed.d.ts.map +0 -1
  311. package/dist/components/SddBoardView.d.ts.map +0 -1
  312. package/dist/components/SddDestroyDialog.d.ts.map +0 -1
  313. package/dist/components/SddFlowGraph.d.ts.map +0 -1
  314. package/dist/components/SddHub.d.ts.map +0 -1
  315. package/dist/components/SddKanbanView.d.ts.map +0 -1
  316. package/dist/components/SddTaskDrawer.d.ts.map +0 -1
  317. package/dist/components/SddWizard.d.ts.map +0 -1
  318. package/dist/components/SearchOverlay.d.ts.map +0 -1
  319. package/dist/components/SendButton.d.ts.map +0 -1
  320. package/dist/components/SessionWatchPanel.d.ts.map +0 -1
  321. package/dist/components/SessionsDashboard.d.ts.map +0 -1
  322. package/dist/components/SettingsPanel/BasicSettingsTabs.d.ts.map +0 -1
  323. package/dist/components/SettingsPanel/BrainSection.d.ts.map +0 -1
  324. package/dist/components/SettingsPanel/ChimeraSettingsPanel.d.ts.map +0 -1
  325. package/dist/components/SettingsPanel/ClearAllowlistDialog.d.ts.map +0 -1
  326. package/dist/components/SettingsPanel/ConnectionsHealthSection.d.ts.map +0 -1
  327. package/dist/components/SettingsPanel/FallbacksSection.d.ts.map +0 -1
  328. package/dist/components/SettingsPanel/FleetSection.d.ts.map +0 -1
  329. package/dist/components/SettingsPanel/IntegrationsSection.d.ts.map +0 -1
  330. package/dist/components/SettingsPanel/MCPSection.d.ts.map +0 -1
  331. package/dist/components/SettingsPanel/ModelSection.d.ts.map +0 -1
  332. package/dist/components/SettingsPanel/OAuthLoginSection.d.ts.map +0 -1
  333. package/dist/components/SettingsPanel/PluginToggleList.d.ts.map +0 -1
  334. package/dist/components/SettingsPanel/PreferenceControls.d.ts.map +0 -1
  335. package/dist/components/SettingsPanel/PreferenceToggle.d.ts.map +0 -1
  336. package/dist/components/SettingsPanel/ProviderModelsPanel.d.ts.map +0 -1
  337. package/dist/components/SettingsPanel/ProviderModelsPanel.filter.d.ts.map +0 -1
  338. package/dist/components/SettingsPanel/ProviderSection.d.ts.map +0 -1
  339. package/dist/components/SettingsPanel/RoutingSection.d.ts.map +0 -1
  340. package/dist/components/SettingsPanel/SecuritySection.d.ts.map +0 -1
  341. package/dist/components/SettingsPanel/ShadowSection.d.ts.map +0 -1
  342. package/dist/components/SettingsPanel/ToolsSection.d.ts.map +0 -1
  343. package/dist/components/SettingsPanel/brain-section-options.d.ts.map +0 -1
  344. package/dist/components/SettingsPanel/index.d.ts.map +0 -1
  345. package/dist/components/SettingsPanel/local-presets.d.ts.map +0 -1
  346. package/dist/components/SettingsPanel/official-servers.d.ts.map +0 -1
  347. package/dist/components/SettingsPanel/settings-panel-reducers.d.ts.map +0 -1
  348. package/dist/components/SettingsPanel/undo-send-decision.d.ts.map +0 -1
  349. package/dist/components/SettingsPanel.d.ts.map +0 -1
  350. package/dist/components/SetupScreen/CustomProviderSection.d.ts.map +0 -1
  351. package/dist/components/SetupScreen/ModelEditor.d.ts.map +0 -1
  352. package/dist/components/SetupScreen/ProviderKeyCard.d.ts.map +0 -1
  353. package/dist/components/SetupScreen/key-operation.d.ts.map +0 -1
  354. package/dist/components/SetupScreen/popular-providers.d.ts.map +0 -1
  355. package/dist/components/SetupScreen/relative-time.d.ts.map +0 -1
  356. package/dist/components/SetupScreen/types.d.ts.map +0 -1
  357. package/dist/components/SetupScreen.d.ts.map +0 -1
  358. package/dist/components/ShortcutsOverlay.d.ts.map +0 -1
  359. package/dist/components/SideEffectTimeline.d.ts.map +0 -1
  360. package/dist/components/SidePanel/AgentsPanel.d.ts.map +0 -1
  361. package/dist/components/SidePanel/ChangesPanel.d.ts.map +0 -1
  362. package/dist/components/SidePanel/DesignStudioPanel.d.ts.map +0 -1
  363. package/dist/components/SidePanel/SessionList.d.ts.map +0 -1
  364. package/dist/components/SidePanel/SessionPanel.d.ts.map +0 -1
  365. package/dist/components/SidePanel/SkillsList.d.ts.map +0 -1
  366. package/dist/components/SidePanel/WorktreesPanel.d.ts.map +0 -1
  367. package/dist/components/SidePanel/index.d.ts.map +0 -1
  368. package/dist/components/SkillDetailView.d.ts.map +0 -1
  369. package/dist/components/SpecsView.d.ts.map +0 -1
  370. package/dist/components/TaskActivityTimeline.d.ts.map +0 -1
  371. package/dist/components/TaskBoard.d.ts.map +0 -1
  372. package/dist/components/TaskCard.d.ts.map +0 -1
  373. package/dist/components/TaskExecutionAttempts.d.ts.map +0 -1
  374. package/dist/components/TaskIntelligencePanel.d.ts.map +0 -1
  375. package/dist/components/TaskRiskPanel.d.ts.map +0 -1
  376. package/dist/components/TaskVerificationSection.d.ts.map +0 -1
  377. package/dist/components/TasksPanel.d.ts.map +0 -1
  378. package/dist/components/TechStackView/DependencyDetail.d.ts.map +0 -1
  379. package/dist/components/TechStackView/DependencyTable.d.ts.map +0 -1
  380. package/dist/components/TechStackView/FindingsPanel.d.ts.map +0 -1
  381. package/dist/components/TechStackView/TechStackToolbar.d.ts.map +0 -1
  382. package/dist/components/TechStackView/index.d.ts.map +0 -1
  383. package/dist/components/TechStackView/shared.d.ts.map +0 -1
  384. package/dist/components/TerminalPanel.d.ts.map +0 -1
  385. package/dist/components/ThemeProvider.d.ts.map +0 -1
  386. package/dist/components/Toaster.d.ts.map +0 -1
  387. package/dist/components/TodosPanel.d.ts.map +0 -1
  388. package/dist/components/ToolGroup.d.ts.map +0 -1
  389. package/dist/components/ToolResult.d.ts.map +0 -1
  390. package/dist/components/UpdateBanner.d.ts.map +0 -1
  391. package/dist/components/VerificationReportPanel.d.ts.map +0 -1
  392. package/dist/components/WatchMessageBubble.d.ts.map +0 -1
  393. package/dist/components/WelcomeScreen.d.ts.map +0 -1
  394. package/dist/components/WorkDashboard.d.ts.map +0 -1
  395. package/dist/components/WorkspaceDock.d.ts.map +0 -1
  396. package/dist/components/WorktreeGraph.d.ts.map +0 -1
  397. package/dist/components/WorktreeLanes.d.ts.map +0 -1
  398. package/dist/components/WorktreeOrphans.d.ts.map +0 -1
  399. package/dist/components/activity-bar/index.d.ts.map +0 -1
  400. package/dist/components/activity-bar/nav.d.ts.map +0 -1
  401. package/dist/components/agent-roster-data.d.ts.map +0 -1
  402. package/dist/components/agents/AgentDetailSection.d.ts.map +0 -1
  403. package/dist/components/agents/AgentRosterCard.d.ts.map +0 -1
  404. package/dist/components/agents/FleetSummaryBar.d.ts.map +0 -1
  405. package/dist/components/codemap-model.d.ts.map +0 -1
  406. package/dist/components/context-editor/ContextWindowEditor.d.ts.map +0 -1
  407. package/dist/components/dashboard-primitives.d.ts.map +0 -1
  408. package/dist/components/index.d.ts.map +0 -1
  409. package/dist/components/monaco-theme.d.ts.map +0 -1
  410. package/dist/components/toaster-helpers.d.ts.map +0 -1
  411. package/dist/components/ui/PickerCardList.d.ts.map +0 -1
  412. package/dist/components/ui/api-key-display.d.ts.map +0 -1
  413. package/dist/components/ui/badge.d.ts.map +0 -1
  414. package/dist/components/ui/button.d.ts.map +0 -1
  415. package/dist/components/ui/concurrency-gauge.d.ts.map +0 -1
  416. package/dist/components/ui/dialog.d.ts.map +0 -1
  417. package/dist/components/ui/dropdown-menu.d.ts.map +0 -1
  418. package/dist/components/ui/empty-state.d.ts.map +0 -1
  419. package/dist/components/ui/event-timeline.d.ts.map +0 -1
  420. package/dist/components/ui/fleet-agent-row.d.ts.map +0 -1
  421. package/dist/components/ui/index.d.ts.map +0 -1
  422. package/dist/components/ui/input.d.ts.map +0 -1
  423. package/dist/components/ui/pagination.d.ts.map +0 -1
  424. package/dist/components/ui/progress-ring.d.ts.map +0 -1
  425. package/dist/components/ui/scroll-area.d.ts.map +0 -1
  426. package/dist/components/ui/sheet.d.ts.map +0 -1
  427. package/dist/components/ui/sparkline.d.ts.map +0 -1
  428. package/dist/components/ui/tabs.d.ts.map +0 -1
  429. package/dist/components/useAgentRosterData.d.ts.map +0 -1
  430. package/dist/components/useKanbanRegistrySessionIds.d.ts.map +0 -1
  431. package/dist/hooks/index.d.ts.map +0 -1
  432. package/dist/hooks/use-ws-handlers.d.ts.map +0 -1
  433. package/dist/hooks/useDesktopBridge.d.ts.map +0 -1
  434. package/dist/hooks/useF5Resilience.d.ts.map +0 -1
  435. package/dist/hooks/useFieldKeyboardNav.d.ts.map +0 -1
  436. package/dist/hooks/useFleetPolling.d.ts.map +0 -1
  437. package/dist/hooks/useGitInfo.d.ts.map +0 -1
  438. package/dist/hooks/useGlobalKeyboardShortcuts.d.ts.map +0 -1
  439. package/dist/hooks/useHorizontalScroll.d.ts.map +0 -1
  440. package/dist/hooks/useKanbanMeta.d.ts.map +0 -1
  441. package/dist/hooks/useMemoryForFile.d.ts.map +0 -1
  442. package/dist/hooks/usePagination.d.ts.map +0 -1
  443. package/dist/hooks/useProviderModels.d.ts.map +0 -1
  444. package/dist/hooks/useScrollPosition.d.ts.map +0 -1
  445. package/dist/hooks/useWebSocket.d.ts.map +0 -1
  446. package/dist/hooks/ws-handlers/chat-handlers.d.ts.map +0 -1
  447. package/dist/hooks/ws-handlers/coordinator-handlers.d.ts.map +0 -1
  448. package/dist/hooks/ws-handlers/files-mailbox-handlers.d.ts.map +0 -1
  449. package/dist/hooks/ws-handlers/fleet-handlers.d.ts.map +0 -1
  450. package/dist/hooks/ws-handlers/misc-handlers.d.ts.map +0 -1
  451. package/dist/hooks/ws-handlers/session-handlers.d.ts.map +0 -1
  452. package/dist/hooks/ws-handlers/techstack-handlers.d.ts.map +0 -1
  453. package/dist/hooks/ws-handlers.d.ts.map +0 -1
  454. package/dist/i18n/index.d.ts.map +0 -1
  455. package/dist/i18n/languages.d.ts.map +0 -1
  456. package/dist/index.css.map +0 -7
  457. package/dist/index.js.map +0 -7
  458. package/dist/lib/accent-colors.d.ts.map +0 -1
  459. package/dist/lib/agent-office.d.ts.map +0 -1
  460. package/dist/lib/agent-status.d.ts.map +0 -1
  461. package/dist/lib/chime.d.ts.map +0 -1
  462. package/dist/lib/color.d.ts.map +0 -1
  463. package/dist/lib/completion.d.ts.map +0 -1
  464. package/dist/lib/core-browser-shim.d.ts.map +0 -1
  465. package/dist/lib/default-prompt-pools.d.ts.map +0 -1
  466. package/dist/lib/desktop-host.d.ts.map +0 -1
  467. package/dist/lib/desktop-shell.d.ts.map +0 -1
  468. package/dist/lib/fallback-ref.d.ts.map +0 -1
  469. package/dist/lib/favicon.d.ts.map +0 -1
  470. package/dist/lib/file-icons.d.ts.map +0 -1
  471. package/dist/lib/goal.d.ts.map +0 -1
  472. package/dist/lib/index.d.ts.map +0 -1
  473. package/dist/lib/kanban-cleaner.d.ts.map +0 -1
  474. package/dist/lib/kanban-metadata.d.ts.map +0 -1
  475. package/dist/lib/kanban-verification.d.ts.map +0 -1
  476. package/dist/lib/model-calendar.d.ts.map +0 -1
  477. package/dist/lib/model-matrix-routes.d.ts.map +0 -1
  478. package/dist/lib/notify.d.ts.map +0 -1
  479. package/dist/lib/plugin-enablement.d.ts.map +0 -1
  480. package/dist/lib/roster-ws.d.ts.map +0 -1
  481. package/dist/lib/sage-block.d.ts.map +0 -1
  482. package/dist/lib/sdd-theme.d.ts.map +0 -1
  483. package/dist/lib/stream-coalescer.d.ts.map +0 -1
  484. package/dist/lib/terminal-dock.d.ts.map +0 -1
  485. package/dist/lib/tool-icon.d.ts.map +0 -1
  486. package/dist/lib/tool-summary.d.ts.map +0 -1
  487. package/dist/lib/utils.d.ts.map +0 -1
  488. package/dist/lib/view-navigation.d.ts.map +0 -1
  489. package/dist/lib/ws-client-actions.d.ts.map +0 -1
  490. package/dist/lib/ws-client-contracts.d.ts.map +0 -1
  491. package/dist/lib/ws-client-helpers.d.ts.map +0 -1
  492. package/dist/lib/ws-client-utils.d.ts.map +0 -1
  493. package/dist/lib/ws-client.d.ts.map +0 -1
  494. package/dist/main.d.ts.map +0 -1
  495. package/dist/protocol-compatibility.d.ts.map +0 -1
  496. package/dist/stores/auto-submit-streak.d.ts.map +0 -1
  497. package/dist/stores/chat-store.d.ts.map +0 -1
  498. package/dist/stores/codemap-activity-store.d.ts.map +0 -1
  499. package/dist/stores/codemap-index-store.d.ts.map +0 -1
  500. package/dist/stores/config-store.d.ts.map +0 -1
  501. package/dist/stores/context-editor-store.d.ts.map +0 -1
  502. package/dist/stores/coordinator-monitor-store.d.ts.map +0 -1
  503. package/dist/stores/cron-store.d.ts.map +0 -1
  504. package/dist/stores/file-reference-store.d.ts.map +0 -1
  505. package/dist/stores/file-store.d.ts.map +0 -1
  506. package/dist/stores/fleet-store.d.ts.map +0 -1
  507. package/dist/stores/git-changes-store.d.ts.map +0 -1
  508. package/dist/stores/git-info-store.d.ts.map +0 -1
  509. package/dist/stores/goal-assess-store.d.ts.map +0 -1
  510. package/dist/stores/goal-run-store.d.ts.map +0 -1
  511. package/dist/stores/goal-state-store.d.ts.map +0 -1
  512. package/dist/stores/goal-store.d.ts.map +0 -1
  513. package/dist/stores/history-store.d.ts.map +0 -1
  514. package/dist/stores/index.d.ts.map +0 -1
  515. package/dist/stores/kanban-store.d.ts.map +0 -1
  516. package/dist/stores/local-prefs.d.ts.map +0 -1
  517. package/dist/stores/mailbox-store.d.ts.map +0 -1
  518. package/dist/stores/memory-injector-store.d.ts.map +0 -1
  519. package/dist/stores/memory-lifecycle-store.d.ts.map +0 -1
  520. package/dist/stores/monitor-store.d.ts.map +0 -1
  521. package/dist/stores/office-map-store.d.ts.map +0 -1
  522. package/dist/stores/provider-status-store.d.ts.map +0 -1
  523. package/dist/stores/sdd-board-store.d.ts.map +0 -1
  524. package/dist/stores/sdd-wizard-store.d.ts.map +0 -1
  525. package/dist/stores/session-store.d.ts.map +0 -1
  526. package/dist/stores/side-effect-store.d.ts.map +0 -1
  527. package/dist/stores/specs-store.d.ts.map +0 -1
  528. package/dist/stores/techstack-store.d.ts.map +0 -1
  529. package/dist/stores/types.d.ts.map +0 -1
  530. package/dist/stores/ui-store.d.ts.map +0 -1
  531. package/dist/stores/viz-store.d.ts.map +0 -1
  532. package/dist/stores/worktree-store.d.ts.map +0 -1
  533. package/dist/types/brain.d.ts.map +0 -1
  534. package/dist/types/chronicle.d.ts.map +0 -1
  535. package/dist/types/client-message.d.ts.map +0 -1
  536. package/dist/types/collab.d.ts.map +0 -1
  537. package/dist/types/connections.d.ts.map +0 -1
  538. package/dist/types/goal-kanban-worktree.d.ts.map +0 -1
  539. package/dist/types/protocol-core.d.ts.map +0 -1
  540. package/dist/types/runtime.d.ts.map +0 -1
  541. package/dist/types/sage.d.ts.map +0 -1
  542. package/dist/types/server-message.d.ts.map +0 -1
  543. package/dist/types/skills-design.d.ts.map +0 -1
  544. package/dist/types/system.d.ts.map +0 -1
  545. package/dist/types.d.ts.map +0 -1
  546. package/dist/types.js.map +0 -7
@@ -1,3 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{$t as t,Ai as n,Ci as r,Ct as i,Ii as a,Ir as o,It as s,Ki as c,Kn as l,Kr as u,Mi as d,Mt as f,Pn as p,Ri as m,Sa as h,Si as g,Ut as _,Vt as v,Wt as y,Xt as b,Yi as x,Zt as S,_i as C,an as w,at as T,br as E,bt as D,ci as ee,cn as O,di as te,en as k,et as A,ht as ne,ii as re,in as ie,ki as ae,kn as oe,ma as se,mn as ce,ni as le,nn as ue,pn as de,pr as fe,qn as pe,sa as me,wt as j,yn as he,zi as M,zn as ge,zt as N}from"./vendor-2VBBgNb5.js";import{n as P}from"./ui-store-CS-njcmT.js";import{t as _e}from"./ws-client-WVGn8ORh.js";import{t as F}from"./utils-CN2sfDVP.js";import{t as ve}from"./session-store-BsNYnfOc.js";import{M as ye,u as be,x as I}from"./stores-mpa0202y.js";import{n as xe,t as Se}from"./ModelPicker-CN-UD3lc.js";import{b as Ce,f as L,p as R}from"./index-BPfIz78e.js";import{n as we,t as z}from"./progress-ring-CFOvGxw7.js";var B=e(h(),1);function Te(e,t=!0){(0,B.useEffect)(()=>{let n=e.current;if(!n||!t)return;let r=e=>{if(!e.shiftKey||n.scrollWidth<=n.clientWidth+1)return;let t=Math.abs(e.deltaY)>Math.abs(e.deltaX)?e.deltaY:e.deltaX;t!==0&&(e.preventDefault(),n.scrollLeft+=t)},i=e=>{if(!e.ctrlKey&&!e.metaKey||n.scrollWidth<=n.clientWidth+1)return;let t=n.clientWidth*.8;e.key===`ArrowLeft`?(e.preventDefault(),n.scrollLeft-=t):e.key===`ArrowRight`&&(e.preventDefault(),n.scrollLeft+=t)};return n.addEventListener(`wheel`,r,{passive:!1}),n.addEventListener(`keydown`,i),()=>{n.removeEventListener(`wheel`,r),n.removeEventListener(`keydown`,i)}},[e,t])}var V=4320*60*1e3,Ee=new Set([`completed`,`archived`]);function De(e,t){let n=He(t.now);if(n===null)throw TypeError(`Kanban audit requires a valid current time`);let r=Re(t.liveAgentIdentities),i=Ne(e,t.defaultReviewStaleAfterMs??V),a=Me(e),o=[];for(let s of e.tasks)Ee.has(s.status)||(Oe(o,s,t.requireDueDate===!0),ke(o,s,n,r),Ae(o,s,n,i),a.length>1&&je(o,s,a));return o.sort(Ue),{issues:o,counts:{error:o.filter(e=>e.severity===`error`).length,warning:o.filter(e=>e.severity===`warning`).length},affectedTaskCount:new Set(o.map(e=>e.taskId)).size}}function Oe(e,t,n){U(t.description)||W(e,t,`missing-description`,`warning`,`Add a description`),Ie(t).length===0&&W(e,t,`missing-assignee`,`warning`,`Assign an owner`),n&&!U(t.dueDate)&&W(e,t,`missing-due-date`,`warning`,`Set a due date`),!Be(t.labels)&&!Be(t.tags)&&W(e,t,`missing-labels`,`warning`,`Add labels or tags`),!Be(t.childTaskIds)&&!Be(t.subtasks)&&W(e,t,`missing-subtasks`,`warning`,`Define subtasks`),Be(t.successCriteria)||W(e,t,`missing-success-criteria`,`warning`,`Add success criteria`)}function ke(e,t,n,r){let i=t.assignment;if(!(t.status===`in_progress`||i?.status===`running`))return;let a=Ie(t);if(!i||a.length===0||!U(i.leaseId)||!U(i.leaseExpiresAt)){W(e,t,`abandoned-running-task`,`error`,`Running without a complete assignment lease`);return}let o=He(i.leaseExpiresAt);if(o===null||o<=n){W(e,t,`stale-running-task`,`error`,`Assignment lease is expired`);return}a.some(e=>r.has(H(e)))||W(e,t,`abandoned-running-task`,`error`,`Assigned agent is not live`)}function Ae(e,t,n,r){if(t.status!==`review`)return;let i=Fe(t,`review`)??He(t.updatedAt);i===null||n-i<=r||W(e,t,`stale-review`,`warning`,`Waiting in review for ${Math.max(1,Math.floor((n-i)/(3600*1e3)))}h`)}function je(e,t,n){let r=Pe(t);if(r.length<2)return;let i=new Map(n.map((e,t)=>[H(e),t]));for(let n=1;n<r.length;n+=1){let a=r[n-1],o=r[n];if(!a||!o)continue;let s=i.get(H(a.state)),c=i.get(H(o.state));if(!(s===void 0||c===void 0||Math.abs(c-s)<=1)){W(e,t,`skipped-lifecycle-state`,`error`,`Lifecycle skipped ${a.state} → ${o.state}`);return}}}function Me(e){let t=[e.lifecycle,e.lifecyclePolicy,e.managedLifecycle];for(let e of t){let t=Le(e);if(t.length>1)return t;if(!e||typeof e!=`object`||Array.isArray(e))continue;let n=e;if(n.mode===`managed`&&n.columns){let e=[`backlog`,`todo`,`running`,`review`,`done`].map(e=>n.columns?.[e]).filter(e=>U(e));if(e.length===5)return e}for(let e of[n.states,n.statuses,n.order,n.managedStatuses]){let t=Le(e);if(t.length>1)return t}}return[]}function Ne(e,t){let n=[e,e.lifecycle,e.lifecyclePolicy,e.managedLifecycle];for(let e of n){if(!e||typeof e!=`object`||Array.isArray(e))continue;let t=e;if(Ve(t.staleReviewAfterMs))return t.staleReviewAfterMs;if(Ve(t.reviewStaleAfterMs))return t.reviewStaleAfterMs;if(Ve(t.reviewStaleHours))return t.reviewStaleHours*60*60*1e3}return t}function Pe(e){let t=e.lifecycle?.history??e.lifecycleHistory??e.statusHistory??e.history;if(!Array.isArray(t))return[];let n=[];for(let e of t){if(typeof e==`string`&&U(e)){n.push({state:e.trim(),at:null});continue}if(!e||typeof e!=`object`)continue;let t=e,r=ze(t.status,t.state,t.toStatus,t.to,t.columnId);r&&n.push({state:r,at:He(t.at??t.ts??t.timestamp??t.changedAt??t.createdAt)})}return n}function Fe(e,t){let n=null;for(let r of Pe(e))H(r.state)!==H(t)||r.at===null||(n=n===null?r.at:Math.max(n,r.at));return n}function Ie(e){let t=e.assignment;return[e.assignee,e.assignedAgent,t?.agentId,t?.subagentId,t?.name].filter(U)}function Le(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(U(n)){t.push(n.trim());continue}if(!n||typeof n!=`object`)continue;let e=n,r=ze(e.id,e.status,e.state,e.name);r&&t.push(r)}return t}function Re(e){let t=new Set;if(!e)return t;for(let n of e)U(n)&&t.add(H(n));return t}function H(e){return e.trim().toLocaleLowerCase()}function ze(...e){for(let t of e)if(U(t))return t.trim();return null}function U(e){return typeof e==`string`&&e.trim().length>0}function Be(e){return Array.isArray(e)&&e.length>0}function Ve(e){return typeof e==`number`&&Number.isFinite(e)&&e>0}function He(e){if(e instanceof Date){let t=e.getTime();return Number.isFinite(t)?t:null}if(typeof e==`number`)return Number.isFinite(e)?e:null;if(typeof e!=`string`||!e.trim())return null;let t=Date.parse(e);return Number.isFinite(t)?t:null}function W(e,t,n,r,i){e.push({id:`${t.id}:${n}`,taskId:t.id,taskTitle:t.title,code:n,severity:r,message:i})}function Ue(e,t){let n=We(e.severity)-We(t.severity);if(n!==0)return n;let r=e.taskTitle.localeCompare(t.taskTitle);return r===0?e.message.localeCompare(t.message):r}function We(e){return e===`error`?0:1}function Ge(e){let t=ye(e=>e.wsUrl),n=ye(e=>e.provider),r=ye(e=>e.model),[i,a]=(0,B.useState)([]),[o,s]=(0,B.useState)([]),[c,l]=(0,B.useState)({}),[u,d]=(0,B.useState)(``),[f,p]=(0,B.useState)(``);return(0,B.useEffect)(()=>{let e=_e(t).on(`kanban.meta`,e=>{let t=e.payload?.data;t&&(a(t.tools??[]),s(t.skills??[]),l(t.fallbackProfiles??{}),t.sessionProvider&&d(t.sessionProvider),t.sessionModel&&p(t.sessionModel))});return()=>e()},[t]),(0,B.useEffect)(()=>{e&&_e(t).send({type:`kanban.meta`})},[e,t]),{tools:i,skills:o,fallbackProfiles:c,sessionProvider:u||n,sessionModel:f||r}}var G=A();function K({options:e,selected:t,onChange:n,placeholder:r,emptyLabel:i}){let[a,o]=(0,B.useState)(!1),[s,c]=(0,B.useState)(``),l=(0,B.useRef)(null);(0,B.useEffect)(()=>{if(!a)return;let e=e=>{l.current&&!l.current.contains(e.target)&&o(!1)};return window.addEventListener(`mousedown`,e),()=>window.removeEventListener(`mousedown`,e)},[a]);let u=(0,B.useMemo)(()=>{let t=new Map(e.map(e=>[e.value,e.label]));return e=>t.get(e)??e},[e]),d=(0,B.useMemo)(()=>{let t=s.trim().toLowerCase();return(t?e.filter(e=>`${e.value} ${e.label} ${e.tag??``}`.toLowerCase().includes(t)):e).slice(0,80)},[e,s]),f=e=>{n(t.includes(e)?t.filter(t=>t!==e):[...t,e])};return(0,G.jsxs)(`div`,{ref:l,className:`relative`,children:[t.length>0&&(0,G.jsx)(`div`,{className:`mb-1 flex flex-wrap gap-1`,children:t.map(e=>(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded bg-muted px-1.5 py-0.5 text-[11px]`,children:[(0,G.jsx)(`span`,{className:`max-w-[150px] truncate`,children:u(e)}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>f(e),className:`text-muted-foreground hover:text-destructive`,"aria-label":`Remove ${u(e)}`,children:(0,G.jsx)(T,{size:11})})]},e))}),(0,G.jsxs)(`button`,{type:`button`,onClick:()=>o(e=>!e),className:`flex w-full items-center gap-1.5 rounded-md border border-border bg-muted px-2 py-1.5 text-left text-xs transition-colors hover:border-primary/45 hover:bg-muted/80`,children:[(0,G.jsx)(de,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-muted-foreground`,children:r??`Add…`}),(0,G.jsx)(m,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`})]}),a&&(0,G.jsxs)(`div`,{className:`absolute z-50 mt-1 max-h-72 w-full min-w-[240px] overflow-hidden rounded-md border border-border/80 bg-popover shadow-xl`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-border/70 bg-muted/20 px-2 py-1.5`,children:[(0,G.jsx)(`input`,{value:s,onChange:e=>c(e.target.value),placeholder:`Filter…`,className:`min-w-0 flex-1 bg-transparent text-xs outline-none placeholder:text-muted-foreground`}),s&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>c(``),className:`text-muted-foreground hover:text-foreground`,children:(0,G.jsx)(T,{className:`h-3 w-3`})})]}),(0,G.jsxs)(`div`,{className:`max-h-60 overflow-y-auto py-1`,children:[d.map(e=>{let n=t.includes(e.value);return(0,G.jsxs)(`button`,{type:`button`,onClick:()=>f(e.value),className:F(`flex w-full items-start gap-1.5 px-2 py-1.5 text-left text-xs transition-colors hover:bg-muted`,n?`bg-primary/8 text-primary`:`text-foreground`),children:[n?(0,G.jsx)(M,{className:`mt-0.5 h-3 w-3 shrink-0 text-primary`}):(0,G.jsx)(`span`,{className:`w-3 shrink-0`}),(0,G.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`span`,{className:`block truncate`,children:e.label}),e.description&&(0,G.jsx)(`span`,{className:`mt-0.5 block truncate text-[10px] text-muted-foreground`,children:e.description})]}),e.tag&&(0,G.jsx)(`span`,{className:`mt-0.5 shrink-0 font-mono text-[9px] text-muted-foreground`,children:e.tag})]},e.value)}),d.length===0&&(0,G.jsx)(`div`,{className:`px-2 py-3 text-center text-[11px] text-muted-foreground`,children:e.length===0?i??`Nothing available`:`No match`})]})]})]})}function Ke(e){let t=Math.max(0,Date.now()-Date.parse(e));return t<6e4?`just now`:t<36e5?`${Math.floor(t/6e4)}m ago`:`${Math.floor(t/36e5)}h ago`}function qe(e,t){if(!e)return null;let n=Date.parse(e),r=t?Date.parse(t):Date.now();if(!Number.isFinite(n)||!Number.isFinite(r))return null;let i=Math.max(0,Math.floor((r-n)/1e3));if(i<60)return`${i}s`;let a=Math.floor(i/60);if(a<60)return`${a}m`;let o=Math.floor(a/60);return o<24?`${o}h`:`${Math.floor(o/24)}d`}function Je({presence:e=[]}){return e.length===0?null:(0,G.jsxs)(`section`,{"aria-label":`Board presence`,className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-border bg-card/50 px-4 py-2`,children:[(0,G.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:`Live board users`}),e.map(e=>(0,G.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5 rounded-full border border-border bg-background px-2.5 py-1 text-xs shadow-sm`,title:`Session ${e.sessionId} · last seen ${e.lastSeenAt}`,children:[(0,G.jsx)(`span`,{role:`img`,"aria-label":e.active?`active`:`inactive`,className:F(`h-2 w-2 shrink-0 rounded-full`,e.active?`bg-success`:`bg-muted-foreground/50`)}),(0,G.jsx)(r,{size:13,"aria-hidden":`true`}),(0,G.jsx)(`span`,{className:`max-w-32 truncate font-medium`,children:e.agentName??e.agentId}),(0,G.jsx)(`span`,{className:`max-w-32 truncate text-muted-foreground`,children:e.sessionId}),(0,G.jsx)(C,{size:12,className:`text-muted-foreground`,"aria-hidden":`true`}),(0,G.jsx)(`time`,{dateTime:e.lastSeenAt,className:`tabular-nums text-muted-foreground`,children:Ke(e.lastSeenAt)})]},e.id))]})}function Ye({board:e,snapshot:t,sendKanban:n}){let[r,i]=(0,B.useState)(!1),[a,o]=(0,B.useState)(!0),[s,c]=(0,B.useState)(`deterministic`),[l,u]=(0,B.useState)(`session`),[d,f]=(0,B.useState)(``),[p,h]=(0,B.useState)(``),[g,v]=(0,B.useState)(``),[y,b]=(0,B.useState)([]),[x,S]=(0,B.useState)([]),[C,w]=(0,B.useState)(10),T=xe(r&&s===`agentic`),E=Ge(r&&s===`agentic`);(0,B.useEffect)(()=>{let t=e.supervisor;o(t?.enabled??!0),c(t?.mode??`deterministic`),u(t?.routing?.mode??`session`),f(t?.routing?.provider??``),h(t?.routing?.model??``),v(t?.routing?.fallbackProfile??``),b(t?.routing?.fallbackModels??[]),S(t?.skills??[]),w(Math.max(2,Math.round((t?.intervalMs??1e4)/1e3)))},[e.id,e.supervisor]);let D=()=>{let t={mode:l,...l===`fixed`&&d?{provider:d}:{},...l===`fixed`&&p?{model:p}:{},...l===`fallback_profile`&&g?{fallbackProfile:g}:{},...y.length?{fallbackModels:y}:{}};n(`kanban.update`,{boardId:e.id,supervisor:{enabled:a,mode:s,intervalMs:Math.max(2,C)*1e3,recoveryMode:`auto`,...s===`agentic`?{routing:t,skills:x}:{}}}),window.setTimeout(()=>n(`kanban.supervisor.audit`,{boardId:e.id}),150)},ee=a?t?.status??`starting`:`disabled`;return(0,G.jsxs)(`div`,{className:`shrink-0 border-b bg-background/80`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>i(e=>!e),className:`flex w-full items-center gap-2 px-4 py-1.5 text-left text-[11px] hover:bg-muted/40`,children:[(0,G.jsx)(_,{size:13,className:ee===`healthy`?`text-success`:`text-warning`}),(0,G.jsx)(`span`,{className:`font-semibold`,children:`Kanban Agent`}),(0,G.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 capitalize text-muted-foreground`,children:[s,` · `,ee]}),t?.summary&&(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-muted-foreground`,children:t.summary}),(0,G.jsx)(`span`,{className:`ml-auto text-muted-foreground`,children:t?.lastAuditAt?`checked ${qe(t.lastAuditAt)} ago`:`not checked`}),(0,G.jsx)(m,{size:13,className:F(`transition-transform`,r&&`rotate-180`)})]}),r&&(0,G.jsxs)(`div`,{className:`grid gap-3 border-t p-3 text-xs lg:grid-cols-[220px_220px_1fr_auto]`,children:[(0,G.jsxs)(`label`,{className:`flex items-center gap-2 rounded-md border bg-card px-2 py-2`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:a,onChange:e=>o(e.target.checked)}),(0,G.jsx)(`span`,{children:`Watch this board`})]}),(0,G.jsx)(Xe,{label:`Supervisor engine`,value:s,options:[`deterministic`,`agentic`],onChange:e=>c(e)}),(0,G.jsxs)(`label`,{className:`block`,children:[(0,G.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:`Audit interval (seconds)`}),(0,G.jsx)(`input`,{type:`number`,min:2,value:C,onChange:e=>w(Number(e.target.value)||2),className:`h-8 w-full rounded-md border bg-background px-2 outline-none focus:border-primary`})]}),(0,G.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:D,className:`inline-flex h-8 items-center gap-1 rounded-md bg-primary px-3 text-primary-foreground`,children:[(0,G.jsx)(k,{size:13}),` Save`]}),(0,G.jsxs)(`button`,{type:`button`,onClick:()=>n(`kanban.supervisor.audit`,{boardId:e.id}),className:`inline-flex h-8 items-center gap-1 rounded-md border px-3 hover:bg-muted`,children:[(0,G.jsx)(se,{size:13}),` Audit now`]})]}),s===`deterministic`?(0,G.jsx)(`div`,{className:`lg:col-span-4 rounded-md border border-success/20 bg-success/5 px-3 py-2 text-muted-foreground`,children:`Deterministic mode uses no provider, model, token, or billing. It repairs assignment/status/column drift and recovers expired leases.`}):(0,G.jsxs)(`div`,{className:`grid gap-3 lg:col-span-4 lg:grid-cols-2`,children:[(0,G.jsx)(Xe,{label:`Kanban Agent model source`,value:l,options:[`session`,`fixed`,`fallback_profile`],onChange:e=>u(e)}),l===`fixed`&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:`Fixed provider / model`}),(0,G.jsx)(Se,{value:p||void 0,provider:d||void 0,candidates:T,placeholder:`Select exact provider / model…`,onPick:(e,t)=>{h(e),f(t)}})]}),l===`fallback_profile`&&(0,G.jsx)(Xe,{label:`Fallback profile (first model is primary)`,value:g,options:Object.keys(E.fallbackProfiles),placeholder:`Select configured profile…`,onChange:v}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:`Supervisor skills`}),(0,G.jsx)(K,{options:E.skills.map(e=>({value:e.name,label:e.name,description:e.description,tag:e.source})),selected:x,onChange:S,placeholder:`Force-load agentic skills…`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:`Extra fallback models`}),(0,G.jsx)(K,{options:T.map(e=>({value:`${e.provider}/${e.model}`,label:e.label,tag:e.provider})),selected:y,onChange:b,placeholder:`Optional ordered fallbacks…`})]})]})]})]})}function Xe({label:e,value:t,options:n,onChange:r,placeholder:i}){return(0,G.jsxs)(`label`,{className:`block`,children:[(0,G.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:e}),(0,G.jsxs)(`select`,{value:t,onChange:e=>r(e.target.value),className:`h-8 w-full rounded-md border bg-background px-2 text-xs outline-none focus:border-primary`,children:[i&&(0,G.jsx)(`option`,{value:``,children:i}),n.map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))]})]})}function Ze(e){let t=new Set;for(let n of e)n.status===`running`&&(t.add(n.id),t.add(n.name));return t}function Qe(e){let t=new Set;e.sessionId&&t.add(e.sessionId);for(let n of e.registrySessionIds)t.add(n);for(let n of e.agents)n.status===`running`&&n.sessionId&&t.add(n.sessionId);return[...t]}function $e(e,t){return e.presence?.some(e=>e.active)===!0||e.tags?.some(e=>e.startsWith(`session:`)&&t.includes(e.slice(8)))===!0}function et(e){return e?e.tasks.filter(e=>e.status===`in_progress`||e.assignment?.status===`running`||e.assignment?.status===`queued`).reduce((e,t)=>e+(t.costCeilingUsd??0),0):0}function tt(e){let t=e?.tags??[],n=t.includes(`sdd`)?`sdd`:t.includes(`goal`)?`goal`:null;if(!n)return null;let r=t.find(e=>e.startsWith(`run:`))?.slice(4);return{engine:n,...r?{runId:r}:{}}}function nt({boardTotal:e,activeBoardTotal:t,orphanedBoardTotal:n,activeBoardId:r,activeBoards:i,orphanedBoards:a,boardPage:o,boardPageSize:s,loading:c,newBoardTitle:l,onClose:u,onRefresh:d,onNewBoardTitleChange:f,onCreateBoard:p,onBoardSelect:m,onBoardPageChange:h}){return(0,G.jsxs)(`aside`,{className:`flex max-h-[45dvh] w-full shrink-0 flex-col border-b bg-card/40 md:max-h-none md:w-[280px] md:border-b-0 md:border-r`,children:[(0,G.jsxs)(`div`,{className:`flex h-12 items-center gap-2 border-b px-3`,children:[(0,G.jsx)(`button`,{type:`button`,title:`Back`,onClick:u,className:`flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,G.jsx)(me,{size:16})}),(0,G.jsx)(te,{size:17,className:`text-primary`}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`truncate text-sm font-semibold`,children:`Kanban`}),(0,G.jsxs)(`div`,{className:`truncate text-[11px] text-muted-foreground`,children:[e,` boards · `,t,` active · `,n,` orphaned`]})]}),(0,G.jsx)(`button`,{type:`button`,title:`Refresh`,onClick:d,className:`flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,G.jsx)(O,{size:15,className:c?`animate-spin`:void 0})})]}),(0,G.jsxs)(`div`,{className:`flex gap-1 border-b p-2`,children:[(0,G.jsx)(`input`,{value:l,onChange:e=>f(e.target.value),onKeyDown:e=>{e.key===`Enter`&&p()},placeholder:`New board`,className:`min-w-0 flex-1 rounded-md border bg-background px-2 py-1.5 text-sm outline-none focus:border-primary`}),(0,G.jsx)(`button`,{type:`button`,title:`Create board`,onClick:p,className:`flex h-8 w-8 items-center justify-center rounded-md bg-primary text-primary-foreground hover:bg-primary/90`,children:(0,G.jsx)(de,{size:16})})]}),(0,G.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-2`,children:[i.length>0&&(0,G.jsxs)(`div`,{className:`mb-1 px-2 py-1 text-[10px] font-semibold uppercase tracking-wider text-success`,children:[`Active session · `,t]}),i.map(e=>(0,G.jsx)(rt,{board:e,active:r===e.id,dotClassName:`bg-success`,onSelect:m},e.id)),a.length>0&&(0,G.jsxs)(`div`,{className:`mb-1 mt-2 px-2 py-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:[`No active session · `,n]}),a.map(e=>(0,G.jsx)(rt,{board:e,active:r===e.id,dotClassName:`bg-muted-foreground/45`,onSelect:m},e.id))]}),(0,G.jsx)(L,{page:o,pageSize:s,totalItems:e,onPageChange:h,compact:!0,itemLabel:`boards`})]})}function rt({board:e,active:t,dotClassName:n,onSelect:r}){return(0,G.jsxs)(`button`,{type:`button`,onClick:()=>r(e.id),className:F(`mb-1 w-full rounded-md px-2 py-2 text-left transition-colors`,t?`bg-primary/10 text-foreground`:`text-muted-foreground hover:bg-muted hover:text-foreground`),children:[(0,G.jsx)(`div`,{className:`truncate text-sm font-medium`,children:e.title}),(0,G.jsxs)(`div`,{className:`mt-0.5 flex items-center justify-between text-[11px]`,children:[(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,G.jsx)(`span`,{className:F(`h-1.5 w-1.5 rounded-full`,n)}),e.taskCount,` tasks`]}),(0,G.jsxs)(`span`,{children:[e.completedTaskCount,` done`]})]})]})}var it={enabled:!1,enforcement:`confirm`,shellAccess:`confirm`,allow:[]};function at({title:e,value:t,inherited:n,onSave:r}){let[i,a]=(0,B.useState)(t??it),[o,s]=(0,B.useState)(st(t?.allow??[])),[c,l]=(0,B.useState)(st(t?.deny??[])),[u,d]=(0,B.useState)(null);return(0,B.useEffect)(()=>{a(t??it),s(st(t?.allow??[])),l(st(t?.deny??[])),d(null)},[t]),(0,G.jsxs)(`details`,{className:`rounded-md border border-primary/25 bg-primary/5`,children:[(0,G.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-3 py-2 text-xs font-semibold`,children:[(0,G.jsx)(_,{size:14,className:`text-primary`}),(0,G.jsx)(`span`,{children:e}),(0,G.jsx)(`span`,{className:`ml-auto font-normal text-muted-foreground`,children:t?.enabled?`${t.enforcement} · ${t.allow.length} allow · shell ${t.shellAccess}`:n?.enabled?`inherits board boundary`:`unrestricted`})]}),(0,G.jsxs)(`div`,{className:`space-y-2 border-t p-3 text-xs`,children:[n?.enabled&&(0,G.jsx)(`div`,{className:`rounded border border-warning/25 bg-warning/10 px-2 py-1.5 text-muted-foreground`,children:`Board policy remains authoritative. This task policy can only narrow that scope.`}),(0,G.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:i.enabled,onChange:e=>a({...i,enabled:e.target.checked})}),`Enable this boundary layer`]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,G.jsxs)(`label`,{children:[(0,G.jsx)(`span`,{className:`mb-1 block text-[10px] font-medium uppercase text-muted-foreground`,children:`Outside scope`}),(0,G.jsxs)(`select`,{value:i.enforcement,onChange:e=>a({...i,enforcement:e.target.value}),className:`h-8 w-full rounded border bg-background px-2`,children:[(0,G.jsx)(`option`,{value:`confirm`,children:`Ask permission`}),(0,G.jsx)(`option`,{value:`block`,children:`Always block`})]})]}),(0,G.jsxs)(`label`,{children:[(0,G.jsx)(`span`,{className:`mb-1 block text-[10px] font-medium uppercase text-muted-foreground`,children:`Shell / opaque tools`}),(0,G.jsxs)(`select`,{value:i.shellAccess,onChange:e=>a({...i,shellAccess:e.target.value}),className:`h-8 w-full rounded border bg-background px-2`,children:[(0,G.jsx)(`option`,{value:`confirm`,children:`Ask permission`}),(0,G.jsx)(`option`,{value:`block`,children:`Always block`}),(0,G.jsx)(`option`,{value:`allow`,children:`Allow`})]})]})]}),(0,G.jsx)(ot,{label:`Allow selectors`,value:o,onChange:s}),(0,G.jsx)(ot,{label:`Deny selectors`,value:c,onChange:l}),(0,G.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:`One per line: kind:access:path — for example directory:read_write:packages/webui or file:read:README.md. Kinds: file, directory, package, glob. If an access type has no allow selector, it remains unrestricted except for deny rules. Shell “Allow” is opaque and can cross path selectors.`}),u&&(0,G.jsx)(`div`,{className:`text-destructive`,children:u}),(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>{try{let e=ct(o),t=ct(c);r({...i,allow:e,...t.length?{deny:t}:{}}),d(null)}catch(e){d(e instanceof Error?e.message:String(e))}},className:`inline-flex h-8 flex-1 items-center justify-center gap-2 rounded bg-primary text-primary-foreground`,children:[(0,G.jsx)(k,{size:13}),` Save boundary`]}),t&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>r(null),className:`h-8 rounded border px-3 text-muted-foreground hover:bg-muted`,children:`Remove layer`})]})]})]})}function ot({label:e,value:t,onChange:n}){return(0,G.jsxs)(`label`,{className:`block`,children:[(0,G.jsx)(`span`,{className:`mb-1 block text-[10px] font-medium uppercase text-muted-foreground`,children:e}),(0,G.jsx)(`textarea`,{rows:3,value:t,onChange:e=>n(e.target.value),className:`w-full resize-y rounded border bg-background px-2 py-1.5 font-mono text-[11px] outline-none focus:border-primary`})]})}function st(e){return e.map(e=>`${e.kind}:${e.access}:${e.path}`).join(`
2
- `)}function ct(e){let t=new Set([`file`,`directory`,`package`,`glob`]),n=new Set([`read`,`write`,`read_write`]);return e.split(/\r?\n/).map(e=>e.trim()).filter(Boolean).map((e,r)=>{let i=e.indexOf(`:`),a=e.indexOf(`:`,i+1);if(i<=0||a<=i+1||a===e.length-1)throw Error(`Boundary line ${r+1} must use kind:access:path.`);let o=e.slice(0,i),s=e.slice(i+1,a),c=e.slice(a+1).trim();if(!t.has(o))throw Error(`Boundary line ${r+1} has unknown kind.`);if(!n.has(s))throw Error(`Boundary line ${r+1} has unknown access.`);return{kind:o,access:s,path:c}})}function lt({audit:e,onSelectTask:t}){let[n,r]=(0,B.useState)(!0),i=(0,B.useId)();if((0,B.useEffect)(()=>{e.issues.length>0&&r(!0)},[e.issues.length]),e.issues.length===0)return null;let a=ut(e.issues);return(0,G.jsxs)(`section`,{"aria-labelledby":`${i}-title`,className:`shrink-0 border-b border-warning/25 bg-card/95 shadow-[inset_0_1px_0_hsl(var(--warning)/0.08)]`,children:[(0,G.jsxs)(`div`,{className:`flex min-h-10 flex-wrap items-center gap-2 px-3 py-2 sm:px-4`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,role:`status`,"aria-live":`polite`,children:[(0,G.jsx)(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-warning/25 bg-warning/10 text-warning`,children:(0,G.jsx)(s,{size:14,"aria-hidden":`true`})}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`h2`,{id:`${i}-title`,className:`text-xs font-semibold text-foreground`,children:[`Kanban Cleaner found `,e.issues.length,` `,e.issues.length===1?`issue`:`issues`]}),(0,G.jsxs)(`p`,{className:`truncate text-[10px] text-muted-foreground`,children:[e.affectedTaskCount,` `,e.affectedTaskCount===1?`card needs`:`cards need`,` attention`]})]})]}),e.counts.error>0&&(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-destructive/25 bg-destructive/10 px-2 py-0.5 text-[10px] font-medium text-destructive`,children:[(0,G.jsx)(d,{size:11,"aria-hidden":`true`}),` `,e.counts.error,` critical`]}),e.counts.warning>0&&(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-warning/25 bg-warning/10 px-2 py-0.5 text-[10px] font-medium text-warning`,children:[(0,G.jsx)(D,{size:11,"aria-hidden":`true`}),` `,e.counts.warning,` warning`]}),(0,G.jsx)(`button`,{type:`button`,"aria-expanded":n,"aria-controls":i,"aria-label":n?`Collapse Kanban Cleaner issues`:`Expand Kanban Cleaner issues`,onClick:()=>r(e=>!e),className:`flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,children:(0,G.jsx)(m,{size:14,"aria-hidden":`true`,className:F(`transition-transform`,n&&`rotate-180`)})})]}),n&&(0,G.jsx)(`ul`,{id:i,className:`grid max-h-36 gap-1 overflow-y-auto px-3 pb-2 sm:grid-cols-2 sm:px-4 xl:grid-cols-3`,children:a.map(({taskId:e,taskTitle:n,issues:r})=>(0,G.jsx)(`li`,{children:(0,G.jsxs)(`button`,{type:`button`,onClick:()=>t(e),"aria-label":`Open ${n}: ${r.map(e=>e.message).join(`, `)}`,className:`group flex w-full items-start gap-2 rounded-md border border-border/70 bg-background/70 px-2.5 py-2 text-left transition-colors hover:border-primary/40 hover:bg-primary/5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,children:[(0,G.jsx)(`span`,{className:F(`mt-1 h-1.5 w-1.5 shrink-0 rounded-full`,r.some(e=>e.severity===`error`)?`bg-destructive shadow-[0_0_8px_hsl(var(--destructive)/0.55)]`:`bg-warning shadow-[0_0_8px_hsl(var(--warning)/0.45)]`),"aria-hidden":`true`}),(0,G.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`span`,{className:`block truncate text-[11px] font-semibold text-foreground group-hover:text-primary`,children:n}),(0,G.jsx)(`span`,{className:`mt-0.5 block line-clamp-2 text-[10px] leading-4 text-muted-foreground`,children:r.map(e=>e.message).join(` · `)})]})]})},e))})]})}function ut(e){let t=new Map;for(let n of e){let e=t.get(n.taskId);e?e.issues.push(n):t.set(n.taskId,{taskId:n.taskId,taskTitle:n.taskTitle,issues:[n]})}return[...t.values()]}function dt({board:e,sendKanban:n,onSelectTask:r}){let[i,o]=(0,B.useState)(!1),s=e.tasks.filter(e=>e.decomposition?.status===`proposed`);return s.length?(0,G.jsxs)(`div`,{className:`shrink-0 border-b border-warning/30 bg-warning/5 px-4 py-2`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>o(e=>!e),className:`flex w-full items-center gap-2 text-left text-xs font-semibold text-warning`,children:[i?(0,G.jsx)(a,{size:13}):(0,G.jsx)(m,{size:13}),(0,G.jsx)(t,{size:13}),s.length,` decomposition proposal`,s.length>1?`s`:``,` awaiting approval`]}),!i&&(0,G.jsx)(`ul`,{className:`mt-1.5 space-y-1`,children:s.map(t=>(0,G.jsxs)(`li`,{className:`flex items-center gap-2 text-xs`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>r(t.id),className:`min-w-0 flex-1 truncate text-left hover:underline`,children:[t.title,(0,G.jsxs)(`span`,{className:`ml-1.5 text-muted-foreground`,children:[`→ `,t.decomposition?.proposedSubtasks.length??0,` subtasks`]})]}),(0,G.jsxs)(`button`,{type:`button`,onClick:()=>n(`kanban.decomposition.approve`,{boardId:e.id,taskId:t.id,proposalId:t.decomposition.id}),className:`inline-flex items-center gap-1 rounded-md bg-success/10 px-2 py-1 text-[11px] font-medium text-success hover:bg-success/20`,children:[(0,G.jsx)(M,{size:12}),` Approve`]}),(0,G.jsxs)(`button`,{type:`button`,onClick:()=>n(`kanban.decomposition.reject`,{boardId:e.id,taskId:t.id,proposalId:t.decomposition.id}),className:`inline-flex items-center gap-1 rounded-md bg-destructive/10 px-2 py-1 text-[11px] font-medium text-destructive hover:bg-destructive/20`,children:[(0,G.jsx)(T,{size:12}),` Reject`]})]},t.id))})]}):null}var ft=[`assessed`,`proposed`,`approval`,`applied`];function pt(e){let t=e.decomposition?.status;return t===`applied`?3:t===`approved`||t===`rejected`?2:t===`proposed`?1:e.atomicityAssessment?0:-1}function mt({board:e,task:n,sendKanban:r,onSelectTask:i}){let a=n.decomposition,o=pt(n),s=(0,B.useMemo)(()=>{if(!a)return null;let t=(a.appliedChildTaskIds??[]).map(t=>e.tasks.find(e=>e.id===t)).filter(e=>!!e);return{tasks:[{id:n.id,shortId:`parent`,title:n.title,displayStatus:a.status===`applied`?`completed`:`in_progress`,priority:n.priority,deps:[]},...a.proposedSubtasks.map((e,r)=>{let i=t[r];return{id:i?.id??`proposed-${r}`,shortId:`s${r}`,title:e.title,displayStatus:i?i.status===`completed`?`completed`:i.status===`failed`?`failed`:i.status===`in_progress`?`in_progress`:`pending`:a.status===`approved`?`queued`:`pending`,priority:n.priority,deps:(e.dependsOnIndex??[]).map(e=>`s${e}`)}})],columns:[{label:`Parent`,taskIds:[`parent`]},{label:a.status===`applied`?`Subtasks`:`Proposed subtasks`,taskIds:a.proposedSubtasks.map((e,t)=>`s${t}`)}],appliedChildren:t}},[e,a,n]);return!a&&!n.atomicityAssessment?null:(0,G.jsxs)(`div`,{className:`mt-4 rounded-md border p-3`,children:[(0,G.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-xs font-semibold uppercase text-muted-foreground`,children:[(0,G.jsx)(t,{size:13}),`Decomposition`]}),(0,G.jsxs)(`div`,{className:`mb-2 flex items-center gap-1 text-[11px]`,children:[ft.map((e,t)=>(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[t>0&&(0,G.jsx)(`span`,{className:`text-muted-foreground/50`,children:`→`}),(0,G.jsx)(`span`,{className:F(`rounded px-1.5 py-0.5`,a?.status===`rejected`&&t===2?`bg-destructive/10 text-destructive`:t<=o?`bg-primary/10 font-medium text-primary`:`bg-muted text-muted-foreground`),children:a?.status===`rejected`&&t===2?`rejected`:e})]},e)),n.atomicityAssessment&&(0,G.jsxs)(`span`,{className:`ml-auto text-muted-foreground`,children:[n.atomicityAssessment.verdict,` · score `,n.atomicityAssessment.score]})]}),!a&&n.atomicityAssessment?.verdict===`needs_decomposition`&&(0,G.jsxs)(`div`,{className:`rounded-md border border-warning/30 bg-warning/5 p-2 text-[11px] text-warning`,children:[`This task should be split before dispatch:`,(0,G.jsx)(`ul`,{className:`ml-4 mt-1 list-disc`,children:n.atomicityAssessment.criteria.filter(e=>e.score<1).map(e=>(0,G.jsx)(`li`,{children:e.reason},e.id))})]}),a&&s&&(0,G.jsxs)(G.Fragment,{children:[a.rationale&&(0,G.jsxs)(`div`,{className:`mb-2 text-[11px] text-muted-foreground`,children:[`“`,a.rationale,`”`]}),(0,G.jsx)(`div`,{className:`h-64 overflow-hidden rounded-md border`,children:(0,G.jsx)(we,{tasks:s.tasks,columns:s.columns,onTaskClick:t=>{e.tasks.some(e=>e.id===t)&&i(t)}})}),(0,G.jsx)(`ul`,{className:`mt-2 space-y-1 text-[11px]`,children:a.proposedSubtasks.map((e,t)=>(0,G.jsxs)(`li`,{className:`rounded bg-muted/40 px-2 py-1`,children:[(0,G.jsx)(`span`,{className:`font-medium`,children:e.title}),e.successCriteria?.length?(0,G.jsxs)(`span`,{className:`ml-1.5 text-muted-foreground`,children:[`✓ `,e.successCriteria.join(` · `)]}):null]},`${e.title}-${t}`))}),a.status===`proposed`&&(0,G.jsxs)(`div`,{className:`mt-2 flex gap-1.5`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>r(`kanban.decomposition.approve`,{boardId:e.id,taskId:n.id,proposalId:a.id}),className:`inline-flex items-center gap-1 rounded-md bg-success/10 px-2.5 py-1.5 text-xs font-medium text-success hover:bg-success/20`,children:[(0,G.jsx)(M,{size:13}),` Approve & split`]}),(0,G.jsxs)(`button`,{type:`button`,onClick:()=>r(`kanban.decomposition.reject`,{boardId:e.id,taskId:n.id,proposalId:a.id}),className:`inline-flex items-center gap-1 rounded-md bg-destructive/10 px-2.5 py-1.5 text-xs font-medium text-destructive hover:bg-destructive/20`,children:[(0,G.jsx)(T,{size:13}),` Reject`]})]}),a.status===`applied`&&s.appliedChildren.length>0&&(0,G.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:s.appliedChildren.map(e=>(0,G.jsxs)(`button`,{type:`button`,onClick:()=>i(e.id),className:`rounded-md border px-2 py-1 text-[11px] hover:bg-muted`,children:[e.title,(0,G.jsxs)(`span`,{className:`ml-1 text-muted-foreground`,children:[`[`,e.status,`]`]})]},e.id))}),a.status===`rejected`&&a.resolutionReason&&(0,G.jsxs)(`div`,{className:`mt-2 text-[11px] text-muted-foreground`,children:[`Rejected: `,a.resolutionReason]})]})]})}var ht=[`id`,`name`,`type`];function q(e){if(typeof e==`string`)return e.trim()||void 0;if(typeof e==`number`||typeof e==`boolean`)return String(e);if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e;for(let e of ht){let n=t[e];if(typeof n==`string`&&n.trim())return n.trim()}}function gt(e,t){return t?`running`:e.verificationReport?.verdict||`unverified`}var _t=new Set([`completed`,`review`,`failed`]);function vt(e){let t={totalTasks:e.tasks.length,gradedTasks:0,passed:0,failed:0,needsHuman:0,incomplete:0,unverified:0,failingChecks:[],missingEvidence:[],needsDecomposition:[],pendingProposals:[]};for(let n of e.tasks){if(n.status===`archived`)continue;let e=n.verificationReport;if(_t.has(n.status)&&(t.gradedTasks+=1,e?e.verdict===`passed`?t.passed+=1:e.verdict===`failed`?t.failed+=1:e.verdict===`needs_human`?t.needsHuman+=1:t.incomplete+=1:t.unverified+=1),e)for(let r of e.checks)(r.status===`failed`||r.status===`error`)&&t.failingChecks.push({task:n,check:r}),(r.type===`agent`||r.type===`council`)&&r.status===`passed`&&!r.backingRefs?.length&&t.missingEvidence.push({task:n,check:r});!n.childTaskIds?.length&&n.atomicityAssessment?.verdict===`needs_decomposition`&&n.status!==`completed`&&t.needsDecomposition.push(n),n.decomposition?.status===`proposed`&&t.pendingProposals.push(n)}return t}function yt(e){let t=new Map(e.tasks.map(e=>[e.id,e])),n=new Set,r=(e,i)=>{n.add(e.id);let a=e.childTaskIds??[],o=[];for(let e of a){let a=t.get(e);!a||n.has(a.id)||o.push(r(a,i+1))}return{task:e,children:o,depth:i}},i=[];for(let a of e.tasks)a.parentTaskId&&t.get(a.parentTaskId)||n.has(a.id)||i.push(r(a,0));return i}function bt(e){let t=[],n=e=>{t.push(e);for(let t of e.children)n(t)};for(let t of e)n(t);return t}function xt(e,t){return e?.columns.find(e=>e.id===t)?.title??t}function St({label:e,value:t}){return(0,G.jsxs)(`div`,{className:`rounded-md border bg-background px-2 py-1.5`,children:[(0,G.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground`,children:e}),(0,G.jsx)(`div`,{className:`mt-0.5 truncate text-xs font-medium`,children:t})]})}function J({label:e,value:t,onChange:n}){return(0,G.jsxs)(`label`,{className:`block`,children:[(0,G.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:e}),(0,G.jsx)(`input`,{value:t,onChange:e=>n(e.target.value),className:`h-8 w-full rounded-md border bg-background px-2 text-sm outline-none focus:border-primary`})]})}function Ct({label:e,value:t,options:n,placeholder:r,onChange:i}){return(0,G.jsxs)(`label`,{className:`block`,children:[(0,G.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:e}),(0,G.jsxs)(`select`,{value:t,onChange:e=>i(e.target.value),className:`h-8 w-full rounded-md border bg-background px-2 text-sm outline-none focus:border-primary`,children:[r&&(0,G.jsx)(`option`,{value:``,children:r}),n.map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))]})]})}function wt(e){let t=`rounded px-1.5 py-0.5`;return e===`critical`?`${t} bg-destructive/10 text-destructive`:e===`high`?`${t} bg-warning/10 text-warning`:e===`low`?`${t} bg-muted text-muted-foreground`:`${t} bg-info/10 text-info`}function Tt(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function Et(e){return e===`completed`||e===`failed`||e===`cancelled`}function Dt(e,t){return t?Math.round(e/t*100):0}function Ot(e,t,n,r=new Date){let i=[],a=n.filter(e=>e.taskId===t.id),o=a.filter(e=>e.type!==`task.created`),s=o.filter(e=>e.type!==`task.assignment.heartbeat`&&e.type!==`task.assignment.snapshot`),c=s.filter(e=>!!e.note?.trim()),l=t.assignment,u=r.getTime(),d=100,f=(e,t=0)=>{i.some(t=>t.id===e.id)||(i.push(e),d=Math.max(0,d-t))};t.dueDate&&![`completed`,`archived`].includes(t.status)&&Date.parse(t.dueDate)<u&&f({id:`overdue`,severity:`critical`,category:`operational`,title:`Task is overdue`,detail:`Due date ${t.dueDate} has passed while status is ${t.status}.`,remediation:`Re-plan the due date or record the blocker and owner response.`});let p=(t.dependsOn??[]).filter(t=>!e.tasks.some(e=>e.id===t));p.length&&f({id:`missing-dependency`,severity:`critical`,category:`operational`,title:`Dependency references are broken`,detail:`${p.length} dependency task${p.length===1?``:`s`} cannot be found.`,remediation:`Repair or remove the missing dependency IDs before dispatch.`});let m=(t.dependsOn??[]).filter(t=>{let n=e.tasks.find(e=>e.id===t);return n&&![`completed`,`archived`].includes(n.status)});m.length&&f({id:`unresolved-dependency`,severity:`warning`,category:`operational`,title:`Dependencies are unresolved`,detail:`${m.length} dependency task${m.length===1?``:`s`} still block execution.`,remediation:`Complete dependencies or explicitly waive them with a decision event.`}),(l?.status===`failed`||l?.error)&&f({id:`assignment-failed`,severity:`critical`,category:`operational`,title:`Latest agent run failed`,detail:l.error??l.lastFailureKind??`Assignment status is failed.`,remediation:`Review the failed attempt evidence, adjust routing, then retry or block the task.`}),l?.status===`failed`&&l.maxAttempts!==void 0&&(l.attempt??0)>=l.maxAttempts&&f({id:`retry-exhausted`,severity:`critical`,category:`operational`,title:`Retry budget is exhausted`,detail:`${l.attempt??0}/${l.maxAttempts} attempts have been consumed.`,remediation:`Escalate for a new route or explicitly increase the attempt budget.`}),l&&[`queued`,`running`].includes(l.status)&&l.leaseExpiresAt&&Date.parse(l.leaseExpiresAt)<=u&&f({id:`lease-expired`,severity:`critical`,category:`operational`,title:`Assignment lease has expired`,detail:`Lease expired at ${l.leaseExpiresAt} while run status is ${l.status}.`,remediation:`Recover, release, or retry the stale assignment.`}),l?.status===`running`&&l.heartbeatAt&&u-Date.parse(l.heartbeatAt)>5*6e4&&f({id:`heartbeat-stale`,severity:`warning`,category:`operational`,title:`Agent heartbeat is stale`,detail:`No heartbeat has been recorded since ${l.heartbeatAt}.`,remediation:`Inspect the subagent/run and recover the assignment if it is no longer alive.`}),t.status===`in_progress`&&!l&&f({id:`unowned-in-progress`,severity:`warning`,category:`operational`,title:`In-progress task has no assignment`,detail:`The task claims active work but has no inspectable agent assignment.`,remediation:`Assign an agent or return the task to ready/blocked.`});let h=(t.successCriteria??[]).filter(e=>e.status===`failed`),g=(t.successCriteria??[]).filter(e=>e.status===`pending`);h.length&&f({id:`failed-checks`,severity:t.status===`completed`?`critical`:`warning`,category:`operational`,title:`Acceptance checks failed`,detail:`${h.length} completion check${h.length===1?``:`s`} failed.`,remediation:`Resolve or explicitly waive failed acceptance evidence.`}),t.status===`completed`&&g.length&&f({id:`completed-with-pending-checks`,severity:`critical`,category:`operational`,title:`Completed task still has pending checks`,detail:`${g.length} acceptance check${g.length===1?``:`s`} remain pending.`,remediation:`Move the task back to review or complete the missing checks.`}),a.length?a.some(e=>e.type===`task.created`)||f({id:`missing-creation-event`,severity:`warning`,category:`audit`,title:`Creation provenance is missing`,detail:`The loaded event range does not contain task.created.`,remediation:`Load deeper history or record the legacy origin explicitly.`},10):f({id:`no-durable-events`,severity:`critical`,category:`audit`,title:`No durable activity events loaded`,detail:`Current state cannot be traced to an append-only task event.`,remediation:`Refresh activity; migrate legacy state or record an observation event.`},25);let _=Dt(o.filter(e=>!!e.actor).length,o.length),v=Dt(o.filter(e=>!!e.sessionId).length,o.length),y=Dt(c.length,s.length);o.length&&_<100&&f({id:`actor-coverage`,severity:`warning`,category:`audit`,title:`Some mutations have no actor`,detail:`Actor coverage is ${_}%.`,remediation:`Ensure every route/tool mutation supplies agent or operator identity.`},10),o.length&&v<100&&f({id:`session-coverage`,severity:`warning`,category:`audit`,title:`Some mutations have no session`,detail:`Session coverage is ${v}%.`,remediation:`Propagate session identity into all task event contexts.`},10),s.length&&y<50&&f({id:`reason-coverage`,severity:`info`,category:`audit`,title:`Decision rationale is sparse`,detail:`Only ${y}% of mutations include a reason or outcome.`,remediation:`Use the change-reason and decision/outcome fields for meaningful mutations.`},10);let b={...Tt([...a].sort((e,t)=>t.ts.localeCompare(e.ts)).find(e=>e.type===`task.assigned`||e.type.startsWith(`task.assignment.`))?.after),...l??{}},x=!!(b.provider||b.model||b.modelRouting);l&&!x&&f({id:`missing-route`,severity:`warning`,category:`audit`,title:`Execution route is not inspectable`,detail:`Assignment has no routing mode, provider, or model.`,remediation:`Reassign with explicit session/fixed/fallback routing metadata.`},10);let S=!!(l?.lastResult||l?.error||a.some(e=>Et(String(Tt(e.after).status??``))&&!!e.note?.trim()));return Et(l?.status)&&!S&&f({id:`missing-terminal-evidence`,severity:`critical`,category:`audit`,title:`Terminal run has no result or error evidence`,detail:`Assignment ended as ${l?.status} without an inspectable output.`,remediation:`Record the final result/error and supporting evidence.`},15),i.sort((e,t)=>{let n={critical:0,warning:1,info:2};return n[e.severity]-n[t.severity]}),{score:d,findings:i,critical:i.filter(e=>e.severity===`critical`).length,warnings:i.filter(e=>e.severity===`warning`).length,coverage:{durableEvents:a.length,actorPercent:_,sessionPercent:v,reasonPercent:y,hasExecutionRoute:x,hasTerminalEvidence:S}}}function kt(e){return e===`critical`?`border-destructive/30 bg-destructive/5 text-destructive`:e===`warning`?`border-warning/30 bg-warning/5 text-warning`:`border-info/30 bg-info/5 text-info`}function At({board:e,task:t,events:r}){let i=Ot(e,t,r),a=R(i.findings,8,t.id);return(0,G.jsxs)(`details`,{open:!0,className:`mt-3 rounded-md border border-border/70 bg-muted/10`,children:[(0,G.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-3 py-2.5 [&::-webkit-details-marker]:hidden`,children:[(0,G.jsx)(y,{className:`size-4 text-primary`}),(0,G.jsx)(`span`,{className:`text-xs font-semibold`,children:`Risk & audit quality`}),(0,G.jsxs)(`span`,{className:`rounded px-1.5 py-0.5 text-[9px] ${i.score>=90?`bg-success/10 text-success`:i.score>=70?`bg-warning/10 text-warning`:`bg-destructive/10 text-destructive`}`,children:[`audit `,i.score,`/100`]}),i.critical>0&&(0,G.jsxs)(`span`,{className:`rounded bg-destructive/10 px-1.5 py-0.5 text-[9px] text-destructive`,children:[i.critical,` critical`]}),(0,G.jsx)(m,{className:`ml-auto size-3.5 text-muted-foreground`})]}),(0,G.jsxs)(`div`,{className:`space-y-2 border-t border-border/60 p-2.5`,children:[(0,G.jsx)(`div`,{className:`grid grid-cols-3 gap-1 text-center sm:grid-cols-6`,children:[[`Events`,i.coverage.durableEvents],[`Actor`,`${i.coverage.actorPercent}%`],[`Session`,`${i.coverage.sessionPercent}%`],[`Reasons`,`${i.coverage.reasonPercent}%`],[`Route`,i.coverage.hasExecutionRoute?`yes`:`no`],[`Outcome`,i.coverage.hasTerminalEvidence?`yes`:`no`]].map(([e,t])=>(0,G.jsxs)(`div`,{className:`rounded border bg-background/70 px-1 py-1.5`,children:[(0,G.jsx)(`div`,{className:`text-[11px] font-semibold`,children:t}),(0,G.jsx)(`div`,{className:`text-[8px] uppercase text-muted-foreground`,children:e})]},String(e)))}),i.findings.length===0?(0,G.jsxs)(`div`,{className:`flex items-center gap-2 rounded border border-success/30 bg-success/5 px-2.5 py-2 text-[11px] text-success`,children:[(0,G.jsx)(n,{className:`size-4`}),` No deterministic task risks detected.`]}):(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[a.pageItems.map(e=>(0,G.jsxs)(`section`,{className:`rounded border px-2.5 py-2 ${kt(e.severity)}`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] font-semibold`,children:[e.category===`audit`?(0,G.jsx)(re,{className:`size-3.5`}):(0,G.jsx)(D,{className:`size-3.5`}),e.title,(0,G.jsxs)(`span`,{className:`ml-auto text-[8px] uppercase opacity-75`,children:[e.category,` · `,e.severity]})]}),(0,G.jsx)(`p`,{className:`mt-1 text-[10px] leading-4 opacity-90`,children:e.detail}),(0,G.jsxs)(`p`,{className:`mt-1 text-[9px] leading-4 opacity-75`,children:[(0,G.jsx)(`strong`,{children:`Next:`}),` `,e.remediation]})]},e.id)),(0,G.jsx)(L,{page:a.page,pageSize:a.pageSize,totalItems:a.totalItems,onPageChange:a.setPage,compact:!0,itemLabel:`risk findings`})]})]})]})}function jt(e,t,n){let r=t.assignment,i=Ot(e,t,[]).findings.filter(e=>e.category===`operational`),a=q(r?.provider),o=q(r?.model);return{owner:q(r?.name)??q(r?.agentId)??q(r?.role)??q(t.assignee)??q(t.assignedAgent)??`Unassigned`,route:a||o?`${a?`${a}/`:``}${o??`default`}`:r?.modelRouting===`session`?`session default`:`default route`,blockers:(t.dependsOn??[]).filter(t=>{let n=e.tasks.find(e=>e.id===t);return!n||![`completed`,`archived`].includes(n.status)}).length,attempts:r?.attempt?`${r.attempt}${r.maxAttempts?`/${r.maxAttempts}`:``}`:`0`,fallbackCount:+!!r?.fallbackProfile+(r?.fallbackModels?.length??0),activeUsers:(e.presence??[]).filter(e=>e.taskId===t.id&&e.active).length,failed:t.status===`failed`||r?.status===`failed`||!!r?.error,criticalRisks:i.filter(e=>e.severity===`critical`).length,warningRisks:i.filter(e=>e.severity===`warning`).length,verification:gt(t,n?.[`${e.id}:${t.id}`]),subtaskCounts:(()=>{let n=t.childTaskIds??[];if(!n.length)return null;let r=n.map(t=>e.tasks.find(e=>e.id===t)).filter(e=>!!e);return r.length?{done:r.filter(e=>[`completed`,`review`,`archived`].includes(e.status)).length,total:r.length}:null})(),atomicityVerdict:t.atomicityAssessment?.verdict??null,evidenceCount:t.verificationReport?.attachments.length??0,pendingDecomposition:t.decomposition?.status===`proposed`}}function Mt({board:e,column:t,selectedTaskId:n,dragTaskId:r,setDragTaskId:a,onSelectTask:o,onDeleteTask:s,onMoveTask:c}){let l=be(e=>e.verificationActivity),u=e.tasks.filter(e=>e.columnId===t.id).sort((e,t)=>e.order-t.order);return(0,G.jsxs)(`section`,{className:F(`flex h-full shrink-0 flex-col rounded-md border bg-muted/25 transition-[width] duration-200`,u.length===0?`w-[180px]`:`w-[310px]`),children:[(0,G.jsxs)(`div`,{className:`flex h-10 shrink-0 items-center gap-2 border-b px-3`,children:[(0,G.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-full`,style:{background:t.color??`hsl(var(--primary))`}}),(0,G.jsx)(`div`,{className:`min-w-0 flex-1 truncate text-sm font-semibold`,children:t.title}),(0,G.jsx)(`span`,{className:`rounded bg-background px-1.5 py-0.5 text-[11px] text-muted-foreground`,children:u.length})]}),(0,G.jsx)(`ul`,{className:`min-h-0 flex-1 space-y-2 overflow-y-auto p-2 [scrollbar-gutter:stable]`,onDragOver:e=>e.preventDefault(),onDrop:n=>{n.preventDefault(),e.lifecycle?.mode!==`managed`&&r&&c(r,t.id),a(null)},children:u.map(t=>{let r=jt(e,t,l);return(0,G.jsxs)(`li`,{draggable:e.lifecycle?.mode!==`managed`,onDragStart:()=>{e.lifecycle?.mode!==`managed`&&a(t.id)},onDragEnd:()=>a(null),className:F(`relative rounded-md border bg-background p-3 shadow-sm transition-colors`,n===t.id?`border-primary`:`hover:border-primary/50`),children:[(0,G.jsx)(`button`,{type:`button`,"aria-label":`Select task: ${t.title}`,onClick:()=>o(t.id),className:`absolute inset-0 cursor-pointer rounded-md`}),(0,G.jsxs)(`div`,{className:`pointer-events-none relative flex items-start gap-2`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(t.atomic||r.atomicityVerdict)&&(0,G.jsx)(`span`,{className:F(`shrink-0 rounded px-1 py-0.5 text-[10px] font-medium`,r.atomicityVerdict===`needs_decomposition`?`bg-destructive/15 text-destructive`:r.atomicityVerdict===`composite`?`bg-info/15 text-info`:r.atomicityVerdict===`borderline`||t.atomic?`bg-warning/15 text-warning`:`bg-muted text-muted-foreground`),title:r.atomicityVerdict?`Atomicity: ${r.atomicityVerdict}`:`Atomic task (subtree verification required)`,children:t.atomic?`atomic`:r.atomicityVerdict===`needs_decomposition`?`split me`:r.atomicityVerdict}),(0,G.jsx)(`span`,{className:`line-clamp-2 text-sm font-medium leading-5`,children:t.title})]}),t.description&&(0,G.jsx)(`div`,{className:`mt-1 line-clamp-2 text-xs leading-4 text-muted-foreground`,children:t.description})]}),(0,G.jsx)(`button`,{type:`button`,title:`Delete task`,"aria-label":`Delete task: ${t.title}`,onClick:()=>s(t),className:`pointer-events-auto relative flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-destructive/10 hover:text-destructive`,children:(0,G.jsx)(i,{size:14})})]}),(0,G.jsxs)(`div`,{className:`pointer-events-none relative mt-2 flex flex-wrap items-center gap-1.5 text-[11px]`,children:[(0,G.jsx)(`span`,{className:wt(t.priority),children:t.priority}),(0,G.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-muted-foreground`,children:t.status}),r.owner!==`Unassigned`&&(0,G.jsx)(`span`,{className:`rounded bg-primary/10 px-1.5 py-0.5 text-primary`,children:r.owner}),t.assignment&&(0,G.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-muted-foreground`,children:r.route}),t.assignment?.attempt?(0,G.jsxs)(`span`,{className:`rounded bg-info/10 px-1.5 py-0.5 text-info`,children:[`attempt `,r.attempts]}):null,r.fallbackCount>0&&(0,G.jsxs)(`span`,{className:`rounded bg-info/10 px-1.5 py-0.5 text-info`,children:[r.fallbackCount,` fallback`]}),r.blockers>0?(0,G.jsxs)(`span`,{className:`rounded bg-warning/10 px-1.5 py-0.5 text-warning`,children:[r.blockers,` blocker`]}):null,r.activeUsers>0&&(0,G.jsxs)(`span`,{className:`rounded bg-success/10 px-1.5 py-0.5 text-success`,children:[r.activeUsers,` active`]}),r.failed&&(0,G.jsx)(`span`,{className:`rounded bg-destructive/10 px-1.5 py-0.5 text-destructive`,children:`run failed`}),r.criticalRisks>0&&(0,G.jsxs)(`span`,{className:`rounded bg-destructive/10 px-1.5 py-0.5 text-destructive`,children:[r.criticalRisks,` critical risk`]}),r.warningRisks>0&&(0,G.jsxs)(`span`,{className:`rounded bg-warning/10 px-1.5 py-0.5 text-warning`,children:[r.warningRisks,` warning`]}),t.chain&&(0,G.jsxs)(`span`,{className:`rounded bg-primary/10 px-1.5 py-0.5 text-primary`,children:[`chain `,t.chain.order+1]}),t.assignment?.skills?.length?(0,G.jsxs)(`span`,{className:`rounded bg-success/10 px-1.5 py-0.5 text-success`,children:[t.assignment.skills.length,` skills`]}):null,r.verification!==`unverified`&&(0,G.jsxs)(`span`,{className:F(`rounded px-1.5 py-0.5`,r.verification===`passed`?`bg-success/10 text-success`:r.verification===`failed`?`bg-destructive/10 text-destructive`:`bg-warning/10 text-warning`),children:[`✓ `,r.verification]}),r.subtaskCounts&&(0,G.jsxs)(`span`,{className:`rounded bg-info/10 px-1.5 py-0.5 text-info`,children:[r.subtaskCounts.done,`/`,r.subtaskCounts.total,` subtasks`]}),r.evidenceCount>0&&(0,G.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-muted-foreground`,children:[r.evidenceCount,` evidence`]}),r.pendingDecomposition&&(0,G.jsx)(`span`,{className:`rounded bg-warning/10 px-1.5 py-0.5 text-warning`,children:`split pending approval`})]})]},t.id)})})]})}function Nt({queueHealth:e,runningCostTotal:t}){return(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-4 border-b px-4 py-2 text-xs text-muted-foreground`,children:[(0,G.jsx)(`span`,{className:`font-medium text-foreground`,children:`Queue health`}),e.counts.ready>0&&(0,G.jsxs)(`span`,{title:`Claimable tasks`,className:`inline-flex items-center gap-1 text-success`,children:[e.counts.ready,` ready`]}),e.counts.running>0&&(0,G.jsxs)(`span`,{title:`Running assignments`,className:`inline-flex items-center gap-1 text-warning`,children:[e.counts.running,` running`]}),e.counts.review>0&&(0,G.jsxs)(`span`,{title:`In review`,className:`inline-flex items-center gap-1 text-primary`,children:[e.counts.review,` review`]}),e.counts.blocked>0&&(0,G.jsxs)(`span`,{title:`Manually blocked`,className:`inline-flex items-center gap-1 text-destructive`,children:[e.counts.blocked,` blocked`]}),e.counts.failed>0&&(0,G.jsxs)(`span`,{title:`Failed tasks`,className:`inline-flex items-center gap-1 text-destructive`,children:[e.counts.failed,` failed`]}),e.dependencyBlocked.count>0&&(0,G.jsxs)(`span`,{title:`Ready/pending tasks blocked by dependencies`,className:`inline-flex items-center gap-1 rounded bg-warning/10 px-1.5 py-0.5 text-warning`,children:[e.dependencyBlocked.count,` blocked by deps`]}),e.staleAssignments.count>0&&(0,G.jsxs)(`span`,{title:`Expired lease assignments`,className:`inline-flex items-center gap-1 rounded bg-destructive/10 px-1.5 py-0.5 text-destructive`,children:[e.staleAssignments.count,` stale`]}),e.heartbeatDue.count===0&&e.staleAssignments.count===0&&e.dependencyBlocked.count===0&&(0,G.jsx)(`span`,{className:`text-success`,children:`healthy`}),t>0&&(0,G.jsxs)(`span`,{title:`Sum of costCeilingUsd for running/queued tasks`,className:`inline-flex items-center gap-1 text-info`,children:[`~$`,t.toFixed(2),` running cost`]})]})}function Pt({runLink:e,sendRaw:t}){let n=e.engine===`sdd`,r=n?`sdd.board`:`goal`,i=P(e=>e.setCurrentView),a=`inline-flex items-center gap-1 rounded-md border px-2 py-1 text-[11px] font-medium hover:bg-muted`;return(0,G.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b bg-primary/5 px-4 py-1.5`,children:[(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded bg-primary/15 px-1.5 py-0.5 text-[10px] font-semibold uppercase text-primary`,children:[(0,G.jsx)(w,{size:11}),` `,e.engine]}),(0,G.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`Live run — steer it from here`}),n&&(0,G.jsxs)(`button`,{type:`button`,className:a,title:`Open the live run view (SDD Hub)`,onClick:()=>i(`sddhub`),children:[(0,G.jsx)(w,{size:12}),` Open live run`]}),(0,G.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[(0,G.jsxs)(`button`,{type:`button`,className:a,onClick:()=>t(`${r}.pause`),children:[(0,G.jsx)(he,{size:12}),` Pause`]}),(0,G.jsxs)(`button`,{type:`button`,className:a,onClick:()=>t(`${r}.resume`),children:[(0,G.jsx)(ce,{size:12}),` Resume`]}),n&&(0,G.jsxs)(`button`,{type:`button`,className:a,onClick:()=>t(`sdd.board.retry_all_failed`),children:[(0,G.jsx)(ie,{size:12}),` Retry failed`]}),(0,G.jsxs)(`button`,{type:`button`,className:F(a,`text-destructive hover:bg-destructive/10`),onClick:()=>t(`${r}.stop`),children:[(0,G.jsx)(f,{size:12}),` Stop`]})]})]})}function Ft({boardId:e,sendKanban:t}){let n=`inline-flex items-center gap-1 rounded-md border px-2 py-1 text-[11px] font-medium text-primary hover:bg-primary/10`;return(0,G.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b bg-muted/30 px-4 py-1.5`,children:[(0,G.jsx)(w,{size:13,className:`text-primary`}),(0,G.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`Run this board as a live agent job:`}),(0,G.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[(0,G.jsx)(`button`,{type:`button`,className:n,onClick:()=>t(`kanban.run.start`,{boardId:e,engine:`goal`}),children:`Start as Goal`}),(0,G.jsx)(`button`,{type:`button`,className:n,onClick:()=>t(`kanban.run.start`,{boardId:e,engine:`sdd`}),children:`Start as SDD`})]})]})}function It({runLink:e,runTaskId:t,modelCandidates:n,sendRaw:r}){let i=e.engine===`sdd`,[a,o]=(0,B.useState)(!1),[s,c]=(0,B.useState)(``),l=`inline-flex flex-1 items-center justify-center gap-1 rounded-md border py-1.5 text-xs font-medium hover:bg-muted`,u=()=>{let e=s.trim();e&&(r(i?`sdd.board.reassign`:`goal.assignTask`,{taskId:t,agentName:e}),o(!1),c(``))};return(0,G.jsxs)(`div`,{className:`mt-4 rounded-md border bg-primary/5 p-2.5`,children:[(0,G.jsx)(`div`,{className:`mb-2 text-[10px] font-semibold uppercase tracking-wide text-primary`,children:`Run controls`}),i&&(0,G.jsxs)(`div`,{className:`mb-2`,children:[(0,G.jsx)(`div`,{className:`mb-1 text-[10px] uppercase text-muted-foreground`,children:`Worker model`}),(0,G.jsx)(Se,{candidates:n,placeholder:`Set model for this task…`,onPick:(e,n)=>r(`sdd.board.set_task_model`,{taskId:t,model:e,provider:n})})]}),a?(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(`input`,{value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&u(),e.key===`Escape`&&o(!1)},placeholder:`New worker name`,className:`min-w-0 flex-1 rounded-md border bg-background px-2 py-1.5 text-xs outline-none focus:border-primary`}),(0,G.jsx)(`button`,{type:`button`,onClick:u,className:`rounded-md bg-primary/10 px-2 py-1.5 text-primary`,children:(0,G.jsx)(M,{size:14})}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>o(!1),className:`rounded-md bg-muted px-2 py-1.5`,children:(0,G.jsx)(T,{size:14})})]}):(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,G.jsxs)(`button`,{type:`button`,className:l,onClick:()=>r(i?`sdd.board.retry`:`goal.retryTask`,{taskId:t}),children:[(0,G.jsx)(ie,{size:13}),` Retry`]}),(0,G.jsxs)(`button`,{type:`button`,className:l,onClick:()=>o(!0),children:[(0,G.jsx)(ne,{size:13}),` Reassign`]}),i?(0,G.jsxs)(`button`,{type:`button`,className:F(l,`text-destructive hover:bg-destructive/10`),onClick:()=>r(`sdd.board.cancel_task`,{taskId:t}),children:[(0,G.jsx)(f,{size:13}),` Cancel`]}):(0,G.jsxs)(`button`,{type:`button`,className:l,onClick:()=>r(`goal.runTask`,{taskId:t}),children:[(0,G.jsx)(ce,{size:13}),` Run now`]})]})]})}var Lt={unverified:{label:`unverified`,className:`bg-muted text-muted-foreground`,icon:v},running:{label:`verifying…`,className:`bg-info/10 text-info`,icon:l},passed:{label:`verified`,className:`bg-success/10 text-success`,icon:_},failed:{label:`verification failed`,className:`bg-destructive/10 text-destructive`,icon:N},needs_human:{label:`needs review`,className:`bg-warning/10 text-warning`,icon:D},incomplete:{label:`incomplete`,className:`bg-warning/10 text-warning`,icon:D}};function Rt({task:e}){return e.status===`completed`?(0,G.jsx)(M,{size:13,className:`text-success`}):e.status===`failed`?(0,G.jsx)(T,{size:13,className:`text-destructive`}):e.status===`in_progress`?(0,G.jsx)(l,{size:13,className:`animate-spin text-info`}):(0,G.jsx)(ae,{size:13,className:`text-muted-foreground`})}function zt({board:e,selectedTaskId:t,onSelectTask:n}){let r=be(e=>e.verificationActivity),i=(0,B.useMemo)(()=>bt(yt(e)),[e]);return i.length?(0,G.jsx)(`div`,{className:`h-full overflow-y-auto p-4`,children:(0,G.jsx)(`ul`,{className:`space-y-0.5`,children:i.map(({task:i,depth:o,children:s})=>{let c=Lt[gt(i,r[`${e.id}:${i.id}`])],l=c.icon,u=i.atomicityAssessment?.verdict;return(0,G.jsx)(`li`,{children:(0,G.jsxs)(`button`,{type:`button`,onClick:()=>n(i.id),style:{paddingLeft:`${o*22+8}px`},className:F(`flex w-full items-center gap-2 rounded-md border py-1.5 pr-2 text-left text-xs transition-colors`,t===i.id?`border-primary bg-primary/5`:`border-transparent hover:border-primary/40 hover:bg-muted/40`),children:[s.length>0?(0,G.jsx)(a,{size:12,className:`shrink-0 text-muted-foreground`}):(0,G.jsx)(`span`,{className:`w-3 shrink-0`}),(0,G.jsx)(Rt,{task:i}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:i.title}),i.atomic&&(0,G.jsx)(`span`,{className:`shrink-0 rounded bg-warning/15 px-1 py-0.5 text-[10px] text-warning`,children:`atomic`}),u&&u!==`atomic`&&(0,G.jsx)(`span`,{className:F(`shrink-0 rounded px-1 py-0.5 text-[10px]`,u===`needs_decomposition`?`bg-destructive/15 text-destructive`:u===`composite`?`bg-info/15 text-info`:`bg-warning/15 text-warning`),children:u===`needs_decomposition`?`split me`:u}),i.decomposition?.status===`proposed`&&(0,G.jsx)(`span`,{className:`shrink-0 rounded bg-warning/10 px-1 py-0.5 text-[10px] text-warning`,children:`proposal pending`}),(0,G.jsxs)(`span`,{className:F(`inline-flex shrink-0 items-center gap-1 rounded px-1.5 py-0.5 text-[10px]`,c.className),children:[(0,G.jsx)(l,{size:11,className:c.label===`verifying…`?`animate-spin`:void 0}),c.label]})]})},i.id)})})}):(0,G.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`No tasks on this board yet.`})}function Bt({label:e,value:t,tone:n}){return(0,G.jsxs)(`div`,{className:`rounded-md border bg-background p-3`,children:[(0,G.jsx)(`div`,{className:F(`text-xl font-bold`,n===`success`&&`text-success`,n===`destructive`&&`text-destructive`,n===`warning`&&`text-warning`,n===`muted`&&`text-muted-foreground`),children:t}),(0,G.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:e})]})}function Vt({title:e,icon:t,tone:n,rows:r,onSelectTask:i}){return r.length?(0,G.jsxs)(`div`,{className:`rounded-md border bg-background`,children:[(0,G.jsxs)(`div`,{className:F(`flex items-center gap-2 border-b px-3 py-2 text-xs font-semibold`,n),children:[(0,G.jsx)(t,{size:14}),e,(0,G.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground`,children:r.length})]}),(0,G.jsx)(`ul`,{className:`divide-y`,children:r.map(e=>(0,G.jsx)(`li`,{children:(0,G.jsxs)(`button`,{type:`button`,onClick:()=>i(e.taskId),className:`flex w-full flex-col items-start gap-0.5 px-3 py-2 text-left text-xs hover:bg-muted/40`,children:[(0,G.jsx)(`span`,{className:`font-medium`,children:e.primary}),e.secondary&&(0,G.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:e.secondary})]})},e.id))})]}):null}function Ht({board:e,onSelectTask:n}){let r=(0,B.useMemo)(()=>vt(e),[e]);return(0,G.jsxs)(`div`,{className:`h-full space-y-4 overflow-y-auto p-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-4 rounded-md border bg-background p-4`,children:[(0,G.jsx)(z,{pct:r.gradedTasks?r.passed/r.gradedTasks*100:0}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-sm font-semibold`,children:`Definition of Done`}),(0,G.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[r.passed,` of `,r.gradedTasks,` graded tasks verified passed ·`,` `,r.totalTasks,` tasks total`]})]})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-5`,children:[(0,G.jsx)(Bt,{label:`verified`,value:r.passed,tone:`success`}),(0,G.jsx)(Bt,{label:`failed`,value:r.failed,tone:`destructive`}),(0,G.jsx)(Bt,{label:`needs human`,value:r.needsHuman,tone:`warning`}),(0,G.jsx)(Bt,{label:`incomplete`,value:r.incomplete,tone:`warning`}),(0,G.jsx)(Bt,{label:`unverified`,value:r.unverified,tone:`muted`})]}),(0,G.jsx)(Vt,{title:`Failing checks`,icon:N,tone:`text-destructive`,onSelectTask:n,rows:r.failingChecks.map(({task:e,check:t})=>({id:`${e.id}:${t.checkId}`,taskId:e.id,primary:e.title,secondary:`${t.description}${t.error?` — ${t.error}`:``}`}))}),(0,G.jsx)(Vt,{title:`Evidence missing (agent/council checks without backing refs)`,icon:D,tone:`text-warning`,onSelectTask:n,rows:r.missingEvidence.map(({task:e,check:t})=>({id:`${e.id}:${t.checkId}`,taskId:e.id,primary:e.title,secondary:t.description}))}),(0,G.jsx)(Vt,{title:`Needs decomposition`,icon:t,tone:`text-warning`,onSelectTask:n,rows:r.needsDecomposition.map(e=>({id:e.id,taskId:e.id,primary:e.title,secondary:`atomicity score ${e.atomicityAssessment?.score??`?`} — split before dispatch`}))}),(0,G.jsx)(Vt,{title:`Decomposition proposals awaiting approval`,icon:v,tone:`text-info`,onSelectTask:n,rows:r.pendingProposals.map(e=>({id:e.id,taskId:e.id,primary:e.title,secondary:`${e.decomposition?.proposedSubtasks.length??0} proposed subtasks`}))}),r.failingChecks.length===0&&r.missingEvidence.length===0&&r.needsDecomposition.length===0&&r.pendingProposals.length===0&&(0,G.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-success/30 bg-success/5 p-3 text-xs text-success`,children:[(0,G.jsx)(_,{size:14}),`No outstanding verification or decomposition issues on this board.`]})]})}var Ut={assigned:`bg-info/10 text-info`,queued:`bg-info/10 text-info`,running:`bg-warning/10 text-warning`,completed:`bg-success/10 text-success`,failed:`bg-destructive/10 text-destructive`,cancelled:`bg-muted text-muted-foreground`};function Wt(e,t){if(!e)return null;let n=Date.parse(e);if(Number.isNaN(n))return null;let r=t?Date.parse(t):Date.now();if(Number.isNaN(r))return null;let i=Math.max(0,Math.round((r-n)/1e3));if(i<60)return`${i}s`;let a=Math.floor(i/60);return a<60?`${a}m ${i%60}s`:`${Math.floor(a/60)}h ${a%60}m`}function Gt({assignment:e}){let t=e.status===`running`,n=Wt(e.dispatchedAt,e.completedAt),r=q(e.name)??q(e.agentId),i=q(e.role),a=q(e.provider),o=q(e.model),s=[];return r&&s.push({label:`Agent`,value:r}),i&&s.push({label:`Role`,value:i}),e.modelRouting&&s.push({label:`Model source`,value:e.modelRouting}),(a||o)&&s.push({label:`Model`,value:(0,G.jsxs)(`span`,{className:`font-mono text-[11px]`,children:[a?`${a}/`:``,o??`—`]})}),e.subagentId&&s.push({label:`Subagent`,value:(0,G.jsx)(`span`,{className:`font-mono text-[11px]`,children:e.subagentId})}),n&&s.push({label:e.completedAt?`Duration`:`Elapsed`,value:n}),typeof e.attempt==`number`&&s.push({label:`Attempt`,value:`${e.attempt}${e.maxAttempts?` / ${e.maxAttempts}`:``}`}),e.costCeilingUsd&&s.push({label:`Cost ceiling`,value:`$${e.costCeilingUsd.toFixed(2)}`}),e.fallbackProfile&&s.push({label:`Fallback profile`,value:e.fallbackProfile}),e.fallbackModels?.length&&s.push({label:`Fallbacks`,value:e.fallbackModels.join(` → `)}),e.skills?.length&&s.push({label:`Skills`,value:e.skills.join(`, `)}),e.tools?.length&&s.push({label:`Tools`,value:e.tools.join(`, `)}),e.leaseExpiresAt&&s.push({label:`Lease expires`,value:new Date(e.leaseExpiresAt).toLocaleString()}),(0,G.jsxs)(`div`,{className:`mt-4 rounded-md border bg-background p-2.5`,children:[(0,G.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:`Live run`}),(0,G.jsxs)(`span`,{className:F(`ml-auto inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium capitalize`,Ut[e.status]??`bg-muted text-muted-foreground`),children:[t&&(0,G.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse rounded-full bg-current`,"aria-hidden":!0}),e.status]})]}),s.length>0&&(0,G.jsx)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-xs`,children:s.map(e=>(0,G.jsxs)(`div`,{className:`contents`,children:[(0,G.jsx)(`dt`,{className:`text-muted-foreground`,children:e.label}),(0,G.jsx)(`dd`,{className:`min-w-0 truncate text-right text-foreground`,children:e.value})]},e.label))}),e.lastResult&&(0,G.jsxs)(`div`,{className:`mt-2`,children:[(0,G.jsx)(`div`,{className:`mb-1 text-[10px] uppercase text-muted-foreground`,children:`Last result`}),(0,G.jsx)(`div`,{className:`max-h-24 overflow-y-auto whitespace-pre-wrap rounded bg-muted px-2 py-1 text-[11px] leading-relaxed text-foreground`,children:e.lastResult})]}),e.error&&(0,G.jsx)(`div`,{className:`mt-2 rounded border border-destructive/30 bg-destructive/10 px-2 py-1 text-[11px] text-destructive`,children:e.error})]})}function Kt({activityKind:e,activityOutcome:t,note:n,details:r,onActivityKindChange:i,onActivityOutcomeChange:a,onNoteChange:o,onDetailsChange:s,onRecordActivity:c}){return(0,G.jsxs)(`div`,{className:`mt-4`,children:[(0,G.jsx)(`div`,{className:`mb-2 text-xs font-semibold uppercase text-muted-foreground`,children:`Record decision / outcome`}),(0,G.jsxs)(`div`,{className:`mb-1.5 grid grid-cols-2 gap-1.5`,children:[(0,G.jsx)(`select`,{value:e,onChange:e=>i(e.target.value),"aria-label":`Task activity kind`,className:`h-8 rounded-md border bg-background px-2 text-xs`,children:[`decision`,`attempt`,`result`,`blocker`,`observation`].map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))}),(0,G.jsx)(`select`,{value:t,onChange:e=>a(e.target.value),"aria-label":`Task activity outcome`,className:`h-8 rounded-md border bg-background px-2 text-xs`,children:[`unknown`,`succeeded`,`failed`,`partial`,`skipped`].map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))})]}),(0,G.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,G.jsx)(`input`,{value:n,onChange:e=>o(e.target.value),onKeyDown:e=>e.key===`Enter`&&c(),placeholder:`What was decided, attempted, or produced?`,className:`h-8 min-w-0 flex-1 rounded-md border bg-background px-2 text-xs outline-none focus:border-primary`}),(0,G.jsx)(`button`,{type:`button`,onClick:c,className:`h-8 rounded-md border px-2 hover:bg-muted`,"aria-label":`Record task decision or outcome`,children:(0,G.jsx)(de,{size:14})})]}),(0,G.jsx)(`input`,{value:r,onChange:e=>s(e.target.value),placeholder:`Optional evidence, rationale, command, link, or failure detail…`,"aria-label":`Task activity details`,className:`mt-1.5 h-8 w-full rounded-md border bg-background px-2 text-xs outline-none focus:border-primary`})]})}function qt({board:e,task:t,newCheck:n,onNewCheckChange:r,onAddCheck:i,sendKanban:a}){return(0,G.jsxs)(`div`,{className:`mt-5`,children:[(0,G.jsx)(`div`,{className:`mb-2 text-xs font-semibold uppercase text-muted-foreground`,children:`Completion checks`}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(t.successCriteria??[]).map(n=>(0,G.jsxs)(`div`,{className:`grid grid-cols-[auto_1fr_92px] items-center gap-2 rounded-md border bg-background px-2 py-1.5 text-xs`,children:[(0,G.jsx)(M,{size:13,className:n.status===`passed`?`text-success`:`text-muted-foreground`}),(0,G.jsx)(`span`,{className:`min-w-0 truncate`,children:n.description}),(0,G.jsx)(`select`,{value:n.status,onChange:r=>a(`kanban.task.check.update`,{boardId:e?.id,taskId:t.id,checkId:n.id,status:r.target.value}),className:`h-7 rounded border bg-background px-1 text-[11px]`,children:[`pending`,`passed`,`failed`,`skipped`].map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))})]},n.id)),(0,G.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,G.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),onKeyDown:e=>e.key===`Enter`&&i(),placeholder:`Add a verifiable completion check…`,className:`h-8 min-w-0 flex-1 rounded-md border bg-background px-2 text-xs outline-none focus:border-primary`}),(0,G.jsx)(`button`,{type:`button`,onClick:i,className:`h-8 rounded-md border px-2 hover:bg-muted`,children:(0,G.jsx)(de,{size:14})})]})]})]})}var Jt=[`architect`,`developer`,`reviewer`,`tester`,`verifier`,`security`,`documenter`,`external`,`leader`,`shadow`,`subagent`],Yt=[{value:`fs.read`,label:`Read files`,description:`fs.read`},{value:`fs.write`,label:`Write files (in project)`,description:`fs.write`},{value:`fs.write.outside-project`,label:`Write outside project`,description:`fs.write.outside-project`},{value:`net.outbound`,label:`Outbound network`,description:`net.outbound`},{value:`shell.exec`,label:`Run project commands`,description:`shell.exec`},{value:`shell.restricted`,label:`Restricted shell`,description:`shell.restricted`},{value:`shell.arbitrary`,label:`Arbitrary shell`,description:`shell.arbitrary`},{value:`session.todo`,label:`Session todos`,description:`session.todo`},{value:`tool.meta`,label:`Tool metadata`,description:`tool.meta`},{value:`tool.mutate.any`,label:`Invoke any tool`,description:`tool.mutate.any`},{value:`memory.read`,label:`Read memory`,description:`memory.read`},{value:`memory.write`,label:`Write memory`,description:`memory.write`},{value:`package.install`,label:`Install packages`,description:`package.install`},{value:`subagent.spawn`,label:`Spawn subagents`,description:`subagent.spawn`},{value:`config.mutate`,label:`Mutate config / trust`,description:`config.mutate`}];function Xt(e,t,n,r=new Date().toISOString()){return{format:`wrongstack-kanban-task-activity`,version:1,exportedAt:r,scope:n,task:e,events:t}}function Y(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function X(e){return typeof e==`string`&&e.trim()?e.trim():void 0}function Zt(e){return e.type.startsWith(`task.file.`)?e.type===`task.file.read`?`execution`:`changes`:e.type.startsWith(`task.activity.`)?X(Y(e.after).outcome)===`failed`?`failures`:e.type===`task.activity.attempt`?`execution`:`notes`:e.type.includes(`failed`)||e.type.includes(`cancelled`)?`failures`:e.type===`task.assigned`||e.type===`task.claimed`||e.type===`task.released`||e.type.startsWith(`task.assignment.`)||e.type===`task.stale_recovered`?`execution`:e.type.includes(`note`)||e.type.includes(`check`)||e.type.includes(`metric`)?`notes`:`changes`}function Qt(e){let t=Y(e.before),n=Y(e.after);return[...new Set([...Object.keys(t),...Object.keys(n)])].filter(e=>JSON.stringify(t[e])!==JSON.stringify(n[e])).map(e=>({field:e,before:t[e],after:n[e]}))}function $t(e){if(e.type.startsWith(`task.file.`))return`File ${e.type.slice(10)}`.replace(/\b\w/g,e=>e.toUpperCase());if(e.type.startsWith(`task.activity.`))return`Recorded ${e.type.slice(14)}`.replace(/\b\w/g,e=>e.toUpperCase());switch(e.type){case`task.created`:return`Task created`;case`task.copied`:return`Task copied`;case`task.updated`:return`Task contract updated`;case`task.moved`:return`Task moved`;case`task.assigned`:return`Agent assigned`;case`task.claimed`:return`Task claimed`;case`task.released`:return`Assignment released`;case`task.assignment.updated`:return`Assignment updated`;case`task.assignment.running`:return`Agent started work`;case`task.assignment.completed`:return`Agent completed work`;case`task.assignment.failed`:return`Agent run failed`;case`task.assignment.cancelled`:return`Agent run cancelled`;case`task.assignment.heartbeat`:return`Agent heartbeat`;case`task.note.added`:return`Operator note added`;case`task.check.added`:return`Acceptance check added`;case`task.check.updated`:return`Acceptance check updated`;case`task.metric.added`:return`Goal metric added`;case`task.metric.updated`:return`Goal metric updated`;case`task.lifecycle.transition`:return`Lifecycle advanced`;case`task.assignment.snapshot`:return`Current assignment observed`;case`task.stale_recovered`:return`Stale assignment recovered`;case`task.reconciled`:return`Task state reconciled`;default:return e.type.replace(/^task\./,``).replaceAll(`.`,` `).replace(/\b\w/g,e=>e.toUpperCase())}}function en(e){let t=Y(e.before),n=Y(e.after);if(e.type.startsWith(`task.file.`)){let e=X(n.filePath),t=X(n.toolName),r=typeof n.durationMs==`number`?n.durationMs:void 0,i=typeof n.lines==`number`?n.lines:void 0;return[e,t?`tool:${t}`:void 0,r===void 0?void 0:`${r}ms`,i===void 0?void 0:`${i} lines`].filter(Boolean).join(` · `)||void 0}if(e.type.startsWith(`task.activity.`))return[X(n.outcome),X(n.details)].filter(Boolean).join(` · `)||void 0;if(e.type===`task.moved`){let e=X(t.columnId),r=X(n.columnId);if(e||r)return`${e??`unknown`} → ${r??`unknown`}`}if(e.type===`task.updated`){let t=Qt(e);if(t.length)return`${t.length} field${t.length===1?``:`s`} changed: ${t.map(e=>e.field).join(`, `)}`}if(e.type===`task.lifecycle.transition`){let e=X(t.stage),r=X(n.stage);if(r)return e?`${e} → ${r}`:`Entered ${r}`}if(e.type===`task.assigned`||e.type===`task.assignment.snapshot`){let e=X(n.name)??X(n.agentId)??X(n.role),t=X(n.provider),r=X(n.model);return[e,t||r?`${t?`${t}/`:``}${r??`default`}`:void 0].filter(Boolean).join(` · `)||void 0}if(e.type.startsWith(`task.check.`))return[X(n.description),X(n.status)].filter(Boolean).join(` · `)||void 0;if(e.type.startsWith(`task.metric.`))return[X(n.name),X(n.status)].filter(Boolean).join(` · `)||void 0}function tn(e){let t=e.type;return X(Y(e.after).outcome)===`failed`||t.includes(`failed`)||t.includes(`cancelled`)?`bg-destructive ring-destructive/20`:t.includes(`completed`)||t.includes(`reconciled`)?`bg-success ring-success/20`:t.includes(`running`)||t.includes(`claimed`)||t.includes(`assigned`)?`bg-info ring-info/20`:t.includes(`note`)?`bg-warning ring-warning/20`:`bg-primary ring-primary/20`}function nn(e){let t=Date.parse(e);return Number.isFinite(t)?new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`}).format(t):e}function rn(e){if(e===void 0)return`unset`;if(e===null)return`none`;if(typeof e==`string`)return e||`empty`;if(typeof e==`number`||typeof e==`boolean`)return String(e);try{return JSON.stringify(e)}catch{return String(e)}}function an(e,t,n){let r=t.filter(t=>t.taskId===e.id).map(e=>({...e}));(e=>r.some(t=>t.type===e))(`task.created`)||r.push({id:`created:${e.id}`,boardId:``,taskId:e.id,type:`task.created`,ts:e.createdAt,...n?{sessionId:n}:{},after:{title:e.title,status:`created`,columnId:e.columnId}});for(let[t,i]of(e.lifecycle?.history??[]).entries())r.some(e=>e.type===`task.lifecycle.transition`&&e.ts===i.at&&e.actor===i.actor)||r.push({id:`lifecycle:${e.id}:${t}`,boardId:``,taskId:e.id,type:`task.lifecycle.transition`,ts:i.at,actor:i.actor,...n?{sessionId:n}:{},before:i.from?{stage:i.from}:void 0,after:{stage:i.to,action:i.action,attachment:i.attachment},note:i.comment});for(let t of e.notes??[])r.some(e=>e.type===`task.note.added`&&e.note===t.content&&Math.abs(Date.parse(e.ts)-Date.parse(t.createdAt))<2e3)||r.push({id:`note:${t.id}`,boardId:``,taskId:e.id,type:`task.note.added`,ts:t.createdAt,actor:t.author,...n?{sessionId:n}:{},note:t.content});let i=r.some(e=>e.type===`task.assigned`||e.type===`task.claimed`||e.type.startsWith(`task.assignment.`));return e.assignment&&!i&&r.push({id:`assignment:${e.id}`,boardId:``,taskId:e.id,type:`task.assignment.snapshot`,ts:e.assignment.completedAt??e.assignment.dispatchedAt??e.assignment.claimedAt??e.updatedAt,actor:e.assignment.agentId??e.assignment.name??e.assignment.role,...n?{sessionId:n}:{},subagentId:e.assignment.subagentId,runTaskId:e.assignment.runTaskId,after:{...e.assignment},note:e.assignment.error??e.assignment.lastResult}),r.sort((e,t)=>t.ts.localeCompare(e.ts))}function on({event:e}){let t=Y(e.after),n=X(t.provider),r=X(t.model),i=X(t.modelRouting),a=X(t.fallbackProfile),o=Array.isArray(t.fallbackModels)?t.fallbackModels.filter(e=>typeof e==`string`):[],s=typeof t.attempt==`number`?t.attempt:void 0,c=typeof t.maxAttempts==`number`?t.maxAttempts:void 0,l=X(t.status);return!n&&!r&&!i&&!a&&!o.length&&s===void 0&&!l?null:(0,G.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap gap-1 font-mono text-[9px] text-muted-foreground`,children:[l&&(0,G.jsxs)(`span`,{className:`rounded border border-border/60 px-1.5 py-0.5`,children:[`status:`,l]}),i&&(0,G.jsxs)(`span`,{className:`rounded border border-border/60 px-1.5 py-0.5`,children:[`route:`,i]}),(n||r)&&(0,G.jsxs)(`span`,{className:`rounded border border-border/60 px-1.5 py-0.5`,children:[`model:`,n?`${n}/`:``,r??`default`]}),a&&(0,G.jsxs)(`span`,{className:`rounded border border-border/60 px-1.5 py-0.5`,children:[`profile:`,a]}),o.map((e,t)=>(0,G.jsxs)(`span`,{className:`rounded border border-border/60 px-1.5 py-0.5`,children:[`fallback-`,t+1,`:`,e]},`${e}:${t}`)),s!==void 0&&(0,G.jsxs)(`span`,{className:`rounded border border-border/60 px-1.5 py-0.5`,children:[`attempt:`,s,c?`/${c}`:``]})]})}function sn({task:e,events:t,sessionId:n,loading:r=!1,error:i,onRefresh:a}){let[o,s]=(0,B.useState)(`all`),[c,l]=(0,B.useState)(``),[u,d]=(0,B.useState)(!1),f=(0,B.useMemo)(()=>an(e,t,n),[e,t,n]),p=(0,B.useMemo)(()=>({all:f.length,execution:f.filter(e=>Zt(e)===`execution`).length,changes:f.filter(e=>Zt(e)===`changes`).length,notes:f.filter(e=>Zt(e)===`notes`).length,failures:f.filter(e=>Zt(e)===`failures`).length}),[f]),m=(0,B.useMemo)(()=>{let e=c.trim().toLowerCase();return f.filter(t=>o!==`all`&&Zt(t)!==o?!1:!e||[$t(t),t.type,t.actor,t.sessionId,t.subagentId,t.runTaskId,t.note,JSON.stringify(t.before),JSON.stringify(t.after)].filter(Boolean).join(` `).toLowerCase().includes(e))},[f,o,c]),h=R(m,50,`${o}:${c}`),g=h.pageItems,_=[...new Set(f.map(e=>e.actor).filter(Boolean))].length,v=[...new Set(f.map(e=>e.sessionId??n).filter(Boolean))].length;return(0,G.jsxs)(`section`,{"aria-label":`Task activity`,className:`mt-5`,children:[(0,G.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,G.jsx)(se,{className:`size-3.5 text-primary`}),(0,G.jsx)(`h3`,{className:`text-xs font-semibold uppercase text-muted-foreground`,children:`Activity ledger`}),(0,G.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-[10px] tabular-nums text-muted-foreground`,children:[m.length,`/`,f.length]}),(0,G.jsxs)(`div`,{className:`ml-auto flex items-center gap-0.5`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:async()=>{try{await navigator.clipboard.writeText(JSON.stringify(Xt(e,m,`filtered`),null,2)),d(!0)}catch{d(!1)}},className:`flex size-7 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground`,"aria-label":`Copy visible task activity JSON`,title:`Copy filtered activity JSON`,children:u?(0,G.jsx)(M,{className:`size-3 text-success`}):(0,G.jsx)(ee,{className:`size-3`})}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>{let t=JSON.stringify(Xt(e,f,`full`),null,2),n=URL.createObjectURL(new Blob([t],{type:`application/json`})),r=document.createElement(`a`);r.href=n,r.download=`${e.title.replace(/[^a-z0-9]+/gi,`-`).replace(/^-|-$/g,``).toLowerCase()||e.id}-activity.json`,r.click(),URL.revokeObjectURL(n)},className:`flex size-7 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground`,"aria-label":`Download full task activity JSON`,title:`Download full activity JSON`,children:(0,G.jsx)(le,{className:`size-3`})}),a&&(0,G.jsx)(`button`,{type:`button`,onClick:a,className:`flex size-7 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground`,"aria-label":`Refresh task activity`,children:(0,G.jsx)(O,{className:F(`size-3`,r&&`animate-spin`)})})]})]}),(0,G.jsx)(`div`,{className:`mb-2 grid grid-cols-4 gap-px overflow-hidden rounded-md border border-border/60 bg-border/60 text-center`,children:[[`Events`,f.length],[`Actors`,_],[`Sessions`,v],[`Failures`,p.failures]].map(([e,t])=>(0,G.jsxs)(`div`,{className:`bg-background/90 px-1 py-1.5`,children:[(0,G.jsx)(`div`,{className:`text-xs font-semibold tabular-nums`,children:t}),(0,G.jsx)(`div`,{className:`text-[8px] uppercase text-muted-foreground`,children:e})]},String(e)))}),(0,G.jsx)(`div`,{className:`mb-2 flex flex-wrap gap-1`,children:[`all`,`execution`,`changes`,`notes`,`failures`].map(e=>(0,G.jsxs)(`button`,{type:`button`,onClick:()=>s(e),className:F(`rounded border px-1.5 py-1 text-[9px] capitalize`,o===e?`border-primary/50 bg-primary/10 text-primary`:`border-border text-muted-foreground hover:text-foreground`),children:[e,` `,p[e]]},e))}),(0,G.jsxs)(`div`,{className:`relative mb-3`,children:[(0,G.jsx)(S,{className:`pointer-events-none absolute left-2 top-1/2 size-3 -translate-y-1/2 text-muted-foreground`}),(0,G.jsx)(`input`,{value:c,onChange:e=>l(e.target.value),"aria-label":`Search task activity`,placeholder:`Search agent, session, model, result, field…`,className:`h-8 w-full rounded-md border bg-background pl-7 pr-7 text-[11px] outline-none focus:border-primary`}),c&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>l(``),"aria-label":`Clear task activity search`,className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,children:(0,G.jsx)(T,{className:`size-3`})})]}),i&&(0,G.jsx)(`div`,{className:`mb-2 rounded-md border border-destructive/30 bg-destructive/5 px-2.5 py-2 text-[11px] text-destructive`,children:i}),m.length===0?(0,G.jsx)(`div`,{className:`rounded-md border border-dashed px-3 py-6 text-center text-[11px] text-muted-foreground`,children:`No activity matches this filter.`}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`ol`,{className:`relative ml-1.5 space-y-0 border-l border-border/70`,children:g.map(e=>{let t=en(e),r=e.sessionId??n,i=Qt(e),a=Zt(e)===`failures`,o=e.type.includes(`completed`)||X(Y(e.after).outcome)===`succeeded`;return(0,G.jsxs)(`li`,{className:`relative pb-4 pl-4 last:pb-0`,children:[(0,G.jsx)(`span`,{className:F(`absolute -left-[5px] top-1.5 size-2 rounded-full ring-4`,tn(e))}),(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`p`,{className:`text-xs font-medium leading-5`,children:$t(e)}),(0,G.jsx)(`code`,{className:`block truncate text-[8px] text-muted-foreground/70`,title:e.type,children:e.type})]}),(0,G.jsx)(`time`,{dateTime:e.ts,title:new Date(e.ts).toLocaleString(),className:`shrink-0 text-[9px] text-muted-foreground`,children:nn(e.ts)})]}),t&&(0,G.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap text-[11px] leading-4 text-muted-foreground`,children:t}),e.note&&(0,G.jsxs)(`div`,{className:F(`mt-1.5 max-h-32 overflow-y-auto whitespace-pre-wrap rounded border px-2 py-1.5 text-[10px] leading-4`,a?`border-destructive/30 bg-destructive/5 text-destructive`:o?`border-success/30 bg-success/5 text-success`:`border-border/70 bg-muted/35 text-foreground`),children:[(0,G.jsxs)(`strong`,{children:[a?`Error`:o?`Result`:`Reason / result`,`:`]}),` `,e.note]}),i.length>0&&e.type!==`task.assigned`&&e.type!==`task.assignment.snapshot`&&!e.type.startsWith(`task.file.`)&&(0,G.jsx)(`div`,{className:`mt-1.5 space-y-1 rounded border border-border/60 bg-background/50 p-1.5`,children:i.map(e=>(0,G.jsxs)(`div`,{className:`grid grid-cols-[5rem_minmax(0,1fr)] gap-1.5 text-[9px] leading-4`,children:[(0,G.jsx)(`code`,{className:`truncate text-primary`,title:e.field,children:e.field}),(0,G.jsxs)(`span`,{className:`min-w-0 break-all text-muted-foreground`,children:[(0,G.jsx)(`span`,{className:`line-through opacity-70`,children:rn(e.before)}),` `,(0,G.jsx)(`span`,{"aria-hidden":!0,children:`→`}),` `,(0,G.jsx)(`span`,{className:`text-foreground`,children:rn(e.after)})]})]},e.field))}),(0,G.jsx)(on,{event:e}),(e.actor||r||e.subagentId||e.runTaskId||e.correlationId)&&(0,G.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap gap-1 font-mono text-[9px] text-muted-foreground`,children:[e.actor&&(0,G.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5`,children:[`agent:`,e.actor]}),r&&(0,G.jsxs)(`span`,{className:`max-w-52 truncate rounded bg-muted px-1.5 py-0.5`,title:r,children:[`session:`,r]}),e.subagentId&&(0,G.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5`,children:[`subagent:`,e.subagentId]}),e.runTaskId&&(0,G.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5`,children:[`run:`,e.runTaskId]}),e.correlationId&&(0,G.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5`,children:[`trace:`,e.correlationId]})]}),(0,G.jsxs)(`details`,{className:`mt-1.5 text-[9px] text-muted-foreground`,children:[(0,G.jsx)(`summary`,{className:`cursor-pointer hover:text-foreground`,children:`Full event payload`}),(0,G.jsx)(`pre`,{className:`mt-1 max-h-64 overflow-auto rounded border bg-muted/30 p-2 text-[9px] leading-4 text-foreground`,children:JSON.stringify(e,null,2)})]})]},e.id)})}),(0,G.jsx)(L,{page:h.page,pageSize:h.pageSize,totalItems:h.totalItems,onPageChange:h.setPage,className:`mt-3`,itemLabel:`activity events`})]})]})}function cn(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function Z(e){return typeof e==`string`&&e.trim()?e.trim():void 0}function ln(e){return e.type===`task.assigned`||e.type===`task.claimed`||e.type===`task.released`||e.type===`task.assignment.snapshot`||e.type===`task.stale_recovered`||e.type.startsWith(`task.assignment.`)}function un(e,t){return Z(t.status)||(e.type===`task.claimed`?`claimed`:e.type===`task.released`?`released`:e.type===`task.stale_recovered`?`recovered`:e.type.split(`.`).at(-1)??`unknown`)}function dn(e){return[`completed`,`failed`,`cancelled`,`released`,`recovered`].includes(e)}function fn(e,t){if(!t)return;let n=Date.parse(e),r=Date.parse(t);return Number.isFinite(n)&&Number.isFinite(r)?Math.max(0,r-n):void 0}function pn(e,t,n){let r=an(e,t,n).filter(ln).sort((e,t)=>e.ts.localeCompare(t.ts)),i=new Map,a=0,o=0,s=!1;for(let e of r){let t=cn(e.after),r=Number(t.attempt),c=e.type===`task.assigned`||e.type===`task.claimed`;Number.isFinite(r)&&r>0?a=Math.trunc(r):c&&(a===0||s)?a=o+1:a===0&&(a=1),o=Math.max(o,a);let l=un(e,t),u=i.get(a)??{attempt:a,status:l,startedAt:e.ts,fallbackModels:[],sessionIds:new Set,eventCount:0};u.status=l,u.eventCount+=1,(e.sessionId??n)&&u.sessionIds.add(e.sessionId??n),u.owner=Z(t.name)??Z(t.agentId)??Z(t.role)??e.actor??u.owner,u.provider=Z(t.provider)??u.provider,u.model=Z(t.model)??u.model,u.routingMode=Z(t.modelRouting)??u.routingMode,u.fallbackProfile=Z(t.fallbackProfile)??u.fallbackProfile,Array.isArray(t.fallbackModels)&&(u.fallbackModels=t.fallbackModels.filter(e=>typeof e==`string`)),u.subagentId=e.subagentId??Z(t.subagentId)??u.subagentId,u.runTaskId=e.runTaskId??Z(t.runTaskId)??u.runTaskId,l===`running`&&!u.runningAt&&(u.runningAt=e.ts),l===`completed`&&(u.result=Z(t.lastResult)??e.note??u.result),(l===`failed`||l===`cancelled`)&&(u.error=Z(t.error)??e.note??u.error),dn(l)&&(u.endedAt=e.ts),i.set(a,u),s=dn(l)}return[...i.values()].map(e=>({...e,sessionIds:[...e.sessionIds],durationMs:fn(e.startedAt,e.endedAt)})).sort((e,t)=>t.attempt-e.attempt)}function mn(e){if(e===void 0)return`running`;if(e<1e3)return`${e}ms`;let t=Math.round(e/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function hn(e){return e===`completed`?`bg-success/10 text-success`:e===`failed`||e===`cancelled`?`bg-destructive/10 text-destructive`:e===`running`?`bg-info/10 text-info`:`bg-muted text-muted-foreground`}function gn({task:e,events:t,sessionId:n}){let r=pn(e,t,n),i=R(r,8,e.id);return r.length?(0,G.jsxs)(`details`,{open:!0,className:`mt-3 rounded-md border border-border/70 bg-muted/15`,children:[(0,G.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-3 py-2.5 [&::-webkit-details-marker]:hidden`,children:[(0,G.jsx)(fe,{className:`size-4 text-primary`}),(0,G.jsx)(`span`,{className:`text-xs font-semibold`,children:`Execution attempts`}),(0,G.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-[9px] text-muted-foreground`,children:[r.length,` total`]}),(0,G.jsxs)(`span`,{className:`rounded px-1.5 py-0.5 text-[9px] ${hn(r[0].status)}`,children:[`latest:`,r[0].status]}),(0,G.jsx)(m,{className:`ml-auto size-3.5 text-muted-foreground`})]}),(0,G.jsxs)(`div`,{className:`space-y-2 border-t border-border/60 p-2.5`,children:[i.pageItems.map(e=>(0,G.jsxs)(`section`,{className:`rounded-md border bg-background/70 p-2.5`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 text-[10px]`,children:[(0,G.jsxs)(`strong`,{className:`text-xs`,children:[`Attempt #`,e.attempt]}),(0,G.jsx)(`span`,{className:`rounded px-1.5 py-0.5 ${hn(e.status)}`,children:e.status}),(0,G.jsxs)(`span`,{className:`ml-auto inline-flex items-center gap-1 text-muted-foreground`,children:[(0,G.jsx)(j,{className:`size-3`}),` `,mn(e.durationMs),` · `,e.eventCount,` `,`events`]})]}),(0,G.jsxs)(`div`,{className:`mt-2 grid gap-1 text-[10px] text-muted-foreground sm:grid-cols-2`,children:[(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,G.jsx)(x,{className:`size-3`}),` `,e.owner??`Unknown agent`]}),(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-mono`,children:[(0,G.jsx)(ue,{className:`size-3`}),e.provider||e.model?`${e.provider?`${e.provider}/`:``}${e.model??`default`}`:e.routingMode??`default route`]}),(0,G.jsxs)(`span`,{className:`font-mono`,children:[`session:`,e.sessionIds.join(`, `)||`unknown`]}),(0,G.jsxs)(`span`,{className:`font-mono`,children:[`subagent:`,e.subagentId??`—`,` · run:`,e.runTaskId??`—`]})]}),(e.fallbackProfile||e.fallbackModels.length>0)&&(0,G.jsxs)(`p`,{className:`mt-1.5 break-all font-mono text-[9px] text-muted-foreground`,children:[`fallback:`,[e.fallbackProfile?`profile:${e.fallbackProfile}`:``,...e.fallbackModels].filter(Boolean).join(` → `)]}),e.error&&(0,G.jsxs)(`p`,{className:`mt-2 whitespace-pre-wrap rounded border border-destructive/30 bg-destructive/5 px-2 py-1.5 text-[10px] text-destructive`,children:[(0,G.jsx)(`strong`,{children:`Error:`}),` `,e.error]}),e.result&&(0,G.jsxs)(`p`,{className:`mt-2 max-h-32 overflow-y-auto whitespace-pre-wrap rounded border border-success/30 bg-success/5 px-2 py-1.5 text-[10px] text-success`,children:[(0,G.jsx)(`strong`,{children:`Result:`}),` `,e.result]})]},e.attempt)),(0,G.jsx)(L,{page:i.page,pageSize:i.pageSize,totalItems:i.totalItems,onPageChange:i.setPage,compact:!0,itemLabel:`execution attempts`})]})]}):null}function _n(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function Q(e){return q(e)}function vn(e,t){return(t??[]).map(t=>{let n=e.tasks.find(e=>e.id===t);return{id:t,title:n?.title??t,status:n?.status??`missing`}})}function yn(e,t,n,r,i,a,o){let s=an(t,n,r),c=vn(e,t.dependsOn),l=c.filter(e=>![`completed`,`archived`].includes(e.status)),u=t.assignment,d=(o??e.presence??[]).filter(e=>e.taskId===t.id),f=_n(s.find(e=>e.type===`task.assigned`||e.type===`task.claimed`||e.type.startsWith(`task.assignment.`))?.after),p=Q(u?.modelRouting)??Q(f.modelRouting)??`session`,m=Q(u?.provider)??Q(f.provider)??(p===`session`?Q(i):void 0),h=Q(u?.model)??Q(f.model)??(p===`session`?Q(a):void 0),g=(Array.isArray(u?.fallbackModels)?u.fallbackModels:Array.isArray(f.fallbackModels)?f.fallbackModels:[]).map(Q).filter(e=>e!==void 0),_=Q(u?.fallbackProfile)??Q(f.fallbackProfile),v=Q(u?.name)??Q(u?.agentId)??Q(u?.role)??Q(t.assignee)??Q(t.assignedAgent)??`Unassigned`,y=t.lifecycle?.history.at(-1),b=s.find(e=>e.note&&e.type!==`task.note.added`)?.note,x=`Placed in ${e.columns.find(e=>e.id===t.columnId)?.title??t.columnId}.`;u?.error?x=`Agent run failed: ${u.error}`:l.length?x=`Blocked by ${l.map(e=>e.title).join(`, `)}.`:y?.comment?x=y.comment:b?x=b:t.status===`review`?x=`Implementation is waiting for review evidence or approval.`:t.status===`in_progress`?x=`${v} is currently working on this task.`:t.status===`completed`&&(x=`The task and its current assignment are complete.`);let S=s.map(e=>Number(_n(e.after).attempt)).filter(e=>Number.isFinite(e)),C=s.filter(e=>e.type===`task.claimed`||e.type===`task.assigned`).length,w=s.find(e=>Zt(e)===`failures`),T=s.find(e=>e.type.includes(`completed`));return{column:e.columns.find(e=>e.id===t.columnId)?.title??t.columnId,reason:x,owner:v,routingMode:p,provider:m,model:h,primaryModel:m||h?`${m?`${m}/`:``}${h??`default`}`:`Session default`,fallbackRoute:[_?`profile:${_}`:``,...g].filter(Boolean).join(` → `)||`None configured`,blockers:l,dependencies:c,actors:[...new Set([...s.map(e=>e.actor).filter(e=>!!e),...d.map(e=>e.agentId)])],sessions:[...new Set([...s.map(e=>e.sessionId??r),...d.map(e=>e.sessionId)].filter(e=>!!e))],presence:d.map(e=>`${e.agentName??e.agentId} · ${e.active?`active`:`last seen ${bn(e.lastSeenAt)}`}`),activePresence:d.filter(e=>e.active).length,attempts:Math.max(u?.attempt??0,...S,C),failures:s.filter(e=>e.type.includes(`failed`)).length,completions:s.filter(e=>e.type.includes(`completed`)).length,lastFailure:u?.lastFailureKind??u?.error??w?.note,lastResult:u?.lastResult??T?.note,eventCount:s.length,lastActivity:s[0]}}function bn(e){if(!e)return`—`;let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function xn(e,t){if(!e)return`—`;let n=Date.parse(e),r=t?Date.parse(t):Date.now();if(!Number.isFinite(n)||!Number.isFinite(r))return`—`;let i=Math.max(0,Math.round((r-n)/6e4));return i<1?`<1m`:i<60?`${i}m`:`${Math.floor(i/60)}h ${i%60}m`}function $({label:e,value:t,mono:n=!1}){return(0,G.jsxs)(`div`,{className:`grid grid-cols-[7rem_minmax(0,1fr)] gap-2 py-1 text-[11px]`,children:[(0,G.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,G.jsx)(`dd`,{className:n?`break-all font-mono text-[10px]`:`min-w-0 break-words`,children:t})]})}function Sn({icon:e,title:t,children:n}){return(0,G.jsxs)(`section`,{className:`rounded-md border border-border/70 bg-background/55 p-2.5`,children:[(0,G.jsxs)(`h4`,{className:`mb-1.5 flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[e,t]}),(0,G.jsx)(`dl`,{className:`divide-y divide-border/35`,children:n})]})}function Cn({items:e}){return e.length?(0,G.jsx)(`span`,{className:`space-y-1`,children:e.map(e=>(0,G.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsx)(`span`,{className:`truncate`,title:e.title,children:e.title}),(0,G.jsx)(`span`,{className:`shrink-0 rounded bg-muted px-1 py-0.5 text-[9px]`,children:e.status})]},e.id))}):(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`None`})}function wn({board:e,task:t,events:n,presence:r,sessionId:i,sessionProvider:a,sessionModel:o}){let s=yn(e,t,n,i,a,o,r),l=t.assignment,u=t.successCriteria?.length??0,d=t.successCriteria?.filter(e=>e.status===`passed`).length??0,f=[t.parentTaskId,...t.childTaskIds??[],t.chain?.previousTaskId,t.chain?.nextTaskId,t.mergedIntoTaskId,...t.mergedFromTaskIds??[]].filter(e=>!!e),p=vn(e,[...new Set(f)]);return(0,G.jsxs)(`details`,{open:!0,className:`mt-3 rounded-md border border-primary/25 bg-primary/[0.025]`,children:[(0,G.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-3 py-2.5 [&::-webkit-details-marker]:hidden`,children:[(0,G.jsx)(c,{className:`size-4 text-primary`}),(0,G.jsx)(`span`,{className:`text-xs font-semibold`,children:`Task intelligence`}),(0,G.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-[9px] uppercase text-muted-foreground`,children:t.status}),(0,G.jsxs)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,children:[s.eventCount,` events`]}),(0,G.jsx)(m,{className:`size-3.5 text-muted-foreground`})]}),(0,G.jsxs)(`div`,{className:`space-y-2.5 border-t border-border/60 p-2.5`,children:[(0,G.jsxs)(`section`,{className:`rounded-md border border-info/25 bg-info/5 p-2.5`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 text-[10px]`,children:[(0,G.jsx)(`span`,{className:`rounded bg-info/10 px-1.5 py-0.5 font-semibold text-info`,children:s.column}),(0,G.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5`,children:[`stage:`,t.lifecycle?.currentStage??`legacy`]}),(0,G.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5`,children:[`priority:`,t.priority]}),(0,G.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5`,children:[`type:`,t.type??`inferred`]})]}),(0,G.jsxs)(`p`,{className:`mt-2 text-[11px] leading-4`,children:[(0,G.jsx)(`strong`,{children:`Why here:`}),` `,s.reason]}),s.blockers.length>0&&(0,G.jsxs)(`p`,{className:`mt-1 text-[10px] text-warning`,children:[s.blockers.length,` unresolved blocker`,s.blockers.length===1?``:`s`]})]}),(0,G.jsxs)(`div`,{className:`grid gap-2 xl:grid-cols-2`,children:[(0,G.jsxs)(Sn,{icon:(0,G.jsx)(x,{className:`size-3`}),title:`Ownership & runtime`,children:[(0,G.jsx)($,{label:`Owner`,value:s.owner}),(0,G.jsx)($,{label:`Assignee`,value:Q(t.assignee)??Q(t.assignedAgent)??`—`}),(0,G.jsx)($,{label:`Agent ID`,value:Q(l?.agentId)??`—`,mono:!0}),(0,G.jsx)($,{label:`Agent name / role`,value:[Q(l?.name),Q(l?.role)].filter(Boolean).join(` · `)||`—`}),(0,G.jsx)($,{label:`Run status`,value:Q(l?.status)??`unassigned`}),(0,G.jsx)($,{label:`Subagent`,value:Q(l?.subagentId)??`—`,mono:!0}),(0,G.jsx)($,{label:`Run task`,value:Q(l?.runTaskId)??`—`,mono:!0}),(0,G.jsx)($,{label:`Session(s)`,value:s.sessions.join(`, `)||`Unknown`,mono:!0}),(0,G.jsx)($,{label:`Users / presence`,value:s.presence.length?s.presence.join(`, `):`No task-scoped presence recorded`})]}),(0,G.jsxs)(Sn,{icon:(0,G.jsx)(ue,{className:`size-3`}),title:`Model route & fallback`,children:[(0,G.jsx)($,{label:`Routing mode`,value:s.routingMode}),(0,G.jsx)($,{label:`Primary`,value:s.primaryModel,mono:!0}),(0,G.jsx)($,{label:`Provider`,value:s.provider??`—`,mono:!0}),(0,G.jsx)($,{label:`Model`,value:s.model??`—`,mono:!0}),(0,G.jsx)($,{label:`Fallback route`,value:s.fallbackRoute,mono:!0}),(0,G.jsx)($,{label:`Skills`,value:l?.skills?.map(Q).filter(Boolean).join(`, `)||`Default`}),(0,G.jsx)($,{label:`Tools`,value:l?.tools?.map(Q).filter(Boolean).join(`, `)||`Default toolset`}),(0,G.jsx)($,{label:`Capabilities`,value:l?.allowedCapabilities?.map(Q).filter(Boolean).join(`, `)||`Safe defaults`,mono:!0})]}),(0,G.jsxs)(Sn,{icon:(0,G.jsx)(_,{className:`size-3`}),title:`Execution policy & outcome`,children:[(0,G.jsx)($,{label:`Attempts`,value:`${s.attempts}${l?.maxAttempts?` / ${l.maxAttempts}`:``}`}),(0,G.jsx)($,{label:`Retry policy`,value:l?.retryPolicy??t.retryPolicy??`off`}),(0,G.jsx)($,{label:`Cost ceiling`,value:(l?.costCeilingUsd??t.costCeilingUsd)==null?`Unbounded`:`$${(l?.costCeilingUsd??t.costCeilingUsd).toFixed(2)}`}),(0,G.jsx)($,{label:`Failures / done`,value:`${s.failures} / ${s.completions}`}),(0,G.jsx)($,{label:`Checks`,value:`${d} / ${u} passed`}),(0,G.jsx)($,{label:`Last failure`,value:s.lastFailure??`—`}),(0,G.jsx)($,{label:`Result`,value:s.lastResult??`No result recorded`})]}),(0,G.jsxs)(Sn,{icon:(0,G.jsx)(se,{className:`size-3`}),title:`Timing & audit coverage`,children:[(0,G.jsx)($,{label:`Created`,value:bn(t.createdAt)}),(0,G.jsx)($,{label:`Updated`,value:bn(t.updatedAt)}),(0,G.jsx)($,{label:`Due`,value:bn(t.dueDate)}),(0,G.jsx)($,{label:`Dispatched`,value:bn(l?.dispatchedAt??l?.claimedAt)}),(0,G.jsx)($,{label:`Completed`,value:bn(l?.completedAt??t.completedAt)}),(0,G.jsx)($,{label:`Duration`,value:xn(l?.dispatchedAt??l?.claimedAt,l?.completedAt)}),(0,G.jsx)($,{label:`Heartbeat`,value:bn(l?.heartbeatAt)}),(0,G.jsx)($,{label:`Lease expires`,value:bn(l?.leaseExpiresAt)}),(0,G.jsx)($,{label:`Actors`,value:s.actors.join(`, `)||`Unknown`,mono:!0})]})]}),(0,G.jsxs)(Sn,{icon:(0,G.jsx)(E,{className:`size-3`}),title:`Dependencies, chain & provenance`,children:[(0,G.jsx)($,{label:`Dependencies`,value:(0,G.jsx)(Cn,{items:s.dependencies})}),(0,G.jsx)($,{label:`Other relations`,value:(0,G.jsx)(Cn,{items:p})}),(0,G.jsx)($,{label:`Chain`,value:t.chain?`${t.chain.chainId} · position ${t.chain.order}`:`None`,mono:!0}),(0,G.jsx)($,{label:`Origin system`,value:t.origin?.system??`manual`}),(0,G.jsx)($,{label:`Origin IDs`,value:t.origin&&[t.origin.graphId,t.origin.phaseId,t.origin.taskId,t.origin.specId].filter(Boolean).join(` · `)||`—`,mono:!0}),(0,G.jsx)($,{label:`Task ID`,value:t.id,mono:!0}),(0,G.jsx)($,{label:`Board ID`,value:e.id,mono:!0})]})]})]})}var Tn={passed:{icon:n,label:`Passed`,className:`text-success`},failed:{icon:g,label:`Failed`,className:`text-destructive`},needs_human:{icon:D,label:`Needs Review`,className:`text-warning`},incomplete:{icon:y,label:`Incomplete`,className:`text-muted-foreground`}},En={passed:{label:`Passed`,className:`text-success`},failed:{label:`Failed`,className:`text-destructive`},skipped:{label:`Skipped`,className:`text-muted-foreground`},error:{label:`Error`,className:`text-warning`}};function Dn(e,t){let n=Date.parse(t)-Date.parse(e);return Number.isNaN(n)||n<0?``:n<1e3?`${n}ms`:n<6e4?`${Math.round(n/1e3)}s`:`${Math.floor(n/6e4)}m ${Math.round(n%6e4/1e3)}s`}function On({verdict:e}){let t=Tn[e],n=t.icon;return(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-xs font-semibold ${t.className}`,children:[(0,G.jsx)(n,{size:13}),t.label]})}function kn({title:e,icon:t,defaultOpen:n=!1,children:r}){let[i,o]=(0,B.useState)(n);return(0,G.jsxs)(`div`,{className:`rounded-md border bg-background`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>o(!i),className:`flex w-full items-center gap-2 px-3 py-2 text-xs font-semibold uppercase text-muted-foreground hover:bg-muted/50`,children:[i?(0,G.jsx)(m,{size:13}):(0,G.jsx)(a,{size:13}),(0,G.jsx)(t,{size:13}),e]}),i&&(0,G.jsx)(`div`,{className:`border-t px-3 py-2 space-y-2`,children:r})]})}function An({check:e}){let t=En[e.status],[n,r]=(0,B.useState)(!1),i=e.error||e.backingRefs?.length;return(0,G.jsxs)(`div`,{className:`rounded border bg-muted/30 px-2.5 py-2 text-xs`,children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(`span`,{className:`font-medium ${t.className}`,children:t.label}),(0,G.jsx)(`span`,{className:`rounded bg-muted px-1 text-[10px] text-muted-foreground`,children:e.type})]}),(0,G.jsx)(`p`,{className:`mt-0.5 text-muted-foreground`,children:e.description})]}),i&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>r(!n),className:`shrink-0 text-muted-foreground hover:text-foreground`,children:n?(0,G.jsx)(m,{size:13}):(0,G.jsx)(a,{size:13})})]}),n&&(0,G.jsxs)(`div`,{className:`mt-2 space-y-1.5 border-t pt-2`,children:[e.error&&(0,G.jsx)(`div`,{className:`rounded bg-destructive/10 px-2 py-1 text-destructive`,children:e.error}),e.backingRefs?.map((e,t)=>(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,G.jsx)(u,{size:11}),(0,G.jsx)(`span`,{className:`font-mono text-[11px]`,children:e.path}),(0,G.jsxs)(`span`,{className:`text-[10px]`,children:[`(`,e.kind,`)`]}),e.summary&&(0,G.jsxs)(`span`,{className:`truncate`,children:[`— `,e.summary]})]},t))]})]})}function jn({fileScope:e}){return(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3 text-xs`,children:[(0,G.jsxs)(`span`,{className:`text-muted-foreground`,children:[`Expected `,(0,G.jsx)(`strong`,{children:e.expectedChanges}),` changes`]}),(0,G.jsxs)(`span`,{className:`text-muted-foreground`,children:[`Actual `,(0,G.jsx)(`strong`,{children:e.actualChanges}),` changes`]}),(0,G.jsx)(`span`,{className:e.scopeMatches?`text-success`:`text-destructive`,children:e.scopeMatches?`✅ Scope matches`:`❌ Scope mismatch`})]}),(0,G.jsx)(`div`,{className:`space-y-1`,children:e.files.map((e,t)=>(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-mono text-muted-foreground`,children:[(0,G.jsx)(`span`,{className:e.operation===`create`?`text-success`:e.operation===`delete`?`text-destructive`:`text-muted-foreground`,children:e.operation===`create`?`+`:e.operation===`delete`?`−`:`∼`}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.path}),(0,G.jsxs)(`span`,{className:`text-[10px]`,children:[e.linesChanged,` line`,e.linesChanged===1?``:`s`]}),!e.expected&&(0,G.jsx)(`span`,{className:`rounded bg-warning/10 px-1 text-[10px] text-warning`,children:`unexpected`})]},t))})]})}function Mn({subtasks:e}){return(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-muted-foreground`,children:[(0,G.jsxs)(`span`,{children:[`Total `,(0,G.jsx)(`strong`,{children:e.total})]}),(0,G.jsxs)(`span`,{className:`text-success`,children:[`Completed `,(0,G.jsx)(`strong`,{children:e.completed})]}),e.failed>0&&(0,G.jsxs)(`span`,{className:`text-destructive`,children:[`Failed `,(0,G.jsx)(`strong`,{children:e.failed})]})]}),(0,G.jsx)(`div`,{className:`space-y-1`,children:e.children.map((e,t)=>(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[e.verdict===`passed`?(0,G.jsx)(`span`,{className:`text-success`,children:`✓`}):e.verdict===`failed`?(0,G.jsx)(`span`,{className:`text-destructive`,children:`✗`}):e.verdict===`needs_human`?(0,G.jsx)(`span`,{className:`text-warning`,children:`⚠`}):(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`○`}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.title})]},t))})]})}function Nn({attachments:e}){return(0,G.jsx)(`div`,{className:`space-y-1`,children:e.map((e,t)=>(0,G.jsxs)(`div`,{className:`flex items-start gap-2 rounded border bg-muted/30 px-2 py-1.5 text-xs`,children:[(0,G.jsx)(o,{size:12,className:`mt-0.5 shrink-0 text-muted-foreground`}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`font-medium`,children:e.label}),(0,G.jsx)(`div`,{className:`mt-0.5 font-mono text-[11px] text-muted-foreground`,children:e.path?(0,G.jsxs)(`span`,{className:`truncate block`,children:[e.path,(0,G.jsx)(`span`,{className:`ml-1 rounded bg-muted px-1 text-[10px]`,children:e.kind})]}):(0,G.jsx)(`span`,{className:`rounded bg-muted px-1 text-[10px]`,children:e.kind})}),e.content&&(0,G.jsxs)(`pre`,{className:`mt-1 max-h-20 overflow-auto rounded bg-background p-1 text-[10px] text-muted-foreground`,children:[e.content.slice(0,500),e.content.length>500?`
3
- …`:``]})]})]},t))})}function Pn({report:e}){return(0,G.jsxs)(`div`,{className:`mt-5 space-y-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`div`,{className:`text-xs font-semibold uppercase text-muted-foreground`,children:`Verification Report`}),(0,G.jsx)(On,{verdict:e.verdict})]}),e.markdownSummary&&(0,G.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:Dn(e.startedAt,e.completedAt)})]}),e.markdownSummary&&(0,G.jsx)(`div`,{className:`rounded-md border bg-background px-3 py-2 text-xs text-muted-foreground whitespace-pre-wrap`,children:e.markdownSummary}),e.checks.length>0&&(0,G.jsx)(kn,{title:`Check Results`,icon:pe,defaultOpen:e.verdict!==`passed`,children:e.checks.map(e=>(0,G.jsx)(An,{check:e},e.checkId))}),e.fileScope&&(0,G.jsx)(kn,{title:`File Scope`,icon:u,defaultOpen:!e.fileScope.scopeMatches,children:(0,G.jsx)(jn,{fileScope:e.fileScope})}),e.subtasks&&(0,G.jsx)(kn,{title:`Sub-Tasks`,icon:pe,children:(0,G.jsx)(Mn,{subtasks:e.subtasks})}),e.attachments.length>0&&(0,G.jsx)(kn,{title:`Attachments (${e.attachments.length})`,icon:o,children:(0,G.jsx)(Nn,{attachments:e.attachments})})]})}function Fn({boardId:e,task:t,sendKanban:n}){return gt(t,be(n=>n.verificationActivity[`${e}:${t.id}`]))===`running`?(0,G.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 rounded-md border border-info/30 bg-info/5 p-3 text-xs text-info`,children:[(0,G.jsx)(l,{size:14,className:`animate-spin`}),`Verification running — checks are being executed…`]}):t.verificationReport?(0,G.jsxs)(`div`,{className:`mt-4`,children:[(0,G.jsx)(Pn,{report:t.verificationReport}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>n(`kanban.task.verify`,{boardId:e,taskId:t.id}),className:`mt-1.5 rounded-md border px-2 py-1 text-[11px] text-muted-foreground hover:bg-muted`,children:`Re-run verification`})]}):(0,G.jsxs)(`div`,{className:`mt-4 rounded-md border border-dashed p-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,G.jsx)(v,{size:14}),(0,G.jsx)(`span`,{className:`font-medium`,children:`Unverified`}),(0,G.jsx)(`span`,{children:`— no verification report exists for this task yet.`})]}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>n(`kanban.task.verify`,{boardId:e,taskId:t.id}),className:`mt-2 rounded-md bg-primary/10 px-2.5 py-1.5 text-xs font-medium text-primary hover:bg-primary/20`,children:`Run verification`})]})}function In({boards:e,board:t,task:n,runLink:r,onClose:i,onSelectTask:a,sendKanban:o,sendRaw:s,refreshBoard:c,activityEvents:l,activityPresence:u,activityLoading:d,activityError:f,activitySessionId:h,refreshActivity:g}){let[v,y]=(0,B.useState)(``),[x,S]=(0,B.useState)(``),[C,w]=(0,B.useState)(``),[E,D]=(0,B.useState)(``),[O,te]=(0,B.useState)(``),[A,re]=(0,B.useState)(`session`),[ie,ae]=(0,B.useState)(``),[se,ce]=(0,B.useState)([]),[le,ue]=(0,B.useState)([]),[de,fe]=(0,B.useState)([]),[pe,me]=(0,B.useState)([]),[j,he]=(0,B.useState)(``),M=xe(!!n),N=Ge(!!n),P=q(N.sessionProvider),_e=q(N.sessionModel),ve=Ce(`kanban-task-inspector`,!!n),[ye,be]=(0,B.useState)(!1),[I,L]=(0,B.useState)(!1),[R,we]=(0,B.useState)(``),[z,Te]=(0,B.useState)(``),[V,Ee]=(0,B.useState)(``),[De,Oe]=(0,B.useState)(`pending`),[ke,Ae]=(0,B.useState)(``),[je,Me]=(0,B.useState)(``),[Ne,Pe]=(0,B.useState)(``),[Fe,Ie]=(0,B.useState)(`medium`),[Le,Re]=(0,B.useState)(`chore`),[H,ze]=(0,B.useState)(``),[U,Be]=(0,B.useState)([]),[Ve,He]=(0,B.useState)([]),[W,Ue]=(0,B.useState)(!1),[We,Ke]=(0,B.useState)(``),[qe,Je]=(0,B.useState)(``),[Ye,Xe]=(0,B.useState)(`off`),[Ze,Qe]=(0,B.useState)(``),[$e,et]=(0,B.useState)(``),[tt,nt]=(0,B.useState)(``),[rt,it]=(0,B.useState)(``),[ot,st]=(0,B.useState)(``),[ct,lt]=(0,B.useState)(`observation`),[ut,dt]=(0,B.useState)(`unknown`),[ft,pt]=(0,B.useState)(``);(0,B.useEffect)(()=>{let r=q(n?.assignment?.provider),i=q(n?.assignment?.model);y(q(n?.assignment?.agentId)??q(n?.assignedAgent)??``),S(q(n?.assignment?.name)??``),w(q(n?.assignment?.role)??``),D(r??``),te(i??``),re(n?.assignment?.modelRouting??(r||i?`fixed`:`session`)),ae(q(n?.assignment?.fallbackProfile)??``),ce(n?.assignment?.fallbackModels??[]),ue(n?.assignment?.skills??[]),fe(n?.assignment?.tools??[]),me(n?.assignment?.allowedCapabilities??[]),he(e.find(e=>e.id!==t?.id)?.id??``),we(n?.title??``),Te(n?.description??``),Ee(n?.dueDate??``),Oe(n?.status??`pending`),Ae(``),Me(``),Pe(``),Ie(n?.priority??`medium`),Re(n?.type??`chore`),ze(n?.labels?.join(`, `)??``),Be(n?.dependsOn??[]),He(n?.chain&&t?t.tasks.filter(e=>e.chain?.chainId===n.chain?.chainId).sort((e,t)=>(e.chain?.order??0)-(t.chain?.order??0)).map(e=>e.id):n?[n.id]:[]),Ue(!1),Ke(n?.estimatedHours?.toString()??``),Je(n?.actualHours?.toString()??``),Xe(n?.retryPolicy??n?.assignment?.retryPolicy??`off`),Qe((n?.costCeilingUsd??n?.assignment?.costCeilingUsd)?.toString()??``),et(n?.assignment?.maxAttempts?.toString()??``),nt(``),it(``),st(``),lt(`observation`),dt(`unknown`),pt(``)},[t?.id,e,n]);let ht=e=>({boardId:t?.id,taskId:n?.id,...v.trim()?{agentId:v.trim()}:{},...x.trim()?{name:x.trim()}:{},...C.trim()?{role:C.trim()}:{},modelRouting:A,...A===`fixed`&&E.trim()?{provider:E.trim()}:{},...A===`fixed`&&O.trim()?{model:O.trim()}:{},...A===`fallback_profile`&&ie.trim()?{fallbackProfile:ie.trim()}:{},fallbackModels:se,skills:le,tools:de,allowedCapabilities:pe,...$e?{maxAttempts:Number($e)}:{},...Ze?{costCeilingUsd:Number(Ze)}:{},retryPolicy:Ye,activityNote:ft.trim()||`${e===`dispatch`?`Dispatched`:`Assigned`} from WebUI to ${x.trim()||v.trim()||C.trim()||`the configured agent route`}.`}),gt=()=>{!t||!n||!R.trim()||(o(`kanban.task.update`,{boardId:t.id,taskId:n.id,title:R.trim(),description:z,dueDate:V||null,...t.lifecycle?.mode===`managed`?{}:{status:De},priority:Fe,type:Le,labels:H.split(`,`).map(e=>e.trim()).filter(Boolean),dependsOn:U,...n.chain&&Ve.length<=1?{chain:null}:{},estimatedHours:We?Number(We):0,actualHours:qe?Number(qe):0,retryPolicy:Ye,costCeilingUsd:Ze?Number(Ze):null,activityNote:ft.trim()||`Task contract edited in WebUI.`}),Ve.length>1&&o(`kanban.task.chain`,{boardId:t.id,taskIds:Ve,enforceDependencies:W}),window.setTimeout(()=>c(t.id),180),pt(``))},_t=[`backlog`,`todo`,`running`,`review`,`done`],vt=n?.lifecycle?.currentStage,yt=vt?_t.indexOf(vt):-1,bt=yt>=0&&yt<_t.length-1?_t[yt+1]:void 0;return n?(0,G.jsxs)(`aside`,{"aria-label":`Task inspector`,"data-expanded":I?`true`:`false`,className:F(`flex max-h-[42dvh] w-full shrink-0 flex-col border-t bg-card/40 transition-[width] duration-200 ease-out md:max-h-none md:border-l md:border-t-0`,I?`fixed inset-0 z-50 h-dvh max-h-none w-screen border-0 bg-card transition-none md:w-screen md:border-0`:`md:w-[420px] xl:w-[480px]`),children:[(0,G.jsxs)(`div`,{className:F(`flex h-12 items-center gap-2 border-b px-3`,I&&`px-5`),children:[(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`truncate text-sm font-semibold`,children:`Task`}),(0,G.jsx)(`div`,{className:`truncate text-[11px] text-muted-foreground`,children:n.id.slice(0,8)})]}),(0,G.jsx)(`button`,{type:`button`,title:I?`Collapse task details`:`Expand task details`,"aria-label":I?`Collapse task details`:`Expand task details`,"aria-pressed":I,onClick:()=>L(e=>!e),className:`flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground`,children:I?(0,G.jsx)(p,{size:16}):(0,G.jsx)(ge,{size:16})}),(0,G.jsx)(`button`,{type:`button`,title:`Close`,onClick:()=>{L(!1),i()},className:`flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,G.jsx)(T,{size:16})})]}),n?(0,G.jsxs)(`div`,{ref:ve,className:F(`min-h-0 flex-1 overflow-y-auto overscroll-contain p-3`,I&&`px-5 py-4 xl:px-7`),children:[(0,G.jsxs)(`div`,{className:`space-y-3 rounded-md border bg-background p-2.5`,children:[(0,G.jsx)(at,{title:`Task boundary`,value:n.boundary,inherited:t?.boundary,onSave:e=>{t&&(o(`kanban.task.update`,{boardId:t.id,taskId:n.id,boundary:e,activityNote:`Task boundary edited in WebUI.`}),window.setTimeout(()=>c(t.id),150))}}),(0,G.jsx)(J,{label:`Title`,value:R,onChange:we}),(0,G.jsxs)(`label`,{className:`block`,children:[(0,G.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:`Description / working context`}),(0,G.jsx)(`textarea`,{value:z,onChange:e=>Te(e.target.value),rows:5,className:`w-full resize-y rounded-md border bg-background px-2 py-1.5 text-xs leading-5 outline-none focus:border-primary`})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[t?.lifecycle?.mode===`managed`?(0,G.jsxs)(`div`,{className:`rounded-md border bg-muted/30 px-2 py-1.5`,children:[(0,G.jsx)(`div`,{className:`text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:`Managed stage`}),(0,G.jsx)(`div`,{className:`mt-1 text-xs font-semibold capitalize`,children:n.lifecycle?.currentStage??`Backlog`})]}):(0,G.jsx)(Ct,{label:`Status`,value:De,options:[`pending`,`ready`,`in_progress`,`blocked`,`review`,`completed`,`failed`,`archived`],onChange:e=>Oe(e)}),(0,G.jsx)(Ct,{label:`Priority`,value:Fe,options:[`critical`,`high`,`medium`,`low`],onChange:e=>Ie(e)}),(0,G.jsx)(Ct,{label:`Type`,value:Le,options:[`feature`,`bugfix`,`refactor`,`docs`,`test`,`chore`],onChange:e=>Re(e)}),(0,G.jsx)(J,{label:`Labels (comma separated)`,value:H,onChange:ze})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,G.jsx)(J,{label:`Due date (ISO or YYYY-MM-DD)`,value:V,onChange:Ee}),(0,G.jsx)(J,{label:`Estimated hours`,value:We,onChange:Ke}),(0,G.jsx)(J,{label:`Actual hours`,value:qe,onChange:Je})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:`Dependencies`}),(0,G.jsx)(K,{options:(t?.tasks??[]).filter(e=>e.id!==n.id).map(e=>({value:e.id,label:e.title,description:e.status})),selected:U,onChange:Be,placeholder:`Select blocking tasks…`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:`Task chain (selection order)`}),(0,G.jsx)(K,{options:(t?.tasks??[]).map(e=>({value:e.id,label:e.title,description:e.status})),selected:Ve,onChange:e=>He(e.includes(n.id)?e:[n.id,...e]),placeholder:`Add tasks to a sequential chain…`}),(0,G.jsxs)(`label`,{className:`mt-1.5 flex items-center gap-2 text-[11px] text-muted-foreground`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:W,onChange:e=>Ue(e.target.checked)}),`Enforce chain order as dependencies`]})]}),(0,G.jsx)(J,{label:`Change / assignment reason (persisted to activity)`,value:ft,onChange:pt}),(0,G.jsxs)(`button`,{type:`button`,onClick:gt,className:`inline-flex h-9 w-full items-center justify-center gap-2 rounded-md bg-primary text-sm text-primary-foreground hover:bg-primary/90`,children:[(0,G.jsx)(k,{size:15}),` Save task contract`]}),t?.lifecycle?.mode===`managed`&&bt&&(0,G.jsxs)(`section`,{"aria-label":`Managed lifecycle transition`,className:`space-y-2 rounded-md border border-primary/30 bg-primary/5 p-2.5`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wide text-primary`,children:`Kanban Agent transition`}),(0,G.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[vt,` → `,bt,`; no stages can be skipped.`]})]}),(0,G.jsx)(_,{size:16,className:`text-primary`})]}),(0,G.jsx)(J,{label:`Completed action / reviewer action`,value:je,onChange:Me}),(0,G.jsx)(J,{label:`Truthful progress comment (required)`,value:ke,onChange:Ae}),(0,G.jsx)(J,{label:`Evidence attachment URL`,value:Ne,onChange:Pe}),(0,G.jsxs)(`button`,{type:`button`,disabled:!ke.trim(),onClick:()=>{!t||!n||!bt||!ke.trim()||(o(`kanban.task.transition`,{boardId:t.id,taskId:n.id,to:bt,actor:v.trim()||x.trim()||n.assignee||n.assignedAgent||`webui-agent`,comment:ke.trim(),...je.trim()?{action:je.trim()}:{},...Ne.trim()?{attachment:{url:Ne.trim(),type:`url`,title:`Evidence for ${n.title}`}}:{}}),window.setTimeout(()=>c(t.id),180))},className:`inline-flex h-9 w-full items-center justify-center gap-2 rounded-md bg-primary text-sm text-primary-foreground hover:bg-primary/90 disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,G.jsx)(oe,{size:15}),` Advance to `,bt]})]})]}),t&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(wn,{board:t,task:n,events:l,presence:u,sessionId:h,sessionProvider:P,sessionModel:_e}),(0,G.jsx)(gn,{task:n,events:l,sessionId:h}),(0,G.jsx)(At,{board:t,task:n,events:l})]}),(0,G.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 gap-2 text-xs`,children:[(0,G.jsx)(St,{label:`Source`,value:n.origin?.system??`manual`}),(0,G.jsx)(St,{label:`Task ID`,value:n.id.slice(0,8)}),(0,G.jsx)(St,{label:`Run`,value:n.assignment?.status??`unassigned`}),(0,G.jsx)(St,{label:`Column`,value:xt(t,n.columnId)})]}),n.assignment&&(0,G.jsx)(Gt,{assignment:n.assignment}),r&&n.origin?.taskId&&(0,G.jsx)(It,{runLink:r,runTaskId:n.origin.taskId,modelCandidates:M,sendRaw:s}),!r&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,G.jsx)(Ct,{label:`Primary model source`,value:A,options:[`session`,`fixed`,`fallback_profile`],onChange:e=>re(e)}),A===`session`&&(0,G.jsxs)(`div`,{className:`rounded-md border bg-info/5 px-2 py-1.5 text-[11px] text-muted-foreground`,children:[`Uses the live session model: `,P?`${P}/`:``,_e||`not available`,`.`]}),A===`fixed`&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:`Fixed provider / model`}),(0,G.jsx)(Se,{value:O||void 0,provider:E||void 0,candidates:M,placeholder:`Select exact provider / model…`,onPick:(e,t)=>{te(e),D(t)}})]}),A===`fallback_profile`&&(0,G.jsx)(Ct,{label:`Fallback profile (first model is primary)`,value:ie,options:Object.keys(N.fallbackProfiles),placeholder:`Select configured profile…`,onChange:ae}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:`Fallback models`}),(0,G.jsx)(K,{options:M.map(e=>({value:`${e.provider}/${e.model}`,label:e.label,description:e.description,tag:e.provider})),selected:se,onChange:ce,placeholder:`Add fallback model…`,emptyLabel:`No models — add a provider in Settings`})]}),(0,G.jsx)(Ct,{label:`Role`,value:C,options:Jt,placeholder:`Select a role…`,onChange:w}),(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:[`Agentic skills`,` `,(0,G.jsx)(`span`,{className:`text-muted-foreground/70`,children:`· force-loaded into the worker`})]}),(0,G.jsx)(K,{options:N.skills.map(e=>({value:e.name,label:e.name,description:e.description,tag:e.source})),selected:le,onChange:ue,placeholder:`Assign required skills…`,emptyLabel:`No skills registered`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:[`Tools`,` `,(0,G.jsx)(`span`,{className:`text-muted-foreground/70`,children:`· blank = full default toolset`})]}),(0,G.jsx)(K,{options:N.tools.map(e=>({value:e.name,label:e.name,description:e.description})),selected:de,onChange:fe,placeholder:`Restrict to specific tools…`,emptyLabel:`Tool list unavailable on this server`})]}),(0,G.jsxs)(`div`,{className:`rounded-md border bg-background/60`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>be(e=>!e),className:`flex w-full items-center justify-between px-2 py-1.5 text-[11px] font-medium text-muted-foreground hover:text-foreground`,children:[`Advanced`,(0,G.jsx)(m,{size:13,className:F(`transition-transform`,ye&&`rotate-180`)})]}),ye&&(0,G.jsxs)(`div`,{className:`space-y-3 border-t p-2`,children:[(0,G.jsx)(J,{label:`Agent name (optional)`,value:x,onChange:S}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,G.jsx)(Ct,{label:`Retry policy`,value:Ye,options:[`off`,`incremental`,`exponential`],onChange:e=>Xe(e)}),(0,G.jsx)(J,{label:`Max attempts`,value:$e,onChange:et}),(0,G.jsx)(J,{label:`Cost ceiling USD`,value:Ze,onChange:Qe})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:[`Capabilities`,` `,(0,G.jsx)(`span`,{className:`text-muted-foreground/70`,children:`· blank = safe defaults`})]}),(0,G.jsx)(K,{options:Yt,selected:pe,onChange:me,placeholder:`Grant a capability…`})]})]})]})]}),(0,G.jsxs)(`div`,{className:`mt-4 grid grid-cols-2 gap-2`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>{!t||!n||(o(`kanban.task.assign`,ht(`assign`)),pt(``),window.setTimeout(()=>c(t.id),150))},className:`inline-flex h-9 items-center justify-center gap-2 rounded-md border text-sm hover:bg-muted`,children:[(0,G.jsx)(ne,{size:15}),`Assign`]}),(0,G.jsxs)(`button`,{type:`button`,onClick:()=>{!t||!n||(o(`kanban.task.dispatch`,ht(`dispatch`)),pt(``),window.setTimeout(()=>c(t.id),200))},className:`inline-flex h-9 items-center justify-center gap-2 rounded-md bg-primary text-sm text-primary-foreground hover:bg-primary/90`,children:[(0,G.jsx)(b,{size:15}),`Dispatch`]})]})]}),e.length>1&&!r?(0,G.jsxs)(`div`,{className:`mt-4 space-y-2 rounded-md border bg-background p-2`,children:[(0,G.jsxs)(`label`,{className:`block`,children:[(0,G.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:`Target board`}),(0,G.jsx)(`select`,{value:j,onChange:e=>he(e.target.value),className:`h-8 w-full rounded-md border bg-background px-2 text-sm outline-none focus:border-primary`,children:e.filter(e=>e.id!==t?.id).map(e=>(0,G.jsx)(`option`,{value:e.id,children:e.title},e.id))})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>{!t||!n||!j||o(`kanban.task.copy`,{boardId:t.id,taskId:n.id,targetBoardId:j})},disabled:!j,className:`inline-flex h-9 items-center justify-center gap-2 rounded-md border text-sm hover:bg-muted disabled:opacity-50`,children:[(0,G.jsx)(ee,{size:15}),`Copy`]}),(0,G.jsxs)(`button`,{type:`button`,onClick:()=>{!t||!n||!j||o(`kanban.task.transfer`,{boardId:t.id,taskId:n.id,targetBoardId:j})},disabled:!j,className:`inline-flex h-9 items-center justify-center gap-2 rounded-md border text-sm hover:bg-muted disabled:opacity-50`,children:[(0,G.jsx)(oe,{size:15}),`Transfer`]})]})]}):null,(0,G.jsx)(qt,{board:t,task:n,newCheck:tt,onNewCheckChange:nt,onAddCheck:()=>{!t||!n||!tt.trim()||(o(`kanban.task.check.add`,{boardId:t.id,taskId:n.id,description:tt.trim(),checkType:`manual`}),nt(``))},sendKanban:o}),t&&(0,G.jsx)(Fn,{boardId:t.id,task:n,sendKanban:o}),t&&(0,G.jsx)(mt,{board:t,task:n,sendKanban:o,onSelectTask:a}),(0,G.jsx)(sn,{task:n,events:l,sessionId:h,loading:d,error:f,onRefresh:g}),(0,G.jsx)(Kt,{activityKind:ct,activityOutcome:ut,note:rt,details:ot,onActivityKindChange:lt,onActivityOutcomeChange:dt,onNoteChange:it,onDetailsChange:st,onRecordActivity:()=>{!t||!n||!rt.trim()||(o(`kanban.task.activity.add`,{boardId:t.id,taskId:n.id,kind:ct,outcome:ut,summary:rt.trim(),...ot.trim()?{details:ot.trim()}:{},actor:x.trim()||v.trim()||`webui-operator`}),it(``),st(``),window.setTimeout(g,150))}})]}):null]}):null}var Ln=[[`board`,`Board`],[`tree`,`Tree`],[`dashboard`,`Verification`]];function Rn({viewMode:e,onViewModeChange:t}){return(0,G.jsx)(`div`,{className:`flex shrink-0 items-center gap-1 border-b px-4 py-1.5`,children:Ln.map(([n,r])=>(0,G.jsx)(`button`,{type:`button`,onClick:()=>t(n),className:F(`rounded-md px-2.5 py-1 text-[11px] font-medium transition-colors`,e===n?`bg-primary/10 text-primary`:`text-muted-foreground hover:bg-muted`),children:r},n))})}function zn(){let[e,t]=(0,B.useState)([]);return(0,B.useEffect)(()=>{let e=!1,n=async()=>{try{let n=await fetch(`/api/sessions`);if(!n.ok)return;let r=await n.json();if(!Array.isArray(r)||e)return;let i=r.filter(e=>!!e&&typeof e==`object`&&typeof e.sessionId==`string`&&e.status!==`lost`).map(e=>e.sessionId).sort();t(e=>e.length===i.length&&e.every((e,t)=>e===i[t])?e:i)}catch{}};n();let r=window.setInterval(n,8e3);return()=>{e=!0,window.clearInterval(r)}},[]),e}var Bn=5e3,Vn=12;function Hn({onClose:e}){let t=ye(e=>e.wsUrl),n=ve(e=>e.session?.id??null),r=I(e=>e.agents),{boards:a,boardTotal:o,activeBoardTotal:s,orphanedBoardTotal:c,activeBoardId:l,activeBoard:u,loading:d,error:f,queueHealth:p,supervisorSnapshot:m,setLoading:h,setActiveBoardId:g}=be(),[_,v]=(0,B.useState)(``),[y,b]=(0,B.useState)(1),x=zn(),[S,C]=(0,B.useState)(``),w=(0,B.useRef)(null);Te(w);let[E,D]=(0,B.useState)(``),[O,k]=(0,B.useState)(null),[A,ne]=(0,B.useState)([]),[re,ie]=(0,B.useState)(),[ae,oe]=(0,B.useState)(!1),[se,ce]=(0,B.useState)(null),[le,ue]=(0,B.useState)(0),[fe,pe]=(0,B.useState)(null),[me,j]=(0,B.useState)(`board`),he=(0,B.useRef)(null),M=(0,B.useMemo)(()=>_e(t),[t]),ge=u?.tasks.find(e=>e.id===O)??null,N=(0,B.useMemo)(()=>Ze(r.values()),[r]),P=(0,B.useMemo)(()=>Qe({sessionId:n,registrySessionIds:x,agents:r.values()}),[r,x,n]),F=a.filter(e=>$e(e,P)),xe=a.filter(e=>!$e(e,P)),Se=(0,B.useMemo)(()=>u?De(u,{now:Date.now(),liveAgentIdentities:N,requireDueDate:u.lifecycle?.mode===`managed`}):null,[u,N]),Ce=(0,B.useMemo)(()=>et(u),[u]),L=(e,t={})=>{h(!0),M.send({type:e,payload:t})},R=(e,t={})=>{M.send({type:e,payload:t})},we=(0,B.useMemo)(()=>tt(u),[u]),z=(e=y)=>L(`kanban.list`,{page:e,pageSize:Vn,activeSessionIds:P}),V=(e=l)=>{e&&L(`kanban.get`,{boardId:e})};(0,B.useEffect)(()=>{z()},[]),(0,B.useEffect)(()=>{let e=n?a.find(e=>e.tags?.includes(`session:${n}`)):void 0,t=!!(n&&e)&&he.current!==n,r=t?e:l?void 0:a[0];r?.id&&(t&&(he.current=n),g(r.id),L(`kanban.get`,{boardId:r.id}))},[a,l,n,g]),(0,B.useEffect)(()=>{u&&O&&!u.tasks.some(e=>e.id===O)&&k(null)},[u,O]),(0,B.useEffect)(()=>{l&&(L(`kanban.health`,{boardId:l}),L(`kanban.supervisor.status`,{boardId:l}))},[l]),(0,B.useEffect)(()=>{if(!l)return;let e=setInterval(()=>{M.send({type:`kanban.get`,payload:{boardId:l}}),M.send({type:`kanban.health`,payload:{boardId:l}})},5e3);return()=>clearInterval(e)},[l,M]),(0,B.useEffect)(()=>{let e=setInterval(()=>{M.send({type:`kanban.list`,payload:{page:y,pageSize:Vn,activeSessionIds:P}})},8e3);return()=>clearInterval(e)},[P,y,M]);let Ee=e=>{b(e),g(null),z(e)};(0,B.useEffect)(()=>{ie(void 0)},[l,O]),(0,B.useEffect)(()=>{if(!l||!O)return;let e=l,t=O;oe(!0),ce(null);let n=M.on(`kanban.task.activity`,n=>{let r=n.payload;if(r.success===!1){ce(r.error??`Task activity could not be loaded.`),oe(!1);return}r.data?.boardId!==e||r.data.taskId!==t||(ne(r.data.events??[]),ie(r.data.presence??[]),oe(!1))});return M.send({type:`kanban.task.activity`,payload:{boardId:e,taskId:t,limit:Bn}}),n},[l,O,ge?.updatedAt,le,M]),(0,B.useEffect)(()=>{if(!(!l||!O))return M.on.bind(M)(`kanban.task.activity.changed`,e=>{let t=e.payload;t.boardId===l&&t.taskId===O&&ue(e=>e+1)})},[l,O,M]);let Oe=()=>{let e=_.trim();e&&(v(``),L(`kanban.create`,{title:e,lifecycle:{mode:`managed`,columns:{backlog:`backlog`,todo:`todo`,running:`in-progress`,review:`review`,done:`done`}}}))},ke=()=>{if(!u)return;let e=S.trim();e&&(C(``),L(`kanban.task.add`,{boardId:u.id,title:e,columnId:u.columns[0]?.id??`backlog`,activityNote:`Task created manually in WebUI.`}),window.setTimeout(()=>V(u.id),150))},Ae=()=>{if(!u)return;let e=E.trim();e&&(D(``),L(`kanban.column.add`,{boardId:u.id,title:e}),window.setTimeout(()=>V(u.id),150))},je=()=>{u&&(L(`kanban.delete`,{boardId:u.id}),window.setTimeout(z,150))},Me=()=>{u&&(L(`kanban.duplicate`,{boardId:u.id,title:`${u.title} Copy`}),window.setTimeout(z,150))},Ne=e=>{u&&(L(`kanban.task.remove`,{boardId:u.id,taskId:e.id}),window.setTimeout(()=>V(u.id),150))},Pe=(e,t)=>{if(!u)return;let n=u.tasks.find(t=>t.id===e),r=u.columns.find(e=>e.id===n?.columnId)?.title,i=u.columns.find(e=>e.id===t)?.title??t;L(`kanban.task.move`,{boardId:u.id,taskId:e,columnId:t,activityNote:`Moved in WebUI${r?` from ${r}`:``} to ${i}.`}),window.setTimeout(()=>V(u.id),150)};return(0,G.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col bg-background text-foreground md:flex-row`,children:[(0,G.jsx)(nt,{boardTotal:o,activeBoardTotal:s,orphanedBoardTotal:c,activeBoardId:l,activeBoards:F,orphanedBoards:xe,boardPage:y,boardPageSize:Vn,loading:d,newBoardTitle:_,onClose:e,onRefresh:()=>z(),onNewBoardTitleChange:v,onCreateBoard:Oe,onBoardSelect:e=>{g(e),L(`kanban.get`,{boardId:e})},onBoardPageChange:Ee}),(0,G.jsxs)(`main`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,G.jsxs)(`header`,{className:`flex min-h-12 shrink-0 flex-wrap items-center gap-2 border-b px-3 py-2 sm:px-4`,children:[(0,G.jsxs)(`div`,{className:`w-full min-w-0 sm:w-auto sm:flex-1`,children:[(0,G.jsx)(`div`,{className:`truncate text-sm font-semibold`,children:u?.title??`No board selected`}),(0,G.jsx)(`div`,{className:`truncate text-[11px] text-muted-foreground`,children:u?`${u.columns.length} columns / ${u.tasks.length} tasks`:`Create or select a board`})]}),u&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`input`,{value:S,onChange:e=>C(e.target.value),onKeyDown:e=>{e.key===`Enter`&&ke()},placeholder:`New task`,className:`h-8 w-[calc(100%-2.5rem)] min-w-0 flex-none rounded-md border bg-background px-2 text-sm outline-none focus:border-primary sm:w-56`}),(0,G.jsx)(`button`,{type:`button`,title:`Add task`,onClick:ke,className:`flex h-8 w-8 items-center justify-center rounded-md bg-primary text-primary-foreground hover:bg-primary/90`,children:(0,G.jsx)(de,{size:16})}),(0,G.jsx)(`input`,{value:E,onChange:e=>D(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Ae()},placeholder:`New column`,className:`h-8 w-[calc(100%-2.5rem)] min-w-0 flex-none rounded-md border bg-background px-2 text-sm outline-none focus:border-primary sm:w-44`}),(0,G.jsx)(`button`,{type:`button`,title:`Add column`,onClick:Ae,className:`hidden h-8 w-8 items-center justify-center rounded-md border text-muted-foreground hover:bg-muted hover:text-foreground sm:flex`,children:(0,G.jsx)(te,{size:16})}),(0,G.jsx)(`button`,{type:`button`,title:`Duplicate board`,onClick:Me,className:`flex h-8 w-8 items-center justify-center rounded-md border text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,G.jsx)(ee,{size:16})}),(0,G.jsx)(`button`,{type:`button`,title:`Delete board`,onClick:je,className:`hidden h-8 w-8 items-center justify-center rounded-md border text-muted-foreground hover:bg-destructive/10 hover:text-destructive sm:flex`,children:(0,G.jsx)(i,{size:16})})]})]}),u&&(0,G.jsx)(Je,{presence:u.presence}),u&&(0,G.jsx)(`div`,{className:`shrink-0 border-b px-3 py-2 sm:px-4`,children:(0,G.jsx)(at,{title:`Board boundary`,value:u.boundary,onSave:e=>{L(`kanban.update`,{boardId:u.id,boundary:e}),window.setTimeout(()=>V(u.id),150)}})}),u&&we&&(0,G.jsx)(Pt,{runLink:we,sendRaw:R}),u&&!we&&u.tasks.length>0&&(0,G.jsx)(Ft,{boardId:u.id,sendKanban:L}),u&&(0,G.jsx)(Ye,{board:u,snapshot:m,sendKanban:L}),Se&&(0,G.jsx)(lt,{audit:Se,onSelectTask:k}),u&&(0,G.jsx)(dt,{board:u,sendKanban:L,onSelectTask:k}),u&&(0,G.jsx)(Rn,{viewMode:me,onViewModeChange:j}),f&&(0,G.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center gap-2 border-b border-destructive/30 bg-destructive/10 px-4 text-sm text-destructive`,children:[(0,G.jsx)(T,{size:15}),(0,G.jsx)(`span`,{className:`truncate`,children:f})]}),(0,G.jsx)(`div`,{ref:w,className:`kanban-scroll-area min-h-0 flex-1 overflow-x-auto overflow-y-hidden overscroll-contain`,children:u?(0,G.jsxs)(G.Fragment,{children:[p&&(0,G.jsx)(Nt,{queueHealth:p,runningCostTotal:Ce}),me===`tree`?(0,G.jsx)(zt,{board:u,selectedTaskId:O,onSelectTask:k}):me===`dashboard`?(0,G.jsx)(Ht,{board:u,onSelectTask:k}):(0,G.jsx)(`div`,{className:`flex h-full min-w-max gap-3 p-4`,children:[...u.columns].sort((e,t)=>e.order-t.order).map(e=>(0,G.jsx)(Mt,{board:u,column:e,selectedTaskId:O,dragTaskId:fe,setDragTaskId:pe,onSelectTask:k,onDeleteTask:Ne,onMoveTask:Pe},e.id))})]}):(0,G.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`No kanban board selected.`})})]}),(0,G.jsx)(In,{boards:a,board:u,task:ge,runLink:we,onClose:()=>k(null),onSelectTask:k,sendKanban:L,sendRaw:R,refreshBoard:V,activityEvents:A,activityPresence:re,activityLoading:ae,activityError:se,activitySessionId:u?.tags?.find(e=>e.startsWith(`session:`))?.slice(8),refreshActivity:()=>ue(e=>e+1)})]})}export{Hn as KanbanView};
@@ -1,3 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-2VBBgNb5.js","assets/rolldown-runtime-QTnfLwEv.js","assets/monaco-BLUV5g0U.js","assets/monaco-Bowa0-zp.css","assets/markdown-L6DLSM7f.js","assets/vendor-BMdWcCR4.css"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Kr as t,Sa as n,_a as r,ci as i,et as a,zi as o}from"./vendor-2VBBgNb5.js";import"./i18n-1BkaqMgr.js";import{s}from"./monaco-BLUV5g0U.js";import{t as c}from"./utils-CN2sfDVP.js";import{d as l}from"./markdown-L6DLSM7f.js";var u=e(n(),1),d=a();async function f(e){try{if(typeof navigator<`u`&&navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}try{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select();let n=document.execCommand(`copy`);return document.body.removeChild(t),n}catch{return!1}}function p(e,t){if(typeof document>`u`)return;let n=new Blob([t],{type:`text/plain;charset=utf-8`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=e,document.body.appendChild(i),i.click(),document.body.removeChild(i),setTimeout(()=>URL.revokeObjectURL(r),1e3)}function m(e){let t=(e??``).toLowerCase();return/bash|shell|exec|run/.test(t)?`log`:(/grep|search|find/.test(t),`txt`)}function h(e){return e<1e3?`${e} ms`:e<6e4?`${(e/1e3).toFixed(e<1e4?2:1)}s`:`${Math.floor(e/6e4)}m ${Math.floor(e%6e4/1e3)}s`}function g(e){if(!e)return;let t=e.match(/(?:^|\n)\s*(?:\[?exit(?:\s*code)?\]?\s*[:=]?\s*)(\d+)\s*$/i);return t?Number(t[1]):void 0}var _=[l];function v(e){return typeof e==`string`||typeof e==`number`?String(e):Array.isArray(e)?e.map(v).join(``):(0,u.isValidElement)(e)?v(e.props.children):``}function y({text:e}){let{t}=r(),[n,a]=(0,u.useState)(!1);return(0,d.jsxs)(`button`,{type:`button`,onClick:(0,u.useCallback)(async()=>{await f(e)&&(a(!0),setTimeout(()=>a(!1),1500))},[e]),className:c(`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] transition-colors`,`hover:bg-muted-foreground/10`,n?`text-success`:`text-muted-foreground hover:text-foreground`),title:t(n?`common:action.copied`:`common:action.copy`),children:[n?(0,d.jsx)(o,{className:`h-3 w-3`}):(0,d.jsx)(i,{className:`h-3 w-3`}),(0,d.jsx)(`span`,{children:t(n?`common:action.copied`:`common:action.copy`)})]})}var b={code({inline:e,className:n,children:r,...i}){let a=/language-(\w+)/.exec(n??``),o=v(r).replace(/\n$/,``);if(e||!a)return(0,d.jsx)(`code`,{className:c(`rounded border border-border/60 px-1.5 py-0.5 text-[0.85em] font-mono`,n),...i,children:r});let s=(0,u.useMemo)(()=>o.split(`
3
- `),[o]),l=s.length>1;return(0,d.jsxs)(`div`,{className:`not-prose relative my-3 rounded-lg border border-border overflow-hidden group/codeblock`,children:[(0,d.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-1 border-b border-border text-xs`,children:[(0,d.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,d.jsx)(t,{className:`h-3 w-3 text-muted-foreground`}),(0,d.jsx)(`span`,{className:`font-mono text-muted-foreground font-medium`,children:a[1]}),s.length>0&&(0,d.jsxs)(`span`,{className:`text-[10px] text-muted-foreground/75 tabular-nums`,children:[s.length,` line`,s.length===1?``:`s`]})]}),(0,d.jsx)(y,{text:o})]}),l?(0,d.jsxs)(`div`,{className:`flex max-h-[40rem] overflow-auto`,children:[(0,d.jsx)(`pre`,{"aria-hidden":!0,className:`text-xs font-mono leading-[1.55] py-3 pl-3 pr-2 text-muted-foreground/65 select-none border-r border-border/30 tabular-nums text-right shrink-0`,children:s.map((e,t)=>(0,d.jsx)(`div`,{children:t+1},t))}),(0,d.jsx)(`pre`,{className:`overflow-x-auto py-3 px-3 text-xs leading-[1.55] font-mono flex-1`,children:(0,d.jsx)(`code`,{className:c(`hljs`,n),...i,children:r})})]}):(0,d.jsx)(`pre`,{className:`overflow-x-auto p-3 text-xs leading-relaxed font-mono max-h-[40rem]`,children:(0,d.jsx)(`code`,{className:c(`hljs`,n),...i,children:r})}),(0,d.jsx)(`div`,{className:`pointer-events-none absolute bottom-8 left-0 right-0 h-8 opacity-0 group-hover/codeblock:opacity-100 transition-opacity`,style:{background:`linear-gradient(to top, hsl(var(--foreground) / 0.08), transparent)`}})]})}},x=(0,u.lazy)(()=>s(()=>import(`./vendor-2VBBgNb5.js`).then(e=>e.x),__vite__mapDeps([0,1,2,3,4,5])));function S(e){return(0,d.jsx)(u.Suspense,{fallback:null,children:(0,d.jsx)(x,{...e})})}export{m as a,_ as c,g as i,f as n,h as o,p as r,b as s,S as t};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{$i as t,Ai as n,Bn as r,Dt as i,Fn as a,Ir as o,Sa as s,Ti as c,Wn as l,Xt as u,Zt as d,_a as f,_r as p,at as m,ba as h,et as g,gi as _,mt as v,rn as y,sa as b,sn as x,xi as S}from"./vendor-2VBBgNb5.js";import"./i18n-1BkaqMgr.js";import{n as C}from"./ui-store-CS-njcmT.js";import{t as w}from"./utils-CN2sfDVP.js";import{t as T}from"./mailbox-store-DVoNbOZr.js";import{o as E}from"./view-navigation-Cgy5xh9q.js";import{s as D,t as O}from"./LazyMarkdown-BGwFjYKr.js";import{t as k}from"./empty-state-CdyXy96A.js";var A=e(s(),1),j=g(),M={note:o,ask:c,assign:u,steer:y,btw:t,broadcast:u,status:S,result:n,review:d},N={high:`border-destructive/25 bg-destructive/10 text-destructive`,normal:`border-border bg-muted text-muted-foreground`,low:`border-primary/20 bg-primary/10 text-primary`};function P(e){return new Date(e).toLocaleString()}function F(e){let t=new Date(e),n=Date.now()-t.getTime();return n<6e4?h.t(`common:time.justNow`):n<36e5?h.t(`common:time.minutesAgo`,{count:Math.round(n/6e4)}):n<864e5?h.t(`common:time.hoursAgo`,{count:Math.round(n/36e5)}):n<6048e5?h.t(`common:time.daysAgo`,{count:Math.round(n/864e5)}):t.toLocaleDateString()}function I({readBy:e}){let{t}=f(),r=Object.entries(e);return r.length===0?null:(0,j.jsxs)(`div`,{className:`space-y-1`,children:[(0,j.jsx)(`div`,{className:`text-[10px] font-semibold text-muted-foreground uppercase tracking-wide`,children:t(`activity:mailbox.readBy`)}),(0,j.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:r.map(([e,t])=>(0,j.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] bg-success/10 text-success`,title:P(t),children:[(0,j.jsx)(n,{className:`h-2.5 w-2.5`}),e]},e))})]})}function L({className:e}){let{t}=f(),o=C(e=>e.selectedMailMessage),s=C(e=>e.setSelectedMailMessage);(0,A.useEffect)(()=>()=>{s(null)},[s]);function c(){s(null),E(`chat`)}if(!o)return(0,j.jsx)(k,{icon:(0,j.jsx)(r,{className:`h-6 w-6`}),title:t(`activity:mailbox.emptyDetail`),description:t(`activity:mailbox.emptyDetailHint`)});let u=M[o.type]??a,d=t(`activity:mailbox.type.${o.type}`,{defaultValue:o.type}),h=N[o.priority]??N.normal,g=o.scope?{scope:o.scope,recipientSessionId:o.recipientSessionId}:T(o.to),y=o.to===`*`||o.to===`all`?t(`activity:mailbox.everyone`):o.to,S=g.scope===`session`?t(`activity:mailbox.sessionScope`,{sid:g.recipientSessionId??``}):g.scope===`project`?t(`activity:mailbox.projectScope`):t(`activity:mailbox.directScope`);return(0,j.jsx)(`div`,{className:w(`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-[hsl(var(--surface-2)/0.45)] p-3`,e),children:(0,j.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-border/70 bg-card/75 shadow-sm`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-border/70 px-3 py-3 sm:px-4 shrink-0`,children:[(0,j.jsx)(`button`,{type:`button`,onClick:c,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-md border border-border/70 bg-background/60 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,title:t(`activity:mailbox.backToChat`),children:(0,j.jsx)(b,{className:`h-4 w-4`})}),(0,j.jsx)(`div`,{className:w(`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg`,o.completed?`bg-success/10`:`bg-primary/10`),children:(0,j.jsx)(u,{className:w(`h-4 w-4`,o.completed?`text-success`:`text-primary`)})}),(0,j.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,j.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,j.jsx)(`h2`,{className:`text-sm font-semibold text-foreground truncate`,children:o.subject}),o.completed&&(0,j.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 rounded-md border border-success/25 bg-success/8 px-1.5 py-0.5 text-[10px] font-semibold text-success`,children:[(0,j.jsx)(n,{className:`h-3 w-3`}),t(`activity:mailbox.completed`)]}),(0,j.jsx)(`span`,{className:w(`rounded-md border px-1.5 py-0.5 text-[10px] font-semibold uppercase`,h),children:o.priority||`normal`}),o.audience===`leaders`&&(0,j.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-primary/25 bg-primary/10 px-1.5 py-0.5 text-[10px] font-semibold text-primary`,children:[(0,j.jsx)(l,{className:`h-2.5 w-2.5`}),` `,t(`activity:mailbox.audienceLeaders`)]})]}),(0,j.jsxs)(`div`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-2 text-[11px] text-muted-foreground`,children:[(0,j.jsx)(`span`,{className:`min-w-0 truncate font-medium text-foreground/80`,children:o.from}),(0,j.jsx)(`span`,{children:`→`}),(0,j.jsx)(`span`,{className:`min-w-0 truncate`,children:y}),g.scope===`session`&&(0,j.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-semibold bg-warning/12 text-warning`,title:t(`activity:mailbox.sessionScopeTitle`,{sid:g.recipientSessionId??``}),children:[(0,j.jsx)(l,{className:`h-2.5 w-2.5`}),t(`activity:mailbox.sessionLabel`)]}),g.scope===`project`&&(0,j.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-semibold bg-primary/12 text-primary`,children:[(0,j.jsx)(p,{className:`h-2.5 w-2.5`}),t(`activity:mailbox.projectLabel`)]}),(0,j.jsx)(`span`,{className:`opacity-40`,children:`•`}),(0,j.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,j.jsx)(_,{className:`h-3 w-3`}),F(o.timestamp)]})]})]}),(0,j.jsx)(`button`,{type:`button`,onClick:c,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,title:t(`activity:mailbox.closeTitle`),children:(0,j.jsx)(m,{className:`h-4 w-4`})})]}),(0,j.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,j.jsx)(`div`,{className:`mx-auto w-full max-w-4xl px-4 py-5`,children:(0,j.jsx)(`div`,{className:`markdown-content prose prose-sm dark:prose-invert max-w-none text-sm leading-relaxed`,children:(0,j.jsx)(O,{components:D,children:o.body})})})}),(0,j.jsxs)(`div`,{className:`border-t border-border/70 bg-muted/20 px-4 py-3 shrink-0`,children:[(0,j.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-x-6 gap-y-2 text-xs`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,j.jsx)(i,{className:`h-3 w-3 shrink-0`}),(0,j.jsx)(`span`,{children:d})]}),(0,j.jsx)(`div`,{className:`flex items-center gap-1.5`,children:(0,j.jsx)(`span`,{className:w(`rounded border px-1.5 py-0.5 text-[10px] font-semibold uppercase`,h),children:o.priority||`normal`})}),(0,j.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,j.jsx)(v,{className:`h-3 w-3 shrink-0`}),(0,j.jsx)(`span`,{className:`truncate`,title:o.from,children:o.from})]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[g.scope===`session`?(0,j.jsx)(l,{className:`h-3 w-3 shrink-0 text-warning`}):(0,j.jsx)(p,{className:`h-3 w-3 shrink-0 text-primary`}),(0,j.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wide shrink-0`,children:t(`activity:mailbox.scopeLabel`)}),(0,j.jsx)(`span`,{className:`truncate`,children:S})]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,j.jsx)(_,{className:`h-3 w-3 shrink-0`}),(0,j.jsx)(`span`,{children:P(o.timestamp)})]}),o.replyTo&&(0,j.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground col-span-2`,children:[(0,j.jsx)(x,{className:`h-3 w-3 shrink-0`}),(0,j.jsx)(`span`,{className:`truncate`,children:t(`activity:mailbox.replyTo`,{id:o.replyTo})})]}),o.completed&&o.completedBy&&(0,j.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground col-span-2`,children:[(0,j.jsx)(n,{className:`h-3 w-3 shrink-0 text-success`}),(0,j.jsx)(`span`,{children:o.completedAt?t(`activity:mailbox.completedByAt`,{name:o.completedBy,time:P(o.completedAt)}):t(`activity:mailbox.completedBy`,{name:o.completedBy})})]}),o.outcome&&(0,j.jsxs)(`div`,{className:`flex items-start gap-1.5 text-muted-foreground col-span-2 sm:col-span-4`,children:[(0,j.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wide shrink-0 mt-0.5`,children:t(`activity:mailbox.outcome`)}),(0,j.jsx)(`span`,{children:o.outcome})]}),o.taskContext&&(0,j.jsxs)(`div`,{className:`flex items-start gap-1.5 text-muted-foreground col-span-2 sm:col-span-4`,children:[(0,j.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wide shrink-0 mt-0.5`,children:t(`activity:mailbox.task`)}),(0,j.jsx)(`span`,{children:o.taskContext})]})]}),Object.keys(o.readBy??{}).length>0&&(0,j.jsx)(`div`,{className:`mt-3 pt-3 border-t border-border/50`,children:(0,j.jsx)(I,{readBy:o.readBy})})]})]})})}export{L as MailboxDetailView};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{$n as t,Ct as n,Dt as r,Ii as i,Ir as a,It as o,Ki as s,Kn as c,Kr as l,Nt as u,On as d,Qi as f,Qr as p,Ri as m,Sa as h,Si as g,Sn as _,Tr as v,Ut as y,Xr as b,Yr as x,Zt as ee,_ as S,_n as C,a as w,at as T,br as E,bt as D,cn as te,en as O,et as ne,f as re,fa as ie,hn as k,i as ae,ii as oe,ki as se,n as ce,pn as A,r as le,s as j,sa as ue,vi as de,vr as fe,xn as pe,zi as me}from"./vendor-2VBBgNb5.js";import{n as he}from"./ui-store-CS-njcmT.js";import{t as ge}from"./useWebSocket-Dh3aAFDE.js";import{t as M}from"./ws-client-WVGn8ORh.js";import{t as N}from"./utils-CN2sfDVP.js";import{M as _e}from"./stores-mpa0202y.js";import{a as ve,i as ye,n as be,o as xe,r as P,t as F}from"./dialog-CT1PTjzK.js";import{t as I}from"./button-uGqXvobk.js";import{t as L}from"./input-B-VCX2sG.js";import{b as Se,f as Ce,p as we}from"./index-BPfIz78e.js";import{t as Te}from"./roster-ws-DXm0krqH.js";import{_ as Ee,a as De,b as Oe,c as ke,d as Ae,f as je,g as R,h as Me,i as z,l as B,m as V,n as Ne,o as Pe,p as Fe,r as H,s as Ie,t as Le,u as Re,v as ze,y as U}from"./shared-jvJxtKc5.js";var W=e(h(),1),G=ne(),Be=212,Ve=188;function He(e){return e.length>14?`${e.slice(0,11)}…`:e}function Ue(e,t=58){let n=e.replace(/\s+/g,` `).trim();return n.length>t?`${n.slice(0,t-1)}…`:n}function We(e){return e.type===`symbol`?[e.path,e.symbol?`#${e.symbol}`:``].filter(Boolean).join(``):e.path??e.command??e.symbol??e.role??e.type}function Ge(e){return e===`active`?`border-success/45 bg-success/10 text-success`:e===`stale`?`border-warning/45 bg-warning/10 text-warning`:e===`contradicted`?`border-destructive/45 bg-destructive/10 text-destructive`:e===`superseded`?`border-warning/35 bg-warning/5 text-warning`:`border-border bg-muted/55 text-muted-foreground`}function Ke({data:e}){let{entry:t,center:n}=e;return(0,G.jsxs)(`div`,{className:n?`border border-primary/70 bg-card px-3 py-2.5 text-card-foreground shadow-[0_0_0_1px_hsl(var(--primary)/0.2),0_0_24px_hsl(var(--primary)/0.12)]`:`border border-border/80 bg-card/95 px-3 py-2.5 text-card-foreground shadow-lg`,style:{width:Be},title:t.text,children:[(0,G.jsx)(j,{type:`target`,position:S.Top,className:`!border-background !bg-muted-foreground`}),(0,G.jsx)(j,{type:`source`,position:S.Bottom,className:`!border-background !bg-primary`}),(0,G.jsx)(j,{type:`source`,position:S.Right,className:`!border-background !bg-primary`}),(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`border px-1.5 py-0.5 text-[9px] font-bold uppercase ${Ge(t.status)}`,children:t.status}),(0,G.jsx)(`span`,{className:`ml-auto truncate font-mono text-[9px] text-muted-foreground`,children:He(t.id)})]}),(0,G.jsx)(`p`,{className:`mt-2 line-clamp-2 text-[11px] leading-4 text-foreground/90`,children:Ue(t.text)}),(0,G.jsx)(`p`,{className:`mt-1 font-mono text-[9px] uppercase text-muted-foreground`,children:t.kind})]})}function qe({data:e}){return(0,G.jsxs)(`div`,{className:`border border-info/40 bg-info/8 px-2.5 py-2 text-card-foreground shadow-lg`,style:{width:Ve},title:e.label,children:[(0,G.jsx)(j,{type:`target`,position:S.Left,className:`!border-background !bg-info`}),(0,G.jsx)(`p`,{className:`font-mono text-[9px] font-bold uppercase text-info`,children:e.anchor.type}),(0,G.jsx)(`p`,{className:`mt-1 truncate font-mono text-[10px] text-foreground/85`,children:e.label})]})}var Je={memoryNode:Ke,anchorNode:qe};function Ye(e){return{id:e,revision:0,scope:`project`,kind:`fact`,status:`deleted`,text:`Memory is unavailable or has been removed.`,importance:0,confidence:0,freshness:0,tags:[],anchors:[],createdAt:``,updatedAt:``}}function Xe({nodes:e,edges:t,className:n}){return(0,G.jsx)(`div`,{className:N(`w-full`,n),children:(0,G.jsxs)(re,{nodes:e,edges:t,nodeTypes:Je,fitView:!0,fitViewOptions:{padding:.24,maxZoom:1.05},minZoom:.4,maxZoom:1.5,nodesConnectable:!1,elementsSelectable:!1,panOnScroll:!1,zoomOnScroll:!1,proOptions:{hideAttribution:!0},children:[(0,G.jsx)(le,{variant:ae.Dots,gap:18,size:1,color:`hsl(var(--muted-foreground) / 0.18)`}),(0,G.jsx)(w,{showInteractive:!1,className:`!border-border !bg-card !shadow-lg`})]})})}function K({centerMemory:e,allMemories:t,graphEdges:n,loading:r=!1,error:i=null}){let[a,o]=(0,W.useState)(!1),s=`mem:${e.id}`,c=(0,W.useMemo)(()=>n.filter(e=>e.from===s&&e.to.startsWith(`mem:`)||e.to===s&&e.from.startsWith(`mem:`)).slice(0,24),[s,n]),{nodes:l,edges:u}=(0,W.useMemo)(()=>{let n=[],r=[],i=new Map(t.map(e=>[e.id,e]));n.push({id:e.id,type:`memoryNode`,position:{x:320-Be/2,y:120},data:{entry:e,center:!0}});let a=[...e.supersededBy?[{id:e.supersededBy,relation:`superseded by`}]:[],...(e.supersedes??[]).map(e=>({id:e,relation:`supersedes`})),...(e.contradicts??[]).map(e=>({id:e,relation:`contradicts`}))];for(let e of c){let t=(e.from===s?e.to:e.from).slice(4);a.some(n=>n.id===t&&n.relation===e.relation)||a.push({id:t,relation:e.relation,weight:e.weight,evidence:e.evidence})}let o=320-(a.length-1)*220/2;return a.forEach((t,a)=>{let s=i.get(t.id)??Ye(t.id),c=t.relation===`superseded by`,l=c?0:280+Math.floor(a/3)*130,u=c?320-Be/2:o+a*220-Be/2;n.push({id:`memory:${t.id}:${a}`,type:`memoryNode`,position:{x:u,y:l},data:{entry:s,center:!1}});let d=t.relation===`contradicts`,f=c?`memory:${t.id}:${a}`:e.id,p=c?e.id:`memory:${t.id}:${a}`;r.push({id:`relation:${t.relation}:${t.id}:${a}`,source:f,target:p,type:`smoothstep`,animated:!d,label:t.weight===void 0?t.relation:`${t.relation} ${t.weight.toFixed(2)}`,data:{evidence:t.evidence??[]},style:{stroke:d?`hsl(var(--destructive))`:`hsl(var(--primary))`,strokeWidth:1.7,...d?{strokeDasharray:`5 4`}:{}},labelStyle:{fill:d?`hsl(var(--destructive))`:`hsl(var(--muted-foreground))`,fontSize:9,fontWeight:700},labelBgStyle:{fill:`hsl(var(--card))`,fillOpacity:.9}})}),e.anchors.forEach((t,i)=>{let a=`anchor:${i}`;n.push({id:a,type:`anchorNode`,position:{x:540,y:120+(i-(e.anchors.length-1)/2)*66},data:{anchor:t,label:We(t)}}),r.push({id:`anchor-edge:${i}`,source:e.id,target:a,type:`smoothstep`,style:{stroke:`hsl(var(--info))`,strokeWidth:1.3}})}),{nodes:n,edges:r}},[t,e,s,c]);return l.length<=1&&!r&&!i?null:(0,G.jsxs)(`section`,{className:`overflow-hidden border border-border/75 bg-background/35`,"aria-label":`Memory relationship graph`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/70 bg-card/55 px-3 py-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`p`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-muted-foreground`,children:`Relationship map`}),l.length>1&&(0,G.jsxs)(I,{variant:`ghost`,size:`sm`,onClick:()=>o(!0),className:`h-6 gap-1 px-2 text-[9px] font-bold uppercase tracking-[0.12em]`,"aria-label":`Open full screen graph`,children:[(0,G.jsx)(p,{className:`size-3`}),`Open full screen`]})]}),(0,G.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:r?`loading real graph…`:`${l.length} nodes · ${u.length} edges`})]}),i&&(0,G.jsx)(`p`,{className:`border-b border-destructive/25 bg-destructive/5 px-3 py-2 text-[10px] text-destructive`,children:i}),l.length>1&&(0,G.jsx)(Xe,{nodes:l,edges:u,className:`h-[320px]`}),c.some(e=>e.evidence?.length)&&(0,G.jsx)(`div`,{className:`grid gap-1 border-t border-border/70 bg-card/35 px-3 py-2`,children:c.filter(e=>e.evidence?.length).slice(0,12).map(e=>{let t=(e.from===s?e.to:e.from).slice(4);return(0,G.jsxs)(`p`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:[(0,G.jsx)(`span`,{className:`text-info`,children:e.relation}),` `,He(t),` · why:`,` `,e.evidence?.join(`, `)]},e.id)})}),a&&(0,G.jsx)(F,{open:a,onOpenChange:o,children:(0,G.jsxs)(be,{className:`flex max-h-[90dvh] max-w-[90vw] flex-col p-0`,showCloseButton:!1,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/70 bg-card/55 px-4 py-3`,children:[(0,G.jsxs)(`p`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-muted-foreground`,children:[`Relationship map — `,e.id]}),(0,G.jsx)(I,{variant:`ghost`,size:`sm`,onClick:()=>o(!1),className:`h-7 gap-1 px-2 text-[10px]`,children:`Close`})]}),(0,G.jsx)(`div`,{className:`min-h-0 flex-1 px-4 pb-4`,children:(0,G.jsx)(Xe,{nodes:l,edges:u,className:`h-[65vh]`})})]})})]})}function Ze({memory:e,allMemories:t,relatedMemories:r,graphEdges:i,graphLoading:a,graphError:o,onClose:c,onOpenMemory:l,onEdit:u,onDelete:d,onTagSelect:f,onNotice:p}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-border/70 bg-card/65 px-4 py-3 backdrop-blur-xl`,children:[(0,G.jsx)(I,{variant:`ghost`,size:`icon`,className:`md:hidden`,onClick:c,"aria-label":`Back to memory list`,children:(0,G.jsx)(ue,{className:`size-4`})}),(0,G.jsx)(`span`,{className:N(`text-[10px] font-bold uppercase tracking-[0.14em]`,Me(e.kind)),children:H[e.kind]??e.kind}),(0,G.jsx)(B,{status:e.status}),(0,G.jsx)(`span`,{className:`border border-border/70 px-2 py-0.5 font-mono text-[9px] uppercase text-muted-foreground`,children:e.scope}),e.audience&&(0,G.jsxs)(`span`,{className:`flex items-center gap-1 border border-primary/30 bg-primary/10 px-2 py-0.5 font-mono text-[9px] text-primary`,title:Fe(e.audience),children:[(0,G.jsx)(s,{className:`size-3`}),Fe(e.audience)]}),(0,G.jsxs)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:[(0,G.jsx)(I,{variant:`ghost`,size:`icon`,"aria-label":`Copy memory ID`,title:`Copy memory ID`,onClick:()=>{navigator.clipboard?.writeText(e.id),p(`Memory ID copied.`)},children:(0,G.jsx)(de,{className:`size-4`})}),(0,G.jsxs)(I,{variant:`outline`,size:`sm`,onClick:u,disabled:e.status===`deleted`,children:[(0,G.jsx)(C,{className:`size-3.5`}),` Edit`]}),(0,G.jsxs)(I,{variant:`destructive`,size:`sm`,onClick:d,disabled:e.status===`deleted`,children:[(0,G.jsx)(n,{className:`size-3.5`}),` Delete`]})]})]}),(0,G.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-4 md:p-5`,children:(0,G.jsxs)(`div`,{className:`mx-auto max-w-5xl space-y-5`,children:[(0,G.jsx)(Qe,{memory:e}),(0,G.jsx)(q,{memory:e}),e.tags.length>0&&(0,G.jsx)($e,{tags:e.tags,onTagSelect:f}),e.anchors.length>0&&(0,G.jsx)(J,{anchors:e.anchors}),r.length>0&&(0,G.jsx)(et,{relatedMemories:r,allMemories:t,onOpenMemory:l}),(0,G.jsx)(K,{centerMemory:e,allMemories:t,graphEdges:i,loading:a,error:o}),(0,G.jsx)(Y,{memory:e}),e.status===`deleted`&&(0,G.jsx)(tt,{contextPolicy:e.contextPolicy})]})})]})}function Qe({memory:e}){return(0,G.jsxs)(`div`,{className:`relative overflow-hidden border border-border/75 bg-card/55 p-5 shadow-[inset_0_1px_0_hsl(var(--foreground)/0.04)]`,children:[(0,G.jsx)(`div`,{className:`pointer-events-none absolute -right-10 -top-10 size-36 bg-[radial-gradient(circle,hsl(var(--info)/0.13),transparent_68%)]`}),(0,G.jsx)(`p`,{className:`relative whitespace-pre-wrap text-sm leading-7 text-foreground md:text-[15px]`,children:e.text}),e.summary&&(0,G.jsx)(`p`,{className:`relative mt-4 border-l-2 border-info/50 pl-3 text-xs italic leading-5 text-muted-foreground`,children:e.summary}),(0,G.jsxs)(`div`,{className:`relative mt-5 flex flex-wrap items-center gap-2 border-t border-border/60 pt-3`,children:[(0,G.jsx)(`code`,{className:`min-w-0 break-all font-mono text-[10px] text-muted-foreground`,children:e.id}),(0,G.jsxs)(`span`,{className:`ml-auto font-mono text-[10px] text-muted-foreground`,children:[`revision `,e.revision]})]})]})}function q({memory:e}){return(0,G.jsx)(`div`,{className:`grid gap-px bg-border/60 sm:grid-cols-3`,children:[[`Importance`,e.importance,y],[`Confidence`,e.confidence,se],[`Freshness`,e.freshness,te]].map(([e,t,n])=>(0,G.jsxs)(`div`,{className:`bg-card/60 p-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(n,{className:`size-3.5 text-info`}),(0,G.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-[0.13em] text-muted-foreground`,children:e}),(0,G.jsxs)(`span`,{className:`ml-auto font-mono text-xs font-bold tabular-nums`,children:[Math.round(t*100),`%`]})]}),(0,G.jsx)(`div`,{className:`mt-2 h-1 bg-muted`,children:(0,G.jsx)(`div`,{className:`h-full bg-info shadow-[0_0_8px_hsl(var(--info)/0.45)]`,style:{width:`${Math.round(t*100)}%`}})})]},e))})}function $e({tags:e,onTagSelect:t}){return(0,G.jsxs)(`section`,{children:[(0,G.jsxs)(`h3`,{className:`mb-2 flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:[(0,G.jsx)(r,{className:`size-3.5 text-info`}),` Tags`]}),(0,G.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.map(e=>(0,G.jsxs)(`button`,{type:`button`,onClick:()=>t(e),className:`border border-info/25 bg-info/5 px-2 py-1 font-mono text-[10px] text-info hover:border-info/55 hover:bg-info/10`,children:[`#`,e]},e))})]})}function J({anchors:e}){return(0,G.jsxs)(`section`,{className:`border border-border/75 bg-card/40`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/65 px-3 py-2.5`,children:[(0,G.jsxs)(`h3`,{className:`flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:[(0,G.jsx)(l,{className:`size-3.5 text-info`}),` Anchors`]}),(0,G.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:e.length})]}),(0,G.jsx)(`ul`,{className:`divide-y divide-border/55`,children:e.map((e,t)=>(0,G.jsxs)(`li`,{className:`flex min-w-0 items-start gap-3 px-3 py-2.5`,children:[(0,G.jsx)(`span`,{className:`mt-0.5 flex size-7 shrink-0 items-center justify-center border border-info/25 bg-info/5 text-info`,children:e.type===`command`?(0,G.jsx)(u,{className:`size-3.5`}):(0,G.jsx)(l,{className:`size-3.5`})}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`p`,{className:`text-[9px] font-bold uppercase text-muted-foreground`,children:e.type}),(0,G.jsxs)(`p`,{className:`mt-0.5 break-all font-mono text-[10px] leading-4 text-foreground/85`,children:[e.path??e.command??e.role??`—`,e.symbol?`#${e.symbol}`:``]})]}),(e.lineStart||e.lineEnd)&&(0,G.jsxs)(`span`,{className:`ml-auto shrink-0 font-mono text-[9px] text-muted-foreground`,children:[`L`,e.lineStart??`?`,`–`,e.lineEnd??`?`]})]},`${e.type}:${e.path??e.command??e.symbol??e.role}:${t}`))})]})}function et({relatedMemories:e,allMemories:t,onOpenMemory:n}){return(0,G.jsxs)(`section`,{className:`border border-border/75 bg-card/40`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/65 px-3 py-2.5`,children:[(0,G.jsxs)(`h3`,{className:`flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:[(0,G.jsx)(E,{className:`size-3.5 text-info`}),` Memory relationships`]}),(0,G.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:e.length})]}),(0,G.jsx)(`ul`,{className:`divide-y divide-border/55`,children:e.map(e=>{let r=t.find(t=>t.id===e.id);return(0,G.jsx)(`li`,{children:(0,G.jsxs)(`button`,{type:`button`,disabled:!r,onClick:()=>r&&n(r.id),className:`group flex w-full min-w-0 items-center gap-3 px-3 py-2.5 text-left hover:bg-info/5 disabled:cursor-not-allowed disabled:opacity-55`,children:[(0,G.jsx)(`span`,{className:N(`w-24 shrink-0 text-[9px] font-bold uppercase`,e.relation===`Contradicts`?`text-destructive`:`text-info`),children:e.relation}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs`,children:r?R(r.text,95):`Referenced memory is unavailable`}),(0,G.jsx)(`code`,{className:`hidden max-w-32 truncate font-mono text-[9px] text-muted-foreground sm:block`,children:e.id}),r&&(0,G.jsx)(i,{className:`size-3.5 shrink-0 text-muted-foreground group-hover:text-info`})]})},`${e.relation}:${e.id}`)})})]})}function Y({memory:e}){return(0,G.jsx)(`section`,{className:`grid gap-px bg-border/60 sm:grid-cols-2 lg:grid-cols-4`,children:[[`Created`,V(e.createdAt),f],[`Updated`,V(e.updatedAt),te],[`Last accessed`,V(e.lastAccessedAt),d],[`Last verified`,V(e.lastVerifiedAt),y]].map(([e,t,n])=>(0,G.jsxs)(`div`,{className:`bg-card/50 p-3`,children:[(0,G.jsx)(n,{className:`size-3.5 text-muted-foreground`}),(0,G.jsx)(`p`,{className:`mt-2 text-[9px] font-bold uppercase tracking-[0.12em] text-muted-foreground`,children:e}),(0,G.jsx)(`p`,{className:`mt-1 text-[10px] leading-4 text-foreground/85`,children:t})]},e))})}function tt({contextPolicy:e}){return(0,G.jsxs)(`div`,{className:`flex items-start gap-3 border border-border bg-muted/50 p-4 text-xs text-muted-foreground`,children:[(0,G.jsx)(ie,{className:`mt-0.5 size-4 shrink-0`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`font-bold text-foreground`,children:`Deleted memory`}),(0,G.jsx)(`p`,{className:`mt-1 leading-5`,children:e===`never`?`This record is audit-only and carries an absolute ban: it can never enter LLM context.`:`The record is inactive and cannot be edited, but remains eligible as historical evidence when retrieval finds it relevant.`})]})]})}var X={filePath:``,primaryMatches:[],symbolMatches:[],relatedMatches:[],totalCount:0,activeCount:0,supersededCount:0,reviewPendingCount:0};function nt(e){let{filePath:t,lineStart:n,lineEnd:r,limit:i=50,showSuperseded:a=!0,showDeleted:o=!1,autoFetch:s=!0,sendOptions:c}=e,l=c?JSON.stringify(c):``,[u,d]=(0,W.useState)(null),[f,p]=(0,W.useState)(!1),[m,h]=(0,W.useState)(null),g=(0,W.useRef)(0),_=(0,W.useRef)(null),v=(0,W.useRef)(c);v.current=c;let y=(0,W.useCallback)(()=>{if(!t){d(null),h(null),p(!1);return}let e=++g.current;p(!0),h(null);let s=M();if(!s){h(`WebSocket client unavailable`),p(!1);return}_.current?.(),_.current=null;let c=t,l=s.on(`memory.sage.forFile`,t=>{if(e!==g.current)return;let n=t.payload.response;n&&n.filePath!==c||(t.payload.error?(h(t.payload.error),d(null)):(d(n??X),h(null)),p(!1))});_.current=l;let u={filePath:t,limit:i,showSuperseded:a,showDeleted:o,...n===void 0?{}:{lineStart:n},...r===void 0?{}:{lineEnd:r}};try{s.findMemoriesForFile(u,v.current??void 0)}catch(t){l(),_.current===l&&(_.current=null),e===g.current&&(h(t instanceof Error?t.message:String(t)),p(!1))}},[t,n,r,i,a,o]);(0,W.useEffect)(()=>{if(s)return y(),()=>{g.current++,_.current?.(),_.current=null}},[s,y,l]);let b=(0,W.useCallback)(()=>{y()},[y]);return(0,W.useEffect)(()=>()=>{_.current?.(),_.current=null},[]),{data:u,loading:f,error:m,refetch:b}}function rt(e){return e>=.9?`bg-success/15 border-success/40`:e>=.7?`bg-info/15 border-info/40`:e>=.4?`bg-warning/10 border-warning/30`:`bg-muted/30 border-border/40`}function Z(e){switch(e){case`scope_file`:return`scope: file`;case`scope_symbol`:return`scope: symbol`;case`anchor_file`:return`anchor: file`;case`anchor_symbol`:return`anchor: symbol`;case`anchor_directory`:return`anchor: directory`;case`mention`:return`text mention`}}function it({match:e,cursorBoosted:t,onShowMemory:n,onAcceptDeletion:r,onKeep:i,onUpdate:a,onMarkPermanent:s,onRecover:l,pendingAction:u}){let d=e.memory.status===`deleted`,f=e.memory.status===`superseded`,p=e.pendingReview,m=u!==void 0,h=t===!0;return(0,G.jsxs)(`article`,{className:N(`group relative rounded-md border px-3 py-2 text-sm transition-colors`,rt(e.matchStrength),h&&`ring-1 ring-primary/40 ring-offset-0`,d&&`opacity-70`),"data-match-via":e.matchedVia,"data-memory-id":e.memory.id,children:[(0,G.jsx)(`header`,{className:`flex items-start justify-between gap-2`,children:(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] uppercase tracking-wide`,children:[(0,G.jsx)(`span`,{className:N(`font-mono`,Me(e.memory.kind)),children:H[e.memory.kind]??e.memory.kind}),(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`·`}),(0,G.jsx)(`span`,{className:`font-mono text-muted-foreground`,children:Z(e.matchedVia)}),h&&(0,G.jsxs)(`span`,{className:`flex items-center gap-0.5 rounded-sm bg-primary/15 px-1 py-0.5 font-mono text-primary`,title:`Cursor line range matches this memory's anchor`,children:[(0,G.jsx)(k,{className:`size-2.5`}),` cursor`]}),p&&(0,G.jsxs)(`span`,{className:`flex items-center gap-0.5 rounded-sm bg-warning/15 px-1 py-0.5 font-mono text-warning`,title:`Hygiene review: ${p.reason} (${p.ageDays}d old)`,children:[(0,G.jsx)(D,{className:`size-2.5`}),` review`]}),d&&(0,G.jsx)(`span`,{className:`font-mono text-destructive`,children:`deleted`}),f&&!d&&(0,G.jsx)(`span`,{className:`font-mono text-muted-foreground`,children:`superseded`})]}),(0,G.jsx)(`p`,{className:`mt-1 text-foreground/90`,children:R(e.memory.text,200)}),(0,G.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 text-[10px] text-muted-foreground`,children:[(0,G.jsx)(B,{status:e.memory.status}),(0,G.jsxs)(`span`,{children:[`updated `,ze(e.memory.updatedAt)]})]})]})}),(0,G.jsxs)(`footer`,{className:`mt-2 flex flex-wrap items-center gap-1.5`,children:[d&&l&&(0,G.jsxs)(I,{type:`button`,size:`sm`,variant:`outline`,disabled:m,onClick:()=>l(e.memory.id),className:`h-7 gap-1 border-primary/40 px-2 text-[11px] text-primary hover:bg-primary/10`,title:`Restore this memory to active status (PR #1: memory_recover)`,children:[(0,G.jsx)(te,{className:`size-3`}),` Recover`]}),f&&e.supersededByActiveId&&n&&(0,G.jsxs)(I,{type:`button`,size:`sm`,variant:`outline`,disabled:m,onClick:()=>n(e.supersededByActiveId),className:`h-7 gap-1 px-2 text-[11px]`,title:`This version is superseded — jump to the active version`,children:[(0,G.jsx)(fe,{className:`size-3`}),` Go to active`]}),p&&(0,G.jsxs)(G.Fragment,{children:[p.suggestedAction===`delete`&&(0,G.jsxs)(I,{type:`button`,size:`sm`,variant:`destructive`,disabled:m,onClick:()=>r?.(p.candidateId,e.memory.id),className:`h-7 gap-1 px-2 text-[11px]`,title:`Accept hygiene's deletion suggestion — memory will be forgotten`,children:[(0,G.jsx)(me,{className:`size-3`}),` Accept Deletion`]}),(0,G.jsxs)(I,{type:`button`,size:`sm`,variant:`outline`,disabled:m,onClick:()=>i?.(p.candidateId,e.memory.id),className:`h-7 gap-1 px-2 text-[11px]`,title:`Reject the suggestion — memory stays as-is and may be re-suggested later`,children:[(0,G.jsx)(T,{className:`size-3`}),` Keep`]}),(0,G.jsxs)(I,{type:`button`,size:`sm`,variant:`outline`,disabled:m,onClick:()=>a?.(e.memory.id),className:`h-7 gap-1 px-2 text-[11px]`,title:`Update the memory's content — versioning creates a new active record`,children:[(0,G.jsx)(o,{className:`size-3`}),` Update`]}),s&&(0,G.jsxs)(I,{type:`button`,size:`sm`,variant:`outline`,disabled:m,onClick:()=>s(e.memory.id),className:`h-7 gap-1 border-warning/40 px-2 text-[11px] text-warning hover:bg-warning/10`,title:"Promote to `permanent` — hygiene will never surface this again",children:[(0,G.jsx)(k,{className:`size-3`}),` Mark as Permanent`]})]}),n&&!d&&(0,G.jsxs)(I,{type:`button`,size:`sm`,variant:`ghost`,disabled:m,onClick:()=>n(e.memory.id),className:`h-7 gap-1 px-2 text-[11px] text-muted-foreground hover:text-foreground`,title:`Open the full record in MemoryManager`,children:[(0,G.jsx)(x,{className:`size-3`}),` Show full`]}),u&&(0,G.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 text-[10px] text-muted-foreground`,children:[(0,G.jsx)(c,{className:`size-3 animate-spin`}),` `,u]})]})]})}function at({icon:e,title:t,count:n,matches:r,cursorBoosted:i=!1,...a}){let o=we(r,10);return r.length===0?null:(0,G.jsxs)(`section`,{className:`flex flex-col gap-1.5`,children:[(0,G.jsxs)(`h3`,{className:`flex items-center gap-1.5 px-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[(0,G.jsx)(e,{className:`size-3`}),(0,G.jsx)(`span`,{children:t}),(0,G.jsxs)(`span`,{className:`font-mono`,children:[`(`,n,`)`]}),i&&(0,G.jsxs)(`span`,{className:`ml-auto flex items-center gap-0.5 font-mono text-[9px] text-primary`,children:[(0,G.jsx)(k,{className:`size-2.5`}),` cursor boost`]})]}),(0,G.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:o.pageItems.map(e=>(0,G.jsx)(it,{match:e,cursorBoosted:i&&(e.matchedVia===`anchor_symbol`||e.matchedVia===`scope_symbol`),pendingAction:a.pendingActionById.get(e.memory.id),...a},e.memory.id))}),(0,G.jsx)(Ce,{page:o.page,pageSize:o.pageSize,totalItems:o.totalItems,onPageChange:o.setPage,compact:!0,itemLabel:`memories`})]})}function ot({filePath:e,lineStart:t,lineEnd:n,open:r,onClose:i,onShowMemory:o,onAcceptDeletion:s,onKeep:c,onUpdate:l,onMarkPermanent:u,onRecover:d}){let[f,p]=(0,W.useState)(!1),[m,h]=(0,W.useState)(new Map),{data:_,loading:v,error:y,refetch:ee}=nt({filePath:e,lineStart:t,lineEnd:n,showDeleted:f,autoFetch:r}),S=t!==void 0&&n!==void 0,C=(0,W.useCallback)(async(e,t,n)=>{if(n){h(n=>new Map(n).set(e,t));try{await n(e)}finally{h(t=>{let n=new Map(t);return n.delete(e),n})}}},[]);if((0,W.useEffect)(()=>{p(!1)},[e]),!r)return null;let w=_,T=w?.totalCount??0;return(0,G.jsxs)(`aside`,{className:`flex h-full min-h-0 w-full flex-col border-l border-border/70 bg-card/15`,"aria-label":`File memory drawer`,"data-file-path":e??``,children:[(0,G.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-border/60 px-3 py-2`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] uppercase tracking-wide text-muted-foreground`,children:[(0,G.jsx)(a,{className:`size-3`}),(0,G.jsx)(`span`,{className:`truncate font-mono`,title:e??``,children:e??`(no file)`})]}),(0,G.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-2 text-[10px] text-muted-foreground`,children:[(0,G.jsxs)(`span`,{className:`font-mono`,children:[T,` memories`]}),w&&w.reviewPendingCount>0&&(0,G.jsxs)(`span`,{className:`flex items-center gap-0.5 font-mono text-warning`,children:[(0,G.jsx)(D,{className:`size-3`}),w.reviewPendingCount,` pending review`]}),w&&w.supersededCount>0&&(0,G.jsxs)(`span`,{className:`font-mono`,children:[w.supersededCount,` superseded`]})]})]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,G.jsx)(I,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>ee(),disabled:v||!e,className:`h-7 w-7 p-0`,"aria-label":`Refresh`,title:`Re-query for this file`,children:(0,G.jsx)(te,{className:N(`size-3.5`,v&&`animate-spin`)})}),(0,G.jsx)(I,{type:`button`,size:`sm`,variant:`ghost`,onClick:i,className:`h-7 w-7 p-0`,"aria-label":`Close drawer`,title:`Close memory drawer`,children:(0,G.jsx)(g,{className:`size-3.5`})})]})]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-border/40 bg-background/40 px-3 py-1.5 text-[10px] text-muted-foreground`,children:[(0,G.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:f,onChange:e=>p(e.target.checked),className:`size-3 accent-primary`,disabled:!e,"data-testid":`memory-drawer-show-deleted`}),f?(0,G.jsx)(x,{className:`size-3`}):(0,G.jsx)(b,{className:`size-3`}),(0,G.jsx)(`span`,{children:`Show recoverable (deleted)`})]}),S&&(0,G.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 font-mono text-[10px] text-primary`,children:[(0,G.jsx)(k,{className:`size-3`}),` lines `,t,`–`,n]})]}),(0,G.jsx)(`div`,{className:`flex-1 overflow-y-auto px-3 py-3`,children:e?v&&!w?(0,G.jsx)(Q,{loading:!0,message:`Loading memories…`}):y?(0,G.jsx)(Q,{tone:`error`,message:`Error: ${y}`}):!w||T===0?(0,G.jsx)(Q,{message:`No memories attached to ${e} yet.`}):(0,G.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,G.jsx)(at,{icon:k,title:`Cursor boost`,count:w.symbolMatches.length,cursorBoosted:S,matches:w.symbolMatches,pendingActionById:m,onShowMemory:o,onAcceptDeletion:(e,t)=>C(t,`accepting…`,()=>s?.(e,t)),onKeep:(e,t)=>C(t,`keeping…`,()=>c?.(e,t)),onUpdate:e=>C(e,`updating…`,()=>l?.(e)),onMarkPermanent:e=>C(e,`marking…`,()=>u?.(e)),onRecover:e=>C(e,`recovering…`,()=>d?.(e))}),(0,G.jsx)(at,{icon:a,title:`File-scoped`,count:w.primaryMatches.length,matches:w.primaryMatches,pendingActionById:m,onShowMemory:o,onAcceptDeletion:(e,t)=>C(t,`accepting…`,()=>s?.(e,t)),onKeep:(e,t)=>C(t,`keeping…`,()=>c?.(e,t)),onUpdate:e=>C(e,`updating…`,()=>l?.(e)),onMarkPermanent:e=>C(e,`marking…`,()=>u?.(e)),onRecover:e=>C(e,`recovering…`,()=>d?.(e))}),(0,G.jsx)(at,{icon:x,title:`Mentioned in`,count:w.relatedMatches.length,matches:w.relatedMatches,pendingActionById:m,onShowMemory:o,onAcceptDeletion:(e,t)=>C(t,`accepting…`,()=>s?.(e,t)),onKeep:(e,t)=>C(t,`keeping…`,()=>c?.(e,t)),onUpdate:e=>C(e,`updating…`,()=>l?.(e)),onMarkPermanent:e=>C(e,`marking…`,()=>u?.(e)),onRecover:e=>C(e,`recovering…`,()=>d?.(e))})]}):(0,G.jsx)(Q,{message:`Open a file to see its memories.`})})]})}function Q({message:e,loading:t=!1,tone:n=`default`}){return(0,G.jsxs)(`div`,{className:N(`flex min-h-[120px] flex-col items-center justify-center gap-2 rounded-md border border-dashed border-border/60 px-4 py-6 text-center text-[11px]`,n===`error`?`text-destructive`:`text-muted-foreground`),children:[t&&(0,G.jsx)(c,{className:`size-4 animate-spin`}),(0,G.jsx)(`p`,{children:e})]})}function st({mode:e,draft:r,busy:i,error:a,onChange:s,onCancel:l,onSubmit:u}){let d=(0,W.useRef)(null),[f,p]=(0,W.useState)([]);(0,W.useEffect)(()=>{d.current?.focus();let e=new AbortController;return Te(`agent-roster.list`,{},e.signal).then(e=>{let t=e.roles;Array.isArray(t)&&p(t.filter(e=>typeof e==`string`))}).catch(()=>void 0),()=>e.abort()},[]);let m=(e,t)=>{s({...r,[e]:t})},h=()=>{m(`anchors`,[...r.anchors,{type:`file`,path:``}])};return(0,G.jsxs)(`form`,{className:`flex min-h-0 flex-1 flex-col`,onSubmit:e=>{e.preventDefault(),u()},"aria-busy":i,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-border/70 bg-card/70 px-4 py-3 backdrop-blur-xl`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`flex size-8 items-center justify-center border border-info/35 bg-info/10 text-info`,children:e===`create`?(0,G.jsx)(o,{className:`size-4`}):(0,G.jsx)(C,{className:`size-4`})}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`p`,{className:`truncate text-sm font-bold`,children:e===`create`?`Capture a memory`:`Edit memory`}),(0,G.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:e===`create`?`Add durable knowledge with retrieval metadata.`:`Update content without losing provenance.`})]})]}),(0,G.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,G.jsxs)(I,{type:`button`,variant:`ghost`,size:`sm`,onClick:l,disabled:i,children:[(0,G.jsx)(T,{className:`size-3.5`}),` Cancel`]}),(0,G.jsxs)(I,{type:`submit`,size:`sm`,disabled:i||!r.text.trim(),children:[i?(0,G.jsx)(c,{className:`size-3.5 animate-spin`}):e===`create`?(0,G.jsx)(A,{className:`size-3.5`}):(0,G.jsx)(O,{className:`size-3.5`}),i?`Saving…`:e===`create`?`Create memory`:`Save changes`]})]})]}),(0,G.jsx)(`div`,{className:`flex-1 overflow-y-auto overscroll-contain p-4 md:p-5`,children:(0,G.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-5`,children:[a&&(0,G.jsxs)(`div`,{role:`alert`,className:`flex items-start gap-2 border border-destructive/40 bg-destructive/10 px-3 py-2.5 text-sm text-destructive`,children:[(0,G.jsx)(D,{className:`mt-0.5 size-4 shrink-0`}),(0,G.jsx)(`span`,{children:a})]}),(0,G.jsxs)(`section`,{className:`border border-border/75 bg-card/45 p-4`,children:[(0,G.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`text-xs font-bold uppercase tracking-[0.14em]`,children:`Knowledge`}),(0,G.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:`Write the durable fact or decision in complete, searchable language.`})]}),(0,G.jsxs)(`span`,{className:`font-mono text-[10px] text-muted-foreground tabular-nums`,children:[r.text.length,` chars`]})]}),(0,G.jsx)(`label`,{htmlFor:`memory-text`,className:`sr-only`,children:`Memory content`}),(0,G.jsx)(`textarea`,{ref:d,id:`memory-text`,value:r.text,onChange:e=>m(`text`,e.target.value),rows:7,required:!0,placeholder:`Example: WebUI state is owned by Zustand stores; server messages update those stores through singleton WebSocket handlers.`,className:`min-h-36 w-full resize-y border border-input bg-background/75 px-3 py-3 text-sm leading-6 text-foreground shadow-inner placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`})]}),(0,G.jsxs)(`section`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`label`,{htmlFor:`memory-kind`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Kind`}),(0,G.jsx)(`select`,{id:`memory-kind`,value:r.kind,onChange:e=>m(`kind`,e.target.value),className:`h-10 w-full border border-input bg-background px-3 text-sm`,children:z.map(e=>(0,G.jsx)(`option`,{value:e,children:H[e]},e))})]}),e===`create`?(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`label`,{htmlFor:`memory-scope`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Scope`}),(0,G.jsx)(`select`,{id:`memory-scope`,value:r.scope,onChange:e=>m(`scope`,e.target.value),className:`h-10 w-full border border-input bg-background px-3 text-sm`,children:De.map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))})]}):(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`label`,{htmlFor:`memory-status`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Lifecycle status`}),(0,G.jsx)(`select`,{id:`memory-status`,value:r.status,onChange:e=>m(`status`,e.target.value),className:`h-10 w-full border border-input bg-background px-3 text-sm`,children:Ne.map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))})]}),(0,G.jsxs)(`div`,{className:N(`min-w-0`,e===`create`?`sm:col-span-2 lg:col-span-1`:``),children:[(0,G.jsx)(`label`,{htmlFor:`memory-tags`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Tags`}),(0,G.jsx)(L,{id:`memory-tags`,value:r.tags,onChange:e=>m(`tags`,e.target.value),placeholder:`architecture, webui, workflow`,className:`h-10 bg-background`})]})]}),(0,G.jsxs)(`section`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,G.jsx)(ke,{id:`memory-importance`,label:`Importance`,value:r.importance,onChange:e=>m(`importance`,e)}),(0,G.jsx)(ke,{id:`memory-confidence`,label:`Confidence`,value:r.confidence,onChange:e=>m(`confidence`,e)}),(0,G.jsx)(ke,{id:`memory-freshness`,label:`Freshness`,value:r.freshness,onChange:e=>m(`freshness`,e)})]}),(0,G.jsxs)(`section`,{className:`border border-border/75 bg-card/45 p-4`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`text-xs font-bold uppercase tracking-[0.14em]`,children:`Anchors`}),(0,G.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:`Bind knowledge to files, symbols, packages, tests, Git paths, or commands.`})]}),(0,G.jsxs)(I,{type:`button`,variant:`outline`,size:`sm`,onClick:h,children:[(0,G.jsx)(A,{className:`size-3.5`}),` Add anchor`]})]}),r.anchors.length===0?(0,G.jsxs)(`button`,{type:`button`,onClick:h,className:`mt-4 flex w-full items-center justify-center gap-2 border border-dashed border-border px-4 py-7 text-xs text-muted-foreground transition-colors hover:border-info/50 hover:bg-info/5 hover:text-info`,children:[(0,G.jsx)(t,{className:`size-4`}),` No anchors yet — add one to improve retrieval precision`]}):(0,G.jsx)(`div`,{className:`mt-4 space-y-2`,children:r.anchors.map((e,t)=>(0,G.jsxs)(`div`,{className:`grid gap-2 border border-border/65 bg-background/40 p-2 sm:grid-cols-[9rem_minmax(0,1fr)_auto]`,children:[(0,G.jsxs)(`label`,{className:`sr-only`,htmlFor:`anchor-type-${t}`,children:[`Anchor `,t+1,` type`]}),(0,G.jsx)(`select`,{id:`anchor-type-${t}`,value:e.type,onChange:e=>{let n=e.target.value,i=n===`command`?{type:n,command:``}:n===`agent`?{type:n,role:``}:{type:n,path:``},a=r.anchors.map((e,n)=>n===t?i:e);m(`anchors`,a)},className:`h-10 border border-input bg-background px-2 text-xs`,children:Le.map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))}),(0,G.jsxs)(`div`,{className:N(`grid min-w-0 gap-2`,e.type===`symbol`&&`sm:grid-cols-[minmax(0,1fr)_11rem]`),children:[(0,G.jsxs)(`label`,{className:`sr-only`,htmlFor:`anchor-value-${t}`,children:[`Anchor `,t+1,` value`]}),(0,G.jsx)(L,{id:`anchor-value-${t}`,list:e.type===`agent`?`memory-agent-role-options`:void 0,value:Re(e),onChange:e=>{let n=r.anchors.map((n,r)=>r===t?Oe(n,e.target.value):n);m(`anchors`,n)},placeholder:e.type===`command`?`pnpm test --filter webui`:e.type===`agent`?`reviewer`:`packages/webui/src/App.tsx`,className:`h-10 min-w-0 bg-background font-mono text-xs`}),e.type===`symbol`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`label`,{className:`sr-only`,htmlFor:`anchor-symbol-${t}`,children:[`Anchor `,t+1,` symbol`]}),(0,G.jsx)(L,{id:`anchor-symbol-${t}`,value:e.symbol??``,onChange:e=>{let n=r.anchors.map((n,r)=>r===t?{...n,symbol:e.target.value}:n);m(`anchors`,n)},placeholder:`Symbol name`,className:`h-10 bg-background font-mono text-xs`})]})]}),(0,G.jsx)(I,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Remove anchor ${t+1}`,onClick:()=>m(`anchors`,r.anchors.filter((e,n)=>n!==t)),children:(0,G.jsx)(n,{className:`size-4 text-destructive`})})]},`${e.type}:${t}`))}),(0,G.jsx)(`datalist`,{id:`memory-agent-role-options`,children:f.map(e=>(0,G.jsx)(`option`,{value:e},e))})]}),(0,G.jsxs)(`section`,{className:`grid gap-3 border border-border/75 bg-card/45 p-4 sm:grid-cols-2`,children:[(0,G.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,G.jsx)(`h3`,{className:`text-xs font-bold uppercase tracking-[0.14em]`,children:`Relationships`}),(0,G.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:`Reference exact memory IDs. Relationships are validated and graph edges are rebuilt by SAGE.`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{htmlFor:`memory-supersedes`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Supersedes`}),(0,G.jsx)(L,{id:`memory-supersedes`,value:r.supersedes,onChange:e=>m(`supersedes`,e.target.value),placeholder:`mem_id, mem_id`,className:`h-10 bg-background font-mono text-xs`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{htmlFor:`memory-contradicts`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Contradicts`}),(0,G.jsx)(L,{id:`memory-contradicts`,value:r.contradicts,onChange:e=>m(`contradicts`,e.target.value),placeholder:`mem_id, mem_id`,className:`h-10 bg-background font-mono text-xs`})]})]}),(0,G.jsxs)(`section`,{className:`space-y-2`,children:[(0,G.jsx)(`h3`,{className:`text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Audience (Optional)`}),(0,G.jsx)(`p`,{className:`text-[10px] text-muted-foreground/70`,children:`Target this memory to specific agent types. Leave empty for general project memory.`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{htmlFor:`memory-audience-roles`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Roles`}),(0,G.jsx)(L,{id:`memory-audience-roles`,value:r.audienceRoles,onChange:e=>m(`audienceRoles`,e.target.value),placeholder:`reviewer, refactor-planner`,className:`h-9 bg-background font-mono text-xs`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{htmlFor:`memory-audience-task-types`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Task types`}),(0,G.jsx)(L,{id:`memory-audience-task-types`,value:r.audienceTaskTypes,onChange:e=>m(`audienceTaskTypes`,e.target.value),placeholder:`review, refactor, bugfix`,className:`h-9 bg-background font-mono text-xs`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{htmlFor:`memory-audience-modes`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Modes`}),(0,G.jsx)(L,{id:`memory-audience-modes`,value:r.audienceModes,onChange:e=>m(`audienceModes`,e.target.value),placeholder:`teach, code-review`,className:`h-9 bg-background font-mono text-xs`})]})]})]})})]})}function ct({searchQuery:e,statusFilter:t,kindFilter:n,audienceOnly:i,tagFilter:a,hasFilters:o,allTags:c,stats:l,onSearchChange:u,onStatusFilterChange:d,onKindFilterChange:f,onToggleAudienceOnly:p,onTagFilterChange:h,onClearFilters:g}){let[_,y]=(0,W.useState)(!!a),b=_||!!a,x=c.length>0;return(0,G.jsxs)(`div`,{className:`shrink-0 space-y-2 overflow-hidden border-b border-border/70 bg-card/45 p-3`,children:[(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,G.jsx)(ee,{className:`pointer-events-none absolute left-3 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,G.jsx)(L,{"aria-label":`Search memories`,value:e,onChange:e=>u(e.target.value),placeholder:`Search content, IDs, tags, anchors…`,className:`h-10 min-w-0 bg-background pl-9 pr-8 text-xs`}),e&&(0,G.jsx)(`button`,{type:`button`,"aria-label":`Clear search`,onClick:()=>u(``),className:`absolute right-2 top-1/2 -translate-y-1/2 p-1 text-muted-foreground hover:text-foreground`,children:(0,G.jsx)(T,{className:`size-3.5`})})]}),(0,G.jsx)(I,{variant:i?`default`:`ghost`,size:`icon`,onClick:p,"aria-label":`Filter audience-scoped only`,title:`Show only audience-scoped memories`,className:`shrink-0`,children:(0,G.jsx)(s,{className:`size-4`})}),o&&(0,G.jsx)(I,{variant:`ghost`,size:`icon`,onClick:g,"aria-label":`Clear all filters`,title:`Clear all filters`,children:(0,G.jsx)(v,{className:`size-4`})})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,G.jsx)(`label`,{className:`sr-only`,htmlFor:`memory-status-filter`,children:`Filter by status`}),(0,G.jsxs)(`select`,{id:`memory-status-filter`,value:t,onChange:e=>d(e.target.value),className:`h-9 min-w-0 border border-input bg-background px-2 text-xs`,children:[(0,G.jsx)(`option`,{value:`all`,children:`All statuses`}),Pe.map(e=>(0,G.jsxs)(`option`,{value:e,children:[e,` · `,l?.byStatus[e]??0]},e))]}),(0,G.jsx)(`label`,{className:`sr-only`,htmlFor:`memory-kind-filter`,children:`Filter by kind`}),(0,G.jsxs)(`select`,{id:`memory-kind-filter`,value:n,onChange:e=>f(e.target.value),className:`h-9 min-w-0 border border-input bg-background px-2 text-xs`,children:[(0,G.jsx)(`option`,{value:`all`,children:`All kinds`}),z.map(e=>(0,G.jsxs)(`option`,{value:e,children:[H[e],` · `,l?.byKind[e]??0]},e))]})]}),x&&(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>{a||y(e=>!e)},"aria-expanded":b,"aria-controls":`memory-tags-panel`,disabled:!!a,className:N(`flex items-center gap-1.5 px-1 py-0.5 text-[10px] uppercase tracking-wide transition-colors`,b?`text-foreground`:`text-muted-foreground hover:text-foreground`,!!a&&`cursor-default`),title:a?`Active filter: ${a} (click the chip to clear)`:b?`Hide tag filters`:`Show tag filters (${c.length})`,children:[(0,G.jsx)(m,{className:N(`size-3 transition-transform`,!b&&`-rotate-90`)}),(0,G.jsx)(r,{className:`size-3`}),(0,G.jsx)(`span`,{className:`font-semibold`,children:`Tags`}),(0,G.jsx)(`span`,{className:`font-mono text-[9px] text-muted-foreground`,children:c.length})]}),a&&(0,G.jsx)(`span`,{"aria-label":`Active tag filter: ${a}`,className:`border border-info/55 bg-info/10 px-1 font-mono text-[9px] uppercase text-info`,children:a})]}),x&&b&&(0,G.jsxs)(`fieldset`,{id:`memory-tags-panel`,className:`min-w-0 border-0 p-0`,children:[(0,G.jsx)(`legend`,{className:`sr-only`,children:`Popular tags`}),(0,G.jsx)(`div`,{className:`no-scrollbar flex gap-1.5 overflow-x-auto pb-0.5`,children:c.slice(0,18).map(([e,t])=>(0,G.jsxs)(`button`,{type:`button`,"aria-pressed":a===e,onClick:()=>h(a===e?null:e),className:N(`flex shrink-0 items-center gap-1 border px-2 py-1 text-[10px] transition-colors`,a===e?`border-info/55 bg-info/10 text-info`:`border-border/70 bg-background/45 text-muted-foreground hover:border-info/35 hover:text-foreground`),children:[(0,G.jsx)(r,{className:`size-2.5`}),` `,e,(0,G.jsx)(`span`,{className:`font-mono opacity-60`,children:t})]},e))})]})]})}var lt=100;function ut({memoryListRef:e,memories:t,filteredMemories:n,selectedId:r,onSelectMemory:i,onOpenCreate:a,onClearFilters:o}){let s=n.length>lt,c=ce({count:n.length,getScrollElement:()=>e.current,estimateSize:()=>100,overscan:8,enabled:s});return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-border/60 px-3 py-2 text-[10px] text-muted-foreground`,children:[(0,G.jsxs)(`span`,{children:[n.length,` of `,t.length,` memories`]}),(0,G.jsx)(`span`,{className:`font-mono uppercase`,children:`updated ↓`})]}),(0,G.jsx)(`section`,{ref:e,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,"aria-label":`Memories`,children:n.length===0?(0,G.jsx)(dt,{hasMemories:t.length>0,onOpenCreate:a,onClearFilters:o}):s?(0,G.jsx)(`div`,{style:{height:`${c.getTotalSize()}px`,width:`100%`,position:`relative`},children:c.getVirtualItems().map(e=>{let t=n[e.index];return t?(0,G.jsx)(`div`,{"data-index":e.index,ref:c.measureElement,style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${e.start}px)`},children:(0,G.jsx)(ft,{memory:t,isSelected:r===t.id,onClick:()=>i(t.id)})},t.id):null})}):n.map(e=>(0,G.jsx)(ft,{memory:e,isSelected:r===e.id,onClick:()=>i(e.id)},e.id))})]})}function dt({hasMemories:e,onOpenCreate:t,onClearFilters:n}){return(0,G.jsxs)(`div`,{className:`flex min-h-64 flex-col items-center justify-center px-6 text-center`,children:[(0,G.jsx)(`span`,{className:`flex size-12 items-center justify-center border border-dashed border-border text-muted-foreground`,children:(0,G.jsx)(oe,{className:`size-5`})}),(0,G.jsx)(`h2`,{className:`mt-4 text-sm font-bold`,children:e?`No matching memories`:`Build your memory graph`}),(0,G.jsx)(`p`,{className:`mt-1 max-w-xs text-xs leading-5 text-muted-foreground`,children:e?`Change the filters or clear the search query.`:`Capture durable facts, decisions, conventions, and file-bound notes for every agent.`}),(0,G.jsxs)(I,{className:`mt-4`,variant:`outline`,size:`sm`,onClick:e?n:t,children:[e?(0,G.jsx)(v,{className:`size-3.5`}):(0,G.jsx)(A,{className:`size-3.5`}),e?`Clear filters`:`Create first memory`]})]})}function ft({memory:e,isSelected:t,onClick:n}){return(0,G.jsxs)(`button`,{type:`button`,"aria-current":t?`true`:void 0,onClick:n,className:N(`group relative block w-full border-b border-border/55 px-3 py-3 text-left transition-[background-color,border-color] hover:bg-info/5`,t&&`bg-info/8`),children:[t&&(0,G.jsx)(`span`,{className:`absolute inset-y-0 left-0 w-0.5 bg-info shadow-[0_0_10px_hsl(var(--info)/0.7)]`}),(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(`span`,{className:N(`truncate text-[10px] font-bold uppercase tracking-[0.1em]`,Me(e.kind)),children:H[e.kind]??e.kind}),(0,G.jsx)(B,{status:e.status}),(0,G.jsxs)(`span`,{className:`ml-auto shrink-0 font-mono text-[9px] text-muted-foreground`,children:[`r`,e.revision]})]}),(0,G.jsx)(`p`,{className:N(`mt-2 line-clamp-2 text-xs leading-5 text-foreground/90`,e.status===`deleted`&&`line-through opacity-60`),children:R(e.text)}),(0,G.jsxs)(`div`,{className:`mt-2 flex min-w-0 items-center gap-1.5`,children:[(0,G.jsx)(`span`,{className:`border border-border/60 bg-background/50 px-1.5 py-0.5 font-mono text-[9px] uppercase text-muted-foreground`,children:e.scope}),e.audience&&(0,G.jsxs)(`span`,{className:`flex items-center gap-0.5 border border-primary/30 bg-primary/10 px-1.5 py-0.5 font-mono text-[9px] text-primary`,children:[(0,G.jsx)(s,{className:`size-2.5`}),(e.audience.roles??e.audience.taskTypes??e.audience.modes??[]).slice(0,1)[0]??`scoped`]}),e.tags.slice(0,2).map(e=>(0,G.jsxs)(`span`,{className:`max-w-24 truncate border border-border/60 px-1.5 py-0.5 font-mono text-[9px] text-muted-foreground`,children:[`#`,e]},e)),e.tags.length>2&&(0,G.jsxs)(`span`,{className:`font-mono text-[9px] text-muted-foreground`,children:[`+`,e.tags.length-2]}),(0,G.jsx)(`span`,{className:`ml-auto shrink-0 text-[9px] text-muted-foreground`,children:ze(e.updatedAt)}),(0,G.jsx)(i,{className:`size-3 shrink-0 text-muted-foreground transition-transform group-hover:translate-x-0.5 group-hover:text-info`})]})]})}function pt({busyAction:e,deletingId:t,memories:r,onCancel:i,onConfirm:a,onOpenChange:o}){return(0,G.jsx)(F,{open:!!t,onOpenChange:o,children:(0,G.jsxs)(be,{className:`max-w-md`,children:[(0,G.jsxs)(ve,{children:[(0,G.jsx)(`span`,{className:`mb-2 flex size-10 items-center justify-center border border-destructive/35 bg-destructive/10 text-destructive`,children:(0,G.jsx)(n,{className:`size-4`})}),(0,G.jsx)(xe,{children:`Delete this memory?`}),(0,G.jsx)(P,{className:`leading-6`,children:`SAGE will mark the record deleted, remove graph edges, and clean references from related memories. The record remains in the audit trail but cannot be restored from this page.`})]}),(0,G.jsx)(`div`,{className:`border border-border/70 bg-background/45 p-3 text-xs text-muted-foreground`,children:R(r.find(e=>e.id===t)?.text??``,180)}),(0,G.jsxs)(ye,{children:[(0,G.jsx)(I,{variant:`outline`,onClick:i,disabled:e===`delete`,children:`Cancel`}),(0,G.jsxs)(I,{variant:`destructive`,onClick:a,disabled:e===`delete`,children:[e===`delete`?(0,G.jsx)(c,{className:`size-4 animate-spin`}):(0,G.jsx)(n,{className:`size-4`}),e===`delete`?`Deleting…`:`Delete memory`]})]})]})})}function mt({onCapture:e}){return(0,G.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center p-8 text-center`,children:[(0,G.jsxs)(`div`,{className:`relative flex size-20 items-center justify-center border border-info/25 bg-info/5 text-info`,children:[(0,G.jsx)(s,{className:`size-8`}),(0,G.jsx)(`span`,{className:`absolute inset-2 border border-info/10`})]}),(0,G.jsx)(`h2`,{className:`mt-5 text-lg font-bold`,children:`Your project’s long-term context`}),(0,G.jsx)(`p`,{className:`mt-2 max-w-md text-sm leading-6 text-muted-foreground`,children:`Select a memory to inspect its metadata and relationship graph, or capture knowledge that future agents should retrieve automatically.`}),(0,G.jsxs)(`div`,{className:`mt-6 grid w-full max-w-lg gap-2 sm:grid-cols-3`,children:[(0,G.jsxs)(`div`,{className:`border border-border/70 bg-card/45 p-3`,children:[(0,G.jsx)(me,{className:`mx-auto size-4 text-success`}),(0,G.jsx)(`p`,{className:`mt-2 text-[10px] font-bold uppercase`,children:`Verified anchors`})]}),(0,G.jsxs)(`div`,{className:`border border-border/70 bg-card/45 p-3`,children:[(0,G.jsx)(s,{className:`mx-auto size-4 text-info`}),(0,G.jsx)(`p`,{className:`mt-2 text-[10px] font-bold uppercase`,children:`Typed relations`})]}),(0,G.jsxs)(`div`,{className:`border border-border/70 bg-card/45 p-3`,children:[(0,G.jsx)(A,{className:`mx-auto size-4 text-warning`}),(0,G.jsx)(`p`,{className:`mt-2 text-[10px] font-bold uppercase`,children:`Agent recall`})]})]}),(0,G.jsxs)(I,{onClick:e,children:[(0,G.jsx)(A,{className:`size-4`}),` Capture memory`]})]})}function ht(e,t){let n=t.searchQuery.trim().toLowerCase();return e.filter(e=>{if(t.statusFilter!==`all`&&e.status!==t.statusFilter||t.kindFilter!==`all`&&e.kind!==t.kindFilter||t.tagFilter&&!e.tags.includes(t.tagFilter)||t.audienceOnly&&!e.audience)return!1;if(!n)return!0;let r=e.anchors.map(e=>[e.path,e.symbol,e.command,e.role].filter(Boolean).join(` `)).join(` `),i=e.audience?[e.audience.roles?.join(` `)??``,e.audience.taskTypes?.join(` `)??``,e.audience.modes?.join(` `)??``].join(` `):``;return[e.id,e.text,e.summary??``,e.kind,e.scope,e.tags.join(` `),r,i].join(` `).toLowerCase().includes(n)})}function gt(e){let t=new Map;for(let n of e)for(let e of n.tags)t.set(e,(t.get(e)??0)+1);return[...t.entries()].sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0]))}function _t(e){if(!e)return[];let t=[];e.supersededBy&&t.push({relation:`Superseded by`,id:e.supersededBy});for(let n of e.supersedes??[])t.push({relation:`Supersedes`,id:n});for(let n of e.contradicts??[])t.push({relation:`Contradicts`,id:n});return t}function vt(){let{client:e,listSageMemoriesPage:t,rememberSage:n,updateSage:r,deleteSage:i,getSageGraph:a,recoverSage:o,resolveMemoryCandidate:c}=ge(),l=_e(e=>e.wsConnected),u=he(e=>e.setCurrentView),d=Se(`memory`),[f,p]=(0,W.useState)([]),[m,h]=(0,W.useState)(null),[g,v]=(0,W.useState)(!0),[y,b]=(0,W.useState)(!1),[x,ee]=(0,W.useState)(null),[S,C]=(0,W.useState)(null),[w,T]=(0,W.useState)(null),[E,O]=(0,W.useState)(null),[ne,re]=(0,W.useState)([]),[ie,k]=(0,W.useState)([]),[ae,oe]=(0,W.useState)(null),[se,ce]=(0,W.useState)(!1),[le,j]=(0,W.useState)(!1),[de,fe]=(0,W.useState)(!1),[M,ve]=(0,W.useState)(je),[ye,be]=(0,W.useState)(je),[xe,P]=(0,W.useState)(null),[F,L]=(0,W.useState)(null),[Ce,we]=(0,W.useState)(``),[Te,De]=(0,W.useState)(`all`),[Oe,ke]=(0,W.useState)(`all`),[R,Me]=(0,W.useState)(!1),[z,B]=(0,W.useState)(null),[V,Ne]=(0,W.useState)(!1),[Pe,Fe]=(0,W.useState)(null),[H,Le]=(0,W.useState)(!1),[Re,ze]=(0,W.useState)(!1),[Be,Ve]=(0,W.useState)({}),[He,Ue]=(0,W.useState)(!1),[We,Ge]=(0,W.useState)(null),[Ke,qe]=(0,W.useState)(void 0),[Je,Ye]=(0,W.useState)(void 0),Xe=(0,W.useRef)(!1),K=(0,W.useRef)(!0),Qe=(0,W.useRef)(0),q=(0,W.useRef)(0),$e=(0,W.useRef)(null),J=(0,W.useRef)(null),et=(0,W.useMemo)(()=>JSON.stringify(M)!==JSON.stringify(ye),[ye,M]),Y=(0,W.useMemo)(()=>f.find(e=>e.id===E)??null,[f,E]),tt=(0,W.useCallback)(n=>{let r=n!==null,i=++Qe.current;$e.current?.(),ee(null),r?ze(!0):(b(!0),Xe.current||v(!0));let a=()=>{},o=null,s=!1,c=()=>{s||(s=!0,o!==null&&clearTimeout(o),a(),$e.current===c&&($e.current=null))};a=e.on(`memory.sage.listPage`,e=>{if(i!==Qe.current||!K.current){c();return}if(c(),e.payload.error)ee(e.payload.error);else{let t=e.payload.memories??[];p(e=>r?[...e,...t]:t),Fe(e.payload.nextCursor??null),Le(!!e.payload.nextCursor);let n=e.payload.statusCounts??{};Ve(n);let i=Object.values(n).reduce((e,t)=>e+t,0);e.payload.stats?h(e.payload.stats):h(e=>({total:i,byStatus:n,byKind:e?.byKind??{},edges:e?.edges??0})),Xe.current=!0,r||O(e=>e&&t.some(t=>t.id===e)?e:null)}v(!1),b(!1),ze(!1)}),o=setTimeout(()=>{i!==Qe.current||!K.current||(c(),ee(`The memory store did not respond. Check the WebSocket connection and try again.`),v(!1),b(!1),ze(!1))},2e4),$e.current=c,t({limit:100,...V?{statuses:[`deleted`]}:{},...n?{cursor:n}:{}},{echoToChat:!1})},[e,t,V]),X=(0,W.useCallback)(()=>{Fe(null),Le(!1),tt(null)},[tt]),nt=(0,W.useCallback)(()=>{Re||!Pe||tt(Pe)},[tt,Re,Pe]);(0,W.useEffect)(()=>(K.current=!0,X(),()=>{K.current=!1,Qe.current+=1,q.current+=1,$e.current?.(),J.current?.()}),[X]),(0,W.useEffect)(()=>{if(re([]),k([]),oe(null),!E){ce(!1);return}let t=E;ce(!0);let n=null,r=e.on(`memory.sage.graph`,e=>{e.payload.query===t&&(n!==null&&clearTimeout(n),re(e.payload.edges??[]),k(e.payload.memories??[]),oe(e.payload.error??null),ce(!1))});return n=setTimeout(()=>{oe(`Relationship graph did not respond in time.`),ce(!1)},15e3),a(t,{maxDepth:1,limit:120},{echoToChat:!1}),()=>{n!==null&&clearTimeout(n),r()}},[e,a,E]);let rt=(0,W.useRef)(l);(0,W.useEffect)(()=>{l&&!rt.current&&Xe.current&&X(),rt.current=l},[X,l]),(0,W.useEffect)(()=>{if(!w)return;let e=setTimeout(()=>T(null),4e3);return()=>clearTimeout(e)},[w]);let Z=(0,W.useCallback)(()=>!et||!le&&!de||window.confirm(`Discard the unsaved memory changes?`),[de,et,le]),it=(0,W.useCallback)(()=>{if(!Z())return;let e=je();ve(e),be(e),fe(!0),j(!1),O(null),C(null)},[Z]),at=(0,W.useCallback)(e=>{Z()&&(O(e),fe(!1),j(!1),C(null))},[Z]),Q=(0,W.useCallback)(()=>{if(!Y||Y.status===`deleted`)return;let e=Ae(Y);ve(e),be(e),j(!0),fe(!1),C(null)},[Y]),lt=(0,W.useCallback)(()=>{Z()&&(j(!1),fe(!1),C(null))},[Z]),dt=(0,W.useCallback)((t,n,r)=>{if(!M.text.trim()){C(`Memory content is required.`);return}let i=++q.current;J.current?.(),P(r),C(null),T(null);let a=()=>{},o=null,s=!1,c=()=>{s||(s=!0,o!==null&&clearTimeout(o),a(),J.current===c&&(J.current=null))},l=e=>{if(i!==q.current||!K.current){c();return}if(c(),P(null),e.payload.error||!e.payload.memory){C(e.payload.error??`The server returned no memory record.`);return}let t=e.payload.memory;p(e=>{let n=e.filter(e=>e.id!==t.id);return[t,...n]}),O(t.id),fe(!1),j(!1),T(r===`create`?`Memory captured.`:`Memory updated.`),X()};a=t===`memory.sage.remember`?e.on(`memory.sage.remember`,l):e.on(`memory.sage.update`,l),o=setTimeout(()=>{i!==q.current||!K.current||(c(),P(null),C(`${r===`create`?`Create`:`Save`} timed out. Your draft is still here.`))},2e4),J.current=c,n()},[e,M.text,X]),ft=(0,W.useCallback)(()=>{dt(`memory.sage.remember`,()=>n({text:M.text.trim(),kind:M.kind,scope:M.scope,tags:U(M.tags),importance:M.importance,confidence:M.confidence,freshness:M.freshness,anchors:Ee(M.anchors),...U(M.audienceRoles).length||U(M.audienceTaskTypes).length||U(M.audienceModes).length?{audience:{roles:U(M.audienceRoles),taskTypes:U(M.audienceTaskTypes),modes:U(M.audienceModes)}}:{},supersedes:U(M.supersedes),contradicts:U(M.contradicts)},{echoToChat:!1}),`create`)},[M,n,dt]),vt=(0,W.useCallback)(()=>{Y&&dt(`memory.sage.update`,()=>r(Y.id,{text:M.text.trim(),kind:M.kind,status:M.status,tags:U(M.tags),importance:M.importance,confidence:M.confidence,freshness:M.freshness,anchors:Ee(M.anchors),...U(M.audienceRoles).length||U(M.audienceTaskTypes).length||U(M.audienceModes).length?{audience:{roles:U(M.audienceRoles),taskTypes:U(M.audienceTaskTypes),modes:U(M.audienceModes)}}:{},supersedes:U(M.supersedes),contradicts:U(M.contradicts)},{echoToChat:!1}),`update`)},[M,dt,Y,r]),yt=(0,W.useCallback)(()=>{if(!F)return;let t=++q.current;J.current?.(),P(`delete`),C(null);let n=()=>{},r=null,a=!1,o=()=>{a||(a=!0,r!==null&&clearTimeout(r),n(),J.current===o&&(J.current=null))};n=e.on(`memory.sage.delete`,e=>{if(t!==q.current||!K.current){o();return}if(o(),P(null),!e.payload.success){C(e.payload.message||`Delete failed.`);return}L(null),O(null),j(!1),T(`Memory deleted and relationship edges cleaned up.`),X()}),r=setTimeout(()=>{t!==q.current||!K.current||(o(),P(null),C(`Delete timed out. The memory may still exist; refresh to confirm.`))},2e4),J.current=o,i(F,`Deleted from the WebUI Memory Manager.`)},[e,i,F,X]),bt=(0,W.useMemo)(()=>ht(f,{searchQuery:Ce,statusFilter:Te,kindFilter:Oe,tagFilter:z,audienceOnly:R}),[R,Oe,f,Ce,Te,z]),xt=(0,W.useMemo)(()=>gt(f),[f]),St=(0,W.useMemo)(()=>_t(Y),[Y]),Ct=(0,W.useCallback)(()=>{we(``),De(`all`),ke(`all`),Me(!1),B(null)},[]),wt=!!(Ce||Te!==`all`||Oe!==`all`||z||R),Tt=de||!!Y,$=He&&!!We;return g&&f.length===0?(0,G.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-background`,"aria-busy":`true`,children:[(0,G.jsxs)(`div`,{className:`border-b border-border/70 bg-card/70 px-5 py-4`,children:[(0,G.jsx)(`div`,{className:`h-3 w-28 animate-pulse bg-muted`}),(0,G.jsx)(`div`,{className:`mt-3 h-7 w-56 animate-pulse bg-muted`})]}),(0,G.jsxs)(`div`,{className:`grid flex-1 gap-px bg-border/60 md:grid-cols-[minmax(300px,0.82fr)_minmax(0,1.35fr)]`,children:[(0,G.jsx)(`div`,{className:`space-y-px bg-background p-4`,children:Array.from({length:7},(e,t)=>(0,G.jsx)(`div`,{className:`h-24 animate-pulse border border-border/60 bg-card/45`},t))}),(0,G.jsx)(`div`,{className:`hidden bg-background p-6 md:block`,children:(0,G.jsx)(`div`,{className:`h-full animate-pulse border border-border/60 bg-card/35`})})]}),(0,G.jsx)(`span`,{className:`sr-only`,role:`status`,children:`Loading SAGE content`})]}):x&&f.length===0?(0,G.jsx)(`div`,{className:`flex h-full min-h-0 items-center justify-center bg-background p-6`,children:(0,G.jsxs)(`div`,{className:`max-w-md border border-destructive/35 bg-card p-6 shadow-2xl`,children:[(0,G.jsx)(`span`,{className:`flex size-11 items-center justify-center border border-destructive/35 bg-destructive/10 text-destructive`,children:(0,G.jsx)(D,{className:`size-5`})}),(0,G.jsx)(`h2`,{className:`mt-4 text-lg font-bold`,children:`Memory store unavailable`}),(0,G.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-muted-foreground`,children:x}),(0,G.jsxs)(`div`,{className:`mt-5 flex gap-2`,children:[(0,G.jsxs)(I,{onClick:X,children:[(0,G.jsx)(te,{className:`size-4`}),` Retry`]}),(0,G.jsxs)(I,{variant:`outline`,onClick:()=>u(`chat`),children:[(0,G.jsx)(ue,{className:`size-4`}),` Back to chat`]})]})]})}):(0,G.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-background`,children:[(0,G.jsxs)(`header`,{className:`relative shrink-0 overflow-hidden border-b border-border/70 bg-card/72 px-4 py-3 backdrop-blur-xl sm:px-5`,children:[(0,G.jsx)(`div`,{className:`pointer-events-none absolute inset-y-0 right-0 w-1/2 bg-[radial-gradient(circle_at_right,hsl(var(--info)/0.11),transparent_68%)]`}),(0,G.jsxs)(`div`,{className:`relative flex flex-wrap items-center gap-3`,children:[(0,G.jsx)(I,{variant:`ghost`,size:`icon`,onClick:()=>u(`chat`),"aria-label":`Back to chat`,title:`Back to chat`,children:(0,G.jsx)(ue,{className:`size-4`})}),(0,G.jsx)(`span`,{className:`flex size-10 items-center justify-center border border-info/40 bg-info/10 text-info shadow-[0_0_20px_hsl(var(--info)/0.12)]`,children:(0,G.jsx)(s,{className:`size-5`})}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`h1`,{className:`text-base font-bold sm:text-lg`,children:`SAGE`}),(0,G.jsx)(`span`,{className:`border border-success/35 bg-success/10 px-2 py-0.5 font-mono text-[9px] font-bold uppercase text-success`,children:`project knowledge`})]}),(0,G.jsx)(`p`,{className:`mt-0.5 max-w-2xl text-[10px] text-muted-foreground sm:text-xs`,children:`Inspect, connect, curate, and retire durable context used across agent sessions.`})]}),(0,G.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,G.jsxs)(`span`,{className:N(`hidden items-center gap-1.5 border px-2 py-1 font-mono text-[9px] uppercase sm:flex`,l?`border-success/30 text-success`:`border-warning/30 text-warning`),children:[(0,G.jsx)(`span`,{className:`size-1.5 bg-current`}),` `,l?`live store`:`reconnecting`]}),(0,G.jsxs)(I,{variant:`outline`,size:`sm`,onClick:X,disabled:y,"aria-label":`Refresh memories`,children:[(0,G.jsx)(te,{className:N(`size-3.5`,y&&`animate-spin`)}),(0,G.jsx)(`span`,{className:`hidden sm:inline`,children:`Refresh`})]}),(0,G.jsxs)(I,{size:`sm`,onClick:it,children:[(0,G.jsx)(A,{className:`size-3.5`}),` New memory`]})]})]})]}),(0,G.jsxs)(`div`,{className:`grid shrink-0 grid-cols-2 gap-px border-b border-border/70 bg-border/60 sm:grid-cols-4`,children:[(0,G.jsx)(Ie,{label:`Memories`,value:m?.total??f.length,hint:`${bt.length} visible`}),(0,G.jsx)(Ie,{label:`Active`,value:m?.byStatus.active??f.filter(e=>e.status===`active`).length,hint:`retrievable`,tone:`success`}),(0,G.jsx)(Ie,{label:`Needs review`,value:(m?.byStatus.stale??0)+(m?.byStatus.contradicted??0),hint:`stale + conflicts`,tone:`warning`}),(0,G.jsx)(`div`,{className:`hidden sm:block`,children:(0,G.jsx)(Ie,{label:`Graph edges`,value:m?.edges??0,hint:`${xt.length} tags`,tone:`info`})})]}),(()=>{let e=f.filter(e=>e.audience).length;if(e===0)return null;let t=new Set;for(let e of f)if(e.audience){for(let n of e.audience.roles??[])t.add(n);for(let n of e.audience.taskTypes??[])t.add(n);for(let n of e.audience.modes??[])t.add(n)}return(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-border/70 bg-primary/5 px-4 py-1.5`,children:[(0,G.jsx)(s,{className:`size-3.5 text-primary`}),(0,G.jsxs)(`span`,{className:`text-[11px] font-medium text-primary`,children:[e,` audience-scoped memory`,e===1?``:`ies`]}),t.size>0&&(0,G.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`(`,[...t].sort().join(`, `),`)`]})]})})(),(w||x||S)&&(0,G.jsxs)(`div`,{className:`shrink-0 border-b border-border/70 px-4 py-2`,"aria-live":`polite`,children:[w&&(0,G.jsxs)(`div`,{role:`status`,className:`flex items-center gap-2 text-xs text-success`,children:[(0,G.jsx)(me,{className:`size-3.5`}),` `,w]}),x&&(0,G.jsxs)(`div`,{role:`alert`,className:`flex items-center gap-2 text-xs text-warning`,children:[(0,G.jsx)(D,{className:`size-3.5`}),` `,x,` Existing content remains available.`]}),S&&!le&&!de&&(0,G.jsxs)(`div`,{role:`alert`,className:`flex items-center gap-2 text-xs text-destructive`,children:[(0,G.jsx)(D,{className:`size-3.5`}),` `,S]})]}),(0,G.jsxs)(`div`,{className:`grid min-h-0 flex-1 md:grid-cols-[minmax(320px,0.82fr)_minmax(0,1.35fr)]`,children:[(0,G.jsxs)(`section`,{className:N(`min-h-0 border-r border-border/70 bg-card/25`,Tt?`hidden md:flex md:flex-col`:`flex flex-col`),"aria-label":`Memory library`,children:[(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 border-b border-border/60 px-3 pt-1`,role:`tablist`,"aria-label":`Memory view`,children:[(0,G.jsx)(I,{type:`button`,variant:`ghost`,size:`sm`,role:`tab`,"aria-selected":!V,onClick:()=>{V&&Ne(!1)},className:N(`h-7 rounded-b-none border-b-2 px-3 text-[11px]`,V?`border-transparent text-muted-foreground`:`border-primary text-foreground`),children:`Active`}),(0,G.jsxs)(I,{type:`button`,variant:`ghost`,size:`sm`,role:`tab`,"aria-selected":V,onClick:()=>{V||Ne(!0)},className:N(`h-7 rounded-b-none border-b-2 px-3 text-[11px]`,V?`border-primary text-foreground`:`border-transparent text-muted-foreground`),children:[`Deleted`,typeof Be.deleted==`number`?` (${Be.deleted})`:``]})]}),(0,G.jsx)(ct,{searchQuery:Ce,statusFilter:Te,kindFilter:Oe,audienceOnly:R,tagFilter:z,hasFilters:wt,allTags:xt,stats:m,onSearchChange:we,onStatusFilterChange:De,onKindFilterChange:ke,onToggleAudienceOnly:()=>Me(e=>!e),onTagFilterChange:B,onClearFilters:Ct}),(0,G.jsx)(ut,{memoryListRef:d,memories:f,filteredMemories:bt,selectedId:E,onSelectMemory:at,onOpenCreate:it,onClearFilters:Ct}),H?(0,G.jsx)(`div`,{className:`shrink-0 border-t border-border/60 p-2`,children:(0,G.jsx)(I,{type:`button`,variant:`outline`,size:`sm`,onClick:nt,disabled:Re,className:`h-7 w-full text-[11px]`,children:Re?`Loading…`:`Load more (${f.length} loaded)`})}):null]}),(0,G.jsxs)(`section`,{className:N(`min-h-0 bg-background`,Tt?`flex flex-col`:`hidden md:flex md:flex-col`),"aria-label":`Memory detail`,children:[f.some(e=>(e.anchors??[]).some(e=>e.type===`file`&&e.path))&&(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-border/60 bg-card/30 px-3 py-1.5`,children:[(0,G.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground`,children:`File drawer`}),(0,G.jsxs)(`select`,{value:We??``,onChange:e=>{let t=e.target.value||null;Ge(t),t&&Ue(!0)},className:`min-w-0 max-w-[260px] flex-1 truncate rounded-sm border border-border/60 bg-background px-1.5 py-0.5 text-[10px] font-mono`,"aria-label":`File for memory drawer`,"data-testid":`memory-drawer-file-select`,children:[(0,G.jsx)(`option`,{value:``,children:`— select a file —`}),f.flatMap(e=>e.anchors??[]).filter(e=>e.type===`file`&&e.path).map((e,t)=>(0,G.jsx)(`option`,{value:e.path,title:e.path,children:e.path},`${e.path}-${t}`))]}),(0,G.jsxs)(I,{type:`button`,size:`sm`,variant:$?`default`:`outline`,onClick:()=>{We&&Ue(e=>!e)},disabled:!We,className:`h-7 shrink-0 gap-1 px-2 text-[11px]`,"aria-pressed":$,title:$?`Hide file memory drawer`:`Show file memory drawer`,children:[$?(0,G.jsx)(_,{className:`size-3`}):(0,G.jsx)(pe,{className:`size-3`}),$?`Hide`:`Show`,` drawer`]})]}),de?(0,G.jsx)(st,{mode:`create`,draft:M,busy:xe===`create`,error:S,onChange:ve,onCancel:lt,onSubmit:ft}):Y?le?(0,G.jsx)(st,{mode:`edit`,draft:M,busy:xe===`update`,error:S,onChange:ve,onCancel:lt,onSubmit:vt}):$?(0,G.jsx)(ot,{filePath:We,lineStart:Ke,lineEnd:Je,open:$,onClose:()=>Ue(!1),onShowMemory:e=>O(e),onAcceptDeletion:async(e,t)=>{c({candidateId:e,action:`accept`}),T(`Accepted hygiene review for ${t.slice(0,12)}… (candidate ${e.slice(0,12)}…).`),setTimeout(()=>{X()},500)},onKeep:async(e,t)=>{c({candidateId:e,action:`reject`}),T(`Kept ${t.slice(0,12)}… (candidate ${e.slice(0,12)}… rejected).`)},onUpdate:e=>{O(e),Q()},onMarkPermanent:async e=>{P(`update`);try{await r(e,{persistence:`permanent`}),T(`Memory ${e.slice(0,12)}… promoted to permanent.`),await X()}catch(e){C(e instanceof Error?e.message:String(e))}finally{P(null)}},onRecover:async e=>{o({id:e,reason:`recovered via file drawer`}),T(`Recovered ${e.slice(0,12)}…`),setTimeout(()=>{X()},500)}}):(0,G.jsx)(Ze,{memory:Y,allMemories:[...f,...ie],relatedMemories:St,graphEdges:ne,graphLoading:se,graphError:ae,onClose:()=>O(null),onOpenMemory:at,onEdit:Q,onDelete:()=>L(Y.id),onTagSelect:e=>{B(e),O(null)},onNotice:T}):(0,G.jsx)(mt,{onCapture:it})]})]}),(0,G.jsx)(pt,{busyAction:xe,deletingId:F,memories:f,onCancel:()=>L(null),onConfirm:yt,onOpenChange:e=>{!e&&xe!==`delete`&&L(null)}})]})}export{vt as MemoryManager};