@a-company/paradigm 3.44.0 → 5.3.3

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 (168) hide show
  1. package/dist/{accept-orchestration-ZUWQUHSK.js → accept-orchestration-GX2YRWM4.js} +5 -5
  2. package/dist/{add-VSPZ6FM4.js → add-FZRKEGH4.js} +1 -1
  3. package/dist/agent-HYKC2LAK.js +387 -0
  4. package/dist/agent-loader-SJPJJS33.js +36 -0
  5. package/dist/{agents-suggest-65SER5IS.js → agents-suggest-DNSYJ6IA.js} +1 -1
  6. package/dist/{aggregate-SV3VGEIL.js → aggregate-H57K7PNV.js} +1 -1
  7. package/dist/{assess-UHBDYIK7.js → assess-4WVXZLZQ.js} +2 -2
  8. package/dist/{auto-24ICVUH4.js → auto-QFS5NHQU.js} +1 -1
  9. package/dist/{beacon-3SJV4DAP.js → beacon-KXZXYQHX.js} +1 -1
  10. package/dist/{calibration-WWHK73WU.js → calibration-V46G7JTY.js} +2 -2
  11. package/dist/{check-OLI6AUS6.js → check-OWAIWV23.js} +1 -1
  12. package/dist/{chunk-RP6TZYGE.js → chunk-2IO7JAG2.js} +1 -1
  13. package/dist/chunk-2T6BTYBN.js +712 -0
  14. package/dist/{chunk-CDMAMDSG.js → chunk-5VKJBNJL.js} +13 -5
  15. package/dist/{chunk-KB4XJWE3.js → chunk-6N3JTACN.js} +98 -437
  16. package/dist/chunk-7N7GSU6K.js +34 -0
  17. package/dist/chunk-A2L4TSLZ.js +526 -0
  18. package/dist/{chunk-P7XSBJE3.js → chunk-ABVQGRF7.js} +1 -1
  19. package/dist/{chunk-HIKKOCXY.js → chunk-EI32ZBE6.js} +1 -1
  20. package/dist/{chunk-QIOCFXDQ.js → chunk-EKGMAM62.js} +1 -1
  21. package/dist/chunk-EZ3GOCYC.js +132 -0
  22. package/dist/chunk-GGMI6C2L.js +1075 -0
  23. package/dist/{chunk-DS5QY37M.js → chunk-GTR2TBIJ.js} +247 -15
  24. package/dist/{chunk-QDXI2DHR.js → chunk-J2JEQRT3.js} +1 -1
  25. package/dist/{chunk-AKIMFN6I.js → chunk-JASGXLK3.js} +2 -2
  26. package/dist/chunk-KVDYJLTC.js +121 -0
  27. package/dist/{chunk-J4E6K5MG.js → chunk-LSRABQIY.js} +25 -1
  28. package/dist/chunk-MCMOGQMU.js +145 -0
  29. package/dist/{chunk-ZXMDA7VB.js → chunk-PDX44BCA.js} +1 -6
  30. package/dist/{chunk-SOBTKFSP.js → chunk-S2HO5MLR.js} +5 -0
  31. package/dist/{chunk-2SKXFXIT.js → chunk-S3ORKP3V.js} +10 -15
  32. package/dist/{chunk-ZMQA6SCO.js → chunk-S6MZ2IEX.js} +628 -228
  33. package/dist/chunk-TAIJOFOE.js +124 -0
  34. package/dist/{chunk-FS3WTUHY.js → chunk-TXESEO7Y.js} +6 -6
  35. package/dist/{chunk-7COU5S2Z.js → chunk-VL67H5IC.js} +1 -1
  36. package/dist/{chunk-QWA26UNO.js → chunk-WQITYKHM.js} +7 -7
  37. package/dist/{chunk-MW5DMGBB.js → chunk-YMDLDELF.js} +114 -55
  38. package/dist/{claude-63ISJAZK.js → claude-FRRWJSTJ.js} +1 -1
  39. package/dist/{claude-cli-ABML5RHX.js → claude-cli-XJLK2X4L.js} +1 -1
  40. package/dist/{claude-code-JRLMRPTO.js → claude-code-HTBA4XRB.js} +1 -1
  41. package/dist/{claude-code-teams-CAJBEFIZ.js → claude-code-teams-T4SP24MD.js} +1 -1
  42. package/dist/{conductor-HLWYWUVH.js → conductor-PGPDVIVE.js} +1 -1
  43. package/dist/{config-schema-3YNIFJCJ.js → config-schema-EA4XALGG.js} +4 -2
  44. package/dist/{constellation-FAGT45TU.js → constellation-A26CCGQS.js} +1 -1
  45. package/dist/{context-audit-557EO6PK.js → context-audit-RLO3ETRP.js} +8 -5
  46. package/dist/{cost-XEBADYFT.js → cost-BGM32XJU.js} +1 -1
  47. package/dist/{cost-UD3WPEKZ.js → cost-VI46A4XL.js} +1 -1
  48. package/dist/{cursor-cli-QUOOF2N4.js → cursor-cli-JVEZGHWQ.js} +1 -1
  49. package/dist/{cursorrules-3TKZ4E4R.js → cursorrules-HLIKJJZT.js} +1 -1
  50. package/dist/decision-loader-WWCLIQPJ.js +20 -0
  51. package/dist/{delete-RRK4RL6Y.js → delete-KBRPQLPC.js} +2 -2
  52. package/dist/{diff-IP5CIARP.js → diff-RQLLNAFI.js} +5 -5
  53. package/dist/{discipline-5F5OVTXB.js → discipline-FA4OZXIS.js} +1 -1
  54. package/dist/{dist-UXWV4OKX.js → dist-34NA5RS5.js} +1 -1
  55. package/dist/{dist-5QE2BB2B-X6DYVSUL.js → dist-5QE2BB2B-5S3T6Y3T.js} +1 -1
  56. package/dist/{dist-CM3MVWWW.js → dist-77JDTVAY.js} +1 -0
  57. package/dist/{dist-POMVY6WP.js → dist-QK4SQAK7.js} +1 -1
  58. package/dist/{dist-3RVKEJRT.js → dist-TA6LSC2Q.js} +1 -1
  59. package/dist/docs-LVLRPBAW.js +155 -0
  60. package/dist/docs-PBZB7LYP.js +89 -0
  61. package/dist/{doctor-GKZJU7QG.js → doctor-ULBOHEIC.js} +3 -3
  62. package/dist/{drift-YGT4LJ7Q.js → drift-R5NRKFHI.js} +1 -1
  63. package/dist/{echo-A6HD5UP7.js → echo-O2LY7CC2.js} +1 -1
  64. package/dist/{edit-4CLNN5JG.js → edit-R2HNLMOG.js} +2 -2
  65. package/dist/event-25OJKDCE.js +31 -0
  66. package/dist/{export-T7CMMJIB.js → export-IWVL7XLF.js} +1 -1
  67. package/dist/{flow-UFMPVOEM.js → flow-CRRVV3O3.js} +2 -2
  68. package/dist/{global-HHUJSBG5.js → global-3NG5JXUB.js} +1 -1
  69. package/dist/graduate-USAWGBJM.js +160 -0
  70. package/dist/{graph-YYUXI3F7.js → graph-VHUMAAS6.js} +2 -2
  71. package/dist/{graph-server-ZPXRSGCW.js → graph-server-YL22VBBN.js} +1 -1
  72. package/dist/{habits-RG5SVKXP.js → habits-OL5NGPXO.js} +3 -3
  73. package/dist/{history-CETCSUCP.js → history-WOWC573W.js} +1 -1
  74. package/dist/{hooks-TCUHQMPF.js → hooks-HFWSCGPV.js} +2 -2
  75. package/dist/index.js +307 -184
  76. package/dist/{integrity-MK2OP5TA.js → integrity-IHO4FZTS.js} +1 -1
  77. package/dist/{integrity-checker-J7YXRTBT.js → integrity-checker-PSKJA5SB.js} +1 -0
  78. package/dist/journal-loader-5EYSBFFY.js +18 -0
  79. package/dist/{lint-HYWGS3JJ.js → lint-K6CJGGPH.js} +1 -1
  80. package/dist/{list-IUCYPGMK.js → list-4YK7QKFF.js} +1 -1
  81. package/dist/{list-BTLFHSRC.js → list-ENR7Q4CR.js} +2 -2
  82. package/dist/{lore-loader-VTEEZDX3.js → lore-loader-7NO6N6FT.js} +4 -1
  83. package/dist/{lore-server-NOOAHKJX.js → lore-server-UNJY5KC3.js} +1 -1
  84. package/dist/{manual-AFJ2J2V3.js → manual-G6FISID5.js} +1 -1
  85. package/dist/mcp.js +3954 -479
  86. package/dist/{migrate-FQVGQNXZ.js → migrate-LS45DNEV.js} +2 -2
  87. package/dist/{migrate-assessments-JP6Q5KME.js → migrate-assessments-RGH4O6IX.js} +2 -2
  88. package/dist/nomination-engine-Q4XSXFKT.js +40 -0
  89. package/dist/notebook-YWIYGEHV.js +155 -0
  90. package/dist/{orchestrate-A226N6FC.js → orchestrate-XZA33TJC.js} +5 -5
  91. package/dist/peers-DEOUIZM6.js +82 -0
  92. package/dist/persona-UHAHIVST.js +390 -0
  93. package/dist/{pipeline-3G2FRAKM.js → pipeline-L4HCSBGN.js} +1 -1
  94. package/dist/{platform-server-KHL6ZPPN.js → platform-server-PMD57BEG.js} +264 -18
  95. package/dist/{plugin-update-checker-HMRPGY5Z.js → plugin-update-checker-ELOEEQYS.js} +1 -0
  96. package/dist/{portal-check-FF5EKZE5.js → portal-check-NPYGII2D.js} +2 -2
  97. package/dist/{portal-compliance-VU4NIFEN.js → portal-compliance-J7DGAPFX.js} +2 -2
  98. package/dist/{probe-7JK7IDNI.js → probe-MHL5HQZ2.js} +3 -3
  99. package/dist/{promote-XO63XMAN.js → promote-F6ZYZZAL.js} +2 -2
  100. package/dist/{providers-YNFSL6HK.js → providers-GK7PB2OL.js} +2 -2
  101. package/dist/{quiz-I75NU2QQ.js → quiz-M66SC7F7.js} +1 -1
  102. package/dist/{record-46CLR4OG.js → record-RA4WR2BO.js} +2 -2
  103. package/dist/{reindex-WIJMCJ4A.js → reindex-HRA2AUS6.js} +3 -2
  104. package/dist/{remember-4EUZKIIB.js → remember-HBWJ655S.js} +1 -1
  105. package/dist/{retag-KC4JVRLE.js → retag-3OLCVDEQ.js} +2 -2
  106. package/dist/{review-Q7M4CRB5.js → review-27ATYTD2.js} +2 -2
  107. package/dist/review-57QMURZV.js +334 -0
  108. package/dist/{ripple-RI3LOT6R.js → ripple-JPBXP5I3.js} +1 -1
  109. package/dist/{sentinel-UOIGJWHH.js → sentinel-4XIG4STA.js} +2 -2
  110. package/dist/{sentinel-bridge-APDXYAZS.js → sentinel-bridge-MDUXTQRL.js} +2 -2
  111. package/dist/{serve-JVXSRSUB.js → serve-FLTFTM3P.js} +2 -2
  112. package/dist/{serve-22A4XOIG.js → serve-INL7SNBK.js} +2 -2
  113. package/dist/{serve-2YJ6D2Y6.js → serve-KBSE36PL.js} +4 -4
  114. package/dist/{server-JV6UFGWZ.js → server-54SKYFFY.js} +2 -2
  115. package/dist/{server-RDLQ3DK7.js → server-XUOIO7E6.js} +1 -1
  116. package/dist/{setup-YNZJQLW7.js → setup-EDS27WUR.js} +1 -1
  117. package/dist/{setup-M2ZKLKNN.js → setup-KO5AFC4K.js} +2 -2
  118. package/dist/{shift-LNMKFYLR.js → shift-VFG23DLA.js} +16 -16
  119. package/dist/{show-P7GYO43X.js → show-5PV5KFJE.js} +2 -2
  120. package/dist/{show-PKZMYKRN.js → show-NQKYX6WQ.js} +1 -1
  121. package/dist/{snapshot-Y3COXK4T.js → snapshot-BK4RBPCG.js} +1 -1
  122. package/dist/{spawn-SSXZX45U.js → spawn-AW6GDECS.js} +3 -3
  123. package/dist/{status-KLHALGW4.js → status-WGIAQODY.js} +1 -1
  124. package/dist/{summary-5NQNOD3F.js → summary-NIRABMF5.js} +2 -2
  125. package/dist/{sweep-EZU3GU6S.js → sweep-QMHNSIY5.js} +2 -2
  126. package/dist/{switch-WYUMVNA5.js → switch-6EJPZDIA.js} +1 -1
  127. package/dist/{symphony-EYRGGVNE.js → symphony-4OCY36AI.js} +350 -29
  128. package/dist/{symphony-QWOEKZMC.js → symphony-B75X2MME.js} +20 -2
  129. package/dist/symphony-peers-2ZQYLRNI.js +34 -0
  130. package/dist/symphony-peers-OL7F6M5S.js +121 -0
  131. package/dist/symphony-relay-UJYUXN65.js +710 -0
  132. package/dist/{sync-ZM4Q3R4U.js → sync-VEHUH4OA.js} +3 -3
  133. package/dist/{sync-llms-JIPP3XX4.js → sync-llms-YHCFIE6X.js} +2 -2
  134. package/dist/{task-loader-7M2FCBX6.js → task-loader-LDYWQSLM.js} +1 -0
  135. package/dist/{team-HGLJXWQG.js → team-7HG7XK5C.js} +6 -6
  136. package/dist/{test-WTR5Q33E.js → test-566CP5KC.js} +1 -1
  137. package/dist/{thread-3WM7KKID.js → thread-N754I4D5.js} +1 -1
  138. package/dist/{timeline-ANC7LVDL.js → timeline-M3CICQFE.js} +2 -2
  139. package/dist/{triage-IZ4MDYNB.js → triage-HHYGT3HY.js} +1 -1
  140. package/dist/{tutorial-GC6QL4US.js → tutorial-KD22SUNO.js} +1 -1
  141. package/dist/university-content/courses/.purpose +66 -0
  142. package/dist/university-content/courses/para-401.json +146 -0
  143. package/dist/university-content/courses/para-501.json +151 -0
  144. package/dist/university-content/courses/para-601.json +608 -0
  145. package/dist/university-content/plsat/.purpose +6 -0
  146. package/dist/university-content/plsat/v2.0.json +2 -2
  147. package/dist/university-content/plsat/v3.0.json +563 -3
  148. package/dist/university-content/reference.json +91 -0
  149. package/dist/{upgrade-ANX3LVSA.js → upgrade-H5PF32BW.js} +2 -2
  150. package/dist/{validate-GD5XWILV.js → validate-CNKEKO6A.js} +1 -1
  151. package/dist/{validate-ITC5D6QG.js → validate-MB5ULIHS.js} +1 -1
  152. package/dist/{validate-ZVPNN4FL.js → validate-QH3LADM6.js} +1 -1
  153. package/dist/{watch-X64UK7K4.js → watch-2TKP5PVL.js} +3 -3
  154. package/dist/{watch-ERBEJUJW.js → watch-ZF4ML6CD.js} +2 -2
  155. package/dist/{wisdom-L2WC7J62.js → wisdom-AATMGNFA.js} +1 -1
  156. package/dist/work-log-loader-5L45XNYZ.js +14 -0
  157. package/dist/{workspace-UIUTHZTD.js → workspace-6E6OSRNU.js} +4 -4
  158. package/package.json +1 -1
  159. package/platform-ui/dist/assets/DocsSection-ByAgPzWV.js +1 -0
  160. package/platform-ui/dist/assets/DocsSection-CjdO6R-u.css +1 -0
  161. package/platform-ui/dist/assets/{GitSection-BD3Ze06e.js → GitSection-BLovj9yT.js} +1 -1
  162. package/platform-ui/dist/assets/{GraphSection-SglITfSs.js → GraphSection-C5PCPUFl.js} +1 -1
  163. package/platform-ui/dist/assets/{LoreSection-bR5Km4Fd.js → LoreSection-BftejTla.js} +1 -1
  164. package/platform-ui/dist/assets/{SentinelSection-QSpAZArG.js → SentinelSection-CnYcasN7.js} +1 -1
  165. package/platform-ui/dist/assets/{SymphonySection-CobYJgvg.js → SymphonySection-BpmqCHeK.js} +1 -1
  166. package/platform-ui/dist/assets/{index-DbxeSMkV.js → index-G9JnWEs_.js} +10 -10
  167. package/platform-ui/dist/index.html +1 -1
  168. package/dist/dist-PSF5CP4I.js +0 -7294
