@a-company/paradigm 3.43.0 → 3.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/dist/{chunk-YW5OCVKB.js → chunk-FKJUBQU3.js} +14 -1
  2. package/dist/{symphony-ROEKK7VD.js → chunk-SOBTKFSP.js} +48 -431
  3. package/dist/{chunk-RGFANZ4Q.js → chunk-ZDHLG5VP.js} +14 -1
  4. package/dist/{chunk-CZEIK3Y2.js → chunk-ZMQA6SCO.js} +1 -1
  5. package/dist/{chunk-7WEKMZ46.js → chunk-ZSYVKSY6.js} +1 -1
  6. package/dist/{commands-LEPFD7S5.js → commands-5N4ILTPH.js} +13 -0
  7. package/dist/{dist-RVKYUCRU.js → dist-CM3MVWWW.js} +1 -1
  8. package/dist/{dist-Y7I3CFY5.js → dist-POMVY6WP.js} +2 -2
  9. package/dist/{habits-O37HTUKE.js → habits-RG5SVKXP.js} +2 -2
  10. package/dist/index.js +47 -47
  11. package/dist/mcp.js +19 -9
  12. package/dist/{platform-server-KK4OCRTV.js → platform-server-KHL6ZPPN.js} +10 -1
  13. package/dist/{reindex-NZQRGKPN.js → reindex-WIJMCJ4A.js} +1 -1
  14. package/dist/{sentinel-BKYTBT7M.js → sentinel-UOIGJWHH.js} +1 -1
  15. package/dist/{sentinel-bridge-IZTXYS5M.js → sentinel-bridge-APDXYAZS.js} +1 -1
  16. package/dist/sentinel-mcp.js +13 -0
  17. package/dist/sentinel.js +6 -6
  18. package/dist/{serve-3V2WXLGM.js → serve-JVXSRSUB.js} +1 -1
  19. package/dist/{server-OFEJ2HJP.js → server-JV6UFGWZ.js} +1 -1
  20. package/dist/symphony-EYRGGVNE.js +470 -0
  21. package/dist/symphony-QWOEKZMC.js +308 -0
  22. package/dist/{triage-POXJ2TIX.js → triage-IZ4MDYNB.js} +2 -2
  23. package/package.json +1 -1
  24. package/platform-ui/dist/assets/{GitSection-DvyJBF_-.js → GitSection-BD3Ze06e.js} +1 -1
  25. package/platform-ui/dist/assets/{GraphSection-BiQrXqfs.js → GraphSection-SglITfSs.js} +1 -1
  26. package/platform-ui/dist/assets/{LoreSection-BaH1FaRb.js → LoreSection-bR5Km4Fd.js} +1 -1
  27. package/platform-ui/dist/assets/{SentinelSection-DemAznjI.js → SentinelSection-QSpAZArG.js} +1 -1
  28. package/platform-ui/dist/assets/SymphonySection-CobYJgvg.js +1 -0
  29. package/platform-ui/dist/assets/SymphonySection-zY0C5tFl.css +1 -0
  30. package/platform-ui/dist/assets/{index-DDKhCt-w.js → index-DbxeSMkV.js} +11 -11
  31. package/platform-ui/dist/index.html +1 -1
