@wrongstack/webui 0.299.0 → 0.301.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (180) hide show
  1. package/dist/assets/AgentRosterView-BV6ysoGs.js +9 -0
  2. package/dist/assets/{AnalyticsDashboard-D58kSekC.js → AnalyticsDashboard-UWNP8zjE.js} +1 -1
  3. package/dist/assets/AudienceMemoryPanel-DwDKbvSA.js +3 -0
  4. package/dist/assets/ChangesView-DuVlGWkD.js +1 -0
  5. package/dist/assets/ChronicleDashboard-cs16n708.js +1 -0
  6. package/dist/assets/CodeEditor-sr50ljZN.js +1 -0
  7. package/dist/assets/CodeMap-CtK-C8gK.js +1 -0
  8. package/dist/assets/ConfirmModal-ndS17YwF.js +1 -0
  9. package/dist/assets/CronJobsPanel-Dovomns5.js +1 -0
  10. package/dist/assets/DeadCodeScanPanel-DjR4LLMs.js +2 -0
  11. package/dist/assets/DebugDashboard-jK1yp3qS.js +1 -0
  12. package/dist/assets/DesignGalleryView-CqXlEUzE.js +1 -0
  13. package/dist/assets/GoalView-CGNLrnA4.js +1 -0
  14. package/dist/assets/KanbanView--tAf_K7N.js +3 -0
  15. package/dist/assets/{MailboxDetailView-ZcKcOEAe.js → MailboxDetailView-0TBzZTdN.js} +1 -1
  16. package/dist/assets/MemoryManager-CDK_MO8A.js +1 -0
  17. package/dist/assets/{ModelPicker-DvNLZzkm.js → ModelPicker-BbBZuQwR.js} +1 -1
  18. package/dist/assets/OfficeMapPanel-68sVzHRD.js +4 -0
  19. package/dist/assets/OfficeMapPanel-D6yTfGIT.css +1 -0
  20. package/dist/assets/{ProcessMonitor-2nSk6sXA.js → ProcessMonitor-gFwiF8gX.js} +1 -1
  21. package/dist/assets/{QueuePanel-4KBBWFxj.js → QueuePanel-Cx-isRGl.js} +1 -1
  22. package/dist/assets/{RefreshDebugView-D3XnE53y.js → RefreshDebugView-C9tdu6Ld.js} +1 -1
  23. package/dist/assets/RequirementIntakeView-cPEw-RpV.js +1 -0
  24. package/dist/assets/SageTabs-BbK6VFO0.js +2 -0
  25. package/dist/assets/SddHub-NKvDRECi.js +2 -0
  26. package/dist/assets/SessionInspectView-DPG5qWhj.js +1 -0
  27. package/dist/assets/SessionList-ncl-20X_.js +1 -0
  28. package/dist/assets/SessionsDashboard-D23UVLr4.js +1 -0
  29. package/dist/assets/SetupScreen-D3XQ8MGk.js +1 -0
  30. package/dist/assets/{SkillDetailView-D7EQ2XtV.js → SkillDetailView-DDPhVFet.js} +1 -1
  31. package/dist/assets/SpecsView-afIS0QpX.js +1 -0
  32. package/dist/assets/TechStackView-kQ2OGxxw.js +1 -0
  33. package/dist/assets/{TerminalPanel-BL9ZPGJt.js → TerminalPanel-GcJWeldW.js} +1 -1
  34. package/dist/assets/{Toaster-CJI70aa-.js → Toaster-CgQA9256.js} +1 -1
  35. package/dist/assets/activity-B-cvKIfT.js +9 -0
  36. package/dist/assets/activity-Ba3aMzvo.js +9 -0
  37. package/dist/assets/activity-CRTVZ5A4.js +9 -0
  38. package/dist/assets/activity-DsSuflRW.js +9 -0
  39. package/dist/assets/activity-DxDRJ8kN.js +9 -0
  40. package/dist/assets/activity-VI776bUZ.js +9 -0
  41. package/dist/assets/activity-nVmsmqAI.js +9 -0
  42. package/dist/assets/chat-BPuAsrkF.js +1 -0
  43. package/dist/assets/chat-BfQBSiII.js +1 -0
  44. package/dist/assets/chat-BnkVCZ3Q.js +1 -0
  45. package/dist/assets/chat-CR2B97dj.js +1 -0
  46. package/dist/assets/chat-CdiY7G6Z.js +1 -0
  47. package/dist/assets/chat-DResBrkV.js +1 -0
  48. package/dist/assets/chat-Di8o0wDz.js +1 -0
  49. package/dist/assets/chat-store-DbxFVDwi.js +17 -0
  50. package/dist/assets/{common-DMM-xyW3.js → common-BXJbu5Y-.js} +1 -1
  51. package/dist/assets/{common-C9ikgX7d.js → common-BiNu_WzQ.js} +1 -1
  52. package/dist/assets/common-COVxQ0FV.js +1 -0
  53. package/dist/assets/{common-D29Zdkxb.js → common-Ch7JihXD.js} +1 -1
  54. package/dist/assets/{common-DoUBSHRY.js → common-DPaTeTls.js} +1 -1
  55. package/dist/assets/{common-vdwxzODB.js → common-DdGpRh8j.js} +1 -1
  56. package/dist/assets/{common-C5hY-d_0.js → common-pI6fYZW3.js} +1 -1
  57. package/dist/assets/i18n-COgumVF5.js +2 -0
  58. package/dist/assets/index-CtpViiZy.js +132 -0
  59. package/dist/assets/index-fIsq43fR.css +1 -0
  60. package/dist/assets/mailbox-store-C1mzoSqJ.js +1 -0
  61. package/dist/assets/{progress-ring-61A-xUEl.js → progress-ring-D_48qsBl.js} +1 -1
  62. package/dist/assets/{roster-ws-Dfg_187V.js → roster-ws-Da57e_sI.js} +1 -1
  63. package/dist/assets/session-store-Df7_hhe9.js +1 -0
  64. package/dist/assets/settings-Bb7_utQE.js +1 -0
  65. package/dist/assets/settings-Bd8zMwvC.js +1 -0
  66. package/dist/assets/settings-DdFgBMAw.js +1 -0
  67. package/dist/assets/settings-De6sXIFO.js +1 -0
  68. package/dist/assets/settings-E8SKMLxq.js +1 -0
  69. package/dist/assets/settings-zIY9-ivF.js +1 -0
  70. package/dist/assets/settings-zKBcRjqE.js +1 -0
  71. package/dist/assets/stores-ChEnUmic.js +7 -0
  72. package/dist/assets/ui-store-CE4-TlwB.js +1 -0
  73. package/dist/assets/useWebSocket-_gk4MRJz.js +29 -0
  74. package/dist/assets/{view-navigation-DxfiZrXS.js → view-navigation-DIDEcp4V.js} +1 -1
  75. package/dist/assets/ws-client-TTMa0XaT.js +1 -0
  76. package/dist/components/AgentCard.d.ts +21 -0
  77. package/dist/components/AgentsPage.d.ts +0 -3
  78. package/dist/components/AutonomyPicker.d.ts +1 -1
  79. package/dist/components/ChatInput/refine-panel-host.d.ts +2 -2
  80. package/dist/components/ChatView/auto-collapse.d.ts +42 -0
  81. package/dist/components/ConfirmModal.d.ts +7 -2
  82. package/dist/components/FallbackModal.d.ts +2 -0
  83. package/dist/components/KanbanBoardState.d.ts +1 -1
  84. package/dist/components/KanbanVerificationDashboard.d.ts +0 -6
  85. package/dist/components/SettingsPanel/PluginToggleList.d.ts +11 -3
  86. package/dist/components/SettingsPanel/ShadowSection.d.ts +18 -1
  87. package/dist/components/SettingsPanel/brain-section-options.d.ts +27 -55
  88. package/dist/components/TaskCard.d.ts +0 -1
  89. package/dist/components/TaskRiskPanel.d.ts +10 -3
  90. package/dist/components/TechStackView/shared.d.ts +11 -6
  91. package/dist/components/ThemeProvider.d.ts +6 -1
  92. package/dist/components/agent-roster-data.d.ts +2 -1
  93. package/dist/components/index.d.ts +0 -1
  94. package/dist/hooks/useWebSocket.d.ts +10 -2
  95. package/dist/hooks/ws-handlers/files-mailbox-handlers.d.ts +1 -0
  96. package/dist/hooks/ws-handlers/misc-handlers.d.ts +13 -0
  97. package/dist/hooks/ws-handlers/session-handlers.d.ts +1 -0
  98. package/dist/index.css +62 -0
  99. package/dist/index.html +18 -17
  100. package/dist/index.js +26640 -12728
  101. package/dist/lib/file-icons.d.ts +3 -3
  102. package/dist/lib/kanban-board-active.d.ts +19 -0
  103. package/dist/lib/palettes.d.ts +37 -0
  104. package/dist/lib/plugin-enablement.d.ts +1 -1
  105. package/dist/lib/ws-client.d.ts +24 -4
  106. package/dist/providers.json +7 -7
  107. package/dist/stores/config-store.d.ts +9 -1
  108. package/dist/stores/context-editor-store.d.ts +9 -1
  109. package/dist/stores/fallback-store.d.ts +30 -0
  110. package/dist/stores/fleet-store.d.ts +14 -1
  111. package/dist/stores/index.d.ts +2 -0
  112. package/dist/stores/local-prefs.d.ts +13 -0
  113. package/dist/stores/mailbox-store.d.ts +2 -0
  114. package/dist/stores/session-store.d.ts +9 -1
  115. package/dist/stores/ui-store.d.ts +2 -0
  116. package/dist/types/brain.d.ts +2 -0
  117. package/dist/types/client-message.d.ts +19 -2
  118. package/dist/types/protocol-core.d.ts +21 -0
  119. package/dist/types/runtime.d.ts +22 -0
  120. package/dist/types/server-message.d.ts +15 -4
  121. package/package.json +9 -9
  122. package/dist/assets/AgentRosterView-BqojERFR.js +0 -11
  123. package/dist/assets/AudienceMemoryPanel-Cc1UkbDl.js +0 -3
  124. package/dist/assets/ChangesView-BKU80ANq.js +0 -1
  125. package/dist/assets/ChronicleDashboard-CvCS1Dj1.js +0 -1
  126. package/dist/assets/CodeEditor-BHZQhx_8.js +0 -1
  127. package/dist/assets/CodeMap-qllGEFLB.js +0 -1
  128. package/dist/assets/CronJobsPanel-DD5mhZ4Q.js +0 -1
  129. package/dist/assets/DeadCodeScanPanel-PB-c8et_.js +0 -2
  130. package/dist/assets/DebugDashboard-Q8QiVflQ.js +0 -1
  131. package/dist/assets/DesignGalleryView-CGOtWO7s.js +0 -1
  132. package/dist/assets/GoalView-Dlk42vW7.js +0 -1
  133. package/dist/assets/KanbanView-DIP6kKmU.js +0 -3
  134. package/dist/assets/MemoryManager-B7620q_K.js +0 -1
  135. package/dist/assets/OfficeMapPanel-BFIF-EMt.css +0 -1
  136. package/dist/assets/OfficeMapPanel-DKJNTtOZ.js +0 -4
  137. package/dist/assets/RequirementIntakeView-BMxlf8bt.js +0 -1
  138. package/dist/assets/SageTabs-g1hO2hJ0.js +0 -2
  139. package/dist/assets/SddHub-Kv_TbTgT.js +0 -2
  140. package/dist/assets/SessionInspectView-PnKTvyvP.js +0 -1
  141. package/dist/assets/SessionList-BeinIC-h.js +0 -1
  142. package/dist/assets/SessionsDashboard-DEG_BylE.js +0 -1
  143. package/dist/assets/SetupScreen-DxJwZ1OZ.js +0 -1
  144. package/dist/assets/SpecsView-Fm7pYYcj.js +0 -1
  145. package/dist/assets/TechStackView-Bo_UenRF.js +0 -1
  146. package/dist/assets/activity-BCgOEWgR.js +0 -5
  147. package/dist/assets/activity-BQ0zqkw2.js +0 -5
  148. package/dist/assets/activity-CAovbq3e.js +0 -5
  149. package/dist/assets/activity-CFQyCvgu.js +0 -5
  150. package/dist/assets/activity-CdQf7zRK.js +0 -5
  151. package/dist/assets/activity-DACvyn2-.js +0 -5
  152. package/dist/assets/activity-DOwYydU-.js +0 -5
  153. package/dist/assets/chat-CRmMDzCb.js +0 -1
  154. package/dist/assets/chat-CwnuX7tG.js +0 -1
  155. package/dist/assets/chat-DLn1hY01.js +0 -1
  156. package/dist/assets/chat-DSEq1Bdz.js +0 -1
  157. package/dist/assets/chat-DxLD17ER.js +0 -1
  158. package/dist/assets/chat-DzPxYALH.js +0 -1
  159. package/dist/assets/chat-OunddzYy.js +0 -1
  160. package/dist/assets/chat-store-CtOyUCdF.js +0 -17
  161. package/dist/assets/common-BfVFjVhf.js +0 -1
  162. package/dist/assets/i18n-B0hsnanh.js +0 -2
  163. package/dist/assets/index-DHdO0CRE.js +0 -132
  164. package/dist/assets/index-DKrFQ76m.css +0 -1
  165. package/dist/assets/mailbox-store-D8TvJsuk.js +0 -1
  166. package/dist/assets/session-store-b2KGFwkX.js +0 -1
  167. package/dist/assets/settings-B5xal2R3.js +0 -1
  168. package/dist/assets/settings-BHtFy8EG.js +0 -1
  169. package/dist/assets/settings-Bss5hBla.js +0 -1
  170. package/dist/assets/settings-BzrLCVRP.js +0 -1
  171. package/dist/assets/settings-C7RdvmLZ.js +0 -1
  172. package/dist/assets/settings-Dd94HoV6.js +0 -1
  173. package/dist/assets/settings-Dm9THFe8.js +0 -1
  174. package/dist/assets/stores-BptlyD_v.js +0 -7
  175. package/dist/assets/ui-store-BsBnjO3w.js +0 -1
  176. package/dist/assets/useWebSocket-Bc4S0N4r.js +0 -29
  177. package/dist/assets/ws-client-DqFoX4jJ.js +0 -1
  178. package/dist/components/AgentsMonitor.d.ts +0 -26
  179. package/dist/components/FleetMonitor.d.ts +0 -21
  180. package/dist/lib/accent-colors.d.ts +0 -136
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wrongstack/webui",
3
- "version": "0.299.0",
3
+ "version": "0.301.0",
4
4
  "license": "MIT",
5
5
  "description": "Browser-based WebUI for WrongStack — React + Vite frontend. The WebSocket backend lives in the separate @wrongstack/webui-server package (extracted in PR #018b to remove the CLI -> @wrongstack/webui/server cross-package edge).",
6
6
  "keywords": [
@@ -76,12 +76,12 @@
76
76
  "tailwind-merge": "^3.6.0",
77
77
  "virtua": "^0.49.3",
78
78
  "zustand": "^5.0.14",
79
- "@wrongstack/core": "0.299.0",
80
- "@wrongstack/providers": "0.299.0",
81
- "@wrongstack/plugins": "0.299.0",
82
- "@wrongstack/webui-server": "0.299.0",
83
- "@wrongstack/kanban": "0.299.0",
84
- "@wrongstack/tools": "0.299.0"
79
+ "@wrongstack/kanban": "0.301.0",
80
+ "@wrongstack/core": "0.301.0",
81
+ "@wrongstack/providers": "0.301.0",
82
+ "@wrongstack/tools": "0.301.0",
83
+ "@wrongstack/plugins": "0.301.0",
84
+ "@wrongstack/webui-server": "0.301.0"
85
85
  },
86
86
  "optionalDependencies": {
87
87
  "node-pty": "1.2.0-beta.14"
@@ -103,7 +103,7 @@
103
103
  "typescript": "^7.0.2",
104
104
  "vite": "^8.1.5",
105
105
  "vitest": "^4.1.10",
106
- "@wrongstack/sdd": "0.299.0"
106
+ "@wrongstack/sdd": "0.301.0"
107
107
  },
108
108
  "scripts": {
109
109
  "dev": "vite",
@@ -111,6 +111,6 @@
111
111
  "typecheck": "tsc --noEmit",
112
112
  "test": "vitest run",
113
113
  "test:watch": "vitest",
114
- "test:coverage": "vitest run --coverage"
114
+ "test:coverage": "node ../../scripts/run-vitest-coverage.mjs run --coverage"
115
115
  }
116
116
  }
