@wrongstack/webui 0.295.0 → 0.295.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. package/dist/App.d.ts.map +1 -1
  2. package/dist/assets/AgentRosterView-C7u9H5Jp.js +11 -0
  3. package/dist/assets/{AnalyticsDashboard-tGlXeqV5.js → AnalyticsDashboard-CZ8KAg7h.js} +1 -1
  4. package/dist/assets/{AudienceMemoryPanel-D45M-Fr6.js → AudienceMemoryPanel-N6ErXDAb.js} +2 -2
  5. package/dist/assets/{ChangesView-Otr6kwYr.js → ChangesView-fVxtWQ07.js} +1 -1
  6. package/dist/assets/ChronicleDashboard-C-NQsArq.js +1 -0
  7. package/dist/assets/CodeEditor-B9k1HwTM.js +1 -0
  8. package/dist/assets/CodeMap-CZ7wFa8f.js +1 -0
  9. package/dist/assets/{ConfirmModal-C7H16wDN.js → ConfirmModal-BvW6_eIc.js} +1 -1
  10. package/dist/assets/{CronJobsPanel-CT6XRgmQ.js → CronJobsPanel-C4zvyecc.js} +1 -1
  11. package/dist/assets/{DebugDashboard-DZy3VUpn.js → DebugDashboard-Z7ZFkSFX.js} +1 -1
  12. package/dist/assets/{DesignGalleryView-CQkuFsfj.js → DesignGalleryView-DIsg05FX.js} +1 -1
  13. package/dist/assets/{GoalView-CTqdYc-z.js → GoalView-pBKJcLBt.js} +1 -1
  14. package/dist/assets/KanbanView-qzKvGeMx.js +3 -0
  15. package/dist/assets/{LazyMarkdown-DWlQpo_8.js → LazyMarkdown-Cpjlf6IL.js} +3 -3
  16. package/dist/assets/MailboxDetailView-BKxA4wf_.js +1 -0
  17. package/dist/assets/MemoryManager-DO_Z8Scl.js +1 -0
  18. package/dist/assets/{ModelPicker-fGNsJUXK.js → ModelPicker-DOXb0iz4.js} +1 -1
  19. package/dist/assets/OfficeMapPanel-BVDeIWuD.js +4 -0
  20. package/dist/assets/{ProcessMonitor-BtgVvQgx.js → ProcessMonitor-Ci000o1n.js} +1 -1
  21. package/dist/assets/{QueuePanel-BGSxmdqf.js → QueuePanel-63vvbJOy.js} +1 -1
  22. package/dist/assets/{RefreshDebugView-B_wCBpFb.js → RefreshDebugView-8Sivo34V.js} +1 -1
  23. package/dist/assets/SddHub-DW97GpcS.js +2 -0
  24. package/dist/assets/{SessionsDashboard-DLOhC9JZ.js → SessionsDashboard-DhNaepDJ.js} +1 -1
  25. package/dist/assets/SetupScreen-BewutFxF.js +1 -0
  26. package/dist/assets/SkillDetailView-d39kknmg.js +3 -0
  27. package/dist/assets/{SpecsView-Dh9YG8Id.js → SpecsView-BOp0sUME.js} +1 -1
  28. package/dist/assets/TechStackView-DfFfTJVR.js +1 -0
  29. package/dist/assets/{TerminalPanel-3rZfmUfb.js → TerminalPanel-663hC2Jc.js} +1 -1
  30. package/dist/assets/Toaster-YMBi0Ssd.js +1 -0
  31. package/dist/assets/activity-3HtRx2SK.js +5 -0
  32. package/dist/assets/activity-BGlYr63p.js +5 -0
  33. package/dist/assets/activity-BolwRvqr.js +5 -0
  34. package/dist/assets/activity-C8BMSvRx.js +5 -0
  35. package/dist/assets/activity-CM8z-okz.js +5 -0
  36. package/dist/assets/activity-HfL12UVp.js +5 -0
  37. package/dist/assets/activity-Xd77MZv_.js +5 -0
  38. package/dist/assets/{button-GVbauxIJ.js → button-5TIs9T5p.js} +1 -1
  39. package/dist/assets/{chat-store-BEcTB7SD.js → chat-store-fBghgjNK.js} +2 -2
  40. package/dist/assets/{codemap-activity-store-DrrI6G7M.js → codemap-activity-store-C5DyqUoZ.js} +1 -1
  41. package/dist/assets/codemap-index-store-p2tz1Laz.js +1 -0
  42. package/dist/assets/{dialog-BjPQYovj.js → dialog-BkCs93Vo.js} +1 -1
  43. package/dist/assets/{empty-state-DJc37Wg1.js → empty-state-DrJ4uVh8.js} +1 -1
  44. package/dist/assets/{i18n-c37VNlP9.js → i18n-Cjk0Ya0G.js} +2 -2
  45. package/dist/assets/index-D0zt9ziw.css +1 -0
  46. package/dist/assets/index-HYvJnpTs.js +126 -0
  47. package/dist/assets/{input-BVi5hYQz.js → input-dEFwkTqb.js} +1 -1
  48. package/dist/assets/{mailbox-store-DSvN5ZEo.js → mailbox-store-DC7x_eml.js} +1 -1
  49. package/dist/assets/progress-ring-CGN0o9DE.js +1 -0
  50. package/dist/assets/{roster-ws-BD-ATeja.js → roster-ws-GsDcHg-w.js} +1 -1
  51. package/dist/assets/{session-store-K_ozfq0o.js → session-store-DGtTSpPv.js} +1 -1
  52. package/dist/assets/{shared-BQ9yQXDx.js → shared-C_yjayIp.js} +1 -1
  53. package/dist/assets/stores-BSWgxKNz.js +6 -0
  54. package/dist/assets/{ui-store-DxFtiYFb.js → ui-store-DPNSalc-.js} +1 -1
  55. package/dist/assets/useWebSocket-BBOEYTRy.js +28 -0
  56. package/dist/assets/{utils-DvgvNCoT.js → utils-YTsIExHc.js} +1 -1
  57. package/dist/assets/{vendor-BmsAdDhb.js → vendor-B8C0AAAG.js} +27 -27
  58. package/dist/assets/{view-navigation-D8lN47bJ.js → view-navigation-CV5XT76I.js} +1 -1
  59. package/dist/assets/ws-client-Cc6w_0zh.js +1 -0
  60. package/dist/components/AgentRosterView.d.ts.map +1 -1
  61. package/dist/components/ChatInput.d.ts.map +1 -1
  62. package/dist/components/ChronicleDashboard.d.ts.map +1 -1
  63. package/dist/components/CodeMap.d.ts +6 -0
  64. package/dist/components/CodeMap.d.ts.map +1 -1
  65. package/dist/components/ContextDashboard.d.ts.map +1 -1
  66. package/dist/components/CronTrigger.d.ts +1 -1
  67. package/dist/components/CronTrigger.d.ts.map +1 -1
  68. package/dist/components/FileActivityDrawer.d.ts +14 -0
  69. package/dist/components/FileActivityDrawer.d.ts.map +1 -1
  70. package/dist/components/FleetMonitor.d.ts.map +1 -1
  71. package/dist/components/KanbanDecompositionPanel.d.ts +28 -0
  72. package/dist/components/KanbanDecompositionPanel.d.ts.map +1 -0
  73. package/dist/components/KanbanTaskTree.d.ts +13 -0
  74. package/dist/components/KanbanTaskTree.d.ts.map +1 -0
  75. package/dist/components/KanbanVerificationDashboard.d.ts +12 -0
  76. package/dist/components/KanbanVerificationDashboard.d.ts.map +1 -0
  77. package/dist/components/KanbanView.d.ts +17 -1
  78. package/dist/components/KanbanView.d.ts.map +1 -1
  79. package/dist/components/OfficeMapCanvas.d.ts.map +1 -1
  80. package/dist/components/QueuePanel.d.ts.map +1 -1
  81. package/dist/components/RefinePanel.d.ts +10 -3
  82. package/dist/components/RefinePanel.d.ts.map +1 -1
  83. package/dist/components/SddBoardView.d.ts.map +1 -1
  84. package/dist/components/SddTaskDrawer.d.ts.map +1 -1
  85. package/dist/components/SearchOverlay.d.ts.map +1 -1
  86. package/dist/components/SettingsPanel/BrainSection.d.ts.map +1 -1
  87. package/dist/components/SettingsPanel/ChimeraSettingsPanel.d.ts.map +1 -1
  88. package/dist/components/SettingsPanel/index.d.ts.map +1 -1
  89. package/dist/components/SidePanel/AgentsPanel.d.ts.map +1 -1
  90. package/dist/components/SidePanel/SessionPanel.d.ts.map +1 -1
  91. package/dist/components/TaskVerificationSection.d.ts +15 -0
  92. package/dist/components/TaskVerificationSection.d.ts.map +1 -0
  93. package/dist/components/TechStackView/DependencyDetail.d.ts +2 -1
  94. package/dist/components/TechStackView/DependencyDetail.d.ts.map +1 -1
  95. package/dist/components/TechStackView/DependencyTable.d.ts +2 -1
  96. package/dist/components/TechStackView/DependencyTable.d.ts.map +1 -1
  97. package/dist/components/TechStackView/index.d.ts.map +1 -1
  98. package/dist/components/TechStackView/shared.d.ts +37 -4
  99. package/dist/components/TechStackView/shared.d.ts.map +1 -1
  100. package/dist/components/activity-bar/index.d.ts.map +1 -1
  101. package/dist/components/agents/AgentDetailSection.d.ts.map +1 -1
  102. package/dist/components/agents/AgentRosterCard.d.ts.map +1 -1
  103. package/dist/components/agents/FleetSummaryBar.d.ts.map +1 -1
  104. package/dist/components/codemap-model.d.ts +9 -0
  105. package/dist/components/codemap-model.d.ts.map +1 -1
  106. package/dist/components/ui/progress-ring.d.ts +10 -0
  107. package/dist/components/ui/progress-ring.d.ts.map +1 -0
  108. package/dist/hooks/ws-handlers/session-handlers.d.ts.map +1 -1
  109. package/dist/hooks/ws-handlers.d.ts.map +1 -1
  110. package/dist/index.css +7 -7
  111. package/dist/index.css.map +1 -1
  112. package/dist/index.html +23 -22
  113. package/dist/index.js +6176 -4279
  114. package/dist/index.js.map +4 -4
  115. package/dist/lib/kanban-verification.d.ts +52 -0
  116. package/dist/lib/kanban-verification.d.ts.map +1 -0
  117. package/dist/stores/codemap-index-store.d.ts +9 -0
  118. package/dist/stores/codemap-index-store.d.ts.map +1 -0
  119. package/dist/stores/kanban-store.d.ts +4 -0
  120. package/dist/stores/kanban-store.d.ts.map +1 -1
  121. package/dist/stores/local-prefs.d.ts.map +1 -1
  122. package/dist/stores/specs-store.d.ts +4 -0
  123. package/dist/stores/specs-store.d.ts.map +1 -1
  124. package/dist/stores/ui-store.d.ts +3 -1
  125. package/dist/stores/ui-store.d.ts.map +1 -1
  126. package/dist/types.d.ts +120 -1
  127. package/dist/types.d.ts.map +1 -1
  128. package/package.json +7 -7
  129. package/dist/assets/AgentRosterView-y-MCHghy.js +0 -7
  130. package/dist/assets/ChronicleDashboard-BvsfI25e.js +0 -1
  131. package/dist/assets/CodeEditor-DtD0-wwy.js +0 -1
  132. package/dist/assets/CodeMap-CVmu16Ec.js +0 -1
  133. package/dist/assets/KanbanView-DryFcAzY.js +0 -3
  134. package/dist/assets/MailboxDetailView-CsI_6HsE.js +0 -1
  135. package/dist/assets/MemoryManager-D_bjR09v.js +0 -1
  136. package/dist/assets/OfficeMapPanel-KRrwpmvi.js +0 -4
  137. package/dist/assets/SddHub-BryXNdFd.js +0 -2
  138. package/dist/assets/SetupScreen-DsXgzxA1.js +0 -1
  139. package/dist/assets/SkillDetailView-ChyQLtrl.js +0 -3
  140. package/dist/assets/TechStackView-RJGVF44_.js +0 -1
  141. package/dist/assets/Toaster-BzC_AdG5.js +0 -1
  142. package/dist/assets/activity-7VmgGy-T.js +0 -5
  143. package/dist/assets/activity-BzwApar4.js +0 -5
  144. package/dist/assets/activity-CCUWlVKh.js +0 -5
  145. package/dist/assets/activity-DAHFiOfU.js +0 -5
  146. package/dist/assets/activity-DkkpH2Tf.js +0 -5
  147. package/dist/assets/activity-DqsX-GMs.js +0 -5
  148. package/dist/assets/activity-t0PmZ94i.js +0 -5
  149. package/dist/assets/index-196U0qsu.js +0 -125
  150. package/dist/assets/index-n_-BWskP.css +0 -1
  151. package/dist/assets/stores-DVhvmaer.js +0 -6
  152. package/dist/assets/useWebSocket-kb2VPjLc.js +0 -28
  153. package/dist/assets/ws-client-BydCS6yi.js +0 -1
@@ -1,7 +0,0 @@
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};
@@ -1 +0,0 @@
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};
@@ -1 +0,0 @@
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};
@@ -1 +0,0 @@
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};