@@ -1 +1 @@
1
- import{c as A,j as e,r as p,R as y}from"./index-DbxeSMkV.js";function k(){try{const t=localStorage.getItem("paradigm-lore-theme");if(t==="light"||t==="dark")return t}catch{}return"dark"}function T(){try{const t=localStorage.getItem("paradigm-lore-left-authors");if(t)return JSON.parse(t)}catch{}return[]}const c=A((t,r)=>({entries:[],filter:{},view:"timeline",selectedEntryId:null,symbols:[],authors:[],selectedSymbol:null,selectedAuthor:null,sessions:[],selectedSessionId:null,loading:!1,projectName:"",theme:k(),leftAuthors:T(),setView:s=>t({view:s}),setFilter:s=>{t(n=>({filter:{...n.filter,...s}})),r().fetchEntries()},clearFilters:()=>{t({filter:{}}),r().fetchEntries()},selectEntry:s=>t({selectedEntryId:s}),selectSymbol:s=>t({selectedSymbol:s}),selectAuthor:s=>t({selectedAuthor:s}),toggleTheme:()=>{const s=r().theme==="dark"?"light":"dark";document.documentElement.setAttribute("data-theme",s);try{localStorage.setItem("paradigm-lore-theme",s)}catch{}t({theme:s})},toggleLeftAuthor:s=>{const n=r().leftAuthors,a=n.includes(s)?n.filter(i=>i!==s):[...n,s];try{localStorage.setItem("paradigm-lore-left-authors",JSON.stringify(a))}catch{}t({leftAuthors:a})},selectSession:async s=>{if(t({selectedSessionId:s}),s)try{const a=await(await fetch(`/api/sessions/${encodeURIComponent(s)}`)).json();t(i=>({sessions:i.sessions.map(x=>x.id===s?{...x,entries:a.entries}:x)}))}catch{}},fetchEntries:async()=>{var s;t({loading:!0});try{const n=r().filter,a=new URLSearchParams;n.author&&a.set("author",n.author),n.hasAgent!==void 0?a.set("hasAgent",String(n.hasAgent)):n.authorType&&a.set("authorType",n.authorType),n.symbol&&a.set("symbol",n.symbol),n.type&&a.set("type",n.type),n.dateFrom&&a.set("from",n.dateFrom),n.dateTo&&a.set("to",n.dateTo),n.tag&&a.set("tag",n.tag),(s=n.tags)!=null&&s.length&&a.set("tags",n.tags.join(",")),n.hasReview!==void 0&&a.set("hasReview",String(n.hasReview)),n.hasBody!==void 0&&a.set("hasBody",String(n.hasBody)),a.set("limit","200");let d=(await(await fetch(`/api/lore?${a}`)).json()).entries||[];if(n.search){const h=n.search.toLowerCase();d=d.filter(u=>{var m;return u.title.toLowerCase().includes(h)||u.summary.toLowerCase().includes(h)||((m=u.symbols_touched)==null?void 0:m.some(j=>j.toLowerCase().includes(h)))})}t({entries:d,loading:!1})}catch{t({loading:!1})}},fetchSymbols:async()=>{try{const n=await(await fetch("/api/lore/symbols")).json();t({symbols:n.symbols||[]})}catch{}},fetchAuthors:async()=>{try{const n=await(await fetch("/api/lore/authors")).json();t({authors:n.authors||[]})}catch{}},fetchSessions:async()=>{try{const n=await(await fetch("/api/sessions")).json();t({sessions:n.sessions||[]})}catch{}},fetchAll:async()=>{try{const n=await(await fetch("/api/info")).json();t({projectName:n.project||""})}catch{}await Promise.all([r().fetchEntries(),r().fetchSymbols(),r().fetchAuthors(),r().fetchSessions()])}})),C=[{mode:"timeline",label:"Timeline"},{mode:"session",label:"Sessions"},{mode:"symbol",label:"Symbol"},{mode:"author",label:"Author"}];function F(){const t=c(a=>a.view),r=c(a=>a.setView),s=c(a=>a.theme),n=c(a=>a.toggleTheme);return e.jsxs("div",{className:"view-switcher-row",children:[e.jsx("div",{className:"view-switcher",children:C.map(a=>e.jsx("button",{className:`view-tab ${t===a.mode?"active":""}`,onClick:()=>r(a.mode),children:a.label},a.mode))}),e.jsx("button",{className:"theme-toggle",onClick:n,title:s==="dark"?"Switch to light mode":"Switch to dark mode",children:s==="dark"?"☀️":"🌙"})]})}const L=["","agent-session","human-note","decision","review","incident","milestone","retro","insight"],R=[{value:void 0,label:"All"},{value:!1,label:"Human Only"},{value:!0,label:"AI-Assisted"}];function E(){const t=c(l=>l.filter),r=c(l=>l.setFilter),s=c(l=>l.clearFilters),n=c(l=>l.authors),a=c(l=>l.symbols),[i,x]=p.useState(""),[d,h]=p.useState(!1),u=p.useRef(null),m=p.useRef(null),[j,v]=p.useState([]),b=Object.values(t).some(l=>l!==void 0&&l!==""&&(Array.isArray(l)?l.length>0:!0)),o=i?a.filter(l=>l.symbol.toLowerCase().includes(i.toLowerCase())).slice(0,10):a.slice(0,10);return p.useEffect(()=>{fetch("/api/lore/tags").then(l=>l.json()).then(l=>v(l.tags||[])).catch(()=>{})},[]),p.useEffect(()=>{function l(S){m.current&&!m.current.contains(S.target)&&u.current&&!u.current.contains(S.target)&&h(!1)}return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[]),e.jsxs("div",{className:"filter-bar",children:[e.jsx("div",{className:"author-type-toggle",children:R.map(l=>e.jsx("button",{className:`author-type-pill ${t.hasAgent===l.value?"active":""} ${l.value===void 0?"all":l.value?"agent":"human"}`,onClick:()=>r({hasAgent:l.value}),children:l.label},l.label))}),e.jsxs("select",{value:t.author||"",onChange:l=>r({author:l.target.value||void 0}),children:[e.jsx("option",{value:"",children:"All authors"}),n.map(l=>e.jsxs("option",{value:l.id,children:[l.hasAgent?"🤖":"👤"," ",l.id]},l.id))]}),e.jsxs("select",{value:t.type||"",onChange:l=>r({type:l.target.value||void 0}),children:[e.jsx("option",{value:"",children:"All types"}),L.filter(Boolean).map(l=>e.jsx("option",{value:l,children:l},l))]}),j.length>0&&e.jsxs("select",{value:t.tag||"",onChange:l=>r({tag:l.target.value||void 0}),children:[e.jsx("option",{value:"",children:"All tags"}),j.map(l=>e.jsxs("option",{value:l.tag,children:[l.tag," (",l.count,")"]},l.tag))]}),e.jsxs("div",{className:"symbol-autocomplete-wrapper",children:[e.jsx("input",{ref:u,type:"text",placeholder:t.symbol?`Symbol: ${t.symbol}`:"Filter by symbol...",value:i,onChange:l=>{x(l.target.value),h(!0)},onFocus:()=>h(!0),style:{width:160}}),t.symbol&&e.jsx("button",{className:"symbol-clear",onClick:()=>{r({symbol:void 0}),x("")},children:"x"}),d&&o.length>0&&e.jsx("div",{className:"symbol-dropdown",ref:m,children:o.map(l=>e.jsxs("div",{className:`symbol-dropdown-item ${t.symbol===l.symbol?"active":""}`,onClick:()=>{r({symbol:l.symbol}),x(""),h(!1)},children:[e.jsx("span",{className:"symbol-dropdown-name",children:l.symbol}),e.jsx("span",{className:"symbol-dropdown-count",children:l.count})]},l.symbol))})]}),e.jsx("input",{type:"text",placeholder:"Search...",value:t.search||"",onChange:l=>r({search:l.target.value||void 0}),style:{width:140}}),e.jsx("input",{type:"date",value:t.dateFrom||"",onChange:l=>r({dateFrom:l.target.value||void 0}),title:"From date"}),e.jsx("input",{type:"date",value:t.dateTo||"",onChange:l=>r({dateTo:l.target.value||void 0}),title:"To date"}),e.jsx("button",{className:`filter-preset ${t.hasReview===!1?"active":""}`,onClick:()=>r({hasReview:t.hasReview===!1?void 0:!1}),children:"Needs Review"}),b&&e.jsx("button",{className:"filter-clear",onClick:s,children:"Clear filters"})]})}const $={"#":"component","^":"gate",$:"flow","!":"signal","~":"aspect"};function g({symbol:t}){const r=t.charAt(0),s=$[r]||"component";return e.jsx("span",{className:`symbol-tag ${s}`,children:t})}function _({status:t}){if(!t)return null;const r={pass:{icon:"✓",className:"pass"},fail:{icon:"✗",className:"fail"},partial:{icon:"⚠",className:"partial"},untested:{icon:"·",className:""}},s=r[t]||r.untested;return e.jsxs("span",{className:`lore-card-verify ${s.className}`,children:[s.icon," ",t]})}function w({rating:t}){return e.jsxs("span",{className:"review-stars",children:["★".repeat(t),"☆".repeat(5-t)]})}function z(){var a,i,x,d,h,u,m,j,v,b;const t=c(o=>o.selectedEntryId),r=c(o=>o.selectEntry),[s,n]=p.useState(null);return p.useEffect(()=>{if(!t){n(null);return}fetch(`/api/lore/${t}`).then(o=>o.json()).then(n).catch(()=>n(null))},[t]),!t||!s?null:e.jsxs("div",{className:"detail-overlay",children:[e.jsx("div",{className:"detail-backdrop",onClick:()=>r(null)}),e.jsxs("div",{className:"detail-panel",children:[e.jsxs("div",{className:"detail-header",children:[e.jsxs("div",{children:[e.jsx("div",{className:"lore-card-title",style:{fontSize:16},children:s.title}),e.jsxs("div",{style:{display:"flex",gap:8,marginTop:4,alignItems:"center"},children:[e.jsx("span",{className:`lore-card-type ${s.type}`,children:s.type}),e.jsx("span",{style:{color:"var(--text-muted)",fontSize:12},children:s.id})]})]}),e.jsx("button",{className:"detail-close",onClick:()=>r(null),children:"✕"})]}),e.jsxs("div",{className:"detail-body",children:[e.jsxs("div",{className:"detail-section",children:[e.jsx("h3",{children:"Details"}),e.jsxs("dl",{className:"detail-meta",children:[e.jsx("dt",{children:"Author"}),e.jsxs("dd",{children:["👤"," ",typeof s.author=="string"?s.author:"unknown"]}),s.agent&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"AI Agent"}),e.jsxs("dd",{children:["🤖"," ",s.agent.model,s.agent.provider?` (${s.agent.provider})`:""]})]}),e.jsx("dt",{children:"Time"}),e.jsx("dd",{children:new Date(s.timestamp).toLocaleString()}),s.duration_minutes&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Duration"}),e.jsxs("dd",{children:[s.duration_minutes," minutes"]})]}),s.commit&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Commit"}),e.jsx("dd",{style:{fontFamily:"monospace",fontSize:12},children:s.commit})]})]})]}),e.jsxs("div",{className:"detail-section",children:[e.jsx("h3",{children:"Summary"}),e.jsx("p",{style:{fontSize:13,color:"var(--text-secondary)"},children:s.summary})]}),s.body&&e.jsxs("div",{className:"detail-section",children:[e.jsx("h3",{children:"Body"}),e.jsx("pre",{style:{fontSize:12,color:"var(--text-secondary)",whiteSpace:"pre-wrap",wordBreak:"break-word",background:"var(--bg-primary)",padding:12,borderRadius:6,border:"1px solid var(--border)",maxHeight:300,overflowY:"auto"},children:s.body})]}),(a=s.linked_lore)!=null&&a.length||(i=s.linked_tasks)!=null&&i.length||(x=s.linked_commits)!=null&&x.length?e.jsxs("div",{className:"detail-section",children:[e.jsx("h3",{children:"Linked"}),e.jsxs("dl",{className:"detail-meta",children:[s.linked_lore&&s.linked_lore.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Lore"}),e.jsx("dd",{children:s.linked_lore.map(o=>e.jsx("span",{onClick:()=>r(o),style:{cursor:"pointer",color:"var(--color-component)",textDecoration:"underline",marginRight:8,fontSize:12},children:o},o))})]}),s.linked_tasks&&s.linked_tasks.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Tasks"}),e.jsx("dd",{children:s.linked_tasks.map(o=>e.jsx("span",{style:{fontFamily:"monospace",fontSize:12,marginRight:8},children:o},o))})]}),s.linked_commits&&s.linked_commits.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Commits"}),e.jsx("dd",{children:s.linked_commits.map(o=>e.jsx("span",{style:{fontFamily:"monospace",fontSize:12,marginRight:8},children:o.slice(0,8)},o))})]})]})]}):null,((d=s.symbols_touched)==null?void 0:d.length)>0&&e.jsxs("div",{className:"detail-section",children:[e.jsx("h3",{children:"Symbols Touched"}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:s.symbols_touched.map(o=>e.jsx(g,{symbol:o},o))})]}),s.symbols_created&&s.symbols_created.length>0&&e.jsxs("div",{className:"detail-section",children:[e.jsx("h3",{children:"Symbols Created"}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:s.symbols_created.map(o=>e.jsx(g,{symbol:o},o))})]}),(h=s.files_created)!=null&&h.length||(u=s.files_modified)!=null&&u.length?e.jsxs("div",{className:"detail-section",children:[e.jsxs("h3",{children:["Files (",(((m=s.files_created)==null?void 0:m.length)||0)+(((j=s.files_modified)==null?void 0:j.length)||0),")"]}),e.jsxs("ul",{className:"detail-files",children:[(v=s.files_created)==null?void 0:v.map(o=>e.jsxs("li",{style:{color:"#34d399"},children:["+ ",o]},o)),(b=s.files_modified)==null?void 0:b.map(o=>e.jsxs("li",{style:{color:"#fbbf24"},children:["~ ",o]},o))]}),s.lines_added||s.lines_removed?e.jsxs("p",{style:{fontSize:12,color:"var(--text-muted)",marginTop:4},children:[e.jsxs("span",{style:{color:"#34d399"},children:["+",s.lines_added||0]})," ",e.jsxs("span",{style:{color:"#f87171"},children:["-",s.lines_removed||0]})," lines"]}):null]}):null,s.decisions&&s.decisions.length>0&&e.jsxs("div",{className:"detail-section",children:[e.jsx("h3",{children:"Decisions"}),s.decisions.map(o=>e.jsxs("div",{className:"detail-decision",children:[e.jsx("div",{className:"decision-text",children:o.decision}),e.jsx("div",{className:"decision-rationale",children:o.rationale})]},o.id))]}),s.errors_encountered&&s.errors_encountered.length>0&&e.jsxs("div",{className:"detail-section",children:[e.jsx("h3",{children:"Errors Encountered"}),s.errors_encountered.map((o,l)=>e.jsxs("div",{className:"detail-error",children:[e.jsx("div",{style:{color:"var(--color-incident)",fontSize:13},children:o.description}),e.jsxs("div",{style:{color:"var(--text-secondary)",fontSize:12,marginTop:2},children:["→"," ",o.resolution,o.time_to_fix?` (${o.time_to_fix})`:""]})]},l))]}),s.learnings&&s.learnings.length>0&&e.jsxs("div",{className:"detail-section",children:[e.jsx("h3",{children:"Learnings"}),s.learnings.map((o,l)=>e.jsx("div",{className:"detail-learning",children:o},l))]}),s.verification&&e.jsxs("div",{className:"detail-section",children:[e.jsx("h3",{children:"Verification"}),e.jsx(_,{status:s.verification.status}),s.verification.details&&e.jsx("dl",{className:"detail-meta",style:{marginTop:8},children:Object.entries(s.verification.details).map(([o,l])=>e.jsxs(y.Fragment,{children:[e.jsx("dt",{children:o}),e.jsx("dd",{style:{color:l==="pass"?"#34d399":"#f87171"},children:l})]},o))})]}),(s.confidence!=null||s.assessment)&&e.jsxs("div",{className:"detail-section",children:[e.jsx("h3",{children:"Confidence & Assessment"}),e.jsxs("dl",{className:"detail-meta",children:[s.confidence!=null&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Confidence"}),e.jsx("dd",{children:e.jsxs("span",{style:{padding:"2px 8px",background:"rgba(139, 92, 246, 0.15)",border:"1px solid rgba(139, 92, 246, 0.3)",borderRadius:10,fontSize:12,color:"#8b5cf6"},children:[(s.confidence*100).toFixed(0),"%"]})})]}),s.assessment&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Verdict"}),e.jsx("dd",{children:e.jsx("span",{style:{padding:"2px 8px",background:s.assessment.verdict==="correct"?"rgba(52, 211, 153, 0.15)":s.assessment.verdict==="partial"?"rgba(251, 191, 36, 0.15)":"rgba(248, 113, 113, 0.15)",border:`1px solid ${s.assessment.verdict==="correct"?"rgba(52, 211, 153, 0.3)":s.assessment.verdict==="partial"?"rgba(251, 191, 36, 0.3)":"rgba(248, 113, 113, 0.3)"}`,borderRadius:10,fontSize:12,color:s.assessment.verdict==="correct"?"#34d399":s.assessment.verdict==="partial"?"#fbbf24":"#f87171"},children:s.assessment.verdict})}),e.jsx("dt",{children:"Assessed by"}),e.jsx("dd",{children:s.assessment.assessed_by}),e.jsx("dt",{children:"Assessed at"}),e.jsx("dd",{children:new Date(s.assessment.assessed_at).toLocaleString()}),s.assessment.notes&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Notes"}),e.jsx("dd",{children:s.assessment.notes})]})]}),s.assessment_delta!=null&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Delta"}),e.jsxs("dd",{style:{color:Math.abs(s.assessment_delta)<=.1?"#34d399":Math.abs(s.assessment_delta)<=.3?"#fbbf24":"#f87171"},children:[s.assessment_delta>0?"+":"",s.assessment_delta.toFixed(2)," ",e.jsxs("span",{style:{fontSize:11,color:"var(--text-muted)"},children:["(",s.assessment_delta>.1?"under-confident":s.assessment_delta<-.1?"over-confident":"well-calibrated",")"]})]})]})]})]}),s.review?e.jsxs("div",{className:"detail-section",children:[e.jsx("h3",{children:"Review"}),e.jsxs("dl",{className:"detail-meta",children:[e.jsx("dt",{children:"Reviewer"}),e.jsx("dd",{children:s.review.reviewer}),e.jsx("dt",{children:"Completeness"}),e.jsx("dd",{children:e.jsx(w,{rating:s.review.completeness})}),e.jsx("dt",{children:"Quality"}),e.jsx("dd",{children:e.jsx(w,{rating:s.review.quality})}),s.review.notes&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Notes"}),e.jsx("dd",{children:s.review.notes})]})]})]}):e.jsxs("div",{className:"detail-section",children:[e.jsx("h3",{children:"Review"}),e.jsxs("p",{style:{color:"var(--text-muted)",fontSize:13},children:["No review yet. Run ",e.jsxs("code",{style:{background:"var(--bg-card)",padding:"2px 4px",borderRadius:3},children:["paradigm lore review ",s.id]})]})]}),s.git_context&&e.jsxs("div",{className:"detail-section",children:[e.jsx("h3",{children:"Git Context"}),e.jsxs("dl",{className:"detail-meta",children:[e.jsx("dt",{children:"Commit"}),e.jsx("dd",{style:{fontFamily:"monospace",fontSize:12},children:s.git_context.ref.slice(0,8)}),e.jsx("dt",{children:"Branch"}),e.jsx("dd",{children:s.git_context.branch}),e.jsx("dt",{children:"Working tree"}),e.jsx("dd",{children:s.git_context.dirty?"Dirty (uncommitted changes)":"Clean"})]})]}),s.meta&&Object.keys(s.meta).length>0&&e.jsxs("div",{className:"detail-section",children:[e.jsx("h3",{children:"Metadata"}),e.jsx("dl",{className:"detail-meta",children:Object.entries(s.meta).map(([o,l])=>e.jsxs(y.Fragment,{children:[e.jsx("dt",{children:o}),e.jsx("dd",{children:typeof l=="object"?JSON.stringify(l):String(l)})]},o))})]}),s.tags&&s.tags.length>0&&e.jsxs("div",{className:"detail-section",children:[e.jsx("h3",{children:"Tags"}),e.jsx("div",{style:{display:"flex",gap:4,flexWrap:"wrap"},children:s.tags.map(o=>{const l=o.startsWith("arc:");return e.jsxs("span",{style:{padding:"2px 8px",background:l?"var(--color-flow-bg, rgba(96, 165, 250, 0.15))":"var(--bg-primary)",border:`1px solid ${l?"var(--color-flow, #60a5fa)":"var(--border)"}`,borderRadius:12,fontSize:11,color:l?"var(--color-flow, #60a5fa)":"var(--text-secondary)"},children:[l?"↻ ":"",o]},o)})})]})]})]})]})}function D(t){return new Date(t).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"})}function N({entry:t,side:r="right"}){var x,d,h,u;const s=c(m=>m.selectEntry),n=t.agent!=null,a=(((x=t.files_created)==null?void 0:x.length)||0)+(((d=t.files_modified)==null?void 0:d.length)||0),i=(t.lines_added||0)+(t.lines_removed||0);return e.jsx("div",{className:`lore-card-row ${r} ${n?"agent":"human"}`,children:e.jsxs("div",{className:"lore-card",onClick:()=>s(t.id),children:[e.jsxs("div",{className:"lore-card-header",children:[e.jsx("div",{className:"lore-card-author",children:e.jsxs("span",{className:`author-badge ${n?"agent":"human"}`,children:[n?"🤖":"👤"," ",typeof t.author=="string"?t.author:"unknown"]})}),e.jsx("span",{className:`lore-card-type ${t.type||"agent-session"}`,children:t.type||"agent-session"})]}),e.jsx("div",{className:"lore-card-title",children:t.title}),e.jsx("div",{className:"lore-card-summary",children:t.summary}),t.body&&e.jsxs("div",{style:{fontSize:11,color:"var(--text-muted)",marginTop:4,fontStyle:"italic",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[t.body.slice(0,100),t.body.length>100?"...":""]}),((h=t.symbols_touched)==null?void 0:h.length)>0&&e.jsxs("div",{className:"lore-card-symbols",children:[t.symbols_touched.slice(0,5).map(m=>e.jsx(g,{symbol:m},m)),t.symbols_touched.length>5&&e.jsxs("span",{className:"symbol-tag component",children:["+",t.symbols_touched.length-5]})]}),Array.isArray(t.tags)&&t.tags.some(m=>m.startsWith("arc:"))&&e.jsx("div",{style:{display:"flex",gap:4,marginTop:4,flexWrap:"wrap"},children:t.tags.filter(m=>m.startsWith("arc:")).map(m=>e.jsxs("span",{style:{padding:"1px 6px",background:"rgba(96, 165, 250, 0.15)",border:"1px solid rgba(96, 165, 250, 0.3)",borderRadius:10,fontSize:10,color:"#60a5fa"},children:["↻"," ",m]},m))}),e.jsxs("div",{className:"lore-card-footer",children:[e.jsxs("div",{className:"lore-card-stats",children:[a>0&&e.jsxs("span",{children:[a," files"]}),i>0&&e.jsxs("span",{children:[i," loc"]}),t.duration_minutes&&e.jsxs("span",{children:[t.duration_minutes,"m"]}),e.jsx(_,{status:(u=t.verification)==null?void 0:u.status}),t.confidence!=null&&e.jsxs("span",{style:{padding:"1px 5px",background:"rgba(139, 92, 246, 0.15)",border:"1px solid rgba(139, 92, 246, 0.3)",borderRadius:8,fontSize:10,color:"#8b5cf6"},children:[(t.confidence*100).toFixed(0),"%"]}),t.assessment&&e.jsx("span",{style:{padding:"1px 5px",background:t.assessment.verdict==="correct"?"rgba(52, 211, 153, 0.15)":t.assessment.verdict==="partial"?"rgba(251, 191, 36, 0.15)":"rgba(248, 113, 113, 0.15)",border:`1px solid ${t.assessment.verdict==="correct"?"rgba(52, 211, 153, 0.3)":t.assessment.verdict==="partial"?"rgba(251, 191, 36, 0.3)":"rgba(248, 113, 113, 0.3)"}`,borderRadius:8,fontSize:10,color:t.assessment.verdict==="correct"?"#34d399":t.assessment.verdict==="partial"?"#fbbf24":"#f87171"},children:t.assessment.verdict})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.review&&e.jsx(w,{rating:t.review.quality}),e.jsx("span",{children:D(t.timestamp)})]})]})]})})}function I({date:t,humanCount:r,agentCount:s}){const a=new Date(t).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"});return e.jsxs("div",{className:"date-separator",children:[e.jsx("span",{className:"date-count human",children:r}),e.jsx("span",{className:"date-badge",children:a}),e.jsx("span",{className:"date-count agent",children:s})]})}function B(){const t=c(d=>d.entries),r=c(d=>d.authors),s=c(d=>d.leftAuthors),n=c(d=>d.toggleLeftAuthor);if(t.length===0)return e.jsxs("div",{className:"empty-state",children:[e.jsx("h2",{children:"No lore entries yet"}),e.jsxs("p",{children:["Record your first entry with ",e.jsx("code",{children:"paradigm lore record"})," or via the MCP tool ",e.jsx("code",{children:"paradigm_lore_record"}),"."]})]});const a=s.length>0,i=new Map;for(const d of t){const h=d.timestamp.slice(0,10);i.has(h)||i.set(h,[]),i.get(h).push(d)}const x=d=>s.includes(d);return e.jsxs("div",{className:`thread-view ${a?"":"single-column"}`,children:[a&&e.jsx("div",{className:"timeline-spine"}),e.jsx("div",{className:"timeline-column-labels",children:a?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"column-label-group left",children:s.map(d=>e.jsxs("button",{className:"column-author-pill active",onClick:()=>n(d),title:"Remove from left column",children:[d," ×"]},d))}),e.jsx("div",{className:"column-label-group right",children:e.jsx("span",{className:"column-label-text",children:"EVERYONE ELSE"})})]}):e.jsxs("div",{className:"column-author-selector",children:[e.jsx("span",{className:"column-label-text",children:"Pick an author for the left column:"}),r.map(d=>e.jsx("button",{className:"column-author-pill",onClick:()=>n(d.id),children:d.id},d.id))]})}),Array.from(i.entries()).map(([d,h])=>{const u=h.filter(j=>x(j.author)).length,m=h.filter(j=>!x(j.author)).length;return e.jsxs(y.Fragment,{children:[e.jsx(I,{date:d,humanCount:u,agentCount:m}),h.map(j=>e.jsx(N,{entry:j,side:a&&x(j.author)?"left":"right"},j.id))]},d)})]})}function O(){const t=c(i=>i.symbols),r=c(i=>i.entries),s=c(i=>i.selectedSymbol),n=c(i=>i.selectSymbol),a=c(i=>i.setFilter);return p.useEffect(()=>{a(s?{symbol:s}:{symbol:void 0})},[s]),e.jsxs("div",{className:"sidebar-view",children:[e.jsxs("div",{className:"sidebar",children:[e.jsxs("div",{style:{padding:"12px 16px",borderBottom:"1px solid var(--border)",fontSize:11,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.05em"},children:["Symbols (",t.length,")"]}),t.map(i=>e.jsxs("div",{className:`sidebar-item ${s===i.symbol?"active":""}`,onClick:()=>n(s===i.symbol?null:i.symbol),children:[e.jsx("span",{className:"sidebar-item-name",children:e.jsx(g,{symbol:i.symbol})}),e.jsx("span",{className:"sidebar-item-count",children:i.count})]},i.symbol)),t.length===0&&e.jsx("div",{style:{padding:20,color:"var(--text-muted)",textAlign:"center",fontSize:13},children:"No symbols found"})]}),e.jsx("div",{className:"sidebar-content",children:s?e.jsxs(e.Fragment,{children:[e.jsxs("h2",{style:{fontSize:16,marginBottom:16},children:[e.jsx(g,{symbol:s})," entries"]}),r.length===0?e.jsx("div",{style:{color:"var(--text-muted)"},children:"No entries for this symbol"}):r.map(i=>e.jsx("div",{style:{marginBottom:12},children:e.jsx(N,{entry:i})},i.id))]}):e.jsxs("div",{className:"empty-state",children:[e.jsx("h2",{children:"Select a symbol"}),e.jsx("p",{children:"Choose a symbol from the sidebar to view its history."})]})})]})}function V(){const t=c(i=>i.authors),r=c(i=>i.entries),s=c(i=>i.selectedAuthor),n=c(i=>i.selectAuthor),a=c(i=>i.setFilter);return p.useEffect(()=>{a(s?{author:s}:{author:void 0})},[s]),e.jsxs("div",{className:"sidebar-view",children:[e.jsxs("div",{className:"sidebar",children:[e.jsxs("div",{style:{padding:"12px 16px",borderBottom:"1px solid var(--border)",fontSize:11,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.05em"},children:["Authors (",t.length,")"]}),t.map(i=>e.jsxs("div",{className:`sidebar-item ${s===i.id?"active":""}`,onClick:()=>n(s===i.id?null:i.id),children:[e.jsxs("div",{children:[e.jsxs("span",{className:"sidebar-item-name",children:[i.hasAgent?"🤖":"👤"," ",i.id]}),e.jsxs("div",{style:{fontSize:10,color:"var(--text-muted)",marginTop:2},children:["Last active: ",new Date(i.lastActive).toLocaleDateString()]})]}),e.jsx("span",{className:"sidebar-item-count",children:i.count})]},i.id)),t.length===0&&e.jsx("div",{style:{padding:20,color:"var(--text-muted)",textAlign:"center",fontSize:13},children:"No authors found"})]}),e.jsx("div",{className:"sidebar-content",children:s?e.jsxs(e.Fragment,{children:[e.jsxs("h2",{style:{fontSize:16,marginBottom:16},children:[s,"'s entries"]}),r.length===0?e.jsx("div",{style:{color:"var(--text-muted)"},children:"No entries for this author"}):r.map(i=>e.jsx("div",{style:{marginBottom:12},children:e.jsx(N,{entry:i})},i.id))]}):e.jsxs("div",{className:"empty-state",children:[e.jsx("h2",{children:"Select an author"}),e.jsx("p",{children:"Choose an author from the sidebar to view their work."})]})})]})}function f(t){return new Date(t).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"})}function M(t,r){const s=new Date(r).getTime()-new Date(t).getTime(),n=Math.round(s/6e4);if(n<60)return`${n}m`;const a=Math.floor(n/60),i=n%60;return i>0?`${a}h ${i}m`:`${a}h`}function W({session:t,active:r,onClick:s}){var a;const n=t.author.hasAgent;return e.jsxs("div",{className:`sidebar-item session-sidebar-item ${r?"active":""}`,onClick:s,children:[e.jsxs("div",{className:"session-sidebar-info",children:[e.jsxs("span",{className:`session-author-badge ${n?"agent":"human"}`,children:[n?"🤖":"👤"," ",t.author.name]}),e.jsxs("div",{className:"session-sidebar-meta",children:[f(t.startTime),t.startTime!==t.endTime&&` - ${f(t.endTime)}`]})]}),e.jsxs("div",{className:"session-sidebar-stats",children:[e.jsxs("span",{className:"sidebar-item-count",children:[t.entryCount," entries"]}),((a=t.symbolsTouched)==null?void 0:a.length)>0&&e.jsxs("span",{className:"sidebar-item-count",children:[t.symbolsTouched.length," symbols"]})]})]})}function P({session:t}){var n;const r=M(t.startTime,t.endTime),s=new Date(t.date).toLocaleDateString("en-US",{weekday:"long",year:"numeric",month:"long",day:"numeric"});return e.jsxs("div",{className:"session-detail",children:[e.jsxs("div",{className:"session-detail-header",children:[e.jsx("h2",{children:e.jsxs("span",{className:`session-author-badge ${t.author.hasAgent?"agent":"human"}`,children:[t.author.hasAgent?"🤖":"👤"," ",t.author.name]})}),e.jsxs("div",{className:"session-detail-meta",children:[e.jsx("span",{children:s}),e.jsxs("span",{children:[f(t.startTime)," - ",f(t.endTime)]}),e.jsx("span",{children:r}),e.jsxs("span",{children:[t.entryCount," entries"]})]})]}),((n=t.symbolsTouched)==null?void 0:n.length)>0&&e.jsxs("div",{className:"session-detail-section",children:[e.jsx("h3",{children:"Symbols Touched"}),e.jsx("div",{className:"session-symbols",children:t.symbolsTouched.map(a=>e.jsx(g,{symbol:a},a))})]}),t.breadcrumbs&&t.breadcrumbs.length>0&&e.jsxs("div",{className:"session-detail-section",children:[e.jsx("h3",{children:"Session Breadcrumbs"}),e.jsx("div",{className:"breadcrumb-list",children:t.breadcrumbs.map((a,i)=>e.jsxs("div",{className:"breadcrumb-item",children:[a.phase&&e.jsx("span",{className:"breadcrumb-phase",children:a.phase}),a.context&&e.jsx("span",{className:"breadcrumb-context",children:a.context}),a.timestamp&&e.jsx("span",{className:"breadcrumb-time",children:f(a.timestamp)}),a.decisions&&a.decisions.length>0&&e.jsx("div",{className:"breadcrumb-decisions",children:a.decisions.map((x,d)=>e.jsx("span",{className:"breadcrumb-decision",children:x},d))})]},i))})]}),e.jsxs("div",{className:"session-detail-section",children:[e.jsx("h3",{children:"Lore Entries"}),t.entries?t.entries.map(a=>e.jsx("div",{style:{marginBottom:12},children:e.jsx(N,{entry:a})},a.id)):e.jsx("div",{style:{color:"var(--text-muted)",fontSize:13},children:"Loading entries..."})]})]})}function U(){const t=c(i=>i.sessions),r=c(i=>i.selectedSessionId),s=c(i=>i.selectSession),n=t.find(i=>i.id===r),a=new Map;for(const i of t)a.has(i.date)||a.set(i.date,[]),a.get(i.date).push(i);return e.jsxs("div",{className:"sidebar-view",children:[e.jsxs("div",{className:"sidebar",children:[e.jsxs("div",{style:{padding:"12px 16px",borderBottom:"1px solid var(--border)",fontSize:11,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.05em"},children:["Sessions (",t.length,")"]}),t.length===0?e.jsx("div",{style:{padding:20,color:"var(--text-muted)",textAlign:"center",fontSize:13},children:"No sessions found"}):Array.from(a.entries()).map(([i,x])=>{const d=new Date(i).toLocaleDateString("en-US",{month:"short",day:"numeric"});return e.jsxs(y.Fragment,{children:[e.jsx("div",{className:"session-date-header",children:d}),x.map(h=>e.jsx(W,{session:h,active:r===h.id,onClick:()=>s(r===h.id?null:h.id)},h.id))]},i)})]}),e.jsx("div",{className:"sidebar-content",children:n?e.jsx(P,{session:n}):e.jsxs("div",{className:"empty-state",children:[e.jsx("h2",{children:"Select a session"}),e.jsx("p",{children:"Choose a session from the sidebar to view its details, entries, and breadcrumbs."})]})})]})}function q(){const t=c(i=>i.view),r=c(i=>i.entries),s=c(i=>i.projectName),n=c(i=>i.authors),a=c(i=>i.fetchAll);return p.useEffect(()=>{a()},[]),e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%"},children:[e.jsxs("div",{style:{padding:"12px 16px",borderBottom:"1px solid var(--p-border)"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:t==="timeline"?8:0},children:[e.jsxs("div",{children:[e.jsx("span",{style:{fontSize:16,fontWeight:600},children:"Lore"}),e.jsxs("span",{style:{fontSize:12,color:"var(--p-text-muted)",marginLeft:10},children:[s||"project"," · ",r.length," entries · ",n.length," authors"]})]}),e.jsx(F,{})]}),t==="timeline"&&e.jsx(E,{})]}),e.jsxs("main",{style:{flex:1,overflow:"auto",paddingBottom:32},children:[t==="timeline"&&e.jsx(B,{}),t==="session"&&e.jsx(U,{}),t==="symbol"&&e.jsx(O,{}),t==="author"&&e.jsx(V,{})]}),e.jsx(z,{})]})}export{q as default};
1
+ import{c as A,j as e,r as p,R as y}from"./index-G9JnWEs_.js";function k(){try{const t=localStorage.getItem("paradigm-lore-theme");if(t==="light"||t==="dark")return t}catch{}return"dark"}function T(){try{const t=localStorage.getItem("paradigm-lore-left-authors");if(t)return JSON.parse(t)}catch{}return[]}const c=A((t,r)=>({entries:[],filter:{},view:"timeline",selectedEntryId:null,symbols:[],authors:[],selectedSymbol:null,selectedAuthor:null,sessions:[],selectedSessionId:null,loading:!1,projectName:"",theme:k(),leftAuthors:T(),setView:s=>t({view:s}),setFilter:s=>{t(n=>({filter:{...n.filter,...s}})),r().fetchEntries()},clearFilters:()=>{t({filter:{}}),r().fetchEntries()},selectEntry:s=>t({selectedEntryId:s}),selectSymbol:s=>t({selectedSymbol:s}),selectAuthor:s=>t({selectedAuthor:s}),toggleTheme:()=>{const s=r().theme==="dark"?"light":"dark";document.documentElement.setAttribute("data-theme",s);try{localStorage.setItem("paradigm-lore-theme",s)}catch{}t({theme:s})},toggleLeftAuthor:s=>{const n=r().leftAuthors,a=n.includes(s)?n.filter(i=>i!==s):[...n,s];try{localStorage.setItem("paradigm-lore-left-authors",JSON.stringify(a))}catch{}t({leftAuthors:a})},selectSession:async s=>{if(t({selectedSessionId:s}),s)try{const a=await(await fetch(`/api/sessions/${encodeURIComponent(s)}`)).json();t(i=>({sessions:i.sessions.map(x=>x.id===s?{...x,entries:a.entries}:x)}))}catch{}},fetchEntries:async()=>{var s;t({loading:!0});try{const n=r().filter,a=new URLSearchParams;n.author&&a.set("author",n.author),n.hasAgent!==void 0?a.set("hasAgent",String(n.hasAgent)):n.authorType&&a.set("authorType",n.authorType),n.symbol&&a.set("symbol",n.symbol),n.type&&a.set("type",n.type),n.dateFrom&&a.set("from",n.dateFrom),n.dateTo&&a.set("to",n.dateTo),n.tag&&a.set("tag",n.tag),(s=n.tags)!=null&&s.length&&a.set("tags",n.tags.join(",")),n.hasReview!==void 0&&a.set("hasReview",String(n.hasReview)),n.hasBody!==void 0&&a.set("hasBody",String(n.hasBody)),a.set("limit","200");let d=(await(await fetch(`/api/lore?${a}`)).json()).entries||[];if(n.search){const h=n.search.toLowerCase();d=d.filter(u=>{var m;return u.title.toLowerCase().includes(h)||u.summary.toLowerCase().includes(h)||((m=u.symbols_touched)==null?void 0:m.some(j=>j.toLowerCase().includes(h)))})}t({entries:d,loading:!1})}catch{t({loading:!1})}},fetchSymbols:async()=>{try{const n=await(await fetch("/api/lore/symbols")).json();t({symbols:n.symbols||[]})}catch{}},fetchAuthors:async()=>{try{const n=await(await fetch("/api/lore/authors")).json();t({authors:n.authors||[]})}catch{}},fetchSessions:async()=>{try{const n=await(await fetch("/api/sessions")).json();t({sessions:n.sessions||[]})}catch{}},fetchAll:async()=>{try{const n=await(await fetch("/api/info")).json();t({projectName:n.project||""})}catch{}await Promise.all([r().fetchEntries(),r().fetchSymbols(),r().fetchAuthors(),r().fetchSessions()])}})),C=[{mode:"timeline",label:"Timeline"},{mode:"session",label:"Sessions"},{mode:"symbol",label:"Symbol"},{mode:"author",label:"Author"}];function F(){const t=c(a=>a.view),r=c(a=>a.setView),s=c(a=>a.theme),n=c(a=>a.toggleTheme);return e.jsxs("div",{className:"view-switcher-row",children:[e.jsx("div",{className:"view-switcher",children:C.map(a=>e.jsx("button",{className:`view-tab ${t===a.mode?"active":""}`,onClick:()=>r(a.mode),children:a.label},a.mode))}),e.jsx("button",{className:"theme-toggle",onClick:n,title:s==="dark"?"Switch to light mode":"Switch to dark mode",children:s==="dark"?"☀️":"🌙"})]})}const L=["","agent-session","human-note","decision","review","incident","milestone","retro","insight"],R=[{value:void 0,label:"All"},{value:!1,label:"Human Only"},{value:!0,label:"AI-Assisted"}];function E(){const t=c(l=>l.filter),r=c(l=>l.setFilter),s=c(l=>l.clearFilters),n=c(l=>l.authors),a=c(l=>l.symbols),[i,x]=p.useState(""),[d,h]=p.useState(!1),u=p.useRef(null),m=p.useRef(null),[j,v]=p.useState([]),b=Object.values(t).some(l=>l!==void 0&&l!==""&&(Array.isArray(l)?l.length>0:!0)),o=i?a.filter(l=>l.symbol.toLowerCase().includes(i.toLowerCase())).slice(0,10):a.slice(0,10);return p.useEffect(()=>{fetch("/api/lore/tags").then(l=>l.json()).then(l=>v(l.tags||[])).catch(()=>{})},[]),p.useEffect(()=>{function l(S){m.current&&!m.current.contains(S.target)&&u.current&&!u.current.contains(S.target)&&h(!1)}return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[]),e.jsxs("div",{className:"filter-bar",children:[e.jsx("div",{className:"author-type-toggle",children:R.map(l=>e.jsx("button",{className:`author-type-pill ${t.hasAgent===l.value?"active":""} ${l.value===void 0?"all":l.value?"agent":"human"}`,onClick:()=>r({hasAgent:l.value}),children:l.label},l.label))}),e.jsxs("select",{value:t.author||"",onChange:l=>r({author:l.target.value||void 0}),children:[e.jsx("option",{value:"",children:"All authors"}),n.map(l=>e.jsxs("option",{value:l.id,children:[l.hasAgent?"🤖":"👤"," ",l.id]},l.id))]}),e.jsxs("select",{value:t.type||"",onChange:l=>r({type:l.target.value||void 0}),children:[e.jsx("option",{value:"",children:"All types"}),L.filter(Boolean).map(l=>e.jsx("option",{value:l,children:l},l))]}),j.length>0&&e.jsxs("select",{value:t.tag||"",onChange:l=>r({tag:l.target.value||void 0}),children:[e.jsx("option",{value:"",children:"All tags"}),j.map(l=>e.jsxs("option",{value:l.tag,children:[l.tag," (",l.count,")"]},l.tag))]}),e.jsxs("div",{className:"symbol-autocomplete-wrapper",children:[e.jsx("input",{ref:u,type:"text",placeholder:t.symbol?`Symbol: ${t.symbol}`:"Filter by symbol...",value:i,onChange:l=>{x(l.target.value),h(!0)},onFocus:()=>h(!0),style:{width:160}}),t.symbol&&e.jsx("button",{className:"symbol-clear",onClick:()=>{r({symbol:void 0}),x("")},children:"x"}),d&&o.length>0&&e.jsx("div",{className:"symbol-dropdown",ref:m,children:o.map(l=>e.jsxs("div",{className:`symbol-dropdown-item ${t.symbol===l.symbol?"active":""}`,onClick:()=>{r({symbol:l.symbol}),x(""),h(!1)},children:[e.jsx("span",{className:"symbol-dropdown-name",children:l.symbol}),e.jsx("span",{className:"symbol-dropdown-count",children:l.count})]},l.symbol))})]}),e.jsx("input",{type:"text",placeholder:"Search...",value:t.search||"",onChange:l=>r({search:l.target.value||void 0}),style:{width:140}}),e.jsx("input",{type:"date",value:t.dateFrom||"",onChange:l=>r({dateFrom:l.target.value||void 0}),title:"From date"}),e.jsx("input",{type:"date",value:t.dateTo||"",onChange:l=>r({dateTo:l.target.value||void 0}),title:"To date"}),e.jsx("button",{className:`filter-preset ${t.hasReview===!1?"active":""}`,onClick:()=>r({hasReview:t.hasReview===!1?void 0:!1}),children:"Needs Review"}),b&&e.jsx("button",{className:"filter-clear",onClick:s,children:"Clear filters"})]})}const $={"#":"component","^":"gate",$:"flow","!":"signal","~":"aspect"};function g({symbol:t}){const r=t.charAt(0),s=$[r]||"component";return e.jsx("span",{className:`symbol-tag ${s}`,children:t})}function _({status:t}){if(!t)return null;const r={pass:{icon:"✓",className:"pass"},fail:{icon:"✗",className:"fail"},partial:{icon:"⚠",className:"partial"},untested:{icon:"·",className:""}},s=r[t]||r.untested;return e.jsxs("span",{className:`lore-card-verify ${s.className}`,children:[s.icon," ",t]})}function w({rating:t}){return e.jsxs("span",{className:"review-stars",children:["★".repeat(t),"☆".repeat(5-t)]})}function z(){var a,i,x,d,h,u,m,j,v,b;const t=c(o=>o.selectedEntryId),r=c(o=>o.selectEntry),[s,n]=p.useState(null);return p.useEffect(()=>{if(!t){n(null);return}fetch(`/api/lore/${t}`).then(o=>o.json()).then(n).catch(()=>n(null))},[t]),!t||!s?null:e.jsxs("div",{className:"detail-overlay",children:[e.jsx("div",{className:"detail-backdrop",onClick:()=>r(null)}),e.jsxs("div",{className:"detail-panel",children:[e.jsxs("div",{className:"detail-header",children:[e.jsxs("div",{children:[e.jsx("div",{className:"lore-card-title",style:{fontSize:16},children:s.title}),e.jsxs("div",{style:{display:"flex",gap:8,marginTop:4,alignItems:"center"},children:[e.jsx("span",{className:`lore-card-type ${s.type}`,children:s.type}),e.jsx("span",{style:{color:"var(--text-muted)",fontSize:12},children:s.id})]})]}),e.jsx("button",{className:"detail-close",onClick:()=>r(null),children:"✕"})]}),e.jsxs("div",{className:"detail-body",children:[e.jsxs("div",{className:"detail-section",children:[e.jsx("h3",{children:"Details"}),e.jsxs("dl",{className:"detail-meta",children:[e.jsx("dt",{children:"Author"}),e.jsxs("dd",{children:["👤"," ",typeof s.author=="string"?s.author:"unknown"]}),s.agent&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"AI Agent"}),e.jsxs("dd",{children:["🤖"," ",s.agent.model,s.agent.provider?` (${s.agent.provider})`:""]})]}),e.jsx("dt",{children:"Time"}),e.jsx("dd",{children:new Date(s.timestamp).toLocaleString()}),s.duration_minutes&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Duration"}),e.jsxs("dd",{children:[s.duration_minutes," minutes"]})]}),s.commit&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Commit"}),e.jsx("dd",{style:{fontFamily:"monospace",fontSize:12},children:s.commit})]})]})]}),e.jsxs("div",{className:"detail-section",children:[e.jsx("h3",{children:"Summary"}),e.jsx("p",{style:{fontSize:13,color:"var(--text-secondary)"},children:s.summary})]}),s.body&&e.jsxs("div",{className:"detail-section",children:[e.jsx("h3",{children:"Body"}),e.jsx("pre",{style:{fontSize:12,color:"var(--text-secondary)",whiteSpace:"pre-wrap",wordBreak:"break-word",background:"var(--bg-primary)",padding:12,borderRadius:6,border:"1px solid var(--border)",maxHeight:300,overflowY:"auto"},children:s.body})]}),(a=s.linked_lore)!=null&&a.length||(i=s.linked_tasks)!=null&&i.length||(x=s.linked_commits)!=null&&x.length?e.jsxs("div",{className:"detail-section",children:[e.jsx("h3",{children:"Linked"}),e.jsxs("dl",{className:"detail-meta",children:[s.linked_lore&&s.linked_lore.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Lore"}),e.jsx("dd",{children:s.linked_lore.map(o=>e.jsx("span",{onClick:()=>r(o),style:{cursor:"pointer",color:"var(--color-component)",textDecoration:"underline",marginRight:8,fontSize:12},children:o},o))})]}),s.linked_tasks&&s.linked_tasks.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Tasks"}),e.jsx("dd",{children:s.linked_tasks.map(o=>e.jsx("span",{style:{fontFamily:"monospace",fontSize:12,marginRight:8},children:o},o))})]}),s.linked_commits&&s.linked_commits.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Commits"}),e.jsx("dd",{children:s.linked_commits.map(o=>e.jsx("span",{style:{fontFamily:"monospace",fontSize:12,marginRight:8},children:o.slice(0,8)},o))})]})]})]}):null,((d=s.symbols_touched)==null?void 0:d.length)>0&&e.jsxs("div",{className:"detail-section",children:[e.jsx("h3",{children:"Symbols Touched"}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:s.symbols_touched.map(o=>e.jsx(g,{symbol:o},o))})]}),s.symbols_created&&s.symbols_created.length>0&&e.jsxs("div",{className:"detail-section",children:[e.jsx("h3",{children:"Symbols Created"}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:s.symbols_created.map(o=>e.jsx(g,{symbol:o},o))})]}),(h=s.files_created)!=null&&h.length||(u=s.files_modified)!=null&&u.length?e.jsxs("div",{className:"detail-section",children:[e.jsxs("h3",{children:["Files (",(((m=s.files_created)==null?void 0:m.length)||0)+(((j=s.files_modified)==null?void 0:j.length)||0),")"]}),e.jsxs("ul",{className:"detail-files",children:[(v=s.files_created)==null?void 0:v.map(o=>e.jsxs("li",{style:{color:"#34d399"},children:["+ ",o]},o)),(b=s.files_modified)==null?void 0:b.map(o=>e.jsxs("li",{style:{color:"#fbbf24"},children:["~ ",o]},o))]}),s.lines_added||s.lines_removed?e.jsxs("p",{style:{fontSize:12,color:"var(--text-muted)",marginTop:4},children:[e.jsxs("span",{style:{color:"#34d399"},children:["+",s.lines_added||0]})," ",e.jsxs("span",{style:{color:"#f87171"},children:["-",s.lines_removed||0]})," lines"]}):null]}):null,s.decisions&&s.decisions.length>0&&e.jsxs("div",{className:"detail-section",children:[e.jsx("h3",{children:"Decisions"}),s.decisions.map(o=>e.jsxs("div",{className:"detail-decision",children:[e.jsx("div",{className:"decision-text",children:o.decision}),e.jsx("div",{className:"decision-rationale",children:o.rationale})]},o.id))]}),s.errors_encountered&&s.errors_encountered.length>0&&e.jsxs("div",{className:"detail-section",children:[e.jsx("h3",{children:"Errors Encountered"}),s.errors_encountered.map((o,l)=>e.jsxs("div",{className:"detail-error",children:[e.jsx("div",{style:{color:"var(--color-incident)",fontSize:13},children:o.description}),e.jsxs("div",{style:{color:"var(--text-secondary)",fontSize:12,marginTop:2},children:["→"," ",o.resolution,o.time_to_fix?` (${o.time_to_fix})`:""]})]},l))]}),s.learnings&&s.learnings.length>0&&e.jsxs("div",{className:"detail-section",children:[e.jsx("h3",{children:"Learnings"}),s.learnings.map((o,l)=>e.jsx("div",{className:"detail-learning",children:o},l))]}),s.verification&&e.jsxs("div",{className:"detail-section",children:[e.jsx("h3",{children:"Verification"}),e.jsx(_,{status:s.verification.status}),s.verification.details&&e.jsx("dl",{className:"detail-meta",style:{marginTop:8},children:Object.entries(s.verification.details).map(([o,l])=>e.jsxs(y.Fragment,{children:[e.jsx("dt",{children:o}),e.jsx("dd",{style:{color:l==="pass"?"#34d399":"#f87171"},children:l})]},o))})]}),(s.confidence!=null||s.assessment)&&e.jsxs("div",{className:"detail-section",children:[e.jsx("h3",{children:"Confidence & Assessment"}),e.jsxs("dl",{className:"detail-meta",children:[s.confidence!=null&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Confidence"}),e.jsx("dd",{children:e.jsxs("span",{style:{padding:"2px 8px",background:"rgba(139, 92, 246, 0.15)",border:"1px solid rgba(139, 92, 246, 0.3)",borderRadius:10,fontSize:12,color:"#8b5cf6"},children:[(s.confidence*100).toFixed(0),"%"]})})]}),s.assessment&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Verdict"}),e.jsx("dd",{children:e.jsx("span",{style:{padding:"2px 8px",background:s.assessment.verdict==="correct"?"rgba(52, 211, 153, 0.15)":s.assessment.verdict==="partial"?"rgba(251, 191, 36, 0.15)":"rgba(248, 113, 113, 0.15)",border:`1px solid ${s.assessment.verdict==="correct"?"rgba(52, 211, 153, 0.3)":s.assessment.verdict==="partial"?"rgba(251, 191, 36, 0.3)":"rgba(248, 113, 113, 0.3)"}`,borderRadius:10,fontSize:12,color:s.assessment.verdict==="correct"?"#34d399":s.assessment.verdict==="partial"?"#fbbf24":"#f87171"},children:s.assessment.verdict})}),e.jsx("dt",{children:"Assessed by"}),e.jsx("dd",{children:s.assessment.assessed_by}),e.jsx("dt",{children:"Assessed at"}),e.jsx("dd",{children:new Date(s.assessment.assessed_at).toLocaleString()}),s.assessment.notes&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Notes"}),e.jsx("dd",{children:s.assessment.notes})]})]}),s.assessment_delta!=null&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Delta"}),e.jsxs("dd",{style:{color:Math.abs(s.assessment_delta)<=.1?"#34d399":Math.abs(s.assessment_delta)<=.3?"#fbbf24":"#f87171"},children:[s.assessment_delta>0?"+":"",s.assessment_delta.toFixed(2)," ",e.jsxs("span",{style:{fontSize:11,color:"var(--text-muted)"},children:["(",s.assessment_delta>.1?"under-confident":s.assessment_delta<-.1?"over-confident":"well-calibrated",")"]})]})]})]})]}),s.review?e.jsxs("div",{className:"detail-section",children:[e.jsx("h3",{children:"Review"}),e.jsxs("dl",{className:"detail-meta",children:[e.jsx("dt",{children:"Reviewer"}),e.jsx("dd",{children:s.review.reviewer}),e.jsx("dt",{children:"Completeness"}),e.jsx("dd",{children:e.jsx(w,{rating:s.review.completeness})}),e.jsx("dt",{children:"Quality"}),e.jsx("dd",{children:e.jsx(w,{rating:s.review.quality})}),s.review.notes&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Notes"}),e.jsx("dd",{children:s.review.notes})]})]})]}):e.jsxs("div",{className:"detail-section",children:[e.jsx("h3",{children:"Review"}),e.jsxs("p",{style:{color:"var(--text-muted)",fontSize:13},children:["No review yet. Run ",e.jsxs("code",{style:{background:"var(--bg-card)",padding:"2px 4px",borderRadius:3},children:["paradigm lore review ",s.id]})]})]}),s.git_context&&e.jsxs("div",{className:"detail-section",children:[e.jsx("h3",{children:"Git Context"}),e.jsxs("dl",{className:"detail-meta",children:[e.jsx("dt",{children:"Commit"}),e.jsx("dd",{style:{fontFamily:"monospace",fontSize:12},children:s.git_context.ref.slice(0,8)}),e.jsx("dt",{children:"Branch"}),e.jsx("dd",{children:s.git_context.branch}),e.jsx("dt",{children:"Working tree"}),e.jsx("dd",{children:s.git_context.dirty?"Dirty (uncommitted changes)":"Clean"})]})]}),s.meta&&Object.keys(s.meta).length>0&&e.jsxs("div",{className:"detail-section",children:[e.jsx("h3",{children:"Metadata"}),e.jsx("dl",{className:"detail-meta",children:Object.entries(s.meta).map(([o,l])=>e.jsxs(y.Fragment,{children:[e.jsx("dt",{children:o}),e.jsx("dd",{children:typeof l=="object"?JSON.stringify(l):String(l)})]},o))})]}),s.tags&&s.tags.length>0&&e.jsxs("div",{className:"detail-section",children:[e.jsx("h3",{children:"Tags"}),e.jsx("div",{style:{display:"flex",gap:4,flexWrap:"wrap"},children:s.tags.map(o=>{const l=o.startsWith("arc:");return e.jsxs("span",{style:{padding:"2px 8px",background:l?"var(--color-flow-bg, rgba(96, 165, 250, 0.15))":"var(--bg-primary)",border:`1px solid ${l?"var(--color-flow, #60a5fa)":"var(--border)"}`,borderRadius:12,fontSize:11,color:l?"var(--color-flow, #60a5fa)":"var(--text-secondary)"},children:[l?"↻ ":"",o]},o)})})]})]})]})]})}function D(t){return new Date(t).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"})}function N({entry:t,side:r="right"}){var x,d,h,u;const s=c(m=>m.selectEntry),n=t.agent!=null,a=(((x=t.files_created)==null?void 0:x.length)||0)+(((d=t.files_modified)==null?void 0:d.length)||0),i=(t.lines_added||0)+(t.lines_removed||0);return e.jsx("div",{className:`lore-card-row ${r} ${n?"agent":"human"}`,children:e.jsxs("div",{className:"lore-card",onClick:()=>s(t.id),children:[e.jsxs("div",{className:"lore-card-header",children:[e.jsx("div",{className:"lore-card-author",children:e.jsxs("span",{className:`author-badge ${n?"agent":"human"}`,children:[n?"🤖":"👤"," ",typeof t.author=="string"?t.author:"unknown"]})}),e.jsx("span",{className:`lore-card-type ${t.type||"agent-session"}`,children:t.type||"agent-session"})]}),e.jsx("div",{className:"lore-card-title",children:t.title}),e.jsx("div",{className:"lore-card-summary",children:t.summary}),t.body&&e.jsxs("div",{style:{fontSize:11,color:"var(--text-muted)",marginTop:4,fontStyle:"italic",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[t.body.slice(0,100),t.body.length>100?"...":""]}),((h=t.symbols_touched)==null?void 0:h.length)>0&&e.jsxs("div",{className:"lore-card-symbols",children:[t.symbols_touched.slice(0,5).map(m=>e.jsx(g,{symbol:m},m)),t.symbols_touched.length>5&&e.jsxs("span",{className:"symbol-tag component",children:["+",t.symbols_touched.length-5]})]}),Array.isArray(t.tags)&&t.tags.some(m=>m.startsWith("arc:"))&&e.jsx("div",{style:{display:"flex",gap:4,marginTop:4,flexWrap:"wrap"},children:t.tags.filter(m=>m.startsWith("arc:")).map(m=>e.jsxs("span",{style:{padding:"1px 6px",background:"rgba(96, 165, 250, 0.15)",border:"1px solid rgba(96, 165, 250, 0.3)",borderRadius:10,fontSize:10,color:"#60a5fa"},children:["↻"," ",m]},m))}),e.jsxs("div",{className:"lore-card-footer",children:[e.jsxs("div",{className:"lore-card-stats",children:[a>0&&e.jsxs("span",{children:[a," files"]}),i>0&&e.jsxs("span",{children:[i," loc"]}),t.duration_minutes&&e.jsxs("span",{children:[t.duration_minutes,"m"]}),e.jsx(_,{status:(u=t.verification)==null?void 0:u.status}),t.confidence!=null&&e.jsxs("span",{style:{padding:"1px 5px",background:"rgba(139, 92, 246, 0.15)",border:"1px solid rgba(139, 92, 246, 0.3)",borderRadius:8,fontSize:10,color:"#8b5cf6"},children:[(t.confidence*100).toFixed(0),"%"]}),t.assessment&&e.jsx("span",{style:{padding:"1px 5px",background:t.assessment.verdict==="correct"?"rgba(52, 211, 153, 0.15)":t.assessment.verdict==="partial"?"rgba(251, 191, 36, 0.15)":"rgba(248, 113, 113, 0.15)",border:`1px solid ${t.assessment.verdict==="correct"?"rgba(52, 211, 153, 0.3)":t.assessment.verdict==="partial"?"rgba(251, 191, 36, 0.3)":"rgba(248, 113, 113, 0.3)"}`,borderRadius:8,fontSize:10,color:t.assessment.verdict==="correct"?"#34d399":t.assessment.verdict==="partial"?"#fbbf24":"#f87171"},children:t.assessment.verdict})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.review&&e.jsx(w,{rating:t.review.quality}),e.jsx("span",{children:D(t.timestamp)})]})]})]})})}function I({date:t,humanCount:r,agentCount:s}){const a=new Date(t).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"});return e.jsxs("div",{className:"date-separator",children:[e.jsx("span",{className:"date-count human",children:r}),e.jsx("span",{className:"date-badge",children:a}),e.jsx("span",{className:"date-count agent",children:s})]})}function B(){const t=c(d=>d.entries),r=c(d=>d.authors),s=c(d=>d.leftAuthors),n=c(d=>d.toggleLeftAuthor);if(t.length===0)return e.jsxs("div",{className:"empty-state",children:[e.jsx("h2",{children:"No lore entries yet"}),e.jsxs("p",{children:["Record your first entry with ",e.jsx("code",{children:"paradigm lore record"})," or via the MCP tool ",e.jsx("code",{children:"paradigm_lore_record"}),"."]})]});const a=s.length>0,i=new Map;for(const d of t){const h=d.timestamp.slice(0,10);i.has(h)||i.set(h,[]),i.get(h).push(d)}const x=d=>s.includes(d);return e.jsxs("div",{className:`thread-view ${a?"":"single-column"}`,children:[a&&e.jsx("div",{className:"timeline-spine"}),e.jsx("div",{className:"timeline-column-labels",children:a?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"column-label-group left",children:s.map(d=>e.jsxs("button",{className:"column-author-pill active",onClick:()=>n(d),title:"Remove from left column",children:[d," ×"]},d))}),e.jsx("div",{className:"column-label-group right",children:e.jsx("span",{className:"column-label-text",children:"EVERYONE ELSE"})})]}):e.jsxs("div",{className:"column-author-selector",children:[e.jsx("span",{className:"column-label-text",children:"Pick an author for the left column:"}),r.map(d=>e.jsx("button",{className:"column-author-pill",onClick:()=>n(d.id),children:d.id},d.id))]})}),Array.from(i.entries()).map(([d,h])=>{const u=h.filter(j=>x(j.author)).length,m=h.filter(j=>!x(j.author)).length;return e.jsxs(y.Fragment,{children:[e.jsx(I,{date:d,humanCount:u,agentCount:m}),h.map(j=>e.jsx(N,{entry:j,side:a&&x(j.author)?"left":"right"},j.id))]},d)})]})}function O(){const t=c(i=>i.symbols),r=c(i=>i.entries),s=c(i=>i.selectedSymbol),n=c(i=>i.selectSymbol),a=c(i=>i.setFilter);return p.useEffect(()=>{a(s?{symbol:s}:{symbol:void 0})},[s]),e.jsxs("div",{className:"sidebar-view",children:[e.jsxs("div",{className:"sidebar",children:[e.jsxs("div",{style:{padding:"12px 16px",borderBottom:"1px solid var(--border)",fontSize:11,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.05em"},children:["Symbols (",t.length,")"]}),t.map(i=>e.jsxs("div",{className:`sidebar-item ${s===i.symbol?"active":""}`,onClick:()=>n(s===i.symbol?null:i.symbol),children:[e.jsx("span",{className:"sidebar-item-name",children:e.jsx(g,{symbol:i.symbol})}),e.jsx("span",{className:"sidebar-item-count",children:i.count})]},i.symbol)),t.length===0&&e.jsx("div",{style:{padding:20,color:"var(--text-muted)",textAlign:"center",fontSize:13},children:"No symbols found"})]}),e.jsx("div",{className:"sidebar-content",children:s?e.jsxs(e.Fragment,{children:[e.jsxs("h2",{style:{fontSize:16,marginBottom:16},children:[e.jsx(g,{symbol:s})," entries"]}),r.length===0?e.jsx("div",{style:{color:"var(--text-muted)"},children:"No entries for this symbol"}):r.map(i=>e.jsx("div",{style:{marginBottom:12},children:e.jsx(N,{entry:i})},i.id))]}):e.jsxs("div",{className:"empty-state",children:[e.jsx("h2",{children:"Select a symbol"}),e.jsx("p",{children:"Choose a symbol from the sidebar to view its history."})]})})]})}function V(){const t=c(i=>i.authors),r=c(i=>i.entries),s=c(i=>i.selectedAuthor),n=c(i=>i.selectAuthor),a=c(i=>i.setFilter);return p.useEffect(()=>{a(s?{author:s}:{author:void 0})},[s]),e.jsxs("div",{className:"sidebar-view",children:[e.jsxs("div",{className:"sidebar",children:[e.jsxs("div",{style:{padding:"12px 16px",borderBottom:"1px solid var(--border)",fontSize:11,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.05em"},children:["Authors (",t.length,")"]}),t.map(i=>e.jsxs("div",{className:`sidebar-item ${s===i.id?"active":""}`,onClick:()=>n(s===i.id?null:i.id),children:[e.jsxs("div",{children:[e.jsxs("span",{className:"sidebar-item-name",children:[i.hasAgent?"🤖":"👤"," ",i.id]}),e.jsxs("div",{style:{fontSize:10,color:"var(--text-muted)",marginTop:2},children:["Last active: ",new Date(i.lastActive).toLocaleDateString()]})]}),e.jsx("span",{className:"sidebar-item-count",children:i.count})]},i.id)),t.length===0&&e.jsx("div",{style:{padding:20,color:"var(--text-muted)",textAlign:"center",fontSize:13},children:"No authors found"})]}),e.jsx("div",{className:"sidebar-content",children:s?e.jsxs(e.Fragment,{children:[e.jsxs("h2",{style:{fontSize:16,marginBottom:16},children:[s,"'s entries"]}),r.length===0?e.jsx("div",{style:{color:"var(--text-muted)"},children:"No entries for this author"}):r.map(i=>e.jsx("div",{style:{marginBottom:12},children:e.jsx(N,{entry:i})},i.id))]}):e.jsxs("div",{className:"empty-state",children:[e.jsx("h2",{children:"Select an author"}),e.jsx("p",{children:"Choose an author from the sidebar to view their work."})]})})]})}function f(t){return new Date(t).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"})}function M(t,r){const s=new Date(r).getTime()-new Date(t).getTime(),n=Math.round(s/6e4);if(n<60)return`${n}m`;const a=Math.floor(n/60),i=n%60;return i>0?`${a}h ${i}m`:`${a}h`}function W({session:t,active:r,onClick:s}){var a;const n=t.author.hasAgent;return e.jsxs("div",{className:`sidebar-item session-sidebar-item ${r?"active":""}`,onClick:s,children:[e.jsxs("div",{className:"session-sidebar-info",children:[e.jsxs("span",{className:`session-author-badge ${n?"agent":"human"}`,children:[n?"🤖":"👤"," ",t.author.name]}),e.jsxs("div",{className:"session-sidebar-meta",children:[f(t.startTime),t.startTime!==t.endTime&&` - ${f(t.endTime)}`]})]}),e.jsxs("div",{className:"session-sidebar-stats",children:[e.jsxs("span",{className:"sidebar-item-count",children:[t.entryCount," entries"]}),((a=t.symbolsTouched)==null?void 0:a.length)>0&&e.jsxs("span",{className:"sidebar-item-count",children:[t.symbolsTouched.length," symbols"]})]})]})}function P({session:t}){var n;const r=M(t.startTime,t.endTime),s=new Date(t.date).toLocaleDateString("en-US",{weekday:"long",year:"numeric",month:"long",day:"numeric"});return e.jsxs("div",{className:"session-detail",children:[e.jsxs("div",{className:"session-detail-header",children:[e.jsx("h2",{children:e.jsxs("span",{className:`session-author-badge ${t.author.hasAgent?"agent":"human"}`,children:[t.author.hasAgent?"🤖":"👤"," ",t.author.name]})}),e.jsxs("div",{className:"session-detail-meta",children:[e.jsx("span",{children:s}),e.jsxs("span",{children:[f(t.startTime)," - ",f(t.endTime)]}),e.jsx("span",{children:r}),e.jsxs("span",{children:[t.entryCount," entries"]})]})]}),((n=t.symbolsTouched)==null?void 0:n.length)>0&&e.jsxs("div",{className:"session-detail-section",children:[e.jsx("h3",{children:"Symbols Touched"}),e.jsx("div",{className:"session-symbols",children:t.symbolsTouched.map(a=>e.jsx(g,{symbol:a},a))})]}),t.breadcrumbs&&t.breadcrumbs.length>0&&e.jsxs("div",{className:"session-detail-section",children:[e.jsx("h3",{children:"Session Breadcrumbs"}),e.jsx("div",{className:"breadcrumb-list",children:t.breadcrumbs.map((a,i)=>e.jsxs("div",{className:"breadcrumb-item",children:[a.phase&&e.jsx("span",{className:"breadcrumb-phase",children:a.phase}),a.context&&e.jsx("span",{className:"breadcrumb-context",children:a.context}),a.timestamp&&e.jsx("span",{className:"breadcrumb-time",children:f(a.timestamp)}),a.decisions&&a.decisions.length>0&&e.jsx("div",{className:"breadcrumb-decisions",children:a.decisions.map((x,d)=>e.jsx("span",{className:"breadcrumb-decision",children:x},d))})]},i))})]}),e.jsxs("div",{className:"session-detail-section",children:[e.jsx("h3",{children:"Lore Entries"}),t.entries?t.entries.map(a=>e.jsx("div",{style:{marginBottom:12},children:e.jsx(N,{entry:a})},a.id)):e.jsx("div",{style:{color:"var(--text-muted)",fontSize:13},children:"Loading entries..."})]})]})}function U(){const t=c(i=>i.sessions),r=c(i=>i.selectedSessionId),s=c(i=>i.selectSession),n=t.find(i=>i.id===r),a=new Map;for(const i of t)a.has(i.date)||a.set(i.date,[]),a.get(i.date).push(i);return e.jsxs("div",{className:"sidebar-view",children:[e.jsxs("div",{className:"sidebar",children:[e.jsxs("div",{style:{padding:"12px 16px",borderBottom:"1px solid var(--border)",fontSize:11,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.05em"},children:["Sessions (",t.length,")"]}),t.length===0?e.jsx("div",{style:{padding:20,color:"var(--text-muted)",textAlign:"center",fontSize:13},children:"No sessions found"}):Array.from(a.entries()).map(([i,x])=>{const d=new Date(i).toLocaleDateString("en-US",{month:"short",day:"numeric"});return e.jsxs(y.Fragment,{children:[e.jsx("div",{className:"session-date-header",children:d}),x.map(h=>e.jsx(W,{session:h,active:r===h.id,onClick:()=>s(r===h.id?null:h.id)},h.id))]},i)})]}),e.jsx("div",{className:"sidebar-content",children:n?e.jsx(P,{session:n}):e.jsxs("div",{className:"empty-state",children:[e.jsx("h2",{children:"Select a session"}),e.jsx("p",{children:"Choose a session from the sidebar to view its details, entries, and breadcrumbs."})]})})]})}function q(){const t=c(i=>i.view),r=c(i=>i.entries),s=c(i=>i.projectName),n=c(i=>i.authors),a=c(i=>i.fetchAll);return p.useEffect(()=>{a()},[]),e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%"},children:[e.jsxs("div",{style:{padding:"12px 16px",borderBottom:"1px solid var(--p-border)"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:t==="timeline"?8:0},children:[e.jsxs("div",{children:[e.jsx("span",{style:{fontSize:16,fontWeight:600},children:"Lore"}),e.jsxs("span",{style:{fontSize:12,color:"var(--p-text-muted)",marginLeft:10},children:[s||"project"," · ",r.length," entries · ",n.length," authors"]})]}),e.jsx(F,{})]}),t==="timeline"&&e.jsx(E,{})]}),e.jsxs("main",{style:{flex:1,overflow:"auto",paddingBottom:32},children:[t==="timeline"&&e.jsx(B,{}),t==="session"&&e.jsx(U,{}),t==="symbol"&&e.jsx(O,{}),t==="author"&&e.jsx(V,{})]}),e.jsx(z,{})]})}export{q as default};
@@ -1 +1 @@
1
- import{c as _,r,j as e}from"./index-DbxeSMkV.js";const Q=_((t,n)=>({logs:[],services:[],flowEvents:[],isLoading:!1,error:null,isLive:!1,levelFilter:"all",serviceFilter:null,symbolFilter:null,searchQuery:"",excludedSymbols:new Set,excludedSymbolTypes:new Set,excludedMessages:new Set,excludedServices:new Set,loadLogs:async()=>{t({isLoading:!0,error:null});try{const s=new URLSearchParams,l=n();l.levelFilter!=="all"&&s.set("level",l.levelFilter),l.serviceFilter&&s.set("service",l.serviceFilter),l.symbolFilter&&s.set("symbol",l.symbolFilter),l.searchQuery&&s.set("search",l.searchQuery),s.set("limit","200");const a=await fetch(`/api/sentinel/logs?${s}`);if(!a.ok)throw new Error(`API error: ${a.status}`);const i=await a.json();t({logs:i.logs||[],isLoading:!1})}catch(s){t({isLoading:!1,error:s instanceof Error?s.message:"Failed to load logs",logs:[]})}},loadServices:async()=>{try{const s=await fetch("/api/sentinel/services");if(!s.ok)return;const l=await s.json();t({services:l.services||[]})}catch{}},handleWsMessage:s=>{if(s.type==="sentinel:log"&&s.entry&&t(l=>({logs:[s.entry,...l.logs].slice(0,500)})),s.type==="sentinel:flow_event"){const l={type:"flow_event",flowId:s.flowId,nodeSymbol:s.nodeSymbol,event:s.event,timestamp:s.timestamp,service:s.service};t(a=>({flowEvents:[l,...a.flowEvents].slice(0,200)}))}},setIsLive:s=>t({isLive:s}),setLevelFilter:s=>t({levelFilter:s}),setServiceFilter:s=>t({serviceFilter:s}),setSymbolFilter:s=>t({symbolFilter:s}),setSearchQuery:s=>t({searchQuery:s}),clearLogs:()=>t({logs:[],flowEvents:[]}),toggleExcludedSymbol:s=>{const l=new Set(n().excludedSymbols);l.has(s)?l.delete(s):l.add(s),t({excludedSymbols:l})},toggleExcludedSymbolType:s=>{const l=new Set(n().excludedSymbolTypes);l.has(s)?l.delete(s):l.add(s),t({excludedSymbolTypes:l})},toggleExcludedMessage:s=>{const l=new Set(n().excludedMessages);l.has(s)?l.delete(s):l.add(s),t({excludedMessages:l})},toggleExcludedService:s=>{const l=new Set(n().excludedServices);l.has(s)?l.delete(s):l.add(s),t({excludedServices:l})},clearAllExclusions:()=>t({excludedSymbols:new Set,excludedSymbolTypes:new Set,excludedMessages:new Set,excludedServices:new Set}),getFilteredLogs:()=>{const s=n();let l=s.logs;if(s.levelFilter!=="all"&&(l=l.filter(a=>a.level===s.levelFilter)),s.serviceFilter&&(l=l.filter(a=>a.service===s.serviceFilter)),s.symbolFilter&&(l=l.filter(a=>a.symbol.includes(s.symbolFilter))),s.searchQuery){const a=s.searchQuery.toLowerCase();l=l.filter(i=>i.message.toLowerCase().includes(a)||i.symbol.toLowerCase().includes(a))}return s.excludedSymbols.size>0&&(l=l.filter(a=>!s.excludedSymbols.has(a.symbol))),s.excludedSymbolTypes.size>0&&(l=l.filter(a=>!s.excludedSymbolTypes.has(a.symbolType))),s.excludedMessages.size>0&&(l=l.filter(a=>!s.excludedMessages.has(a.message))),s.excludedServices.size>0&&(l=l.filter(a=>!s.excludedServices.has(a.service))),l}})),R=_((t,n)=>({events:[],scopes:[],selectedScope:null,excludedTypes:new Set,excludedServices:new Set,categoryFilter:null,loading:!1,error:null,total:0,fetchEvents:async(s,l={})=>{t({loading:!0,error:null});try{const a=new URLSearchParams({schemaId:s,...l}),i=await fetch(`/api/sentinel/events?${a}`);if(!i.ok)throw new Error(`Failed to fetch events: ${i.status}`);const d=await i.json();t({events:d.events||[],total:d.total||0,loading:!1})}catch(a){t({error:a instanceof Error?a.message:"Failed to fetch events",loading:!1})}},fetchScopes:async s=>{try{const l=await fetch(`/api/sentinel/events/scopes?schemaId=${encodeURIComponent(s)}`);if(!l.ok)throw new Error(`Failed to fetch scopes: ${l.status}`);const a=await l.json();t({scopes:a.scopes||[]})}catch(l){t({error:l instanceof Error?l.message:"Failed to fetch scopes"})}},fetchScopeEvents:async(s,l)=>{t({loading:!0,error:null,selectedScope:l});try{const a=await fetch(`/api/sentinel/events/scope/${encodeURIComponent(l)}?schemaId=${encodeURIComponent(s)}`);if(!a.ok)throw new Error(`Failed to fetch scope events: ${a.status}`);const i=await a.json();t({events:i.events||[],total:i.count||0,loading:!1})}catch(a){t({error:a instanceof Error?a.message:"Failed to fetch scope events",loading:!1})}},selectScope:s=>t({selectedScope:s}),toggleExcludedType:s=>{const l=new Set(n().excludedTypes);l.has(s)?l.delete(s):l.add(s),t({excludedTypes:l})},toggleExcludedService:s=>{const l=new Set(n().excludedServices);l.has(s)?l.delete(s):l.add(s),t({excludedServices:l})},clearAllExclusions:()=>t({excludedTypes:new Set,excludedServices:new Set}),setCategoryFilter:s=>t({categoryFilter:s}),handleWsMessage:s=>{s.type==="sentinel:event"&&s.event&&t(l=>({events:[s.event,...l.events].slice(0,500),total:l.total+1}))}}));function te(){r.useEffect(()=>{function t(n){const s=n.detail;s!=null&&s.type&&((s.type==="sentinel:log"||s.type==="sentinel:flow_event")&&Q.getState().handleWsMessage(s),s.type==="sentinel:event"&&R.getState().handleWsMessage(s))}return window.addEventListener("sentinel-ws",t),()=>window.removeEventListener("sentinel-ws",t)},[])}function ne(t){const[n,s]=r.useState(t),l=r.useRef(null),a=r.useCallback((d,f)=>{f.preventDefault(),l.current={idx:d,startX:f.clientX,startW:n[d]};const p=j=>{const g=l.current;if(!g)return;const x=Math.max(40,g.startW+(j.clientX-g.startX));s(c=>{const v=[...c];return v[g.idx]=x,v})},u=()=>{l.current=null,window.removeEventListener("mousemove",p),window.removeEventListener("mouseup",u)};window.addEventListener("mousemove",p),window.addEventListener("mouseup",u)},[n]);return{gridTemplate:n.map(d=>`${d}px`).join(" ")+" 1fr",onMouseDown:a}}function z({idx:t,onMouseDown:n}){return e.jsx("span",{className:"col-resize-handle",onMouseDown:s=>n(t,s)})}const ae={debug:"#94a3b8",info:"#3b82f6",warn:"#f59e0b",error:"#ef4444"},Y={component:"var(--p-symbol-component)",gate:"var(--p-symbol-gate)",signal:"var(--p-symbol-signal)",flow:"var(--p-symbol-flow)",aspect:"var(--p-symbol-aspect)",raw:"var(--p-text-muted)"};function ie(t){const n=new Date(t),s=(l,a=2)=>String(l).padStart(a,"0");return`${n.getFullYear()}-${s(n.getMonth()+1)}-${s(n.getDate())} ${s(n.getHours())}:${s(n.getMinutes())}:${s(n.getSeconds())}`}function ce({entry:t,isExpanded:n,onToggle:s,onContextMenu:l}){const a=Y[t.symbolType]||Y.raw;return e.jsxs("div",{className:`log-row log-row--${t.level}${n?" log-row--expanded":""}`,onClick:s,onContextMenu:l,children:[e.jsx("span",{className:"log-time",children:ie(t.timestamp)}),e.jsx("span",{className:"log-level",style:{color:ae[t.level]},children:t.level.toUpperCase().padEnd(5)}),e.jsx("span",{className:"log-symbol",style:{color:a},children:t.symbol}),e.jsx("span",{className:"log-service",children:t.service}),e.jsxs("span",{className:"log-message",children:[t.message,t.durationMs!==void 0&&e.jsxs("span",{className:"log-duration",children:[t.durationMs.toFixed(1),"ms"]})]}),n&&t.data&&e.jsx("div",{className:"log-data",onClick:i=>i.stopPropagation(),children:e.jsx("pre",{children:JSON.stringify(t.data,null,2)})})]})}function oe(){const{isLoading:t,error:n,isLive:s,services:l,levelFilter:a,serviceFilter:i,searchQuery:d,excludedSymbols:f,excludedSymbolTypes:p,excludedMessages:u,excludedServices:j,loadLogs:g,loadServices:x,setIsLive:c,setLevelFilter:v,setServiceFilter:m,setSearchQuery:y,getFilteredLogs:N,clearLogs:T,toggleExcludedSymbol:w,toggleExcludedSymbolType:k,toggleExcludedMessage:b,toggleExcludedService:F,clearAllExclusions:h}=Q(),S=N(),L=r.useRef(null),[C,V]=r.useState(new Set),[M,U]=r.useState(!1),[I,q]=r.useState(!0),[E,$]=r.useState(null),{gridTemplate:K,onMouseDown:D}=ne([180,50,160,100]),Z=f.size>0||p.size>0||u.size>0||j.size>0,ee=r.useCallback((o,A)=>{o.preventDefault(),$({x:o.clientX,y:o.clientY,entry:A})},[]);r.useEffect(()=>{if(!E)return;const o=()=>$(null);return window.addEventListener("click",o),()=>window.removeEventListener("click",o)},[E]);const se=o=>{V(A=>{const O=new Set(A);return O.has(o)?(O.delete(o),U(!1)):O.add(o),O})},le=()=>{M?(V(new Set),U(!1)):U(!0)};return r.useEffect(()=>(g(),x(),c(!0),()=>c(!1)),[]),r.useEffect(()=>{I&&L.current&&L.current.scrollIntoView({behavior:"smooth"})},[S.length,I]),t&&S.length===0?e.jsx("div",{className:"logs-view s-loading-state",children:e.jsxs("div",{className:"s-loading-content",children:[e.jsx("div",{className:"s-loading-spinner"}),e.jsx("p",{children:"Loading logs..."})]})}):n&&S.length===0?e.jsx("div",{className:"logs-view s-error-state",children:e.jsxs("div",{className:"s-error-content",children:[e.jsx("h2",{children:"Failed to load logs"}),e.jsx("p",{children:n}),e.jsx("button",{onClick:()=>g(),children:"Retry"})]})}):e.jsxs("div",{className:"logs-view",children:[e.jsxs("div",{className:"logs-toolbar",children:[e.jsxs("div",{className:"logs-filters",children:[e.jsxs("select",{value:a,onChange:o=>v(o.target.value),className:"logs-select",children:[e.jsx("option",{value:"all",children:"All Levels"}),e.jsx("option",{value:"debug",children:"Debug"}),e.jsx("option",{value:"info",children:"Info"}),e.jsx("option",{value:"warn",children:"Warn"}),e.jsx("option",{value:"error",children:"Error"})]}),e.jsxs("select",{value:i||"",onChange:o=>m(o.target.value||null),className:"logs-select",children:[e.jsx("option",{value:"",children:"All Services"}),l.map(o=>e.jsx("option",{value:o.name,children:o.name},o.name))]}),e.jsx("input",{type:"text",placeholder:"Search logs...",value:d,onChange:o=>y(o.target.value),className:"logs-search"})]}),e.jsxs("div",{className:"logs-actions",children:[e.jsxs("span",{className:"logs-count",children:[S.length," entries"]}),e.jsx("button",{className:`logs-expand-btn ${M?"active":""}`,onClick:le,title:M?"Collapse all payloads":"Expand all payloads",children:M?"Collapse All":"Expand All"}),e.jsxs("button",{className:`logs-live-btn ${s?"active":""}`,onClick:()=>c(!s),title:s?"Streaming live":"Click to connect",children:[e.jsx("span",{className:`live-dot ${s?"live":""}`}),s?"Live":"Paused"]}),e.jsx("button",{className:`logs-scroll-btn ${I?"active":""}`,onClick:()=>q(!I),title:"Auto-scroll to new logs",children:I?"Auto":"Manual"}),e.jsx("button",{className:"logs-clear-btn",onClick:T,title:"Clear log buffer",children:"Clear"})]})]}),Z&&e.jsxs("div",{className:"exclusion-bar",children:[[...f].map(o=>e.jsxs("span",{className:"exclusion-chip",children:["symbol: ",o," ",e.jsx("button",{onClick:()=>w(o),children:"×"})]},`sym-${o}`)),[...p].map(o=>e.jsxs("span",{className:"exclusion-chip",children:["type: ",o," ",e.jsx("button",{onClick:()=>k(o),children:"×"})]},`type-${o}`)),[...u].map(o=>e.jsxs("span",{className:"exclusion-chip",children:["msg: ",o.length>40?o.slice(0,40)+"...":o," ",e.jsx("button",{onClick:()=>b(o),children:"×"})]},`msg-${o}`)),[...j].map(o=>e.jsxs("span",{className:"exclusion-chip",children:["service: ",o," ",e.jsx("button",{onClick:()=>F(o),children:"×"})]},`svc-${o}`)),e.jsx("button",{className:"exclusion-clear",onClick:h,children:"Clear all"})]}),E&&e.jsxs("div",{className:"context-menu",style:{top:E.y,left:E.x},onClick:o=>o.stopPropagation(),children:[e.jsxs("button",{onClick:()=>{w(E.entry.symbol),$(null)},children:['Exclude symbol "',E.entry.symbol,'"']}),e.jsxs("button",{onClick:()=>{k(E.entry.symbolType),$(null)},children:['Exclude type "',E.entry.symbolType,'"']}),e.jsx("button",{onClick:()=>{b(E.entry.message),$(null)},children:"Exclude this message"}),e.jsxs("button",{onClick:()=>{F(E.entry.service),$(null)},children:['Exclude service "',E.entry.service,'"']})]}),e.jsxs("div",{className:"logs-table",style:{"--log-cols":K},children:[e.jsxs("div",{className:"logs-header",children:[e.jsxs("span",{className:"log-time",children:["Time",e.jsx(z,{idx:0,onMouseDown:D})]}),e.jsxs("span",{className:"log-level",children:["Level",e.jsx(z,{idx:1,onMouseDown:D})]}),e.jsxs("span",{className:"log-symbol",children:["Symbol",e.jsx(z,{idx:2,onMouseDown:D})]}),e.jsxs("span",{className:"log-service",children:["Service",e.jsx(z,{idx:3,onMouseDown:D})]}),e.jsx("span",{className:"log-message",children:"Message"})]}),e.jsxs("div",{className:"logs-body",children:[e.jsx("div",{ref:L}),S.length===0?e.jsxs("div",{className:"logs-empty",children:[e.jsx("p",{children:"No logs yet."}),e.jsxs("p",{className:"hint",children:["POST structured logs to ",e.jsx("code",{children:"/api/sentinel/logs"})," or connect an app with the Sentinel client SDK."]})]}):S.map(o=>e.jsx(ce,{entry:o,isExpanded:M||C.has(o.id),onToggle:()=>se(o.id),onContextMenu:A=>ee(A,o)},o.id))]})]})]})}const re=_((t,n)=>({incidents:[],patterns:[],selectedIncidentId:null,isLoading:!1,error:null,statusFilter:"all",environmentFilter:null,symbolFilter:null,loadIncidents:async()=>{t({isLoading:!0,error:null});try{const s=await fetch("/api/sentinel/incidents");if(!s.ok)throw new Error(`API error: ${s.status}`);const l=await s.json();t({incidents:l.incidents||[],isLoading:!1})}catch(s){t({isLoading:!1,error:s instanceof Error?s.message:"Failed to load incidents",incidents:[]})}},loadPatterns:async()=>{try{const s=await fetch("/api/sentinel/patterns");if(!s.ok)throw new Error(`API error: ${s.status}`);const l=await s.json();t({patterns:l.patterns||[]})}catch{}},selectIncident:s=>t({selectedIncidentId:s}),setStatusFilter:s=>t({statusFilter:s}),setEnvironmentFilter:s=>t({environmentFilter:s}),setSymbolFilter:s=>t({symbolFilter:s}),resolveIncident:async s=>{try{const l=await fetch(`/api/sentinel/incidents/${s}/resolve`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!l.ok)throw new Error(`API error: ${l.status}`);await n().loadIncidents()}catch(l){throw l}},getFilteredIncidents:()=>{const s=n();let l=s.incidents;return s.statusFilter!=="all"&&(l=l.filter(a=>a.status===s.statusFilter)),s.environmentFilter&&(l=l.filter(a=>a.environment===s.environmentFilter)),s.symbolFilter&&(l=l.filter(a=>{const i=a.symbols;return i.feature===s.symbolFilter||i.component===s.symbolFilter||i.flow===s.symbolFilter||i.gate===s.symbolFilter||i.signal===s.symbolFilter})),l},getSelectedIncident:()=>{const s=n();return s.incidents.find(l=>l.id===s.selectedIncidentId)}})),H={open:"#ef4444",investigating:"#f59e0b",resolved:"#22c55e","wont-fix":"#6b7280"},B={open:"Open",investigating:"Investigating",resolved:"Resolved","wont-fix":"Won't Fix"};function de(){const{isLoading:t,error:n,statusFilter:s,selectedIncidentId:l,loadIncidents:a,loadPatterns:i,selectIncident:d,setStatusFilter:f,getFilteredIncidents:p,getSelectedIncident:u,resolveIncident:j}=re(),g=p(),x=u();return r.useEffect(()=>{a(),i()},[]),t?e.jsx("div",{className:"incidents-view s-loading-state",children:e.jsxs("div",{className:"s-loading-content",children:[e.jsx("div",{className:"s-loading-spinner"}),e.jsx("p",{children:"Loading incidents..."})]})}):n?e.jsx("div",{className:"incidents-view s-error-state",children:e.jsxs("div",{className:"s-error-content",children:[e.jsx("h2",{children:"Failed to load incidents"}),e.jsx("p",{children:n}),e.jsx("button",{onClick:()=>a(),children:"Retry"})]})}):e.jsxs("div",{className:"incidents-view",children:[e.jsxs("div",{className:"incidents-filters",children:[e.jsxs("div",{className:"filter-group",children:[e.jsx("label",{children:"Status:"}),e.jsxs("select",{value:s,onChange:c=>f(c.target.value),children:[e.jsx("option",{value:"all",children:"All"}),e.jsx("option",{value:"open",children:"Open"}),e.jsx("option",{value:"investigating",children:"Investigating"}),e.jsx("option",{value:"resolved",children:"Resolved"}),e.jsx("option",{value:"wont-fix",children:"Won't Fix"})]})]}),e.jsxs("div",{className:"filter-stats",children:[g.length," incident",g.length!==1?"s":""]})]}),e.jsxs("div",{className:"incidents-content",children:[e.jsx("div",{className:"incidents-list",children:g.length===0?e.jsxs("div",{className:"incidents-empty",children:[e.jsx("p",{children:"No incidents found."}),e.jsx("p",{className:"hint",children:"Incidents are recorded when errors occur in your application."})]}):g.map(c=>e.jsxs("div",{className:`incident-card ${l===c.id?"selected":""}`,onClick:()=>d(c.id),children:[e.jsxs("div",{className:"incident-header",children:[e.jsx("span",{className:"incident-id",children:c.id}),e.jsx("span",{className:"incident-status",style:{color:H[c.status]},children:B[c.status]})]}),e.jsx("div",{className:"incident-error",children:c.error.message}),e.jsxs("div",{className:"incident-meta",children:[e.jsx("span",{className:"incident-env",children:c.environment}),e.jsx("span",{className:"incident-time",children:new Date(c.timestamp).toLocaleString()})]}),c.symbols&&Object.keys(c.symbols).length>0&&e.jsxs("div",{className:"incident-symbols",children:[c.symbols.component&&e.jsxs("span",{className:"symbol-tag component",children:["#",c.symbols.component]}),c.symbols.flow&&e.jsxs("span",{className:"symbol-tag flow",children:["$",c.symbols.flow]}),c.symbols.gate&&e.jsxs("span",{className:"symbol-tag gate",children:["^",c.symbols.gate]}),c.symbols.signal&&e.jsxs("span",{className:"symbol-tag signal",children:["!",c.symbols.signal]})]}),c.patternMatches&&c.patternMatches.length>0&&e.jsx("div",{className:"incident-patterns",children:e.jsxs("span",{className:"pattern-match",children:["Matched: ",c.patternMatches[0].patternName,"(",Math.round(c.patternMatches[0].confidence),"%)"]})})]},c.id))}),x&&e.jsxs("div",{className:"incident-detail",children:[e.jsxs("div",{className:"detail-header",children:[e.jsx("h2",{children:x.id}),e.jsx("button",{className:"detail-close",onClick:()=>d(null),children:"×"})]}),e.jsxs("div",{className:"detail-content",children:[e.jsxs("section",{className:"detail-section",children:[e.jsx("h3",{children:"Error"}),e.jsx("div",{className:"error-message",children:x.error.message}),x.error.type&&e.jsxs("div",{className:"error-type",children:["Type: ",x.error.type]})]}),e.jsxs("section",{className:"detail-section",children:[e.jsx("h3",{children:"Context"}),e.jsxs("div",{className:"detail-field",children:[e.jsx("label",{children:"Status"}),e.jsx("span",{className:"status-badge",style:{backgroundColor:H[x.status]},children:B[x.status]})]}),e.jsxs("div",{className:"detail-field",children:[e.jsx("label",{children:"Environment"}),e.jsx("span",{children:x.environment})]}),e.jsxs("div",{className:"detail-field",children:[e.jsx("label",{children:"Timestamp"}),e.jsx("span",{children:new Date(x.timestamp).toLocaleString()})]})]}),x.symbols&&Object.keys(x.symbols).length>0&&e.jsxs("section",{className:"detail-section",children:[e.jsx("h3",{children:"Symbols"}),e.jsx("div",{className:"symbols-list",children:Object.entries(x.symbols).map(([c,v])=>v&&e.jsxs("div",{className:"symbol-item",children:[e.jsx("label",{children:c}),e.jsx("span",{className:`symbol-value ${c}`,children:v})]},c))})]}),x.patternMatches&&x.patternMatches.length>0&&e.jsxs("section",{className:"detail-section",children:[e.jsx("h3",{children:"Pattern Matches"}),e.jsx("div",{className:"patterns-list",children:x.patternMatches.map(c=>e.jsxs("div",{className:"pattern-item",children:[e.jsx("div",{className:"pattern-name",children:c.patternName}),e.jsxs("div",{className:"pattern-confidence",children:[Math.round(c.confidence),"% confidence"]})]},c.patternId))})]}),x.status==="open"&&e.jsx("section",{className:"detail-actions",children:e.jsx("button",{className:"action-btn resolve",onClick:()=>j(x.id),children:"Mark Resolved"})})]})]})]})]})}const X=_((t,n)=>({schemas:[],selectedSchemaId:null,loading:!1,error:null,fetchSchemas:async()=>{t({loading:!0,error:null});try{const s=await fetch("/api/sentinel/schemas");if(!s.ok)throw new Error(`Failed to fetch schemas: ${s.status}`);const a=(await s.json()).schemas||[];t({schemas:a,loading:!1}),!n().selectedSchemaId&&a.length>0&&t({selectedSchemaId:a[0].id})}catch(s){t({error:s instanceof Error?s.message:"Failed to fetch schemas",loading:!1})}},selectSchema:s=>t({selectedSchemaId:s}),getSelectedSchema:()=>{const s=n();return s.schemas.find(l=>l.id===s.selectedSchemaId)}}));function ue(t){const[n,s]=r.useState(t),l=r.useRef(null),a=r.useCallback((d,f)=>{f.preventDefault(),l.current={idx:d,startX:f.clientX,startW:n[d]};const p=j=>{const g=l.current;if(!g)return;const x=Math.max(40,g.startW+(j.clientX-g.startX));s(c=>{const v=[...c];return v[g.idx]=x,v})},u=()=>{l.current=null,window.removeEventListener("mousemove",p),window.removeEventListener("mouseup",u)};window.addEventListener("mousemove",p),window.addEventListener("mouseup",u)},[n]);return{gridTemplate:n.map(d=>`${d}px`).join(" ")+" 1fr",onMouseDown:a}}function P({idx:t,onMouseDown:n}){return e.jsx("span",{className:"col-resize-handle",onMouseDown:s=>n(t,s)})}const me={debug:"#94a3b8",info:"#3b82f6",warn:"#f59e0b",error:"#ef4444"},he={logs:"#3b82f6",metrics:"#22c55e",traces:"#a855f7",incidents:"#ef4444",rules:"#f59e0b",state:"#06b6d4",cascade:"#ec4899",lifecycle:"#84cc16"};function pe(t){const n=new Date(t),s=(l,a=2)=>String(l).padStart(a,"0");return`${n.getFullYear()}-${s(n.getMonth()+1)}-${s(n.getDate())} ${s(n.getHours())}:${s(n.getMinutes())}:${s(n.getSeconds())}`}function W(t,n){var l;const s=(l=n==null?void 0:n.visualization)==null?void 0:l.categoryColors;return s&&s[t]?s[t]:he[t]||"var(--p-text-muted)"}function xe(){const{schemas:t,selectedSchemaId:n,selectSchema:s,fetchSchemas:l,loading:a}=X();return r.useEffect(()=>{l()},[]),a?e.jsx("div",{className:"events-loading",children:"Loading schemas..."}):t.length===0?e.jsxs("div",{className:"events-empty-state",children:[e.jsx("p",{children:"No event schemas registered."}),e.jsxs("p",{className:"hint",children:["Applications register schemas via ",e.jsx("code",{children:"POST /api/sentinel/schemas"}),"."]})]}):e.jsx("select",{className:"events-schema-select",value:n||"",onChange:i=>s(i.target.value||null),children:t.map(i=>e.jsxs("option",{value:i.id,children:[i.name," (v",i.version,")"]},i.id))})}function ve({schema:t}){const{scopes:n,selectedScope:s,fetchScopes:l,fetchScopeEvents:a,selectScope:i,fetchEvents:d}=R();r.useEffect(()=>{l(t.id)},[t.id]);const f=p=>{s===p?(i(null),d(t.id)):a(t.id,p)};return n.length===0?null:e.jsxs("div",{className:"events-scope-nav",children:[e.jsxs("div",{className:"events-scope-label",children:[t.scope.label,"s"]}),e.jsx("div",{className:"events-scope-list",children:n.slice(0,50).map(p=>e.jsxs("button",{className:`events-scope-chip ${s===p.scopeValue?"active":""}`,onClick:()=>f(p.scopeValue),title:`${p.eventCount} events`,children:[e.jsx("span",{className:"scope-value",children:t.scope.type==="number"?`#${p.scopeValue}`:p.scopeValue}),e.jsx("span",{className:"scope-count",children:p.eventCount})]},p.scopeValue))})]})}function ge({schema:t}){var p;const{events:n,categoryFilter:s,setCategoryFilter:l,excludedTypes:a,toggleExcludedType:i}=R(),d=[...new Set(n.map(u=>u.category))],f=((p=t.visualization)==null?void 0:p.defaultExcluded)||[];return r.useEffect(()=>{for(const u of f)a.has(u)||i(u)},[t.id]),e.jsxs("div",{className:"events-category-filters",children:[e.jsx("button",{className:`events-category-chip ${s?"":"active"}`,onClick:()=>l(null),children:"All"}),d.map(u=>e.jsx("button",{className:`events-category-chip ${s===u?"active":""}`,onClick:()=>l(s===u?null:u),style:{borderColor:W(u,t),color:s===u?"#fff":W(u,t),backgroundColor:s===u?W(u,t):"transparent"},children:u},u))]})}function fe({event:t,schema:n,isExpanded:s,onToggle:l,onContextMenu:a}){const i=W(t.category,n);return e.jsxs("div",{className:`event-row event-row--${t.severity||"info"}${s?" event-row--expanded":""}`,onClick:l,onContextMenu:a,children:[e.jsx("span",{className:"event-time",children:pe(t.timestamp)}),e.jsx("span",{className:"event-severity",style:{color:me[t.severity||"info"]},children:(t.severity||"info").toUpperCase().padEnd(5)}),e.jsxs("span",{className:"event-type",children:[t.category&&t.category!=="unknown"&&e.jsxs("span",{className:"event-category-badge",style:{color:i},children:["[",t.category,"]"]})," ",t.eventType]}),e.jsx("span",{className:"event-service",children:t.service}),t.scopeValue&&e.jsx("span",{className:"event-scope",children:t.scopeValue}),t.depth!=null&&t.depth>0&&e.jsx("span",{className:"event-depth",style:{paddingLeft:`${t.depth*12}px`},children:" ".repeat(t.depth)}),s&&t.data&&e.jsx("div",{className:"event-data",onClick:d=>d.stopPropagation(),children:e.jsx("pre",{children:JSON.stringify(t.data,null,2)})})]})}function je({schema:t}){const{events:n,excludedTypes:s,excludedServices:l,categoryFilter:a,loading:i,toggleExcludedType:d,toggleExcludedService:f,clearAllExclusions:p}=R(),[u,j]=r.useState(new Set),[g,x]=r.useState(!1),c=r.useRef(null),{gridTemplate:v,onMouseDown:m}=ue([180,50,200,100]),y=h=>{j(S=>{const L=new Set(S);return L.has(h)?(L.delete(h),x(!1)):L.add(h),L})},N=n.filter(h=>!(s.has(h.eventType)||l.has(h.service)||a&&h.category!==a)),T=s.size>0||l.size>0,[w,k]=r.useState(null),b=r.useCallback((h,S)=>{h.preventDefault(),k({x:h.clientX,y:h.clientY,event:S})},[]);r.useEffect(()=>{if(!w)return;const h=()=>k(null);return window.addEventListener("click",h),()=>window.removeEventListener("click",h)},[w]);const F=()=>{g?(j(new Set),x(!1)):x(!0)};return i?e.jsx("div",{className:"events-loading",children:"Loading events..."}):N.length===0?e.jsxs("div",{className:"events-empty-state",children:[e.jsx("p",{children:"No events to display."}),e.jsx("p",{className:"hint",children:"Events will appear here when applications send them to Sentinel."})]}):e.jsxs("div",{className:"events-table",ref:c,style:{"--evt-cols":v},children:[e.jsxs("div",{className:"events-table-actions",children:[e.jsxs("span",{className:"events-count",children:[N.length," events"]}),e.jsx("button",{className:`events-expand-btn ${g?"active":""}`,onClick:F,title:g?"Collapse all payloads":"Expand all payloads",children:g?"Collapse All":"Expand All"})]}),T&&e.jsxs("div",{className:"exclusion-bar",children:[[...s].map(h=>e.jsxs("span",{className:"exclusion-chip",children:["type: ",h," ",e.jsx("button",{onClick:()=>d(h),children:"×"})]},`type-${h}`)),[...l].map(h=>e.jsxs("span",{className:"exclusion-chip",children:["service: ",h," ",e.jsx("button",{onClick:()=>f(h),children:"×"})]},`svc-${h}`)),e.jsx("button",{className:"exclusion-clear",onClick:p,children:"Clear all"})]}),w&&e.jsxs("div",{className:"context-menu",style:{top:w.y,left:w.x},onClick:h=>h.stopPropagation(),children:[e.jsxs("button",{onClick:()=>{d(w.event.eventType),k(null)},children:['Exclude type "',w.event.eventType,'"']}),e.jsxs("button",{onClick:()=>{f(w.event.service),k(null)},children:['Exclude service "',w.event.service,'"']})]}),e.jsxs("div",{className:"events-table-header",children:[e.jsxs("span",{className:"event-time",children:["Time",e.jsx(P,{idx:0,onMouseDown:m})]}),e.jsxs("span",{className:"event-severity",children:["Level",e.jsx(P,{idx:1,onMouseDown:m})]}),e.jsxs("span",{className:"event-type",children:["Type",e.jsx(P,{idx:2,onMouseDown:m})]}),e.jsxs("span",{className:"event-service",children:["Service",e.jsx(P,{idx:3,onMouseDown:m})]}),e.jsx("span",{className:"event-scope",children:"Scope"})]}),e.jsx("div",{className:"events-table-body",children:N.map(h=>e.jsx(fe,{event:h,schema:t,isExpanded:g||u.has(h.id),onToggle:()=>y(h.id),onContextMenu:S=>b(S,h)},h.id))})]})}function ye(){const{selectedSchemaId:t}=X(),n=X(l=>l.getSelectedSchema()),{fetchEvents:s}=R();return r.useEffect(()=>{t&&s(t)},[t]),e.jsxs("div",{className:"events-view",children:[e.jsxs("div",{className:"events-toolbar",children:[e.jsx(xe,{}),n&&e.jsx(ge,{schema:n})]}),n&&e.jsx(ve,{schema:n}),n?e.jsx(je,{schema:n}):e.jsx("div",{className:"events-empty-state",children:e.jsx("p",{children:"Select a schema to view events."})})]})}const G={gate:"var(--p-symbol-gate)",action:"var(--p-symbol-component)",signal:"var(--p-symbol-signal)"},be={gate:"^",action:"#",signal:"!"};function J(t,n){const s=Date.now();return n.some(l=>l.nodeSymbol===t&&s-new Date(l.timestamp).getTime()<5e3)}function we({flow:t,flowEvents:n,isSelected:s,onSelect:l}){return e.jsxs("div",{className:`flow-card ${s?"selected":""}`,onClick:l,children:[e.jsxs("div",{className:"flow-card-header",children:[e.jsx("span",{className:"flow-card-id",children:t.id}),t.trigger&&e.jsx("span",{className:"flow-card-trigger",children:t.trigger})]}),e.jsx("div",{className:"flow-card-name",children:t.name}),e.jsx("div",{className:"flow-card-steps",children:t.steps.map((a,i)=>{const d=J(a.symbol,n);return e.jsxs("div",{className:"flow-step-mini",children:[i>0&&e.jsx("span",{className:"flow-arrow",children:"→"}),e.jsx("span",{className:`flow-step-dot ${d?"active pulse":""}`,style:{backgroundColor:d?G[a.type]:"var(--p-text-muted)"},title:`${a.symbol} (${a.type})`})]},i)})})]})}function Se({flow:t,flowEvents:n}){return e.jsxs("div",{className:"flow-diagram",children:[e.jsx("h3",{children:t.name}),t.trigger&&e.jsxs("div",{className:"flow-trigger-label",children:["Trigger: ",e.jsx("code",{children:t.trigger})]}),e.jsx("div",{className:"flow-steps",children:t.steps.map((s,l)=>{const a=J(s.symbol,n),i=n.find(d=>d.nodeSymbol===s.symbol);return e.jsxs("div",{className:"flow-step-container",children:[l>0&&e.jsx("div",{className:"flow-connector",children:e.jsx("div",{className:`flow-line ${a?"active":""}`})}),e.jsxs("div",{className:`flow-step-node ${a?"active":""}`,style:{borderColor:G[s.type]},children:[e.jsx("span",{className:"flow-step-icon",children:be[s.type]}),e.jsx("span",{className:"flow-step-symbol",children:s.symbol}),e.jsx("span",{className:"flow-step-type",children:s.type}),a&&i&&e.jsxs("span",{className:"flow-step-live",children:[i.service," · ",new Date(i.timestamp).toLocaleTimeString()]})]})]},l)})})]})}function Ne({symbols:t,onSave:n,onCancel:s}){const[l,a]=r.useState(""),[i,d]=r.useState(""),[f,p]=r.useState([]),u=r.useCallback(v=>{p(m=>[...m,{type:v,symbol:""}])},[]),j=r.useCallback((v,m,y)=>{p(N=>N.map((T,w)=>w===v?{...T,[m]:y}:T))},[]),g=r.useCallback(v=>{p(m=>m.filter((y,N)=>N!==v))},[]),x=()=>{if(!l||f.length===0)return;const v=`$${l.toLowerCase().replace(/\s+/g,"-")}`;n({id:v,name:l,trigger:i||void 0,steps:f})},c=v=>v==="gate"?t.filter(m=>m.type==="gate"):v==="signal"?t.filter(m=>m.type==="signal"):t.filter(m=>m.type==="component");return e.jsxs("div",{className:"flow-composer",children:[e.jsx("h3",{children:"New Flow"}),e.jsxs("div",{className:"composer-field",children:[e.jsx("label",{children:"Flow Name"}),e.jsx("input",{type:"text",placeholder:"e.g. Checkout Flow",value:l,onChange:v=>a(v.target.value)})]}),e.jsxs("div",{className:"composer-field",children:[e.jsx("label",{children:"Trigger (optional)"}),e.jsx("input",{type:"text",placeholder:"e.g. POST /api/checkout",value:i,onChange:v=>d(v.target.value)})]}),e.jsxs("div",{className:"composer-steps",children:[e.jsx("label",{children:"Steps"}),f.map((v,m)=>e.jsxs("div",{className:"composer-step",children:[e.jsxs("select",{value:v.type,onChange:y=>j(m,"type",y.target.value),children:[e.jsx("option",{value:"gate",children:"Gate (^)"}),e.jsx("option",{value:"action",children:"Action (#)"}),e.jsx("option",{value:"signal",children:"Signal (!)"})]}),e.jsxs("select",{value:v.symbol,onChange:y=>j(m,"symbol",y.target.value),children:[e.jsx("option",{value:"",children:"Select symbol..."}),c(v.type).map(y=>e.jsx("option",{value:y.symbol,children:y.symbol},y.symbol))]}),e.jsx("button",{className:"composer-remove",onClick:()=>g(m),children:"×"})]},m)),e.jsxs("div",{className:"composer-add-buttons",children:[e.jsx("button",{onClick:()=>u("gate"),children:"+ Gate"}),e.jsx("button",{onClick:()=>u("action"),children:"+ Action"}),e.jsx("button",{onClick:()=>u("signal"),children:"+ Signal"})]})]}),e.jsxs("div",{className:"composer-actions",children:[e.jsx("button",{className:"action-btn",onClick:x,disabled:!l||f.length===0,children:"Save Flow"}),e.jsx("button",{className:"action-btn cancel",onClick:s,children:"Cancel"})]})]})}function Ce(){const{flowEvents:t,isLive:n,setIsLive:s}=Q(),[l,a]=r.useState([]),[i,d]=r.useState([]),[f,p]=r.useState(null),[u,j]=r.useState(!1),[g,x]=r.useState(!0),c=l.find(m=>m.id===f);r.useEffect(()=>{async function m(){try{const y=await fetch("/api/sentinel/symbols");if(!y.ok){x(!1);return}const N=await y.json(),T=(N.symbols||[]).map(b=>({symbol:b.symbol,type:b.type}));d(T);const k=(N.symbols||[]).filter(b=>b.type==="flow").map(b=>{var h,S,L;const F=[];if((h=b.data)!=null&&h.steps&&Array.isArray(b.data.steps))for(const C of b.data.steps)F.push({type:C.type||"action",symbol:C.symbol||"",label:C.label});if(F.length===0&&b.references)for(const C of b.references)C.startsWith("^")?F.push({type:"gate",symbol:C}):C.startsWith("!")?F.push({type:"signal",symbol:C}):C.startsWith("#")&&F.push({type:"action",symbol:C});return{id:b.symbol,name:((S=b.data)==null?void 0:S.name)||b.symbol.replace("$",""),trigger:(L=b.data)==null?void 0:L.trigger,steps:F}});a(k),x(!1)}catch{x(!1)}}m()},[]),r.useEffect(()=>(s(!0),()=>s(!1)),[]);const v=m=>{a(y=>[...y,m]),j(!1),p(m.id)};return g?e.jsx("div",{className:"flows-view s-loading-state",children:e.jsxs("div",{className:"s-loading-content",children:[e.jsx("div",{className:"s-loading-spinner"}),e.jsx("p",{children:"Loading flows..."})]})}):e.jsxs("div",{className:"flows-view",children:[e.jsxs("div",{className:"flows-toolbar",children:[e.jsxs("div",{className:"flows-toolbar-left",children:[e.jsxs("span",{className:"flows-count",children:[l.length," flow",l.length!==1?"s":""]}),e.jsxs("button",{className:`logs-live-btn ${n?"active":""}`,onClick:()=>s(!n),children:[e.jsx("span",{className:`live-dot ${n?"live":""}`}),n?"Live":"Paused"]})]}),e.jsx("div",{className:"flows-toolbar-right",children:e.jsx("button",{className:"action-btn",onClick:()=>{j(!0),p(null)},children:"+ New Flow"})})]}),e.jsxs("div",{className:"flows-content",children:[e.jsx("div",{className:"flows-list",children:l.length===0&&!u?e.jsxs("div",{className:"flows-empty",children:[e.jsx("p",{children:"No flows defined."}),e.jsxs("p",{className:"hint",children:["Define flows in ",e.jsx("code",{children:".purpose"})," files or use the composer to create one."]})]}):l.map(m=>e.jsx(we,{flow:m,flowEvents:t,isSelected:f===m.id,onSelect:()=>{p(m.id),j(!1)}},m.id))}),e.jsx("div",{className:"flows-detail",children:u?e.jsx(Ne,{symbols:i,onSave:v,onCancel:()=>j(!1)}):c?e.jsx(Se,{flow:c,flowEvents:t}):e.jsx("div",{className:"flows-empty-detail",children:e.jsx("p",{children:"Select a flow to visualize or create a new one."})})})]})]})}const Ee=[{id:"logs",label:"Logs"},{id:"incidents",label:"Incidents"},{id:"events",label:"Events"},{id:"flows",label:"Flows"}];function Le(){const[t,n]=r.useState("logs");return te(),e.jsxs("div",{className:"sentinel-section",children:[e.jsx("div",{className:"sentinel-tabs",children:Ee.map(s=>e.jsx("button",{className:`sentinel-tab ${t===s.id?"active":""}`,onClick:()=>n(s.id),children:s.label},s.id))}),e.jsxs("div",{className:"sentinel-tab-content",children:[t==="logs"&&e.jsx(oe,{}),t==="incidents"&&e.jsx(de,{}),t==="events"&&e.jsx(ye,{}),t==="flows"&&e.jsx(Ce,{})]})]})}export{Le as default};
1
+ import{c as _,r,j as e}from"./index-G9JnWEs_.js";const Q=_((t,n)=>({logs:[],services:[],flowEvents:[],isLoading:!1,error:null,isLive:!1,levelFilter:"all",serviceFilter:null,symbolFilter:null,searchQuery:"",excludedSymbols:new Set,excludedSymbolTypes:new Set,excludedMessages:new Set,excludedServices:new Set,loadLogs:async()=>{t({isLoading:!0,error:null});try{const s=new URLSearchParams,l=n();l.levelFilter!=="all"&&s.set("level",l.levelFilter),l.serviceFilter&&s.set("service",l.serviceFilter),l.symbolFilter&&s.set("symbol",l.symbolFilter),l.searchQuery&&s.set("search",l.searchQuery),s.set("limit","200");const a=await fetch(`/api/sentinel/logs?${s}`);if(!a.ok)throw new Error(`API error: ${a.status}`);const i=await a.json();t({logs:i.logs||[],isLoading:!1})}catch(s){t({isLoading:!1,error:s instanceof Error?s.message:"Failed to load logs",logs:[]})}},loadServices:async()=>{try{const s=await fetch("/api/sentinel/services");if(!s.ok)return;const l=await s.json();t({services:l.services||[]})}catch{}},handleWsMessage:s=>{if(s.type==="sentinel:log"&&s.entry&&t(l=>({logs:[s.entry,...l.logs].slice(0,500)})),s.type==="sentinel:flow_event"){const l={type:"flow_event",flowId:s.flowId,nodeSymbol:s.nodeSymbol,event:s.event,timestamp:s.timestamp,service:s.service};t(a=>({flowEvents:[l,...a.flowEvents].slice(0,200)}))}},setIsLive:s=>t({isLive:s}),setLevelFilter:s=>t({levelFilter:s}),setServiceFilter:s=>t({serviceFilter:s}),setSymbolFilter:s=>t({symbolFilter:s}),setSearchQuery:s=>t({searchQuery:s}),clearLogs:()=>t({logs:[],flowEvents:[]}),toggleExcludedSymbol:s=>{const l=new Set(n().excludedSymbols);l.has(s)?l.delete(s):l.add(s),t({excludedSymbols:l})},toggleExcludedSymbolType:s=>{const l=new Set(n().excludedSymbolTypes);l.has(s)?l.delete(s):l.add(s),t({excludedSymbolTypes:l})},toggleExcludedMessage:s=>{const l=new Set(n().excludedMessages);l.has(s)?l.delete(s):l.add(s),t({excludedMessages:l})},toggleExcludedService:s=>{const l=new Set(n().excludedServices);l.has(s)?l.delete(s):l.add(s),t({excludedServices:l})},clearAllExclusions:()=>t({excludedSymbols:new Set,excludedSymbolTypes:new Set,excludedMessages:new Set,excludedServices:new Set}),getFilteredLogs:()=>{const s=n();let l=s.logs;if(s.levelFilter!=="all"&&(l=l.filter(a=>a.level===s.levelFilter)),s.serviceFilter&&(l=l.filter(a=>a.service===s.serviceFilter)),s.symbolFilter&&(l=l.filter(a=>a.symbol.includes(s.symbolFilter))),s.searchQuery){const a=s.searchQuery.toLowerCase();l=l.filter(i=>i.message.toLowerCase().includes(a)||i.symbol.toLowerCase().includes(a))}return s.excludedSymbols.size>0&&(l=l.filter(a=>!s.excludedSymbols.has(a.symbol))),s.excludedSymbolTypes.size>0&&(l=l.filter(a=>!s.excludedSymbolTypes.has(a.symbolType))),s.excludedMessages.size>0&&(l=l.filter(a=>!s.excludedMessages.has(a.message))),s.excludedServices.size>0&&(l=l.filter(a=>!s.excludedServices.has(a.service))),l}})),R=_((t,n)=>({events:[],scopes:[],selectedScope:null,excludedTypes:new Set,excludedServices:new Set,categoryFilter:null,loading:!1,error:null,total:0,fetchEvents:async(s,l={})=>{t({loading:!0,error:null});try{const a=new URLSearchParams({schemaId:s,...l}),i=await fetch(`/api/sentinel/events?${a}`);if(!i.ok)throw new Error(`Failed to fetch events: ${i.status}`);const d=await i.json();t({events:d.events||[],total:d.total||0,loading:!1})}catch(a){t({error:a instanceof Error?a.message:"Failed to fetch events",loading:!1})}},fetchScopes:async s=>{try{const l=await fetch(`/api/sentinel/events/scopes?schemaId=${encodeURIComponent(s)}`);if(!l.ok)throw new Error(`Failed to fetch scopes: ${l.status}`);const a=await l.json();t({scopes:a.scopes||[]})}catch(l){t({error:l instanceof Error?l.message:"Failed to fetch scopes"})}},fetchScopeEvents:async(s,l)=>{t({loading:!0,error:null,selectedScope:l});try{const a=await fetch(`/api/sentinel/events/scope/${encodeURIComponent(l)}?schemaId=${encodeURIComponent(s)}`);if(!a.ok)throw new Error(`Failed to fetch scope events: ${a.status}`);const i=await a.json();t({events:i.events||[],total:i.count||0,loading:!1})}catch(a){t({error:a instanceof Error?a.message:"Failed to fetch scope events",loading:!1})}},selectScope:s=>t({selectedScope:s}),toggleExcludedType:s=>{const l=new Set(n().excludedTypes);l.has(s)?l.delete(s):l.add(s),t({excludedTypes:l})},toggleExcludedService:s=>{const l=new Set(n().excludedServices);l.has(s)?l.delete(s):l.add(s),t({excludedServices:l})},clearAllExclusions:()=>t({excludedTypes:new Set,excludedServices:new Set}),setCategoryFilter:s=>t({categoryFilter:s}),handleWsMessage:s=>{s.type==="sentinel:event"&&s.event&&t(l=>({events:[s.event,...l.events].slice(0,500),total:l.total+1}))}}));function te(){r.useEffect(()=>{function t(n){const s=n.detail;s!=null&&s.type&&((s.type==="sentinel:log"||s.type==="sentinel:flow_event")&&Q.getState().handleWsMessage(s),s.type==="sentinel:event"&&R.getState().handleWsMessage(s))}return window.addEventListener("sentinel-ws",t),()=>window.removeEventListener("sentinel-ws",t)},[])}function ne(t){const[n,s]=r.useState(t),l=r.useRef(null),a=r.useCallback((d,f)=>{f.preventDefault(),l.current={idx:d,startX:f.clientX,startW:n[d]};const p=j=>{const g=l.current;if(!g)return;const x=Math.max(40,g.startW+(j.clientX-g.startX));s(c=>{const v=[...c];return v[g.idx]=x,v})},u=()=>{l.current=null,window.removeEventListener("mousemove",p),window.removeEventListener("mouseup",u)};window.addEventListener("mousemove",p),window.addEventListener("mouseup",u)},[n]);return{gridTemplate:n.map(d=>`${d}px`).join(" ")+" 1fr",onMouseDown:a}}function z({idx:t,onMouseDown:n}){return e.jsx("span",{className:"col-resize-handle",onMouseDown:s=>n(t,s)})}const ae={debug:"#94a3b8",info:"#3b82f6",warn:"#f59e0b",error:"#ef4444"},Y={component:"var(--p-symbol-component)",gate:"var(--p-symbol-gate)",signal:"var(--p-symbol-signal)",flow:"var(--p-symbol-flow)",aspect:"var(--p-symbol-aspect)",raw:"var(--p-text-muted)"};function ie(t){const n=new Date(t),s=(l,a=2)=>String(l).padStart(a,"0");return`${n.getFullYear()}-${s(n.getMonth()+1)}-${s(n.getDate())} ${s(n.getHours())}:${s(n.getMinutes())}:${s(n.getSeconds())}`}function ce({entry:t,isExpanded:n,onToggle:s,onContextMenu:l}){const a=Y[t.symbolType]||Y.raw;return e.jsxs("div",{className:`log-row log-row--${t.level}${n?" log-row--expanded":""}`,onClick:s,onContextMenu:l,children:[e.jsx("span",{className:"log-time",children:ie(t.timestamp)}),e.jsx("span",{className:"log-level",style:{color:ae[t.level]},children:t.level.toUpperCase().padEnd(5)}),e.jsx("span",{className:"log-symbol",style:{color:a},children:t.symbol}),e.jsx("span",{className:"log-service",children:t.service}),e.jsxs("span",{className:"log-message",children:[t.message,t.durationMs!==void 0&&e.jsxs("span",{className:"log-duration",children:[t.durationMs.toFixed(1),"ms"]})]}),n&&t.data&&e.jsx("div",{className:"log-data",onClick:i=>i.stopPropagation(),children:e.jsx("pre",{children:JSON.stringify(t.data,null,2)})})]})}function oe(){const{isLoading:t,error:n,isLive:s,services:l,levelFilter:a,serviceFilter:i,searchQuery:d,excludedSymbols:f,excludedSymbolTypes:p,excludedMessages:u,excludedServices:j,loadLogs:g,loadServices:x,setIsLive:c,setLevelFilter:v,setServiceFilter:m,setSearchQuery:y,getFilteredLogs:N,clearLogs:T,toggleExcludedSymbol:w,toggleExcludedSymbolType:k,toggleExcludedMessage:b,toggleExcludedService:F,clearAllExclusions:h}=Q(),S=N(),L=r.useRef(null),[C,V]=r.useState(new Set),[M,U]=r.useState(!1),[I,q]=r.useState(!0),[E,$]=r.useState(null),{gridTemplate:K,onMouseDown:D}=ne([180,50,160,100]),Z=f.size>0||p.size>0||u.size>0||j.size>0,ee=r.useCallback((o,A)=>{o.preventDefault(),$({x:o.clientX,y:o.clientY,entry:A})},[]);r.useEffect(()=>{if(!E)return;const o=()=>$(null);return window.addEventListener("click",o),()=>window.removeEventListener("click",o)},[E]);const se=o=>{V(A=>{const O=new Set(A);return O.has(o)?(O.delete(o),U(!1)):O.add(o),O})},le=()=>{M?(V(new Set),U(!1)):U(!0)};return r.useEffect(()=>(g(),x(),c(!0),()=>c(!1)),[]),r.useEffect(()=>{I&&L.current&&L.current.scrollIntoView({behavior:"smooth"})},[S.length,I]),t&&S.length===0?e.jsx("div",{className:"logs-view s-loading-state",children:e.jsxs("div",{className:"s-loading-content",children:[e.jsx("div",{className:"s-loading-spinner"}),e.jsx("p",{children:"Loading logs..."})]})}):n&&S.length===0?e.jsx("div",{className:"logs-view s-error-state",children:e.jsxs("div",{className:"s-error-content",children:[e.jsx("h2",{children:"Failed to load logs"}),e.jsx("p",{children:n}),e.jsx("button",{onClick:()=>g(),children:"Retry"})]})}):e.jsxs("div",{className:"logs-view",children:[e.jsxs("div",{className:"logs-toolbar",children:[e.jsxs("div",{className:"logs-filters",children:[e.jsxs("select",{value:a,onChange:o=>v(o.target.value),className:"logs-select",children:[e.jsx("option",{value:"all",children:"All Levels"}),e.jsx("option",{value:"debug",children:"Debug"}),e.jsx("option",{value:"info",children:"Info"}),e.jsx("option",{value:"warn",children:"Warn"}),e.jsx("option",{value:"error",children:"Error"})]}),e.jsxs("select",{value:i||"",onChange:o=>m(o.target.value||null),className:"logs-select",children:[e.jsx("option",{value:"",children:"All Services"}),l.map(o=>e.jsx("option",{value:o.name,children:o.name},o.name))]}),e.jsx("input",{type:"text",placeholder:"Search logs...",value:d,onChange:o=>y(o.target.value),className:"logs-search"})]}),e.jsxs("div",{className:"logs-actions",children:[e.jsxs("span",{className:"logs-count",children:[S.length," entries"]}),e.jsx("button",{className:`logs-expand-btn ${M?"active":""}`,onClick:le,title:M?"Collapse all payloads":"Expand all payloads",children:M?"Collapse All":"Expand All"}),e.jsxs("button",{className:`logs-live-btn ${s?"active":""}`,onClick:()=>c(!s),title:s?"Streaming live":"Click to connect",children:[e.jsx("span",{className:`live-dot ${s?"live":""}`}),s?"Live":"Paused"]}),e.jsx("button",{className:`logs-scroll-btn ${I?"active":""}`,onClick:()=>q(!I),title:"Auto-scroll to new logs",children:I?"Auto":"Manual"}),e.jsx("button",{className:"logs-clear-btn",onClick:T,title:"Clear log buffer",children:"Clear"})]})]}),Z&&e.jsxs("div",{className:"exclusion-bar",children:[[...f].map(o=>e.jsxs("span",{className:"exclusion-chip",children:["symbol: ",o," ",e.jsx("button",{onClick:()=>w(o),children:"×"})]},`sym-${o}`)),[...p].map(o=>e.jsxs("span",{className:"exclusion-chip",children:["type: ",o," ",e.jsx("button",{onClick:()=>k(o),children:"×"})]},`type-${o}`)),[...u].map(o=>e.jsxs("span",{className:"exclusion-chip",children:["msg: ",o.length>40?o.slice(0,40)+"...":o," ",e.jsx("button",{onClick:()=>b(o),children:"×"})]},`msg-${o}`)),[...j].map(o=>e.jsxs("span",{className:"exclusion-chip",children:["service: ",o," ",e.jsx("button",{onClick:()=>F(o),children:"×"})]},`svc-${o}`)),e.jsx("button",{className:"exclusion-clear",onClick:h,children:"Clear all"})]}),E&&e.jsxs("div",{className:"context-menu",style:{top:E.y,left:E.x},onClick:o=>o.stopPropagation(),children:[e.jsxs("button",{onClick:()=>{w(E.entry.symbol),$(null)},children:['Exclude symbol "',E.entry.symbol,'"']}),e.jsxs("button",{onClick:()=>{k(E.entry.symbolType),$(null)},children:['Exclude type "',E.entry.symbolType,'"']}),e.jsx("button",{onClick:()=>{b(E.entry.message),$(null)},children:"Exclude this message"}),e.jsxs("button",{onClick:()=>{F(E.entry.service),$(null)},children:['Exclude service "',E.entry.service,'"']})]}),e.jsxs("div",{className:"logs-table",style:{"--log-cols":K},children:[e.jsxs("div",{className:"logs-header",children:[e.jsxs("span",{className:"log-time",children:["Time",e.jsx(z,{idx:0,onMouseDown:D})]}),e.jsxs("span",{className:"log-level",children:["Level",e.jsx(z,{idx:1,onMouseDown:D})]}),e.jsxs("span",{className:"log-symbol",children:["Symbol",e.jsx(z,{idx:2,onMouseDown:D})]}),e.jsxs("span",{className:"log-service",children:["Service",e.jsx(z,{idx:3,onMouseDown:D})]}),e.jsx("span",{className:"log-message",children:"Message"})]}),e.jsxs("div",{className:"logs-body",children:[e.jsx("div",{ref:L}),S.length===0?e.jsxs("div",{className:"logs-empty",children:[e.jsx("p",{children:"No logs yet."}),e.jsxs("p",{className:"hint",children:["POST structured logs to ",e.jsx("code",{children:"/api/sentinel/logs"})," or connect an app with the Sentinel client SDK."]})]}):S.map(o=>e.jsx(ce,{entry:o,isExpanded:M||C.has(o.id),onToggle:()=>se(o.id),onContextMenu:A=>ee(A,o)},o.id))]})]})]})}const re=_((t,n)=>({incidents:[],patterns:[],selectedIncidentId:null,isLoading:!1,error:null,statusFilter:"all",environmentFilter:null,symbolFilter:null,loadIncidents:async()=>{t({isLoading:!0,error:null});try{const s=await fetch("/api/sentinel/incidents");if(!s.ok)throw new Error(`API error: ${s.status}`);const l=await s.json();t({incidents:l.incidents||[],isLoading:!1})}catch(s){t({isLoading:!1,error:s instanceof Error?s.message:"Failed to load incidents",incidents:[]})}},loadPatterns:async()=>{try{const s=await fetch("/api/sentinel/patterns");if(!s.ok)throw new Error(`API error: ${s.status}`);const l=await s.json();t({patterns:l.patterns||[]})}catch{}},selectIncident:s=>t({selectedIncidentId:s}),setStatusFilter:s=>t({statusFilter:s}),setEnvironmentFilter:s=>t({environmentFilter:s}),setSymbolFilter:s=>t({symbolFilter:s}),resolveIncident:async s=>{try{const l=await fetch(`/api/sentinel/incidents/${s}/resolve`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!l.ok)throw new Error(`API error: ${l.status}`);await n().loadIncidents()}catch(l){throw l}},getFilteredIncidents:()=>{const s=n();let l=s.incidents;return s.statusFilter!=="all"&&(l=l.filter(a=>a.status===s.statusFilter)),s.environmentFilter&&(l=l.filter(a=>a.environment===s.environmentFilter)),s.symbolFilter&&(l=l.filter(a=>{const i=a.symbols;return i.feature===s.symbolFilter||i.component===s.symbolFilter||i.flow===s.symbolFilter||i.gate===s.symbolFilter||i.signal===s.symbolFilter})),l},getSelectedIncident:()=>{const s=n();return s.incidents.find(l=>l.id===s.selectedIncidentId)}})),H={open:"#ef4444",investigating:"#f59e0b",resolved:"#22c55e","wont-fix":"#6b7280"},B={open:"Open",investigating:"Investigating",resolved:"Resolved","wont-fix":"Won't Fix"};function de(){const{isLoading:t,error:n,statusFilter:s,selectedIncidentId:l,loadIncidents:a,loadPatterns:i,selectIncident:d,setStatusFilter:f,getFilteredIncidents:p,getSelectedIncident:u,resolveIncident:j}=re(),g=p(),x=u();return r.useEffect(()=>{a(),i()},[]),t?e.jsx("div",{className:"incidents-view s-loading-state",children:e.jsxs("div",{className:"s-loading-content",children:[e.jsx("div",{className:"s-loading-spinner"}),e.jsx("p",{children:"Loading incidents..."})]})}):n?e.jsx("div",{className:"incidents-view s-error-state",children:e.jsxs("div",{className:"s-error-content",children:[e.jsx("h2",{children:"Failed to load incidents"}),e.jsx("p",{children:n}),e.jsx("button",{onClick:()=>a(),children:"Retry"})]})}):e.jsxs("div",{className:"incidents-view",children:[e.jsxs("div",{className:"incidents-filters",children:[e.jsxs("div",{className:"filter-group",children:[e.jsx("label",{children:"Status:"}),e.jsxs("select",{value:s,onChange:c=>f(c.target.value),children:[e.jsx("option",{value:"all",children:"All"}),e.jsx("option",{value:"open",children:"Open"}),e.jsx("option",{value:"investigating",children:"Investigating"}),e.jsx("option",{value:"resolved",children:"Resolved"}),e.jsx("option",{value:"wont-fix",children:"Won't Fix"})]})]}),e.jsxs("div",{className:"filter-stats",children:[g.length," incident",g.length!==1?"s":""]})]}),e.jsxs("div",{className:"incidents-content",children:[e.jsx("div",{className:"incidents-list",children:g.length===0?e.jsxs("div",{className:"incidents-empty",children:[e.jsx("p",{children:"No incidents found."}),e.jsx("p",{className:"hint",children:"Incidents are recorded when errors occur in your application."})]}):g.map(c=>e.jsxs("div",{className:`incident-card ${l===c.id?"selected":""}`,onClick:()=>d(c.id),children:[e.jsxs("div",{className:"incident-header",children:[e.jsx("span",{className:"incident-id",children:c.id}),e.jsx("span",{className:"incident-status",style:{color:H[c.status]},children:B[c.status]})]}),e.jsx("div",{className:"incident-error",children:c.error.message}),e.jsxs("div",{className:"incident-meta",children:[e.jsx("span",{className:"incident-env",children:c.environment}),e.jsx("span",{className:"incident-time",children:new Date(c.timestamp).toLocaleString()})]}),c.symbols&&Object.keys(c.symbols).length>0&&e.jsxs("div",{className:"incident-symbols",children:[c.symbols.component&&e.jsxs("span",{className:"symbol-tag component",children:["#",c.symbols.component]}),c.symbols.flow&&e.jsxs("span",{className:"symbol-tag flow",children:["$",c.symbols.flow]}),c.symbols.gate&&e.jsxs("span",{className:"symbol-tag gate",children:["^",c.symbols.gate]}),c.symbols.signal&&e.jsxs("span",{className:"symbol-tag signal",children:["!",c.symbols.signal]})]}),c.patternMatches&&c.patternMatches.length>0&&e.jsx("div",{className:"incident-patterns",children:e.jsxs("span",{className:"pattern-match",children:["Matched: ",c.patternMatches[0].patternName,"(",Math.round(c.patternMatches[0].confidence),"%)"]})})]},c.id))}),x&&e.jsxs("div",{className:"incident-detail",children:[e.jsxs("div",{className:"detail-header",children:[e.jsx("h2",{children:x.id}),e.jsx("button",{className:"detail-close",onClick:()=>d(null),children:"×"})]}),e.jsxs("div",{className:"detail-content",children:[e.jsxs("section",{className:"detail-section",children:[e.jsx("h3",{children:"Error"}),e.jsx("div",{className:"error-message",children:x.error.message}),x.error.type&&e.jsxs("div",{className:"error-type",children:["Type: ",x.error.type]})]}),e.jsxs("section",{className:"detail-section",children:[e.jsx("h3",{children:"Context"}),e.jsxs("div",{className:"detail-field",children:[e.jsx("label",{children:"Status"}),e.jsx("span",{className:"status-badge",style:{backgroundColor:H[x.status]},children:B[x.status]})]}),e.jsxs("div",{className:"detail-field",children:[e.jsx("label",{children:"Environment"}),e.jsx("span",{children:x.environment})]}),e.jsxs("div",{className:"detail-field",children:[e.jsx("label",{children:"Timestamp"}),e.jsx("span",{children:new Date(x.timestamp).toLocaleString()})]})]}),x.symbols&&Object.keys(x.symbols).length>0&&e.jsxs("section",{className:"detail-section",children:[e.jsx("h3",{children:"Symbols"}),e.jsx("div",{className:"symbols-list",children:Object.entries(x.symbols).map(([c,v])=>v&&e.jsxs("div",{className:"symbol-item",children:[e.jsx("label",{children:c}),e.jsx("span",{className:`symbol-value ${c}`,children:v})]},c))})]}),x.patternMatches&&x.patternMatches.length>0&&e.jsxs("section",{className:"detail-section",children:[e.jsx("h3",{children:"Pattern Matches"}),e.jsx("div",{className:"patterns-list",children:x.patternMatches.map(c=>e.jsxs("div",{className:"pattern-item",children:[e.jsx("div",{className:"pattern-name",children:c.patternName}),e.jsxs("div",{className:"pattern-confidence",children:[Math.round(c.confidence),"% confidence"]})]},c.patternId))})]}),x.status==="open"&&e.jsx("section",{className:"detail-actions",children:e.jsx("button",{className:"action-btn resolve",onClick:()=>j(x.id),children:"Mark Resolved"})})]})]})]})]})}const X=_((t,n)=>({schemas:[],selectedSchemaId:null,loading:!1,error:null,fetchSchemas:async()=>{t({loading:!0,error:null});try{const s=await fetch("/api/sentinel/schemas");if(!s.ok)throw new Error(`Failed to fetch schemas: ${s.status}`);const a=(await s.json()).schemas||[];t({schemas:a,loading:!1}),!n().selectedSchemaId&&a.length>0&&t({selectedSchemaId:a[0].id})}catch(s){t({error:s instanceof Error?s.message:"Failed to fetch schemas",loading:!1})}},selectSchema:s=>t({selectedSchemaId:s}),getSelectedSchema:()=>{const s=n();return s.schemas.find(l=>l.id===s.selectedSchemaId)}}));function ue(t){const[n,s]=r.useState(t),l=r.useRef(null),a=r.useCallback((d,f)=>{f.preventDefault(),l.current={idx:d,startX:f.clientX,startW:n[d]};const p=j=>{const g=l.current;if(!g)return;const x=Math.max(40,g.startW+(j.clientX-g.startX));s(c=>{const v=[...c];return v[g.idx]=x,v})},u=()=>{l.current=null,window.removeEventListener("mousemove",p),window.removeEventListener("mouseup",u)};window.addEventListener("mousemove",p),window.addEventListener("mouseup",u)},[n]);return{gridTemplate:n.map(d=>`${d}px`).join(" ")+" 1fr",onMouseDown:a}}function P({idx:t,onMouseDown:n}){return e.jsx("span",{className:"col-resize-handle",onMouseDown:s=>n(t,s)})}const me={debug:"#94a3b8",info:"#3b82f6",warn:"#f59e0b",error:"#ef4444"},he={logs:"#3b82f6",metrics:"#22c55e",traces:"#a855f7",incidents:"#ef4444",rules:"#f59e0b",state:"#06b6d4",cascade:"#ec4899",lifecycle:"#84cc16"};function pe(t){const n=new Date(t),s=(l,a=2)=>String(l).padStart(a,"0");return`${n.getFullYear()}-${s(n.getMonth()+1)}-${s(n.getDate())} ${s(n.getHours())}:${s(n.getMinutes())}:${s(n.getSeconds())}`}function W(t,n){var l;const s=(l=n==null?void 0:n.visualization)==null?void 0:l.categoryColors;return s&&s[t]?s[t]:he[t]||"var(--p-text-muted)"}function xe(){const{schemas:t,selectedSchemaId:n,selectSchema:s,fetchSchemas:l,loading:a}=X();return r.useEffect(()=>{l()},[]),a?e.jsx("div",{className:"events-loading",children:"Loading schemas..."}):t.length===0?e.jsxs("div",{className:"events-empty-state",children:[e.jsx("p",{children:"No event schemas registered."}),e.jsxs("p",{className:"hint",children:["Applications register schemas via ",e.jsx("code",{children:"POST /api/sentinel/schemas"}),"."]})]}):e.jsx("select",{className:"events-schema-select",value:n||"",onChange:i=>s(i.target.value||null),children:t.map(i=>e.jsxs("option",{value:i.id,children:[i.name," (v",i.version,")"]},i.id))})}function ve({schema:t}){const{scopes:n,selectedScope:s,fetchScopes:l,fetchScopeEvents:a,selectScope:i,fetchEvents:d}=R();r.useEffect(()=>{l(t.id)},[t.id]);const f=p=>{s===p?(i(null),d(t.id)):a(t.id,p)};return n.length===0?null:e.jsxs("div",{className:"events-scope-nav",children:[e.jsxs("div",{className:"events-scope-label",children:[t.scope.label,"s"]}),e.jsx("div",{className:"events-scope-list",children:n.slice(0,50).map(p=>e.jsxs("button",{className:`events-scope-chip ${s===p.scopeValue?"active":""}`,onClick:()=>f(p.scopeValue),title:`${p.eventCount} events`,children:[e.jsx("span",{className:"scope-value",children:t.scope.type==="number"?`#${p.scopeValue}`:p.scopeValue}),e.jsx("span",{className:"scope-count",children:p.eventCount})]},p.scopeValue))})]})}function ge({schema:t}){var p;const{events:n,categoryFilter:s,setCategoryFilter:l,excludedTypes:a,toggleExcludedType:i}=R(),d=[...new Set(n.map(u=>u.category))],f=((p=t.visualization)==null?void 0:p.defaultExcluded)||[];return r.useEffect(()=>{for(const u of f)a.has(u)||i(u)},[t.id]),e.jsxs("div",{className:"events-category-filters",children:[e.jsx("button",{className:`events-category-chip ${s?"":"active"}`,onClick:()=>l(null),children:"All"}),d.map(u=>e.jsx("button",{className:`events-category-chip ${s===u?"active":""}`,onClick:()=>l(s===u?null:u),style:{borderColor:W(u,t),color:s===u?"#fff":W(u,t),backgroundColor:s===u?W(u,t):"transparent"},children:u},u))]})}function fe({event:t,schema:n,isExpanded:s,onToggle:l,onContextMenu:a}){const i=W(t.category,n);return e.jsxs("div",{className:`event-row event-row--${t.severity||"info"}${s?" event-row--expanded":""}`,onClick:l,onContextMenu:a,children:[e.jsx("span",{className:"event-time",children:pe(t.timestamp)}),e.jsx("span",{className:"event-severity",style:{color:me[t.severity||"info"]},children:(t.severity||"info").toUpperCase().padEnd(5)}),e.jsxs("span",{className:"event-type",children:[t.category&&t.category!=="unknown"&&e.jsxs("span",{className:"event-category-badge",style:{color:i},children:["[",t.category,"]"]})," ",t.eventType]}),e.jsx("span",{className:"event-service",children:t.service}),t.scopeValue&&e.jsx("span",{className:"event-scope",children:t.scopeValue}),t.depth!=null&&t.depth>0&&e.jsx("span",{className:"event-depth",style:{paddingLeft:`${t.depth*12}px`},children:" ".repeat(t.depth)}),s&&t.data&&e.jsx("div",{className:"event-data",onClick:d=>d.stopPropagation(),children:e.jsx("pre",{children:JSON.stringify(t.data,null,2)})})]})}function je({schema:t}){const{events:n,excludedTypes:s,excludedServices:l,categoryFilter:a,loading:i,toggleExcludedType:d,toggleExcludedService:f,clearAllExclusions:p}=R(),[u,j]=r.useState(new Set),[g,x]=r.useState(!1),c=r.useRef(null),{gridTemplate:v,onMouseDown:m}=ue([180,50,200,100]),y=h=>{j(S=>{const L=new Set(S);return L.has(h)?(L.delete(h),x(!1)):L.add(h),L})},N=n.filter(h=>!(s.has(h.eventType)||l.has(h.service)||a&&h.category!==a)),T=s.size>0||l.size>0,[w,k]=r.useState(null),b=r.useCallback((h,S)=>{h.preventDefault(),k({x:h.clientX,y:h.clientY,event:S})},[]);r.useEffect(()=>{if(!w)return;const h=()=>k(null);return window.addEventListener("click",h),()=>window.removeEventListener("click",h)},[w]);const F=()=>{g?(j(new Set),x(!1)):x(!0)};return i?e.jsx("div",{className:"events-loading",children:"Loading events..."}):N.length===0?e.jsxs("div",{className:"events-empty-state",children:[e.jsx("p",{children:"No events to display."}),e.jsx("p",{className:"hint",children:"Events will appear here when applications send them to Sentinel."})]}):e.jsxs("div",{className:"events-table",ref:c,style:{"--evt-cols":v},children:[e.jsxs("div",{className:"events-table-actions",children:[e.jsxs("span",{className:"events-count",children:[N.length," events"]}),e.jsx("button",{className:`events-expand-btn ${g?"active":""}`,onClick:F,title:g?"Collapse all payloads":"Expand all payloads",children:g?"Collapse All":"Expand All"})]}),T&&e.jsxs("div",{className:"exclusion-bar",children:[[...s].map(h=>e.jsxs("span",{className:"exclusion-chip",children:["type: ",h," ",e.jsx("button",{onClick:()=>d(h),children:"×"})]},`type-${h}`)),[...l].map(h=>e.jsxs("span",{className:"exclusion-chip",children:["service: ",h," ",e.jsx("button",{onClick:()=>f(h),children:"×"})]},`svc-${h}`)),e.jsx("button",{className:"exclusion-clear",onClick:p,children:"Clear all"})]}),w&&e.jsxs("div",{className:"context-menu",style:{top:w.y,left:w.x},onClick:h=>h.stopPropagation(),children:[e.jsxs("button",{onClick:()=>{d(w.event.eventType),k(null)},children:['Exclude type "',w.event.eventType,'"']}),e.jsxs("button",{onClick:()=>{f(w.event.service),k(null)},children:['Exclude service "',w.event.service,'"']})]}),e.jsxs("div",{className:"events-table-header",children:[e.jsxs("span",{className:"event-time",children:["Time",e.jsx(P,{idx:0,onMouseDown:m})]}),e.jsxs("span",{className:"event-severity",children:["Level",e.jsx(P,{idx:1,onMouseDown:m})]}),e.jsxs("span",{className:"event-type",children:["Type",e.jsx(P,{idx:2,onMouseDown:m})]}),e.jsxs("span",{className:"event-service",children:["Service",e.jsx(P,{idx:3,onMouseDown:m})]}),e.jsx("span",{className:"event-scope",children:"Scope"})]}),e.jsx("div",{className:"events-table-body",children:N.map(h=>e.jsx(fe,{event:h,schema:t,isExpanded:g||u.has(h.id),onToggle:()=>y(h.id),onContextMenu:S=>b(S,h)},h.id))})]})}function ye(){const{selectedSchemaId:t}=X(),n=X(l=>l.getSelectedSchema()),{fetchEvents:s}=R();return r.useEffect(()=>{t&&s(t)},[t]),e.jsxs("div",{className:"events-view",children:[e.jsxs("div",{className:"events-toolbar",children:[e.jsx(xe,{}),n&&e.jsx(ge,{schema:n})]}),n&&e.jsx(ve,{schema:n}),n?e.jsx(je,{schema:n}):e.jsx("div",{className:"events-empty-state",children:e.jsx("p",{children:"Select a schema to view events."})})]})}const G={gate:"var(--p-symbol-gate)",action:"var(--p-symbol-component)",signal:"var(--p-symbol-signal)"},be={gate:"^",action:"#",signal:"!"};function J(t,n){const s=Date.now();return n.some(l=>l.nodeSymbol===t&&s-new Date(l.timestamp).getTime()<5e3)}function we({flow:t,flowEvents:n,isSelected:s,onSelect:l}){return e.jsxs("div",{className:`flow-card ${s?"selected":""}`,onClick:l,children:[e.jsxs("div",{className:"flow-card-header",children:[e.jsx("span",{className:"flow-card-id",children:t.id}),t.trigger&&e.jsx("span",{className:"flow-card-trigger",children:t.trigger})]}),e.jsx("div",{className:"flow-card-name",children:t.name}),e.jsx("div",{className:"flow-card-steps",children:t.steps.map((a,i)=>{const d=J(a.symbol,n);return e.jsxs("div",{className:"flow-step-mini",children:[i>0&&e.jsx("span",{className:"flow-arrow",children:"→"}),e.jsx("span",{className:`flow-step-dot ${d?"active pulse":""}`,style:{backgroundColor:d?G[a.type]:"var(--p-text-muted)"},title:`${a.symbol} (${a.type})`})]},i)})})]})}function Se({flow:t,flowEvents:n}){return e.jsxs("div",{className:"flow-diagram",children:[e.jsx("h3",{children:t.name}),t.trigger&&e.jsxs("div",{className:"flow-trigger-label",children:["Trigger: ",e.jsx("code",{children:t.trigger})]}),e.jsx("div",{className:"flow-steps",children:t.steps.map((s,l)=>{const a=J(s.symbol,n),i=n.find(d=>d.nodeSymbol===s.symbol);return e.jsxs("div",{className:"flow-step-container",children:[l>0&&e.jsx("div",{className:"flow-connector",children:e.jsx("div",{className:`flow-line ${a?"active":""}`})}),e.jsxs("div",{className:`flow-step-node ${a?"active":""}`,style:{borderColor:G[s.type]},children:[e.jsx("span",{className:"flow-step-icon",children:be[s.type]}),e.jsx("span",{className:"flow-step-symbol",children:s.symbol}),e.jsx("span",{className:"flow-step-type",children:s.type}),a&&i&&e.jsxs("span",{className:"flow-step-live",children:[i.service," · ",new Date(i.timestamp).toLocaleTimeString()]})]})]},l)})})]})}function Ne({symbols:t,onSave:n,onCancel:s}){const[l,a]=r.useState(""),[i,d]=r.useState(""),[f,p]=r.useState([]),u=r.useCallback(v=>{p(m=>[...m,{type:v,symbol:""}])},[]),j=r.useCallback((v,m,y)=>{p(N=>N.map((T,w)=>w===v?{...T,[m]:y}:T))},[]),g=r.useCallback(v=>{p(m=>m.filter((y,N)=>N!==v))},[]),x=()=>{if(!l||f.length===0)return;const v=`$${l.toLowerCase().replace(/\s+/g,"-")}`;n({id:v,name:l,trigger:i||void 0,steps:f})},c=v=>v==="gate"?t.filter(m=>m.type==="gate"):v==="signal"?t.filter(m=>m.type==="signal"):t.filter(m=>m.type==="component");return e.jsxs("div",{className:"flow-composer",children:[e.jsx("h3",{children:"New Flow"}),e.jsxs("div",{className:"composer-field",children:[e.jsx("label",{children:"Flow Name"}),e.jsx("input",{type:"text",placeholder:"e.g. Checkout Flow",value:l,onChange:v=>a(v.target.value)})]}),e.jsxs("div",{className:"composer-field",children:[e.jsx("label",{children:"Trigger (optional)"}),e.jsx("input",{type:"text",placeholder:"e.g. POST /api/checkout",value:i,onChange:v=>d(v.target.value)})]}),e.jsxs("div",{className:"composer-steps",children:[e.jsx("label",{children:"Steps"}),f.map((v,m)=>e.jsxs("div",{className:"composer-step",children:[e.jsxs("select",{value:v.type,onChange:y=>j(m,"type",y.target.value),children:[e.jsx("option",{value:"gate",children:"Gate (^)"}),e.jsx("option",{value:"action",children:"Action (#)"}),e.jsx("option",{value:"signal",children:"Signal (!)"})]}),e.jsxs("select",{value:v.symbol,onChange:y=>j(m,"symbol",y.target.value),children:[e.jsx("option",{value:"",children:"Select symbol..."}),c(v.type).map(y=>e.jsx("option",{value:y.symbol,children:y.symbol},y.symbol))]}),e.jsx("button",{className:"composer-remove",onClick:()=>g(m),children:"×"})]},m)),e.jsxs("div",{className:"composer-add-buttons",children:[e.jsx("button",{onClick:()=>u("gate"),children:"+ Gate"}),e.jsx("button",{onClick:()=>u("action"),children:"+ Action"}),e.jsx("button",{onClick:()=>u("signal"),children:"+ Signal"})]})]}),e.jsxs("div",{className:"composer-actions",children:[e.jsx("button",{className:"action-btn",onClick:x,disabled:!l||f.length===0,children:"Save Flow"}),e.jsx("button",{className:"action-btn cancel",onClick:s,children:"Cancel"})]})]})}function Ce(){const{flowEvents:t,isLive:n,setIsLive:s}=Q(),[l,a]=r.useState([]),[i,d]=r.useState([]),[f,p]=r.useState(null),[u,j]=r.useState(!1),[g,x]=r.useState(!0),c=l.find(m=>m.id===f);r.useEffect(()=>{async function m(){try{const y=await fetch("/api/sentinel/symbols");if(!y.ok){x(!1);return}const N=await y.json(),T=(N.symbols||[]).map(b=>({symbol:b.symbol,type:b.type}));d(T);const k=(N.symbols||[]).filter(b=>b.type==="flow").map(b=>{var h,S,L;const F=[];if((h=b.data)!=null&&h.steps&&Array.isArray(b.data.steps))for(const C of b.data.steps)F.push({type:C.type||"action",symbol:C.symbol||"",label:C.label});if(F.length===0&&b.references)for(const C of b.references)C.startsWith("^")?F.push({type:"gate",symbol:C}):C.startsWith("!")?F.push({type:"signal",symbol:C}):C.startsWith("#")&&F.push({type:"action",symbol:C});return{id:b.symbol,name:((S=b.data)==null?void 0:S.name)||b.symbol.replace("$",""),trigger:(L=b.data)==null?void 0:L.trigger,steps:F}});a(k),x(!1)}catch{x(!1)}}m()},[]),r.useEffect(()=>(s(!0),()=>s(!1)),[]);const v=m=>{a(y=>[...y,m]),j(!1),p(m.id)};return g?e.jsx("div",{className:"flows-view s-loading-state",children:e.jsxs("div",{className:"s-loading-content",children:[e.jsx("div",{className:"s-loading-spinner"}),e.jsx("p",{children:"Loading flows..."})]})}):e.jsxs("div",{className:"flows-view",children:[e.jsxs("div",{className:"flows-toolbar",children:[e.jsxs("div",{className:"flows-toolbar-left",children:[e.jsxs("span",{className:"flows-count",children:[l.length," flow",l.length!==1?"s":""]}),e.jsxs("button",{className:`logs-live-btn ${n?"active":""}`,onClick:()=>s(!n),children:[e.jsx("span",{className:`live-dot ${n?"live":""}`}),n?"Live":"Paused"]})]}),e.jsx("div",{className:"flows-toolbar-right",children:e.jsx("button",{className:"action-btn",onClick:()=>{j(!0),p(null)},children:"+ New Flow"})})]}),e.jsxs("div",{className:"flows-content",children:[e.jsx("div",{className:"flows-list",children:l.length===0&&!u?e.jsxs("div",{className:"flows-empty",children:[e.jsx("p",{children:"No flows defined."}),e.jsxs("p",{className:"hint",children:["Define flows in ",e.jsx("code",{children:".purpose"})," files or use the composer to create one."]})]}):l.map(m=>e.jsx(we,{flow:m,flowEvents:t,isSelected:f===m.id,onSelect:()=>{p(m.id),j(!1)}},m.id))}),e.jsx("div",{className:"flows-detail",children:u?e.jsx(Ne,{symbols:i,onSave:v,onCancel:()=>j(!1)}):c?e.jsx(Se,{flow:c,flowEvents:t}):e.jsx("div",{className:"flows-empty-detail",children:e.jsx("p",{children:"Select a flow to visualize or create a new one."})})})]})]})}const Ee=[{id:"logs",label:"Logs"},{id:"incidents",label:"Incidents"},{id:"events",label:"Events"},{id:"flows",label:"Flows"}];function Le(){const[t,n]=r.useState("logs");return te(),e.jsxs("div",{className:"sentinel-section",children:[e.jsx("div",{className:"sentinel-tabs",children:Ee.map(s=>e.jsx("button",{className:`sentinel-tab ${t===s.id?"active":""}`,onClick:()=>n(s.id),children:s.label},s.id))}),e.jsxs("div",{className:"sentinel-tab-content",children:[t==="logs"&&e.jsx(oe,{}),t==="incidents"&&e.jsx(de,{}),t==="events"&&e.jsx(ye,{}),t==="flows"&&e.jsx(Ce,{})]})]})}export{Le as default};
@@ -1 +1 @@
1
- import{c as p,r as m,j as e}from"./index-DbxeSMkV.js";const l=p((a,r)=>({agents:[],myIdentity:null,threads:[],activeThreadId:null,activeThread:null,fileRequests:[],status:null,loading:!1,activeTab:"threads",threadFilter:"active",fileFilter:"pending",fetchAgents:async()=>{try{const s=await fetch("/api/symphony/agents");if(!s.ok)return;const i=await s.json();a({agents:i.agents||[]})}catch{}},fetchMyIdentity:async()=>{try{const s=await fetch("/api/symphony/agents/me");if(!s.ok)return;const i=await s.json();a({myIdentity:i.identity||null})}catch{}},fetchThreads:async()=>{try{const s=r().threadFilter,i=s!=="all"?`?status=${s}`:"",t=await fetch(`/api/symphony/threads${i}`);if(!t.ok)return;const d=await t.json();a({threads:d.threads||[]})}catch{}},fetchThread:async s=>{try{const i=await fetch(`/api/symphony/threads/${s}`);if(!i.ok)return;const t=await i.json();a({activeThreadId:s,activeThread:{thread:t.thread,messages:t.messages||[],symbolsDiscussed:t.symbolsDiscussed||[]}})}catch{}},fetchFileRequests:async()=>{try{const s=r().fileFilter,i=s!=="all"?`?status=${s}`:"",t=await fetch(`/api/symphony/file-requests${i}`);if(!t.ok)return;const d=await t.json();a({fileRequests:d.fileRequests||[]})}catch{}},fetchStatus:async()=>{try{const s=await fetch("/api/symphony/status");if(!s.ok)return;const i=await s.json();a({status:i})}catch{}},sendMessage:async s=>{try{const i=await fetch("/api/symphony/messages",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!i.ok)return;const{activeThreadId:t}=r(),n=(await i.json()).threadId||t;n&&await r().fetchThread(n),await r().fetchThreads()}catch{}},resolveThread:async(s,i)=>{try{(await fetch(`/api/symphony/threads/${s}/resolve`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({decision:i})})).ok&&(await r().fetchThread(s),await r().fetchThreads())}catch{}},handleFileAction:async(s,i,t)=>{try{(await fetch(`/api/symphony/file-requests/${s}/action`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:i,reason:t})})).ok&&await r().fetchFileRequests()}catch{}},setActiveTab:s=>a({activeTab:s}),setActiveThread:s=>{s?r().fetchThread(s):a({activeThreadId:null,activeThread:null})},setThreadFilter:s=>{a({threadFilter:s}),r().fetchThreads()},setFileFilter:s=>{a({fileFilter:s}),r().fetchFileRequests()},handleWsMessage:s=>{if(s.type==="symphony:message"){const{activeThreadId:i,activeThread:t}=r();s.threadId&&s.threadId===i&&t&&s.message&&(t.messages.some(n=>n.id===s.message.id)||a({activeThread:{...t,messages:[...t.messages,s.message]}})),r().fetchThreads()}if(s.type==="symphony:thread_resolved"){const{activeThreadId:i}=r();s.threadId===i&&r().fetchThread(s.threadId),r().fetchThreads()}},refresh:async()=>{a({loading:!0}),await Promise.all([r().fetchThreads(),r().fetchAgents(),r().fetchStatus()]),a({loading:!1})}}));function j(){m.useEffect(()=>{function a(r){const s=r.detail;s!=null&&s.type&&(s.type==="symphony:message"||s.type==="symphony:thread_resolved")&&l.getState().handleWsMessage(s)}return window.addEventListener("symphony-ws",a),()=>window.removeEventListener("symphony-ws",a)},[])}const x={question:"dialogue",context:"dialogue",clarification:"dialogue",verification:"dialogue",reference:"dialogue",proposal:"action",action:"action",decision:"outcome",approval:"outcome",rejection:"outcome",alert:"system",handoff:"lifecycle",fileRequest:"transfer",fileApproved:"transfer",fileDenied:"transfer",fileDelivery:"transfer"};function y(a){return x[a]||"dialogue"}function N(a){const r=Date.now()-new Date(a).getTime(),s=Math.floor(r/1e3);if(s<60)return`${s}s ago`;const i=Math.floor(s/60);if(i<60)return`${i}m ago`;const t=Math.floor(i/60);return t<24?`${t}h ago`:`${Math.floor(t/24)}d ago`}function g(a){return new Date(a).toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"})}function b(){const a=l(n=>n.threads),r=l(n=>n.activeThreadId),s=l(n=>n.threadFilter),i=l(n=>n.setActiveThread),t=l(n=>n.setThreadFilter),d=[{id:"active",label:"Active"},{id:"resolved",label:"Resolved"},{id:"all",label:"All"}];return e.jsxs("div",{className:"thread-list-sidebar",children:[e.jsx("div",{className:"thread-list-toolbar",children:d.map(n=>e.jsx("button",{className:`thread-filter-btn ${s===n.id?"active":""}`,onClick:()=>t(n.id),children:n.label},n.id))}),e.jsx("div",{className:"thread-list-items",children:a.length===0?e.jsxs("div",{className:"thread-list-empty",children:["No threads yet.",e.jsx("br",{}),e.jsx("br",{}),"Agents create threads via ",e.jsx("code",{children:"paradigm_symphony_send"})]}):a.map(n=>e.jsxs("div",{className:`thread-card ${r===n.id?"selected":""}`,onClick:()=>i(n.id),children:[e.jsx("div",{className:"thread-card-topic",children:n.topic}),e.jsxs("div",{className:"thread-card-meta",children:[e.jsxs("div",{className:"thread-card-participants",children:[n.participants.slice(0,4).map(h=>e.jsx("span",{className:`participant-avatar ${h.type==="human"?"human":""}`,title:h.name,children:h.name.charAt(0).toUpperCase()},h.id)),n.participants.length>4&&e.jsxs("span",{className:"participant-avatar",style:{background:"var(--p-text-muted)"},children:["+",n.participants.length-4]})]}),e.jsxs("div",{className:"thread-card-stats",children:[e.jsx("span",{className:"thread-card-count",children:n.messageCount}),e.jsx("span",{className:`thread-card-status ${n.status}`,children:n.status}),e.jsx("span",{children:N(n.lastActivity)})]})]})]},n.id))})]})}function T({msg:a}){const[r,s]=m.useState(!1),i=y(a.intent);return e.jsxs("div",{className:"message-bubble",children:[e.jsxs("div",{className:"message-bubble-header",children:[e.jsx("span",{className:"message-sender",children:a.sender.name}),e.jsx("span",{className:`message-sender-type ${a.sender.type}`,children:a.sender.type}),e.jsx("span",{className:`intent-pill ${i}`,children:a.intent})]}),e.jsx("div",{className:"message-text",children:a.text}),a.symbols.length>0&&e.jsx("div",{className:"message-symbols",children:a.symbols.map(t=>e.jsx("span",{className:"message-symbol-tag",children:t},t))}),a.diff&&e.jsxs("div",{className:"message-diff",children:[e.jsx("button",{className:"message-diff-toggle",onClick:()=>s(!r),children:r?"Hide diff":"Show diff"}),r&&e.jsx("pre",{className:"message-diff-content",children:a.diff})]}),a.decision&&e.jsxs("div",{className:"message-decision",children:[e.jsx("div",{className:"message-decision-label",children:"Decision"}),a.decision]}),e.jsx("div",{className:"message-time",children:g(a.timestamp)})]})}const w=["question","context","proposal","decision","action","alert","approval","rejection","reference","clarification","verification"];function k({threadId:a}){const[r,s]=m.useState("question"),[i,t]=m.useState(""),d=l(o=>o.sendMessage);async function n(){const o=i.trim();o&&(await d({intent:r,text:o,threadRoot:a||void 0}),t(""))}function h(o){o.key==="Enter"&&!o.shiftKey&&(o.preventDefault(),n())}return e.jsx("div",{className:"compose-box",children:e.jsxs("div",{className:"compose-row",children:[e.jsx("select",{className:"compose-intent-select",value:r,onChange:o=>s(o.target.value),children:w.map(o=>e.jsx("option",{value:o,children:o},o))}),e.jsx("textarea",{className:"compose-textarea",value:i,onChange:o=>t(o.target.value),onKeyDown:h,placeholder:"Type a message... (Enter to send, Shift+Enter for newline)",rows:1}),e.jsx("button",{className:"compose-send-btn",onClick:n,disabled:!i.trim(),children:"Send"})]})})}function F(){const a=l(n=>n.activeThread),r=l(n=>n.activeThreadId),s=l(n=>n.resolveThread),i=m.useRef(null);if(m.useEffect(()=>{var n;(n=i.current)==null||n.scrollIntoView({behavior:"smooth"})},[a==null?void 0:a.messages.length]),!a)return e.jsx("div",{className:"conversation",children:e.jsx("div",{className:"conversation-empty",children:"Select a thread to view"})});const{thread:t,messages:d}=a;return e.jsxs("div",{className:"conversation",children:[e.jsxs("div",{className:"conversation-header",children:[e.jsxs("div",{className:"conversation-header-left",children:[e.jsx("div",{className:"conversation-topic",children:t.topic}),e.jsx("div",{className:"conversation-participants",children:t.participants.map(n=>n.name).join(", ")})]}),e.jsxs("div",{className:"conversation-actions",children:[e.jsx("span",{className:`thread-card-status ${t.status}`,children:t.status}),t.status==="active"&&e.jsx("button",{className:"resolve-btn",onClick:()=>s(r),children:"Resolve"})]})]}),e.jsxs("div",{className:"conversation-messages",children:[d.map(n=>e.jsx(T,{msg:n},n.id)),e.jsx("div",{ref:i})]}),e.jsx(k,{threadId:r})]})}function I(){return e.jsxs("div",{className:"threads-layout",children:[e.jsx(b,{}),e.jsx(F,{})]})}function f(a){if(!a)return"never";const r=Date.now()-new Date(a).getTime(),s=Math.floor(r/1e3);if(s<60)return`${s}s ago`;const i=Math.floor(s/60);if(i<60)return`${i}m ago`;const t=Math.floor(i/60);return t<24?`${t}h ago`:`${Math.floor(t/24)}d ago`}function R(){const a=l(s=>s.agents),r=l(s=>s.status);return e.jsxs("div",{className:"network-view",children:[r&&e.jsxs("div",{className:"network-status-bar",children:[e.jsxs("div",{className:"network-stat",children:[e.jsx("div",{className:"network-stat-value",children:r.agentCount}),e.jsx("div",{className:"network-stat-label",children:"Agents"})]}),e.jsxs("div",{className:"network-stat",children:[e.jsx("div",{className:"network-stat-value",style:{color:"var(--p-accent-green)"},children:r.awakeCount}),e.jsx("div",{className:"network-stat-label",children:"Awake"})]}),e.jsxs("div",{className:"network-stat",children:[e.jsx("div",{className:"network-stat-value",children:r.activeThreadCount}),e.jsx("div",{className:"network-stat-label",children:"Active Threads"})]}),e.jsxs("div",{className:"network-stat",children:[e.jsx("div",{className:"network-stat-value",children:r.unreadCount}),e.jsx("div",{className:"network-stat-label",children:"Unread"})]}),e.jsxs("div",{className:"network-stat",children:[e.jsx("div",{className:"network-stat-value",children:r.pendingFileRequests}),e.jsx("div",{className:"network-stat-label",children:"Pending Files"})]})]}),a.length===0?e.jsxs("div",{className:"network-empty",children:[e.jsx("p",{children:"No agents registered."}),e.jsxs("p",{style:{marginTop:8},children:["Run ",e.jsx("code",{children:"paradigm symphony join"})," in a project to register an agent."]})]}):e.jsx("div",{className:"agent-grid",children:a.map(s=>e.jsxs("div",{className:"agent-card",children:[e.jsxs("div",{className:"agent-card-header",children:[e.jsx("span",{className:"agent-card-id",children:s.id}),e.jsx("span",{className:`agent-status-dot ${s.status}`,title:s.status})]}),e.jsx("div",{className:"agent-card-name",children:s.name}),s.statusBlurb&&e.jsx("div",{className:"agent-card-blurb",children:s.statusBlurb}),e.jsxs("div",{className:"agent-card-details",children:[e.jsxs("div",{className:"agent-card-detail",children:[e.jsx("span",{className:"agent-card-detail-label",children:"Project"}),e.jsx("span",{className:"agent-card-detail-value",children:s.project})]}),e.jsxs("div",{className:"agent-card-detail",children:[e.jsx("span",{className:"agent-card-detail-label",children:"Role"}),e.jsx("span",{className:"agent-card-detail-value",children:s.role})]}),e.jsxs("div",{className:"agent-card-detail",children:[e.jsx("span",{className:"agent-card-detail-label",children:"Last Poll"}),e.jsx("span",{className:"agent-card-detail-value",children:f(s.lastPoll)})]}),e.jsxs("div",{className:"agent-card-detail",children:[e.jsx("span",{className:"agent-card-detail-label",children:"Started"}),e.jsx("span",{className:"agent-card-detail-value",children:f(s.startedAt)})]})]})]},s.id))})]})}function v(a){const r=Date.now()-new Date(a).getTime(),s=Math.floor(r/1e3);if(s<60)return`${s}s ago`;const i=Math.floor(s/60);if(i<60)return`${i}m ago`;const t=Math.floor(i/60);return t<24?`${t}h ago`:`${Math.floor(t/24)}d ago`}function S({request:a}){const[r,s]=m.useState(!1),[i,t]=m.useState(""),d=l(h=>h.handleFileAction),n=a.status==="pending";return e.jsxs("div",{className:"file-request-card",children:[e.jsxs("div",{className:"file-request-header",children:[e.jsxs("span",{className:"file-request-path",children:[a.filePath,a.urgency==="urgent"&&e.jsx("span",{className:"urgency-badge urgent",children:"urgent"})]}),e.jsx("span",{className:`file-request-status ${a.status}`,children:a.status})]}),e.jsxs("div",{className:"file-request-requester",children:["From: ",a.requester.name]}),e.jsx("div",{className:"file-request-body",children:a.reason}),a.snippet&&e.jsxs("div",{className:"file-request-snippet",children:["Snippet: ",a.snippet]}),e.jsxs("div",{className:"file-request-meta",children:[e.jsx("span",{children:v(a.createdAt)}),a.resolvedAt&&e.jsxs("span",{children:["Resolved ",v(a.resolvedAt)]}),a.denyReason&&e.jsxs("span",{children:["Reason: ",a.denyReason]})]}),n&&e.jsxs("div",{className:"file-request-actions",children:[e.jsx("button",{className:"file-action-btn approve",onClick:()=>d(a.requestId,"approve"),children:"Approve"}),e.jsx("button",{className:"file-action-btn approve-redacted",onClick:()=>d(a.requestId,"approve-redacted"),children:"Approve (redacted)"}),r?e.jsxs(e.Fragment,{children:[e.jsx("input",{className:"deny-reason-input",value:i,onChange:h=>t(h.target.value),placeholder:"Reason for denial...",onKeyDown:h=>{h.key==="Enter"&&(d(a.requestId,"deny",i||void 0),s(!1),t("")),h.key==="Escape"&&(s(!1),t(""))},autoFocus:!0}),e.jsx("button",{className:"file-action-btn deny",onClick:()=>{d(a.requestId,"deny",i||void 0),s(!1),t("")},children:"Confirm Deny"})]}):e.jsx("button",{className:"file-action-btn deny",onClick:()=>s(!0),children:"Deny"})]})]})}function $(){const a=l(t=>t.fileRequests),r=l(t=>t.fileFilter),s=l(t=>t.setFileFilter),i=[{id:"pending",label:"Pending"},{id:"all",label:"All"}];return e.jsxs("div",{className:"files-view",children:[e.jsxs("div",{className:"files-toolbar",children:[e.jsx("div",{className:"files-filter-group",children:i.map(t=>e.jsx("button",{className:`thread-filter-btn ${r===t.id?"active":""}`,onClick:()=>s(t.id),children:t.label},t.id))}),e.jsxs("span",{className:"files-count",children:[a.length," request",a.length!==1?"s":""]})]}),e.jsx("div",{className:"files-list",children:a.length===0?e.jsxs("div",{className:"files-empty",children:[e.jsx("p",{children:"No file requests."}),e.jsxs("p",{style:{marginTop:8,fontSize:13},children:["Agents request files via ",e.jsx("code",{children:"paradigm_symphony_request_file"})]})]}):a.map(t=>e.jsx(S,{request:t},t.requestId))})]})}const C=[{id:"threads",label:"Threads"},{id:"network",label:"Network"},{id:"files",label:"Files"}];function q(){const a=l(c=>c.activeTab),r=l(c=>c.setActiveTab),s=l(c=>c.refresh),i=l(c=>c.fetchThread),t=l(c=>c.fetchFileRequests),d=l(c=>c.activeThreadId),n=l(c=>c.status);j(),m.useEffect(()=>{s(),l.getState().fetchMyIdentity(),l.getState().fetchFileRequests()},[]);const h=m.useRef(s);h.current=s,m.useEffect(()=>{const c=setInterval(()=>h.current(),1e4);return()=>clearInterval(c)},[]);const o=m.useRef(d);o.current=d;const u=m.useRef(i);return u.current=i,m.useEffect(()=>{const c=setInterval(()=>{o.current&&u.current(o.current)},3e3);return()=>clearInterval(c)},[]),m.useEffect(()=>{if(a!=="files")return;const c=setInterval(()=>t(),1e4);return()=>clearInterval(c)},[a,t]),e.jsxs("div",{className:"symphony-section",children:[e.jsx("div",{className:"symphony-tabs",children:C.map(c=>e.jsxs("button",{className:`symphony-tab ${a===c.id?"active":""}`,onClick:()=>r(c.id),children:[c.label,c.id==="threads"&&n&&n.activeThreadCount>0&&e.jsx("span",{className:"tab-badge",children:n.activeThreadCount}),c.id==="files"&&n&&n.pendingFileRequests>0&&e.jsx("span",{className:"tab-badge",children:n.pendingFileRequests})]},c.id))}),e.jsxs("div",{className:"symphony-tab-content",children:[a==="threads"&&e.jsx(I,{}),a==="network"&&e.jsx(R,{}),a==="files"&&e.jsx($,{})]})]})}export{q as default};
1
+ import{c as p,r as m,j as e}from"./index-G9JnWEs_.js";const l=p((a,r)=>({agents:[],myIdentity:null,threads:[],activeThreadId:null,activeThread:null,fileRequests:[],status:null,loading:!1,activeTab:"threads",threadFilter:"active",fileFilter:"pending",fetchAgents:async()=>{try{const s=await fetch("/api/symphony/agents");if(!s.ok)return;const i=await s.json();a({agents:i.agents||[]})}catch{}},fetchMyIdentity:async()=>{try{const s=await fetch("/api/symphony/agents/me");if(!s.ok)return;const i=await s.json();a({myIdentity:i.identity||null})}catch{}},fetchThreads:async()=>{try{const s=r().threadFilter,i=s!=="all"?`?status=${s}`:"",t=await fetch(`/api/symphony/threads${i}`);if(!t.ok)return;const d=await t.json();a({threads:d.threads||[]})}catch{}},fetchThread:async s=>{try{const i=await fetch(`/api/symphony/threads/${s}`);if(!i.ok)return;const t=await i.json();a({activeThreadId:s,activeThread:{thread:t.thread,messages:t.messages||[],symbolsDiscussed:t.symbolsDiscussed||[]}})}catch{}},fetchFileRequests:async()=>{try{const s=r().fileFilter,i=s!=="all"?`?status=${s}`:"",t=await fetch(`/api/symphony/file-requests${i}`);if(!t.ok)return;const d=await t.json();a({fileRequests:d.fileRequests||[]})}catch{}},fetchStatus:async()=>{try{const s=await fetch("/api/symphony/status");if(!s.ok)return;const i=await s.json();a({status:i})}catch{}},sendMessage:async s=>{try{const i=await fetch("/api/symphony/messages",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!i.ok)return;const{activeThreadId:t}=r(),n=(await i.json()).threadId||t;n&&await r().fetchThread(n),await r().fetchThreads()}catch{}},resolveThread:async(s,i)=>{try{(await fetch(`/api/symphony/threads/${s}/resolve`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({decision:i})})).ok&&(await r().fetchThread(s),await r().fetchThreads())}catch{}},handleFileAction:async(s,i,t)=>{try{(await fetch(`/api/symphony/file-requests/${s}/action`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:i,reason:t})})).ok&&await r().fetchFileRequests()}catch{}},setActiveTab:s=>a({activeTab:s}),setActiveThread:s=>{s?r().fetchThread(s):a({activeThreadId:null,activeThread:null})},setThreadFilter:s=>{a({threadFilter:s}),r().fetchThreads()},setFileFilter:s=>{a({fileFilter:s}),r().fetchFileRequests()},handleWsMessage:s=>{if(s.type==="symphony:message"){const{activeThreadId:i,activeThread:t}=r();s.threadId&&s.threadId===i&&t&&s.message&&(t.messages.some(n=>n.id===s.message.id)||a({activeThread:{...t,messages:[...t.messages,s.message]}})),r().fetchThreads()}if(s.type==="symphony:thread_resolved"){const{activeThreadId:i}=r();s.threadId===i&&r().fetchThread(s.threadId),r().fetchThreads()}},refresh:async()=>{a({loading:!0}),await Promise.all([r().fetchThreads(),r().fetchAgents(),r().fetchStatus()]),a({loading:!1})}}));function j(){m.useEffect(()=>{function a(r){const s=r.detail;s!=null&&s.type&&(s.type==="symphony:message"||s.type==="symphony:thread_resolved")&&l.getState().handleWsMessage(s)}return window.addEventListener("symphony-ws",a),()=>window.removeEventListener("symphony-ws",a)},[])}const x={question:"dialogue",context:"dialogue",clarification:"dialogue",verification:"dialogue",reference:"dialogue",proposal:"action",action:"action",decision:"outcome",approval:"outcome",rejection:"outcome",alert:"system",handoff:"lifecycle",fileRequest:"transfer",fileApproved:"transfer",fileDenied:"transfer",fileDelivery:"transfer"};function y(a){return x[a]||"dialogue"}function N(a){const r=Date.now()-new Date(a).getTime(),s=Math.floor(r/1e3);if(s<60)return`${s}s ago`;const i=Math.floor(s/60);if(i<60)return`${i}m ago`;const t=Math.floor(i/60);return t<24?`${t}h ago`:`${Math.floor(t/24)}d ago`}function g(a){return new Date(a).toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"})}function b(){const a=l(n=>n.threads),r=l(n=>n.activeThreadId),s=l(n=>n.threadFilter),i=l(n=>n.setActiveThread),t=l(n=>n.setThreadFilter),d=[{id:"active",label:"Active"},{id:"resolved",label:"Resolved"},{id:"all",label:"All"}];return e.jsxs("div",{className:"thread-list-sidebar",children:[e.jsx("div",{className:"thread-list-toolbar",children:d.map(n=>e.jsx("button",{className:`thread-filter-btn ${s===n.id?"active":""}`,onClick:()=>t(n.id),children:n.label},n.id))}),e.jsx("div",{className:"thread-list-items",children:a.length===0?e.jsxs("div",{className:"thread-list-empty",children:["No threads yet.",e.jsx("br",{}),e.jsx("br",{}),"Agents create threads via ",e.jsx("code",{children:"paradigm_symphony_send"})]}):a.map(n=>e.jsxs("div",{className:`thread-card ${r===n.id?"selected":""}`,onClick:()=>i(n.id),children:[e.jsx("div",{className:"thread-card-topic",children:n.topic}),e.jsxs("div",{className:"thread-card-meta",children:[e.jsxs("div",{className:"thread-card-participants",children:[n.participants.slice(0,4).map(h=>e.jsx("span",{className:`participant-avatar ${h.type==="human"?"human":""}`,title:h.name,children:h.name.charAt(0).toUpperCase()},h.id)),n.participants.length>4&&e.jsxs("span",{className:"participant-avatar",style:{background:"var(--p-text-muted)"},children:["+",n.participants.length-4]})]}),e.jsxs("div",{className:"thread-card-stats",children:[e.jsx("span",{className:"thread-card-count",children:n.messageCount}),e.jsx("span",{className:`thread-card-status ${n.status}`,children:n.status}),e.jsx("span",{children:N(n.lastActivity)})]})]})]},n.id))})]})}function T({msg:a}){const[r,s]=m.useState(!1),i=y(a.intent);return e.jsxs("div",{className:"message-bubble",children:[e.jsxs("div",{className:"message-bubble-header",children:[e.jsx("span",{className:"message-sender",children:a.sender.name}),e.jsx("span",{className:`message-sender-type ${a.sender.type}`,children:a.sender.type}),e.jsx("span",{className:`intent-pill ${i}`,children:a.intent})]}),e.jsx("div",{className:"message-text",children:a.text}),a.symbols.length>0&&e.jsx("div",{className:"message-symbols",children:a.symbols.map(t=>e.jsx("span",{className:"message-symbol-tag",children:t},t))}),a.diff&&e.jsxs("div",{className:"message-diff",children:[e.jsx("button",{className:"message-diff-toggle",onClick:()=>s(!r),children:r?"Hide diff":"Show diff"}),r&&e.jsx("pre",{className:"message-diff-content",children:a.diff})]}),a.decision&&e.jsxs("div",{className:"message-decision",children:[e.jsx("div",{className:"message-decision-label",children:"Decision"}),a.decision]}),e.jsx("div",{className:"message-time",children:g(a.timestamp)})]})}const w=["question","context","proposal","decision","action","alert","approval","rejection","reference","clarification","verification"];function k({threadId:a}){const[r,s]=m.useState("question"),[i,t]=m.useState(""),d=l(o=>o.sendMessage);async function n(){const o=i.trim();o&&(await d({intent:r,text:o,threadRoot:a||void 0}),t(""))}function h(o){o.key==="Enter"&&!o.shiftKey&&(o.preventDefault(),n())}return e.jsx("div",{className:"compose-box",children:e.jsxs("div",{className:"compose-row",children:[e.jsx("select",{className:"compose-intent-select",value:r,onChange:o=>s(o.target.value),children:w.map(o=>e.jsx("option",{value:o,children:o},o))}),e.jsx("textarea",{className:"compose-textarea",value:i,onChange:o=>t(o.target.value),onKeyDown:h,placeholder:"Type a message... (Enter to send, Shift+Enter for newline)",rows:1}),e.jsx("button",{className:"compose-send-btn",onClick:n,disabled:!i.trim(),children:"Send"})]})})}function F(){const a=l(n=>n.activeThread),r=l(n=>n.activeThreadId),s=l(n=>n.resolveThread),i=m.useRef(null);if(m.useEffect(()=>{var n;(n=i.current)==null||n.scrollIntoView({behavior:"smooth"})},[a==null?void 0:a.messages.length]),!a)return e.jsx("div",{className:"conversation",children:e.jsx("div",{className:"conversation-empty",children:"Select a thread to view"})});const{thread:t,messages:d}=a;return e.jsxs("div",{className:"conversation",children:[e.jsxs("div",{className:"conversation-header",children:[e.jsxs("div",{className:"conversation-header-left",children:[e.jsx("div",{className:"conversation-topic",children:t.topic}),e.jsx("div",{className:"conversation-participants",children:t.participants.map(n=>n.name).join(", ")})]}),e.jsxs("div",{className:"conversation-actions",children:[e.jsx("span",{className:`thread-card-status ${t.status}`,children:t.status}),t.status==="active"&&e.jsx("button",{className:"resolve-btn",onClick:()=>s(r),children:"Resolve"})]})]}),e.jsxs("div",{className:"conversation-messages",children:[d.map(n=>e.jsx(T,{msg:n},n.id)),e.jsx("div",{ref:i})]}),e.jsx(k,{threadId:r})]})}function I(){return e.jsxs("div",{className:"threads-layout",children:[e.jsx(b,{}),e.jsx(F,{})]})}function f(a){if(!a)return"never";const r=Date.now()-new Date(a).getTime(),s=Math.floor(r/1e3);if(s<60)return`${s}s ago`;const i=Math.floor(s/60);if(i<60)return`${i}m ago`;const t=Math.floor(i/60);return t<24?`${t}h ago`:`${Math.floor(t/24)}d ago`}function R(){const a=l(s=>s.agents),r=l(s=>s.status);return e.jsxs("div",{className:"network-view",children:[r&&e.jsxs("div",{className:"network-status-bar",children:[e.jsxs("div",{className:"network-stat",children:[e.jsx("div",{className:"network-stat-value",children:r.agentCount}),e.jsx("div",{className:"network-stat-label",children:"Agents"})]}),e.jsxs("div",{className:"network-stat",children:[e.jsx("div",{className:"network-stat-value",style:{color:"var(--p-accent-green)"},children:r.awakeCount}),e.jsx("div",{className:"network-stat-label",children:"Awake"})]}),e.jsxs("div",{className:"network-stat",children:[e.jsx("div",{className:"network-stat-value",children:r.activeThreadCount}),e.jsx("div",{className:"network-stat-label",children:"Active Threads"})]}),e.jsxs("div",{className:"network-stat",children:[e.jsx("div",{className:"network-stat-value",children:r.unreadCount}),e.jsx("div",{className:"network-stat-label",children:"Unread"})]}),e.jsxs("div",{className:"network-stat",children:[e.jsx("div",{className:"network-stat-value",children:r.pendingFileRequests}),e.jsx("div",{className:"network-stat-label",children:"Pending Files"})]})]}),a.length===0?e.jsxs("div",{className:"network-empty",children:[e.jsx("p",{children:"No agents registered."}),e.jsxs("p",{style:{marginTop:8},children:["Run ",e.jsx("code",{children:"paradigm symphony join"})," in a project to register an agent."]})]}):e.jsx("div",{className:"agent-grid",children:a.map(s=>e.jsxs("div",{className:"agent-card",children:[e.jsxs("div",{className:"agent-card-header",children:[e.jsx("span",{className:"agent-card-id",children:s.id}),e.jsx("span",{className:`agent-status-dot ${s.status}`,title:s.status})]}),e.jsx("div",{className:"agent-card-name",children:s.name}),s.statusBlurb&&e.jsx("div",{className:"agent-card-blurb",children:s.statusBlurb}),e.jsxs("div",{className:"agent-card-details",children:[e.jsxs("div",{className:"agent-card-detail",children:[e.jsx("span",{className:"agent-card-detail-label",children:"Project"}),e.jsx("span",{className:"agent-card-detail-value",children:s.project})]}),e.jsxs("div",{className:"agent-card-detail",children:[e.jsx("span",{className:"agent-card-detail-label",children:"Role"}),e.jsx("span",{className:"agent-card-detail-value",children:s.role})]}),e.jsxs("div",{className:"agent-card-detail",children:[e.jsx("span",{className:"agent-card-detail-label",children:"Last Poll"}),e.jsx("span",{className:"agent-card-detail-value",children:f(s.lastPoll)})]}),e.jsxs("div",{className:"agent-card-detail",children:[e.jsx("span",{className:"agent-card-detail-label",children:"Started"}),e.jsx("span",{className:"agent-card-detail-value",children:f(s.startedAt)})]})]})]},s.id))})]})}function v(a){const r=Date.now()-new Date(a).getTime(),s=Math.floor(r/1e3);if(s<60)return`${s}s ago`;const i=Math.floor(s/60);if(i<60)return`${i}m ago`;const t=Math.floor(i/60);return t<24?`${t}h ago`:`${Math.floor(t/24)}d ago`}function S({request:a}){const[r,s]=m.useState(!1),[i,t]=m.useState(""),d=l(h=>h.handleFileAction),n=a.status==="pending";return e.jsxs("div",{className:"file-request-card",children:[e.jsxs("div",{className:"file-request-header",children:[e.jsxs("span",{className:"file-request-path",children:[a.filePath,a.urgency==="urgent"&&e.jsx("span",{className:"urgency-badge urgent",children:"urgent"})]}),e.jsx("span",{className:`file-request-status ${a.status}`,children:a.status})]}),e.jsxs("div",{className:"file-request-requester",children:["From: ",a.requester.name]}),e.jsx("div",{className:"file-request-body",children:a.reason}),a.snippet&&e.jsxs("div",{className:"file-request-snippet",children:["Snippet: ",a.snippet]}),e.jsxs("div",{className:"file-request-meta",children:[e.jsx("span",{children:v(a.createdAt)}),a.resolvedAt&&e.jsxs("span",{children:["Resolved ",v(a.resolvedAt)]}),a.denyReason&&e.jsxs("span",{children:["Reason: ",a.denyReason]})]}),n&&e.jsxs("div",{className:"file-request-actions",children:[e.jsx("button",{className:"file-action-btn approve",onClick:()=>d(a.requestId,"approve"),children:"Approve"}),e.jsx("button",{className:"file-action-btn approve-redacted",onClick:()=>d(a.requestId,"approve-redacted"),children:"Approve (redacted)"}),r?e.jsxs(e.Fragment,{children:[e.jsx("input",{className:"deny-reason-input",value:i,onChange:h=>t(h.target.value),placeholder:"Reason for denial...",onKeyDown:h=>{h.key==="Enter"&&(d(a.requestId,"deny",i||void 0),s(!1),t("")),h.key==="Escape"&&(s(!1),t(""))},autoFocus:!0}),e.jsx("button",{className:"file-action-btn deny",onClick:()=>{d(a.requestId,"deny",i||void 0),s(!1),t("")},children:"Confirm Deny"})]}):e.jsx("button",{className:"file-action-btn deny",onClick:()=>s(!0),children:"Deny"})]})]})}function $(){const a=l(t=>t.fileRequests),r=l(t=>t.fileFilter),s=l(t=>t.setFileFilter),i=[{id:"pending",label:"Pending"},{id:"all",label:"All"}];return e.jsxs("div",{className:"files-view",children:[e.jsxs("div",{className:"files-toolbar",children:[e.jsx("div",{className:"files-filter-group",children:i.map(t=>e.jsx("button",{className:`thread-filter-btn ${r===t.id?"active":""}`,onClick:()=>s(t.id),children:t.label},t.id))}),e.jsxs("span",{className:"files-count",children:[a.length," request",a.length!==1?"s":""]})]}),e.jsx("div",{className:"files-list",children:a.length===0?e.jsxs("div",{className:"files-empty",children:[e.jsx("p",{children:"No file requests."}),e.jsxs("p",{style:{marginTop:8,fontSize:13},children:["Agents request files via ",e.jsx("code",{children:"paradigm_symphony_request_file"})]})]}):a.map(t=>e.jsx(S,{request:t},t.requestId))})]})}const C=[{id:"threads",label:"Threads"},{id:"network",label:"Network"},{id:"files",label:"Files"}];function q(){const a=l(c=>c.activeTab),r=l(c=>c.setActiveTab),s=l(c=>c.refresh),i=l(c=>c.fetchThread),t=l(c=>c.fetchFileRequests),d=l(c=>c.activeThreadId),n=l(c=>c.status);j(),m.useEffect(()=>{s(),l.getState().fetchMyIdentity(),l.getState().fetchFileRequests()},[]);const h=m.useRef(s);h.current=s,m.useEffect(()=>{const c=setInterval(()=>h.current(),1e4);return()=>clearInterval(c)},[]);const o=m.useRef(d);o.current=d;const u=m.useRef(i);return u.current=i,m.useEffect(()=>{const c=setInterval(()=>{o.current&&u.current(o.current)},3e3);return()=>clearInterval(c)},[]),m.useEffect(()=>{if(a!=="files")return;const c=setInterval(()=>t(),1e4);return()=>clearInterval(c)},[a,t]),e.jsxs("div",{className:"symphony-section",children:[e.jsx("div",{className:"symphony-tabs",children:C.map(c=>e.jsxs("button",{className:`symphony-tab ${a===c.id?"active":""}`,onClick:()=>r(c.id),children:[c.label,c.id==="threads"&&n&&n.activeThreadCount>0&&e.jsx("span",{className:"tab-badge",children:n.activeThreadCount}),c.id==="files"&&n&&n.pendingFileRequests>0&&e.jsx("span",{className:"tab-badge",children:n.pendingFileRequests})]},c.id))}),e.jsxs("div",{className:"symphony-tab-content",children:[a==="threads"&&e.jsx(I,{}),a==="network"&&e.jsx(R,{}),a==="files"&&e.jsx($,{})]})]})}export{q as default};