@wrongstack/webui 0.293.0 → 0.295.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (207) hide show
  1. package/dist/App.d.ts.map +1 -1
  2. package/dist/assets/AgentRosterView-y-MCHghy.js +7 -0
  3. package/dist/assets/AnalyticsDashboard-tGlXeqV5.js +1 -0
  4. package/dist/assets/AudienceMemoryPanel-D45M-Fr6.js +3 -0
  5. package/dist/assets/ChangesView-Otr6kwYr.js +1 -0
  6. package/dist/assets/ChronicleDashboard-BvsfI25e.js +1 -0
  7. package/dist/assets/CodeEditor-DtD0-wwy.js +1 -0
  8. package/dist/assets/CodeMap-CVmu16Ec.js +1 -0
  9. package/dist/assets/ConfirmModal-C7H16wDN.js +1 -0
  10. package/dist/assets/{CronJobsPanel-ByJqIjCv.js → CronJobsPanel-CT6XRgmQ.js} +1 -1
  11. package/dist/assets/{DebugDashboard-B0pikasm.js → DebugDashboard-DZy3VUpn.js} +1 -1
  12. package/dist/assets/DesignGalleryView-CQkuFsfj.js +1 -0
  13. package/dist/assets/{GoalView-DXO9txQs.js → GoalView-CTqdYc-z.js} +1 -1
  14. package/dist/assets/KanbanView-DryFcAzY.js +3 -0
  15. package/dist/assets/{LazyMarkdown-BHoUIDge.js → LazyMarkdown-DWlQpo_8.js} +3 -3
  16. package/dist/assets/MailboxDetailView-CsI_6HsE.js +1 -0
  17. package/dist/assets/MemoryManager-D_bjR09v.js +1 -0
  18. package/dist/assets/{ModelPicker-CEZN673P.js → ModelPicker-fGNsJUXK.js} +1 -1
  19. package/dist/assets/{OfficeMapPanel-B0j4e2O1.css → OfficeMapPanel-BFIF-EMt.css} +1 -1
  20. package/dist/assets/OfficeMapPanel-KRrwpmvi.js +4 -0
  21. package/dist/assets/ProcessMonitor-BtgVvQgx.js +1 -0
  22. package/dist/assets/{QueuePanel-DMXksqFS.js → QueuePanel-BGSxmdqf.js} +1 -1
  23. package/dist/assets/{RefreshDebugView-D08bCHA4.js → RefreshDebugView-B_wCBpFb.js} +1 -1
  24. package/dist/assets/SddHub-BryXNdFd.js +2 -0
  25. package/dist/assets/{SessionsDashboard-BY77vax1.js → SessionsDashboard-DLOhC9JZ.js} +1 -1
  26. package/dist/assets/SetupScreen-DsXgzxA1.js +1 -0
  27. package/dist/assets/SkillDetailView-ChyQLtrl.js +3 -0
  28. package/dist/assets/{SpecsView-CZg7e2ml.js → SpecsView-Dh9YG8Id.js} +1 -1
  29. package/dist/assets/TechStackView-RJGVF44_.js +1 -0
  30. package/dist/assets/{TerminalPanel-SnRvUh6N.js → TerminalPanel-3rZfmUfb.js} +1 -1
  31. package/dist/assets/Toaster-BzC_AdG5.js +1 -0
  32. package/dist/assets/activity-7VmgGy-T.js +5 -0
  33. package/dist/assets/activity-BzwApar4.js +5 -0
  34. package/dist/assets/activity-CCUWlVKh.js +5 -0
  35. package/dist/assets/activity-DAHFiOfU.js +5 -0
  36. package/dist/assets/activity-DkkpH2Tf.js +5 -0
  37. package/dist/assets/activity-DqsX-GMs.js +5 -0
  38. package/dist/assets/{activity-Cyx4UukM.js → activity-t0PmZ94i.js} +3 -3
  39. package/dist/assets/{button-Dy0bAtEY.js → button-GVbauxIJ.js} +1 -1
  40. package/dist/assets/{chat-store-CUODHW6c.js → chat-store-BEcTB7SD.js} +7 -7
  41. package/dist/assets/{codemap-activity-store-CgtLR4PV.js → codemap-activity-store-DrrI6G7M.js} +1 -1
  42. package/dist/assets/{dialog-CBgO-uqz.js → dialog-BjPQYovj.js} +1 -1
  43. package/dist/assets/empty-state-DJc37Wg1.js +1 -0
  44. package/dist/assets/{i18n-Dk35g-uV.js → i18n-c37VNlP9.js} +2 -2
  45. package/dist/assets/index-196U0qsu.js +125 -0
  46. package/dist/assets/index-n_-BWskP.css +1 -0
  47. package/dist/assets/{input-B6FY_vtB.js → input-BVi5hYQz.js} +1 -1
  48. package/dist/assets/{mailbox-store-BY2SVw-s.js → mailbox-store-DSvN5ZEo.js} +1 -1
  49. package/dist/assets/roster-ws-BD-ATeja.js +1 -0
  50. package/dist/assets/{session-store-Coiik-Ib.js → session-store-K_ozfq0o.js} +1 -1
  51. package/dist/assets/{settings-C65WW7Jn.js → settings-24NUQrlz.js} +1 -1
  52. package/dist/assets/{settings-Dp5NIt-h.js → settings-BcyGqyX3.js} +1 -1
  53. package/dist/assets/{settings-B9dVH8oJ.js → settings-BhEHLxqK.js} +1 -1
  54. package/dist/assets/{settings-BBR9xBqW.js → settings-C67tfoiy.js} +1 -1
  55. package/dist/assets/{settings-BaZcBGA7.js → settings-CvkIXOQE.js} +1 -1
  56. package/dist/assets/{settings-BXWyZpz5.js → settings-DGTQ4aKo.js} +1 -1
  57. package/dist/assets/{settings-BK1-R1dO.js → settings-i7lxRYZu.js} +1 -1
  58. package/dist/assets/shared-BQ9yQXDx.js +1 -0
  59. package/dist/assets/{stores-CUp_ut8r.js → stores-DVhvmaer.js} +2 -2
  60. package/dist/assets/ui-store-DxFtiYFb.js +1 -0
  61. package/dist/assets/useWebSocket-kb2VPjLc.js +28 -0
  62. package/dist/assets/{utils-DEzFewqr.js → utils-DvgvNCoT.js} +1 -1
  63. package/dist/assets/{vendor-DffL_bim.js → vendor-BmsAdDhb.js} +30 -30
  64. package/dist/assets/{view-navigation-BjlXpDXc.js → view-navigation-D8lN47bJ.js} +1 -1
  65. package/dist/assets/ws-client-BydCS6yi.js +1 -0
  66. package/dist/components/AgentOfficeView.d.ts.map +1 -1
  67. package/dist/components/AgentRosterView.d.ts +16 -0
  68. package/dist/components/AgentRosterView.d.ts.map +1 -0
  69. package/dist/components/AgentRuntimePolicyEditor.d.ts +8 -0
  70. package/dist/components/AgentRuntimePolicyEditor.d.ts.map +1 -0
  71. package/dist/components/AvailabilityCalendarEditor.d.ts +1 -1
  72. package/dist/components/AvailabilityCalendarEditor.d.ts.map +1 -1
  73. package/dist/components/ChangesView.d.ts.map +1 -1
  74. package/dist/components/ChatInput/slash-commands.d.ts.map +1 -1
  75. package/dist/components/ChatInput/slash-routing.d.ts +2 -0
  76. package/dist/components/ChatInput/slash-routing.d.ts.map +1 -1
  77. package/dist/components/ChatInput.d.ts.map +1 -1
  78. package/dist/components/ChatView/index.d.ts.map +1 -1
  79. package/dist/components/ChronicleDashboard.d.ts.map +1 -1
  80. package/dist/components/CodeEditor.d.ts.map +1 -1
  81. package/dist/components/CodeMap.d.ts.map +1 -1
  82. package/dist/components/CustomRosterPanel.d.ts +38 -0
  83. package/dist/components/CustomRosterPanel.d.ts.map +1 -0
  84. package/dist/components/DesignGalleryView.d.ts.map +1 -1
  85. package/dist/components/KanbanView.d.ts.map +1 -1
  86. package/dist/components/MailboxDetailView.d.ts.map +1 -1
  87. package/dist/components/MailboxPanel.d.ts.map +1 -1
  88. package/dist/components/MemoryManager/MemoryDetail.d.ts +4 -4
  89. package/dist/components/MemoryManager/MemoryDetail.d.ts.map +1 -1
  90. package/dist/components/MemoryManager/MemoryEditor.d.ts.map +1 -1
  91. package/dist/components/MemoryManager/MemoryFilters.d.ts +4 -4
  92. package/dist/components/MemoryManager/MemoryFilters.d.ts.map +1 -1
  93. package/dist/components/MemoryManager/MemoryGraph.d.ts +4 -4
  94. package/dist/components/MemoryManager/MemoryGraph.d.ts.map +1 -1
  95. package/dist/components/MemoryManager/MemoryList.d.ts +3 -3
  96. package/dist/components/MemoryManager/MemoryList.d.ts.map +1 -1
  97. package/dist/components/MemoryManager/index.d.ts.map +1 -1
  98. package/dist/components/MemoryManager/shared.d.ts +15 -15
  99. package/dist/components/MemoryManager/shared.d.ts.map +1 -1
  100. package/dist/components/MessageBubble/index.d.ts.map +1 -1
  101. package/dist/components/OfficeMapCanvas/resolve.d.ts +17 -1
  102. package/dist/components/OfficeMapCanvas/resolve.d.ts.map +1 -1
  103. package/dist/components/OfficeMapCanvas/use-recently-finished.d.ts +21 -0
  104. package/dist/components/OfficeMapCanvas/use-recently-finished.d.ts.map +1 -0
  105. package/dist/components/OfficeMapCanvas.d.ts.map +1 -1
  106. package/dist/components/ProcessMonitor.d.ts.map +1 -1
  107. package/dist/components/SettingsPanel/BrainSection.d.ts.map +1 -1
  108. package/dist/components/SettingsPanel/MCPSection.d.ts +4 -0
  109. package/dist/components/SettingsPanel/MCPSection.d.ts.map +1 -1
  110. package/dist/components/SettingsPanel/PluginToggleList.d.ts.map +1 -1
  111. package/dist/components/SettingsPanel/PreferenceControls.d.ts +3 -1
  112. package/dist/components/SettingsPanel/PreferenceControls.d.ts.map +1 -1
  113. package/dist/components/SettingsPanel/PreferenceToggle.d.ts +3 -1
  114. package/dist/components/SettingsPanel/PreferenceToggle.d.ts.map +1 -1
  115. package/dist/components/SettingsPanel/ProviderModelsPanel.d.ts.map +1 -1
  116. package/dist/components/SettingsPanel/ProviderSection.d.ts.map +1 -1
  117. package/dist/components/SettingsPanel/local-presets.d.ts +2 -29
  118. package/dist/components/SettingsPanel/local-presets.d.ts.map +1 -1
  119. package/dist/components/SetupScreen.d.ts.map +1 -1
  120. package/dist/components/ShortcutsOverlay.d.ts.map +1 -1
  121. package/dist/components/SidePanel/SkillsList.d.ts.map +1 -1
  122. package/dist/components/SkillDetailView.d.ts.map +1 -1
  123. package/dist/components/TechStackView/index.d.ts.map +1 -1
  124. package/dist/components/VerificationReportPanel.d.ts +15 -0
  125. package/dist/components/VerificationReportPanel.d.ts.map +1 -0
  126. package/dist/components/activity-bar/index.d.ts.map +1 -1
  127. package/dist/components/ui/api-key-display.d.ts +14 -0
  128. package/dist/components/ui/api-key-display.d.ts.map +1 -0
  129. package/dist/components/ui/empty-state.d.ts +29 -0
  130. package/dist/components/ui/empty-state.d.ts.map +1 -0
  131. package/dist/hooks/useGlobalKeyboardShortcuts.d.ts +1 -1
  132. package/dist/hooks/useGlobalKeyboardShortcuts.d.ts.map +1 -1
  133. package/dist/hooks/useWebSocket.d.ts +13 -13
  134. package/dist/hooks/useWebSocket.d.ts.map +1 -1
  135. package/dist/hooks/ws-handlers/chat-handlers.d.ts.map +1 -1
  136. package/dist/hooks/ws-handlers/fleet-handlers.d.ts.map +1 -1
  137. package/dist/hooks/ws-handlers/session-handlers.d.ts.map +1 -1
  138. package/dist/hooks/ws-handlers.d.ts +8 -7
  139. package/dist/hooks/ws-handlers.d.ts.map +1 -1
  140. package/dist/index.css +251 -0
  141. package/dist/index.css.map +2 -2
  142. package/dist/index.html +23 -23
  143. package/dist/index.js +11542 -7712
  144. package/dist/index.js.map +4 -4
  145. package/dist/lib/agent-office.d.ts +22 -0
  146. package/dist/lib/agent-office.d.ts.map +1 -1
  147. package/dist/lib/model-calendar.d.ts +1 -1
  148. package/dist/lib/model-calendar.d.ts.map +1 -1
  149. package/dist/lib/model-matrix-routes.d.ts +2 -191
  150. package/dist/lib/model-matrix-routes.d.ts.map +1 -1
  151. package/dist/lib/plugin-enablement.d.ts +1 -1
  152. package/dist/lib/plugin-enablement.d.ts.map +1 -1
  153. package/dist/lib/roster-ws.d.ts +48 -0
  154. package/dist/lib/roster-ws.d.ts.map +1 -0
  155. package/dist/lib/view-navigation.d.ts +1 -1
  156. package/dist/lib/view-navigation.d.ts.map +1 -1
  157. package/dist/lib/ws-client-utils.d.ts +1 -2
  158. package/dist/lib/ws-client-utils.d.ts.map +1 -1
  159. package/dist/lib/ws-client.d.ts +30 -22
  160. package/dist/lib/ws-client.d.ts.map +1 -1
  161. package/dist/protocol-compatibility.d.ts +12 -0
  162. package/dist/protocol-compatibility.d.ts.map +1 -0
  163. package/dist/providers.json +105 -85
  164. package/dist/stores/local-prefs.d.ts +2 -2
  165. package/dist/stores/local-prefs.d.ts.map +1 -1
  166. package/dist/stores/mailbox-store.d.ts +2 -0
  167. package/dist/stores/mailbox-store.d.ts.map +1 -1
  168. package/dist/stores/session-store.d.ts +1 -1
  169. package/dist/stores/session-store.d.ts.map +1 -1
  170. package/dist/stores/types.d.ts +1 -1
  171. package/dist/stores/types.d.ts.map +1 -1
  172. package/dist/stores/ui-store.d.ts +3 -3
  173. package/dist/stores/ui-store.d.ts.map +1 -1
  174. package/dist/stores/viz-store.d.ts.map +1 -1
  175. package/dist/types.d.ts +363 -68
  176. package/dist/types.d.ts.map +1 -1
  177. package/package.json +7 -6
  178. package/dist/assets/AnalyticsDashboard--x-f8QI-.js +0 -1
  179. package/dist/assets/AudienceMemoryPanel-j9I0RvhP.js +0 -3
  180. package/dist/assets/ChangesView-Bb5LXWiI.js +0 -1
  181. package/dist/assets/ChronicleDashboard-D34oKMQ_.js +0 -1
  182. package/dist/assets/CodeEditor-BkIIR8EU.js +0 -1
  183. package/dist/assets/CodeMap-Ej4UNFUm.js +0 -1
  184. package/dist/assets/ConfirmModal-4l0Tyazp.js +0 -1
  185. package/dist/assets/DesignGalleryView-CgLsdzTx.js +0 -1
  186. package/dist/assets/KanbanView--bFrj9Xa.js +0 -2
  187. package/dist/assets/MailboxDetailView-C-Vf3h1d.js +0 -1
  188. package/dist/assets/MemoryManager-DoHNBnKd.js +0 -1
  189. package/dist/assets/OfficeMapPanel-BMf4PTWo.js +0 -4
  190. package/dist/assets/ProcessMonitor-BtfARuHq.js +0 -1
  191. package/dist/assets/SddHub-QgMFn_rC.js +0 -2
  192. package/dist/assets/SetupScreen-CU7Mq-5T.js +0 -1
  193. package/dist/assets/SkillDetailView-6ZIVx1BG.js +0 -3
  194. package/dist/assets/TechStackView-9hfnNKx-.js +0 -1
  195. package/dist/assets/Toaster-BNdKxZ1U.js +0 -1
  196. package/dist/assets/activity-AfUMXtSI.js +0 -5
  197. package/dist/assets/activity-Bd_pRifE.js +0 -5
  198. package/dist/assets/activity-Ct_QOdtL.js +0 -5
  199. package/dist/assets/activity-Dyikq8Zm.js +0 -5
  200. package/dist/assets/activity-Ukyu3lON.js +0 -5
  201. package/dist/assets/activity-gaWDc806.js +0 -5
  202. package/dist/assets/index-DGX8tPCe.css +0 -1
  203. package/dist/assets/index-OmSX-BAb.js +0 -124
  204. package/dist/assets/shared-CpXz-tzA.js +0 -1
  205. package/dist/assets/ui-store-CwOvhFZG.js +0 -1
  206. package/dist/assets/useWebSocket-BJorYmOi.js +0 -27
  207. package/dist/assets/ws-client-Fnmzo7vN.js +0 -1