@@ -1 +1 @@
1
- import{c as A,j as e,r as p,R as y}from"./index-DDKhCt-w.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-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 +1 @@
1
- import{c as _,r,j as e}from"./index-DDKhCt-w.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-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};
@@ -0,0 +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};
@@ -0,0 +1 @@
1
+ .symphony-section{display:flex;flex-direction:column;height:100%;overflow:hidden;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif}.symphony-tabs{display:flex;gap:0;padding:0 16px;border-bottom:1px solid var(--p-border);background:var(--p-bg-secondary);flex-shrink:0}.symphony-tab{padding:10px 16px;border:none;background:none;color:var(--p-text-secondary);font-size:13px;font-weight:500;cursor:pointer;border-bottom:2px solid transparent;transition:all .15s ease}.symphony-tab:hover{color:var(--p-text-primary);background:var(--p-bg-hover)}.symphony-tab.active{color:var(--p-accent-blue);border-bottom-color:var(--p-accent-blue)}.symphony-tab .tab-badge{display:inline-flex;align-items:center;justify-content:center;min-width:18px;height:18px;padding:0 5px;margin-left:6px;border-radius:9px;background:var(--p-bg-tertiary);color:var(--p-text-muted);font-size:11px;font-weight:600}.symphony-tab.active .tab-badge{background:#58a6ff26;color:var(--p-accent-blue)}.symphony-tab-content{flex:1;overflow:hidden;display:flex;flex-direction:column}.threads-layout{display:flex;flex:1;overflow:hidden}.thread-list-sidebar{width:320px;flex-shrink:0;display:flex;flex-direction:column;border-right:1px solid var(--p-border);background:var(--p-bg-secondary);overflow:hidden}.thread-list-toolbar{display:flex;gap:4px;padding:8px 12px;border-bottom:1px solid var(--p-border);flex-shrink:0}.thread-filter-btn{padding:4px 10px;border:1px solid var(--p-border);border-radius:var(--p-radius);background:transparent;color:var(--p-text-secondary);font-size:12px;cursor:pointer;transition:all .15s}.thread-filter-btn:hover{color:var(--p-text-primary)}.thread-filter-btn.active{background:var(--p-accent-blue);border-color:var(--p-accent-blue);color:#fff}.thread-list-items{flex:1;overflow-y:auto}.thread-card{padding:12px;border-bottom:1px solid rgba(255,255,255,.04);cursor:pointer;transition:background .15s}.thread-card:hover{background:var(--p-bg-hover)}.thread-card.selected{background:var(--p-bg-hover);border-left:3px solid var(--p-accent-blue);padding-left:9px}.thread-card-topic{font-size:13px;font-weight:500;color:var(--p-text-primary);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;margin-bottom:4px}.thread-card-meta{display:flex;align-items:center;justify-content:space-between;font-size:11px;color:var(--p-text-muted)}.thread-card-participants{display:flex;gap:2px}.participant-avatar{width:20px;height:20px;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:9px;font-weight:700;color:#fff;background:var(--p-accent-blue)}.participant-avatar.human{background:var(--p-accent-green)}.thread-card-stats{display:flex;align-items:center;gap:8px}.thread-card-count{display:flex;align-items:center;gap:2px}.thread-card-status{font-size:10px;font-weight:600;text-transform:uppercase;padding:1px 5px;border-radius:3px}.thread-card-status.active{color:var(--p-accent-green);background:#3fb9501a}.thread-card-status.resolved{color:var(--p-text-muted);background:#ffffff0d}.thread-list-empty{padding:40px 24px;text-align:center;color:var(--p-text-muted);font-size:13px}.thread-list-empty code{background:var(--p-bg-tertiary);padding:2px 6px;border-radius:4px;font-size:12px}.conversation{flex:1;display:flex;flex-direction:column;overflow:hidden;background:var(--p-bg-primary)}.conversation-empty{display:flex;align-items:center;justify-content:center;flex:1;color:var(--p-text-muted);font-size:14px}.conversation-header{display:flex;align-items:center;justify-content:space-between;padding:12px 16px;border-bottom:1px solid var(--p-border);background:var(--p-bg-secondary);flex-shrink:0}.conversation-header-left{flex:1;min-width:0}.conversation-topic{font-size:15px;font-weight:600;color:var(--p-text-primary);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.conversation-participants{font-size:12px;color:var(--p-text-muted);margin-top:2px}.conversation-actions{display:flex;gap:8px;align-items:center}.resolve-btn{padding:6px 12px;border:none;border-radius:var(--p-radius);background:var(--p-accent-green);color:#fff;font-size:12px;font-weight:600;cursor:pointer;transition:opacity .15s}.resolve-btn:hover{opacity:.85}.resolve-btn:disabled{opacity:.4;cursor:not-allowed}.conversation-messages{flex:1;overflow-y:auto;padding:16px;display:flex;flex-direction:column;gap:12px}.message-bubble{max-width:85%;padding:10px 14px;background:var(--p-bg-secondary);border:1px solid var(--p-border);border-radius:10px;position:relative}.message-bubble-header{display:flex;align-items:center;gap:8px;margin-bottom:4px}.message-sender{font-size:12px;font-weight:600;color:var(--p-text-primary)}.message-sender-type{font-size:10px;font-weight:600;text-transform:uppercase;padding:1px 5px;border-radius:3px;background:#ffffff0d;color:var(--p-text-muted)}.message-sender-type.human{background:#3fb9501a;color:var(--p-accent-green)}.intent-pill{font-size:10px;font-weight:600;text-transform:uppercase;padding:2px 7px;border-radius:8px;letter-spacing:.03em}.intent-pill.dialogue{background:#58a6ff1f;color:#58a6ff}.intent-pill.action{background:rgba(var(--p-symbol-component-rgb, 139, 233, 253),.12);color:var(--p-symbol-component, #8be9fd)}.intent-pill.outcome{background:#d299221f;color:var(--p-accent-orange, #d29922)}.intent-pill.system{background:#f851491f;color:var(--p-accent-red, #f85149)}.intent-pill.lifecycle{background:rgba(var(--p-symbol-aspect-rgb, 189, 147, 249),.12);color:var(--p-symbol-aspect, #bd93f9)}.intent-pill.transfer{background:#3fb9501f;color:var(--p-accent-green, #3fb950)}.message-text{font-size:13px;color:var(--p-text-primary);line-height:1.5;white-space:pre-wrap;word-break:break-word}.message-symbols{display:flex;flex-wrap:wrap;gap:4px;margin-top:6px}.message-symbol-tag{font-family:SF Mono,monospace;font-size:11px;padding:1px 6px;border-radius:4px;background:#ffffff0d;color:var(--p-accent-blue)}.message-diff{margin-top:8px;border-radius:var(--p-radius);overflow:hidden}.message-diff-toggle{display:block;width:100%;padding:4px 8px;border:1px solid var(--p-border);border-radius:var(--p-radius);background:var(--p-bg-tertiary);color:var(--p-text-muted);font-size:11px;cursor:pointer;text-align:left;transition:all .15s}.message-diff-toggle:hover{color:var(--p-text-primary)}.message-diff-content{margin-top:4px;padding:8px;background:var(--p-bg-tertiary);border-radius:var(--p-radius);font-family:SF Mono,monospace;font-size:11px;white-space:pre-wrap;word-break:break-all;color:var(--p-text-secondary);overflow-x:auto;max-height:300px;overflow-y:auto}.message-decision{margin-top:8px;padding:8px 12px;border-left:3px solid var(--p-accent-orange, #d29922);background:#d299220f;border-radius:0 var(--p-radius) var(--p-radius) 0;font-size:12px;color:var(--p-text-primary)}.message-decision-label{font-size:10px;font-weight:700;text-transform:uppercase;color:var(--p-accent-orange, #d29922);margin-bottom:2px;letter-spacing:.05em}.message-time{font-size:10px;color:var(--p-text-muted);margin-top:4px;text-align:right}.compose-box{padding:12px 16px;border-top:1px solid var(--p-border);background:var(--p-bg-secondary);flex-shrink:0}.compose-row{display:flex;gap:8px;align-items:flex-end}.compose-intent-select{padding:8px;border:1px solid var(--p-border);border-radius:var(--p-radius);background:var(--p-bg-tertiary);color:var(--p-text-primary);font-size:12px;flex-shrink:0;width:120px}.compose-textarea{flex:1;padding:8px 12px;border:1px solid var(--p-border);border-radius:var(--p-radius);background:var(--p-bg-tertiary);color:var(--p-text-primary);font-size:13px;font-family:inherit;resize:none;min-height:38px;max-height:120px;line-height:1.4}.compose-textarea:focus{outline:none;border-color:var(--p-accent-blue)}.compose-textarea::placeholder{color:var(--p-text-muted)}.compose-send-btn{padding:8px 16px;border:none;border-radius:var(--p-radius);background:var(--p-accent-blue);color:#fff;font-size:13px;font-weight:600;cursor:pointer;flex-shrink:0;transition:opacity .15s}.compose-send-btn:hover{opacity:.85}.compose-send-btn:disabled{opacity:.4;cursor:not-allowed}.network-view{flex:1;overflow-y:auto;padding:20px;background:var(--p-bg-primary)}.network-status-bar{display:flex;gap:16px;margin-bottom:20px;flex-wrap:wrap}.network-stat{padding:12px 20px;background:var(--p-bg-secondary);border:1px solid var(--p-border);border-radius:8px;text-align:center;min-width:100px}.network-stat-value{font-size:24px;font-weight:700;color:var(--p-text-primary)}.network-stat-label{font-size:11px;color:var(--p-text-muted);text-transform:uppercase;letter-spacing:.05em;margin-top:2px}.agent-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(280px,1fr));gap:12px}.agent-card{padding:16px;background:var(--p-bg-secondary);border:1px solid var(--p-border);border-radius:8px;transition:border-color .15s}.agent-card:hover{border-color:var(--p-accent-blue)}.agent-card-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:8px}.agent-card-id{font-family:SF Mono,monospace;font-size:13px;font-weight:600;color:var(--p-text-primary);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.agent-status-dot{width:8px;height:8px;border-radius:50%;flex-shrink:0}.agent-status-dot.awake{background:var(--p-accent-green);box-shadow:0 0 6px #3fb95066;animation:symphony-pulse 2s infinite}.agent-status-dot.asleep{background:var(--p-text-muted)}@keyframes symphony-pulse{0%,to{opacity:1}50%{opacity:.5}}.agent-card-name{font-size:12px;color:var(--p-text-secondary);margin-bottom:4px}.agent-card-blurb{font-size:12px;color:var(--p-text-primary);padding:4px 8px;background:#58a6ff0f;border-left:2px solid var(--p-accent-blue);border-radius:0 var(--p-radius) var(--p-radius) 0;margin-bottom:8px;line-height:1.4}.agent-card-details{display:flex;flex-direction:column;gap:4px;font-size:11px;color:var(--p-text-muted)}.agent-card-detail{display:flex;justify-content:space-between}.agent-card-detail-label{color:var(--p-text-muted)}.agent-card-detail-value{color:var(--p-text-secondary);font-family:SF Mono,monospace}.network-empty{text-align:center;padding:48px 24px;color:var(--p-text-muted)}.network-empty code{background:var(--p-bg-tertiary);padding:2px 6px;border-radius:4px;font-size:12px}.files-view{flex:1;display:flex;flex-direction:column;overflow:hidden;background:var(--p-bg-primary)}.files-toolbar{display:flex;align-items:center;justify-content:space-between;padding:8px 16px;border-bottom:1px solid var(--p-border);background:var(--p-bg-secondary);flex-shrink:0}.files-filter-group{display:flex;gap:4px}.files-count{font-size:12px;color:var(--p-text-muted)}.files-list{flex:1;overflow-y:auto;padding:16px}.file-request-card{padding:16px;background:var(--p-bg-secondary);border:1px solid var(--p-border);border-radius:8px;margin-bottom:12px}.file-request-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:8px}.file-request-path{font-family:SF Mono,monospace;font-size:13px;font-weight:600;color:var(--p-text-primary)}.file-request-status{font-size:11px;font-weight:600;text-transform:uppercase;padding:2px 8px;border-radius:4px}.file-request-status.pending{background:#d299221a;color:var(--p-accent-orange, #d29922)}.file-request-status.approved{background:#3fb9501a;color:var(--p-accent-green)}.file-request-status.denied{background:#f851491a;color:var(--p-accent-red)}.file-request-status.expired{background:#ffffff0d;color:var(--p-text-muted)}.file-request-body{font-size:13px;color:var(--p-text-secondary);margin-bottom:8px}.file-request-requester{font-size:12px;color:var(--p-text-muted);margin-bottom:4px}.file-request-snippet{margin-top:8px;padding:6px 10px;background:var(--p-bg-tertiary);border-radius:var(--p-radius);font-family:SF Mono,monospace;font-size:11px;color:var(--p-text-muted)}.urgency-badge{font-size:10px;font-weight:600;text-transform:uppercase;padding:1px 5px;border-radius:3px;margin-left:6px}.urgency-badge.urgent{background:#f851491a;color:var(--p-accent-red)}.urgency-badge.normal{background:#ffffff0d;color:var(--p-text-muted)}.file-request-meta{display:flex;align-items:center;gap:12px;font-size:11px;color:var(--p-text-muted);margin-bottom:12px}.file-request-actions{display:flex;gap:8px;align-items:center}.file-action-btn{padding:6px 14px;border:none;border-radius:var(--p-radius);font-size:12px;font-weight:600;cursor:pointer;transition:opacity .15s}.file-action-btn:hover{opacity:.85}.file-action-btn.approve{background:var(--p-accent-green);color:#fff}.file-action-btn.approve-redacted{background:transparent;border:1px solid var(--p-accent-green);color:var(--p-accent-green)}.file-action-btn.deny{background:transparent;border:1px solid var(--p-accent-red);color:var(--p-accent-red)}.deny-reason-input{flex:1;padding:6px 10px;border:1px solid var(--p-border);border-radius:var(--p-radius);background:var(--p-bg-tertiary);color:var(--p-text-primary);font-size:12px}.files-empty{text-align:center;padding:48px 24px;color:var(--p-text-muted)}