gossipcat 0.5.3 → 0.5.5
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.
- package/dist-dashboard/assets/{index-BSpZTn_T.js → index-Chrn1WHu.js} +4 -4
- package/dist-dashboard/assets/index-DUZrYB2U.css +1 -0
- package/dist-dashboard/index.html +2 -2
- package/dist-mcp/default-skills/catalog.json +24 -0
- package/dist-mcp/default-skills/implementation-discipline.md +77 -0
- package/dist-mcp/mcp-server.js +2517 -1630
- package/docs/RULES.md +7 -5
- package/package.json +1 -1
- package/scripts/postinstall.js +2 -2
- package/dist-dashboard/assets/index-D622Bi2n.css +0 -1
|
@@ -67,12 +67,12 @@ Severity-weighted findings.`})]}),a.jsxs("div",{style:{display:"flex",flexDirect
|
|
|
67
67
|
@media (prefers-reduced-motion: reduce) {
|
|
68
68
|
.animate-pulse { animation: none !important; }
|
|
69
69
|
}
|
|
70
|
-
`})]})}function ag(){return a.jsx("div",{className:"rounded-md border p-10 text-center",style:{borderColor:"var(--border)",background:"var(--surface-elev)"},children:a.jsx("p",{className:"font-mono text-[12px]",style:{color:"var(--ink-3)"},children:"No consensus rounds yet — dispatch your first review to see the consensus flow."})})}function sg({error:i,stale:r}){return a.jsxs("div",{className:"relative rounded-md border p-5",style:{borderColor:"var(--border)",background:"var(--surface-elev)"},children:[a.jsx("div",{className:"absolute right-3 top-3",children:a.jsxs("span",{className:"rounded-sm px-1.5 py-0.5 font-mono text-[10px]",style:{background:"var(--bad-soft)",color:"var(--bad)",border:"1px solid var(--bad)"},title:i,children:["error · ",i]})}),r?a.jsx("div",{style:{opacity:.5,pointerEvents:"none"},children:a.jsx(gh,{data:r})}):a.jsx("p",{className:"py-10 text-center font-mono text-[12px]",style:{color:"var(--ink-3)"},children:"Failed to load consensus flow."})]})}function ig(){const[i,r]=k.useState(!1);return k.useEffect(()=>{if(typeof window>"u"||!window.matchMedia)return;const u=window.matchMedia("(prefers-reduced-motion: reduce)");r(u.matches);const o=d=>r(d.matches);return u.addEventListener("change",o),()=>u.removeEventListener("change",o)},[]),i}function cg({consensusId:i}){return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"mb-6",children:[a.jsxs("nav",{className:"mb-2 flex items-center gap-2 font-mono text-[11px]",style:{color:"var(--ink-3)"},"aria-label":"Breadcrumb",children:[a.jsx("a",{href:vn("/"),className:"hover:underline",style:{color:"var(--ink-3)"},children:"Overview"}),a.jsx("span",{"aria-hidden":"true",children:"›"}),a.jsx("span",{style:{color:"var(--ink)"},children:i})]}),a.jsx("h1",{className:"h-route",children:"Consensus flow"}),a.jsx("p",{className:"mt-0.5 font-mono text-[10px]",style:{color:"var(--ink-3)"},children:"Model families on the left, findings reviewed in the middle, verdicts on the right."})]}),a.jsx(Iv,{consensusId:i})]})}function rg({onLogin:i,error:r}){const[u,o]=k.useState(""),[d,m]=k.useState(!1),v=async x=>{if(x.preventDefault(),!(!u.trim()||d)){m(!0);try{await i(u.trim())}finally{m(!1)}}},p=r==="bad_key"?"Invalid key. Check your terminal for the correct key.":r==="network"?"Connection error — relay may be offline.":null;return a.jsx("div",{className:"min-h-screen flex items-center justify-center",style:{background:"var(--surface)"},children:a.jsxs("div",{className:"w-full max-w-sm rounded-xl border [border-color:var(--border)] p-8 text-center",style:{background:"var(--surface-elev)"},children:[a.jsx("div",{className:"crt-logo mx-auto mb-4",style:{width:"fit-content"},children:a.jsx("img",{src:"/dashboard/assets/gossip-mini.png",alt:"gossipcat",className:"crt-logo-img h-56 w-56 object-contain",style:{filter:"drop-shadow(0 0 28px var(--accent))"}})}),a.jsx("p",{className:"h-route mb-1",style:{letterSpacing:"-0.02em",textShadow:"0 0 24px var(--accent)"},children:"Gossipcat"}),a.jsx("p",{className:"mb-6 text-[13px]",style:{color:"var(--ink-3)"},children:"Authenticate to access the dashboard"}),a.jsxs("form",{onSubmit:v,children:[a.jsx("input",{type:"password",value:u,onChange:x=>o(x.target.value),placeholder:"Dashboard key",autoFocus:!0,disabled:d,className:"w-full rounded-lg border [border-color:var(--border)] px-4 py-3 font-mono text-sm outline-none focus:[border-color:var(--ink-3)] focus:ring-2 focus:[--tw-ring-color:color-mix(in_oklch,var(--ink-3)_20%,transparent)] disabled:opacity-50",style:{background:"var(--surface)",color:"var(--ink)"}}),a.jsx("button",{type:"submit",disabled:d,className:"mt-4 w-full rounded-lg px-4 py-3 text-sm font-semibold transition hover:opacity-90 disabled:opacity-60",style:{background:"var(--accent)",color:"#fff"},children:d?"Unlocking…":"Unlock"})]}),p&&a.jsx("p",{className:"mt-3 text-sm",style:{color:"var(--bad)"},children:p})]})})}const yh="dashboard:theme",og=["light","dark"];function ug(i){return i==="light"||i==="dark"?i:i==="editorial"?"light":i==="default"?"dark":null}function dg(i,r){const u=ug(i);return u!==null?u:r?"dark":"light"}function fg(){return typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(prefers-color-scheme: dark)").matches}function mg(){if(typeof window>"u")return"light";let i=null;try{i=window.localStorage.getItem(yh)}catch{}return dg(i,fg())}function hg(){const[i,r]=k.useState(mg);k.useEffect(()=>{typeof document>"u"||(i==="light"?delete document.documentElement.dataset.theme:document.documentElement.dataset.theme=i)},[i]);function u(d){if(og.includes(d)&&(r(d),typeof window<"u"))try{window.localStorage.setItem(yh,d)}catch{}}return{theme:i,setTheme:u,toggle:()=>{u(i==="light"?"dark":"light")}}}const xg=[{term:"Consensus Round",definition:"A structured multi-agent review session. Each agent independently reviews the target code or output, then all agents cross-review each other's findings. The result is a set of findings tagged by how many agents agreed. The /debates URL in the dashboard lists all past consensus rounds.",seeAlso:"Finding, Signal"},{term:"Finding",definition:"A verifiable claim about a specific line of code, always cited with a file path and line number. Agents emit findings during a consensus round. A finding that cannot be located in the code is a hallucination.",seeAlso:"Insight, Hallucination"},{term:"Insight",definition:"An observation that does not point to a specific code location. Insights are informational — they cannot be confirmed or disputed by other agents and are excluded from accuracy scoring.",seeAlso:"Finding"},{term:"Signal",definition:"A scored event recorded against an agent, such as agreement, hallucination_caught, or unique_confirmed. Each signal adjusts the agent's accuracy and dispatch weight over time. Signals are the primary feedback mechanism that drives agent improvement.",seeAlso:"Accuracy (Adjusted), Dispatch Weight"},{term:"Hallucination",definition:"A fabricated finding: the cited file and line exist, but the code does not support the claim the agent made. Caught during cross-review by a peer agent. Each hallucination lowers the emitting agent's accuracy score.",seeAlso:"Finding, Signal"},{term:"Confirmed / Disputed / Unverified / Unique",definition:"The four statuses assigned to a finding after cross-review. Confirmed = two or more agents independently verified it. Disputed = at least one agent found contradictory evidence. Unverified = peer agents could not check it (no code anchor, out of scope). Unique = only one agent surfaced it; not yet confirmed or denied.",seeAlso:"Consensus Round"},{term:"Dispatch Weight",definition:"How likely an agent is to be selected for the next task. Ranges from 0.3 (rarely dispatched) to 2.0 (strongly preferred). Updated after every task based on accuracy and uniqueness signals. Visible on the Team page.",seeAlso:"Accuracy (Adjusted), Uniqueness"},{term:"Accuracy (Adjusted)",definition:"The fraction of an agent's findings that survived cross-review, with a penalty applied for hallucinations. Category Competency on the agent page shows the raw per-category ratio without the penalty; the Metrics section shows the penalized aggregate used for dispatch decisions.",seeAlso:"Hallucination, Dispatch Weight"},{term:"Uniqueness",definition:"How often this agent surfaces findings that no other agent in the same round found. High uniqueness with low accuracy is a useful combination: always include such agents in a consensus round, but never send them solo.",seeAlso:"Accuracy (Adjusted), Consensus Round"},{term:"Reliability",definition:"Task completion rate — the fraction of dispatched tasks that finished without a pipeline error or timeout. Distinct from accuracy, which measures finding correctness.",seeAlso:"Accuracy (Adjusted)"},{term:"Impact",definition:"A severity-weighted score for an agent's findings. Critical and high findings contribute more than medium or low ones. Impact reflects not just how many findings an agent produces, but how serious those findings tend to be.",seeAlso:"Finding"},{term:"Benched / Struggling / Kept for coverage",definition:"Circuit-breaker states that limit dispatch when an agent underperforms. Benched = fully excluded from dispatch (chronic = sustained low accuracy; burst = recent failure streak). Struggling = consecutive failures tripped the breaker; agent is deprioritized until it recovers. Kept for coverage = the agent would be benched, but it is the only agent with a required skill category, so it stays in the pool.",seeAlso:"Dispatch Weight, Skill"},{term:"Skill",definition:"A markdown file injected into an agent's prompt for a specific task category (e.g. input_validation, trust_boundaries). Skills are generated from an agent's actual failure history and override generic defaults. A skill graduates from pending to passed or failed after 120 post-bind signals.",seeAlso:"bound_at"},{term:"bound_at",definition:"The timestamp when a skill was attached to an agent. This anchors the effectiveness window: only signals recorded after bound_at count toward the skill's graduation verdict.",seeAlso:"Skill"},{term:"Invalid Output Types",definition:"Agent finding tags with a type= attribute outside the allowed set (finding, suggestion, insight). The pipeline silently rejects these — they never reach the consensus round or the dashboard. The count is tracked so skill development can address systematic format drift.",seeAlso:"Finding"},{term:"Process Violation",definition:"A guardrail breach detected outside normal code review. Examples: an agent pushed a commit directly to master bypassing the PR process, or an agent wrote to a file outside its declared scope. Process violations are logged separately from code findings."}],pg={background:"var(--surface-elev)",borderRadius:"16px",boxShadow:"var(--shadow-overlay)",border:"1px solid var(--border)",color:"var(--text)",fontFamily:"var(--font-sans)"};function vg({open:i,onClose:r}){const u=k.useRef(null);return k.useEffect(()=>{if(!i)return;const o=requestAnimationFrame(()=>{var m;(m=u.current)==null||m.focus()}),d=m=>{m.key==="Escape"&&r()};return document.addEventListener("keydown",d),document.body.style.overflow="hidden",()=>{cancelAnimationFrame(o),document.removeEventListener("keydown",d),document.body.style.overflow=""}},[i,r]),i?a.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-6 backdrop-blur-sm",style:{background:"color-mix(in oklch, var(--surface) 80%, transparent)"},onClick:r,role:"presentation",children:a.jsxs("div",{className:"relative flex max-h-[calc(100vh-48px)] w-full max-w-2xl flex-col overflow-hidden",style:pg,role:"dialog","aria-modal":"true","aria-labelledby":"glossary-title",onClick:o=>o.stopPropagation(),children:[a.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-border/60 px-5 py-3.5",children:[a.jsx("h2",{id:"glossary-title",className:"font-mono text-sm font-semibold",style:{color:"var(--text)"},children:"Gossipcat Glossary"}),a.jsx("button",{ref:u,onClick:r,"aria-label":"Close glossary",className:"flex min-h-[44px] min-w-[44px] shrink-0 items-center justify-center rounded border border-border/40 font-mono text-xs transition hover:[color:var(--text)] hover:[background:var(--surface-sunk)]",style:{background:"var(--surface-elev)",color:"var(--text-dim)"},children:"×"})]}),a.jsx("div",{className:"flex-1 overflow-y-auto px-5 py-4",children:a.jsx("dl",{className:"space-y-5",children:xg.map(({term:o,definition:d,seeAlso:m})=>a.jsxs("div",{className:"rounded-md border border-border/40 px-4 py-3",style:{background:"color-mix(in oklch, var(--surface) 40%, transparent)"},children:[a.jsx("dt",{className:"h-section",children:o}),a.jsx("dd",{className:"mt-1.5 font-mono text-xs leading-relaxed",style:{color:"color-mix(in oklch, var(--text) 80%, transparent)"},children:d}),m&&a.jsxs("dd",{className:"mt-1.5 font-mono text-[10px]",style:{color:"color-mix(in oklch, var(--text-dim) 60%, transparent)"},children:["See also: ",m]})]},o))})}),a.jsx("div",{className:"shrink-0 border-t border-border/60 px-5 py-3",children:a.jsx("a",{href:"https://github.com/gossipcat-ai/gossipcat-ai/blob/master/docs/HANDBOOK.md",target:"_blank",rel:"noopener noreferrer",className:"font-mono text-xs transition hover:underline",style:{color:"var(--accent)"},children:"Read the full HANDBOOK →"})})]})}):null}const gg=[{to:"/",label:"Dashboard",match:i=>i==="/"||i==="/overview"},{to:"/team",label:"Team",match:i=>i==="/team"||i.startsWith("/agent/")},{to:"/debates",label:"Consensus Rounds",match:i=>i==="/debates"},{to:"/tasks",label:"Tasks",match:i=>i==="/tasks"},{to:"/signals",label:"Signals",match:i=>i==="/signals"},{to:"/logs",label:"Logs",match:i=>i==="/logs"}];function Im(){const[i,r]=k.useState(!1),u=rh(),{theme:o,toggle:d}=hg();return a.jsxs("nav",{className:"relative flex items-center justify-between border-b border-border px-6 py-3.5",children:[a.jsxs("div",{className:"flex items-center gap-6",children:[a.jsxs("a",{href:vn("/"),className:"flex items-center gap-3 leading-none",children:[a.jsx("img",{src:"/dashboard/assets/gossip-mini.png",alt:"",className:"h-10 w-10 object-contain"}),a.jsx("span",{className:"text-[17px] font-bold",style:{color:"var(--accent)"},children:"gossipcat"})]}),a.jsx("div",{className:"flex gap-1",children:gg.map(m=>{const v=m.match(u);return a.jsx("a",{href:vn(m.to),className:`rounded-md px-3.5 py-1.5 font-mono text-[13px] transition ${v?"font-semibold":"hover:bg-accent/10"}`,style:v?{background:"color-mix(in oklch, var(--accent) 10%, transparent)",color:"var(--accent)"}:{color:"var(--ink-3)"},children:m.label},m.to)})})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{"aria-hidden":"true",title:"Search — coming soon",style:{display:"inline-flex",alignItems:"center",gap:"8px",height:"32px",padding:"0 12px",minWidth:"220px",background:"var(--surface-elev)",border:"1px solid var(--border)",borderRadius:"8px",color:"var(--ink-3)",fontFamily:"var(--font-sans)",fontSize:"13px",cursor:"default"},children:[a.jsx("span",{style:{opacity:.7},children:"Search…"}),a.jsx("kbd",{style:{marginLeft:"auto",padding:"1px 6px",borderRadius:"4px",background:"var(--surface-sunk)",border:"1px solid var(--border)",fontFamily:"var(--font-mono)",fontSize:"11px",color:"var(--ink-3)"},children:"⌘K"})]}),a.jsx("button",{type:"button",onClick:d,title:`Switch to ${o==="light"?"dark":"light"} theme`,"aria-label":`Switch to ${o==="light"?"dark":"light"} theme`,style:{width:"32px",height:"32px",display:"inline-flex",alignItems:"center",justifyContent:"center",background:"var(--surface-elev)",border:"1px solid var(--border)",borderRadius:"8px",color:"var(--ink)",cursor:"pointer",fontSize:"16px",lineHeight:1},children:o==="light"?"◐":"◑"}),a.jsx("button",{type:"button",onClick:()=>r(!0),"aria-label":"Open glossary",title:"Glossary",style:{width:"32px",height:"32px",display:"inline-flex",alignItems:"center",justifyContent:"center",background:"var(--surface-elev)",border:"1px solid var(--border)",borderRadius:"8px",color:"var(--ink)",cursor:"pointer",lineHeight:1},children:a.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[a.jsx("path",{d:"M4 19.5A2.5 2.5 0 0 1 6.5 17H20"}),a.jsx("path",{d:"M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z"})]})})]}),a.jsx(vg,{open:i,onClose:()=>r(!1)})]})}const yg={completed:{label:"COMPLETED",cls:"text-confirmed bg-confirmed/10"},failed:{label:"FAILED",cls:"text-destructive bg-destructive/10"},cancelled:{label:"CANCELLED",cls:"",clsStyle:{color:"var(--text-dim)",background:"color-mix(in oklch, var(--surface-sunk) 30%, transparent)"}},running:{label:"RUNNING",cls:"text-unverified bg-unverified/10 animate-pulse"}};function bh({task:i,onClose:r}){if(k.useEffect(()=>{if(!i)return;const d=m=>{m.key==="Escape"&&r()};return document.addEventListener("keydown",d),document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",d),document.body.style.overflow=""}},[i,r]),!i)return null;const u=yg[i.status],o=(i.inputTokens||0)+(i.outputTokens||0);return a.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center overflow-y-auto p-6 backdrop-blur-sm",style:{background:"color-mix(in oklch, var(--surface) 80%, transparent)"},onClick:r,children:a.jsxs("div",{className:"relative mt-12 w-full max-w-3xl rounded-lg border border-border",style:{background:"var(--surface-elev)",boxShadow:"var(--shadow-overlay)"},onClick:d=>d.stopPropagation(),children:[a.jsxs("div",{className:"flex items-start justify-between gap-4 border-b border-border/60 px-5 py-4",children:[a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:`shrink-0 rounded-sm px-1.5 py-0.5 font-mono text-[9px] font-bold ${u.cls}`,style:u.clsStyle,children:u.label}),a.jsx("span",{className:"warn-badge shrink-0 rounded px-1.5 py-0.5 font-mono text-[10px] font-semibold",children:i.taskId.slice(0,8)}),a.jsx("a",{href:`/dashboard/agent/${encodeURIComponent(i.agentId)}`,className:"truncate font-mono text-xs transition",style:{color:"var(--text-dim)"},children:i.agentId})]}),a.jsxs("div",{className:"mt-2 flex flex-wrap gap-3 font-mono text-[10px]",style:{color:"var(--text-dim)"},children:[a.jsx("span",{children:We(i.timestamp)}),i.duration!=null&&a.jsxs("span",{children:["· ",n0(i.duration)]}),o>0&&a.jsxs("span",{children:["· ",o.toLocaleString()," tokens (",(i.inputTokens||0).toLocaleString()," in / ",(i.outputTokens||0).toLocaleString()," out)"]})]})]}),a.jsx("button",{onClick:r,className:"shrink-0 rounded-md border border-border/40 px-2 py-1 font-mono text-xs transition hover:bg-accent/10",style:{background:"var(--surface-elev)",color:"var(--text-dim)"},"aria-label":"Close",children:"✕"})]}),a.jsxs("div",{className:"max-h-[calc(100vh-220px)] space-y-5 overflow-y-auto px-5 py-4",children:[a.jsxs("section",{children:[a.jsx("h3",{className:"mb-2 h-section",children:"Task"}),a.jsx("div",{className:"task-md rounded-md border border-border/40 p-3 text-xs leading-relaxed overflow-x-auto",style:{background:"color-mix(in oklch, var(--surface) 40%, transparent)",color:"color-mix(in oklch, var(--text) 90%, transparent)"},dangerouslySetInnerHTML:{__html:t0(i.task)}})]}),i.result?a.jsxs("section",{children:[a.jsx("h3",{className:"mb-2 h-section",children:"Result"}),a.jsx("div",{className:"finding-md rounded-md border border-border/40 p-3 font-mono text-xs leading-relaxed whitespace-pre-wrap [&_.cite-file]:rounded [&_.cite-file]:bg-blue-500/10 [&_.cite-file]:px-1 [&_.cite-file]:text-blue-400 [&_.cite-fn]:rounded [&_.cite-fn]:bg-purple-500/10 [&_.cite-fn]:px-1 [&_.cite-fn]:text-purple-400 [&_.inline-code]:rounded [&_.inline-code]:bg-[color-mix(in_oklch,var(--surface-sunk)_40%,transparent)] [&_.inline-code]:px-1 [&_.inline-code-block]:my-2 [&_.inline-code-block]:block [&_.inline-code-block]:rounded [&_.inline-code-block]:bg-[color-mix(in_oklch,var(--surface-sunk)_30%,transparent)] [&_.inline-code-block]:p-2",style:{background:"color-mix(in oklch, var(--surface) 40%, transparent)",color:"color-mix(in oklch, var(--text) 90%, transparent)"},dangerouslySetInnerHTML:{__html:Oi(i.result)}})]}):a.jsxs("section",{children:[a.jsx("h3",{className:"mb-2 h-section",children:"Result"}),a.jsx("div",{className:"rounded-md border border-border/40 p-3 text-center font-mono text-xs",style:{background:"color-mix(in oklch, var(--surface) 40%, transparent)",color:"var(--text-dim)"},children:i.status==="running"?"Task is still running...":"No result recorded."})]})]})]})})}function No(i){return i.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const oo=5,uo={agreement:{label:"CONFIRMED",filter:"confirmed",cls:"text-confirmed bg-confirmed/10"},consensus_verified:{label:"CONFIRMED",filter:"confirmed",cls:"text-confirmed bg-confirmed/10"},disagreement:{label:"DISPUTED",filter:"disputed",cls:"text-disputed bg-disputed/10"},hallucination_caught:{label:"DISPUTED",filter:"disputed",cls:"text-disputed bg-disputed/10"},unverified:{label:"UNVERIFIED",filter:"unverified",cls:"text-unverified bg-unverified/10"},unique_confirmed:{label:"UNIQUE",filter:"unique",cls:"text-unique bg-unique/10"},unique_unconfirmed:{label:"UNIQUE?",filter:"unique",cls:"text-unverified bg-unverified/10"},new_finding:{label:"NEW",filter:"unique",cls:"text-unique bg-unique/10"}},Wm=[{key:"all",label:"All",cls:"border-border/40 hover:border-border/60",activeCls:"border-border",activeStyle:{color:"var(--text)",background:"var(--surface-sunk)"},inactiveStyle:{color:"var(--text-dim)"}},{key:"confirmed",label:"Confirmed",cls:"text-confirmed/50 border-confirmed/20 hover:border-confirmed/40",activeCls:"text-confirmed bg-confirmed/10 border-confirmed/40"},{key:"unique",label:"Unique",cls:"text-unique/50 border-unique/20 hover:border-unique/40",activeCls:"text-unique bg-unique/10 border-unique/40"},{key:"disputed",label:"Disputed",cls:"text-disputed/50 border-disputed/20 hover:border-disputed/40",activeCls:"text-disputed bg-disputed/10 border-disputed/40"},{key:"unverified",label:"Unverified",cls:"text-unverified/50 border-unverified/20 hover:border-unverified/40",activeCls:"text-unverified bg-unverified/10 border-unverified/40"},{key:"insight",label:"Insight",cls:"text-insight/60 border-insight/20 hover:border-insight/40",activeCls:"text-insight bg-insight/10 border-insight/40",tooltip:"Observations without a specific file:line anchor. Not scored — cannot be confirmed or disputed by peers."}],bg=[{key:"all",label:"All",cls:"border-border/40 hover:border-border/60",activeCls:"border-border",activeStyle:{color:"var(--text)",background:"var(--surface-sunk)"},inactiveStyle:{color:"var(--text-dim)"}},{key:"critical",label:"Critical",cls:"text-bad/50 border-bad/20 hover:border-bad/40",activeCls:"text-bad bg-bad/10 border-bad/40"},{key:"high",label:"High",cls:"text-severity-high/50 border-severity-high/20 hover:border-severity-high/40",activeCls:"text-severity-high bg-severity-high/10 border-severity-high/40"},{key:"medium",label:"Medium",cls:"text-warn/50 border-warn/20 hover:border-warn/40",activeCls:"text-warn bg-warn/10 border-warn/40"},{key:"low",label:"Low",cls:"border-border/40 hover:border-border/60",activeCls:"border-border",activeStyle:{color:"var(--text-dim)",background:"color-mix(in oklch, var(--surface-sunk) 50%, transparent)"},inactiveStyle:{color:"color-mix(in oklch, var(--text-dim) 50%, transparent)"}}],jg={critical:"text-bad bg-bad/10",high:"text-severity-high bg-severity-high/10",medium:"text-warn bg-warn/10",low:""},Ng={color:"var(--text-dim)",background:"color-mix(in oklch, var(--surface-sunk) 50%, transparent)"},Sg="[&_.cite-file]:rounded [&_.cite-file]:bg-blue-500/10 [&_.cite-file]:px-1 [&_.cite-file]:font-mono [&_.cite-file]:text-blue-400 [&_.cite-fn]:rounded [&_.cite-fn]:bg-purple-500/10 [&_.cite-fn]:px-1 [&_.cite-fn]:font-mono [&_.cite-fn]:text-purple-400 [&_.inline-code]:rounded [&_.inline-code]:[background:var(--surface-sunk)] [&_.inline-code]:px-1 [&_.inline-code]:py-0.5 [&_.inline-code]:font-mono [&_.inline-code]:text-[11px] [&_.inline-code]:[color:color-mix(in_oklch,var(--text)_80%,transparent)] [&_.inline-code-block]:my-1.5 [&_.inline-code-block]:block [&_.inline-code-block]:rounded [&_.inline-code-block]:[background:color-mix(in_oklch,var(--surface-sunk)_70%,transparent)] [&_.inline-code-block]:p-2 [&_.inline-code-block]:font-mono [&_.inline-code-block]:text-[11px] [&_.inline-code-block]:[color:color-mix(in_oklch,var(--text)_70%,transparent)] [&_.inline-code-block]:overflow-x-auto",kg={HTML_ENTITY_ENCODED_TAGS:"HTML-entity-encoded <agent_finding> tags — parser saw 0 tags",HTML_ENTITY_MIXED_PAYLOAD:"Mixed raw + HTML-entity-encoded tags — some findings dropped",SCHEMA_DRIFT_PHASE2_VERDICT_TOKENS:"Schema drift — Phase-2 consensus verdict types emitted (confirmed/disputed/unique/verdict)",SCHEMA_DRIFT_INVENTED_TYPE_TOKENS:"Schema drift — invented <agent_finding> type names (valid: finding | suggestion | insight)",SCHEMA_DRIFT_NESTED_SUBTAGS:'Schema drift — nested <type>...</type> subtags instead of type="..." attribute'};function _g({f:i,reviewInfo:r,diagnostics:u}){const o=i.tag==="confirmed"?"text-confirmed bg-confirmed/10 border-confirmed/20":i.tag==="disputed"?"text-disputed bg-disputed/10 border-disputed/20":i.tag==="unverified"?"text-unverified bg-unverified/10 border-unverified/20":"text-unique bg-unique/10 border-unique/20",d=i.severity&&jg[i.severity]||"",m=i.severity==="low"?Ng:void 0,v=i.findingType==="suggestion"?"SUGGESTION":i.findingType==="insight"?"INSIGHT":null,p=i.findingType==="suggestion"?"text-info bg-info/10":i.findingType==="insight"?"text-text-dim bg-text-dim/10":"",x=i.finding.match(/<cite\s+tag="file">([^<]+)<\/cite>/),g=x?x[1]:null;return a.jsxs("div",{className:"rounded-md border border-border/40 hover:border-border/60 transition-colors px-4 py-3.5",style:{background:"color-mix(in oklch, var(--surface-elev) 30%, transparent)"},children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[a.jsx("span",{className:`shrink-0 rounded border px-2 py-1 font-mono text-[10px] font-bold ${o}`,children:i.tag.toUpperCase()}),i.severity&&a.jsx("span",{className:`shrink-0 rounded border px-2 py-1 font-mono text-[10px] font-bold ${d}`,style:m,children:i.severity.toUpperCase()}),v&&a.jsx("span",{className:`shrink-0 rounded border px-2 py-1 font-mono text-[10px] font-bold ${p}`,children:v}),g&&a.jsx("span",{className:"bg-info/10 px-2 py-1 font-mono text-[10px] text-info border border-info/15 rounded",children:g}),a.jsx("span",{className:"ml-auto font-mono text-[10px]",style:{color:"color-mix(in oklch, var(--text-dim) 40%, transparent)"},children:i.originalAgentId}),i.confirmedBy&&i.confirmedBy.length>0&&(()=>{const b=[...new Set(i.confirmedBy)];return a.jsxs("span",{className:"cursor-help rounded px-1 py-0.5 font-mono text-[10px] text-confirmed/50 transition hover:bg-confirmed/10","data-tooltip":`Verified by:
|
|
70
|
+
`})]})}function ag(){return a.jsx("div",{className:"rounded-md border p-10 text-center",style:{borderColor:"var(--border)",background:"var(--surface-elev)"},children:a.jsx("p",{className:"font-mono text-[12px]",style:{color:"var(--ink-3)"},children:"No consensus rounds yet — dispatch your first review to see the consensus flow."})})}function sg({error:i,stale:r}){return a.jsxs("div",{className:"relative rounded-md border p-5",style:{borderColor:"var(--border)",background:"var(--surface-elev)"},children:[a.jsx("div",{className:"absolute right-3 top-3",children:a.jsxs("span",{className:"rounded-sm px-1.5 py-0.5 font-mono text-[10px]",style:{background:"var(--bad-soft)",color:"var(--bad)",border:"1px solid var(--bad)"},title:i,children:["error · ",i]})}),r?a.jsx("div",{style:{opacity:.5,pointerEvents:"none"},children:a.jsx(gh,{data:r})}):a.jsx("p",{className:"py-10 text-center font-mono text-[12px]",style:{color:"var(--ink-3)"},children:"Failed to load consensus flow."})]})}function ig(){const[i,r]=k.useState(!1);return k.useEffect(()=>{if(typeof window>"u"||!window.matchMedia)return;const u=window.matchMedia("(prefers-reduced-motion: reduce)");r(u.matches);const o=d=>r(d.matches);return u.addEventListener("change",o),()=>u.removeEventListener("change",o)},[]),i}function cg({consensusId:i}){return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"mb-6",children:[a.jsxs("nav",{className:"mb-2 flex items-center gap-2 font-mono text-[11px]",style:{color:"var(--ink-3)"},"aria-label":"Breadcrumb",children:[a.jsx("a",{href:vn("/"),className:"hover:underline",style:{color:"var(--ink-3)"},children:"Overview"}),a.jsx("span",{"aria-hidden":"true",children:"›"}),a.jsx("span",{style:{color:"var(--ink)"},children:i})]}),a.jsx("h1",{className:"h-route",children:"Consensus flow"}),a.jsx("p",{className:"mt-0.5 font-mono text-[10px]",style:{color:"var(--ink-3)"},children:"Model families on the left, findings reviewed in the middle, verdicts on the right."})]}),a.jsx(Iv,{consensusId:i})]})}function rg({onLogin:i,error:r}){const[u,o]=k.useState(""),[d,m]=k.useState(!1),v=async x=>{if(x.preventDefault(),!(!u.trim()||d)){m(!0);try{await i(u.trim())}finally{m(!1)}}},p=r==="bad_key"?"Invalid key. Check your terminal for the correct key.":r==="network"?"Connection error — relay may be offline.":null;return a.jsx("div",{className:"min-h-screen flex items-center justify-center",style:{background:"var(--surface)"},children:a.jsxs("div",{className:"w-full max-w-sm rounded-xl border [border-color:var(--border)] p-8 text-center",style:{background:"var(--surface-elev)"},children:[a.jsx("div",{className:"crt-logo mx-auto mb-4",style:{width:"fit-content"},children:a.jsx("img",{src:"/dashboard/assets/gossip-mini.png",alt:"gossipcat",className:"crt-logo-img h-56 w-56 object-contain",style:{filter:"drop-shadow(0 0 28px var(--accent))"}})}),a.jsx("p",{className:"h-route mb-1",style:{letterSpacing:"-0.02em",textShadow:"0 0 24px var(--accent)"},children:"Gossipcat"}),a.jsx("p",{className:"mb-6 text-[13px]",style:{color:"var(--ink-3)"},children:"Authenticate to access the dashboard"}),a.jsxs("form",{onSubmit:v,children:[a.jsx("input",{type:"password",value:u,onChange:x=>o(x.target.value),placeholder:"Dashboard key",autoFocus:!0,disabled:d,className:"w-full rounded-lg border [border-color:var(--border)] px-4 py-3 font-mono text-sm outline-none focus:[border-color:var(--ink-3)] focus:ring-2 focus:[--tw-ring-color:color-mix(in_oklch,var(--ink-3)_20%,transparent)] disabled:opacity-50",style:{background:"var(--surface)",color:"var(--ink)"}}),a.jsx("button",{type:"submit",disabled:d,className:"mt-4 w-full rounded-lg px-4 py-3 text-sm font-semibold transition hover:opacity-90 disabled:opacity-60",style:{background:"var(--accent)",color:"#fff"},children:d?"Unlocking…":"Unlock"})]}),p&&a.jsx("p",{className:"mt-3 text-sm",style:{color:"var(--bad)"},children:p})]})})}const yh="dashboard:theme",og=["light","dark"];function ug(i){return i==="light"||i==="dark"?i:i==="editorial"?"light":i==="default"?"dark":null}function dg(i,r){const u=ug(i);return u!==null?u:r?"dark":"light"}function fg(){return typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(prefers-color-scheme: dark)").matches}function mg(){if(typeof window>"u")return"light";let i=null;try{i=window.localStorage.getItem(yh)}catch{}return dg(i,fg())}function hg(){const[i,r]=k.useState(mg);k.useEffect(()=>{typeof document>"u"||(i==="light"?delete document.documentElement.dataset.theme:document.documentElement.dataset.theme=i)},[i]);function u(d){if(og.includes(d)&&(r(d),typeof window<"u"))try{window.localStorage.setItem(yh,d)}catch{}}return{theme:i,setTheme:u,toggle:()=>{u(i==="light"?"dark":"light")}}}const xg=[{term:"Consensus Round",definition:"A structured multi-agent review session. Each agent independently reviews the target code or output, then all agents cross-review each other's findings. The result is a set of findings tagged by how many agents agreed. The /debates URL in the dashboard lists all past consensus rounds.",seeAlso:"Finding, Signal"},{term:"Finding",definition:"A verifiable claim about a specific line of code, always cited with a file path and line number. Agents emit findings during a consensus round. A finding that cannot be located in the code is a hallucination.",seeAlso:"Insight, Hallucination"},{term:"Insight",definition:"An observation that does not point to a specific code location. Insights are informational — they cannot be confirmed or disputed by other agents and are excluded from accuracy scoring.",seeAlso:"Finding"},{term:"Signal",definition:"A scored event recorded against an agent, such as agreement, hallucination_caught, or unique_confirmed. Each signal adjusts the agent's accuracy and dispatch weight over time. Signals are the primary feedback mechanism that drives agent improvement.",seeAlso:"Accuracy (Adjusted), Dispatch Weight"},{term:"Hallucination",definition:"A fabricated finding: the cited file and line exist, but the code does not support the claim the agent made. Caught during cross-review by a peer agent. Each hallucination lowers the emitting agent's accuracy score.",seeAlso:"Finding, Signal"},{term:"Confirmed / Disputed / Unverified / Unique",definition:"The four statuses assigned to a finding after cross-review. Confirmed = two or more agents independently verified it. Disputed = at least one agent found contradictory evidence. Unverified = peer agents could not check it (no code anchor, out of scope). Unique = only one agent surfaced it; not yet confirmed or denied.",seeAlso:"Consensus Round"},{term:"Dispatch Weight",definition:"How likely an agent is to be selected for the next task. Ranges from 0.3 (rarely dispatched) to 2.0 (strongly preferred). Updated after every task based on accuracy and uniqueness signals. Visible on the Team page.",seeAlso:"Accuracy (Adjusted), Uniqueness"},{term:"Accuracy (Adjusted)",definition:"The fraction of an agent's findings that survived cross-review, with a penalty applied for hallucinations. Category Competency on the agent page shows the raw per-category ratio without the penalty; the Metrics section shows the penalized aggregate used for dispatch decisions.",seeAlso:"Hallucination, Dispatch Weight"},{term:"Uniqueness",definition:"How often this agent surfaces findings that no other agent in the same round found. High uniqueness with low accuracy is a useful combination: always include such agents in a consensus round, but never send them solo.",seeAlso:"Accuracy (Adjusted), Consensus Round"},{term:"Reliability",definition:"Task completion rate — the fraction of dispatched tasks that finished without a pipeline error or timeout. Distinct from accuracy, which measures finding correctness.",seeAlso:"Accuracy (Adjusted)"},{term:"Impact",definition:"A severity-weighted score for an agent's findings. Critical and high findings contribute more than medium or low ones. Impact reflects not just how many findings an agent produces, but how serious those findings tend to be.",seeAlso:"Finding"},{term:"Benched / Struggling / Kept for coverage",definition:"Circuit-breaker states that limit dispatch when an agent underperforms. Benched = fully excluded from dispatch (chronic = sustained low accuracy; burst = recent failure streak). Struggling = consecutive failures tripped the breaker; agent is deprioritized until it recovers. Kept for coverage = the agent would be benched, but it is the only agent with a required skill category, so it stays in the pool.",seeAlso:"Dispatch Weight, Skill"},{term:"Skill",definition:"A markdown file injected into an agent's prompt for a specific task category (e.g. input_validation, trust_boundaries). Skills are generated from an agent's actual failure history and override generic defaults. A skill graduates from pending to passed or failed after 120 post-bind signals.",seeAlso:"bound_at"},{term:"bound_at",definition:"The timestamp when a skill was attached to an agent. This anchors the effectiveness window: only signals recorded after bound_at count toward the skill's graduation verdict.",seeAlso:"Skill"},{term:"Invalid Output Types",definition:"Agent finding tags with a type= attribute outside the allowed set (finding, suggestion, insight). The pipeline silently rejects these — they never reach the consensus round or the dashboard. The count is tracked so skill development can address systematic format drift.",seeAlso:"Finding"},{term:"Process Violation",definition:"A guardrail breach detected outside normal code review. Examples: an agent pushed a commit directly to master bypassing the PR process, or an agent wrote to a file outside its declared scope. Process violations are logged separately from code findings."}],pg={background:"var(--surface-elev)",borderRadius:"16px",boxShadow:"var(--shadow-overlay)",border:"1px solid var(--border)",color:"var(--text)",fontFamily:"var(--font-sans)"};function vg({open:i,onClose:r}){const u=k.useRef(null);return k.useEffect(()=>{if(!i)return;const o=requestAnimationFrame(()=>{var m;(m=u.current)==null||m.focus()}),d=m=>{m.key==="Escape"&&r()};return document.addEventListener("keydown",d),document.body.style.overflow="hidden",()=>{cancelAnimationFrame(o),document.removeEventListener("keydown",d),document.body.style.overflow=""}},[i,r]),i?a.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-6 backdrop-blur-sm",style:{background:"color-mix(in oklch, var(--surface) 80%, transparent)"},onClick:r,role:"presentation",children:a.jsxs("div",{className:"relative flex max-h-[calc(100vh-48px)] w-full max-w-2xl flex-col overflow-hidden",style:pg,role:"dialog","aria-modal":"true","aria-labelledby":"glossary-title",onClick:o=>o.stopPropagation(),children:[a.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-border/60 px-5 py-3.5",children:[a.jsx("h2",{id:"glossary-title",className:"font-mono text-sm font-semibold",style:{color:"var(--text)"},children:"Gossipcat Glossary"}),a.jsx("button",{ref:u,onClick:r,"aria-label":"Close glossary",className:"flex min-h-[44px] min-w-[44px] shrink-0 items-center justify-center rounded border border-border/40 font-mono text-xs transition hover:[color:var(--text)] hover:[background:var(--surface-sunk)]",style:{background:"var(--surface-elev)",color:"var(--text-dim)"},children:"×"})]}),a.jsx("div",{className:"flex-1 overflow-y-auto px-5 py-4",children:a.jsx("dl",{className:"space-y-5",children:xg.map(({term:o,definition:d,seeAlso:m})=>a.jsxs("div",{className:"rounded-md border border-border/40 px-4 py-3",style:{background:"color-mix(in oklch, var(--surface) 40%, transparent)"},children:[a.jsx("dt",{className:"h-section",children:o}),a.jsx("dd",{className:"mt-1.5 font-mono text-xs leading-relaxed",style:{color:"color-mix(in oklch, var(--text) 80%, transparent)"},children:d}),m&&a.jsxs("dd",{className:"mt-1.5 font-mono text-[10px]",style:{color:"color-mix(in oklch, var(--text-dim) 60%, transparent)"},children:["See also: ",m]})]},o))})}),a.jsx("div",{className:"shrink-0 border-t border-border/60 px-5 py-3",children:a.jsx("a",{href:"https://github.com/gossipcat-ai/gossipcat-ai/blob/master/docs/HANDBOOK.md",target:"_blank",rel:"noopener noreferrer",className:"font-mono text-xs transition hover:underline",style:{color:"var(--accent)"},children:"Read the full HANDBOOK →"})})]})}):null}const gg=[{to:"/",label:"Dashboard",match:i=>i==="/"||i==="/overview"},{to:"/team",label:"Team",match:i=>i==="/team"||i.startsWith("/agent/")},{to:"/debates",label:"Consensus Rounds",match:i=>i==="/debates"},{to:"/tasks",label:"Tasks",match:i=>i==="/tasks"},{to:"/signals",label:"Signals",match:i=>i==="/signals"},{to:"/logs",label:"Logs",match:i=>i==="/logs"}];function Im(){const[i,r]=k.useState(!1),u=rh(),{theme:o,toggle:d}=hg();return a.jsxs("nav",{className:"relative flex items-center justify-between border-b border-border px-6 py-3.5",children:[a.jsxs("div",{className:"flex items-center gap-6",children:[a.jsxs("a",{href:vn("/"),className:"flex items-center gap-3 leading-none",children:[a.jsx("img",{src:"/dashboard/assets/gossip-mini.png",alt:"",className:"h-10 w-10 object-contain"}),a.jsx("span",{className:"text-[17px] font-bold",style:{color:"var(--accent)"},children:"gossipcat"})]}),a.jsx("div",{className:"flex gap-1",children:gg.map(m=>{const v=m.match(u);return a.jsx("a",{href:vn(m.to),className:`rounded-md px-3.5 py-1.5 font-mono text-[13px] transition ${v?"font-semibold":"hover:bg-accent/10"}`,style:v?{background:"color-mix(in oklch, var(--accent) 10%, transparent)",color:"var(--accent)"}:{color:"var(--ink-3)"},children:m.label},m.to)})})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{"aria-hidden":"true",title:"Search — coming soon",style:{display:"inline-flex",alignItems:"center",gap:"8px",height:"32px",padding:"0 12px",minWidth:"220px",background:"var(--surface-elev)",border:"1px solid var(--border)",borderRadius:"8px",color:"var(--ink-3)",fontFamily:"var(--font-sans)",fontSize:"13px",cursor:"default"},children:[a.jsx("span",{style:{opacity:.7},children:"Search…"}),a.jsx("kbd",{style:{marginLeft:"auto",padding:"1px 6px",borderRadius:"4px",background:"var(--surface-sunk)",border:"1px solid var(--border)",fontFamily:"var(--font-mono)",fontSize:"11px",color:"var(--ink-3)"},children:"⌘K"})]}),a.jsx("button",{type:"button",onClick:d,title:`Switch to ${o==="light"?"dark":"light"} theme`,"aria-label":`Switch to ${o==="light"?"dark":"light"} theme`,style:{width:"32px",height:"32px",display:"inline-flex",alignItems:"center",justifyContent:"center",background:"var(--surface-elev)",border:"1px solid var(--border)",borderRadius:"8px",color:"var(--ink)",cursor:"pointer",fontSize:"16px",lineHeight:1},children:o==="light"?"◐":"◑"}),a.jsx("button",{type:"button",onClick:()=>r(!0),"aria-label":"Open glossary",title:"Glossary",style:{width:"32px",height:"32px",display:"inline-flex",alignItems:"center",justifyContent:"center",background:"var(--surface-elev)",border:"1px solid var(--border)",borderRadius:"8px",color:"var(--ink)",cursor:"pointer",lineHeight:1},children:a.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[a.jsx("path",{d:"M4 19.5A2.5 2.5 0 0 1 6.5 17H20"}),a.jsx("path",{d:"M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z"})]})})]}),a.jsx(vg,{open:i,onClose:()=>r(!1)})]})}const yg={completed:{label:"COMPLETED",cls:"text-confirmed bg-confirmed/10"},failed:{label:"FAILED",cls:"text-destructive bg-destructive/10"},cancelled:{label:"CANCELLED",cls:"",clsStyle:{color:"var(--text-dim)",background:"color-mix(in oklch, var(--surface-sunk) 30%, transparent)"}},running:{label:"RUNNING",cls:"text-unverified bg-unverified/10 animate-pulse"}};function bh({task:i,onClose:r}){if(k.useEffect(()=>{if(!i)return;const d=m=>{m.key==="Escape"&&r()};return document.addEventListener("keydown",d),document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",d),document.body.style.overflow=""}},[i,r]),!i)return null;const u=yg[i.status],o=(i.inputTokens||0)+(i.outputTokens||0);return a.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center overflow-y-auto p-6 backdrop-blur-sm",style:{background:"color-mix(in oklch, var(--surface) 80%, transparent)"},onClick:r,children:a.jsxs("div",{className:"relative mt-12 w-full max-w-3xl rounded-lg border border-border",style:{background:"var(--surface-elev)",boxShadow:"var(--shadow-overlay)"},onClick:d=>d.stopPropagation(),children:[a.jsxs("div",{className:"flex items-start justify-between gap-4 border-b border-border/60 px-5 py-4",children:[a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:`shrink-0 rounded-sm px-1.5 py-0.5 font-mono text-[9px] font-bold ${u.cls}`,style:u.clsStyle,children:u.label}),a.jsx("span",{className:"warn-badge shrink-0 rounded px-1.5 py-0.5 font-mono text-[10px] font-semibold",children:i.taskId.slice(0,8)}),a.jsx("a",{href:`/dashboard/agent/${encodeURIComponent(i.agentId)}`,className:"truncate font-mono text-xs transition",style:{color:"var(--text-dim)"},children:i.agentId})]}),a.jsxs("div",{className:"mt-2 flex flex-wrap gap-3 font-mono text-[10px]",style:{color:"var(--text-dim)"},children:[a.jsx("span",{children:We(i.timestamp)}),i.duration!=null&&a.jsxs("span",{children:["· ",n0(i.duration)]}),o>0&&a.jsxs("span",{children:["· ",o.toLocaleString()," tokens (",(i.inputTokens||0).toLocaleString()," in / ",(i.outputTokens||0).toLocaleString()," out)"]})]})]}),a.jsx("button",{onClick:r,className:"shrink-0 rounded-md border border-border/40 px-2 py-1 font-mono text-xs transition hover:bg-accent/10",style:{background:"var(--surface-elev)",color:"var(--text-dim)"},"aria-label":"Close",children:"✕"})]}),a.jsxs("div",{className:"max-h-[calc(100vh-220px)] space-y-5 overflow-y-auto px-5 py-4",children:[a.jsxs("section",{children:[a.jsx("h3",{className:"mb-2 h-section",children:"Task"}),a.jsx("div",{className:"task-md rounded-md border border-border/40 p-3 text-xs leading-relaxed overflow-x-auto",style:{background:"color-mix(in oklch, var(--surface) 40%, transparent)",color:"color-mix(in oklch, var(--text) 90%, transparent)"},dangerouslySetInnerHTML:{__html:t0(i.task)}})]}),i.result?a.jsxs("section",{children:[a.jsx("h3",{className:"mb-2 h-section",children:"Result"}),a.jsx("div",{className:"finding-md rounded-md border border-border/40 p-3 font-mono text-xs leading-relaxed whitespace-pre-wrap [&_.cite-file]:rounded [&_.cite-file]:bg-[color-mix(in_oklch,var(--cite-file)_10%,transparent)] [&_.cite-file]:px-1 [&_.cite-file]:text-[var(--cite-file)] [&_.cite-fn]:rounded [&_.cite-fn]:bg-[color-mix(in_oklch,var(--cite-fn)_10%,transparent)] [&_.cite-fn]:px-1 [&_.cite-fn]:text-[var(--cite-fn)] [&_.inline-code]:rounded [&_.inline-code]:bg-[color-mix(in_oklch,var(--surface-sunk)_40%,transparent)] [&_.inline-code]:px-1 [&_.inline-code-block]:my-2 [&_.inline-code-block]:block [&_.inline-code-block]:rounded [&_.inline-code-block]:bg-[color-mix(in_oklch,var(--surface-sunk)_30%,transparent)] [&_.inline-code-block]:p-2",style:{background:"color-mix(in oklch, var(--surface) 40%, transparent)",color:"color-mix(in oklch, var(--text) 90%, transparent)"},dangerouslySetInnerHTML:{__html:Oi(i.result)}})]}):a.jsxs("section",{children:[a.jsx("h3",{className:"mb-2 h-section",children:"Result"}),a.jsx("div",{className:"rounded-md border border-border/40 p-3 text-center font-mono text-xs",style:{background:"color-mix(in oklch, var(--surface) 40%, transparent)",color:"var(--text-dim)"},children:i.status==="running"?"Task is still running...":"No result recorded."})]})]})]})})}function No(i){return i.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const oo=5,uo={agreement:{label:"CONFIRMED",filter:"confirmed",cls:"text-confirmed bg-confirmed/10"},consensus_verified:{label:"CONFIRMED",filter:"confirmed",cls:"text-confirmed bg-confirmed/10"},disagreement:{label:"DISPUTED",filter:"disputed",cls:"text-disputed bg-disputed/10"},hallucination_caught:{label:"DISPUTED",filter:"disputed",cls:"text-disputed bg-disputed/10"},unverified:{label:"UNVERIFIED",filter:"unverified",cls:"text-unverified bg-unverified/10"},unique_confirmed:{label:"UNIQUE",filter:"unique",cls:"text-unique bg-unique/10"},unique_unconfirmed:{label:"UNIQUE?",filter:"unique",cls:"text-unverified bg-unverified/10"},new_finding:{label:"NEW",filter:"unique",cls:"text-unique bg-unique/10"}},Wm=[{key:"all",label:"All",cls:"border-border/40 hover:border-border/60",activeCls:"border-border",activeStyle:{color:"var(--text)",background:"var(--surface-sunk)"},inactiveStyle:{color:"var(--text-dim)"}},{key:"confirmed",label:"Confirmed",cls:"text-confirmed/50 border-confirmed/20 hover:border-confirmed/40",activeCls:"text-confirmed bg-confirmed/10 border-confirmed/40"},{key:"unique",label:"Unique",cls:"text-unique/50 border-unique/20 hover:border-unique/40",activeCls:"text-unique bg-unique/10 border-unique/40"},{key:"disputed",label:"Disputed",cls:"text-disputed/50 border-disputed/20 hover:border-disputed/40",activeCls:"text-disputed bg-disputed/10 border-disputed/40"},{key:"unverified",label:"Unverified",cls:"text-unverified/50 border-unverified/20 hover:border-unverified/40",activeCls:"text-unverified bg-unverified/10 border-unverified/40"},{key:"insight",label:"Insight",cls:"text-insight/60 border-insight/20 hover:border-insight/40",activeCls:"text-insight bg-insight/10 border-insight/40",tooltip:"Observations without a specific file:line anchor. Not scored — cannot be confirmed or disputed by peers."}],bg=[{key:"all",label:"All",cls:"border-border/40 hover:border-border/60",activeCls:"border-border",activeStyle:{color:"var(--text)",background:"var(--surface-sunk)"},inactiveStyle:{color:"var(--text-dim)"}},{key:"critical",label:"Critical",cls:"text-bad/50 border-bad/20 hover:border-bad/40",activeCls:"text-bad bg-bad/10 border-bad/40"},{key:"high",label:"High",cls:"text-severity-high/50 border-severity-high/20 hover:border-severity-high/40",activeCls:"text-severity-high bg-severity-high/10 border-severity-high/40"},{key:"medium",label:"Medium",cls:"text-warn/50 border-warn/20 hover:border-warn/40",activeCls:"text-warn bg-warn/10 border-warn/40"},{key:"low",label:"Low",cls:"border-border/40 hover:border-border/60",activeCls:"border-border",activeStyle:{color:"var(--text-dim)",background:"color-mix(in oklch, var(--surface-sunk) 50%, transparent)"},inactiveStyle:{color:"color-mix(in oklch, var(--text-dim) 50%, transparent)"}}],jg={critical:"text-bad bg-bad/10",high:"text-severity-high bg-severity-high/10",medium:"text-warn bg-warn/10",low:""},Ng={color:"var(--text-dim)",background:"color-mix(in oklch, var(--surface-sunk) 50%, transparent)"},Sg="[&_.cite-file]:rounded [&_.cite-file]:bg-[color-mix(in_oklch,var(--cite-file)_10%,transparent)] [&_.cite-file]:px-1 [&_.cite-file]:font-mono [&_.cite-file]:text-[var(--cite-file)] [&_.cite-fn]:rounded [&_.cite-fn]:bg-[color-mix(in_oklch,var(--cite-fn)_10%,transparent)] [&_.cite-fn]:px-1 [&_.cite-fn]:font-mono [&_.cite-fn]:text-[var(--cite-fn)] [&_.inline-code]:rounded [&_.inline-code]:[background:var(--surface-sunk)] [&_.inline-code]:px-1 [&_.inline-code]:py-0.5 [&_.inline-code]:font-mono [&_.inline-code]:text-[11px] [&_.inline-code]:[color:color-mix(in_oklch,var(--text)_80%,transparent)] [&_.inline-code-block]:my-1.5 [&_.inline-code-block]:block [&_.inline-code-block]:rounded [&_.inline-code-block]:[background:color-mix(in_oklch,var(--surface-sunk)_70%,transparent)] [&_.inline-code-block]:p-2 [&_.inline-code-block]:font-mono [&_.inline-code-block]:text-[11px] [&_.inline-code-block]:[color:color-mix(in_oklch,var(--text)_70%,transparent)] [&_.inline-code-block]:overflow-x-auto",kg={HTML_ENTITY_ENCODED_TAGS:"HTML-entity-encoded <agent_finding> tags — parser saw 0 tags",HTML_ENTITY_MIXED_PAYLOAD:"Mixed raw + HTML-entity-encoded tags — some findings dropped",SCHEMA_DRIFT_PHASE2_VERDICT_TOKENS:"Schema drift — Phase-2 consensus verdict types emitted (confirmed/disputed/unique/verdict)",SCHEMA_DRIFT_INVENTED_TYPE_TOKENS:"Schema drift — invented <agent_finding> type names (valid: finding | suggestion | insight)",SCHEMA_DRIFT_NESTED_SUBTAGS:'Schema drift — nested <type>...</type> subtags instead of type="..." attribute'};function _g({f:i,reviewInfo:r,diagnostics:u}){const o=i.tag==="confirmed"?"text-confirmed bg-confirmed/10 border-confirmed/20":i.tag==="disputed"?"text-disputed bg-disputed/10 border-disputed/20":i.tag==="unverified"?"text-unverified bg-unverified/10 border-unverified/20":"text-unique bg-unique/10 border-unique/20",d=i.severity&&jg[i.severity]||"",m=i.severity==="low"?Ng:void 0,v=i.findingType==="suggestion"?"SUGGESTION":i.findingType==="insight"?"INSIGHT":null,p=i.findingType==="suggestion"?"text-info bg-info/10":i.findingType==="insight"?"text-text-dim bg-text-dim/10":"",x=i.finding.match(/<cite\s+tag="file">([^<]+)<\/cite>/),g=x?x[1]:null;return a.jsxs("div",{className:"rounded-md border border-border/40 hover:border-border/60 transition-colors px-4 py-3.5",style:{background:"color-mix(in oklch, var(--surface-elev) 30%, transparent)"},children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[a.jsx("span",{className:`shrink-0 rounded border px-2 py-1 font-mono text-[10px] font-bold ${o}`,children:i.tag.toUpperCase()}),i.severity&&a.jsx("span",{className:`shrink-0 rounded border px-2 py-1 font-mono text-[10px] font-bold ${d}`,style:m,children:i.severity.toUpperCase()}),v&&a.jsx("span",{className:`shrink-0 rounded border px-2 py-1 font-mono text-[10px] font-bold ${p}`,children:v}),g&&a.jsx("span",{className:"bg-info/10 px-2 py-1 font-mono text-[10px] text-info border border-info/15 rounded",children:g}),a.jsx("span",{className:"ml-auto font-mono text-[10px]",style:{color:"color-mix(in oklch, var(--text-dim) 40%, transparent)"},children:i.originalAgentId}),i.confirmedBy&&i.confirmedBy.length>0&&(()=>{const b=[...new Set(i.confirmedBy)];return a.jsxs("span",{className:"cursor-help rounded px-1 py-0.5 font-mono text-[10px] text-confirmed/50 transition hover:bg-confirmed/10","data-tooltip":`Verified by:
|
|
71
71
|
${b.join(", ")}`,"data-tooltip-pos":"left",children:["+",b.length," ✓"]})})(),i.disputedBy&&i.disputedBy.length>0&&a.jsxs("span",{className:"cursor-help rounded px-1 py-0.5 font-mono text-[10px] text-disputed/50 transition hover:bg-disputed/10","data-tooltip":`Disputed by:
|
|
72
72
|
${i.disputedBy.map(b=>b.agentId).join(", ")}`,"data-tooltip-pos":"left",children:[i.disputedBy.length," ⚡"]}),i.unverifiedBy&&i.unverifiedBy.length>0&&a.jsxs("span",{className:"cursor-help rounded px-1 py-0.5 font-mono text-[10px] text-unverified/50 transition hover:bg-unverified/10","data-tooltip":`Unverified by:
|
|
73
73
|
${i.unverifiedBy.map(b=>b.agentId).join(", ")}`,"data-tooltip-pos":"left",children:[i.unverifiedBy.length," ◇"]})]}),u&&u.length>0&&a.jsx("div",{className:"mt-1.5 mb-1 space-y-1",children:u.map((b,S)=>a.jsxs("div",{className:"rounded border border-unverified/20 bg-unverified/5 px-2.5 py-1.5","data-diagnostic-code":b.code,children:[a.jsxs("div",{className:"font-mono text-[10px] font-bold uppercase tracking-wider text-unverified/80",children:["⚠ ",b.code]}),a.jsx("div",{className:"mt-0.5 text-[11px]",style:{color:"color-mix(in oklch, var(--text-dim) 80%, transparent)"},dangerouslySetInnerHTML:{__html:No(kg[b.code])+" — "+No(b.message)}})]},S))}),i.disputedBy&&i.disputedBy.length>0&&a.jsx("div",{className:"mt-1.5 mb-1 rounded border border-disputed/10 bg-disputed/5 px-2.5 py-1.5",children:i.disputedBy.map((b,S)=>a.jsxs("div",{className:"text-[11px]",children:[a.jsx("span",{className:"font-mono font-bold text-disputed/70",children:b.agentId}),a.jsxs("span",{style:{color:"color-mix(in oklch, var(--text-dim) 60%, transparent)"},children:[" — ",b.reason||b.evidence||"No reason given"]})]},S))}),a.jsx("div",{className:`finding-md font-inter text-xs leading-relaxed ${Sg}`,style:{color:"var(--text-dim)"},dangerouslySetInnerHTML:{__html:Oi(i.finding)}}),r&&a.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5",children:[r.reviewers.map(b=>a.jsx("span",{title:b,className:"inline-flex h-5 w-5 items-center justify-center rounded-full font-mono text-[8px] font-bold text-background opacity-70",style:{backgroundColor:gn(b)},children:ho(b)},b)),a.jsxs("span",{className:`rounded px-1.5 py-0.5 font-mono text-[9px] font-bold ${r.assigned>=r.targetK?"text-confirmed/70 bg-confirmed/5":"text-unverified/70 bg-unverified/5"}`,children:[r.assigned>=r.targetK?"✓":"⚠"," ",r.assigned,"/",r.targetK]})]})]})}function Eg({consensus:i,reports:r,showAll:u=!1,hideHeader:o=!1,filteredRuns:d}){const m=d??i.runs,v=u?m:m.slice(0,oo);!u&&m.length>oo;const[p,x]=k.useState(null),[g,b]=k.useState("all"),[S,O]=k.useState("all"),[Q,L]=k.useState(1),[X,M]=k.useState([]),[I,K]=k.useState(0),[ee,J]=k.useState(!1),[A,q]=k.useState({});k.useEffect(()=>{if(!u&&(r!=null&&r.reports)&&(M(r.reports),K(r.totalReports??r.reports.length),L(1)),r!=null&&r.roundRetractions){const E={};for(const T of r.roundRetractions)E[T.consensus_id]={reason:T.reason,retracted_at:T.retracted_at};q(E)}},[r,u]),k.useEffect(()=>{if(!u)return;let E=!1;return(async()=>{var T;try{const H=await Ge("consensus-reports?page=1&pageSize=200");if(E)return;if(M(H.reports||[]),K(H.totalReports??(((T=H.reports)==null?void 0:T.length)||0)),L(1),H.roundRetractions){const W={};for(const ce of H.roundRetractions)W[ce.consensus_id]={reason:ce.reason,retracted_at:ce.retracted_at};q(W)}}catch{}})(),()=>{E=!0}},[u]);const w=X.slice().sort((E,T)=>T.timestamp.localeCompare(E.timestamp)),Z=10,[te,ne]=k.useState(0),de=Math.max(1,Math.ceil(w.length/Z)),F=Math.min(te,de-1),ae=u?w.slice(F*Z,(F+1)*Z):w.slice(0,oo),me=E=>{const T=new Date,H=new Date(E),W=ue=>new Date(ue.getFullYear(),ue.getMonth(),ue.getDate()).getTime(),ce=Math.round((W(T)-W(H))/864e5);return ce<=0?"Today":ce===1?"Yesterday":ce<7?`${ce} days ago`:ce<30?`${Math.floor(ce/7)} weeks ago`:H.toISOString().slice(0,10)};return a.jsxs("section",{children:[!o&&a.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[a.jsxs("h2",{className:"h-section",children:["Consensus Rounds ",a.jsx("span",{style:{color:"var(--ink)",fontWeight:700},children:i.totalRuns??i.runs.length})]}),!u&&a.jsx("a",{href:"/dashboard/debates",className:"font-mono text-xs transition",style:{color:"var(--text-dim)"},children:"view all"})]}),ae.length>0?a.jsxs("div",{className:"space-y-2",children:[ae.map((E,T)=>{const H=T>0?ae[T-1]:null,W=u?me(E.timestamp):null,ce=u&&H?me(H.timestamp):null,ue=u&&W!==ce,y={};if(E.crossReviewAssignments||E.crossReviewCoverage){const P={};if(E.crossReviewAssignments)for(const[we,Ve]of Object.entries(E.crossReviewAssignments))for(const Fe of Ve)(P[Fe]??(P[Fe]=[])).push(we);if(E.crossReviewCoverage)for(const we of E.crossReviewCoverage)y[we.findingId]={reviewers:P[we.findingId]||[],assigned:we.assigned,targetK:we.targetK};else for(const[we,Ve]of Object.entries(P))y[we]={reviewers:Ve,assigned:Ve.length,targetK:Ve.length}}const R=[...E.confirmed,...E.disputed,...E.unverified,...E.unique,...E.insights||[]],V=g==="all"?R:g==="insight"?R.filter(P=>P.findingType==="insight"||P.findingType==="suggestion"):R.filter(P=>P.tag===g),G=S==="all"?V:V.filter(P=>P.severity===S),le=p===E.id,re=(()=>{const P=new Set;return we=>{var Bt;const Ve=(Bt=E.authorDiagnostics)==null?void 0:Bt[we.originalAgentId];if(!Ve||Ve.length===0)return;const Fe=Ve.filter(Le=>{const Jn=`${we.originalAgentId}:${Le.code}`;return P.has(Jn)?!1:(P.add(Jn),!0)});return Fe.length>0?Fe:void 0}})(),ve=R.length||1,Re=E.confirmed.length,Me=E.disputed.length,qt=E.unverified.length,Ae=E.unique.length,yn=(E.insights||[]).length,Zn=(()=>{if(ve===0)return"border-l-border/40";const P=Re/ve,we=Me/ve;return P>=.5?"border-l-confirmed/60":we>=.4?"border-l-disputed/60":"border-l-unverified/50"})(),Lt=[{count:Re,textCls:"text-confirmed",label:"confirmed"},{count:Me,textCls:"text-disputed",label:"disputed"},{count:qt,textCls:"text-unverified",label:"unverified"},{count:Ae,textCls:"text-unique",label:"unique"},{count:yn,textCls:"text-zinc-400",label:"insights"}].filter(P=>P.count>0),Yt=[...new Set(R.map(P=>P.originalAgentId).filter(Boolean))],jl=Yt.slice(0,5),Kn=A[E.id],Nl=!!Kn;return a.jsxs("div",{children:[ue&&a.jsxs("div",{className:`mb-2 flex items-center gap-3 ${T>0?"mt-4":""}`,children:[a.jsx("span",{className:"h-section",children:W}),a.jsx("div",{className:"h-px flex-1 bg-border/30"})]}),a.jsxs("div",{className:`group rounded-md border-l-2 border border-border/40 transition-all duration-150
|
|
74
74
|
${Zn}
|
|
75
75
|
${Nl?"opacity-60 line-through decoration-disputed/40":""}
|
|
76
|
-
${le?"border-r-border/60 border-t-border/60 border-b-border/60":"hover:border-r-border/60 hover:border-t-border/60 hover:border-b-border/60 hover:-translate-y-px"}`,style:{background:le?"var(--surface-elev)":"color-mix(in oklch, var(--surface-elev) 50%, transparent)"},"data-retracted":Nl?"true":void 0,children:[Nl&&a.jsxs("div",{className:"no-underline rounded-t-md border-b border-disputed/30 bg-disputed/10 px-3 py-2 font-mono text-[11px] text-disputed",style:{textDecoration:"none"},children:[a.jsx("span",{className:"font-bold",children:"⚠ RETRACTED"}),Kn.retracted_at&&a.jsxs("span",{className:"ml-2 text-disputed/70",children:["on ",Kn.retracted_at.slice(0,10)]}),Kn.reason&&a.jsxs("span",{className:"ml-2",style:{color:"color-mix(in oklch, var(--text-dim) 80%, transparent)"},children:["— ",Kn.reason]})]}),a.jsxs("button",{className:"flex w-full items-start gap-3 px-3 py-2.5 text-left","aria-expanded":le,onClick:()=>{const P=!le;x(P?E.id:null),P&&(b("all"),O("all"))},children:[a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"font-mono text-sm font-bold",style:{color:"var(--text)"},children:R.length}),a.jsx("span",{className:"text-[11px]",style:{color:"color-mix(in oklch, var(--text-dim) 70%, transparent)"},children:"findings"}),a.jsx("span",{className:"text-[10px]",style:{color:"color-mix(in oklch, var(--text-dim) 30%, transparent)"},children:"·"}),a.jsxs("span",{className:"text-[11px]",style:{color:"color-mix(in oklch, var(--text-dim) 60%, transparent)"},children:[E.rounds,"r"]}),jl.length>0&&a.jsxs("div",{className:"flex items-center gap-1 ml-1",children:[jl.map(P=>a.jsx("span",{title:P,className:"inline-flex h-4 w-4 items-center justify-center rounded-full font-mono text-[8px] font-bold",style:{color:"var(--surface)",backgroundColor:gn(P)},children:ho(P)},P)),Yt.length>5&&a.jsxs("span",{className:"font-mono text-[9px]",style:{color:"color-mix(in oklch, var(--text-dim) 40%, transparent)"},children:["+",Yt.length-5]})]}),a.jsx("span",{className:"shrink-0 rounded border border-border/30 px-1.5 py-0.5 font-mono text-[10px] font-semibold",style:{background:"color-mix(in oklch, var(--surface-sunk) 40%, transparent)",color:"var(--text-dim)"},title:E.id,children:E.id.slice(0,8)}),E.zeroTagAgents&&E.zeroTagAgents.length>0&&(()=>{const P=E.zeroTagAgents,we=E.zeroTagOverflow??0,Ve=P.length+we,Fe=we>0?`${P.join(", ")} (+${we} more)`:P.join(", ");return a.jsxs("span",{className:"shrink-0 rounded border border-unverified/20 bg-unverified/5 px-1.5 py-0.5 font-mono text-[10px] font-semibold text-unverified",title:`Zero-tag agents — emitted no parseable <agent_finding> tags (likely paraphrased relay or HTML-entity encoding). See HANDBOOK invariant #12. Agents: ${Fe}`,children:[Ve," zero-tag"]})})(),E.droppedFindingsByType&&Object.keys(E.droppedFindingsByType).length>0&&(()=>{const P=Object.entries(E.droppedFindingsByType),we=P.reduce((Fe,[,Bt])=>Fe+Bt,0),Ve=P.map(([Fe,Bt])=>`${Fe}:${Bt}`).join(", ");return a.jsxs("span",{className:"shrink-0 rounded border border-unverified/20 bg-unverified/5 px-1.5 py-0.5 font-mono text-[10px] font-semibold text-unverified",title:`Silently dropped <agent_finding> tags with invalid type=: ${Ve}. These never reach the dashboard, scores, or signals.`,children:[we," dropped"]})})(),a.jsx("span",{className:"ml-auto font-mono text-[10px] shrink-0",style:{color:"color-mix(in oklch, var(--text-dim) 50%, transparent)"},children:We(E.timestamp)})]}),a.jsx("div",{className:"mt-1.5 flex items-center gap-3",children:Lt.map(P=>a.jsxs("span",{className:`font-mono text-[10px] font-semibold ${P.textCls}`,children:[P.count," ",P.label]},P.label))}),E.topic&&a.jsxs("div",{className:"mt-1.5 flex items-start gap-2",children:[a.jsx("span",{className:"shrink-0 rounded border border-border/30 px-1.5 py-0.5 font-mono text-[9px] font-bold uppercase tracking-wider",style:{background:"color-mix(in oklch, var(--surface-sunk) 30%, transparent)",color:"color-mix(in oklch, var(--text-dim) 50%, transparent)"},children:"Topic"}),a.jsx("span",{className:"font-inter text-[11px] leading-relaxed",style:{color:"color-mix(in oklch, var(--text-dim) 70%, transparent)"},children:E.topic})]})]}),a.jsx("span",{className:`mt-1 shrink-0 font-mono text-[10px] transition-transform duration-150 ${le?"rotate-90":""}`,style:{color:le?"color-mix(in oklch, var(--ink) 60%, transparent)":"color-mix(in oklch, var(--text-dim) 40%, transparent)"},children:"▸"})]}),le&&a.jsxs("div",{className:"border-t border-border/20 px-4 pb-4 pt-3",children:[a.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[a.jsx("span",{className:"font-mono text-[10px]",style:{color:"color-mix(in oklch, var(--text-dim) 50%, transparent)"},children:"Type:"}),Wm.map(P=>a.jsx("button",{onClick:()=>b(P.key),className:`rounded-md border px-3 py-1.5 font-mono text-[10px] font-medium transition ${g===P.key?P.activeCls:P.cls}`,style:g===P.key?P.activeStyle:P.inactiveStyle,...P.tooltip?{"data-tooltip":P.tooltip}:{},children:P.label},P.key))]}),a.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[a.jsx("span",{className:"font-mono text-[10px]",style:{color:"color-mix(in oklch, var(--text-dim) 50%, transparent)"},children:"Severity:"}),bg.map(P=>a.jsx("button",{onClick:()=>O(P.key),className:`rounded-md border px-3 py-1.5 font-mono text-[10px] font-medium transition ${S===P.key?P.activeCls:P.cls}`,style:S===P.key?P.activeStyle:P.inactiveStyle,children:P.label},P.key))]}),E.coverageDegraded&&a.jsxs("div",{className:"mb-3 rounded-md border border-unverified/20 bg-unverified/8 px-3 py-2",children:[a.jsxs("p",{className:"font-mono text-[10px] font-semibold text-unverified",children:["⚠ Coverage degraded — ",E.coverageDegraded.received," of ",E.coverageDegraded.expected," agents responded"]}),E.coverageDegraded.droppedAgents.length>0&&a.jsxs("p",{className:"mt-0.5 font-mono text-[9px]",style:{color:"color-mix(in oklch, var(--text-dim) 70%, transparent)"},children:["Dropped: ",E.coverageDegraded.droppedAgents.join(", ")]})]}),E.zeroTagAgents&&E.zeroTagAgents.length>0&&a.jsxs("div",{className:"mb-3 rounded-md border border-unverified/20 bg-unverified/8 px-3 py-2",children:[a.jsxs("p",{className:"font-mono text-[10px] font-semibold text-unverified",children:["⚠ Zero-tag agents — ",E.zeroTagAgents.length+(E.zeroTagOverflow??0)," agent",E.zeroTagAgents.length+(E.zeroTagOverflow??0)===1?"":"s"," emitted no parseable <agent_finding> tags"]}),a.jsxs("p",{className:"mt-0.5 font-mono text-[9px]",style:{color:"color-mix(in oklch, var(--text-dim) 70%, transparent)"},children:[E.zeroTagAgents.join(", "),E.zeroTagOverflow&&E.zeroTagOverflow>0?` (+${E.zeroTagOverflow} more)`:""]}),a.jsx("p",{className:"mt-1 font-mono text-[9px]",style:{color:"color-mix(in oklch, var(--text-dim) 50%, transparent)"},children:"Likely a paraphrased relay or HTML-entity-encoded tags. See HANDBOOK invariant #12."})]}),E.relayCrossReviewSkipped&&E.relayCrossReviewSkipped.length>0&&a.jsxs("div",{className:"mb-3 rounded-md border border-unverified/20 bg-unverified/8 px-3 py-2",children:[a.jsxs("p",{className:"font-mono text-[10px] font-semibold text-unverified",children:["⚠ Cross-review skipped: ",E.relayCrossReviewSkipped.length," relay agent",E.relayCrossReviewSkipped.length===1?"":"s"," failed Phase 2"]}),a.jsx("p",{className:"mt-0.5 font-mono text-[9px]",style:{color:"color-mix(in oklch, var(--text-dim) 70%, transparent)"},children:E.relayCrossReviewSkipped.map(P=>P.agentId).join(", ")})]}),(E.crossReviewAssignments||E.crossReviewCoverage)&&(()=>{const P=E.crossReviewAssignments||{},we=Object.entries(P),Ve=E.crossReviewCoverage||[],Fe=Ve.length,Bt=Ve.filter(Le=>Le.assigned<Le.targetK);return a.jsxs("details",{className:"mb-3 rounded-md border border-border/30",style:{background:"color-mix(in oklch, var(--surface-elev) 30%, transparent)"},children:[a.jsxs("summary",{className:"flex cursor-pointer items-center gap-2 px-3 py-2 h-section select-none",children:["Cross-Review Assignments",E.partialReview&&a.jsx("span",{className:"rounded border border-unverified/15 bg-unverified/5 px-1.5 py-0.5 font-mono text-[9px] font-bold normal-case tracking-normal text-unverified",children:"partial"}),a.jsxs("span",{className:"ml-auto font-mono text-[9px] font-normal normal-case tracking-normal",style:{color:"color-mix(in oklch, var(--text-dim) 50%, transparent)"},children:[we.length," reviewers · ",Fe," findings"]})]}),a.jsxs("div",{className:"border-t border-border/20 px-3 pb-3 pt-2 space-y-2",children:[we.map(([Le,Jn])=>a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{title:Le,className:"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full font-mono text-[8px] font-bold",style:{color:"var(--surface)",backgroundColor:gn(Le)},children:ho(Le)}),a.jsx("span",{className:"font-mono text-[10px]",style:{color:"var(--text-dim)"},children:Le}),a.jsxs("span",{className:"font-mono text-[10px]",style:{color:"color-mix(in oklch, var(--text-dim) 40%, transparent)"},children:["(",Jn.length,")"]}),a.jsx("div",{className:"flex flex-wrap gap-1 ml-1",children:Jn.map(Fn=>a.jsx("span",{className:"rounded px-1.5 py-0.5 font-mono text-[9px]",style:{background:"color-mix(in oklch, var(--surface-sunk) 50%, transparent)",color:"var(--text-dim)"},children:Fn.length>12?Fn.slice(0,12)+"…":Fn},Fn))})]},Le)),Fe>0&&a.jsx("div",{className:"mt-1 pt-1.5 border-t border-border/15",children:Bt.length>0?a.jsxs("span",{className:"rounded border border-unverified/15 bg-unverified/5 px-2 py-1 font-mono text-[10px] font-semibold text-unverified",children:["⚠ ",Bt.length," of ",Fe," findings under-reviewed"]}):a.jsxs("span",{className:"font-mono text-[10px] font-semibold text-confirmed/60",children:["✓ All ",Fe," findings fully covered"]})})]})]})})(),a.jsx("div",{className:"space-y-3",children:G.length===0?a.jsx("div",{className:"py-4 text-center text-xs",style:{color:"var(--text-dim)"},children:"No findings match this filter."}):G.map((P,we)=>a.jsx(_g,{f:P,reviewInfo:P.id?y[P.id]:void 0,diagnostics:re(P)},we))})]})]})]},E.id)}),u&&de>1&&a.jsxs("div",{className:"flex items-center justify-center gap-3 pt-4 font-mono text-[11px]",style:{color:"var(--text-dim)"},children:[a.jsx("button",{onClick:()=>ne(E=>Math.max(0,E-1)),disabled:F===0,className:"rounded-sm border border-border/40 px-3 py-1 transition hover:bg-accent/10 disabled:opacity-30",style:{background:"var(--surface-elev)"},children:"◂ Prev"}),a.jsxs("span",{children:["Page ",F+1," of ",de]}),a.jsx("button",{onClick:()=>ne(E=>Math.min(de-1,E+1)),disabled:F>=de-1,className:"rounded-sm border border-border/40 px-3 py-1 transition hover:bg-accent/10 disabled:opacity-30",style:{background:"var(--surface-elev)"},children:"Next ▸"})]})]}):v.length===0?a.jsx(da,{title:"No consensus runs yet",hint:"Dispatch a consensus round with gossip_dispatch to populate this view."}):a.jsx("div",{className:"space-y-2",children:v.map((E,T)=>{const H=E.counts,W=(H.agreement||0)+(H.disagreement||0)+(H.hallucination||0)+(H.unverified||0)+(H.unique||0)+(H.new||0),ce=W||1,ue=p===E.taskId,y=[{key:"confirmed",count:H.agreement||0,color:"bg-confirmed",text:"text-confirmed",label:"confirmed"},{key:"disputed",count:(H.disagreement||0)+(H.hallucination||0),color:"bg-disputed",text:"text-disputed",label:"disputed"},{key:"unverified",count:H.unverified||0,color:"bg-unverified",text:"text-unverified",label:"unverified"},{key:"unique",count:(H.unique||0)+(H.new||0),color:"bg-unique",text:"text-unique",label:"unique"}],R=E.signals.filter(G=>{if(G.signal==="signal_retracted")return!1;if(g==="all")return!!uo[G.signal];const le=uo[G.signal];return le&&le.filter===g}),V=!!E.retracted;return a.jsxs("div",{className:`rounded-md border transition ${ue?"border-primary/25":"border-border"} ${V?"opacity-60":""}`,style:{background:"var(--surface-elev)"},"data-retracted":V?"true":void 0,title:V&&E.retractionReason?`Retracted: ${E.retractionReason}`:void 0,children:[V&&a.jsxs("div",{className:"rounded-t-md border-b border-disputed/30 bg-disputed/10 px-3 py-1.5 font-mono text-[10px] text-disputed",style:{textDecoration:"none"},children:[a.jsx("span",{className:"font-bold uppercase tracking-wider",children:"⚠ Retracted"}),E.retractedAt&&a.jsxs("span",{className:"ml-2 text-disputed/70",children:["on ",E.retractedAt.slice(0,10)]}),E.retractionReason&&a.jsxs("span",{className:"ml-2",style:{color:"color-mix(in oklch, var(--text-dim) 80%, transparent)"},children:["— ",E.retractionReason]})]}),a.jsxs("button",{"aria-expanded":ue,onClick:()=>{const G=!ue;x(G?E.taskId:null),G&&(b("all"),O("all"))},className:"flex w-full items-center p-3 text-left transition hover:bg-accent/10",children:[a.jsx("span",{className:"mr-3 font-mono text-xs transition",style:{color:ue?"var(--ink)":"var(--text-dim)",fontWeight:ue?600:400},children:ue?"▾":"▸"}),a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("span",{className:"font-mono text-[10px]",style:{color:"var(--ink-3)"},children:E.taskId}),a.jsxs("span",{className:`font-mono text-sm font-semibold ${V?"line-through decoration-disputed/40":""}`,style:{color:"var(--text)"},children:[W," findings"]}),a.jsxs("div",{className:"flex gap-1.5",children:[E.agents.slice(0,4).map(G=>a.jsx("span",{className:"rounded-sm px-1.5 py-0.5 font-mono text-[10px]",style:{background:"var(--surface-sunk)",color:"var(--text-dim)"},children:G.split("-").map(le=>le[0]).join("").toUpperCase().slice(0,2)},G)),E.agents.length>4&&a.jsxs("span",{className:"font-mono text-[10px]",style:{color:"var(--text-dim)"},children:["+",E.agents.length-4]})]})]}),a.jsx("span",{className:"font-mono text-xs",style:{color:"var(--text-dim)"},children:We(E.timestamp)})]}),a.jsx("div",{className:"mt-2 flex gap-2",children:y.map(G=>G.count>0&&a.jsxs("span",{className:`font-mono text-[10px] font-semibold ${G.text} ${V?"line-through decoration-disputed/40":""}`,children:[G.count," ",G.label]},G.key))}),a.jsx("div",{className:"mt-2 flex h-1.5 overflow-hidden rounded-sm",children:y.map(G=>G.count>0&&a.jsx("div",{className:`${G.color} transition-all`,style:{width:`${G.count/ce*100}%`}},G.key))})]})]}),ue&&a.jsxs("div",{className:"border-t border-border px-4 pb-3 pt-3",children:[a.jsx("div",{className:"mb-3 flex gap-1.5",children:Wm.map(G=>a.jsx("button",{onClick:()=>b(G.key),className:`rounded-sm px-2 py-0.5 font-mono text-[10px] font-semibold transition ${g===G.key?G.activeCls:G.cls} hover:opacity-80`,style:g===G.key?G.activeStyle:G.inactiveStyle,...G.tooltip?{"data-tooltip":G.tooltip}:{},children:G.label},G.key))}),R.length===0?a.jsx("div",{className:"py-4 text-center text-xs",style:{color:"var(--text-dim)"},children:"No findings match this filter."}):a.jsx("div",{className:"space-y-2",children:R.map((G,le)=>{const re=uo[G.signal];return re?a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx("span",{className:`shrink-0 rounded-sm px-1.5 py-0.5 font-mono text-[9px] font-bold ${re.cls}`,children:re.label}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("span",{className:"text-xs [&_.cite-file]:rounded [&_.cite-file]:bg-blue-500/10 [&_.cite-file]:px-1 [&_.cite-file]:font-mono [&_.cite-file]:text-blue-400 [&_.cite-fn]:rounded [&_.cite-fn]:bg-purple-500/10 [&_.cite-fn]:px-1 [&_.cite-fn]:font-mono [&_.cite-fn]:text-purple-400",style:{color:"var(--text-dim)"},children:a.jsx("span",{className:"finding-md",dangerouslySetInnerHTML:{__html:Oi(G.evidence||"")}})}),a.jsxs("span",{className:"ml-2 font-mono text-[10px]",style:{color:"color-mix(in oklch, var(--text-dim) 50%, transparent)"},children:[G.agentId,G.counterpartId?` + ${G.counterpartId}`:""]})]})]},le):null})})]})]},E.taskId+T)})})]})}const Ci=25;function Tg({commits:i}){const[r,u]=k.useState(!1);if(i.length===0)return a.jsx("span",{style:{color:"color-mix(in oklch, var(--text-dim) 50%, transparent)"},children:"—"});const o=i[0],d=o.includes(" ")?o.slice(o.indexOf(" ")+1):o,m=i.length-1;return a.jsxs("span",{className:"font-mono text-[11px]",children:[a.jsx("span",{style:{color:"var(--text)"},children:d}),m>0&&a.jsxs(a.Fragment,{children:[" ",a.jsx("button",{type:"button","aria-expanded":r,onClick:()=>u(v=>!v),className:"font-mono text-[10px] underline",style:{color:"color-mix(in oklch, var(--text-dim) 70%, transparent)"},children:r?"(collapse)":`(+${m} more)`}),r&&a.jsx("ul",{className:"mt-1 space-y-0.5 pl-2",children:i.slice(1).map((v,p)=>{const x=v.includes(" ")?v.slice(v.indexOf(" ")+1):v;return a.jsx("li",{className:"font-mono text-[10px]",style:{color:"color-mix(in oklch, var(--text-dim) 80%, transparent)"},children:x},p)})})]})]})}function Mg({row:i}){const r=i.preSha.slice(0,8),u=i.postSha.slice(0,8);return a.jsxs("tr",{className:"border-t border-border/20 align-top transition-colors hover:bg-accent/20",children:[a.jsx("td",{className:"whitespace-nowrap py-3 pl-4 pr-4 font-mono text-[10px]",style:{color:"color-mix(in oklch, var(--text-dim) 80%, transparent)"},children:We(i.detectedAt)}),a.jsx("td",{className:"max-w-[160px] truncate whitespace-nowrap py-3 pr-4",children:a.jsx("a",{href:`/dashboard/agent/${encodeURIComponent(i.agentId)}`,className:"font-mono text-[11px] hover:underline",style:{color:"var(--text)"},onMouseEnter:o=>o.currentTarget.style.color="var(--accent)",onMouseLeave:o=>o.currentTarget.style.color="var(--text)",children:i.agentId})}),a.jsxs("td",{className:"whitespace-nowrap py-3 pr-4 font-mono text-[10px]",children:[a.jsx("span",{style:{color:"color-mix(in oklch, var(--text-dim) 70%, transparent)"},children:r}),a.jsx("span",{className:"mx-1",style:{color:"color-mix(in oklch, var(--text-dim) 40%, transparent)"},children:"→"}),a.jsx("span",{style:{color:"var(--text)"},children:u})]}),a.jsx("td",{className:"py-3 pr-4",children:a.jsx(Tg,{commits:i.commits})})]})}function Ag(){const[i,r]=k.useState([]),[u,o]=k.useState(0),[d,m]=k.useState(1),[v,p]=k.useState(!1),[x,g]=k.useState(null);k.useEffect(()=>{let S=!1;return p(!0),g(null),Ge(`violations?page=${d}&pageSize=${Ci}`).then(O=>{S||(r(O.items??[]),o(O.total??0))}).catch(O=>{S||g(String((O==null?void 0:O.message)??O))}).finally(()=>{S||p(!1)}),()=>{S=!0}},[d]);const b=Math.max(1,Math.ceil(u/Ci));return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-baseline gap-3",children:[a.jsx("h1",{className:"h-route",children:"Process Violations"}),u>0&&a.jsx("span",{className:"font-mono text-sm tabular-nums",style:{color:"var(--ink-3)"},children:u})]}),a.jsx("p",{className:"mt-0.5 font-mono text-[10px]",style:{color:"color-mix(in oklch, var(--text-dim) 70%, transparent)"},children:"Direct master pushes detected by the ref-allowlist enforcer"})]}),a.jsxs("div",{className:"overflow-hidden rounded-md border border-border/40",style:{background:"color-mix(in oklch, var(--surface-elev) 80%, transparent)"},children:[x&&a.jsx("div",{className:"border-b border-border/60 bg-disputed/10 px-3 py-2 font-mono text-[10px] text-disputed",children:x}),!x&&a.jsxs("table",{className:"w-full table-fixed text-left",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b border-border/40 font-mono text-[10px] uppercase tracking-wider",style:{background:"color-mix(in oklch, var(--surface-sunk) 20%, transparent)",color:"color-mix(in oklch, var(--text-dim) 80%, transparent)"},children:[a.jsx("th",{className:"py-2.5 pl-4 pr-4",children:"When"}),a.jsx("th",{className:"py-2.5 pr-4",children:"Agent"}),a.jsx("th",{className:"py-2.5 pr-4",children:"Commit Range"}),a.jsx("th",{className:"py-2.5 pr-4",children:"Commits"})]})}),a.jsxs("tbody",{children:[!v&&i.length===0&&a.jsx("tr",{children:a.jsx("td",{colSpan:4,className:"px-4 py-6 text-center font-mono text-[11px]",style:{color:"color-mix(in oklch, var(--text-dim) 50%, transparent)"},children:"No violations recorded"})}),v&&a.jsx("tr",{children:a.jsx("td",{colSpan:4,className:"px-4 py-6 text-center font-mono text-[10px]",style:{color:"color-mix(in oklch, var(--text-dim) 50%, transparent)"},children:"Loading…"})}),!v&&i.map(S=>a.jsx(Mg,{row:S},`${S.taskId}-${S.detectedAt}`))]})]}),a.jsxs("div",{className:"flex items-center justify-between border-t border-border/60 px-3 py-2",children:[a.jsx("span",{className:"font-mono text-[10px]",style:{color:"color-mix(in oklch, var(--text-dim) 60%, transparent)"},children:v?"loading…":u===0?"no violations":`${(d-1)*Ci+1}–${Math.min(d*Ci,u)} of ${u}`}),a.jsxs("div",{className:`flex items-center gap-2 font-mono text-[10px] ${b<=1?"invisible":""}`,style:{color:"var(--text-dim)"},children:[a.jsx("button",{type:"button",onClick:()=>m(S=>Math.max(1,S-1)),disabled:d===1||v,className:"rounded-sm border border-border/40 px-2 py-0.5 transition hover:bg-accent/10 disabled:opacity-30",style:{background:"var(--surface-elev)"},children:"◂ Prev"}),a.jsxs("span",{className:"tabular-nums",children:[d," / ",b]}),a.jsx("button",{type:"button",onClick:()=>m(S=>Math.min(b,S+1)),disabled:d>=b||v,className:"rounded-sm border border-border/40 px-2 py-0.5 transition hover:bg-accent/10 disabled:opacity-30",style:{background:"var(--surface-elev)"},children:"Next ▸"})]})]})]})]})}function wg({categoryAccuracy:i,categoryCorrect:r,categoryHallucinated:u}){const o=Object.keys(i??{});if(o.length===0)return a.jsx(da,{title:"No category data yet",hint:"Accuracy accrues after ≥5 signals per category.",compact:!0});const d=o.map(m=>{const v=Math.max(0,Math.min(1,i[m]??0)),p=(r==null?void 0:r[m])??0,x=(u==null?void 0:u[m])??0;return{key:m,acc:v,c:p,h:x,n:p+x}}).sort((m,v)=>v.acc-m.acc);return a.jsx("div",{className:"space-y-2",children:d.map(m=>{const v=m.acc>=.7?"bg-confirmed":m.acc>=.4?"bg-unverified":"bg-disputed",p=m.n>0?`${m.c} correct / ${m.h} hallucinated / ${m.n} total`:void 0;return a.jsxs("div",{className:`grid grid-cols-[128px_1fr_auto_44px] items-center gap-3 ${m.n>0&&m.n<10?"opacity-50":""}`,title:m.n>0&&m.n<10?`${p} — low sample (n<10)`:p,children:[a.jsx("span",{className:"truncate font-mono text-[11px]",style:{color:"var(--text-dim)"},children:m.key.replace(/_/g," ")}),a.jsx("div",{className:"h-2 overflow-hidden rounded-sm",style:{background:"color-mix(in oklch, var(--surface-sunk) 30%, transparent)"},children:a.jsx("div",{className:`h-full rounded-sm transition-all ${v}`,style:{width:`${m.acc*100}%`}})}),a.jsx("span",{className:"shrink-0 text-right font-mono text-[10px] tabular-nums w-16",style:{color:"color-mix(in oklch, var(--text-dim) 60%, transparent)"},children:m.n>0?a.jsxs(a.Fragment,{children:[m.c,"/",m.n,m.h>0&&a.jsxs("span",{className:"ml-1 text-disputed/70",children:["·",m.h,"✗"]})]}):"—"}),a.jsxs("span",{className:"text-right font-mono text-[11px] font-bold tabular-nums",style:{color:"var(--text)"},children:[Math.round(m.acc*100),"%"]})]},m.key)})})}const Cg=new Set(["passed","failed","silent_skill","insufficient_evidence","flagged_for_manual_review"]);function zg(i,r,u){return(!i||!Cg.has(i))&&r!==void 0&&u!==void 0&&u>0}const Dg={silent_skill:"No signals recorded after bind — skill may not be injecting correctly",insufficient_evidence:"Fewer than 120 post-bind signals — verdict pending more data",inconclusive:"Mixed signals — needs further evaluation",passed:"Skill verified effective",failed:"Skill verified ineffective",pending:"Awaiting evidence",flagged_for_manual_review:"Manual review required"},Rg={pending:"border-border/50",passed:"border-confirmed/40 bg-confirmed/10 text-confirmed",failed:"border-disputed/40 bg-disputed/10 text-disputed",silent_skill:"border-unverified/40 bg-unverified/10 text-unverified",insufficient_evidence:"border-unverified/40 bg-unverified/10 text-unverified",inconclusive:"border-[color:var(--warn)]/40 bg-[color:var(--warn)]/10 text-[color:var(--warn)]",flagged_for_manual_review:"border-disputed/40 bg-disputed/10 text-disputed"};function Og(i){const r=Math.round(i*100),u=r>0?"+":"";return r>0?{text:`${u}${r}pp`,cls:"text-confirmed"}:r<0?{text:`${u}${r}pp`,cls:"text-disputed"}:{text:`${u}${r}pp`,cls:"",clsStyle:{color:"var(--text-dim)"}}}function Ug({slot:i}){const r=i.status,u=r?Rg[r]:"border-border/50",o=!r||r==="pending"?{background:"color-mix(in oklch, var(--surface-sunk) 30%, transparent)",color:"var(--text-dim)"}:void 0,d=r==="inconclusive"&&(i.inconclusiveStrikes??0)>0,m=i.forcedDevelops??[],v=m.length>0?m[m.length-1]:null,p=typeof i.effectiveness=="number"?Og(i.effectiveness):null,x=zg(r,i.postBindSignals,i.minEvidence);return a.jsxs("div",{className:`rounded-md border p-3 ${i.enabled?"border-border/50":"border-border/30 opacity-60"}`,style:{background:"color-mix(in oklch, var(--surface-elev) 80%, transparent)"},children:[a.jsxs("div",{className:"flex items-start justify-between gap-2",children:[a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[a.jsxs("span",{className:`font-mono text-xs font-semibold ${i.enabled?"":"line-through"}`,style:{color:i.enabled?"var(--text)":"var(--text-dim)"},children:[i.mode==="contextual"&&"⚡ ",i.name]}),a.jsx("span",{className:"rounded-sm px-1.5 py-0.5 font-mono text-[9px]",style:{background:"var(--surface-sunk)",color:"var(--text-dim)"},children:i.source}),i.mode==="contextual"&&a.jsx("span",{className:"warn-badge rounded-sm px-1.5 py-0.5 font-mono text-[9px]",children:"contextual"})]}),a.jsxs("div",{className:"mt-1 font-mono text-[10px]",style:{color:"color-mix(in oklch, var(--text-dim) 60%, transparent)"},children:["bound ",We(i.boundAt)]}),x&&(()=>{const g=i.postBindSignals,b=i.minEvidence,S=Math.round(g/b*100),O=Math.min(g/b,1)*100;return a.jsxs("div",{className:"mt-1.5",title:`MIN_EVIDENCE gate: ${g} of ${b} post-bind signals (${S}%)`,children:[a.jsxs("div",{className:"mb-0.5 font-mono text-[9px]",style:{color:"color-mix(in oklch, var(--text-dim) 50%, transparent)"},children:["post-bind: ",g," / ",b]}),a.jsx("div",{className:"relative h-1 w-full overflow-hidden rounded-full border border-border/40",style:{background:"color-mix(in oklch, var(--surface-sunk) 30%, transparent)"},children:a.jsx("div",{className:"absolute inset-y-0 left-0 rounded-full border-r border-confirmed/40 bg-confirmed/20",style:{width:`${O}%`}})})]})})()]}),r&&a.jsx("span",{className:`shrink-0 rounded-sm border px-1.5 py-0.5 font-mono text-[9px] font-bold uppercase ${u}`,style:o,title:Dg[r],children:r.replace(/_/g," ")})]}),a.jsxs("div",{className:"mt-2 flex items-center gap-3 font-mono text-[10px]",children:[p&&a.jsx("span",{className:p.cls,style:p.clsStyle,title:"Effectiveness: change in hallucination rate pre/post",children:p.text}),d&&a.jsxs("span",{className:"text-unique",title:i.inconclusiveAt?`last strike ${We(i.inconclusiveAt)}`:void 0,children:[i.inconclusiveStrikes," strike",i.inconclusiveStrikes===1?"":"s"]})]}),m.length>0&&a.jsxs("div",{className:"mt-2 border-t border-border/40 pt-2 font-mono text-[10px]",style:{color:"var(--text-dim)"},title:v!=null&&v.reason?`latest: ${v.reason}`:void 0,children:["forced ",m.length," time",m.length===1?"":"s",v&&` · last ${We(v.timestamp)}`]})]})}function qg({open:i,onOpenChange:r,children:u}){return k.useEffect(()=>{if(!i)return;const o=m=>{m.key==="Escape"&&r(!1)};document.addEventListener("keydown",o);const d=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",o),document.body.style.overflow=d}},[i,r]),i?a.jsxs("div",{className:"fixed inset-0 z-50",children:[a.jsx("div",{className:"absolute inset-0 backdrop-blur-sm",style:{background:"color-mix(in oklch, var(--surface) 70%, transparent)"},onClick:()=>r(!1)}),a.jsx("div",{className:"absolute inset-y-0 right-0 flex",children:a.jsx("div",{onClick:o=>o.stopPropagation(),className:"contents",children:u})})]}):null}function Lg({side:i="right",className:r="",children:u,style:o,...d}){return a.jsx("div",{className:`h-full p-6 ${r}`,style:{background:"var(--surface-elev)",...o},...d,children:u})}function Bg({className:i="",...r}){return a.jsx("div",{className:`mb-2 ${i}`,...r})}function Hg({className:i="",...r}){return a.jsx("h2",{className:`font-semibold ${i}`,...r})}function $g({citation:i}){const r=i.snippet.split(`
|
|
77
|
-
`);return a.jsxs("div",{className:"rounded-md border border-border/40 overflow-hidden",style:{background:"color-mix(in oklch, var(--surface-elev) 60%, transparent)"},children:[a.jsx("div",{className:"flex items-center justify-between px-3 py-1 border-b border-border/40",style:{background:"color-mix(in oklch, var(--surface-sunk) 40%, transparent)"},children:a.jsxs("span",{className:"font-mono text-[10px]",style:{color:"var(--text-dim)"},children:[i.file,":",i.line]})}),a.jsx("pre",{className:"overflow-x-auto",style:{background:"var(--surface-sunk)",borderLeft:"3px solid var(--border-strong)",padding:"12px 16px",borderRadius:"6px",fontFamily:"var(--font-mono)",fontSize:"12px",color:"var(--text)"},children:r.map((u,o)=>a.jsx("div",{className:"whitespace-pre",children:u||" "},o))})]})}const Pm={critical:"text-red-400 bg-red-500/10",high:"text-severity-high bg-severity-high/10",medium:"text-yellow-400 bg-yellow-500/10",low:""},Gg={color:"var(--text-dim)",background:"color-mix(in oklch, var(--surface-sunk) 50%, transparent)"},eh={confirmed:"text-confirmed bg-confirmed/10 border border-confirmed/20",disputed:"text-disputed bg-disputed/10 border border-disputed/20",unverified:"text-unverified bg-unverified/10 border border-unverified/20",unique:"text-unique bg-unique/10 border border-unique/20",insight:"text-insight bg-insight/10 border border-insight/20",newFinding:"text-unique bg-unique/10 border border-unique/20"},Yg={background:"var(--surface-elev)",borderRadius:"16px 0 0 16px",boxShadow:"var(--shadow-overlay)",border:"1px solid var(--border)",color:"var(--text)",fontFamily:"var(--font-sans)"};function qi({open:i,onOpenChange:r,consensusId:u,findingId:o}){const[d,m]=k.useState(null),[v,p]=k.useState(null);return k.useEffect(()=>{if(!i||!u||!o){m(null),p(null);return}m(null),p(null),Ge(`finding/${encodeURIComponent(u)}/${encodeURIComponent(o)}`).then(m).catch(x=>p(x.message||"failed to load finding"))},[i,u,o]),a.jsx(qg,{open:i,onOpenChange:r,children:a.jsxs(Lg,{side:"right",className:"w-[480px] sm:w-[480px] sm:max-w-[480px] overflow-y-auto",style:Yg,children:[a.jsx(Bg,{children:a.jsx(Hg,{className:"font-mono text-sm",style:{color:"var(--text)"},children:"Finding detail"})}),v&&a.jsx("div",{className:"mt-4",children:a.jsx(Eo,{message:v})}),!v&&!d&&a.jsx("div",{className:"mt-4 text-[11px]",style:{color:"var(--text-dim)"},children:"Loading…"}),d&&a.jsxs("div",{className:"mt-4 space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[a.jsx("span",{className:`font-mono text-[9px] uppercase tracking-wider px-2 py-0.5 rounded ${eh[d.finding.tag]||""}`,style:eh[d.finding.tag]?void 0:{background:"var(--surface-sunk)"},children:d.finding.tag}),d.finding.severity&&a.jsx("span",{className:`font-mono text-[9px] uppercase tracking-wider px-2 py-0.5 rounded ${Pm[d.finding.severity]||""}`,style:d.finding.severity==="low"?Gg:Pm[d.finding.severity]?void 0:{background:"var(--surface-sunk)"},children:d.finding.severity}),a.jsxs("span",{className:"font-mono text-[9px]",style:{color:"var(--text-dim)"},children:["by ",d.finding.originalAgentId]}),d.retracted&&a.jsx("span",{className:"font-mono text-[9px] uppercase tracking-wider px-2 py-0.5 rounded bg-disputed/50",children:"retracted"})]}),a.jsx("div",{className:"font-mono text-[12px] leading-relaxed whitespace-pre-wrap",children:d.finding.finding.replace(/<cite tag="file">[^<]+<\/cite>/g,"").trim()}),d.citations.length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsx("div",{className:"font-mono text-[10px] uppercase tracking-wider",style:{color:"var(--text-dim)"},children:"Citations"}),d.citations.map((x,g)=>a.jsx($g,{citation:x},g))]}),a.jsxs("div",{className:"space-y-1",children:[a.jsx("div",{className:"font-mono text-[10px] uppercase tracking-wider",style:{color:"var(--text-dim)"},children:"Coverage"}),d.finding.confirmedBy.length>0&&a.jsxs("div",{className:"text-[11px]",children:[a.jsx("span",{className:"text-confirmed",children:"✓"})," confirmed by ",d.finding.confirmedBy.join(", ")]}),d.finding.disputedBy.map((x,g)=>a.jsxs("div",{className:"text-[11px]",children:[a.jsx("span",{className:"text-disputed",children:"✗"})," disputed by ",x.agentId,": ",a.jsx("span",{style:{color:"var(--text-dim)"},children:x.reason})]},g)),d.finding.confirmedBy.length===0&&d.finding.disputedBy.length===0&&a.jsx("div",{className:"text-[11px]",style:{color:"var(--text-dim)"},children:"No peer review"})]}),d.signals.length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"font-mono text-[10px] uppercase tracking-wider",style:{color:"var(--text-dim)"},children:["Signals (",d.signals.length,")"]}),a.jsx("div",{className:"space-y-1",children:d.signals.map((x,g)=>a.jsxs("div",{className:"text-[11px] border-l-2 border-border/40 pl-2",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"font-mono font-semibold",children:x.signal}),a.jsx("span",{style:{color:"var(--text-dim)"},children:"·"}),a.jsx("span",{children:x.agentId}),x.counterpartId&&a.jsxs(a.Fragment,{children:[a.jsx("span",{style:{color:"var(--text-dim)"},children:"→"}),a.jsx("span",{children:x.counterpartId})]}),a.jsx("span",{className:"ml-auto",style:{color:"var(--text-dim)"},children:We(x.timestamp)})]}),x.evidence&&a.jsx("div",{className:"mt-0.5",style:{color:"var(--text-dim)"},children:x.evidence.slice(0,200)})]},g))})]}),a.jsx("div",{className:"pt-2 border-t border-border/40",children:a.jsxs("a",{href:vn(`/consensus/${d.consensusId}`),className:"font-mono text-[10px] hover:underline",style:{color:"var(--accent)"},children:["→ consensus round ",d.consensusId]})})]})]})})}const Xg={agreement:"text-confirmed bg-confirmed/10",consensus_verified:"text-confirmed bg-confirmed/10",unique_confirmed:"text-unique bg-unique/10",unique_unconfirmed:"text-unique bg-unique/10",new_finding:"text-unique bg-unique/10",disagreement:"text-disputed bg-disputed/10",hallucination_caught:"text-disputed bg-disputed/10",unverified:"text-unverified bg-unverified/10"};function Vg({agentId:i}){const[r,u]=k.useState([]),[o,d]=k.useState(!0),[m,v]=k.useState("all"),[p,x]=k.useState(null);k.useEffect(()=>{let O=!1;return d(!0),Ge(`signals?agent=${encodeURIComponent(i)}&limit=100`).then(Q=>{O||(u(Q.items||[]),d(!1))}).catch(()=>{O||(u([]),d(!1))}),()=>{O=!0}},[i]);const g=[...r].sort((O,Q)=>(Q.timestamp||"").localeCompare(O.timestamp||"")),b=m==="all"||m==="signals"?g:[],S=({k:O,label:Q,enabled:L})=>a.jsx("button",{type:"button",onClick:()=>L&&v(O),disabled:!L,className:`rounded-sm px-2 py-0.5 font-mono text-[10px] font-semibold transition ${L?"":"opacity-40 cursor-not-allowed"}`,style:m===O?{background:"var(--surface-sunk)",color:"var(--text)"}:{color:"var(--text-dim)"},children:Q});return a.jsxs("div",{className:"rounded-md border border-border/40 px-4 py-3",style:{background:"color-mix(in oklch, var(--surface-elev) 80%, transparent)"},children:[a.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[a.jsx("span",{className:"h-section",children:"Activity"}),a.jsxs("div",{className:"flex gap-1",children:[a.jsx(S,{k:"all",label:"All",enabled:!0}),a.jsx(S,{k:"signals",label:"Signals",enabled:!0}),a.jsx(S,{k:"tasks",label:"Tasks (none yet)",enabled:!1}),a.jsx(S,{k:"skills",label:"Skills (none yet)",enabled:!1})]})]}),o?a.jsx("div",{className:"py-6 text-center text-xs",style:{color:"var(--text-dim)"},children:"Loading…"}):b.length===0?a.jsx(da,{title:"No activity yet",hint:"Signals, task completions, and skill binds will appear here.",compact:!0}):a.jsx("div",{className:"space-y-1",children:b.map((O,Q)=>{const L=Xg[O.signal]||"text-text-dim",X=!!(O.consensusId&&O.findingId),M=a.jsxs("div",{className:"flex items-start gap-2 py-1.5",children:[a.jsx("span",{className:"shrink-0 font-mono text-[9px] tabular-nums w-16",style:{color:"color-mix(in oklch, var(--text-dim) 60%, transparent)"},children:We(O.timestamp)}),a.jsx("span",{className:`shrink-0 rounded-sm px-1.5 py-0.5 font-mono text-[9px] font-bold ${L}`,children:O.signal}),a.jsxs("div",{className:"min-w-0 flex-1 text-[11px]",style:{color:"var(--text-dim)"},children:[O.counterpartId&&a.jsxs("span",{className:"font-mono text-[10px]",style:{color:"color-mix(in oklch, var(--text-dim) 70%, transparent)"},children:["→ ",O.counterpartId," · "]}),O.evidence&&a.jsx("span",{children:O.evidence.length>160?O.evidence.slice(0,160)+"…":O.evidence})]})]});return X?a.jsx("button",{type:"button",onClick:()=>x({consensusId:O.consensusId,findingId:O.findingId}),className:"w-full rounded-sm text-left transition hover:bg-accent/10",children:M},Q):a.jsx("div",{children:M},Q)})}),a.jsx(qi,{open:!!p,onOpenChange:O=>{O||x(null)},consensusId:(p==null?void 0:p.consensusId)??null,findingId:(p==null?void 0:p.findingId)??null})]})}function Qg(){const i=k.useRef(null),[r,u]=k.useState(0);return k.useEffect(()=>{const o=i.current;if(!o||typeof ResizeObserver>"u")return;const d=new ResizeObserver(m=>{for(const v of m)u(v.contentRect.width)});return d.observe(o),()=>d.disconnect()},[]),[i,r]}const th={agreement:"bg-confirmed",consensus_verified:"bg-confirmed",unique_confirmed:"bg-unique",unique_unconfirmed:"bg-unique/50",disagreement:"bg-disputed/70",hallucination_caught:"bg-disputed",new_finding:"bg-unique",unverified:"bg-unverified",citation_fabricated:"bg-amber-500",boundary_escape:"bg-destructive"},Zg={agreement:"Confirmed",consensus_verified:"Confirmed",unique_confirmed:"Unique (confirmed)",unique_unconfirmed:"Unique (unconfirmed)",disagreement:"Disputed",hallucination_caught:"Hallucination",new_finding:"New finding",unverified:"Unverified",citation_fabricated:"Fabricated citation",boundary_escape:"Process violation"},Kg=6,Jg=500,jh=100,Fg=150;function Ig(i){if(i<=0)return jh;const r=Math.floor(i/Kg);return Math.max(1,Math.min(r,Jg))}function Wg({agentId:i}){const[r,u]=k.useState([]),[o,d]=k.useState(0),[m,v]=k.useState(!1),[p,x]=k.useState(null),[g,b]=Qg(),[S,O]=k.useState(jh),Q=k.useRef(null);k.useEffect(()=>{if(b<=0)return;const K=Ig(b);return Q.current&&clearTimeout(Q.current),Q.current=setTimeout(()=>{O(ee=>ee===K?ee:K)},Fg),()=>{Q.current&&clearTimeout(Q.current)}},[b]),k.useEffect(()=>{Ge(`signals?agent=${encodeURIComponent(i)}&limit=${S}`).then(K=>{u(K.items||[]),d(K.total||0)}).catch(()=>{})},[i,S]);const L=k.useMemo(()=>[...r].reverse(),[r]),X={confirmed:0,disputed:0,unique:0,unverified:0,fabricated:0};for(const K of r)K.signal==="agreement"||K.signal==="consensus_verified"?X.confirmed++:K.signal==="disagreement"||K.signal==="hallucination_caught"?X.disputed++:K.signal==="unique_confirmed"||K.signal==="unique_unconfirmed"||K.signal==="new_finding"?X.unique++:K.signal==="unverified"?X.unverified++:K.signal==="citation_fabricated"&&X.fabricated++;const M=r.length,I=o>M;return r.length===0?a.jsx("div",{ref:g,className:"rounded-md border border-border/40 px-4 py-3",style:{background:"color-mix(in oklch, var(--surface-elev) 80%, transparent)"},children:a.jsx(da,{title:"No signal history yet",hint:"Signals are recorded during consensus rounds.",compact:!0})}):a.jsxs("div",{ref:g,className:"rounded-md border border-border/40 px-4 py-3",style:{background:"color-mix(in oklch, var(--surface-elev) 80%, transparent)"},children:[a.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-baseline gap-2",children:[a.jsx("span",{className:"h-section",children:"Signal Timeline"}),a.jsx("span",{className:"font-mono text-[9px]",style:{color:"color-mix(in oklch, var(--text-dim) 50%, transparent)"},children:I?`last ${M} of ${o}`:`${o} total`})]}),a.jsxs("div",{className:"flex items-center gap-3 font-mono text-[10px]",children:[a.jsxs("span",{className:"text-confirmed",children:[X.confirmed," confirmed"]}),X.disputed>0&&a.jsxs("span",{className:"text-disputed",children:[X.disputed," disputed"]}),X.unique>0&&a.jsxs("span",{className:"text-unique",children:[X.unique," unique"]}),X.unverified>0&&a.jsxs("span",{className:"text-unverified",children:[X.unverified," unverified"]}),X.fabricated>0&&a.jsxs("span",{className:"text-amber-500",children:[X.fabricated," fabricated"]})]})]}),a.jsx("div",{className:"flex items-center gap-0.5",children:L.map((K,ee)=>{const J=!!(K.consensusId&&K.findingId);return a.jsx("button",{type:"button",disabled:!J,onClick:()=>{K.consensusId&&K.findingId&&(x({consensusId:K.consensusId,findingId:K.findingId}),v(!0))},className:`h-4 min-w-[4px] flex-1 rounded-sm transition-opacity hover:opacity-80 ${th[K.signal]||""} ${J?"cursor-pointer":"cursor-default"}`,style:th[K.signal]?void 0:{background:"var(--surface-sunk)"},title:`${Zg[K.signal]||K.signal} — ${We(K.timestamp)}${J?" (click for detail)":""}`},ee)})}),a.jsx("div",{className:"mt-2 flex flex-wrap gap-3",children:[{color:"bg-confirmed",label:"Confirmed"},{color:"bg-disputed",label:"Disputed"},{color:"bg-unique",label:"Unique (confirmed)"},{color:"bg-unique/50",label:"Unique (unconfirmed)"},{color:"bg-unverified",label:"Unverified"},{color:"bg-amber-500",label:"Fabricated citation"}].map(K=>a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("div",{className:`h-2 w-2 rounded-sm ${K.color}`}),a.jsx("span",{className:"font-mono text-[9px]",style:{color:"color-mix(in oklch, var(--text-dim) 60%, transparent)"},children:K.label})]},K.label))}),a.jsx(qi,{open:m,onOpenChange:v,consensusId:(p==null?void 0:p.consensusId)??null,findingId:(p==null?void 0:p.findingId)??null})]})}function Pg(i){const r=i.toLowerCase();return r==="completed"||r==="done"||r==="success"||r==="succeeded"?"completed":r==="running"||r==="active"||r==="in_progress"||r==="pending"?"running":r==="failed"||r==="error"||r==="errored"||r==="timeout"||r==="timed_out"?"failed":r==="cancelled"||r==="canceled"||r==="queued"||r==="waiting"?"cancelled":"unknown"}const ey={completed:{label:"Done",iconBox:"bg-confirmed/10 border-confirmed/30",text:"text-confirmed",pulse:!1},running:{label:"Running",iconBox:"bg-unverified/10 border-unverified/30",text:"text-unverified",pulse:!0},failed:{label:"Failed",iconBox:"bg-destructive/10 border-destructive/30",text:"text-destructive",pulse:!1},cancelled:{label:"Cancelled",iconBox:"border-muted-foreground/25",text:"",textStyle:{color:"var(--text-dim)",background:"color-mix(in oklch, var(--text-dim) 10%, transparent)"},pulse:!1},unknown:{label:"Unknown",iconBox:"border-muted-foreground/25",text:"",textStyle:{color:"var(--text-dim)",background:"color-mix(in oklch, var(--text-dim) 10%, transparent)"},pulse:!1}},ty={completed:a.jsx("polyline",{points:"5 12 10 17 19 7"}),running:a.jsxs(a.Fragment,{children:[a.jsx("circle",{cx:"12",cy:"12",r:"3",fill:"currentColor",stroke:"none"}),a.jsx("circle",{cx:"12",cy:"12",r:"8",opacity:"0.45"})]}),failed:a.jsxs(a.Fragment,{children:[a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"}),a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"})]}),cancelled:a.jsx("line",{x1:"6",y1:"12",x2:"18",y2:"12"}),unknown:a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M9.5 9a2.5 2.5 0 1 1 3.5 2.3c-.8.4-1 .9-1 1.7"}),a.jsx("line",{x1:"12",y1:"16.5",x2:"12",y2:"16.5"})]})};function ny(i){if(!i)return"—";if(i<1e3)return"< 1s";if(i<6e4)return Math.floor(i/1e3)+"s";if(i<36e5){const o=Math.floor(i/6e4),d=Math.floor(i%6e4/1e3);return d>0?`${o}m ${d}s`:`${o}m`}const r=Math.floor(i/36e5),u=Math.floor(i%36e5/6e4);return u>0?`${r}h ${u}m`:`${r}h`}function Nh({task:i,onClick:r}){const u=Pg(i.status),o=ey[u];return a.jsxs("tr",{className:`border-b border-border hover:bg-accent/10 transition-colors ${r?"cursor-pointer":""}`,onClick:r?d=>{d.target.closest("a")||r(i)}:void 0,children:[a.jsx("td",{className:"py-2.5 pl-4 pr-2",children:a.jsxs("span",{className:"inline-flex items-center gap-2","aria-label":`Status: ${o.label}`,children:[a.jsx("span",{className:`flex h-[22px] w-[22px] shrink-0 items-center justify-center rounded-full border ${o.iconBox} ${o.text} ${o.pulse?"animate-pulse":""}`,style:o.textStyle,"aria-hidden":!0,children:a.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:ty[u]})}),a.jsx("span",{className:`font-mono text-[10px] font-semibold uppercase tracking-wider ${o.text}`,style:o.textStyle,children:o.label})]})}),a.jsx("td",{className:"py-2.5 pr-3",children:a.jsx("span",{className:"warn-badge rounded px-2 py-1 font-mono text-[10px] font-semibold",title:i.taskId,children:i.taskId.slice(0,8)})}),a.jsx("td",{className:"py-2.5 pr-3 font-mono text-xs",style:{color:"var(--text-dim)"},children:a.jsxs("a",{href:`/dashboard/agent/${encodeURIComponent(i.agentId)}`,className:"inline-flex items-center gap-1.5 transition",children:[a.jsx("span",{className:"inline-block h-2 w-2 shrink-0 rounded-full",style:{backgroundColor:gn(i.agentId)}}),i.agentId]})}),a.jsx("td",{className:"py-2.5 pr-3 text-xs leading-snug",style:{color:"color-mix(in oklch, var(--text) 80%, transparent)"},children:(()=>{const d=i.task.replace(/\n.*/s,"");return d.length>100?d.slice(0,100)+"…":d})()}),a.jsx("td",{className:"py-2.5 pr-3 font-mono text-xs",style:{color:"var(--text-dim)"},children:u==="running"?"running":ny(i.duration)}),a.jsx("td",{className:"py-2.5 pr-4 text-right font-mono text-xs",style:{color:"color-mix(in oklch, var(--text-dim) 50%, transparent)"},children:We(i.timestamp)})]})}const ly=3,ay=720*60*60*1e3;function sy({agentId:i,agents:r,tasks:u,consensus:o}){const d=r.find(y=>y.id===i),[m,v]=k.useState([]),[p,x]=k.useState([]),[g,b]=k.useState(null),[S,O]=k.useState(null),[Q,L]=k.useState(null),[X,M]=k.useState(0),[I,K]=k.useState(0),[ee,J]=k.useState(null);k.useEffect(()=>{Ge(`memory/${i}`).then(y=>{v(y.knowledge||[])}).catch(()=>v([]))},[i]),k.useEffect(()=>{let y=!1;return Ge("consensus-reports?page=1&pageSize=200").then(R=>{y||x(R.reports||[])}).catch(()=>{y||x([])}),()=>{y=!0}},[]);const A=k.useMemo(()=>{var G;const y=Date.now(),R=new Map;for(const le of p){const re=Date.parse(le.timestamp);if(Number.isNaN(re)||y-re>ay)continue;const ve=(G=le.authorDiagnostics)==null?void 0:G[i];if(ve)for(const Re of ve)R.set(Re.code,(R.get(Re.code)??0)+1)}const V=[];for(const[le,re]of R)re>=ly&&V.push({code:le,count:re});return V},[p,i]);if(!d)return a.jsxs("div",{className:"py-20 text-center",style:{color:"var(--text-dim)"},children:["Agent not found: ",i]});const q=d.scores,w=(u==null?void 0:u.items.filter(y=>y.agentId===i))||[],Z=(o==null?void 0:o.runs.filter(y=>y.agents.includes(i)))||[],te=[{label:"accuracy",value:q.accuracy,fill:q.accuracy>=.7?"bg-confirmed":q.accuracy>=.4?"bg-unverified":"bg-disputed"},{label:"unique",value:q.uniqueness,fill:"bg-unique"},{label:"impact",value:q.impactScore,fill:"bg-[var(--c8)]"}],ne=q.unverifiedsEmitted??0,de=q.unverifiedsReceived??0,F=ne+de,ae=[{label:"Signals",value:String(q.signals),color:"",colorStyle:{color:"var(--text)"}},{label:"Agreements",value:String(q.agreements),color:"text-confirmed",colorStyle:void 0},{label:"Disagreements",value:String(q.disagreements),color:"text-disputed",colorStyle:void 0},{label:"Hallucinations",value:String(q.hallucinations),color:q.hallucinations>0?"text-disputed":"",colorStyle:q.hallucinations>0?void 0:{color:"var(--text-dim)"}},{label:"Unverified",value:F>0?`${ne}↑ ${de}↓`:"0",color:F>0?"text-unverified":"",colorStyle:F>0?void 0:{color:"var(--text-dim)"},title:F>0?`${ne} emitted (as reviewer) · ${de} received (as author)`:void 0},{label:"Tokens",value:d.totalTokens.toLocaleString(),color:"",colorStyle:{color:"var(--text)"}}],me=10,E=Math.max(1,Math.ceil(w.length/me)),T=Math.min(X,E-1),H=w.slice(T*me,(T+1)*me),W=k.useMemo(()=>{const y=new Map;for(const R of m){const V=R.filename.match(/^(\d{4}-\d{2}-\d{2})/),G=V?V[1]:"undated",le=y.get(G)||[];le.push(R),y.set(G,le)}return Array.from(y.entries()).sort(([R],[V])=>R==="undated"?1:V==="undated"?-1:V.localeCompare(R)).map(([R,V])=>({day:R,items:V}))},[m]),ce=Math.min(I,Math.max(0,W.length-1)),ue=W[ce];return a.jsxs(a.Fragment,{children:[(()=>{const y=_o(q);return y==="benched"?a.jsx("div",{className:"mb-6 rounded-lg border border-destructive/30 bg-destructive/5 px-4 py-3",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"font-mono text-xs font-bold text-destructive",children:"BENCHED"}),a.jsxs("span",{className:"text-xs text-destructive/70",children:["Auto-bench rule fired (",q.bench.reason??"unknown","). Agent excluded from dispatch until scores recover."]})]})}):y==="struggling"?a.jsx("div",{className:"mb-6 rounded-lg border border-unverified/30 bg-unverified/5 px-4 py-3",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"font-mono text-xs font-bold text-unverified",children:"STRUGGLING"}),a.jsxs("span",{className:"text-xs text-unverified/70",children:[q.consecutiveFailures,"+ consecutive failures. Deprioritized until clean signals recorded."]})]})}):y==="kept-for-coverage"?a.jsx("div",{className:"mb-6 rounded-lg border border-unverified/30 bg-unverified/5 px-4 py-3",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"font-mono text-xs font-bold text-unverified",children:"KEPT FOR COVERAGE"}),a.jsxs("span",{className:"text-xs text-unverified/70",children:["Would be benched (",q.bench.reason??"rule","), but is the sole provider of a category — kept to preserve coverage."]})]})}):null})(),A.length>0&&a.jsx("div",{className:"mb-6 space-y-2",children:A.map(({code:y,count:R})=>a.jsxs("div",{className:"rounded-lg border border-unverified/30 bg-unverified/5 px-4 py-3","data-diagnostic-code":y,children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"font-mono text-xs font-bold text-unverified",children:"PARSE DIAGNOSTIC"}),a.jsx("span",{className:"font-mono text-[11px] text-unverified/80",dangerouslySetInnerHTML:{__html:No(y)}}),a.jsxs("span",{className:"font-mono text-[11px] text-unverified/60",children:["· ",R," fires in 30d"]})]}),a.jsxs("div",{className:"mt-1 text-xs",style:{color:"color-mix(in oklch, var(--text-dim) 80%, transparent)"},children:["This agent's raw output has repeatedly tripped ",a.jsx("span",{className:"font-mono",children:y}),". Inspect recent consensus rounds on this page for the per-finding banner, or check upstream pipeline layers (sanitizer / renderer / relay encoding)."]})]},y))}),a.jsx("div",{"data-theme":"dark",className:"relative mb-6 rounded-xl border border-border p-5",style:{background:"var(--surface-elev)",color:"var(--text)"},children:a.jsxs("div",{className:"flex items-center gap-6",children:[a.jsx("div",{className:"relative shrink-0","data-tooltip":`Accuracy ${Math.round(q.accuracy*100)}% · Uniqueness ${Math.round(q.uniqueness*100)}% · Impact ${Math.round(q.impactScore*100)}%`,children:a.jsx(us,{agentId:d.id,size:120,signals:q.signals,accuracy:q.accuracy,uniqueness:q.uniqueness,impact:q.impactScore})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("h1",{className:"truncate font-mono text-2xl font-bold",style:{color:"var(--text)"},children:d.id}),a.jsxs("p",{className:"mt-1 text-sm",style:{color:"var(--text-dim)"},children:[d.provider,"/",d.model]}),a.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[a.jsx("span",{className:`rounded-sm px-2 py-0.5 font-mono text-[10px] font-semibold ${d.native?"":"text-confirmed bg-confirmed/10"}`,style:d.native?{color:"var(--idle)",background:"color-mix(in oklch, var(--idle) 10%, transparent)"}:void 0,children:d.native?"NATIVE":"RELAY"}),d.preset&&a.jsx("span",{className:"rounded-sm px-2 py-0.5 font-mono text-[10px]",style:{background:"var(--surface-sunk)",color:"var(--text-dim)"},children:d.preset}),a.jsxs("span",{className:"font-mono text-[10px]",style:{color:"color-mix(in oklch, var(--text-dim) 60%, transparent)"},children:[q.signals," signals",d.lastTask?` · ${We(d.lastTask.timestamp)}`:""]})]})]}),a.jsxs("div",{className:"flex shrink-0 flex-col items-end rounded-md border border-border px-3 py-2",style:{background:"color-mix(in oklch, var(--surface) 60%, transparent)"},"data-tooltip":`Dispatch weight ${q.dispatchWeight.toFixed(2)}
|
|
78
|
-
Scale 0.3 → 2.0`,"data-tooltip-pos":"left",children:[a.jsx("span",{className:"font-mono text-2xl font-bold tabular-nums leading-none",style:{color:"var(--text)"},children:q.dispatchWeight.toFixed(2)}),a.jsx("span",{className:"mt-1 font-mono text-[9px] uppercase",style:{color:"color-mix(in oklch, var(--text-dim) 50%, transparent)"},children:"weight"})]})]})}),a.jsx("section",{className:"mb-6",children:a.jsx(Wg,{agentId:i})}),a.jsxs("section",{className:"mb-8 grid grid-cols-1 gap-6 lg:grid-cols-2",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"mb-3 h-section",children:"Metrics"}),a.jsxs("div",{className:"rounded-lg border border-border/40 p-4",style:{background:"color-mix(in oklch, var(--surface-elev) 80%, transparent)"},children:[a.jsx("div",{className:"space-y-2.5",children:te.map(y=>a.jsxs("div",{className:"grid grid-cols-[72px_1fr_44px] items-center gap-3",children:[a.jsx("span",{className:"h-section",style:{color:"var(--text-dim)",fontSize:"10px"},children:y.label}),a.jsx("div",{className:"h-1.5 overflow-hidden rounded-full",style:{background:"color-mix(in oklch, var(--surface) 80%, transparent)"},children:a.jsx("div",{className:`h-full rounded-full transition-all ${y.fill}`,style:{width:`${Math.max(0,Math.min(100,y.value*100))}%`}})}),a.jsxs("span",{className:"text-right font-mono text-[11px] font-bold tabular-nums",style:{color:"var(--text)"},children:[Math.round(y.value*100),"%"]})]},y.label))}),a.jsx("div",{className:"mt-4 grid grid-cols-6 gap-px overflow-hidden rounded-md border border-border/30 bg-border/30",children:ae.map(y=>a.jsxs("div",{className:"px-2 py-2 text-center",style:{background:"color-mix(in oklch, var(--surface) 60%, transparent)"},title:y.title,children:[a.jsx("div",{className:`font-mono text-sm font-bold tabular-nums ${y.color}`,style:y.colorStyle,children:y.value}),a.jsx("div",{className:"mt-0.5 font-mono text-[9px] uppercase tracking-wider",style:{color:"color-mix(in oklch, var(--text-dim) 70%, transparent)"},children:y.label})]},y.label))})]})]}),a.jsxs("div",{children:[a.jsx("h2",{className:"mb-1 h-section",children:"Category Competency"}),a.jsx("p",{className:"mb-3 mt-0.5 font-mono text-[11px]",style:{color:"color-mix(in oklch, var(--text-dim) 80%, transparent)"},children:"◆ Raw per-category ratio — unweighted. Overall accuracy in Metrics applies a hallucination penalty."}),a.jsx(wg,{categoryAccuracy:q.categoryAccuracy,categoryCorrect:q.categoryCorrect,categoryHallucinated:q.categoryHallucinated})]})]}),(d.skillSlots.length>0||d.skills.length>0)&&a.jsxs("section",{className:"mb-8",children:[a.jsxs("h2",{className:"mb-3 h-section",children:["Skills ",a.jsx("span",{style:{color:"var(--ink)",fontWeight:700},children:d.skillSlots.length||d.skills.length})]}),d.skillSlots.length>0?a.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-3",children:d.skillSlots.map(y=>a.jsx(Ug,{slot:y},y.name))}):a.jsx("div",{className:"flex flex-wrap gap-1.5",children:d.skills.map(y=>a.jsx("span",{className:"rounded-sm border border-border px-2.5 py-1 font-mono text-xs",style:{background:"var(--surface-elev)",color:"var(--text-dim)"},children:y},y))})]}),a.jsxs("section",{className:"mb-8",children:[a.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[a.jsxs("h2",{className:"h-section",children:["Tasks ",a.jsx("span",{style:{color:"var(--ink)",fontWeight:700},children:w.length})]}),E>1&&a.jsxs("div",{className:"flex items-center gap-2 font-mono text-[10px]",style:{color:"var(--text-dim)"},children:[a.jsx("button",{onClick:()=>M(y=>Math.max(0,y-1)),disabled:T===0,className:"rounded-sm border border-border/40 px-2 py-0.5 transition hover:bg-accent/10 disabled:opacity-30",style:{background:"var(--surface-elev)"},children:"◂ Prev"}),a.jsxs("span",{children:[T+1," / ",E]}),a.jsx("button",{onClick:()=>M(y=>Math.min(E-1,y+1)),disabled:T>=E-1,className:"rounded-sm border border-border/40 px-2 py-0.5 transition hover:bg-accent/10 disabled:opacity-30",style:{background:"var(--surface-elev)"},children:"Next ▸"})]})]}),w.length>0?a.jsx("div",{className:"overflow-hidden rounded-md border border-border/40",children:a.jsxs("table",{className:"w-full text-left",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b border-border",style:{background:"var(--surface-elev)"},children:[a.jsx("th",{className:"py-2 pl-4 pr-2 text-xs font-medium",style:{width:32,color:"var(--text-dim)"}}),a.jsx("th",{className:"py-2 pr-3 font-mono text-xs font-medium",style:{color:"var(--text-dim)"},children:"ID"}),a.jsx("th",{className:"py-2 pr-3 font-mono text-xs font-medium",style:{color:"var(--text-dim)"},children:"Agent"}),a.jsx("th",{className:"py-2 pr-3 text-xs font-medium",style:{color:"var(--text-dim)"},children:"Description"}),a.jsx("th",{className:"py-2 pr-3 font-mono text-xs font-medium",style:{color:"var(--text-dim)"},children:"Duration"}),a.jsx("th",{className:"py-2 pr-4 text-right font-mono text-xs font-medium",style:{color:"var(--text-dim)"},children:"When"})]})}),a.jsx("tbody",{children:H.map(y=>a.jsx(Nh,{task:y,onClick:J},y.taskId))})]})}):a.jsx("div",{className:"py-6 text-center text-sm",style:{color:"var(--text-dim)"},children:"No tasks recorded."})]}),a.jsxs("section",{className:"mb-8",children:[a.jsxs("h2",{className:"mb-3 h-section",children:["Consensus Runs ",a.jsx("span",{style:{color:"var(--ink)",fontWeight:700},children:Z.length})]}),Z.length>0?a.jsx("div",{className:"space-y-2",children:Z.slice(0,20).map((y,R)=>{const V=y.counts,G=(V.agreement||0)+(V.disagreement||0)+(V.hallucination||0)+(V.unverified||0)+(V.unique||0)+(V.new||0),le=G||1,re=[{key:"confirmed",count:V.agreement||0,color:"bg-confirmed",text:"text-confirmed"},{key:"disputed",count:(V.disagreement||0)+(V.hallucination||0),color:"bg-disputed",text:"text-disputed"},{key:"unverified",count:V.unverified||0,color:"bg-unverified",text:"text-unverified"},{key:"unique",count:(V.unique||0)+(V.new||0),color:"bg-unique",text:"text-unique"}],ve={agreement:{label:"CONFIRMED",cls:"text-confirmed bg-confirmed/10"},consensus_verified:{label:"CONFIRMED",cls:"text-confirmed bg-confirmed/10"},disagreement:{label:"DISPUTED",cls:"text-disputed bg-disputed/10"},hallucination_caught:{label:"DISPUTED",cls:"text-disputed bg-disputed/10"},unverified:{label:"UNVERIFIED",cls:"text-unverified bg-unverified/10"},unique_confirmed:{label:"UNIQUE",cls:"text-unique bg-unique/10"},unique_unconfirmed:{label:"UNIQUE",cls:"text-unique bg-unique/10"},new_finding:{label:"NEW",cls:"text-unique bg-unique/10"}},Re=y.signals.filter(Ae=>Ae.signal!=="signal_retracted"&&ve[Ae.signal]),Me=y.taskId+":"+R,qt=S===Me;return a.jsxs("div",{className:"rounded-md border border-border/40",style:{background:"var(--surface-elev)"},children:[a.jsx("button",{type:"button",onClick:()=>O(qt?null:Me),disabled:Re.length===0,className:`flex w-full items-center p-3 text-left transition ${Re.length>0?"hover:bg-accent/20":"cursor-default"}`,children:a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("span",{className:"font-mono text-sm font-semibold",style:{color:"var(--text)"},children:[Re.length>0&&a.jsx("span",{className:"mr-1.5 inline-block",style:{color:"var(--text-dim)"},children:qt?"▾":"▸"}),G," findings"]}),a.jsx("span",{className:"font-mono text-xs",style:{color:"var(--text-dim)"},children:We(y.timestamp)})]}),a.jsx("div",{className:"mt-1.5 flex gap-2",children:re.map(Ae=>Ae.count>0&&a.jsxs("span",{className:`font-mono text-[10px] font-semibold ${Ae.text}`,children:[Ae.count," ",Ae.key]},Ae.key))}),a.jsx("div",{className:"mt-1.5 flex h-1.5 overflow-hidden rounded-sm",children:re.map(Ae=>Ae.count>0&&a.jsx("div",{className:Ae.color,style:{width:`${Ae.count/le*100}%`}},Ae.key))})]})}),qt&&Re.length>0&&a.jsx("div",{className:"border-t border-border/30 px-3 pb-2 pt-2",children:a.jsx("div",{className:"space-y-1",children:Re.map((Ae,yn)=>{const Zn=ve[Ae.signal],Lt=!!(Ae.findingId&&y.taskId),Yt=a.jsxs("div",{className:"flex items-start gap-2 py-1",children:[a.jsx("span",{className:`shrink-0 rounded-sm px-1.5 py-0.5 font-mono text-[9px] font-bold ${Zn.cls}`,children:Zn.label}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("span",{className:"finding-md text-xs [&_.cite-file]:rounded [&_.cite-file]:bg-blue-500/10 [&_.cite-file]:px-1 [&_.cite-file]:font-mono [&_.cite-file]:text-blue-400 [&_.cite-fn]:rounded [&_.cite-fn]:bg-purple-500/10 [&_.cite-fn]:px-1 [&_.cite-fn]:font-mono [&_.cite-fn]:text-purple-400",style:{color:"var(--text-dim)"},dangerouslySetInnerHTML:{__html:Oi(Ae.evidence||"")}}),a.jsxs("span",{className:"ml-2 font-mono text-[10px]",style:{color:"color-mix(in oklch, var(--text-dim) 50%, transparent)"},children:[Ae.agentId,Ae.counterpartId?` + ${Ae.counterpartId}`:""]})]})]});return Lt?a.jsx("button",{type:"button",onClick:()=>L({consensusId:y.taskId,findingId:Ae.findingId}),className:"block w-full rounded-sm text-left transition hover:bg-accent/10",children:Yt},yn):a.jsx("div",{children:Yt},yn)})})})]},Me)})}):a.jsx("div",{className:"py-6 text-center text-sm",style:{color:"var(--text-dim)"},children:"No consensus participation recorded."})]}),a.jsx("section",{className:"mb-8",children:a.jsx(Vg,{agentId:i})}),a.jsx(qi,{open:!!Q,onOpenChange:y=>{y||L(null)},consensusId:(Q==null?void 0:Q.consensusId)??null,findingId:(Q==null?void 0:Q.findingId)??null}),a.jsx(bh,{task:ee,onClose:()=>J(null)}),a.jsxs("section",{className:"mb-8",children:[a.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[a.jsxs("h2",{className:"h-section",children:["Memory ",a.jsxs("span",{style:{color:"var(--ink)",fontWeight:700},children:[m.length," files"]}),ue&&a.jsxs("span",{className:"ml-2 font-mono text-[10px]",style:{color:"var(--text-dim)"},children:["· ",ue.day," (",ue.items.length,")"]})]}),W.length>1&&a.jsxs("div",{className:"flex items-center gap-2 font-mono text-[10px]",style:{color:"var(--text-dim)"},children:[a.jsx("button",{onClick:()=>K(y=>Math.max(0,y-1)),disabled:ce===0,className:"rounded-sm border border-border/40 px-2 py-0.5 transition hover:bg-accent/10 disabled:opacity-30",style:{background:"var(--surface-elev)"},children:"◂ Newer"}),a.jsxs("span",{children:[ce+1," / ",W.length]}),a.jsx("button",{onClick:()=>K(y=>Math.min(W.length-1,y+1)),disabled:ce>=W.length-1,className:"rounded-sm border border-border/40 px-2 py-0.5 transition hover:bg-accent/10 disabled:opacity-30",style:{background:"var(--surface-elev)"},children:"Older ▸"})]})]}),ue&&ue.items.length>0?a.jsx("div",{className:"space-y-1.5",children:ue.items.map(y=>{var le,re;const R=g===y.filename,V=((le=y.frontmatter)==null?void 0:le.type)||"memory",G=((re=y.frontmatter)==null?void 0:re.name)||y.filename.replace(/\.md$/,"");return a.jsxs("div",{className:"rounded-md border border-border/40",style:{background:"color-mix(in oklch, var(--surface-elev) 80%, transparent)"},children:[a.jsxs("button",{onClick:()=>b(R?null:y.filename),className:"flex w-full items-center gap-2 p-3 text-left transition hover:bg-accent/10",children:[a.jsx("span",{className:"font-mono text-xs",style:{color:R?"var(--text)":"var(--text-dim)"},children:R?"▾":"▸"}),a.jsx("span",{className:"shrink-0 rounded-sm px-1.5 py-0.5 font-mono text-[9px] font-bold uppercase",style:{background:"var(--surface-sunk)",color:"var(--text-dim)"},children:V}),a.jsx("span",{className:"truncate font-mono text-xs font-semibold",style:{color:"var(--text)"},children:G}),a.jsx("span",{className:"ml-auto shrink-0 font-mono text-[10px]",style:{color:"var(--text-dim)"},children:y.filename})]}),R&&a.jsx("div",{className:"border-t border-border px-4 py-3",children:a.jsx("pre",{className:"whitespace-pre-wrap font-mono text-xs leading-relaxed",style:{color:"var(--text-dim)"},children:y.content})})]},y.filename)})}):a.jsx("div",{className:"py-6 text-center text-sm",style:{color:"var(--text-dim)"},children:"No memory files."})]})]})}const nh={dispatch:{color:"color-mix(in oklch, var(--text-dim) 80%, transparent)"},consensus:{color:"color-mix(in oklch, var(--info) 80%, transparent)"},error:{},timeout:{},worker:{color:"color-mix(in oklch, var(--text-dim) 70%, transparent)"},gemini:{color:"color-mix(in oklch, var(--text-dim) 70%, transparent)"},skill:{color:"color-mix(in oklch, var(--text-dim) 80%, transparent)"},boot:{color:"color-mix(in oklch, var(--text-dim) 50%, transparent)"},relay:{color:"color-mix(in oklch, var(--text-dim) 80%, transparent)"},gossip:{color:"color-mix(in oklch, var(--text-dim) 80%, transparent)"},utility:{color:"color-mix(in oklch, var(--text-dim) 60%, transparent)"},memory:{color:"color-mix(in oklch, var(--text-dim) 80%, transparent)"},persist:{color:"color-mix(in oklch, var(--text-dim) 50%, transparent)"},toolserver:{color:"color-mix(in oklch, var(--text-dim) 50%, transparent)"},other:{color:"color-mix(in oklch, var(--text-dim) 70%, transparent)"}},iy={error:"text-disputed",timeout:"text-unverified"},cy=[[/^\[gossipcat\]\s*\[worker:/,"worker"],[/^\[gossipcat\]\s*\[Gemini\]/,"gemini"],[/^\[gossipcat\]\s*\[ToolServer\]/,"toolserver"],[/^\[gossipcat\]\s*dispatch\b/,"dispatch"],[/^\[gossipcat\]\s*relay\b/,"relay"],[/^\[gossipcat\]\s*Cross-review\b/,"consensus"],[/^\[gossipcat\]\s*Consensus\b/,"consensus"],[/^\[gossipcat\]\s*Skill\b/,"skill"],[/^\[gossipcat\]\s*Bootstrap\b/,"boot"],[/^\[gossipcat\]\s*Booted:/,"boot"],[/^\[gossipcat\]\s*Dashboard:/,"boot"],[/^\[gossipcat\]\s*Adaptive\b/,"boot"],[/^\[gossipcat\]\s*Gossip\b/,"gossip"],[/^\[gossipcat\]\s*utility\b/,"utility"],[/^\[gossipcat\]\s*Compacted\b/,"memory"],[/native agent/,"boot"],[/persist|Persist/,"persist"],[/timeout|Timeout|timed.out/,"timeout"],[/^\[gossipcat\].*(?:Error|error|failed|Failed)/,"error"]];function ry(i){for(const[r,u]of cy)if(r.test(i))return u;return"other"}const oy=[{key:"all",label:"All"},{key:"dispatch",label:"Dispatch"},{key:"consensus",label:"Consensus"},{key:"error",label:"Errors"},{key:"timeout",label:"Timeouts"},{key:"worker",label:"Workers"},{key:"skill",label:"Skills"},{key:"relay",label:"Relay"},{key:"boot",label:"Boot"}],lh=1e3;function uy(){const[i,r]=k.useState([]),[u,o]=k.useState(0),[d,m]=k.useState(0),[v,p]=k.useState("all"),[x,g]=k.useState(!0),[b,S]=k.useState(!0),O=k.useRef(null),Q=k.useRef(0);k.useEffect(()=>{let M=!1;return(async()=>{try{const K=await Ge("logs?tail=500");if(M)return;r(K.entries),o(K.totalLines),m(K.fileSize),Q.current=K.totalLines+1}catch{}})(),()=>{M=!0}},[]),k.useEffect(()=>{if(b)return hh(M=>{var K;if(M.type!=="log_lines")return;const I=(K=M.data)==null?void 0:K.lines;I!=null&&I.length&&r(ee=>{const J=I.map((q,w)=>({line:Q.current+w,text:q,category:ry(q)}));Q.current+=I.length,o(q=>q+I.length);const A=[...ee,...J];return A.length>lh?A.slice(-lh):A})})},[b]),k.useEffect(()=>{x&&O.current&&O.current.scrollIntoView({behavior:"smooth"})},[i,x]);const L=v==="all"?i:i.filter(M=>M.category===v),X=k.useCallback(M=>M<1024?`${M} B`:M<1048576?`${(M/1024).toFixed(1)} KB`:`${(M/1048576).toFixed(1)} MB`,[]);return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"mb-4 flex items-baseline gap-3",children:[a.jsx("h1",{className:"h-route",children:"MCP Log"}),a.jsxs("span",{className:"font-mono text-sm tabular-nums",style:{color:"var(--ink-3)"},children:[u," lines"]}),a.jsx("span",{className:"font-mono text-[10px]",style:{color:"color-mix(in oklch, var(--text-dim) 50%, transparent)"},children:X(d)}),b&&a.jsxs("span",{className:"flex items-center gap-1 font-mono text-[10px] text-confirmed",children:[a.jsx("span",{className:"inline-block h-1.5 w-1.5 animate-pulse rounded-full bg-confirmed"}),"live"]})]}),a.jsxs("div",{className:"mb-3 flex items-center gap-1.5",children:[oy.map(M=>a.jsx("button",{onClick:()=>p(M.key),className:"rounded-sm px-2.5 py-1 font-mono text-[10px] font-semibold transition",style:v===M.key?{background:"var(--surface-sunk)",color:"var(--text)"}:{color:"var(--text-dim)"},children:M.label},M.key)),a.jsxs("div",{className:"ml-auto flex gap-1.5",children:[a.jsx("button",{onClick:()=>S(!b),className:`rounded-sm px-2.5 py-1 font-mono text-[10px] font-semibold transition ${b?"bg-confirmed/10 text-confirmed":""}`,style:b?void 0:{color:"var(--text-dim)"},children:b?"● Live":"○ Paused"}),a.jsx("button",{onClick:()=>g(!x),className:"rounded-sm px-2.5 py-1 font-mono text-[10px] font-semibold transition",style:x?{color:"var(--ok)",background:"color-mix(in oklch, var(--ok) 10%, transparent)"}:{color:"var(--text-dim)"},children:x?"⤓ Auto":"⤓ Scroll"})]})]}),a.jsx("div",{className:"overflow-hidden rounded-md border border-border",style:{background:"var(--surface-elev)"},children:a.jsxs("div",{className:"max-h-[70vh] overflow-y-auto p-3 font-mono text-xs leading-relaxed",children:[L.map(M=>a.jsxs("div",{className:"flex gap-2 hover:bg-accent/10",children:[a.jsx("span",{className:"w-10 shrink-0 select-none text-right",style:{color:"color-mix(in oklch, var(--text-dim) 30%, transparent)"},children:M.line}),a.jsx("span",{className:iy[M.category]??"",style:nh[M.category]??nh.other,children:M.text})]},M.line)),L.length===0&&a.jsx("div",{className:"py-8 text-center font-mono text-xs",style:{color:"var(--text-dim)"},children:i.length===0?"Loading...":v==="all"?"No log entries in current tail.":`No ${v} entries in current tail.`}),a.jsx("div",{ref:O})]})})]})}const dy=["critical","high","medium","low"],fy=["manual","impl","meta","auto-provisional"];function ah(i,r){return i.includes(r)?i.filter(u=>u!==r):[...i,r]}const Kt="mb-1 block h-section",Jt={},Vn="w-full rounded border border-border px-2 py-1 font-mono text-[10px] focus:border-primary focus:outline-none",Qn={background:"var(--surface)",color:"var(--text)"};function my({filters:i,onChange:r,agents:u,signalTypes:o}){const d=m=>v=>{const p=v.target.value;r({[m]:p===""?void 0:p})};return a.jsxs("aside",{className:"space-y-3 rounded-md border border-border/60 p-3",style:{background:"color-mix(in oklch, var(--surface-elev) 70%, transparent)"},children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("h2",{className:"h-section",children:"Filters"}),a.jsx("button",{type:"button",className:"font-mono text-[9px]",style:{color:"color-mix(in oklch, var(--text-dim) 70%, transparent)"},onClick:()=>r({agents:[],counterpart:void 0,signals:[],category:void 0,severity:void 0,since:void 0,until:void 0,consensusId:void 0,findingId:void 0,source:void 0}),children:"clear"})]}),a.jsxs("div",{children:[a.jsxs("label",{className:Kt,style:Jt,children:["Agents (",i.agents.length," selected)"]}),a.jsxs("div",{className:"max-h-32 overflow-y-auto rounded border border-border/60 p-1",style:{background:"var(--surface)"},children:[u.length===0&&a.jsx("div",{className:"px-1 py-0.5 font-mono text-[10px]",style:{color:"color-mix(in oklch, var(--text-dim) 50%, transparent)"},children:"no agents"}),u.map(m=>a.jsxs("label",{className:"flex cursor-pointer items-center gap-1.5 px-1 py-0.5 font-mono text-[10px] hover:bg-accent/20",style:{color:"var(--text)"},children:[a.jsx("input",{type:"checkbox",className:"h-3 w-3",checked:i.agents.includes(m),onChange:()=>r({agents:ah(i.agents,m)})}),a.jsx("span",{children:m})]},m))]})]}),a.jsxs("div",{children:[a.jsx("label",{className:Kt,style:Jt,children:"Counterpart"}),a.jsxs("select",{className:Vn,style:Qn,value:i.counterpart??"",onChange:d("counterpart"),children:[a.jsx("option",{value:"",children:"any"}),u.map(m=>a.jsx("option",{value:m,children:m},m))]})]}),a.jsxs("div",{children:[a.jsxs("label",{className:Kt,style:Jt,children:["Signal types (",i.signals.length,")"]}),a.jsxs("div",{className:"max-h-32 overflow-y-auto rounded border border-border/60 p-1",style:{background:"var(--surface)"},children:[o.length===0&&a.jsx("div",{className:"px-1 py-0.5 font-mono text-[10px]",style:{color:"color-mix(in oklch, var(--text-dim) 50%, transparent)"},children:"no signals"}),o.map(m=>a.jsxs("label",{className:"flex cursor-pointer items-center gap-1.5 px-1 py-0.5 font-mono text-[10px] hover:bg-accent/20",style:{color:"var(--text)"},children:[a.jsx("input",{type:"checkbox",className:"h-3 w-3",checked:i.signals.includes(m),onChange:()=>r({signals:ah(i.signals,m)})}),a.jsx("span",{children:m})]},m))]})]}),a.jsxs("div",{children:[a.jsx("label",{className:Kt,style:Jt,children:"Severity"}),a.jsxs("select",{className:Vn,style:Qn,value:i.severity??"",onChange:d("severity"),children:[a.jsx("option",{value:"",children:"any"}),dy.map(m=>a.jsx("option",{value:m,children:m},m))]})]}),a.jsxs("div",{children:[a.jsx("label",{className:Kt,style:Jt,"data-tooltip":"manual = operator-recorded · impl = implementer pipeline · meta = orchestrator self-telemetry · auto-provisional = unvalidated",children:"Source"}),a.jsxs("select",{className:Vn,style:Qn,value:i.source??"",onChange:d("source"),children:[a.jsx("option",{value:"",children:"any"}),fy.map(m=>a.jsx("option",{value:m,children:m},m))]})]}),a.jsxs("div",{children:[a.jsx("label",{className:Kt,style:Jt,children:"Category"}),a.jsx("input",{type:"text",className:Vn,style:Qn,value:i.category??"",onChange:d("category"),placeholder:"e.g. trust_boundaries"})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[a.jsxs("div",{children:[a.jsx("label",{className:Kt,style:Jt,children:"Since"}),a.jsx("input",{type:"datetime-local",className:Vn,style:Qn,value:i.since?i.since.slice(0,16):"",onChange:m=>r({since:m.target.value?new Date(m.target.value).toISOString():void 0})})]}),a.jsxs("div",{children:[a.jsx("label",{className:Kt,style:Jt,children:"Until"}),a.jsx("input",{type:"datetime-local",className:Vn,style:Qn,value:i.until?i.until.slice(0,16):"",onChange:m=>r({until:m.target.value?new Date(m.target.value).toISOString():void 0})})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:Kt,style:Jt,children:"Consensus ID (prefix)"}),a.jsx("input",{type:"text",className:Vn,style:Qn,value:i.consensusId??"",onChange:d("consensusId"),placeholder:"e.g. d07eac46"})]}),a.jsxs("div",{children:[a.jsx("label",{className:Kt,style:Jt,children:"Finding ID (prefix)"}),a.jsx("input",{type:"text",className:Vn,style:Qn,value:i.findingId??"",onChange:d("findingId"),placeholder:"e.g. d07eac46-5f464e89:sonnet"})]})]})}const sh={agents:[],signals:[]},hy=["agreement","consensus_verified","unique_confirmed","unique_unconfirmed","disagreement","hallucination_caught","new_finding","unverified","impl_test_pass","impl_test_fail","impl_typecheck_pass","impl_typecheck_fail","task_completed","tool_turns","format_compliance"],xy={agreement:"Agreement",consensus_verified:"Consensus verified",unique_confirmed:"Unique (confirmed)",unique_unconfirmed:"Unique (unconfirmed)",disagreement:"Disagreement",hallucination_caught:"Hallucination",new_finding:"New finding",unverified:"Unverified",impl_test_pass:"Test pass",impl_test_fail:"Test fail",impl_typecheck_pass:"Typecheck pass",impl_typecheck_fail:"Typecheck fail",impl_peer_approved:"Peer approved",impl_peer_rejected:"Peer rejected",boundary_escape:"Boundary escape"},py={agreement:"var(--ok)",consensus_verified:"var(--ok)",impl_test_pass:"var(--ok)",impl_typecheck_pass:"var(--ok)",impl_peer_approved:"var(--ok)",disagreement:"var(--bad)",hallucination_caught:"var(--bad)",impl_test_fail:"var(--bad)",impl_typecheck_fail:"var(--bad)",impl_peer_rejected:"var(--bad)",boundary_escape:"var(--bad)",unique_confirmed:"var(--info)",unique_unconfirmed:"var(--info)",new_finding:"var(--info)",unverified:"var(--info)"},vy={critical:"var(--bad)",high:"var(--warn)",medium:"var(--severity-medium)",low:"var(--ink-3)"},is=100;function gy(){if(typeof window>"u")return{filters:sh,hadAny:!1};const i=new URLSearchParams(window.location.search),r=i.getAll("signal").filter(Boolean),u=i.get("agent"),o=i.get("counterpart")??void 0,d=i.get("category")??void 0,m=i.get("severity"),v=m==="critical"||m==="high"||m==="medium"||m==="low"?m:void 0,p=i.get("since")??void 0,x=i.get("until")??void 0,g=i.get("consensus_id")??void 0,b=i.get("finding_id")??void 0,S=i.get("source"),O=S==="manual"||S==="impl"||S==="meta"||S==="auto-provisional"?S:void 0;return r.length>0||u||o||d||v||p||x||g||b||O?{filters:{agents:u?[u]:[],signals:r,counterpart:o,category:d,severity:v,since:p,until:x,consensusId:g,findingId:b,source:O},hadAny:!0}:{filters:sh,hadAny:!1}}function yy(i,r,u=is){const o=new URLSearchParams;o.set("limit",String(u)),o.set("offset",String(r)),i.agents.length===1&&o.set("agent",i.agents[0]),i.counterpart&&o.set("counterpart",i.counterpart);for(const d of i.signals)o.append("signal",d);return i.category&&o.set("category",i.category),i.severity&&o.set("severity",i.severity),i.since&&o.set("since",i.since),i.until&&o.set("until",i.until),i.consensusId&&o.set("consensus_id",i.consensusId),i.findingId&&o.set("finding_id",i.findingId),i.source&&o.set("source",i.source),o}function fo(i,r){return i?i.length>r?i.slice(0,r)+"…":i:""}function by(){const[{filters:i,hadAny:r}]=k.useState(gy),[u,o]=k.useState(i),[d,m]=k.useState([]),[v,p]=k.useState(0),[x,g]=k.useState(0),[b,S]=k.useState(!1),[O,Q]=k.useState(null),[L,X]=k.useState([]),[M,I]=k.useState(!1),[K,ee]=k.useState(null),[J,A]=k.useState(null),q=k.useRef(null),w=k.useRef(0),Z=k.useCallback(async(E,T)=>{const H=++w.current;S(!0),Q(null);try{const W=yy(E,T*is),ce=await Ge(`signals?${W.toString()}`);if(H!==w.current)return;m(ce.items??[]),g(ce.total??0)}catch(W){if(H!==w.current)return;Q(W instanceof Error?W.message:"fetch failed")}finally{H===w.current&&S(!1)}},[]);k.useEffect(()=>{Ge("agents").then(E=>{const T=(E??[]).map(H=>H.id).filter(Boolean).sort();T.length>0&&X(T)}).catch(()=>{})},[]),k.useEffect(()=>{p(0)},[u]),k.useEffect(()=>(q.current&&clearTimeout(q.current),q.current=setTimeout(()=>{Z(u,v)},250),()=>{q.current&&clearTimeout(q.current)}),[u,v,Z]);const te=k.useCallback(E=>{o(T=>({...T,...E}))},[]),ne=Math.max(1,Math.ceil(x/is)),de=Math.min(v,ne-1),F=x>0||r||b,ae=(E,T)=>{!E||!T||(ee(E),A(T),I(!0))},me=k.useMemo(()=>{const E=[];return u.agents.length&&E.push(`${u.agents.length} agents`),u.signals.length&&E.push(`${u.signals.length} signals`),u.severity&&E.push(u.severity),u.source&&E.push(u.source),(u.since||u.until)&&E.push("time window"),E.length?E.join(" · "):"all signals"},[u]);return a.jsxs("div",{className:"space-y-4",children:[a.jsx("div",{className:"flex items-baseline justify-between",children:a.jsxs("div",{children:[a.jsx("h1",{className:"h-route",children:"Signals"}),a.jsx("p",{className:"mt-0.5 font-mono text-[10px]",style:{color:"color-mix(in oklch, var(--text-dim) 60%, transparent)"},children:"Scored events emitted by agents during consensus review."}),a.jsxs("p",{className:"mt-0.5 font-mono text-[10px]",style:{color:"color-mix(in oklch, var(--text-dim) 70%, transparent)"},children:[me," — showing ",d.length," of ",x]})]})}),r&&a.jsxs("div",{className:"rounded-md border border-border/40 px-3 py-2 font-mono text-[10px]",style:{background:"color-mix(in oklch, var(--surface-sunk) 30%, transparent)",color:"var(--text-dim)"},children:["Filtered view — ",u.signals.length," signal type",u.signals.length!==1?"s":"",u.agents.length>0?` · ${u.agents.length} agent${u.agents.length!==1?"s":""}`:"",u.severity?` · severity: ${u.severity}`:"",u.source?` · source: ${u.source}`:"",". ",a.jsx("a",{href:vn("/signals"),style:{color:"var(--accent)"},children:"Clear filters"})]}),a.jsxs("div",{className:`grid grid-cols-1 gap-4 ${F?"lg:grid-cols-[260px_1fr]":""} lg:items-start`,children:[F&&a.jsx("div",{className:r?"opacity-70 transition-opacity hover:opacity-100 focus-within:opacity-100":void 0,children:a.jsx(my,{filters:u,onChange:te,agents:L,signalTypes:hy})}),a.jsxs("section",{className:"min-w-0 overflow-hidden rounded-md border border-border/60",style:{background:"color-mix(in oklch, var(--surface-elev) 70%, transparent)"},children:[O&&a.jsx("div",{className:"border-b border-border/60 px-3 py-2 font-mono text-[10px]",style:{color:"var(--bad)",background:"color-mix(in oklch, var(--bad) 10%, transparent)"},children:O}),a.jsx("div",{className:"overflow-x-auto",children:a.jsxs("table",{className:"w-full border-collapse text-[10px]",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"h-section border-b border-border/60 text-left",style:{color:"color-mix(in oklch, var(--ink-2) 80%, transparent)"},children:[a.jsx("th",{className:"w-[6px] p-0","aria-label":"severity"}),a.jsx("th",{className:"px-2 py-1.5",children:"time"}),a.jsx("th",{className:"px-2 py-1.5",children:"agent"}),a.jsx("th",{className:"px-2 py-1.5",children:"verdict"}),a.jsx("th",{className:"px-2 py-1.5",children:"finding"}),a.jsx("th",{className:"px-2 py-1.5","data-tooltip":"The other agent in this signal — e.g. the peer who agreed or disputed",children:"counterpart"}),a.jsx("th",{className:"px-2 py-1.5","data-tooltip":"Finding ID — click row to open finding detail",children:"id"}),a.jsx("th",{className:"px-2 py-1.5",children:"consensus"})]})}),a.jsxs("tbody",{children:[d.length===0&&!b&&a.jsx("tr",{children:a.jsx("td",{colSpan:8,className:"px-2 py-8 text-center font-mono",style:{color:"color-mix(in oklch, var(--text-dim) 50%, transparent)"},children:"no signals match these filters"})}),d.map((E,T)=>{const H=!!(E.consensusId&&E.findingId),W=E.severity?vy[E.severity]:"transparent",ce=py[E.signal]??"var(--ink-2)",ue=xy[E.signal]??E.signal;return a.jsxs("tr",{className:`border-b border-border/30 ${H?"cursor-pointer transition-colors":""}`,style:H?{"--row-hover-bg":"color-mix(in oklch, var(--surface-sunk) 40%, transparent)"}:void 0,role:H?"button":void 0,tabIndex:H?0:void 0,"aria-label":H?`View finding ${E.findingId??""}`:void 0,onMouseEnter:y=>{H&&(y.currentTarget.style.background="color-mix(in oklch, var(--surface-sunk) 40%, transparent)")},onMouseLeave:y=>{H&&(y.currentTarget.style.background="")},onClick:()=>H&&ae(E.consensusId,E.findingId),onKeyDown:y=>{H&&(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),ae(E.consensusId,E.findingId))},children:[a.jsx("td",{className:"p-0",style:{background:W,width:6},title:E.severity??"no severity"}),a.jsx("td",{className:"whitespace-nowrap px-2 py-1 font-mono tabular-nums",style:{color:"color-mix(in oklch, var(--text-dim) 80%, transparent)"},title:E.timestamp,children:We(E.timestamp)}),a.jsx("td",{className:"whitespace-nowrap px-2 py-1 font-mono",style:{color:"var(--text)"},children:E.agentId}),a.jsx("td",{className:"whitespace-nowrap px-2 py-1",children:a.jsx("span",{className:"h-section",style:{color:ce,fontSize:11},children:ue})}),a.jsx("td",{className:"max-w-[320px] truncate px-2 py-1",style:{fontFamily:"var(--font-mono)",fontSize:12,lineHeight:1.45,color:"var(--text)"},title:E.evidence,children:fo(E.evidence,80)}),a.jsx("td",{className:"whitespace-nowrap px-2 py-1 font-mono",style:{color:"color-mix(in oklch, var(--text-dim) 80%, transparent)"},children:E.counterpartId??"—"}),a.jsx("td",{className:"whitespace-nowrap px-2 py-1 font-mono",style:{color:"color-mix(in oklch, var(--text-dim) 70%, transparent)"},title:E.findingId,children:E.findingId?fo(E.findingId,24):"—"}),a.jsx("td",{className:"whitespace-nowrap px-2 py-1 font-mono",style:{color:"color-mix(in oklch, var(--text-dim) 70%, transparent)"},title:E.consensusId,children:E.consensusId?fo(E.consensusId,16):"—"})]},`${E.timestamp}-${E.agentId}-${T}`)})]})]})}),a.jsxs("div",{className:"flex items-center justify-between border-t border-border/60 px-3 py-2",children:[a.jsx("span",{className:"font-mono text-[10px]",style:{color:"color-mix(in oklch, var(--text-dim) 60%, transparent)"},children:b?"loading…":`${de*is+1}–${de*is+d.length} of ${x}`}),a.jsxs("div",{className:"flex items-center gap-2 font-mono text-[10px]",style:{color:"var(--text-dim)"},children:[a.jsx("button",{type:"button",onClick:()=>p(E=>Math.max(0,E-1)),disabled:de===0||b,className:"rounded-sm border border-border/40 px-2 py-0.5 transition hover:bg-[color-mix(in_oklch,var(--surface-sunk)_50%,transparent)] disabled:opacity-30",style:{background:"var(--surface-elev)"},children:"◂ Prev"}),a.jsxs("span",{className:"tabular-nums",children:[de+1," / ",ne]}),a.jsx("button",{type:"button",onClick:()=>p(E=>Math.min(ne-1,E+1)),disabled:de>=ne-1||b,className:"rounded-sm border border-border/40 px-2 py-0.5 transition hover:bg-[color-mix(in_oklch,var(--surface-sunk)_50%,transparent)] disabled:opacity-30",style:{background:"var(--surface-elev)"},children:"Next ▸"})]})]})]})]}),a.jsx(qi,{open:M,onOpenChange:I,consensusId:K,findingId:J})]})}function jy(){const[i,r]=k.useState(null),[u,o]=k.useState(null);k.useEffect(()=>{m0().then(r)},[]);const d=k.useCallback(async m=>{o(null);const v=await f0(m);v.ok?r(!0):o(v.kind)},[]);return{authed:i,login:d,error:u}}const Ny=5e3;function Sy(){const[i,r]=k.useState({overview:null,agents:null,tasks:null,consensus:null,consensusReports:null,fleetTrend:null,signalActivity:null,skills:null,nativeMemories:null,gossipMemories:null,memories:null,loading:!0,error:null}),u=k.useRef(!1),o=k.useCallback(async()=>{if(!u.current){u.current=!0;try{const[d,m,v,p,x,g,b,S,O,Q]=await Promise.all([Ge("overview"),Ge("agents"),Ge("tasks?limit=2000"),Ge("consensus?pageSize=500"),Ge("consensus-reports?page=1&pageSize=200").catch(()=>({reports:[]})),Ge("fleet-trend?days=7").catch(()=>({days:7,points:[]})),Ge("signal-activity").catch(()=>({agents:[],total:0,generatedAt:""})),Ge("skills").catch(()=>({index:{},suggestions:[],effectiveness:[]})),Ge("native-memory").catch(()=>({knowledge:[]})),Ge("gossip-memory").catch(()=>({knowledge:[]}))]),L=[...O.knowledge||[]].map(M=>({...M,origin:"native"})).sort((M,I)=>I.filename>M.filename?1:-1),X=[...Q.knowledge||[]].map(M=>({...M,origin:"gossip"})).sort((M,I)=>I.filename>M.filename?1:-1);r({overview:d,agents:m,tasks:v,consensus:p,consensusReports:x,fleetTrend:g,signalActivity:b,skills:S,nativeMemories:L,gossipMemories:X,memories:L,loading:!1,error:null})}catch(d){r(m=>({...m,loading:!1,error:d.message}))}finally{u.current=!1}}},[]);return k.useEffect(()=>{o()},[o]),k.useEffect(()=>{const d=setInterval(()=>{o()},Ny);return()=>clearInterval(d)},[o]),{...i,refresh:o}}const Sh="dashboard:lastEventId";function ky(){if(typeof window>"u")return 0;const i=window.localStorage.getItem(Sh);if(!i)return 0;const r=parseInt(i,10);return Number.isFinite(r)?r:0}function _y(i){typeof window>"u"||window.localStorage.setItem(Sh,String(i))}const ih=1e3,Ey=5e3;function Ty(i){k.useEffect(()=>{if(typeof window>"u"||typeof window.EventSource>"u")return;let r=null,u=null,o=ih,d=!1;function m(){if(d)return;const v=ky();r=new window.EventSource(`/dashboard/api/events?last_id=${v}`),r.onmessage=p=>{try{const x=JSON.parse(p.data);i(x),_y(x.id),o=ih}catch{}},r.onerror=()=>{r&&(r.close(),r=null),!d&&(u=setTimeout(()=>{m()},o),o=Math.min(o*2,Ey))}}return m(),()=>{d=!0,u!==null&&clearTimeout(u),r&&(r.close(),r=null)}},[])}const ch=5,My=6e3;function Ay({toast:i,onDismiss:r}){const u=k.useRef(null),o=k.useCallback(()=>{u.current&&(clearTimeout(u.current),u.current=null)},[]),d=k.useCallback(()=>{o(),u.current=setTimeout(()=>r(i.id),My)},[i.id,r,o]);k.useEffect(()=>(d(),o),[d,o]);const{type:m,payload:v}=i.event,p=m==="task.completed"?a.jsx("span",{style:{color:"var(--text-dim)"},children:"✓"}):v.confirmed>v.disputed?a.jsx("span",{className:"text-confirmed",children:"◎"}):a.jsx("span",{className:"text-disputed",children:"◎"});let x;if(m==="task.completed"){const b=String(v.agentId??"agent"),S=typeof v.durationMs=="number"?v.durationMs:null,O=S!==null?`${(S/1e3).toFixed(1)}s`:"—";x=`${b} finished in ${O}`}else{const b=Number(v.confirmed??0),S=Number(v.disputed??0);x=`Consensus done — ${b} confirmed · ${S} disputed`}const g=()=>{o(),m==="task.completed"&&v.taskId?rs("/tasks"):m==="consensus.completed"&&v.consensusId&&rs("/debates"),r(i.id)};return a.jsx("div",{className:["pointer-events-auto border rounded px-4 py-3 max-w-sm cursor-pointer","transition-all duration-200","motion-reduce:transition-none motion-reduce:transform-none","hover:border-border",i.exiting?"opacity-0 scale-95 opacity-0 translate-y-2":"opacity-100 scale-100 translate-x-0"].join(" "),style:{background:"var(--surface-elev)",boxShadow:"var(--shadow-card)"},onClick:g,onMouseEnter:o,onMouseLeave:d,children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"shrink-0 text-sm font-bold",children:p}),a.jsx("span",{title:x,className:"font-mono text-[11px] min-w-0 truncate",style:{color:"var(--text)"},children:x}),a.jsx("button",{className:"ml-auto shrink-0 hover:[color:var(--text-dim)] text-xs leading-none",style:{color:"color-mix(in oklch, var(--text-dim) 50%, transparent)"},onClick:b=>{b.stopPropagation(),o(),r(i.id)},"aria-label":"Dismiss notification",children:"×"})]})})}function wy(){const[i,r]=k.useState([]),u=k.useCallback(d=>{r(m=>m.map(v=>v.id===d?{...v,exiting:!0}:v)),setTimeout(()=>{r(m=>m.filter(v=>v.id!==d))},250)},[]),o=k.useCallback(d=>{r(m=>{const v={id:d.id,event:d,exiting:!1},p=[...m,v];if(p.length>ch){const x=p.length-ch;return p.slice(x)}return p})},[]);return Ty(o),a.jsx("div",{className:"fixed bottom-4 right-4 z-50 flex flex-col-reverse gap-2 pointer-events-none",role:"region","aria-label":"Notifications","aria-live":"polite","aria-atomic":"false",children:i.map(d=>a.jsx(Ay,{toast:d,onDismiss:u},d.id))})}function Cy({agents:i,tasks:r,consensusReports:u,fleetTrend:o}){const[d,m]=k.useState("weight"),[v,p]=k.useState("desc"),[x,g]=k.useState(""),b=k.useMemo(()=>{const A=new Map;if(r)for(const q of r.items){const w=A.get(q.agentId);(!w||q.timestamp>w.timestamp)&&A.set(q.agentId,q)}return A},[r]);vh(u==null?void 0:u.reports),k.useMemo(()=>{const A=new Map;if(o){for(const q of o.points){const w=A.get(q.agentId)??[];w.push(q),A.set(q.agentId,w)}for(const q of A.values())q.sort((w,Z)=>w.day.localeCompare(Z.day))}return A},[o]);const S=i.filter(E0).length,O=i.filter(A=>A.scores.accuracy>=.5).length,Q=i.reduce((A,q)=>A+q.scores.signals,0),L=i.reduce((A,q)=>A+q.totalTokens,0),X=x.trim().toLowerCase(),M=X?i.filter(A=>A.id.toLowerCase().includes(X)||A.provider.toLowerCase().includes(X)||A.model.toLowerCase().includes(X)):i,I=A=>{const q=A.scores;switch(d){case"weight":return q.dispatchWeight;case"accuracy":return q.accuracy;case"uniqueness":return q.uniqueness;case"impact":return q.impactScore;case"signals":return q.signals;case"agreements":return q.agreements;case"hallucinations":return q.hallucinations;case"lastTask":{const w=b.get(A.id);return w?new Date(w.timestamp).getTime():0}}},K=[...M].sort((A,q)=>{const w=I(A),Z=I(q);return v==="desc"?Z-w:w-Z}),ee=A=>{d===A?p(q=>q==="desc"?"asc":"desc"):(m(A),p("desc"))},J=A=>d===A?v==="desc"?"▾":"▴":"";return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"mb-6",children:[a.jsxs("div",{className:"flex items-baseline gap-3",children:[a.jsx("h1",{className:"h-route",children:"Team"}),a.jsx("span",{className:"font-mono text-sm tabular-nums",style:{color:"var(--ink-3)"},children:i.length})]}),a.jsx("p",{className:"mt-0.5 text-[13px]",style:{color:"var(--ink-3)"},children:"Per-agent accuracy, signal counts, and dispatch weights."}),a.jsx("div",{className:"mt-2 grid grid-cols-2 gap-px overflow-hidden rounded-md [border-color:color-mix(in_oklch,var(--border)_40%,transparent)] border [background:color-mix(in_oklch,var(--border)_30%,transparent)] sm:grid-cols-4",children:[{label:"Healthy",value:O,varColor:"var(--ok)"},{label:"Benched",value:S,varColor:S>0?"var(--bad)":"var(--ink-3)"},{label:"Total Signals",value:Q.toLocaleString(),varColor:"var(--ink)"},{label:"Tokens Used",value:L.toLocaleString(),varColor:"var(--ink)"}].map(A=>a.jsxs("div",{style:{background:"var(--surface-elev)"},className:"px-4 py-3",children:[a.jsx("div",{className:"font-mono text-lg font-bold tabular-nums",style:{color:A.varColor},children:A.value}),a.jsx("div",{className:"h-section mt-0.5",children:A.label})]},A.label))})]}),a.jsx("div",{className:"mb-3",children:a.jsx("input",{type:"text",value:x,onChange:A=>g(A.target.value),placeholder:"Search agents by id, provider, or model...",className:"w-full max-w-md rounded-md [border-color:color-mix(in_oklch,var(--border)_40%,transparent)] border px-3 py-1.5 font-mono text-xs focus:[border-color:var(--ink-3)] focus:outline-none",style:{background:"color-mix(in oklch, var(--surface-elev) 80%, transparent)",color:"var(--ink)"}})}),a.jsx("div",{className:"overflow-hidden rounded-md [border-color:color-mix(in_oklch,var(--border)_40%,transparent)] border",style:{background:"color-mix(in oklch, var(--surface-elev) 80%, transparent)"},children:a.jsxs("table",{className:"w-full text-left",children:[a.jsxs("colgroup",{children:[a.jsx("col",{style:{width:44}}),a.jsx("col",{}),a.jsx("col",{style:{width:80}}),a.jsx("col",{style:{width:260}}),a.jsx("col",{style:{width:80}}),a.jsx("col",{style:{width:60}}),a.jsx("col",{})]}),a.jsx("thead",{children:a.jsxs("tr",{className:"border-b [border-color:color-mix(in_oklch,var(--border)_40%,transparent)]",style:{background:"color-mix(in oklch, var(--surface-sunk) 20%, transparent)"},children:[a.jsx("th",{className:"h-section py-2.5 pl-5 pr-2 text-center",children:"#"}),a.jsx("th",{className:"h-section py-2.5 pr-3 text-left",children:"Agent"}),a.jsxs("th",{className:"h-section py-2.5 pr-4 text-right cursor-pointer select-none hover:[color:var(--ink)]",onClick:()=>ee("weight"),children:["Weight ",J("weight")]}),a.jsx("th",{className:"h-section py-2.5 pr-4 text-left align-top",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("button",{onClick:()=>ee("accuracy"),className:"flex items-center gap-1 hover:[color:var(--ink)]","data-tooltip":"Accuracy — fraction of findings confirmed by cross-review (with hallucination penalty)",children:[a.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full bg-confirmed"}),"Acc",J("accuracy")]}),a.jsx("span",{style:{color:"color-mix(in oklch, var(--ink-3) 30%, transparent)"},children:"·"}),a.jsxs("button",{onClick:()=>ee("uniqueness"),className:"flex items-center gap-1 hover:[color:var(--ink)]","data-tooltip":"Uniqueness — findings this agent surfaced that no peer found",children:[a.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full bg-unique"}),"Unq",J("uniqueness")]}),a.jsx("span",{style:{color:"color-mix(in oklch, var(--ink-3) 30%, transparent)"},children:"·"}),a.jsxs("button",{onClick:()=>ee("impact"),className:"flex items-center gap-1 hover:[color:var(--ink)]","data-tooltip":"Impact — severity-weighted finding score",children:[a.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full bg-[var(--c8)]"}),"Imp",J("impact")]})]})}),a.jsxs("th",{className:"h-section py-2.5 pr-4 text-right cursor-pointer select-none hover:[color:var(--ink)]",onClick:()=>ee("signals"),children:["Signals ",J("signals")]}),a.jsxs("th",{className:"h-section py-2.5 pr-4 text-right cursor-pointer select-none hover:[color:var(--ink)]",onClick:()=>ee("hallucinations"),"data-tooltip":"Hallucinations — fabricated findings caught by cross-review",children:["Halluc ",J("hallucinations")]}),a.jsxs("th",{className:"h-section py-2.5 pr-5 text-left cursor-pointer select-none hover:[color:var(--ink)]",onClick:()=>ee("lastTask"),children:["Last Task ",J("lastTask")]})]})}),a.jsx("tbody",{children:K.map((A,q)=>{const w=A.scores,Z=b.get(A.id),te=w.dispatchWeight>=1.2?"var(--ok)":w.dispatchWeight>=.8?"var(--ink)":"var(--bad)",ne=q+1;return a.jsxs("tr",{className:"group border-t [border-color:color-mix(in_oklch,var(--border)_20%,transparent)] align-top transition-colors hover:bg-accent/20",children:[a.jsx("td",{className:"py-3 pl-5 pr-2 text-center align-top",children:a.jsx("span",{className:"font-mono text-[11px] tabular-nums",style:{color:ne===1?"var(--ink)":ne===2||ne===3?"color-mix(in oklch, var(--ink-2) 80%, transparent)":"var(--ink-3)",fontWeight:ne===1?"bold":ne<=3?600:void 0},children:ne})}),a.jsx("td",{className:"py-2.5 pr-3 align-top",children:a.jsxs("a",{href:`/dashboard/agent/${encodeURIComponent(A.id)}`,className:"flex items-center gap-3",children:[a.jsx(us,{agentId:A.id,size:32,signals:w.signals,accuracy:w.accuracy,uniqueness:w.uniqueness,impact:w.impactScore}),a.jsxs("div",{className:"min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("span",{className:"truncate font-mono text-xs font-semibold group-hover:[color:var(--accent)]",style:{color:"var(--ink)"},children:A.id}),(()=>{const de=_o(w);return de==="benched"?a.jsx("span",{className:"shrink-0 rounded px-1 text-[8px] font-bold",style:{background:"color-mix(in oklch, var(--bad) 15%, transparent)",color:"var(--bad)",fontVariant:"small-caps",letterSpacing:"0.04em"},"data-tooltip":`Benched (${w.bench.reason??"auto"}). Excluded from dispatch until recovery.`,children:"benched"}):de==="struggling"?a.jsx("span",{className:"shrink-0 rounded bg-unverified/15 px-1 text-[8px] font-bold text-unverified",style:{fontVariant:"small-caps",letterSpacing:"0.04em"},"data-tooltip":"Struggling: consecutive failures tripped the circuit breaker. Deprioritized until new clean signals recover the score.",children:"struggling"}):de==="kept-for-coverage"?a.jsx("span",{className:"shrink-0 rounded border border-unverified/40 px-1 text-[8px] font-bold text-unverified",style:{fontVariant:"small-caps",letterSpacing:"0.04em"},"data-tooltip":`Would bench (${w.bench.reason??"rule"}), but kept as sole provider of a category.`,children:"kept for coverage"}):null})()]}),a.jsxs("div",{className:"truncate font-mono text-[10px]",style:{color:"var(--ink-3)"},children:[A.provider,"/",A.model]})]})]})}),a.jsx("td",{className:"py-3 pr-4 text-right align-top",children:a.jsx("span",{className:"font-mono text-sm font-bold tabular-nums",style:{color:te},children:w.dispatchWeight.toFixed(2)})}),a.jsx("td",{className:"py-3 pr-4 align-top",children:a.jsxs("div",{className:"space-y-1",children:[a.jsx(mo,{label:"A",value:w.accuracy,fillClass:w.accuracy>=.7?"bg-confirmed":w.accuracy>=.4?"bg-unverified":"bg-disputed",tooltip:"Adjusted accuracy = raw signal ratio × 1/(1 + weighted hallucinations × 0.3). The penalty is recoverable via skill-gated multiplier in the same category."}),a.jsx(mo,{label:"U",value:w.uniqueness,fillClass:"bg-unique",tooltip:"Uniqueness — findings this agent surfaced that no other agent found"}),a.jsx(mo,{label:"I",value:w.impactScore,fillClass:"bg-[var(--c8)]",tooltip:"Impact — severity-weighted finding score; critical and high findings count more"})]})}),a.jsx("td",{className:"py-3 pr-4 text-right align-top font-mono text-xs tabular-nums",style:{color:"var(--ink)"},children:w.signals.toLocaleString()}),a.jsx("td",{className:"py-3 pr-4 text-right align-top font-mono text-xs tabular-nums",children:a.jsx("span",{style:{color:w.hallucinations>0?"var(--bad)":"var(--ink-3)",fontWeight:w.hallucinations>10?"bold":void 0},"data-tooltip":`Agreements ${w.agreements} · Disagreements ${w.disagreements} · Hallucinations ${w.hallucinations}`,children:w.hallucinations})}),a.jsx("td",{className:"py-3 pr-5 align-top",children:Z?a.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[a.jsx("span",{className:"warn-badge shrink-0 rounded px-1.5 py-0.5 font-mono text-[9px] font-semibold",children:Z.taskId.slice(0,8)}),a.jsx("span",{className:"truncate text-[11px]",style:{maxWidth:260,color:"var(--ink-2)"},children:Z.task}),a.jsx("span",{className:"ml-auto shrink-0 font-mono text-[10px]",style:{color:"var(--ink-3)"},children:We(Z.timestamp)})]}):a.jsx("span",{className:"font-mono text-[10px]",style:{color:"var(--ink-3)"},children:"no tasks"})})]},A.id)})})]})})]})}function mo({label:i,value:r,fillClass:u,tooltip:o}){return a.jsxs("div",{className:"flex items-center gap-2","data-tooltip":o,"data-tooltip-pos":"top",children:[a.jsx("span",{className:"w-6 text-[10px]",style:{color:"var(--ink-3)",fontVariant:"small-caps",letterSpacing:"0.04em"},children:i}),a.jsx("div",{className:"h-1 flex-1 overflow-hidden rounded-full",style:{background:"color-mix(in oklch, var(--surface) 60%, transparent)"},children:a.jsx("div",{className:`h-full rounded-full ${u}`,style:{width:`${Math.max(0,Math.min(100,r*100))}%`}})}),a.jsxs("span",{className:"w-8 text-right font-mono text-[10px] tabular-nums",style:{color:"var(--ink-2)"},children:[Math.round(r*100),"%"]})]})}function zy({tasks:i}){const[r,u]=k.useState(""),[o,d]=k.useState(0),[m,v]=k.useState(null),p=100,x=i.items.filter(M=>M.status==="completed").length,g=i.items.filter(M=>M.status==="failed").length,b=i.items.filter(M=>M.status==="running").length,S=r.trim().toLowerCase(),O=S?i.items.filter(M=>{var I,K,ee,J;return((I=M.task)==null?void 0:I.toLowerCase().includes(S))||((K=M.agentId)==null?void 0:K.toLowerCase().includes(S))||((ee=M.taskId)==null?void 0:ee.toLowerCase().includes(S))||((J=M.status)==null?void 0:J.toLowerCase().includes(S))}):i.items,Q=Math.max(1,Math.ceil(O.length/p)),L=Math.min(o,Q-1),X=O.slice(L*p,(L+1)*p);return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"mb-6",children:[a.jsxs("div",{className:"flex items-baseline gap-3",children:[a.jsx("h1",{className:"h-route",children:"Tasks"}),a.jsx("span",{className:"font-mono text-sm tabular-nums",style:{color:"var(--ink-3)"},children:i.total})]}),a.jsx("p",{className:"mt-0.5 text-[13px]",style:{color:"var(--ink-3)"},children:"Live dispatched tasks and their relay status."}),a.jsxs("div",{className:"mt-2 flex gap-4 font-mono text-[11px]",style:{color:"var(--ink-3)"},children:[a.jsxs("span",{children:[a.jsx("span",{style:{color:"var(--ok)"},children:x})," completed"]}),g>0&&a.jsxs("span",{children:[a.jsx("span",{style:{color:"var(--bad)"},children:g})," failed"]}),b>0&&a.jsxs("span",{children:[a.jsx("span",{className:"text-unverified",children:b})," running"]}),a.jsxs("span",{children:["showing ",X.length," of ",O.length,S&&` (filtered from ${i.items.length})`]})]})]}),a.jsxs("div",{className:"mb-3 flex items-center justify-between gap-3",children:[a.jsx("input",{type:"text",value:r,onChange:M=>{u(M.target.value),d(0)},placeholder:"Search tasks by description, agent, id, status...",className:"w-full max-w-md rounded-md [border-color:color-mix(in_oklch,var(--border)_40%,transparent)] border px-3 py-1.5 font-mono text-xs focus:[border-color:color-mix(in_oklch,var(--accent)_40%,transparent)] focus:outline-none",style:{background:"color-mix(in oklch, var(--surface-elev) 80%, transparent)",color:"var(--ink)"}}),a.jsxs("div",{className:`flex shrink-0 items-center gap-2 font-mono text-[11px] ${Q<=1?"invisible":""}`,style:{color:"var(--ink-3)"},children:[a.jsx("button",{onClick:()=>d(M=>Math.max(0,M-1)),disabled:L===0,className:"rounded-sm [border-color:color-mix(in_oklch,var(--border)_40%,transparent)] border px-2 py-0.5 transition hover:bg-accent/10 disabled:opacity-30",style:{background:"var(--surface-elev)"},children:"◂ Prev"}),a.jsxs("span",{children:[L+1," / ",Q]}),a.jsx("button",{onClick:()=>d(M=>Math.min(Q-1,M+1)),disabled:L>=Q-1,className:"rounded-sm [border-color:color-mix(in_oklch,var(--border)_40%,transparent)] border px-2 py-0.5 transition hover:bg-accent/10 disabled:opacity-30",style:{background:"var(--surface-elev)"},children:"Next ▸"})]})]}),a.jsx("div",{className:"overflow-hidden rounded-md [border-color:color-mix(in_oklch,var(--border)_40%,transparent)] border",style:{background:"color-mix(in oklch, var(--surface-elev) 80%, transparent)"},children:X.length===0?a.jsx("div",{className:"py-12 text-center text-sm",style:{color:"var(--ink-3)"},children:S?"No tasks match your search.":"No tasks yet."}):a.jsxs("table",{className:"w-full text-left",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b [border-color:color-mix(in_oklch,var(--border)_40%,transparent)]",style:{background:"color-mix(in oklch, var(--surface-sunk) 30%, transparent)"},children:[a.jsx("th",{className:"py-2.5 pl-4 pr-2 h-section",style:{width:32}}),a.jsx("th",{className:"py-2.5 pr-3 h-section",children:"ID"}),a.jsx("th",{className:"py-2.5 pr-3 h-section",children:"Agent"}),a.jsx("th",{className:"py-2.5 pr-3 h-section",children:"Description"}),a.jsx("th",{className:"py-2.5 pr-3 h-section",children:"Duration"}),a.jsx("th",{className:"py-2.5 pr-4 text-right h-section",children:"When"})]})}),a.jsx("tbody",{children:X.map(M=>a.jsx(Nh,{task:M,onClick:v},M.taskId))})]})}),a.jsx(bh,{task:m,onClose:()=>v(null)})]})}function Dy({consensus:i,consensusReports:r}){const[u,o]=k.useState(!1),d=u?i.runs:i.runs.filter(g=>!g.retracted),m=i.runs.filter(g=>g.retracted).length,v=d.reduce((g,b)=>g+(b.counts.agreement||0),0),p=d.reduce((g,b)=>g+((b.counts.disagreement||0)+(b.counts.hallucination||0)),0),x=d.reduce((g,b)=>g+(b.counts.unverified||0),0);return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"mb-6",children:[a.jsxs("div",{className:"flex items-baseline gap-3",children:[a.jsx("h1",{className:"h-route",children:"Consensus Rounds"}),a.jsx("span",{className:"font-mono text-sm tabular-nums",style:{color:"var(--ink-3)"},children:d.length}),!u&&m>0&&a.jsxs("span",{className:"font-mono text-sm tabular-nums",style:{color:"var(--ink-3)"},children:["/ ",i.totalRuns??i.runs.length," total"]})]}),a.jsx("p",{className:"mt-0.5 text-[13px]",style:{color:"var(--ink-3)"},children:"Multi-agent review rounds — findings confirmed when ≥2 agents agree."}),a.jsxs("div",{className:"mt-2 flex gap-4 font-mono text-[11px]",style:{color:"var(--ink-3)"},children:[a.jsxs("span",{children:[a.jsx("span",{style:{color:"var(--ok)"},children:v})," confirmed"]}),a.jsxs("span",{children:[a.jsx("span",{style:{color:"var(--bad)"},children:p})," disputed"]}),x>0&&a.jsxs("span",{children:[a.jsx("span",{className:"text-unverified",children:x})," unverified"]}),a.jsxs("span",{children:[i.totalSignals," total signals"]})]}),m>0&&a.jsxs("div",{className:"mt-2 flex items-center gap-2 font-mono text-[11px]",style:{color:"var(--ink-3)"},children:[a.jsx("span",{children:u?`${m} retracted run${m===1?"":"s"} shown`:`${m} retracted run${m===1?"":"s"} hidden`}),a.jsx("button",{type:"button",onClick:()=>o(g=>!g),className:"rounded-sm [border-color:color-mix(in_oklch,var(--border)_40%,transparent)] border px-2 py-0.5 text-[10px] transition hover:bg-accent/10 hover:[color:var(--ink)]",style:{background:"var(--surface-elev)"},children:u?"hide":"show"})]})]}),a.jsx(Eg,{consensus:i,filteredRuns:d,reports:r,showAll:!0,hideHeader:!0})]})}function Ry(){const i=rh(),{overview:r,agents:u,tasks:o,consensus:d,consensusReports:m,fleetTrend:v,signalActivity:p,skills:x,loading:g,refresh:b}=Sy(),[S,O]=k.useState(0),Q=k.useCallback(ee=>{ee.type!=="log_lines"&&b()},[b]);if(xh(Q),g||!r||!d)return a.jsxs("div",{className:"min-h-screen",style:{background:"var(--surface)"},children:[a.jsx(Im,{}),a.jsx("div",{className:"flex items-center justify-center py-20",style:{color:"var(--ink-3)"},children:"Loading dashboard..."})]});let L;const X=i.match(/^\/agent\/(.+)$/),M=i.match(/^\/consensus\/(.+)$/);if(X&&u){const ee=decodeURIComponent(X[1]);L=a.jsx(sy,{agentId:ee,agents:u,tasks:o,consensus:d})}else if(M){const ee=decodeURIComponent(M[1]);L=a.jsx(cg,{consensusId:ee})}else i==="/team"&&u?L=a.jsx(Cy,{agents:u,tasks:o,consensusReports:m,fleetTrend:v}):i==="/tasks"&&o?L=a.jsx(zy,{tasks:o}):i==="/debates"&&d?L=a.jsx(Dy,{consensus:d,consensusReports:m}):i==="/logs"?L=a.jsx(uy,{}):i==="/signals"?L=a.jsx(by,{}):i==="/violations"?L=a.jsx(Ag,{}):L=a.jsx(Jv,{overview:r,agents:u,tasks:o,consensus:d,consensusReports:m,fleetTrend:v,signalActivity:p,skills:x,activeTaskCount:S,setActiveTaskCount:O});const K=i==="/"||i==="/overview"||!/^\/(agent\/|consensus\/|team|tasks|debates|logs|signals|violations)/.test(i)?"px-6 py-6":"mx-auto max-w-7xl space-y-6 px-6 py-6";return a.jsxs("div",{className:"min-h-screen",style:{background:"var(--surface)"},children:[a.jsx(Im,{}),a.jsx("main",{className:K,children:L})]})}function Oy(){const{authed:i,login:r,error:u}=jy();return i===null?a.jsx("div",{className:"flex min-h-screen items-center justify-center",style:{color:"var(--ink-3)"},children:"Loading..."}):i?a.jsxs(a.Fragment,{children:[a.jsx(Ry,{}),a.jsx(wy,{})]}):a.jsx(rg,{onLogin:r,error:u})}e0.createRoot(document.getElementById("root")).render(a.jsx(k.StrictMode,{children:a.jsx(Oy,{})}));
|
|
76
|
+
${le?"border-r-border/60 border-t-border/60 border-b-border/60":"hover:border-r-border/60 hover:border-t-border/60 hover:border-b-border/60 hover:-translate-y-px"}`,style:{background:le?"var(--surface-elev)":"color-mix(in oklch, var(--surface-elev) 50%, transparent)"},"data-retracted":Nl?"true":void 0,children:[Nl&&a.jsxs("div",{className:"no-underline rounded-t-md border-b border-disputed/30 bg-disputed/10 px-3 py-2 font-mono text-[11px] text-disputed",style:{textDecoration:"none"},children:[a.jsx("span",{className:"font-bold",children:"⚠ RETRACTED"}),Kn.retracted_at&&a.jsxs("span",{className:"ml-2 text-disputed/70",children:["on ",Kn.retracted_at.slice(0,10)]}),Kn.reason&&a.jsxs("span",{className:"ml-2",style:{color:"color-mix(in oklch, var(--text-dim) 80%, transparent)"},children:["— ",Kn.reason]})]}),a.jsxs("button",{className:"flex w-full items-start gap-3 px-3 py-2.5 text-left","aria-expanded":le,onClick:()=>{const P=!le;x(P?E.id:null),P&&(b("all"),O("all"))},children:[a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"font-mono text-sm font-bold",style:{color:"var(--text)"},children:R.length}),a.jsx("span",{className:"text-[11px]",style:{color:"color-mix(in oklch, var(--text-dim) 70%, transparent)"},children:"findings"}),a.jsx("span",{className:"text-[10px]",style:{color:"color-mix(in oklch, var(--text-dim) 30%, transparent)"},children:"·"}),a.jsxs("span",{className:"text-[11px]",style:{color:"color-mix(in oklch, var(--text-dim) 60%, transparent)"},children:[E.rounds,"r"]}),jl.length>0&&a.jsxs("div",{className:"flex items-center gap-1 ml-1",children:[jl.map(P=>a.jsx("span",{title:P,className:"inline-flex h-4 w-4 items-center justify-center rounded-full font-mono text-[8px] font-bold",style:{color:"var(--surface)",backgroundColor:gn(P)},children:ho(P)},P)),Yt.length>5&&a.jsxs("span",{className:"font-mono text-[9px]",style:{color:"color-mix(in oklch, var(--text-dim) 40%, transparent)"},children:["+",Yt.length-5]})]}),a.jsx("span",{className:"shrink-0 rounded border border-border/30 px-1.5 py-0.5 font-mono text-[10px] font-semibold",style:{background:"color-mix(in oklch, var(--surface-sunk) 40%, transparent)",color:"var(--text-dim)"},title:E.id,children:E.id.slice(0,8)}),E.zeroTagAgents&&E.zeroTagAgents.length>0&&(()=>{const P=E.zeroTagAgents,we=E.zeroTagOverflow??0,Ve=P.length+we,Fe=we>0?`${P.join(", ")} (+${we} more)`:P.join(", ");return a.jsxs("span",{className:"shrink-0 rounded border border-unverified/20 bg-unverified/5 px-1.5 py-0.5 font-mono text-[10px] font-semibold text-unverified",title:`Zero-tag agents — emitted no parseable <agent_finding> tags (likely paraphrased relay or HTML-entity encoding). See HANDBOOK invariant #12. Agents: ${Fe}`,children:[Ve," zero-tag"]})})(),E.droppedFindingsByType&&Object.keys(E.droppedFindingsByType).length>0&&(()=>{const P=Object.entries(E.droppedFindingsByType),we=P.reduce((Fe,[,Bt])=>Fe+Bt,0),Ve=P.map(([Fe,Bt])=>`${Fe}:${Bt}`).join(", ");return a.jsxs("span",{className:"shrink-0 rounded border border-unverified/20 bg-unverified/5 px-1.5 py-0.5 font-mono text-[10px] font-semibold text-unverified",title:`Silently dropped <agent_finding> tags with invalid type=: ${Ve}. These never reach the dashboard, scores, or signals.`,children:[we," dropped"]})})(),a.jsx("span",{className:"ml-auto font-mono text-[10px] shrink-0",style:{color:"color-mix(in oklch, var(--text-dim) 50%, transparent)"},children:We(E.timestamp)})]}),a.jsx("div",{className:"mt-1.5 flex items-center gap-3",children:Lt.map(P=>a.jsxs("span",{className:`font-mono text-[10px] font-semibold ${P.textCls}`,children:[P.count," ",P.label]},P.label))}),E.topic&&a.jsxs("div",{className:"mt-1.5 flex items-start gap-2",children:[a.jsx("span",{className:"shrink-0 rounded border border-border/30 px-1.5 py-0.5 font-mono text-[9px] font-bold uppercase tracking-wider",style:{background:"color-mix(in oklch, var(--surface-sunk) 30%, transparent)",color:"color-mix(in oklch, var(--text-dim) 50%, transparent)"},children:"Topic"}),a.jsx("span",{className:"font-inter text-[11px] leading-relaxed",style:{color:"color-mix(in oklch, var(--text-dim) 70%, transparent)"},children:E.topic})]})]}),a.jsx("span",{className:`mt-1 shrink-0 font-mono text-[10px] transition-transform duration-150 ${le?"rotate-90":""}`,style:{color:le?"color-mix(in oklch, var(--ink) 60%, transparent)":"color-mix(in oklch, var(--text-dim) 40%, transparent)"},children:"▸"})]}),le&&a.jsxs("div",{className:"border-t border-border/20 px-4 pb-4 pt-3",children:[a.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[a.jsx("span",{className:"font-mono text-[10px]",style:{color:"color-mix(in oklch, var(--text-dim) 50%, transparent)"},children:"Type:"}),Wm.map(P=>a.jsx("button",{onClick:()=>b(P.key),className:`rounded-md border px-3 py-1.5 font-mono text-[10px] font-medium transition ${g===P.key?P.activeCls:P.cls}`,style:g===P.key?P.activeStyle:P.inactiveStyle,...P.tooltip?{"data-tooltip":P.tooltip}:{},children:P.label},P.key))]}),a.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[a.jsx("span",{className:"font-mono text-[10px]",style:{color:"color-mix(in oklch, var(--text-dim) 50%, transparent)"},children:"Severity:"}),bg.map(P=>a.jsx("button",{onClick:()=>O(P.key),className:`rounded-md border px-3 py-1.5 font-mono text-[10px] font-medium transition ${S===P.key?P.activeCls:P.cls}`,style:S===P.key?P.activeStyle:P.inactiveStyle,children:P.label},P.key))]}),E.coverageDegraded&&a.jsxs("div",{className:"mb-3 rounded-md border border-unverified/20 bg-unverified/8 px-3 py-2",children:[a.jsxs("p",{className:"font-mono text-[10px] font-semibold text-unverified",children:["⚠ Coverage degraded — ",E.coverageDegraded.received," of ",E.coverageDegraded.expected," agents responded"]}),E.coverageDegraded.droppedAgents.length>0&&a.jsxs("p",{className:"mt-0.5 font-mono text-[9px]",style:{color:"color-mix(in oklch, var(--text-dim) 70%, transparent)"},children:["Dropped: ",E.coverageDegraded.droppedAgents.join(", ")]})]}),E.zeroTagAgents&&E.zeroTagAgents.length>0&&a.jsxs("div",{className:"mb-3 rounded-md border border-unverified/20 bg-unverified/8 px-3 py-2",children:[a.jsxs("p",{className:"font-mono text-[10px] font-semibold text-unverified",children:["⚠ Zero-tag agents — ",E.zeroTagAgents.length+(E.zeroTagOverflow??0)," agent",E.zeroTagAgents.length+(E.zeroTagOverflow??0)===1?"":"s"," emitted no parseable <agent_finding> tags"]}),a.jsxs("p",{className:"mt-0.5 font-mono text-[9px]",style:{color:"color-mix(in oklch, var(--text-dim) 70%, transparent)"},children:[E.zeroTagAgents.join(", "),E.zeroTagOverflow&&E.zeroTagOverflow>0?` (+${E.zeroTagOverflow} more)`:""]}),a.jsx("p",{className:"mt-1 font-mono text-[9px]",style:{color:"color-mix(in oklch, var(--text-dim) 50%, transparent)"},children:"Likely a paraphrased relay or HTML-entity-encoded tags. See HANDBOOK invariant #12."})]}),E.relayCrossReviewSkipped&&E.relayCrossReviewSkipped.length>0&&a.jsxs("div",{className:"mb-3 rounded-md border border-unverified/20 bg-unverified/8 px-3 py-2",children:[a.jsxs("p",{className:"font-mono text-[10px] font-semibold text-unverified",children:["⚠ Cross-review skipped: ",E.relayCrossReviewSkipped.length," relay agent",E.relayCrossReviewSkipped.length===1?"":"s"," failed Phase 2"]}),a.jsx("p",{className:"mt-0.5 font-mono text-[9px]",style:{color:"color-mix(in oklch, var(--text-dim) 70%, transparent)"},children:E.relayCrossReviewSkipped.map(P=>P.agentId).join(", ")})]}),(E.crossReviewAssignments||E.crossReviewCoverage)&&(()=>{const P=E.crossReviewAssignments||{},we=Object.entries(P),Ve=E.crossReviewCoverage||[],Fe=Ve.length,Bt=Ve.filter(Le=>Le.assigned<Le.targetK);return a.jsxs("details",{className:"mb-3 rounded-md border border-border/30",style:{background:"color-mix(in oklch, var(--surface-elev) 30%, transparent)"},children:[a.jsxs("summary",{className:"flex cursor-pointer items-center gap-2 px-3 py-2 h-section select-none",children:["Cross-Review Assignments",E.partialReview&&a.jsx("span",{className:"rounded border border-unverified/15 bg-unverified/5 px-1.5 py-0.5 font-mono text-[9px] font-bold normal-case tracking-normal text-unverified",children:"partial"}),a.jsxs("span",{className:"ml-auto font-mono text-[9px] font-normal normal-case tracking-normal",style:{color:"color-mix(in oklch, var(--text-dim) 50%, transparent)"},children:[we.length," reviewers · ",Fe," findings"]})]}),a.jsxs("div",{className:"border-t border-border/20 px-3 pb-3 pt-2 space-y-2",children:[we.map(([Le,Jn])=>a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{title:Le,className:"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full font-mono text-[8px] font-bold",style:{color:"var(--surface)",backgroundColor:gn(Le)},children:ho(Le)}),a.jsx("span",{className:"font-mono text-[10px]",style:{color:"var(--text-dim)"},children:Le}),a.jsxs("span",{className:"font-mono text-[10px]",style:{color:"color-mix(in oklch, var(--text-dim) 40%, transparent)"},children:["(",Jn.length,")"]}),a.jsx("div",{className:"flex flex-wrap gap-1 ml-1",children:Jn.map(Fn=>a.jsx("span",{className:"rounded px-1.5 py-0.5 font-mono text-[9px]",style:{background:"color-mix(in oklch, var(--surface-sunk) 50%, transparent)",color:"var(--text-dim)"},children:Fn.length>12?Fn.slice(0,12)+"…":Fn},Fn))})]},Le)),Fe>0&&a.jsx("div",{className:"mt-1 pt-1.5 border-t border-border/15",children:Bt.length>0?a.jsxs("span",{className:"rounded border border-unverified/15 bg-unverified/5 px-2 py-1 font-mono text-[10px] font-semibold text-unverified",children:["⚠ ",Bt.length," of ",Fe," findings under-reviewed"]}):a.jsxs("span",{className:"font-mono text-[10px] font-semibold text-confirmed/60",children:["✓ All ",Fe," findings fully covered"]})})]})]})})(),a.jsx("div",{className:"space-y-3",children:G.length===0?a.jsx("div",{className:"py-4 text-center text-xs",style:{color:"var(--text-dim)"},children:"No findings match this filter."}):G.map((P,we)=>a.jsx(_g,{f:P,reviewInfo:P.id?y[P.id]:void 0,diagnostics:re(P)},we))})]})]})]},E.id)}),u&&de>1&&a.jsxs("div",{className:"flex items-center justify-center gap-3 pt-4 font-mono text-[11px]",style:{color:"var(--text-dim)"},children:[a.jsx("button",{onClick:()=>ne(E=>Math.max(0,E-1)),disabled:F===0,className:"rounded-sm border border-border/40 px-3 py-1 transition hover:bg-accent/10 disabled:opacity-30",style:{background:"var(--surface-elev)"},children:"◂ Prev"}),a.jsxs("span",{children:["Page ",F+1," of ",de]}),a.jsx("button",{onClick:()=>ne(E=>Math.min(de-1,E+1)),disabled:F>=de-1,className:"rounded-sm border border-border/40 px-3 py-1 transition hover:bg-accent/10 disabled:opacity-30",style:{background:"var(--surface-elev)"},children:"Next ▸"})]})]}):v.length===0?a.jsx(da,{title:"No consensus runs yet",hint:"Dispatch a consensus round with gossip_dispatch to populate this view."}):a.jsx("div",{className:"space-y-2",children:v.map((E,T)=>{const H=E.counts,W=(H.agreement||0)+(H.disagreement||0)+(H.hallucination||0)+(H.unverified||0)+(H.unique||0)+(H.new||0),ce=W||1,ue=p===E.taskId,y=[{key:"confirmed",count:H.agreement||0,color:"bg-confirmed",text:"text-confirmed",label:"confirmed"},{key:"disputed",count:(H.disagreement||0)+(H.hallucination||0),color:"bg-disputed",text:"text-disputed",label:"disputed"},{key:"unverified",count:H.unverified||0,color:"bg-unverified",text:"text-unverified",label:"unverified"},{key:"unique",count:(H.unique||0)+(H.new||0),color:"bg-unique",text:"text-unique",label:"unique"}],R=E.signals.filter(G=>{if(G.signal==="signal_retracted")return!1;if(g==="all")return!!uo[G.signal];const le=uo[G.signal];return le&&le.filter===g}),V=!!E.retracted;return a.jsxs("div",{className:`rounded-md border transition ${ue?"border-primary/25":"border-border"} ${V?"opacity-60":""}`,style:{background:"var(--surface-elev)"},"data-retracted":V?"true":void 0,title:V&&E.retractionReason?`Retracted: ${E.retractionReason}`:void 0,children:[V&&a.jsxs("div",{className:"rounded-t-md border-b border-disputed/30 bg-disputed/10 px-3 py-1.5 font-mono text-[10px] text-disputed",style:{textDecoration:"none"},children:[a.jsx("span",{className:"font-bold uppercase tracking-wider",children:"⚠ Retracted"}),E.retractedAt&&a.jsxs("span",{className:"ml-2 text-disputed/70",children:["on ",E.retractedAt.slice(0,10)]}),E.retractionReason&&a.jsxs("span",{className:"ml-2",style:{color:"color-mix(in oklch, var(--text-dim) 80%, transparent)"},children:["— ",E.retractionReason]})]}),a.jsxs("button",{"aria-expanded":ue,onClick:()=>{const G=!ue;x(G?E.taskId:null),G&&(b("all"),O("all"))},className:"flex w-full items-center p-3 text-left transition hover:bg-accent/10",children:[a.jsx("span",{className:"mr-3 font-mono text-xs transition",style:{color:ue?"var(--ink)":"var(--text-dim)",fontWeight:ue?600:400},children:ue?"▾":"▸"}),a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("span",{className:"font-mono text-[10px]",style:{color:"var(--ink-3)"},children:E.taskId}),a.jsxs("span",{className:`font-mono text-sm font-semibold ${V?"line-through decoration-disputed/40":""}`,style:{color:"var(--text)"},children:[W," findings"]}),a.jsxs("div",{className:"flex gap-1.5",children:[E.agents.slice(0,4).map(G=>a.jsx("span",{className:"rounded-sm px-1.5 py-0.5 font-mono text-[10px]",style:{background:"var(--surface-sunk)",color:"var(--text-dim)"},children:G.split("-").map(le=>le[0]).join("").toUpperCase().slice(0,2)},G)),E.agents.length>4&&a.jsxs("span",{className:"font-mono text-[10px]",style:{color:"var(--text-dim)"},children:["+",E.agents.length-4]})]})]}),a.jsx("span",{className:"font-mono text-xs",style:{color:"var(--text-dim)"},children:We(E.timestamp)})]}),a.jsx("div",{className:"mt-2 flex gap-2",children:y.map(G=>G.count>0&&a.jsxs("span",{className:`font-mono text-[10px] font-semibold ${G.text} ${V?"line-through decoration-disputed/40":""}`,children:[G.count," ",G.label]},G.key))}),a.jsx("div",{className:"mt-2 flex h-1.5 overflow-hidden rounded-sm",children:y.map(G=>G.count>0&&a.jsx("div",{className:`${G.color} transition-all`,style:{width:`${G.count/ce*100}%`}},G.key))})]})]}),ue&&a.jsxs("div",{className:"border-t border-border px-4 pb-3 pt-3",children:[a.jsx("div",{className:"mb-3 flex gap-1.5",children:Wm.map(G=>a.jsx("button",{onClick:()=>b(G.key),className:`rounded-sm px-2 py-0.5 font-mono text-[10px] font-semibold transition ${g===G.key?G.activeCls:G.cls} hover:opacity-80`,style:g===G.key?G.activeStyle:G.inactiveStyle,...G.tooltip?{"data-tooltip":G.tooltip}:{},children:G.label},G.key))}),R.length===0?a.jsx("div",{className:"py-4 text-center text-xs",style:{color:"var(--text-dim)"},children:"No findings match this filter."}):a.jsx("div",{className:"space-y-2",children:R.map((G,le)=>{const re=uo[G.signal];return re?a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx("span",{className:`shrink-0 rounded-sm px-1.5 py-0.5 font-mono text-[9px] font-bold ${re.cls}`,children:re.label}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("span",{className:"text-xs [&_.cite-file]:rounded [&_.cite-file]:bg-[color-mix(in_oklch,var(--cite-file)_10%,transparent)] [&_.cite-file]:px-1 [&_.cite-file]:font-mono [&_.cite-file]:text-[var(--cite-file)] [&_.cite-fn]:rounded [&_.cite-fn]:bg-[color-mix(in_oklch,var(--cite-fn)_10%,transparent)] [&_.cite-fn]:px-1 [&_.cite-fn]:font-mono [&_.cite-fn]:text-[var(--cite-fn)]",style:{color:"var(--text-dim)"},children:a.jsx("span",{className:"finding-md",dangerouslySetInnerHTML:{__html:Oi(G.evidence||"")}})}),a.jsxs("span",{className:"ml-2 font-mono text-[10px]",style:{color:"color-mix(in oklch, var(--text-dim) 50%, transparent)"},children:[G.agentId,G.counterpartId?` + ${G.counterpartId}`:""]})]})]},le):null})})]})]},E.taskId+T)})})]})}const Ci=25;function Tg({commits:i}){const[r,u]=k.useState(!1);if(i.length===0)return a.jsx("span",{style:{color:"color-mix(in oklch, var(--text-dim) 50%, transparent)"},children:"—"});const o=i[0],d=o.includes(" ")?o.slice(o.indexOf(" ")+1):o,m=i.length-1;return a.jsxs("span",{className:"font-mono text-[11px]",children:[a.jsx("span",{style:{color:"var(--text)"},children:d}),m>0&&a.jsxs(a.Fragment,{children:[" ",a.jsx("button",{type:"button","aria-expanded":r,onClick:()=>u(v=>!v),className:"font-mono text-[10px] underline",style:{color:"color-mix(in oklch, var(--text-dim) 70%, transparent)"},children:r?"(collapse)":`(+${m} more)`}),r&&a.jsx("ul",{className:"mt-1 space-y-0.5 pl-2",children:i.slice(1).map((v,p)=>{const x=v.includes(" ")?v.slice(v.indexOf(" ")+1):v;return a.jsx("li",{className:"font-mono text-[10px]",style:{color:"color-mix(in oklch, var(--text-dim) 80%, transparent)"},children:x},p)})})]})]})}function Mg({row:i}){const r=i.preSha.slice(0,8),u=i.postSha.slice(0,8);return a.jsxs("tr",{className:"border-t border-border/20 align-top transition-colors hover:bg-accent/20",children:[a.jsx("td",{className:"whitespace-nowrap py-3 pl-4 pr-4 font-mono text-[10px]",style:{color:"color-mix(in oklch, var(--text-dim) 80%, transparent)"},children:We(i.detectedAt)}),a.jsx("td",{className:"max-w-[160px] truncate whitespace-nowrap py-3 pr-4",children:a.jsx("a",{href:`/dashboard/agent/${encodeURIComponent(i.agentId)}`,className:"font-mono text-[11px] hover:underline",style:{color:"var(--text)"},onMouseEnter:o=>o.currentTarget.style.color="var(--accent)",onMouseLeave:o=>o.currentTarget.style.color="var(--text)",children:i.agentId})}),a.jsxs("td",{className:"whitespace-nowrap py-3 pr-4 font-mono text-[10px]",children:[a.jsx("span",{style:{color:"color-mix(in oklch, var(--text-dim) 70%, transparent)"},children:r}),a.jsx("span",{className:"mx-1",style:{color:"color-mix(in oklch, var(--text-dim) 40%, transparent)"},children:"→"}),a.jsx("span",{style:{color:"var(--text)"},children:u})]}),a.jsx("td",{className:"py-3 pr-4",children:a.jsx(Tg,{commits:i.commits})})]})}function Ag(){const[i,r]=k.useState([]),[u,o]=k.useState(0),[d,m]=k.useState(1),[v,p]=k.useState(!1),[x,g]=k.useState(null);k.useEffect(()=>{let S=!1;return p(!0),g(null),Ge(`violations?page=${d}&pageSize=${Ci}`).then(O=>{S||(r(O.items??[]),o(O.total??0))}).catch(O=>{S||g(String((O==null?void 0:O.message)??O))}).finally(()=>{S||p(!1)}),()=>{S=!0}},[d]);const b=Math.max(1,Math.ceil(u/Ci));return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-baseline gap-3",children:[a.jsx("h1",{className:"h-route",children:"Process Violations"}),u>0&&a.jsx("span",{className:"font-mono text-sm tabular-nums",style:{color:"var(--ink-3)"},children:u})]}),a.jsx("p",{className:"mt-0.5 font-mono text-[10px]",style:{color:"color-mix(in oklch, var(--text-dim) 70%, transparent)"},children:"Direct master pushes detected by the ref-allowlist enforcer"})]}),a.jsxs("div",{className:"overflow-hidden rounded-md border border-border/40",style:{background:"color-mix(in oklch, var(--surface-elev) 80%, transparent)"},children:[x&&a.jsx("div",{className:"border-b border-border/60 bg-disputed/10 px-3 py-2 font-mono text-[10px] text-disputed",children:x}),!x&&a.jsxs("table",{className:"w-full table-fixed text-left",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b border-border/40 font-mono text-[10px] uppercase tracking-wider",style:{background:"color-mix(in oklch, var(--surface-sunk) 20%, transparent)",color:"color-mix(in oklch, var(--text-dim) 80%, transparent)"},children:[a.jsx("th",{className:"py-2.5 pl-4 pr-4",children:"When"}),a.jsx("th",{className:"py-2.5 pr-4",children:"Agent"}),a.jsx("th",{className:"py-2.5 pr-4",children:"Commit Range"}),a.jsx("th",{className:"py-2.5 pr-4",children:"Commits"})]})}),a.jsxs("tbody",{children:[!v&&i.length===0&&a.jsx("tr",{children:a.jsx("td",{colSpan:4,className:"px-4 py-6 text-center font-mono text-[11px]",style:{color:"color-mix(in oklch, var(--text-dim) 50%, transparent)"},children:"No violations recorded"})}),v&&a.jsx("tr",{children:a.jsx("td",{colSpan:4,className:"px-4 py-6 text-center font-mono text-[10px]",style:{color:"color-mix(in oklch, var(--text-dim) 50%, transparent)"},children:"Loading…"})}),!v&&i.map(S=>a.jsx(Mg,{row:S},`${S.taskId}-${S.detectedAt}`))]})]}),a.jsxs("div",{className:"flex items-center justify-between border-t border-border/60 px-3 py-2",children:[a.jsx("span",{className:"font-mono text-[10px]",style:{color:"color-mix(in oklch, var(--text-dim) 60%, transparent)"},children:v?"loading…":u===0?"no violations":`${(d-1)*Ci+1}–${Math.min(d*Ci,u)} of ${u}`}),a.jsxs("div",{className:`flex items-center gap-2 font-mono text-[10px] ${b<=1?"invisible":""}`,style:{color:"var(--text-dim)"},children:[a.jsx("button",{type:"button",onClick:()=>m(S=>Math.max(1,S-1)),disabled:d===1||v,className:"rounded-sm border border-border/40 px-2 py-0.5 transition hover:bg-accent/10 disabled:opacity-30",style:{background:"var(--surface-elev)"},children:"◂ Prev"}),a.jsxs("span",{className:"tabular-nums",children:[d," / ",b]}),a.jsx("button",{type:"button",onClick:()=>m(S=>Math.min(b,S+1)),disabled:d>=b||v,className:"rounded-sm border border-border/40 px-2 py-0.5 transition hover:bg-accent/10 disabled:opacity-30",style:{background:"var(--surface-elev)"},children:"Next ▸"})]})]})]})]})}function wg({categoryAccuracy:i,categoryCorrect:r,categoryHallucinated:u}){const o=Object.keys(i??{});if(o.length===0)return a.jsx(da,{title:"No category data yet",hint:"Accuracy accrues after ≥5 signals per category.",compact:!0});const d=o.map(m=>{const v=Math.max(0,Math.min(1,i[m]??0)),p=(r==null?void 0:r[m])??0,x=(u==null?void 0:u[m])??0;return{key:m,acc:v,c:p,h:x,n:p+x}}).sort((m,v)=>v.acc-m.acc);return a.jsx("div",{className:"space-y-2",children:d.map(m=>{const v=m.acc>=.7?"bg-confirmed":m.acc>=.4?"bg-unverified":"bg-disputed",p=m.n>0?`${m.c} correct / ${m.h} hallucinated / ${m.n} total`:void 0;return a.jsxs("div",{className:`grid grid-cols-[128px_1fr_auto_44px] items-center gap-3 ${m.n>0&&m.n<10?"opacity-50":""}`,title:m.n>0&&m.n<10?`${p} — low sample (n<10)`:p,children:[a.jsx("span",{className:"truncate font-mono text-[11px]",style:{color:"var(--text-dim)"},children:m.key.replace(/_/g," ")}),a.jsx("div",{className:"h-2 overflow-hidden rounded-sm",style:{background:"color-mix(in oklch, var(--surface-sunk) 30%, transparent)"},children:a.jsx("div",{className:`h-full rounded-sm transition-all ${v}`,style:{width:`${m.acc*100}%`}})}),a.jsx("span",{className:"shrink-0 text-right font-mono text-[10px] tabular-nums w-16",style:{color:"color-mix(in oklch, var(--text-dim) 60%, transparent)"},children:m.n>0?a.jsxs(a.Fragment,{children:[m.c,"/",m.n,m.h>0&&a.jsxs("span",{className:"ml-1 text-disputed/70",children:["·",m.h,"✗"]})]}):"—"}),a.jsxs("span",{className:"text-right font-mono text-[11px] font-bold tabular-nums",style:{color:"var(--text)"},children:[Math.round(m.acc*100),"%"]})]},m.key)})})}const Cg=new Set(["passed","failed","silent_skill","insufficient_evidence","flagged_for_manual_review"]);function zg(i,r,u){return(!i||!Cg.has(i))&&r!==void 0&&u!==void 0&&u>0}const Dg={silent_skill:"No signals recorded after bind — skill may not be injecting correctly",insufficient_evidence:"Fewer than 120 post-bind signals — verdict pending more data",inconclusive:"Mixed signals — needs further evaluation",passed:"Skill verified effective",failed:"Skill verified ineffective",pending:"Awaiting evidence",flagged_for_manual_review:"Manual review required"},Rg={pending:"border-border/50",passed:"border-confirmed/40 bg-confirmed/10 text-confirmed",failed:"border-disputed/40 bg-disputed/10 text-disputed",silent_skill:"border-unverified/40 bg-unverified/10 text-unverified",insufficient_evidence:"border-unverified/40 bg-unverified/10 text-unverified",inconclusive:"border-[color:var(--warn)]/40 bg-[color:var(--warn)]/10 text-[color:var(--warn)]",flagged_for_manual_review:"border-disputed/40 bg-disputed/10 text-disputed"};function Og(i){const r=Math.round(i*100),u=r>0?"+":"";return r>0?{text:`${u}${r}pp`,cls:"text-confirmed"}:r<0?{text:`${u}${r}pp`,cls:"text-disputed"}:{text:`${u}${r}pp`,cls:"",clsStyle:{color:"var(--text-dim)"}}}function Ug({slot:i}){const r=i.status,u=r?Rg[r]:"border-border/50",o=!r||r==="pending"?{background:"color-mix(in oklch, var(--surface-sunk) 30%, transparent)",color:"var(--text-dim)"}:void 0,d=r==="inconclusive"&&(i.inconclusiveStrikes??0)>0,m=i.forcedDevelops??[],v=m.length>0?m[m.length-1]:null,p=typeof i.effectiveness=="number"?Og(i.effectiveness):null,x=zg(r,i.postBindSignals,i.minEvidence);return a.jsxs("div",{className:`rounded-md border p-3 ${i.enabled?"border-border/50":"border-border/30 opacity-60"}`,style:{background:"color-mix(in oklch, var(--surface-elev) 80%, transparent)"},children:[a.jsxs("div",{className:"flex items-start justify-between gap-2",children:[a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[a.jsxs("span",{className:`font-mono text-xs font-semibold ${i.enabled?"":"line-through"}`,style:{color:i.enabled?"var(--text)":"var(--text-dim)"},children:[i.mode==="contextual"&&"⚡ ",i.name]}),a.jsx("span",{className:"rounded-sm px-1.5 py-0.5 font-mono text-[9px]",style:{background:"var(--surface-sunk)",color:"var(--text-dim)"},children:i.source}),i.mode==="contextual"&&a.jsx("span",{className:"warn-badge rounded-sm px-1.5 py-0.5 font-mono text-[9px]",children:"contextual"})]}),a.jsxs("div",{className:"mt-1 font-mono text-[10px]",style:{color:"color-mix(in oklch, var(--text-dim) 60%, transparent)"},children:["bound ",We(i.boundAt)]}),x&&(()=>{const g=i.postBindSignals,b=i.minEvidence,S=Math.round(g/b*100),O=Math.min(g/b,1)*100;return a.jsxs("div",{className:"mt-1.5",title:`MIN_EVIDENCE gate: ${g} of ${b} post-bind signals (${S}%)`,children:[a.jsxs("div",{className:"mb-0.5 font-mono text-[9px]",style:{color:"color-mix(in oklch, var(--text-dim) 50%, transparent)"},children:["post-bind: ",g," / ",b]}),a.jsx("div",{className:"relative h-1 w-full overflow-hidden rounded-full border border-border/40",style:{background:"color-mix(in oklch, var(--surface-sunk) 30%, transparent)"},children:a.jsx("div",{className:"absolute inset-y-0 left-0 rounded-full border-r border-confirmed/40 bg-confirmed/20",style:{width:`${O}%`}})})]})})()]}),r&&a.jsx("span",{className:`shrink-0 rounded-sm border px-1.5 py-0.5 font-mono text-[9px] font-bold uppercase ${u}`,style:o,title:Dg[r],children:r.replace(/_/g," ")})]}),a.jsxs("div",{className:"mt-2 flex items-center gap-3 font-mono text-[10px]",children:[p&&a.jsx("span",{className:p.cls,style:p.clsStyle,title:"Effectiveness: change in hallucination rate pre/post",children:p.text}),d&&a.jsxs("span",{className:"text-unique",title:i.inconclusiveAt?`last strike ${We(i.inconclusiveAt)}`:void 0,children:[i.inconclusiveStrikes," strike",i.inconclusiveStrikes===1?"":"s"]})]}),m.length>0&&a.jsxs("div",{className:"mt-2 border-t border-border/40 pt-2 font-mono text-[10px]",style:{color:"var(--text-dim)"},title:v!=null&&v.reason?`latest: ${v.reason}`:void 0,children:["forced ",m.length," time",m.length===1?"":"s",v&&` · last ${We(v.timestamp)}`]})]})}function qg({open:i,onOpenChange:r,children:u}){return k.useEffect(()=>{if(!i)return;const o=m=>{m.key==="Escape"&&r(!1)};document.addEventListener("keydown",o);const d=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",o),document.body.style.overflow=d}},[i,r]),i?a.jsxs("div",{className:"fixed inset-0 z-50",children:[a.jsx("div",{className:"absolute inset-0 backdrop-blur-sm",style:{background:"color-mix(in oklch, var(--surface) 70%, transparent)"},onClick:()=>r(!1)}),a.jsx("div",{className:"absolute inset-y-0 right-0 flex",children:a.jsx("div",{onClick:o=>o.stopPropagation(),className:"contents",children:u})})]}):null}function Lg({side:i="right",className:r="",children:u,style:o,...d}){return a.jsx("div",{className:`h-full p-6 ${r}`,style:{background:"var(--surface-elev)",...o},...d,children:u})}function Bg({className:i="",...r}){return a.jsx("div",{className:`mb-2 ${i}`,...r})}function Hg({className:i="",...r}){return a.jsx("h2",{className:`font-semibold ${i}`,...r})}function $g({citation:i}){const r=i.snippet.split(`
|
|
77
|
+
`);return a.jsxs("div",{className:"rounded-md border border-border/40 overflow-hidden",style:{background:"color-mix(in oklch, var(--surface-elev) 60%, transparent)"},children:[a.jsx("div",{className:"flex items-center justify-between px-3 py-1 border-b border-border/40",style:{background:"color-mix(in oklch, var(--surface-sunk) 40%, transparent)"},children:a.jsxs("span",{className:"font-mono text-[10px]",style:{color:"var(--text-dim)"},children:[i.file,":",i.line]})}),a.jsx("pre",{className:"overflow-x-auto",style:{background:"var(--surface-sunk)",borderLeft:"3px solid var(--border-strong)",padding:"12px 16px",borderRadius:"6px",fontFamily:"var(--font-mono)",fontSize:"12px",color:"var(--text)"},children:r.map((u,o)=>a.jsx("div",{className:"whitespace-pre",children:u||" "},o))})]})}const Pm={critical:"text-red-400 bg-red-500/10",high:"text-severity-high bg-severity-high/10",medium:"text-yellow-400 bg-yellow-500/10",low:""},Gg={color:"var(--text-dim)",background:"color-mix(in oklch, var(--surface-sunk) 50%, transparent)"},eh={confirmed:"text-confirmed bg-confirmed/10 border border-confirmed/20",disputed:"text-disputed bg-disputed/10 border border-disputed/20",unverified:"text-unverified bg-unverified/10 border border-unverified/20",unique:"text-unique bg-unique/10 border border-unique/20",insight:"text-insight bg-insight/10 border border-insight/20",newFinding:"text-unique bg-unique/10 border border-unique/20"},Yg={background:"var(--surface-elev)",borderRadius:"16px 0 0 16px",boxShadow:"var(--shadow-overlay)",border:"1px solid var(--border)",color:"var(--text)",fontFamily:"var(--font-sans)"};function Xg(){const i=(r,u)=>a.jsx("div",{className:`${r} ${u} rounded`,style:{background:"var(--border)",opacity:.4}});return a.jsxs("div",{className:"mt-4 space-y-4","aria-busy":"true",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[i("h-3.5","w-12"),i("h-3.5","w-14"),i("h-3.5","w-16")]}),a.jsxs("div",{className:"space-y-2",children:[i("h-2","w-full"),i("h-2","w-[92%]"),i("h-2","w-[70%]")]}),a.jsxs("div",{className:"space-y-2",children:[i("h-2","w-16"),i("h-12","w-full")]}),a.jsxs("div",{className:"space-y-2",children:[i("h-2","w-16"),i("h-2","w-[60%]"),i("h-2","w-[45%]")]}),a.jsxs("div",{className:"space-y-2",children:[i("h-2","w-20"),i("h-2","w-full"),i("h-2","w-[80%]")]})]})}function qi({open:i,onOpenChange:r,consensusId:u,findingId:o}){const[d,m]=k.useState(null),[v,p]=k.useState(null);return k.useEffect(()=>{if(!i||!u||!o){m(null),p(null);return}m(null),p(null),Ge(`finding/${encodeURIComponent(u)}/${encodeURIComponent(o)}`).then(m).catch(x=>p(x.message||"failed to load finding"))},[i,u,o]),a.jsx(qg,{open:i,onOpenChange:r,children:a.jsxs(Lg,{side:"right",className:"w-[480px] sm:w-[480px] sm:max-w-[480px] overflow-y-auto",style:Yg,children:[a.jsx(Bg,{children:a.jsx(Hg,{className:"font-mono text-sm",style:{color:"var(--text)"},children:"Finding detail"})}),v&&a.jsx("div",{className:"mt-4",children:a.jsx(Eo,{message:v})}),!v&&!d&&a.jsx(Xg,{}),d&&a.jsxs("div",{className:"mt-4 space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[a.jsx("span",{className:`font-mono text-[9px] uppercase tracking-wider px-2 py-0.5 rounded ${eh[d.finding.tag]||""}`,style:eh[d.finding.tag]?void 0:{background:"var(--surface-sunk)"},children:d.finding.tag}),d.finding.severity&&a.jsx("span",{className:`font-mono text-[9px] uppercase tracking-wider px-2 py-0.5 rounded ${Pm[d.finding.severity]||""}`,style:d.finding.severity==="low"?Gg:Pm[d.finding.severity]?void 0:{background:"var(--surface-sunk)"},children:d.finding.severity}),a.jsxs("span",{className:"font-mono text-[9px]",style:{color:"var(--text-dim)"},children:["by ",d.finding.originalAgentId]}),d.retracted&&a.jsx("span",{className:"font-mono text-[9px] uppercase tracking-wider px-2 py-0.5 rounded bg-disputed/50",children:"retracted"})]}),a.jsx("div",{className:"font-mono text-[12px] leading-relaxed whitespace-pre-wrap",children:d.finding.finding.replace(/<cite tag="file">[^<]+<\/cite>/g,"").trim()}),d.citations.length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsx("div",{className:"font-mono text-[10px] uppercase tracking-wider",style:{color:"var(--text-dim)"},children:"Citations"}),d.citations.map((x,g)=>a.jsx($g,{citation:x},g))]}),a.jsxs("div",{className:"space-y-1",children:[a.jsx("div",{className:"font-mono text-[10px] uppercase tracking-wider",style:{color:"var(--text-dim)"},children:"Coverage"}),d.finding.confirmedBy.length>0&&a.jsxs("div",{className:"text-[11px]",children:[a.jsx("span",{className:"text-confirmed",children:"✓"})," confirmed by ",d.finding.confirmedBy.join(", ")]}),d.finding.disputedBy.map((x,g)=>a.jsxs("div",{className:"text-[11px]",children:[a.jsx("span",{className:"text-disputed",children:"✗"})," disputed by ",x.agentId,": ",a.jsx("span",{style:{color:"var(--text-dim)"},children:x.reason})]},g)),d.finding.confirmedBy.length===0&&d.finding.disputedBy.length===0&&a.jsx("div",{className:"text-[11px]",style:{color:"var(--text-dim)"},children:"No peer review"})]}),d.signals.length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"font-mono text-[10px] uppercase tracking-wider",style:{color:"var(--text-dim)"},children:["Signals (",d.signals.length,")"]}),a.jsx("div",{className:"space-y-1",children:d.signals.map((x,g)=>a.jsxs("div",{className:"text-[11px] border-l-2 border-border/40 pl-2",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"font-mono font-semibold",children:x.signal}),a.jsx("span",{style:{color:"var(--text-dim)"},children:"·"}),a.jsx("span",{children:x.agentId}),x.counterpartId&&a.jsxs(a.Fragment,{children:[a.jsx("span",{style:{color:"var(--text-dim)"},children:"→"}),a.jsx("span",{children:x.counterpartId})]}),a.jsx("span",{className:"ml-auto",style:{color:"var(--text-dim)"},children:We(x.timestamp)})]}),x.evidence&&a.jsx("div",{className:"mt-0.5",style:{color:"var(--text-dim)"},children:x.evidence.slice(0,200)})]},g))})]}),a.jsx("div",{className:"pt-2 border-t border-border/40",children:a.jsxs("a",{href:vn(`/consensus/${d.consensusId}`),className:"font-mono text-[10px] hover:underline",style:{color:"var(--accent)"},children:["→ consensus round ",d.consensusId]})})]})]})})}const Vg={agreement:"text-confirmed bg-confirmed/10",consensus_verified:"text-confirmed bg-confirmed/10",unique_confirmed:"text-unique bg-unique/10",unique_unconfirmed:"text-unique bg-unique/10",new_finding:"text-unique bg-unique/10",disagreement:"text-disputed bg-disputed/10",hallucination_caught:"text-disputed bg-disputed/10",unverified:"text-unverified bg-unverified/10"};function Qg({agentId:i}){const[r,u]=k.useState([]),[o,d]=k.useState(!0),[m,v]=k.useState("all"),[p,x]=k.useState(null);k.useEffect(()=>{let O=!1;return d(!0),Ge(`signals?agent=${encodeURIComponent(i)}&limit=100`).then(Q=>{O||(u(Q.items||[]),d(!1))}).catch(()=>{O||(u([]),d(!1))}),()=>{O=!0}},[i]);const g=[...r].sort((O,Q)=>(Q.timestamp||"").localeCompare(O.timestamp||"")),b=m==="all"||m==="signals"?g:[],S=({k:O,label:Q,enabled:L})=>a.jsx("button",{type:"button",onClick:()=>L&&v(O),disabled:!L,className:`rounded-sm px-2 py-0.5 font-mono text-[10px] font-semibold transition ${L?"":"opacity-40 cursor-not-allowed"}`,style:m===O?{background:"var(--surface-sunk)",color:"var(--text)"}:{color:"var(--text-dim)"},children:Q});return a.jsxs("div",{className:"rounded-md border border-border/40 px-4 py-3",style:{background:"color-mix(in oklch, var(--surface-elev) 80%, transparent)"},children:[a.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[a.jsx("span",{className:"h-section",children:"Activity"}),a.jsxs("div",{className:"flex gap-1",children:[a.jsx(S,{k:"all",label:"All",enabled:!0}),a.jsx(S,{k:"signals",label:"Signals",enabled:!0}),a.jsx(S,{k:"tasks",label:"Tasks (none yet)",enabled:!1}),a.jsx(S,{k:"skills",label:"Skills (none yet)",enabled:!1})]})]}),o?a.jsx("div",{className:"py-6 text-center text-xs",style:{color:"var(--text-dim)"},children:"Loading…"}):b.length===0?a.jsx(da,{title:"No activity yet",hint:"Signals, task completions, and skill binds will appear here.",compact:!0}):a.jsx("div",{className:"space-y-1",children:b.map((O,Q)=>{const L=Vg[O.signal]||"text-text-dim",X=!!(O.consensusId&&O.findingId),M=a.jsxs("div",{className:"flex items-start gap-2 py-1.5",children:[a.jsx("span",{className:"shrink-0 font-mono text-[9px] tabular-nums w-16",style:{color:"color-mix(in oklch, var(--text-dim) 60%, transparent)"},children:We(O.timestamp)}),a.jsx("span",{className:`shrink-0 rounded-sm px-1.5 py-0.5 font-mono text-[9px] font-bold ${L}`,children:O.signal}),a.jsxs("div",{className:"min-w-0 flex-1 text-[11px]",style:{color:"var(--text-dim)"},children:[O.counterpartId&&a.jsxs("span",{className:"font-mono text-[10px]",style:{color:"color-mix(in oklch, var(--text-dim) 70%, transparent)"},children:["→ ",O.counterpartId," · "]}),O.evidence&&a.jsx("span",{children:O.evidence.length>160?O.evidence.slice(0,160)+"…":O.evidence})]})]});return X?a.jsx("button",{type:"button",onClick:()=>x({consensusId:O.consensusId,findingId:O.findingId}),className:"w-full rounded-sm text-left transition hover:bg-accent/10",children:M},Q):a.jsx("div",{children:M},Q)})}),a.jsx(qi,{open:!!p,onOpenChange:O=>{O||x(null)},consensusId:(p==null?void 0:p.consensusId)??null,findingId:(p==null?void 0:p.findingId)??null})]})}function Zg(){const i=k.useRef(null),[r,u]=k.useState(0);return k.useEffect(()=>{const o=i.current;if(!o||typeof ResizeObserver>"u")return;const d=new ResizeObserver(m=>{for(const v of m)u(v.contentRect.width)});return d.observe(o),()=>d.disconnect()},[]),[i,r]}const th={agreement:"bg-confirmed",consensus_verified:"bg-confirmed",unique_confirmed:"bg-unique",unique_unconfirmed:"bg-unique/50",disagreement:"bg-disputed/70",hallucination_caught:"bg-disputed",new_finding:"bg-unique",unverified:"bg-unverified",citation_fabricated:"bg-amber-500",boundary_escape:"bg-destructive"},Kg={agreement:"Confirmed",consensus_verified:"Confirmed",unique_confirmed:"Unique (confirmed)",unique_unconfirmed:"Unique (unconfirmed)",disagreement:"Disputed",hallucination_caught:"Hallucination",new_finding:"New finding",unverified:"Unverified",citation_fabricated:"Fabricated citation",boundary_escape:"Process violation"},Jg=6,Fg=500,jh=100,Ig=150;function Wg(i){if(i<=0)return jh;const r=Math.floor(i/Jg);return Math.max(1,Math.min(r,Fg))}function Pg({agentId:i}){const[r,u]=k.useState([]),[o,d]=k.useState(0),[m,v]=k.useState(!1),[p,x]=k.useState(null),[g,b]=Zg(),[S,O]=k.useState(jh),Q=k.useRef(null);k.useEffect(()=>{if(b<=0)return;const K=Wg(b);return Q.current&&clearTimeout(Q.current),Q.current=setTimeout(()=>{O(ee=>ee===K?ee:K)},Ig),()=>{Q.current&&clearTimeout(Q.current)}},[b]),k.useEffect(()=>{Ge(`signals?agent=${encodeURIComponent(i)}&limit=${S}`).then(K=>{u(K.items||[]),d(K.total||0)}).catch(()=>{})},[i,S]);const L=k.useMemo(()=>[...r].reverse(),[r]),X={confirmed:0,disputed:0,unique:0,unverified:0,fabricated:0};for(const K of r)K.signal==="agreement"||K.signal==="consensus_verified"?X.confirmed++:K.signal==="disagreement"||K.signal==="hallucination_caught"?X.disputed++:K.signal==="unique_confirmed"||K.signal==="unique_unconfirmed"||K.signal==="new_finding"?X.unique++:K.signal==="unverified"?X.unverified++:K.signal==="citation_fabricated"&&X.fabricated++;const M=r.length,I=o>M;return r.length===0?a.jsx("div",{ref:g,className:"rounded-md border border-border/40 px-4 py-3",style:{background:"color-mix(in oklch, var(--surface-elev) 80%, transparent)"},children:a.jsx(da,{title:"No signal history yet",hint:"Signals are recorded during consensus rounds.",compact:!0})}):a.jsxs("div",{ref:g,className:"rounded-md border border-border/40 px-4 py-3",style:{background:"color-mix(in oklch, var(--surface-elev) 80%, transparent)"},children:[a.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-baseline gap-2",children:[a.jsx("span",{className:"h-section",children:"Signal Timeline"}),a.jsx("span",{className:"font-mono text-[9px]",style:{color:"color-mix(in oklch, var(--text-dim) 50%, transparent)"},children:I?`last ${M} of ${o}`:`${o} total`})]}),a.jsxs("div",{className:"flex items-center gap-3 font-mono text-[10px]",children:[a.jsxs("span",{className:"text-confirmed",children:[X.confirmed," confirmed"]}),X.disputed>0&&a.jsxs("span",{className:"text-disputed",children:[X.disputed," disputed"]}),X.unique>0&&a.jsxs("span",{className:"text-unique",children:[X.unique," unique"]}),X.unverified>0&&a.jsxs("span",{className:"text-unverified",children:[X.unverified," unverified"]}),X.fabricated>0&&a.jsxs("span",{className:"text-amber-500",children:[X.fabricated," fabricated"]})]})]}),a.jsx("div",{className:"flex items-center gap-0.5",children:L.map((K,ee)=>{const J=!!(K.consensusId&&K.findingId);return a.jsx("button",{type:"button",disabled:!J,onClick:()=>{K.consensusId&&K.findingId&&(x({consensusId:K.consensusId,findingId:K.findingId}),v(!0))},className:`h-4 min-w-[4px] flex-1 rounded-sm transition-opacity hover:opacity-80 ${th[K.signal]||""} ${J?"cursor-pointer":"cursor-default"}`,style:th[K.signal]?void 0:{background:"var(--surface-sunk)"},title:`${Kg[K.signal]||K.signal} — ${We(K.timestamp)}${J?" (click for detail)":""}`},ee)})}),a.jsx("div",{className:"mt-2 flex flex-wrap gap-3",children:[{color:"bg-confirmed",label:"Confirmed"},{color:"bg-disputed",label:"Disputed"},{color:"bg-unique",label:"Unique (confirmed)"},{color:"bg-unique/50",label:"Unique (unconfirmed)"},{color:"bg-unverified",label:"Unverified"},{color:"bg-amber-500",label:"Fabricated citation"}].map(K=>a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("div",{className:`h-2 w-2 rounded-sm ${K.color}`}),a.jsx("span",{className:"font-mono text-[9px]",style:{color:"color-mix(in oklch, var(--text-dim) 60%, transparent)"},children:K.label})]},K.label))}),a.jsx(qi,{open:m,onOpenChange:v,consensusId:(p==null?void 0:p.consensusId)??null,findingId:(p==null?void 0:p.findingId)??null})]})}function ey(i){const r=i.toLowerCase();return r==="completed"||r==="done"||r==="success"||r==="succeeded"?"completed":r==="running"||r==="active"||r==="in_progress"||r==="pending"?"running":r==="failed"||r==="error"||r==="errored"||r==="timeout"||r==="timed_out"?"failed":r==="cancelled"||r==="canceled"||r==="queued"||r==="waiting"?"cancelled":"unknown"}const ty={completed:{label:"Done",iconBox:"bg-confirmed/10 border-confirmed/30",text:"text-confirmed",pulse:!1},running:{label:"Running",iconBox:"bg-unverified/10 border-unverified/30",text:"text-unverified",pulse:!0},failed:{label:"Failed",iconBox:"bg-destructive/10 border-destructive/30",text:"text-destructive",pulse:!1},cancelled:{label:"Cancelled",iconBox:"border-muted-foreground/25",text:"",textStyle:{color:"var(--text-dim)",background:"color-mix(in oklch, var(--text-dim) 10%, transparent)"},pulse:!1},unknown:{label:"Unknown",iconBox:"border-muted-foreground/25",text:"",textStyle:{color:"var(--text-dim)",background:"color-mix(in oklch, var(--text-dim) 10%, transparent)"},pulse:!1}},ny={completed:a.jsx("polyline",{points:"5 12 10 17 19 7"}),running:a.jsxs(a.Fragment,{children:[a.jsx("circle",{cx:"12",cy:"12",r:"3",fill:"currentColor",stroke:"none"}),a.jsx("circle",{cx:"12",cy:"12",r:"8",opacity:"0.45"})]}),failed:a.jsxs(a.Fragment,{children:[a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"}),a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"})]}),cancelled:a.jsx("line",{x1:"6",y1:"12",x2:"18",y2:"12"}),unknown:a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M9.5 9a2.5 2.5 0 1 1 3.5 2.3c-.8.4-1 .9-1 1.7"}),a.jsx("line",{x1:"12",y1:"16.5",x2:"12",y2:"16.5"})]})};function ly(i){if(!i)return"—";if(i<1e3)return"< 1s";if(i<6e4)return Math.floor(i/1e3)+"s";if(i<36e5){const o=Math.floor(i/6e4),d=Math.floor(i%6e4/1e3);return d>0?`${o}m ${d}s`:`${o}m`}const r=Math.floor(i/36e5),u=Math.floor(i%36e5/6e4);return u>0?`${r}h ${u}m`:`${r}h`}function Nh({task:i,onClick:r}){const u=ey(i.status),o=ty[u];return a.jsxs("tr",{className:`border-b border-border hover:bg-accent/10 transition-colors ${r?"cursor-pointer":""}`,onClick:r?d=>{d.target.closest("a")||r(i)}:void 0,children:[a.jsx("td",{className:"py-2.5 pl-4 pr-2",children:a.jsxs("span",{className:"inline-flex items-center gap-2","aria-label":`Status: ${o.label}`,children:[a.jsx("span",{className:`flex h-[22px] w-[22px] shrink-0 items-center justify-center rounded-full border ${o.iconBox} ${o.text} ${o.pulse?"animate-pulse":""}`,style:o.textStyle,"aria-hidden":!0,children:a.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:ny[u]})}),a.jsx("span",{className:`font-mono text-[10px] font-semibold uppercase tracking-wider ${o.text}`,style:o.textStyle,children:o.label})]})}),a.jsx("td",{className:"py-2.5 pr-3",children:a.jsx("span",{className:"warn-badge rounded px-2 py-1 font-mono text-[10px] font-semibold",title:i.taskId,children:i.taskId.slice(0,8)})}),a.jsx("td",{className:"py-2.5 pr-3 font-mono text-xs",style:{color:"var(--text-dim)"},children:a.jsxs("a",{href:`/dashboard/agent/${encodeURIComponent(i.agentId)}`,className:"inline-flex items-center gap-1.5 transition",children:[a.jsx("span",{className:"inline-block h-2 w-2 shrink-0 rounded-full",style:{backgroundColor:gn(i.agentId)}}),i.agentId]})}),a.jsx("td",{className:"py-2.5 pr-3 text-xs leading-snug",style:{color:"color-mix(in oklch, var(--text) 80%, transparent)"},children:(()=>{const d=i.task.replace(/\n.*/s,"");return d.length>100?d.slice(0,100)+"…":d})()}),a.jsx("td",{className:"py-2.5 pr-3 font-mono text-xs",style:{color:"var(--text-dim)"},children:u==="running"?"running":ly(i.duration)}),a.jsx("td",{className:"py-2.5 pr-4 text-right font-mono text-xs",style:{color:"color-mix(in oklch, var(--text-dim) 50%, transparent)"},children:We(i.timestamp)})]})}const ay=3,sy=720*60*60*1e3;function iy({agentId:i,agents:r,tasks:u,consensus:o}){const d=r.find(y=>y.id===i),[m,v]=k.useState([]),[p,x]=k.useState([]),[g,b]=k.useState(null),[S,O]=k.useState(null),[Q,L]=k.useState(null),[X,M]=k.useState(0),[I,K]=k.useState(0),[ee,J]=k.useState(null);k.useEffect(()=>{Ge(`memory/${i}`).then(y=>{v(y.knowledge||[])}).catch(()=>v([]))},[i]),k.useEffect(()=>{let y=!1;return Ge("consensus-reports?page=1&pageSize=200").then(R=>{y||x(R.reports||[])}).catch(()=>{y||x([])}),()=>{y=!0}},[]);const A=k.useMemo(()=>{var G;const y=Date.now(),R=new Map;for(const le of p){const re=Date.parse(le.timestamp);if(Number.isNaN(re)||y-re>sy)continue;const ve=(G=le.authorDiagnostics)==null?void 0:G[i];if(ve)for(const Re of ve)R.set(Re.code,(R.get(Re.code)??0)+1)}const V=[];for(const[le,re]of R)re>=ay&&V.push({code:le,count:re});return V},[p,i]);if(!d)return a.jsxs("div",{className:"py-20 text-center",style:{color:"var(--text-dim)"},children:["Agent not found: ",i]});const q=d.scores,w=(u==null?void 0:u.items.filter(y=>y.agentId===i))||[],Z=(o==null?void 0:o.runs.filter(y=>y.agents.includes(i)))||[],te=[{label:"accuracy",value:q.accuracy,fill:q.accuracy>=.7?"bg-confirmed":q.accuracy>=.4?"bg-unverified":"bg-disputed"},{label:"unique",value:q.uniqueness,fill:"bg-unique"},{label:"impact",value:q.impactScore,fill:"bg-[var(--c8)]"}],ne=q.unverifiedsEmitted??0,de=q.unverifiedsReceived??0,F=ne+de,ae=[{label:"Signals",value:String(q.signals),color:"",colorStyle:{color:"var(--text)"}},{label:"Agreements",value:String(q.agreements),color:"text-confirmed",colorStyle:void 0},{label:"Disagreements",value:String(q.disagreements),color:"text-disputed",colorStyle:void 0},{label:"Hallucinations",value:String(q.hallucinations),color:q.hallucinations>0?"text-disputed":"",colorStyle:q.hallucinations>0?void 0:{color:"var(--text-dim)"}},{label:"Unverified",value:F>0?`${ne}↑ ${de}↓`:"0",color:F>0?"text-unverified":"",colorStyle:F>0?void 0:{color:"var(--text-dim)"},title:F>0?`${ne} emitted (as reviewer) · ${de} received (as author)`:void 0},{label:"Tokens",value:d.totalTokens.toLocaleString(),color:"",colorStyle:{color:"var(--text)"}}],me=10,E=Math.max(1,Math.ceil(w.length/me)),T=Math.min(X,E-1),H=w.slice(T*me,(T+1)*me),W=k.useMemo(()=>{const y=new Map;for(const R of m){const V=R.filename.match(/^(\d{4}-\d{2}-\d{2})/),G=V?V[1]:"undated",le=y.get(G)||[];le.push(R),y.set(G,le)}return Array.from(y.entries()).sort(([R],[V])=>R==="undated"?1:V==="undated"?-1:V.localeCompare(R)).map(([R,V])=>({day:R,items:V}))},[m]),ce=Math.min(I,Math.max(0,W.length-1)),ue=W[ce];return a.jsxs(a.Fragment,{children:[(()=>{const y=_o(q);return y==="benched"?a.jsx("div",{className:"mb-6 rounded-lg border border-destructive/30 bg-destructive/5 px-4 py-3",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"font-mono text-xs font-bold text-destructive",children:"BENCHED"}),a.jsxs("span",{className:"text-xs text-destructive/70",children:["Auto-bench rule fired (",q.bench.reason??"unknown","). Agent excluded from dispatch until scores recover."]})]})}):y==="struggling"?a.jsx("div",{className:"mb-6 rounded-lg border border-unverified/30 bg-unverified/5 px-4 py-3",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"font-mono text-xs font-bold text-unverified",children:"STRUGGLING"}),a.jsxs("span",{className:"text-xs text-unverified/70",children:[q.consecutiveFailures,"+ consecutive failures. Deprioritized until clean signals recorded."]})]})}):y==="kept-for-coverage"?a.jsx("div",{className:"mb-6 rounded-lg border border-unverified/30 bg-unverified/5 px-4 py-3",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"font-mono text-xs font-bold text-unverified",children:"KEPT FOR COVERAGE"}),a.jsxs("span",{className:"text-xs text-unverified/70",children:["Would be benched (",q.bench.reason??"rule","), but is the sole provider of a category — kept to preserve coverage."]})]})}):null})(),A.length>0&&a.jsx("div",{className:"mb-6 space-y-2",children:A.map(({code:y,count:R})=>a.jsxs("div",{className:"rounded-lg border border-unverified/30 bg-unverified/5 px-4 py-3","data-diagnostic-code":y,children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"font-mono text-xs font-bold text-unverified",children:"PARSE DIAGNOSTIC"}),a.jsx("span",{className:"font-mono text-[11px] text-unverified/80",dangerouslySetInnerHTML:{__html:No(y)}}),a.jsxs("span",{className:"font-mono text-[11px] text-unverified/60",children:["· ",R," fires in 30d"]})]}),a.jsxs("div",{className:"mt-1 text-xs",style:{color:"color-mix(in oklch, var(--text-dim) 80%, transparent)"},children:["This agent's raw output has repeatedly tripped ",a.jsx("span",{className:"font-mono",children:y}),". Inspect recent consensus rounds on this page for the per-finding banner, or check upstream pipeline layers (sanitizer / renderer / relay encoding)."]})]},y))}),a.jsx("div",{"data-theme":"dark",className:"relative mb-6 rounded-xl border border-border p-5",style:{background:"var(--surface-elev)",color:"var(--text)"},children:a.jsxs("div",{className:"flex items-center gap-6",children:[a.jsx("div",{className:"relative shrink-0","data-tooltip":`Accuracy ${Math.round(q.accuracy*100)}% · Uniqueness ${Math.round(q.uniqueness*100)}% · Impact ${Math.round(q.impactScore*100)}%`,children:a.jsx(us,{agentId:d.id,size:120,signals:q.signals,accuracy:q.accuracy,uniqueness:q.uniqueness,impact:q.impactScore})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("h1",{className:"truncate font-mono text-2xl font-bold",style:{color:"var(--text)"},children:d.id}),a.jsxs("p",{className:"mt-1 text-sm",style:{color:"var(--text-dim)"},children:[d.provider,"/",d.model]}),a.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[a.jsx("span",{className:`rounded-sm px-2 py-0.5 font-mono text-[10px] font-semibold ${d.native?"":"text-confirmed bg-confirmed/10"}`,style:d.native?{color:"var(--idle)",background:"color-mix(in oklch, var(--idle) 10%, transparent)"}:void 0,children:d.native?"NATIVE":"RELAY"}),d.preset&&a.jsx("span",{className:"rounded-sm px-2 py-0.5 font-mono text-[10px]",style:{background:"var(--surface-sunk)",color:"var(--text-dim)"},children:d.preset}),a.jsxs("span",{className:"font-mono text-[10px]",style:{color:"color-mix(in oklch, var(--text-dim) 60%, transparent)"},children:[q.signals," signals",d.lastTask?` · ${We(d.lastTask.timestamp)}`:""]})]})]}),a.jsxs("div",{className:"flex shrink-0 flex-col items-end rounded-md border border-border px-3 py-2",style:{background:"color-mix(in oklch, var(--surface) 60%, transparent)"},"data-tooltip":`Dispatch weight ${q.dispatchWeight.toFixed(2)}
|
|
78
|
+
Scale 0.3 → 2.0`,"data-tooltip-pos":"left",children:[a.jsx("span",{className:"font-mono text-2xl font-bold tabular-nums leading-none",style:{color:"var(--text)"},children:q.dispatchWeight.toFixed(2)}),a.jsx("span",{className:"mt-1 font-mono text-[9px] uppercase",style:{color:"color-mix(in oklch, var(--text-dim) 50%, transparent)"},children:"weight"})]})]})}),a.jsx("section",{className:"mb-6",children:a.jsx(Pg,{agentId:i})}),a.jsxs("section",{className:"mb-8 grid grid-cols-1 gap-6 lg:grid-cols-2",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"mb-3 h-section",children:"Metrics"}),a.jsxs("div",{className:"rounded-lg border border-border/40 p-4",style:{background:"color-mix(in oklch, var(--surface-elev) 80%, transparent)"},children:[a.jsx("div",{className:"space-y-2.5",children:te.map(y=>a.jsxs("div",{className:"grid grid-cols-[72px_1fr_44px] items-center gap-3",children:[a.jsx("span",{className:"h-section",style:{color:"var(--text-dim)",fontSize:"10px"},children:y.label}),a.jsx("div",{className:"h-1.5 overflow-hidden rounded-full",style:{background:"color-mix(in oklch, var(--surface) 80%, transparent)"},children:a.jsx("div",{className:`h-full rounded-full transition-all ${y.fill}`,style:{width:`${Math.max(0,Math.min(100,y.value*100))}%`}})}),a.jsxs("span",{className:"text-right font-mono text-[11px] font-bold tabular-nums",style:{color:"var(--text)"},children:[Math.round(y.value*100),"%"]})]},y.label))}),a.jsx("div",{className:"mt-4 grid grid-cols-6 gap-px overflow-hidden rounded-md border border-border/30 bg-border/30",children:ae.map(y=>a.jsxs("div",{className:"px-2 py-2 text-center",style:{background:"color-mix(in oklch, var(--surface) 60%, transparent)"},title:y.title,children:[a.jsx("div",{className:`font-mono text-sm font-bold tabular-nums ${y.color}`,style:y.colorStyle,children:y.value}),a.jsx("div",{className:"mt-0.5 font-mono text-[9px] uppercase tracking-wider",style:{color:"color-mix(in oklch, var(--text-dim) 70%, transparent)"},children:y.label})]},y.label))})]})]}),a.jsxs("div",{children:[a.jsx("h2",{className:"mb-1 h-section",children:"Category Competency"}),a.jsx("p",{className:"mb-3 mt-0.5 font-mono text-[11px]",style:{color:"color-mix(in oklch, var(--text-dim) 80%, transparent)"},children:"◆ Raw per-category ratio — unweighted. Overall accuracy in Metrics applies a hallucination penalty."}),a.jsx(wg,{categoryAccuracy:q.categoryAccuracy,categoryCorrect:q.categoryCorrect,categoryHallucinated:q.categoryHallucinated})]})]}),(d.skillSlots.length>0||d.skills.length>0)&&a.jsxs("section",{className:"mb-8",children:[a.jsxs("h2",{className:"mb-3 h-section",children:["Skills ",a.jsx("span",{style:{color:"var(--ink)",fontWeight:700},children:d.skillSlots.length||d.skills.length})]}),d.skillSlots.length>0?a.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-3",children:d.skillSlots.map(y=>a.jsx(Ug,{slot:y},y.name))}):a.jsx("div",{className:"flex flex-wrap gap-1.5",children:d.skills.map(y=>a.jsx("span",{className:"rounded-sm border border-border px-2.5 py-1 font-mono text-xs",style:{background:"var(--surface-elev)",color:"var(--text-dim)"},children:y},y))})]}),a.jsxs("section",{className:"mb-8",children:[a.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[a.jsxs("h2",{className:"h-section",children:["Tasks ",a.jsx("span",{style:{color:"var(--ink)",fontWeight:700},children:w.length})]}),E>1&&a.jsxs("div",{className:"flex items-center gap-2 font-mono text-[10px]",style:{color:"var(--text-dim)"},children:[a.jsx("button",{onClick:()=>M(y=>Math.max(0,y-1)),disabled:T===0,className:"rounded-sm border border-border/40 px-2 py-0.5 transition hover:bg-accent/10 disabled:opacity-30",style:{background:"var(--surface-elev)"},children:"◂ Prev"}),a.jsxs("span",{children:[T+1," / ",E]}),a.jsx("button",{onClick:()=>M(y=>Math.min(E-1,y+1)),disabled:T>=E-1,className:"rounded-sm border border-border/40 px-2 py-0.5 transition hover:bg-accent/10 disabled:opacity-30",style:{background:"var(--surface-elev)"},children:"Next ▸"})]})]}),w.length>0?a.jsx("div",{className:"overflow-hidden rounded-md border border-border/40",children:a.jsxs("table",{className:"w-full text-left",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b border-border",style:{background:"var(--surface-elev)"},children:[a.jsx("th",{className:"py-2 pl-4 pr-2 text-xs font-medium",style:{width:32,color:"var(--text-dim)"}}),a.jsx("th",{className:"py-2 pr-3 font-mono text-xs font-medium",style:{color:"var(--text-dim)"},children:"ID"}),a.jsx("th",{className:"py-2 pr-3 font-mono text-xs font-medium",style:{color:"var(--text-dim)"},children:"Agent"}),a.jsx("th",{className:"py-2 pr-3 text-xs font-medium",style:{color:"var(--text-dim)"},children:"Description"}),a.jsx("th",{className:"py-2 pr-3 font-mono text-xs font-medium",style:{color:"var(--text-dim)"},children:"Duration"}),a.jsx("th",{className:"py-2 pr-4 text-right font-mono text-xs font-medium",style:{color:"var(--text-dim)"},children:"When"})]})}),a.jsx("tbody",{children:H.map(y=>a.jsx(Nh,{task:y,onClick:J},y.taskId))})]})}):a.jsx("div",{className:"py-6 text-center text-sm",style:{color:"var(--text-dim)"},children:"No tasks recorded."})]}),a.jsxs("section",{className:"mb-8",children:[a.jsxs("h2",{className:"mb-3 h-section",children:["Consensus Runs ",a.jsx("span",{style:{color:"var(--ink)",fontWeight:700},children:Z.length})]}),Z.length>0?a.jsx("div",{className:"space-y-2",children:Z.slice(0,20).map((y,R)=>{const V=y.counts,G=(V.agreement||0)+(V.disagreement||0)+(V.hallucination||0)+(V.unverified||0)+(V.unique||0)+(V.new||0),le=G||1,re=[{key:"confirmed",count:V.agreement||0,color:"bg-confirmed",text:"text-confirmed"},{key:"disputed",count:(V.disagreement||0)+(V.hallucination||0),color:"bg-disputed",text:"text-disputed"},{key:"unverified",count:V.unverified||0,color:"bg-unverified",text:"text-unverified"},{key:"unique",count:(V.unique||0)+(V.new||0),color:"bg-unique",text:"text-unique"}],ve={agreement:{label:"CONFIRMED",cls:"text-confirmed bg-confirmed/10"},consensus_verified:{label:"CONFIRMED",cls:"text-confirmed bg-confirmed/10"},disagreement:{label:"DISPUTED",cls:"text-disputed bg-disputed/10"},hallucination_caught:{label:"DISPUTED",cls:"text-disputed bg-disputed/10"},unverified:{label:"UNVERIFIED",cls:"text-unverified bg-unverified/10"},unique_confirmed:{label:"UNIQUE",cls:"text-unique bg-unique/10"},unique_unconfirmed:{label:"UNIQUE",cls:"text-unique bg-unique/10"},new_finding:{label:"NEW",cls:"text-unique bg-unique/10"}},Re=y.signals.filter(Ae=>Ae.signal!=="signal_retracted"&&ve[Ae.signal]),Me=y.taskId+":"+R,qt=S===Me;return a.jsxs("div",{className:"rounded-md border border-border/40",style:{background:"var(--surface-elev)"},children:[a.jsx("button",{type:"button",onClick:()=>O(qt?null:Me),disabled:Re.length===0,className:`flex w-full items-center p-3 text-left transition ${Re.length>0?"hover:bg-accent/20":"cursor-default"}`,children:a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("span",{className:"font-mono text-sm font-semibold",style:{color:"var(--text)"},children:[Re.length>0&&a.jsx("span",{className:"mr-1.5 inline-block",style:{color:"var(--text-dim)"},children:qt?"▾":"▸"}),G," findings"]}),a.jsx("span",{className:"font-mono text-xs",style:{color:"var(--text-dim)"},children:We(y.timestamp)})]}),a.jsx("div",{className:"mt-1.5 flex gap-2",children:re.map(Ae=>Ae.count>0&&a.jsxs("span",{className:`font-mono text-[10px] font-semibold ${Ae.text}`,children:[Ae.count," ",Ae.key]},Ae.key))}),a.jsx("div",{className:"mt-1.5 flex h-1.5 overflow-hidden rounded-sm",children:re.map(Ae=>Ae.count>0&&a.jsx("div",{className:Ae.color,style:{width:`${Ae.count/le*100}%`}},Ae.key))})]})}),qt&&Re.length>0&&a.jsx("div",{className:"border-t border-border/30 px-3 pb-2 pt-2",children:a.jsx("div",{className:"space-y-1",children:Re.map((Ae,yn)=>{const Zn=ve[Ae.signal],Lt=!!(Ae.findingId&&y.taskId),Yt=a.jsxs("div",{className:"flex items-start gap-2 py-1",children:[a.jsx("span",{className:`shrink-0 rounded-sm px-1.5 py-0.5 font-mono text-[9px] font-bold ${Zn.cls}`,children:Zn.label}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("span",{className:"finding-md text-xs [&_.cite-file]:rounded [&_.cite-file]:bg-[color-mix(in_oklch,var(--cite-file)_10%,transparent)] [&_.cite-file]:px-1 [&_.cite-file]:font-mono [&_.cite-file]:text-[var(--cite-file)] [&_.cite-fn]:rounded [&_.cite-fn]:bg-[color-mix(in_oklch,var(--cite-fn)_10%,transparent)] [&_.cite-fn]:px-1 [&_.cite-fn]:font-mono [&_.cite-fn]:text-[var(--cite-fn)]",style:{color:"var(--text-dim)"},dangerouslySetInnerHTML:{__html:Oi(Ae.evidence||"")}}),a.jsxs("span",{className:"ml-2 font-mono text-[10px]",style:{color:"color-mix(in oklch, var(--text-dim) 50%, transparent)"},children:[Ae.agentId,Ae.counterpartId?` + ${Ae.counterpartId}`:""]})]})]});return Lt?a.jsx("button",{type:"button",onClick:()=>L({consensusId:y.taskId,findingId:Ae.findingId}),className:"block w-full rounded-sm text-left transition hover:bg-accent/10",children:Yt},yn):a.jsx("div",{children:Yt},yn)})})})]},Me)})}):a.jsx("div",{className:"py-6 text-center text-sm",style:{color:"var(--text-dim)"},children:"No consensus participation recorded."})]}),a.jsx("section",{className:"mb-8",children:a.jsx(Qg,{agentId:i})}),a.jsx(qi,{open:!!Q,onOpenChange:y=>{y||L(null)},consensusId:(Q==null?void 0:Q.consensusId)??null,findingId:(Q==null?void 0:Q.findingId)??null}),a.jsx(bh,{task:ee,onClose:()=>J(null)}),a.jsxs("section",{className:"mb-8",children:[a.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[a.jsxs("h2",{className:"h-section",children:["Memory ",a.jsxs("span",{style:{color:"var(--ink)",fontWeight:700},children:[m.length," files"]}),ue&&a.jsxs("span",{className:"ml-2 font-mono text-[10px]",style:{color:"var(--text-dim)"},children:["· ",ue.day," (",ue.items.length,")"]})]}),W.length>1&&a.jsxs("div",{className:"flex items-center gap-2 font-mono text-[10px]",style:{color:"var(--text-dim)"},children:[a.jsx("button",{onClick:()=>K(y=>Math.max(0,y-1)),disabled:ce===0,className:"rounded-sm border border-border/40 px-2 py-0.5 transition hover:bg-accent/10 disabled:opacity-30",style:{background:"var(--surface-elev)"},children:"◂ Newer"}),a.jsxs("span",{children:[ce+1," / ",W.length]}),a.jsx("button",{onClick:()=>K(y=>Math.min(W.length-1,y+1)),disabled:ce>=W.length-1,className:"rounded-sm border border-border/40 px-2 py-0.5 transition hover:bg-accent/10 disabled:opacity-30",style:{background:"var(--surface-elev)"},children:"Older ▸"})]})]}),ue&&ue.items.length>0?a.jsx("div",{className:"space-y-1.5",children:ue.items.map(y=>{var le,re;const R=g===y.filename,V=((le=y.frontmatter)==null?void 0:le.type)||"memory",G=((re=y.frontmatter)==null?void 0:re.name)||y.filename.replace(/\.md$/,"");return a.jsxs("div",{className:"rounded-md border border-border/40",style:{background:"color-mix(in oklch, var(--surface-elev) 80%, transparent)"},children:[a.jsxs("button",{onClick:()=>b(R?null:y.filename),className:"flex w-full items-center gap-2 p-3 text-left transition hover:bg-accent/10",children:[a.jsx("span",{className:"font-mono text-xs",style:{color:R?"var(--text)":"var(--text-dim)"},children:R?"▾":"▸"}),a.jsx("span",{className:"shrink-0 rounded-sm px-1.5 py-0.5 font-mono text-[9px] font-bold uppercase",style:{background:"var(--surface-sunk)",color:"var(--text-dim)"},children:V}),a.jsx("span",{className:"truncate font-mono text-xs font-semibold",style:{color:"var(--text)"},children:G}),a.jsx("span",{className:"ml-auto shrink-0 font-mono text-[10px]",style:{color:"var(--text-dim)"},children:y.filename})]}),R&&a.jsx("div",{className:"border-t border-border px-4 py-3",children:a.jsx("pre",{className:"whitespace-pre-wrap font-mono text-xs leading-relaxed",style:{color:"var(--text-dim)"},children:y.content})})]},y.filename)})}):a.jsx("div",{className:"py-6 text-center text-sm",style:{color:"var(--text-dim)"},children:"No memory files."})]})]})}const nh={dispatch:{color:"color-mix(in oklch, var(--text-dim) 80%, transparent)"},consensus:{color:"color-mix(in oklch, var(--info) 80%, transparent)"},error:{},timeout:{},worker:{color:"color-mix(in oklch, var(--text-dim) 70%, transparent)"},gemini:{color:"color-mix(in oklch, var(--text-dim) 70%, transparent)"},skill:{color:"color-mix(in oklch, var(--text-dim) 80%, transparent)"},boot:{color:"color-mix(in oklch, var(--text-dim) 50%, transparent)"},relay:{color:"color-mix(in oklch, var(--text-dim) 80%, transparent)"},gossip:{color:"color-mix(in oklch, var(--text-dim) 80%, transparent)"},utility:{color:"color-mix(in oklch, var(--text-dim) 60%, transparent)"},memory:{color:"color-mix(in oklch, var(--text-dim) 80%, transparent)"},persist:{color:"color-mix(in oklch, var(--text-dim) 50%, transparent)"},toolserver:{color:"color-mix(in oklch, var(--text-dim) 50%, transparent)"},other:{color:"color-mix(in oklch, var(--text-dim) 70%, transparent)"}},cy={error:"text-disputed",timeout:"text-unverified"},ry=[[/^\[gossipcat\]\s*\[worker:/,"worker"],[/^\[gossipcat\]\s*\[Gemini\]/,"gemini"],[/^\[gossipcat\]\s*\[ToolServer\]/,"toolserver"],[/^\[gossipcat\]\s*dispatch\b/,"dispatch"],[/^\[gossipcat\]\s*relay\b/,"relay"],[/^\[gossipcat\]\s*Cross-review\b/,"consensus"],[/^\[gossipcat\]\s*Consensus\b/,"consensus"],[/^\[gossipcat\]\s*Skill\b/,"skill"],[/^\[gossipcat\]\s*Bootstrap\b/,"boot"],[/^\[gossipcat\]\s*Booted:/,"boot"],[/^\[gossipcat\]\s*Dashboard:/,"boot"],[/^\[gossipcat\]\s*Adaptive\b/,"boot"],[/^\[gossipcat\]\s*Gossip\b/,"gossip"],[/^\[gossipcat\]\s*utility\b/,"utility"],[/^\[gossipcat\]\s*Compacted\b/,"memory"],[/native agent/,"boot"],[/persist|Persist/,"persist"],[/timeout|Timeout|timed.out/,"timeout"],[/^\[gossipcat\].*(?:Error|error|failed|Failed)/,"error"]];function oy(i){for(const[r,u]of ry)if(r.test(i))return u;return"other"}const uy=[{key:"all",label:"All"},{key:"dispatch",label:"Dispatch"},{key:"consensus",label:"Consensus"},{key:"error",label:"Errors"},{key:"timeout",label:"Timeouts"},{key:"worker",label:"Workers"},{key:"skill",label:"Skills"},{key:"relay",label:"Relay"},{key:"boot",label:"Boot"}],lh=1e3;function dy(){const[i,r]=k.useState([]),[u,o]=k.useState(0),[d,m]=k.useState(0),[v,p]=k.useState("all"),[x,g]=k.useState(!0),[b,S]=k.useState(!0),O=k.useRef(null),Q=k.useRef(0);k.useEffect(()=>{let M=!1;return(async()=>{try{const K=await Ge("logs?tail=500");if(M)return;r(K.entries),o(K.totalLines),m(K.fileSize),Q.current=K.totalLines+1}catch{}})(),()=>{M=!0}},[]),k.useEffect(()=>{if(b)return hh(M=>{var K;if(M.type!=="log_lines")return;const I=(K=M.data)==null?void 0:K.lines;I!=null&&I.length&&r(ee=>{const J=I.map((q,w)=>({line:Q.current+w,text:q,category:oy(q)}));Q.current+=I.length,o(q=>q+I.length);const A=[...ee,...J];return A.length>lh?A.slice(-lh):A})})},[b]),k.useEffect(()=>{x&&O.current&&O.current.scrollIntoView({behavior:"smooth"})},[i,x]);const L=v==="all"?i:i.filter(M=>M.category===v),X=k.useCallback(M=>M<1024?`${M} B`:M<1048576?`${(M/1024).toFixed(1)} KB`:`${(M/1048576).toFixed(1)} MB`,[]);return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"mb-4 flex items-baseline gap-3",children:[a.jsx("h1",{className:"h-route",children:"MCP Log"}),a.jsxs("span",{className:"font-mono text-sm tabular-nums",style:{color:"var(--ink-3)"},children:[u," lines"]}),a.jsx("span",{className:"font-mono text-[10px]",style:{color:"color-mix(in oklch, var(--text-dim) 50%, transparent)"},children:X(d)}),b&&a.jsxs("span",{className:"flex items-center gap-1 font-mono text-[10px] text-confirmed",children:[a.jsx("span",{className:"inline-block h-1.5 w-1.5 animate-pulse rounded-full bg-confirmed"}),"live"]})]}),a.jsxs("div",{className:"mb-3 flex items-center gap-1.5",children:[uy.map(M=>a.jsx("button",{onClick:()=>p(M.key),className:"rounded-sm px-2.5 py-1 font-mono text-[10px] font-semibold transition",style:v===M.key?{background:"var(--surface-sunk)",color:"var(--text)"}:{color:"var(--text-dim)"},children:M.label},M.key)),a.jsxs("div",{className:"ml-auto flex gap-1.5",children:[a.jsx("button",{onClick:()=>S(!b),className:`rounded-sm px-2.5 py-1 font-mono text-[10px] font-semibold transition ${b?"bg-confirmed/10 text-confirmed":""}`,style:b?void 0:{color:"var(--text-dim)"},children:b?"● Live":"○ Paused"}),a.jsx("button",{onClick:()=>g(!x),className:"rounded-sm px-2.5 py-1 font-mono text-[10px] font-semibold transition",style:x?{color:"var(--ok)",background:"color-mix(in oklch, var(--ok) 10%, transparent)"}:{color:"var(--text-dim)"},children:x?"⤓ Auto":"⤓ Scroll"})]})]}),a.jsx("div",{className:"overflow-hidden rounded-md border border-border",style:{background:"var(--surface-elev)"},children:a.jsxs("div",{className:"max-h-[70vh] overflow-y-auto p-3 font-mono text-xs leading-relaxed",children:[L.map(M=>a.jsxs("div",{className:"flex gap-2 hover:bg-accent/10",children:[a.jsx("span",{className:"w-10 shrink-0 select-none text-right",style:{color:"color-mix(in oklch, var(--text-dim) 30%, transparent)"},children:M.line}),a.jsx("span",{className:cy[M.category]??"",style:nh[M.category]??nh.other,children:M.text})]},M.line)),L.length===0&&a.jsx("div",{className:"py-8 text-center font-mono text-xs",style:{color:"var(--text-dim)"},children:i.length===0?"Loading...":v==="all"?"No log entries in current tail.":`No ${v} entries in current tail.`}),a.jsx("div",{ref:O})]})})]})}const fy=["critical","high","medium","low"],my=["manual","impl","meta","auto-provisional"];function ah(i,r){return i.includes(r)?i.filter(u=>u!==r):[...i,r]}const Kt="mb-1 block h-section",Jt={},Vn="w-full rounded border border-border px-2 py-1 font-mono text-[10px] focus:border-primary focus:outline-none",Qn={background:"var(--surface)",color:"var(--text)"};function hy({filters:i,onChange:r,agents:u,signalTypes:o}){const d=m=>v=>{const p=v.target.value;r({[m]:p===""?void 0:p})};return a.jsxs("aside",{className:"space-y-3 rounded-md border border-border/60 p-3",style:{background:"color-mix(in oklch, var(--surface-elev) 70%, transparent)"},children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("h2",{className:"h-section",children:"Filters"}),a.jsx("button",{type:"button",className:"font-mono text-[9px]",style:{color:"color-mix(in oklch, var(--text-dim) 70%, transparent)"},onClick:()=>r({agents:[],counterpart:void 0,signals:[],category:void 0,severity:void 0,since:void 0,until:void 0,consensusId:void 0,findingId:void 0,source:void 0}),children:"clear"})]}),a.jsxs("div",{children:[a.jsxs("label",{className:Kt,style:Jt,children:["Agents (",i.agents.length," selected)"]}),a.jsxs("div",{className:"max-h-32 overflow-y-auto rounded border border-border/60 p-1",style:{background:"var(--surface)"},children:[u.length===0&&a.jsx("div",{className:"px-1 py-0.5 font-mono text-[10px]",style:{color:"color-mix(in oklch, var(--text-dim) 50%, transparent)"},children:"no agents"}),u.map(m=>a.jsxs("label",{className:"flex cursor-pointer items-center gap-1.5 px-1 py-0.5 font-mono text-[10px] hover:bg-accent/20",style:{color:"var(--text)"},children:[a.jsx("input",{type:"checkbox",className:"h-3 w-3",checked:i.agents.includes(m),onChange:()=>r({agents:ah(i.agents,m)})}),a.jsx("span",{children:m})]},m))]})]}),a.jsxs("div",{children:[a.jsx("label",{className:Kt,style:Jt,children:"Counterpart"}),a.jsxs("select",{className:Vn,style:Qn,value:i.counterpart??"",onChange:d("counterpart"),children:[a.jsx("option",{value:"",children:"any"}),u.map(m=>a.jsx("option",{value:m,children:m},m))]})]}),a.jsxs("div",{children:[a.jsxs("label",{className:Kt,style:Jt,children:["Signal types (",i.signals.length,")"]}),a.jsxs("div",{className:"max-h-32 overflow-y-auto rounded border border-border/60 p-1",style:{background:"var(--surface)"},children:[o.length===0&&a.jsx("div",{className:"px-1 py-0.5 font-mono text-[10px]",style:{color:"color-mix(in oklch, var(--text-dim) 50%, transparent)"},children:"no signals"}),o.map(m=>a.jsxs("label",{className:"flex cursor-pointer items-center gap-1.5 px-1 py-0.5 font-mono text-[10px] hover:bg-accent/20",style:{color:"var(--text)"},children:[a.jsx("input",{type:"checkbox",className:"h-3 w-3",checked:i.signals.includes(m),onChange:()=>r({signals:ah(i.signals,m)})}),a.jsx("span",{children:m})]},m))]})]}),a.jsxs("div",{children:[a.jsx("label",{className:Kt,style:Jt,children:"Severity"}),a.jsxs("select",{className:Vn,style:Qn,value:i.severity??"",onChange:d("severity"),children:[a.jsx("option",{value:"",children:"any"}),fy.map(m=>a.jsx("option",{value:m,children:m},m))]})]}),a.jsxs("div",{children:[a.jsx("label",{className:Kt,style:Jt,"data-tooltip":"manual = operator-recorded · impl = implementer pipeline · meta = orchestrator self-telemetry · auto-provisional = unvalidated",children:"Source"}),a.jsxs("select",{className:Vn,style:Qn,value:i.source??"",onChange:d("source"),children:[a.jsx("option",{value:"",children:"any"}),my.map(m=>a.jsx("option",{value:m,children:m},m))]})]}),a.jsxs("div",{children:[a.jsx("label",{className:Kt,style:Jt,children:"Category"}),a.jsx("input",{type:"text",className:Vn,style:Qn,value:i.category??"",onChange:d("category"),placeholder:"e.g. trust_boundaries"})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[a.jsxs("div",{children:[a.jsx("label",{className:Kt,style:Jt,children:"Since"}),a.jsx("input",{type:"datetime-local",className:Vn,style:Qn,value:i.since?i.since.slice(0,16):"",onChange:m=>r({since:m.target.value?new Date(m.target.value).toISOString():void 0})})]}),a.jsxs("div",{children:[a.jsx("label",{className:Kt,style:Jt,children:"Until"}),a.jsx("input",{type:"datetime-local",className:Vn,style:Qn,value:i.until?i.until.slice(0,16):"",onChange:m=>r({until:m.target.value?new Date(m.target.value).toISOString():void 0})})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:Kt,style:Jt,children:"Consensus ID (prefix)"}),a.jsx("input",{type:"text",className:Vn,style:Qn,value:i.consensusId??"",onChange:d("consensusId"),placeholder:"e.g. d07eac46"})]}),a.jsxs("div",{children:[a.jsx("label",{className:Kt,style:Jt,children:"Finding ID (prefix)"}),a.jsx("input",{type:"text",className:Vn,style:Qn,value:i.findingId??"",onChange:d("findingId"),placeholder:"e.g. d07eac46-5f464e89:sonnet"})]})]})}const sh={agents:[],signals:[]},xy=["agreement","consensus_verified","unique_confirmed","unique_unconfirmed","disagreement","hallucination_caught","new_finding","unverified","impl_test_pass","impl_test_fail","impl_typecheck_pass","impl_typecheck_fail","task_completed","tool_turns","format_compliance"],py={agreement:"Agreement",consensus_verified:"Consensus verified",unique_confirmed:"Unique (confirmed)",unique_unconfirmed:"Unique (unconfirmed)",disagreement:"Disagreement",hallucination_caught:"Hallucination",new_finding:"New finding",unverified:"Unverified",impl_test_pass:"Test pass",impl_test_fail:"Test fail",impl_typecheck_pass:"Typecheck pass",impl_typecheck_fail:"Typecheck fail",impl_peer_approved:"Peer approved",impl_peer_rejected:"Peer rejected",boundary_escape:"Boundary escape"},vy={agreement:"var(--ok)",consensus_verified:"var(--ok)",impl_test_pass:"var(--ok)",impl_typecheck_pass:"var(--ok)",impl_peer_approved:"var(--ok)",disagreement:"var(--bad)",hallucination_caught:"var(--bad)",impl_test_fail:"var(--bad)",impl_typecheck_fail:"var(--bad)",impl_peer_rejected:"var(--bad)",boundary_escape:"var(--bad)",unique_confirmed:"var(--info)",unique_unconfirmed:"var(--info)",new_finding:"var(--info)",unverified:"var(--info)"},gy={critical:"var(--bad)",high:"var(--warn)",medium:"var(--severity-medium)",low:"var(--ink-3)"},is=100;function yy(){if(typeof window>"u")return{filters:sh,hadAny:!1};const i=new URLSearchParams(window.location.search),r=i.getAll("signal").filter(Boolean),u=i.get("agent"),o=i.get("counterpart")??void 0,d=i.get("category")??void 0,m=i.get("severity"),v=m==="critical"||m==="high"||m==="medium"||m==="low"?m:void 0,p=i.get("since")??void 0,x=i.get("until")??void 0,g=i.get("consensus_id")??void 0,b=i.get("finding_id")??void 0,S=i.get("source"),O=S==="manual"||S==="impl"||S==="meta"||S==="auto-provisional"?S:void 0;return r.length>0||u||o||d||v||p||x||g||b||O?{filters:{agents:u?[u]:[],signals:r,counterpart:o,category:d,severity:v,since:p,until:x,consensusId:g,findingId:b,source:O},hadAny:!0}:{filters:sh,hadAny:!1}}function by(i,r,u=is){const o=new URLSearchParams;o.set("limit",String(u)),o.set("offset",String(r)),i.agents.length===1&&o.set("agent",i.agents[0]),i.counterpart&&o.set("counterpart",i.counterpart);for(const d of i.signals)o.append("signal",d);return i.category&&o.set("category",i.category),i.severity&&o.set("severity",i.severity),i.since&&o.set("since",i.since),i.until&&o.set("until",i.until),i.consensusId&&o.set("consensus_id",i.consensusId),i.findingId&&o.set("finding_id",i.findingId),i.source&&o.set("source",i.source),o}function fo(i,r){return i?i.length>r?i.slice(0,r)+"…":i:""}function jy(){const[{filters:i,hadAny:r}]=k.useState(yy),[u,o]=k.useState(i),[d,m]=k.useState([]),[v,p]=k.useState(0),[x,g]=k.useState(0),[b,S]=k.useState(!1),[O,Q]=k.useState(null),[L,X]=k.useState([]),[M,I]=k.useState(!1),[K,ee]=k.useState(null),[J,A]=k.useState(null),q=k.useRef(null),w=k.useRef(0),Z=k.useCallback(async(E,T)=>{const H=++w.current;S(!0),Q(null);try{const W=by(E,T*is),ce=await Ge(`signals?${W.toString()}`);if(H!==w.current)return;m(ce.items??[]),g(ce.total??0)}catch(W){if(H!==w.current)return;Q(W instanceof Error?W.message:"fetch failed")}finally{H===w.current&&S(!1)}},[]);k.useEffect(()=>{Ge("agents").then(E=>{const T=(E??[]).map(H=>H.id).filter(Boolean).sort();T.length>0&&X(T)}).catch(()=>{})},[]),k.useEffect(()=>{p(0)},[u]),k.useEffect(()=>(q.current&&clearTimeout(q.current),q.current=setTimeout(()=>{Z(u,v)},250),()=>{q.current&&clearTimeout(q.current)}),[u,v,Z]);const te=k.useCallback(E=>{o(T=>({...T,...E}))},[]),ne=Math.max(1,Math.ceil(x/is)),de=Math.min(v,ne-1),F=x>0||r||b,ae=(E,T)=>{!E||!T||(ee(E),A(T),I(!0))},me=k.useMemo(()=>{const E=[];return u.agents.length&&E.push(`${u.agents.length} agents`),u.signals.length&&E.push(`${u.signals.length} signals`),u.severity&&E.push(u.severity),u.source&&E.push(u.source),(u.since||u.until)&&E.push("time window"),E.length?E.join(" · "):"all signals"},[u]);return a.jsxs("div",{className:"space-y-4",children:[a.jsx("div",{className:"flex items-baseline justify-between",children:a.jsxs("div",{children:[a.jsx("h1",{className:"h-route",children:"Signals"}),a.jsx("p",{className:"mt-0.5 font-mono text-[10px]",style:{color:"color-mix(in oklch, var(--text-dim) 60%, transparent)"},children:"Scored events emitted by agents during consensus review."}),a.jsxs("p",{className:"mt-0.5 font-mono text-[10px]",style:{color:"color-mix(in oklch, var(--text-dim) 70%, transparent)"},children:[me," — showing ",d.length," of ",x]})]})}),r&&a.jsxs("div",{className:"rounded-md border border-border/40 px-3 py-2 font-mono text-[10px]",style:{background:"color-mix(in oklch, var(--surface-sunk) 30%, transparent)",color:"var(--text-dim)"},children:["Filtered view — ",u.signals.length," signal type",u.signals.length!==1?"s":"",u.agents.length>0?` · ${u.agents.length} agent${u.agents.length!==1?"s":""}`:"",u.severity?` · severity: ${u.severity}`:"",u.source?` · source: ${u.source}`:"",". ",a.jsx("a",{href:vn("/signals"),style:{color:"var(--accent)"},children:"Clear filters"})]}),a.jsxs("div",{className:`grid grid-cols-1 gap-4 ${F?"lg:grid-cols-[260px_1fr]":""} lg:items-start`,children:[F&&a.jsx("div",{className:r?"opacity-70 transition-opacity hover:opacity-100 focus-within:opacity-100":void 0,children:a.jsx(hy,{filters:u,onChange:te,agents:L,signalTypes:xy})}),a.jsxs("section",{className:"min-w-0 overflow-hidden rounded-md border border-border/60",style:{background:"color-mix(in oklch, var(--surface-elev) 70%, transparent)"},children:[O&&a.jsx("div",{className:"border-b border-border/60 px-3 py-2 font-mono text-[10px]",style:{color:"var(--bad)",background:"color-mix(in oklch, var(--bad) 10%, transparent)"},children:O}),a.jsx("div",{className:"overflow-x-auto",children:a.jsxs("table",{className:"w-full border-collapse text-[10px]",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"h-section border-b border-border/60 text-left",style:{color:"color-mix(in oklch, var(--ink-2) 80%, transparent)"},children:[a.jsx("th",{className:"w-[6px] p-0","aria-label":"severity"}),a.jsx("th",{className:"px-2 py-1.5",children:"time"}),a.jsx("th",{className:"px-2 py-1.5",children:"agent"}),a.jsx("th",{className:"px-2 py-1.5",children:"verdict"}),a.jsx("th",{className:"px-2 py-1.5",children:"finding"}),a.jsx("th",{className:"px-2 py-1.5","data-tooltip":"The other agent in this signal — e.g. the peer who agreed or disputed",children:"counterpart"}),a.jsx("th",{className:"px-2 py-1.5","data-tooltip":"Finding ID — click row to open finding detail",children:"id"}),a.jsx("th",{className:"px-2 py-1.5",children:"consensus"})]})}),a.jsxs("tbody",{children:[d.length===0&&!b&&a.jsx("tr",{children:a.jsx("td",{colSpan:8,className:"px-2 py-8 text-center font-mono",style:{color:"color-mix(in oklch, var(--text-dim) 50%, transparent)"},children:"no signals match these filters"})}),d.map((E,T)=>{const H=!!(E.consensusId&&E.findingId),W=E.severity?gy[E.severity]:"transparent",ce=vy[E.signal]??"var(--ink-2)",ue=py[E.signal]??E.signal;return a.jsxs("tr",{className:`border-b border-border/30 ${H?"cursor-pointer transition-colors":""}`,style:H?{"--row-hover-bg":"color-mix(in oklch, var(--surface-sunk) 40%, transparent)"}:void 0,role:H?"button":void 0,tabIndex:H?0:void 0,"aria-label":H?`View finding ${E.findingId??""}`:void 0,onMouseEnter:y=>{H&&(y.currentTarget.style.background="color-mix(in oklch, var(--surface-sunk) 40%, transparent)")},onMouseLeave:y=>{H&&(y.currentTarget.style.background="")},onClick:()=>H&&ae(E.consensusId,E.findingId),onKeyDown:y=>{H&&(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),ae(E.consensusId,E.findingId))},children:[a.jsx("td",{className:"p-0",style:{background:W,width:6},title:E.severity??"no severity"}),a.jsx("td",{className:"whitespace-nowrap px-2 py-1 font-mono tabular-nums",style:{color:"color-mix(in oklch, var(--text-dim) 80%, transparent)"},title:E.timestamp,children:We(E.timestamp)}),a.jsx("td",{className:"whitespace-nowrap px-2 py-1 font-mono",style:{color:"var(--text)"},children:E.agentId}),a.jsx("td",{className:"whitespace-nowrap px-2 py-1",children:a.jsx("span",{className:"h-section",style:{color:ce,fontSize:11},children:ue})}),a.jsx("td",{className:"max-w-[320px] truncate px-2 py-1",style:{fontFamily:"var(--font-mono)",fontSize:12,lineHeight:1.45,color:"var(--text)"},title:E.evidence,children:fo(E.evidence,80)}),a.jsx("td",{className:"whitespace-nowrap px-2 py-1 font-mono",style:{color:"color-mix(in oklch, var(--text-dim) 80%, transparent)"},children:E.counterpartId??"—"}),a.jsx("td",{className:"whitespace-nowrap px-2 py-1 font-mono",style:{color:"color-mix(in oklch, var(--text-dim) 70%, transparent)"},title:E.findingId,children:E.findingId?fo(E.findingId,24):"—"}),a.jsx("td",{className:"whitespace-nowrap px-2 py-1 font-mono",style:{color:"color-mix(in oklch, var(--text-dim) 70%, transparent)"},title:E.consensusId,children:E.consensusId?fo(E.consensusId,16):"—"})]},`${E.timestamp}-${E.agentId}-${T}`)})]})]})}),a.jsxs("div",{className:"flex items-center justify-between border-t border-border/60 px-3 py-2",children:[a.jsx("span",{className:"font-mono text-[10px]",style:{color:"color-mix(in oklch, var(--text-dim) 60%, transparent)"},children:b?"loading…":`${de*is+1}–${de*is+d.length} of ${x}`}),a.jsxs("div",{className:"flex items-center gap-2 font-mono text-[10px]",style:{color:"var(--text-dim)"},children:[a.jsx("button",{type:"button",onClick:()=>p(E=>Math.max(0,E-1)),disabled:de===0||b,className:"rounded-sm border border-border/40 px-2 py-0.5 transition hover:bg-[color-mix(in_oklch,var(--surface-sunk)_50%,transparent)] disabled:opacity-30",style:{background:"var(--surface-elev)"},children:"◂ Prev"}),a.jsxs("span",{className:"tabular-nums",children:[de+1," / ",ne]}),a.jsx("button",{type:"button",onClick:()=>p(E=>Math.min(ne-1,E+1)),disabled:de>=ne-1||b,className:"rounded-sm border border-border/40 px-2 py-0.5 transition hover:bg-[color-mix(in_oklch,var(--surface-sunk)_50%,transparent)] disabled:opacity-30",style:{background:"var(--surface-elev)"},children:"Next ▸"})]})]})]})]}),a.jsx(qi,{open:M,onOpenChange:I,consensusId:K,findingId:J})]})}function Ny(){const[i,r]=k.useState(null),[u,o]=k.useState(null);k.useEffect(()=>{m0().then(r)},[]);const d=k.useCallback(async m=>{o(null);const v=await f0(m);v.ok?r(!0):o(v.kind)},[]);return{authed:i,login:d,error:u}}const Sy=5e3;function ky(){const[i,r]=k.useState({overview:null,agents:null,tasks:null,consensus:null,consensusReports:null,fleetTrend:null,signalActivity:null,skills:null,nativeMemories:null,gossipMemories:null,memories:null,loading:!0,error:null}),u=k.useRef(!1),o=k.useCallback(async()=>{if(!u.current){u.current=!0;try{const[d,m,v,p,x,g,b,S,O,Q]=await Promise.all([Ge("overview"),Ge("agents"),Ge("tasks?limit=2000"),Ge("consensus?pageSize=500"),Ge("consensus-reports?page=1&pageSize=200").catch(()=>({reports:[]})),Ge("fleet-trend?days=7").catch(()=>({days:7,points:[]})),Ge("signal-activity").catch(()=>({agents:[],total:0,generatedAt:""})),Ge("skills").catch(()=>({index:{},suggestions:[],effectiveness:[]})),Ge("native-memory").catch(()=>({knowledge:[]})),Ge("gossip-memory").catch(()=>({knowledge:[]}))]),L=[...O.knowledge||[]].map(M=>({...M,origin:"native"})).sort((M,I)=>I.filename>M.filename?1:-1),X=[...Q.knowledge||[]].map(M=>({...M,origin:"gossip"})).sort((M,I)=>I.filename>M.filename?1:-1);r({overview:d,agents:m,tasks:v,consensus:p,consensusReports:x,fleetTrend:g,signalActivity:b,skills:S,nativeMemories:L,gossipMemories:X,memories:L,loading:!1,error:null})}catch(d){r(m=>({...m,loading:!1,error:d.message}))}finally{u.current=!1}}},[]);return k.useEffect(()=>{o()},[o]),k.useEffect(()=>{const d=setInterval(()=>{o()},Sy);return()=>clearInterval(d)},[o]),{...i,refresh:o}}const Sh="dashboard:lastEventId";function _y(){if(typeof window>"u")return 0;const i=window.localStorage.getItem(Sh);if(!i)return 0;const r=parseInt(i,10);return Number.isFinite(r)?r:0}function Ey(i){typeof window>"u"||window.localStorage.setItem(Sh,String(i))}const ih=1e3,Ty=5e3;function My(i){k.useEffect(()=>{if(typeof window>"u"||typeof window.EventSource>"u")return;let r=null,u=null,o=ih,d=!1;function m(){if(d)return;const v=_y();r=new window.EventSource(`/dashboard/api/events?last_id=${v}`),r.onmessage=p=>{try{const x=JSON.parse(p.data);i(x),Ey(x.id),o=ih}catch{}},r.onerror=()=>{r&&(r.close(),r=null),!d&&(u=setTimeout(()=>{m()},o),o=Math.min(o*2,Ty))}}return m(),()=>{d=!0,u!==null&&clearTimeout(u),r&&(r.close(),r=null)}},[])}const ch=5,Ay=6e3;function wy({toast:i,onDismiss:r}){const u=k.useRef(null),o=k.useCallback(()=>{u.current&&(clearTimeout(u.current),u.current=null)},[]),d=k.useCallback(()=>{o(),u.current=setTimeout(()=>r(i.id),Ay)},[i.id,r,o]);k.useEffect(()=>(d(),o),[d,o]);const{type:m,payload:v}=i.event,p=m==="task.completed"?a.jsx("span",{style:{color:"var(--text-dim)"},children:"✓"}):v.confirmed>v.disputed?a.jsx("span",{className:"text-confirmed",children:"◎"}):a.jsx("span",{className:"text-disputed",children:"◎"});let x;if(m==="task.completed"){const b=String(v.agentId??"agent"),S=typeof v.durationMs=="number"?v.durationMs:null,O=S!==null?`${(S/1e3).toFixed(1)}s`:"—";x=`${b} finished in ${O}`}else{const b=Number(v.confirmed??0),S=Number(v.disputed??0);x=`Consensus done — ${b} confirmed · ${S} disputed`}const g=()=>{o(),m==="task.completed"&&v.taskId?rs("/tasks"):m==="consensus.completed"&&v.consensusId&&rs("/debates"),r(i.id)};return a.jsx("div",{className:["pointer-events-auto border rounded px-4 py-3 max-w-sm cursor-pointer","transition-all duration-200","motion-reduce:transition-none motion-reduce:transform-none","hover:border-border",i.exiting?"opacity-0 scale-95 opacity-0 translate-y-2":"opacity-100 scale-100 translate-x-0"].join(" "),style:{background:"var(--surface-elev)",boxShadow:"var(--shadow-card)"},onClick:g,onMouseEnter:o,onMouseLeave:d,children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"shrink-0 text-sm font-bold",children:p}),a.jsx("span",{title:x,className:"font-mono text-[11px] min-w-0 truncate",style:{color:"var(--text)"},children:x}),a.jsx("button",{className:"ml-auto shrink-0 hover:[color:var(--text-dim)] text-xs leading-none",style:{color:"color-mix(in oklch, var(--text-dim) 50%, transparent)"},onClick:b=>{b.stopPropagation(),o(),r(i.id)},"aria-label":"Dismiss notification",children:"×"})]})})}function Cy(){const[i,r]=k.useState([]),u=k.useCallback(d=>{r(m=>m.map(v=>v.id===d?{...v,exiting:!0}:v)),setTimeout(()=>{r(m=>m.filter(v=>v.id!==d))},250)},[]),o=k.useCallback(d=>{r(m=>{const v={id:d.id,event:d,exiting:!1},p=[...m,v];if(p.length>ch){const x=p.length-ch;return p.slice(x)}return p})},[]);return My(o),a.jsx("div",{className:"fixed bottom-4 right-4 z-50 flex flex-col-reverse gap-2 pointer-events-none",role:"region","aria-label":"Notifications","aria-live":"polite","aria-atomic":"false",children:i.map(d=>a.jsx(wy,{toast:d,onDismiss:u},d.id))})}function zy({agents:i,tasks:r,consensusReports:u,fleetTrend:o}){const[d,m]=k.useState("weight"),[v,p]=k.useState("desc"),[x,g]=k.useState(""),b=k.useMemo(()=>{const A=new Map;if(r)for(const q of r.items){const w=A.get(q.agentId);(!w||q.timestamp>w.timestamp)&&A.set(q.agentId,q)}return A},[r]);vh(u==null?void 0:u.reports),k.useMemo(()=>{const A=new Map;if(o){for(const q of o.points){const w=A.get(q.agentId)??[];w.push(q),A.set(q.agentId,w)}for(const q of A.values())q.sort((w,Z)=>w.day.localeCompare(Z.day))}return A},[o]);const S=i.filter(E0).length,O=i.filter(A=>A.scores.accuracy>=.5).length,Q=i.reduce((A,q)=>A+q.scores.signals,0),L=i.reduce((A,q)=>A+q.totalTokens,0),X=x.trim().toLowerCase(),M=X?i.filter(A=>A.id.toLowerCase().includes(X)||A.provider.toLowerCase().includes(X)||A.model.toLowerCase().includes(X)):i,I=A=>{const q=A.scores;switch(d){case"weight":return q.dispatchWeight;case"accuracy":return q.accuracy;case"uniqueness":return q.uniqueness;case"impact":return q.impactScore;case"signals":return q.signals;case"agreements":return q.agreements;case"hallucinations":return q.hallucinations;case"lastTask":{const w=b.get(A.id);return w?new Date(w.timestamp).getTime():0}}},K=[...M].sort((A,q)=>{const w=I(A),Z=I(q);return v==="desc"?Z-w:w-Z}),ee=A=>{d===A?p(q=>q==="desc"?"asc":"desc"):(m(A),p("desc"))},J=A=>d===A?v==="desc"?"▾":"▴":"";return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"mb-6",children:[a.jsxs("div",{className:"flex items-baseline gap-3",children:[a.jsx("h1",{className:"h-route",children:"Team"}),a.jsx("span",{className:"font-mono text-sm tabular-nums",style:{color:"var(--ink-3)"},children:i.length})]}),a.jsx("p",{className:"mt-0.5 text-[13px]",style:{color:"var(--ink-3)"},children:"Per-agent accuracy, signal counts, and dispatch weights."}),a.jsx("div",{className:"mt-2 grid grid-cols-2 gap-px overflow-hidden rounded-md [border-color:color-mix(in_oklch,var(--border)_40%,transparent)] border [background:color-mix(in_oklch,var(--border)_30%,transparent)] sm:grid-cols-4",children:[{label:"Healthy",value:O,varColor:"var(--ok)"},{label:"Benched",value:S,varColor:S>0?"var(--bad)":"var(--ink-3)"},{label:"Total Signals",value:Q.toLocaleString(),varColor:"var(--ink)"},{label:"Tokens Used",value:L.toLocaleString(),varColor:"var(--ink)"}].map(A=>a.jsxs("div",{style:{background:"var(--surface-elev)"},className:"px-4 py-3",children:[a.jsx("div",{className:"font-mono text-lg font-bold tabular-nums",style:{color:A.varColor},children:A.value}),a.jsx("div",{className:"h-section mt-0.5",children:A.label})]},A.label))})]}),a.jsx("div",{className:"mb-3",children:a.jsx("input",{type:"text",value:x,onChange:A=>g(A.target.value),placeholder:"Search agents by id, provider, or model...",className:"w-full max-w-md rounded-md [border-color:color-mix(in_oklch,var(--border)_40%,transparent)] border px-3 py-1.5 font-mono text-xs focus:[border-color:var(--ink-3)] focus:outline-none",style:{background:"color-mix(in oklch, var(--surface-elev) 80%, transparent)",color:"var(--ink)"}})}),a.jsx("div",{className:"overflow-hidden rounded-md [border-color:color-mix(in_oklch,var(--border)_40%,transparent)] border",style:{background:"color-mix(in oklch, var(--surface-elev) 80%, transparent)"},children:a.jsxs("table",{className:"w-full text-left",children:[a.jsxs("colgroup",{children:[a.jsx("col",{style:{width:44}}),a.jsx("col",{}),a.jsx("col",{style:{width:80}}),a.jsx("col",{style:{width:260}}),a.jsx("col",{style:{width:80}}),a.jsx("col",{style:{width:60}}),a.jsx("col",{})]}),a.jsx("thead",{children:a.jsxs("tr",{className:"border-b [border-color:color-mix(in_oklch,var(--border)_40%,transparent)]",style:{background:"color-mix(in oklch, var(--surface-sunk) 20%, transparent)"},children:[a.jsx("th",{className:"h-section py-2.5 pl-5 pr-2 text-center",children:"#"}),a.jsx("th",{className:"h-section py-2.5 pr-3 text-left",children:"Agent"}),a.jsxs("th",{className:"h-section py-2.5 pr-4 text-right cursor-pointer select-none hover:[color:var(--ink)]",onClick:()=>ee("weight"),children:["Weight ",J("weight")]}),a.jsx("th",{className:"h-section py-2.5 pr-4 text-left align-top",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("button",{onClick:()=>ee("accuracy"),className:"flex items-center gap-1 hover:[color:var(--ink)]","data-tooltip":"Accuracy — fraction of findings confirmed by cross-review (with hallucination penalty)",children:[a.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full bg-confirmed"}),"Acc",J("accuracy")]}),a.jsx("span",{style:{color:"color-mix(in oklch, var(--ink-3) 30%, transparent)"},children:"·"}),a.jsxs("button",{onClick:()=>ee("uniqueness"),className:"flex items-center gap-1 hover:[color:var(--ink)]","data-tooltip":"Uniqueness — findings this agent surfaced that no peer found",children:[a.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full bg-unique"}),"Unq",J("uniqueness")]}),a.jsx("span",{style:{color:"color-mix(in oklch, var(--ink-3) 30%, transparent)"},children:"·"}),a.jsxs("button",{onClick:()=>ee("impact"),className:"flex items-center gap-1 hover:[color:var(--ink)]","data-tooltip":"Impact — severity-weighted finding score",children:[a.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full bg-[var(--c8)]"}),"Imp",J("impact")]})]})}),a.jsxs("th",{className:"h-section py-2.5 pr-4 text-right cursor-pointer select-none hover:[color:var(--ink)]",onClick:()=>ee("signals"),children:["Signals ",J("signals")]}),a.jsxs("th",{className:"h-section py-2.5 pr-4 text-right cursor-pointer select-none hover:[color:var(--ink)]",onClick:()=>ee("hallucinations"),"data-tooltip":"Hallucinations — fabricated findings caught by cross-review",children:["Halluc ",J("hallucinations")]}),a.jsxs("th",{className:"h-section py-2.5 pr-5 text-left cursor-pointer select-none hover:[color:var(--ink)]",onClick:()=>ee("lastTask"),children:["Last Task ",J("lastTask")]})]})}),a.jsx("tbody",{children:K.map((A,q)=>{const w=A.scores,Z=b.get(A.id),te=w.dispatchWeight>=1.2?"var(--ok)":w.dispatchWeight>=.8?"var(--ink)":"var(--bad)",ne=q+1;return a.jsxs("tr",{className:"group border-t [border-color:color-mix(in_oklch,var(--border)_20%,transparent)] align-top transition-colors hover:bg-accent/20",children:[a.jsx("td",{className:"py-3 pl-5 pr-2 text-center align-top",children:a.jsx("span",{className:"font-mono text-[11px] tabular-nums",style:{color:ne===1?"var(--ink)":ne===2||ne===3?"color-mix(in oklch, var(--ink-2) 80%, transparent)":"var(--ink-3)",fontWeight:ne===1?"bold":ne<=3?600:void 0},children:ne})}),a.jsx("td",{className:"py-2.5 pr-3 align-top",children:a.jsxs("a",{href:`/dashboard/agent/${encodeURIComponent(A.id)}`,className:"flex items-center gap-3",children:[a.jsx(us,{agentId:A.id,size:32,signals:w.signals,accuracy:w.accuracy,uniqueness:w.uniqueness,impact:w.impactScore}),a.jsxs("div",{className:"min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("span",{className:"truncate font-mono text-xs font-semibold group-hover:[color:var(--accent)]",style:{color:"var(--ink)"},children:A.id}),(()=>{const de=_o(w);return de==="benched"?a.jsx("span",{className:"shrink-0 rounded px-1 text-[8px] font-bold",style:{background:"color-mix(in oklch, var(--bad) 15%, transparent)",color:"var(--bad)",fontVariant:"small-caps",letterSpacing:"0.04em"},"data-tooltip":`Benched (${w.bench.reason??"auto"}). Excluded from dispatch until recovery.`,children:"benched"}):de==="struggling"?a.jsx("span",{className:"shrink-0 rounded bg-unverified/15 px-1 text-[8px] font-bold text-unverified",style:{fontVariant:"small-caps",letterSpacing:"0.04em"},"data-tooltip":"Struggling: consecutive failures tripped the circuit breaker. Deprioritized until new clean signals recover the score.",children:"struggling"}):de==="kept-for-coverage"?a.jsx("span",{className:"shrink-0 rounded border border-unverified/40 px-1 text-[8px] font-bold text-unverified",style:{fontVariant:"small-caps",letterSpacing:"0.04em"},"data-tooltip":`Would bench (${w.bench.reason??"rule"}), but kept as sole provider of a category.`,children:"kept for coverage"}):null})()]}),a.jsxs("div",{className:"truncate font-mono text-[10px]",style:{color:"var(--ink-3)"},children:[A.provider,"/",A.model]})]})]})}),a.jsx("td",{className:"py-3 pr-4 text-right align-top",children:a.jsx("span",{className:"font-mono text-sm font-bold tabular-nums",style:{color:te},children:w.dispatchWeight.toFixed(2)})}),a.jsx("td",{className:"py-3 pr-4 align-top",children:a.jsxs("div",{className:"space-y-1",children:[a.jsx(mo,{label:"A",value:w.accuracy,fillClass:w.accuracy>=.7?"bg-confirmed":w.accuracy>=.4?"bg-unverified":"bg-disputed",tooltip:"Adjusted accuracy = raw signal ratio × 1/(1 + weighted hallucinations × 0.3). The penalty is recoverable via skill-gated multiplier in the same category."}),a.jsx(mo,{label:"U",value:w.uniqueness,fillClass:"bg-unique",tooltip:"Uniqueness — findings this agent surfaced that no other agent found"}),a.jsx(mo,{label:"I",value:w.impactScore,fillClass:"bg-[var(--c8)]",tooltip:"Impact — severity-weighted finding score; critical and high findings count more"})]})}),a.jsx("td",{className:"py-3 pr-4 text-right align-top font-mono text-xs tabular-nums",style:{color:"var(--ink)"},children:w.signals.toLocaleString()}),a.jsx("td",{className:"py-3 pr-4 text-right align-top font-mono text-xs tabular-nums",children:a.jsx("span",{style:{color:w.hallucinations>0?"var(--bad)":"var(--ink-3)",fontWeight:w.hallucinations>10?"bold":void 0},"data-tooltip":`Agreements ${w.agreements} · Disagreements ${w.disagreements} · Hallucinations ${w.hallucinations}`,children:w.hallucinations})}),a.jsx("td",{className:"py-3 pr-5 align-top",children:Z?a.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[a.jsx("span",{className:"warn-badge shrink-0 rounded px-1.5 py-0.5 font-mono text-[9px] font-semibold",children:Z.taskId.slice(0,8)}),a.jsx("span",{className:"truncate text-[11px]",style:{maxWidth:260,color:"var(--ink-2)"},children:Z.task}),a.jsx("span",{className:"ml-auto shrink-0 font-mono text-[10px]",style:{color:"var(--ink-3)"},children:We(Z.timestamp)})]}):a.jsx("span",{className:"font-mono text-[10px]",style:{color:"var(--ink-3)"},children:"no tasks"})})]},A.id)})})]})})]})}function mo({label:i,value:r,fillClass:u,tooltip:o}){return a.jsxs("div",{className:"flex items-center gap-2","data-tooltip":o,"data-tooltip-pos":"top",children:[a.jsx("span",{className:"w-6 text-[10px]",style:{color:"var(--ink-3)",fontVariant:"small-caps",letterSpacing:"0.04em"},children:i}),a.jsx("div",{className:"h-1 flex-1 overflow-hidden rounded-full",style:{background:"color-mix(in oklch, var(--surface) 60%, transparent)"},children:a.jsx("div",{className:`h-full rounded-full ${u}`,style:{width:`${Math.max(0,Math.min(100,r*100))}%`}})}),a.jsxs("span",{className:"w-8 text-right font-mono text-[10px] tabular-nums",style:{color:"var(--ink-2)"},children:[Math.round(r*100),"%"]})]})}function Dy({tasks:i}){const[r,u]=k.useState(""),[o,d]=k.useState(0),[m,v]=k.useState(null),p=100,x=i.items.filter(M=>M.status==="completed").length,g=i.items.filter(M=>M.status==="failed").length,b=i.items.filter(M=>M.status==="running").length,S=r.trim().toLowerCase(),O=S?i.items.filter(M=>{var I,K,ee,J;return((I=M.task)==null?void 0:I.toLowerCase().includes(S))||((K=M.agentId)==null?void 0:K.toLowerCase().includes(S))||((ee=M.taskId)==null?void 0:ee.toLowerCase().includes(S))||((J=M.status)==null?void 0:J.toLowerCase().includes(S))}):i.items,Q=Math.max(1,Math.ceil(O.length/p)),L=Math.min(o,Q-1),X=O.slice(L*p,(L+1)*p);return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"mb-6",children:[a.jsxs("div",{className:"flex items-baseline gap-3",children:[a.jsx("h1",{className:"h-route",children:"Tasks"}),a.jsx("span",{className:"font-mono text-sm tabular-nums",style:{color:"var(--ink-3)"},children:i.total})]}),a.jsx("p",{className:"mt-0.5 text-[13px]",style:{color:"var(--ink-3)"},children:"Live dispatched tasks and their relay status."}),a.jsxs("div",{className:"mt-2 flex gap-4 font-mono text-[11px]",style:{color:"var(--ink-3)"},children:[a.jsxs("span",{children:[a.jsx("span",{style:{color:"var(--ok)"},children:x})," completed"]}),g>0&&a.jsxs("span",{children:[a.jsx("span",{style:{color:"var(--bad)"},children:g})," failed"]}),b>0&&a.jsxs("span",{children:[a.jsx("span",{className:"text-unverified",children:b})," running"]}),a.jsxs("span",{children:["showing ",X.length," of ",O.length,S&&` (filtered from ${i.items.length})`]})]})]}),a.jsxs("div",{className:"mb-3 flex items-center justify-between gap-3",children:[a.jsx("input",{type:"text",value:r,onChange:M=>{u(M.target.value),d(0)},placeholder:"Search tasks by description, agent, id, status...",className:"w-full max-w-md rounded-md [border-color:color-mix(in_oklch,var(--border)_40%,transparent)] border px-3 py-1.5 font-mono text-xs focus:[border-color:color-mix(in_oklch,var(--accent)_40%,transparent)] focus:outline-none",style:{background:"color-mix(in oklch, var(--surface-elev) 80%, transparent)",color:"var(--ink)"}}),a.jsxs("div",{className:`flex shrink-0 items-center gap-2 font-mono text-[11px] ${Q<=1?"invisible":""}`,style:{color:"var(--ink-3)"},children:[a.jsx("button",{onClick:()=>d(M=>Math.max(0,M-1)),disabled:L===0,className:"rounded-sm [border-color:color-mix(in_oklch,var(--border)_40%,transparent)] border px-2 py-0.5 transition hover:bg-accent/10 disabled:opacity-30",style:{background:"var(--surface-elev)"},children:"◂ Prev"}),a.jsxs("span",{children:[L+1," / ",Q]}),a.jsx("button",{onClick:()=>d(M=>Math.min(Q-1,M+1)),disabled:L>=Q-1,className:"rounded-sm [border-color:color-mix(in_oklch,var(--border)_40%,transparent)] border px-2 py-0.5 transition hover:bg-accent/10 disabled:opacity-30",style:{background:"var(--surface-elev)"},children:"Next ▸"})]})]}),a.jsx("div",{className:"overflow-hidden rounded-md [border-color:color-mix(in_oklch,var(--border)_40%,transparent)] border",style:{background:"color-mix(in oklch, var(--surface-elev) 80%, transparent)"},children:X.length===0?a.jsx("div",{className:"py-12 text-center text-sm",style:{color:"var(--ink-3)"},children:S?"No tasks match your search.":"No tasks yet."}):a.jsxs("table",{className:"w-full text-left",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b [border-color:color-mix(in_oklch,var(--border)_40%,transparent)]",style:{background:"color-mix(in oklch, var(--surface-sunk) 30%, transparent)"},children:[a.jsx("th",{className:"py-2.5 pl-4 pr-2 h-section",style:{width:32}}),a.jsx("th",{className:"py-2.5 pr-3 h-section",children:"ID"}),a.jsx("th",{className:"py-2.5 pr-3 h-section",children:"Agent"}),a.jsx("th",{className:"py-2.5 pr-3 h-section",children:"Description"}),a.jsx("th",{className:"py-2.5 pr-3 h-section",children:"Duration"}),a.jsx("th",{className:"py-2.5 pr-4 text-right h-section",children:"When"})]})}),a.jsx("tbody",{children:X.map(M=>a.jsx(Nh,{task:M,onClick:v},M.taskId))})]})}),a.jsx(bh,{task:m,onClose:()=>v(null)})]})}function Ry({consensus:i,consensusReports:r}){const[u,o]=k.useState(!1),d=u?i.runs:i.runs.filter(g=>!g.retracted),m=i.runs.filter(g=>g.retracted).length,v=d.reduce((g,b)=>g+(b.counts.agreement||0),0),p=d.reduce((g,b)=>g+((b.counts.disagreement||0)+(b.counts.hallucination||0)),0),x=d.reduce((g,b)=>g+(b.counts.unverified||0),0);return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"mb-6",children:[a.jsxs("div",{className:"flex items-baseline gap-3",children:[a.jsx("h1",{className:"h-route",children:"Consensus Rounds"}),a.jsx("span",{className:"font-mono text-sm tabular-nums",style:{color:"var(--ink-3)"},children:d.length}),!u&&m>0&&a.jsxs("span",{className:"font-mono text-sm tabular-nums",style:{color:"var(--ink-3)"},children:["/ ",i.totalRuns??i.runs.length," total"]})]}),a.jsx("p",{className:"mt-0.5 text-[13px]",style:{color:"var(--ink-3)"},children:"Multi-agent review rounds — findings confirmed when ≥2 agents agree."}),a.jsxs("div",{className:"mt-2 flex gap-4 font-mono text-[11px]",style:{color:"var(--ink-3)"},children:[a.jsxs("span",{children:[a.jsx("span",{style:{color:"var(--ok)"},children:v})," confirmed"]}),a.jsxs("span",{children:[a.jsx("span",{style:{color:"var(--bad)"},children:p})," disputed"]}),x>0&&a.jsxs("span",{children:[a.jsx("span",{className:"text-unverified",children:x})," unverified"]}),a.jsxs("span",{children:[i.totalSignals," total signals"]})]}),m>0&&a.jsxs("div",{className:"mt-2 flex items-center gap-2 font-mono text-[11px]",style:{color:"var(--ink-3)"},children:[a.jsx("span",{children:u?`${m} retracted run${m===1?"":"s"} shown`:`${m} retracted run${m===1?"":"s"} hidden`}),a.jsx("button",{type:"button",onClick:()=>o(g=>!g),className:"rounded-sm [border-color:color-mix(in_oklch,var(--border)_40%,transparent)] border px-2 py-0.5 text-[10px] transition hover:bg-accent/10 hover:[color:var(--ink)]",style:{background:"var(--surface-elev)"},children:u?"hide":"show"})]})]}),a.jsx(Eg,{consensus:i,filteredRuns:d,reports:r,showAll:!0,hideHeader:!0})]})}function Oy(){const i=rh(),{overview:r,agents:u,tasks:o,consensus:d,consensusReports:m,fleetTrend:v,signalActivity:p,skills:x,loading:g,refresh:b}=ky(),[S,O]=k.useState(0),Q=k.useCallback(ee=>{ee.type!=="log_lines"&&b()},[b]);if(xh(Q),g||!r||!d)return a.jsxs("div",{className:"min-h-screen",style:{background:"var(--surface)"},children:[a.jsx(Im,{}),a.jsx("div",{className:"flex items-center justify-center py-20",style:{color:"var(--ink-3)"},children:"Loading dashboard..."})]});let L;const X=i.match(/^\/agent\/(.+)$/),M=i.match(/^\/consensus\/(.+)$/);if(X&&u){const ee=decodeURIComponent(X[1]);L=a.jsx(iy,{agentId:ee,agents:u,tasks:o,consensus:d})}else if(M){const ee=decodeURIComponent(M[1]);L=a.jsx(cg,{consensusId:ee})}else i==="/team"&&u?L=a.jsx(zy,{agents:u,tasks:o,consensusReports:m,fleetTrend:v}):i==="/tasks"&&o?L=a.jsx(Dy,{tasks:o}):i==="/debates"&&d?L=a.jsx(Ry,{consensus:d,consensusReports:m}):i==="/logs"?L=a.jsx(dy,{}):i==="/signals"?L=a.jsx(jy,{}):i==="/violations"?L=a.jsx(Ag,{}):L=a.jsx(Jv,{overview:r,agents:u,tasks:o,consensus:d,consensusReports:m,fleetTrend:v,signalActivity:p,skills:x,activeTaskCount:S,setActiveTaskCount:O});const K=i==="/"||i==="/overview"||!/^\/(agent\/|consensus\/|team|tasks|debates|logs|signals|violations)/.test(i)?"px-6 py-6":"mx-auto max-w-7xl space-y-6 px-6 py-6";return a.jsxs("div",{className:"min-h-screen",style:{background:"var(--surface)"},children:[a.jsx(Im,{}),a.jsx("main",{className:K,children:L})]})}function Uy(){const{authed:i,login:r,error:u}=Ny();return i===null?a.jsx("div",{className:"flex min-h-screen items-center justify-center",style:{color:"var(--ink-3)"},children:"Loading..."}):i?a.jsxs(a.Fragment,{children:[a.jsx(Oy,{}),a.jsx(Cy,{})]}):a.jsx(rg,{onLogin:r,error:u})}e0.createRoot(document.getElementById("root")).render(a.jsx(k.StrictMode,{children:a.jsx(Uy,{})}));
|