package/dist/App.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../src/App.tsx"],"names":[],"mappings":"AA8zBA,wBAAgB,GAAG,gCAQlB"}
1
+ {"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../src/App.tsx"],"names":[],"mappings":"AA81BA,wBAAgB,GAAG,gCAQlB"}
@@ -0,0 +1,7 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./chat-store-BEcTB7SD.js";import{$r as n,Ar as r,Bt as i,Ct as a,Di as o,Ft as s,Li as c,Qn as l,Qr as u,Ri as d,Vn as f,Wt as p,Xn as m,at as h,bi as g,bt as _,ci as v,na as y,ot as b,pi as x,qt as S,rn as C,st as w,tt as T,ua as E,zi as D}from"./vendor-BmsAdDhb.js";import{n as O}from"./ui-store-DxFtiYFb.js";import{t as k}from"./ws-client-BydCS6yi.js";import{t as A}from"./utils-DvgvNCoT.js";import{b as j}from"./stores-DVhvmaer.js";import{n as M,t as N}from"./ModelPicker-fGNsJUXK.js";import{u as P}from"./index-196U0qsu.js";import{t as F}from"./roster-ws-BD-ATeja.js";var I=e(E(),1),L=T(),R=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],z=[[`timeoutMs`,`Total timeout (ms)`],[`idleTimeoutMs`,`Idle timeout (ms)`],[`maxIterations`,`Max iterations`],[`maxToolCalls`,`Max tool calls`],[`maxTokens`,`Max tokens`],[`maxCostUsd`,`Max cost (USD)`]];function B(e){return`${e.provider}/${e.model}`}function V(e){let t=e.indexOf(`/`);return t<0?{provider:``,model:e}:{provider:e.slice(0,t),model:e.slice(t+1)}}function H(e){return Array.isArray(e)?e.join(`, `):``}function U(e){return[...new Set(e.split(/[\n,]+/).map(e=>e.trim()).filter(Boolean))]}function W({initialConfig:e,systemProtected:t,saving:n,onSave:r,onCancel:a}){let[o,s]=(0,I.useState)(()=>structuredClone(e)),c=M(!0),l=o.modelPolicy,u=(0,I.useMemo)(()=>(l?.allowed??[]).map(B),[l?.allowed]),d=(0,I.useMemo)(()=>(l?.fallbacks??[]).map(B),[l?.fallbacks]),f=e=>s(t=>({...t,...e})),p=(e,t)=>{let n=U(t);s(t=>{let r={...t};return n.length?r[e]=n:delete r[e],r})},m=(e,t)=>{s(n=>{let r={...n.budget??{}};t===``?delete r[e]:r[e]=Number(t);let i={...n};return Object.keys(r).length?i.budget=r:delete i.budget,i})},h=e=>{let t=e.map(V),n=new Set(e);s(e=>({...e,modelPolicy:{allowed:t,fallbacks:(e.modelPolicy?.fallbacks??[]).filter(e=>n.has(B(e))),strict:e.modelPolicy?.strict??!0}}))};return(0,L.jsxs)(`div`,{className:`space-y-4 rounded-lg border border-border bg-card/40 p-4`,children:[t&&(0,L.jsxs)(`div`,{className:`flex gap-2 rounded-md border border-amber-500/30 bg-amber-500/5 p-2 text-[11px] text-muted-foreground`,children:[(0,L.jsx)(i,{className:`mt-0.5 h-4 w-4 shrink-0 text-amber-500`}),(0,L.jsx)(`span`,{children:`Protected system agent: required tools and capabilities are retained, minimum budgets are enforced, working hours remain advisory, and emergency model recovery stays enabled so core operations cannot be disabled.`})]}),(0,L.jsxs)(`section`,{className:`space-y-2`,children:[(0,L.jsx)(`h4`,{className:`text-xs font-semibold`,children:`Provider and model policy`}),(0,L.jsx)(N,{candidates:c,provider:o.provider,value:o.model,placeholder:`Use project default model`,resetLabel:`Use project default`,onReset:()=>{s(e=>{let t={...e};return delete t.provider,delete t.model,t})},onPick:(e,t)=>{let n=`${t}/${e}`;f({provider:t,model:e}),l&&!u.includes(n)&&h([...u,n])}}),(0,L.jsxs)(`label`,{className:`flex items-center gap-2 text-[11px]`,children:[(0,L.jsx)(`input`,{type:`checkbox`,checked:!!l,onChange:e=>{if(e.target.checked){let e=o.provider&&o.model?[{provider:o.provider,model:o.model}]:c[0]?[{provider:c[0].provider,model:c[0].model}]:[];e.length&&f({modelPolicy:{allowed:e,strict:!0}})}else s(e=>{let t={...e};return delete t.modelPolicy,t})}}),`Restrict this agent to an explicit model allowlist`]}),l&&(0,L.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,L.jsxs)(`div`,{className:`space-y-1`,children:[(0,L.jsx)(`span`,{className:`text-[10px] font-medium`,children:`Allowed models`}),(0,L.jsx)(P,{value:u,candidates:c,onChange:h,placeholder:`Add allowed model`,emptyHint:`At least one model is required`})]}),(0,L.jsxs)(`div`,{className:`space-y-1`,children:[(0,L.jsx)(`span`,{className:`text-[10px] font-medium`,children:`Ordered fallback chain`}),(0,L.jsx)(P,{value:d,candidates:c,onChange:e=>{let t=[...new Set([...u,...e])];s(n=>({...n,modelPolicy:{allowed:t.map(V),fallbacks:e.map(V),strict:n.modelPolicy?.strict??!0}}))},placeholder:`Add fallback model`,emptyHint:`No fallback; primary failure stops the task`})]})]})]}),(0,L.jsx)(`section`,{className:`grid gap-3 sm:grid-cols-3`,children:[[`tools`,`Tools`,`read_file, search, bash`],[`skillNames`,`Skills`,`security-check, browser`],[`allowedCapabilities`,`Capabilities`,`fs.read, fs.write`]].map(([e,t,n])=>(0,L.jsxs)(`label`,{className:`space-y-1 text-[10px]`,children:[(0,L.jsx)(`span`,{className:`font-medium`,children:t}),(0,L.jsx)(`textarea`,{value:H(o[e]),onChange:t=>p(e,t.target.value),placeholder:n,className:`h-20 w-full resize-y rounded border border-border bg-background p-2 font-mono`})]},e))}),(0,L.jsxs)(`section`,{className:`space-y-2`,children:[(0,L.jsx)(`h4`,{className:`text-xs font-semibold`,children:`Workspace and isolation`}),(0,L.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,L.jsxs)(`label`,{className:`space-y-1 text-[10px]`,children:[(0,L.jsx)(`span`,{children:`Project-relative working directory`}),(0,L.jsx)(`input`,{value:o.cwd??``,onChange:e=>f({cwd:e.target.value||void 0}),placeholder:`packages/webui`,className:`h-8 w-full rounded border border-border bg-background px-2 font-mono`})]}),(0,L.jsxs)(`label`,{className:`space-y-1 text-[10px]`,children:[(0,L.jsx)(`span`,{children:`Git worktree isolation`}),(0,L.jsxs)(`select`,{value:String(o.worktree??`auto`),onChange:e=>f({worktree:e.target.value}),className:`h-8 w-full rounded border border-border bg-background px-2`,children:[(0,L.jsx)(`option`,{value:`auto`,children:`Automatic`}),(0,L.jsx)(`option`,{value:`required`,children:`Required`}),(0,L.jsx)(`option`,{value:`off`,children:`Off`})]})]})]})]}),(0,L.jsxs)(`section`,{className:`space-y-2`,children:[(0,L.jsx)(`h4`,{className:`text-xs font-semibold`,children:`Limits`}),(0,L.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:z.map(([e,t])=>(0,L.jsxs)(`label`,{className:`space-y-1 text-[10px]`,children:[(0,L.jsx)(`span`,{children:t}),(0,L.jsx)(`input`,{type:`number`,min:`0`,step:e===`maxCostUsd`?`0.01`:`1`,value:o.budget?.[e]??``,onChange:t=>m(e,t.target.value),className:`h-8 w-full rounded border border-border bg-background px-2`})]},e))})]}),(0,L.jsxs)(`section`,{className:`space-y-2`,children:[(0,L.jsxs)(`label`,{className:`flex items-center gap-2 text-xs font-semibold`,children:[(0,L.jsx)(`input`,{type:`checkbox`,checked:!!o.availability,onChange:e=>{e.target.checked?f({availability:{timezone:Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`,days:[1,2,3,4,5],start:`09:00`,end:`18:00`,mode:t?`advisory`:`enforce`}}):s(e=>{let t={...e};return delete t.availability,t})}}),`Working hours`]}),o.availability&&(0,L.jsxs)(`div`,{className:`space-y-2 rounded border border-border p-2`,children:[(0,L.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:R.map((e,t)=>(0,L.jsxs)(`label`,{className:`flex items-center gap-1 text-[10px]`,children:[(0,L.jsx)(`input`,{type:`checkbox`,checked:o.availability?.days.includes(t)??!1,onChange:e=>{let n=o.availability;if(!n)return;let r=e.target.checked?[...new Set([...n.days,t])].sort():n.days.filter(e=>e!==t);f({availability:{...n,days:r}})}}),e]},e))}),(0,L.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-4`,children:[(0,L.jsx)(`input`,{value:o.availability.timezone,onChange:e=>f({availability:{...o.availability,timezone:e.target.value}}),placeholder:`Europe/Kiev`,className:`h-8 rounded border border-border bg-background px-2 text-[10px]`}),(0,L.jsx)(`input`,{type:`time`,value:o.availability.start,onChange:e=>f({availability:{...o.availability,start:e.target.value}}),className:`h-8 rounded border border-border bg-background px-2 text-[10px]`}),(0,L.jsx)(`input`,{type:`time`,value:o.availability.end,onChange:e=>f({availability:{...o.availability,end:e.target.value}}),className:`h-8 rounded border border-border bg-background px-2 text-[10px]`}),(0,L.jsxs)(`select`,{value:t?`advisory`:o.availability.mode??`enforce`,disabled:t,onChange:e=>f({availability:{...o.availability,mode:e.target.value}}),className:`h-8 rounded border border-border bg-background px-2 text-[10px]`,children:[(0,L.jsx)(`option`,{value:`enforce`,children:`Enforce`}),(0,L.jsx)(`option`,{value:`advisory`,children:`Advisory`})]})]})]})]}),(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.jsx)(`button`,{type:`button`,disabled:n||!!(l&&l.allowed.length===0),onClick:()=>r(o),className:`rounded bg-primary px-3 py-1.5 text-xs text-primary-foreground disabled:opacity-50`,children:n?`Saving…`:`Save runtime policy`}),(0,L.jsx)(`button`,{type:`button`,onClick:a,className:`rounded border border-border px-3 py-1.5 text-xs hover:bg-accent`,children:`Cancel`})]})]})}var G=[{id:`live`,icon:(0,L.jsx)(y,{className:`h-4 w-4`}),label:`Live Fleet`},{id:`catalog`,icon:(0,L.jsx)(d,{className:`h-4 w-4`}),label:`Roster Catalog`},{id:`learning`,icon:(0,L.jsx)(D,{className:`h-4 w-4`}),label:`Self-Learning`},{id:`customize`,icon:(0,L.jsx)(p,{className:`h-4 w-4`}),label:`Customization`}],K=[{role:`generic`,name:`Generic Project Agent`,summary:`Flexible template that can be cloned into independently learning project roles.`,tools:0,budget:{maxIterations:2500,maxToolCalls:7500}},{role:`audit-log`,name:`Audit Log`,summary:`Analyzes session logs, event streams, and system traces.`,tools:12,budget:{timeoutMs:108e5,maxIterations:2500,maxToolCalls:7500}},{role:`bug-hunter`,name:`Bug Hunter`,summary:`Scans code for bugs, code smells, and anti-patterns.`,tools:15,budget:{timeoutMs:18e6,maxIterations:4e3,maxToolCalls:1e4}},{role:`refactor-planner`,name:`Refactor Planner`,summary:`Analyzes code structure and produces phased refactoring plans.`,tools:14,budget:{timeoutMs:144e5,maxIterations:3e3,maxToolCalls:9e3}},{role:`security-scanner`,name:`Security Scanner`,summary:`Scans code, configs, and dependencies for security issues.`,tools:18,budget:{timeoutMs:18e6,maxIterations:4e3,maxToolCalls:1e4}},{role:`critic`,name:`Critic`,summary:`Evaluates decisions, plans, and implementations.`,tools:10,budget:{timeoutMs:108e5,maxIterations:2e3,maxToolCalls:5e3}},{role:`shadow-agent`,name:`Shadow Agent`,summary:`Background monitoring agent that watches fleet health.`,tools:8,budget:{timeoutMs:36e6,maxIterations:500,maxToolCalls:2e3}},{role:`executor`,name:`Executor`,summary:`General-purpose task executor for delegated work.`,tools:20,budget:{timeoutMs:72e5,maxIterations:1500,maxToolCalls:4e3}},{role:`chimera`,name:`Chimera`,summary:`Post-session code quality review of changed files.`,tools:10,budget:{timeoutMs:72e5,maxIterations:1e3,maxToolCalls:3e3}},{role:`researcher`,name:`Researcher`,summary:`Web research and data gathering specialist.`,tools:8,budget:{timeoutMs:72e5,maxIterations:1e3,maxToolCalls:3e3}},{role:`tech-stack`,name:`Tech Stack Validator`,summary:`Validates package/library/framework choices.`,tools:9,budget:{timeoutMs:72e5,maxIterations:1e3,maxToolCalls:3e3}},{role:`orchestrator`,name:`Orchestrator`,summary:`Coordinates multi-agent task execution.`,tools:12,budget:{timeoutMs:144e5,maxIterations:3e3,maxToolCalls:8e3}},{role:`supervisor`,name:`Supervisor`,summary:`Oversees subagent execution and handles escalations.`,tools:10,budget:{timeoutMs:144e5,maxIterations:2e3,maxToolCalls:6e3}},{role:`quality-gate`,name:`Quality Gate`,summary:`Enforces quality gates on implementations.`,tools:8,budget:{timeoutMs:72e5,maxIterations:1e3,maxToolCalls:3e3}},{role:`architect`,name:`Architect`,summary:`Makes design and architecture decisions.`,tools:14,budget:{timeoutMs:144e5,maxIterations:3e3,maxToolCalls:8e3}},{role:`prompt-engineer`,name:`Prompt Engineer`,summary:`Designs and optimizes system prompts.`,tools:8,budget:{timeoutMs:72e5,maxIterations:1e3,maxToolCalls:3e3}},{role:`mnemosyne`,name:`Mnemosyne`,summary:`Memory curator — reviews and maintains SAGE integrity.`,tools:6,budget:{timeoutMs:72e5,maxIterations:500,maxToolCalls:2e3}},{role:`autophase`,name:`AutoPhase`,summary:`Manages multi-phase autonomous task execution.`,tools:10,budget:{timeoutMs:144e5,maxIterations:2e3,maxToolCalls:6e3}}],q={running:{led:`bg-success`,badge:`bg-success/12 text-success`,icon:(0,L.jsx)(`span`,{className:`led text-success led-pulse`}),color:`text-success`},completed:{led:`bg-success`,badge:`bg-success/12 text-success`,icon:(0,L.jsx)(g,{className:`h-3.5 w-3.5`}),color:`text-success`},failed:{led:`bg-destructive`,badge:`bg-destructive/15 text-destructive`,icon:(0,L.jsx)(x,{className:`h-3.5 w-3.5`}),color:`text-destructive`},timeout:{led:`bg-warning`,badge:`bg-muted text-muted-foreground`,icon:(0,L.jsx)(v,{className:`h-3.5 w-3.5`}),color:`text-warning`},stopped:{led:`bg-muted-foreground`,badge:`bg-muted text-muted-foreground`,icon:(0,L.jsx)(`span`,{className:`led text-muted-foreground`}),color:`text-muted-foreground`},idle:{led:`bg-muted-foreground`,badge:`bg-muted text-muted-foreground`,icon:(0,L.jsx)(`span`,{className:`led text-muted-foreground`}),color:`text-muted-foreground`}};function J(e){let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m ${t%60}s`;let r=Math.floor(n/60);return r<24?`${r}h ${n%60}m`:`${Math.floor(r/24)}d`}function Y(e){if(e==null||!Number.isFinite(e)||e<=0)return`$0`;if(e<.01){let t=e.toFixed(5);return t===`0.00000`?`$0`:`$`+t.replace(/(\d)0+$/,`$1`).replace(/\.$/,``)}return`$`+e.toFixed(3)}function X({nowTick:e}){let t=j(e=>e.agents),r=j(e=>e.leaderId),[i,o]=(0,I.useState)(null),[s,u]=(0,I.useState)(`all`),d=(0,I.useMemo)(()=>{let e=Array.from(t.values());return e.sort((e,t)=>{let n=e.status===`running`?0:1,r=t.status===`running`?0:1;return n===r?t.startedAt-e.startedAt:n-r}),s===`all`?e:s===`running`?e.filter(e=>e.status===`running`):s===`done`?e.filter(e=>e.status===`completed`):s===`failed`?e.filter(e=>e.status===`failed`||e.status===`timeout`):e},[t,s]),f=(0,I.useMemo)(()=>{let e=0,n=0,r=0;for(let i of t.values())i.status===`running`?e++:i.status===`completed`?n++:(i.status===`failed`||i.status===`timeout`)&&r++;return{running:e,completed:n,failed:r,total:t.size}},[t]),p=j(e=>e.clearFinishedAgents),m=i?d.find(e=>e.id===i):null,h=(0,I.useCallback)(e=>{let t=O.getState();e?(t.setInspectorFocusedAgentId(e),t.setInspectorTab(`agents`)):t.setInspectorTab(`fleet`),t.setInspectorOpen(!0)},[]);return d.length===0?(0,L.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-muted-foreground`,children:(0,L.jsxs)(`div`,{className:`text-center space-y-3`,children:[(0,L.jsx)(c,{className:`h-10 w-10 mx-auto opacity-30`}),(0,L.jsx)(`p`,{className:`text-sm`,children:`No active fleet agents`}),(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground/70`,children:`Agents appear here when subagents spawn`})]})}):(0,L.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:[(0,L.jsxs)(`div`,{className:A(`flex flex-col min-h-0 min-w-0 overflow-hidden`,m?`w-80 shrink-0 border-r border-border/50`:`flex-1`),children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0 px-3 py-2 border-b border-border/50`,children:[[`all`,`running`,`done`,`failed`].map(e=>(0,L.jsxs)(`button`,{type:`button`,onClick:()=>u(e),className:A(`rounded px-2 py-0.5 text-[10px] font-medium transition-colors`,s===e?`bg-primary/10 text-primary`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),children:[e===`all`&&`All (${f.total})`,e===`running`&&`Running (${f.running})`,e===`done`&&`Done (${f.completed})`,e===`failed`&&`Failed (${f.failed})`]},e)),(0,L.jsx)(`span`,{className:`flex-1`}),f.completed+f.failed>0&&(0,L.jsxs)(`button`,{type:`button`,onClick:p,className:`inline-flex items-center gap-0.5 rounded px-1.5 py-0.5 text-[10px] text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition-colors`,children:[(0,L.jsx)(a,{className:`h-2.5 w-2.5`}),` Clear`]})]}),(0,L.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-2 space-y-1`,children:d.map(e=>(0,L.jsxs)(`button`,{type:`button`,onClick:()=>o(i===e.id?null:e.id),className:A(`w-full text-left rounded-lg border px-3 py-2 transition-colors flex items-center gap-2`,i===e.id?`border-primary/50 bg-primary/[0.06]`:`border-border/60 hover:border-primary/30 hover:bg-primary/[0.03]`),children:[(0,L.jsx)(`span`,{className:A(`led shrink-0`,q[e.status]?.led??`bg-muted-foreground`,e.status===`running`&&`led-pulse`)}),(0,L.jsx)(`span`,{className:`text-xs font-semibold min-w-0 truncate max-w-[7rem]`,children:e.name}),e.id===r&&(0,L.jsx)(n,{className:`h-3 w-3 shrink-0 text-warning`}),e.model&&(0,L.jsx)(`span`,{className:`text-[9px] text-muted-foreground font-mono truncate max-w-[6rem] shrink-0`,children:e.model}),(0,L.jsxs)(`span`,{className:`text-[9px] text-muted-foreground tabular-nums shrink-0`,children:[e.iteration,`it · `,e.toolCalls,`t`]}),e.status===`running`&&(0,L.jsx)(`span`,{className:`text-[9px] text-primary tabular-nums shrink-0 ml-auto`,children:J(Date.now()-e.startedAt)}),e.status!==`running`&&(0,L.jsx)(`span`,{className:A(`text-[9px] tabular-nums shrink-0 ml-auto`,q[e.status]?.color??`text-muted-foreground`),children:e.status}),e.costUsd>0&&(0,L.jsx)(`span`,{className:`text-[9px] text-success tabular-nums font-medium shrink-0`,children:Y(e.costUsd)}),e.status===`running`&&e.currentTool&&(0,L.jsxs)(`span`,{className:`text-[9px] text-primary font-mono truncate max-w-[6rem] shrink-0`,children:[`→ `,e.currentTool]})]},e.id))}),(0,L.jsxs)(`div`,{className:`shrink-0 border-t border-border/50 px-3 py-2 flex items-center gap-2 text-[10px] text-muted-foreground`,children:[(0,L.jsx)(`span`,{className:`font-medium tabular-nums`,children:f.total}),` agents total`,(0,L.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,L.jsx)(`span`,{className:`text-success tabular-nums`,children:f.running}),` running`,(0,L.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,L.jsx)(`span`,{className:`tabular-nums`,children:f.completed}),` done`,f.failed>0&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,L.jsx)(`span`,{className:`text-destructive tabular-nums`,children:f.failed}),` failed`]}),(0,L.jsx)(`span`,{className:`flex-1`}),(0,L.jsxs)(`button`,{type:`button`,onClick:()=>h(),className:`inline-flex items-center gap-1 rounded border border-border/50 px-2 py-1 hover:bg-accent transition-colors`,children:[(0,L.jsx)(l,{className:`h-3 w-3`}),`Fleet Inspector`]})]})]}),m&&(0,L.jsx)(`div`,{className:`flex-1 min-w-0 overflow-y-auto p-4`,children:(0,L.jsx)(Z,{agent:m,nowTick:e})})]})}function Z({agent:e,nowTick:t}){let r=e.status===`running`?J(t-e.startedAt):e.completedAt?J(e.completedAt-e.startedAt):`-`,i=Math.min(100,Math.max(0,e.ctxPct)),a=e.currentTool||e.lastTool,o=j(e=>e.leaderId);return(0,L.jsxs)(`div`,{className:`space-y-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`div`,{className:`flex items-center justify-center w-10 h-10 rounded-lg bg-primary/10`,children:(0,L.jsx)(c,{className:`h-5 w-5 text-primary`})}),(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`text-base font-semibold`,children:e.name}),e.id===o&&(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded border border-warning/30 bg-warning/10 px-1.5 py-0.5 text-[9px] font-medium text-warning`,children:[(0,L.jsx)(n,{className:`h-2.5 w-2.5`}),` Leader`]})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-muted-foreground`,children:[(0,L.jsx)(`span`,{className:A(`led`,q[e.status]?.led,e.status===`running`&&`led-pulse`)}),(0,L.jsx)(`span`,{children:e.status}),e.model&&(0,L.jsxs)(`span`,{children:[`· `,e.provider,`/`,e.model]}),(0,L.jsxs)(`span`,{children:[`· `,r]})]})]})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-4 gap-2`,children:[(0,L.jsxs)(`div`,{className:`rounded-lg border bg-card p-2`,children:[(0,L.jsx)(`span`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:`Iterations`}),(0,L.jsx)(`div`,{className:`text-lg font-mono font-semibold mt-0.5`,children:e.iteration})]}),(0,L.jsxs)(`div`,{className:`rounded-lg border bg-card p-2`,children:[(0,L.jsx)(`span`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:`Tool Calls`}),(0,L.jsx)(`div`,{className:`text-lg font-mono font-semibold mt-0.5`,children:e.toolCalls})]}),(0,L.jsxs)(`div`,{className:`rounded-lg border bg-card p-2`,children:[(0,L.jsx)(`span`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:`Cost`}),(0,L.jsx)(`div`,{className:`text-lg font-mono font-semibold mt-0.5 text-success`,children:Y(e.costUsd)})]}),(0,L.jsxs)(`div`,{className:`rounded-lg border bg-card p-2`,children:[(0,L.jsx)(`span`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:`Context`}),(0,L.jsxs)(`div`,{className:`text-lg font-mono font-semibold mt-0.5`,children:[i,`%`]})]})]}),e.maxContext>0&&(0,L.jsxs)(`div`,{className:`space-y-1`,children:[(0,L.jsxs)(`div`,{className:`flex justify-between text-[10px]`,children:[(0,L.jsx)(`span`,{className:`text-muted-foreground`,children:`Context Window`}),(0,L.jsxs)(`span`,{className:A(`tabular font-medium`,i>=85?`text-destructive`:i>=70?`text-warning`:`text-success`),children:[e.ctxTokens.toLocaleString(),` / `,e.maxContext.toLocaleString(),` tokens`]})]}),(0,L.jsx)(`div`,{className:`h-2 w-full overflow-hidden rounded-full bg-muted`,children:(0,L.jsx)(`div`,{className:A(`h-full rounded-full transition-all`,i>=85?`bg-destructive`:i>=70?`bg-warning`:`bg-primary`),style:{width:`${Math.max(2,i)}%`}})})]}),a&&(0,L.jsxs)(`div`,{className:A(`flex items-center gap-2 rounded-lg border px-3 py-2`,e.status===`running`?`border-primary/30 bg-primary/[0.04]`:`border-border bg-muted/30`),children:[(0,L.jsx)(w,{className:A(`h-4 w-4`,e.status===`running`?`text-primary animate-pulse`:`text-muted-foreground`)}),(0,L.jsx)(`span`,{className:`text-sm font-mono`,children:e.currentTool??e.lastTool}),(0,L.jsx)(`span`,{className:`text-[10px] text-muted-foreground ml-auto`,children:e.currentTool?`Running`:`Last tool`})]}),e.error&&(0,L.jsxs)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/5 p-3`,children:[(0,L.jsx)(`span`,{className:`text-[10px] font-semibold text-destructive uppercase tracking-wider`,children:`Error`}),(0,L.jsx)(`p`,{className:`text-xs text-destructive/90 mt-1`,children:e.error.message})]}),e.toolLog.length>0&&(0,L.jsxs)(`div`,{className:`space-y-1`,children:[(0,L.jsxs)(`span`,{className:`text-[10px] font-semibold text-muted-foreground uppercase tracking-wider`,children:[`Tool Log (`,e.toolLog.length,`)`]}),(0,L.jsx)(`div`,{className:`space-y-0.5`,children:e.toolLog.slice(0,10).map((e,t)=>(0,L.jsxs)(`div`,{className:A(`flex items-center gap-2 rounded px-2 py-1 text-[10px] font-mono`,e.ok?`bg-muted/30`:`bg-destructive/5 border border-destructive/20`),children:[(0,L.jsx)(`span`,{className:A(`led shrink-0`,e.ok?`text-success`:`text-destructive`)}),(0,L.jsx)(`span`,{className:`truncate flex-1`,children:e.name}),(0,L.jsxs)(`span`,{className:`tabular text-muted-foreground`,children:[e.durationMs,`ms`]}),!e.ok&&(0,L.jsx)(`span`,{className:`text-destructive`,children:`✗`})]},`${e.name}-${t}`))})]}),e.budgetWarning&&(0,L.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg bg-warning/10 border border-warning/25 text-xs`,children:[(0,L.jsx)(h,{className:`h-3.5 w-3.5 text-warning shrink-0`}),(0,L.jsxs)(`span`,{className:`text-warning`,children:[`Budget: `,e.budgetWarning.kind,` limit (`,e.budgetWarning.used,`/`,e.budgetWarning.limit,`)`]})]})]})}function Q({customStats:e,catalog:t}){let[n,i]=(0,I.useState)(``),[a,s]=(0,I.useState)(null),l=(0,I.useMemo)(()=>new Set(e.filter(e=>e.exists||e.hasIdentity||e.hasConfig||e.hasKnowledge).map(e=>e.role)),[e]),d=(0,I.useMemo)(()=>{if(!n.trim())return t;let e=n.toLowerCase();return t.filter(t=>t.role.includes(e)||t.name.toLowerCase().includes(e)||t.summary.toLowerCase().includes(e))},[t,n]),f=(0,I.useCallback)(t=>e.find(e=>e.role===t),[e]),m=d;return(0,L.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,L.jsx)(`div`,{className:`shrink-0 px-3 py-2 border-b border-border/50`,children:(0,L.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-border/60 bg-background px-3 py-1.5`,children:[(0,L.jsx)(S,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,L.jsx)(`input`,{type:`text`,value:n,onChange:e=>i(e.target.value),placeholder:`Search agents by name, role, or description…`,className:`flex-1 bg-transparent text-xs outline-none placeholder:text-muted-foreground/50`}),n&&(0,L.jsx)(`button`,{type:`button`,onClick:()=>i(``),className:`text-muted-foreground hover:text-foreground`,children:(0,L.jsx)(b,{className:`h-3 w-3`})})]})}),(0,L.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-3`,children:[(0,L.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-2`,children:m.map(e=>{let t=f(e.role),n=l.has(e.role),i=a===e.role;return(0,L.jsxs)(`div`,{className:A(`rounded-lg border bg-card transition-colors`,i?`border-primary/40 ring-1 ring-primary/20`:`border-border/60 hover:border-primary/30`),children:[(0,L.jsxs)(`button`,{type:`button`,onClick:()=>s(i?null:e.role),className:`w-full text-left p-3`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,L.jsx)(c,{className:`h-4 w-4 shrink-0 text-primary`}),(0,L.jsx)(`span`,{className:`text-sm font-semibold truncate`,children:e.name}),(0,L.jsxs)(`code`,{className:`text-[9px] text-muted-foreground font-mono shrink-0`,children:[`@`,e.role]})]}),(0,L.jsx)(o,{className:A(`h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform`,i&&`rotate-180`)})]}),(0,L.jsx)(`p`,{className:`text-[10px] text-muted-foreground mt-1 leading-relaxed line-clamp-2`,children:e.summary}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2 mt-1.5`,children:[(0,L.jsxs)(`span`,{className:`text-[9px] text-muted-foreground tabular-nums`,children:[e.tools,` tools`]}),e.budget.maxIterations&&(0,L.jsxs)(`span`,{className:`text-[9px] text-muted-foreground tabular-nums`,children:[e.budget.maxIterations.toLocaleString(),` max it`]}),n&&(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 rounded bg-brand-2/10 px-1 py-0.5 text-[8px] text-brand-2 font-medium`,children:[(0,L.jsx)(r,{className:`h-2.5 w-2.5`}),` Customized`]}),t?.needsSummarization&&(0,L.jsx)(`span`,{className:`text-[9px] text-warning`,children:`⚠ Needs summary`})]})]}),i&&(0,L.jsxs)(`div`,{className:`border-t border-border/50 px-3 py-2 space-y-2`,children:[(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,L.jsxs)(`div`,{className:`rounded bg-muted/30 p-1.5`,children:[(0,L.jsx)(`span`,{className:`text-[8px] text-muted-foreground uppercase tracking-wider`,children:`Max Iterations`}),(0,L.jsx)(`div`,{className:`text-xs font-mono mt-0.5`,children:e.budget.maxIterations?.toLocaleString()??`—`})]}),(0,L.jsxs)(`div`,{className:`rounded bg-muted/30 p-1.5`,children:[(0,L.jsx)(`span`,{className:`text-[8px] text-muted-foreground uppercase tracking-wider`,children:`Timeout`}),(0,L.jsx)(`div`,{className:`text-xs font-mono mt-0.5`,children:e.budget.timeoutMs?`${Math.round(e.budget.timeoutMs/6e4)}m`:`—`})]}),(0,L.jsxs)(`div`,{className:`rounded bg-muted/30 p-1.5`,children:[(0,L.jsx)(`span`,{className:`text-[8px] text-muted-foreground uppercase tracking-wider`,children:`Max Tool Calls`}),(0,L.jsx)(`div`,{className:`text-xs font-mono mt-0.5`,children:e.budget.maxToolCalls?.toLocaleString()??`—`})]}),(0,L.jsxs)(`div`,{className:`rounded bg-muted/30 p-1.5`,children:[(0,L.jsx)(`span`,{className:`text-[8px] text-muted-foreground uppercase tracking-wider`,children:`Customized`}),(0,L.jsx)(`div`,{className:`text-xs font-mono mt-0.5`,children:n?`Yes`:`No`})]})]}),n&&t&&(0,L.jsxs)(`div`,{className:`rounded bg-accent/30 p-2 space-y-1`,children:[(0,L.jsx)(`span`,{className:`text-[9px] font-medium text-muted-foreground`,children:`Project Customizations`}),(0,L.jsxs)(`div`,{className:`flex flex-wrap gap-2 text-[9px]`,children:[t.hasIdentity&&(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,children:[(0,L.jsx)(r,{className:`h-2.5 w-2.5 text-primary`}),` identity.md`]}),t.entryCount>0&&(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,children:[(0,L.jsx)(u,{className:`h-2.5 w-2.5 text-brand-2`}),` `,t.entryCount,` `,`learned entries`]}),t.hasConfig&&(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,children:[(0,L.jsx)(p,{className:`h-2.5 w-2.5 text-muted-foreground`}),` config.json`]}),t.sessionCaptureCount>0&&(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,children:[(0,L.jsx)(y,{className:`h-2.5 w-2.5 text-success`}),` `,t.sessionCaptureCount,` session captures`]})]})]})]})]},e.role)})}),m.length===0&&(0,L.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-40 text-muted-foreground`,children:[(0,L.jsx)(S,{className:`h-8 w-8 mb-2 opacity-30`}),(0,L.jsxs)(`p`,{className:`text-sm`,children:[`No agents match "`,n,`"`]})]})]}),(0,L.jsxs)(`div`,{className:`shrink-0 border-t border-border/50 px-3 py-2 text-[10px] text-muted-foreground flex items-center gap-2`,children:[(0,L.jsxs)(`span`,{children:[(0,L.jsx)(`strong`,{children:t.length}),` roster roles`]}),(0,L.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,L.jsxs)(`span`,{className:`text-brand-2`,children:[(0,L.jsx)(`strong`,{children:l.size}),` customized`]}),(0,L.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,L.jsxs)(`span`,{children:[(0,L.jsx)(`strong`,{children:e.reduce((e,t)=>e+t.entryCount,0)}),` total learned entries`]})]})]})}function $({customStats:e,onRefresh:t}){let[n,r]=(0,I.useState)(null),[i,a]=(0,I.useState)(null),[o,s]=(0,I.useState)({}),[c,l]=(0,I.useState)(``),[p,m]=(0,I.useState)(null),[h,g]=(0,I.useState)(!1),[v,y]=(0,I.useState)(!1),b=(0,I.useMemo)(()=>[...e].sort((e,t)=>e.role.localeCompare(t.role)),[e]),x=(0,I.useMemo)(()=>n?b.find(e=>e.role===n):null,[n,b]),S=(0,I.useCallback)(async e=>{y(!0),a(null);try{let t=await F(`agent-roster.read-learned`,{role:e});a(t.entries??[]),s({})}catch{}y(!1)},[]),C=(0,I.useCallback)(async()=>{if(!n||!i)return;g(!0);let e=i.filter((e,t)=>o[t]!==`drop`).join(`
2
+
3
+ ---
4
+
5
+ `);try{await F(`agent-roster.update-learned`,{role:n,content:e}),a(null),s({})}catch{}g(!1)},[n,i,o]),w=(0,I.useCallback)(async()=>{if(!(!n||!c.trim())){m(null),g(!0);try{let e=`> Taught ${new Date().toISOString().slice(0,10)}\n\n${c.trim()}`;(await F(`agent-roster.append-learned`,{role:n,content:e})).success?(m({ok:!0,msg:`Saved to learned.md`}),l(``),t()):m({ok:!1,msg:`Save failed`})}catch(e){m({ok:!1,msg:e instanceof Error?e.message:`Failed`})}g(!1)}},[t,n,c]),T=(0,I.useCallback)(async(e,n)=>{g(!0),m(null);try{let r=await F(`agent-roster.update-learning`,{role:e,enabled:n});if(r.error)throw Error(r.error);m({ok:!0,msg:n?`Automatic learning resumed`:`Automatic learning paused`}),t()}catch(e){m({ok:!1,msg:e instanceof Error?e.message:`Policy update failed`})}finally{g(!1)}},[t]);return b.length===0?(0,L.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-muted-foreground`,children:(0,L.jsxs)(`div`,{className:`text-center space-y-3`,children:[(0,L.jsx)(u,{className:`h-10 w-10 mx-auto opacity-30`}),(0,L.jsx)(`p`,{className:`text-sm`,children:`No self-learning data yet`}),(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground/70`,children:`Learning entries appear when agents capture output`})]})}):(0,L.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:[(0,L.jsxs)(`div`,{className:A(`flex flex-col min-h-0 min-w-0 overflow-hidden border-r border-border/50`,n?`w-80 shrink-0`:`flex-1`),children:[(0,L.jsx)(`div`,{className:`shrink-0 px-3 py-2 border-b border-border/50`,children:(0,L.jsxs)(`h3`,{className:`text-xs font-semibold flex items-center gap-1.5`,children:[(0,L.jsx)(u,{className:`h-3.5 w-3.5 text-brand-2`}),`All Roster Agents`]})}),(0,L.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-2 space-y-1`,children:b.map(e=>(0,L.jsxs)(`button`,{type:`button`,onClick:()=>{r(e.role),a(null)},className:A(`w-full text-left rounded-lg border px-3 py-2 transition-colors`,n===e.role?`border-primary/50 bg-primary/[0.06]`:`border-border/60 hover:border-primary/30`),children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsx)(`span`,{className:`text-xs font-semibold`,children:e.role}),(0,L.jsx)(`span`,{className:A(`text-[9px] tabular-nums`,e.learningEnabled?`text-success`:`text-muted-foreground`),children:e.learningEnabled?`learning`:`paused`})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2 mt-1 text-[9px] text-muted-foreground`,children:[(0,L.jsxs)(`span`,{className:`tabular-nums`,children:[e.entryCount,` entries`]}),e.sessionCaptureCount>0&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,L.jsxs)(`span`,{className:`text-success tabular-nums`,children:[`+`,e.sessionCaptureCount]})]}),e.lastCapture&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,L.jsx)(`span`,{children:new Date(e.lastCapture).toLocaleDateString()})]}),e.needsSummarization&&(0,L.jsx)(_,{className:`h-2.5 w-2.5 text-warning`})]})]},e.role))})]}),(0,L.jsxs)(`div`,{className:`flex-1 min-w-0 overflow-y-auto p-4`,children:[!n&&(0,L.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground`,children:`Select an agent to view learning details`}),n&&x&&(0,L.jsxs)(`div`,{className:`space-y-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsx)(`h3`,{className:`text-base font-semibold`,children:n}),(0,L.jsx)(`div`,{className:`flex gap-1`,children:(0,L.jsxs)(`button`,{type:`button`,onClick:()=>T(n,!x.learningEnabled),disabled:h,className:A(`inline-flex items-center gap-1 rounded border px-2 py-1 text-[10px] transition-colors disabled:opacity-50`,x.learningEnabled?`border-success/40 text-success hover:bg-success/10`:`border-border/50 text-muted-foreground hover:bg-accent`),children:[(0,L.jsx)(u,{className:`h-3 w-3`}),` `,x.learningEnabled?`Learning on`:`Learning paused`]})})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-4 gap-2`,children:[(0,L.jsxs)(`div`,{className:`rounded-lg border bg-card p-2`,children:[(0,L.jsx)(`span`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:`Entries`}),(0,L.jsx)(`div`,{className:`text-lg font-mono font-semibold mt-0.5`,children:x.entryCount})]}),(0,L.jsxs)(`div`,{className:`rounded-lg border bg-card p-2`,children:[(0,L.jsx)(`span`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:`Size`}),(0,L.jsxs)(`div`,{className:`text-lg font-mono font-semibold mt-0.5`,children:[x.totalBytes,`B`]})]}),(0,L.jsxs)(`div`,{className:`rounded-lg border bg-card p-2`,children:[(0,L.jsx)(`span`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:`Last Capture`}),(0,L.jsx)(`div`,{className:`text-lg font-mono font-semibold mt-0.5`,children:x.lastCapture?new Date(x.lastCapture).toLocaleDateString():`—`})]}),(0,L.jsxs)(`div`,{className:`rounded-lg border bg-card p-2`,children:[(0,L.jsx)(`span`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:`Lifetime Captures`}),(0,L.jsx)(`div`,{className:`text-lg font-mono font-semibold mt-0.5`,children:x.lifetimeCaptureCount})]})]}),x.needsSummarization&&(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-warning bg-warning/10 rounded-lg px-3 py-2`,children:[(0,L.jsx)(_,{className:`h-3.5 w-3.5 shrink-0`}),`learned.md exceeds soft limit (`,x.totalBytes,`B / 8192B). Run /agent-improve `,n,` refresh.`]}),x.entryCount>0&&(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,L.jsxs)(`button`,{type:`button`,onClick:()=>S(n),disabled:v,className:`inline-flex items-center gap-1 rounded border border-border/50 px-3 py-1.5 text-xs hover:bg-accent transition-colors`,children:[v?(0,L.jsx)(f,{className:`h-3 w-3 animate-spin`}):(0,L.jsx)(d,{className:`h-3 w-3`}),`Review Learned Entries (`,x.entryCount,`)`]})}),i&&(0,L.jsxs)(`div`,{className:`space-y-2 border border-border rounded-lg p-3 bg-card`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`span`,{className:`text-xs font-medium`,children:[i.filter((e,t)=>o[t]!==`drop`).length,`/`,i.length,` kept`]}),(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:C,disabled:h,className:`inline-flex items-center gap-1 rounded bg-primary px-2 py-1 text-[10px] text-primary-foreground hover:bg-primary/90 transition-colors`,children:h?`Applying…`:`Apply Selection`}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>{a(null),s({})},className:`inline-flex items-center gap-1 rounded border border-border/50 px-2 py-1 text-[10px] hover:bg-accent transition-colors`,children:`Cancel`})]})]}),(0,L.jsx)(`div`,{className:`max-h-72 overflow-y-auto space-y-2`,children:i.map((e,t)=>{let n=o[t]??`keep`,r=e.length>200?e.slice(0,200)+`…`:e;return(0,L.jsx)(`div`,{className:A(`rounded-lg border p-2 transition-colors`,n===`drop`?`border-destructive/40 bg-destructive/5 opacity-60`:`border-border`),children:(0,L.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,L.jsx)(`pre`,{className:`text-[10px] whitespace-pre-wrap flex-1 leading-relaxed font-sans`,children:r}),(0,L.jsxs)(`div`,{className:`flex gap-1 shrink-0`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:()=>s(e=>({...e,[t]:`keep`})),className:A(`px-2 py-1 text-[9px] rounded`,n===`keep`?`bg-success/20 text-success`:`bg-muted text-muted-foreground`),children:`Keep`}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>s(e=>({...e,[t]:`drop`})),className:A(`px-2 py-1 text-[9px] rounded`,n===`drop`?`bg-destructive/20 text-destructive`:`bg-muted text-muted-foreground`),children:`Drop`})]})]})},t)})})]})]}),(0,L.jsxs)(`div`,{className:`space-y-2 pt-4 border-t border-border`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-1 text-sm font-medium`,children:[(0,L.jsx)(D,{className:`h-4 w-4 text-brand-2`}),` Teach this agent`]}),(0,L.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Describe a command, pattern, or behavior you want this agent to remember.`}),(0,L.jsx)(`textarea`,{className:`w-full h-20 text-xs p-2 bg-card border border-border rounded resize-y`,value:c,onChange:e=>l(e.target.value),placeholder:`e.g. Always use pnpm for this project`}),(0,L.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,L.jsxs)(`button`,{type:`button`,onClick:w,disabled:!c.trim()||h,className:`inline-flex items-center gap-1 rounded bg-primary px-3 py-1.5 text-xs text-primary-foreground hover:bg-primary/90 transition-colors disabled:opacity-50`,children:[(0,L.jsx)(D,{className:`h-3.5 w-3.5`}),` Teach`]}),p&&(0,L.jsx)(`span`,{className:A(`text-xs`,p.ok?`text-success`:`text-destructive`),children:p.msg})]})]})]})]})]})}function ee({customStats:e,catalog:n,onRefresh:o}){let[c,l]=(0,I.useState)(null),[f,m]=(0,I.useState)(null),[h,g]=(0,I.useState)(``),[_,v]=(0,I.useState)(null),[y,b]=(0,I.useState)(!1),[x,S]=(0,I.useState)(null),[C,w]=(0,I.useState)(!1),[T,E]=(0,I.useState)({name:``,role:``,baseRole:`generic`,purpose:``,taskTypes:``}),D=(0,I.useMemo)(()=>c?e.find(e=>e.role===c):null,[c,e]),j=(0,I.useMemo)(()=>{let e=n.find(e=>e.role===c);return e?.systemProtected??!e?.custom},[n,c]),M=(0,I.useCallback)(async(e,t)=>{b(!0),S(null),l(e);try{let n=await F(`agent-roster.read-customization`,{role:e});g(t===`config`?`${JSON.stringify(n.config??{},null,2)}\n`:n[t]??``),m(t),v(null)}catch(e){S(e instanceof Error?e.message:`Failed to load customization`)}finally{b(!1)}},[]),N=(0,I.useCallback)(async e=>{b(!0),S(null),l(e);try{let t=await F(`agent-roster.read-customization`,{role:e});v(t.config??{}),m(null)}catch(e){S(e instanceof Error?e.message:`Failed to load runtime policy`)}finally{b(!1)}},[]),P=(0,I.useCallback)(async e=>{if(c){b(!0),S(null);try{await F(`agent-roster.update-config`,{role:c,config:e}),v(null),o()}catch(e){S(e instanceof Error?e.message:`Runtime policy save failed`)}finally{b(!1)}}},[o,c]),R=(0,I.useCallback)(async()=>{if(!(!c||!f)){b(!0);try{let e={identity:`agent-roster.update-identity`,learned:`agent-roster.update-learned`,config:`agent-roster.update-config`},t={role:c};if(f===`config`)try{t.config=JSON.parse(h)}catch{S(`config.json must contain valid JSON`),b(!1);return}else t.content=h;await F(e[f],t),m(null),S(null),o()}catch(e){S(e instanceof Error?e.message:`Save failed`)}b(!1)}},[c,f,h,o]),z=(0,I.useCallback)(async()=>{if(c)try{let e=await F(`agent-roster.llm-improve`,{role:c,prompt:`Improve this agent for optimal project performance`});if(!e.instruction)throw Error(`No improvement instruction generated`);let n=t.getState();n.addMessage({role:`user`,content:e.instruction}),n.setLoading(!0),k().sendMessage(e.instruction);let r=O.getState();r.setSidebarOpen(!1),r.setCurrentView(`chat`)}catch(e){S(e instanceof Error?e.message:`LLM improvement failed`)}},[c]),B=(0,I.useCallback)(async e=>{if(window.confirm(`Reset all project-specific data for agent "${e}"?`))try{await F(`agent-roster.reset`,{role:e}),l(null),o()}catch{}},[o]),V=(0,I.useCallback)(async()=>{let e=T.taskTypes.split(/[\n,]+/).map(e=>e.trim()).filter(Boolean);b(!0),S(null);try{let t=await F(`agent-roster.create`,{name:T.name,role:T.role,baseRole:T.baseRole,purpose:T.purpose,taskTypes:e});w(!1),E({name:``,role:``,baseRole:`generic`,purpose:``,taskTypes:``}),l(t.role),o()}catch(e){S(e instanceof Error?e.message:`Agent creation failed`)}finally{b(!1)}},[T,o]),H=(0,I.useMemo)(()=>[...e].sort((e,t)=>{let n=+!!e.hasIdentity+ +(e.entryCount>0)+ +!!e.hasConfig;return+!!t.hasIdentity+ +(t.entryCount>0)+ +!!t.hasConfig-n}),[e]);return(0,L.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:[(0,L.jsxs)(`div`,{className:`w-80 shrink-0 border-r border-border/50 flex flex-col overflow-hidden`,children:[(0,L.jsx)(`div`,{className:`shrink-0 border-b border-border/50 px-3 py-2`,children:(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,L.jsxs)(`h3`,{className:`flex items-center gap-1.5 text-xs font-semibold`,children:[(0,L.jsx)(p,{className:`h-3.5 w-3.5`}),`Project Agents`]}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>{w(!0),l(null),v(null),S(null)},className:`rounded border border-primary/40 px-1.5 py-1 text-[9px] text-primary hover:bg-primary/10`,children:`+ Clone`})]})}),(0,L.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-2 space-y-1`,children:[H.map(e=>(0,L.jsxs)(`button`,{type:`button`,onClick:()=>{l(e.role),v(null),m(null)},className:A(`w-full text-left rounded-lg border px-3 py-2 transition-colors`,c===e.role?`border-primary/50 bg-primary/[0.06]`:`border-border/60 hover:border-primary/30`),children:[(0,L.jsx)(`div`,{className:`text-xs font-semibold`,children:e.role}),(0,L.jsxs)(`div`,{className:`flex gap-2 mt-0.5 text-[9px] text-muted-foreground`,children:[e.hasIdentity&&(0,L.jsx)(`span`,{className:`text-primary`,children:`id`}),e.entryCount>0&&(0,L.jsxs)(`span`,{className:`text-brand-2`,children:[e.entryCount,`e`]}),e.hasConfig&&(0,L.jsx)(`span`,{children:`cfg`})]})]},e.role)),H.length===0&&(0,L.jsx)(`div`,{className:`text-[10px] text-muted-foreground text-center py-4`,children:`No customizations yet`})]})]}),(0,L.jsxs)(`div`,{className:`flex-1 min-w-0 overflow-y-auto p-4`,children:[C&&(0,L.jsxs)(`div`,{className:`max-w-2xl space-y-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{className:`text-base font-semibold`,children:`Create or Clone Project Agent`}),(0,L.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Inherit any roster agent as a template, then develop an independent identity, runtime policy and learned history.`})]}),(0,L.jsxs)(`label`,{className:`block space-y-1 text-xs`,children:[(0,L.jsx)(`span`,{className:`font-medium`,children:`Clone from roster role`}),(0,L.jsx)(`select`,{value:T.baseRole,onChange:e=>E(t=>({...t,baseRole:e.target.value})),className:`h-9 w-full rounded border border-border bg-card px-2`,children:[...n].sort((e,t)=>e.name.localeCompare(t.name)).map(e=>(0,L.jsxs)(`option`,{value:e.role,children:[e.name,` (`,e.role,`)`]},e.role))}),(0,L.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Prompt, tools, skills and defaults are inherited. Learning and later edits remain isolated to the new agent.`})]}),(0,L.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,L.jsxs)(`label`,{className:`space-y-1 text-xs`,children:[(0,L.jsx)(`span`,{className:`font-medium`,children:`Display name`}),(0,L.jsx)(`input`,{value:T.name,onChange:e=>E(t=>({...t,name:e.target.value})),placeholder:`ABC`,className:`h-9 w-full rounded border border-border bg-card px-2`})]}),(0,L.jsxs)(`label`,{className:`space-y-1 text-xs`,children:[(0,L.jsx)(`span`,{className:`font-medium`,children:`Role id (optional)`}),(0,L.jsx)(`input`,{value:T.role,onChange:e=>E(t=>({...t,role:e.target.value})),placeholder:`abc (generated from name)`,className:`h-9 w-full rounded border border-border bg-card px-2 font-mono`})]})]}),(0,L.jsxs)(`label`,{className:`block space-y-1 text-xs`,children:[(0,L.jsx)(`span`,{className:`font-medium`,children:`Purpose`}),(0,L.jsx)(`textarea`,{value:T.purpose,onChange:e=>E(t=>({...t,purpose:e.target.value})),placeholder:`Own X, Y and Z workflows for this project and verify their results.`,className:`h-24 w-full resize-y rounded border border-border bg-card p-2`})]}),(0,L.jsxs)(`label`,{className:`block space-y-1 text-xs`,children:[(0,L.jsx)(`span`,{className:`font-medium`,children:`Task types (comma or one per line)`}),(0,L.jsx)(`textarea`,{value:T.taskTypes,onChange:e=>E(t=>({...t,taskTypes:e.target.value})),placeholder:`X workflow
6
+ Y analysis
7
+ Z verification`,className:`h-24 w-full resize-y rounded border border-border bg-card p-2`})]}),x&&(0,L.jsx)(`p`,{className:`text-xs text-destructive`,children:x}),(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:V,disabled:y||!T.name.trim()||T.purpose.trim().length<10||!T.taskTypes.trim(),className:`rounded bg-primary px-3 py-1.5 text-xs text-primary-foreground disabled:opacity-50`,children:y?`Creating…`:`Clone Agent`}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>w(!1),className:`rounded border border-border px-3 py-1.5 text-xs hover:bg-accent`,children:`Cancel`})]})]}),!C&&!c&&(0,L.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground`,children:`Select an agent to edit customizations`}),!C&&c&&D&&(0,L.jsxs)(`div`,{className:`space-y-4 max-w-2xl`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsx)(`h3`,{className:`text-base font-semibold`,children:c}),(0,L.jsxs)(`div`,{className:`flex gap-1`,children:[(0,L.jsxs)(`button`,{type:`button`,onClick:z,className:`inline-flex items-center gap-1 rounded border border-border/50 px-2 py-1 text-[10px] hover:bg-accent transition-colors`,children:[(0,L.jsx)(s,{className:`h-3 w-3 text-brand-2`}),` LLM Improve`]}),(0,L.jsxs)(`button`,{type:`button`,onClick:()=>B(c),className:`inline-flex items-center gap-1 rounded border border-destructive/30 px-2 py-1 text-[10px] text-destructive hover:bg-destructive/10 transition-colors`,children:[(0,L.jsx)(a,{className:`h-3 w-3`}),` Reset`]})]})]}),(0,L.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[D.hasIdentity&&(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded bg-primary/10 px-2 py-1 text-[10px] text-primary`,children:[(0,L.jsx)(r,{className:`h-3 w-3`}),` identity.md`]}),D.hasConfig&&(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded bg-muted px-2 py-1 text-[10px] text-muted-foreground`,children:[(0,L.jsx)(p,{className:`h-3 w-3`}),` config.json`]}),D.hasKnowledge&&(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded bg-muted px-2 py-1 text-[10px] text-muted-foreground`,children:[(0,L.jsx)(u,{className:`h-3 w-3`}),` knowledge.json`]}),D.entryCount>0&&(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded bg-brand-2/10 px-2 py-1 text-[10px] text-brand-2`,children:[(0,L.jsx)(d,{className:`h-3 w-3`}),` `,D.entryCount,` learned entries`]})]}),(0,L.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,L.jsxs)(`button`,{type:`button`,onClick:()=>M(c,`identity`),className:`inline-flex items-center gap-1 rounded border border-border/50 px-3 py-1.5 text-xs hover:bg-accent transition-colors`,children:[(0,L.jsx)(r,{className:`h-3.5 w-3.5`}),` Edit identity.md`]}),(0,L.jsxs)(`button`,{type:`button`,onClick:()=>M(c,`learned`),className:`inline-flex items-center gap-1 rounded border border-border/50 px-3 py-1.5 text-xs hover:bg-accent transition-colors`,children:[(0,L.jsx)(d,{className:`h-3.5 w-3.5`}),` Edit learned.md`]}),(0,L.jsxs)(`button`,{type:`button`,onClick:()=>N(c),className:`inline-flex items-center gap-1 rounded border border-primary/40 bg-primary/5 px-3 py-1.5 text-xs text-primary hover:bg-primary/10 transition-colors`,children:[(0,L.jsx)(i,{className:`h-3.5 w-3.5`}),` Runtime policy`]}),(0,L.jsxs)(`button`,{type:`button`,onClick:()=>M(c,`config`),className:`inline-flex items-center gap-1 rounded border border-border/50 px-3 py-1.5 text-xs hover:bg-accent transition-colors`,children:[(0,L.jsx)(p,{className:`h-3.5 w-3.5`}),` Edit config.json`]})]}),x&&(0,L.jsx)(`p`,{className:`text-xs text-destructive`,children:x}),_&&(0,L.jsx)(W,{initialConfig:_,systemProtected:j,saving:y,onSave:P,onCancel:()=>v(null)},c),f&&(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`span`,{className:`text-xs font-medium`,children:[f,`.md / `,f,`.json`]}),(0,L.jsxs)(`div`,{className:`flex gap-1`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:R,disabled:y,className:`inline-flex items-center gap-1 rounded bg-primary px-3 py-1.5 text-xs text-primary-foreground hover:bg-primary/90 transition-colors disabled:opacity-50`,children:y?`Saving…`:`Save`}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>m(null),className:`inline-flex items-center gap-1 rounded border border-border/50 px-3 py-1.5 text-xs hover:bg-accent transition-colors`,children:`Cancel`})]})]}),(0,L.jsx)(`textarea`,{className:`w-full h-48 font-mono text-xs p-2 bg-card border border-border rounded resize-y`,value:h,onChange:e=>g(e.target.value),placeholder:f===`config`?`{ "tools": [...], "budget": {...} }`:`# Project identity for ${c}\n\nDescribe this agent's role…`})]})]})]})]})}function te({className:e}){let[t,n]=(0,I.useState)(`live`),[r,i]=(0,I.useState)(Date.now()),[a,o]=(0,I.useState)([]),[s,c]=(0,I.useState)(K),[l,u]=(0,I.useState)(!1),[d,p]=(0,I.useState)(null);(0,I.useEffect)(()=>{let e=setInterval(()=>{document.hidden||i(Date.now())},2e3);return()=>clearInterval(e)},[]);let h=(0,I.useCallback)(async()=>{u(!0),p(null);try{let e=await F(`agent-roster.list`,{});e.stats&&o(e.stats),e.catalog?.length&&c(e.catalog)}catch(e){p(e instanceof Error?e.message:`Failed to load roster`)}u(!1)},[]);return(0,I.useEffect)(()=>{h()},[h]),(0,L.jsxs)(`div`,{className:A(`flex h-full min-h-0 min-w-0 w-full flex-col overflow-hidden`,e),children:[(0,L.jsx)(`div`,{className:`shrink-0 border-b border-border/70 bg-card/80 px-4 py-2.5`,children:(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-2 flex-nowrap min-w-0`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 overflow-hidden`,children:[(0,L.jsx)(`div`,{className:`flex items-center justify-center w-8 h-8 shrink-0 rounded-lg bg-primary/10`,children:(0,L.jsx)(m,{className:`h-4 w-4 text-primary`})}),(0,L.jsxs)(`div`,{className:`min-w-0 overflow-hidden`,children:[(0,L.jsx)(`h1`,{className:`text-sm font-semibold truncate`,children:`Agent Roster`}),(0,L.jsxs)(`p`,{className:`text-[10px] text-muted-foreground truncate`,children:[a.filter(e=>e.exists||e.hasIdentity||e.hasConfig||e.hasKnowledge).length,` `,`customized · `,a.reduce((e,t)=>e+t.entryCount,0),` learned entries`]})]})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[l&&(0,L.jsx)(f,{className:`h-4 w-4 animate-spin text-muted-foreground shrink-0`}),(0,L.jsxs)(`button`,{type:`button`,onClick:h,className:`inline-flex items-center gap-1 rounded border border-border/50 px-2 py-1 text-[10px] hover:bg-accent transition-colors shrink-0 whitespace-nowrap`,title:`Refresh roster data`,children:[(0,L.jsx)(C,{className:`h-3 w-3`}),` Refresh`]})]})]})}),(0,L.jsx)(`div`,{className:`shrink-0 border-b border-border/50 bg-muted/20 px-3 flex gap-0`,children:G.map(e=>(0,L.jsxs)(`button`,{type:`button`,onClick:()=>n(e.id),className:A(`flex items-center gap-1.5 px-3 py-2 text-[10px] font-medium border-b-2 transition-colors`,t===e.id?`border-primary text-primary`:`border-transparent text-muted-foreground hover:text-foreground hover:border-muted-foreground/30`),children:[e.icon,e.label]},e.id))}),(0,L.jsxs)(`div`,{className:`flex min-h-0 min-w-0 w-full flex-1 overflow-hidden bg-background/50`,children:[d&&(0,L.jsxs)(`div`,{className:`flex items-center justify-center w-full text-destructive text-xs gap-2`,children:[(0,L.jsx)(_,{className:`h-4 w-4`}),d,(0,L.jsx)(`button`,{type:`button`,onClick:h,className:`underline`,children:`Retry`})]}),t===`live`&&(0,L.jsx)(X,{nowTick:r}),t===`catalog`&&(0,L.jsx)(Q,{customStats:a,catalog:s}),t===`learning`&&(0,L.jsx)($,{customStats:a,onRefresh:h}),t===`customize`&&(0,L.jsx)(ee,{customStats:a,catalog:s,onRefresh:h})]})]})}export{te as AgentRosterView};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Ai as t,An as n,Tt as r,Vn as i,Zr as a,aa as o,bt as s,ei as c,na as l,pt as u,tt as d,ua as f,xt as p}from"./vendor-BmsAdDhb.js";import"./i18n-c37VNlP9.js";import{t as m}from"./ws-client-BydCS6yi.js";import{j as h}from"./stores-DVhvmaer.js";import{d as g,f as _,y as v}from"./index-196U0qsu.js";var y=e(f(),1),b=d();function x(e){let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m ${t%60}s`;let r=Math.floor(n/60);return r<24?`${r}h ${n%60}m`:`${Math.floor(r/24)}d`}function S(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function C(e){return e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}function w(e){return new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function T(e){return e.includes(`error`)||e.includes(`fail`)?`text-destructive`:e.includes(`warn`)?`text-warning`:e.includes(`success`)||e.includes(`complete`)?`text-success`:`text-muted-foreground`}function E({icon:e,label:t,value:n,sub:r,color:i=`text-muted-foreground`}){return(0,b.jsxs)(`div`,{className:`flex items-start gap-3 rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,b.jsx)(`div`,{className:`mt-0.5 ${i}`,children:e}),(0,b.jsxs)(`div`,{className:`min-w-0`,children:[(0,b.jsx)(`div`,{className:`text-2xl font-semibold tabular-nums text-foreground`,children:n}),(0,b.jsx)(`div`,{className:`mt-0.5 text-xs text-muted-foreground`,children:t}),r?(0,b.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground/70`,children:r}):null]})]})}function D(){let{t:e}=o(),[d,f]=(0,y.useState)(null),[D,O]=(0,y.useState)([]),[k,A]=(0,y.useState)([]),[j,M]=(0,y.useState)(null),[N,P]=(0,y.useState)(!0),[F,I]=(0,y.useState)(!1),L=(0,y.useRef)(null),R=(0,y.useCallback)(async()=>{try{let e=await fetch(`/api/analytics/summary`);if(e.ok){let t=await e.json();f(t)}}catch{}},[]),z=(0,y.useCallback)(async()=>{try{let e=await fetch(`/api/analytics?limit=50`);if(e.ok){let t=await e.json();O(t.events)}}catch{}},[]),B=(0,y.useCallback)(async()=>{try{let e=await fetch(`/api/sessions`);if(e.ok){let t=await e.json();A(t)}}catch{}},[]),V=(0,y.useCallback)(async()=>{if(!F){I(!0);try{let e=m(h.getState().wsUrl);L.current=e;let t=e.on(`stats.get`,e=>{let n=e.payload;M(n),I(!1),t()});e.getStats({echoToChat:!1}),setTimeout(()=>{I(!1),t()},8e3)}catch{I(!1)}}},[F]);(0,y.useEffect)(()=>{let e=()=>{Promise.all([R(),z(),B(),V()]).finally(()=>P(!1))};e();let t=setInterval(e,1e4);return()=>clearInterval(t)},[R,z,B,V]);let{totalAgents:H,activeAgents:U,totalToolCalls:W,totalIterations:G}=(0,y.useMemo)(()=>{let e=0,t=0,n=0,r=0;for(let i of k)for(let a of i.agents)e++,a.status===`running`&&t++,n+=a.toolCalls,r+=a.iterations;return{totalAgents:e,activeAgents:t,totalToolCalls:n,totalIterations:r}},[k]),K=(0,y.useMemo)(()=>d?Object.entries(d.categoryBreakdown).sort((e,t)=>t[1]-e[1]).slice(0,8):[],[d]),q=(0,y.useMemo)(()=>d?Object.entries(d.eventBreakdown).sort((e,t)=>t[1]-e[1]).slice(0,10):[],[d]),J=(0,y.useMemo)(()=>{if(!d)return 0;let e=0;for(let[t,n]of Object.entries(d.eventBreakdown))t.toLowerCase().includes(`error`)&&(e+=n);return e},[d]),Y=(0,y.useMemo)(()=>{if(!d)return 0;let e=0;for(let[t,n]of Object.entries(d.eventBreakdown))t.toLowerCase().includes(`warn`)&&(e+=n);return e},[d]),X=_((0,y.useMemo)(()=>[...D].reverse(),[D]),20);return N?(0,b.jsx)(`div`,{className:`flex h-full min-h-0 items-center justify-center bg-[hsl(var(--surface-2)/0.45)] p-4`,children:(0,b.jsxs)(`div`,{className:`ws-surface flex items-center gap-2 rounded-xl px-4 py-3 text-sm text-muted-foreground`,children:[(0,b.jsx)(i,{className:`h-4 w-4 animate-spin text-primary`}),e(`activity:analytics.loading`)]})}):(0,b.jsx)(`div`,{ref:v(`analytics`),className:`h-full min-h-0 min-w-0 overflow-y-auto overscroll-contain bg-[hsl(var(--surface-2)/0.45)] p-4 sm:p-6`,children:(0,b.jsxs)(`div`,{className:`mx-auto flex w-full max-w-7xl flex-col gap-5`,children:[(0,b.jsx)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:(0,b.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between`,children:[(0,b.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,b.jsx)(t,{className:`h-4 w-4 text-primary`}),(0,b.jsx)(`h1`,{className:`truncate text-base font-semibold`,children:e(`activity:analytics.heading`)})]}),(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e(`activity:analytics.autoRefresh`)})]})}),(0,b.jsxs)(`div`,{className:`min-w-0 space-y-5`,children:[(0,b.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3`,children:[(0,b.jsx)(E,{icon:(0,b.jsx)(l,{className:`h-4 w-4`}),label:e(`activity:analytics.liveSessions`),value:k.length,color:`text-primary`}),(0,b.jsx)(E,{icon:(0,b.jsx)(u,{className:`h-4 w-4`}),label:e(`activity:analytics.agents`),value:`${U}/${H}`,sub:U>0?e(`activity:analytics.agentsActive`,{count:U}):void 0,color:`text-success`}),(0,b.jsx)(E,{icon:(0,b.jsx)(n,{className:`h-4 w-4`}),label:e(`activity:analytics.totalEvents`),value:d?.totalEvents??0,sub:e(`activity:analytics.categoriesSub`,{count:d?.uniqueCategories??0}),color:`text-warning`}),(0,b.jsx)(E,{icon:(0,b.jsx)(r,{className:`h-4 w-4`}),label:e(`activity:analytics.toolCalls`),value:W,sub:e(`activity:analytics.iterationsSub`,{count:G}),color:`text-success`}),(0,b.jsx)(E,{icon:(0,b.jsx)(a,{className:`h-4 w-4`}),label:e(`activity:analytics.sessionCost`),value:j?C(j.cost):`—`,sub:j?e(`activity:analytics.tokensSub`,{input:S(j.usage.input),output:S(j.usage.output)}):void 0,color:`text-primary`}),(0,b.jsx)(E,{icon:(0,b.jsx)(c,{className:`h-4 w-4`}),label:e(`activity:analytics.sessionDuration`),value:j?x(j.elapsedMs):`—`,sub:j?e(`activity:analytics.messagesSub`,{count:j.messages}):void 0,color:`text-muted-foreground`})]}),(0,b.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-4`,children:[(0,b.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,b.jsxs)(`h3`,{className:`mb-3 flex items-center gap-2 text-xs font-semibold uppercase text-muted-foreground`,children:[(0,b.jsx)(p,{className:`h-3.5 w-3.5 text-primary`}),e(`activity:analytics.eventsByCategory`)]}),K.length===0?(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`activity:analytics.noEvents`)}):(0,b.jsx)(`div`,{className:`space-y-1.5`,children:K.map(([e,t])=>{let n=K[0]?.[1]??1,r=Math.round(t/n*100);return(0,b.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,7rem)_minmax(0,1fr)_2.5rem] items-center gap-2 text-xs`,children:[(0,b.jsx)(`span`,{className:`min-w-0 truncate text-foreground`,children:e}),(0,b.jsx)(`div`,{className:`h-4 overflow-hidden rounded-full bg-muted`,children:(0,b.jsx)(`div`,{className:`h-full rounded-full bg-primary/70 transition-all`,style:{width:`${Math.max(r,4)}%`}})}),(0,b.jsx)(`span`,{className:`text-right tabular-nums text-muted-foreground`,children:t})]},e)})})]}),(0,b.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,b.jsxs)(`h3`,{className:`mb-3 flex items-center gap-2 text-xs font-semibold uppercase text-muted-foreground`,children:[(0,b.jsx)(t,{className:`h-3.5 w-3.5 text-warning`}),e(`activity:analytics.topEvents`)]}),q.length===0?(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`activity:analytics.noEvents`)}):(0,b.jsx)(`div`,{className:`space-y-1.5`,children:q.map(([e,t])=>{let n=q[0]?.[1]??1,r=Math.round(t/n*100);return(0,b.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,9rem)_minmax(0,1fr)_2.5rem] items-center gap-2 text-xs`,children:[(0,b.jsx)(`span`,{className:`min-w-0 truncate ${T(e)}`,children:e}),(0,b.jsx)(`div`,{className:`h-4 overflow-hidden rounded-full bg-muted`,children:(0,b.jsx)(`div`,{className:`h-full rounded-full bg-warning/70 transition-all`,style:{width:`${Math.max(r,4)}%`}})}),(0,b.jsx)(`span`,{className:`text-right tabular-nums text-muted-foreground`,children:t})]},e)})})]})]}),(0,b.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-4`,children:[(0,b.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,b.jsxs)(`h3`,{className:`mb-3 flex items-center gap-2 text-xs font-semibold uppercase text-muted-foreground`,children:[(0,b.jsx)(a,{className:`h-3.5 w-3.5 text-primary`}),e(`activity:analytics.activeSessionUsage`)]}),j?(0,b.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 text-xs`,children:[(0,b.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-border/70 bg-background/50 px-3 py-2`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.provider`)}),(0,b.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-foreground`,children:j.provider})]}),(0,b.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-border/70 bg-background/50 px-3 py-2`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.model`)}),(0,b.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-foreground`,children:j.model})]}),(0,b.jsxs)(`div`,{className:`rounded-lg border border-border/70 bg-background/50 px-3 py-2`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.inputTokens`)}),(0,b.jsx)(`p`,{className:`mt-0.5 tabular-nums text-foreground`,children:S(j.usage.input)})]}),(0,b.jsxs)(`div`,{className:`rounded-lg border border-border/70 bg-background/50 px-3 py-2`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.outputTokens`)}),(0,b.jsx)(`p`,{className:`mt-0.5 tabular-nums text-foreground`,children:S(j.usage.output)})]}),(0,b.jsxs)(`div`,{className:`rounded-lg border border-border/70 bg-background/50 px-3 py-2`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.cacheRatio`)}),(0,b.jsxs)(`p`,{className:`mt-0.5 tabular-nums text-foreground`,children:[(j.cache.ratio*100).toFixed(1),`%`]})]}),(0,b.jsxs)(`div`,{className:`rounded-lg border border-border/70 bg-background/50 px-3 py-2`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.filesRead`)}),(0,b.jsx)(`p`,{className:`mt-0.5 tabular-nums text-foreground`,children:j.readFiles})]})]}):(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`activity:analytics.noSession`)})]}),(0,b.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,b.jsxs)(`h3`,{className:`mb-3 flex items-center gap-2 text-xs font-semibold uppercase text-muted-foreground`,children:[(0,b.jsx)(s,{className:`h-3.5 w-3.5 text-warning`}),e(`activity:analytics.healthErrors`)]}),(0,b.jsx)(`div`,{className:`space-y-2 text-xs`,children:d?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{className:`flex justify-between`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.errorEvents`)}),(0,b.jsx)(`span`,{className:`tabular-nums text-destructive`,children:J})]}),(0,b.jsxs)(`div`,{className:`flex justify-between`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.warningEvents`)}),(0,b.jsx)(`span`,{className:`tabular-nums text-warning`,children:Y})]}),(0,b.jsxs)(`div`,{className:`flex justify-between`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.cacheHitRate`)}),(0,b.jsx)(`span`,{className:`tabular-nums text-success`,children:j?`${(j.cache.ratio*100).toFixed(1)}%`:`—`})]}),(0,b.jsxs)(`div`,{className:`flex justify-between`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.totalCategories`)}),(0,b.jsx)(`span`,{className:`tabular-nums text-foreground`,children:d.uniqueCategories})]})]}):(0,b.jsx)(`p`,{className:`text-muted-foreground`,children:e(`activity:analytics.waitingData`)})})]})]}),(0,b.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,b.jsxs)(`h3`,{className:`mb-3 flex items-center gap-2 text-xs font-semibold uppercase text-muted-foreground`,children:[(0,b.jsx)(l,{className:`h-3.5 w-3.5 text-primary`}),e(`activity:analytics.recentEvents`)]}),D.length===0?(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`activity:analytics.noRecentEvents`)}):(0,b.jsx)(`div`,{className:`max-h-64 space-y-1 overflow-y-auto`,children:X.pageItems.map((e,t)=>(0,b.jsxs)(`div`,{className:`grid grid-cols-[4rem_minmax(0,7rem)_minmax(0,6rem)_minmax(0,1fr)] items-start gap-2 rounded px-2 py-1 text-xs hover:bg-muted/60`,children:[(0,b.jsx)(`span`,{className:`tabular-nums text-muted-foreground/70`,children:w(e.timestamp)}),(0,b.jsx)(`span`,{className:`min-w-0 truncate ${T(e.event)}`,children:e.event}),(0,b.jsx)(`span`,{className:`min-w-0 truncate text-muted-foreground`,children:e.category}),(0,b.jsx)(`span`,{className:`min-w-0 truncate text-foreground/80`,children:e.label??e.sessionId??``})]},`${e.timestamp}-${t}`))}),(0,b.jsx)(g,{page:X.page,pageSize:X.pageSize,totalItems:X.totalItems,onPageChange:X.setPage,compact:!0,itemLabel:`events`,className:`mt-3 rounded-lg border`})]})]})]})})}export{D as AnalyticsDashboard};
@@ -0,0 +1,3 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Ct as t,Dt as n,Xr as r,cn as i,ot as a,qt as o,rn as s,tt as c,ua as l,vr as u,vt as d,zt as f}from"./vendor-BmsAdDhb.js";import{t as p}from"./useWebSocket-kb2VPjLc.js";import{t as m}from"./utils-DvgvNCoT.js";import{a as h,i as g,n as _,o as v,r as y,t as b}from"./dialog-BjPQYovj.js";import{t as x}from"./button-GVbauxIJ.js";import{t as S}from"./input-BVi5hYQz.js";import{d as C,f as w}from"./index-196U0qsu.js";import{g as T,i as E,r as D,y as O}from"./shared-BQ9yQXDx.js";var k=e(l(),1),A=c();function j(e){if(!Array.isArray(e))return;let t=[...new Set(e.filter(e=>typeof e==`string`).map(e=>e.trim()).filter(Boolean))];return t.length>0?t:void 0}function M(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e,n={roles:j(t.roles),taskTypes:j(t.taskTypes),modes:j(t.modes)};return n.roles||n.taskTypes||n.modes?n:void 0}function ee(e){let t=e.trim().replace(/^```(?:json)?\s*/i,``).replace(/\s*```$/,``),n=JSON.parse(t);if(!Array.isArray(n))throw Error(`Input must be a JSON array.`);let r=[],i=0;for(let e of n){if(!e||typeof e!=`object`||Array.isArray(e)){i++;continue}let t=e,n=typeof t.text==`string`?t.text.trim():``,a=M(t.audience);if(!n||!a){i++;continue}let o=typeof t.kind==`string`&&E.some(e=>e===t.kind)?t.kind:void 0,s=j(t.tags);r.push({text:n,audience:a,kind:o,tags:s,importance:typeof t.importance==`number`?t.importance:void 0,confidence:typeof t.confidence==`number`?t.confidence:void 0})}return{entries:r,skipped:i}}function te(e,t){if(!t)return!0;let n=e.audience;return[e.text,e.kind,e.status,...n?.roles??[],...n?.taskTypes??[],...n?.modes??[]].join(` `).toLocaleLowerCase().includes(t.toLocaleLowerCase())}function N(e,t){return[...new Set(e.flatMap(e=>e.audience?.[t]??[]).filter(e=>e.length>0))].sort((e,t)=>e.localeCompare(t))}function P(){let e=p(),[c,l]=(0,k.useState)([]),[f,E]=(0,k.useState)(!0),[D,O]=(0,k.useState)(null),[j,M]=(0,k.useState)(``),[P,L]=(0,k.useState)(!1),[B,V]=(0,k.useState)(!1),[H,U]=(0,k.useState)(null),[W,G]=(0,k.useState)(!1),[K,q]=(0,k.useState)(!1),J=(0,k.useRef)(null),Y=(0,k.useCallback)(()=>{E(!0),O(null),e.listSageMemories({echoToChat:!1})},[e.listSageMemories]);(0,k.useEffect)(()=>{let t=e.client,n=t.on(`memory.sage.list`,e=>{let t=e.payload;t.error?O({tone:`error`,text:t.error}):l(t.memories??[]),E(!1)}),r=t.on(`memory.sage.remember`,e=>{let t=e.payload;if(G(!1),t.error){O({tone:`error`,text:t.error});return}t.memory&&(l(e=>[t.memory,...e.filter(e=>e.id!==t.memory.id)]),L(!1))}),i=t.on(`memory.sage.update`,e=>{let t=e.payload;t.error?O({tone:`error`,text:t.error}):t.memory&&(l(e=>e.map(e=>e.id===t.memory.id?t.memory:e)),t.memory.audience||O({tone:`success`,text:`Audience scope removed. The memory is now general.`}))}),a=t.on(`memory.sage.delete`,e=>{let t=e.payload,n=J.current;t.success&&n?(l(e=>e.filter(e=>e.id!==n)),O({tone:`success`,text:`Audience memory deleted.`}),U(null),q(!1),J.current=null):t.success?Y():(O({tone:`error`,text:t.message??`Could not delete the memory.`}),q(!1),J.current=null)});return Y(),()=>{n(),r(),i(),a()}},[Y,e.client]);let X=(0,k.useMemo)(()=>c.filter(e=>{let t=e.audience;return!!(t&&(t.roles?.length||t.taskTypes?.length||t.modes?.length))}),[c]),Z=j.trim(),Q=(0,k.useMemo)(()=>X.filter(e=>te(e,Z)),[Z,X]),$=w(Q,16,Z),ie=(0,k.useMemo)(()=>N(X,`roles`),[X]),ae=(0,k.useMemo)(()=>N(X,`taskTypes`),[X]),oe=(0,k.useMemo)(()=>N(X,`modes`),[X]),se=t=>{O(null),e.updateSage(t,{audience:void 0},{echoToChat:!1})},ce=()=>{H&&(J.current=H,q(!0),O(null),e.deleteSage(H,`Removed from the audience memory panel.`))},le=async()=>{let e=X.map(e=>({id:e.id,text:e.text,kind:e.kind,status:e.status,audience:e.audience,tags:e.tags,importance:e.importance,confidence:e.confidence}));try{if(!navigator.clipboard)throw Error(`Clipboard access is unavailable.`);await navigator.clipboard.writeText(JSON.stringify(e,null,2)),O({tone:`success`,text:`${e.length} audience memor${e.length===1?`y`:`ies`} copied as JSON.`})}catch(e){O({tone:`error`,text:e instanceof Error?e.message:`Failed to copy JSON to the clipboard.`})}};return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col bg-card/20`,"aria-labelledby":`audience-memory-title`,children:[(0,A.jsxs)(`div`,{className:`shrink-0 border-b border-border/60 p-3`,children:[(0,A.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,A.jsx)(`div`,{className:`min-w-0`,children:(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center rounded-md border border-primary/20 bg-primary/10 text-primary`,children:(0,A.jsx)(n,{className:`size-3.5`})}),(0,A.jsxs)(`div`,{className:`min-w-0`,children:[(0,A.jsx)(`h2`,{id:`audience-memory-title`,className:`truncate text-sm font-semibold`,children:`Audience Memory`}),(0,A.jsx)(`p`,{className:`truncate text-[10px] text-muted-foreground`,children:`Guidance routed to matching agents`})]})]})}),(0,A.jsxs)(x,{variant:`default`,size:`sm`,className:`h-7 shrink-0 gap-1 px-2 text-xs`,onClick:()=>L(!0),children:[(0,A.jsx)(i,{className:`size-3`}),`Add`]})]}),(0,A.jsxs)(`div`,{className:`mt-3 grid grid-cols-4 gap-px overflow-hidden rounded-md border border-border/60 bg-border/60`,children:[(0,A.jsx)(F,{value:X.length,label:`Memories`}),(0,A.jsx)(F,{value:ie.length,label:`Roles`}),(0,A.jsx)(F,{value:ae.length,label:`Tasks`}),(0,A.jsx)(F,{value:oe.length,label:`Modes`})]}),(0,A.jsxs)(`div`,{className:`mt-3 flex items-center gap-1.5`,children:[(0,A.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,A.jsx)(o,{className:`pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,A.jsx)(S,{value:j,onChange:e=>M(e.target.value),placeholder:`Search text, role, task or mode…`,"aria-label":`Search audience memories`,className:`h-8 pl-8 pr-8 text-xs`}),j&&(0,A.jsx)(`button`,{type:`button`,className:`absolute right-2 top-1/2 -translate-y-1/2 rounded-sm p-0.5 text-muted-foreground hover:text-foreground`,onClick:()=>M(``),"aria-label":`Clear audience memory search`,children:(0,A.jsx)(a,{className:`size-3`})})]}),(0,A.jsx)(x,{variant:`ghost`,size:`icon`,className:`size-8 shrink-0`,onClick:Y,"aria-label":`Refresh audience memories`,title:`Refresh`,children:(0,A.jsx)(s,{className:m(`size-3.5`,f&&`animate-spin`)})}),(0,A.jsx)(x,{variant:`ghost`,size:`icon`,className:`size-8 shrink-0`,onClick:()=>V(!0),"aria-label":`Import audience memories`,title:`Import JSON`,children:(0,A.jsx)(d,{className:`size-3.5`})}),(0,A.jsx)(x,{variant:`ghost`,size:`icon`,className:`size-8 shrink-0`,onClick:()=>void le(),"aria-label":`Copy audience memories as JSON`,title:`Copy JSON`,disabled:X.length===0,children:(0,A.jsx)(r,{className:`size-3.5`})})]})]}),D&&(0,A.jsxs)(`div`,{role:D.tone===`error`?`alert`:`status`,className:m(`mx-3 mt-3 flex shrink-0 items-start justify-between gap-2 rounded-md border px-2.5 py-2 text-[11px]`,D.tone===`error`?`border-destructive/30 bg-destructive/5 text-destructive`:`border-success/30 bg-success/5 text-success`),children:[(0,A.jsx)(`span`,{children:D.text}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>O(null),className:`shrink-0 rounded-sm opacity-70 hover:opacity-100`,"aria-label":`Dismiss message`,children:(0,A.jsx)(a,{className:`size-3`})})]}),(0,A.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[!f&&X.length>0&&(0,A.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between px-3 pb-1.5 pt-3 text-[10px] text-muted-foreground`,children:[(0,A.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,A.jsx)(u,{className:`size-3`}),Z?`${Q.length} of ${X.length}`:`${X.length} scoped`]}),Z&&(0,A.jsx)(`button`,{type:`button`,className:`hover:text-foreground`,onClick:()=>M(``),children:`Clear filter`})]}),(0,A.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-3`,children:[f?(0,A.jsx)(R,{}):X.length===0?(0,A.jsx)(z,{onAdd:()=>L(!0)}):Q.length===0?(0,A.jsxs)(`div`,{className:`flex h-full min-h-32 flex-col items-center justify-center px-4 text-center`,children:[(0,A.jsx)(o,{className:`mb-2 size-5 text-muted-foreground/60`}),(0,A.jsx)(`p`,{className:`text-xs font-medium`,children:`No matching memories`}),(0,A.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:`Try another role, task, mode, or phrase.`}),(0,A.jsx)(x,{variant:`ghost`,size:`sm`,className:`mt-2 h-7 text-xs`,onClick:()=>M(``),children:`Clear search`})]}):(0,A.jsx)(`ul`,{className:`space-y-2`,children:$.pageItems.map(e=>(0,A.jsx)(I,{memory:e,onFilter:M,onClearScope:()=>se(e.id),onDelete:()=>U(e.id)},e.id))}),(0,A.jsx)(C,{page:$.page,pageSize:$.pageSize,totalItems:$.totalItems,onPageChange:$.setPage,compact:!0,itemLabel:`memories`})]})]})]}),(0,A.jsx)(ne,{open:P,busy:W,onOpenChange:e=>{W||L(e)},onCreate:t=>{O(null),G(!0),e.rememberSage({text:t.text,kind:t.kind,audience:{roles:t.roles.length>0?t.roles:void 0,taskTypes:t.taskTypes.length>0?t.taskTypes:void 0,modes:t.modes.length>0?t.modes:void 0}},{echoToChat:!1})}}),(0,A.jsx)(re,{open:B,onOpenChange:V,onImport:t=>{try{let{entries:n,skipped:r}=ee(t);if(n.length===0)return O({tone:`error`,text:`No valid audience-scoped memories were found in the JSON.`}),!1;for(let t of n)e.rememberSage(t,{echoToChat:!1});return O({tone:`success`,text:`${n.length} memor${n.length===1?`y`:`ies`} queued for import${r?`; ${r} invalid ${r===1?`entry was`:`entries were`} skipped`:``}.`}),V(!1),!0}catch(e){return O({tone:`error`,text:e instanceof Error?e.message:`Invalid JSON.`}),!1}}}),(0,A.jsx)(b,{open:!!H,onOpenChange:e=>{!e&&!K&&U(null)},children:(0,A.jsxs)(_,{className:`max-w-md`,children:[(0,A.jsxs)(h,{children:[(0,A.jsx)(v,{children:`Delete this audience memory?`}),(0,A.jsx)(y,{children:`This removes the memory from active use. To keep it as general project guidance, cancel and use the un-scope action instead.`})]}),(0,A.jsx)(`div`,{className:`rounded-md border border-border/70 bg-background/45 p-3 text-xs text-muted-foreground`,children:T(c.find(e=>e.id===H)?.text??``,180)}),(0,A.jsxs)(g,{children:[(0,A.jsx)(x,{variant:`outline`,onClick:()=>U(null),disabled:K,children:`Cancel`}),(0,A.jsxs)(x,{variant:`destructive`,onClick:ce,disabled:K,children:[(0,A.jsx)(t,{className:`size-4`}),K?`Deleting…`:`Delete memory`]})]})]})})]})}function F({value:e,label:t}){return(0,A.jsxs)(`div`,{className:`bg-card/95 px-1.5 py-2 text-center`,children:[(0,A.jsx)(`p`,{className:`text-sm font-semibold tabular-nums`,children:e}),(0,A.jsx)(`p`,{className:`truncate text-[9px] uppercase tracking-wide text-muted-foreground`,children:t})]})}function I({memory:e,onFilter:n,onClearScope:r,onDelete:i}){return(0,A.jsxs)(`li`,{className:`group rounded-md border border-border/65 bg-card/55 p-2.5 transition-colors hover:border-border hover:bg-card/85`,children:[(0,A.jsx)(`p`,{className:`break-words text-xs leading-5`,children:e.text}),e.audience&&(0,A.jsx)(L,{audience:e.audience,onFilter:n}),(0,A.jsxs)(`div`,{className:`mt-2 flex items-center justify-between gap-2 border-t border-border/45 pt-2`,children:[(0,A.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-[9px] uppercase tracking-wide text-muted-foreground`,children:[(0,A.jsx)(`span`,{className:`truncate`,children:D[e.kind]??e.kind}),(0,A.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,A.jsx)(`span`,{children:e.status})]}),(0,A.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[(0,A.jsx)(x,{variant:`ghost`,size:`icon`,className:`size-6`,onClick:r,"aria-label":`Remove audience scope from ${T(e.text,42)}`,title:`Make general memory`,children:(0,A.jsx)(f,{className:`size-3`})}),(0,A.jsx)(x,{variant:`ghost`,size:`icon`,className:`size-6 text-destructive hover:text-destructive`,onClick:i,"aria-label":`Delete ${T(e.text,42)}`,title:`Delete`,children:(0,A.jsx)(t,{className:`size-3`})})]})]})]})}function L({audience:e,onFilter:t}){return(0,A.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[...(e.roles??[]).map(e=>({label:`role`,value:e})),...(e.taskTypes??[]).map(e=>({label:`task`,value:e})),...(e.modes??[]).map(e=>({label:`mode`,value:e}))].map(({label:e,value:n})=>(0,A.jsxs)(`button`,{type:`button`,className:`max-w-full truncate rounded border border-primary/15 bg-primary/7 px-1.5 py-0.5 font-mono text-[9px] text-primary/90 transition-colors hover:border-primary/35 hover:bg-primary/12`,onClick:()=>t(n),title:`Filter by ${e}: ${n}`,children:[e,`:`,n]},`${e}:${n}`))})}function R(){return(0,A.jsx)(`div`,{className:`space-y-2 pt-3`,role:`status`,"aria-label":`Loading audience memories`,children:[0,1,2].map(e=>(0,A.jsxs)(`div`,{className:`animate-pulse rounded-md border border-border/50 p-3`,children:[(0,A.jsx)(`div`,{className:`h-2.5 w-full rounded bg-muted`}),(0,A.jsx)(`div`,{className:`mt-2 h-2.5 w-2/3 rounded bg-muted`}),(0,A.jsx)(`div`,{className:`mt-3 h-4 w-24 rounded bg-muted`})]},e))})}function z({onAdd:e}){return(0,A.jsxs)(`div`,{className:`flex h-full min-h-44 flex-col items-center justify-center px-5 text-center`,children:[(0,A.jsx)(`span`,{className:`mb-3 flex size-10 items-center justify-center rounded-full border border-dashed border-primary/35 bg-primary/5 text-primary`,children:(0,A.jsx)(n,{className:`size-4`})}),(0,A.jsx)(`p`,{className:`text-xs font-medium`,children:`Route guidance to the right agents`}),(0,A.jsx)(`p`,{className:`mt-1 max-w-52 text-[10px] leading-4 text-muted-foreground`,children:`Scope a memory by role, task type, or operating mode. Matching agents receive it automatically.`}),(0,A.jsxs)(x,{variant:`outline`,size:`sm`,className:`mt-3 h-7 gap-1 text-xs`,onClick:e,children:[(0,A.jsx)(i,{className:`size-3`}),`Add scoped memory`]})]})}function ne({open:e,busy:t,onOpenChange:n,onCreate:r}){let[i,a]=(0,k.useState)(``),[o,s]=(0,k.useState)(`workflow`),[c,l]=(0,k.useState)(``),[u,d]=(0,k.useState)(``),[f,p]=(0,k.useState)(``);(0,k.useEffect)(()=>{e||(a(``),s(`workflow`),l(``),d(``),p(``))},[e]);let m=O(c),S=O(u),C=O(f),w=i.trim().length>0&&(m.length>0||S.length>0||C.length>0);return(0,A.jsx)(b,{open:e,onOpenChange:n,children:(0,A.jsxs)(_,{className:`max-w-xl`,children:[(0,A.jsxs)(h,{children:[(0,A.jsx)(v,{children:`Add audience-scoped memory`}),(0,A.jsx)(y,{children:`This guidance is injected only when an agent matches at least one supplied selector.`})]}),(0,A.jsxs)(`div`,{className:`space-y-4`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{htmlFor:`audience-memory-text`,className:`mb-1.5 block text-xs font-medium`,children:`Memory`}),(0,A.jsx)(`textarea`,{id:`audience-memory-text`,value:i,onChange:e=>a(e.target.value),placeholder:`What should matching agents remember?`,rows:4,autoFocus:!0,className:`w-full resize-y rounded-md border border-input bg-background px-3 py-2 text-sm outline-none placeholder:text-muted-foreground focus-visible:ring-2 focus-visible:ring-ring`})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{htmlFor:`audience-memory-kind`,className:`mb-1.5 block text-xs font-medium`,children:`Kind`}),(0,A.jsx)(`select`,{id:`audience-memory-kind`,value:o,onChange:e=>s(e.target.value),className:`h-9 w-full rounded-md border border-input bg-background px-3 text-xs outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:E.map(e=>(0,A.jsx)(`option`,{value:e,children:D[e]??e},e))})]}),(0,A.jsxs)(`fieldset`,{className:`space-y-3 rounded-md border border-border/70 bg-background/35 p-3`,children:[(0,A.jsx)(`legend`,{className:`px-1 text-xs font-medium`,children:`Audience selectors`}),(0,A.jsx)(B,{id:`audience-memory-roles`,label:`Roles`,value:c,onChange:l,placeholder:`reviewer, refactor-planner`}),(0,A.jsx)(B,{id:`audience-memory-task-types`,label:`Task types`,value:u,onChange:d,placeholder:`review, refactor, bugfix`}),(0,A.jsx)(B,{id:`audience-memory-modes`,label:`Modes`,value:f,onChange:p,placeholder:`teach, code-review`}),(0,A.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Comma-separate multiple values. At least one selector is required.`})]})]}),(0,A.jsxs)(g,{children:[(0,A.jsx)(x,{variant:`outline`,onClick:()=>n(!1),disabled:t,children:`Cancel`}),(0,A.jsx)(x,{onClick:()=>r({text:i.trim(),kind:o,roles:m,taskTypes:S,modes:C}),disabled:!w||t,children:t?`Remembering…`:`Remember`})]})]})})}function B({id:e,label:t,value:n,placeholder:r,onChange:i}){return(0,A.jsxs)(`div`,{className:`grid gap-1.5 sm:grid-cols-[6rem_1fr] sm:items-center`,children:[(0,A.jsx)(`label`,{htmlFor:e,className:`text-[11px] font-medium text-muted-foreground`,children:t}),(0,A.jsx)(S,{id:e,value:n,onChange:e=>i(e.target.value),placeholder:r,className:`h-8 font-mono text-xs`})]})}function re({open:e,onOpenChange:t,onImport:n}){let[r,i]=(0,k.useState)(``);return(0,k.useEffect)(()=>{e||i(``)},[e]),(0,A.jsx)(b,{open:e,onOpenChange:t,children:(0,A.jsxs)(_,{className:`max-w-xl`,children:[(0,A.jsxs)(h,{children:[(0,A.jsx)(v,{children:`Import audience memories`}),(0,A.jsxs)(y,{children:[`Paste the JSON produced here or by `,(0,A.jsx)(`code`,{children:`/memory audience export`}),`. Entries without a valid audience selector are skipped.`]})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{htmlFor:`audience-memory-import`,className:`mb-1.5 block text-xs font-medium`,children:`JSON array`}),(0,A.jsx)(`textarea`,{id:`audience-memory-import`,value:r,onChange:e=>i(e.target.value),placeholder:`[
2
+ { "text": "…", "audience": { "roles": ["reviewer"] } }
3
+ ]`,rows:10,autoFocus:!0,spellCheck:!1,className:`w-full resize-y rounded-md border border-input bg-background p-3 font-mono text-xs outline-none placeholder:text-muted-foreground focus-visible:ring-2 focus-visible:ring-ring`})]}),(0,A.jsxs)(g,{children:[(0,A.jsx)(x,{variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,A.jsxs)(x,{onClick:()=>n(r),disabled:!r.trim(),children:[(0,A.jsx)(d,{className:`size-4`}),`Import memories`]})]})]})})}export{P as AudienceMemoryPanel};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Lr as t,Oi as n,Vn as r,Xt as i,Yt as a,aa as o,ai as s,b as c,rn as l,tt as u,ua as d}from"./vendor-BmsAdDhb.js";import"./i18n-c37VNlP9.js";import{a as f,n as p,t as m}from"./monaco-C7izDJhg.js";import{t as h}from"./ws-client-BydCS6yi.js";import{t as g}from"./utils-DvgvNCoT.js";import{h as _,j as v}from"./stores-DVhvmaer.js";import{x as y}from"./index-196U0qsu.js";import{t as b}from"./empty-state-DJc37Wg1.js";import{t as x}from"./monaco-theme-BoNOJHQB.js";var S=e(d(),1),C=u();p.config({monaco:m});var w={ts:`typescript`,tsx:`typescript`,js:`javascript`,jsx:`javascript`,mjs:`javascript`,json:`json`,css:`css`,scss:`scss`,html:`html`,md:`markdown`,py:`python`,go:`go`,rs:`rust`,java:`java`,c:`c`,cpp:`cpp`,cs:`csharp`,rb:`ruby`,php:`php`,sh:`shell`,bash:`shell`,yml:`yaml`,yaml:`yaml`,toml:`toml`,sql:`sql`};function T(e){return w[e.split(`.`).pop()?.toLowerCase()??``]??`plaintext`}function E({path:e,oldText:t,newText:i}){let{t:s}=o(),l=(0,S.useRef)(null),[u,d]=(0,S.useState)(!1),[p,m]=(0,S.useState)(!1),[g,_]=(0,S.useState)(null);(0,S.useEffect)(()=>{d(!1),m(!1),_(null)},[]);let y=(0,S.useCallback)(e=>{l.current=e,f.setTheme(x()),e.getModifiedEditor().onDidChangeModelContent(()=>d(!0))},[]),b=(0,S.useCallback)(()=>{let t=l.current?.getModifiedEditor().getValue();if(t==null)return;m(!0);let n=h(v.getState().wsUrl),r=n.on(`files.written`,t=>{t.type===`files.written`&&t.payload.filePath===e&&(r(),clearTimeout(i),m(!1),t.payload.success&&(d(!1),_(Date.now())))}),i=setTimeout(()=>{r(),m(!1)},5e3);n.send({type:`files.write`,payload:{filePath:e,content:t}})},[e]),w=T(e);return(0,C.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,C.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2 px-2 py-1.5 border-b border-border/40`,children:[(0,C.jsx)(`span`,{className:`text-xs font-mono text-muted-foreground truncate`,children:e}),(0,C.jsxs)(`button`,{type:`button`,onClick:b,disabled:!u||p,className:`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-md border border-border text-xs font-medium disabled:opacity-40 enabled:hover:bg-muted transition-colors`,title:s(`activity:monacoDiff.applyTitle`),children:[p?(0,C.jsx)(r,{className:`h-3.5 w-3.5 animate-spin`}):g&&!u?(0,C.jsx)(n,{className:`h-3.5 w-3.5 text-success`}):(0,C.jsx)(a,{className:`h-3.5 w-3.5`}),s(p?`activity:monacoDiff.applying`:g&&!u?`activity:monacoDiff.applied`:`activity:monacoDiff.apply`)]})]}),(0,C.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-hidden`,children:(0,C.jsx)(c,{original:t,modified:i,language:w,theme:x(),onMount:y,options:{renderSideBySide:!0,readOnly:!1,originalEditable:!1,minimap:{enabled:!1},fontSize:13,scrollBeyondLastLine:!1,automaticLayout:!0}})})]})}var D=1e4;function O({className:e}){let{t:n}=o(),a=_(e=>e.selectedPath),c=_(e=>e.diff),u=_(e=>e.loadingDiff),[d,f]=(0,S.useState)(`unified`),[p,m]=(0,S.useState)(!1),x=!!a&&(u||!c);(0,S.useEffect)(()=>{if(m(!1),!x)return;let e=setTimeout(()=>m(!0),D);return()=>clearTimeout(e)},[x,a]);let w=()=>{a&&(m(!1),_.getState().setDiffLoading(!0),h(v.getState().wsUrl).getGitDiff?.(a))};if(!a)return(0,C.jsx)(b,{icon:(0,C.jsx)(t,{className:`h-6 w-6`}),title:`Source changes`,description:n(`activity:changes.selectPrompt`),className:e});let T=c&&!c.error&&!c.binary&&!c.tooLarge;return(0,C.jsx)(`div`,{className:g(`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,C.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,C.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-2 border-b border-border/70 px-3 py-2`,children:[(0,C.jsxs)(`div`,{className:`min-w-0`,children:[(0,C.jsx)(`div`,{className:`text-[10px] font-semibold uppercase text-muted-foreground`,children:`Source control`}),(0,C.jsx)(`div`,{className:`truncate font-mono text-xs text-foreground`,title:a,children:a})]}),T&&(0,C.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,C.jsxs)(`button`,{type:`button`,onClick:()=>f(`unified`),title:n(`activity:changes.unifiedTitle`),className:g(`inline-flex h-8 items-center gap-1 rounded-md border px-2 text-xs transition-colors`,d===`unified`?`border-primary/40 bg-primary/10 text-primary`:`border-border text-muted-foreground hover:bg-muted`),children:[(0,C.jsx)(i,{className:`h-3.5 w-3.5`}),` `,n(`activity:changes.unified`)]}),(0,C.jsxs)(`button`,{type:`button`,onClick:()=>f(`edit`),title:n(`activity:changes.editTitle`),className:g(`inline-flex h-8 items-center gap-1 rounded-md border px-2 text-xs transition-colors`,d===`edit`?`border-primary/40 bg-primary/10 text-primary`:`border-border text-muted-foreground hover:bg-muted`),children:[(0,C.jsx)(s,{className:`h-3.5 w-3.5`}),` `,n(`activity:changes.edit`)]})]})]}),(0,C.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:u||!c?p?(0,C.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center gap-3 p-4 text-center`,children:[(0,C.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n(`activity:changes.diffTimeout`)}),(0,C.jsxs)(`button`,{type:`button`,onClick:w,className:`inline-flex h-8 items-center gap-1.5 rounded-md border border-border px-3 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:[(0,C.jsx)(l,{className:`h-3.5 w-3.5`}),` `,n(`common:action.retry`)]})]}):(0,C.jsxs)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,C.jsx)(r,{className:`h-4 w-4 animate-spin`}),` `,n(`activity:changes.loadingDiff`)]}):c.error?(0,C.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-sm text-destructive`,children:c.error}):c.binary?(0,C.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-sm text-muted-foreground`,children:n(`activity:changes.binary`)}):c.tooLarge?(0,C.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-sm text-muted-foreground`,children:n(`activity:changes.tooLarge`)}):d===`edit`?(0,C.jsx)(E,{path:c.path,oldText:c.oldText??``,newText:c.newText??``},c.path):(0,C.jsx)(y,{oldText:c.oldText,newText:c.newText,caption:c.path,fill:!0})})]})})}export{O as ChangesView};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{$t as t,Br as n,Bt as r,Li as i,Nt as a,Pi as o,Qr as s,Ti as c,bt as l,hr as u,li as d,na as f,ot as p,qt as m,rn as h,tt as g,ua as _,vr as v}from"./vendor-BmsAdDhb.js";import{t as y}from"./ws-client-BydCS6yi.js";import{t as b}from"./utils-DvgvNCoT.js";import{d as x,f as S}from"./index-196U0qsu.js";var C=e(_(),1),w=g(),T=[`eventType`,`providerId`,`modelId`,`outcome`,`resourceKind`],ee=[{id:`all`,label:`All signals`,icon:(0,w.jsx)(f,{})},{id:`llm`,label:`LLM`,icon:(0,w.jsx)(o,{})},{id:`agents`,label:`Agents`,icon:(0,w.jsx)(i,{})},{id:`tools`,label:`Tools`,icon:(0,w.jsx)(a,{})},{id:`files`,label:`Files`,icon:(0,w.jsx)(n,{})},{id:`failures`,label:`Failures`,icon:(0,w.jsx)(l,{})}];function E(){let e=y(),[r,s]=(0,C.useState)([]),[c,l]=(0,C.useState)(null),[u,f]=(0,C.useState)({}),[g,_]=(0,C.useState)({limit:300,order:`desc`}),[E,D]=(0,C.useState)({text:``,path:``,providerId:``,modelId:``,sessionId:``}),[j,R]=(0,C.useState)(`all`),[B,V]=(0,C.useState)({total:0,scannedEvents:0,sourceFiles:0,invalidLines:0}),[H,U]=(0,C.useState)(O),[W,G]=(0,C.useState)(!0),[K,q]=(0,C.useState)(null),[ne,J]=(0,C.useState)(null),Y=(0,C.useCallback)(t=>{if(!e.supportsCapability(`chronicle.query`)){G(!1),q(`Restart the backend once to activate Chronicle protocol support.`);return}if(G(!0),q(null),_(t),f({}),e.send({type:`chronicle.query`,payload:{query:t}}),e.supportsCapability(`chronicle.facets`))e.send({type:`chronicle.facets`,payload:{fields:[...T],query:t,limit:12}});else for(let n of T)e.send({type:`chronicle.facet`,payload:{field:n,query:t,limit:12}})},[e]);(0,C.useEffect)(()=>{let t=e.on(`chronicle.query_result`,e=>{e.type===`chronicle.query_result`&&(s(e.payload.events),V(e.payload),U(e.payload.summary??O),G(!1))}),n=e.on(`chronicle.facet_result`,e=>{e.type===`chronicle.facet_result`&&f(t=>({...t,[e.payload.field]:e.payload.values}))}),r=e.on(`chronicle.facets_result`,e=>{e.type===`chronicle.facets_result`&&f(e.payload.values)}),i=e.on(`chronicle.error`,e=>{e.type===`chronicle.error`&&(q(e.payload.message),G(!1))}),a=e.on(`chronicle.graph_result`,e=>{e.type===`chronicle.graph_result`&&J(e.payload)});return Y({limit:300,order:`desc`}),()=>{t(),n(),r(),i(),a()}},[e,Y]);let X=(0,C.useMemo)(()=>r.filter(e=>A(e,j)),[r,j]),Z=S(X,25,j),Q=(0,C.useMemo)(()=>r.find(e=>e.eventType===`runtime.health.sampled`)?.attributes,[r]),$=()=>Y({limit:300,order:`desc`,...E.text?{text:E.text}:{},...E.path?{path:E.path}:{},...E.providerId?{providerId:E.providerId}:{},...E.modelId?{modelId:E.modelId}:{},...E.sessionId?{sessionId:E.sessionId}:{}}),re=()=>{D({text:``,path:``,providerId:``,modelId:``,sessionId:``}),R(`all`),Y({limit:300,order:`desc`})},ie=t=>{l(t),J(null),e.supportsCapability(`chronicle.graph`)&&e.send({type:`chronicle.graph`,payload:{seed:{eventId:t.eventId},hops:2,maxNodes:250}})};return(0,w.jsxs)(`div`,{className:`flex h-full min-h-0 bg-background`,"data-testid":`chronicle-dashboard`,children:[(0,w.jsxs)(`main`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,w.jsx)(`header`,{className:`border-b border-border/70 bg-gradient-to-r from-primary/[0.045] via-background to-background px-5 py-4`,children:(0,w.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,w.jsxs)(`div`,{children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,w.jsx)(o,{className:`h-5 w-5 text-primary`}),(0,w.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight`,children:`Coding Intelligence`}),(0,w.jsx)(`span`,{className:`rounded-full border border-primary/20 bg-primary/10 px-2 py-0.5 text-[9px] font-semibold tracking-wider text-primary`,children:`CHRONICLE`})]}),(0,w.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`LLM, agent, tool and file evidence — connected from decision to code change.`})]}),(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,w.jsx)(`span`,{className:b(`h-2 w-2 rounded-full`,K?`bg-destructive`:W?`animate-pulse bg-warning`:`bg-success`)}),(0,w.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:W?`Reading journal`:K?`Unavailable`:`Live evidence`}),(0,w.jsx)(`button`,{onClick:()=>Y(g),className:`ml-2 rounded-md border border-border bg-card p-2 hover:bg-muted`,title:`Refresh evidence`,children:(0,w.jsx)(h,{className:b(`h-4 w-4`,W&&`animate-spin`)})})]})]})}),(0,w.jsxs)(`section`,{className:`grid grid-cols-2 border-b border-border/70 xl:grid-cols-6`,children:[(0,w.jsx)(P,{icon:(0,w.jsx)(o,{}),label:`LLM requests`,value:H.logicalRequests,detail:`${H.modelAttempts} attempts · ${H.providers} providers · ${H.models} models`}),(0,w.jsx)(P,{icon:(0,w.jsx)(i,{}),label:`Agent work`,value:H.agentEvents,detail:`${H.uniqueAgents} correlated agents · ${H.decisions} decisions`}),(0,w.jsx)(P,{icon:(0,w.jsx)(a,{}),label:`Tool calls`,value:H.toolCalls,detail:`${H.failedTools} failed · ${H.processes} processes`}),(0,w.jsx)(P,{icon:(0,w.jsx)(n,{}),label:`File evidence`,value:H.fileEvents,detail:`${H.uniqueFiles} unique paths`}),(0,w.jsx)(P,{icon:(0,w.jsx)(t,{}),label:`Retries`,value:H.scheduledRetries,detail:`${H.failures} failures · ${H.fallbacks} fallbacks`,tone:H.failures?`danger`:`normal`}),(0,w.jsx)(P,{icon:(0,w.jsx)(d,{}),label:`Provider p95`,value:M(H.providerP95DurationMs),detail:`${M(H.providerAvgDurationMs)} average · all matches`})]}),(0,w.jsxs)(`section`,{className:`flex flex-wrap gap-x-6 gap-y-1 border-b border-border/60 bg-primary/[0.018] px-4 py-1.5 font-mono text-[9px] text-muted-foreground`,children:[(0,w.jsx)(`span`,{className:`font-sans font-semibold uppercase tracking-wider text-primary`,children:`Token economics`}),(0,w.jsxs)(`span`,{children:[`fresh input `,(0,w.jsx)(`b`,{className:`text-foreground`,children:H.inputTokens.toLocaleString()})]}),(0,w.jsxs)(`span`,{children:[`output `,(0,w.jsx)(`b`,{className:`text-foreground`,children:H.outputTokens.toLocaleString()})]}),(0,w.jsxs)(`span`,{children:[`cache read `,(0,w.jsx)(`b`,{className:`text-foreground`,children:H.cacheReadTokens.toLocaleString()})]}),(0,w.jsxs)(`span`,{children:[`cache write `,(0,w.jsx)(`b`,{className:`text-foreground`,children:H.cacheWriteTokens.toLocaleString()})]}),(0,w.jsxs)(`span`,{children:[`cache hit `,(0,w.jsxs)(`b`,{className:`text-foreground`,children:[k(H).toFixed(1),`%`]})]}),(0,w.jsxs)(`span`,{children:[`estimated cost `,(0,w.jsxs)(`b`,{className:`text-foreground`,children:[`$`,H.estimatedCostUsd.toFixed(4)]})]})]}),(0,w.jsx)(`section`,{className:`border-b border-border/70 px-4 py-3`,children:(0,w.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 xl:grid-cols-[1.35fr_1fr_1fr_1fr_1fr_auto]`,children:[(0,w.jsx)(N,{icon:(0,w.jsx)(m,{}),placeholder:`Search event evidence`,value:E.text,onChange:e=>D(t=>({...t,text:e})),onEnter:$}),(0,w.jsx)(N,{placeholder:`File or directory`,value:E.path,onChange:e=>D(t=>({...t,path:e})),onEnter:$}),(0,w.jsx)(N,{placeholder:`Provider`,value:E.providerId,onChange:e=>D(t=>({...t,providerId:e})),onEnter:$}),(0,w.jsx)(N,{placeholder:`Model`,value:E.modelId,onChange:e=>D(t=>({...t,modelId:e})),onEnter:$}),(0,w.jsx)(N,{placeholder:`Session`,value:E.sessionId,onChange:e=>D(t=>({...t,sessionId:e})),onEnter:$}),(0,w.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,w.jsxs)(`button`,{onClick:$,className:`rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground`,children:[(0,w.jsx)(v,{className:`mr-1 inline h-3 w-3`}),`Apply`]}),(0,w.jsx)(`button`,{onClick:re,className:`rounded-md border border-border px-2.5 text-xs hover:bg-muted`,children:`Clear`})]})]})}),(0,w.jsxs)(`section`,{className:`flex items-center gap-1 overflow-x-auto border-b border-border/70 px-4 py-2`,children:[ee.map(e=>(0,w.jsxs)(`button`,{onClick:()=>R(e.id),className:b(`flex shrink-0 items-center gap-1.5 rounded-md px-2.5 py-1.5 text-[11px] transition-colors [&>svg]:h-3.5 [&>svg]:w-3.5`,j===e.id?`bg-primary/10 font-medium text-primary`:`text-muted-foreground hover:bg-muted hover:text-foreground`),children:[e.icon,e.label,(0,w.jsx)(`span`,{className:`ml-1 rounded bg-background/70 px-1 font-mono text-[9px]`,children:te(H,e.id,B.total)})]},e.id)),(0,w.jsxs)(`div`,{className:`ml-auto hidden items-center gap-3 pl-4 text-[9px] text-muted-foreground lg:flex`,children:[(0,w.jsxs)(`span`,{children:[B.total.toLocaleString(),` matched`]}),(0,w.jsxs)(`span`,{children:[B.sourceFiles,` journal files`]}),B.invalidLines>0&&(0,w.jsxs)(`span`,{className:`text-warning`,children:[B.invalidLines,` invalid lines`]})]})]}),Q&&(0,w.jsx)(F,{health:Q}),(0,w.jsx)(`section`,{className:`flex gap-4 overflow-x-auto border-b border-border/60 bg-muted/[0.18] px-4 py-2`,children:[`providerId`,`modelId`,`outcome`].map(e=>(0,w.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,w.jsx)(`span`,{className:`mr-1 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e.replace(`Id`,``)}),(u[e]??[]).slice(0,4).map(t=>(0,w.jsxs)(`button`,{onClick:()=>Y({...g,[e]:t.value}),className:`rounded-full border border-border bg-card px-2 py-0.5 text-[9px] hover:border-primary/50`,children:[t.value,` `,(0,w.jsx)(`b`,{children:t.count})]},t.value))]},e))}),(0,w.jsxs)(`div`,{className:`grid grid-cols-[92px_minmax(190px,1.25fr)_110px_minmax(180px,1fr)_minmax(140px,.8fr)_24px] gap-3 border-b border-border/60 bg-muted/20 px-4 py-1.5 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,w.jsx)(`span`,{children:`Time`}),(0,w.jsx)(`span`,{children:`Signal`}),(0,w.jsx)(`span`,{children:`Outcome`}),(0,w.jsx)(`span`,{children:`Model / agent`}),(0,w.jsx)(`span`,{children:`Resource`}),(0,w.jsx)(`span`,{})]}),(0,w.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:K?(0,w.jsx)(z,{text:K}):!W&&X.length===0?(0,w.jsx)(z,{text:`No coding evidence matches these filters.`}):(0,w.jsx)(`div`,{className:`divide-y divide-border/40`,children:Z.pageItems.map(e=>(0,w.jsx)(I,{event:e,active:c?.eventId===e.eventId,onClick:()=>ie(e)},e.eventId))})}),(0,w.jsx)(x,{page:Z.page,pageSize:Z.pageSize,totalItems:Z.totalItems,onPageChange:Z.setPage,itemLabel:`events`})]}),c&&(0,w.jsxs)(`aside`,{className:`w-[440px] max-w-[48vw] shrink-0 overflow-auto border-l border-border bg-card/60 shadow-[-12px_0_32px_hsl(var(--background)/.35)]`,children:[(0,w.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center justify-between border-b border-border bg-card/95 px-4 py-3 backdrop-blur`,children:[(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`div`,{className:`text-xs font-semibold`,children:`Evidence & lineage`}),(0,w.jsxs)(`div`,{className:`mt-0.5 font-mono text-[9px] text-muted-foreground`,children:[`#`,c.sequence,` · `,c.eventId]})]}),(0,w.jsx)(`button`,{onClick:()=>l(null),className:`rounded p-1 hover:bg-muted`,children:(0,w.jsx)(p,{className:`h-4 w-4`})})]}),(0,w.jsx)(L,{event:c,graph:ne})]})]})}var D={llm:0,agent:0,tool:0,file:0,memory:0,task:0,decision:0,runtime:0},O={logicalRequests:0,modelAttempts:0,completedAttempts:0,failedAttempts:0,scheduledRetries:0,fallbacks:0,providers:0,models:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheWriteTokens:0,estimatedCostUsd:0,providerAvgDurationMs:0,providerP95DurationMs:0,toolCalls:0,completedTools:0,failedTools:0,toolAvgDurationMs:0,processes:0,failedProcesses:0,fileEvents:0,uniqueFiles:0,agentEvents:0,uniqueAgents:0,decisions:0,escalations:0,failures:0,cancellations:0,families:{...D},failuresByFamily:{...D}};function te(e,t,n){return t===`all`?n:t===`llm`?e.families.llm:t===`agents`?e.families.agent:t===`tools`?e.families.tool:t===`files`?e.families.file:e.failures}function k(e){let t=e.inputTokens+e.cacheReadTokens;return t?e.cacheReadTokens/t*100:0}function A(e,t){return t===`all`?!0:t===`llm`?/^(provider|token|context|compaction)\./.test(e.eventType):t===`agents`?/^(agent|subagent|delegate|fleet|sdd)\./.test(e.eventType):t===`tools`?/^(tool|process|mcp|network)\./.test(e.eventType):t===`files`?e.resource?.kind===`file`||/^(file|worktree|storage)\./.test(e.eventType):e.outcome===`failure`||/(?:failed|error|retry|fallback|blocked|conflict)/i.test(e.eventType)}function j(e){if(!e)return`—`;let t=e/1e6;return t<1?`${(e/1e3).toFixed(0)}µs`:t<1e3?`${t.toFixed(1)}ms`:`${(t/1e3).toFixed(1)}s`}function M(e){return e?e<1?`${(e*1e3).toFixed(0)}µs`:e<1e3?`${e.toFixed(1)}ms`:`${(e/1e3).toFixed(1)}s`:`—`}function N({placeholder:e,value:t,onChange:n,onEnter:r,icon:i}){return(0,w.jsxs)(`label`,{className:`flex items-center gap-2 rounded-md border border-border bg-card px-2.5 py-2 focus-within:border-primary/60`,children:[i&&(0,w.jsx)(`span`,{className:`text-muted-foreground [&>svg]:h-3.5 [&>svg]:w-3.5`,children:i}),(0,w.jsx)(`input`,{className:`w-full bg-transparent text-xs outline-none placeholder:text-muted-foreground/70`,placeholder:e,value:t,onChange:e=>n(e.target.value),onKeyDown:e=>{e.key===`Enter`&&r()}})]})}function P({icon:e,label:t,value:n,detail:r,tone:i=`normal`}){return(0,w.jsxs)(`div`,{className:`min-w-0 border-r border-border/60 px-4 py-3`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:[(0,w.jsx)(`span`,{className:`text-primary [&>svg]:h-3.5 [&>svg]:w-3.5`,children:e}),t]}),(0,w.jsx)(`div`,{className:b(`mt-1 text-xl font-semibold tabular-nums`,i===`danger`&&`text-destructive`),children:typeof n==`number`?n.toLocaleString():n}),(0,w.jsx)(`div`,{className:`mt-0.5 truncate text-[9px] text-muted-foreground`,children:r})]})}function F({health:e}){return(0,w.jsxs)(`section`,{className:`flex flex-wrap gap-x-5 gap-y-1 border-b border-border/60 bg-success/[0.025] px-4 py-1.5 font-mono text-[9px] text-muted-foreground`,children:[(0,w.jsx)(`span`,{className:`font-sans font-semibold uppercase tracking-wider text-success`,children:`Collector healthy`}),(0,w.jsxs)(`span`,{children:[`ELU `,(0,w.jsxs)(`b`,{className:`text-foreground`,children:[((e.eventLoop?.utilization??0)*100).toFixed(1),`%`]})]}),(0,w.jsxs)(`span`,{children:[`p95 `,(0,w.jsxs)(`b`,{className:`text-foreground`,children:[(e.eventLoop?.delayP95Ms??0).toFixed(1),`ms`]})]}),(0,w.jsxs)(`span`,{children:[`heap `,(0,w.jsxs)(`b`,{className:`text-foreground`,children:[((e.memory?.heapUsedBytes??0)/1048576).toFixed(0),`MB`]})]}),(0,w.jsxs)(`span`,{children:[`queue `,(0,w.jsx)(`b`,{className:`text-foreground`,children:e.chronicle?.pendingEvents??0})]}),(0,w.jsxs)(`span`,{children:[`dropped `,(0,w.jsx)(`b`,{className:b((e.chronicle?.rejectedEvents??0)>0&&`text-destructive`),children:e.chronicle?.rejectedEvents??0})]})]})}function I({event:e,active:t,onClick:n}){let r=e.occurredAt??e.observedAt,i=e.runtime?.modelId??e.scope.agentId??e.runtime?.providerId??`—`,a=e.resource?.path??e.resource?.id??e.correlation.toolCallId??`—`;return(0,w.jsxs)(`button`,{onClick:n,className:b(`grid w-full grid-cols-[92px_minmax(190px,1.25fr)_110px_minmax(180px,1fr)_minmax(140px,.8fr)_24px] items-center gap-3 px-4 py-2.5 text-left hover:bg-muted/45`,t&&`bg-primary/[0.07]`),children:[(0,w.jsx)(`span`,{className:`font-mono text-[9px] text-muted-foreground`,children:new Date(r).toLocaleTimeString()}),(0,w.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,w.jsx)(`span`,{className:b(`h-1.5 w-1.5 shrink-0 rounded-full`,e.outcome===`failure`?`bg-destructive`:e.outcome===`success`?`bg-success`:`bg-primary`)}),(0,w.jsx)(`span`,{className:`truncate font-mono text-[11px] font-medium`,children:e.eventType})]}),(0,w.jsx)(`span`,{className:b(`w-fit rounded px-1.5 py-0.5 text-[9px]`,B(e.outcome)),children:e.outcome??`unknown`}),(0,w.jsx)(`span`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:i}),(0,w.jsx)(`span`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:a}),(0,w.jsx)(c,{className:`h-3.5 w-3.5 text-muted-foreground`})]})}function L({event:e,graph:t}){let n=(0,C.useMemo)(()=>[[`Scope`,e.scope],[`Correlation`,e.correlation],[`Runtime`,e.runtime],[`Resource`,e.resource],[`Attributes`,e.attributes],[`Tags`,e.tags]],[e]);return(0,w.jsxs)(`div`,{className:`p-4`,children:[(0,w.jsxs)(`div`,{className:`mb-4 rounded-lg border border-border bg-background/60 p-3`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,w.jsx)(`span`,{className:b(`h-2 w-2 rounded-full`,e.outcome===`failure`?`bg-destructive`:e.outcome===`success`?`bg-success`:`bg-primary`)}),(0,w.jsx)(`span`,{className:`font-mono text-xs font-semibold`,children:e.eventType})]}),(0,w.jsxs)(`div`,{className:`mt-2 flex gap-4 text-[9px] text-muted-foreground`,children:[(0,w.jsx)(`span`,{children:new Date(e.occurredAt??e.observedAt).toLocaleString()}),(0,w.jsx)(`span`,{children:j(Number(e.durationNs??0))})]})]}),(0,w.jsxs)(`div`,{className:`mb-4 grid grid-cols-2 gap-2`,children:[(0,w.jsx)(R,{icon:(0,w.jsx)(r,{}),label:`Evidence hash`,value:e.hash.slice(0,16)}),(0,w.jsx)(R,{icon:(0,w.jsx)(s,{}),label:`Sequence`,value:String(e.sequence)})]}),t&&(0,w.jsxs)(`section`,{className:`mb-4`,children:[(0,w.jsxs)(`h3`,{className:`mb-1.5 flex items-center gap-1 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,w.jsx)(u,{className:`h-3 w-3`}),`Lineage · `,t.nodes.length,` nodes · `,t.edges.length,` edges`]}),(0,w.jsx)(`div`,{className:`space-y-1 rounded-md border border-border bg-background/70 p-2`,children:t.edges.slice(0,40).map((e,n)=>(0,w.jsxs)(`div`,{className:`flex items-center gap-2 font-mono text-[9px]`,children:[(0,w.jsx)(`span`,{className:b(`rounded px-1`,e.confidence===`explicit`?`bg-success/10 text-success`:e.confidence===`inferred`?`bg-warning/10 text-warning`:`bg-primary/10 text-primary`),children:e.confidence}),(0,w.jsx)(`span`,{className:`text-muted-foreground`,children:e.kind}),(0,w.jsxs)(`span`,{className:`truncate`,children:[t.nodes.find(t=>t.eventId===e.from)?.eventType,` → `,t.nodes.find(t=>t.eventId===e.to)?.eventType]})]},`${e.from}-${e.to}-${e.kind}-${n}`))}),t.truncated&&(0,w.jsx)(`p`,{className:`mt-1 text-[9px] text-warning`,children:`Lineage truncated at safety limit.`})]}),n.map(([e,t])=>t&&(0,w.jsxs)(`section`,{className:`mb-4`,children:[(0,w.jsx)(`h3`,{className:`mb-1.5 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e}),(0,w.jsx)(`pre`,{className:`overflow-auto rounded-md border border-border bg-background/70 p-3 font-mono text-[9px] leading-relaxed`,children:JSON.stringify(t,null,2)})]},e))]})}function R({icon:e,label:t,value:n}){return(0,w.jsxs)(`div`,{className:`rounded-md border border-border p-2`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-1 text-[8px] uppercase text-muted-foreground`,children:[(0,w.jsx)(`span`,{className:`[&>svg]:h-3 [&>svg]:w-3`,children:e}),t]}),(0,w.jsx)(`div`,{className:`mt-1 truncate font-mono text-[9px]`,children:n})]})}function z({text:e}){return(0,w.jsx)(`div`,{className:`flex h-48 items-center justify-center text-sm text-muted-foreground`,children:e})}function B(e){return e===`failure`?`bg-destructive/10 text-destructive`:e===`success`?`bg-success/10 text-success`:e===`started`?`bg-primary/10 text-primary`:`bg-muted text-muted-foreground`}export{E as ChronicleDashboard};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Ar as t,Di as n,Hn as r,Kt as i,Li as a,Lr as o,Nt as s,Vn as c,Vr as l,Vt as u,aa as d,fi as f,hr as p,na as m,ot as h,pt as g,rn as _,tt as v,ua as y,wi as b,y as x,yi as S}from"./vendor-BmsAdDhb.js";import"./i18n-c37VNlP9.js";import{a as C,i as w,n as T,o as E,r as D,t as O}from"./monaco-C7izDJhg.js";import{t as ee}from"./ws-client-BydCS6yi.js";import{t as k}from"./utils-DvgvNCoT.js";import{i as A}from"./codemap-activity-store-DrrI6G7M.js";import{E as j,O as M,j as te,o as ne,u as re}from"./stores-DVhvmaer.js";import{s as N}from"./view-navigation-D8lN47bJ.js";import{S as P,T as F,x as ie}from"./index-196U0qsu.js";import{t as I}from"./empty-state-DJc37Wg1.js";import{t as L}from"./monaco-theme-BoNOJHQB.js";var R={ts:`typescript`,tsx:`typescript`,js:`javascript`,jsx:`javascript`,json:`json`,css:`css`,html:`html`,svg:`xml`,md:`markdown`,yml:`yaml`,yaml:`yaml`,toml:`toml`,sh:`shell`,bash:`shell`,ps1:`powershell`,py:`python`,rs:`rust`,go:`go`,rb:`ruby`,java:`java`,c:`c`,cpp:`cpp`,h:`c`,hpp:`cpp`,sql:`sql`,xml:`xml`},z=Array.from(new Set(Object.values(R))).filter(e=>e!==`plaintext`),B=12e3,V=4e3,H=5e3,U=1e4;function W(e){return R[e.split(`.`).pop()?.toLowerCase()??``]??`plaintext`}function G(e){return e.match(/([A-Za-z_$][\w$]*)$/)?.[1]??``}function ae(e,t){return e.triggerCharacter?!0:t.length>=3}function oe(e,t){return e.triggerCharacter===`.`||!e.triggerCharacter&&/^(findBy|findAllBy|create|update|delete|remove|get[A-Z_]|set[A-Z_]|use[A-Z_])/.test(t)}function se(e){return[e.filePath,e.language,e.lineNumber,e.column,e.versionId??``,e.triggerCharacter??``,e.linePrefix.slice(-160),e.suffix.slice(0,160)].join(`\0`)}var K=e(y(),1),q=v(),J=150,ce=224,le=38,ue=/(write|edit|update|create|delete|rename|modified|changed)/i;function de(e){return e.replace(/\\/g,`/`).replace(/^\.\//,``).replace(/\/{2,}/g,`/`).toLowerCase()}function Y(e,t){let n=de(e),r=de(t);return n===r||n.endsWith(`/${r}`)||r.endsWith(`/${n}`)}function fe(e,t=Date.now()){let n=e.filter(e=>t-e.at<=30*6e4),r=n.filter(e=>ue.test(e.action)),i=new Set(n.map(e=>e.sessionId).filter(Boolean)).size,a=new Set(n.map(e=>e.actor).filter(Boolean)).size,o=new Set(n.map(e=>e.taskId).filter(Boolean)).size;return{level:r.length>=8||r.length>=4&&a>=3?`churn`:r.length>0?`active`:`quiet`,mutationCount:r.length,sessionCount:i,actorCount:a,taskCount:o}}function X(e){return typeof e==`string`&&e.length>0?e:void 0}function pe(e){let t=Date.parse(e.occurredAt??e.observedAt);return Number.isFinite(t)?t:Date.now()}function me(e){let t=e.attributes??{},n=X(t.operation)??e.eventType,r=e.scope.agentId,i=e.runtime?.providerId,a=e.runtime?.modelId;return{id:e.eventId,at:pe(e),action:n,actor:r??i??X(t.actor)??`external`,source:X(t.source)??e.tags?.collector??`chronicle`,summary:[e.eventType,i&&a?`${i}/${a}`:i,e.outcome].filter(Boolean).join(` · `),sessionId:e.scope.sessionId,agentId:r,taskId:e.scope.taskId??X(t.taskId),boardId:X(t.boardId)??e.scope.boardId,tool:X(t.toolName),status:e.outcome,raw:e}}function he(e){return{id:e.id??`${e.filePath}:${e.timestamp}:${e.type}`,at:e.timestamp,action:e.type,actor:e.agentName??e.agent??e.agentId??`external`,source:e.source??`live`,summary:e.summary,sessionId:e.sessionId,agentId:e.agentId,tool:e.toolName,status:e.status,raw:e}}function ge(e){let t=new Set;return e.sort((e,t)=>t.at-e.at).filter(e=>{let n=`${e.id}:${e.at}`;return t.has(n)?!1:(t.add(n),!0)})}function _e(e){return e?e.split(/\r?\n/).length:0}function ve(e){return new TextEncoder().encode(e).length}function ye(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function be(e){return e.length>18?`${e.slice(0,8)}…${e.slice(-6)}`:e}function xe(e,t){let n=P(e,t);return n?{added:n.filter(e=>e.kind===`add`).length,removed:n.filter(e=>e.kind===`del`).length,large:!1}:{added:0,removed:0,large:!0}}function Se({file:e}){let{t}=d(),[i,a]=(0,K.useState)(!0),[c,u]=(0,K.useState)(ce),[f,h]=(0,K.useState)(`overview`),[g,v]=(0,K.useState)([]),[y,x]=(0,K.useState)(!1),[C,w]=(0,K.useState)(null),[T,E]=(0,K.useState)(null),D=(0,K.useRef)(null),O=te(e=>e.wsUrl),j=A(e=>e.history),M=A(e=>e.activeOperations),N=re(e=>e.activeBoard),P=ne(e=>e.snapshot),F=(0,K.useMemo)(()=>ee(O),[O]),I=(0,K.useCallback)(()=>{w(null),x(!0),typeof F.getGitDiff==`function`&&F.getGitDiff(e.path),typeof F.supportsCapability==`function`&&F.supportsCapability(`chronicle.query`)?F.send({type:`chronicle.query`,payload:{query:{path:e.path,resourceKind:`file`,order:`desc`,limit:150}}}):x(!1)},[F,e.path]);(0,K.useEffect)(()=>{v([]),E(null);let t=F.on(`chronicle.query_result`,t=>{if(t.type!==`chronicle.query_result`)return;let n=t.payload.events.filter(t=>t.resource?.path&&Y(t.resource.path,e.path));t.payload.events.length>0&&n.length===0||(v(n),x(!1))}),n=F.on(`chronicle.error`,e=>{e.type===`chronicle.error`&&(w(e.payload.message),x(!1))}),r=F.on(`git.diff`,t=>{if(t.type!==`git.diff`||!Y(t.payload.path,e.path))return;let n=t.payload;if(n.error||n.binary||n.tooLarge){E({text:e.savedContent,available:!1,error:n.error});return}E({text:n.oldText??``,available:!0})});return I(),()=>{t(),n(),r()}},[F,e.path,e.savedContent,I]),(0,K.useEffect)(()=>{let e=e=>{if(!D.current)return;let t=D.current.startY-e.clientY,n=Math.max(J,Math.floor(window.innerHeight*.62));u(Math.min(n,Math.max(J,D.current.startHeight+t)))},t=()=>{D.current=null,document.body.style.cursor=``,document.body.style.userSelect=``};return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,t),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,t)}},[]);let L=(0,K.useMemo)(()=>{let t=[];for(let[n,r]of j)Y(n,e.path)&&t.push(...r);for(let n of M.values())t.push(...n.filter(t=>Y(t.filePath,e.path)));return t},[M,e.path,j]),R=(0,K.useMemo)(()=>ge([...L.map(he),...g.map(me)]),[g,L]),z=(0,K.useMemo)(()=>fe(R),[R]),B=T?.text??e.savedContent,V=(0,K.useMemo)(()=>xe(B,e.content),[B,e.content]),H=(0,K.useMemo)(()=>[...new Set(R.map(e=>e.sessionId).filter(e=>!!e))],[R]),U=(0,K.useMemo)(()=>[...new Set(R.map(e=>e.actor).filter(Boolean))],[R]),W=(0,K.useMemo)(()=>[...new Set(R.map(e=>e.taskId).filter(e=>!!e))],[R]),G=(0,K.useCallback)(e=>{let t=N?.tasks.find(t=>t.id===e),n=P?.tasks.find(t=>t.id===e||t.shortId===e);return t?.title??n?.title??e},[N,P]),ae=e=>{i||a(!0),D.current={startY:e.clientY,startHeight:i?c:J},document.body.style.cursor=`ns-resize`,document.body.style.userSelect=`none`},oe=[{id:`overview`,label:t(`activity:fileActivity.overview`),icon:(0,q.jsx)(m,{})},{id:`changes`,label:t(`activity:fileActivity.changes`),icon:(0,q.jsx)(o,{})},{id:`context`,label:t(`activity:fileActivity.context`),icon:(0,q.jsx)(r,{})},{id:`logs`,label:t(`activity:fileActivity.logs`),icon:(0,q.jsx)(s,{})}];return(0,q.jsxs)(`section`,{className:`flex shrink-0 flex-col overflow-hidden border-t border-border bg-card/95 shadow-[0_-10px_30px_hsl(var(--background)/0.24)] backdrop-blur`,style:{height:i?c:le},"data-testid":`file-activity-drawer`,children:[(0,q.jsx)(`button`,{type:`button`,"aria-label":t(`activity:fileActivity.resizeHint`),className:`group relative block h-2 w-full cursor-ns-resize touch-none`,onPointerDown:ae,onDoubleClick:()=>{a(!0),u(ce)},title:t(`activity:fileActivity.resizeHint`),children:(0,q.jsx)(`span`,{className:`absolute left-1/2 top-0.5 h-1 w-10 -translate-x-1/2 rounded-full bg-border transition-colors group-hover:bg-primary/60`})}),(0,q.jsxs)(`header`,{className:`flex h-[30px] min-w-0 items-center gap-2 border-b border-border/70 px-2.5`,children:[(0,q.jsxs)(`button`,{type:`button`,onClick:()=>a(e=>!e),className:`inline-flex min-w-0 items-center gap-1.5 rounded px-1.5 py-1 text-[11px] font-semibold hover:bg-muted`,"aria-expanded":i,children:[(0,q.jsx)(l,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,q.jsx)(`span`,{className:`truncate`,children:t(`activity:fileActivity.title`)}),i?(0,q.jsx)(n,{className:`h-3 w-3`}):(0,q.jsx)(b,{className:`h-3 w-3`})]}),(0,q.jsx)(`span`,{className:`hidden h-3 w-px bg-border sm:block`}),(0,q.jsx)(Ce,{label:`${_e(e.content)} ${t(`activity:fileActivity.lines`)}`}),(0,q.jsx)(Ce,{label:ye(ve(e.content))}),!V.large&&(V.added>0||V.removed>0)&&(0,q.jsxs)(`span`,{className:`hidden items-center gap-1 font-mono text-[10px] md:flex`,children:[(0,q.jsxs)(`span`,{className:`text-success`,children:[`+`,V.added]}),(0,q.jsxs)(`span`,{className:`text-destructive`,children:[`−`,V.removed]})]}),(0,q.jsxs)(`span`,{className:k(`ml-auto inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[9px] font-semibold uppercase tracking-wide`,z.level===`churn`&&`bg-destructive/10 text-destructive`,z.level===`active`&&`bg-warning/10 text-warning`,z.level===`quiet`&&`bg-success/10 text-success`),children:[(0,q.jsx)(S,{className:`h-2.5 w-2.5`}),t(`activity:fileActivity.level.${z.level}`)]}),(0,q.jsx)(`span`,{className:`hidden text-[9px] text-muted-foreground lg:inline`,children:t(`activity:fileActivity.evidenceCount`,{count:R.length})}),i&&(0,q.jsx)(`button`,{type:`button`,onClick:I,className:`rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground`,title:t(`activity:fileActivity.refresh`),children:(0,q.jsx)(_,{className:k(`h-3.5 w-3.5`,y&&`animate-spin`)})})]}),i&&(0,q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,q.jsxs)(`nav`,{className:`flex shrink-0 items-center gap-0.5 border-b border-border/60 bg-muted/20 px-2`,children:[oe.map(e=>(0,q.jsxs)(`button`,{type:`button`,onClick:()=>h(e.id),className:k(`inline-flex h-7 items-center gap-1.5 border-b-2 px-2 text-[10px] transition-colors [&>svg]:h-3 [&>svg]:w-3`,f===e.id?`border-primary font-medium text-foreground`:`border-transparent text-muted-foreground hover:text-foreground`),children:[e.icon,e.label]},e.id)),C&&(0,q.jsx)(`span`,{className:`ml-auto truncate px-2 text-[9px] text-warning`,children:C})]}),(0,q.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:[f===`overview`&&(0,q.jsx)(we,{analysis:z,records:R,sessions:H,agents:U,tasks:W,taskLabel:G}),f===`changes`&&(0,q.jsxs)(`div`,{className:`h-full min-h-[120px] p-2`,children:[(0,q.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-2 text-[9px] text-muted-foreground`,children:[(0,q.jsx)(p,{className:`h-3 w-3`}),(0,q.jsx)(`span`,{children:T?.available?t(`activity:fileActivity.gitToBuffer`):t(`activity:fileActivity.savedToBuffer`)}),e.dirty&&(0,q.jsx)(`span`,{className:`rounded bg-warning/10 px-1.5 py-0.5 text-warning`,children:t(`activity:fileActivity.unsaved`)}),T?.error&&(0,q.jsx)(`span`,{className:`truncate text-warning`,children:T.error})]}),(0,q.jsx)(`div`,{className:`h-[calc(100%-24px)] min-h-[90px]`,children:(0,q.jsx)(ie,{oldText:B,newText:e.content,caption:e.path,fill:!0})})]}),f===`context`&&(0,q.jsx)(Te,{sessions:H,agents:U,tasks:W,records:R,taskLabel:G,boardTitle:N?.title??P?.title}),f===`logs`&&(0,q.jsx)(Ee,{records:R,loading:y})]})]})]})}function Ce({label:e}){return(0,q.jsx)(`span`,{className:`hidden whitespace-nowrap font-mono text-[9px] text-muted-foreground sm:inline`,children:e})}function we({analysis:e,records:t,sessions:n,agents:i,tasks:s,taskLabel:c}){let{t:l}=d();return(0,q.jsxs)(`div`,{className:`grid min-h-full grid-cols-1 gap-2 p-2 lg:grid-cols-[minmax(360px,.9fr)_minmax(420px,1.35fr)]`,children:[(0,q.jsxs)(`div`,{className:`space-y-2`,children:[(0,q.jsx)(`div`,{className:`grid grid-cols-4 gap-1.5`,children:[{label:l(`activity:fileActivity.mutations30m`),value:e.mutationCount,icon:(0,q.jsx)(o,{})},{label:l(`activity:fileActivity.sessions`),value:n.length,icon:(0,q.jsx)(g,{})},{label:l(`activity:fileActivity.actors`),value:i.length,icon:(0,q.jsx)(a,{})},{label:l(`activity:fileActivity.linkedWork`),value:s.length,icon:(0,q.jsx)(r,{})}].map(e=>(0,q.jsxs)(`div`,{className:`rounded-md border border-border/70 bg-background/45 px-2 py-1.5`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-1 text-[9px] text-muted-foreground [&>svg]:h-3 [&>svg]:w-3`,children:[e.icon,(0,q.jsx)(`span`,{className:`truncate`,children:e.label})]}),(0,q.jsx)(`div`,{className:`mt-0.5 font-mono text-sm font-semibold`,children:e.value})]},e.label))}),(0,q.jsxs)(`div`,{className:k(`flex items-start gap-2 rounded-md border px-2.5 py-2 text-[10px]`,e.level===`churn`?`border-destructive/25 bg-destructive/[0.055]`:`border-border/70 bg-background/45`),children:[(0,q.jsx)(u,{className:k(`mt-0.5 h-3.5 w-3.5 shrink-0`,e.level===`churn`?`text-destructive`:`text-primary`)}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`font-semibold`,children:l(`activity:fileActivity.analysisTitle.${e.level}`)}),(0,q.jsx)(`p`,{className:`mt-0.5 text-muted-foreground`,children:l(`activity:fileActivity.analysisBody.${e.level}`,{mutations:e.mutationCount,actors:e.actorCount,sessions:e.sessionCount})})]})]}),s.length>0&&(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 text-[9px]`,children:[(0,q.jsxs)(`span`,{className:`text-muted-foreground`,children:[l(`activity:fileActivity.workLinks`),`:`]}),s.slice(0,4).map(e=>(0,q.jsx)(`span`,{className:`max-w-[180px] truncate rounded border border-primary/20 bg-primary/5 px-1.5 py-0.5 text-primary`,title:e,children:c(e)},e))]})]}),(0,q.jsxs)(`div`,{className:`min-w-0 rounded-md border border-border/70 bg-background/35`,children:[(0,q.jsx)(`div`,{className:`border-b border-border/60 px-2.5 py-1.5 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:l(`activity:fileActivity.recentActivity`)}),(0,q.jsx)(`div`,{className:`divide-y divide-border/40`,children:t.length===0?(0,q.jsx)($,{text:l(`activity:fileActivity.noEvidence`)}):t.slice(0,5).map(e=>(0,q.jsx)(De,{record:e},`${e.id}:${e.at}`))})]})]})}function Te({sessions:e,agents:t,tasks:n,records:i,taskLabel:o,boardTitle:s}){let{t:c}=d();return(0,q.jsxs)(`div`,{className:`grid min-h-full grid-cols-1 divide-y divide-border/50 md:grid-cols-3 md:divide-x md:divide-y-0`,children:[(0,q.jsx)(Z,{icon:(0,q.jsx)(g,{}),title:c(`activity:fileActivity.sessions`),empty:c(`activity:fileActivity.noSessions`),children:e.map(e=>(0,q.jsx)(Q,{title:be(e),subtitle:`${i.filter(t=>t.sessionId===e).length} ${c(`activity:fileActivity.events`)}`,raw:e},e))}),(0,q.jsx)(Z,{icon:(0,q.jsx)(a,{}),title:c(`activity:fileActivity.actors`),empty:c(`activity:fileActivity.noActors`),children:t.map(e=>(0,q.jsx)(Q,{title:e,subtitle:`${i.filter(t=>t.actor===e).length} ${c(`activity:fileActivity.events`)}`},e))}),(0,q.jsx)(Z,{icon:(0,q.jsx)(r,{}),title:c(`activity:fileActivity.workLinks`),empty:c(`activity:fileActivity.noWorkLinks`),children:n.map(e=>(0,q.jsx)(Q,{title:o(e),subtitle:s??c(`activity:fileActivity.taskOrTodo`),raw:e},e))})]})}function Z({icon:e,title:t,empty:n,children:r}){let i=Array.isArray(r)?r.length>0:!!r;return(0,q.jsxs)(`section`,{className:`min-w-0 p-2`,children:[(0,q.jsxs)(`h3`,{className:`mb-1.5 flex items-center gap-1.5 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground [&>svg]:h-3 [&>svg]:w-3`,children:[e,t]}),(0,q.jsx)(`div`,{className:`space-y-1`,children:i?r:(0,q.jsx)($,{text:n})})]})}function Q({title:e,subtitle:t,raw:n}){return(0,q.jsxs)(`div`,{className:`rounded-md border border-border/60 bg-background/45 px-2 py-1.5`,title:n,children:[(0,q.jsx)(`div`,{className:`truncate text-[10px] font-medium`,children:e}),(0,q.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-[8px] text-muted-foreground`,children:t})]})}function Ee({records:e,loading:t}){let{t:n}=d();return t&&e.length===0?(0,q.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-[10px] text-muted-foreground`,children:[(0,q.jsx)(c,{className:`h-3.5 w-3.5 animate-spin`}),n(`activity:fileActivity.loadingEvidence`)]}):e.length===0?(0,q.jsx)($,{text:n(`activity:fileActivity.noEvidence`)}):(0,q.jsx)(`div`,{className:`divide-y divide-border/40`,children:e.map(e=>(0,q.jsx)(De,{record:e,raw:!0},`${e.id}:${e.at}`))})}function De({record:e,raw:t=!1}){let n=(0,q.jsxs)(`div`,{className:`grid grid-cols-[62px_74px_minmax(90px,.7fr)_minmax(160px,1.5fr)] items-center gap-2 text-[9px]`,children:[(0,q.jsx)(`span`,{className:`font-mono text-muted-foreground`,children:new Date(e.at).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}),(0,q.jsx)(`span`,{className:k(`w-fit rounded px-1.5 py-0.5 font-mono`,ue.test(e.action)?`bg-warning/10 text-warning`:`bg-primary/10 text-primary`),children:e.action}),(0,q.jsx)(`span`,{className:`truncate`,title:e.agentId,children:e.actor}),(0,q.jsx)(`span`,{className:`truncate text-muted-foreground`,title:e.summary,children:e.summary})]});return t?(0,q.jsxs)(`details`,{className:`group cursor-pointer px-2.5 py-1.5`,children:[(0,q.jsx)(`summary`,{className:`list-none [&::-webkit-details-marker]:hidden`,children:n}),(0,q.jsx)(`pre`,{className:`mt-1.5 max-h-48 overflow-auto rounded border border-border/60 bg-background/60 p-2 font-mono text-[8px] leading-relaxed text-muted-foreground`,children:JSON.stringify(e.raw,null,2)})]}):(0,q.jsx)(`div`,{className:`px-2.5 py-1.5`,children:n})}function $({text:e}){return(0,q.jsx)(`div`,{className:`px-3 py-3 text-center text-[10px] text-muted-foreground`,children:e})}T.config({monaco:O});function Oe(e){switch(e){case`method`:return E.CompletionItemKind.Method;case`function`:return E.CompletionItemKind.Function;case`constructor`:return E.CompletionItemKind.Constructor;case`field`:return E.CompletionItemKind.Field;case`variable`:return E.CompletionItemKind.Variable;case`class`:return E.CompletionItemKind.Class;case`interface`:return E.CompletionItemKind.Interface;case`module`:return E.CompletionItemKind.Module;case`property`:return E.CompletionItemKind.Property;case`unit`:return E.CompletionItemKind.Unit;case`value`:return E.CompletionItemKind.Value;case`enum`:return E.CompletionItemKind.Enum;case`keyword`:return E.CompletionItemKind.Keyword;case`snippet`:return E.CompletionItemKind.Snippet;case`file`:return E.CompletionItemKind.File;case`reference`:return E.CompletionItemKind.Reference;default:return E.CompletionItemKind.Text}}function ke(){let e=j(e=>e.openFiles),t=j(e=>e.activeFilePath),n=j(e=>e.setActiveFile),r=j(e=>e.closeFile);return e.length===0?null:(0,q.jsx)(`div`,{className:`flex items-center border-b bg-muted/40 overflow-x-auto shrink-0`,children:e.map(e=>{let i=e.path===t,a=e.path.split(`/`).pop()??e.path;return(0,q.jsxs)(`button`,{type:`button`,onClick:()=>n(e.path),onMouseDown:t=>{t.button===1&&(t.preventDefault(),r(e.path))},className:k(`group flex items-center gap-1.5 px-3 py-1.5 text-[11px] border-r whitespace-nowrap min-w-0 max-w-[180px] transition-colors`,i?`bg-background border-t-2 border-t-primary text-foreground -mb-px`:`text-muted-foreground hover:bg-muted/60 hover:text-foreground`),title:e.path,children:[e.dirty&&(0,q.jsx)(f,{className:`h-2 w-2 fill-current text-primary shrink-0`}),(0,q.jsx)(`span`,{className:`truncate`,children:a}),(0,q.jsx)(h,{className:k(`h-3 w-3 shrink-0 rounded-sm hover:bg-muted-foreground/20 opacity-0 group-hover:opacity-100 transition-opacity`,i&&`opacity-100`),onClick:t=>{t.stopPropagation(),r(e.path)}})]},e.path)})})}function Ae(){let{t:e}=d(),n=j(e=>e.openFiles),r=j(e=>e.activeFilePath),a=j(e=>e.updateContent),{theme:o}=F(),s=(0,K.useRef)(null),c=(0,K.useRef)(r),l=(0,K.useRef)(new Map),u=(0,K.useMemo)(()=>n.find(e=>e.path===r)??null,[n,r]),f=r?W(r):`plaintext`,p=L(),[m,h]=(0,K.useState)(!1);(0,K.useEffect)(()=>{c.current=r},[r]),(0,K.useEffect)(()=>{let e=L();C.setTheme(e)},[o]),(0,K.useEffect)(()=>{let e=z.map(e=>E.registerCompletionItemProvider(e,{triggerCharacters:[`.`,`_`],provideCompletionItems:async(e,t,n,r)=>{let i=c.current;if(!i)return{suggestions:[]};let a=e.getOffsetAt(t),o=e.getValue(),s=o.slice(Math.max(0,a-B),a),u=o.slice(a,a+V),d=e.getLineContent(t.lineNumber).slice(0,Math.max(0,t.column-1)),f=G(d),p={triggerCharacter:n.triggerCharacter,triggerKind:n.triggerKind};if(!ae(p,f))return{suggestions:[]};let m=`cmp_${Date.now()}_${Math.random().toString(36).slice(2)}`,h=e.getWordUntilPosition(t),g={startLineNumber:t.lineNumber,endLineNumber:t.lineNumber,startColumn:h.startColumn,endColumn:t.column},_=ee(te.getState().wsUrl),v=e=>e.map((e,t)=>({label:e.label,kind:Oe(e.kind),insertText:e.insertText,detail:e.detail??(e.source?`WrongStack ${e.source}`:void 0),documentation:e.documentation,sortText:e.sortText??`${String(t).padStart(3,`0`)}-${e.label}`,range:g,insertTextRules:e.kind===`snippet`?E.CompletionItemInsertTextRule.InsertAsSnippet:void 0})),y=se({filePath:i,language:e.getLanguageId(),lineNumber:t.lineNumber,column:t.column,versionId:e.getVersionId(),triggerCharacter:n.triggerCharacter,linePrefix:d,suffix:u}),b=l.current.get(y);return b&&b.expiresAt>Date.now()?{suggestions:v(b.items)}:await new Promise(a=>{let c=!1,d=()=>{},h=null,g,b=e=>{c||(c=!0,d(),g!==void 0&&window.clearTimeout(g),h?.dispose(),a({suggestions:e}))};d=_.on(`completion.result`,e=>{let t=e;t.payload.requestId===m&&(l.current.set(y,{expiresAt:Date.now()+U,items:t.payload.items}),b(v(t.payload.items)))}),g=window.setTimeout(()=>b([]),H),h=r.onCancellationRequested(()=>b([])),_.requestCompletion({requestId:m,filePath:i,language:e.getLanguageId(),lineNumber:t.lineNumber,column:t.column,content:o.length<=5e5?o:void 0,prefix:s,suffix:u,triggerCharacter:n.triggerCharacter,triggerKind:n.triggerKind,allowLlm:oe(p,f)})})}}));return()=>{e.forEach(e=>{e.dispose()})}},[]);let g=(0,K.useCallback)(()=>{let e=s.current;if(!e)return null;let t=e.getSelection();if(!t||t.isEmpty())return null;let n=e.getModel();if(!n)return null;let r=n.getValueInRange(t);return r.trim()?{content:r,startLine:t.startLineNumber,endLine:t.endLineNumber}:null},[]),_=(0,K.useCallback)(()=>{N(`chat`),requestAnimationFrame(()=>{document.querySelector(`[data-chat-textarea]`)?.focus()})},[]),v=(0,K.useCallback)(()=>{let e=c.current;if(!e)return;let t=g();t&&(M.getState().addRef({kind:`snippet`,path:e,startLine:t.startLine,endLine:t.endLine,content:t.content}),_())},[g,_]),y=(0,K.useCallback)(()=>{let e=c.current;e&&(M.getState().addRef({kind:`file`,path:e}),_())},[_]),b=(0,K.useCallback)(t=>{s.current=t,C.setTheme(L()),t.onDidChangeCursorSelection(()=>{let e=t.getSelection();h(!!e&&!e.isEmpty())}),t.addAction({id:`wrongstack-send-to-chat`,label:e(`activity:codeEditor.sendSelectionAction`),contextMenuGroupId:`wrongstack`,contextMenuOrder:0,precondition:void 0,keybindings:[w.CtrlCmd|w.Shift|D.KeyL],run:e=>{let t=e.getSelection();t&&!t.isEmpty()?v():y()}})},[v,y]),S=(0,K.useCallback)(e=>{r&&e!==void 0&&a(r,e)},[r,a]);return(0,K.useEffect)(()=>{let e=e=>{let t=e.ctrlKey||e.metaKey,n=e.target?.tagName?.toLowerCase()===`textarea`||e.target?.closest(`.monaco-editor`)!==null;!t||!n||(e.key.toLowerCase()===`s`&&(e.preventDefault(),window.dispatchEvent(new CustomEvent(`wrongstack:save-file`,{detail:{filePath:r}}))),e.key.toLowerCase()===`w`&&(e.preventDefault(),r&&j.getState().closeFile(r)))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r]),n.length===0?(0,q.jsx)(I,{title:e(`activity:codeEditor.noFilesOpen`),description:e(`activity:codeEditor.selectToEdit`)}):(0,q.jsxs)(`div`,{className:`flex h-full min-w-0 flex-col overflow-hidden`,children:[(0,q.jsx)(ke,{}),(0,q.jsxs)(`div`,{className:`relative min-h-0 min-w-0 flex-1 overflow-hidden`,children:[(m||u)&&(0,q.jsx)(`div`,{className:`absolute top-2 right-2 z-10 flex items-center gap-1 rounded-lg border border-border bg-popover/95 backdrop-blur shadow-md p-1`,children:(0,q.jsxs)(`button`,{type:`button`,onClick:m?v:y,className:`inline-flex items-center gap-1.5 rounded-md px-2 py-1 text-[11px] text-foreground hover:bg-accent transition-colors`,title:e(m?`activity:codeEditor.sendSelectedTitle`:`activity:codeEditor.mentionFileTitle`),children:[m?(0,q.jsx)(i,{className:`h-3 w-3`}):(0,q.jsx)(t,{className:`h-3 w-3`}),(0,q.jsx)(`span`,{children:e(m?`activity:codeEditor.sendToChat`:`activity:codeEditor.mentionFile`)})]})}),u?(0,q.jsx)(x,{language:f,value:u.content,onChange:S,theme:p,onMount:b,loading:(0,q.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,q.jsx)(`span`,{className:`text-[11px] text-muted-foreground animate-pulse`,children:e(`activity:codeEditor.loadingEditor`)})}),options:{minimap:{enabled:!1},fontSize:13,fontFamily:`'IBM Plex Mono', 'Cascadia Code', 'Fira Code', 'JetBrains Mono', monospace`,lineNumbers:`on`,renderWhitespace:`selection`,scrollBeyondLastLine:!1,wordWrap:`off`,tabSize:2,smoothScrolling:!0,cursorBlinking:`smooth`,cursorSmoothCaretAnimation:`on`,bracketPairColorization:{enabled:!0},"semanticHighlighting.enabled":!0,automaticLayout:!0,padding:{top:8}}},u.path):(0,q.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,q.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:e(`activity:codeEditor.selectTab`)})})]}),u&&(0,q.jsx)(Se,{file:u})]})}export{Ae as CodeEditor};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{$n as t,Bt as n,Cn as r,Di as i,Et as a,Gr as o,Ii as s,Sn as c,Ti as l,Vn as u,Yi as d,_ as f,a as p,c as ee,f as te,g as ne,h as re,hr as ie,i as ae,in as m,ln as h,m as oe,mn as se,na as ce,ot as le,p as ue,qt as de,r as fe,s as g,sr as pe,tt as me,u as _,ua as v,wr as y,xn as he,xr as ge,zr as b}from"./vendor-BmsAdDhb.js";import{t as x}from"./utils-DvgvNCoT.js";import{i as _e,r as ve,t as ye}from"./codemap-activity-store-DrrI6G7M.js";var S=e(v(),1);function C(e){return e.level===`packages`?`packages`:e.level===`files`?`files:${e.package}`:`symbols:${e.file}`}function be(e){return e.level===`packages`?`/api/codemap/packages`:e.level===`files`?`/api/codemap/files?package=${encodeURIComponent(e.package)}`:`/api/codemap/symbols?file=${encodeURIComponent(e.file)}`}function w(e,t,n){let r=new Map(e.nodes.map(e=>[e.id,e])),i=[];for(let a of e.edges){let e=n===`incoming`?a.target===t?a.source:void 0:a.source===t?a.target:void 0;if(!e)continue;let o=r.get(e);o&&i.push({node:o,edge:a})}return i.sort((e,t)=>t.edge.weight-e.edge.weight||e.node.label.localeCompare(t.node.label))}function xe(e,t){let n=new Set([t]);for(let r of e.edges)r.source===t&&n.add(r.target),r.target===t&&n.add(r.source);return n}function T(e,t){let n=new Map(e.nodes.map(e=>[e.id,0]));for(let r of e.edges)!t.has(r.source)||!t.has(r.target)||(n.set(r.source,(n.get(r.source)??0)+r.weight),r.target!==r.source&&n.set(r.target,(n.get(r.target)??0)+r.weight));return n}function E(e){let t=new Set(e.nodes.map(e=>e.id)),n=T(e,t),r=new Map(e.nodes.map(e=>[e.id,0])),i=new Map;for(let n of e.edges){if(!t.has(n.source)||!t.has(n.target)||n.source===n.target)continue;r.set(n.target,(r.get(n.target)??0)+1);let e=i.get(n.source)??[];e.push(n.target),i.set(n.source,e)}let a=new Map,o=e.nodes.filter(e=>(r.get(e.id)??0)===0).sort((e,t)=>(n.get(t.id)??0)-(n.get(e.id)??0)).map(e=>e.id);o.length===0&&e.nodes[0]&&o.push(e.nodes[0].id);for(let e of o)a.set(e,0);let s=new Set,c=0;for(;c<o.length;){let e=o[c++];if(!s.has(e)){s.add(e);for(let t of i.get(e)??[])a.set(t,Math.max(a.get(t)??0,Math.min((a.get(e)??0)+1,7))),r.set(t,(r.get(t)??1)-1),(r.get(t)??0)<=0&&o.push(t)}}let l=e.nodes.filter(e=>!a.has(e.id)).sort((e,t)=>(n.get(t.id)??0)-(n.get(e.id)??0));l.forEach((e,t)=>{a.set(e.id,t%Math.min(4,Math.max(1,l.length)))});let u=new Map;for(let t of e.nodes){let e=a.get(t.id)??0,n=u.get(e)??[];n.push(t),u.set(e,n)}for(let e of u.values())e.sort((e,t)=>Number(e.external)-Number(t.external)||(n.get(t.id)??0)-(n.get(e.id)??0)||e.label.localeCompare(t.label));let d=Math.max(1,...[...u.values()].map(e=>e.length))*160,f=[];for(let[e,t]of[...u.entries()].sort(([e],[t])=>e-t)){let n=(d-t.length*160)/2;t.forEach((t,r)=>{f.push({node:t,position:{x:e*386,y:n+r*160}})})}return f}function Se(e,t){if(e.nodes.length===0)return[];let n=T(e,new Set(e.nodes.map(e=>e.id))),r=e.nodes.find(e=>e.id===t)??[...e.nodes].sort((e,t)=>(n.get(t.id)??0)-(n.get(e.id)??0))[0],i=xe(e,r.id);i.delete(r.id);let a=e.nodes.filter(e=>i.has(e.id)),o=e.nodes.filter(e=>e.id!==r.id&&!i.has(e.id)),s=[{node:r,position:{x:0,y:0}}],c=(e,t,n)=>{e.forEach((r,i)=>{let a=n+Math.PI*2*i/Math.max(1,e.length);s.push({node:r,position:{x:Math.cos(a)*t,y:Math.sin(a)*t}})})};c(a,Math.max(330,a.length*34),-Math.PI/2);for(let e=0;e<o.length;e+=18)c(o.slice(e,e+18),620+Math.floor(e/18)*280,-Math.PI/2+.12);return s}function Ce(e,t,n){return t===`orbit`?Se(e,n):E(e)}function we(e){let t=(e.file??e.label).replace(/\\/g,`/`),n=e.package??``,r=n.startsWith(`@wrongstack/`)?`/packages/${n.slice(12)}/`:n.startsWith(`app:`)?`/apps/${n.slice(4)}/`:void 0;if(r){let e=t.indexOf(r);if(e>=0)return t.slice(e+r.length)}let i=t.lastIndexOf(`/src/`);return i>=0?t.slice(i+1):t.split(`/`).slice(-3).join(`/`)}var D=new WeakMap;function Te(e){let t=D.get(e);if(t)return t;let n={name:``,path:``,directories:[],files:[]};for(let t of e.filter(e=>e.kind===`file`&&!e.external)){let e=we(t).split(`/`).filter(Boolean),r=e.pop()??t.label,i=n;for(let t of e){let e=i.path?`${i.path}/${t}`:t,n=i.directories.find(e=>e.name===t);n||(n={name:t,path:e,directories:[],files:[]},i.directories.push(n)),i=n}i.files.push({...t,label:r})}let r=e=>{e.directories.sort((e,t)=>e.name.localeCompare(t.name)),e.files.sort((e,t)=>e.label.localeCompare(t.label)),e.directories.forEach(r)};return r(n),D.set(e,n),n}var O=me(),Ee={nodes:[],edges:[]},De={package:{icon:he,accent:`border-l-primary`,iconStyle:`bg-primary/12 text-primary`},file:{icon:b,accent:`border-l-info`,iconStyle:`bg-info/12 text-info`},symbol:{icon:s,accent:`border-l-success`,iconStyle:`bg-success/12 text-success`}},Oe={call:`hsl(var(--primary))`,import:`hsl(var(--info))`,type_ref:`hsl(var(--success))`,inherit:`hsl(var(--warning))`,implement:`hsl(var(--destructive))`},ke={read:`ring-2 ring-info/60 shadow-info/20`,write:`ring-2 ring-warning/70 shadow-warning/30`,edit:`ring-2 ring-warning/80 shadow-warning/40`,delete:`ring-2 ring-destructive/70 shadow-destructive/30`,search:`ring-2 ring-primary/55 shadow-primary/20`,memory:`ring-2 ring-success/60 shadow-success/30`,index:`ring-2 ring-info/50 shadow-info/20`,execute:`ring-2 ring-primary/55 shadow-primary/25`},k=[`bg-primary text-primary-foreground`,`bg-info text-info-foreground`,`bg-success text-success-foreground`,`bg-warning text-warning-foreground`,`bg-destructive text-destructive-foreground`],Ae=new Map;function A(e){let t=Ae.get(e);if(t!==void 0)return t;let n=e.replace(/\\/g,`/`).replace(/^\.\//,``).toLocaleLowerCase();return Ae.set(e,n),n}function je(e,t){if(!e||!t)return!1;let n=A(e),r=A(t);return n===r||n.endsWith(`/${r}`)||r.endsWith(`/${n}`)}function Me(e){let t=A(e),n=t.match(/\/packages\/([^/]+)\//);if(n?.[1])return`@wrongstack/${n[1]}`;let r=t.match(/\/apps\/([^/]+)\//);return r?.[1]?`app:${r[1]}`:`(root)`}function j(e,t){return t.kind===`package`?Me(e.filePath)===(t.package??t.label):je(e.filePath,t.file)?t.kind!==`symbol`||e.symbol?.id===t.id:!1}function Ne(e){let t=e.trim().split(/[\s:_-]+/).filter(Boolean);return(t.length>1?`${t[0]?.[0]??``}${t[1]?.[0]??``}`:e.slice(0,2)).toLocaleUpperCase()}function M(e){let t=0;for(let n of e)t=t*31+n.charCodeAt(0)|0;return k[Math.abs(t)%k.length]??k[0]}function Pe(e){let t=0;for(let n of e)t=t*31+n.charCodeAt(0)|0;return`hsl(${Math.abs(t)%360} 82% 58%)`}function N(e){let t=e.replace(/\\/g,`/`),n=t.lastIndexOf(`/packages/`),r=t.lastIndexOf(`/apps/`),i=Math.max(n,r);return i>=0?t.slice(i+1):t.split(`/`).slice(-3).join(`/`)}function Fe(e){return[e.symbol?.name,e.line?`L${e.line}`:void 0].filter(Boolean).join(` · `)}function Ie(e,t){let n=t.filter(t=>t.kind===`symbol`&&!t.external&&je(t.file,e.filePath));if(n.length===0)return;if(e.line)return[...n].sort((e,t)=>(t.line??0)-(e.line??0)).find(t=>(t.line??0)<=e.line)??n[0];let r=e.summary.toLocaleLowerCase();return n.find(e=>e.label.length>2&&(r.includes(e.label.toLocaleLowerCase())||!!(e.signature&&r.includes(e.signature.toLocaleLowerCase()))))}var P=160;function Le(e,t,n){if(n===`all`||e.nodes.length<=P)return e;let r=new Map(e.nodes.map(e=>[e.id,e])),i=new Map;for(let t of e.edges)i.set(t.source,(i.get(t.source)??0)+t.weight),i.set(t.target,(i.get(t.target)??0)+t.weight);let a=[...e.nodes].sort((e,t)=>(i.get(t.id)??0)-(i.get(e.id)??0)||e.label.localeCompare(t.label)),o=new Set,s=e=>{r.has(e)&&o.size<P&&o.add(e)};if(t&&r.has(t)){s(t);let n=e.edges.filter(e=>e.source===t||e.target===t).sort((e,t)=>t.weight-e.weight);for(let e of n)s(e.source),s(e.target);let r=new Set(o),i=e.edges.filter(e=>r.has(e.source)||r.has(e.target)).sort((e,t)=>t.weight-e.weight);for(let e of i)s(e.source),s(e.target)}else{let e=a.filter(e=>!e.external).slice(0,124),t=a.filter(e=>e.external).slice(0,36);for(let n of[...e,...t])s(n.id)}for(let e of a)s(e.id);return{nodes:e.nodes.filter(e=>o.has(e.id)),edges:e.edges.filter(e=>o.has(e.source)&&o.has(e.target))}}function F({data:e}){let{graphNode:t,selected:n,dimmed:r,incoming:i,outgoing:a,isActive:s,activityType:c,activeOperations:l}=e,u=De[t.kind],d=u.icon,p=t.kind!==`symbol`,ee=t.kind===`symbol`?`${t.symbolKind??`symbol`}${t.line?` · L${t.line}`:``}`:t.kind===`file`?we(t):`${t.fileCount??0} files · ${t.symbolCount??0} symbols`;return(0,O.jsxs)(`div`,{className:x(`group relative w-[236px] border border-l-[3px] bg-card text-card-foreground shadow-[0_8px_24px_hsl(var(--shadow-color)/0.08)] transition-[opacity,filter,box-shadow,border-color,background-color]`,u.accent,n&&`border-primary bg-primary/5 shadow-[0_0_0_2px_hsl(var(--primary)/0.18),0_16px_36px_hsl(var(--shadow-color)/0.18)]`,t.external&&`border-dashed bg-muted/75`,r&&`opacity-25 grayscale`,s&&c&&ke[c]),children:[l.length>0&&(0,O.jsxs)(`div`,{className:`absolute -top-5 left-2 z-20 flex max-w-[210px] items-center gap-1`,children:[l.slice(0,4).map(e=>{let t=e.agentName??e.agent??`External`,n=`${e.sessionId??`none`}:${e.agentId??t}`;return(0,O.jsxs)(`span`,{className:x(`flex h-6 items-center gap-1 border-2 border-background px-1.5 font-mono text-[8px] font-bold shadow-md`,M(n)),title:`${t} · ${e.type} ${Fe(e)}`,children:[(0,O.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse bg-current`}),Ne(t),e.symbol&&(0,O.jsx)(`span`,{className:`max-w-[80px] truncate`,children:e.symbol.name})]},e.id??`${n}:${e.filePath}`)}),l.length>4&&(0,O.jsxs)(`span`,{className:`border bg-card px-1 font-mono text-[8px] shadow`,children:[`+`,l.length-4]})]}),(0,O.jsx)(g,{type:`target`,position:f.Left,className:`!h-2.5 !w-2.5 !border-2 !border-card !bg-muted-foreground`}),(0,O.jsxs)(`button`,{type:`button`,className:`block w-full text-left`,onClick:n=>{if(n.shiftKey&&t.file){e.onShowHistory(t.file);return}e.onSelect(t)},onDoubleClick:()=>p&&e.onOpen(t),"aria-label":`${t.kind} ${t.label}`,children:[(0,O.jsxs)(`div`,{className:`flex items-start gap-3 p-3 pr-10`,children:[(0,O.jsx)(`span`,{className:x(`flex h-8 w-8 shrink-0 items-center justify-center border`,u.iconStyle),children:(0,O.jsx)(d,{className:`h-4 w-4`})}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[9px] font-bold uppercase tracking-[0.18em] text-muted-foreground`,children:[(0,O.jsx)(`span`,{children:t.kind}),t.external&&(0,O.jsx)(`span`,{className:`border border-border px-1 py-0.5 text-[8px] text-warning`,children:`external`}),t.lang&&(0,O.jsx)(`span`,{className:`ml-auto font-mono normal-case tracking-normal`,children:t.lang})]}),(0,O.jsx)(`div`,{className:`truncate font-mono text-[13px] font-semibold`,title:t.label,children:t.label}),(0,O.jsx)(`div`,{className:`mt-1 truncate text-[10px] text-muted-foreground`,title:ee,children:ee})]})]}),(0,O.jsxs)(`div`,{className:`flex items-center gap-3 border-t bg-muted/30 px-3 py-1.5 font-mono text-[9px] text-muted-foreground`,children:[(0,O.jsxs)(`span`,{title:`Incoming relationships`,children:[`← `,i]}),(0,O.jsxs)(`span`,{title:`Outgoing relationships`,children:[`→ `,a]}),t.symbolCount!==void 0&&t.kind===`file`&&(0,O.jsxs)(`span`,{className:`ml-auto`,children:[t.symbolCount,` sym`]}),s&&(0,O.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 font-bold text-warning`,children:[(0,O.jsx)(m,{className:`h-2.5 w-2.5 animate-pulse`}),` LIVE`]})]})]}),p&&(0,O.jsx)(`button`,{type:`button`,className:`absolute right-2 top-2 z-10 flex h-7 w-7 items-center justify-center border border-transparent text-muted-foreground opacity-0 transition hover:border-border hover:bg-muted hover:text-foreground group-hover:opacity-100 focus:opacity-100`,onClick:()=>e.onOpen(t),title:t.kind===`package`?`Open file map`:`Open symbol map`,"aria-label":`Open ${t.label} map`,children:(0,O.jsx)(o,{className:`h-3.5 w-3.5`})}),(0,O.jsx)(g,{type:`source`,position:f.Right,className:`!h-2.5 !w-2.5 !border-2 !border-card !bg-muted-foreground`})]})}function I(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function L(e,t){return e.graphNode===t.graphNode&&e.selected===t.selected&&e.dimmed===t.dimmed&&e.incoming===t.incoming&&e.outgoing===t.outgoing&&e.isActive===t.isActive&&e.activityType===t.activityType&&e.onSelect===t.onSelect&&e.onOpen===t.onOpen&&e.onShowHistory===t.onShowHistory&&I(e.activeOperations,t.activeOperations)}var Re={codemap:(0,S.memo)(F,(e,t)=>L(e.data,t.data))};function ze(e,t){let n=new Map(e.map(e=>[e.id,e])),r=e.length!==t.length,i=t.map((t,i)=>{let a=n.get(t.id);return a?a.type===t.type&&a.position.x===t.position.x&&a.position.y===t.position.y&&L(a.data,t.data)?(e[i]!==a&&(r=!0),a):(r=!0,{...a,...t,measured:a.measured}):(r=!0,t)});return r?i:e}function R(e){return e.data?.renderKey}function Be(e,t){let n=new Map(e.map(e=>[e.id,e])),r=e.length!==t.length,i=t.map((t,i)=>{let a=n.get(t.id);return a&&R(a)===R(t)?(e[i]!==a&&(r=!0),a):(r=!0,t)});return r?i:e}function Ve(e){let{directory:t,packageName:n,depth:r,expandedDirectories:a,expandedFiles:c,loadingBranches:d,graphForFile:f,onToggleDirectory:p,onToggleFile:ee,onSelectFile:te,onOpenFile:ne,onSelectSymbol:re,selectedId:ie,activeOperations:ae}=e;return(0,O.jsxs)(O.Fragment,{children:[t.directories.map(t=>{let o=`${n}:${t.path}`,s=a.has(o);return(0,O.jsxs)(`div`,{children:[(0,O.jsxs)(`button`,{type:`button`,className:`flex h-7 w-full items-center gap-1.5 pr-2 text-left text-[11px] text-muted-foreground hover:bg-muted hover:text-foreground`,style:{paddingLeft:8+r*12},onClick:()=>p(o),children:[s?(0,O.jsx)(i,{className:`h-3 w-3`}):(0,O.jsx)(l,{className:`h-3 w-3`}),s?(0,O.jsx)(y,{className:`h-3.5 w-3.5 text-warning`}):(0,O.jsx)(ge,{className:`h-3.5 w-3.5 text-warning`}),(0,O.jsx)(`span`,{className:`truncate`,children:t.name})]}),s&&(0,O.jsx)(Ve,{...e,directory:t,depth:r+1})]},o)}),t.files.map(e=>{let t=c.has(e.file??e.id),n=C({level:`symbols`,file:e.file??e.label}),a=(e.file?f(e.file):void 0)?.nodes.filter(t=>t.kind===`symbol`&&t.file===e.file&&!t.external)??[],p=ae.filter(t=>je(t.filePath,e.file));return(0,O.jsxs)(`div`,{children:[(0,O.jsxs)(`div`,{className:x(`group flex h-7 items-center pr-1 text-[11px] hover:bg-muted`,ie===e.id&&`bg-primary/10 text-primary`),style:{paddingLeft:8+r*12},children:[(0,O.jsx)(`button`,{type:`button`,className:`flex h-6 w-4 shrink-0 items-center justify-center text-muted-foreground`,onClick:()=>ee(e),"aria-label":`${t?`Collapse`:`Expand`} ${e.label}`,children:d.has(n)?(0,O.jsx)(u,{className:`h-3 w-3 animate-spin`}):t?(0,O.jsx)(i,{className:`h-3 w-3`}):(0,O.jsx)(l,{className:`h-3 w-3`})}),(0,O.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-1.5 text-left`,onClick:()=>te(e),onDoubleClick:()=>ne(e),children:[(0,O.jsx)(b,{className:`h-3.5 w-3.5 shrink-0 text-info`}),p.length>0&&(0,O.jsx)(`span`,{className:`h-1.5 w-1.5 shrink-0 animate-pulse bg-success`,title:`${p.length} live operation(s)`}),(0,O.jsx)(`span`,{className:`truncate font-mono`,title:e.file,children:e.label}),(0,O.jsx)(`span`,{className:`ml-auto text-[9px] text-muted-foreground`,children:e.symbolCount??0})]}),(0,O.jsx)(`button`,{type:`button`,className:`ml-1 hidden h-5 w-5 items-center justify-center text-muted-foreground hover:text-foreground group-hover:flex`,onClick:()=>ne(e),title:`Open symbol map`,"aria-label":`Open ${e.label} map`,children:(0,O.jsx)(o,{className:`h-3 w-3`})})]}),t&&a.map(e=>(0,O.jsxs)(`button`,{type:`button`,className:x(`flex h-7 w-full items-center gap-1.5 pr-2 text-left text-[10px] hover:bg-muted`,ie===e.id?`bg-primary/10 text-primary`:`text-muted-foreground`),style:{paddingLeft:38+r*12},onClick:()=>re(e),children:[(0,O.jsx)(s,{className:`h-3 w-3 shrink-0 text-success`}),ae.some(t=>t.symbol?.id===e.id)&&(0,O.jsx)(m,{className:`h-3 w-3 shrink-0 animate-pulse text-success`}),(0,O.jsx)(`span`,{className:`truncate font-mono`,children:e.label}),e.line&&(0,O.jsxs)(`span`,{className:`ml-auto font-mono text-[8px] opacity-60`,children:[`:`,e.line]})]},e.id))]},e.id)})]})}function He(e){let{title:t,subtitle:n,items:r,graph:a,selectedId:o,expanded:s,onToggle:c,onSelect:u}=e;return(0,O.jsxs)(`section`,{className:`border-b py-3`,children:[(0,O.jsxs)(`div`,{className:`mb-2 flex items-end justify-between px-3`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`h3`,{className:`text-[10px] font-bold uppercase tracking-[0.16em]`,children:t}),(0,O.jsx)(`p`,{className:`mt-0.5 text-[9px] text-muted-foreground`,children:n})]}),(0,O.jsx)(`span`,{className:`border bg-muted px-1.5 py-0.5 font-mono text-[9px]`,children:r.length})]}),r.length===0?(0,O.jsx)(`p`,{className:`px-3 py-2 text-[10px] text-muted-foreground`,children:`No relationships in this view.`}):r.map(e=>{let n=`${t}:${e.node.id}`,r=s.has(n),d=[...w(a,e.node.id,`incoming`),...w(a,e.node.id,`outgoing`)].filter((e,t,n)=>e.node.id!==o&&n.findIndex(t=>t.node.id===e.node.id)===t).slice(0,8);return(0,O.jsxs)(`div`,{children:[(0,O.jsxs)(`div`,{className:`group flex min-h-9 items-center gap-1 px-2 hover:bg-muted/70`,children:[(0,O.jsx)(`button`,{type:`button`,className:`flex h-6 w-5 shrink-0 items-center justify-center text-muted-foreground`,onClick:()=>d.length>0&&c(n),"aria-label":`${r?`Collapse`:`Expand`} relation ${e.node.label}`,children:d.length>0?r?(0,O.jsx)(i,{className:`h-3 w-3`}):(0,O.jsx)(l,{className:`h-3 w-3`}):(0,O.jsx)(`span`,{className:`h-px w-2 bg-border`})}),(0,O.jsxs)(`button`,{type:`button`,className:`min-w-0 flex-1 py-1 text-left`,onClick:()=>u(e.node),children:[(0,O.jsx)(`span`,{className:`block truncate font-mono text-[10px] font-semibold`,title:e.node.label,children:e.node.label}),(0,O.jsx)(`span`,{className:`block truncate text-[9px] text-muted-foreground`,children:e.node.package??e.node.symbolKind??e.node.kind})]}),(0,O.jsx)(`span`,{className:`border px-1 py-0.5 font-mono text-[8px] text-muted-foreground`,children:e.edge.refType}),(0,O.jsxs)(`span`,{className:`w-5 text-right font-mono text-[9px] text-muted-foreground`,children:[`×`,e.edge.weight]})]}),r&&d.map(e=>(0,O.jsxs)(`button`,{type:`button`,className:`relative flex h-7 w-full items-center gap-2 border-l border-border pl-11 pr-3 text-left text-[9px] text-muted-foreground hover:bg-muted hover:text-foreground`,onClick:()=>u(e.node),children:[(0,O.jsx)(`span`,{className:`absolute left-7 top-1/2 h-px w-3 bg-border`}),(0,O.jsx)(ie,{className:`h-3 w-3 shrink-0`}),(0,O.jsx)(`span`,{className:`truncate font-mono`,children:e.node.label}),(0,O.jsx)(`span`,{className:`ml-auto font-mono opacity-70`,children:e.edge.refType})]},`${n}:${e.node.id}`))]},n)})]})}function Ue({activity:e}){return(0,O.jsx)(`span`,{className:x(`shrink-0 border px-1.5 py-0.5 font-mono text-[8px] font-bold uppercase`,e.type===`delete`?`border-destructive/50 bg-destructive/10 text-destructive`:e.type===`read`?`border-info/50 bg-info/10 text-info`:e.type===`search`||e.type===`index`?`border-primary/50 bg-primary/10 text-primary`:`border-warning/50 bg-warning/10 text-warning`),children:e.filePath.startsWith(`(tool:`)?e.toolName:e.type})}function z({activity:e,onLocate:t,showAgent:r=!1}){let i=e.agentName??e.agent??`External process`,s=`${e.sessionId??`none`}:${e.agentId??i}`;return(0,O.jsxs)(`button`,{type:`button`,className:`group flex w-full items-start gap-2 border-b px-3 py-2 text-left last:border-b-0 hover:bg-muted/70`,onClick:()=>!e.filePath.startsWith(`(`)&&t(e),title:`Locate ${e.filePath}`,children:[r&&(0,O.jsx)(`span`,{className:x(`mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center font-mono text-[8px] font-black`,M(s)),children:Ne(i)}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,O.jsx)(Ue,{activity:e}),r&&(0,O.jsx)(`span`,{className:`truncate text-[9px] font-semibold`,children:i}),e.status===`active`&&(0,O.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 font-mono text-[8px] font-bold text-success`,children:[(0,O.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse bg-success`}),` LIVE`]}),e.watcherConfirmed&&(0,O.jsx)(n,{className:`ml-auto h-3 w-3 text-success`,"aria-label":`Filesystem confirmed`}),e.attribution===`correlated`&&!e.watcherConfirmed&&(0,O.jsx)(`span`,{className:`ml-auto font-mono text-[7px] uppercase text-warning`,title:`Correlated from the only active tool`,children:`~ correlated`}),e.attribution===`external`&&(0,O.jsx)(`span`,{className:`ml-auto font-mono text-[7px] uppercase text-destructive`,children:`external`})]}),(0,O.jsx)(`div`,{className:`mt-1 truncate font-mono text-[9px] font-semibold`,title:e.filePath,children:N(e.filePath)}),(e.symbol||e.line)&&(0,O.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-1 truncate font-mono text-[8px] text-success`,children:[(0,O.jsx)(a,{className:`h-2.5 w-2.5 shrink-0`}),e.symbol?.name??`line ${e.line}`,e.symbol?.kind&&(0,O.jsxs)(`span`,{className:`text-muted-foreground`,children:[`· `,e.symbol.kind]})]}),e.change&&(0,O.jsxs)(`div`,{className:`mt-1 flex items-center gap-1 font-mono text-[8px]`,children:[(0,O.jsxs)(`span`,{className:`border border-success/40 bg-success/10 px-1 text-success`,children:[`+`,e.change.added]}),(0,O.jsxs)(`span`,{className:`border border-destructive/40 bg-destructive/10 px-1 text-destructive`,children:[`−`,e.change.removed]}),e.durationMs!==void 0&&(0,O.jsxs)(`span`,{className:`ml-auto text-muted-foreground`,children:[e.durationMs,`ms`]})]}),e.summary&&e.summary!==e.toolName&&(0,O.jsx)(`div`,{className:`mt-1 line-clamp-2 text-[8px] leading-3 text-muted-foreground`,children:e.summary})]}),!e.filePath.startsWith(`(`)&&(0,O.jsx)(o,{className:`mt-1 h-3 w-3 shrink-0 text-muted-foreground opacity-0 group-hover:opacity-100`})]})}function We({presences:e,onLocate:t}){return e.length===0?null:(0,O.jsxs)(`section`,{className:`pointer-events-auto absolute left-3 top-14 z-20 w-[304px] border bg-card/95 shadow-xl backdrop-blur`,children:[(0,O.jsxs)(`div`,{className:`flex h-9 items-center gap-2 border-b px-3`,children:[(0,O.jsx)(m,{className:`h-3.5 w-3.5 animate-pulse text-success`}),(0,O.jsx)(`h2`,{className:`text-[9px] font-black uppercase tracking-[0.18em]`,children:`Live agent operations`}),(0,O.jsxs)(`span`,{className:`ml-auto bg-success px-1.5 py-0.5 font-mono text-[8px] font-bold text-success-foreground`,children:[e.length,` ONLINE`]})]}),(0,O.jsx)(`div`,{className:`max-h-[330px] overflow-y-auto`,children:e.map(e=>(0,O.jsxs)(`div`,{className:`border-b last:border-b-0`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2 bg-muted/35 px-3 py-1.5`,children:[(0,O.jsx)(`span`,{className:x(`flex h-6 w-6 items-center justify-center font-mono text-[8px] font-black`,M(e.key)),children:Ne(e.agentName)}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(`div`,{className:`truncate text-[9px] font-bold`,children:e.agentName}),(0,O.jsxs)(`div`,{className:`truncate font-mono text-[7px] text-muted-foreground`,children:[`session `,e.sessionId.slice(0,12),` · agent `,e.agentId.slice(0,12)]})]}),(0,O.jsxs)(`span`,{className:`font-mono text-[8px] text-success`,children:[e.operations.length,` op`]})]}),e.operations.map(e=>(0,O.jsx)(z,{activity:e,onLocate:t},e.id??`${e.toolUseId}:${e.filePath}`))]},e.key))})]})}function Ge({paused:e,followLive:t,agentFilter:n,agents:r,onTogglePaused:i,onToggleFollow:o,onAgentFilter:s}){return(0,O.jsxs)(`div`,{className:`pointer-events-auto absolute right-3 top-14 z-20 flex h-9 items-center border bg-card/95 shadow-lg backdrop-blur`,children:[(0,O.jsxs)(`button`,{type:`button`,className:x(`flex h-full items-center gap-1.5 border-r px-2.5 text-[8px] font-bold uppercase tracking-wider`,t?`bg-primary text-primary-foreground`:`text-muted-foreground hover:bg-muted`),onClick:o,title:`Automatically enter the file/function used by the newest visible agent`,children:[(0,O.jsx)(a,{className:`h-3 w-3`}),` Follow`]}),(0,O.jsxs)(`button`,{type:`button`,className:x(`flex h-full items-center gap-1.5 border-r px-2.5 text-[8px] font-bold uppercase tracking-wider`,e?`bg-warning text-warning-foreground`:`text-success hover:bg-success/10`),onClick:i,title:e?`Resume the live telemetry stream`:`Freeze the current telemetry frame`,children:[e?(0,O.jsx)(h,{className:`h-3 w-3`}):(0,O.jsx)(se,{className:`h-3 w-3`}),e?`Resume`:`Live`]}),(0,O.jsxs)(`label`,{className:`flex h-full items-center gap-1.5 px-2 text-[8px] uppercase text-muted-foreground`,children:[`Agent`,(0,O.jsxs)(`select`,{"aria-label":`Filter CodeMap by agent and session`,className:`h-6 max-w-[170px] border bg-background px-1.5 font-mono text-[8px] text-foreground outline-none focus:border-primary`,value:n,onChange:e=>s(e.target.value),children:[(0,O.jsx)(`option`,{value:`all`,children:`ALL AGENTS`}),r.map(e=>(0,O.jsxs)(`option`,{value:e.key,children:[e.agentName,` · `,e.sessionId.slice(0,10)]},e.key))]})]})]})}function B(){let[e,n]=(0,S.useState)({level:`packages`}),a=C(e),[s,f]=(0,S.useState)(Ee),[h,se]=(0,S.useState)(!0),[g,me]=(0,S.useState)(null),[_,v]=(0,S.useState)(null),[y,ge]=(0,S.useState)(`layers`),[b,T]=(0,S.useState)(`smart`),[E,Se]=(0,S.useState)(`all`),[D,ke]=(0,S.useState)(``),[k,Ae]=(0,S.useState)(new Set),[A,M]=(0,S.useState)(new Set),[N,Fe]=(0,S.useState)(new Set),[P,F]=(0,S.useState)(new Set),[I,L]=(0,S.useState)(new Set),[R,Ue]=(0,S.useState)(0),[B,Ke]=(0,S.useState)(null),[qe,Je]=(0,S.useState)(!1),[V,Ye]=(0,S.useState)(`all`),[H,Xe]=(0,S.useState)(null),[Ze,Qe]=(0,S.useState)(null),[$e,et]=(0,S.useState)(0),U=(0,S.useRef)(new Map),tt=(0,S.useRef)(null),nt=(0,S.useRef)(null),rt=(0,S.useRef)(``),W=_e(),G=(0,S.useMemo)(()=>[...W.activeOperations.values()].flat(),[W.activeOperations]),it=(0,S.useMemo)(()=>[...W.pulses.keys()].map(e=>W.history.get(e)?.[0]).filter(e=>!!e),[W.history,W.pulses]),K=(0,S.useMemo)(()=>{let e=[];for(let t of W.history.values())e.push(...t.slice(0,16));return e.sort((e,t)=>t.timestamp-e.timestamp).slice(0,16)},[W.history]),at=(0,S.useMemo)(()=>ve([...G,...K]),[G,K]),q=(0,S.useMemo)(()=>{let e=H??G;return V===`all`?e:e.filter(e=>ye(e)===V)},[G,V,H]),ot=(0,S.useMemo)(()=>{let e=Ze??K;return V===`all`?e:e.filter(e=>ye(e)===V)},[V,Ze,K]),st=(0,S.useMemo)(()=>ve(q),[q]),[ct,lt,ut]=oe([]),[dt,ft,pt]=ue([]),{fitView:mt}=re(),J=(0,S.useCallback)(async(e,t=!1)=>{let n=C(e),r=U.current.get(n);if(r&&!t)return r;let i=await fetch(be(e));if(!i.ok){let e=await i.json().catch(()=>({error:i.statusText}));throw Error(e.error??`HTTP ${i.status}`)}let a=await i.json();return U.current.set(n,a),Ue(e=>e+1),a},[]);(0,S.useEffect)(()=>{let t=!1;return se(!0),me(null),J(e).then(e=>{if(t)return;f(e);let n=tt.current;tt.current=null,v(n&&e.nodes.some(e=>e.id===n)?n:null),se(!1)}).catch(e=>{t||(me(e instanceof Error?e.message:String(e)),f(Ee),se(!1))}),()=>{t=!0}},[a,J]);let Y=(0,S.useCallback)((e,t)=>{if(tt.current=t??null,C(e)===a){v(t??null),tt.current=null;return}n(e)},[a]),ht=(0,S.useCallback)(async e=>{let t=C(e);if(!(U.current.has(t)||I.has(t))){L(e=>new Set(e).add(t));try{await J(e)}finally{L(e=>{let n=new Set(e);return n.delete(t),n})}}},[J,I]);(0,S.useEffect)(()=>{let e=!1;for(let t of G)t.symbol||!t.toolUseId||t.filePath.startsWith(`(`)||J({level:`symbols`,file:t.filePath}).then(n=>{if(e)return;let r=Ie(t,n.nodes);r&&W.resolveActivitySymbol(t.toolUseId,t.filePath,{id:r.id,name:r.label,...r.symbolKind?{kind:r.symbolKind}:{},...r.line?{line:r.line}:{}})}).catch(()=>void 0);return()=>{e=!0}},[G,W.resolveActivitySymbol,J]);let X=(0,S.useMemo)(()=>({nodes:s.nodes,edges:E===`all`?s.edges:s.edges.filter(e=>e.refType===E)}),[s,E]),Z=s.nodes.find(e=>e.id===_),Q=(0,S.useMemo)(()=>Le(X,_,b),[b,X,_]),gt=(0,S.useMemo)(()=>_?xe(X,_):new Set,[X,_]),{incomingCounts:_t,outgoingCounts:vt}=(0,S.useMemo)(()=>{let e=new Map,t=new Map;for(let n of X.edges)t.set(n.source,(t.get(n.source)??0)+1),e.set(n.target,(e.get(n.target)??0)+1);return{incomingCounts:e,outgoingCounts:t}},[X]),yt=y===`orbit`?_??void 0:void 0,bt=(0,S.useMemo)(()=>Ce(Q,y,yt),[Q,y,yt]),xt=(0,S.useMemo)(()=>[a,y,y===`orbit`?_??``:``,Q.nodes.map(e=>e.id).join(``),Q.edges.map(e=>`${e.source}>${e.target}:${e.refType}`).join(``)].join(``),[Q,a,y,_]),St=(0,S.useCallback)(e=>{v(e.id),F(new Set)},[]),Ct=(0,S.useCallback)(e=>{e.kind===`package`&&Y({level:`files`,package:e.package??e.label}),e.kind===`file`&&e.file&&Y({level:`symbols`,file:e.file,package:e.package})},[Y]);(0,S.useEffect)(()=>{let e=new Set(bt.filter(({node:e})=>q.some(t=>j(t,e))).map(({node:e})=>e.id)),t=bt.map(({node:e,position:t})=>{let n=q.filter(t=>j(t,e)),r=n[0]??it.find(t=>j(t,e));return{id:e.id,type:`codemap`,position:t,data:{graphNode:e,selected:e.id===_,dimmed:!!_&&!gt.has(e.id),incoming:_t.get(e.id)??0,outgoing:vt.get(e.id)??0,isActive:!!r,...r?{activityType:r.type}:{},activeOperations:n,onSelect:St,onOpen:Ct,onShowHistory:Ke}}});lt(e=>ze(e,t));let n=Q.edges.map((t,n)=>{let r=!!_&&(t.source===_||t.target===_),i=e.has(t.source)||e.has(t.target),a=Oe[t.refType]??`hsl(var(--muted-foreground))`;return{id:`edge:${t.source}:${t.target}:${n}`,source:t.source,target:t.target,type:`smoothstep`,animated:i,label:r?`${t.refType}${t.weight>1?` ×${t.weight}`:``}`:void 0,markerEnd:{type:ne.ArrowClosed,color:a,width:14,height:14},style:{stroke:a,strokeWidth:i?Math.min(2.5+Math.log2(t.weight+1)*.65,5):r?Math.min(1.25+Math.log2(t.weight+1)*.65,4):1,opacity:i?1:_?r?.88:.08:.52},labelStyle:{fontSize:9,fontFamily:`var(--font-mono)`,fill:`hsl(var(--muted-foreground))`},labelBgStyle:{fill:`hsl(var(--card))`,fillOpacity:.92},labelBgPadding:[4,2],zIndex:i?4:r?2:0,data:{renderKey:`${t.refType}:${t.weight}:${_?r?`focused`:`dimmed`:`idle`}:${i?`live`:`still`}`}}}),r=new Map,i=new Set(q.map(ye));for(let e of[...ot].sort((e,t)=>e.timestamp-t.timestamp)){let t=ye(e);r.set(t,[...r.get(t)??[],e])}let a=[];for(let[e,t]of r){let n=i.has(e),r=t.map(e=>({activity:e,node:Q.nodes.find(t=>j(e,t))})).filter(e=>!!e.node).filter((e,t,n)=>t===0||e.node.id!==n[t-1]?.node.id),o=Pe(e);for(let t=1;t<r.length;t++){let i=r[t-1],s=r[t];a.push({id:`trail:${e}:${i.activity.timestamp}:${s.activity.timestamp}`,source:i.node.id,target:s.node.id,type:`smoothstep`,animated:n,label:t===r.length-1?`${Ne(s.activity.agentName??s.activity.agent??`agent`)} TRAIL`:void 0,markerEnd:{type:ne.ArrowClosed,color:o,width:13,height:13},style:{stroke:o,strokeWidth:2.5,strokeDasharray:`7 5`,opacity:.9},labelStyle:{fontSize:8,fontWeight:700,fill:o},labelBgStyle:{fill:`hsl(var(--card))`,fillOpacity:.94},labelBgPadding:[4,2],zIndex:6,data:{renderKey:`${o}:${t===r.length-1?`label`:`plain`}:${n?`live`:`still`}`}})}}if(et(a.length),ft(e=>Be(e,[...n,...a])),rt.current===xt)return;let o=window.setTimeout(()=>{rt.current=xt,mt({padding:.2,duration:240,maxZoom:1.25})},20);return()=>window.clearTimeout(o)},[Q,_,q,ot,xt,gt,mt,Ct,St,_t,vt,bt,it,ft,lt]),(0,S.useEffect)(()=>{let e=window.setInterval(()=>{W._sweep()},2e3);return()=>window.clearInterval(e)},[W._sweep]);let wt=U.current.get(`packages`)??(e.level===`packages`?s:Ee),Tt=(0,S.useCallback)(e=>U.current.get(C({level:`files`,package:e})),[R]),Et=(0,S.useCallback)(e=>U.current.get(C({level:`symbols`,file:e})),[R]),$=(0,S.useCallback)(e=>{let t=e.filePath,n=Me(e.filePath),r=`file:${e.filePath}`;for(let i of U.current.values()){let a=i.nodes.find(t=>t.kind===`file`&&!t.external&&je(t.file,e.filePath));if(a){t=a.file??t,n=a.package??n,r=a.id;break}}if(e.symbol){Y({level:`symbols`,file:t,package:n},e.symbol.id);return}Y({level:`files`,package:n},r)},[Y]);(0,S.useEffect)(()=>{if(!qe||H)return;let e=[...q].filter(e=>!e.filePath.startsWith(`(`)).sort((e,t)=>t.timestamp-e.timestamp)[0];if(!e)return;let t=`${e.id??e.toolUseId}:${e.filePath}:${e.symbol?.id??`file`}`;nt.current!==t&&(nt.current=t,$(e))},[q,qe,$,H]);let Dt=(0,S.useCallback)(()=>{if(H){Xe(null),Qe(null);return}Xe([...G]),Qe([...K])},[G,H,K]),Ot=(0,S.useCallback)(e=>{let t=e.package??e.label,n=!k.has(t);Ae(e=>{let r=new Set(e);return n?r.add(t):r.delete(t),r}),n&&ht({level:`files`,package:t}).then(()=>{let e=U.current.get(C({level:`files`,package:t})),n=e?Te(e.nodes):void 0;n?.directories.length===1&&n.directories[0]&&M(e=>new Set(e).add(`${t}:${n.directories[0].path}`))}).catch(()=>void 0)},[ht,k]),kt=(0,S.useCallback)(e=>{if(!e.file)return;let t=!N.has(e.file);Fe(n=>{let r=new Set(n);return t?r.add(e.file):r.delete(e.file),r}),t&&ht({level:`symbols`,file:e.file,package:e.package}).catch(()=>void 0)},[ht,N]),At=(0,S.useCallback)(e=>{M(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),jt=(0,S.useCallback)(e=>{Y({level:`files`,package:e.package??`(root)`},e.id)},[Y]),Mt=(0,S.useCallback)(e=>{e.file&&Y({level:`symbols`,file:e.file,package:e.package},e.id)},[Y]),Nt=(0,S.useMemo)(()=>{let e=D.trim().toLocaleLowerCase();if(!e)return[];let t=new Map;for(let n of U.current.values())for(let r of n.nodes)`${r.label} ${r.file??``} ${r.signature??``} ${r.package??``}`.toLocaleLowerCase().includes(e)&&t.set(r.id,r);return[...t.values()].sort((e,t)=>e.kind.localeCompare(t.kind)||e.label.localeCompare(t.label)).slice(0,80)},[D,R]),Pt=(0,S.useCallback)(e=>{e.kind===`package`?Y({level:`packages`},e.id):e.kind===`file`?Y({level:`files`,package:e.package??`(root)`},e.id):e.file&&Y({level:`symbols`,file:e.file,package:e.package},e.id)},[Y]),{incoming:Ft,outgoing:It}=(0,S.useMemo)(()=>({incoming:Z?w(X,Z.id,`incoming`):[],outgoing:Z?w(X,Z.id,`outgoing`):[]}),[X,Z]),{edgeWeight:Lt,connectedNodeCount:Rt}=(0,S.useMemo)(()=>{let e=0,t=new Set;for(let n of X.edges)e+=n.weight,t.add(n.source),t.add(n.target);return{edgeWeight:e,connectedNodeCount:t.size}},[X]),zt=Z?q.filter(e=>j(e,Z)):[],Bt=B?W.getActivityForFile(B):[];return(0,O.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-background`,children:[(0,O.jsxs)(`header`,{className:`flex h-[62px] shrink-0 items-center gap-4 border-b bg-card px-4`,children:[(0,O.jsxs)(`div`,{className:`flex min-w-[220px] items-center gap-3`,children:[(0,O.jsx)(`span`,{className:`flex h-9 w-9 items-center justify-center border border-primary bg-primary/10 text-primary`,children:(0,O.jsx)(r,{className:`h-4 w-4`})}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`h1`,{className:`font-display text-sm font-semibold tracking-tight`,children:`Code Atlas`}),(0,O.jsx)(`p`,{className:`text-[9px] uppercase tracking-[0.18em] text-muted-foreground`,children:`Architecture intelligence`})]})]}),(0,O.jsxs)(`nav`,{className:`flex min-w-0 flex-1 items-center gap-1 font-mono text-[10px]`,"aria-label":`Code map breadcrumb`,children:[e.level!==`packages`&&(0,O.jsx)(`button`,{type:`button`,className:`mr-1 flex h-7 w-7 items-center justify-center border text-muted-foreground hover:bg-muted`,onClick:()=>{e.level===`symbols`?Y({level:`files`,package:e.package??`(root)`}):Y({level:`packages`})},"aria-label":`Back`,children:(0,O.jsx)(d,{className:`h-3.5 w-3.5`})}),(0,O.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1.5 px-1.5 py-1 text-muted-foreground hover:text-foreground`,onClick:()=>Y({level:`packages`}),children:[(0,O.jsx)(pe,{className:`h-3 w-3`}),` workspace`]}),e.level!==`packages`&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(l,{className:`h-3 w-3 text-muted-foreground`}),(0,O.jsx)(`button`,{type:`button`,className:`max-w-[220px] truncate px-1.5 py-1 hover:text-primary`,onClick:()=>Y({level:`files`,package:e.package??`(root)`}),children:e.package??`(root)`})]}),e.level===`symbols`&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(l,{className:`h-3 w-3 text-muted-foreground`}),(0,O.jsx)(`span`,{className:`truncate px-1.5 py-1 text-primary`,children:we({id:``,label:e.file,kind:`file`,file:e.file,package:e.package})})]})]}),(0,O.jsxs)(`div`,{className:`hidden items-center gap-5 xl:flex`,children:[(0,O.jsxs)(`div`,{className:x(`flex h-8 items-center gap-2 border px-2.5`,st.length>0?`border-success/50 bg-success/10 text-success`:`text-muted-foreground`),children:[(0,O.jsx)(m,{className:x(`h-3 w-3`,st.length>0&&`animate-pulse`)}),(0,O.jsxs)(`div`,{children:[(0,O.jsxs)(`div`,{className:`font-mono text-[10px] font-bold`,children:[st.length,` LIVE`]}),(0,O.jsx)(`div`,{className:`text-[7px] uppercase tracking-wider`,children:`agents`})]})]}),(0,O.jsxs)(`div`,{className:`text-right`,children:[(0,O.jsx)(`div`,{className:`font-mono text-sm font-semibold`,children:s.nodes.length}),(0,O.jsx)(`div`,{className:`text-[8px] uppercase tracking-wider text-muted-foreground`,children:`nodes`})]}),(0,O.jsxs)(`div`,{className:`text-right`,children:[(0,O.jsx)(`div`,{className:`font-mono text-sm font-semibold`,children:s.edges.length}),(0,O.jsx)(`div`,{className:`text-[8px] uppercase tracking-wider text-muted-foreground`,children:`links`})]}),(0,O.jsxs)(`div`,{className:`text-right`,children:[(0,O.jsx)(`div`,{className:`font-mono text-sm font-semibold`,children:Lt}),(0,O.jsx)(`div`,{className:`text-[8px] uppercase tracking-wider text-muted-foreground`,children:`references`})]}),(0,O.jsxs)(`div`,{className:`text-right`,children:[(0,O.jsx)(`div`,{className:`font-mono text-sm font-semibold`,children:Rt}),(0,O.jsx)(`div`,{className:`text-[8px] uppercase tracking-wider text-muted-foreground`,children:`connected`})]})]})]}),(0,O.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,O.jsxs)(`aside`,{className:`flex w-[286px] shrink-0 flex-col border-r bg-card/70`,children:[(0,O.jsxs)(`div`,{className:`border-b p-3`,children:[(0,O.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,O.jsx)(`h2`,{className:`text-[10px] font-bold uppercase tracking-[0.18em]`,children:`Code tree`}),(0,O.jsxs)(`span`,{className:`font-mono text-[9px] text-muted-foreground`,children:[wt.nodes.length,` roots`]})]}),(0,O.jsxs)(`label`,{className:`flex h-8 items-center gap-2 border bg-background px-2 focus-within:border-primary`,children:[(0,O.jsx)(de,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,O.jsx)(`input`,{className:`min-w-0 flex-1 bg-transparent font-mono text-[10px] outline-none placeholder:text-muted-foreground`,value:D,onChange:e=>ke(e.target.value),placeholder:`Find package, file, symbol…`}),D&&(0,O.jsx)(`button`,{type:`button`,onClick:()=>ke(``),"aria-label":`Clear search`,children:(0,O.jsx)(le,{className:`h-3 w-3 text-muted-foreground`})})]})]}),(0,O.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-2`,children:D.trim()?(0,O.jsxs)(`div`,{children:[(0,O.jsxs)(`div`,{className:`px-3 pb-2 text-[9px] text-muted-foreground`,children:[Nt.length,` loaded-map results`]}),Nt.map(e=>{let t=De[e.kind].icon;return(0,O.jsxs)(`button`,{type:`button`,className:`flex min-h-8 w-full items-center gap-2 px-3 py-1 text-left hover:bg-muted`,onClick:()=>Pt(e),children:[(0,O.jsx)(t,{className:x(`h-3.5 w-3.5 shrink-0`,e.kind===`package`?`text-primary`:e.kind===`file`?`text-info`:`text-success`)}),(0,O.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(`span`,{className:`block truncate font-mono text-[10px]`,children:e.label}),(0,O.jsx)(`span`,{className:`block truncate text-[8px] text-muted-foreground`,children:e.file??e.package??e.symbolKind})]}),(0,O.jsx)(`span`,{className:`text-[8px] uppercase text-muted-foreground`,children:e.kind.slice(0,3)})]},e.id)}),Nt.length===0&&(0,O.jsxs)(`p`,{className:`px-3 py-8 text-center text-[10px] text-muted-foreground`,children:[`No match in loaded branches.`,(0,O.jsx)(`br`,{}),`Expand a package to search its files.`]})]}):wt.nodes.map(e=>{let t=e.package??e.label,n=k.has(t),r=C({level:`files`,package:t}),a=Tt(t),s=a?Te(a.nodes):void 0;return(0,O.jsxs)(`div`,{children:[(0,O.jsxs)(`div`,{className:x(`group flex h-8 items-center px-2 hover:bg-muted`,_===e.id&&`bg-primary/10 text-primary`),children:[(0,O.jsx)(`button`,{type:`button`,className:`flex h-6 w-5 items-center justify-center text-muted-foreground`,onClick:()=>Ot(e),"aria-label":`${n?`Collapse`:`Expand`} ${t}`,children:I.has(r)?(0,O.jsx)(u,{className:`h-3 w-3 animate-spin`}):n?(0,O.jsx)(i,{className:`h-3 w-3`}):(0,O.jsx)(l,{className:`h-3 w-3`})}),(0,O.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-2 text-left`,onClick:()=>Y({level:`packages`},e.id),onDoubleClick:()=>Y({level:`files`,package:t}),children:[(0,O.jsx)(he,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,O.jsx)(`span`,{className:`truncate font-mono text-[10px] font-semibold`,children:e.label}),(0,O.jsx)(`span`,{className:`ml-auto text-[9px] text-muted-foreground`,children:e.fileCount??0})]}),(0,O.jsx)(`button`,{type:`button`,className:`ml-1 hidden h-5 w-5 items-center justify-center text-muted-foreground hover:text-foreground group-hover:flex`,onClick:()=>Y({level:`files`,package:t}),title:`Open file map`,"aria-label":`Open ${t} map`,children:(0,O.jsx)(o,{className:`h-3 w-3`})})]}),n&&s&&(0,O.jsx)(Ve,{directory:s,packageName:t,depth:1,expandedDirectories:A,expandedFiles:N,loadingBranches:I,graphForFile:Et,onToggleDirectory:At,onToggleFile:kt,onSelectFile:jt,onOpenFile:Ct,onSelectSymbol:Mt,selectedId:_,activeOperations:q})]},e.id)})}),(0,O.jsxs)(`div`,{className:`border-t px-3 py-2 text-[9px] leading-relaxed text-muted-foreground`,children:[`Click to focus · double-click to enter`,(0,O.jsx)(`br`,{}),`Branches stay open while the map changes`]})]}),(0,O.jsxs)(`main`,{className:`relative min-w-0 flex-1 bg-[radial-gradient(circle_at_50%_0%,hsl(var(--primary)/0.055),transparent_38%)]`,children:[(0,O.jsxs)(`div`,{className:`absolute left-3 right-3 top-3 z-10 flex items-center gap-2 pointer-events-none`,children:[(0,O.jsxs)(`div`,{className:`pointer-events-auto flex border bg-card/95 shadow-md backdrop-blur`,children:[(0,O.jsxs)(`button`,{type:`button`,className:x(`flex h-8 items-center gap-1.5 border-r px-2.5 text-[9px] font-semibold uppercase tracking-wider`,y===`layers`?`bg-primary text-primary-foreground`:`text-muted-foreground hover:bg-muted`),onClick:()=>ge(`layers`),children:[(0,O.jsx)(t,{className:`h-3 w-3`}),` Layers`]}),(0,O.jsxs)(`button`,{type:`button`,className:x(`flex h-8 items-center gap-1.5 px-2.5 text-[9px] font-semibold uppercase tracking-wider`,y===`orbit`?`bg-primary text-primary-foreground`:`text-muted-foreground hover:bg-muted`),onClick:()=>ge(`orbit`),children:[(0,O.jsx)(c,{className:`h-3 w-3`}),` Relations`]})]}),(0,O.jsxs)(`div`,{className:`pointer-events-auto flex border bg-card/95 shadow-md backdrop-blur`,children:[(0,O.jsxs)(`button`,{type:`button`,className:x(`h-8 border-r px-2.5 font-mono text-[9px] font-bold`,b===`smart`?`bg-success text-success-foreground`:`text-muted-foreground hover:bg-muted`),onClick:()=>T(`smart`),title:`Keep the full tree, show the strongest relations and selected neighbourhood`,children:[`SMART `,Q.nodes.length,`/`,s.nodes.length]}),(0,O.jsx)(`button`,{type:`button`,className:x(`h-8 px-2.5 font-mono text-[9px] font-bold`,b===`all`?`bg-foreground text-background`:`text-muted-foreground hover:bg-muted`),onClick:()=>T(`all`),title:`Render every node and relation in this scope`,children:`ALL`})]}),(0,O.jsx)(`div`,{className:`pointer-events-auto ml-auto flex max-w-[60%] overflow-x-auto border bg-card/95 shadow-md backdrop-blur`,children:[`all`,`import`,`call`,`type_ref`,`inherit`,`implement`].map(e=>(0,O.jsx)(`button`,{type:`button`,className:x(`h-8 whitespace-nowrap border-r px-2.5 font-mono text-[9px] last:border-r-0`,E===e?`bg-foreground text-background`:`text-muted-foreground hover:bg-muted`),onClick:()=>Se(e),children:e===`all`?`ALL LINKS`:e.replace(`_`,` `).toUpperCase()},e))})]}),(0,O.jsx)(We,{presences:st,onLocate:$}),(0,O.jsx)(Ge,{paused:H!==null,followLive:qe,agentFilter:V,agents:at,onTogglePaused:Dt,onToggleFollow:()=>{nt.current=null,Je(e=>!e)},onAgentFilter:e=>{nt.current=null,Ye(e)}}),h&&(0,O.jsxs)(`div`,{className:`absolute inset-0 z-20 flex flex-col items-center justify-center gap-3 bg-background/75 backdrop-blur-sm`,children:[(0,O.jsx)(u,{className:`h-7 w-7 animate-spin text-primary`}),(0,O.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-widest text-muted-foreground`,children:`Mapping relationships`})]}),g&&!h&&(0,O.jsxs)(`div`,{className:`absolute inset-0 z-20 flex flex-col items-center justify-center gap-3 p-8 text-center`,children:[(0,O.jsx)(r,{className:`h-10 w-10 text-destructive`}),(0,O.jsx)(`p`,{className:`font-mono text-sm text-destructive`,children:g}),(0,O.jsxs)(`p`,{className:`max-w-md text-xs text-muted-foreground`,children:[`The map needs a codebase index. Run`,` `,(0,O.jsx)(`code`,{className:`border bg-muted px-1.5 py-0.5`,children:`codebase-index`}),` once, then reopen this view.`]})]}),!h&&!g&&s.nodes.length===0&&(0,O.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-2 text-muted-foreground`,children:[(0,O.jsx)(r,{className:`h-8 w-8 opacity-40`}),(0,O.jsx)(`p`,{className:`text-xs`,children:`No indexed nodes at this level.`})]}),!h&&!g&&s.nodes.length>1&&s.edges.length===0&&(0,O.jsxs)(`div`,{className:`pointer-events-none absolute left-1/2 top-14 z-10 -translate-x-1/2 border border-warning/40 bg-warning/10 px-3 py-2 text-center shadow backdrop-blur`,children:[(0,O.jsx)(`div`,{className:`font-mono text-[9px] font-bold uppercase tracking-wider text-warning`,children:`No resolved relations in this scope`}),(0,O.jsx)(`div`,{className:`mt-0.5 text-[8px] text-muted-foreground`,children:`The upgraded index will rebuild and resolve call/import/type links automatically.`})]}),!g&&s.nodes.length>0&&(0,O.jsxs)(te,{nodes:ct,edges:dt,onNodesChange:ut,onEdgesChange:pt,nodeTypes:Re,nodesConnectable:!1,nodesDraggable:!1,edgesFocusable:!1,elementsSelectable:!1,onlyRenderVisibleElements:Q.nodes.length>30,minZoom:.08,maxZoom:2.2,proOptions:{hideAttribution:!0},children:[(0,O.jsx)(fe,{variant:ae.Dots,gap:22,size:1,color:`hsl(var(--muted-foreground))`,className:`!opacity-25`}),(0,O.jsx)(p,{position:`bottom-left`,showInteractive:!1,className:`!border !border-border !bg-card !shadow-md [&>button]:!border-border [&>button]:!bg-card [&>button]:!fill-foreground`}),(0,O.jsx)(ee,{position:`bottom-right`,pannable:!0,zoomable:!0,className:`!h-[112px] !w-[180px] !border !border-border !bg-card !shadow-md`,maskColor:`hsl(var(--background) / 0.72)`,nodeColor:e=>{let t=e.data?.graphNode.kind;return t===`package`?`hsl(var(--primary))`:t===`file`?`hsl(var(--info))`:`hsl(var(--success))`}})]}),(0,O.jsxs)(`div`,{className:`pointer-events-none absolute bottom-3 left-1/2 z-10 flex -translate-x-1/2 items-center gap-3 border bg-card/90 px-3 py-1.5 font-mono text-[8px] text-muted-foreground shadow backdrop-blur`,children:[Object.entries(Oe).map(([e,t])=>(0,O.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,O.jsx)(`span`,{className:`h-0.5 w-3`,style:{backgroundColor:t}}),e.replace(`_`,` `)]},e)),(0,O.jsxs)(`span`,{className:`flex items-center gap-1 text-primary`,"data-testid":`agent-trail-count`,children:[(0,O.jsx)(`span`,{className:`w-4 border-t-2 border-dashed border-primary`}),`agent trail`,$e>0?` ×${$e}`:``]})]})]}),(0,O.jsxs)(`aside`,{className:`flex w-[326px] shrink-0 flex-col border-l bg-card/80`,children:[(0,O.jsxs)(`div`,{className:`flex h-10 items-center justify-between border-b px-3`,children:[(0,O.jsx)(`h2`,{className:`text-[10px] font-bold uppercase tracking-[0.18em]`,children:`Relation inspector`}),Z&&(0,O.jsx)(`button`,{type:`button`,className:`text-muted-foreground hover:text-foreground`,onClick:()=>v(null),"aria-label":`Clear selection`,children:(0,O.jsx)(le,{className:`h-3.5 w-3.5`})})]}),Z?(0,O.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[(0,O.jsxs)(`div`,{className:`border-b bg-muted/25 p-3`,children:[(0,O.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,O.jsx)(`span`,{className:x(`flex h-8 w-8 items-center justify-center border`,De[Z.kind].iconStyle),children:(()=>{let e=De[Z.kind].icon;return(0,O.jsx)(e,{className:`h-4 w-4`})})()}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsxs)(`div`,{className:`text-[8px] font-bold uppercase tracking-[0.18em] text-muted-foreground`,children:[Z.external?`external `:``,Z.kind]}),(0,O.jsx)(`div`,{className:`truncate font-mono text-xs font-semibold`,title:Z.label,children:Z.label})]})]}),(0,O.jsx)(`div`,{className:`break-all font-mono text-[9px] leading-relaxed text-muted-foreground`,children:Z.file?we(Z):Z.package}),Z.signature&&(0,O.jsx)(`pre`,{className:`mt-3 overflow-x-auto border bg-background p-2 font-mono text-[9px] leading-relaxed text-foreground`,children:Z.signature}),(0,O.jsxs)(`div`,{className:`mt-3 grid grid-cols-3 border`,children:[(0,O.jsxs)(`div`,{className:`border-r p-2 text-center`,children:[(0,O.jsx)(`div`,{className:`font-mono text-sm font-semibold text-info`,children:Ft.length}),(0,O.jsx)(`div`,{className:`text-[8px] uppercase text-muted-foreground`,children:`incoming`})]}),(0,O.jsxs)(`div`,{className:`border-r p-2 text-center`,children:[(0,O.jsx)(`div`,{className:`font-mono text-sm font-semibold text-primary`,children:It.length}),(0,O.jsx)(`div`,{className:`text-[8px] uppercase text-muted-foreground`,children:`outgoing`})]}),(0,O.jsxs)(`div`,{className:`p-2 text-center`,children:[(0,O.jsx)(`div`,{className:`font-mono text-sm font-semibold`,children:Z.symbolCount??Z.fileCount??Z.line??`—`}),(0,O.jsx)(`div`,{className:`text-[8px] uppercase text-muted-foreground`,children:Z.kind===`package`?`files`:Z.kind===`file`?`symbols`:`line`})]})]}),(0,O.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[Z.kind!==`symbol`&&(0,O.jsxs)(`button`,{type:`button`,className:`flex h-7 flex-1 items-center justify-center gap-1.5 border bg-foreground text-[9px] font-semibold uppercase tracking-wider text-background hover:opacity-90`,onClick:()=>Ct(Z),children:[(0,O.jsx)(o,{className:`h-3 w-3`}),` Open`,` `,Z.kind===`package`?`files`:`symbols`]}),Z.file&&(0,O.jsxs)(`button`,{type:`button`,className:`flex h-7 items-center justify-center gap-1.5 border px-2 text-[9px] uppercase text-muted-foreground hover:bg-muted`,onClick:()=>Ke(Z.file),children:[(0,O.jsx)(ce,{className:`h-3 w-3`}),` Activity`]})]})]}),zt.length>0&&(0,O.jsxs)(`section`,{className:`border-b bg-success/5 py-2`,children:[(0,O.jsxs)(`div`,{className:`mb-1 flex items-center gap-2 px-3`,children:[(0,O.jsx)(m,{className:`h-3 w-3 animate-pulse text-success`}),(0,O.jsx)(`h3`,{className:`text-[9px] font-bold uppercase tracking-[0.16em]`,children:`Agents on this node`}),(0,O.jsx)(`span`,{className:`ml-auto font-mono text-[9px] text-success`,children:zt.length})]}),zt.map(e=>(0,O.jsx)(z,{activity:e,onLocate:$,showAgent:!0},e.id??`${e.toolUseId}:${e.filePath}`))]}),(0,O.jsx)(He,{title:`Incoming`,subtitle:`Who depends on this`,items:Ft,graph:X,selectedId:Z.id,expanded:P,onToggle:e=>F(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),onSelect:St}),(0,O.jsx)(He,{title:`Outgoing`,subtitle:`What this depends on`,items:It,graph:X,selectedId:Z.id,expanded:P,onToggle:e=>F(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),onSelect:St})]}):(0,O.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[q.length>0&&(0,O.jsxs)(`section`,{className:`border-b`,children:[(0,O.jsxs)(`div`,{className:`flex h-9 items-center gap-2 border-b bg-success/5 px-3`,children:[(0,O.jsx)(m,{className:`h-3 w-3 animate-pulse text-success`}),(0,O.jsx)(`h3`,{className:`text-[9px] font-bold uppercase tracking-[0.16em]`,children:`Active now`}),(0,O.jsx)(`span`,{className:`ml-auto font-mono text-[9px] text-success`,children:q.length})]}),q.map(e=>(0,O.jsx)(z,{activity:e,onLocate:$,showAgent:!0},e.id??`${e.toolUseId}:${e.filePath}`))]}),(0,O.jsxs)(`section`,{children:[(0,O.jsxs)(`div`,{className:`flex h-9 items-center gap-2 border-b px-3`,children:[(0,O.jsx)(ce,{className:`h-3 w-3 text-muted-foreground`}),(0,O.jsx)(`h3`,{className:`text-[9px] font-bold uppercase tracking-[0.16em]`,children:`Event stream`}),(0,O.jsxs)(`span`,{className:`ml-auto font-mono text-[8px] text-muted-foreground`,children:[W.totalCount,` total`]})]}),ot.length>0?ot.map((e,t)=>(0,O.jsx)(z,{activity:e,onLocate:$,showAgent:!0},e.id??`${e.timestamp}:${t}`)):(0,O.jsxs)(`div`,{className:`flex flex-col items-center justify-center px-7 py-16 text-center`,children:[(0,O.jsx)(`span`,{className:`mb-4 flex h-12 w-12 items-center justify-center border bg-muted text-muted-foreground`,children:(0,O.jsx)(ie,{className:`h-5 w-5`})}),(0,O.jsx)(`h3`,{className:`text-xs font-semibold`,children:`Select a node or wait for an agent`}),(0,O.jsx)(`p`,{className:`mt-2 text-[10px] leading-relaxed text-muted-foreground`,children:`Relations appear on selection. Tool calls and external filesystem touches stream here live.`})]})]})]})]})]}),B&&(0,O.jsxs)(`div`,{className:`absolute right-0 top-0 z-50 flex h-full w-[390px] max-w-[90%] flex-col border-l bg-card shadow-2xl`,children:[(0,O.jsxs)(`div`,{className:`flex h-12 items-center justify-between border-b px-4`,children:[(0,O.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,O.jsx)(ce,{className:`h-4 w-4 shrink-0 text-warning`}),(0,O.jsx)(`span`,{className:`truncate font-mono text-[11px] font-semibold`,title:B,children:B})]}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>Ke(null),className:`flex h-7 w-7 items-center justify-center border text-muted-foreground hover:bg-muted`,"aria-label":`Close activity`,children:(0,O.jsx)(le,{className:`h-3.5 w-3.5`})})]}),(0,O.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-3`,children:Bt.length===0?(0,O.jsx)(`p`,{className:`py-12 text-center text-[10px] text-muted-foreground`,children:`No activity recorded for this file yet.`}):Bt.map((e,t)=>(0,O.jsxs)(`div`,{className:`mb-1 flex items-start gap-2 border p-2 text-[10px]`,children:[(0,O.jsx)(`span`,{className:x(`border px-1.5 py-0.5 font-mono text-[8px] font-bold uppercase`,e.type===`delete`?`border-destructive/40 text-destructive`:e.type===`read`?`border-info/40 text-info`:`border-warning/40 text-warning`),children:e.type}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(`div`,{className:`font-mono text-[9px] text-muted-foreground`,children:new Date(e.timestamp).toLocaleTimeString()}),e.toolName&&(0,O.jsxs)(`div`,{className:`mt-1`,children:[`via `,e.toolName]}),e.agent&&(0,O.jsx)(`div`,{className:`text-muted-foreground`,children:e.agent}),e.summary&&(0,O.jsx)(`div`,{className:`mt-1 text-muted-foreground`,children:e.summary}),e.change&&(0,O.jsxs)(`div`,{className:`mt-1 flex items-center gap-1 font-mono text-[8px]`,children:[(0,O.jsxs)(`span`,{className:`border border-success/40 bg-success/10 px-1 text-success`,children:[`+`,e.change.added]}),(0,O.jsxs)(`span`,{className:`border border-destructive/40 bg-destructive/10 px-1 text-destructive`,children:[`−`,e.change.removed]}),e.change.before&&(0,O.jsx)(`span`,{className:`ml-1 truncate text-destructive/80`,title:e.change.before,children:e.change.before}),e.change.after&&(0,O.jsxs)(`span`,{className:`truncate text-success/80`,title:e.change.after,children:[`→ `,e.change.after]})]}),(0,O.jsxs)(`div`,{className:`mt-1 flex gap-2 font-mono text-[8px] uppercase text-muted-foreground`,children:[(0,O.jsx)(`span`,{children:e.status??`observed`}),(0,O.jsx)(`span`,{children:e.source??`legacy`}),e.durationMs!==void 0&&(0,O.jsxs)(`span`,{children:[e.durationMs,`ms`]}),e.watcherConfirmed&&(0,O.jsx)(`span`,{className:`text-success`,children:`fs verified`})]})]})]},`${e.timestamp}-${t}`))}),(0,O.jsxs)(`div`,{className:`border-t px-4 py-2 font-mono text-[9px] text-muted-foreground`,children:[Bt.length,` events · newest first`]})]})]})}function Ke(){return(0,O.jsx)(_,{children:(0,O.jsx)(B,{})})}export{Ke as CodeMap};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{aa as t,ia as n,tt as r,ua as i}from"./vendor-BmsAdDhb.js";import"./i18n-c37VNlP9.js";import{a,i as o,n as s,o as c,r as l,t as u}from"./dialog-BjPQYovj.js";import{t as d}from"./button-GVbauxIJ.js";import{t as f}from"./input-BVi5hYQz.js";var p=e(i(),1),m=r(),h=n()((e,t)=>({request:null,open:n=>{t().request?.resolve(!1),e({request:n})},settle:n=>{t().request?.resolve(n),e({request:null})}}));function g(e){return new Promise(t=>{h.getState().open({...e,resolve:t})})}function _(){let{t:e}=t(),n=h(e=>e.request),r=h(e=>e.settle);return(0,p.useEffect)(()=>{if(!n)return;let e=e=>{e.key===`Enter`&&(e.preventDefault(),h.getState().settle(!0))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]),(0,m.jsx)(u,{open:n!==null,onOpenChange:e=>{e||r(!1)},children:(0,m.jsxs)(s,{className:`max-w-md`,children:[(0,m.jsxs)(a,{children:[(0,m.jsx)(c,{children:n?.title}),n?.message&&(0,m.jsx)(l,{children:n.message})]}),(0,m.jsxs)(o,{className:`gap-2`,children:[(0,m.jsx)(d,{variant:`outline`,size:`sm`,onClick:()=>r(!1),children:n?.cancelLabel??e(`common:action.cancel`)}),(0,m.jsx)(d,{variant:n?.danger?`destructive`:`default`,size:`sm`,autoFocus:!0,onClick:()=>r(!0),children:n?.confirmLabel??e(`common:action.confirm`)})]})]})})}var v=n()((e,t)=>({request:null,open:n=>{t().request?.resolve(null),e({request:n})},settle:n=>{t().request?.resolve(n),e({request:null})}}));function y(e){return new Promise(t=>{v.getState().open({...e,resolve:t})})}function b(){let{t:e}=t(),n=v(e=>e.request),r=v(e=>e.settle),[i,h]=(0,p.useState)(``);(0,p.useEffect)(()=>{h(n?.defaultValue??``)},[n]);let g=()=>{let e=i.trim();r(e.length>0?e:null)};return(0,m.jsx)(u,{open:n!==null,onOpenChange:e=>{e||r(null)},children:(0,m.jsxs)(s,{className:`max-w-md`,children:[(0,m.jsxs)(a,{children:[(0,m.jsx)(c,{children:n?.title}),n?.message&&(0,m.jsx)(l,{children:n.message})]}),(0,m.jsx)(f,{autoFocus:!0,value:i,placeholder:n?.placeholder,onChange:e=>h(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),g())}}),(0,m.jsxs)(o,{className:`gap-2`,children:[(0,m.jsx)(d,{variant:`outline`,size:`sm`,onClick:()=>r(null),children:n?.cancelLabel??e(`common:action.cancel`)}),(0,m.jsx)(d,{size:`sm`,disabled:i.trim().length===0,onClick:g,children:n?.confirmLabel??e(`common:action.ok`)})]})]})})}export{y as i,b as n,g as r,_ as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Qt as t,ai as n,hi as r,mi as i,oa as a,tt as o}from"./vendor-DffL_bim.js";import{k as s}from"./stores-CUp_ut8r.js";import{a as c,n as l,o as u,r as d,t as f}from"./dialog-CBgO-uqz.js";import{_ as p,c as m}from"./index-OmSX-BAb.js";var h=e(a(),1),g=o();function _(e){return e<1e3?`${e}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:e<36e5?`${(e/6e4).toFixed(1)}m`:`${(e/36e5).toFixed(1)}h`}function v(e){if(!e)return`—`;let t=new Date(e),n=Date.now(),r=t.getTime()-n,i=Math.abs(r);if(i<6e4)return r>=0?`<1m`:`<1m ago`;if(i<36e5){let e=Math.round(i/6e4);return r>=0?`${e}m`:`${e}m ago`}if(i<864e5){let e=Math.round(i/36e5);return r>=0?`${e}h`:`${e}h ago`}return t.toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function y({enabled:e,overdue:t}){return e?t?(0,g.jsxs)(m,{variant:`destructive`,className:`gap-1`,children:[(0,g.jsx)(n,{className:`h-3 w-3`}),`Overdue`]}):(0,g.jsxs)(m,{variant:`default`,className:`gap-1 bg-emerald-600 hover:bg-emerald-600`,children:[(0,g.jsx)(i,{className:`h-3 w-3`}),`Active`]}):(0,g.jsxs)(m,{variant:`secondary`,className:`gap-1`,children:[(0,g.jsx)(r,{className:`h-3 w-3`}),`Disabled`]})}function b({open:e,onClose:r}){let i=s(e=>e.snapshot),a=s(e=>e.lastFiredAt);s(e=>e.revision);let o=i?.jobs??[],m=i?.count??0,b=i?.maxConcurrent??0,x=o.filter(e=>e.overdue).length,S=o.filter(e=>e.enabled).length,C=o.reduce((e,t)=>e+t.runCount,0);return(0,g.jsx)(f,{open:e,onOpenChange:(0,h.useCallback)(e=>{e||r()},[r]),children:(0,g.jsxs)(l,{className:`max-w-3xl max-h-[80vh] flex flex-col`,children:[(0,g.jsxs)(c,{children:[(0,g.jsxs)(u,{className:`flex items-center gap-2`,children:[(0,g.jsx)(t,{className:`h-5 w-5`}),`Cron Jobs`]}),(0,g.jsx)(d,{children:`Scheduled recurring tasks managed by the cron plugin.`})]}),m>0&&(0,g.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 text-sm text-muted-foreground border-b border-border/70 pb-3`,children:[(0,g.jsxs)(`span`,{className:`font-medium text-foreground`,children:[m,` job`,m===1?``:`s`]}),(0,g.jsxs)(`span`,{className:`text-emerald-500`,children:[S,` enabled`]}),x>0&&(0,g.jsxs)(`span`,{className:`text-destructive`,children:[x,` overdue`]}),(0,g.jsxs)(`span`,{children:[C,` total runs`]}),(0,g.jsxs)(`span`,{className:`text-muted-foreground/60`,children:[`max `,b,` concurrent`]})]}),m===0&&(0,g.jsxs)(`div`,{className:`flex flex-col items-center gap-2 py-12 text-muted-foreground`,children:[(0,g.jsx)(n,{className:`h-8 w-8 opacity-40`}),(0,g.jsx)(`p`,{className:`text-sm`,children:`No cron jobs scheduled.`}),(0,g.jsxs)(`p`,{className:`text-xs`,children:[`Use `,(0,g.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5`,children:`cron_schedule`}),` to add one.`]})]}),m>0&&(0,g.jsx)(p,{className:`flex-1 -mx-6 px-6`,children:(0,g.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,g.jsx)(`thead`,{children:(0,g.jsxs)(`tr`,{className:`border-b border-border/50 text-left text-xs text-muted-foreground`,children:[(0,g.jsx)(`th`,{className:`pb-2 pr-3 font-medium`,children:`Status`}),(0,g.jsx)(`th`,{className:`pb-2 pr-3 font-medium`,children:`Name`}),(0,g.jsx)(`th`,{className:`pb-2 pr-3 font-medium`,children:`Interval`}),(0,g.jsx)(`th`,{className:`pb-2 pr-3 font-medium text-right`,children:`Runs`}),(0,g.jsx)(`th`,{className:`pb-2 pr-3 font-medium`,children:`Next Run`}),(0,g.jsx)(`th`,{className:`pb-2 pr-3 font-medium`,children:`Last Run`}),(0,g.jsx)(`th`,{className:`pb-2 font-medium`,children:`Action`})]})}),(0,g.jsx)(`tbody`,{children:o.map(e=>(0,g.jsxs)(`tr`,{className:`border-b border-border/30 last:border-0`,children:[(0,g.jsx)(`td`,{className:`py-2.5 pr-3`,children:(0,g.jsx)(y,{enabled:e.enabled,overdue:e.overdue})}),(0,g.jsx)(`td`,{className:`py-2.5 pr-3 font-mono text-xs font-medium max-w-[160px] truncate`,title:e.name,children:e.name}),(0,g.jsx)(`td`,{className:`py-2.5 pr-3 font-mono text-xs tabular-nums`,children:_(e.intervalMs)}),(0,g.jsxs)(`td`,{className:`py-2.5 pr-3 text-right font-mono text-xs tabular-nums`,children:[e.runCount,a[e.name]&&(0,g.jsx)(`span`,{className:`ml-1 text-emerald-500`,title:`Last fired at ${a[e.name]}`,children:`●`})]}),(0,g.jsx)(`td`,{className:`py-2.5 pr-3 font-mono text-xs tabular-nums`,children:v(e.nextRun)}),(0,g.jsx)(`td`,{className:`py-2.5 pr-3 font-mono text-xs tabular-nums`,children:v(e.lastRun)}),(0,g.jsx)(`td`,{className:`py-2.5 font-mono text-xs max-w-[200px] truncate text-muted-foreground`,title:e.action,children:e.action})]},e.name))})]})}),m>0&&(0,g.jsxs)(`p`,{className:`text-xs text-muted-foreground pt-3 border-t border-border/70`,children:[`Use `,(0,g.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5 text-[11px]`,children:`cron_schedule`}),` to add,`,(0,g.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5 text-[11px] ml-1`,children:`cron_cancel`}),` to remove.`]})]})})}export{b as CronJobsPanel};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Qt as t,_i as n,ci as r,tt as i,ua as a,vi as o}from"./vendor-BmsAdDhb.js";import{k as s}from"./stores-DVhvmaer.js";import{a as c,n as l,o as u,r as d,t as f}from"./dialog-BjPQYovj.js";import{l as p,v as m}from"./index-196U0qsu.js";var h=e(a(),1),g=i();function _(e){return e<1e3?`${e}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:e<36e5?`${(e/6e4).toFixed(1)}m`:`${(e/36e5).toFixed(1)}h`}function v(e){if(!e)return`—`;let t=new Date(e),n=Date.now(),r=t.getTime()-n,i=Math.abs(r);if(i<6e4)return r>=0?`<1m`:`<1m ago`;if(i<36e5){let e=Math.round(i/6e4);return r>=0?`${e}m`:`${e}m ago`}if(i<864e5){let e=Math.round(i/36e5);return r>=0?`${e}h`:`${e}h ago`}return t.toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function y({enabled:e,overdue:t}){return e?t?(0,g.jsxs)(p,{variant:`destructive`,className:`gap-1`,children:[(0,g.jsx)(r,{className:`h-3 w-3`}),`Overdue`]}):(0,g.jsxs)(p,{variant:`default`,className:`gap-1 bg-emerald-600 hover:bg-emerald-600`,children:[(0,g.jsx)(n,{className:`h-3 w-3`}),`Active`]}):(0,g.jsxs)(p,{variant:`secondary`,className:`gap-1`,children:[(0,g.jsx)(o,{className:`h-3 w-3`}),`Disabled`]})}function b({open:e,onClose:n}){let i=s(e=>e.snapshot),a=s(e=>e.lastFiredAt);s(e=>e.revision);let o=i?.jobs??[],p=i?.count??0,b=i?.maxConcurrent??0,x=o.filter(e=>e.overdue).length,S=o.filter(e=>e.enabled).length,C=o.reduce((e,t)=>e+t.runCount,0);return(0,g.jsx)(f,{open:e,onOpenChange:(0,h.useCallback)(e=>{e||n()},[n]),children:(0,g.jsxs)(l,{className:`max-w-3xl max-h-[80vh] flex flex-col`,children:[(0,g.jsxs)(c,{children:[(0,g.jsxs)(u,{className:`flex items-center gap-2`,children:[(0,g.jsx)(t,{className:`h-5 w-5`}),`Cron Jobs`]}),(0,g.jsx)(d,{children:`Scheduled recurring tasks managed by the cron plugin.`})]}),p>0&&(0,g.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 text-sm text-muted-foreground border-b border-border/70 pb-3`,children:[(0,g.jsxs)(`span`,{className:`font-medium text-foreground`,children:[p,` job`,p===1?``:`s`]}),(0,g.jsxs)(`span`,{className:`text-emerald-500`,children:[S,` enabled`]}),x>0&&(0,g.jsxs)(`span`,{className:`text-destructive`,children:[x,` overdue`]}),(0,g.jsxs)(`span`,{children:[C,` total runs`]}),(0,g.jsxs)(`span`,{className:`text-muted-foreground/60`,children:[`max `,b,` concurrent`]})]}),p===0&&(0,g.jsxs)(`div`,{className:`flex flex-col items-center gap-2 py-12 text-muted-foreground`,children:[(0,g.jsx)(r,{className:`h-8 w-8 opacity-40`}),(0,g.jsx)(`p`,{className:`text-sm`,children:`No cron jobs scheduled.`}),(0,g.jsxs)(`p`,{className:`text-xs`,children:[`Use `,(0,g.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5`,children:`cron_schedule`}),` to add one.`]})]}),p>0&&(0,g.jsx)(m,{className:`flex-1 -mx-6 px-6`,children:(0,g.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,g.jsx)(`thead`,{children:(0,g.jsxs)(`tr`,{className:`border-b border-border/50 text-left text-xs text-muted-foreground`,children:[(0,g.jsx)(`th`,{className:`pb-2 pr-3 font-medium`,children:`Status`}),(0,g.jsx)(`th`,{className:`pb-2 pr-3 font-medium`,children:`Name`}),(0,g.jsx)(`th`,{className:`pb-2 pr-3 font-medium`,children:`Interval`}),(0,g.jsx)(`th`,{className:`pb-2 pr-3 font-medium text-right`,children:`Runs`}),(0,g.jsx)(`th`,{className:`pb-2 pr-3 font-medium`,children:`Next Run`}),(0,g.jsx)(`th`,{className:`pb-2 pr-3 font-medium`,children:`Last Run`}),(0,g.jsx)(`th`,{className:`pb-2 font-medium`,children:`Action`})]})}),(0,g.jsx)(`tbody`,{children:o.map(e=>(0,g.jsxs)(`tr`,{className:`border-b border-border/30 last:border-0`,children:[(0,g.jsx)(`td`,{className:`py-2.5 pr-3`,children:(0,g.jsx)(y,{enabled:e.enabled,overdue:e.overdue})}),(0,g.jsx)(`td`,{className:`py-2.5 pr-3 font-mono text-xs font-medium max-w-[160px] truncate`,title:e.name,children:e.name}),(0,g.jsx)(`td`,{className:`py-2.5 pr-3 font-mono text-xs tabular-nums`,children:_(e.intervalMs)}),(0,g.jsxs)(`td`,{className:`py-2.5 pr-3 text-right font-mono text-xs tabular-nums`,children:[e.runCount,a[e.name]&&(0,g.jsx)(`span`,{className:`ml-1 text-emerald-500`,title:`Last fired at ${a[e.name]}`,children:`●`})]}),(0,g.jsx)(`td`,{className:`py-2.5 pr-3 font-mono text-xs tabular-nums`,children:v(e.nextRun)}),(0,g.jsx)(`td`,{className:`py-2.5 pr-3 font-mono text-xs tabular-nums`,children:v(e.lastRun)}),(0,g.jsx)(`td`,{className:`py-2.5 font-mono text-xs max-w-[200px] truncate text-muted-foreground`,title:e.action,children:e.action})]},e.name))})]})}),p>0&&(0,g.jsxs)(`p`,{className:`text-xs text-muted-foreground pt-3 border-t border-border/70`,children:[`Use `,(0,g.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5 text-[11px]`,children:`cron_schedule`}),` to add,`,(0,g.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5 text-[11px] ml-1`,children:`cron_cancel`}),` to remove.`]})]})})}export{b as CronJobsPanel};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Di as t,Gt as n,Pr as r,Qi as i,Vr as a,ai as o,hr as s,ia as c,oa as l,rn as u,ta as d,tt as f,vi as p,xt as m}from"./vendor-DffL_bim.js";import"./i18n-Dk35g-uV.js";import{v as h}from"./index-OmSX-BAb.js";var g=e(l(),1),_=f();function v({title:e,value:t,subtitle:n,icon:r,color:i=`text-primary`,trend:a}){let{t:o}=d();return(0,_.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,_.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,_.jsxs)(`div`,{className:`min-w-0`,children:[(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground font-medium`,children:e}),(0,_.jsx)(`p`,{className:`mt-1 truncate text-xl font-semibold tabular-nums sm:text-2xl ${i}`,children:t}),n&&(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:n})]}),(0,_.jsx)(`div`,{className:`shrink-0 rounded-lg bg-muted/70 p-2 ${i}`,children:(0,_.jsx)(r,{className:`w-5 h-5`})})]}),a&&(0,_.jsxs)(`div`,{className:`mt-2 flex items-center gap-1`,children:[a===`up`&&(0,_.jsx)(m,{className:`w-3 h-3 text-success`}),a===`down`&&(0,_.jsx)(m,{className:`w-3 h-3 rotate-180 text-destructive`}),(0,_.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:o(a===`up`?`activity:debug.trendUp`:a===`down`?`activity:debug.trendDown`:`activity:debug.trendStable`)})]})]})}function y(){let{t:e}=d(),[l,f]=(0,g.useState)({fileWatcher:null,system:null,lastUpdated:null,error:null}),[y,S]=(0,g.useState)(!0),[C,w]=(0,g.useState)(2e3),T=(0,g.useCallback)(async()=>{try{let[e,t]=await Promise.all([fetch(`/debug/watcher-metrics`),fetch(`/debug/system`,{cache:`no-store`})]),n=null,r=e.headers.get(`content-type`)??``;if(e.ok&&r.includes(`application/json`)&&(n=await e.json()),!t.ok)throw Error(`System metrics request failed (${t.status})`);let i=await t.json();f({fileWatcher:n,system:i,lastUpdated:new Date,error:null})}catch(e){f(t=>({...t,error:e instanceof Error?e.message:c.t(`activity:debug.fetchFailed`)}))}finally{S(!1)}},[]);return(0,g.useEffect)(()=>{T();let e=setInterval(T,C);return()=>clearInterval(e)},[T,C]),(0,_.jsx)(`div`,{ref:h(`debug`),className:`h-full min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain bg-[hsl(var(--surface-2)/0.45)] p-4 sm:p-6`,children:(0,_.jsxs)(`div`,{className:`mx-auto flex max-w-7xl flex-col gap-5`,children:[(0,_.jsx)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:(0,_.jsxs)(`div`,{className:`flex flex-col gap-4 lg:flex-row lg:items-center lg:justify-between`,children:[(0,_.jsxs)(`div`,{className:`min-w-0`,children:[(0,_.jsxs)(`h1`,{className:`flex items-center gap-2 text-lg font-semibold sm:text-xl`,children:[(0,_.jsx)(t,{className:`h-5 w-5 text-primary`}),e(`activity:debug.heading`)]}),(0,_.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:e(`activity:debug.subtitle`)})]}),(0,_.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center`,children:[(0,_.jsxs)(`label`,{className:`flex min-w-0 items-center gap-2 text-sm`,children:[(0,_.jsx)(u,{className:`w-4 h-4 text-muted-foreground`}),(0,_.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:e(`activity:debug.refreshLabel`)}),(0,_.jsxs)(`select`,{value:C,onChange:e=>w(Number(e.target.value)),className:`h-9 rounded-md border border-border/70 bg-background/70 px-2 text-sm`,children:[(0,_.jsx)(`option`,{value:1e3,children:`1s`}),(0,_.jsx)(`option`,{value:2e3,children:`2s`}),(0,_.jsx)(`option`,{value:5e3,children:`5s`}),(0,_.jsx)(`option`,{value:1e4,children:`10s`})]})]}),(0,_.jsxs)(`button`,{type:`button`,onClick:()=>{S(!0),T()},disabled:y,className:`inline-flex h-9 items-center justify-center gap-2 rounded-md bg-primary px-3 text-sm font-medium text-primary-foreground shadow-sm shadow-primary/15 hover:bg-primary/90 disabled:opacity-50`,children:[(0,_.jsx)(u,{className:`w-4 h-4 ${y?`animate-spin`:``}`}),e(`common:action.refresh`)]})]})]})}),l.lastUpdated&&(0,_.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-border/60 bg-card/55 px-3 py-2 text-sm text-muted-foreground`,children:[(0,_.jsx)(o,{className:`w-4 h-4`}),e(`activity:debug.lastUpdated`,{time:l.lastUpdated.toLocaleTimeString()})]}),l.error&&(0,_.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl border border-destructive/25 bg-destructive/10 p-4 text-destructive`,children:[(0,_.jsx)(p,{className:`w-5 h-5 flex-shrink-0`}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`p`,{className:`font-medium`,children:e(`activity:debug.fetchFailed`)}),(0,_.jsx)(`p`,{className:`text-sm opacity-80`,children:l.error})]})]}),(0,_.jsxs)(`section`,{children:[(0,_.jsxs)(`h2`,{className:`mb-3 flex items-center gap-2 text-sm font-semibold text-muted-foreground`,children:[(0,_.jsx)(a,{className:`h-4 w-4 text-primary`}),e(`activity:debug.fileWatcher`)]}),(0,_.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4`,children:[(0,_.jsx)(v,{title:e(`activity:debug.watcherStatus`),value:l.fileWatcher?.watcherActive?e(`activity:debug.running`):e(`activity:debug.stopped`),icon:n,color:l.fileWatcher?.watcherActive?`text-success`:`text-destructive`}),(0,_.jsx)(v,{title:e(`activity:debug.activeProjects`),value:l.fileWatcher?.activeProjects??0,subtitle:e(`activity:debug.projectsWatched`),icon:r,color:`text-primary`}),(0,_.jsx)(v,{title:e(`activity:debug.fileChanges`),value:l.fileWatcher?.fileChangesDetected??0,subtitle:e(`activity:debug.totalDetected`),icon:i,color:`text-primary`,trend:`neutral`}),(0,_.jsx)(v,{title:e(`activity:debug.filesProcessed`),value:l.fileWatcher?.filesProcessed??0,subtitle:e(`activity:debug.afterHash`),icon:s,color:`text-success`})]}),(0,_.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4 mt-4`,children:[(0,_.jsx)(v,{title:e(`activity:debug.broadcastsSent`),value:l.fileWatcher?.broadcastsSent??0,subtitle:e(`activity:debug.toClients`),icon:m,color:`text-success`}),(0,_.jsx)(v,{title:e(`activity:debug.debounceResets`),value:l.fileWatcher?.debounceResets??0,subtitle:e(`activity:debug.rapidWrites`),icon:u,color:`text-warning`}),(0,_.jsx)(v,{title:e(`activity:debug.avgDebounce`),value:`${(l.fileWatcher?.averageDebounceDelayMs??0).toFixed(1)}ms`,subtitle:e(`activity:debug.actualDelay`),icon:o,color:`text-warning`}),(0,_.jsx)(v,{title:e(`activity:debug.totalDelay`),value:`${(l.fileWatcher?.totalDebounceDelayMs??0).toFixed(0)}ms`,subtitle:e(`activity:debug.sumDelays`),icon:t,color:`text-primary`})]})]}),(0,_.jsxs)(`section`,{children:[(0,_.jsxs)(`h2`,{className:`mb-3 flex items-center gap-2 text-sm font-semibold text-muted-foreground`,children:[(0,_.jsx)(s,{className:`h-4 w-4 text-primary`}),`WebUI Server Process`]}),(0,_.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4`,children:[(0,_.jsx)(v,{title:`Process RAM (RSS)`,value:b(l.system?.memoryUsage?.rss??0),subtitle:l.system?`PID ${l.system.pid}`:void 0,icon:n,color:`text-primary`}),(0,_.jsx)(v,{title:e(`activity:debug.heapUsed`),value:b(l.system?.memoryUsage?.heapUsed??0),subtitle:e(`activity:debug.jsHeap`),icon:t,color:`text-primary`}),(0,_.jsx)(v,{title:e(`activity:debug.heapTotal`),value:b(l.system?.memoryUsage?.heapTotal??0),subtitle:e(`activity:debug.totalHeap`),icon:t,color:`text-success`}),(0,_.jsx)(v,{title:`V8 Heap Limit`,value:b(l.system?.heapLimit??0),subtitle:`Configured old-space ceiling`,icon:s,color:`text-warning`}),(0,_.jsx)(v,{title:`Server Uptime`,value:x(l.system?.uptime??0),subtitle:`Since process start`,icon:o,color:`text-primary`})]})]}),(0,_.jsxs)(`section`,{children:[(0,_.jsxs)(`h2`,{className:`mb-3 flex items-center gap-2 text-sm font-semibold text-muted-foreground`,children:[(0,_.jsx)(i,{className:`h-4 w-4 text-primary`}),e(`activity:debug.rawData`)]}),(0,_.jsx)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:(0,_.jsx)(`pre`,{className:`overflow-x-auto text-xs font-mono text-muted-foreground`,children:JSON.stringify({fileWatcher:l.fileWatcher,serverPid:l.system?.pid,serverMemory:l.system?.memoryUsage,serverHeapLimit:l.system?.heapLimit,serverUptime:l.system?.uptime},null,2)})})]})]})})}function b(e){if(e===0)return`0 B`;let t=1024,n=[`B`,`KB`,`MB`,`GB`],r=Math.floor(Math.log(e)/Math.log(t));return`${(e/t**r).toFixed(1)} ${n[r]}`}function x(e){return e<60?`${e.toFixed(0)}s`:e<3600?`${(e/60).toFixed(1)}m`:`${(e/3600).toFixed(1)}h`}export{y as DebugDashboard};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Ai as t,Gt as n,Ir as r,Ur as i,_r as a,aa as o,ca as s,ci as c,na as l,rn as u,tt as d,ua as f,xi as p,xt as m}from"./vendor-BmsAdDhb.js";import"./i18n-c37VNlP9.js";import{y as h}from"./index-196U0qsu.js";var g=e(f(),1),_=d();function v({title:e,value:t,subtitle:n,icon:r,color:i=`text-primary`,trend:a}){let{t:s}=o();return(0,_.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,_.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,_.jsxs)(`div`,{className:`min-w-0`,children:[(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground font-medium`,children:e}),(0,_.jsx)(`p`,{className:`mt-1 truncate text-xl font-semibold tabular-nums sm:text-2xl ${i}`,children:t}),n&&(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:n})]}),(0,_.jsx)(`div`,{className:`shrink-0 rounded-lg bg-muted/70 p-2 ${i}`,children:(0,_.jsx)(r,{className:`w-5 h-5`})})]}),a&&(0,_.jsxs)(`div`,{className:`mt-2 flex items-center gap-1`,children:[a===`up`&&(0,_.jsx)(m,{className:`w-3 h-3 text-success`}),a===`down`&&(0,_.jsx)(m,{className:`w-3 h-3 rotate-180 text-destructive`}),(0,_.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:s(a===`up`?`activity:debug.trendUp`:a===`down`?`activity:debug.trendDown`:`activity:debug.trendStable`)})]})]})}function y(){let{t:e}=o(),[d,f]=(0,g.useState)({fileWatcher:null,system:null,lastUpdated:null,error:null}),[y,S]=(0,g.useState)(!0),[C,w]=(0,g.useState)(2e3),T=(0,g.useCallback)(async()=>{try{let[e,t]=await Promise.all([fetch(`/debug/watcher-metrics`),fetch(`/debug/system`,{cache:`no-store`})]),n=null,r=e.headers.get(`content-type`)??``;if(e.ok&&r.includes(`application/json`)&&(n=await e.json()),!t.ok)throw Error(`System metrics request failed (${t.status})`);let i=await t.json();f({fileWatcher:n,system:i,lastUpdated:new Date,error:null})}catch(e){f(t=>({...t,error:e instanceof Error?e.message:s.t(`activity:debug.fetchFailed`)}))}finally{S(!1)}},[]);return(0,g.useEffect)(()=>{T();let e=setInterval(T,C);return()=>clearInterval(e)},[T,C]),(0,_.jsx)(`div`,{ref:h(`debug`),className:`h-full min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain bg-[hsl(var(--surface-2)/0.45)] p-4 sm:p-6`,children:(0,_.jsxs)(`div`,{className:`mx-auto flex max-w-7xl flex-col gap-5`,children:[(0,_.jsx)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:(0,_.jsxs)(`div`,{className:`flex flex-col gap-4 lg:flex-row lg:items-center lg:justify-between`,children:[(0,_.jsxs)(`div`,{className:`min-w-0`,children:[(0,_.jsxs)(`h1`,{className:`flex items-center gap-2 text-lg font-semibold sm:text-xl`,children:[(0,_.jsx)(t,{className:`h-5 w-5 text-primary`}),e(`activity:debug.heading`)]}),(0,_.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:e(`activity:debug.subtitle`)})]}),(0,_.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center`,children:[(0,_.jsxs)(`label`,{className:`flex min-w-0 items-center gap-2 text-sm`,children:[(0,_.jsx)(u,{className:`w-4 h-4 text-muted-foreground`}),(0,_.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:e(`activity:debug.refreshLabel`)}),(0,_.jsxs)(`select`,{value:C,onChange:e=>w(Number(e.target.value)),className:`h-9 rounded-md border border-border/70 bg-background/70 px-2 text-sm`,children:[(0,_.jsx)(`option`,{value:1e3,children:`1s`}),(0,_.jsx)(`option`,{value:2e3,children:`2s`}),(0,_.jsx)(`option`,{value:5e3,children:`5s`}),(0,_.jsx)(`option`,{value:1e4,children:`10s`})]})]}),(0,_.jsxs)(`button`,{type:`button`,onClick:()=>{S(!0),T()},disabled:y,className:`inline-flex h-9 items-center justify-center gap-2 rounded-md bg-primary px-3 text-sm font-medium text-primary-foreground shadow-sm shadow-primary/15 hover:bg-primary/90 disabled:opacity-50`,children:[(0,_.jsx)(u,{className:`w-4 h-4 ${y?`animate-spin`:``}`}),e(`common:action.refresh`)]})]})]})}),d.lastUpdated&&(0,_.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-border/60 bg-card/55 px-3 py-2 text-sm text-muted-foreground`,children:[(0,_.jsx)(c,{className:`w-4 h-4`}),e(`activity:debug.lastUpdated`,{time:d.lastUpdated.toLocaleTimeString()})]}),d.error&&(0,_.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl border border-destructive/25 bg-destructive/10 p-4 text-destructive`,children:[(0,_.jsx)(p,{className:`w-5 h-5 flex-shrink-0`}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`p`,{className:`font-medium`,children:e(`activity:debug.fetchFailed`)}),(0,_.jsx)(`p`,{className:`text-sm opacity-80`,children:d.error})]})]}),(0,_.jsxs)(`section`,{children:[(0,_.jsxs)(`h2`,{className:`mb-3 flex items-center gap-2 text-sm font-semibold text-muted-foreground`,children:[(0,_.jsx)(i,{className:`h-4 w-4 text-primary`}),e(`activity:debug.fileWatcher`)]}),(0,_.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4`,children:[(0,_.jsx)(v,{title:e(`activity:debug.watcherStatus`),value:d.fileWatcher?.watcherActive?e(`activity:debug.running`):e(`activity:debug.stopped`),icon:n,color:d.fileWatcher?.watcherActive?`text-success`:`text-destructive`}),(0,_.jsx)(v,{title:e(`activity:debug.activeProjects`),value:d.fileWatcher?.activeProjects??0,subtitle:e(`activity:debug.projectsWatched`),icon:r,color:`text-primary`}),(0,_.jsx)(v,{title:e(`activity:debug.fileChanges`),value:d.fileWatcher?.fileChangesDetected??0,subtitle:e(`activity:debug.totalDetected`),icon:l,color:`text-primary`,trend:`neutral`}),(0,_.jsx)(v,{title:e(`activity:debug.filesProcessed`),value:d.fileWatcher?.filesProcessed??0,subtitle:e(`activity:debug.afterHash`),icon:a,color:`text-success`})]}),(0,_.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4 mt-4`,children:[(0,_.jsx)(v,{title:e(`activity:debug.broadcastsSent`),value:d.fileWatcher?.broadcastsSent??0,subtitle:e(`activity:debug.toClients`),icon:m,color:`text-success`}),(0,_.jsx)(v,{title:e(`activity:debug.debounceResets`),value:d.fileWatcher?.debounceResets??0,subtitle:e(`activity:debug.rapidWrites`),icon:u,color:`text-warning`}),(0,_.jsx)(v,{title:e(`activity:debug.avgDebounce`),value:`${(d.fileWatcher?.averageDebounceDelayMs??0).toFixed(1)}ms`,subtitle:e(`activity:debug.actualDelay`),icon:c,color:`text-warning`}),(0,_.jsx)(v,{title:e(`activity:debug.totalDelay`),value:`${(d.fileWatcher?.totalDebounceDelayMs??0).toFixed(0)}ms`,subtitle:e(`activity:debug.sumDelays`),icon:t,color:`text-primary`})]})]}),(0,_.jsxs)(`section`,{children:[(0,_.jsxs)(`h2`,{className:`mb-3 flex items-center gap-2 text-sm font-semibold text-muted-foreground`,children:[(0,_.jsx)(a,{className:`h-4 w-4 text-primary`}),`WebUI Server Process`]}),(0,_.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4`,children:[(0,_.jsx)(v,{title:`Process RAM (RSS)`,value:b(d.system?.memoryUsage?.rss??0),subtitle:d.system?`PID ${d.system.pid}`:void 0,icon:n,color:`text-primary`}),(0,_.jsx)(v,{title:e(`activity:debug.heapUsed`),value:b(d.system?.memoryUsage?.heapUsed??0),subtitle:e(`activity:debug.jsHeap`),icon:t,color:`text-primary`}),(0,_.jsx)(v,{title:e(`activity:debug.heapTotal`),value:b(d.system?.memoryUsage?.heapTotal??0),subtitle:e(`activity:debug.totalHeap`),icon:t,color:`text-success`}),(0,_.jsx)(v,{title:`V8 Heap Limit`,value:b(d.system?.heapLimit??0),subtitle:`Configured old-space ceiling`,icon:a,color:`text-warning`}),(0,_.jsx)(v,{title:`Server Uptime`,value:x(d.system?.uptime??0),subtitle:`Since process start`,icon:c,color:`text-primary`})]})]}),(0,_.jsxs)(`section`,{children:[(0,_.jsxs)(`h2`,{className:`mb-3 flex items-center gap-2 text-sm font-semibold text-muted-foreground`,children:[(0,_.jsx)(l,{className:`h-4 w-4 text-primary`}),e(`activity:debug.rawData`)]}),(0,_.jsx)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:(0,_.jsx)(`pre`,{className:`overflow-x-auto text-xs font-mono text-muted-foreground`,children:JSON.stringify({fileWatcher:d.fileWatcher,serverPid:d.system?.pid,serverMemory:d.system?.memoryUsage,serverHeapLimit:d.system?.heapLimit,serverUptime:d.system?.uptime},null,2)})})]})]})})}function b(e){if(e===0)return`0 B`;let t=1024,n=[`B`,`KB`,`MB`,`GB`],r=Math.floor(Math.log(e)/Math.log(t));return`${(e/t**r).toFixed(1)} ${n[r]}`}function x(e){return e<60?`${e.toFixed(0)}s`:e<3600?`${(e/60).toFixed(1)}m`:`${(e/3600).toFixed(1)}h`}export{y as DebugDashboard};