@@ -1,11 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./chat-store-CtOyUCdF.js";import{Ai as n,Ii as r,Oa as i,Ot as a,Qi as o,Wi as s,Wt as c,Xr as l,Zt as u,an as d,da as f,dt as p,ft as m,hr as h,ir as g,jt as _,la as v,lt as y,pr as b,tn as x,ua as S,ut as C,vi as w,vn as T,yi as E,za as D}from"./vendor-BuarzSSb.js";import{n as O}from"./ui-store-BsBnjO3w.js";import{t as k}from"./ws-client-DqFoX4jJ.js";import{t as A}from"./utils-B-9lSDIn.js";import{C as j}from"./stores-BptlyD_v.js";import{n as M}from"./Toaster-CJI70aa-.js";import{n as N,t as P}from"./ModelPicker-DvNLZzkm.js";import{s as F}from"./index-DHdO0CRE.js";import{t as I}from"./roster-ws-Dfg_187V.js";var L=e(D(),1),R=y(),z=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],B=[[`timeoutMs`,`Total timeout (ms)`],[`idleTimeoutMs`,`Idle timeout (ms)`],[`maxIterations`,`Max iterations`],[`maxToolCalls`,`Max tool calls`],[`maxTokens`,`Max tokens`],[`maxCostUsd`,`Max cost (USD)`]];function V(e){return`${e.provider}/${e.model}`}function H(e){let t=e.indexOf(`/`);return t<0?{provider:``,model:e}:{provider:e.slice(0,t),model:e.slice(t+1)}}function U(e){return Array.isArray(e)?e.join(`, `):``}function W(e){return[...new Set(e.split(/[\n,]+/).map(e=>e.trim()).filter(Boolean))]}function G({initialConfig:e,systemProtected:t,saving:n,onSave:r,onCancel:i}){let[a,o]=(0,L.useState)(()=>structuredClone(e)),s=N(!0),c=a.modelPolicy,l=(0,L.useMemo)(()=>(c?.allowed??[]).map(V),[c?.allowed]),d=(0,L.useMemo)(()=>(c?.fallbacks??[]).map(V),[c?.fallbacks]),f=e=>o(t=>({...t,...e})),p=(e,t)=>{let n=W(t);o(t=>{let r={...t};return n.length?r[e]=n:delete r[e],r})},m=(e,t)=>{o(n=>{let r={...n.budget??{}};t===``?delete r[e]:r[e]=Number(t);let i={...n};return Object.keys(r).length?i.budget=r:delete i.budget,i})},h=e=>{let t=e.map(H),n=new Set(e);o(e=>({...e,modelPolicy:{allowed:t,fallbacks:(e.modelPolicy?.fallbacks??[]).filter(e=>n.has(V(e))),strict:e.modelPolicy?.strict??!0}}))};return(0,R.jsxs)(`div`,{className:`space-y-4 rounded-lg border border-border bg-card/40 p-4`,children:[t&&(0,R.jsxs)(`div`,{className:`flex gap-2 rounded-md border border-amber-500/30 bg-amber-500/5 p-2 text-[11px] text-muted-foreground`,children:[(0,R.jsx)(u,{className:`mt-0.5 h-4 w-4 shrink-0 text-amber-500`}),(0,R.jsx)(`span`,{children:`Protected system agent: required tools and capabilities are retained, minimum budgets are enforced, working hours remain advisory, and emergency model recovery stays enabled so core operations cannot be disabled.`})]}),(0,R.jsxs)(`section`,{className:`space-y-2`,children:[(0,R.jsx)(`h4`,{className:`text-xs font-semibold`,children:`Provider and model policy`}),(0,R.jsx)(P,{candidates:s,provider:a.provider,value:a.model,placeholder:`Use project default model`,resetLabel:`Use project default`,onReset:()=>{o(e=>{let t={...e};return delete t.provider,delete t.model,t})},onPick:(e,t)=>{let n=`${t}/${e}`;f({provider:t,model:e}),c&&!l.includes(n)&&h([...l,n])}}),(0,R.jsxs)(`label`,{className:`flex items-center gap-2 text-[11px]`,children:[(0,R.jsx)(`input`,{type:`checkbox`,checked:!!c,onChange:e=>{if(e.target.checked){let e=a.provider&&a.model?[{provider:a.provider,model:a.model}]:s[0]?[{provider:s[0].provider,model:s[0].model}]:[];e.length&&f({modelPolicy:{allowed:e,strict:!0}})}else o(e=>{let t={...e};return delete t.modelPolicy,t})}}),`Restrict this agent to an explicit model allowlist`]}),c&&(0,R.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,R.jsxs)(`div`,{className:`space-y-1`,children:[(0,R.jsx)(`span`,{className:`text-[10px] font-medium`,children:`Allowed models`}),(0,R.jsx)(F,{value:l,candidates:s,onChange:h,placeholder:`Add allowed model`,emptyHint:`At least one model is required`})]}),(0,R.jsxs)(`div`,{className:`space-y-1`,children:[(0,R.jsx)(`span`,{className:`text-[10px] font-medium`,children:`Ordered fallback chain`}),(0,R.jsx)(F,{value:d,candidates:s,onChange:e=>{let t=[...new Set([...l,...e])];o(n=>({...n,modelPolicy:{allowed:t.map(H),fallbacks:e.map(H),strict:n.modelPolicy?.strict??!0}}))},placeholder:`Add fallback model`,emptyHint:`No fallback; primary failure stops the task`})]})]})]}),(0,R.jsx)(`section`,{className:`grid gap-3 sm:grid-cols-3`,children:[[`tools`,`Tools`,`read_file, search, bash`],[`skillNames`,`Skills`,`security-check, browser`],[`allowedCapabilities`,`Capabilities`,`fs.read, fs.write`]].map(([e,t,n])=>(0,R.jsxs)(`label`,{className:`space-y-1 text-[10px]`,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:t}),(0,R.jsx)(`textarea`,{value:U(a[e]),onChange:t=>p(e,t.target.value),placeholder:n,className:`h-20 w-full resize-y rounded border border-border bg-background p-2 font-mono`})]},e))}),(0,R.jsxs)(`section`,{className:`space-y-2`,children:[(0,R.jsx)(`h4`,{className:`text-xs font-semibold`,children:`Workspace and isolation`}),(0,R.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,R.jsxs)(`label`,{className:`space-y-1 text-[10px]`,children:[(0,R.jsx)(`span`,{children:`Project-relative working directory`}),(0,R.jsx)(`input`,{value:a.cwd??``,onChange:e=>f({cwd:e.target.value||void 0}),placeholder:`packages/webui`,className:`h-8 w-full rounded border border-border bg-background px-2 font-mono`})]}),(0,R.jsxs)(`label`,{className:`space-y-1 text-[10px]`,children:[(0,R.jsx)(`span`,{children:`Git worktree isolation`}),(0,R.jsxs)(`select`,{value:String(a.worktree??`auto`),onChange:e=>f({worktree:e.target.value}),className:`h-8 w-full rounded border border-border bg-background px-2`,children:[(0,R.jsx)(`option`,{value:`auto`,children:`Automatic`}),(0,R.jsx)(`option`,{value:`required`,children:`Required`}),(0,R.jsx)(`option`,{value:`off`,children:`Off`})]})]})]})]}),(0,R.jsxs)(`section`,{className:`space-y-2`,children:[(0,R.jsx)(`h4`,{className:`text-xs font-semibold`,children:`Limits`}),(0,R.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:B.map(([e,t])=>(0,R.jsxs)(`label`,{className:`space-y-1 text-[10px]`,children:[(0,R.jsx)(`span`,{children:t}),(0,R.jsx)(`input`,{type:`number`,min:`0`,step:e===`maxCostUsd`?`0.01`:`1`,value:a.budget?.[e]??``,onChange:t=>m(e,t.target.value),className:`h-8 w-full rounded border border-border bg-background px-2`})]},e))})]}),(0,R.jsxs)(`section`,{className:`space-y-2`,children:[(0,R.jsxs)(`label`,{className:`flex items-center gap-2 text-xs font-semibold`,children:[(0,R.jsx)(`input`,{type:`checkbox`,checked:!!a.availability,onChange:e=>{e.target.checked?f({availability:{timezone:Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`,days:[1,2,3,4,5],start:`09:00`,end:`18:00`,mode:t?`advisory`:`enforce`}}):o(e=>{let t={...e};return delete t.availability,t})}}),`Working hours`]}),a.availability&&(0,R.jsxs)(`div`,{className:`space-y-2 rounded border border-border p-2`,children:[(0,R.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:z.map((e,t)=>(0,R.jsxs)(`label`,{className:`flex items-center gap-1 text-[10px]`,children:[(0,R.jsx)(`input`,{type:`checkbox`,checked:a.availability?.days.includes(t)??!1,onChange:e=>{let n=a.availability;if(!n)return;let r=e.target.checked?[...new Set([...n.days,t])].sort():n.days.filter(e=>e!==t);f({availability:{...n,days:r}})}}),e]},e))}),(0,R.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-4`,children:[(0,R.jsx)(`input`,{value:a.availability.timezone,onChange:e=>f({availability:{...a.availability,timezone:e.target.value}}),placeholder:`Europe/Kiev`,className:`h-8 rounded border border-border bg-background px-2 text-[10px]`}),(0,R.jsx)(`input`,{type:`time`,value:a.availability.start,onChange:e=>f({availability:{...a.availability,start:e.target.value}}),className:`h-8 rounded border border-border bg-background px-2 text-[10px]`}),(0,R.jsx)(`input`,{type:`time`,value:a.availability.end,onChange:e=>f({availability:{...a.availability,end:e.target.value}}),className:`h-8 rounded border border-border bg-background px-2 text-[10px]`}),(0,R.jsxs)(`select`,{value:t?`advisory`:a.availability.mode??`enforce`,disabled:t,onChange:e=>f({availability:{...a.availability,mode:e.target.value}}),className:`h-8 rounded border border-border bg-background px-2 text-[10px]`,children:[(0,R.jsx)(`option`,{value:`enforce`,children:`Enforce`}),(0,R.jsx)(`option`,{value:`advisory`,children:`Advisory`})]})]})]})]}),(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[(0,R.jsx)(`button`,{type:`button`,disabled:n||!!(c&&c.allowed.length===0),onClick:()=>r(a),className:`rounded bg-primary px-3 py-1.5 text-xs text-primary-foreground disabled:opacity-50`,children:n?`Saving…`:`Save runtime policy`}),(0,R.jsx)(`button`,{type:`button`,onClick:i,className:`rounded border border-border px-3 py-1.5 text-xs hover:bg-accent`,children:`Cancel`})]})]})}var K=[{id:`live`,icon:(0,R.jsx)(i,{className:`h-4 w-4`}),label:`Live Fleet`},{id:`catalog`,icon:(0,R.jsx)(S,{className:`h-4 w-4`}),label:`Roster Catalog`},{id:`learning`,icon:(0,R.jsx)(f,{className:`h-4 w-4`}),label:`Self-Learning`},{id:`customize`,icon:(0,R.jsx)(x,{className:`h-4 w-4`}),label:`Customization`}],q=[{role:`generic`,name:`Generic Project Agent`,summary:`Flexible template that can be cloned into independently learning project roles.`,tools:0,budget:{maxIterations:2500,maxToolCalls:7500}},{role:`audit-log`,name:`Audit Log`,summary:`Analyzes session logs, event streams, and system traces.`,tools:12,budget:{timeoutMs:108e5,maxIterations:2500,maxToolCalls:7500}},{role:`bug-hunter`,name:`Bug Hunter`,summary:`Scans code for bugs, code smells, and anti-patterns.`,tools:15,budget:{timeoutMs:18e6,maxIterations:4e3,maxToolCalls:1e4}},{role:`refactor-planner`,name:`Refactor Planner`,summary:`Analyzes code structure and produces phased refactoring plans.`,tools:14,budget:{timeoutMs:144e5,maxIterations:3e3,maxToolCalls:9e3}},{role:`security-scanner`,name:`Security Scanner`,summary:`Scans code, configs, and dependencies for security issues.`,tools:18,budget:{timeoutMs:18e6,maxIterations:4e3,maxToolCalls:1e4}},{role:`critic`,name:`Critic`,summary:`Evaluates decisions, plans, and implementations.`,tools:10,budget:{timeoutMs:108e5,maxIterations:2e3,maxToolCalls:5e3}},{role:`shadow-agent`,name:`Shadow Agent`,summary:`Background monitoring agent that watches fleet health.`,tools:8,budget:{timeoutMs:36e6,maxIterations:500,maxToolCalls:2e3}},{role:`executor`,name:`Executor`,summary:`General-purpose task executor for delegated work.`,tools:20,budget:{timeoutMs:72e5,maxIterations:1500,maxToolCalls:4e3}},{role:`chimera`,name:`Chimera`,summary:`Post-session code quality review of changed files.`,tools:10,budget:{timeoutMs:72e5,maxIterations:1e3,maxToolCalls:3e3}},{role:`researcher`,name:`Researcher`,summary:`Web research and data gathering specialist.`,tools:8,budget:{timeoutMs:72e5,maxIterations:1e3,maxToolCalls:3e3}},{role:`tech-stack`,name:`Tech Stack Validator`,summary:`Validates package/library/framework choices.`,tools:9,budget:{timeoutMs:72e5,maxIterations:1e3,maxToolCalls:3e3}},{role:`orchestrator`,name:`Orchestrator`,summary:`Coordinates multi-agent task execution.`,tools:12,budget:{timeoutMs:144e5,maxIterations:3e3,maxToolCalls:8e3}},{role:`supervisor`,name:`Supervisor`,summary:`Oversees subagent execution and handles escalations.`,tools:10,budget:{timeoutMs:144e5,maxIterations:2e3,maxToolCalls:6e3}},{role:`quality-gate`,name:`Quality Gate`,summary:`Enforces quality gates on implementations.`,tools:8,budget:{timeoutMs:72e5,maxIterations:1e3,maxToolCalls:3e3}},{role:`architect`,name:`Architect`,summary:`Makes design and architecture decisions.`,tools:14,budget:{timeoutMs:144e5,maxIterations:3e3,maxToolCalls:8e3}},{role:`prompt-engineer`,name:`Prompt Engineer`,summary:`Designs and optimizes system prompts.`,tools:8,budget:{timeoutMs:72e5,maxIterations:1e3,maxToolCalls:3e3}},{role:`mnemosyne`,name:`Mnemosyne`,summary:`Memory curator — reviews and maintains SAGE integrity.`,tools:6,budget:{timeoutMs:72e5,maxIterations:500,maxToolCalls:2e3}},{role:`autophase`,name:`AutoPhase`,summary:`Manages multi-phase autonomous task execution.`,tools:10,budget:{timeoutMs:144e5,maxIterations:2e3,maxToolCalls:6e3}}];function J({customStats:e,rosterLoading:t,onRefresh:n}){return(0,R.jsx)(`div`,{className:`shrink-0 border-b border-border/70 bg-card/80 px-4 py-2.5`,children:(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2 flex-nowrap min-w-0`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 overflow-hidden`,children:[(0,R.jsx)(`div`,{className:`flex items-center justify-center w-8 h-8 shrink-0 rounded-lg bg-primary/10`,children:(0,R.jsx)(b,{className:`h-4 w-4 text-primary`})}),(0,R.jsxs)(`div`,{className:`min-w-0 overflow-hidden`,children:[(0,R.jsx)(`h1`,{className:`text-sm font-semibold truncate`,children:`Agent Roster`}),(0,R.jsxs)(`p`,{className:`text-[10px] text-muted-foreground truncate`,children:[e.filter(e=>e.exists||e.hasIdentity||e.hasConfig||e.hasKnowledge).length,` `,`customized · `,e.reduce((e,t)=>e+t.entryCount,0),` learned entries`]})]})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[t&&(0,R.jsx)(g,{className:`h-4 w-4 animate-spin text-muted-foreground shrink-0`}),(0,R.jsxs)(`button`,{type:`button`,onClick:n,className:`inline-flex items-center gap-1 rounded border border-border/50 px-2 py-1 text-[10px] hover:bg-accent transition-colors shrink-0 whitespace-nowrap`,title:`Refresh roster data`,children:[(0,R.jsx)(T,{className:`h-3 w-3`}),` Refresh`]})]})]})})}function Y({activeTab:e,onTabChange:t}){return(0,R.jsx)(`div`,{className:`shrink-0 border-b border-border/50 bg-muted/20 px-3 flex gap-0`,children:K.map(n=>(0,R.jsxs)(`button`,{type:`button`,onClick:()=>t(n.id),className:A(`flex items-center gap-1.5 px-3 py-2 text-[10px] font-medium border-b-2 transition-colors`,e===n.id?`border-primary text-primary`:`border-transparent text-muted-foreground hover:text-foreground hover:border-muted-foreground/30`),children:[n.icon,n.label]},n.id))})}function X({customStats:e,onRefresh:n}){let[r,i]=(0,L.useState)(null),[o,l]=(0,L.useState)(null),[u,d]=(0,L.useState)({}),[p,m]=(0,L.useState)(``),[h,_]=(0,L.useState)(null),[v,y]=(0,L.useState)(!1),[b,x]=(0,L.useState)(!1),[T,E]=(0,L.useState)(null),[D,j]=(0,L.useState)(!1),[N,P]=(0,L.useState)(!1),F=(0,L.useMemo)(()=>[...e].sort((e,t)=>e.role.localeCompare(t.role)),[e]),z=(0,L.useMemo)(()=>r?F.find(e=>e.role===r):null,[r,F]),B=(0,L.useCallback)(async e=>{x(!0),l(null);try{let t=await I(`agent-roster.read-learned`,{role:e});l(t.entries??[]),d({})}catch{}x(!1)},[]),V=(0,L.useCallback)(async()=>{if(!r||!o)return;y(!0);let e=o.filter((e,t)=>u[t]!==`drop`).join(`
2
-
3
- ---
4
-
5
- `);try{await I(`agent-roster.update-learned`,{role:r,content:e}),l(null),d({})}catch{}y(!1)},[r,o,u]),H=(0,L.useCallback)(async()=>{if(!(!r||!p.trim())){_(null),y(!0);try{let e=`> Taught ${new Date().toISOString().slice(0,10)}\n\n${p.trim()}`;(await I(`agent-roster.append-learned`,{role:r,content:e})).success?(_({ok:!0,msg:`Saved to learned.md`}),m(``),n()):_({ok:!1,msg:`Save failed`})}catch(e){_({ok:!1,msg:e instanceof Error?e.message:`Failed`})}y(!1)}},[n,r,p]),U=(0,L.useCallback)(async(e,t)=>{y(!0),_(null);try{let r=await I(`agent-roster.update-learning`,{role:e,enabled:t});if(r.error)throw Error(r.error);_({ok:!0,msg:t?`Automatic learning resumed`:`Automatic learning paused`}),n()}catch(e){_({ok:!1,msg:e instanceof Error?e.message:`Policy update failed`})}finally{y(!1)}},[n]),W=(0,L.useCallback)(async e=>{try{let t=await I(`agent-roster.read-consolidated`,{role:e});E(t.isConsolidated?t.content:null)}catch{E(null)}},[]),G=(0,L.useCallback)(async e=>{j(!0),_(null);try{let r=await I(`agent-roster.consolidate`,{role:e});if(r.error)throw Error(r.error);if(r.rawEntryCount===0){_({ok:!1,msg:`No raw entries to optimize yet.`});return}if(r.consolidated){await n(),await W(e),_({ok:!0,msg:`Optimized. Consolidated knowledge updated.`}),M.success(r.model?`Learnings consolidated with ${r.model}.`:`Learnings consolidated.`);return}if(r.emptySynthesis){_({ok:!1,msg:`The model returned an empty result. Nothing was changed — try again.`}),M.error(`Optimization produced an empty result. Try again.`);return}let i=r.instruction;if(!i)throw Error(`No consolidation instruction generated`);let a=t.getState();a.addMessage({role:`user`,content:i}),a.setLoading(!0),k().sendMessage(i);let o=O.getState();o.setSidebarOpen(!1),o.setCurrentView(`chat`),_({ok:!0,msg:`No active model on server — optimization sent to chat agent instead.`}),M.info(`No active model on server. Optimization sent to the chat agent.`)}catch(e){_({ok:!1,msg:e instanceof Error?e.message:`Optimization failed`}),M.error(e instanceof Error?e.message:`Optimization failed`)}finally{j(!1)}},[n,W]),K=(0,L.useCallback)(async e=>{if(e.length!==0){P(!0),_(null);try{let n=[],i=0,a=0,o=``,s=[];for(let t of e)try{let e=await I(`agent-roster.consolidate`,{role:t});e.error?(a++,o=e.error):e.consolidated?n.push(t):e.rawEntryCount===0?i++:e.emptySynthesis?(a++,o=`Model returned an empty result`):e.instruction?s.push({role:t,instruction:e.instruction}):(a++,o=`No consolidation produced`)}catch(e){a++,o=e instanceof Error?e.message:String(e)}if(r&&n.includes(r)&&await W(r),s.length>0){let e=`Optimize the learned data for ${s.length} agent${s.length>1?`s`:``}. For each agent below, read its raw learned entries, synthesize them into a single narrowly-scoped document preserving every fact, and save the result to its consolidated.md file.\n\n`+s.map(e=>`## Agent: ${e.role}\n\n${e.instruction}`).join(`
6
-
7
- ---
8
-
9
- `),n=t.getState();n.addMessage({role:`user`,content:e}),n.setLoading(!0),k().sendMessage(e);let r=O.getState();r.setSidebarOpen(!1),r.setCurrentView(`chat`)}if(n.length===0&&s.length===0){if(a>0){let t=i>0?` ${i} skipped.`:``,n=`Bulk consolidate failed for ${a} of ${e.length} agent${e.length>1?`s`:``}.${o?` Last error: ${o}`:``}${t}`;_({ok:!1,msg:n});return}let t=i>0?`Bulk optimize: ${i} skipped (no entries to optimize).`:`No agents had optimizable entries.`;_({ok:!0,msg:t}),M.info(t,6e3);return}let c=[];n.length>0&&c.push(`${n.length} consolidated`),s.length>0&&c.push(`${s.length} sent to chat`),i>0&&c.push(`${i} skipped`),a>0&&c.push(`${a} failed`);let l=`Bulk optimize: ${c.join(`, `)}.`;_({ok:a===0,msg:l}),n.length>0&&s.length===0?M.success(l,6e3):M.info(l,6e3)}catch(e){_({ok:!1,msg:e instanceof Error?e.message:`Bulk optimization failed`}),M.error(e instanceof Error?e.message:`Bulk optimization failed`)}finally{P(!1)}}},[r,W]);return F.length===0?(0,R.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-muted-foreground`,children:(0,R.jsxs)(`div`,{className:`text-center space-y-3`,children:[(0,R.jsx)(w,{className:`h-10 w-10 mx-auto opacity-30`}),(0,R.jsx)(`p`,{className:`text-sm`,children:`No self-learning data yet`}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground/70`,children:`Learning entries appear when agents capture output`})]})}):(0,R.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:[(0,R.jsxs)(`div`,{className:A(`flex flex-col min-h-0 min-w-0 overflow-hidden border-r border-border/50`,r?`w-80 shrink-0`:`flex-1`),children:[(0,R.jsxs)(`div`,{className:`shrink-0 px-3 py-2 border-b border-border/50`,children:[(0,R.jsxs)(`h3`,{className:`text-xs font-semibold flex items-center gap-1.5`,children:[(0,R.jsx)(w,{className:`h-3.5 w-3.5 text-brand-2`}),`All Roster Agents`]}),(()=>{let e=F.filter(e=>e.needsSummarization);return e.length===0?null:(0,R.jsxs)(`div`,{className:`mt-2 flex flex-col gap-1.5 rounded border border-warning/40 bg-warning/10 px-2 py-1.5`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(C,{className:`h-3 w-3 text-warning shrink-0`}),(0,R.jsxs)(`span`,{className:`text-[10px] text-warning leading-tight`,children:[e.length,` agent`,e.length>1?`s`:``,` need`,e.length===1?`s`:``,` optimization`]}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>{let t=e[0];t&&(i(t.role),l(null),E(null))},className:`ml-auto text-[9px] text-warning underline hover:text-warning/80 shrink-0`,children:`review →`})]}),(0,R.jsxs)(`button`,{type:`button`,onClick:()=>K(e.map(e=>e.role)),disabled:N,className:`flex items-center justify-center gap-1 rounded bg-warning/20 border border-warning/40 px-2 py-1 text-[10px] font-medium text-warning hover:bg-warning/30 transition-colors disabled:opacity-50`,children:[N?(0,R.jsx)(g,{className:`h-3 w-3 animate-spin`}):(0,R.jsx)(C,{className:`h-3 w-3`}),N?`Optimizing…`:`Optimize All (${e.length})`]})]})})()]}),(0,R.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-2 space-y-1`,children:F.map(e=>(0,R.jsxs)(`button`,{type:`button`,onClick:()=>{i(e.role),l(null),E(null)},className:A(`w-full text-left rounded-lg border px-3 py-2 transition-colors`,r===e.role?`border-primary/50 bg-primary/[0.06]`:`border-border/60 hover:border-primary/30`,e.needsSummarization&&r!==e.role&&`border-warning/40`),children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,R.jsx)(`span`,{className:`text-xs font-semibold`,children:e.role}),(0,R.jsx)(`span`,{className:A(`text-[9px] tabular-nums`,e.learningEnabled?`text-success`:`text-muted-foreground`),children:e.learningEnabled?`learning`:`paused`})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-2 mt-1 text-[9px] text-muted-foreground`,children:[(0,R.jsxs)(`span`,{className:`tabular-nums`,children:[e.entryCount,` entries`]}),e.sessionCaptureCount>0&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,R.jsxs)(`span`,{className:`text-success tabular-nums`,children:[`+`,e.sessionCaptureCount]})]}),e.lastCapture&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,R.jsx)(`span`,{children:new Date(e.lastCapture).toLocaleDateString()})]}),e.needsSummarization&&(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-warning font-medium`,children:[(0,R.jsx)(C,{className:`h-2.5 w-2.5`}),`optimize`]})]})]},e.role))})]}),(0,R.jsxs)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-y-auto p-4`,children:[!r&&(0,R.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground`,children:`Select an agent to view learning details`}),r&&z&&(0,R.jsxs)(`div`,{className:`space-y-4`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,R.jsx)(`h3`,{className:`text-base font-semibold`,children:r}),(0,R.jsx)(`div`,{className:`flex gap-1`,children:(0,R.jsxs)(`button`,{type:`button`,onClick:()=>U(r,!z.learningEnabled),disabled:v,className:A(`inline-flex items-center gap-1 rounded border px-2 py-1 text-[10px] transition-colors disabled:opacity-50`,z.learningEnabled?`border-success/40 text-success hover:bg-success/10`:`border-border/50 text-muted-foreground hover:bg-accent`),children:[(0,R.jsx)(w,{className:`h-3 w-3`}),` `,z.learningEnabled?`Learning on`:`Learning paused`]})})]}),(0,R.jsxs)(`div`,{className:`grid grid-cols-4 gap-2`,children:[(0,R.jsxs)(`div`,{className:`rounded-lg border bg-card p-2`,children:[(0,R.jsx)(`span`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:`Entries`}),(0,R.jsx)(`div`,{className:`text-lg font-mono font-semibold mt-0.5`,children:z.entryCount})]}),(0,R.jsxs)(`div`,{className:`rounded-lg border bg-card p-2`,children:[(0,R.jsx)(`span`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:`Size`}),(0,R.jsxs)(`div`,{className:`text-lg font-mono font-semibold mt-0.5`,children:[z.totalBytes,`B`]})]}),(0,R.jsxs)(`div`,{className:`rounded-lg border bg-card p-2`,children:[(0,R.jsx)(`span`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:`Last Capture`}),(0,R.jsx)(`div`,{className:`text-lg font-mono font-semibold mt-0.5`,children:z.lastCapture?new Date(z.lastCapture).toLocaleDateString():`—`})]}),(0,R.jsxs)(`div`,{className:`rounded-lg border bg-card p-2`,children:[(0,R.jsx)(`span`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:`Lifetime Captures`}),(0,R.jsx)(`div`,{className:`text-lg font-mono font-semibold mt-0.5`,children:z.lifetimeCaptureCount})]})]}),z.needsSummarization&&(0,R.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-warning bg-warning/10 rounded-lg px-3 py-2.5`,children:[(0,R.jsx)(a,{className:`h-4 w-4 shrink-0`}),(0,R.jsxs)(`span`,{className:`flex-1`,children:[`Learned data exceeds soft limit (`,z.totalBytes.toLocaleString(),`B / 8,192B). Optimize to synthesize raw entries into a consolidated document and reduce context volume.`]}),(0,R.jsxs)(`button`,{type:`button`,onClick:()=>G(r),disabled:D,className:`inline-flex items-center gap-1 rounded bg-warning/20 text-warning border border-warning/40 px-2.5 py-1 text-[10px] font-medium hover:bg-warning/30 transition-colors disabled:opacity-50 shrink-0`,children:[D?(0,R.jsx)(g,{className:`h-3 w-3 animate-spin`}):(0,R.jsx)(C,{className:`h-3 w-3`}),D?`Optimizing…`:`Optimize Now`]})]}),(0,R.jsxs)(`div`,{className:`space-y-2 border border-border rounded-lg p-3 bg-card`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(c,{className:`h-4 w-4 text-primary`}),(0,R.jsx)(`span`,{className:`text-xs font-semibold`,children:`Optimize Learnings`})]}),(0,R.jsxs)(`button`,{type:`button`,onClick:()=>G(r),disabled:D||z.entryCount===0,className:`inline-flex items-center gap-1 rounded bg-primary px-3 py-1.5 text-xs text-primary-foreground hover:bg-primary/90 transition-colors disabled:opacity-50`,title:z.entryCount===0?`No raw entries to optimize`:`Synthesize raw entries into a consolidated, narrowly-scoped document`,children:[D?(0,R.jsx)(g,{className:`h-3.5 w-3.5 animate-spin`}):(0,R.jsx)(C,{className:`h-3.5 w-3.5`}),D?`Optimizing…`:`Optimize`]})]}),(0,R.jsxs)(`p`,{className:`text-[10px] text-muted-foreground leading-relaxed`,children:[`Synthesizes all `,z.entryCount,` raw entries into a single reviewed document — narrowly scoped to this agent's skills, preserving every fact but reducing context volume. The result replaces raw entries in the agent's prompt.`]}),z.isConsolidated&&z.consolidation&&(0,R.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-muted-foreground pt-1 border-t border-border/50`,children:[(0,R.jsx)(s,{className:`h-3 w-3 text-success`}),(0,R.jsxs)(`span`,{children:[`Consolidated`,` `,new Date(z.consolidation.consolidatedAt).toLocaleDateString(),` ·`,` `,z.consolidation.sourceBytes,`B →`,` `,z.consolidation.consolidatedBytes,`B`,z.consolidation.sourceEntryCount<z.entryCount&&(0,R.jsxs)(`span`,{className:`text-warning ml-1`,children:[`· `,z.entryCount-z.consolidation.sourceEntryCount,` `,`new pending`]})]}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>{T===null?W(r):E(null)},className:`ml-auto underline text-primary hover:text-primary/80`,children:T===null?`View`:`Hide`})]}),T!==null&&(0,R.jsxs)(`div`,{className:`mt-2 max-h-72 overflow-y-auto rounded border border-border/50 bg-background/50 p-2`,children:[(0,R.jsxs)(`div`,{className:`text-[10px] text-muted-foreground mb-1 font-medium`,children:[`Consolidated knowledge for `,r]}),(0,R.jsx)(`pre`,{className:`text-[10px] whitespace-pre-wrap font-sans leading-relaxed`,children:T||`(empty)`})]})]}),z.entryCount>0&&(0,R.jsxs)(`div`,{className:`space-y-2`,children:[(0,R.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,R.jsxs)(`button`,{type:`button`,onClick:()=>B(r),disabled:b,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:[b?(0,R.jsx)(g,{className:`h-3 w-3 animate-spin`}):(0,R.jsx)(S,{className:`h-3 w-3`}),`Review Learned Entries (`,z.entryCount,`)`]})}),o&&(0,R.jsxs)(`div`,{className:`space-y-2 border border-border rounded-lg p-3 bg-card`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,R.jsxs)(`span`,{className:`text-xs font-medium`,children:[o.filter((e,t)=>u[t]!==`drop`).length,`/`,o.length,` kept`]}),(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:V,disabled:v,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:v?`Applying…`:`Apply Selection`}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>{l(null),d({})},className:`inline-flex items-center gap-1 rounded border border-border/50 px-2 py-1 text-[10px] hover:bg-accent transition-colors`,children:`Cancel`})]})]}),(0,R.jsx)(`div`,{className:`max-h-72 overflow-y-auto space-y-2`,children:o.map((e,t)=>{let n=u[t]??`keep`,r=e.length>200?e.slice(0,200)+`…`:e;return(0,R.jsx)(`div`,{className:A(`rounded-lg border p-2 transition-colors`,n===`drop`?`border-destructive/40 bg-destructive/5 opacity-60`:`border-border`),children:(0,R.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,R.jsx)(`pre`,{className:`text-[10px] whitespace-pre-wrap flex-1 leading-relaxed font-sans`,children:r}),(0,R.jsxs)(`div`,{className:`flex gap-1 shrink-0`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:()=>d(e=>({...e,[t]:`keep`})),className:A(`px-2 py-1 text-[9px] rounded`,n===`keep`?`bg-success/20 text-success`:`bg-muted text-muted-foreground`),children:`Keep`}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>d(e=>({...e,[t]:`drop`})),className:A(`px-2 py-1 text-[9px] rounded`,n===`drop`?`bg-destructive/20 text-destructive`:`bg-muted text-muted-foreground`),children:`Drop`})]})]})},t)})})]})]}),(0,R.jsxs)(`div`,{className:`space-y-2 pt-4 border-t border-border`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-1 text-sm font-medium`,children:[(0,R.jsx)(f,{className:`h-4 w-4 text-brand-2`}),` Teach this agent`]}),(0,R.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Describe a command, pattern, or behavior you want this agent to remember.`}),(0,R.jsx)(`textarea`,{className:`w-full h-20 text-xs p-2 bg-card border border-border rounded resize-y`,value:p,onChange:e=>m(e.target.value),placeholder:`e.g. Always use pnpm for this project`}),(0,R.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,R.jsxs)(`button`,{type:`button`,onClick:H,disabled:!p.trim()||v,className:`inline-flex items-center gap-1 rounded bg-primary px-3 py-1.5 text-xs text-primary-foreground hover:bg-primary/90 transition-colors disabled:opacity-50`,children:[(0,R.jsx)(f,{className:`h-3.5 w-3.5`}),` Teach`]}),h&&(0,R.jsx)(`span`,{className:A(`text-xs`,h.ok?`text-success`:`text-destructive`),children:h.msg})]})]})]})]})]})}function ee({customStats:e,catalog:t}){let[n,r]=(0,L.useState)(``),[a,s]=(0,L.useState)(null),c=(0,L.useMemo)(()=>new Set(e.filter(e=>e.exists||e.hasIdentity||e.hasConfig||e.hasKnowledge).map(e=>e.role)),[e]),u=(0,L.useMemo)(()=>{if(!n.trim())return t;let e=n.toLowerCase();return t.filter(t=>t.role.includes(e)||t.name.toLowerCase().includes(e)||t.summary.toLowerCase().includes(e))},[t,n]),f=(0,L.useCallback)(t=>e.find(e=>e.role===t),[e]),m=u;return(0,R.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,R.jsx)(`div`,{className:`shrink-0 px-3 py-2 border-b border-border/50`,children:(0,R.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-border/60 bg-background px-3 py-1.5`,children:[(0,R.jsx)(d,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,R.jsx)(`input`,{type:`text`,value:n,onChange:e=>r(e.target.value),placeholder:`Search agents by name, role, or description…`,className:`flex-1 bg-transparent text-xs outline-none placeholder:text-muted-foreground/50`}),n&&(0,R.jsx)(`button`,{type:`button`,onClick:()=>r(``),className:`text-muted-foreground hover:text-foreground`,children:(0,R.jsx)(p,{className:`h-3 w-3`})})]})}),(0,R.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-3`,children:[(0,R.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-2`,children:m.map(e=>{let t=f(e.role),n=c.has(e.role),r=a===e.role;return(0,R.jsxs)(`div`,{className:A(`rounded-lg border bg-card transition-colors`,r?`border-primary/40 ring-1 ring-primary/20`:`border-border/60 hover:border-primary/30`),children:[(0,R.jsxs)(`button`,{type:`button`,onClick:()=>s(r?null:e.role),className:`w-full text-left p-3`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,R.jsx)(v,{className:`h-4 w-4 shrink-0 text-primary`}),(0,R.jsx)(`span`,{className:`text-sm font-semibold truncate`,children:e.name}),(0,R.jsxs)(`code`,{className:`text-[9px] text-muted-foreground font-mono shrink-0`,children:[`@`,e.role]})]}),(0,R.jsx)(o,{className:A(`h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform`,r&&`rotate-180`)})]}),(0,R.jsx)(`p`,{className:`text-[10px] text-muted-foreground mt-1 leading-relaxed line-clamp-2`,children:e.summary}),(0,R.jsxs)(`div`,{className:`flex items-center gap-2 mt-1.5`,children:[(0,R.jsxs)(`span`,{className:`text-[9px] text-muted-foreground tabular-nums`,children:[e.tools,` tools`]}),e.budget.maxIterations&&(0,R.jsxs)(`span`,{className:`text-[9px] text-muted-foreground tabular-nums`,children:[e.budget.maxIterations.toLocaleString(),` max it`]}),n&&(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 rounded bg-brand-2/10 px-1 py-0.5 text-[8px] text-brand-2 font-medium`,children:[(0,R.jsx)(l,{className:`h-2.5 w-2.5`}),` Customized`]}),t?.needsSummarization&&(0,R.jsx)(`span`,{className:`text-[9px] text-warning`,children:`⚠ Needs summary`})]})]}),r&&(0,R.jsxs)(`div`,{className:`border-t border-border/50 px-3 py-2 space-y-2`,children:[(0,R.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,R.jsxs)(`div`,{className:`rounded bg-muted/30 p-1.5`,children:[(0,R.jsx)(`span`,{className:`text-[8px] text-muted-foreground uppercase tracking-wider`,children:`Max Iterations`}),(0,R.jsx)(`div`,{className:`text-xs font-mono mt-0.5`,children:e.budget.maxIterations?.toLocaleString()??`—`})]}),(0,R.jsxs)(`div`,{className:`rounded bg-muted/30 p-1.5`,children:[(0,R.jsx)(`span`,{className:`text-[8px] text-muted-foreground uppercase tracking-wider`,children:`Timeout`}),(0,R.jsx)(`div`,{className:`text-xs font-mono mt-0.5`,children:e.budget.timeoutMs?`${Math.round(e.budget.timeoutMs/6e4)}m`:`—`})]}),(0,R.jsxs)(`div`,{className:`rounded bg-muted/30 p-1.5`,children:[(0,R.jsx)(`span`,{className:`text-[8px] text-muted-foreground uppercase tracking-wider`,children:`Max Tool Calls`}),(0,R.jsx)(`div`,{className:`text-xs font-mono mt-0.5`,children:e.budget.maxToolCalls?.toLocaleString()??`—`})]}),(0,R.jsxs)(`div`,{className:`rounded bg-muted/30 p-1.5`,children:[(0,R.jsx)(`span`,{className:`text-[8px] text-muted-foreground uppercase tracking-wider`,children:`Customized`}),(0,R.jsx)(`div`,{className:`text-xs font-mono mt-0.5`,children:n?`Yes`:`No`})]})]}),n&&t&&(0,R.jsxs)(`div`,{className:`rounded bg-accent/30 p-2 space-y-1`,children:[(0,R.jsx)(`span`,{className:`text-[9px] font-medium text-muted-foreground`,children:`Project Customizations`}),(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-2 text-[9px]`,children:[t.hasIdentity&&(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,children:[(0,R.jsx)(l,{className:`h-2.5 w-2.5 text-primary`}),` identity.md`]}),t.entryCount>0&&(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,children:[(0,R.jsx)(w,{className:`h-2.5 w-2.5 text-brand-2`}),` `,t.entryCount,` `,`learned entries`]}),t.hasConfig&&(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,children:[(0,R.jsx)(x,{className:`h-2.5 w-2.5 text-muted-foreground`}),` config.json`]}),t.sessionCaptureCount>0&&(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,children:[(0,R.jsx)(i,{className:`h-2.5 w-2.5 text-success`}),` `,t.sessionCaptureCount,` session captures`]})]})]})]})]},e.role)})}),m.length===0&&(0,R.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-40 text-muted-foreground`,children:[(0,R.jsx)(d,{className:`h-8 w-8 mb-2 opacity-30`}),(0,R.jsxs)(`p`,{className:`text-sm`,children:[`No agents match "`,n,`"`]})]})]}),(0,R.jsxs)(`div`,{className:`shrink-0 border-t border-border/50 px-3 py-2 text-[10px] text-muted-foreground flex items-center gap-2`,children:[(0,R.jsxs)(`span`,{children:[(0,R.jsx)(`strong`,{children:t.length}),` roster roles`]}),(0,R.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,R.jsxs)(`span`,{className:`text-brand-2`,children:[(0,R.jsx)(`strong`,{children:c.size}),` customized`]}),(0,R.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,R.jsxs)(`span`,{children:[(0,R.jsx)(`strong`,{children:e.reduce((e,t)=>e+t.entryCount,0)}),` total learned entries`]})]})]})}var Z={running:{led:`bg-success`,badge:`bg-success/12 text-success`,icon:(0,R.jsx)(`span`,{className:`led text-success led-pulse`}),color:`text-success`},completed:{led:`bg-success`,badge:`bg-success/12 text-success`,icon:(0,R.jsx)(s,{className:`h-3.5 w-3.5`}),color:`text-success`},failed:{led:`bg-destructive`,badge:`bg-destructive/15 text-destructive`,icon:(0,R.jsx)(r,{className:`h-3.5 w-3.5`}),color:`text-destructive`},timeout:{led:`bg-warning`,badge:`bg-muted text-muted-foreground`,icon:(0,R.jsx)(n,{className:`h-3.5 w-3.5`}),color:`text-warning`},stopped:{led:`bg-muted-foreground`,badge:`bg-muted text-muted-foreground`,icon:(0,R.jsx)(`span`,{className:`led text-muted-foreground`}),color:`text-muted-foreground`},idle:{led:`bg-muted-foreground`,badge:`bg-muted text-muted-foreground`,icon:(0,R.jsx)(`span`,{className:`led text-muted-foreground`}),color:`text-muted-foreground`}};function Q(e){let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m ${t%60}s`;let r=Math.floor(n/60);return r<24?`${r}h ${n%60}m`:`${Math.floor(r/24)}d`}function $(e){if(e==null||!Number.isFinite(e)||e<=0)return`$0`;if(e<.01){let t=e.toFixed(5);return t===`0.00000`?`$0`:`$`+t.replace(/(\d)0+$/,`$1`).replace(/\.$/,``)}return`$`+e.toFixed(3)}function te({nowTick:e}){let t=j(e=>e.agents),n=j(e=>e.leaderId),[r,i]=(0,L.useState)(null),[a,o]=(0,L.useState)(`all`),s=(0,L.useMemo)(()=>{let e=Array.from(t.values());return e.sort((e,t)=>{let n=e.status===`running`?0:1,r=t.status===`running`?0:1;return n===r?t.startedAt-e.startedAt:n-r}),a===`all`?e:a===`running`?e.filter(e=>e.status===`running`):a===`done`?e.filter(e=>e.status===`completed`):a===`failed`?e.filter(e=>e.status===`failed`||e.status===`timeout`):e},[t,a]),c=(0,L.useMemo)(()=>{let e=0,n=0,r=0;for(let i of t.values())i.status===`running`?e++:i.status===`completed`?n++:(i.status===`failed`||i.status===`timeout`)&&r++;return{running:e,completed:n,failed:r,total:t.size}},[t]),l=j(e=>e.clearFinishedAgents),u=r?s.find(e=>e.id===r):null,d=(0,L.useCallback)(e=>{let t=O.getState();e?(t.setInspectorFocusedAgentId(e),t.setInspectorTab(`agents`)):t.setInspectorTab(`fleet`),t.setInspectorOpen(!0)},[]);return s.length===0?(0,R.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-muted-foreground`,children:(0,R.jsxs)(`div`,{className:`text-center space-y-3`,children:[(0,R.jsx)(v,{className:`h-10 w-10 mx-auto opacity-30`}),(0,R.jsx)(`p`,{className:`text-sm`,children:`No active fleet agents`}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground/70`,children:`Agents appear here when subagents spawn`})]})}):(0,R.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:[(0,R.jsxs)(`div`,{className:A(`flex flex-col min-h-0 min-w-0 overflow-hidden`,u?`w-80 shrink-0 border-r border-border/50`:`flex-1`),children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0 px-3 py-2 border-b border-border/50`,children:[[`all`,`running`,`done`,`failed`].map(e=>(0,R.jsxs)(`button`,{type:`button`,onClick:()=>o(e),className:A(`rounded px-2 py-0.5 text-[10px] font-medium transition-colors`,a===e?`bg-primary/10 text-primary`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),children:[e===`all`&&`All (${c.total})`,e===`running`&&`Running (${c.running})`,e===`done`&&`Done (${c.completed})`,e===`failed`&&`Failed (${c.failed})`]},e)),(0,R.jsx)(`span`,{className:`flex-1`}),c.completed+c.failed>0&&(0,R.jsxs)(`button`,{type:`button`,onClick:l,className:`inline-flex items-center gap-0.5 rounded px-1.5 py-0.5 text-[10px] text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition-colors`,children:[(0,R.jsx)(_,{className:`h-2.5 w-2.5`}),` Clear`]})]}),(0,R.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-2 space-y-1`,children:s.map(e=>(0,R.jsxs)(`button`,{type:`button`,onClick:()=>i(r===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`,r===e.id?`border-primary/50 bg-primary/[0.06]`:`border-border/60 hover:border-primary/30 hover:bg-primary/[0.03]`),children:[(0,R.jsx)(`span`,{className:A(`led shrink-0`,Z[e.status]?.led??`bg-muted-foreground`,e.status===`running`&&`led-pulse`)}),(0,R.jsx)(`span`,{className:`text-xs font-semibold min-w-0 truncate max-w-[7rem]`,children:e.name}),e.id===n&&(0,R.jsx)(E,{className:`h-3 w-3 shrink-0 text-warning`}),e.model&&(0,R.jsx)(`span`,{className:`text-[9px] text-muted-foreground font-mono truncate max-w-[6rem] shrink-0`,children:e.model}),(0,R.jsxs)(`span`,{className:`text-[9px] text-muted-foreground tabular-nums shrink-0`,children:[e.iteration,`it · `,e.toolCalls,`t`]}),e.status===`running`&&(0,R.jsx)(`span`,{className:`text-[9px] text-primary tabular-nums shrink-0 ml-auto`,children:Q(Date.now()-e.startedAt)}),e.status!==`running`&&(0,R.jsx)(`span`,{className:A(`text-[9px] tabular-nums shrink-0 ml-auto`,Z[e.status]?.color??`text-muted-foreground`),children:e.status}),e.costUsd>0&&(0,R.jsx)(`span`,{className:`text-[9px] text-success tabular-nums font-medium shrink-0`,children:$(e.costUsd)}),e.status===`running`&&e.currentTool&&(0,R.jsxs)(`span`,{className:`text-[9px] text-primary font-mono truncate max-w-[6rem] shrink-0`,children:[`→ `,e.currentTool]})]},e.id))}),(0,R.jsxs)(`div`,{className:`shrink-0 border-t border-border/50 px-3 py-2 flex items-center gap-2 text-[10px] text-muted-foreground`,children:[(0,R.jsx)(`span`,{className:`font-medium tabular-nums`,children:c.total}),` agents total`,(0,R.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,R.jsx)(`span`,{className:`text-success tabular-nums`,children:c.running}),` running`,(0,R.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,R.jsx)(`span`,{className:`tabular-nums`,children:c.completed}),` done`,c.failed>0&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,R.jsx)(`span`,{className:`text-destructive tabular-nums`,children:c.failed}),` failed`]}),(0,R.jsx)(`span`,{className:`flex-1`}),(0,R.jsxs)(`button`,{type:`button`,onClick:()=>d(),className:`inline-flex items-center gap-1 rounded border border-border/50 px-2 py-1 hover:bg-accent transition-colors`,children:[(0,R.jsx)(h,{className:`h-3 w-3`}),`Fleet Inspector`]})]})]}),u&&(0,R.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-y-auto p-4`,children:(0,R.jsx)(ne,{agent:u,nowTick:e})})]})}function ne({agent:e,nowTick:t}){let n=e.status===`running`?Q(t-e.startedAt):e.completedAt?Q(e.completedAt-e.startedAt):`-`,r=Math.min(100,Math.max(0,e.ctxPct)),i=e.currentTool||e.lastTool,a=j(e=>e.leaderId);return(0,R.jsxs)(`div`,{className:`space-y-4`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsx)(`div`,{className:`flex items-center justify-center w-10 h-10 rounded-lg bg-primary/10`,children:(0,R.jsx)(v,{className:`h-5 w-5 text-primary`})}),(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`text-base font-semibold`,children:e.name}),e.id===a&&(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded border border-warning/30 bg-warning/10 px-1.5 py-0.5 text-[9px] font-medium text-warning`,children:[(0,R.jsx)(E,{className:`h-2.5 w-2.5`}),` Leader`]})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-muted-foreground`,children:[(0,R.jsx)(`span`,{className:A(`led`,Z[e.status]?.led,e.status===`running`&&`led-pulse`)}),(0,R.jsx)(`span`,{children:e.status}),e.model&&(0,R.jsxs)(`span`,{children:[`· `,e.provider,`/`,e.model]}),(0,R.jsxs)(`span`,{children:[`· `,n]})]})]})]}),(0,R.jsxs)(`div`,{className:`grid grid-cols-4 gap-2`,children:[(0,R.jsxs)(`div`,{className:`rounded-lg border bg-card p-2`,children:[(0,R.jsx)(`span`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:`Iterations`}),(0,R.jsx)(`div`,{className:`text-lg font-mono font-semibold mt-0.5`,children:e.iteration})]}),(0,R.jsxs)(`div`,{className:`rounded-lg border bg-card p-2`,children:[(0,R.jsx)(`span`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:`Tool Calls`}),(0,R.jsx)(`div`,{className:`text-lg font-mono font-semibold mt-0.5`,children:e.toolCalls})]}),(0,R.jsxs)(`div`,{className:`rounded-lg border bg-card p-2`,children:[(0,R.jsx)(`span`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:`Cost`}),(0,R.jsx)(`div`,{className:`text-lg font-mono font-semibold mt-0.5 text-success`,children:$(e.costUsd)})]}),(0,R.jsxs)(`div`,{className:`rounded-lg border bg-card p-2`,children:[(0,R.jsx)(`span`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:`Context`}),(0,R.jsxs)(`div`,{className:`text-lg font-mono font-semibold mt-0.5`,children:[r,`%`]})]})]}),e.maxContext>0&&(0,R.jsxs)(`div`,{className:`space-y-1`,children:[(0,R.jsxs)(`div`,{className:`flex justify-between text-[10px]`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`Context Window`}),(0,R.jsxs)(`span`,{className:A(`tabular font-medium`,r>=85?`text-destructive`:r>=70?`text-warning`:`text-success`),children:[e.ctxTokens.toLocaleString(),` / `,e.maxContext.toLocaleString(),` tokens`]})]}),(0,R.jsx)(`div`,{className:`h-2 w-full overflow-hidden rounded-full bg-muted`,children:(0,R.jsx)(`div`,{className:A(`h-full rounded-full transition-all`,r>=85?`bg-destructive`:r>=70?`bg-warning`:`bg-primary`),style:{width:`${Math.max(2,r)}%`}})})]}),i&&(0,R.jsxs)(`div`,{className:A(`flex items-center gap-2 rounded-lg border px-3 py-2`,e.status===`running`?`border-primary/30 bg-primary/[0.04]`:`border-border bg-muted/30`),children:[(0,R.jsx)(m,{className:A(`h-4 w-4`,e.status===`running`?`text-primary animate-pulse`:`text-muted-foreground`)}),(0,R.jsx)(`span`,{className:`text-sm font-mono`,children:e.currentTool??e.lastTool}),(0,R.jsx)(`span`,{className:`text-[10px] text-muted-foreground ml-auto`,children:e.currentTool?`Running`:`Last tool`})]}),e.error&&(0,R.jsxs)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/5 p-3`,children:[(0,R.jsx)(`span`,{className:`text-[10px] font-semibold text-destructive uppercase tracking-wider`,children:`Error`}),(0,R.jsx)(`p`,{className:`text-xs text-destructive/90 mt-1`,children:e.error.message})]}),e.toolLog.length>0&&(0,R.jsxs)(`div`,{className:`space-y-1`,children:[(0,R.jsxs)(`span`,{className:`text-[10px] font-semibold text-muted-foreground uppercase tracking-wider`,children:[`Tool Log (`,e.toolLog.length,`)`]}),(0,R.jsx)(`div`,{className:`space-y-0.5`,children:e.toolLog.slice(0,10).map((e,t)=>(0,R.jsxs)(`div`,{className:A(`flex items-center gap-2 rounded px-2 py-1 text-[10px] font-mono`,e.ok?`bg-muted/30`:`bg-destructive/5 border border-destructive/20`),children:[(0,R.jsx)(`span`,{className:A(`led shrink-0`,e.ok?`text-success`:`text-destructive`)}),(0,R.jsx)(`span`,{className:`truncate flex-1`,children:e.name}),(0,R.jsxs)(`span`,{className:`tabular text-muted-foreground`,children:[e.durationMs,`ms`]}),!e.ok&&(0,R.jsx)(`span`,{className:`text-destructive`,children:`✗`})]},`${e.name}-${t}`))})]}),e.budgetWarning&&(0,R.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg bg-warning/10 border border-warning/25 text-xs`,children:[(0,R.jsx)(C,{className:`h-3.5 w-3.5 text-warning shrink-0`}),(0,R.jsxs)(`span`,{className:`text-warning`,children:[`Budget: `,e.budgetWarning.kind,` limit (`,e.budgetWarning.used,`/`,e.budgetWarning.limit,`)`]})]})]})}function re(){let[e,t]=(0,L.useState)([]),[n,r]=(0,L.useState)(q),[i,a]=(0,L.useState)(!1),[o,s]=(0,L.useState)(null),c=(0,L.useCallback)(async()=>{a(!0),s(null);try{let e=await I(`agent-roster.list`,{});e.stats&&t(e.stats),e.catalog?.length&&r(e.catalog)}catch(e){s(e instanceof Error?e.message:`Failed to load roster`)}a(!1)},[]);return(0,L.useEffect)(()=>{c()},[c]),(0,L.useEffect)(()=>{let e=null,t=k().on(`agent-roster.updated`,()=>{e&&clearTimeout(e),e=setTimeout(()=>{e=null,c()},300)});return()=>{e&&clearTimeout(e),t()}},[c]),{customStats:e,catalog:n,rosterLoading:i,rosterError:o,loadRoster:c}}function ie({customStats:e,catalog:n,onRefresh:r}){let[i,a]=(0,L.useState)(null),[o,s]=(0,L.useState)(null),[d,f]=(0,L.useState)(``),[p,m]=(0,L.useState)(null),[h,g]=(0,L.useState)(!1),[v,y]=(0,L.useState)(null),[b,C]=(0,L.useState)(!1),[T,E]=(0,L.useState)({name:``,role:``,baseRole:`generic`,purpose:``,taskTypes:``}),D=(0,L.useMemo)(()=>i?e.find(e=>e.role===i):null,[i,e]),j=(0,L.useMemo)(()=>{let e=n.find(e=>e.role===i);return e?.systemProtected??!e?.custom},[n,i]),M=(0,L.useCallback)(async(e,t)=>{g(!0),y(null),a(e);try{let n=await I(`agent-roster.read-customization`,{role:e});f(t===`config`?`${JSON.stringify(n.config??{},null,2)}\n`:n[t]??``),s(t),m(null)}catch(e){y(e instanceof Error?e.message:`Failed to load customization`)}finally{g(!1)}},[]),N=(0,L.useCallback)(async e=>{g(!0),y(null),a(e);try{let t=await I(`agent-roster.read-customization`,{role:e});m(t.config??{}),s(null)}catch(e){y(e instanceof Error?e.message:`Failed to load runtime policy`)}finally{g(!1)}},[]),P=(0,L.useCallback)(async e=>{if(i){g(!0),y(null);try{await I(`agent-roster.update-config`,{role:i,config:e}),m(null),r()}catch(e){y(e instanceof Error?e.message:`Runtime policy save failed`)}finally{g(!1)}}},[r,i]),F=(0,L.useCallback)(async()=>{if(!(!i||!o)){g(!0);try{let e={identity:`agent-roster.update-identity`,learned:`agent-roster.update-learned`,config:`agent-roster.update-config`},t={role:i};if(o===`config`)try{t.config=JSON.parse(d)}catch{y(`config.json must contain valid JSON`),g(!1);return}else t.content=d;await I(e[o],t),s(null),y(null),r()}catch(e){y(e instanceof Error?e.message:`Save failed`)}g(!1)}},[i,o,d,r]),z=(0,L.useCallback)(async()=>{if(i)try{let e=await I(`agent-roster.llm-improve`,{role:i,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){y(e instanceof Error?e.message:`LLM improvement failed`)}},[i]),B=(0,L.useCallback)(async e=>{if(window.confirm(`Reset all project-specific data for agent "${e}"?`))try{await I(`agent-roster.reset`,{role:e}),a(null),r()}catch{}},[r]),V=(0,L.useCallback)(async()=>{let e=T.taskTypes.split(/[\n,]+/).map(e=>e.trim()).filter(Boolean);g(!0),y(null);try{let t=await I(`agent-roster.create`,{name:T.name,role:T.role,baseRole:T.baseRole,purpose:T.purpose,taskTypes:e});C(!1),E({name:``,role:``,baseRole:`generic`,purpose:``,taskTypes:``}),a(t.role),r()}catch(e){y(e instanceof Error?e.message:`Agent creation failed`)}finally{g(!1)}},[T,r]),H=(0,L.useMemo)(()=>[...e].sort((e,t)=>{let n=+!!e.hasIdentity+ +(e.entryCount>0)+ +!!e.hasConfig;return+!!t.hasIdentity+ +(t.entryCount>0)+ +!!t.hasConfig-n}),[e]);return(0,R.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:[(0,R.jsxs)(`div`,{className:`w-80 shrink-0 border-r border-border/50 flex flex-col overflow-hidden`,children:[(0,R.jsx)(`div`,{className:`shrink-0 border-b border-border/50 px-3 py-2`,children:(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,R.jsxs)(`h3`,{className:`flex items-center gap-1.5 text-xs font-semibold`,children:[(0,R.jsx)(x,{className:`h-3.5 w-3.5`}),`Project Agents`]}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>{C(!0),a(null),m(null),y(null)},className:`rounded border border-primary/40 px-1.5 py-1 text-[9px] text-primary hover:bg-primary/10`,children:`+ Clone`})]})}),(0,R.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-2 space-y-1`,children:[H.map(e=>(0,R.jsxs)(`button`,{type:`button`,onClick:()=>{a(e.role),m(null),s(null)},className:A(`w-full text-left rounded-lg border px-3 py-2 transition-colors`,i===e.role?`border-primary/50 bg-primary/[0.06]`:`border-border/60 hover:border-primary/30`),children:[(0,R.jsx)(`div`,{className:`text-xs font-semibold`,children:e.role}),(0,R.jsxs)(`div`,{className:`flex gap-2 mt-0.5 text-[9px] text-muted-foreground`,children:[e.hasIdentity&&(0,R.jsx)(`span`,{className:`text-primary`,children:`id`}),e.entryCount>0&&(0,R.jsxs)(`span`,{className:`text-brand-2`,children:[e.entryCount,`e`]}),e.hasConfig&&(0,R.jsx)(`span`,{children:`cfg`})]})]},e.role)),H.length===0&&(0,R.jsx)(`div`,{className:`text-[10px] text-muted-foreground text-center py-4`,children:`No customizations yet`})]})]}),(0,R.jsxs)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-y-auto p-4`,children:[b&&(0,R.jsxs)(`div`,{className:`max-w-2xl space-y-4`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h3`,{className:`text-base font-semibold`,children:`Create or Clone Project Agent`}),(0,R.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Inherit any roster agent as a template, then develop an independent identity, runtime policy and learned history.`})]}),(0,R.jsxs)(`label`,{className:`block space-y-1 text-xs`,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:`Clone from roster role`}),(0,R.jsx)(`select`,{value:T.baseRole,onChange:e=>E(t=>({...t,baseRole:e.target.value})),className:`h-9 w-full rounded border border-border bg-card px-2`,children:[...n].sort((e,t)=>e.name.localeCompare(t.name)).map(e=>(0,R.jsxs)(`option`,{value:e.role,children:[e.name,` (`,e.role,`)`]},e.role))}),(0,R.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Prompt, tools, skills and defaults are inherited. Learning and later edits remain isolated to the new agent.`})]}),(0,R.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,R.jsxs)(`label`,{className:`space-y-1 text-xs`,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:`Display name`}),(0,R.jsx)(`input`,{value:T.name,onChange:e=>E(t=>({...t,name:e.target.value})),placeholder:`ABC`,className:`h-9 w-full rounded border border-border bg-card px-2`})]}),(0,R.jsxs)(`label`,{className:`space-y-1 text-xs`,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:`Role id (optional)`}),(0,R.jsx)(`input`,{value:T.role,onChange:e=>E(t=>({...t,role:e.target.value})),placeholder:`abc (generated from name)`,className:`h-9 w-full rounded border border-border bg-card px-2 font-mono`})]})]}),(0,R.jsxs)(`label`,{className:`block space-y-1 text-xs`,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:`Purpose`}),(0,R.jsx)(`textarea`,{value:T.purpose,onChange:e=>E(t=>({...t,purpose:e.target.value})),placeholder:`Own X, Y and Z workflows for this project and verify their results.`,className:`h-24 w-full resize-y rounded border border-border bg-card p-2`})]}),(0,R.jsxs)(`label`,{className:`block space-y-1 text-xs`,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:`Task types (comma or one per line)`}),(0,R.jsx)(`textarea`,{value:T.taskTypes,onChange:e=>E(t=>({...t,taskTypes:e.target.value})),placeholder:`X workflow
10
- Y analysis
11
- Z verification`,className:`h-24 w-full resize-y rounded border border-border bg-card p-2`})]}),v&&(0,R.jsx)(`p`,{className:`text-xs text-destructive`,children:v}),(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:V,disabled:h||!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:h?`Creating…`:`Clone Agent`}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>C(!1),className:`rounded border border-border px-3 py-1.5 text-xs hover:bg-accent`,children:`Cancel`})]})]}),!b&&!i&&(0,R.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground`,children:`Select an agent to edit customizations`}),!b&&i&&D&&(0,R.jsxs)(`div`,{className:`space-y-4 max-w-2xl`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,R.jsx)(`h3`,{className:`text-base font-semibold`,children:i}),(0,R.jsxs)(`div`,{className:`flex gap-1`,children:[(0,R.jsxs)(`button`,{type:`button`,onClick:z,className:`inline-flex items-center gap-1 rounded border border-border/50 px-2 py-1 text-[10px] hover:bg-accent transition-colors`,children:[(0,R.jsx)(c,{className:`h-3 w-3 text-brand-2`}),` LLM Improve`]}),(0,R.jsxs)(`button`,{type:`button`,onClick:()=>B(i),className:`inline-flex items-center gap-1 rounded border border-destructive/30 px-2 py-1 text-[10px] text-destructive hover:bg-destructive/10 transition-colors`,children:[(0,R.jsx)(_,{className:`h-3 w-3`}),` Reset`]})]})]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[D.hasIdentity&&(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded bg-primary/10 px-2 py-1 text-[10px] text-primary`,children:[(0,R.jsx)(l,{className:`h-3 w-3`}),` identity.md`]}),D.hasConfig&&(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded bg-muted px-2 py-1 text-[10px] text-muted-foreground`,children:[(0,R.jsx)(x,{className:`h-3 w-3`}),` config.json`]}),D.hasKnowledge&&(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded bg-muted px-2 py-1 text-[10px] text-muted-foreground`,children:[(0,R.jsx)(w,{className:`h-3 w-3`}),` knowledge.json`]}),D.entryCount>0&&(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded bg-brand-2/10 px-2 py-1 text-[10px] text-brand-2`,children:[(0,R.jsx)(S,{className:`h-3 w-3`}),` `,D.entryCount,` learned entries`]})]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,R.jsxs)(`button`,{type:`button`,onClick:()=>M(i,`identity`),className:`inline-flex items-center gap-1 rounded border border-border/50 px-3 py-1.5 text-xs hover:bg-accent transition-colors`,children:[(0,R.jsx)(l,{className:`h-3.5 w-3.5`}),` Edit identity.md`]}),(0,R.jsxs)(`button`,{type:`button`,onClick:()=>M(i,`learned`),className:`inline-flex items-center gap-1 rounded border border-border/50 px-3 py-1.5 text-xs hover:bg-accent transition-colors`,children:[(0,R.jsx)(S,{className:`h-3.5 w-3.5`}),` Edit learned.md`]}),(0,R.jsxs)(`button`,{type:`button`,onClick:()=>N(i),className:`inline-flex items-center gap-1 rounded border border-primary/40 bg-primary/5 px-3 py-1.5 text-xs text-primary hover:bg-primary/10 transition-colors`,children:[(0,R.jsx)(u,{className:`h-3.5 w-3.5`}),` Runtime policy`]}),(0,R.jsxs)(`button`,{type:`button`,onClick:()=>M(i,`config`),className:`inline-flex items-center gap-1 rounded border border-border/50 px-3 py-1.5 text-xs hover:bg-accent transition-colors`,children:[(0,R.jsx)(x,{className:`h-3.5 w-3.5`}),` Edit config.json`]})]}),v&&(0,R.jsx)(`p`,{className:`text-xs text-destructive`,children:v}),p&&(0,R.jsx)(G,{initialConfig:p,systemProtected:j,saving:h,onSave:P,onCancel:()=>m(null)},i),o&&(0,R.jsxs)(`div`,{className:`space-y-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,R.jsxs)(`span`,{className:`text-xs font-medium`,children:[o,`.md / `,o,`.json`]}),(0,R.jsxs)(`div`,{className:`flex gap-1`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:F,disabled: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:h?`Saving…`:`Save`}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>s(null),className:`inline-flex items-center gap-1 rounded border border-border/50 px-3 py-1.5 text-xs hover:bg-accent transition-colors`,children:`Cancel`})]})]}),(0,R.jsx)(`textarea`,{className:`w-full h-48 font-mono text-xs p-2 bg-card border border-border rounded resize-y`,value:d,onChange:e=>f(e.target.value),placeholder:o===`config`?`{ "tools": [...], "budget": {...} }`:`# Project identity for ${i}\n\nDescribe this agent's role…`})]})]})]})]})}function ae({className:e}){let[t,n]=(0,L.useState)(`live`),[r,i]=(0,L.useState)(Date.now()),{customStats:o,catalog:s,rosterLoading:c,rosterError:l,loadRoster:u}=re();return(0,L.useEffect)(()=>{let e=setInterval(()=>{document.hidden||i(Date.now())},2e3);return()=>clearInterval(e)},[]),(0,R.jsxs)(`div`,{className:A(`flex h-full min-h-0 min-w-0 w-full flex-col overflow-hidden`,e),children:[(0,R.jsx)(J,{customStats:o,rosterLoading:c,onRefresh:u}),(0,R.jsx)(Y,{activeTab:t,onTabChange:n}),(0,R.jsxs)(`div`,{className:`flex min-h-0 min-w-0 w-full flex-1 overflow-hidden bg-background/50`,children:[l&&(0,R.jsxs)(`div`,{className:`flex items-center justify-center w-full text-destructive text-xs gap-2`,children:[(0,R.jsx)(a,{className:`h-4 w-4`}),l,(0,R.jsx)(`button`,{type:`button`,onClick:u,className:`underline`,children:`Retry`})]}),t===`live`&&(0,R.jsx)(te,{nowTick:r}),t===`catalog`&&(0,R.jsx)(ee,{customStats:o,catalog:s}),t===`learning`&&(0,R.jsx)(X,{customStats:o,onRefresh:u}),t===`customize`&&(0,R.jsx)(ie,{customStats:o,catalog:s,onRefresh:u})]})]})}export{ae as AgentRosterView};
@@ -1,3 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Cn as t,Ft as n,Rr as r,Tt as i,Xt as a,an as o,dt as s,gi as c,jt as l,lt as u,vn as d,za as f}from"./vendor-BuarzSSb.js";import{t as p}from"./useWebSocket-Bc4S0N4r.js";import{t as m}from"./utils-B-9lSDIn.js";import{a as h,i as g,n as _,o as v,r as y,t as b}from"./dialog-ftgTihmF.js";import{t as x}from"./button-Dcy288Mc.js";import{t as S}from"./input-fo9-BPBC.js";import{C,S as w}from"./index-DHdO0CRE.js";import{g as T,i as E,r as D,y as O}from"./shared-KAzksK0C.js";var k=e(f(),1),A=u();function j(e){if(!Array.isArray(e))return;let t=[...new Set(e.filter(e=>typeof e==`string`).map(e=>e.trim()).filter(Boolean))];return t.length>0?t:void 0}function M(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e,n={roles:j(t.roles),taskTypes:j(t.taskTypes),modes:j(t.modes)};return n.roles||n.taskTypes||n.modes?n:void 0}function ee(e){let t=e.trim().replace(/^```(?:json)?\s*/i,``).replace(/\s*```$/,``),n=JSON.parse(t);if(!Array.isArray(n))throw Error(`Input must be a JSON array.`);let r=[],i=0;for(let e of n){if(!e||typeof e!=`object`||Array.isArray(e)){i++;continue}let t=e,n=typeof t.text==`string`?t.text.trim():``,a=M(t.audience);if(!n||!a){i++;continue}let o=typeof t.kind==`string`&&E.some(e=>e===t.kind)?t.kind:void 0,s=j(t.tags);r.push({text:n,audience:a,kind:o,tags:s,importance:typeof t.importance==`number`?t.importance:void 0,confidence:typeof t.confidence==`number`?t.confidence:void 0})}return{entries:r,skipped:i}}function N(e,t){if(!t)return!0;let n=e.audience;return[e.text,e.kind,e.status,...n?.roles??[],...n?.taskTypes??[],...n?.modes??[]].join(` `).toLocaleLowerCase().includes(t.toLocaleLowerCase())}function P(e,t){return[...new Set(e.flatMap(e=>e.audience?.[t]??[]).filter(e=>e.length>0))].sort((e,t)=>e.localeCompare(t))}function F(){let e=p(),[a,u]=(0,k.useState)([]),[f,E]=(0,k.useState)(!0),[D,O]=(0,k.useState)(null),[j,M]=(0,k.useState)(``),[F,R]=(0,k.useState)(!1),[B,V]=(0,k.useState)(!1),[H,U]=(0,k.useState)(null),[W,G]=(0,k.useState)(!1),[K,q]=(0,k.useState)(!1),J=(0,k.useRef)(null),Y=(0,k.useCallback)(()=>{E(!0),O(null),e.listSageMemories({echoToChat:!1})},[e.listSageMemories]);(0,k.useEffect)(()=>{let t=e.client,n=t.on(`memory.sage.list`,e=>{let t=e.payload;t.error?O({tone:`error`,text:t.error}):u(t.memories??[]),E(!1)}),r=t.on(`memory.sage.remember`,e=>{let t=e.payload;if(G(!1),t.error){O({tone:`error`,text:t.error});return}t.memory&&(u(e=>[t.memory,...e.filter(e=>e.id!==t.memory.id)]),R(!1))}),i=t.on(`memory.sage.update`,e=>{let t=e.payload;t.error?O({tone:`error`,text:t.error}):t.memory&&(u(e=>e.map(e=>e.id===t.memory.id?t.memory:e)),t.memory.audience||O({tone:`success`,text:`Audience scope removed. The memory is now general.`}))}),a=t.on(`memory.sage.delete`,e=>{let t=e.payload,n=J.current;t.success&&n?(u(e=>e.filter(e=>e.id!==n)),O({tone:`success`,text:`Audience memory deleted.`}),U(null),q(!1),J.current=null):t.success?Y():(O({tone:`error`,text:t.message??`Could not delete the memory.`}),q(!1),J.current=null)});return Y(),()=>{n(),r(),i(),a()}},[Y,e.client]);let X=(0,k.useMemo)(()=>a.filter(e=>{let t=e.audience;return!!(t&&(t.roles?.length||t.taskTypes?.length||t.modes?.length))}),[a]),Z=j.trim(),Q=(0,k.useMemo)(()=>X.filter(e=>N(e,Z)),[Z,X]),$=C(Q,16,Z),ie=(0,k.useMemo)(()=>P(X,`roles`),[X]),ae=(0,k.useMemo)(()=>P(X,`taskTypes`),[X]),oe=(0,k.useMemo)(()=>P(X,`modes`),[X]),se=t=>{O(null),e.updateSage(t,{audience:void 0},{echoToChat:!1})},ce=()=>{H&&(J.current=H,q(!0),O(null),e.deleteSage(H,`Removed from the audience memory panel.`))},le=async()=>{let e=X.map(e=>({id:e.id,text:e.text,kind:e.kind,status:e.status,audience:e.audience,tags:e.tags,importance:e.importance,confidence:e.confidence}));try{if(!navigator.clipboard)throw Error(`Clipboard access is unavailable.`);await navigator.clipboard.writeText(JSON.stringify(e,null,2)),O({tone:`success`,text:`${e.length} audience memor${e.length===1?`y`:`ies`} copied as JSON.`})}catch(e){O({tone:`error`,text:e instanceof Error?e.message:`Failed to copy JSON to the clipboard.`})}};return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col bg-card/20`,"aria-labelledby":`audience-memory-title`,children:[(0,A.jsxs)(`div`,{className:`shrink-0 border-b border-border/60 p-3`,children:[(0,A.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,A.jsx)(`div`,{className:`min-w-0`,children:(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center rounded-md border border-primary/20 bg-primary/10 text-primary`,children:(0,A.jsx)(n,{className:`size-3.5`})}),(0,A.jsxs)(`div`,{className:`min-w-0`,children:[(0,A.jsx)(`h2`,{id:`audience-memory-title`,className:`truncate text-sm font-semibold`,children:`Audience Memory`}),(0,A.jsx)(`p`,{className:`truncate text-[10px] text-muted-foreground`,children:`Guidance routed to matching agents`})]})]})}),(0,A.jsxs)(x,{variant:`default`,size:`sm`,className:`h-7 shrink-0 gap-1 px-2 text-xs`,onClick:()=>R(!0),children:[(0,A.jsx)(t,{className:`size-3`}),`Add`]})]}),(0,A.jsxs)(`div`,{className:`mt-3 grid grid-cols-4 gap-px overflow-hidden rounded-md border border-border/60 bg-border/60`,children:[(0,A.jsx)(I,{value:X.length,label:`Memories`}),(0,A.jsx)(I,{value:ie.length,label:`Roles`}),(0,A.jsx)(I,{value:ae.length,label:`Tasks`}),(0,A.jsx)(I,{value:oe.length,label:`Modes`})]}),(0,A.jsxs)(`div`,{className:`mt-3 flex items-center gap-1.5`,children:[(0,A.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,A.jsx)(o,{className:`pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,A.jsx)(S,{value:j,onChange:e=>M(e.target.value),placeholder:`Search text, role, task or mode…`,"aria-label":`Search audience memories`,className:`h-8 pl-8 pr-8 text-xs`}),j&&(0,A.jsx)(`button`,{type:`button`,className:`absolute right-2 top-1/2 -translate-y-1/2 rounded-sm p-0.5 text-muted-foreground hover:text-foreground`,onClick:()=>M(``),"aria-label":`Clear audience memory search`,children:(0,A.jsx)(s,{className:`size-3`})})]}),(0,A.jsx)(x,{variant:`ghost`,size:`icon`,className:`size-8 shrink-0`,onClick:Y,"aria-label":`Refresh audience memories`,title:`Refresh`,children:(0,A.jsx)(d,{className:m(`size-3.5`,f&&`animate-spin`)})}),(0,A.jsx)(x,{variant:`ghost`,size:`icon`,className:`size-8 shrink-0`,onClick:()=>V(!0),"aria-label":`Import audience memories`,title:`Import JSON`,children:(0,A.jsx)(i,{className:`size-3.5`})}),(0,A.jsx)(x,{variant:`ghost`,size:`icon`,className:`size-8 shrink-0`,onClick:()=>void le(),"aria-label":`Copy audience memories as JSON`,title:`Copy JSON`,disabled:X.length===0,children:(0,A.jsx)(c,{className:`size-3.5`})})]})]}),D&&(0,A.jsxs)(`div`,{role:D.tone===`error`?`alert`:`status`,className:m(`mx-3 mt-3 flex shrink-0 items-start justify-between gap-2 rounded-md border px-2.5 py-2 text-[11px]`,D.tone===`error`?`border-destructive/30 bg-destructive/5 text-destructive`:`border-success/30 bg-success/5 text-success`),children:[(0,A.jsx)(`span`,{children:D.text}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>O(null),className:`shrink-0 rounded-sm opacity-70 hover:opacity-100`,"aria-label":`Dismiss message`,children:(0,A.jsx)(s,{className:`size-3`})})]}),(0,A.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[!f&&X.length>0&&(0,A.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between px-3 pb-1.5 pt-3 text-[10px] text-muted-foreground`,children:[(0,A.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,A.jsx)(r,{className:`size-3`}),Z?`${Q.length} of ${X.length}`:`${X.length} scoped`]}),Z&&(0,A.jsx)(`button`,{type:`button`,className:`hover:text-foreground`,onClick:()=>M(``),children:`Clear filter`})]}),(0,A.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-3`,children:[f?(0,A.jsx)(z,{}):X.length===0?(0,A.jsx)(te,{onAdd:()=>R(!0)}):Q.length===0?(0,A.jsxs)(`div`,{className:`flex h-full min-h-32 flex-col items-center justify-center px-4 text-center`,children:[(0,A.jsx)(o,{className:`mb-2 size-5 text-muted-foreground/60`}),(0,A.jsx)(`p`,{className:`text-xs font-medium`,children:`No matching memories`}),(0,A.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:`Try another role, task, mode, or phrase.`}),(0,A.jsx)(x,{variant:`ghost`,size:`sm`,className:`mt-2 h-7 text-xs`,onClick:()=>M(``),children:`Clear search`})]}):(0,A.jsx)(`ul`,{className:`space-y-2`,children:$.pageItems.map(e=>(0,A.jsx)(L,{memory:e,onFilter:M,onClearScope:()=>se(e.id),onDelete:()=>U(e.id)},e.id))}),(0,A.jsx)(w,{page:$.page,pageSize:$.pageSize,totalItems:$.totalItems,onPageChange:$.setPage,compact:!0,itemLabel:`memories`})]})]})]}),(0,A.jsx)(ne,{open:F,busy:W,onOpenChange:e=>{W||R(e)},onCreate:t=>{O(null),G(!0),e.rememberSage({text:t.text,kind:t.kind,audience:{roles:t.roles.length>0?t.roles:void 0,taskTypes:t.taskTypes.length>0?t.taskTypes:void 0,modes:t.modes.length>0?t.modes:void 0}},{echoToChat:!1})}}),(0,A.jsx)(re,{open:B,onOpenChange:V,onImport:t=>{try{let{entries:n,skipped:r}=ee(t);if(n.length===0)return O({tone:`error`,text:`No valid audience-scoped memories were found in the JSON.`}),!1;for(let t of n)e.rememberSage(t,{echoToChat:!1});return O({tone:`success`,text:`${n.length} memor${n.length===1?`y`:`ies`} queued for import${r?`; ${r} invalid ${r===1?`entry was`:`entries were`} skipped`:``}.`}),V(!1),!0}catch(e){return O({tone:`error`,text:e instanceof Error?e.message:`Invalid JSON.`}),!1}}}),(0,A.jsx)(b,{open:!!H,onOpenChange:e=>{!e&&!K&&U(null)},children:(0,A.jsxs)(_,{className:`max-w-md`,children:[(0,A.jsxs)(h,{children:[(0,A.jsx)(v,{children:`Delete this audience memory?`}),(0,A.jsx)(y,{children:`This removes the memory from active use. To keep it as general project guidance, cancel and use the un-scope action instead.`})]}),(0,A.jsx)(`div`,{className:`rounded-md border border-border/70 bg-background/45 p-3 text-xs text-muted-foreground`,children:T(a.find(e=>e.id===H)?.text??``,180)}),(0,A.jsxs)(g,{children:[(0,A.jsx)(x,{variant:`outline`,onClick:()=>U(null),disabled:K,children:`Cancel`}),(0,A.jsxs)(x,{variant:`destructive`,onClick:ce,disabled:K,children:[(0,A.jsx)(l,{className:`size-4`}),K?`Deleting…`:`Delete memory`]})]})]})})]})}function I({value:e,label:t}){return(0,A.jsxs)(`div`,{className:`bg-card/95 px-1.5 py-2 text-center`,children:[(0,A.jsx)(`p`,{className:`text-sm font-semibold tabular-nums`,children:e}),(0,A.jsx)(`p`,{className:`truncate text-[9px] uppercase tracking-wide text-muted-foreground`,children:t})]})}function L({memory:e,onFilter:t,onClearScope:n,onDelete:r}){return(0,A.jsxs)(`li`,{className:`group rounded-md border border-border/65 bg-card/55 p-2.5 transition-colors hover:border-border hover:bg-card/85`,children:[(0,A.jsx)(`p`,{className:`break-words text-xs leading-5`,children:e.text}),e.audience&&(0,A.jsx)(R,{audience:e.audience,onFilter:t}),(0,A.jsxs)(`div`,{className:`mt-2 flex items-center justify-between gap-2 border-t border-border/45 pt-2`,children:[(0,A.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-[9px] uppercase tracking-wide text-muted-foreground`,children:[(0,A.jsx)(`span`,{className:`truncate`,children:D[e.kind]??e.kind}),(0,A.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,A.jsx)(`span`,{children:e.status})]}),(0,A.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[(0,A.jsx)(x,{variant:`ghost`,size:`icon`,className:`size-6`,onClick:n,"aria-label":`Remove audience scope from ${T(e.text,42)}`,title:`Make general memory`,children:(0,A.jsx)(a,{className:`size-3`})}),(0,A.jsx)(x,{variant:`ghost`,size:`icon`,className:`size-6 text-destructive hover:text-destructive`,onClick:r,"aria-label":`Delete ${T(e.text,42)}`,title:`Delete`,children:(0,A.jsx)(l,{className:`size-3`})})]})]})]})}function R({audience:e,onFilter:t}){return(0,A.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[...(e.roles??[]).map(e=>({label:`role`,value:e})),...(e.taskTypes??[]).map(e=>({label:`task`,value:e})),...(e.modes??[]).map(e=>({label:`mode`,value:e}))].map(({label:e,value:n})=>(0,A.jsxs)(`button`,{type:`button`,className:`max-w-full truncate rounded border border-primary/15 bg-primary/7 px-1.5 py-0.5 font-mono text-[9px] text-primary/90 transition-colors hover:border-primary/35 hover:bg-primary/12`,onClick:()=>t(n),title:`Filter by ${e}: ${n}`,children:[e,`:`,n]},`${e}:${n}`))})}function z(){return(0,A.jsx)(`div`,{className:`space-y-2 pt-3`,role:`status`,"aria-label":`Loading audience memories`,children:[0,1,2].map(e=>(0,A.jsxs)(`div`,{className:`animate-pulse rounded-md border border-border/50 p-3`,children:[(0,A.jsx)(`div`,{className:`h-2.5 w-full rounded bg-muted`}),(0,A.jsx)(`div`,{className:`mt-2 h-2.5 w-2/3 rounded bg-muted`}),(0,A.jsx)(`div`,{className:`mt-3 h-4 w-24 rounded bg-muted`})]},e))})}function te({onAdd:e}){return(0,A.jsxs)(`div`,{className:`flex h-full min-h-44 flex-col items-center justify-center px-5 text-center`,children:[(0,A.jsx)(`span`,{className:`mb-3 flex size-10 items-center justify-center rounded-full border border-dashed border-primary/35 bg-primary/5 text-primary`,children:(0,A.jsx)(n,{className:`size-4`})}),(0,A.jsx)(`p`,{className:`text-xs font-medium`,children:`Route guidance to the right agents`}),(0,A.jsx)(`p`,{className:`mt-1 max-w-52 text-[10px] leading-4 text-muted-foreground`,children:`Scope a memory by role, task type, or operating mode. Matching agents receive it automatically.`}),(0,A.jsxs)(x,{variant:`outline`,size:`sm`,className:`mt-3 h-7 gap-1 text-xs`,onClick:e,children:[(0,A.jsx)(t,{className:`size-3`}),`Add scoped memory`]})]})}function ne({open:e,busy:t,onOpenChange:n,onCreate:r}){let[i,a]=(0,k.useState)(``),[o,s]=(0,k.useState)(`workflow`),[c,l]=(0,k.useState)(``),[u,d]=(0,k.useState)(``),[f,p]=(0,k.useState)(``);(0,k.useEffect)(()=>{e||(a(``),s(`workflow`),l(``),d(``),p(``))},[e]);let m=O(c),S=O(u),C=O(f),w=i.trim().length>0&&(m.length>0||S.length>0||C.length>0);return(0,A.jsx)(b,{open:e,onOpenChange:n,children:(0,A.jsxs)(_,{className:`max-w-xl`,children:[(0,A.jsxs)(h,{children:[(0,A.jsx)(v,{children:`Add audience-scoped memory`}),(0,A.jsx)(y,{children:`This guidance is injected only when an agent matches at least one supplied selector.`})]}),(0,A.jsxs)(`div`,{className:`space-y-4`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{htmlFor:`audience-memory-text`,className:`mb-1.5 block text-xs font-medium`,children:`Memory`}),(0,A.jsx)(`textarea`,{id:`audience-memory-text`,value:i,onChange:e=>a(e.target.value),placeholder:`What should matching agents remember?`,rows:4,autoFocus:!0,className:`w-full resize-y rounded-md border border-input bg-background px-3 py-2 text-sm outline-none placeholder:text-muted-foreground focus-visible:ring-2 focus-visible:ring-ring`})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{htmlFor:`audience-memory-kind`,className:`mb-1.5 block text-xs font-medium`,children:`Kind`}),(0,A.jsx)(`select`,{id:`audience-memory-kind`,value:o,onChange:e=>s(e.target.value),className:`h-9 w-full rounded-md border border-input bg-background px-3 text-xs outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:E.map(e=>(0,A.jsx)(`option`,{value:e,children:D[e]??e},e))})]}),(0,A.jsxs)(`fieldset`,{className:`space-y-3 rounded-md border border-border/70 bg-background/35 p-3`,children:[(0,A.jsx)(`legend`,{className:`px-1 text-xs font-medium`,children:`Audience selectors`}),(0,A.jsx)(B,{id:`audience-memory-roles`,label:`Roles`,value:c,onChange:l,placeholder:`reviewer, refactor-planner`}),(0,A.jsx)(B,{id:`audience-memory-task-types`,label:`Task types`,value:u,onChange:d,placeholder:`review, refactor, bugfix`}),(0,A.jsx)(B,{id:`audience-memory-modes`,label:`Modes`,value:f,onChange:p,placeholder:`teach, code-review`}),(0,A.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Comma-separate multiple values. At least one selector is required.`})]})]}),(0,A.jsxs)(g,{children:[(0,A.jsx)(x,{variant:`outline`,onClick:()=>n(!1),disabled:t,children:`Cancel`}),(0,A.jsx)(x,{onClick:()=>r({text:i.trim(),kind:o,roles:m,taskTypes:S,modes:C}),disabled:!w||t,children:t?`Remembering…`:`Remember`})]})]})})}function B({id:e,label:t,value:n,placeholder:r,onChange:i}){return(0,A.jsxs)(`div`,{className:`grid gap-1.5 sm:grid-cols-[6rem_1fr] sm:items-center`,children:[(0,A.jsx)(`label`,{htmlFor:e,className:`text-[11px] font-medium text-muted-foreground`,children:t}),(0,A.jsx)(S,{id:e,value:n,onChange:e=>i(e.target.value),placeholder:r,className:`h-8 font-mono text-xs`})]})}function re({open:e,onOpenChange:t,onImport:n}){let[r,a]=(0,k.useState)(``);return(0,k.useEffect)(()=>{e||a(``)},[e]),(0,A.jsx)(b,{open:e,onOpenChange:t,children:(0,A.jsxs)(_,{className:`max-w-xl`,children:[(0,A.jsxs)(h,{children:[(0,A.jsx)(v,{children:`Import audience memories`}),(0,A.jsxs)(y,{children:[`Paste the JSON produced here or by `,(0,A.jsx)(`code`,{children:`/memory audience export`}),`. Entries without a valid audience selector are skipped.`]})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{htmlFor:`audience-memory-import`,className:`mb-1.5 block text-xs font-medium`,children:`JSON array`}),(0,A.jsx)(`textarea`,{id:`audience-memory-import`,value:r,onChange:e=>a(e.target.value),placeholder:`[
2
- { "text": "…", "audience": { "roles": ["reviewer"] } }
3
- ]`,rows:10,autoFocus:!0,spellCheck:!1,className:`w-full resize-y rounded-md border border-input bg-background p-3 font-mono text-xs outline-none placeholder:text-muted-foreground focus-visible:ring-2 focus-visible:ring-ring`})]}),(0,A.jsxs)(g,{children:[(0,A.jsx)(x,{variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,A.jsxs)(x,{onClick:()=>n(r),disabled:!r.trim(),children:[(0,A.jsx)(i,{className:`size-4`}),`Import memories`]})]})]})})}export{F as AudienceMemoryPanel};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{$i as t,Ei as n,Pa as r,b as i,dn as a,ir as o,lt as s,ri as c,un as l,vn as u,za as d}from"./vendor-BuarzSSb.js";import"./i18n-B0hsnanh.js";import{a as f,n as p,t as m}from"./monaco-BLUV5g0U.js";import{t as h}from"./ws-client-DqFoX4jJ.js";import{t as g}from"./utils-B-9lSDIn.js";import{P as _,v}from"./stores-BptlyD_v.js";import{b as y}from"./index-DHdO0CRE.js";import{t as b}from"./empty-state-RRSqQaCk.js";import{t as x}from"./monaco-theme-DSeCDzQy.js";var S=e(d(),1),C=s();p.config({monaco:m});var w={ts:`typescript`,tsx:`typescript`,js:`javascript`,jsx:`javascript`,mjs:`javascript`,json:`json`,css:`css`,scss:`scss`,html:`html`,md:`markdown`,py:`python`,go:`go`,rs:`rust`,java:`java`,c:`c`,cpp:`cpp`,cs:`csharp`,rb:`ruby`,php:`php`,sh:`shell`,bash:`shell`,yml:`yaml`,yaml:`yaml`,toml:`toml`,sql:`sql`};function T(e){return w[e.split(`.`).pop()?.toLowerCase()??``]??`plaintext`}function E({path:e,oldText:n,newText:a}){let{t:s}=r(),c=(0,S.useRef)(null),[u,d]=(0,S.useState)(!1),[p,m]=(0,S.useState)(!1),[g,v]=(0,S.useState)(null);(0,S.useEffect)(()=>{d(!1),m(!1),v(null)},[]);let y=(0,S.useCallback)(e=>{c.current=e,f.setTheme(x()),e.getModifiedEditor().onDidChangeModelContent(()=>d(!0))},[]),b=(0,S.useCallback)(()=>{let t=c.current?.getModifiedEditor().getValue();if(t==null)return;m(!0);let n=h(_.getState().wsUrl),r=n.on(`files.written`,t=>{t.type===`files.written`&&t.payload.filePath===e&&(r(),clearTimeout(i),m(!1),t.payload.success&&(d(!1),v(Date.now())))}),i=setTimeout(()=>{r(),m(!1)},5e3);n.send({type:`files.write`,payload:{filePath:e,content:t}})},[e]),w=T(e);return(0,C.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,C.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2 px-2 py-1.5 border-b border-border/40`,children:[(0,C.jsx)(`span`,{className:`text-xs font-mono text-muted-foreground truncate`,children:e}),(0,C.jsxs)(`button`,{type:`button`,onClick:b,disabled:!u||p,className:`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-md border border-border text-xs font-medium disabled:opacity-40 enabled:hover:bg-muted transition-colors`,title:s(`activity:monacoDiff.applyTitle`),children:[p?(0,C.jsx)(o,{className:`h-3.5 w-3.5 animate-spin`}):g&&!u?(0,C.jsx)(t,{className:`h-3.5 w-3.5 text-success`}):(0,C.jsx)(l,{className:`h-3.5 w-3.5`}),s(p?`activity:monacoDiff.applying`:g&&!u?`activity:monacoDiff.applied`:`activity:monacoDiff.apply`)]})]}),(0,C.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-hidden`,children:(0,C.jsx)(i,{original:n,modified:a,language:w,theme:x(),onMount:y,options:{renderSideBySide:!0,readOnly:!1,originalEditable:!1,minimap:{enabled:!1},fontSize:13,scrollBeyondLastLine:!1,automaticLayout:!0}})})]})}var D=1e4;function O({className:e}){let{t}=r(),i=v(e=>e.selectedPath),s=v(e=>e.diff),l=v(e=>e.loadingDiff),[d,f]=(0,S.useState)(`unified`),[p,m]=(0,S.useState)(!1),x=!!i&&(l||!s);(0,S.useEffect)(()=>{if(m(!1),!x)return;let e=setTimeout(()=>m(!0),D);return()=>clearTimeout(e)},[x,i]);let w=()=>{i&&(m(!1),v.getState().setDiffLoading(!0),h(_.getState().wsUrl).getGitDiff?.(i))};if(!i)return(0,C.jsx)(b,{icon:(0,C.jsx)(c,{className:`h-6 w-6`}),title:`Source changes`,description:t(`activity:changes.selectPrompt`),className:e});let T=s&&!s.error&&!s.binary&&!s.tooLarge;return(0,C.jsx)(`div`,{className:g(`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-[hsl(var(--surface-2)/0.45)] p-3`,e),children:(0,C.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-border/70 bg-card/75 shadow-sm`,children:[(0,C.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-2 border-b border-border/70 px-3 py-2`,children:[(0,C.jsxs)(`div`,{className:`min-w-0`,children:[(0,C.jsx)(`div`,{className:`text-[10px] font-semibold uppercase text-muted-foreground`,children:`Source control`}),(0,C.jsx)(`div`,{className:`truncate font-mono text-xs text-foreground`,title:i,children:i})]}),T&&(0,C.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,C.jsxs)(`button`,{type:`button`,onClick:()=>f(`unified`),title:t(`activity:changes.unifiedTitle`),className:g(`inline-flex h-8 items-center gap-1 rounded-md border px-2 text-xs transition-colors`,d===`unified`?`border-primary/40 bg-primary/10 text-primary`:`border-border text-muted-foreground hover:bg-muted`),children:[(0,C.jsx)(a,{className:`h-3.5 w-3.5`}),` `,t(`activity:changes.unified`)]}),(0,C.jsxs)(`button`,{type:`button`,onClick:()=>f(`edit`),title:t(`activity:changes.editTitle`),className:g(`inline-flex h-8 items-center gap-1 rounded-md border px-2 text-xs transition-colors`,d===`edit`?`border-primary/40 bg-primary/10 text-primary`:`border-border text-muted-foreground hover:bg-muted`),children:[(0,C.jsx)(n,{className:`h-3.5 w-3.5`}),` `,t(`activity:changes.edit`)]})]})]}),(0,C.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:l||!s?p?(0,C.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center gap-3 p-4 text-center`,children:[(0,C.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t(`activity:changes.diffTimeout`)}),(0,C.jsxs)(`button`,{type:`button`,onClick:w,className:`inline-flex h-8 items-center gap-1.5 rounded-md border border-border px-3 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:[(0,C.jsx)(u,{className:`h-3.5 w-3.5`}),` `,t(`common:action.retry`)]})]}):(0,C.jsxs)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,C.jsx)(o,{className:`h-4 w-4 animate-spin`}),` `,t(`activity:changes.loadingDiff`)]}):s.error?(0,C.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-sm text-destructive`,children:s.error}):s.binary?(0,C.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-sm text-muted-foreground`,children:t(`activity:changes.binary`)}):s.tooLarge?(0,C.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-sm text-muted-foreground`,children:t(`activity:changes.tooLarge`)}):d===`edit`?(0,C.jsx)(E,{path:s.path,oldText:s.oldText??``,newText:s.newText??``},s.path):(0,C.jsx)(y,{oldText:s.oldText,newText:s.newText,caption:s.path,fill:!0})})]})})}export{O as ChangesView};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Nr as t,Oa as n,Ot as r,Rr as i,Vt as a,Xi as o,Zt as s,an as c,dt as l,ji as ee,la as u,lt as d,mn as te,oa as f,oi as p,ur as ne,vi as m,vn as re,za as h}from"./vendor-BuarzSSb.js";import{t as ie}from"./ws-client-DqFoX4jJ.js";import{t as g}from"./utils-B-9lSDIn.js";import{C as ae,S as oe}from"./index-DHdO0CRE.js";var _=e(h(),1),v=d();function se({status:e}){return(0,v.jsxs)(`section`,{className:`flex flex-wrap gap-x-5 gap-y-1 border-b border-border/60 bg-primary/[0.025] px-4 py-1.5 font-mono text-[9px] text-muted-foreground`,title:e.chronicleDirectory,children:[(0,v.jsx)(`span`,{className:`font-sans font-semibold uppercase tracking-wider text-primary`,children:`Chronicle ownership`}),(0,v.jsxs)(`span`,{children:[`collect `,(0,v.jsx)(`b`,{className:`text-foreground`,children:e.pipeline.collection})]}),(0,v.jsxs)(`span`,{children:[`process `,(0,v.jsx)(`b`,{className:`text-foreground`,children:e.pipeline.processing})]}),(0,v.jsxs)(`span`,{children:[`serve `,(0,v.jsx)(`b`,{className:`text-foreground`,children:e.pipeline.serving})]}),(0,v.jsxs)(`span`,{children:[`PID `,(0,v.jsx)(`b`,{className:`text-foreground`,children:e.pid}),` · `,e.clients,` clients`]}),(0,v.jsxs)(`span`,{children:[`watcher`,` `,(0,v.jsx)(`b`,{className:g(e.watcher.active?`text-success`:`text-warning`),children:e.watcher.active?`active`:`inactive`}),` `,`· `,e.watcher.watchedFiles,` files`]}),(0,v.jsxs)(`span`,{children:[`store `,(0,v.jsx)(`b`,{className:`text-foreground`,children:y(e.pipeline.storage)})]}),e.mode===`inline`&&(0,v.jsx)(`span`,{className:`font-sans font-semibold text-warning`,children:`INLINE FALLBACK`})]})}function y(e){return e.replaceAll(`\\`,`/`).split(`/`).filter(Boolean).slice(-3).join(`/`)}var b=[`eventType`,`providerId`,`modelId`,`outcome`,`resourceKind`],x=1440*60*1e3;function S(){return{limit:300,order:`desc`,from:new Date(Date.now()-x).toISOString()}}var ce=[{id:`all`,label:`All signals`,icon:(0,v.jsx)(n,{})},{id:`llm`,label:`LLM`,icon:(0,v.jsx)(f,{})},{id:`agents`,label:`Agents`,icon:(0,v.jsx)(u,{})},{id:`tools`,label:`Tools`,icon:(0,v.jsx)(a,{})},{id:`files`,label:`Files`,icon:(0,v.jsx)(p,{})},{id:`failures`,label:`Failures`,icon:(0,v.jsx)(r,{})}];function C(){let e=ie(),[t,n]=(0,_.useState)([]),[r,o]=(0,_.useState)(null),[s,d]=(0,_.useState)({}),[m,h]=(0,_.useState)(S()),[y,x]=(0,_.useState)({text:``,path:``,providerId:``,modelId:``,sessionId:``}),[C,w]=(0,_.useState)(`all`),[k,P]=(0,_.useState)({total:0,scannedEvents:0,sourceFiles:0,invalidLines:0}),[I,de]=(0,_.useState)(T),[L,R]=(0,_.useState)(!0),[z,B]=(0,_.useState)(null),[V,H]=(0,_.useState)(null),[U,fe]=(0,_.useState)([]),[W,pe]=(0,_.useState)([]),[G,me]=(0,_.useState)(null),K=(0,_.useCallback)(t=>{if(!e.supportsCapability(`chronicle.query`)){R(!1),B(`Restart the backend once to activate Chronicle protocol support.`);return}if(R(!0),B(null),h(t),d({}),e.send({type:`chronicle.query`,payload:{query:t}}),e.supportsCapability(`chronicle.facets`))e.send({type:`chronicle.facets`,payload:{fields:[...b],query:t,limit:12}});else for(let n of b)e.send({type:`chronicle.facet`,payload:{field:n,query:t,limit:12}})},[e]),q=(0,_.useCallback)(()=>{e.supportsCapability(`chronicle.metrics`)&&(e.send({type:`chronicle.metrics`,payload:{view:`providers`}}),e.send({type:`chronicle.metrics`,payload:{view:`tasks`,limit:200}}))},[e]),J=(0,_.useCallback)(()=>{e.supportsCapability(`chronicle.status`)&&e.send({type:`chronicle.status`})},[e]);(0,_.useEffect)(()=>{let t=e.on(`chronicle.query_result`,e=>{e.type===`chronicle.query_result`&&(n(e.payload.events),P(e.payload),de(e.payload.summary??T),R(!1))}),r=e.on(`chronicle.facet_result`,e=>{e.type===`chronicle.facet_result`&&d(t=>({...t,[e.payload.field]:e.payload.values}))}),i=e.on(`chronicle.facets_result`,e=>{e.type===`chronicle.facets_result`&&d(e.payload.values)}),a=e.on(`chronicle.error`,e=>{e.type===`chronicle.error`&&(B(e.payload.message),R(!1))}),o=e.on(`chronicle.graph_result`,e=>{e.type===`chronicle.graph_result`&&H(e.payload)}),s=e.on(`chronicle.metrics_result`,e=>{e.type===`chronicle.metrics_result`&&(e.payload.view===`providers`?fe(e.payload.data):e.payload.view===`tasks`&&pe(e.payload.data))}),c=e.on(`chronicle.status_result`,e=>{e.type===`chronicle.status_result`&&me(e.payload)});return K(S()),q(),J(),()=>{t(),r(),i(),a(),o(),s(),c()}},[e,K,q,J]);let Y=(0,_.useMemo)(()=>t.filter(e=>O(e,C)),[t,C]),X=ae(Y,25,C),Z=(0,_.useMemo)(()=>{let e=t.find(e=>e.eventType===`metrics.rollup`&&e.attributes?.signal===`runtime.health`)?.attributes?.stats;if(!e)return;let n=t=>e[t]?.last;return{eventLoop:{utilization:n(`eventLoop.utilization`),delayP95Ms:n(`eventLoop.delayP95Ms`)},memory:{heapUsedBytes:n(`memory.heapUsedBytes`)},chronicle:{pendingEvents:n(`chronicle.pendingEvents`),rejectedEvents:n(`chronicle.rejectedEvents`)}}},[t]),Q=(0,_.useMemo)(()=>{let e={};for(let t of W)e[t.status]=(e[t.status]??0)+1;let t=(e.completed??0)+(e.merged??0)+(e.failed??0)+(e.conflict??0),n=(e.completed??0)+(e.merged??0),r=[...W].sort((e,t)=>(t.endedAt??t.startedAt??``).localeCompare(e.endedAt??e.startedAt??``)).slice(0,8);return{counts:e,total:W.length,terminal:t,successRate:t>0?n/t*100:100,recent:r}},[W]),$=()=>K({...S(),...y.text?{text:y.text}:{},...y.path?{path:y.path}:{},...y.providerId?{providerId:y.providerId}:{},...y.modelId?{modelId:y.modelId}:{},...y.sessionId?{sessionId:y.sessionId}:{}}),he=()=>{x({text:``,path:``,providerId:``,modelId:``,sessionId:``}),w(`all`),K(S())},ge=t=>{o(t),H(null),e.supportsCapability(`chronicle.graph`)&&e.send({type:`chronicle.graph`,payload:{seed:{eventId:t.eventId},hops:2,maxNodes:250}})};return(0,v.jsxs)(`div`,{className:`flex h-full min-h-0 bg-background`,"data-testid":`chronicle-dashboard`,children:[(0,v.jsxs)(`main`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,v.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,v.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,v.jsxs)(`div`,{children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,v.jsx)(f,{className:`h-5 w-5 text-primary`}),(0,v.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight`,children:`Coding Intelligence`}),(0,v.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,v.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`LLM, agent, tool and file evidence — connected from decision to code change.`})]}),(0,v.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,v.jsx)(`span`,{className:g(`h-2 w-2 rounded-full`,z?`bg-destructive`:L?`animate-pulse bg-warning`:`bg-success`)}),(0,v.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:L?`Reading journal`:z?`Unavailable`:`Live evidence`}),(0,v.jsx)(`button`,{type:`button`,onClick:()=>{K(m),q(),J()},className:`ml-2 rounded-md border border-border bg-card p-2 hover:bg-muted`,title:`Refresh evidence`,children:(0,v.jsx)(re,{className:g(`h-4 w-4`,L&&`animate-spin`)})})]})]})}),(0,v.jsxs)(`section`,{className:`grid grid-cols-2 border-b border-border/70 xl:grid-cols-6`,children:[(0,v.jsx)(M,{icon:(0,v.jsx)(f,{}),label:`LLM requests`,value:I.logicalRequests,detail:`${I.modelAttempts} attempts · ${I.providers} providers · ${I.models} models`}),(0,v.jsx)(M,{icon:(0,v.jsx)(u,{}),label:`Agent work`,value:I.agentEvents,detail:`${I.uniqueAgents} correlated agents · ${I.decisions} decisions`}),(0,v.jsx)(M,{icon:(0,v.jsx)(a,{}),label:`Tool calls`,value:I.toolCalls,detail:`${I.failedTools} failed · ${I.processes} processes`}),(0,v.jsx)(M,{icon:(0,v.jsx)(p,{}),label:`File evidence`,value:I.fileEvents,detail:`${I.uniqueFiles} unique paths`}),(0,v.jsx)(M,{icon:(0,v.jsx)(te,{}),label:`Retries`,value:I.scheduledRetries,detail:`${I.failures} failures · ${I.fallbacks} fallbacks`,tone:I.failures?`danger`:`normal`}),(0,v.jsx)(M,{icon:(0,v.jsx)(ee,{}),label:`Provider p95`,value:A(I.providerP95DurationMs),detail:`${A(I.providerAvgDurationMs)} average · all matches`})]}),(0,v.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,v.jsx)(`span`,{className:`font-sans font-semibold uppercase tracking-wider text-primary`,children:`Token economics`}),(0,v.jsxs)(`span`,{children:[`fresh input `,(0,v.jsx)(`b`,{className:`text-foreground`,children:I.inputTokens.toLocaleString()})]}),(0,v.jsxs)(`span`,{children:[`output `,(0,v.jsx)(`b`,{className:`text-foreground`,children:I.outputTokens.toLocaleString()})]}),(0,v.jsxs)(`span`,{children:[`cache read `,(0,v.jsx)(`b`,{className:`text-foreground`,children:I.cacheReadTokens.toLocaleString()})]}),(0,v.jsxs)(`span`,{children:[`cache write`,` `,(0,v.jsx)(`b`,{className:`text-foreground`,children:I.cacheWriteTokens.toLocaleString()})]}),(0,v.jsxs)(`span`,{children:[`cache hit `,(0,v.jsxs)(`b`,{className:`text-foreground`,children:[D(I).toFixed(1),`%`]})]}),(0,v.jsxs)(`span`,{children:[`estimated cost `,(0,v.jsxs)(`b`,{className:`text-foreground`,children:[`$`,I.estimatedCostUsd.toFixed(4)]})]})]}),U.length>0&&(0,v.jsxs)(`section`,{className:`flex items-center gap-3 overflow-x-auto border-b border-border/60 bg-muted/[0.14] px-4 py-1.5`,children:[(0,v.jsx)(`span`,{className:`shrink-0 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:`Model reliability`}),U.slice(0,6).map(e=>{let t=e.completed+e.failed,n=t>0?e.completed/t*100:100;return(0,v.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 rounded-full border border-border bg-card px-2.5 py-0.5 font-mono text-[9px]`,title:`${e.day} · ${e.attempts} attempts · avg ${A(e.avgDurationMs)} · ${e.inputTokens.toLocaleString()} in / ${e.outputTokens.toLocaleString()} out`,children:[(0,v.jsx)(`span`,{className:g(`h-1.5 w-1.5 rounded-full`,n>=99?`bg-success`:n>=90?`bg-warning`:`bg-destructive`)}),(0,v.jsxs)(`span`,{className:`max-w-[180px] truncate`,children:[e.providerId,`/`,e.modelId]}),(0,v.jsxs)(`b`,{className:`text-foreground`,children:[n.toFixed(0),`%`]}),(0,v.jsx)(`span`,{className:`text-muted-foreground`,children:e.day.slice(5)})]},`${e.day}-${e.providerId}-${e.modelId}`)})]}),Q.total>0&&(0,v.jsxs)(`section`,{className:`flex items-center gap-3 overflow-x-auto border-b border-border/60 bg-muted/[0.10] px-4 py-1.5`,children:[(0,v.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,v.jsx)(ne,{className:`h-3 w-3`}),`Task outcomes`]}),(0,v.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 rounded-full border border-border bg-card px-2.5 py-0.5 font-mono text-[9px]`,title:`${Q.total} tasks tracked · ${Q.terminal} finished`,children:[(0,v.jsx)(`span`,{className:g(`h-1.5 w-1.5 rounded-full`,Q.successRate>=90?`bg-success`:Q.successRate>=60?`bg-warning`:`bg-destructive`)}),(0,v.jsxs)(`b`,{className:`text-foreground`,children:[Q.successRate.toFixed(0),`%`]}),(0,v.jsxs)(`span`,{className:`text-muted-foreground`,children:[`success · `,Q.total,` tasks`]})]}),[`completed`,`merged`,`failed`,`conflict`,`started`].filter(e=>Q.counts[e]).map(e=>(0,v.jsxs)(`span`,{className:`shrink-0 font-mono text-[9px] text-muted-foreground`,children:[e,` `,(0,v.jsx)(`b`,{className:g(e===`failed`||e===`conflict`?`text-destructive`:`text-foreground`),children:Q.counts[e]})]},e)),(0,v.jsx)(`span`,{className:`mx-1 h-3 w-px shrink-0 bg-border`}),Q.recent.map(e=>(0,v.jsxs)(`button`,{type:`button`,onClick:()=>K({limit:300,order:`desc`,taskId:e.taskId}),className:`flex shrink-0 items-center gap-1.5 rounded-full border border-border bg-card px-2 py-0.5 font-mono text-[9px] hover:border-primary/50`,title:`${e.taskId}${e.boardId?` · board ${e.boardId}`:``}${e.sessionId?` · ${e.sessionId}`:``} · ${e.filesTouched} files${e.retries?` · ${e.retries} retries`:``}${e.verificationFailures?` · ${e.verificationFailures} verify-fails`:``}`,children:[(0,v.jsx)(`span`,{className:g(`h-1.5 w-1.5 rounded-full`,e.status===`completed`||e.status===`merged`?`bg-success`:e.status===`failed`||e.status===`conflict`?`bg-destructive`:`bg-primary`)}),(0,v.jsx)(`span`,{className:`max-w-[84px] truncate`,children:e.taskId}),e.durationMs!==null&&(0,v.jsx)(`span`,{className:`text-muted-foreground`,children:A(e.durationMs)}),e.filesTouched>0&&(0,v.jsxs)(`span`,{className:`flex items-center gap-0.5 text-muted-foreground`,children:[(0,v.jsx)(p,{className:`h-2.5 w-2.5`}),e.filesTouched]})]},e.taskId))]}),(0,v.jsx)(`section`,{className:`border-b border-border/70 px-4 py-3`,children:(0,v.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 xl:grid-cols-[1.35fr_1fr_1fr_1fr_1fr_auto]`,children:[(0,v.jsx)(j,{icon:(0,v.jsx)(c,{}),placeholder:`Search event evidence`,value:y.text,onChange:e=>x(t=>({...t,text:e})),onEnter:$}),(0,v.jsx)(j,{placeholder:`File or directory`,value:y.path,onChange:e=>x(t=>({...t,path:e})),onEnter:$}),(0,v.jsx)(j,{placeholder:`Provider`,value:y.providerId,onChange:e=>x(t=>({...t,providerId:e})),onEnter:$}),(0,v.jsx)(j,{placeholder:`Model`,value:y.modelId,onChange:e=>x(t=>({...t,modelId:e})),onEnter:$}),(0,v.jsx)(j,{placeholder:`Session`,value:y.sessionId,onChange:e=>x(t=>({...t,sessionId:e})),onEnter:$}),(0,v.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,v.jsxs)(`button`,{type:`button`,onClick:$,className:`rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground`,children:[(0,v.jsx)(i,{className:`mr-1 inline h-3 w-3`}),`Apply`]}),(0,v.jsx)(`button`,{type:`button`,onClick:he,className:`rounded-md border border-border px-2.5 text-xs hover:bg-muted`,children:`Clear`})]})]})}),(0,v.jsxs)(`section`,{className:`flex items-center gap-1 overflow-x-auto border-b border-border/70 px-4 py-2`,children:[ce.map(e=>(0,v.jsxs)(`button`,{type:`button`,onClick:()=>w(e.id),className:g(`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`,C===e.id?`bg-primary/10 font-medium text-primary`:`text-muted-foreground hover:bg-muted hover:text-foreground`),children:[e.icon,e.label,(0,v.jsx)(`span`,{className:`ml-1 rounded bg-background/70 px-1 font-mono text-[9px]`,children:E(I,e.id,k.total)})]},e.id)),(0,v.jsxs)(`div`,{className:`ml-auto hidden items-center gap-3 pl-4 text-[9px] text-muted-foreground lg:flex`,children:[(0,v.jsxs)(`span`,{children:[k.total.toLocaleString(),` matched`]}),(0,v.jsxs)(`span`,{children:[k.sourceFiles,` journal files`]}),k.invalidLines>0&&(0,v.jsxs)(`span`,{className:`text-warning`,children:[k.invalidLines,` invalid lines`]})]})]}),G&&(0,v.jsx)(se,{status:G}),Z&&(0,v.jsx)(le,{health:Z}),(0,v.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,v.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,v.jsx)(`span`,{className:`mr-1 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e.replace(`Id`,``)}),(s[e]??[]).slice(0,4).map(t=>(0,v.jsxs)(`button`,{type:`button`,onClick:()=>K({...m,[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,v.jsx)(`b`,{children:t.count})]},t.value))]},e))}),(0,v.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,v.jsx)(`span`,{children:`Time`}),(0,v.jsx)(`span`,{children:`Signal`}),(0,v.jsx)(`span`,{children:`Outcome`}),(0,v.jsx)(`span`,{children:`Model / agent`}),(0,v.jsx)(`span`,{children:`Resource`}),(0,v.jsx)(`span`,{})]}),(0,v.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:z?(0,v.jsx)(F,{text:z}):!L&&Y.length===0?(0,v.jsx)(F,{text:`No coding evidence matches these filters.`}):(0,v.jsx)(`div`,{className:`divide-y divide-border/40`,children:X.pageItems.map(e=>(0,v.jsx)(ue,{event:e,active:r?.eventId===e.eventId,onClick:()=>ge(e)},e.eventId))})}),(0,v.jsx)(oe,{page:X.page,pageSize:X.pageSize,totalItems:X.totalItems,onPageChange:X.setPage,itemLabel:`events`})]}),r&&(0,v.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,v.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,v.jsxs)(`div`,{children:[(0,v.jsx)(`div`,{className:`text-xs font-semibold`,children:`Evidence & lineage`}),(0,v.jsxs)(`div`,{className:`mt-0.5 font-mono text-[9px] text-muted-foreground`,children:[`#`,r.sequence,` · `,r.eventId]})]}),(0,v.jsx)(`button`,{type:`button`,onClick:()=>o(null),className:`rounded p-1 hover:bg-muted`,children:(0,v.jsx)(l,{className:`h-4 w-4`})})]}),(0,v.jsx)(N,{event:r,graph:V})]})]})}var w={llm:0,agent:0,tool:0,file:0,memory:0,task:0,decision:0,runtime:0},T={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:{...w},failuresByFamily:{...w}};function E(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 D(e){let t=e.inputTokens+e.cacheReadTokens;return t?e.cacheReadTokens/t*100:0}function O(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 k(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 A(e){return e?e<1?`${(e*1e3).toFixed(0)}µs`:e<1e3?`${e.toFixed(1)}ms`:`${(e/1e3).toFixed(1)}s`:`—`}function j({placeholder:e,value:t,onChange:n,onEnter:r,icon:i}){return(0,v.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,v.jsx)(`span`,{className:`text-muted-foreground [&>svg]:h-3.5 [&>svg]:w-3.5`,children:i}),(0,v.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 M({icon:e,label:t,value:n,detail:r,tone:i=`normal`}){return(0,v.jsxs)(`div`,{className:`min-w-0 border-r border-border/60 px-4 py-3`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:[(0,v.jsx)(`span`,{className:`text-primary [&>svg]:h-3.5 [&>svg]:w-3.5`,children:e}),t]}),(0,v.jsx)(`div`,{className:g(`mt-1 text-xl font-semibold tabular-nums`,i===`danger`&&`text-destructive`),children:typeof n==`number`?n.toLocaleString():n}),(0,v.jsx)(`div`,{className:`mt-0.5 truncate text-[9px] text-muted-foreground`,children:r})]})}function le({health:e}){return(0,v.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,v.jsx)(`span`,{className:`font-sans font-semibold uppercase tracking-wider text-success`,children:`Collector healthy`}),(0,v.jsxs)(`span`,{children:[`ELU`,` `,(0,v.jsxs)(`b`,{className:`text-foreground`,children:[((e.eventLoop?.utilization??0)*100).toFixed(1),`%`]})]}),(0,v.jsxs)(`span`,{children:[`p95 `,(0,v.jsxs)(`b`,{className:`text-foreground`,children:[(e.eventLoop?.delayP95Ms??0).toFixed(1),`ms`]})]}),(0,v.jsxs)(`span`,{children:[`heap`,` `,(0,v.jsxs)(`b`,{className:`text-foreground`,children:[((e.memory?.heapUsedBytes??0)/1048576).toFixed(0),`MB`]})]}),(0,v.jsxs)(`span`,{children:[`queue `,(0,v.jsx)(`b`,{className:`text-foreground`,children:e.chronicle?.pendingEvents??0})]}),(0,v.jsxs)(`span`,{children:[`dropped`,` `,(0,v.jsx)(`b`,{className:g((e.chronicle?.rejectedEvents??0)>0&&`text-destructive`),children:e.chronicle?.rejectedEvents??0})]})]})}function ue({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,v.jsxs)(`button`,{type:`button`,onClick:n,className:g(`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,v.jsx)(`span`,{className:`font-mono text-[9px] text-muted-foreground`,children:new Date(r).toLocaleTimeString()}),(0,v.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,v.jsx)(`span`,{className:g(`h-1.5 w-1.5 shrink-0 rounded-full`,e.outcome===`failure`?`bg-destructive`:e.outcome===`success`?`bg-success`:`bg-primary`)}),(0,v.jsx)(`span`,{className:`truncate font-mono text-[11px] font-medium`,children:e.eventType})]}),(0,v.jsx)(`span`,{className:g(`w-fit rounded px-1.5 py-0.5 text-[9px]`,I(e.outcome)),children:e.outcome??`unknown`}),(0,v.jsx)(`span`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:i}),(0,v.jsx)(`span`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:a}),(0,v.jsx)(o,{className:`h-3.5 w-3.5 text-muted-foreground`})]})}function N({event:e,graph:n}){let r=(0,_.useMemo)(()=>[[`Scope`,e.scope],[`Correlation`,e.correlation],[`Runtime`,e.runtime],[`Resource`,e.resource],[`Attributes`,e.attributes],[`Tags`,e.tags]],[e]);return(0,v.jsxs)(`div`,{className:`p-4`,children:[(0,v.jsxs)(`div`,{className:`mb-4 rounded-lg border border-border bg-background/60 p-3`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,v.jsx)(`span`,{className:g(`h-2 w-2 rounded-full`,e.outcome===`failure`?`bg-destructive`:e.outcome===`success`?`bg-success`:`bg-primary`)}),(0,v.jsx)(`span`,{className:`font-mono text-xs font-semibold`,children:e.eventType})]}),(0,v.jsxs)(`div`,{className:`mt-2 flex gap-4 text-[9px] text-muted-foreground`,children:[(0,v.jsx)(`span`,{children:new Date(e.occurredAt??e.observedAt).toLocaleString()}),(0,v.jsx)(`span`,{children:k(Number(e.durationNs??0))})]})]}),(0,v.jsxs)(`div`,{className:`mb-4 grid grid-cols-2 gap-2`,children:[(0,v.jsx)(P,{icon:(0,v.jsx)(s,{}),label:`Evidence hash`,value:e.hash.slice(0,16)}),(0,v.jsx)(P,{icon:(0,v.jsx)(m,{}),label:`Sequence`,value:String(e.sequence)})]}),n&&(0,v.jsxs)(`section`,{className:`mb-4`,children:[(0,v.jsxs)(`h3`,{className:`mb-1.5 flex items-center gap-1 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,v.jsx)(t,{className:`h-3 w-3`}),`Lineage · `,n.nodes.length,` nodes · `,n.edges.length,` edges`]}),(0,v.jsx)(`div`,{className:`space-y-1 rounded-md border border-border bg-background/70 p-2`,children:n.edges.slice(0,40).map((e,t)=>(0,v.jsxs)(`div`,{className:`flex items-center gap-2 font-mono text-[9px]`,children:[(0,v.jsx)(`span`,{className:g(`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,v.jsx)(`span`,{className:`text-muted-foreground`,children:e.kind}),(0,v.jsxs)(`span`,{className:`truncate`,children:[n.nodes.find(t=>t.eventId===e.from)?.eventType,` →`,` `,n.nodes.find(t=>t.eventId===e.to)?.eventType]})]},`${e.from}-${e.to}-${e.kind}-${t}`))}),n.truncated&&(0,v.jsx)(`p`,{className:`mt-1 text-[9px] text-warning`,children:`Lineage truncated at safety limit.`})]}),r.map(([e,t])=>t&&(0,v.jsxs)(`section`,{className:`mb-4`,children:[(0,v.jsx)(`h3`,{className:`mb-1.5 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e}),(0,v.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 P({icon:e,label:t,value:n}){return(0,v.jsxs)(`div`,{className:`rounded-md border border-border p-2`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-1 text-[8px] uppercase text-muted-foreground`,children:[(0,v.jsx)(`span`,{className:`[&>svg]:h-3 [&>svg]:w-3`,children:e}),t]}),(0,v.jsx)(`div`,{className:`mt-1 truncate font-mono text-[9px]`,children:n})]})}function F({text:e}){return(0,v.jsx)(`div`,{className:`flex h-48 items-center justify-center text-sm text-muted-foreground`,children:e})}function I(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{C as ChronicleDashboard};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Fi as t,Nr as n,Oa as r,Pa as i,Qi as a,Qt as o,Ui as s,Vt as c,Xr as l,Yi as u,ar as d,dt as f,in as p,ir as m,la as h,lt as g,ri as _,si as v,vn as y,y as b,yt as x,za as S}from"./vendor-BuarzSSb.js";import"./i18n-B0hsnanh.js";import{a as C,i as w,n as T,o as E,r as D,t as O}from"./monaco-BLUV5g0U.js";import{t as ee}from"./ws-client-DqFoX4jJ.js";import{t as k}from"./utils-B-9lSDIn.js";import{i as te}from"./codemap-activity-store-DQfjo7-j.js";import{P as ne,c as re,f as ie,j as A,k as j}from"./stores-BptlyD_v.js";import{o as M}from"./view-navigation-DxfiZrXS.js";import{A as N,b as ae,x as P}from"./index-DHdO0CRE.js";import{t as F}from"./empty-state-RRSqQaCk.js";import{t as I}from"./monaco-theme-DSeCDzQy.js";var L={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`},R=Array.from(new Set(Object.values(L))).filter(e=>e!==`plaintext`),z=12e3,B=4e3,oe=5e3,V=1e4;function H(e){return L[e.split(`.`).pop()?.toLowerCase()??``]??`plaintext`}function U(e){return e.match(/([A-Za-z_$][\w$]*)$/)?.[1]??``}function W(e,t){return e.triggerCharacter?!0:t.length>=3}function G(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 K(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 q=e(S(),1),J=g();function se(e){let t=new Set,n=new Set,r=new Set,i=new Set,a=new Set,o,s;for(let c of e)c.sessionId&&t.add(c.sessionId),c.taskId&&n.add(c.taskId),c.boardId&&r.add(c.boardId),c.toolName&&i.add(c.toolName),c.modelId&&a.add(c.modelId),(!o||c.occurredAt<o)&&(o=c.occurredAt),(!s||c.occurredAt>s)&&(s=c.occurredAt);return{mutations:e.length,sessions:t.size,tasks:n.size,boards:r.size,tools:[...i],models:[...a],firstAt:o,lastAt:s}}var Y=150,ce=224,le=38,X=/(write|edit|update|create|delete|rename|modified|changed)/i;function Z(e){return e.replace(/\\/g,`/`).replace(/^\.\//,``).replace(/\/{2,}/g,`/`).toLowerCase()}function Q(e,t){let n=Z(e),r=Z(t);return n===r||n.endsWith(`/${r}`)||r.endsWith(`/${n}`)}function ue(e,t=Date.now()){let n=e.filter(e=>t-e.at<=30*6e4),r=n.filter(e=>X.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 $(e){return typeof e==`string`&&e.length>0?e:void 0}function de(e){let t=Date.parse(e.occurredAt??e.observedAt);return Number.isFinite(t)?t:Date.now()}function fe(e){let t=e.attributes??{},n=$(t.operation)??e.eventType,r=e.scope.agentId,i=e.runtime?.providerId,a=e.runtime?.modelId;return{id:e.eventId,at:de(e),action:n,actor:r??i??$(t.actor)??`external`,source:$(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??$(t.taskId),boardId:$(t.boardId)??e.scope.boardId,tool:$(t.toolName),status:e.outcome,raw:e}}function pe(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 me(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 he(e){return e?e.split(/\r?\n/).length:0}function ge(e){return new TextEncoder().encode(e).length}function _e(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function ve(e){return e.length>18?`${e.slice(0,8)}…${e.slice(-6)}`:e}function ye(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 be({file:e}){let{t}=i(),[o,l]=(0,q.useState)(!0),[f,p]=(0,q.useState)(ce),[m,h]=(0,q.useState)(`overview`),[g,b]=(0,q.useState)([]),[x,S]=(0,q.useState)([]),[C,w]=(0,q.useState)(!1),[T,E]=(0,q.useState)(null),[D,O]=(0,q.useState)(null),A=(0,q.useRef)(null),j=ne(e=>e.wsUrl),M=te(e=>e.history),N=te(e=>e.activeOperations),P=ie(e=>e.activeBoard),F=re(e=>e.snapshot),I=(0,q.useMemo)(()=>ee(j),[j]),L=(0,q.useCallback)(()=>{E(null),w(!0),typeof I.getGitDiff==`function`&&I.getGitDiff(e.path);let t=typeof I.supportsCapability==`function`?I.supportsCapability.bind(I):null;t?.(`chronicle.query`)?I.send({type:`chronicle.query`,payload:{query:{path:e.path,resourceKind:`file`,order:`desc`,limit:150}}}):w(!1),t?.(`chronicle.metrics`)&&I.send({type:`chronicle.metrics`,payload:{view:`files`,path:e.path,limit:1e3}})},[I,e.path]);(0,q.useEffect)(()=>{b([]),S([]),O(null);let t=I.on(`chronicle.query_result`,t=>{if(t.type!==`chronicle.query_result`)return;let n=t.payload.events.filter(t=>t.resource?.path&&Q(t.resource.path,e.path));t.payload.events.length>0&&n.length===0||(b(n),w(!1))}),n=I.on(`chronicle.metrics_result`,t=>{t.type!==`chronicle.metrics_result`||t.payload.view!==`files`||S(t.payload.data.filter(t=>Q(t.path,e.path)))}),r=I.on(`chronicle.error`,e=>{e.type===`chronicle.error`&&(E(e.payload.message),w(!1))}),i=I.on(`git.diff`,t=>{if(t.type!==`git.diff`||!Q(t.payload.path,e.path))return;let n=t.payload;if(n.error||n.binary||n.tooLarge){O({text:e.savedContent,available:!1,error:n.error});return}O({text:n.oldText??``,available:!0})});return L(),()=>{t(),n(),r(),i()}},[I,e.path,e.savedContent,L]),(0,q.useEffect)(()=>{let e=e=>{if(!A.current)return;let t=A.current.startY-e.clientY,n=Math.max(Y,Math.floor(window.innerHeight*.62));p(Math.min(n,Math.max(Y,A.current.startHeight+t)))},t=()=>{A.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 R=(0,q.useMemo)(()=>{let t=[];for(let[n,r]of M)Q(n,e.path)&&t.push(...r);for(let n of N.values())t.push(...n.filter(t=>Q(t.filePath,e.path)));return t},[N,e.path,M]),z=(0,q.useMemo)(()=>me([...R.map(pe),...g.map(fe)]),[g,R]),B=(0,q.useMemo)(()=>ue(z),[z]),oe=(0,q.useMemo)(()=>se(x),[x]),V=D?.text??e.savedContent,H=(0,q.useMemo)(()=>ye(V,e.content),[V,e.content]),U=(0,q.useMemo)(()=>[...new Set(z.map(e=>e.sessionId).filter(e=>!!e))],[z]),W=(0,q.useMemo)(()=>[...new Set(z.map(e=>e.actor).filter(Boolean))],[z]),G=(0,q.useMemo)(()=>[...new Set(z.map(e=>e.taskId).filter(e=>!!e))],[z]),K=(0,q.useCallback)(e=>{let t=P?.tasks.find(t=>t.id===e),n=F?.tasks.find(t=>t.id===e||t.shortId===e);return t?.title??n?.title??e},[P,F]),X=e=>{o||l(!0),A.current={startY:e.clientY,startHeight:o?f:Y},document.body.style.cursor=`ns-resize`,document.body.style.userSelect=`none`},Z=[{id:`overview`,label:t(`activity:fileActivity.overview`),icon:(0,J.jsx)(r,{})},{id:`changes`,label:t(`activity:fileActivity.changes`),icon:(0,J.jsx)(_,{})},{id:`context`,label:t(`activity:fileActivity.context`),icon:(0,J.jsx)(d,{})},{id:`logs`,label:t(`activity:fileActivity.logs`),icon:(0,J.jsx)(c,{})}];return(0,J.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:o?f:le},"data-testid":`file-activity-drawer`,children:[(0,J.jsx)(`button`,{type:`button`,"aria-label":t(`activity:fileActivity.resizeHint`),className:`group relative block h-2 w-full cursor-ns-resize touch-none`,onPointerDown:X,onDoubleClick:()=>{l(!0),p(ce)},title:t(`activity:fileActivity.resizeHint`),children:(0,J.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,J.jsxs)(`header`,{className:`flex h-[30px] min-w-0 items-center gap-2 border-b border-border/70 px-2.5`,children:[(0,J.jsxs)(`button`,{type:`button`,onClick:()=>l(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":o,children:[(0,J.jsx)(v,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,J.jsx)(`span`,{className:`truncate`,children:t(`activity:fileActivity.title`)}),o?(0,J.jsx)(a,{className:`h-3 w-3`}):(0,J.jsx)(u,{className:`h-3 w-3`})]}),(0,J.jsx)(`span`,{className:`hidden h-3 w-px bg-border sm:block`}),(0,J.jsx)(xe,{label:`${he(e.content)} ${t(`activity:fileActivity.lines`)}`}),(0,J.jsx)(xe,{label:_e(ge(e.content))}),!H.large&&(H.added>0||H.removed>0)&&(0,J.jsxs)(`span`,{className:`hidden items-center gap-1 font-mono text-[10px] md:flex`,children:[(0,J.jsxs)(`span`,{className:`text-success`,children:[`+`,H.added]}),(0,J.jsxs)(`span`,{className:`text-destructive`,children:[`−`,H.removed]})]}),(0,J.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`,B.level===`churn`&&`bg-destructive/10 text-destructive`,B.level===`active`&&`bg-warning/10 text-warning`,B.level===`quiet`&&`bg-success/10 text-success`),children:[(0,J.jsx)(s,{className:`h-2.5 w-2.5`}),t(`activity:fileActivity.level.${B.level}`)]}),(0,J.jsx)(`span`,{className:`hidden text-[9px] text-muted-foreground lg:inline`,children:t(`activity:fileActivity.evidenceCount`,{count:z.length})}),o&&(0,J.jsx)(`button`,{type:`button`,onClick:L,className:`rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground`,title:t(`activity:fileActivity.refresh`),children:(0,J.jsx)(y,{className:k(`h-3.5 w-3.5`,C&&`animate-spin`)})})]}),o&&(0,J.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,J.jsxs)(`nav`,{className:`flex shrink-0 items-center gap-0.5 border-b border-border/60 bg-muted/20 px-2`,children:[Z.map(e=>(0,J.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`,m===e.id?`border-primary font-medium text-foreground`:`border-transparent text-muted-foreground hover:text-foreground`),children:[e.icon,e.label]},e.id)),T&&(0,J.jsx)(`span`,{className:`ml-auto truncate px-2 text-[9px] text-warning`,children:T})]}),(0,J.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:[m===`overview`&&(0,J.jsx)(Se,{analysis:B,lifetime:oe,records:z,sessions:U,agents:W,tasks:G,taskLabel:K}),m===`changes`&&(0,J.jsxs)(`div`,{className:`h-full min-h-[120px] p-2`,children:[(0,J.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-2 text-[9px] text-muted-foreground`,children:[(0,J.jsx)(n,{className:`h-3 w-3`}),(0,J.jsx)(`span`,{children:D?.available?t(`activity:fileActivity.gitToBuffer`):t(`activity:fileActivity.savedToBuffer`)}),e.dirty&&(0,J.jsx)(`span`,{className:`rounded bg-warning/10 px-1.5 py-0.5 text-warning`,children:t(`activity:fileActivity.unsaved`)}),D?.error&&(0,J.jsx)(`span`,{className:`truncate text-warning`,children:D.error})]}),(0,J.jsx)(`div`,{className:`h-[calc(100%-24px)] min-h-[90px]`,children:(0,J.jsx)(ae,{oldText:V,newText:e.content,caption:e.path,fill:!0})})]}),m===`context`&&(0,J.jsx)(we,{sessions:U,agents:W,tasks:G,records:z,taskLabel:K,boardTitle:P?.title??F?.title}),m===`logs`&&(0,J.jsx)(De,{records:z,loading:C})]})]})]})}function xe({label:e}){return(0,J.jsx)(`span`,{className:`hidden whitespace-nowrap font-mono text-[9px] text-muted-foreground sm:inline`,children:e})}function Se({analysis:e,lifetime:t,records:n,sessions:r,agents:a,tasks:s,taskLabel:c}){let{t:l}=i();return(0,J.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,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(`div`,{className:`grid grid-cols-4 gap-1.5`,children:[{label:l(`activity:fileActivity.mutations30m`),value:e.mutationCount,icon:(0,J.jsx)(_,{})},{label:l(`activity:fileActivity.sessions`),value:r.length,icon:(0,J.jsx)(x,{})},{label:l(`activity:fileActivity.actors`),value:a.length,icon:(0,J.jsx)(h,{})},{label:l(`activity:fileActivity.linkedWork`),value:s.length,icon:(0,J.jsx)(d,{})}].map(e=>(0,J.jsxs)(`div`,{className:`rounded-md border border-border/70 bg-background/45 px-2 py-1.5`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1 text-[9px] text-muted-foreground [&>svg]:h-3 [&>svg]:w-3`,children:[e.icon,(0,J.jsx)(`span`,{className:`truncate`,children:e.label})]}),(0,J.jsx)(`div`,{className:`mt-0.5 font-mono text-sm font-semibold`,children:e.value})]},e.label))}),t.mutations>0&&(0,J.jsx)(Ce,{lifetime:t}),(0,J.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,J.jsx)(o,{className:k(`mt-0.5 h-3.5 w-3.5 shrink-0`,e.level===`churn`?`text-destructive`:`text-primary`)}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`font-semibold`,children:l(`activity:fileActivity.analysisTitle.${e.level}`)}),(0,J.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,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 text-[9px]`,children:[(0,J.jsxs)(`span`,{className:`text-muted-foreground`,children:[l(`activity:fileActivity.workLinks`),`:`]}),s.slice(0,4).map(e=>(0,J.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,J.jsxs)(`div`,{className:`min-w-0 rounded-md border border-border/70 bg-background/35`,children:[(0,J.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,J.jsx)(`div`,{className:`divide-y divide-border/40`,children:n.length===0?(0,J.jsx)(ke,{text:l(`activity:fileActivity.noEvidence`)}):n.slice(0,5).map(e=>(0,J.jsx)(Oe,{record:e},`${e.id}:${e.at}`))})]})]})}function Ce({lifetime:e}){let{t}=i(),n=[{value:e.mutations,label:t(`activity:fileActivity.lifetimeChanges`)},{value:e.sessions,label:t(`activity:fileActivity.lifetimeSessions`)},{value:e.tasks,label:t(`activity:fileActivity.lifetimeTasks`)},{value:e.boards,label:t(`activity:fileActivity.lifetimeBoards`)}],r=e.firstAt?new Date(e.firstAt).toLocaleDateString():void 0;return(0,J.jsxs)(`div`,{className:`rounded-md border border-primary/15 bg-primary/[0.03] px-2.5 py-2`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[9px] font-semibold uppercase tracking-wider text-primary [&>svg]:h-3 [&>svg]:w-3`,children:[(0,J.jsx)(v,{}),t(`activity:fileActivity.lifetimeTitle`)]}),(0,J.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-x-3 gap-y-1 font-mono text-[9px] text-muted-foreground`,children:[n.map(e=>(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`b`,{className:`text-foreground`,children:e.value.toLocaleString()}),` `,e.label]},e.label)),r&&(0,J.jsx)(`span`,{children:t(`activity:fileActivity.lifetimeSince`,{date:r})})]}),e.tools.length>0&&(0,J.jsx)(`div`,{className:`mt-1 truncate font-mono text-[8px] text-muted-foreground`,title:e.tools.join(`, `),children:t(`activity:fileActivity.lifetimeTools`,{tools:e.tools.slice(0,6).join(`, `)})})]})}function we({sessions:e,agents:t,tasks:n,records:r,taskLabel:a,boardTitle:o}){let{t:s}=i();return(0,J.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,J.jsx)(Te,{icon:(0,J.jsx)(x,{}),title:s(`activity:fileActivity.sessions`),empty:s(`activity:fileActivity.noSessions`),children:e.map(e=>(0,J.jsx)(Ee,{title:ve(e),subtitle:`${r.filter(t=>t.sessionId===e).length} ${s(`activity:fileActivity.events`)}`,raw:e},e))}),(0,J.jsx)(Te,{icon:(0,J.jsx)(h,{}),title:s(`activity:fileActivity.actors`),empty:s(`activity:fileActivity.noActors`),children:t.map(e=>(0,J.jsx)(Ee,{title:e,subtitle:`${r.filter(t=>t.actor===e).length} ${s(`activity:fileActivity.events`)}`},e))}),(0,J.jsx)(Te,{icon:(0,J.jsx)(d,{}),title:s(`activity:fileActivity.workLinks`),empty:s(`activity:fileActivity.noWorkLinks`),children:n.map(e=>(0,J.jsx)(Ee,{title:a(e),subtitle:o??s(`activity:fileActivity.taskOrTodo`),raw:e},e))})]})}function Te({icon:e,title:t,empty:n,children:r}){let i=Array.isArray(r)?r.length>0:!!r;return(0,J.jsxs)(`section`,{className:`min-w-0 p-2`,children:[(0,J.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,J.jsx)(`div`,{className:`space-y-1`,children:i?r:(0,J.jsx)(ke,{text:n})})]})}function Ee({title:e,subtitle:t,raw:n}){return(0,J.jsxs)(`div`,{className:`rounded-md border border-border/60 bg-background/45 px-2 py-1.5`,title:n,children:[(0,J.jsx)(`div`,{className:`truncate text-[10px] font-medium`,children:e}),(0,J.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-[8px] text-muted-foreground`,children:t})]})}function De({records:e,loading:t}){let{t:n}=i();return t&&e.length===0?(0,J.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-[10px] text-muted-foreground`,children:[(0,J.jsx)(m,{className:`h-3.5 w-3.5 animate-spin`}),n(`activity:fileActivity.loadingEvidence`)]}):e.length===0?(0,J.jsx)(ke,{text:n(`activity:fileActivity.noEvidence`)}):(0,J.jsx)(`div`,{className:`divide-y divide-border/40`,children:e.map(e=>(0,J.jsx)(Oe,{record:e,raw:!0},`${e.id}:${e.at}`))})}function Oe({record:e,raw:t=!1}){let n=(0,J.jsxs)(`div`,{className:`grid grid-cols-[62px_74px_minmax(90px,.7fr)_minmax(160px,1.5fr)] items-center gap-2 text-[9px]`,children:[(0,J.jsx)(`span`,{className:`font-mono text-muted-foreground`,children:new Date(e.at).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}),(0,J.jsx)(`span`,{className:k(`w-fit rounded px-1.5 py-0.5 font-mono`,X.test(e.action)?`bg-warning/10 text-warning`:`bg-primary/10 text-primary`),children:e.action}),(0,J.jsx)(`span`,{className:`truncate`,title:e.agentId,children:e.actor}),(0,J.jsx)(`span`,{className:`truncate text-muted-foreground`,title:e.summary,children:e.summary})]});return t?(0,J.jsxs)(`details`,{className:`group cursor-pointer px-2.5 py-1.5`,children:[(0,J.jsx)(`summary`,{className:`list-none [&::-webkit-details-marker]:hidden`,children:n}),(0,J.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,J.jsx)(`div`,{className:`px-2.5 py-1.5`,children:n})}function ke({text:e}){return(0,J.jsx)(`div`,{className:`px-3 py-3 text-center text-[10px] text-muted-foreground`,children:e})}T.config({monaco:O});function Ae(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 je(){let e=j(e=>e.openFiles),n=j(e=>e.activeFilePath),r=j(e=>e.setActiveFile),i=j(e=>e.closeFile);return e.length===0?null:(0,J.jsx)(`div`,{className:`flex items-center border-b bg-muted/40 overflow-x-auto shrink-0`,children:e.map(e=>{let a=e.path===n,o=e.path.split(`/`).pop()??e.path;return(0,J.jsxs)(`button`,{type:`button`,onClick:()=>r(e.path),onMouseDown:t=>{t.button===1&&(t.preventDefault(),i(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`,a?`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,J.jsx)(t,{className:`h-2 w-2 fill-current text-primary shrink-0`}),(0,J.jsx)(`span`,{className:`truncate`,children:o}),(0,J.jsx)(f,{className:k(`h-3 w-3 shrink-0 rounded-sm hover:bg-muted-foreground/20 opacity-0 group-hover:opacity-100 transition-opacity`,a&&`opacity-100`),onClick:t=>{t.stopPropagation(),i(e.path)}})]},e.path)})})}function Me(){let{t:e}=i(),t=j(e=>e.openFiles),n=j(e=>e.activeFilePath),r=j(e=>e.updateContent),{theme:a}=N(),o=(0,q.useRef)(null),s=(0,q.useRef)(n),c=(0,q.useRef)(new Map),u=(0,q.useMemo)(()=>t.find(e=>e.path===n)??null,[t,n]),d=n?H(n):`plaintext`,f=I(),[m,h]=(0,q.useState)(!1);(0,q.useEffect)(()=>{s.current=n},[n]),(0,q.useEffect)(()=>{let e=I();C.setTheme(e)},[a]),(0,q.useEffect)(()=>{let e=R.map(e=>E.registerCompletionItemProvider(e,{triggerCharacters:[`.`,`_`],provideCompletionItems:async(e,t,n,r)=>{let i=s.current;if(!i)return{suggestions:[]};let a=e.getOffsetAt(t),o=e.getValue(),l=o.slice(Math.max(0,a-z),a),u=o.slice(a,a+B),d=e.getLineContent(t.lineNumber).slice(0,Math.max(0,t.column-1)),f=U(d),p={triggerCharacter:n.triggerCharacter,triggerKind:n.triggerKind};if(!W(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(ne.getState().wsUrl),v=e=>e.map((e,t)=>({label:e.label,kind:Ae(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=K({filePath:i,language:e.getLanguageId(),lineNumber:t.lineNumber,column:t.column,versionId:e.getVersionId(),triggerCharacter:n.triggerCharacter,linePrefix:d,suffix:u}),b=c.current.get(y);return b&&b.expiresAt>Date.now()?{suggestions:v(b.items)}:await new Promise(a=>{let s=!1,d=()=>{},h=null,g,b=e=>{s||(s=!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&&(c.current.set(y,{expiresAt:Date.now()+V,items:t.payload.items}),b(v(t.payload.items)))}),g=window.setTimeout(()=>b([]),oe),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:l,suffix:u,triggerCharacter:n.triggerCharacter,triggerKind:n.triggerKind,allowLlm:G(p,f)})})}}));return()=>{e.forEach(e=>{e.dispose()})}},[]);let g=(0,q.useCallback)(()=>{let e=o.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,q.useCallback)(()=>{M(`chat`),requestAnimationFrame(()=>{document.querySelector(`[data-chat-textarea]`)?.focus()})},[]),v=(0,q.useCallback)(()=>{let e=s.current;if(!e)return;let t=g();t&&(A.getState().addRef({kind:`snippet`,path:e,startLine:t.startLine,endLine:t.endLine,content:t.content}),_())},[g,_]),y=(0,q.useCallback)(()=>{let e=s.current;e&&(A.getState().addRef({kind:`file`,path:e}),_())},[_]),x=(0,q.useCallback)(t=>{o.current=t,C.setTheme(I()),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,q.useCallback)(e=>{n&&e!==void 0&&r(n,e)},[n,r]);return(0,q.useEffect)(()=>{let e=e=>{let t=e.ctrlKey||e.metaKey,r=e.target?.tagName?.toLowerCase()===`textarea`||e.target?.closest(`.monaco-editor`)!==null;!t||!r||(e.key.toLowerCase()===`s`&&(e.preventDefault(),window.dispatchEvent(new CustomEvent(`wrongstack:save-file`,{detail:{filePath:n}}))),e.key.toLowerCase()===`w`&&(e.preventDefault(),n&&j.getState().closeFile(n)))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]),t.length===0?(0,J.jsx)(F,{title:e(`activity:codeEditor.noFilesOpen`),description:e(`activity:codeEditor.selectToEdit`)}):(0,J.jsxs)(`div`,{className:`flex h-full min-w-0 flex-col overflow-hidden`,children:[(0,J.jsx)(je,{}),(0,J.jsxs)(`div`,{className:`relative min-h-0 min-w-0 flex-1 overflow-hidden`,children:[(m||u)&&(0,J.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,J.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,J.jsx)(p,{className:`h-3 w-3`}):(0,J.jsx)(l,{className:`h-3 w-3`}),(0,J.jsx)(`span`,{children:e(m?`activity:codeEditor.sendToChat`:`activity:codeEditor.mentionFile`)})]})}),u?(0,J.jsx)(b,{language:d,value:u.content,onChange:S,theme:f,onMount:x,loading:(0,J.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,J.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,J.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,J.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:e(`activity:codeEditor.selectTab`)})})]}),u&&(0,J.jsx)(be,{file:u})]})}export{Me as CodeEditor};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Ln as t,Nr as n,Oa as r,Pt as i,Qi as a,Rn as o,Tr as s,Vr as c,Wr as l,Xi as u,Zt as d,_ as f,a as p,ai as m,an as h,c as ee,ca as g,di as _,dt as v,f as y,g as b,gr as x,h as te,i as S,ir as ne,ja as re,kn as C,lt as w,m as ie,n as ae,p as oe,r as se,s as T,u as ce,wn as le,xa as ue,yn as E,za as de,zn as D}from"./vendor-BuarzSSb.js";import{t as O}from"./utils-B-9lSDIn.js";import{i as fe,r as pe,t as me}from"./codemap-activity-store-DQfjo7-j.js";import{t as he}from"./codemap-index-store-COStDU-8.js";var k=e(de(),1),A=4096,j=new Map;function M(e){let t=j.get(e);if(t!==void 0)return t;let n=e.replace(/\\/g,`/`).replace(/^\.\//,``).toLocaleLowerCase();for(;j.size>=A;){let e=j.keys().next().value;if(e===void 0)break;j.delete(e)}return j.set(e,n),n}function N(e){return e.level===`packages`?`packages`:e.level===`files`?`files:${e.package}`:`symbols:${e.file}`}function ge(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 _e(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 ve(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 P(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 ye(e){let t=new Set(e.nodes.map(e=>e.id)),n=P(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 F(e,t){if(e.nodes.length===0)return[];let n=P(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=ve(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 be(e,t,n){return t===`orbit`?F(e,n):ye(e)}function xe(e,t,n){if(e.length<=n)return e;let r=t?e.filter(e=>e.source===t||e.target===t):[],i=e.filter(e=>!t||e.source!==t&&e.target!==t).sort((e,t)=>t.weight-e.weight||e.source.localeCompare(t.source)||e.target.localeCompare(t.target)),a=Math.max(0,n-r.length);return[...r,...i.slice(0,a)]}function Se(e,t,n){if(n===`all`)return e;let r=e.nodes;if(e.nodes.length>96){let n=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=>{n.has(e)&&o.size<96&&o.add(e)};if(t&&n.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,72),t=a.filter(e=>e.external).slice(0,24);for(let n of[...e,...t])s(n.id)}for(let e of a)s(e.id);r=e.nodes.filter(e=>o.has(e.id))}let i=new Set(r.map(e=>e.id)),a=e.edges.filter(e=>i.has(e.source)&&i.has(e.target));return{nodes:r,edges:xe(a,t,180)}}function I(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 Ce=new WeakMap;function we(e){let t=Ce.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=I(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),Ce.set(e,n),n}function Te(e){let t=2166136261,n=e=>{for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619)};for(let t of e.nodes)n(t.id);for(let r of e.edges)n(r.source),n(r.target),n(r.refType),t^=r.weight|0,t=Math.imul(t,16777619);return`${e.nodes.length}:${e.edges.length}:${t>>>0}`}function Ee(e,t,n,r){for(e.has(t)&&e.delete(t),e.set(t,n);e.size>r;){let t=e.keys().next().value;if(t===void 0)break;e.delete(t)}}function De(e,t){if(!e||!t)return!1;let n=M(e),r=M(t);return n===r||n.endsWith(`/${r}`)||r.endsWith(`/${n}`)}function Oe(e){let t=M(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 ke(e,t){return t.kind===`package`?Oe(e.filePath)===(t.package??t.label):De(e.filePath,t.file)?t.kind!==`symbol`||e.symbol?.id===t.id:!1}function Ae(e){let t=new Map;for(let n of e){let e=M(n.filePath),r=t.get(e);r?r.push(n):t.set(e,[n])}return t}function je(e,t){let n=new Map;if(t.length===0||e.length===0)return n;let r=Ae(t),i=new Map;for(let a of e){let e;if(a.kind===`package`){let n=a.package??a.label,r=i.get(n);r||(r=t.filter(e=>Oe(e.filePath)===n),i.set(n,r)),e=r}else if(a.file){let t=M(a.file),n=r.get(t);if(!n){n=[];for(let[e,i]of r)(e.endsWith(`/${t}`)||t.endsWith(`/${e}`))&&n.push(...i)}e=a.kind===`symbol`?n.filter(e=>e.symbol?.id===a.id):n}else e=[];e.length>0&&n.set(a.id,e)}return n}function Me(e){if(e.length===0)return``;let t=`${e.length}`;for(let n=0;n<e.length;n++){let r=e[n];t+=`|${r.id??``}:${r.toolUseId??``}:${r.filePath}:${r.type}:${r.status??``}:${r.symbol?.id??``}:${r.timestamp}`}return t}function Ne(e,t){let n=t.filter(t=>t.kind===`symbol`&&!t.external&&De(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 L=w();function Pe({historyFile:e,fileHistory:t,onClose:n}){return(0,L.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,L.jsxs)(`div`,{className:`flex h-12 items-center justify-between border-b px-4`,children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,L.jsx)(r,{className:`h-4 w-4 shrink-0 text-warning`}),(0,L.jsx)(`span`,{className:`truncate font-mono text-[11px] font-semibold`,title:e,children:e})]}),(0,L.jsx)(`button`,{type:`button`,onClick:n,className:`flex h-7 w-7 items-center justify-center border text-muted-foreground hover:bg-muted`,"aria-label":`Close activity`,children:(0,L.jsx)(v,{className:`h-3.5 w-3.5`})})]}),(0,L.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-3`,children:t.length===0?(0,L.jsx)(`p`,{className:`py-12 text-center text-[10px] text-muted-foreground`,children:`No activity recorded for this file yet.`}):t.map((e,t)=>(0,L.jsxs)(`div`,{className:`mb-1 flex items-start gap-2 border p-2 text-[10px]`,children:[(0,L.jsx)(`span`,{className:O(`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,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`div`,{className:`font-mono text-[9px] text-muted-foreground`,children:new Date(e.timestamp).toLocaleTimeString()}),e.toolName&&(0,L.jsxs)(`div`,{className:`mt-1`,children:[`via `,e.toolName]}),e.agent&&(0,L.jsx)(`div`,{className:`text-muted-foreground`,children:e.agent}),e.summary&&(0,L.jsx)(`div`,{className:`mt-1 text-muted-foreground`,children:e.summary}),e.change&&(0,L.jsxs)(`div`,{className:`mt-1 flex items-center gap-1 font-mono text-[8px]`,children:[(0,L.jsxs)(`span`,{className:`border border-success/40 bg-success/10 px-1 text-success`,children:[`+`,e.change.added]}),(0,L.jsxs)(`span`,{className:`border border-destructive/40 bg-destructive/10 px-1 text-destructive`,children:[`−`,e.change.removed]}),e.change.before&&(0,L.jsx)(`span`,{className:`ml-1 truncate text-destructive/80`,title:e.change.before,children:e.change.before}),e.change.after&&(0,L.jsxs)(`span`,{className:`truncate text-success/80`,title:e.change.after,children:[`→ `,e.change.after]})]}),(0,L.jsxs)(`div`,{className:`mt-1 flex gap-2 font-mono text-[8px] uppercase text-muted-foreground`,children:[(0,L.jsx)(`span`,{children:e.status??`observed`}),(0,L.jsx)(`span`,{children:e.source??`legacy`}),e.durationMs!==void 0&&(0,L.jsxs)(`span`,{children:[e.durationMs,`ms`]}),e.watcherConfirmed&&(0,L.jsx)(`span`,{className:`text-success`,children:`fs verified`})]})]})]},`${e.timestamp}-${t}`))}),(0,L.jsxs)(`div`,{className:`border-t px-4 py-2 font-mono text-[9px] text-muted-foreground`,children:[t.length,` events · newest first`]})]})}var R={package:{icon:t,accent:`border-l-primary`,iconStyle:`bg-primary/12 text-primary`},file:{icon:m,accent:`border-l-info`,iconStyle:`bg-info/12 text-info`},symbol:{icon:g,accent:`border-l-success`,iconStyle:`bg-success/12 text-success`}},Fe={call:`hsl(var(--primary))`,import:`hsl(var(--info))`,type_ref:`hsl(var(--success))`,inherit:`hsl(var(--warning))`,implement:`hsl(var(--destructive))`},Ie={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`},Le=[`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`];function Re(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 z(e){let t=0;for(let n of e)t=t*31+n.charCodeAt(0)|0;return Le[Math.abs(t)%Le.length]??Le[0]}function ze(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 B(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 V(e){return[e.symbol?.name,e.line?`L${e.line}`:void 0].filter(Boolean).join(` · `)}function Be({data:e}){let{graphNode:t,selected:n,dimmed:r,incoming:i,outgoing:a,isActive:o,activityType:s,activeOperations:c}=e,l=R[t.kind],u=l.icon,d=t.kind!==`symbol`,p=t.kind===`symbol`?`${t.symbolKind??`symbol`}${t.line?` · L${t.line}`:``}`:t.kind===`file`?I(t):`${t.fileCount??0} files · ${t.symbolCount??0} symbols`;return(0,L.jsxs)(`div`,{className:O(`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,box-shadow,border-color,background-color]`,l.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`,o&&s&&Ie[s]),children:[c.length>0&&(0,L.jsxs)(`div`,{className:`absolute -top-5 left-2 z-20 flex max-w-[210px] items-center gap-1`,children:[c.slice(0,4).map(e=>{let t=e.agentName??e.agent??`External`,n=`${e.sessionId??`none`}:${e.agentId??t}`;return(0,L.jsxs)(`span`,{className:O(`flex h-6 items-center gap-1 border-2 border-background px-1.5 font-mono text-[8px] font-bold shadow-md`,z(n)),title:`${t} · ${e.type} ${V(e)}`,children:[(0,L.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse bg-current`}),Re(t),e.symbol&&(0,L.jsx)(`span`,{className:`max-w-[80px] truncate`,children:e.symbol.name})]},e.id??`${n}:${e.filePath}`)}),c.length>4&&(0,L.jsxs)(`span`,{className:`border bg-card px-1 font-mono text-[8px] shadow`,children:[`+`,c.length-4]})]}),(0,L.jsx)(T,{type:`target`,position:f.Left,className:`!h-2.5 !w-2.5 !border-2 !border-card !bg-muted-foreground`}),(0,L.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:()=>d&&e.onOpen(t),"aria-label":`${t.kind} ${t.label}`,children:[(0,L.jsxs)(`div`,{className:`flex items-start gap-3 p-3 pr-10`,children:[(0,L.jsx)(`span`,{className:O(`flex h-8 w-8 shrink-0 items-center justify-center border`,l.iconStyle),children:(0,L.jsx)(u,{className:`h-4 w-4`})}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[9px] font-bold uppercase tracking-[0.18em] text-muted-foreground`,children:[(0,L.jsx)(`span`,{children:t.kind}),t.external&&(0,L.jsx)(`span`,{className:`border border-border px-1 py-0.5 text-[8px] text-warning`,children:`external`}),t.lang&&(0,L.jsx)(`span`,{className:`ml-auto font-mono normal-case tracking-normal`,children:t.lang})]}),(0,L.jsx)(`div`,{className:`truncate font-mono text-[13px] font-semibold`,title:t.label,children:t.label}),(0,L.jsx)(`div`,{className:`mt-1 truncate text-[10px] text-muted-foreground`,title:p,children:p})]})]}),(0,L.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,L.jsxs)(`span`,{title:`Incoming relationships`,children:[`← `,i]}),(0,L.jsxs)(`span`,{title:`Outgoing relationships`,children:[`→ `,a]}),t.symbolCount!==void 0&&t.kind===`file`&&(0,L.jsxs)(`span`,{className:`ml-auto`,children:[t.symbolCount,` sym`]}),o&&(0,L.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 font-bold text-warning`,children:[(0,L.jsx)(E,{className:`h-2.5 w-2.5 animate-pulse`}),` LIVE`]})]})]}),d&&(0,L.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,L.jsx)(_,{className:`h-3.5 w-3.5`})}),(0,L.jsx)(T,{type:`source`,position:f.Right,className:`!h-2.5 !w-2.5 !border-2 !border-card !bg-muted-foreground`})]})}function Ve(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function H(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&&Ve(e.activeOperations,t.activeOperations)}var He={codemap:(0,k.memo)(Be,(e,t)=>H(e.data,t.data))},Ue={nodes:[],edges:[]};function We({loading:e,error:t,graph:n,canvasNodeCount:r,flowNodes:i,flowEdges:a,onNodesChange:o,onEdgesChange:s,agentTrailCount:c}){return(0,L.jsxs)(L.Fragment,{children:[e&&(0,L.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,L.jsx)(ne,{className:`h-7 w-7 animate-spin text-primary`}),(0,L.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-widest text-muted-foreground`,children:`Mapping relationships`})]}),t&&!e&&(0,L.jsxs)(`div`,{className:`absolute inset-0 z-20 flex flex-col items-center justify-center gap-3 p-8 text-center`,children:[(0,L.jsx)(D,{className:`h-10 w-10 text-destructive`}),(0,L.jsx)(`p`,{className:`font-mono text-sm text-destructive`,children:t}),(0,L.jsxs)(`p`,{className:`max-w-md text-xs text-muted-foreground`,children:[`The map needs a codebase index. Run`,` `,(0,L.jsx)(`code`,{className:`border bg-muted px-1.5 py-0.5`,children:`codebase-index`}),` once, then reopen this view.`]})]}),!e&&!t&&n.nodes.length===0&&(0,L.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-2 text-muted-foreground`,children:[(0,L.jsx)(D,{className:`h-8 w-8 opacity-40`}),(0,L.jsx)(`p`,{className:`text-xs`,children:`No indexed nodes at this level.`})]}),!e&&!t&&n.nodes.length>1&&n.edges.length===0&&(0,L.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,L.jsx)(`div`,{className:`font-mono text-[9px] font-bold uppercase tracking-wider text-warning`,children:`No resolved relations in this scope`}),(0,L.jsx)(`div`,{className:`mt-0.5 text-[8px] text-muted-foreground`,children:`The upgraded index will rebuild and resolve call/import/type links automatically.`})]}),!t&&n.nodes.length>0&&(0,L.jsxs)(y,{nodes:i,edges:a,onNodesChange:o,onEdgesChange:s,nodeTypes:He,nodesConnectable:!1,nodesDraggable:!1,edgesFocusable:!1,elementsSelectable:!1,onlyRenderVisibleElements:!0,minZoom:.08,maxZoom:2.2,proOptions:{hideAttribution:!0},children:[(0,L.jsx)(se,{variant:S.Dots,gap:r>60?32:22,size:1,color:`hsl(var(--muted-foreground))`,className:`!opacity-25`}),(0,L.jsx)(p,{position:`bottom-left`,showInteractive:!1,className:`!border !border-border !bg-card !shadow-md [&>button]:!border-border [&>button]:!bg-card [&>button]:!fill-foreground`}),r<=48&&(0,L.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,L.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(Fe).map(([e,t])=>(0,L.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,L.jsx)(`span`,{className:`h-0.5 w-3`,style:{backgroundColor:t}}),e.replace(`_`,` `)]},e)),(0,L.jsxs)(`span`,{className:`flex items-center gap-1 text-primary`,"data-testid":`agent-trail-count`,children:[(0,L.jsx)(`span`,{className:`w-4 border-t-2 border-dashed border-primary`}),`agent trail`,c>0?` ×${c}`:``]})]})]})}function Ge({layout:e,canvasMode:t,edgeFilter:n,canvasNodeCount:r,graphNodeCount:i,onLayoutChange:a,onCanvasModeChange:s,onEdgeFilterChange:c}){return(0,L.jsxs)(`div`,{className:`pointer-events-none absolute left-3 right-3 top-3 z-10 flex items-center gap-2`,children:[(0,L.jsxs)(`div`,{className:`pointer-events-auto flex border bg-card/95 shadow-md backdrop-blur`,children:[(0,L.jsxs)(`button`,{type:`button`,className:O(`flex h-8 items-center gap-1.5 border-r px-2.5 text-[9px] font-semibold uppercase tracking-wider`,e===`layers`?`bg-primary text-primary-foreground`:`text-muted-foreground hover:bg-muted`),onClick:()=>a(`layers`),children:[(0,L.jsx)(x,{className:`h-3 w-3`}),` Layers`]}),(0,L.jsxs)(`button`,{type:`button`,className:O(`flex h-8 items-center gap-1.5 px-2.5 text-[9px] font-semibold uppercase tracking-wider`,e===`orbit`?`bg-primary text-primary-foreground`:`text-muted-foreground hover:bg-muted`),onClick:()=>a(`orbit`),children:[(0,L.jsx)(o,{className:`h-3 w-3`}),` Relations`]})]}),(0,L.jsxs)(`div`,{className:`pointer-events-auto flex border bg-card/95 shadow-md backdrop-blur`,children:[(0,L.jsxs)(`button`,{type:`button`,className:O(`h-8 border-r px-2.5 font-mono text-[9px] font-bold`,t===`smart`?`bg-success text-success-foreground`:`text-muted-foreground hover:bg-muted`),onClick:()=>s(`smart`),title:`Keep the full tree, show the strongest relations and selected neighbourhood`,children:[`SMART `,r,`/`,i]}),(0,L.jsx)(`button`,{type:`button`,className:O(`h-8 px-2.5 font-mono text-[9px] font-bold`,t===`all`?`bg-foreground text-background`:`text-muted-foreground hover:bg-muted`),onClick:()=>s(`all`),title:`Render every node and relation in this scope`,children:`ALL`})]}),(0,L.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,L.jsx)(`button`,{type:`button`,className:O(`h-8 whitespace-nowrap border-r px-2.5 font-mono text-[9px] last:border-r-0`,n===e?`bg-foreground text-background`:`text-muted-foreground hover:bg-muted`),onClick:()=>c(e),children:e===`all`?`ALL LINKS`:e.replace(`_`,` `).toUpperCase()},e))})]})}function Ke({scope:e,graph:t,agentPresences:n,edgeWeight:r,connectedNodeCount:i,navigate:a}){return(0,L.jsxs)(`header`,{className:`flex h-[62px] shrink-0 items-center gap-4 border-b bg-card px-4`,children:[(0,L.jsxs)(`div`,{className:`flex min-w-[220px] items-center gap-3`,children:[(0,L.jsx)(`span`,{className:`flex h-9 w-9 items-center justify-center border border-primary bg-primary/10 text-primary`,children:(0,L.jsx)(D,{className:`h-4 w-4`})}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h1`,{className:`font-display text-sm font-semibold tracking-tight`,children:`Code Atlas`}),(0,L.jsx)(`p`,{className:`text-[9px] uppercase tracking-[0.18em] text-muted-foreground`,children:`Architecture intelligence`})]})]}),(0,L.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,L.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`?a({level:`files`,package:e.package??`(root)`}):a({level:`packages`})},"aria-label":`Back`,children:(0,L.jsx)(ue,{className:`h-3.5 w-3.5`})}),(0,L.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1.5 px-1.5 py-1 text-muted-foreground hover:text-foreground`,onClick:()=>a({level:`packages`}),children:[(0,L.jsx)(s,{className:`h-3 w-3`}),` workspace`]}),e.level!==`packages`&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(u,{className:`h-3 w-3 text-muted-foreground`}),(0,L.jsx)(`button`,{type:`button`,className:`max-w-[220px] truncate px-1.5 py-1 hover:text-primary`,onClick:()=>a({level:`files`,package:e.package??`(root)`}),children:e.package??`(root)`})]}),e.level===`symbols`&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(u,{className:`h-3 w-3 text-muted-foreground`}),(0,L.jsx)(`span`,{className:`truncate px-1.5 py-1 text-primary`,children:I({id:``,label:e.file,kind:`file`,file:e.file,package:e.package})})]})]}),(0,L.jsxs)(`div`,{className:`hidden items-center gap-5 xl:flex`,children:[(0,L.jsxs)(`div`,{className:O(`flex h-8 items-center gap-2 border px-2.5`,n.length>0?`border-success/50 bg-success/10 text-success`:`text-muted-foreground`),children:[(0,L.jsx)(E,{className:O(`h-3 w-3`,n.length>0&&`animate-pulse`)}),(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:`font-mono text-[10px] font-bold`,children:[n.length,` LIVE`]}),(0,L.jsx)(`div`,{className:`text-[7px] uppercase tracking-wider`,children:`agents`})]})]}),(0,L.jsxs)(`div`,{className:`text-right`,children:[(0,L.jsx)(`div`,{className:`font-mono text-sm font-semibold`,children:t.nodes.length}),(0,L.jsx)(`div`,{className:`text-[8px] uppercase tracking-wider text-muted-foreground`,children:`nodes`})]}),(0,L.jsxs)(`div`,{className:`text-right`,children:[(0,L.jsx)(`div`,{className:`font-mono text-sm font-semibold`,children:t.edges.length}),(0,L.jsx)(`div`,{className:`text-[8px] uppercase tracking-wider text-muted-foreground`,children:`links`})]}),(0,L.jsxs)(`div`,{className:`text-right`,children:[(0,L.jsx)(`div`,{className:`font-mono text-sm font-semibold`,children:r}),(0,L.jsx)(`div`,{className:`text-[8px] uppercase tracking-wider text-muted-foreground`,children:`references`})]}),(0,L.jsxs)(`div`,{className:`text-right`,children:[(0,L.jsx)(`div`,{className:`font-mono text-sm font-semibold`,children:i}),(0,L.jsx)(`div`,{className:`text-[8px] uppercase tracking-wider text-muted-foreground`,children:`connected`})]})]})]})}function U({activity:e}){return(0,L.jsx)(`span`,{className:O(`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 W({activity:e,onLocate:t,showAgent:n=!1}){let r=e.agentName??e.agent??`External process`,a=`${e.sessionId??`none`}:${e.agentId??r}`;return(0,L.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:[n&&(0,L.jsx)(`span`,{className:O(`mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center font-mono text-[8px] font-black`,z(a)),children:Re(r)}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,L.jsx)(U,{activity:e}),n&&(0,L.jsx)(`span`,{className:`truncate text-[9px] font-semibold`,children:r}),e.status===`active`&&(0,L.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 font-mono text-[8px] font-bold text-success`,children:[(0,L.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse bg-success`}),` LIVE`]}),e.watcherConfirmed&&(0,L.jsx)(d,{className:`ml-auto h-3 w-3 text-success`,"aria-label":`Filesystem confirmed`}),e.attribution===`correlated`&&!e.watcherConfirmed&&(0,L.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,L.jsx)(`span`,{className:`ml-auto font-mono text-[7px] uppercase text-destructive`,children:`external`})]}),(0,L.jsx)(`div`,{className:`mt-1 truncate font-mono text-[9px] font-semibold`,title:e.filePath,children:B(e.filePath)}),(e.symbol||e.line)&&(0,L.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-1 truncate font-mono text-[8px] text-success`,children:[(0,L.jsx)(i,{className:`h-2.5 w-2.5 shrink-0`}),e.symbol?.name??`line ${e.line}`,e.symbol?.kind&&(0,L.jsxs)(`span`,{className:`text-muted-foreground`,children:[`· `,e.symbol.kind]})]}),e.change&&(0,L.jsxs)(`div`,{className:`mt-1 flex items-center gap-1 font-mono text-[8px]`,children:[(0,L.jsxs)(`span`,{className:`border border-success/40 bg-success/10 px-1 text-success`,children:[`+`,e.change.added]}),(0,L.jsxs)(`span`,{className:`border border-destructive/40 bg-destructive/10 px-1 text-destructive`,children:[`−`,e.change.removed]}),e.durationMs!==void 0&&(0,L.jsxs)(`span`,{className:`ml-auto text-muted-foreground`,children:[e.durationMs,`ms`]})]}),e.summary&&e.summary!==e.toolName&&(0,L.jsx)(`div`,{className:`mt-1 line-clamp-2 text-[8px] leading-3 text-muted-foreground`,children:e.summary})]}),!e.filePath.startsWith(`(`)&&(0,L.jsx)(_,{className:`mt-1 h-3 w-3 shrink-0 text-muted-foreground opacity-0 group-hover:opacity-100`})]})}function qe({presences:e,onLocate:t}){return e.length===0?null:(0,L.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,L.jsxs)(`div`,{className:`flex h-9 items-center gap-2 border-b px-3`,children:[(0,L.jsx)(E,{className:`h-3.5 w-3.5 animate-pulse text-success`}),(0,L.jsx)(`h2`,{className:`text-[9px] font-black uppercase tracking-[0.18em]`,children:`Live agent operations`}),(0,L.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,L.jsx)(`div`,{className:`max-h-[330px] overflow-y-auto`,children:e.map(e=>(0,L.jsxs)(`div`,{className:`border-b last:border-b-0`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 bg-muted/35 px-3 py-1.5`,children:[(0,L.jsx)(`span`,{className:O(`flex h-6 w-6 items-center justify-center font-mono text-[8px] font-black`,z(e.key)),children:Re(e.agentName)}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`div`,{className:`truncate text-[9px] font-bold`,children:e.agentName}),(0,L.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,L.jsxs)(`span`,{className:`font-mono text-[8px] text-success`,children:[e.operations.length,` op`]})]}),e.operations.map(e=>(0,L.jsx)(W,{activity:e,onLocate:t},e.id??`${e.toolUseId}:${e.filePath}`))]},e.key))})]})}function Je({paused:e,followLive:t,agentFilter:n,agents:r,onTogglePaused:a,onToggleFollow:o,onAgentFilter:s}){return(0,L.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,L.jsxs)(`button`,{type:`button`,className:O(`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,L.jsx)(i,{className:`h-3 w-3`}),` Follow`]}),(0,L.jsxs)(`button`,{type:`button`,className:O(`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:a,title:e?`Resume the live telemetry stream`:`Freeze the current telemetry frame`,children:[e?(0,L.jsx)(le,{className:`h-3 w-3`}):(0,L.jsx)(C,{className:`h-3 w-3`}),e?`Resume`:`Live`]}),(0,L.jsxs)(`label`,{className:`flex h-full items-center gap-1.5 px-2 text-[8px] uppercase text-muted-foreground`,children:[`Agent`,(0,L.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,L.jsx)(`option`,{value:`all`,children:`ALL AGENTS`}),r.map(e=>(0,L.jsxs)(`option`,{value:e.key,children:[e.agentName,` · `,e.sessionId.slice(0,10)]},e.key))]})]})]})}function Ye({activeOperations:e,recentActivities:t,activityTotalCount:i,onLocate:a}){return(0,L.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[e.length>0&&(0,L.jsxs)(`section`,{className:`border-b`,children:[(0,L.jsxs)(`div`,{className:`flex h-9 items-center gap-2 border-b bg-success/5 px-3`,children:[(0,L.jsx)(E,{className:`h-3 w-3 animate-pulse text-success`}),(0,L.jsx)(`h3`,{className:`text-[9px] font-bold uppercase tracking-[0.16em]`,children:`Active now`}),(0,L.jsx)(`span`,{className:`ml-auto font-mono text-[9px] text-success`,children:e.length})]}),e.map(e=>(0,L.jsx)(W,{activity:e,onLocate:a,showAgent:!0},e.id??`${e.toolUseId}:${e.filePath}`))]}),(0,L.jsxs)(`section`,{children:[(0,L.jsxs)(`div`,{className:`flex h-9 items-center gap-2 border-b px-3`,children:[(0,L.jsx)(r,{className:`h-3 w-3 text-muted-foreground`}),(0,L.jsx)(`h3`,{className:`text-[9px] font-bold uppercase tracking-[0.16em]`,children:`Event stream`}),(0,L.jsxs)(`span`,{className:`ml-auto font-mono text-[8px] text-muted-foreground`,children:[i,` total`]})]}),t.length>0?t.map((e,t)=>(0,L.jsx)(W,{activity:e,onLocate:a,showAgent:!0},e.id??`${e.timestamp}:${t}`)):(0,L.jsxs)(`div`,{className:`flex flex-col items-center justify-center px-7 py-16 text-center`,children:[(0,L.jsx)(`span`,{className:`mb-4 flex h-12 w-12 items-center justify-center border bg-muted text-muted-foreground`,children:(0,L.jsx)(n,{className:`h-5 w-5`})}),(0,L.jsx)(`h3`,{className:`text-xs font-semibold`,children:`Select a node or wait for an agent`}),(0,L.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.`})]})]})]})}function Xe({node:e,incomingCount:t,outgoingCount:n,onOpenNode:i,onOpenActivity:a}){let o=R[e.kind].icon;return(0,L.jsxs)(`div`,{className:`border-b bg-muted/25 p-3`,children:[(0,L.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:O(`flex h-8 w-8 items-center justify-center border`,R[e.kind].iconStyle),children:(0,L.jsx)(o,{className:`h-4 w-4`})}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsxs)(`div`,{className:`text-[8px] font-bold uppercase tracking-[0.18em] text-muted-foreground`,children:[e.external?`external `:``,e.kind]}),(0,L.jsx)(`div`,{className:`truncate font-mono text-xs font-semibold`,title:e.label,children:e.label})]})]}),(0,L.jsx)(`div`,{className:`break-all font-mono text-[9px] leading-relaxed text-muted-foreground`,children:e.file?I(e):e.package}),e.signature&&(0,L.jsx)(`pre`,{className:`mt-3 overflow-x-auto border bg-background p-2 font-mono text-[9px] leading-relaxed text-foreground`,children:e.signature}),(0,L.jsxs)(`div`,{className:`mt-3 grid grid-cols-3 border`,children:[(0,L.jsx)(Ze,{value:t,label:`incoming`,className:`border-r text-info`}),(0,L.jsx)(Ze,{value:n,label:`outgoing`,className:`border-r text-primary`}),(0,L.jsx)(Ze,{value:e.symbolCount??e.fileCount??e.line??`—`,label:e.kind===`package`?`files`:e.kind===`file`?`symbols`:`line`})]}),(0,L.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[e.kind!==`symbol`&&(0,L.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:()=>i(e),children:[(0,L.jsx)(_,{className:`h-3 w-3`}),` Open `,e.kind===`package`?`files`:`symbols`]}),e.file&&(0,L.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:()=>a(e.file),children:[(0,L.jsx)(r,{className:`h-3 w-3`}),` Activity`]})]})]})}function Ze({value:e,label:t,className:n}){return(0,L.jsxs)(`div`,{className:O(`p-2 text-center`,n),children:[(0,L.jsx)(`div`,{className:`font-mono text-sm font-semibold`,children:e}),(0,L.jsx)(`div`,{className:`text-[8px] uppercase text-muted-foreground`,children:t})]})}function Qe(e){let{title:t,subtitle:r,items:i,graph:o,selectedId:s,expanded:c,onToggle:l,onSelect:d}=e;return(0,L.jsxs)(`section`,{className:`border-b py-3`,children:[(0,L.jsxs)(`div`,{className:`mb-2 flex items-end justify-between px-3`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{className:`text-[10px] font-bold uppercase tracking-[0.16em]`,children:t}),(0,L.jsx)(`p`,{className:`mt-0.5 text-[9px] text-muted-foreground`,children:r})]}),(0,L.jsx)(`span`,{className:`border bg-muted px-1.5 py-0.5 font-mono text-[9px]`,children:i.length})]}),i.length===0?(0,L.jsx)(`p`,{className:`px-3 py-2 text-[10px] text-muted-foreground`,children:`No relationships in this view.`}):i.map(e=>{let r=`${t}:${e.node.id}`,i=c.has(r),f=[..._e(o,e.node.id,`incoming`),..._e(o,e.node.id,`outgoing`)].filter((e,t,n)=>e.node.id!==s&&n.findIndex(t=>t.node.id===e.node.id)===t).slice(0,8);return(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:`group flex min-h-9 items-center gap-1 px-2 hover:bg-muted/70`,children:[(0,L.jsx)(`button`,{type:`button`,className:`flex h-6 w-5 shrink-0 items-center justify-center text-muted-foreground`,onClick:()=>f.length>0&&l(r),"aria-label":`${i?`Collapse`:`Expand`} relation ${e.node.label}`,children:f.length>0?i?(0,L.jsx)(a,{className:`h-3 w-3`}):(0,L.jsx)(u,{className:`h-3 w-3`}):(0,L.jsx)(`span`,{className:`h-px w-2 bg-border`})}),(0,L.jsxs)(`button`,{type:`button`,className:`min-w-0 flex-1 py-1 text-left`,onClick:()=>d(e.node),children:[(0,L.jsx)(`span`,{className:`block truncate font-mono text-[10px] font-semibold`,title:e.node.label,children:e.node.label}),(0,L.jsx)(`span`,{className:`block truncate text-[9px] text-muted-foreground`,children:e.node.package??e.node.symbolKind??e.node.kind})]}),(0,L.jsx)(`span`,{className:`border px-1 py-0.5 font-mono text-[8px] text-muted-foreground`,children:e.edge.refType}),(0,L.jsxs)(`span`,{className:`w-5 text-right font-mono text-[9px] text-muted-foreground`,children:[`×`,e.edge.weight]})]}),i&&f.map(e=>(0,L.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:()=>d(e.node),children:[(0,L.jsx)(`span`,{className:`absolute left-7 top-1/2 h-px w-3 bg-border`}),(0,L.jsx)(n,{className:`h-3 w-3 shrink-0`}),(0,L.jsx)(`span`,{className:`truncate font-mono`,children:e.node.label}),(0,L.jsx)(`span`,{className:`ml-auto font-mono opacity-70`,children:e.edge.refType})]},`${r}:${e.node.id}`))]},r)})]})}function $e({selectedNode:e,incoming:t,outgoing:n,filteredGraph:r,expandedRelations:i,activeOperations:a,recentActivities:o,activityTotalCount:s,selectedActivities:c,onClearSelection:l,onOpenNode:u,onOpenActivity:d,onLocateActivity:f,onToggleRelation:p,onSelectNode:m}){return(0,L.jsxs)(`aside`,{className:`flex w-[326px] shrink-0 flex-col border-l bg-card/80`,children:[(0,L.jsxs)(`div`,{className:`flex h-10 items-center justify-between border-b px-3`,children:[(0,L.jsx)(`h2`,{className:`text-[10px] font-bold uppercase tracking-[0.18em]`,children:`Relation inspector`}),e&&(0,L.jsx)(`button`,{type:`button`,className:`text-muted-foreground hover:text-foreground`,onClick:l,"aria-label":`Clear selection`,children:(0,L.jsx)(v,{className:`h-3.5 w-3.5`})})]}),e?(0,L.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[(0,L.jsx)(Xe,{node:e,incomingCount:t.length,outgoingCount:n.length,onOpenNode:u,onOpenActivity:d}),c.length>0&&(0,L.jsxs)(`section`,{className:`border-b bg-success/5 py-2`,children:[(0,L.jsxs)(`div`,{className:`mb-1 flex items-center gap-2 px-3`,children:[(0,L.jsx)(E,{className:`h-3 w-3 animate-pulse text-success`}),(0,L.jsx)(`h3`,{className:`text-[9px] font-bold uppercase tracking-[0.16em]`,children:`Agents on this node`}),(0,L.jsx)(`span`,{className:`ml-auto font-mono text-[9px] text-success`,children:c.length})]}),c.map(e=>(0,L.jsx)(W,{activity:e,onLocate:f,showAgent:!0},e.id??`${e.toolUseId}:${e.filePath}`))]}),(0,L.jsx)(Qe,{title:`Incoming`,subtitle:`Who depends on this`,items:t,graph:r,selectedId:e.id,expanded:i,onToggle:p,onSelect:m}),(0,L.jsx)(Qe,{title:`Outgoing`,subtitle:`What this depends on`,items:n,graph:r,selectedId:e.id,expanded:i,onToggle:p,onSelect:m})]}):(0,L.jsx)(Ye,{activeOperations:a,recentActivities:o,activityTotalCount:s,onLocate:f})]})}function et({node:e,onSelect:t,virtual:n}){let r=R[e.kind].icon;return(0,L.jsxs)(`button`,{type:`button`,"data-index":n?.index,ref:n?e=>n.measureElement(e):void 0,className:O(`min-h-8 items-center gap-2 px-3 py-1 text-left hover:bg-muted`,n?`absolute left-0 flex w-full`:`flex w-full`),style:n?{transform:`translateY(${n.start}px)`}:void 0,onClick:()=>t(e),children:[(0,L.jsx)(r,{className:O(`h-3.5 w-3.5 shrink-0`,e.kind===`package`?`text-primary`:e.kind===`file`?`text-info`:`text-success`)}),(0,L.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`span`,{className:`block truncate font-mono text-[10px]`,children:e.label}),(0,L.jsx)(`span`,{className:`block truncate text-[8px] text-muted-foreground`,children:e.file??e.package??e.symbolKind})]}),(0,L.jsx)(`span`,{className:`text-[8px] uppercase text-muted-foreground`,children:e.kind.slice(0,3)})]},e.id)}var G=80,tt=40;function K(e,t){if(!e||t.size===0)return!1;let n=M(e);if(t.has(n))return!0;for(let e of t)if(e.endsWith(`/${n}`)||n.endsWith(`/${e}`))return!0;return!1}var nt=(0,k.memo)(function e(t){let{directory:n,packageName:r,depth:i,expandedDirectories:o,expandedFiles:s,loadingBranches:d,graphForFile:f,onToggleDirectory:p,onToggleFile:h,onSelectFile:ee,onOpenFile:v,onSelectSymbol:y,selectedId:b,activeFileNorms:x,activeSymbolIds:te,revealAllKeys:S,onRevealAll:re}=t,C=`files:${r}:${n.path||`.`}`,w=S.has(C)?n.files:n.files.slice(0,G),ie=n.files.length-w.length;return(0,L.jsxs)(L.Fragment,{children:[n.directories.map(n=>{let s=`${r}:${n.path}`,d=o.has(s);return(0,L.jsxs)(`div`,{children:[(0,L.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+i*12},onClick:()=>p(s),children:[d?(0,L.jsx)(a,{className:`h-3 w-3`}):(0,L.jsx)(u,{className:`h-3 w-3`}),d?(0,L.jsx)(l,{className:`h-3.5 w-3.5 text-warning`}):(0,L.jsx)(c,{className:`h-3.5 w-3.5 text-warning`}),(0,L.jsx)(`span`,{className:`truncate`,children:n.name})]}),d&&(0,L.jsx)(e,{...t,directory:n,depth:i+1})]},s)}),w.map(e=>{let t=s.has(e.file??e.id),n=N({level:`symbols`,file:e.file??e.label}),r=(e.file?f(e.file):void 0)?.nodes.filter(t=>t.kind===`symbol`&&t.file===e.file&&!t.external)??[],o=`symbols:${e.file??e.id}`,c=S.has(o)?r:r.slice(0,tt),l=r.length-c.length,p=K(e.file,x);return(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:O(`group flex h-7 items-center pr-1 text-[11px] hover:bg-muted`,b===e.id&&`bg-primary/10 text-primary`),style:{paddingLeft:8+i*12},children:[(0,L.jsx)(`button`,{type:`button`,className:`flex h-6 w-4 shrink-0 items-center justify-center text-muted-foreground`,onClick:()=>h(e),"aria-label":`${t?`Collapse`:`Expand`} ${e.label}`,children:d.has(n)?(0,L.jsx)(ne,{className:`h-3 w-3 animate-spin`}):t?(0,L.jsx)(a,{className:`h-3 w-3`}):(0,L.jsx)(u,{className:`h-3 w-3`})}),(0,L.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-1.5 text-left`,onClick:()=>ee(e),onDoubleClick:()=>v(e),children:[(0,L.jsx)(m,{className:`h-3.5 w-3.5 shrink-0 text-info`}),p&&(0,L.jsx)(`span`,{className:`h-1.5 w-1.5 shrink-0 animate-pulse bg-success`,title:`Live operation`}),(0,L.jsx)(`span`,{className:`truncate font-mono`,title:e.file,children:e.label}),(0,L.jsx)(`span`,{className:`ml-auto text-[9px] text-muted-foreground`,children:e.symbolCount??0})]}),(0,L.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:()=>v(e),title:`Open symbol map`,"aria-label":`Open ${e.label} map`,children:(0,L.jsx)(_,{className:`h-3 w-3`})})]}),t&&c.map(e=>(0,L.jsxs)(`button`,{type:`button`,className:O(`flex h-7 w-full items-center gap-1.5 pr-2 text-left text-[10px] hover:bg-muted`,b===e.id?`bg-primary/10 text-primary`:`text-muted-foreground`),style:{paddingLeft:38+i*12},onClick:()=>y(e),children:[(0,L.jsx)(g,{className:`h-3 w-3 shrink-0 text-success`}),te.has(e.id)&&(0,L.jsx)(E,{className:`h-3 w-3 shrink-0 animate-pulse text-success`}),(0,L.jsx)(`span`,{className:`truncate font-mono`,children:e.label}),e.line&&(0,L.jsxs)(`span`,{className:`ml-auto font-mono text-[8px] opacity-60`,children:[`:`,e.line]})]},e.id)),t&&l>0&&(0,L.jsxs)(`button`,{type:`button`,className:`flex h-7 w-full items-center text-left font-mono text-[9px] text-primary hover:bg-muted`,style:{paddingLeft:38+i*12},onClick:()=>re(o),children:[`Show `,l,` more symbols`]})]},e.id)}),ie>0&&(0,L.jsxs)(`button`,{type:`button`,className:`flex h-7 w-full items-center text-left font-mono text-[9px] text-primary hover:bg-muted`,style:{paddingLeft:8+i*12},onClick:()=>re(C),children:[`Show `,ie,` more files`]})]})});function rt({rootGraph:e,search:n,searchInput:r,searchResults:i,virtualizeSearch:o,searchVirtualizer:s,treeScrollRef:c,selectedId:l,expandedPackages:d,expandedDirectories:f,expandedFiles:p,loadingBranches:m,activeFileNorms:ee,activeSymbolIds:g,revealAllKeys:y,packageGraph:b,graphForFile:x,navigate:te,togglePackage:S,toggleDirectory:re,toggleFile:C,revealAllTree:w,selectFileFromTree:ie,selectSymbolFromTree:ae,selectSearchResult:oe,handleOpenNode:se,onSearchInputChange:T,onSearchChange:ce}){return(0,L.jsxs)(`aside`,{className:`flex w-[286px] shrink-0 flex-col border-r bg-card/70`,children:[(0,L.jsxs)(`div`,{className:`border-b p-3`,children:[(0,L.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,L.jsx)(`h2`,{className:`text-[10px] font-bold uppercase tracking-[0.18em]`,children:`Code tree`}),(0,L.jsxs)(`span`,{className:`font-mono text-[9px] text-muted-foreground`,children:[e.nodes.length,` roots`]})]}),(0,L.jsxs)(`label`,{className:`flex h-8 items-center gap-2 border bg-background px-2 focus-within:border-primary`,children:[(0,L.jsx)(h,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,L.jsx)(`input`,{className:`min-w-0 flex-1 bg-transparent font-mono text-[10px] outline-none placeholder:text-muted-foreground`,value:r,onChange:e=>T(e.target.value),placeholder:`Find package, file, symbol…`}),r&&(0,L.jsx)(`button`,{type:`button`,onClick:()=>{T(``),ce(``)},"aria-label":`Clear search`,children:(0,L.jsx)(v,{className:`h-3 w-3 text-muted-foreground`})})]})]}),(0,L.jsx)(`div`,{ref:c,className:`min-h-0 flex-1 overflow-y-auto py-2`,children:n.trim()?(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:`px-3 pb-2 text-[9px] text-muted-foreground`,children:[i.length,` loaded-map results`]}),i.length===0?(0,L.jsxs)(`p`,{className:`px-3 py-8 text-center text-[10px] text-muted-foreground`,children:[`No match in loaded branches.`,(0,L.jsx)(`br`,{}),`Expand a package to search its files.`]}):o?(0,L.jsx)(`div`,{style:{height:`${s.getTotalSize()}px`,width:`100%`,position:`relative`},children:s.getVirtualItems().map(e=>{let t=i[e.index];return t?(0,L.jsx)(et,{node:t,onSelect:oe,virtual:{index:e.index,start:e.start,measureElement:s.measureElement}},t.id):null})}):i.map(e=>(0,L.jsx)(et,{node:e,onSelect:oe},e.id))]}):e.nodes.map(e=>{let n=e.package??e.label,r=d.has(n),i=N({level:`files`,package:n}),o=b(n),s=o?we(o.nodes):void 0;return(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:O(`group flex h-8 items-center px-2 hover:bg-muted`,l===e.id&&`bg-primary/10 text-primary`),children:[(0,L.jsx)(`button`,{type:`button`,className:`flex h-6 w-5 items-center justify-center text-muted-foreground`,onClick:()=>S(e),"aria-label":`${r?`Collapse`:`Expand`} ${n}`,children:m.has(i)?(0,L.jsx)(ne,{className:`h-3 w-3 animate-spin`}):r?(0,L.jsx)(a,{className:`h-3 w-3`}):(0,L.jsx)(u,{className:`h-3 w-3`})}),(0,L.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-2 text-left`,onClick:()=>te({level:`packages`},e.id),onDoubleClick:()=>te({level:`files`,package:n}),children:[(0,L.jsx)(t,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,L.jsx)(`span`,{className:`truncate font-mono text-[10px] font-semibold`,children:e.label}),(0,L.jsx)(`span`,{className:`ml-auto text-[9px] text-muted-foreground`,children:e.fileCount??0})]}),(0,L.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:()=>te({level:`files`,package:n}),title:`Open file map`,"aria-label":`Open ${n} map`,children:(0,L.jsx)(_,{className:`h-3 w-3`})})]}),r&&s&&(0,L.jsx)(nt,{directory:s,packageName:n,depth:1,expandedDirectories:f,expandedFiles:p,loadingBranches:m,graphForFile:x,onToggleDirectory:re,onToggleFile:C,onSelectFile:ie,onOpenFile:se,onSelectSymbol:ae,selectedId:l,activeFileNorms:ee,activeSymbolIds:g,revealAllKeys:y,onRevealAll:w})]},e.id)})}),(0,L.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,L.jsx)(`br`,{}),`Branches stay open while the map changes`]})]})}function it(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&&H(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 q(e){return e.data?.renderKey}function at(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&&q(a)===q(t)?(e[i]!==a&&(r=!0),a):(r=!0,t)});return r?i:e}function ot(){let[e,t]=(0,k.useState)({level:`packages`}),n=N(e),[r,i]=(0,k.useState)(Ue),[a,o]=(0,k.useState)(!0),[s,c]=(0,k.useState)(null),[l,u]=(0,k.useState)(null),[d,f]=(0,k.useState)(`layers`),[p,m]=(0,k.useState)(`smart`),[h,ee]=(0,k.useState)(`all`),[g,_]=(0,k.useState)(``),[v,y]=(0,k.useState)(``),[x,S]=(0,k.useState)(new Set),[ne,C]=(0,k.useState)(new Set),[w,se]=(0,k.useState)(new Set),[T,ce]=(0,k.useState)(new Set),[le,ue]=(0,k.useState)(new Set),[E,de]=(0,k.useState)(new Set),[D,O]=(0,k.useState)(0),[A,j]=(0,k.useState)(null),[P,ye]=(0,k.useState)(!1),[F,xe]=(0,k.useState)(`all`),[I,Ce]=(0,k.useState)(null),[Ae,R]=(0,k.useState)(null),[Ie,Le]=(0,k.useState)(0),z=(0,k.useRef)(new Map),B=(0,k.useRef)(null),V=(0,k.useRef)(null),Be=(0,k.useRef)(``),Ve=(0,k.useRef)(``),H=(0,k.useRef)(null),He=(0,k.useRef)(new Set),{history:U,pulses:W,activeOperationsMap:Ye,activityTotalCount:Xe,resolveActivitySymbol:Ze,getActivityForFile:Qe,sweepActivity:et}=fe(re(e=>({history:e.history,pulses:e.pulses,activeOperationsMap:e.activeOperations,activityTotalCount:e.totalCount,resolveActivitySymbol:e.resolveActivitySymbol,getActivityForFile:e.getActivityForFile,sweepActivity:e._sweep}))),G=(0,k.useMemo)(()=>[...Ye.values()].flat(),[Ye]),tt=(0,k.useMemo)(()=>[...W.keys()].map(e=>U.get(e)?.[0]).filter(e=>!!e),[U,W]),K=(0,k.useMemo)(()=>{let e=[];for(let t of U.values())e.push(...t.slice(0,16));return e.sort((e,t)=>t.timestamp-e.timestamp).slice(0,16)},[U]),nt=(0,k.useMemo)(()=>pe([...G,...K]),[G,K]),q=(0,k.useMemo)(()=>{let e=I??G;return F===`all`?e:e.filter(e=>me(e)===F)},[G,F,I]),ot=(0,k.useMemo)(()=>{let e=Ae??K;return F===`all`?e:e.filter(e=>me(e)===F)},[F,Ae,K]),J=(0,k.useDeferredValue)(q),st=(0,k.useDeferredValue)(ot),ct=(0,k.useDeferredValue)(tt),lt=(0,k.useMemo)(()=>pe(q),[q]),[ut,dt,ft]=ie([]),[pt,mt,ht]=oe([]),{fitView:gt}=te(),Y=(0,k.useCallback)(async(e,t=!1)=>{let n=N(e),r=z.current.get(n);if(r&&!t)return Ee(z.current,n,r,48),r;let i=await fetch(ge(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 Ee(z.current,n,a,48),O(e=>e+1),a},[]);(0,k.useEffect)(()=>{let e=window.setTimeout(()=>y(g),150);return()=>window.clearTimeout(e)},[g]);let _t=he(e=>e.generation),vt=(0,k.useRef)(0),yt=(0,k.useRef)(null);(0,k.useEffect)(()=>{let t=!1,n=_t>vt.current;return n&&(vt.current=_t,z.current.clear(),O(e=>e+1),S(new Set),C(new Set),se(new Set),ue(new Set)),o(!0),c(null),Y(e,n).then(e=>{if(!t){if(i(e),!n){let t=B.current;B.current=null,u(t&&e.nodes.some(e=>e.id===t)?t:null)}o(!1)}}).catch(e=>{t||(c(e instanceof Error?e.message:String(e)),i(Ue),o(!1))}),()=>{t=!0}},[n,Y,_t,e]);let X=(0,k.useCallback)((e,r)=>{if(B.current=r??null,N(e)===n){u(r??null),B.current=null;return}t(e)},[n]),bt=(0,k.useCallback)(async e=>{let t=N(e);if(!(z.current.has(t)||E.has(t))){de(e=>new Set(e).add(t));try{await Y(e)}finally{de(e=>{let n=new Set(e);return n.delete(t),n})}}},[Y,E]);(0,k.useEffect)(()=>{let e=!1,t=0;for(let n of G){if(t>=2)break;if(n.symbol||!n.toolUseId||n.filePath.startsWith(`(`))continue;let r=n.filePath;He.current.has(r)||(He.current.add(r),t+=1,Y({level:`symbols`,file:r}).then(t=>{if(e)return;let i=Ne(n,t.nodes);i&&Ze(n.toolUseId,r,{id:i.id,name:i.label,...i.symbolKind?{kind:i.symbolKind}:{},...i.line?{line:i.line}:{}})}).catch(()=>void 0).finally(()=>{He.current.delete(r)}))}return()=>{e=!0}},[G,Y,Ze]);let Z=(0,k.useMemo)(()=>({nodes:r.nodes,edges:h===`all`?r.edges:r.edges.filter(e=>e.refType===h)}),[r,h]),Q=r.nodes.find(e=>e.id===l),$=(0,k.useMemo)(()=>Se(Z,l,p),[p,Z,l]),xt=(0,k.useMemo)(()=>l?ve(Z,l):new Set,[Z,l]),{incomingCounts:St,outgoingCounts:Ct}=(0,k.useMemo)(()=>{let e=new Map,t=new Map;for(let n of Z.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}},[Z]),wt=d===`orbit`?l??void 0:void 0,Tt=(0,k.useMemo)(()=>be($,d,wt),[$,d,wt]),Et=(0,k.useMemo)(()=>[n,d,d===`orbit`?l??``:``,Te($)].join(``),[$,n,d,l]),Dt=(0,k.useCallback)(e=>{u(e.id),ce(new Set)},[]),Ot=(0,k.useCallback)(e=>{e.kind===`package`&&X({level:`files`,package:e.package??e.label}),e.kind===`file`&&e.file&&X({level:`symbols`,file:e.file,package:e.package})},[X]),kt=(0,k.useMemo)(()=>[Me(J),Me(ct),Me(st)].join(``),[J,ct,st]),At=(0,k.useMemo)(()=>{let e=new Set;for(let t of q)e.add(M(t.filePath));return e},[q]),jt=(0,k.useMemo)(()=>{let e=new Set;for(let t of q)t.symbol?.id&&e.add(t.symbol.id);return e},[q]);(0,k.useEffect)(()=>{let e=()=>{let e=Tt.map(({node:e})=>e),t=je(e,J),n=je(e,ct),r=new Set(t.keys()),i=Tt.map(({node:e,position:r})=>{let i=t.get(e.id)??[],a=i[0]??n.get(e.id)?.[0];return{id:e.id,type:`codemap`,position:r,data:{graphNode:e,selected:e.id===l,dimmed:!!l&&!xt.has(e.id),incoming:St.get(e.id)??0,outgoing:Ct.get(e.id)??0,isActive:!!a,...a?{activityType:a.type}:{},activeOperations:i,onSelect:Dt,onOpen:Ot,onShowHistory:j}}});dt(e=>it(e,i));let a=6,o=$.edges.map((e,t)=>{let n=!!l&&(e.source===l||e.target===l),i=r.has(e.source)||r.has(e.target),o=i&&(n||a>0);o&&--a;let s=Fe[e.refType]??`hsl(var(--muted-foreground))`,c=n||i?`smoothstep`:`default`;return{id:`edge:${e.source}:${e.target}:${t}`,source:e.source,target:e.target,type:c,animated:o,label:n?`${e.refType}${e.weight>1?` ×${e.weight}`:``}`:void 0,markerEnd:{type:b.ArrowClosed,color:s,width:14,height:14},style:{stroke:s,strokeWidth:i?Math.min(2.5+Math.log2(e.weight+1)*.65,5):n?Math.min(1.25+Math.log2(e.weight+1)*.65,4):1,opacity:i?1:l?n?.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:n?2:0,data:{renderKey:`${e.refType}:${e.weight}:${l?n?`focused`:`dimmed`:`idle`}:${i?`live`:`still`}:${o?`anim`:`still`}:${c}`}}}),s=new Map,c=new Set(J.map(me));for(let e of[...st].sort((e,t)=>e.timestamp-t.timestamp)){let t=me(e),n=s.get(t);n?n.push(e):s.set(t,[e])}let u=[...s.entries()].map(([e,t])=>({agentKey:e,activities:t,live:c.has(e),latest:t[t.length-1]?.timestamp??0})).sort((e,t)=>Number(t.live)-Number(e.live)||t.latest-e.latest).slice(0,4),d=[];for(let{agentKey:e,activities:t,live:n}of u){let r=t.slice(-7).map(e=>({activity:e,node:$.nodes.find(t=>ke(e,t))})).filter(e=>!!e.node).filter((e,t,n)=>t===0||e.node.id!==n[t-1]?.node.id),i=ze(e);for(let t=1;t<r.length;t++){let o=r[t-1],s=r[t],c=n&&a>0;c&&--a,d.push({id:`trail:${e}:${o.activity.timestamp}:${s.activity.timestamp}`,source:o.node.id,target:s.node.id,type:`smoothstep`,animated:c,label:t===r.length-1?`${Re(s.activity.agentName??s.activity.agent??`agent`)} TRAIL`:void 0,markerEnd:{type:b.ArrowClosed,color:i,width:13,height:13},style:{stroke:i,strokeWidth:2.5,strokeDasharray:`7 5`,opacity:.9},labelStyle:{fontSize:8,fontWeight:700,fill:i},labelBgStyle:{fill:`hsl(var(--card))`,fillOpacity:.94},labelBgPadding:[4,2],zIndex:6,data:{renderKey:`${i}:${t===r.length-1?`label`:`plain`}:${n?`live`:`still`}:${c?`anim`:`still`}`}})}}Le(d.length),mt(e=>at(e,[...o,...d]))},t=Et,n=Ve.current!==t;Ve.current=t,H.current!==null&&(window.clearTimeout(H.current),H.current=null),n?e():H.current=window.setTimeout(()=>{H.current=null,e()},120);let r;return Be.current!==Et&&(r=window.setTimeout(()=>{Be.current=Et;let e=$.nodes.length>48?0:240;gt({padding:.2,duration:e,maxZoom:1.25})},20)),()=>{H.current!==null&&(window.clearTimeout(H.current),H.current=null),r!==void 0&&window.clearTimeout(r)}},[kt,$,l,J,st,ct,Et,xt,gt,Ot,Dt,St,Ct,Tt,mt,dt]),(0,k.useEffect)(()=>{let e=window.setInterval(()=>{et()},2e3);return()=>window.clearInterval(e)},[et]);let Mt=z.current.get(`packages`)??(e.level===`packages`?r:Ue),Nt=(0,k.useCallback)(e=>z.current.get(N({level:`files`,package:e})),[D]),Pt=(0,k.useCallback)(e=>z.current.get(N({level:`symbols`,file:e})),[D]),Ft=(0,k.useCallback)(e=>{let t=e.filePath,n=Oe(e.filePath),r=`file:${e.filePath}`;for(let i of z.current.values()){let a=i.nodes.find(t=>t.kind===`file`&&!t.external&&De(t.file,e.filePath));if(a){t=a.file??t,n=a.package??n,r=a.id;break}}if(e.symbol){X({level:`symbols`,file:t,package:n},e.symbol.id);return}X({level:`files`,package:n},r)},[X]);(0,k.useEffect)(()=>{if(!P||I)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`}`;V.current!==t&&(V.current=t,Ft(e))},[q,P,Ft,I]);let It=(0,k.useCallback)(()=>{if(I){Ce(null),R(null);return}Ce([...G]),R([...K])},[G,I,K]),Lt=(0,k.useCallback)(e=>{let t=e.package??e.label,n=!x.has(t);S(e=>{let r=new Set(e);return n?r.add(t):r.delete(t),r}),n&&bt({level:`files`,package:t}).then(()=>{let e=z.current.get(N({level:`files`,package:t})),n=e?we(e.nodes):void 0;n?.directories.length===1&&n.directories[0]&&C(e=>new Set(e).add(`${t}:${n.directories[0].path}`))}).catch(()=>void 0)},[bt,x]),Rt=(0,k.useCallback)(e=>{if(!e.file)return;let t=!w.has(e.file);se(n=>{let r=new Set(n);return t?r.add(e.file):r.delete(e.file),r}),t&&bt({level:`symbols`,file:e.file,package:e.package}).catch(()=>void 0)},[bt,w]),zt=(0,k.useCallback)(e=>{C(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),Bt=(0,k.useCallback)(e=>{ue(t=>new Set(t).add(e))},[]),Vt=(0,k.useCallback)(e=>{X({level:`files`,package:e.package??`(root)`},e.id)},[X]),Ht=(0,k.useCallback)(e=>{e.file&&X({level:`symbols`,file:e.file,package:e.package},e.id)},[X]),Ut=(0,k.useMemo)(()=>{let e=v.trim().toLocaleLowerCase();if(!e)return[];let t=new Map;for(let n of z.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)},[v,D]),Wt=Ut.length>40,Gt=ae({count:Ut.length,getScrollElement:()=>yt.current,estimateSize:()=>40,overscan:8,enabled:Wt}),Kt=(0,k.useCallback)(e=>{e.kind===`package`?X({level:`packages`},e.id):e.kind===`file`?X({level:`files`,package:e.package??`(root)`},e.id):e.file&&X({level:`symbols`,file:e.file,package:e.package},e.id)},[X]),{incoming:qt,outgoing:Jt}=(0,k.useMemo)(()=>({incoming:Q?_e(Z,Q.id,`incoming`):[],outgoing:Q?_e(Z,Q.id,`outgoing`):[]}),[Z,Q]),{edgeWeight:Yt,connectedNodeCount:Xt}=(0,k.useMemo)(()=>{let e=0,t=new Set;for(let n of Z.edges)e+=n.weight,t.add(n.source),t.add(n.target);return{edgeWeight:e,connectedNodeCount:t.size}},[Z]),Zt=Q?q.filter(e=>ke(e,Q)):[],Qt=A?Qe(A):[];return(0,L.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-background`,children:[(0,L.jsx)(Ke,{scope:e,graph:r,agentPresences:lt,edgeWeight:Yt,connectedNodeCount:Xt,navigate:X}),(0,L.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,L.jsx)(rt,{rootGraph:Mt,search:v,searchInput:g,searchResults:Ut,virtualizeSearch:Wt,searchVirtualizer:Gt,treeScrollRef:yt,selectedId:l,expandedPackages:x,expandedDirectories:ne,expandedFiles:w,loadingBranches:E,activeFileNorms:At,activeSymbolIds:jt,revealAllKeys:le,packageGraph:Nt,graphForFile:Pt,navigate:X,togglePackage:Lt,toggleDirectory:zt,toggleFile:Rt,revealAllTree:Bt,selectFileFromTree:Vt,selectSymbolFromTree:Ht,selectSearchResult:Kt,handleOpenNode:Ot,onSearchInputChange:_,onSearchChange:y}),(0,L.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,L.jsx)(Ge,{layout:d,canvasMode:p,edgeFilter:h,canvasNodeCount:$.nodes.length,graphNodeCount:r.nodes.length,onLayoutChange:f,onCanvasModeChange:m,onEdgeFilterChange:ee}),(0,L.jsx)(qe,{presences:lt,onLocate:Ft}),(0,L.jsx)(Je,{paused:I!==null,followLive:P,agentFilter:F,agents:nt,onTogglePaused:It,onToggleFollow:()=>{V.current=null,ye(e=>!e)},onAgentFilter:e=>{V.current=null,xe(e)}}),(0,L.jsx)(We,{loading:a,error:s,graph:r,canvasNodeCount:$.nodes.length,flowNodes:ut,flowEdges:pt,onNodesChange:ft,onEdgesChange:ht,agentTrailCount:Ie})]}),(0,L.jsx)($e,{selectedNode:Q,incoming:qt,outgoing:Jt,filteredGraph:Z,expandedRelations:T,activeOperations:q,recentActivities:ot,activityTotalCount:Xe,selectedActivities:Zt,onClearSelection:()=>u(null),onOpenNode:Ot,onOpenActivity:j,onLocateActivity:Ft,onToggleRelation:e=>ce(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),onSelectNode:Dt})]}),A&&(0,L.jsx)(Pe,{historyFile:A,fileHistory:Qt,onClose:()=>j(null)})]})}function J(){return(0,L.jsx)(ce,{children:(0,L.jsx)(ot,{})})}export{J as CodeMap};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Ai as t,Bi as n,Vi as r,lt as i,pn as a,za as o}from"./vendor-BuarzSSb.js";import{M as s}from"./stores-BptlyD_v.js";import{a as c,n as l,o as u,r as d,t as f}from"./dialog-ftgTihmF.js";import{k as p,o as m}from"./index-DHdO0CRE.js";var h=e(o(),1),g=i();function _(e){return e<1e3?`${e}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:e<36e5?`${(e/6e4).toFixed(1)}m`:`${(e/36e5).toFixed(1)}h`}function v(e){if(!e)return`—`;let t=new Date(e),n=Date.now(),r=t.getTime()-n,i=Math.abs(r);if(i<6e4)return r>=0?`<1m`:`<1m ago`;if(i<36e5){let e=Math.round(i/6e4);return r>=0?`${e}m`:`${e}m ago`}if(i<864e5){let e=Math.round(i/36e5);return r>=0?`${e}h`:`${e}h ago`}return t.toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function y({enabled:e,overdue:i}){return e?i?(0,g.jsxs)(m,{variant:`destructive`,className:`gap-1`,children:[(0,g.jsx)(t,{className:`h-3 w-3`}),`Overdue`]}):(0,g.jsxs)(m,{variant:`default`,className:`gap-1 bg-emerald-600 hover:bg-emerald-600`,children:[(0,g.jsx)(n,{className:`h-3 w-3`}),`Active`]}):(0,g.jsxs)(m,{variant:`secondary`,className:`gap-1`,children:[(0,g.jsx)(r,{className:`h-3 w-3`}),`Disabled`]})}function b({open:e,onClose:n}){let r=s(e=>e.snapshot),i=s(e=>e.lastFiredAt);s(e=>e.revision);let o=r?.jobs??[],m=r?.count??0,b=r?.maxConcurrent??0,x=o.filter(e=>e.overdue).length,S=o.filter(e=>e.enabled).length,C=o.reduce((e,t)=>e+t.runCount,0);return(0,g.jsx)(f,{open:e,onOpenChange:(0,h.useCallback)(e=>{e||n()},[n]),children:(0,g.jsxs)(l,{className:`max-w-3xl max-h-[80vh] flex flex-col`,children:[(0,g.jsxs)(c,{children:[(0,g.jsxs)(u,{className:`flex items-center gap-2`,children:[(0,g.jsx)(a,{className:`h-5 w-5`}),`Cron Jobs`]}),(0,g.jsx)(d,{children:`Scheduled recurring tasks managed by the cron plugin.`})]}),m>0&&(0,g.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 text-sm text-muted-foreground border-b border-border/70 pb-3`,children:[(0,g.jsxs)(`span`,{className:`font-medium text-foreground`,children:[m,` job`,m===1?``:`s`]}),(0,g.jsxs)(`span`,{className:`text-emerald-500`,children:[S,` enabled`]}),x>0&&(0,g.jsxs)(`span`,{className:`text-destructive`,children:[x,` overdue`]}),(0,g.jsxs)(`span`,{children:[C,` total runs`]}),(0,g.jsxs)(`span`,{className:`text-muted-foreground/60`,children:[`max `,b,` concurrent`]})]}),m===0&&(0,g.jsxs)(`div`,{className:`flex flex-col items-center gap-2 py-12 text-muted-foreground`,children:[(0,g.jsx)(t,{className:`h-8 w-8 opacity-40`}),(0,g.jsx)(`p`,{className:`text-sm`,children:`No cron jobs scheduled.`}),(0,g.jsxs)(`p`,{className:`text-xs`,children:[`Use `,(0,g.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5`,children:`cron_schedule`}),` to add one.`]})]}),m>0&&(0,g.jsx)(p,{className:`flex-1 -mx-6 px-6`,children:(0,g.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,g.jsx)(`thead`,{children:(0,g.jsxs)(`tr`,{className:`border-b border-border/50 text-left text-xs text-muted-foreground`,children:[(0,g.jsx)(`th`,{className:`pb-2 pr-3 font-medium`,children:`Status`}),(0,g.jsx)(`th`,{className:`pb-2 pr-3 font-medium`,children:`Name`}),(0,g.jsx)(`th`,{className:`pb-2 pr-3 font-medium`,children:`Interval`}),(0,g.jsx)(`th`,{className:`pb-2 pr-3 font-medium text-right`,children:`Runs`}),(0,g.jsx)(`th`,{className:`pb-2 pr-3 font-medium`,children:`Next Run`}),(0,g.jsx)(`th`,{className:`pb-2 pr-3 font-medium`,children:`Last Run`}),(0,g.jsx)(`th`,{className:`pb-2 font-medium`,children:`Action`})]})}),(0,g.jsx)(`tbody`,{children:o.map(e=>(0,g.jsxs)(`tr`,{className:`border-b border-border/30 last:border-0`,children:[(0,g.jsx)(`td`,{className:`py-2.5 pr-3`,children:(0,g.jsx)(y,{enabled:e.enabled,overdue:e.overdue})}),(0,g.jsx)(`td`,{className:`py-2.5 pr-3 font-mono text-xs font-medium max-w-[160px] truncate`,title:e.name,children:e.name}),(0,g.jsx)(`td`,{className:`py-2.5 pr-3 font-mono text-xs tabular-nums`,children:_(e.intervalMs)}),(0,g.jsxs)(`td`,{className:`py-2.5 pr-3 text-right font-mono text-xs tabular-nums`,children:[e.runCount,i[e.name]&&(0,g.jsx)(`span`,{className:`ml-1 text-emerald-500`,title:`Last fired at ${i[e.name]}`,children:`●`})]}),(0,g.jsx)(`td`,{className:`py-2.5 pr-3 font-mono text-xs tabular-nums`,children:v(e.nextRun)}),(0,g.jsx)(`td`,{className:`py-2.5 pr-3 font-mono text-xs tabular-nums`,children:v(e.lastRun)}),(0,g.jsx)(`td`,{className:`py-2.5 font-mono text-xs max-w-[200px] truncate text-muted-foreground`,title:e.action,children:e.action})]},e.name))})]})}),m>0&&(0,g.jsxs)(`p`,{className:`text-xs text-muted-foreground pt-3 border-t border-border/70`,children:[`Use `,(0,g.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5 text-[11px]`,children:`cron_schedule`}),` to add,`,(0,g.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5 text-[11px] ml-1`,children:`cron_cancel`}),` to remove.`]})]})})}export{b as CronJobsPanel};
@@ -1,2 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{lt as t,za as n}from"./vendor-BuarzSSb.js";var r=e(n(),1),i=t(),a={0:`P0 Dead Package`,1:`P1 Dead File`,2:`P2 Dead Symbol`},o={0:`hsl(var(--destructive))`,1:`hsl(var(--warning))`,2:`hsl(var(--info))`};async function s(e){let t=await e.text();try{return JSON.parse(t)}catch{let e=t.length>300?`${t.slice(0,300)}…`:t;throw console.warn(JSON.stringify({level:`warn`,event:`deadcode_parse_error`,preview:e,timestamp:new Date().toISOString()})),Error(`The server returned a non-JSON response (possibly an HTML error page). Check that the backend is running and the /api/deadcode/* routes are wired.`)}}function c(){let[e,t]=(0,r.useState)(`idle`),[n,c]=(0,r.useState)(`idle`),[l,p]=(0,r.useState)(null),[m,h]=(0,r.useState)(null),[g,_]=(0,r.useState)(null),v=(0,r.useCallback)(async()=>{t(`scanning`),_(null),p(null),h(null),c(`idle`);try{let e=await fetch(`/api/deadcode/scan`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({})});if(!e.ok){let t=await s(e);throw Error(t.detail??t.error??`HTTP ${e.status}`)}let n=await s(e);p(n),t(`done`)}catch(e){_(e instanceof Error?e.message:String(e)),t(`error`)}},[]),y=(0,r.useCallback)(async()=>{if(l){c(`generating`),_(null);try{let e=await fetch(`/api/deadcode/action-plan`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(l)});if(!e.ok){let t=await s(e);throw Error(t.detail??t.error??`HTTP ${e.status}`)}let t=await s(e);h(t),c(`ready`)}catch(e){_(e instanceof Error?e.message:String(e)),c(`idle`)}}},[l]),b=(0,r.useCallback)(()=>{if(!m)return;c(`executing`);let e=[`# Dead-Code Cleanup Plan`,``,m.summary,``,`## Files to address (in priority order)`,...m.files.map((e,t)=>`${t+1}. [${a[e.priority]}] ${e.file} — ${e.symbolCount} symbol(s) to remove`+(e.symbols.length>0?`\n Symbols: ${e.symbols.slice(0,5).join(`, `)}${e.symbols.length>5?` and ${e.symbols.length-5} more`:``}`:``))].join(`
2
- `),t=window.__WS;t&&t.readyState===WebSocket.OPEN?t.send(JSON.stringify({type:`user.message`,payload:{text:e,action:`send`}})):(navigator.clipboard.writeText(e),_(`Agent not connected. Plan copied to clipboard — paste it into the chat.`)),c(`idle`)},[m]);return(0,i.jsxs)(`div`,{style:{padding:`16px`,fontFamily:`var(--font-sans, system-ui, sans-serif)`,color:`hsl(var(--foreground))`,background:`hsl(var(--background))`},children:[(0,i.jsx)(`h2`,{style:{margin:`0 0 16px`,fontSize:`18px`,fontWeight:600,color:`hsl(var(--foreground))`},children:`🔍 Dead-Code Scan`}),(0,i.jsx)(`button`,{type:`button`,onClick:v,disabled:e===`scanning`,style:{padding:`8px 16px`,fontSize:`14px`,fontWeight:500,background:e===`scanning`?`hsl(var(--muted))`:`hsl(var(--primary))`,color:e===`scanning`?`hsl(var(--muted-foreground))`:`hsl(var(--primary-foreground))`,border:`1px solid hsl(var(--border))`,borderRadius:`0`,cursor:e===`scanning`?`not-allowed`:`pointer`},children:e===`scanning`?`Scanning…`:`Scan for Dead Code`}),g&&(0,i.jsxs)(`div`,{style:{marginTop:`12px`,padding:`8px 12px`,background:`hsl(var(--destructive) / 0.1)`,color:`hsl(var(--destructive))`,border:`1px solid hsl(var(--destructive) / 0.3)`,borderRadius:`0`,fontSize:`13px`},children:[g,(0,i.jsx)(`button`,{type:`button`,onClick:()=>_(null),style:{marginLeft:`12px`,background:`none`,border:`none`,cursor:`pointer`,fontWeight:600,color:`hsl(var(--destructive))`},children:`✕`})]}),l&&(0,i.jsxs)(`div`,{style:{marginTop:`16px`},children:[(0,i.jsxs)(`div`,{style:{display:`flex`,gap:`12px`,marginBottom:`12px`},children:[(0,i.jsx)(u,{label:`Total Symbols`,value:l.stats.totalSymbols,token:`info`}),(0,i.jsx)(u,{label:`Alive`,value:l.stats.alive,token:`success`}),(0,i.jsx)(u,{label:`Dead`,value:l.stats.dead,token:`destructive`})]}),l.deadPackages.length>0&&(0,i.jsx)(d,{title:`Dead Packages (${l.deadPackages.length})`,token:`destructive`,children:l.deadPackages.map(e=>(0,i.jsx)(f,{columns:[e.package,e.path,`${e.fileCount} file(s)`]},e.package))}),l.deadFiles.length>0&&(0,i.jsx)(d,{title:`Dead Files (${l.deadFiles.length})`,token:`warning`,children:l.deadFiles.map(e=>(0,i.jsx)(f,{columns:[e.file,`${e.symbolCount} symbol(s)`,e.lang]},e.file))}),l.deadSymbols.length>0&&(0,i.jsxs)(d,{title:`Dead Symbols (${l.deadSymbols.length})`,token:`info`,children:[l.deadSymbols.slice(0,50).map(e=>(0,i.jsx)(f,{columns:[e.name,e.kind,e.file.split(`/`).pop()??e.file,`line ${e.line}`]},`${e.file}:${e.line}:${e.name}`)),l.deadSymbols.length>50&&(0,i.jsxs)(`div`,{style:{padding:`6px 8px`,color:`hsl(var(--muted-foreground))`,fontSize:`12px`},children:[`… and `,l.deadSymbols.length-50,` more`]})]}),e===`done`&&(0,i.jsx)(`button`,{type:`button`,onClick:y,disabled:n===`generating`,style:{marginTop:`12px`,padding:`8px 16px`,fontSize:`14px`,fontWeight:500,background:n===`generating`?`hsl(var(--muted))`:`hsl(var(--accent))`,color:n===`generating`?`hsl(var(--muted-foreground))`:`hsl(var(--accent-foreground))`,border:`1px solid hsl(var(--border))`,borderRadius:`0`,cursor:n===`generating`?`not-allowed`:`pointer`},children:n===`generating`?`Generating…`:`Generate Action Plan`})]}),m&&(0,i.jsxs)(`div`,{style:{marginTop:`16px`,border:`1px solid hsl(var(--border))`,borderRadius:`0`,padding:`12px`,background:`hsl(var(--card))`},children:[(0,i.jsx)(`h3`,{style:{margin:`0 0 8px`,fontSize:`15px`,fontWeight:600,color:`hsl(var(--card-foreground))`},children:`📋 Action Plan`}),(0,i.jsx)(`p`,{style:{fontSize:`13px`,color:`hsl(var(--muted-foreground))`,margin:`0 0 12px`},children:m.summary}),m.files.map((e,t)=>(0,i.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,gap:`8px`,padding:`6px 0`,borderBottom:t<m.files.length-1?`1px solid hsl(var(--border))`:`none`,fontSize:`13px`},children:[(0,i.jsx)(`span`,{style:{background:o[e.priority]??`hsl(var(--muted-foreground))`,color:`hsl(var(--primary-foreground))`,borderRadius:`0`,padding:`2px 6px`,fontSize:`11px`,fontWeight:600,whiteSpace:`nowrap`,flexShrink:0},children:a[e.priority]??`P${e.priority}`}),(0,i.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,i.jsx)(`div`,{style:{fontWeight:500,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,color:`hsl(var(--foreground))`},children:e.file}),(0,i.jsxs)(`div`,{style:{color:`hsl(var(--muted-foreground))`,fontSize:`12px`},children:[e.symbolCount,` symbol(s)`,e.symbols.length>0&&` · ${e.symbols.slice(0,2).join(`, `)}${e.symbols.length>2?`…`:``}`]})]})]},e.file)),(0,i.jsx)(`button`,{type:`button`,onClick:b,disabled:n===`executing`,style:{marginTop:`12px`,padding:`8px 16px`,fontSize:`14px`,fontWeight:500,background:n===`executing`?`hsl(var(--muted))`:`hsl(var(--success))`,color:`hsl(var(--primary-foreground))`,border:`1px solid hsl(var(--border))`,borderRadius:`0`,cursor:n===`executing`?`not-allowed`:`pointer`},children:n===`executing`?`Sending…`:`Execute Plan via Agent`})]})]})}var l={success:`hsl(var(--success))`,warning:`hsl(var(--warning))`,info:`hsl(var(--info))`,destructive:`hsl(var(--destructive))`,primary:`hsl(var(--primary))`};function u({label:e,value:t,token:n}){let r=l[n];return(0,i.jsxs)(`div`,{style:{flex:1,padding:`10px`,borderRadius:`0`,border:`1px solid hsl(var(--border))`,background:`hsl(var(--card))`,textAlign:`center`},children:[(0,i.jsx)(`div`,{style:{fontSize:`24px`,fontWeight:700,color:r},children:t}),(0,i.jsx)(`div`,{style:{fontSize:`12px`,color:`hsl(var(--muted-foreground))`,marginTop:`2px`},children:e})]})}function d({title:e,token:t,children:n}){let r=l[t];return(0,i.jsxs)(`div`,{style:{marginBottom:`12px`},children:[(0,i.jsx)(`h3`,{style:{margin:`0 0 6px`,fontSize:`14px`,fontWeight:600,color:r,borderLeft:`3px solid ${r}`,paddingLeft:`8px`},children:e}),(0,i.jsx)(`div`,{style:{border:`1px solid hsl(var(--border))`,borderRadius:`0`,overflow:`hidden`,fontSize:`13px`},children:n})]})}function f({columns:e}){return(0,i.jsx)(`div`,{style:{display:`flex`,gap:`8px`,padding:`5px 8px`,borderBottom:`1px solid hsl(var(--border))`,fontSize:`13px`,fontFamily:`var(--font-mono, monospace)`,background:`hsl(var(--card))`,color:`hsl(var(--card-foreground))`},children:e.map((e,t)=>(0,i.jsx)(`span`,{style:{flex:t===0?2:1,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e},t))})}export{c as DeadCodeScanPanel};