@swestash/agent-lens 0.9.3 → 0.9.4

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.
@@ -1 +1 @@
1
- import{C as d,w as h,j as e,A as o,o as r,v as t}from"./index-F_4kZQVd.js";import{relPath as m,LinesDelta as p}from"./FilesView-ZB8kU8Hl.js";function v(){const[i]=d(),l=i.get("path")??"",a=i.get("project")??"",n=new URLSearchParams({path:l});a&&n.set("project",a);const s=h(l?"/file?"+n.toString():null);return e.jsx(o,{state:s,empty:e.jsx("div",{className:"muted pad",children:"Not found."}),children:c=>e.jsx(j,{data:c})})}function j({data:i}){return e.jsxs("div",{className:"file-view",children:[e.jsx(r,{to:"/files",className:"back",children:"← all files"}),e.jsxs("header",{className:"skill-head",children:[e.jsxs("h1",{children:["📄 ",m(i.file_path,i.project_path)]}),e.jsxs("div",{className:"skill-head-meta muted",children:[e.jsx("span",{title:i.file_path,children:i.file_path}),i.project_path?e.jsxs(e.Fragment,{children:[" · in ",i.project_path.replace(/^.*\//,"")]}):null]})]}),e.jsxs("div",{className:"kpis",children:[e.jsxs("div",{className:"kpi",children:[e.jsx("div",{className:"kpi-label",children:"sessions"}),e.jsx("div",{className:"kpi-value",children:i.sessions_count.toLocaleString()})]}),e.jsxs("div",{className:"kpi",children:[e.jsx("div",{className:"kpi-label",children:"changes"}),e.jsx("div",{className:"kpi-value",children:i.changes_count.toLocaleString()})]}),e.jsxs("div",{className:"kpi",children:[e.jsx("div",{className:"kpi-label",children:"lines + / −"}),e.jsxs("div",{className:"kpi-value",children:["+",i.lines_added.toLocaleString()," −",i.lines_removed.toLocaleString()]})]}),e.jsxs("div",{className:"kpi",children:[e.jsx("div",{className:"kpi-label",children:"first · last touched"}),e.jsxs("div",{className:"kpi-value kpi-sub",children:[t(i.first_ts)," · ",t(i.last_ts)]})]})]}),i.sessions.map(l=>{var n;const a=(n=l.changes.find(s=>s.event_uuid))==null?void 0:n.event_uuid;return e.jsxs("div",{className:"card",children:[e.jsxs("div",{className:"card-head",children:[e.jsx("h3",{children:e.jsx(r,{to:`/session/${l.session_id}${a?`#ev-${a}`:""}`,className:"title",title:a?"Open the session at this file's first change":void 0,children:l.title||e.jsx("span",{className:"muted",children:l.session_id.slice(0,12)})})}),e.jsxs("span",{className:"card-hint",children:[l.category&&e.jsx("span",{className:`tag cat-${l.category}`,children:l.category}),l.source_id&&e.jsx("span",{className:"tag",children:l.source_id})," ",t(l.started_at)]})]}),e.jsxs("table",{className:"sessions",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Turn"}),e.jsx("th",{children:"Tool"}),e.jsx("th",{className:"num",children:"+ / −"}),e.jsx("th",{children:"Prompt"}),e.jsx("th",{children:"When"})]})}),e.jsx("tbody",{children:l.changes.map(s=>e.jsxs("tr",{children:[e.jsx("td",{children:s.event_uuid?e.jsxs(r,{to:`/session/${l.session_id}#ev-${s.event_uuid}`,className:"title",title:"Jump to this change in the transcript",children:["turn ",s.turn_seq!=null?s.turn_seq+1:"?"]}):e.jsxs("span",{className:"muted",children:["turn ",s.turn_seq!=null?s.turn_seq+1:"?"]})}),e.jsx("td",{children:e.jsx("span",{className:"tag",children:s.tool_name})}),e.jsx("td",{className:"num",children:e.jsx(p,{added:s.lines_added,removed:s.lines_removed})}),e.jsx("td",{className:"muted",title:s.prompt_preview??void 0,children:s.prompt_preview?s.prompt_preview.length>80?s.prompt_preview.slice(0,79)+"…":s.prompt_preview:"—"}),e.jsx("td",{children:t(s.timestamp)})]},s.id))})]})]},l.session_id)}),e.jsx("p",{className:"muted pad",children:"Tracked from Edit/Write tool calls — changes made via shell commands or outside sessions aren’t captured."})]})}export{v as default};
1
+ import{C as d,w as h,j as e,A as o,L as r,v as t}from"./index-DYY0_SmQ.js";import{relPath as m,LinesDelta as p}from"./FilesView-D0gm4_XO.js";function v(){const[i]=d(),l=i.get("path")??"",a=i.get("project")??"",n=new URLSearchParams({path:l});a&&n.set("project",a);const s=h(l?"/file?"+n.toString():null);return e.jsx(o,{state:s,empty:e.jsx("div",{className:"muted pad",children:"Not found."}),children:c=>e.jsx(j,{data:c})})}function j({data:i}){return e.jsxs("div",{className:"file-view",children:[e.jsx(r,{to:"/files",className:"back",children:"← all files"}),e.jsxs("header",{className:"skill-head",children:[e.jsxs("h1",{children:["📄 ",m(i.file_path,i.project_path)]}),e.jsxs("div",{className:"skill-head-meta muted",children:[e.jsx("span",{title:i.file_path,children:i.file_path}),i.project_path?e.jsxs(e.Fragment,{children:[" · in ",i.project_path.replace(/^.*\//,"")]}):null]})]}),e.jsxs("div",{className:"kpis",children:[e.jsxs("div",{className:"kpi",children:[e.jsx("div",{className:"kpi-label",children:"sessions"}),e.jsx("div",{className:"kpi-value",children:i.sessions_count.toLocaleString()})]}),e.jsxs("div",{className:"kpi",children:[e.jsx("div",{className:"kpi-label",children:"changes"}),e.jsx("div",{className:"kpi-value",children:i.changes_count.toLocaleString()})]}),e.jsxs("div",{className:"kpi",children:[e.jsx("div",{className:"kpi-label",children:"lines + / −"}),e.jsxs("div",{className:"kpi-value",children:["+",i.lines_added.toLocaleString()," −",i.lines_removed.toLocaleString()]})]}),e.jsxs("div",{className:"kpi",children:[e.jsx("div",{className:"kpi-label",children:"first · last touched"}),e.jsxs("div",{className:"kpi-value kpi-sub",children:[t(i.first_ts)," · ",t(i.last_ts)]})]})]}),i.sessions.map(l=>{var n;const a=(n=l.changes.find(s=>s.event_uuid))==null?void 0:n.event_uuid;return e.jsxs("div",{className:"card",children:[e.jsxs("div",{className:"card-head",children:[e.jsx("h3",{children:e.jsx(r,{to:`/session/${l.session_id}${a?`#ev-${a}`:""}`,className:"title",title:a?"Open the session at this file's first change":void 0,children:l.title||e.jsx("span",{className:"muted",children:l.session_id.slice(0,12)})})}),e.jsxs("span",{className:"card-hint",children:[l.category&&e.jsx("span",{className:`tag cat-${l.category}`,children:l.category}),l.source_id&&e.jsx("span",{className:"tag",children:l.source_id})," ",t(l.started_at)]})]}),e.jsxs("table",{className:"sessions",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Turn"}),e.jsx("th",{children:"Tool"}),e.jsx("th",{className:"num",children:"+ / −"}),e.jsx("th",{children:"Prompt"}),e.jsx("th",{children:"When"})]})}),e.jsx("tbody",{children:l.changes.map(s=>e.jsxs("tr",{children:[e.jsx("td",{children:s.event_uuid?e.jsxs(r,{to:`/session/${l.session_id}#ev-${s.event_uuid}`,className:"title",title:"Jump to this change in the transcript",children:["turn ",s.turn_seq!=null?s.turn_seq+1:"?"]}):e.jsxs("span",{className:"muted",children:["turn ",s.turn_seq!=null?s.turn_seq+1:"?"]})}),e.jsx("td",{children:e.jsx("span",{className:"tag",children:s.tool_name})}),e.jsx("td",{className:"num",children:e.jsx(p,{added:s.lines_added,removed:s.lines_removed})}),e.jsx("td",{className:"muted",title:s.prompt_preview??void 0,children:s.prompt_preview?s.prompt_preview.length>80?s.prompt_preview.slice(0,79)+"…":s.prompt_preview:"—"}),e.jsx("td",{children:t(s.timestamp)})]},s.id))})]})]},l.session_id)}),e.jsx("p",{className:"muted pad",children:"Tracked from Edit/Write tool calls — changes made via shell commands or outside sessions aren’t captured."})]})}export{v as default};
@@ -1 +1 @@
1
- import{a as q,d as x,r as E,w as C,j as e,F as P,E as D,L as K,S as n,o as $,v as k,P as I}from"./index-F_4kZQVd.js";const i=50,M={total:0,files:[]};function A(t,a){return a&&t.startsWith(a.replace(/\/$/,"")+"/")?t.slice(a.replace(/\/$/,"").length+1):t}function R({added:t,removed:a}){return t==null&&a==null?e.jsx("span",{className:"muted",children:"—"}):e.jsxs("span",{className:"sub",children:[t!=null&&e.jsxs("span",{className:"tag",children:["+",t.toLocaleString()]}),a!=null&&e.jsxs("span",{className:"tag",children:["−",a.toLocaleString()]})]})}function G(){const{get:t,set:a,pick:g}=q(["offset"]),f=x("/sources",[]),b=x("/projects",[]),[h,u]=E.useState(t("q")),p=Number(t("offset","0")),o=g(["source","project","q","sort","dir"]);o.set("limit",String(i)),o.set("offset",String(p));const{data:N,loading:j,error:S}=C("/files?"+o.toString()),{total:d,files:m}=N??M;function v(s){s.preventDefault(),a({q:h.trim()})}const l=t("sort","last_ts"),r=t("dir")==="asc"?"asc":"desc";function c(s,F){a({sort:s,dir:l===s?r==="asc"?"desc":"asc":F})}const _=Math.floor(p/i)+1,y=Math.max(1,Math.ceil(d/i)),L=!!(t("q")||t("source")||t("project"));return e.jsxs("div",{children:[e.jsx("h1",{className:"sr-only",children:"Files"}),e.jsxs("div",{className:"filters",children:[e.jsxs("form",{onSubmit:v,className:"search",role:"search",children:[e.jsx("input",{type:"search","aria-label":"Search files by path",placeholder:"Search file paths…",value:h,onChange:s=>u(s.target.value)}),e.jsx("button",{type:"submit",children:"Search"}),t("q")&&e.jsx("button",{type:"button",className:"ghost",onClick:()=>(u(""),a({q:""})),children:"clear"})]}),e.jsxs("select",{"aria-label":"Filter by source",value:t("source"),onChange:s=>a({source:s.target.value}),children:[e.jsx("option",{value:"",children:"all sources"}),f.map(s=>e.jsx("option",{value:s.id,children:s.label},s.id))]}),e.jsx(P,{ariaLabel:"Filter by project",searchPlaceholder:"Find project…",value:t("project"),onChange:s=>a({project:s}),options:[{value:"",label:"all projects"},...b.map(s=>({value:s.id,label:s.path.replace(/^.*\//,"")}))]})]}),e.jsx(D,{error:S}),j?e.jsx(K,{}):m.length===0?e.jsx("div",{className:"muted pad",role:"status",children:L?"No files match the filter.":"No file changes ingested yet — run agent-lens refresh (or ingest) first."}):e.jsxs("table",{className:"sessions",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx(n,{label:"File",sortKey:"path",active:l,dir:r,onSort:c,defaultDir:"asc"}),e.jsx("th",{children:"Project"}),e.jsx(n,{label:"Sessions",sortKey:"sessions",active:l,dir:r,onSort:c,className:"num"}),e.jsx(n,{label:"Changes",sortKey:"changes",active:l,dir:r,onSort:c,className:"num"}),e.jsx("th",{className:"num",children:"+ / −"}),e.jsx(n,{label:"Last touched",sortKey:"last_ts",active:l,dir:r,onSort:c})]})}),e.jsx("tbody",{children:m.map(s=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx($,{to:`/file?path=${encodeURIComponent(s.file_path)}${s.project_id?`&project=${encodeURIComponent(s.project_id)}`:""}`,className:"title",title:s.file_path,children:A(s.file_path,s.project_path)})}),e.jsx("td",{children:s.project_path?e.jsx("span",{className:"tag",title:s.project_path,children:s.project_path.replace(/^.*\//,"")}):e.jsx("span",{className:"muted",children:"—"})}),e.jsx("td",{className:"num",children:s.sessions.toLocaleString()}),e.jsx("td",{className:"num",children:s.changes.toLocaleString()}),e.jsx("td",{className:"num",children:e.jsx(R,{added:s.lines_added,removed:s.lines_removed})}),e.jsx("td",{children:k(s.last_ts)})]},(s.project_id??"")+"\0"+s.file_path))})]}),!j&&d>0&&e.jsx(I,{page:_,pages:y,total:d,unit:"files",onPage:s=>a({offset:String((s-1)*i)})}),e.jsx("p",{className:"muted pad",children:"Tracked from Edit/Write tool calls — changes made via shell commands or outside sessions aren’t captured."})]})}export{R as LinesDelta,G as default,A as relPath};
1
+ import{e as q,h as x,r as E,w as C,j as e,F as P,E as D,m as K,S as n,L as $,v as k,P as I}from"./index-DYY0_SmQ.js";const i=50,M={total:0,files:[]};function A(t,a){return a&&t.startsWith(a.replace(/\/$/,"")+"/")?t.slice(a.replace(/\/$/,"").length+1):t}function R({added:t,removed:a}){return t==null&&a==null?e.jsx("span",{className:"muted",children:"—"}):e.jsxs("span",{className:"sub",children:[t!=null&&e.jsxs("span",{className:"tag",children:["+",t.toLocaleString()]}),a!=null&&e.jsxs("span",{className:"tag",children:["−",a.toLocaleString()]})]})}function G(){const{get:t,set:a,pick:g}=q(["offset"]),f=x("/sources",[]),b=x("/projects",[]),[h,u]=E.useState(t("q")),p=Number(t("offset","0")),o=g(["source","project","q","sort","dir"]);o.set("limit",String(i)),o.set("offset",String(p));const{data:N,loading:j,error:S}=C("/files?"+o.toString()),{total:d,files:m}=N??M;function v(s){s.preventDefault(),a({q:h.trim()})}const l=t("sort","last_ts"),r=t("dir")==="asc"?"asc":"desc";function c(s,F){a({sort:s,dir:l===s?r==="asc"?"desc":"asc":F})}const _=Math.floor(p/i)+1,y=Math.max(1,Math.ceil(d/i)),L=!!(t("q")||t("source")||t("project"));return e.jsxs("div",{children:[e.jsx("h1",{className:"sr-only",children:"Files"}),e.jsxs("div",{className:"filters",children:[e.jsxs("form",{onSubmit:v,className:"search",role:"search",children:[e.jsx("input",{type:"search","aria-label":"Search files by path",placeholder:"Search file paths…",value:h,onChange:s=>u(s.target.value)}),e.jsx("button",{type:"submit",children:"Search"}),t("q")&&e.jsx("button",{type:"button",className:"ghost",onClick:()=>(u(""),a({q:""})),children:"clear"})]}),e.jsxs("select",{"aria-label":"Filter by source",value:t("source"),onChange:s=>a({source:s.target.value}),children:[e.jsx("option",{value:"",children:"all sources"}),f.map(s=>e.jsx("option",{value:s.id,children:s.label},s.id))]}),e.jsx(P,{ariaLabel:"Filter by project",searchPlaceholder:"Find project…",value:t("project"),onChange:s=>a({project:s}),options:[{value:"",label:"all projects"},...b.map(s=>({value:s.id,label:s.path.replace(/^.*\//,"")}))]})]}),e.jsx(D,{error:S}),j?e.jsx(K,{}):m.length===0?e.jsx("div",{className:"muted pad",role:"status",children:L?"No files match the filter.":"No file changes ingested yet — run agent-lens refresh (or ingest) first."}):e.jsxs("table",{className:"sessions",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx(n,{label:"File",sortKey:"path",active:l,dir:r,onSort:c,defaultDir:"asc"}),e.jsx("th",{children:"Project"}),e.jsx(n,{label:"Sessions",sortKey:"sessions",active:l,dir:r,onSort:c,className:"num"}),e.jsx(n,{label:"Changes",sortKey:"changes",active:l,dir:r,onSort:c,className:"num"}),e.jsx("th",{className:"num",children:"+ / −"}),e.jsx(n,{label:"Last touched",sortKey:"last_ts",active:l,dir:r,onSort:c})]})}),e.jsx("tbody",{children:m.map(s=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx($,{to:`/file?path=${encodeURIComponent(s.file_path)}${s.project_id?`&project=${encodeURIComponent(s.project_id)}`:""}`,className:"title",title:s.file_path,children:A(s.file_path,s.project_path)})}),e.jsx("td",{children:s.project_path?e.jsx("span",{className:"tag",title:s.project_path,children:s.project_path.replace(/^.*\//,"")}):e.jsx("span",{className:"muted",children:"—"})}),e.jsx("td",{className:"num",children:s.sessions.toLocaleString()}),e.jsx("td",{className:"num",children:s.changes.toLocaleString()}),e.jsx("td",{className:"num",children:e.jsx(R,{added:s.lines_added,removed:s.lines_removed})}),e.jsx("td",{children:k(s.last_ts)})]},(s.project_id??"")+"\0"+s.file_path))})]}),!j&&d>0&&e.jsx(I,{page:_,pages:y,total:d,unit:"files",onPage:s=>a({offset:String((s-1)*i)})}),e.jsx("p",{className:"muted pad",children:"Tracked from Edit/Write tool calls — changes made via shell commands or outside sessions aren’t captured."})]})}export{R as LinesDelta,G as default,A as relPath};
@@ -0,0 +1 @@
1
+ import{r as m,e as ie,h as P,z as ne,w as ae,j as e,D as p,F as le,G as y,E as re,m as ce,S as $,P as oe,v as de,L as ue}from"./index-DYY0_SmQ.js";import{S as he,a as me}from"./severity-CoO1IKlD.js";function W(t,n){const[l,a]=m.useState(n),[N,d]=m.useState(t);return N!==t&&(d(t),a(n)),[l,a]}const M=50,pe={total:0,findings:[]},je=new Set;function ke(){const{get:t,set:n,clear:l}=ie(),a=P("/sources",[]),N=P("/projects",[]),[d,S]=m.useState(!1),[j,V]=m.useState(0),{sort:r,toggle:_}=ne("severity","desc"),b=t("severity"),v=t("category"),k=t("rule"),w=t("session"),R=t("source"),F=t("project"),T=t("from"),A=t("to"),u=t("status","open"),C=m.useMemo(()=>{const s=new URLSearchParams;for(const[c,h]of Object.entries({severity:b,category:v,rule:k,session:w,source:R,project:F,from:T,to:A,status:u}))h&&s.set(c,h);return s},[b,v,k,w,R,F,T,A,u]),i=P("/security/summary",null,[j]),D=P(p?null:"/security/mutes",[],[j]),K=`${C.toString()}|${r.key}|${r.dir}`,[E,B]=W(K,1),[o,L]=W(`${K}|${E}|${j}`,je),f=new URLSearchParams(C);f.set("sort",r.key),f.set("dir",r.dir),f.set("limit",String(M)),f.set("offset",String((E-1)*M));const{data:H,loading:I,error:Y}=ae("/security/findings?"+f.toString(),{deps:[j]}),[q,G]=W(`${K}|${E}|${j}`,null),J=q??Y,{total:g,findings:O}=H??pe,x=m.useCallback(async s=>{S(!0),G(null);try{await s(),V(c=>c+1)}catch(c){G(String(c))}finally{S(!1)}},[]),X=m.useMemo(()=>new Map(((i==null?void 0:i.by_severity)??[]).map(s=>[s.severity,s.n])),[i]),Q=m.useMemo(()=>((i==null?void 0:i.by_rule)??[]).filter(s=>!v||s.category===v),[i,v]),Z=Math.max(1,Math.ceil(g/M)),ee=[...C.keys()].some(s=>s!=="status")||u!=="open",z=O.map(s=>s.id),se=z.length>0&&z.every(s=>o.has(s)),te=s=>L(c=>{const h=new Set(c);return h.has(s)?h.delete(s):h.add(s),h});return e.jsxs("div",{children:[e.jsxs("div",{className:"detail-head",children:[e.jsx("h1",{children:"Security findings"}),e.jsxs("p",{className:"muted page-intro",children:["Risky operations the agent performed, flagged after the fact by deterministic rules over each tool call. Counts show ",e.jsx("strong",{children:"open"})," findings — mark benign ones safe or mute a noisy rule so a real one stands out. agent-lens is retrospective; it surfaces what ",e.jsx("em",{children:"happened"}),", it doesn't block."]})]}),p&&e.jsxs("div",{className:"demo-note",role:"note",children:["📦 This is a static demo over synthetic sessions. Browse the findings and reference below —"," ",e.jsx("strong",{children:"triage"})," (mark safe, mute rules) and live filtering run in the local app on your own data."]}),e.jsxs("div",{className:"kpi-row sev-kpis",role:"group","aria-label":"Open findings by severity",children:[e.jsxs("button",{type:"button",className:"kpi kpi-btn"+(b?"":" is-active"),onClick:()=>n({severity:""}),children:[e.jsx("div",{className:"kpi-label",children:"Open findings"}),e.jsx("div",{className:"kpi-value",children:(i==null?void 0:i.total)??"—"}),e.jsxs("div",{className:"kpi-sub",children:[(i==null?void 0:i.sessions_flagged)??0," sessions flagged"]})]}),he.map(s=>e.jsxs("button",{type:"button",className:"kpi kpi-btn sev-kpi sev-"+s+(b===s?" is-active":""),onClick:()=>n({severity:b===s?"":s}),"aria-pressed":b===s,children:[e.jsx("div",{className:"kpi-label",children:s}),e.jsx("div",{className:"kpi-value",children:X.get(s)??0})]},s))]}),i&&(i.dismissed>0||i.muted>0)&&e.jsxs("div",{className:"triage-counts muted small",children:[e.jsxs("button",{type:"button",className:"linkish",onClick:()=>n({status:"dismissed",severity:""}),children:[i.dismissed," dismissed"]})," · ",e.jsxs("button",{type:"button",className:"linkish",onClick:()=>n({status:"muted",severity:""}),children:[i.muted," muted by rule"]})]}),e.jsxs("div",{className:"filters",children:[e.jsxs("select",{"aria-label":"Filter by status",value:u,onChange:s=>n({status:s.target.value}),children:[e.jsx("option",{value:"open",children:"open"}),e.jsx("option",{value:"dismissed",children:"dismissed"}),e.jsx("option",{value:"muted",children:"muted"}),e.jsx("option",{value:"all",children:"all"})]}),e.jsxs("select",{"aria-label":"Filter by category",value:v,onChange:s=>{const c=s.target.value,h=!k||Q.some(U=>U.rule_id===k&&(!c||U.category===c));n({category:c,rule:h?k:""})},children:[e.jsx("option",{value:"",children:"all categories"}),((i==null?void 0:i.categories)??[]).map(s=>e.jsx("option",{value:s.key,children:s.title},s.key))]}),e.jsxs("select",{"aria-label":"Filter by rule",value:k,onChange:s=>n({rule:s.target.value}),children:[e.jsx("option",{value:"",children:"all rules"}),Q.map(s=>e.jsxs("option",{value:s.rule_id,children:[s.rule_id," (",s.n,")"]},s.rule_id))]}),e.jsxs("select",{"aria-label":"Filter by source",value:R,onChange:s=>n({source:s.target.value}),children:[e.jsx("option",{value:"",children:"all sources"}),a.map(s=>e.jsx("option",{value:s.id,children:s.label},s.id))]}),e.jsx(le,{ariaLabel:"Filter by project",searchPlaceholder:"Find project…",value:F,onChange:s=>n({project:s}),options:[{value:"",label:"all projects"},...N.map(s=>({value:s.id,label:s.path.replace(/^.*\//,"")}))]}),e.jsxs("label",{className:"ctl",children:["from ",e.jsx("input",{type:"date",value:T,onChange:s=>n({from:s.target.value})})]}),e.jsxs("label",{className:"ctl",children:["to ",e.jsx("input",{type:"date",value:A,onChange:s=>n({to:s.target.value})})]}),w&&e.jsxs("span",{className:"tag filter-chip",children:["session ",w.slice(0,8),"… ",e.jsx("button",{type:"button",className:"linkish",onClick:()=>n({session:""}),children:"✕"})]}),ee&&e.jsx("button",{type:"button",className:"ghost",onClick:l,children:"clear filters"})]}),!p&&(o.size>0||u==="open"&&g>0)&&e.jsxs("div",{className:"triage-bar",role:"group","aria-label":"Triage actions",children:[o.size>0&&u!=="dismissed"&&e.jsxs("button",{type:"button",disabled:d,onClick:()=>x(()=>y("/security/dismiss",{ids:[...o]})),children:["✓ Mark ",o.size," safe"]}),o.size>0&&u==="dismissed"&&e.jsxs("button",{type:"button",disabled:d,onClick:()=>x(()=>y("/security/reopen",{ids:[...o]})),children:["↩ Reopen ",o.size]}),o.size>0&&e.jsx("button",{type:"button",className:"ghost",onClick:()=>L(new Set),children:"clear selection"}),u==="open"&&g>0&&e.jsxs("button",{type:"button",className:"ghost",disabled:d,onClick:()=>{confirm(`Dismiss all ${g} open findings matching the current filter as safe?`)&&x(()=>y("/security/dismiss-matching",{filter:Object.fromEntries(C)}))},title:"Mark every open finding matching the current filter as safe",children:["Dismiss all ",g," matching"]})]}),e.jsx(re,{error:J}),I?e.jsx(ce,{}):O.length===0?e.jsx("div",{className:"muted pad",role:"status",children:i&&i.total===0&&u==="open"?"No open security findings — nothing risky is awaiting review.":"No findings match these filters."}):e.jsxs("table",{className:"sessions findings-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[!p&&e.jsx("th",{className:"check-col",children:e.jsx("input",{type:"checkbox","aria-label":"Select all on this page",checked:se,onChange:s=>L(s.target.checked?new Set(z):new Set)})}),e.jsx($,{label:"Severity",sortKey:"severity",active:r.key,dir:r.dir,onSort:_}),e.jsx("th",{children:"Finding"}),e.jsx($,{label:"Category",sortKey:"category",active:r.key,dir:r.dir,onSort:_}),e.jsx("th",{children:"Evidence"}),e.jsx($,{label:"When",sortKey:"time",active:r.key,dir:r.dir,onSort:_}),e.jsx($,{label:"Session",sortKey:"session",active:r.key,dir:r.dir,onSort:_}),!p&&e.jsx("th",{children:"Actions"})]})}),e.jsx("tbody",{children:O.map(s=>e.jsx(ge,{f:s,selected:o.has(s.id),onToggle:()=>te(s.id),busy:d,onDismiss:()=>x(()=>y("/security/dismiss",{ids:[s.id]})),onReopen:()=>x(()=>y("/security/reopen",{ids:[s.id]})),onMute:()=>x(()=>y("/security/mute",{rule_id:s.rule_id,scope:"global"}))},s.id))})]}),!I&&g>M&&e.jsx(oe,{page:E,pages:Z,total:g,unit:"findings",onPage:B}),!p&&D.length>0&&e.jsx(xe,{mutes:D,busy:d,onUnmute:s=>x(()=>y("/security/unmute",{rule_id:s.rule_id,scope:s.scope,scope_id:s.scope_id}))}),i&&i.categories.length>0&&e.jsx(ye,{summary:i})]})}function ge({f:t,selected:n,onToggle:l,busy:a,onDismiss:N,onReopen:d,onMute:S}){const j=`/session/${t.session_id}${t.event_uuid?`#ev-${t.event_uuid}`:""}`;return e.jsxs("tr",{className:t.dismissed?"is-dismissed":"",children:[!p&&e.jsx("td",{className:"check-col",children:e.jsx("input",{type:"checkbox","aria-label":"Select finding",checked:n,onChange:l})}),e.jsxs("td",{children:[e.jsx(me,{severity:t.severity}),t.dismissed?e.jsx("span",{className:"tag dismissed",title:t.dismiss_note??"",children:"safe"}):null]}),e.jsxs("td",{children:[e.jsx("div",{className:"finding-title",children:t.title??t.rule_id}),e.jsxs("div",{className:"muted small",children:[e.jsx("code",{children:t.rule_id}),t.framework_ref&&e.jsx("span",{className:"tag framework",children:t.framework_ref})]})]}),e.jsx("td",{className:"small",children:t.category}),e.jsxs("td",{className:"finding-evidence-cell",children:[t.tool_name&&e.jsx("span",{className:"tag tool-tag",title:"Tool the finding fired on",children:t.tool_name}),e.jsx("code",{title:t.evidence??"",children:t.evidence})]}),e.jsx("td",{className:"small muted",title:t.started_at??"",children:de(t.started_at??null)}),e.jsxs("td",{className:"small",children:[e.jsx(ue,{to:j,className:"title",children:t.session_title||t.session_id.slice(0,12)}),t.is_sidechain?e.jsx("span",{className:"tag subagent",children:"subagent"}):null,t.project_path&&e.jsx("div",{className:"muted path",children:t.project_path.replace(/^.*\//,"")})]}),!p&&e.jsxs("td",{className:"finding-actions small",children:[t.dismissed?e.jsx("button",{type:"button",className:"linkish",disabled:a,onClick:d,children:"reopen"}):e.jsx("button",{type:"button",className:"linkish",disabled:a,onClick:N,children:"safe"}),e.jsx("button",{type:"button",className:"linkish",disabled:a,onClick:S,title:`Mute rule ${t.rule_id} everywhere`,children:"mute rule"})]})]})}function xe({mutes:t,busy:n,onUnmute:l}){return e.jsxs("details",{className:"card muted-rules",children:[e.jsx("summary",{children:e.jsxs("span",{className:"sec-ref-title",children:["Muted rules (",t.length,")"]})}),e.jsx("ul",{className:"muted-rules-list",children:t.map(a=>e.jsxs("li",{children:[e.jsx("code",{children:a.rule_id}),e.jsxs("span",{className:"tag mute-scope",children:[a.scope,a.scope_id?`: ${a.scope_id}`:""]}),a.note&&e.jsx("span",{className:"muted small mute-note",children:a.note}),e.jsx("button",{type:"button",className:"linkish unmute",disabled:n,onClick:()=>l(a),children:"unmute"})]},`${a.rule_id}:${a.scope}:${a.scope_id}`))})]})}function ye({summary:t}){const n=new Map(t.by_category.map(l=>[l.category,l.n]));return e.jsxs("section",{className:"sec-reference",children:[e.jsx("h2",{children:"Risk categories"}),e.jsx("p",{className:"muted small sec-reference-intro",children:"What each category means and why it matters, anchored to OWASP Top 10 for Agentic Apps and MITRE ATLAS."}),e.jsx("div",{className:"sec-ref-grid",children:t.categories.map(l=>e.jsxs("details",{className:"card sec-ref",children:[e.jsxs("summary",{children:[e.jsx("span",{className:"sec-ref-title",children:l.title}),e.jsxs("a",{className:"tag framework",href:l.framework_url,target:"_blank",rel:"noreferrer",onClick:a=>a.stopPropagation(),children:[l.framework_ref," ↗"]}),e.jsxs("span",{className:"muted small",children:[n.get(l.key)??0," open"]})]}),e.jsxs("dl",{className:"sec-ref-body",children:[e.jsx("dt",{children:"What"}),e.jsx("dd",{children:l.what}),e.jsx("dt",{children:"Why it matters"}),e.jsx("dd",{children:l.why}),e.jsx("dt",{children:"What to do"}),e.jsx("dd",{children:l.remediation})]})]},l.key))})]})}export{ke as default};
@@ -1,12 +1,12 @@
1
- import{p as ds,j as s,q as O,r as m,o as _,h as us,t as ms,i as hs,k as C,v as W,s as ps,w as xs,f as R,m as D,l as fs,x as js,y as gs,E as Ns,L as ws}from"./index-F_4kZQVd.js";import{S as I,a as V}from"./severity-ChuAKM2D.js";import{A as F,C as y,p as k}from"./jsonish-B1rzsNYu.js";import{M as _s,r as ks}from"./index-DumYdTnf.js";function ys({id:e}){const n=ds();return s.jsxs("details",{className:"export-menu col-customizer",ref:n,children:[s.jsx("summary",{className:"export",title:"Export this session as Markdown",children:"⬇ Export Markdown"}),s.jsxs("div",{className:"col-menu",role:"group","aria-label":"Export options",children:[s.jsxs("a",{href:O(e),download:!0,children:["Redacted ",s.jsx("span",{className:"muted small",children:"(secrets masked)"})]}),s.jsxs("a",{href:O(e,"structure"),download:!0,children:["Structure only ",s.jsx("span",{className:"muted small",children:"(scrubbed)"})]}),s.jsxs("a",{className:"export-verbatim",href:O(e,"off"),download:!0,children:["Verbatim ",s.jsx("span",{className:"muted small",children:"(unredacted)"})]})]})]})}function bs({c:e}){var r;const[n,t]=m.useState(!1),a=m.useId(),l=(r=e.signals)==null?void 0:r.loc;return s.jsxs("div",{className:"classification",children:[s.jsx("span",{className:"tag cat cat-"+(e.category??"none"),children:e.category??"unclassified"}),e.complexity_band&&s.jsxs("span",{className:"tag complexity",children:[e.complexity_band," · ",e.complexity_score]}),l&&s.jsxs("span",{className:"muted small",children:["+",l.added,"/−",l.removed," LoC · ",l.files," files"]}),s.jsxs("button",{className:"ghost small","aria-expanded":n,"aria-controls":a,onClick:()=>t(i=>!i),children:["why ",n?"▾":"▸"]}),n&&(e.signals?s.jsx(Ss,{id:a,s:e.signals,category:e.category}):s.jsx("div",{id:a,className:"muted small pad",children:"No signals recorded for this session."}))]})}const vs={loc:"Lines changed",files:"Files touched",turns:"Turns",tokens:"Work tokens",duration:"Duration",subagents:"Subagents"},P=e=>`${Math.max(0,Math.min(1,e))*100}%`;function L({counts:e}){const n=Object.entries(e).sort((t,a)=>a[1]-t[1]);return n.length===0?s.jsx("span",{className:"muted",children:"—"}):s.jsx("span",{className:"sig-chips",children:n.map(([t,a])=>s.jsxs("span",{className:"sig-chip",children:[t," ",s.jsxs("span",{className:"muted",children:["×",a]})]},t))})}function Ss({id:e,s:n,category:t}){const[a,l]=m.useState(!1),r=m.useId(),i=n.complexity_weights??{},o=n.complexity_subscores??{},c=Object.keys(i).map(d=>({key:d,weight:i[d],subscore:o[d]??0,pts:i[d]*(o[d]??0)*100})).sort((d,g)=>g.pts-d.pts),u=Math.max(...c.map(d=>d.pts),1e-4),p=Object.entries(n.category_scores??{}).map(([d,g])=>({k:d,v:g})).sort((d,g)=>g.v-d.v),f=Math.max(...p.map(d=>d.v),1e-4),x=p.filter(d=>d.v>.02||d.k===t),j=n.skills&&Object.keys(n.skills).length>0;return s.jsxs("div",{id:e,className:"signals-panel",children:[c.length>0&&s.jsxs("section",{className:"sig-section",children:[s.jsxs("h4",{className:"sig-h",children:["Complexity breakdown ",s.jsx("span",{className:"muted",children:"— what built the score"})]}),s.jsx("ul",{className:"sig-bars",children:c.map(d=>s.jsxs("li",{className:"sig-bar-row",children:[s.jsx("span",{className:"sig-bar-label",children:vs[d.key]??d.key}),s.jsx("span",{className:"sig-bar","aria-hidden":"true",children:s.jsx("span",{className:"sig-bar-fill",style:{width:P(d.pts/u)}})}),s.jsxs("span",{className:"sig-bar-val",children:[d.pts.toFixed(1)," pts"]}),s.jsxs("span",{className:"sig-bar-sub muted",children:[Math.round(d.subscore*100),"% intensity · weight ",Math.round(d.weight*100),"%"]})]},d.key))})]}),x.length>0&&s.jsxs("section",{className:"sig-section",children:[s.jsxs("h4",{className:"sig-h",children:["Category scores ",s.jsxs("span",{className:"muted",children:["— why “",t,"” won"]})]}),s.jsx("ul",{className:"sig-bars",children:x.map(d=>s.jsxs("li",{className:"sig-bar-row"+(d.k===t?" is-win":""),children:[s.jsx("span",{className:"sig-bar-label",children:d.k}),s.jsx("span",{className:"sig-bar","aria-hidden":"true",children:s.jsx("span",{className:"sig-bar-fill",style:{width:P(d.v/f)}})}),s.jsx("span",{className:"sig-bar-val",children:d.v.toFixed(2)})]},d.k))})]}),s.jsxs("section",{className:"sig-section",children:[s.jsx("h4",{className:"sig-h",children:"Evidence"}),s.jsxs("dl",{className:"sig-grid",children:[n.tool_counts&&s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:"Tools"}),s.jsx("dd",{children:s.jsx(L,{counts:n.tool_counts})})]}),j&&s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:"Skills"}),s.jsx("dd",{children:s.jsx(L,{counts:n.skills})})]}),n.subagent_role&&s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:"Subagent role"}),s.jsx("dd",{children:n.subagent_role})]}),n.files&&n.files.length>0&&s.jsxs(s.Fragment,{children:[s.jsxs("dt",{children:["Files (",n.files.length,")"]}),s.jsx("dd",{className:"sig-files",children:n.files.join(", ")})]})]})]}),s.jsx("button",{className:"ghost small","aria-expanded":a,"aria-controls":r,onClick:()=>l(d=>!d),children:a?"Hide raw JSON ▴":"View raw JSON ▾"}),a&&s.jsx("pre",{id:r,className:"code signals",children:JSON.stringify(n,null,2)})]})}function Cs({f:e}){var i;const[n,t]=m.useState(!1),a=m.useId(),l=((i=e.signals)==null?void 0:i.modifiers)??{},r=Object.keys(l).filter(o=>l[o]!==!1&&l[o]!=null&&l[o]!=="");return s.jsxs("div",{className:"finding sev-border-"+e.severity,children:[s.jsxs("button",{className:"finding-head","aria-expanded":n,"aria-controls":a,onClick:()=>t(o=>!o),children:[s.jsx(V,{severity:e.severity}),s.jsx("span",{className:"finding-title",children:e.title??e.rule_id}),e.framework_ref&&s.jsx("span",{className:"tag framework",children:e.framework_ref}),s.jsx("span",{className:"chev",children:n?"▾":"▸"})]}),n&&s.jsxs("div",{className:"finding-body",id:a,children:[e.evidence&&s.jsx("div",{className:"code-block",children:s.jsx("pre",{className:"code finding-evidence",children:e.evidence})}),s.jsxs("dl",{className:"sig-grid",children:[s.jsx("dt",{children:"Rule"}),s.jsx("dd",{children:s.jsx("code",{children:e.rule_id})}),s.jsx("dt",{children:"Category"}),s.jsx("dd",{children:e.category}),r.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:"Context"}),s.jsx("dd",{children:r.map(o=>s.jsxs("span",{className:"sig-chip",children:[o,l[o]!==!0?s.jsxs("span",{className:"muted",children:[" ",String(l[o])]}):null]},o))})]})]}),s.jsxs(_,{className:"subagent-link small",to:`/security?rule=${encodeURIComponent(e.rule_id)}`,children:["see all “",e.rule_id,"” findings →"]})]})]})}function Is({findings:e}){if(!e.length)return null;const n=[...e].sort((t,a)=>I.indexOf(t.severity)-I.indexOf(a.severity));return s.jsx("div",{className:"tool-findings",children:n.map(t=>s.jsx(Cs,{f:t},t.id))})}function Ts({findings:e,sessionId:n}){const t=new Map;for(const l of e)t.set(l.severity,(t.get(l.severity)??0)+1);const a=I.find(l=>t.has(l))??"info";return s.jsxs("div",{className:"security-banner sev-border-"+a,role:"status",children:[s.jsx("span",{className:"security-banner-icon","aria-hidden":"true",children:"🛡"}),s.jsxs("span",{className:"security-banner-text",children:[e.length," security ",e.length===1?"finding":"findings"," in this session"]}),s.jsx("span",{className:"security-banner-sevs",children:I.filter(l=>t.has(l)).map(l=>s.jsx(V,{severity:l,count:t.get(l)},l))}),s.jsx(_,{className:"subagent-link small",to:`/security?session=${encodeURIComponent(n)}`,children:"view on Security page →"})]})}function Os(e){const n={dirs:new Map,files:[]};for(const a of e){const l=a.display.startsWith("/"),r=(l?a.display.slice(1):a.display).split("/");l&&r.length>0&&(r[0]="/"+r[0]);let i=n;for(const o of r.slice(0,-1))i=i.dirs.get(o)??i.dirs.set(o,{dirs:new Map,files:[]}).get(o);i.files.push({name:r[r.length-1],path:a.path,list:a.list})}const t=a=>{for(const[l,r]of[...a.dirs.entries()])if(t(r),r.files.length===0&&r.dirs.size===1){const[i,o]=[...r.dirs.entries()][0];a.dirs.delete(l),a.dirs.set(l+"/"+i,o)}};return t(n),n}function Q({node:e,depth:n}){const t={paddingLeft:`${.4+n*1.1}rem`};return s.jsxs(s.Fragment,{children:[[...e.dirs.entries()].sort(([a],[l])=>a.localeCompare(l)).map(([a,l])=>s.jsxs(m.Fragment,{children:[s.jsx("tr",{children:s.jsx("td",{colSpan:3,style:t,children:s.jsxs("span",{className:"muted",children:["📁 ",a,"/"]})})}),s.jsx(Q,{node:l,depth:n+1})]},a)),[...e.files].sort((a,l)=>a.name.localeCompare(l.name)).map(a=>{const l=a.list.find(o=>o.event_uuid),r=a.list.reduce((o,c)=>o+(c.lines_added??0),0),i=a.list.reduce((o,c)=>o+(c.lines_removed??0),0);return s.jsxs("tr",{children:[s.jsx("td",{style:t,children:l!=null&&l.event_uuid?s.jsx("a",{href:`#ev-${l.event_uuid}`,className:"title",title:a.path+" — jump to the first change",children:a.name}):s.jsx("span",{title:a.path,children:a.name})}),s.jsxs("td",{className:"num",children:[a.list.length,"× ",s.jsxs("span",{className:"muted",children:["(+",r," −",i,")"]})]}),s.jsx("td",{children:s.jsx(_,{className:"subagent-link small",to:`/file?path=${encodeURIComponent(a.path)}`,children:"history →"})})]},a.path)})]})}function Fs({changes:e,projectPath:n}){const t=new Map;for(const r of e)(t.get(r.file_path)??t.set(r.file_path,[]).get(r.file_path)).push(r);const a=r=>n&&r.startsWith(n.replace(/\/$/,"")+"/")?r.slice(n.replace(/\/$/,"").length+1):r,l=Os([...t.entries()].map(([r,i])=>({display:a(r),path:r,list:i})));return s.jsxs("details",{className:"wf-run files-changed",children:[s.jsxs("summary",{children:["📄 ",t.size," ",t.size===1?"file":"files"," changed · ",e.length," ",e.length===1?"edit":"edits"]}),s.jsx("table",{className:"sessions",children:s.jsx("tbody",{children:s.jsx(Q,{node:l,depth:0})})})]})}function Es({d:e}){const n=e.session;return s.jsxs("div",{className:"detail-head",children:[s.jsx(_,{to:"/",className:"back",children:"← all sessions"}),s.jsx("h1",{children:n.title||n.id.slice(0,12)}),s.jsxs("div",{className:"detail-meta",children:[s.jsx("span",{children:s.jsx("b",{children:n.source_id})}),s.jsx("span",{className:"path",children:n.project_path}),n.is_sidechain?s.jsx("span",{className:"tag subagent",children:"subagent"}):null,e.parent&&s.jsxs("span",{className:"spawned-by",children:["↖ spawned by"," ",s.jsx(_,{to:`/session/${e.parent.id}`,children:e.parent.title||e.parent.id.slice(0,12)}),e.parent.turn_seq!=null?` · turn ${e.parent.turn_seq+1}`:""]}),s.jsxs("span",{children:[e.turns.length," turns"]}),s.jsxs("span",{children:[n.event_count," events"]}),s.jsxs("span",{title:ms(n.token_split),children:[us(n.tokens)," tok"]}),s.jsx("span",{title:"Estimated at API list prices (cache-aware)",children:hs(n.cost)}),n.tool_call_count>0&&s.jsxs("span",{className:n.tool_failure_count>0?"tool-err-stat":"muted",title:"Tool calls that returned is_error, of "+n.tool_call_count+". Failures = the agent's tool errored; declined/blocked = you rejected it or a guardrail blocked it (heuristic split from the result text — not an API-reported distinction).",children:[n.tool_failure_count," failed",n.tool_rejection_count>0?` · ${n.tool_rejection_count} declined/blocked`:"",` of ${n.tool_call_count} tool calls`]}),s.jsx("span",{children:C(n.duration_ms)}),s.jsx("span",{className:"muted",children:W(n.started_at)}),s.jsx(ys,{id:n.id})]}),e.classification&&s.jsx(bs,{c:e.classification}),e.findings&&e.findings.length>0&&s.jsx(Ts,{findings:e.findings,sessionId:n.id}),e.file_changes&&e.file_changes.length>0&&s.jsx(Fs,{changes:e.file_changes,projectPath:n.project_path??null})]})}function Ms({turnCount:e,anyOpen:n,onToggleAll:t,hideTools:a,onToggleHideTools:l,format:r,onChooseFormat:i}){return s.jsxs("div",{className:"transcript-tools",children:[e>1&&s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"muted small",children:[e," turns"]}),s.jsx("button",{className:"ghost small",onClick:t,children:n?"Collapse all":"Expand all"})]}),s.jsxs("button",{className:"ghost small"+(a?" is-active":""),"aria-pressed":a,onClick:l,title:"Hide Bash/Edit/Skill and other tool calls — show only assistant answers, plans and questions",children:[a?"☑ ":"☐ ","Hide tool messages"]}),s.jsxs("div",{className:"format-toggle",role:"group","aria-label":"Message format",children:[s.jsx("button",{className:"ghost small"+(r==="markdown"?" is-active":""),"aria-pressed":r==="markdown",onClick:()=>i("markdown"),children:"Markdown"}),s.jsx("button",{className:"ghost small"+(r==="raw"?" is-active":""),"aria-pressed":r==="raw",onClick:()=>i("raw"),children:"Raw"})]})]})}function $s({d:e}){const n=e.workflow_runs??[],t=e.children.filter(l=>!l.workflow_run_id),a=n.length>0;return s.jsxs("div",{className:"subagents",children:[s.jsxs("h2",{children:["Spawned subagents (",e.children.length,")"]}),n.map(l=>{const r=e.children.filter(i=>i.workflow_run_id===l.run_id);return s.jsxs("details",{className:"wf-run",children:[s.jsxs("summary",{children:[s.jsxs(_,{className:"wf-run-name",to:`/workflow/${l.run_id}`,onClick:i=>i.stopPropagation(),children:["🔀 ",l.name||"workflow"," →"]}),l.status&&s.jsx("span",{className:"tag task-status task-status-"+l.status.toLowerCase(),children:l.status}),s.jsxs("span",{className:"muted small",children:[r.length," agent",r.length===1?"":"s",l.turn_seq!=null?` · turn ${l.turn_seq+1}`:""," · ",s.jsx("code",{children:l.run_id})]})]}),s.jsx("ul",{children:r.map(i=>s.jsx(F,{a:i},i.id))})]},l.run_id)}),t.length>0&&(a?s.jsxs("details",{className:"wf-run",open:!0,children:[s.jsxs("summary",{children:[s.jsx("span",{className:"wf-run-name",children:"Task / Agent"}),s.jsxs("span",{className:"muted small",children:[t.length," subagent",t.length===1?"":"s"]})]}),s.jsx("ul",{children:t.map(l=>s.jsx(F,{a:l},l.id))})]}):s.jsx("ul",{children:t.map(l=>s.jsx(F,{a:l},l.id))}))]})}function H(e,n){const t=e===""?[]:e.split(`
1
+ import{p as os,j as s,q as O,r as m,L as _,f as cs,t as ds,b as us,c as C,v as W,s as ms,w as hs,i as R,n as D,l as ps,x as xs,y as fs,E as js,m as gs}from"./index-DYY0_SmQ.js";import{S as I,a as V}from"./severity-CoO1IKlD.js";import{A as E,C as y,p as k}from"./jsonish-Dd3X-MG6.js";import{M as Ns,r as ws}from"./index-Bgxu3c84.js";function _s({id:e}){const n=os();return s.jsxs("details",{className:"export-menu col-customizer",ref:n,children:[s.jsx("summary",{className:"export",title:"Export this session as Markdown",children:"⬇ Export Markdown"}),s.jsxs("div",{className:"col-menu",role:"group","aria-label":"Export options",children:[s.jsxs("a",{href:O(e),download:!0,children:["Redacted ",s.jsx("span",{className:"muted small",children:"(secrets masked)"})]}),s.jsxs("a",{href:O(e,"structure"),download:!0,children:["Structure only ",s.jsx("span",{className:"muted small",children:"(scrubbed)"})]}),s.jsxs("a",{className:"export-verbatim",href:O(e,"off"),download:!0,children:["Verbatim ",s.jsx("span",{className:"muted small",children:"(unredacted)"})]})]})]})}function ks({c:e}){var r;const[n,t]=m.useState(!1),a=m.useId(),l=(r=e.signals)==null?void 0:r.loc;return s.jsxs("div",{className:"classification",children:[s.jsx("span",{className:"tag cat cat-"+(e.category??"none"),children:e.category??"unclassified"}),e.complexity_band&&s.jsxs("span",{className:"tag complexity",children:[e.complexity_band," · ",e.complexity_score]}),l&&s.jsxs("span",{className:"muted small",children:["+",l.added,"/−",l.removed," LoC · ",l.files," files"]}),s.jsxs("button",{className:"ghost small","aria-expanded":n,"aria-controls":a,onClick:()=>t(i=>!i),children:["why ",n?"▾":"▸"]}),n&&(e.signals?s.jsx(bs,{id:a,s:e.signals,category:e.category}):s.jsx("div",{id:a,className:"muted small pad",children:"No signals recorded for this session."}))]})}const ys={loc:"Lines changed",files:"Files touched",turns:"Turns",tokens:"Work tokens",duration:"Duration",subagents:"Subagents"},P=e=>`${Math.max(0,Math.min(1,e))*100}%`;function L({counts:e}){const n=Object.entries(e).sort((t,a)=>a[1]-t[1]);return n.length===0?s.jsx("span",{className:"muted",children:"—"}):s.jsx("span",{className:"sig-chips",children:n.map(([t,a])=>s.jsxs("span",{className:"sig-chip",children:[t," ",s.jsxs("span",{className:"muted",children:["×",a]})]},t))})}function bs({id:e,s:n,category:t}){const[a,l]=m.useState(!1),r=m.useId(),i=n.complexity_weights??{},o=n.complexity_subscores??{},c=Object.keys(i).map(d=>({key:d,weight:i[d],subscore:o[d]??0,pts:i[d]*(o[d]??0)*100})).sort((d,N)=>N.pts-d.pts),u=Math.max(...c.map(d=>d.pts),1e-4),p=Object.entries(n.category_scores??{}).map(([d,N])=>({k:d,v:N})).sort((d,N)=>N.v-d.v),j=Math.max(...p.map(d=>d.v),1e-4),x=p.filter(d=>d.v>.02||d.k===t),f=n.skills&&Object.keys(n.skills).length>0;return s.jsxs("div",{id:e,className:"signals-panel",children:[c.length>0&&s.jsxs("section",{className:"sig-section",children:[s.jsxs("h4",{className:"sig-h",children:["Complexity breakdown ",s.jsx("span",{className:"muted",children:"— what built the score"})]}),s.jsx("ul",{className:"sig-bars",children:c.map(d=>s.jsxs("li",{className:"sig-bar-row",children:[s.jsx("span",{className:"sig-bar-label",children:ys[d.key]??d.key}),s.jsx("span",{className:"sig-bar","aria-hidden":"true",children:s.jsx("span",{className:"sig-bar-fill",style:{width:P(d.pts/u)}})}),s.jsxs("span",{className:"sig-bar-val",children:[d.pts.toFixed(1)," pts"]}),s.jsxs("span",{className:"sig-bar-sub muted",children:[Math.round(d.subscore*100),"% intensity · weight ",Math.round(d.weight*100),"%"]})]},d.key))})]}),x.length>0&&s.jsxs("section",{className:"sig-section",children:[s.jsxs("h4",{className:"sig-h",children:["Category scores ",s.jsxs("span",{className:"muted",children:["— why “",t,"” won"]})]}),s.jsx("ul",{className:"sig-bars",children:x.map(d=>s.jsxs("li",{className:"sig-bar-row"+(d.k===t?" is-win":""),children:[s.jsx("span",{className:"sig-bar-label",children:d.k}),s.jsx("span",{className:"sig-bar","aria-hidden":"true",children:s.jsx("span",{className:"sig-bar-fill",style:{width:P(d.v/j)}})}),s.jsx("span",{className:"sig-bar-val",children:d.v.toFixed(2)})]},d.k))})]}),s.jsxs("section",{className:"sig-section",children:[s.jsx("h4",{className:"sig-h",children:"Evidence"}),s.jsxs("dl",{className:"sig-grid",children:[n.tool_counts&&s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:"Tools"}),s.jsx("dd",{children:s.jsx(L,{counts:n.tool_counts})})]}),f&&s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:"Skills"}),s.jsx("dd",{children:s.jsx(L,{counts:n.skills})})]}),n.subagent_role&&s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:"Subagent role"}),s.jsx("dd",{children:n.subagent_role})]}),n.files&&n.files.length>0&&s.jsxs(s.Fragment,{children:[s.jsxs("dt",{children:["Files (",n.files.length,")"]}),s.jsx("dd",{className:"sig-files",children:n.files.join(", ")})]})]})]}),s.jsx("button",{className:"ghost small","aria-expanded":a,"aria-controls":r,onClick:()=>l(d=>!d),children:a?"Hide raw JSON ▴":"View raw JSON ▾"}),a&&s.jsx("pre",{id:r,className:"code signals",children:JSON.stringify(n,null,2)})]})}function vs({f:e}){var i;const[n,t]=m.useState(!1),a=m.useId(),l=((i=e.signals)==null?void 0:i.modifiers)??{},r=Object.keys(l).filter(o=>l[o]!==!1&&l[o]!=null&&l[o]!=="");return s.jsxs("div",{className:"finding sev-border-"+e.severity,children:[s.jsxs("button",{className:"finding-head","aria-expanded":n,"aria-controls":a,onClick:()=>t(o=>!o),children:[s.jsx(V,{severity:e.severity}),s.jsx("span",{className:"finding-title",children:e.title??e.rule_id}),e.framework_ref&&s.jsx("span",{className:"tag framework",children:e.framework_ref}),s.jsx("span",{className:"chev",children:n?"▾":"▸"})]}),n&&s.jsxs("div",{className:"finding-body",id:a,children:[e.evidence&&s.jsx("div",{className:"code-block",children:s.jsx("pre",{className:"code finding-evidence",children:e.evidence})}),s.jsxs("dl",{className:"sig-grid",children:[s.jsx("dt",{children:"Rule"}),s.jsx("dd",{children:s.jsx("code",{children:e.rule_id})}),s.jsx("dt",{children:"Category"}),s.jsx("dd",{children:e.category}),r.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:"Context"}),s.jsx("dd",{children:r.map(o=>s.jsxs("span",{className:"sig-chip",children:[o,l[o]!==!0?s.jsxs("span",{className:"muted",children:[" ",String(l[o])]}):null]},o))})]})]}),s.jsxs(_,{className:"subagent-link small",to:`/security?rule=${encodeURIComponent(e.rule_id)}`,children:["see all “",e.rule_id,"” findings →"]})]})]})}function Ss({findings:e}){if(!e.length)return null;const n=[...e].sort((t,a)=>I.indexOf(t.severity)-I.indexOf(a.severity));return s.jsx("div",{className:"tool-findings",children:n.map(t=>s.jsx(vs,{f:t},t.id))})}function Cs({findings:e,sessionId:n}){const t=new Map;for(const l of e)t.set(l.severity,(t.get(l.severity)??0)+1);const a=I.find(l=>t.has(l))??"info";return s.jsxs("div",{className:"security-banner sev-border-"+a,role:"status",children:[s.jsx("span",{className:"security-banner-icon","aria-hidden":"true",children:"🛡"}),s.jsxs("span",{className:"security-banner-text",children:[e.length," security ",e.length===1?"finding":"findings"," in this session"]}),s.jsx("span",{className:"security-banner-sevs",children:I.filter(l=>t.has(l)).map(l=>s.jsx(V,{severity:l,count:t.get(l)},l))}),s.jsx(_,{className:"subagent-link small",to:`/security?session=${encodeURIComponent(n)}`,children:"view on Security page →"})]})}function Is(e){const n={dirs:new Map,files:[]};for(const a of e){const l=a.display.startsWith("/"),r=(l?a.display.slice(1):a.display).split("/");l&&r.length>0&&(r[0]="/"+r[0]);let i=n;for(const o of r.slice(0,-1))i=i.dirs.get(o)??i.dirs.set(o,{dirs:new Map,files:[]}).get(o);i.files.push({name:r[r.length-1],path:a.path,list:a.list})}const t=a=>{for(const[l,r]of[...a.dirs.entries()])if(t(r),r.files.length===0&&r.dirs.size===1){const[i,o]=[...r.dirs.entries()][0];a.dirs.delete(l),a.dirs.set(l+"/"+i,o)}};return t(n),n}function Q({node:e,depth:n}){const t={paddingLeft:`${.4+n*1.1}rem`};return s.jsxs(s.Fragment,{children:[[...e.dirs.entries()].sort(([a],[l])=>a.localeCompare(l)).map(([a,l])=>s.jsxs(m.Fragment,{children:[s.jsx("tr",{children:s.jsx("td",{colSpan:3,style:t,children:s.jsxs("span",{className:"muted",children:["📁 ",a,"/"]})})}),s.jsx(Q,{node:l,depth:n+1})]},a)),[...e.files].sort((a,l)=>a.name.localeCompare(l.name)).map(a=>{const l=a.list.find(o=>o.event_uuid),r=a.list.reduce((o,c)=>o+(c.lines_added??0),0),i=a.list.reduce((o,c)=>o+(c.lines_removed??0),0);return s.jsxs("tr",{children:[s.jsx("td",{style:t,children:l!=null&&l.event_uuid?s.jsx("a",{href:`#ev-${l.event_uuid}`,className:"title",title:a.path+" — jump to the first change",children:a.name}):s.jsx("span",{title:a.path,children:a.name})}),s.jsxs("td",{className:"num",children:[a.list.length,"× ",s.jsxs("span",{className:"muted",children:["(+",r," −",i,")"]})]}),s.jsx("td",{children:s.jsx(_,{className:"subagent-link small",to:`/file?path=${encodeURIComponent(a.path)}`,children:"history →"})})]},a.path)})]})}function Ts({changes:e,projectPath:n}){const t=new Map;for(const r of e)(t.get(r.file_path)??t.set(r.file_path,[]).get(r.file_path)).push(r);const a=r=>n&&r.startsWith(n.replace(/\/$/,"")+"/")?r.slice(n.replace(/\/$/,"").length+1):r,l=Is([...t.entries()].map(([r,i])=>({display:a(r),path:r,list:i})));return s.jsxs("details",{className:"wf-run files-changed",children:[s.jsxs("summary",{children:["📄 ",t.size," ",t.size===1?"file":"files"," changed · ",e.length," ",e.length===1?"edit":"edits"]}),s.jsx("table",{className:"sessions",children:s.jsx("tbody",{children:s.jsx(Q,{node:l,depth:0})})})]})}function Os({d:e}){const n=e.session;return s.jsxs("div",{className:"detail-head",children:[s.jsx(_,{to:"/",className:"back",children:"← all sessions"}),s.jsx("h1",{children:n.title||n.id.slice(0,12)}),s.jsxs("div",{className:"detail-meta",children:[s.jsx("span",{children:s.jsx("b",{children:n.source_id})}),s.jsx("span",{className:"path",children:n.project_path}),n.is_sidechain?s.jsx("span",{className:"tag subagent",children:"subagent"}):null,e.parent&&s.jsxs("span",{className:"spawned-by",children:["↖ spawned by"," ",s.jsx(_,{to:`/session/${e.parent.id}`,children:e.parent.title||e.parent.id.slice(0,12)}),e.parent.turn_seq!=null?` · turn ${e.parent.turn_seq+1}`:""]}),s.jsxs("span",{children:[e.turns.length," turns"]}),s.jsxs("span",{children:[n.event_count," events"]}),s.jsxs("span",{title:ds(n.token_split),children:[cs(n.tokens)," tok"]}),s.jsx("span",{title:"Estimated at API list prices (cache-aware)",children:us(n.cost)}),n.tool_call_count>0&&s.jsxs("span",{className:n.tool_failure_count>0?"tool-err-stat":"muted",title:"Tool calls that returned is_error, of "+n.tool_call_count+". Failures = the agent's tool errored; declined/blocked = you rejected it or a guardrail blocked it (heuristic split from the result text — not an API-reported distinction).",children:[n.tool_failure_count," failed",n.tool_rejection_count>0?` · ${n.tool_rejection_count} declined/blocked`:"",` of ${n.tool_call_count} tool calls`]}),s.jsx("span",{children:C(n.duration_ms)}),s.jsx("span",{className:"muted",children:W(n.started_at)}),s.jsx(_s,{id:n.id})]}),e.classification&&s.jsx(ks,{c:e.classification}),e.findings&&e.findings.length>0&&s.jsx(Cs,{findings:e.findings,sessionId:n.id}),e.file_changes&&e.file_changes.length>0&&s.jsx(Ts,{changes:e.file_changes,projectPath:n.project_path??null})]})}function Es({turnCount:e,anyOpen:n,onToggleAll:t,hideTools:a,onToggleHideTools:l,format:r,onChooseFormat:i}){return s.jsxs("div",{className:"transcript-tools",children:[e>1&&s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"muted small",children:[e," turns"]}),s.jsx("button",{className:"ghost small",onClick:t,children:n?"Collapse all":"Expand all"})]}),s.jsxs("button",{className:"ghost small"+(a?" is-active":""),"aria-pressed":a,onClick:l,title:"Hide Bash/Edit/Skill and other tool calls — show only assistant answers, plans and questions",children:[a?"☑ ":"☐ ","Hide tool messages"]}),s.jsxs("div",{className:"format-toggle",role:"group","aria-label":"Message format",children:[s.jsx("button",{className:"ghost small"+(r==="markdown"?" is-active":""),"aria-pressed":r==="markdown",onClick:()=>i("markdown"),children:"Markdown"}),s.jsx("button",{className:"ghost small"+(r==="raw"?" is-active":""),"aria-pressed":r==="raw",onClick:()=>i("raw"),children:"Raw"})]})]})}function Fs({d:e}){const n=e.workflow_runs??[],t=e.children.filter(l=>!l.workflow_run_id),a=n.length>0;return s.jsxs("div",{className:"subagents",children:[s.jsxs("h2",{children:["Spawned subagents (",e.children.length,")"]}),n.map(l=>{const r=e.children.filter(i=>i.workflow_run_id===l.run_id);return s.jsxs("details",{className:"wf-run",children:[s.jsxs("summary",{children:[s.jsxs(_,{className:"wf-run-name",to:`/workflow/${l.run_id}`,onClick:i=>i.stopPropagation(),children:["🔀 ",l.name||"workflow"," →"]}),l.status&&s.jsx("span",{className:"tag task-status task-status-"+l.status.toLowerCase(),children:l.status}),s.jsxs("span",{className:"muted small",children:[r.length," agent",r.length===1?"":"s",l.turn_seq!=null?` · turn ${l.turn_seq+1}`:""," · ",s.jsx("code",{children:l.run_id})]})]}),s.jsx("ul",{children:r.map(i=>s.jsx(E,{a:i},i.id))})]},l.run_id)}),t.length>0&&(a?s.jsxs("details",{className:"wf-run",open:!0,children:[s.jsxs("summary",{children:[s.jsx("span",{className:"wf-run-name",children:"Task / Agent"}),s.jsxs("span",{className:"muted small",children:[t.length," subagent",t.length===1?"":"s"]})]}),s.jsx("ul",{children:t.map(l=>s.jsx(E,{a:l},l.id))})]}):s.jsx("ul",{children:t.map(l=>s.jsx(E,{a:l},l.id))}))]})}function H(e,n){const t=e===""?[]:e.split(`
2
2
  `),a=n===""?[]:n.split(`
3
- `),l=t.length,r=a.length;if(l*r>25e4)return[...t.map(p=>({type:"del",text:p})),...a.map(p=>({type:"add",text:p}))];const i=Array.from({length:l+1},()=>new Array(r+1).fill(0));for(let p=l-1;p>=0;p--)for(let f=r-1;f>=0;f--)i[p][f]=t[p]===a[f]?i[p+1][f+1]+1:Math.max(i[p+1][f],i[p][f+1]);const o=[];let c=0,u=0;for(;c<l&&u<r;)t[c]===a[u]?(o.push({type:"ctx",text:t[c]}),c++,u++):i[c+1][u]>=i[c][u+1]?(o.push({type:"del",text:t[c]}),c++):(o.push({type:"add",text:a[u]}),u++);for(;c<l;)o.push({type:"del",text:t[c++]});for(;u<r;)o.push({type:"add",text:a[u++]});return o}function K(e){if(!e)return null;try{const n=JSON.parse(e).plan;return typeof n=="string"&&n.trim()?n:null}catch{return null}}function As(e){if(!e)return[];try{const n=JSON.parse(e).questions;return Array.isArray(n)?n:[]}catch{return[]}}function qs(e){if(!e)return{answers:{},annotations:{}};try{const n=JSON.parse(e);if(n&&typeof n=="object"&&n.answers)return{answers:n.answers,annotations:n.annotations??{}}}catch{}return{answers:{},annotations:{}}}function Bs(e){if(!e)return null;try{const n=JSON.parse(e);if(!n||typeof n!="object")return null;const t=typeof n.command=="string"?n.command:"";return t.trim()?{command:t,description:typeof n.description=="string"?n.description:void 0,timeout:typeof n.timeout=="number"?n.timeout:void 0,run_in_background:n.run_in_background===!0,restart:n.restart===!0}:null}catch{return null}}function Rs(e,n){if(!n)return null;try{const t=JSON.parse(n);if(!t||typeof t!="object"||typeof t.file_path!="string")return null;let a;if(e==="Write"){if(typeof t.content!="string")return null;a=[t.content===""?[]:t.content.split(`
4
- `).map(i=>({type:"add",text:i}))]}else if(e==="MultiEdit"){if(!Array.isArray(t.edits)||(a=t.edits.filter(i=>{const o=i;return!!o&&typeof o.old_string=="string"&&typeof o.new_string=="string"}).map(i=>H(i.old_string,i.new_string)),a.length===0))return null}else{if(typeof t.old_string!="string"||typeof t.new_string!="string")return null;a=[H(t.old_string,t.new_string)]}let l=0,r=0;for(const i of a)for(const o of i)o.type==="add"?l++:o.type==="del"&&r++;return{file_path:t.file_path,kind:e,hunks:a,adds:l,dels:r}}catch{return null}}function Ps(e){const n=e.lastIndexOf("/");return n>=0?{dir:e.slice(0,n+1),base:e.slice(n+1)}:{dir:"",base:e}}function z(e){var a,l,r,i,o;const n=(l=(a=e.match(/<command-name>([^<]*)<\/command-name>/))==null?void 0:a[1])==null?void 0:l.trim();if(n){const c=((i=(r=e.match(/<command-args>([^<]*)<\/command-args>/))==null?void 0:r[1])==null?void 0:i.trim())??"";return{kind:"invocation",name:n.startsWith("/")?n:`/${n}`,args:c}}const t=(o=e.match(/<(?:local-command-stdout|command-output|local-command-stderr)>([\s\S]*?)<\/(?:local-command-stdout|command-output|local-command-stderr)>/))==null?void 0:o[1];return t!=null?{kind:"output",stdout:t.trim()}:/<local-command-caveat>/.test(e)?{kind:"caveat"}:null}function Y(e){if(!/<task-notification>/.test(e))return null;const n=t=>{var a,l;return((l=(a=e.match(new RegExp(`<${t}>([\\s\\S]*?)</${t}>`)))==null?void 0:a[1])==null?void 0:l.trim())??null};return{taskId:n("task-id"),toolUseId:n("tool-use-id"),status:n("status"),summary:n("summary")}}function Ls(e){const n=z(e);if((n==null?void 0:n.kind)==="invocation")return`⌘ ${n.name}${n.args?" "+n.args:""}`;if((n==null?void 0:n.kind)==="output")return"⌘ command output";if((n==null?void 0:n.kind)==="caveat")return"⌘ local command";const t=Y(e);return t?`🔔 task ${t.status??"notification"}`:e}const G=m.createContext("markdown"),X=m.createContext(new Map),Z=m.createContext(!1),ss=m.createContext(null);function Hs({cmd:e}){return e.kind==="invocation"?s.jsxs("div",{className:"cmd",children:[s.jsxs("span",{className:"cmd-chip",title:"Slash command",children:["⌘ ",e.name]}),e.args&&s.jsx("code",{className:"cmd-args",children:e.args})]}):e.kind==="output"?s.jsx("div",{className:"cmd-out",children:e.stdout&&e.stdout!=="(no content)"?e.stdout:s.jsx("span",{className:"muted",children:"no output"})}):s.jsx("div",{className:"cmd-note muted small",children:"⌘ local command context"})}function Js({n:e}){const n=m.useContext(X),t=e.toolUseId?n.get(e.toolUseId):void 0,a=(e.status??"").toLowerCase();return s.jsxs("div",{className:"task-notif",children:[s.jsxs("div",{className:"task-notif-head",children:[s.jsx("span",{className:"task-notif-icon","aria-hidden":"true",children:"🔔"}),e.status&&s.jsx("span",{className:"tag task-status task-status-"+a,children:e.status}),e.taskId&&s.jsxs("code",{className:"task-notif-id",children:["task ",e.taskId]}),t&&s.jsx(_,{className:"subagent-link small",to:`/workflow/${t}`,children:"view workflow →"})]}),e.summary&&s.jsx("div",{className:"task-notif-summary",children:e.summary})]})}function J({text:e,id:n}){return m.useContext(G)==="raw"?s.jsx("div",{className:"text",id:n,children:e}):s.jsx("div",{className:"text md",id:n,children:s.jsx(_s,{remarkPlugins:[ks],components:Us,children:e})})}const Us={a:({node:e,...n})=>s.jsx("a",{...n,target:"_blank",rel:"noopener noreferrer"})};function es({text:e}){const n=e.length>1400||e.split(`
5
- `).length>18,[t,a]=m.useState(!1),l=m.useId();return n?s.jsxs("div",{className:"text-wrap"+(t?"":" is-clamped"),children:[s.jsx(J,{text:e,id:l}),s.jsx("button",{className:"ghost small show-more","aria-expanded":t,"aria-controls":l,onClick:()=>a(r=>!r),children:t?"Show less ▴":"Show more ▾"})]}):s.jsx(J,{text:e})}function ns({t:e}){const[n,t]=m.useState(!1),[a,l]=m.useState(!1),r=m.useId(),i=e.skill_name?`Skill · ${e.skill_name}`:e.tool_name==="Workflow"&&e.workflow_name?`Workflow · ${e.workflow_name}`:e.agent_type?`${e.tool_name} → ${e.agent_type}`:e.tool_name;return s.jsxs("div",{className:"tool "+(e.status==="error"?"tool-err":""),children:[s.jsxs("button",{className:"tool-head","aria-expanded":n,"aria-controls":r,onClick:()=>t(o=>!o),children:[s.jsxs("span",{className:"tool-name",children:["🔧 ",i]}),e.status&&s.jsx("span",{className:"tool-status",children:e.status}),e.total_duration_ms?s.jsx("span",{className:"muted",children:C(e.total_duration_ms)}):null,s.jsx("span",{className:"chev",children:n?"▾":"▸"})]}),e.spawned_session_id&&s.jsx(_,{className:"subagent-link small",to:`/session/${e.spawned_session_id}`,children:"view subagent transcript →"}),e.workflow_run_id&&s.jsxs(_,{className:"subagent-link small",to:`/workflow/${e.workflow_run_id}`,children:["🔀 launched ",e.workflow_agent_count??0," agent",e.workflow_agent_count===1?"":"s"," · ",s.jsx("code",{children:e.workflow_run_id})," →"]}),e.skill_name&&s.jsxs(_,{className:"subagent-link small",to:`/skill/${encodeURIComponent(e.skill_name)}${e.skill_id?`?v=${e.skill_id}`:""}`,children:["📖 view skill",e.skill_id?" version":""," →"]}),n&&s.jsxs("div",{className:"tool-body",id:r,children:[e.input_json&&e.input_json!=="{}"&&s.jsxs("div",{className:"code-block",children:[s.jsx(y,{text:k(e.input_json),className:"copy-corner",title:"Copy tool input JSON"}),s.jsx("pre",{className:"code",children:k(e.input_json)})]}),e.result_summary&&s.jsx("div",{className:"result",children:e.result_summary}),e.full_result&&s.jsxs("div",{className:"full-result",children:[s.jsxs("button",{type:"button",className:"ghost small show-full","aria-expanded":a,onClick:()=>l(o=>!o),children:[a?"Hide":"Show"," full result (",(e.full_result.bytes/1024).toFixed(1)," KB)"]}),a&&s.jsxs("div",{className:"code-block",children:[s.jsx(y,{text:e.full_result.text,className:"copy-corner",title:"Copy full tool result"}),s.jsx("pre",{className:"code",children:e.full_result.text})]})]})]})]})}function Ws({plan:e}){return s.jsxs("div",{className:"plan-card",children:[s.jsx("div",{className:"plan-card-head",children:"📋 Approved plan"}),s.jsx(es,{text:e})]})}function Ds({t:e}){const[n,t]=m.useState(!1),a=m.useId(),l=As(e.input_json),{answers:r,annotations:i}=qs(e.result_summary);return l.length===0?s.jsx(ns,{t:e}):s.jsxs("div",{className:"qa-card",children:[s.jsxs("div",{className:"qa-card-head",children:["🙋 Question",l.length===1?"":"s"," for the user"]}),l.map((o,c)=>{var g;const u=r[o.question],p=Array.isArray(u)?u:u!=null?[u]:[],f=new Set(p),x=new Set(o.options.map(N=>N.label)),j=p.filter(N=>!x.has(N)),d=(g=i[o.question])==null?void 0:g.notes;return s.jsxs("div",{className:"qa-q",children:[s.jsxs("div",{className:"qa-q-head",children:[o.header&&s.jsx("span",{className:"tag",children:o.header}),o.multiSelect&&s.jsx("span",{className:"muted small",children:"multi-select"})]}),s.jsx("div",{className:"qa-question",children:o.question}),s.jsxs("ul",{className:"qa-options",children:[o.options.map((N,v)=>{const S=f.has(N.label);return s.jsxs("li",{className:"qa-opt"+(S?" is-selected":""),children:[s.jsx("span",{className:"qa-mark","aria-hidden":"true",children:S?"☑":"☐"}),s.jsxs("span",{className:"qa-opt-body",children:[s.jsx("span",{className:"qa-opt-label",children:N.label}),N.description&&s.jsx("span",{className:"qa-opt-desc muted",children:N.description})]})]},v)}),j.map((N,v)=>s.jsxs("li",{className:"qa-opt is-selected",children:[s.jsx("span",{className:"qa-mark","aria-hidden":"true",children:"☑"}),s.jsxs("span",{className:"qa-opt-body",children:[s.jsx("span",{className:"qa-opt-label",children:N}),s.jsx("span",{className:"qa-opt-desc muted",children:"custom answer"})]})]},"c"+v))]}),d&&s.jsxs("div",{className:"qa-note",children:["📝 ",d]})]},c)}),s.jsxs("div",{className:"launch-actions",children:[s.jsx("button",{className:"ghost small","aria-expanded":n,"aria-controls":a,onClick:()=>t(o=>!o),children:n?"Hide raw JSON ▴":"View raw JSON ▾"}),s.jsx(y,{text:k(e.input_json??"{}")+(e.result_summary?`
3
+ `),l=t.length,r=a.length;if(l*r>25e4)return[...t.map(p=>({type:"del",text:p})),...a.map(p=>({type:"add",text:p}))];const i=Array.from({length:l+1},()=>new Array(r+1).fill(0));for(let p=l-1;p>=0;p--)for(let j=r-1;j>=0;j--)i[p][j]=t[p]===a[j]?i[p+1][j+1]+1:Math.max(i[p+1][j],i[p][j+1]);const o=[];let c=0,u=0;for(;c<l&&u<r;)t[c]===a[u]?(o.push({type:"ctx",text:t[c]}),c++,u++):i[c+1][u]>=i[c][u+1]?(o.push({type:"del",text:t[c]}),c++):(o.push({type:"add",text:a[u]}),u++);for(;c<l;)o.push({type:"del",text:t[c++]});for(;u<r;)o.push({type:"add",text:a[u++]});return o}function K(e){if(!e)return null;try{const n=JSON.parse(e).plan;return typeof n=="string"&&n.trim()?n:null}catch{return null}}function Ms(e){if(!e)return[];try{const n=JSON.parse(e).questions;return Array.isArray(n)?n:[]}catch{return[]}}function $s(e){if(!e)return{answers:{},annotations:{}};try{const n=JSON.parse(e);if(n&&typeof n=="object"&&n.answers)return{answers:n.answers,annotations:n.annotations??{}}}catch{}return{answers:{},annotations:{}}}function As(e){if(!e)return null;try{const n=JSON.parse(e);if(!n||typeof n!="object")return null;const t=typeof n.command=="string"?n.command:"";return t.trim()?{command:t,description:typeof n.description=="string"?n.description:void 0,timeout:typeof n.timeout=="number"?n.timeout:void 0,run_in_background:n.run_in_background===!0,restart:n.restart===!0}:null}catch{return null}}function qs(e,n){if(!n)return null;try{const t=JSON.parse(n);if(!t||typeof t!="object"||typeof t.file_path!="string")return null;let a;if(e==="Write"){if(typeof t.content!="string")return null;a=[t.content===""?[]:t.content.split(`
4
+ `).map(i=>({type:"add",text:i}))]}else if(e==="MultiEdit"){if(!Array.isArray(t.edits)||(a=t.edits.filter(i=>{const o=i;return!!o&&typeof o.old_string=="string"&&typeof o.new_string=="string"}).map(i=>H(i.old_string,i.new_string)),a.length===0))return null}else{if(typeof t.old_string!="string"||typeof t.new_string!="string")return null;a=[H(t.old_string,t.new_string)]}let l=0,r=0;for(const i of a)for(const o of i)o.type==="add"?l++:o.type==="del"&&r++;return{file_path:t.file_path,kind:e,hunks:a,adds:l,dels:r}}catch{return null}}function Bs(e){const n=e.lastIndexOf("/");return n>=0?{dir:e.slice(0,n+1),base:e.slice(n+1)}:{dir:"",base:e}}function z(e){var a,l,r,i,o;const n=(l=(a=e.match(/<command-name>([^<]*)<\/command-name>/))==null?void 0:a[1])==null?void 0:l.trim();if(n){const c=((i=(r=e.match(/<command-args>([^<]*)<\/command-args>/))==null?void 0:r[1])==null?void 0:i.trim())??"";return{kind:"invocation",name:n.startsWith("/")?n:`/${n}`,args:c}}const t=(o=e.match(/<(?:local-command-stdout|command-output|local-command-stderr)>([\s\S]*?)<\/(?:local-command-stdout|command-output|local-command-stderr)>/))==null?void 0:o[1];return t!=null?{kind:"output",stdout:t.trim()}:/<local-command-caveat>/.test(e)?{kind:"caveat"}:null}function Y(e){if(!/<task-notification>/.test(e))return null;const n=t=>{var a,l;return((l=(a=e.match(new RegExp(`<${t}>([\\s\\S]*?)</${t}>`)))==null?void 0:a[1])==null?void 0:l.trim())??null};return{taskId:n("task-id"),toolUseId:n("tool-use-id"),status:n("status"),summary:n("summary")}}function Rs(e){const n=z(e);if((n==null?void 0:n.kind)==="invocation")return`⌘ ${n.name}${n.args?" "+n.args:""}`;if((n==null?void 0:n.kind)==="output")return"⌘ command output";if((n==null?void 0:n.kind)==="caveat")return"⌘ local command";const t=Y(e);return t?`🔔 task ${t.status??"notification"}`:e}const G=m.createContext("markdown"),X=m.createContext(new Map),Z=m.createContext(!1),ss=m.createContext(null);function Ps({cmd:e}){return e.kind==="invocation"?s.jsxs("div",{className:"cmd",children:[s.jsxs("span",{className:"cmd-chip",title:"Slash command",children:["⌘ ",e.name]}),e.args&&s.jsx("code",{className:"cmd-args",children:e.args})]}):e.kind==="output"?s.jsx("div",{className:"cmd-out",children:e.stdout&&e.stdout!=="(no content)"?e.stdout:s.jsx("span",{className:"muted",children:"no output"})}):s.jsx("div",{className:"cmd-note muted small",children:"⌘ local command context"})}function Ls({n:e}){const n=m.useContext(X),t=e.toolUseId?n.get(e.toolUseId):void 0,a=(e.status??"").toLowerCase();return s.jsxs("div",{className:"task-notif",children:[s.jsxs("div",{className:"task-notif-head",children:[s.jsx("span",{className:"task-notif-icon","aria-hidden":"true",children:"🔔"}),e.status&&s.jsx("span",{className:"tag task-status task-status-"+a,children:e.status}),e.taskId&&s.jsxs("code",{className:"task-notif-id",children:["task ",e.taskId]}),t&&s.jsx(_,{className:"subagent-link small",to:`/workflow/${t}`,children:"view workflow →"})]}),e.summary&&s.jsx("div",{className:"task-notif-summary",children:e.summary})]})}function J({text:e,id:n}){return m.useContext(G)==="raw"?s.jsx("div",{className:"text",id:n,children:e}):s.jsx("div",{className:"text md",id:n,children:s.jsx(Ns,{remarkPlugins:[ws],components:Hs,children:e})})}const Hs={a:({node:e,...n})=>s.jsx("a",{...n,target:"_blank",rel:"noopener noreferrer"})};function es({text:e}){const n=e.length>1400||e.split(`
5
+ `).length>18,[t,a]=m.useState(!1),l=m.useId();return n?s.jsxs("div",{className:"text-wrap"+(t?"":" is-clamped"),children:[s.jsx(J,{text:e,id:l}),s.jsx("button",{className:"ghost small show-more","aria-expanded":t,"aria-controls":l,onClick:()=>a(r=>!r),children:t?"Show less ▴":"Show more ▾"})]}):s.jsx(J,{text:e})}function ns({t:e}){const[n,t]=m.useState(!1),[a,l]=m.useState(!1),r=m.useId(),i=e.skill_name?`Skill · ${e.skill_name}`:e.tool_name==="Workflow"&&e.workflow_name?`Workflow · ${e.workflow_name}`:e.agent_type?`${e.tool_name} → ${e.agent_type}`:e.tool_name;return s.jsxs("div",{className:"tool "+(e.status==="error"?"tool-err":""),children:[s.jsxs("button",{className:"tool-head","aria-expanded":n,"aria-controls":r,onClick:()=>t(o=>!o),children:[s.jsxs("span",{className:"tool-name",children:["🔧 ",i]}),e.status&&s.jsx("span",{className:"tool-status",children:e.status}),e.total_duration_ms?s.jsx("span",{className:"muted",children:C(e.total_duration_ms)}):null,s.jsx("span",{className:"chev",children:n?"▾":"▸"})]}),e.spawned_session_id&&s.jsx(_,{className:"subagent-link small",to:`/session/${e.spawned_session_id}`,children:"view subagent transcript →"}),e.workflow_run_id&&s.jsxs(_,{className:"subagent-link small",to:`/workflow/${e.workflow_run_id}`,children:["🔀 launched ",e.workflow_agent_count??0," agent",e.workflow_agent_count===1?"":"s"," · ",s.jsx("code",{children:e.workflow_run_id})," →"]}),e.skill_name&&s.jsxs(_,{className:"subagent-link small",to:`/skill/${encodeURIComponent(e.skill_name)}${e.skill_id?`?v=${e.skill_id}`:""}`,children:["📖 view skill",e.skill_id?" version":""," →"]}),n&&s.jsxs("div",{className:"tool-body",id:r,children:[e.input_json&&e.input_json!=="{}"&&s.jsxs("div",{className:"code-block",children:[s.jsx(y,{text:k(e.input_json),className:"copy-corner",title:"Copy tool input JSON"}),s.jsx("pre",{className:"code",children:k(e.input_json)})]}),e.result_summary&&s.jsx("div",{className:"result",children:e.result_summary}),e.full_result&&s.jsxs("div",{className:"full-result",children:[s.jsxs("button",{type:"button",className:"ghost small show-full","aria-expanded":a,onClick:()=>l(o=>!o),children:[a?"Hide":"Show"," full result (",(e.full_result.bytes/1024).toFixed(1)," KB)"]}),a&&s.jsxs("div",{className:"code-block",children:[s.jsx(y,{text:e.full_result.text,className:"copy-corner",title:"Copy full tool result"}),s.jsx("pre",{className:"code",children:e.full_result.text})]})]})]})]})}function Js({plan:e}){return s.jsxs("div",{className:"plan-card",children:[s.jsx("div",{className:"plan-card-head",children:"📋 Approved plan"}),s.jsx(es,{text:e})]})}function Us({t:e}){const[n,t]=m.useState(!1),a=m.useId(),l=Ms(e.input_json),{answers:r,annotations:i}=$s(e.result_summary);return l.length===0?s.jsx(ns,{t:e}):s.jsxs("div",{className:"qa-card",children:[s.jsxs("div",{className:"qa-card-head",children:["🙋 Question",l.length===1?"":"s"," for the user"]}),l.map((o,c)=>{var N;const u=r[o.question],p=Array.isArray(u)?u:u!=null?[u]:[],j=new Set(p),x=new Set(o.options.map(g=>g.label)),f=p.filter(g=>!x.has(g)),d=(N=i[o.question])==null?void 0:N.notes;return s.jsxs("div",{className:"qa-q",children:[s.jsxs("div",{className:"qa-q-head",children:[o.header&&s.jsx("span",{className:"tag",children:o.header}),o.multiSelect&&s.jsx("span",{className:"muted small",children:"multi-select"})]}),s.jsx("div",{className:"qa-question",children:o.question}),s.jsxs("ul",{className:"qa-options",children:[o.options.map((g,v)=>{const S=j.has(g.label);return s.jsxs("li",{className:"qa-opt"+(S?" is-selected":""),children:[s.jsx("span",{className:"qa-mark","aria-hidden":"true",children:S?"☑":"☐"}),s.jsxs("span",{className:"qa-opt-body",children:[s.jsx("span",{className:"qa-opt-label",children:g.label}),g.description&&s.jsx("span",{className:"qa-opt-desc muted",children:g.description})]})]},v)}),f.map((g,v)=>s.jsxs("li",{className:"qa-opt is-selected",children:[s.jsx("span",{className:"qa-mark","aria-hidden":"true",children:"☑"}),s.jsxs("span",{className:"qa-opt-body",children:[s.jsx("span",{className:"qa-opt-label",children:g}),s.jsx("span",{className:"qa-opt-desc muted",children:"custom answer"})]})]},"c"+v))]}),d&&s.jsxs("div",{className:"qa-note",children:["📝 ",d]})]},c)}),s.jsxs("div",{className:"launch-actions",children:[s.jsx("button",{className:"ghost small","aria-expanded":n,"aria-controls":a,onClick:()=>t(o=>!o),children:n?"Hide raw JSON ▴":"View raw JSON ▾"}),s.jsx(y,{text:k(e.input_json??"{}")+(e.result_summary?`
6
6
 
7
7
  `+k(e.result_summary):""),label:"JSON",title:"Copy raw question JSON"})]}),n&&s.jsxs("pre",{id:a,className:"code",children:[k(e.input_json??"{}"),e.result_summary?`
8
8
 
9
- `+k(e.result_summary):""]})]})}function Vs({t:e}){const n=e.workflow_name?`Workflow · ${e.workflow_name}`:"Workflow";return s.jsxs("div",{className:"tool launch-tool",children:[s.jsxs("div",{className:"launch-tool-head",children:[s.jsxs("span",{className:"tool-name",children:["🔀 ",n]}),e.status&&s.jsx("span",{className:"tool-status",children:e.status})]}),e.workflow_run_id&&s.jsxs(_,{className:"subagent-link small",to:`/workflow/${e.workflow_run_id}`,children:["🔀 launched ",e.workflow_agent_count??0," agent",e.workflow_agent_count===1?"":"s"," · ",s.jsx("code",{children:e.workflow_run_id})," →"]}),e.result_summary&&s.jsx("div",{className:"result",children:e.result_summary})]})}function U(e,n,t){let a=n+2,l=!1;for(e[a]==="-"&&(l=!0,a++);e[a]===" "||e[a]===" ";)a++;let r="";(e[a]==="'"||e[a]==='"')&&(r=e[a],a++);let i="";if(r){for(;a<e.length&&e[a]!==r;)i+=e[a++];e[a]===r&&a++}else for(;a<e.length&&/[A-Za-z0-9_]/.test(e[a]);)i+=e[a++];return i&&t.push({delim:i,strip:l}),a-1}function Qs(e){const n=e.split(`
10
- `),t=[];let a="NORMAL",l=0;const r=[];let i=!1;for(const o of n){if(r.length>0){t.push({text:o,cont:!0});const c=r[0];(c.strip?o.replace(/^\t+/,""):o).trimEnd()===c.delim&&r.shift();continue}t.push({text:o,cont:a!=="NORMAL"||l>0||i}),i=!1;for(let c=0;c<o.length;c++){const u=o[c];if(a==="SQUOTE"){u==="'"&&(a="NORMAL");continue}if(a==="DQUOTE"){u==="\\"?c++:u==='"'?a="NORMAL":u==="$"&&o[c+1]==="("?(l++,c++):u===")"?l>0&&l--:u==="<"&&o[c+1]==="<"&&o[c+2]!=="<"&&o[c-1]!=="<"&&(c=U(o,c,r));continue}if(u==="\\")c++;else if(u==="'")a="SQUOTE";else if(u==='"')a="DQUOTE";else{if(u==="#"&&(c===0||/\s/.test(o[c-1])))break;u==="$"&&o[c+1]==="("?(l++,c++):u==="("?l++:u===")"?l>0&&l--:u==="<"&&o[c+1]==="<"&&o[c+2]!=="<"&&o[c-1]!=="<"&&(c=U(o,c,r))}}if(a==="NORMAL"&&l===0&&r.length===0){const c=o.replace(/\s+$/,""),u=c.match(/\\+$/);(u&&u[0].length%2===1||/(&&|\|\||\|)$/.test(c))&&(i=!0)}}return t}function Ks({t:e,bash:n}){const[t,a]=m.useState(!1),[l,r]=m.useState(!1),[i,o]=m.useState(!1),c=m.useId(),u=m.useId(),p=n.command.split(`
11
- `)[0],f=Qs(n.command);return s.jsxs("div",{className:"tool "+(e.status==="error"?"tool-err":""),children:[s.jsxs("button",{className:"tool-head","aria-expanded":t,"aria-controls":c,onClick:()=>a(x=>!x),children:[s.jsx("span",{className:"tool-name",children:"🖥 Bash"}),n.description?s.jsxs("span",{className:"bash-desc",children:["# ",n.description]}):!t&&s.jsx("span",{className:"bash-preview",children:p}),e.status&&s.jsx("span",{className:"tool-status",children:e.status}),e.total_duration_ms?s.jsx("span",{className:"muted",children:C(e.total_duration_ms)}):null,s.jsx("span",{className:"chev",children:t?"▾":"▸"})]}),t&&s.jsxs("div",{className:"tool-body",id:c,children:[s.jsxs("div",{className:"shell code-block",children:[s.jsx(y,{text:n.command,className:"copy-corner",title:"Copy command"}),s.jsx("pre",{className:"shell-cmd",children:f.map((x,j)=>s.jsxs("span",{children:[s.jsx("span",{className:"shell-gutter"+(x.cont?" cont":""),"aria-hidden":"true",children:x.cont?" ":"$ "}),x.text,j<f.length-1?`
12
- `:""]},j))})]}),(n.run_in_background||n.restart||n.timeout!=null)&&s.jsxs("div",{className:"bash-badges",children:[n.run_in_background&&s.jsx("span",{className:"bash-badge",children:"background"}),n.restart&&s.jsx("span",{className:"bash-badge",children:"restart"}),n.timeout!=null&&s.jsxs("span",{className:"bash-badge",children:["timeout ",Math.round(n.timeout/1e3),"s"]})]}),e.result_summary&&s.jsx("pre",{className:"shell-out",children:e.result_summary}),e.full_result&&s.jsxs("div",{className:"full-result",children:[s.jsxs("button",{type:"button",className:"ghost small show-full","aria-expanded":l,onClick:()=>r(x=>!x),children:[l?"Hide":"Show"," full result (",(e.full_result.bytes/1024).toFixed(1)," KB)"]}),l&&s.jsxs("div",{className:"code-block",children:[s.jsx(y,{text:e.full_result.text,className:"copy-corner",title:"Copy full tool result"}),s.jsx("pre",{className:"code",children:e.full_result.text})]})]}),s.jsxs("div",{className:"launch-actions",children:[s.jsx("button",{className:"ghost small","aria-expanded":i,"aria-controls":u,onClick:()=>o(x=>!x),children:i?"Hide raw JSON ▴":"View raw JSON ▾"}),s.jsx(y,{text:k(e.input_json??"{}"),label:"JSON",title:"Copy raw tool input JSON"})]}),i&&s.jsx("pre",{id:u,className:"code",children:k(e.input_json??"{}")})]})]})}const zs={Edit:"✏️",MultiEdit:"✏️",Write:"📄"},E=400;function Ys({t:e,edit:n}){const[t,a]=m.useState(!1),[l,r]=m.useState(!1),[i,o]=m.useState(!1),c=m.useId(),u=m.useId(),{dir:p,base:f}=Ps(n.file_path);return s.jsxs("div",{className:"tool "+(e.status==="error"?"tool-err":""),children:[s.jsxs("button",{className:"tool-head","aria-expanded":t,"aria-controls":c,onClick:()=>a(x=>!x),children:[s.jsxs("span",{className:"tool-name",children:[zs[n.kind]??"✏️"," ",n.kind]}),s.jsxs("span",{className:"edit-path",children:[s.jsx("span",{className:"base",children:f}),p&&s.jsx("span",{className:"dir",children:p.replace(/\/$/,"")})]}),s.jsxs("span",{className:"diff-stat",children:[n.adds>0&&s.jsxs("span",{className:"add",children:["+",n.adds]}),n.dels>0&&s.jsxs("span",{className:"del",children:["−",n.dels]})]}),e.status&&s.jsx("span",{className:"tool-status",children:e.status}),e.total_duration_ms?s.jsx("span",{className:"muted",children:C(e.total_duration_ms)}):null,s.jsx("span",{className:"chev",children:t?"▾":"▸"})]}),t&&s.jsxs("div",{className:"tool-body",id:c,children:[n.hunks.map((x,j)=>s.jsxs("div",{className:"diff",children:[n.hunks.length>1&&s.jsxs("div",{className:"diff-hunk-sep",children:["edit ",j+1]}),x.slice(0,E).map((d,g)=>s.jsxs("div",{className:"diff-line "+d.type,children:[s.jsx("span",{className:"diff-sign","aria-hidden":"true",children:d.type==="add"?"+":d.type==="del"?"−":" "}),s.jsx("span",{className:"diff-text",children:d.text===""?" ":d.text})]},g)),x.length>E&&s.jsxs("div",{className:"diff-more",children:["… ",x.length-E," more lines — View raw JSON for the rest"]})]},j)),e.result_summary&&s.jsx("pre",{className:"shell-out",children:e.result_summary}),e.full_result&&s.jsxs("div",{className:"full-result",children:[s.jsxs("button",{type:"button",className:"ghost small show-full","aria-expanded":l,onClick:()=>r(x=>!x),children:[l?"Hide":"Show"," full result (",(e.full_result.bytes/1024).toFixed(1)," KB)"]}),l&&s.jsxs("div",{className:"code-block",children:[s.jsx(y,{text:e.full_result.text,className:"copy-corner",title:"Copy full tool result"}),s.jsx("pre",{className:"code",children:e.full_result.text})]})]}),s.jsxs("div",{className:"launch-actions",children:[s.jsx("button",{className:"ghost small","aria-expanded":i,"aria-controls":u,onClick:()=>o(x=>!x),children:i?"Hide raw JSON ▴":"View raw JSON ▾"}),s.jsx(y,{text:k(e.input_json??"{}"),label:"JSON",title:"Copy raw tool input JSON"})]}),i&&s.jsx("pre",{id:u,className:"code",children:k(e.input_json??"{}")})]})]})}function Gs({t:e,hideTools:n}){const t=e.findings??[],a=n&&t.length===0,l=Xs(e,a);return t.length===0?l:s.jsxs(s.Fragment,{children:[l,s.jsx(Is,{findings:t})]})}function Xs(e,n){if(e.tool_name==="ExitPlanMode"){const t=K(e.input_json);if(t)return s.jsx(Ws,{plan:t})}if(e.tool_name==="AskUserQuestion")return s.jsx(Ds,{t:e});if(e.tool_name==="Workflow")return s.jsx(Vs,{t:e});if(e.tool_name==="Bash"){const t=Bs(e.input_json);if(t)return n?null:s.jsx(Ks,{t:e,bash:t})}if(e.tool_name==="Edit"||e.tool_name==="MultiEdit"||e.tool_name==="Write"){const t=Rs(e.tool_name,e.input_json);if(t)return n?null:s.jsx(Ys,{t:e,edit:t})}return n?null:s.jsx(ns,{t:e})}function Zs(e,n){return e.findings&&e.findings.length||e.tool_name==="AskUserQuestion"||e.tool_name==="Workflow"||e.tool_name==="ExitPlanMode"&&K(e.input_json)?!0:!n}function ts({e}){const[n,t]=m.useState(!1),a=m.useId(),l=m.useContext(Z),r=m.useContext(ss),i=e.role||e.type,o=i==="user"?"👤":i==="assistant"?"🤖":"⚙️",c=e.toolCalls.filter(j=>Zs(j,l));if(!(e.text||e.thinking||c.length))return null;const p=e.text?z(e.text):null,f=e.text&&!p?Y(e.text):null,x=e.text||e.thinking||"";return s.jsxs("div",{id:"ev-"+e.uuid,className:"event ev-"+i+(r===e.uuid?" ev-flagged":""),children:[s.jsxs("div",{className:"ev-meta",children:[s.jsxs("span",{className:"ev-who",children:[o," ",i]}),e.model&&s.jsx("span",{className:"tag",children:ps(e.model)}),e.is_sidechain?s.jsx("span",{className:"tag subagent",children:"subagent"}):null,s.jsx("span",{className:"muted ev-time",children:W(e.timestamp)}),x&&s.jsx(y,{text:x,className:"ev-copy copy-hover",title:"Copy message"})]}),e.thinking&&s.jsxs("div",{className:"thinking",children:[s.jsxs("button",{className:"thinking-toggle","aria-expanded":n,"aria-controls":a,onClick:()=>t(j=>!j),children:["🧠 thinking ",n?"▾":"▸"]}),n&&s.jsxs("div",{className:"code-block",children:[s.jsx(y,{text:e.thinking,className:"copy-corner",title:"Copy thinking"}),s.jsx("pre",{id:a,className:"thinking-body",children:e.thinking})]})]}),e.text&&(p?s.jsx(Hs,{cmd:p}):f?s.jsx(Js,{n:f}):s.jsx(es,{text:e.text})),c.map((j,d)=>s.jsx(Gs,{t:j,hideTools:l},d))]})}function se({turn:e,events:n,open:t,onToggle:a}){const l=m.useId();return s.jsxs("section",{className:"turn"+(t?" is-open":""),children:[s.jsxs("button",{className:"turn-head","aria-expanded":t,"aria-controls":l,onClick:a,children:[s.jsx("span",{className:"chev turn-chev","aria-hidden":"true",children:t?"▾":"▸"}),s.jsxs("span",{className:"turn-no",children:["turn ",e.seq+1]}),e.prompt_preview?s.jsx("span",{className:"turn-preview",children:Ls(e.prompt_preview)}):null,s.jsxs("span",{className:"turn-stats muted",children:[n.length," msg",n.length===1?"":"s",e.duration_ms?" · "+C(e.duration_ms):""]})]}),s.jsx("div",{id:l,className:"turn-body",role:"region","aria-label":`turn ${e.seq+1} messages`,children:t&&n.map(r=>s.jsx(ts,{e:r},r.uuid))})]})}function ee(e,n){const t=new Map(n.map(l=>[l.id,l])),a=[];for(const l of e){const r=l.turn_id??null,i=a[a.length-1];i&&i.turnId===r?i.events.push(l):a.push({turnId:r,turn:r?t.get(r)??null:null,events:[l]})}return a}function ne(e){const{data:n,error:t}=xs("/sessions/"+e,{reset:!0}),a=m.useMemo(()=>{const l=new Map;for(const r of(n==null?void 0:n.events)??[])for(const i of r.toolCalls)i.tool_name==="Workflow"&&i.id&&i.workflow_run_id&&l.set(i.id,i.workflow_run_id);return l},[n]);return{d:n,error:t,wfMap:a}}const M="msgFormat",$="hideTools";function as(e){const n=fs(e,null);if(n!=null)return n;try{return localStorage.getItem("agentlens."+e)}catch{return null}}const ls=e=>e==="raw"?"raw":"markdown",rs=e=>e===!0||e===1||e==="1";function te(){return ls(as(M))}function ae(){return rs(as($))}function le(e){D(M,e)}function re(e){D($,e)}async function ie(){const[e,n]=await Promise.all([R(M),R($)]);return{...e!=null?{format:ls(e)}:{},...n!=null?{hideTools:rs(n)}:{}}}function me(){const{id:e}=js(),{hash:n}=gs(),{d:t,error:a,wfMap:l}=ne(e),[r,i]=m.useState(new Set),[o,c]=m.useState(te),[u,p]=m.useState(ae);m.useEffect(()=>i(new Set),[e]),m.useEffect(()=>{ie().then(h=>{h.format!==void 0&&c(h.format),h.hideTools!==void 0&&p(h.hideTools)})},[]);const f=h=>{c(h),le(h)},x=()=>p(h=>(re(!h),!h)),[j,d]=m.useState(null),g=m.useRef(null);if(m.useEffect(()=>{if(!t)return;const h=/^#ev-(.+)$/.exec(n);if(!h){g.current=null;return}if(g.current===n)return;const b=h[1],w=t.events.find(T=>T.uuid===b);if(w!=null&&w.turn_id&&r.has(w.turn_id)){const T=w.turn_id;i(cs=>{const B=new Set(cs);return B.delete(T),B});return}const q=document.getElementById("ev-"+b);if(!q)return;g.current=n,q.scrollIntoView({block:"center",behavior:"smooth"}),d(b);const os=window.setTimeout(()=>d(null),3e3);return()=>window.clearTimeout(os)},[t,n,r]),a)return s.jsx(Ns,{error:a});if(!t)return s.jsx(ws,{});const N=t.events.filter(h=>h.text||h.thinking||h.toolCalls.length),v=ee(N,t.turns),S=v.filter(h=>h.turn).map(h=>h.turnId),A=S.some(h=>!r.has(h)),is=h=>i(b=>{const w=new Set(b);return w.has(h)?w.delete(h):w.add(h),w});return s.jsxs("div",{className:"detail",children:[s.jsx(Es,{d:t}),t.children&&t.children.length>0&&s.jsx($s,{d:t}),s.jsx(Ms,{turnCount:S.length,anyOpen:A,onToggleAll:()=>i(A?new Set(S):new Set),hideTools:u,onToggleHideTools:x,format:o,onChooseFormat:f}),s.jsx(X.Provider,{value:l,children:s.jsx(G.Provider,{value:o,children:s.jsx(Z.Provider,{value:u,children:s.jsx(ss.Provider,{value:j,children:s.jsxs("div",{className:"transcript",children:[N.length===0&&s.jsx("div",{className:"muted pad",role:"status",children:"This session has no rendered messages."}),v.map((h,b)=>h.turn?s.jsx(se,{turn:h.turn,events:h.events,open:!r.has(h.turnId),onToggle:()=>is(h.turnId)},h.turnId):s.jsx("div",{className:"unturned",children:h.events.map(w=>s.jsx(ts,{e:w},w.uuid))},"unturned-"+b))]})})})})})]})}export{me as default};
9
+ `+k(e.result_summary):""]})]})}function Ws({t:e}){const n=e.workflow_name?`Workflow · ${e.workflow_name}`:"Workflow";return s.jsxs("div",{className:"tool launch-tool",children:[s.jsxs("div",{className:"launch-tool-head",children:[s.jsxs("span",{className:"tool-name",children:["🔀 ",n]}),e.status&&s.jsx("span",{className:"tool-status",children:e.status})]}),e.workflow_run_id&&s.jsxs(_,{className:"subagent-link small",to:`/workflow/${e.workflow_run_id}`,children:["🔀 launched ",e.workflow_agent_count??0," agent",e.workflow_agent_count===1?"":"s"," · ",s.jsx("code",{children:e.workflow_run_id})," →"]}),e.result_summary&&s.jsx("div",{className:"result",children:e.result_summary})]})}function U(e,n,t){let a=n+2,l=!1;for(e[a]==="-"&&(l=!0,a++);e[a]===" "||e[a]===" ";)a++;let r="";(e[a]==="'"||e[a]==='"')&&(r=e[a],a++);let i="";if(r){for(;a<e.length&&e[a]!==r;)i+=e[a++];e[a]===r&&a++}else for(;a<e.length&&/[A-Za-z0-9_]/.test(e[a]);)i+=e[a++];return i&&t.push({delim:i,strip:l}),a-1}function Ds(e){const n=e.split(`
10
+ `),t=[];let a="NORMAL",l=0;const r=[];let i=!1;for(const o of n){if(r.length>0){t.push({text:o,cont:!0});const c=r[0];(c.strip?o.replace(/^\t+/,""):o).trimEnd()===c.delim&&r.shift();continue}t.push({text:o,cont:a!=="NORMAL"||l>0||i}),i=!1;for(let c=0;c<o.length;c++){const u=o[c];if(a==="SQUOTE"){u==="'"&&(a="NORMAL");continue}if(a==="DQUOTE"){u==="\\"?c++:u==='"'?a="NORMAL":u==="$"&&o[c+1]==="("?(l++,c++):u===")"?l>0&&l--:u==="<"&&o[c+1]==="<"&&o[c+2]!=="<"&&o[c-1]!=="<"&&(c=U(o,c,r));continue}if(u==="\\")c++;else if(u==="'")a="SQUOTE";else if(u==='"')a="DQUOTE";else{if(u==="#"&&(c===0||/\s/.test(o[c-1])))break;u==="$"&&o[c+1]==="("?(l++,c++):u==="("?l++:u===")"?l>0&&l--:u==="<"&&o[c+1]==="<"&&o[c+2]!=="<"&&o[c-1]!=="<"&&(c=U(o,c,r))}}if(a==="NORMAL"&&l===0&&r.length===0){const c=o.replace(/\s+$/,""),u=c.match(/\\+$/);(u&&u[0].length%2===1||/(&&|\|\||\|)$/.test(c))&&(i=!0)}}return t}function Vs({t:e,bash:n}){const[t,a]=m.useState(!1),[l,r]=m.useState(!1),[i,o]=m.useState(!1),c=m.useId(),u=m.useId(),p=n.command.split(`
11
+ `)[0],j=Ds(n.command);return s.jsxs("div",{className:"tool "+(e.status==="error"?"tool-err":""),children:[s.jsxs("button",{className:"tool-head","aria-expanded":t,"aria-controls":c,onClick:()=>a(x=>!x),children:[s.jsx("span",{className:"tool-name",children:"🖥 Bash"}),n.description?s.jsxs("span",{className:"bash-desc",children:["# ",n.description]}):!t&&s.jsx("span",{className:"bash-preview",children:p}),e.status&&s.jsx("span",{className:"tool-status",children:e.status}),e.total_duration_ms?s.jsx("span",{className:"muted",children:C(e.total_duration_ms)}):null,s.jsx("span",{className:"chev",children:t?"▾":"▸"})]}),t&&s.jsxs("div",{className:"tool-body",id:c,children:[s.jsxs("div",{className:"shell code-block",children:[s.jsx(y,{text:n.command,className:"copy-corner",title:"Copy command"}),s.jsx("pre",{className:"shell-cmd",children:j.map((x,f)=>s.jsxs("span",{children:[s.jsx("span",{className:"shell-gutter"+(x.cont?" cont":""),"aria-hidden":"true",children:x.cont?" ":"$ "}),x.text,f<j.length-1?`
12
+ `:""]},f))})]}),(n.run_in_background||n.restart||n.timeout!=null)&&s.jsxs("div",{className:"bash-badges",children:[n.run_in_background&&s.jsx("span",{className:"bash-badge",children:"background"}),n.restart&&s.jsx("span",{className:"bash-badge",children:"restart"}),n.timeout!=null&&s.jsxs("span",{className:"bash-badge",children:["timeout ",Math.round(n.timeout/1e3),"s"]})]}),e.result_summary&&s.jsx("pre",{className:"shell-out",children:e.result_summary}),e.full_result&&s.jsxs("div",{className:"full-result",children:[s.jsxs("button",{type:"button",className:"ghost small show-full","aria-expanded":l,onClick:()=>r(x=>!x),children:[l?"Hide":"Show"," full result (",(e.full_result.bytes/1024).toFixed(1)," KB)"]}),l&&s.jsxs("div",{className:"code-block",children:[s.jsx(y,{text:e.full_result.text,className:"copy-corner",title:"Copy full tool result"}),s.jsx("pre",{className:"code",children:e.full_result.text})]})]}),s.jsxs("div",{className:"launch-actions",children:[s.jsx("button",{className:"ghost small","aria-expanded":i,"aria-controls":u,onClick:()=>o(x=>!x),children:i?"Hide raw JSON ▴":"View raw JSON ▾"}),s.jsx(y,{text:k(e.input_json??"{}"),label:"JSON",title:"Copy raw tool input JSON"})]}),i&&s.jsx("pre",{id:u,className:"code",children:k(e.input_json??"{}")})]})]})}const Qs={Edit:"✏️",MultiEdit:"✏️",Write:"📄"},F=400;function Ks({t:e,edit:n}){const[t,a]=m.useState(!1),[l,r]=m.useState(!1),[i,o]=m.useState(!1),c=m.useId(),u=m.useId(),{dir:p,base:j}=Bs(n.file_path);return s.jsxs("div",{className:"tool "+(e.status==="error"?"tool-err":""),children:[s.jsxs("button",{className:"tool-head","aria-expanded":t,"aria-controls":c,onClick:()=>a(x=>!x),children:[s.jsxs("span",{className:"tool-name",children:[Qs[n.kind]??"✏️"," ",n.kind]}),s.jsxs("span",{className:"edit-path",children:[s.jsx("span",{className:"base",children:j}),p&&s.jsx("span",{className:"dir",children:p.replace(/\/$/,"")})]}),s.jsxs("span",{className:"diff-stat",children:[n.adds>0&&s.jsxs("span",{className:"add",children:["+",n.adds]}),n.dels>0&&s.jsxs("span",{className:"del",children:["−",n.dels]})]}),e.status&&s.jsx("span",{className:"tool-status",children:e.status}),e.total_duration_ms?s.jsx("span",{className:"muted",children:C(e.total_duration_ms)}):null,s.jsx("span",{className:"chev",children:t?"▾":"▸"})]}),t&&s.jsxs("div",{className:"tool-body",id:c,children:[n.hunks.map((x,f)=>s.jsxs("div",{className:"diff",children:[n.hunks.length>1&&s.jsxs("div",{className:"diff-hunk-sep",children:["edit ",f+1]}),x.slice(0,F).map((d,N)=>s.jsxs("div",{className:"diff-line "+d.type,children:[s.jsx("span",{className:"diff-sign","aria-hidden":"true",children:d.type==="add"?"+":d.type==="del"?"−":" "}),s.jsx("span",{className:"diff-text",children:d.text===""?" ":d.text})]},N)),x.length>F&&s.jsxs("div",{className:"diff-more",children:["… ",x.length-F," more lines — View raw JSON for the rest"]})]},f)),e.result_summary&&s.jsx("pre",{className:"shell-out",children:e.result_summary}),e.full_result&&s.jsxs("div",{className:"full-result",children:[s.jsxs("button",{type:"button",className:"ghost small show-full","aria-expanded":l,onClick:()=>r(x=>!x),children:[l?"Hide":"Show"," full result (",(e.full_result.bytes/1024).toFixed(1)," KB)"]}),l&&s.jsxs("div",{className:"code-block",children:[s.jsx(y,{text:e.full_result.text,className:"copy-corner",title:"Copy full tool result"}),s.jsx("pre",{className:"code",children:e.full_result.text})]})]}),s.jsxs("div",{className:"launch-actions",children:[s.jsx("button",{className:"ghost small","aria-expanded":i,"aria-controls":u,onClick:()=>o(x=>!x),children:i?"Hide raw JSON ▴":"View raw JSON ▾"}),s.jsx(y,{text:k(e.input_json??"{}"),label:"JSON",title:"Copy raw tool input JSON"})]}),i&&s.jsx("pre",{id:u,className:"code",children:k(e.input_json??"{}")})]})]})}function zs({t:e,hideTools:n}){const t=e.findings??[],a=n&&t.length===0,l=Ys(e,a);return t.length===0?l:s.jsxs(s.Fragment,{children:[l,s.jsx(Ss,{findings:t})]})}function Ys(e,n){if(e.tool_name==="ExitPlanMode"){const t=K(e.input_json);if(t)return s.jsx(Js,{plan:t})}if(e.tool_name==="AskUserQuestion")return s.jsx(Us,{t:e});if(e.tool_name==="Workflow")return s.jsx(Ws,{t:e});if(e.tool_name==="Bash"){const t=As(e.input_json);if(t)return n?null:s.jsx(Vs,{t:e,bash:t})}if(e.tool_name==="Edit"||e.tool_name==="MultiEdit"||e.tool_name==="Write"){const t=qs(e.tool_name,e.input_json);if(t)return n?null:s.jsx(Ks,{t:e,edit:t})}return n?null:s.jsx(ns,{t:e})}function Gs(e,n){return e.findings&&e.findings.length||e.tool_name==="AskUserQuestion"||e.tool_name==="Workflow"||e.tool_name==="ExitPlanMode"&&K(e.input_json)?!0:!n}function ts({e}){const[n,t]=m.useState(!1),a=m.useId(),l=m.useContext(Z),r=m.useContext(ss),i=e.role||e.type,o=i==="user"?"👤":i==="assistant"?"🤖":"⚙️",c=e.toolCalls.filter(f=>Gs(f,l));if(!(e.text||e.thinking||c.length))return null;const p=e.text?z(e.text):null,j=e.text&&!p?Y(e.text):null,x=e.text||e.thinking||"";return s.jsxs("div",{id:"ev-"+e.uuid,className:"event ev-"+i+(r===e.uuid?" ev-flagged":""),children:[s.jsxs("div",{className:"ev-meta",children:[s.jsxs("span",{className:"ev-who",children:[o," ",i]}),e.model&&s.jsx("span",{className:"tag",children:ms(e.model)}),e.is_sidechain?s.jsx("span",{className:"tag subagent",children:"subagent"}):null,s.jsx("span",{className:"muted ev-time",children:W(e.timestamp)}),x&&s.jsx(y,{text:x,className:"ev-copy copy-hover",title:"Copy message"})]}),e.thinking&&s.jsxs("div",{className:"thinking",children:[s.jsxs("button",{className:"thinking-toggle","aria-expanded":n,"aria-controls":a,onClick:()=>t(f=>!f),children:["🧠 thinking ",n?"▾":"▸"]}),n&&s.jsxs("div",{className:"code-block",children:[s.jsx(y,{text:e.thinking,className:"copy-corner",title:"Copy thinking"}),s.jsx("pre",{id:a,className:"thinking-body",children:e.thinking})]})]}),e.text&&(p?s.jsx(Ps,{cmd:p}):j?s.jsx(Ls,{n:j}):s.jsx(es,{text:e.text})),c.map((f,d)=>s.jsx(zs,{t:f,hideTools:l},d))]})}function Xs({turn:e,events:n,open:t,onToggle:a}){const l=m.useId();return s.jsxs("section",{className:"turn"+(t?" is-open":""),children:[s.jsxs("button",{className:"turn-head","aria-expanded":t,"aria-controls":l,onClick:a,children:[s.jsx("span",{className:"chev turn-chev","aria-hidden":"true",children:t?"▾":"▸"}),s.jsxs("span",{className:"turn-no",children:["turn ",e.seq+1]}),e.prompt_preview?s.jsx("span",{className:"turn-preview",children:Rs(e.prompt_preview)}):null,s.jsxs("span",{className:"turn-stats muted",children:[n.length," msg",n.length===1?"":"s",e.duration_ms?" · "+C(e.duration_ms):""]})]}),s.jsx("div",{id:l,className:"turn-body",role:"region","aria-label":`turn ${e.seq+1} messages`,children:t&&n.map(r=>s.jsx(ts,{e:r},r.uuid))})]})}function Zs(e,n){const t=new Map(n.map(l=>[l.id,l])),a=[];for(const l of e){const r=l.turn_id??null,i=a[a.length-1];i&&i.turnId===r?i.events.push(l):a.push({turnId:r,turn:r?t.get(r)??null:null,events:[l]})}return a}function se(e){const{data:n,error:t}=hs("/sessions/"+e,{reset:!0}),a=m.useMemo(()=>{const l=new Map;for(const r of(n==null?void 0:n.events)??[])for(const i of r.toolCalls)i.tool_name==="Workflow"&&i.id&&i.workflow_run_id&&l.set(i.id,i.workflow_run_id);return l},[n]);return{d:n,error:t,wfMap:a}}const M="msgFormat",$="hideTools";function as(e){const n=ps(e,null);if(n!=null)return n;try{return localStorage.getItem("agentlens."+e)}catch{return null}}const ls=e=>e==="raw"?"raw":"markdown",rs=e=>e===!0||e===1||e==="1";function ee(){return ls(as(M))}function ne(){return rs(as($))}function te(e){D(M,e)}function ae(e){D($,e)}async function le(){const[e,n]=await Promise.all([R(M),R($)]);return{...e!=null?{format:ls(e)}:{},...n!=null?{hideTools:rs(n)}:{}}}function de(){var q;const{id:e}=xs(),{hash:n}=fs(),{d:t,error:a,wfMap:l}=se(e),[r,i]=m.useState(new Set),[o,c]=m.useState(ee),[u,p]=m.useState(ne);m.useEffect(()=>i(new Set),[e]),m.useEffect(()=>{le().then(h=>{h.format!==void 0&&c(h.format),h.hideTools!==void 0&&p(h.hideTools)})},[]);const j=h=>{c(h),te(h)},x=()=>p(h=>(ae(!h),!h)),f=((q=/^#ev-(.+)$/.exec(n))==null?void 0:q[1])??null,[d,N]=m.useState(null);m.useEffect(()=>{var b;const h=f?(b=t==null?void 0:t.events.find(w=>w.uuid===f))==null?void 0:b.turn_id:null;h&&i(w=>{if(!w.has(h))return w;const B=new Set(w);return B.delete(h),B})},[t,f]);const g=m.useRef(null);if(m.useEffect(()=>{if(!t||!f){g.current=null;return}if(g.current===n)return;const h=document.getElementById("ev-"+f);if(!h)return;g.current=n,h.scrollIntoView({block:"center",behavior:"smooth"}),N(f);const b=window.setTimeout(()=>N(null),3e3);return()=>window.clearTimeout(b)},[t,n,f,r]),a)return s.jsx(js,{error:a});if(!t)return s.jsx(gs,{});const v=t.events.filter(h=>h.text||h.thinking||h.toolCalls.length),S=Zs(v,t.turns),T=S.filter(h=>h.turn).map(h=>h.turnId),A=T.some(h=>!r.has(h)),is=h=>i(b=>{const w=new Set(b);return w.has(h)?w.delete(h):w.add(h),w});return s.jsxs("div",{className:"detail",children:[s.jsx(Os,{d:t}),t.children&&t.children.length>0&&s.jsx(Fs,{d:t}),s.jsx(Es,{turnCount:T.length,anyOpen:A,onToggleAll:()=>i(A?new Set(T):new Set),hideTools:u,onToggleHideTools:x,format:o,onChooseFormat:j}),s.jsx(X.Provider,{value:l,children:s.jsx(G.Provider,{value:o,children:s.jsx(Z.Provider,{value:u,children:s.jsx(ss.Provider,{value:d,children:s.jsxs("div",{className:"transcript",children:[v.length===0&&s.jsx("div",{className:"muted pad",role:"status",children:"This session has no rendered messages."}),S.map((h,b)=>h.turn?s.jsx(Xs,{turn:h.turn,events:h.events,open:!r.has(h.turnId),onToggle:()=>is(h.turnId)},h.turnId):s.jsx("div",{className:"unturned",children:h.events.map(w=>s.jsx(ts,{e:w},w.uuid))},"unturned-"+b))]})})})})})]})}export{de as default};
@@ -1 +1 @@
1
- import{x,w as j,j as s,A as v,a as f,r as d,o as m,v as c}from"./index-F_4kZQVd.js";import{M as N,r as p}from"./index-DumYdTnf.js";function k(e){return!e||e<0?"—":e>=1024?(e/1024).toFixed(1)+" KB":e+" B"}function y(e,l){return`${e.slice(0,8)} · ${c(l)}`}function S(){const{name:e=""}=x(),l=j("/skills/"+encodeURIComponent(e),{reset:!0});return s.jsx(v,{state:l,empty:s.jsx("div",{className:"muted pad",children:"Not found."}),children:t=>s.jsx(b,{data:t})})}function b({data:e}){const{get:l,set:t}=f(),o=l("v"),n=d.useMemo(()=>e.versions.length?e.versions.find(i=>i.id===o)??e.versions[0]:null,[e,o]),a=d.useMemo(()=>n?e.sessions.filter(i=>i.version_id===n.id):[],[e,n]),h=d.useMemo(()=>e.sessions.filter(i=>!i.version_id).length,[e]);function u(i){t({v:i})}return s.jsxs("div",{className:"skill-view",children:[s.jsx(m,{to:"/skills",className:"back",children:"← all skills"}),s.jsxs("header",{className:"skill-head",children:[s.jsxs("h1",{children:["📖 ",e.name]}),s.jsxs("div",{className:"skill-head-meta muted",children:[e.call_count.toLocaleString()," firing",e.call_count===1?"":"s"," ·"," ",e.versions.length," version",e.versions.length===1?"":"s",n!=null&&n.summary?s.jsxs(s.Fragment,{children:[" · ",n.summary]}):null]})]}),e.versions.length===0?s.jsxs("div",{className:"empty",children:["This skill fired ",e.call_count.toLocaleString()," time(s) but no SKILL.md body was captured in the transcripts, so there is no version content to show."]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"skill-version-bar",children:[s.jsxs("label",{className:"ctl",children:["version"," ",s.jsx("select",{"aria-label":"Skill version",value:(n==null?void 0:n.id)??"",onChange:i=>u(i.target.value),children:e.versions.map((i,r)=>s.jsxs("option",{value:i.id,children:[y(i.id,i.last_seen)," · ",i.call_count," fire",i.call_count===1?"":"s",r===0?" (latest)":""]},i.id))})]}),n&&s.jsxs("span",{className:"muted small",children:["first seen ",c(n.first_seen)," · last seen ",c(n.last_seen)," ·"," ",k(n.body_bytes)]})]}),n&&s.jsxs("div",{className:"cards skill-cards",children:[s.jsxs("div",{className:"card skill-body-card",children:[s.jsxs("div",{className:"card-head",children:[s.jsx("h3",{children:"Skill body"}),s.jsxs("span",{className:"card-hint",children:["version ",n.id.slice(0,8)]})]}),s.jsx("div",{className:"md skill-body",children:s.jsx(N,{remarkPlugins:[p],children:n.body})})]}),s.jsxs("div",{className:"card skill-sessions-card",children:[s.jsxs("div",{className:"card-head",children:[s.jsx("h3",{children:"Sessions that fired this version"}),s.jsx("span",{className:"card-hint",children:a.length})]}),a.length===0?s.jsx("div",{className:"empty",children:"No sessions fired this version."}):s.jsxs("table",{className:"sessions",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Session"}),s.jsx("th",{children:"Source"}),s.jsx("th",{children:"Project"}),s.jsx("th",{className:"num",children:"Fires"}),s.jsx("th",{children:"When"})]})}),s.jsx("tbody",{children:a.map(i=>{var r;return s.jsxs("tr",{children:[s.jsx("td",{children:s.jsx(m,{to:`/session/${i.id}`,className:"title",children:i.title||s.jsx("span",{className:"muted",children:i.id.slice(0,12)})})}),s.jsx("td",{children:i.source_id}),s.jsx("td",{className:"path",children:((r=i.project_path)==null?void 0:r.replace(/^.*\//,""))??"—"}),s.jsx("td",{className:"num",children:i.fire_count}),s.jsx("td",{children:c(i.fired_at)})]},i.id)})})]}),h>0&&s.jsxs("div",{className:"muted small pad",children:[h," firing(s) had no captured body and aren’t attributed to a version."]})]})]})]})]})}export{S as default};
1
+ import{x,w as j,j as s,A as v,e as f,r as d,L as m,v as c}from"./index-DYY0_SmQ.js";import{M as N,r as p}from"./index-Bgxu3c84.js";function k(e){return!e||e<0?"—":e>=1024?(e/1024).toFixed(1)+" KB":e+" B"}function y(e,l){return`${e.slice(0,8)} · ${c(l)}`}function S(){const{name:e=""}=x(),l=j("/skills/"+encodeURIComponent(e),{reset:!0});return s.jsx(v,{state:l,empty:s.jsx("div",{className:"muted pad",children:"Not found."}),children:t=>s.jsx(b,{data:t})})}function b({data:e}){const{get:l,set:t}=f(),o=l("v"),n=d.useMemo(()=>e.versions.length?e.versions.find(i=>i.id===o)??e.versions[0]:null,[e,o]),a=d.useMemo(()=>n?e.sessions.filter(i=>i.version_id===n.id):[],[e,n]),h=d.useMemo(()=>e.sessions.filter(i=>!i.version_id).length,[e]);function u(i){t({v:i})}return s.jsxs("div",{className:"skill-view",children:[s.jsx(m,{to:"/skills",className:"back",children:"← all skills"}),s.jsxs("header",{className:"skill-head",children:[s.jsxs("h1",{children:["📖 ",e.name]}),s.jsxs("div",{className:"skill-head-meta muted",children:[e.call_count.toLocaleString()," firing",e.call_count===1?"":"s"," ·"," ",e.versions.length," version",e.versions.length===1?"":"s",n!=null&&n.summary?s.jsxs(s.Fragment,{children:[" · ",n.summary]}):null]})]}),e.versions.length===0?s.jsxs("div",{className:"empty",children:["This skill fired ",e.call_count.toLocaleString()," time(s) but no SKILL.md body was captured in the transcripts, so there is no version content to show."]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"skill-version-bar",children:[s.jsxs("label",{className:"ctl",children:["version"," ",s.jsx("select",{"aria-label":"Skill version",value:(n==null?void 0:n.id)??"",onChange:i=>u(i.target.value),children:e.versions.map((i,r)=>s.jsxs("option",{value:i.id,children:[y(i.id,i.last_seen)," · ",i.call_count," fire",i.call_count===1?"":"s",r===0?" (latest)":""]},i.id))})]}),n&&s.jsxs("span",{className:"muted small",children:["first seen ",c(n.first_seen)," · last seen ",c(n.last_seen)," ·"," ",k(n.body_bytes)]})]}),n&&s.jsxs("div",{className:"cards skill-cards",children:[s.jsxs("div",{className:"card skill-body-card",children:[s.jsxs("div",{className:"card-head",children:[s.jsx("h3",{children:"Skill body"}),s.jsxs("span",{className:"card-hint",children:["version ",n.id.slice(0,8)]})]}),s.jsx("div",{className:"md skill-body",children:s.jsx(N,{remarkPlugins:[p],children:n.body})})]}),s.jsxs("div",{className:"card skill-sessions-card",children:[s.jsxs("div",{className:"card-head",children:[s.jsx("h3",{children:"Sessions that fired this version"}),s.jsx("span",{className:"card-hint",children:a.length})]}),a.length===0?s.jsx("div",{className:"empty",children:"No sessions fired this version."}):s.jsxs("table",{className:"sessions",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Session"}),s.jsx("th",{children:"Source"}),s.jsx("th",{children:"Project"}),s.jsx("th",{className:"num",children:"Fires"}),s.jsx("th",{children:"When"})]})}),s.jsx("tbody",{children:a.map(i=>{var r;return s.jsxs("tr",{children:[s.jsx("td",{children:s.jsx(m,{to:`/session/${i.id}`,className:"title",children:i.title||s.jsx("span",{className:"muted",children:i.id.slice(0,12)})})}),s.jsx("td",{children:i.source_id}),s.jsx("td",{className:"path",children:((r=i.project_path)==null?void 0:r.replace(/^.*\//,""))??"—"}),s.jsx("td",{className:"num",children:i.fire_count}),s.jsx("td",{children:c(i.fired_at)})]},i.id)})})]}),h>0&&s.jsxs("div",{className:"muted small pad",children:[h," firing(s) had no captured body and aren’t attributed to a version."]})]})]})]})]})}export{S as default};
@@ -1 +1 @@
1
- import{a as q,d as v,r as c,z as F,w as E,B as C,j as e,F as R,E as w,L as I,S as d,o as K,v as M,P as D}from"./index-F_4kZQVd.js";const u=50,$={name:t=>t.name,fired:t=>t.call_count,last_fired:t=>t.last_fired};function Q(){const{params:t,get:r,set:n,pick:f}=q(),k=v("/sources",[]),y=v("/projects",[]),[h,m]=c.useState(r("q")),{sort:a,toggle:i}=F("fired","desc"),[N,j]=c.useState(1),p=f(["source","project","q"]),{data:x,loading:g,error:_}=E("/skills"+(p.toString()?"?"+p:""));function L(s){s.preventDefault(),n({q:h.trim()})}c.useEffect(()=>j(1),[t,a.key,a.dir]);const l=c.useMemo(()=>C(x??[],$[a.key],a.dir),[x,a.key,a.dir]),b=Math.max(1,Math.ceil(l.length/u)),o=Math.min(N,b),P=l.slice((o-1)*u,o*u);return e.jsxs("div",{children:[e.jsx("h1",{className:"sr-only",children:"Skills"}),e.jsxs("div",{className:"filters",children:[e.jsxs("form",{onSubmit:L,className:"search",role:"search",children:[e.jsx("input",{type:"search","aria-label":"Search skills by name and body",placeholder:"Search skill names & bodies…",value:h,onChange:s=>m(s.target.value)}),e.jsx("button",{type:"submit",children:"Search"}),r("q")&&e.jsx("button",{type:"button",className:"ghost",onClick:()=>(m(""),n({q:""})),children:"clear"})]}),e.jsxs("select",{"aria-label":"Filter by source",value:r("source"),onChange:s=>n({source:s.target.value}),children:[e.jsx("option",{value:"",children:"all sources"}),k.map(s=>e.jsx("option",{value:s.id,children:s.label},s.id))]}),e.jsx(R,{ariaLabel:"Filter by project",searchPlaceholder:"Find project…",value:r("project"),onChange:s=>n({project:s}),options:[{value:"",label:"all projects"},...y.map(s=>({value:s.id,label:s.path.replace(/^.*\//,"")}))]})]}),e.jsx(w,{error:_}),g?e.jsx(I,{}):l.length===0?e.jsx("div",{className:"muted pad",role:"status",children:"No skills fired match."}):e.jsxs("table",{className:"sessions",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx(d,{label:"Skill",sortKey:"name",active:a.key,dir:a.dir,onSort:i,defaultDir:"asc"}),e.jsx(d,{label:"Fired",sortKey:"fired",active:a.key,dir:a.dir,onSort:i,className:"num"}),e.jsx("th",{className:"num",children:"Versions"}),e.jsx("th",{children:"Sources"}),e.jsx(d,{label:"Last fired",sortKey:"last_fired",active:a.key,dir:a.dir,onSort:i})]})}),e.jsx("tbody",{children:P.map(s=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx(K,{to:`/skill/${encodeURIComponent(s.name)}`,className:"title",children:s.name})}),e.jsx("td",{className:"num",children:s.call_count.toLocaleString()}),e.jsx("td",{className:"num",title:`${s.version_count} distinct captured ${s.version_count===1?"version":"versions"}`,children:s.version_count||e.jsx("span",{className:"muted",children:"—"})}),e.jsx("td",{children:e.jsx("span",{className:"sub",children:s.sources.map(S=>e.jsx("span",{className:"tag",children:S},S))})}),e.jsx("td",{children:M(s.last_fired)})]},s.name))})]}),!g&&l.length>0&&e.jsx(D,{page:o,pages:b,total:l.length,unit:"skills",onPage:j})]})}export{Q as default};
1
+ import{e as q,h as v,r as c,z as F,w as E,B as C,j as e,F as R,E as w,m as I,S as d,L as K,v as M,P as D}from"./index-DYY0_SmQ.js";const u=50,$={name:t=>t.name,fired:t=>t.call_count,last_fired:t=>t.last_fired};function Q(){const{params:t,get:r,set:n,pick:f}=q(),k=v("/sources",[]),y=v("/projects",[]),[h,m]=c.useState(r("q")),{sort:a,toggle:i}=F("fired","desc"),[N,j]=c.useState(1),p=f(["source","project","q"]),{data:x,loading:g,error:_}=E("/skills"+(p.toString()?"?"+p:""));function L(s){s.preventDefault(),n({q:h.trim()})}c.useEffect(()=>j(1),[t,a.key,a.dir]);const l=c.useMemo(()=>C(x??[],$[a.key],a.dir),[x,a.key,a.dir]),b=Math.max(1,Math.ceil(l.length/u)),o=Math.min(N,b),P=l.slice((o-1)*u,o*u);return e.jsxs("div",{children:[e.jsx("h1",{className:"sr-only",children:"Skills"}),e.jsxs("div",{className:"filters",children:[e.jsxs("form",{onSubmit:L,className:"search",role:"search",children:[e.jsx("input",{type:"search","aria-label":"Search skills by name and body",placeholder:"Search skill names & bodies…",value:h,onChange:s=>m(s.target.value)}),e.jsx("button",{type:"submit",children:"Search"}),r("q")&&e.jsx("button",{type:"button",className:"ghost",onClick:()=>(m(""),n({q:""})),children:"clear"})]}),e.jsxs("select",{"aria-label":"Filter by source",value:r("source"),onChange:s=>n({source:s.target.value}),children:[e.jsx("option",{value:"",children:"all sources"}),k.map(s=>e.jsx("option",{value:s.id,children:s.label},s.id))]}),e.jsx(R,{ariaLabel:"Filter by project",searchPlaceholder:"Find project…",value:r("project"),onChange:s=>n({project:s}),options:[{value:"",label:"all projects"},...y.map(s=>({value:s.id,label:s.path.replace(/^.*\//,"")}))]})]}),e.jsx(w,{error:_}),g?e.jsx(I,{}):l.length===0?e.jsx("div",{className:"muted pad",role:"status",children:"No skills fired match."}):e.jsxs("table",{className:"sessions",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx(d,{label:"Skill",sortKey:"name",active:a.key,dir:a.dir,onSort:i,defaultDir:"asc"}),e.jsx(d,{label:"Fired",sortKey:"fired",active:a.key,dir:a.dir,onSort:i,className:"num"}),e.jsx("th",{className:"num",children:"Versions"}),e.jsx("th",{children:"Sources"}),e.jsx(d,{label:"Last fired",sortKey:"last_fired",active:a.key,dir:a.dir,onSort:i})]})}),e.jsx("tbody",{children:P.map(s=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx(K,{to:`/skill/${encodeURIComponent(s.name)}`,className:"title",children:s.name})}),e.jsx("td",{className:"num",children:s.call_count.toLocaleString()}),e.jsx("td",{className:"num",title:`${s.version_count} distinct captured ${s.version_count===1?"version":"versions"}`,children:s.version_count||e.jsx("span",{className:"muted",children:"—"})}),e.jsx("td",{children:e.jsx("span",{className:"sub",children:s.sources.map(S=>e.jsx("span",{className:"tag",children:S},S))})}),e.jsx("td",{children:M(s.last_fired)})]},s.name))})]}),!g&&l.length>0&&e.jsx(D,{page:o,pages:b,total:l.length,unit:"skills",onPage:j})]})}export{Q as default};
@@ -1 +1 @@
1
- import{j as s,r as C,x as D,w as G,A as K,o as T,s as R,h as W,i as q,k as Y,v as z}from"./index-F_4kZQVd.js";import{s as E,d as v,l as M,a as H,C as V,p as S,A as Q}from"./jsonish-B1rzsNYu.js";import{M as F,r as J}from"./index-DumYdTnf.js";const N=e=>e===null||typeof e!="object",L=e=>e!==null&&typeof e=="object"&&!Array.isArray(e);function A({v:e}){if(e==null)return s.jsx("span",{className:"json-null",children:"—"});const r=typeof e;return r==="boolean"?s.jsx("span",{className:e?"rv-true":"rv-false",children:e?"✓ true":"✗ false"}):r==="number"?s.jsx("span",{className:"json-number",children:String(e)}):s.jsx("span",{className:"rv-str",children:String(e)})}function P({v:e}){return N(e)?s.jsx(A,{v:e}):Array.isArray(e)?e.every(N)?s.jsx("span",{className:"rv-str",children:e.map(String).join(", ")||"—"}):s.jsxs("span",{className:"muted",children:["[",e.length,"]"]}):s.jsx("span",{className:"muted",children:`{${Object.keys(e).length}}`})}function I(e){const r=[],a=new Set;for(const l of e)for(const n of Object.keys(l??{}))a.has(n)||(a.add(n),r.push(n));return r}function U({rows:e}){const r=I(e);return s.jsx("div",{className:"rv-table-wrap",children:s.jsxs("table",{className:"rv-table",children:[s.jsx("thead",{children:s.jsx("tr",{children:r.map(a=>s.jsx("th",{children:a},a))})}),s.jsx("tbody",{children:e.map((a,l)=>s.jsx("tr",{children:r.map(n=>s.jsx("td",{children:s.jsx(P,{v:a[n]})},n))},l))})]})})}function X({obj:e}){const r=Object.entries(e),a=I(r.map(([,l])=>l));return s.jsx("div",{className:"rv-table-wrap",children:s.jsxs("table",{className:"rv-table",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"key"}),a.map(l=>s.jsx("th",{children:l},l))]})}),s.jsx("tbody",{children:r.map(([l,n])=>s.jsxs("tr",{children:[s.jsx("td",{className:"rv-rowkey",children:l}),a.map(t=>s.jsx("td",{children:s.jsx(P,{v:n[t]})},t))]},l))})]})})}function Z({name:e,value:r,depth:a}){const[l,n]=C.useState(a<1),t=Array.isArray(r)?`[${r.length}]`:`{${Object.keys(r).length}}`;return s.jsxs("div",{className:"rv-section",children:[s.jsxs("button",{className:"rv-sec-head","aria-expanded":l,onClick:()=>n(i=>!i),children:[s.jsx("span",{className:"json-chev","aria-hidden":"true",children:l?"▾":"▸"}),s.jsx("span",{className:"rv-sec-name",children:e}),s.jsx("span",{className:"muted small",children:t})]}),l&&s.jsx("div",{className:"rv-sec-body",children:s.jsx(B,{value:r,depth:a+1})})]})}function B({value:e,depth:r=0}){if(N(e))return s.jsx(A,{v:e});if(Array.isArray(e))return e.length===0?s.jsx("span",{className:"muted",children:"empty"}):e.every(L)?s.jsx(U,{rows:e}):s.jsx("ul",{className:"rv-list",children:e.map((t,i)=>s.jsx("li",{children:s.jsx(P,{v:t})},i))});const a=Object.entries(e);if(a.length===0)return s.jsx("span",{className:"muted",children:"empty"});if(a.every(([,t])=>L(t)))return s.jsx(X,{obj:e});const l=a.filter(([,t])=>N(t)),n=a.filter(([,t])=>!N(t));return s.jsxs("div",{className:"rv-obj",children:[l.length>0&&s.jsx("div",{className:"rv-metrics",children:l.map(([t,i])=>s.jsxs("div",{className:"rv-metric",children:[s.jsx("span",{className:"rv-mkey",children:t}),s.jsx("span",{className:"rv-mval",children:s.jsx(A,{v:i})})]},t))}),n.map(([t,i])=>s.jsx(Z,{name:t,value:i,depth:r},t))]})}function k({value:e}){return s.jsx("div",{className:"rv-root",children:s.jsx(B,{value:e,depth:0})})}const f=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),_=e=>e===null||typeof e!="object",ss=new Set(["script","scriptPath","description"]),es=["skill","name","id","title"];function as({v:e}){return e==null?s.jsx("span",{className:"muted",children:"—"}):typeof e=="string"?s.jsx("span",{className:"launch-text",children:e}):_(e)?s.jsx("span",{className:"json-number",children:String(e)}):Array.isArray(e)?e.every(_)?s.jsx("ol",{className:"launch-list",children:e.map((r,a)=>s.jsx("li",{children:r===null?"—":String(r)},a))}):s.jsx(k,{value:e}):s.jsx(k,{value:e})}function ns({rec:e,index:r}){const a=es.find(t=>typeof e[t]=="string"),l=a?String(e[a]):`task ${r+1}`,n=Object.entries(e).filter(([t])=>t!==a);return s.jsxs("div",{className:"launch-card",children:[s.jsxs("div",{className:"launch-card-head",children:[s.jsx("span",{className:"launch-card-idx",children:r+1}),s.jsx("span",{className:"launch-card-title",children:l})]}),s.jsx("dl",{className:"launch-fields",children:n.map(([t,i])=>s.jsxs("div",{className:"launch-field",children:[s.jsx("dt",{children:t}),s.jsx("dd",{children:s.jsx(as,{v:i})})]},t))})]})}function $({raw:e}){const[r,a]=C.useState(!1),{body:l,note:n}=E(v(e)),{value:t,repaired:i}=M(l);if(t===void 0)return s.jsx("div",{className:"launch",children:s.jsx("pre",{className:"code",children:e})});const d=H(t),x=f(d)?Object.entries(d):[["",d]],g=x.filter(([o,c])=>_(c)&&o!=="script"),y=x.filter(([,o])=>!_(o)),h=f(d)&&typeof d.script=="string"?d.script:null,u=f(d)&&typeof d.scriptPath=="string"?d.scriptPath:null,m=f(d)&&typeof d.description=="string"?d.description:null,p=g.filter(([o])=>!ss.has(o)),w=m||u||h||p.length>0,b=o=>Array.isArray(o)&&o.length>0&&o.every(f);return s.jsxs("div",{className:"launch",children:[w&&s.jsxs("div",{className:"launch-meta",children:[m&&s.jsx("div",{className:"launch-desc",children:m}),u&&s.jsxs("div",{className:"launch-metaline",children:[s.jsx("span",{className:"muted",children:"script"})," ",s.jsx("code",{children:u})]}),p.map(([o,c])=>s.jsxs("div",{className:"launch-metaline",children:[s.jsx("span",{className:"muted",children:o})," ",s.jsx("code",{children:String(c)})]},o)),h&&s.jsxs("details",{className:"launch-src",children:[s.jsxs("summary",{children:["script source · ",h.length.toLocaleString()," chars"]}),s.jsx("pre",{className:"code",children:h})]})]}),y.map(([o,c])=>b(c)?s.jsxs("div",{className:"launch-tasks",children:[s.jsxs("div",{className:"launch-tasks-head",children:[c.length," ",o||(c.length===1?"task":"tasks")," ",s.jsx("span",{className:"muted",children:"launched"})]}),c.map((j,O)=>s.jsx(ns,{rec:j,index:O},O))]},o||"tasks"):s.jsxs("div",{className:"launch-section",children:[o&&s.jsx("div",{className:"launch-tasks-head",children:o}),s.jsx(k,{value:c})]},o||"value")),(n||i)&&s.jsxs("div",{className:"muted small wf-trunc",children:["⚠ ",n??"Payload was truncated; showing the recoverable portion."]}),s.jsxs("div",{className:"launch-actions",children:[s.jsx("button",{type:"button",className:"ghost small","aria-expanded":r,onClick:()=>a(o=>!o),children:r?"Hide raw JSON ▴":"View raw JSON ▾"}),s.jsx(V,{text:S(l),label:"JSON",title:"Copy raw launch JSON"})]}),r&&s.jsx("pre",{className:"code launch-raw",children:S(l)})]})}function ts({raw:e}){const{body:r,note:a}=E(v(e)),l=/^\s*[[{]/.test(r),{value:n,repaired:t}=l?M(r):{value:void 0,repaired:!1},i=n!==void 0;return s.jsxs(s.Fragment,{children:[i?s.jsx("div",{className:"wf-result-body",children:s.jsx(k,{value:n})}):s.jsx("div",{className:"text md wf-result-body",children:s.jsx(F,{remarkPlugins:[J],children:r})}),(a||t)&&s.jsxs("div",{className:"muted small wf-trunc",children:["⚠ ",a??"Result was truncated; showing the recoverable portion."]}),s.jsx("div",{className:"launch-actions",children:s.jsx(V,{text:i?S(r):r,label:"result",title:"Copy the returned result"})})]})}function rs(e,r){if(e&&e.length){const a=new Map,l=(n,t)=>{let i=a.get(n);return i?t&&(i.title=t):(i={title:t||`Phase ${n}`,agentCount:0,models:[]},a.set(n,i)),i};for(const n of e)n.type==="workflow_phase"&&l(n.index,n.title);for(const n of e)if(n.type==="workflow_agent"&&n.phaseIndex!=null){const t=l(n.phaseIndex,n.phaseTitle);t.agentCount++,n.model&&!t.models.includes(n.model)&&t.models.push(n.model)}if(a.size)return[...a.keys()].sort((n,t)=>n-t).map(n=>a.get(n))}return r.map(a=>({title:a,agentCount:0,models:[]}))}function ds(){const{run_id:e}=D(),r=G("/workflows/"+e,{reset:!0});return s.jsx(K,{state:r,children:a=>s.jsx(ls,{d:a})})}function ls({d:e}){var x,g,y,h,u,m,p,w,b,o;const r=(e.status??"").toLowerCase(),a=((x=e.run)==null?void 0:x.agent_count)??e.stats.agent_count,l=((g=e.run)==null?void 0:g.total_tokens)??e.stats.total_tokens,n=((y=e.run)==null?void 0:y.duration_ms)??e.stats.duration_ms,t=(((h=e.run)==null?void 0:h.phases)??[]).map(c=>c==null?void 0:c.title).filter(c=>!!c),i=rs((u=e.run)==null?void 0:u.progress,t),d=((m=e.run)==null?void 0:m.logs)??[];return s.jsxs("div",{className:"detail",children:[s.jsxs("div",{className:"detail-head",children:[s.jsx(T,{to:"/",className:"back",children:"← all sessions"}),s.jsxs("h1",{children:["🔀 ",e.name||"workflow"]}),s.jsxs("div",{className:"detail-meta",children:[s.jsx("code",{children:e.run_id}),e.status&&s.jsx("span",{className:"tag task-status task-status-"+r,children:e.status}),((p=e.run)==null?void 0:p.default_model)&&s.jsx("span",{className:"tag",children:R(e.run.default_model)}),((w=e.parent)==null?void 0:w.id)&&s.jsxs("span",{className:"spawned-by",children:["↖ launched from"," ",s.jsx(T,{to:`/session/${e.parent.id}`,children:e.parent.title||e.parent.id.slice(0,12)}),e.parent.turn_seq!=null?` · turn ${e.parent.turn_seq+1}`:""]}),s.jsxs("span",{children:[a," agent",a===1?"":"s"]}),s.jsxs("span",{children:[W(l)," tok"]}),((b=e.run)==null?void 0:b.total_tool_calls)!=null&&s.jsxs("span",{children:[e.run.total_tool_calls," tool calls"]}),s.jsx("span",{title:"Estimated from ingested agent transcripts at API list prices (cache-aware)",children:q(e.stats.total_cost)}),s.jsx("span",{children:Y(n)}),s.jsx("span",{className:"muted",children:z(((o=e.run)==null?void 0:o.started_at)??e.stats.started_at)})]}),i.length>0&&s.jsx("div",{className:"wf-phases","aria-label":"workflow phases",children:i.map((c,j)=>s.jsxs(C.Fragment,{children:[j>0&&s.jsx("span",{className:"wf-phase-arrow","aria-hidden":"true",children:"→"}),s.jsxs("div",{className:"wf-phase-chip",children:[s.jsx("span",{className:"wf-phase-title",children:c.title}),c.agentCount>0&&s.jsxs("span",{className:"wf-phase-desc",children:[c.agentCount," agent",c.agentCount===1?"":"s",c.models.length?` · ${c.models.map(R).join(", ")}`:""]})]})]},j))})]}),e.completion&&s.jsxs("div",{className:"wf-result",children:[s.jsxs("h2",{children:["Returned result",e.completion.status&&s.jsx("span",{className:"tag task-status task-status-"+e.completion.status.toLowerCase(),children:e.completion.status})]}),e.completion.summary&&s.jsx("p",{className:"wf-result-summary",children:v(e.completion.summary)}),e.completion.result?s.jsx(ts,{raw:e.completion.result}):s.jsx("div",{className:"muted small",children:"Completed with no returned payload."}),e.completion.failures&&s.jsxs("details",{className:"wf-failures",children:[s.jsx("summary",{children:"failures"}),s.jsx("pre",{className:"code wf-result-body",children:v(e.completion.failures)})]})]}),d.length>0&&s.jsxs("details",{className:"wf-logs",open:d.length<=20,children:[s.jsxs("summary",{children:["Run log · ",d.length," line",d.length===1?"":"s"]}),s.jsx("ul",{className:"wf-log-list",children:d.map((c,j)=>s.jsx("li",{children:c},j))})]}),e.input_json?s.jsx("div",{className:"wf-result wf-launch",children:e.completion?s.jsxs("details",{children:[s.jsx("summary",{children:s.jsx("h2",{children:"Launch payload"})}),s.jsx($,{raw:e.input_json})]}):s.jsxs(s.Fragment,{children:[s.jsx("h2",{children:"Launch payload"}),r==="async_launched"&&s.jsx("p",{className:"wf-result-summary muted",children:"Launched asynchronously — results will appear here once the run reports back."}),s.jsx($,{raw:e.input_json})]})}):!e.completion&&e.result_summary?s.jsxs("div",{className:"wf-result",children:[s.jsx("h2",{children:"Workflow launch"}),s.jsx("div",{className:"text md",children:s.jsx(F,{remarkPlugins:[J],children:e.result_summary})})]}):null,s.jsxs("div",{className:"subagents",children:[s.jsxs("h2",{children:["Agents (",e.agents.length,")"]}),e.agents.length===0?s.jsx("div",{className:"muted pad",role:"status",children:"No agent transcripts ingested for this run yet."}):s.jsx("ul",{children:e.agents.map(c=>s.jsx(Q,{a:c},c.id))})]})]})}export{ds as default};
1
+ import{j as s,r as C,x as D,w as G,A as K,L as T,s as L,f as W,b as q,c as Y,v as z}from"./index-DYY0_SmQ.js";import{s as E,d as v,l as M,a as H,C as V,p as S,A as Q}from"./jsonish-Dd3X-MG6.js";import{M as F,r as J}from"./index-Bgxu3c84.js";const N=e=>e===null||typeof e!="object",R=e=>e!==null&&typeof e=="object"&&!Array.isArray(e);function A({v:e}){if(e==null)return s.jsx("span",{className:"json-null",children:"—"});const r=typeof e;return r==="boolean"?s.jsx("span",{className:e?"rv-true":"rv-false",children:e?"✓ true":"✗ false"}):r==="number"?s.jsx("span",{className:"json-number",children:String(e)}):s.jsx("span",{className:"rv-str",children:String(e)})}function P({v:e}){return N(e)?s.jsx(A,{v:e}):Array.isArray(e)?e.every(N)?s.jsx("span",{className:"rv-str",children:e.map(String).join(", ")||"—"}):s.jsxs("span",{className:"muted",children:["[",e.length,"]"]}):s.jsx("span",{className:"muted",children:`{${Object.keys(e).length}}`})}function I(e){const r=[],a=new Set;for(const l of e)for(const n of Object.keys(l??{}))a.has(n)||(a.add(n),r.push(n));return r}function U({rows:e}){const r=I(e);return s.jsx("div",{className:"rv-table-wrap",children:s.jsxs("table",{className:"rv-table",children:[s.jsx("thead",{children:s.jsx("tr",{children:r.map(a=>s.jsx("th",{children:a},a))})}),s.jsx("tbody",{children:e.map((a,l)=>s.jsx("tr",{children:r.map(n=>s.jsx("td",{children:s.jsx(P,{v:a[n]})},n))},l))})]})})}function X({obj:e}){const r=Object.entries(e),a=I(r.map(([,l])=>l));return s.jsx("div",{className:"rv-table-wrap",children:s.jsxs("table",{className:"rv-table",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"key"}),a.map(l=>s.jsx("th",{children:l},l))]})}),s.jsx("tbody",{children:r.map(([l,n])=>s.jsxs("tr",{children:[s.jsx("td",{className:"rv-rowkey",children:l}),a.map(t=>s.jsx("td",{children:s.jsx(P,{v:n[t]})},t))]},l))})]})})}function Z({name:e,value:r,depth:a}){const[l,n]=C.useState(a<1),t=Array.isArray(r)?`[${r.length}]`:`{${Object.keys(r).length}}`;return s.jsxs("div",{className:"rv-section",children:[s.jsxs("button",{className:"rv-sec-head","aria-expanded":l,onClick:()=>n(i=>!i),children:[s.jsx("span",{className:"json-chev","aria-hidden":"true",children:l?"▾":"▸"}),s.jsx("span",{className:"rv-sec-name",children:e}),s.jsx("span",{className:"muted small",children:t})]}),l&&s.jsx("div",{className:"rv-sec-body",children:s.jsx(B,{value:r,depth:a+1})})]})}function B({value:e,depth:r=0}){if(N(e))return s.jsx(A,{v:e});if(Array.isArray(e))return e.length===0?s.jsx("span",{className:"muted",children:"empty"}):e.every(R)?s.jsx(U,{rows:e}):s.jsx("ul",{className:"rv-list",children:e.map((t,i)=>s.jsx("li",{children:s.jsx(P,{v:t})},i))});const a=Object.entries(e);if(a.length===0)return s.jsx("span",{className:"muted",children:"empty"});if(a.every(([,t])=>R(t)))return s.jsx(X,{obj:e});const l=a.filter(([,t])=>N(t)),n=a.filter(([,t])=>!N(t));return s.jsxs("div",{className:"rv-obj",children:[l.length>0&&s.jsx("div",{className:"rv-metrics",children:l.map(([t,i])=>s.jsxs("div",{className:"rv-metric",children:[s.jsx("span",{className:"rv-mkey",children:t}),s.jsx("span",{className:"rv-mval",children:s.jsx(A,{v:i})})]},t))}),n.map(([t,i])=>s.jsx(Z,{name:t,value:i,depth:r},t))]})}function k({value:e}){return s.jsx("div",{className:"rv-root",children:s.jsx(B,{value:e,depth:0})})}const f=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),_=e=>e===null||typeof e!="object",ss=new Set(["script","scriptPath","description"]),es=["skill","name","id","title"];function as({v:e}){return e==null?s.jsx("span",{className:"muted",children:"—"}):typeof e=="string"?s.jsx("span",{className:"launch-text",children:e}):_(e)?s.jsx("span",{className:"json-number",children:String(e)}):Array.isArray(e)?e.every(_)?s.jsx("ol",{className:"launch-list",children:e.map((r,a)=>s.jsx("li",{children:r===null?"—":String(r)},a))}):s.jsx(k,{value:e}):s.jsx(k,{value:e})}function ns({rec:e,index:r}){const a=es.find(t=>typeof e[t]=="string"),l=a?String(e[a]):`task ${r+1}`,n=Object.entries(e).filter(([t])=>t!==a);return s.jsxs("div",{className:"launch-card",children:[s.jsxs("div",{className:"launch-card-head",children:[s.jsx("span",{className:"launch-card-idx",children:r+1}),s.jsx("span",{className:"launch-card-title",children:l})]}),s.jsx("dl",{className:"launch-fields",children:n.map(([t,i])=>s.jsxs("div",{className:"launch-field",children:[s.jsx("dt",{children:t}),s.jsx("dd",{children:s.jsx(as,{v:i})})]},t))})]})}function $({raw:e}){const[r,a]=C.useState(!1),{body:l,note:n}=E(v(e)),{value:t,repaired:i}=M(l);if(t===void 0)return s.jsx("div",{className:"launch",children:s.jsx("pre",{className:"code",children:e})});const d=H(t),x=f(d)?Object.entries(d):[["",d]],g=x.filter(([o,c])=>_(c)&&o!=="script"),y=x.filter(([,o])=>!_(o)),h=f(d)&&typeof d.script=="string"?d.script:null,u=f(d)&&typeof d.scriptPath=="string"?d.scriptPath:null,m=f(d)&&typeof d.description=="string"?d.description:null,p=g.filter(([o])=>!ss.has(o)),w=m||u||h||p.length>0,b=o=>Array.isArray(o)&&o.length>0&&o.every(f);return s.jsxs("div",{className:"launch",children:[w&&s.jsxs("div",{className:"launch-meta",children:[m&&s.jsx("div",{className:"launch-desc",children:m}),u&&s.jsxs("div",{className:"launch-metaline",children:[s.jsx("span",{className:"muted",children:"script"})," ",s.jsx("code",{children:u})]}),p.map(([o,c])=>s.jsxs("div",{className:"launch-metaline",children:[s.jsx("span",{className:"muted",children:o})," ",s.jsx("code",{children:String(c)})]},o)),h&&s.jsxs("details",{className:"launch-src",children:[s.jsxs("summary",{children:["script source · ",h.length.toLocaleString()," chars"]}),s.jsx("pre",{className:"code",children:h})]})]}),y.map(([o,c])=>b(c)?s.jsxs("div",{className:"launch-tasks",children:[s.jsxs("div",{className:"launch-tasks-head",children:[c.length," ",o||(c.length===1?"task":"tasks")," ",s.jsx("span",{className:"muted",children:"launched"})]}),c.map((j,O)=>s.jsx(ns,{rec:j,index:O},O))]},o||"tasks"):s.jsxs("div",{className:"launch-section",children:[o&&s.jsx("div",{className:"launch-tasks-head",children:o}),s.jsx(k,{value:c})]},o||"value")),(n||i)&&s.jsxs("div",{className:"muted small wf-trunc",children:["⚠ ",n??"Payload was truncated; showing the recoverable portion."]}),s.jsxs("div",{className:"launch-actions",children:[s.jsx("button",{type:"button",className:"ghost small","aria-expanded":r,onClick:()=>a(o=>!o),children:r?"Hide raw JSON ▴":"View raw JSON ▾"}),s.jsx(V,{text:S(l),label:"JSON",title:"Copy raw launch JSON"})]}),r&&s.jsx("pre",{className:"code launch-raw",children:S(l)})]})}function ts({raw:e}){const{body:r,note:a}=E(v(e)),l=/^\s*[[{]/.test(r),{value:n,repaired:t}=l?M(r):{value:void 0,repaired:!1},i=n!==void 0;return s.jsxs(s.Fragment,{children:[i?s.jsx("div",{className:"wf-result-body",children:s.jsx(k,{value:n})}):s.jsx("div",{className:"text md wf-result-body",children:s.jsx(F,{remarkPlugins:[J],children:r})}),(a||t)&&s.jsxs("div",{className:"muted small wf-trunc",children:["⚠ ",a??"Result was truncated; showing the recoverable portion."]}),s.jsx("div",{className:"launch-actions",children:s.jsx(V,{text:i?S(r):r,label:"result",title:"Copy the returned result"})})]})}function rs(e,r){if(e&&e.length){const a=new Map,l=(n,t)=>{let i=a.get(n);return i?t&&(i.title=t):(i={title:t||`Phase ${n}`,agentCount:0,models:[]},a.set(n,i)),i};for(const n of e)n.type==="workflow_phase"&&l(n.index,n.title);for(const n of e)if(n.type==="workflow_agent"&&n.phaseIndex!=null){const t=l(n.phaseIndex,n.phaseTitle);t.agentCount++,n.model&&!t.models.includes(n.model)&&t.models.push(n.model)}if(a.size)return[...a.keys()].sort((n,t)=>n-t).map(n=>a.get(n))}return r.map(a=>({title:a,agentCount:0,models:[]}))}function ds(){const{run_id:e}=D(),r=G("/workflows/"+e,{reset:!0});return s.jsx(K,{state:r,children:a=>s.jsx(ls,{d:a})})}function ls({d:e}){var x,g,y,h,u,m,p,w,b,o;const r=(e.status??"").toLowerCase(),a=((x=e.run)==null?void 0:x.agent_count)??e.stats.agent_count,l=((g=e.run)==null?void 0:g.total_tokens)??e.stats.total_tokens,n=((y=e.run)==null?void 0:y.duration_ms)??e.stats.duration_ms,t=(((h=e.run)==null?void 0:h.phases)??[]).map(c=>c==null?void 0:c.title).filter(c=>!!c),i=rs((u=e.run)==null?void 0:u.progress,t),d=((m=e.run)==null?void 0:m.logs)??[];return s.jsxs("div",{className:"detail",children:[s.jsxs("div",{className:"detail-head",children:[s.jsx(T,{to:"/",className:"back",children:"← all sessions"}),s.jsxs("h1",{children:["🔀 ",e.name||"workflow"]}),s.jsxs("div",{className:"detail-meta",children:[s.jsx("code",{children:e.run_id}),e.status&&s.jsx("span",{className:"tag task-status task-status-"+r,children:e.status}),((p=e.run)==null?void 0:p.default_model)&&s.jsx("span",{className:"tag",children:L(e.run.default_model)}),((w=e.parent)==null?void 0:w.id)&&s.jsxs("span",{className:"spawned-by",children:["↖ launched from"," ",s.jsx(T,{to:`/session/${e.parent.id}`,children:e.parent.title||e.parent.id.slice(0,12)}),e.parent.turn_seq!=null?` · turn ${e.parent.turn_seq+1}`:""]}),s.jsxs("span",{children:[a," agent",a===1?"":"s"]}),s.jsxs("span",{children:[W(l)," tok"]}),((b=e.run)==null?void 0:b.total_tool_calls)!=null&&s.jsxs("span",{children:[e.run.total_tool_calls," tool calls"]}),s.jsx("span",{title:"Estimated from ingested agent transcripts at API list prices (cache-aware)",children:q(e.stats.total_cost)}),s.jsx("span",{children:Y(n)}),s.jsx("span",{className:"muted",children:z(((o=e.run)==null?void 0:o.started_at)??e.stats.started_at)})]}),i.length>0&&s.jsx("div",{className:"wf-phases","aria-label":"workflow phases",children:i.map((c,j)=>s.jsxs(C.Fragment,{children:[j>0&&s.jsx("span",{className:"wf-phase-arrow","aria-hidden":"true",children:"→"}),s.jsxs("div",{className:"wf-phase-chip",children:[s.jsx("span",{className:"wf-phase-title",children:c.title}),c.agentCount>0&&s.jsxs("span",{className:"wf-phase-desc",children:[c.agentCount," agent",c.agentCount===1?"":"s",c.models.length?` · ${c.models.map(L).join(", ")}`:""]})]})]},j))})]}),e.completion&&s.jsxs("div",{className:"wf-result",children:[s.jsxs("h2",{children:["Returned result",e.completion.status&&s.jsx("span",{className:"tag task-status task-status-"+e.completion.status.toLowerCase(),children:e.completion.status})]}),e.completion.summary&&s.jsx("p",{className:"wf-result-summary",children:v(e.completion.summary)}),e.completion.result?s.jsx(ts,{raw:e.completion.result}):s.jsx("div",{className:"muted small",children:"Completed with no returned payload."}),e.completion.failures&&s.jsxs("details",{className:"wf-failures",children:[s.jsx("summary",{children:"failures"}),s.jsx("pre",{className:"code wf-result-body",children:v(e.completion.failures)})]})]}),d.length>0&&s.jsxs("details",{className:"wf-logs",open:d.length<=20,children:[s.jsxs("summary",{children:["Run log · ",d.length," line",d.length===1?"":"s"]}),s.jsx("ul",{className:"wf-log-list",children:d.map((c,j)=>s.jsx("li",{children:c},j))})]}),e.input_json?s.jsx("div",{className:"wf-result wf-launch",children:e.completion?s.jsxs("details",{children:[s.jsx("summary",{children:s.jsx("h2",{children:"Launch payload"})}),s.jsx($,{raw:e.input_json})]}):s.jsxs(s.Fragment,{children:[s.jsx("h2",{children:"Launch payload"}),r==="async_launched"&&s.jsx("p",{className:"wf-result-summary muted",children:"Launched asynchronously — results will appear here once the run reports back."}),s.jsx($,{raw:e.input_json})]})}):!e.completion&&e.result_summary?s.jsxs("div",{className:"wf-result",children:[s.jsx("h2",{children:"Workflow launch"}),s.jsx("div",{className:"text md",children:s.jsx(F,{remarkPlugins:[J],children:e.result_summary})})]}):null,s.jsxs("div",{className:"subagents",children:[s.jsxs("h2",{children:["Agents (",e.agents.length,")"]}),e.agents.length===0?s.jsx("div",{className:"muted pad",role:"status",children:"No agent transcripts ingested for this run yet."}):s.jsx("ul",{children:e.agents.map(c=>s.jsx(Q,{a:c},c.id))})]})]})}export{ds as default};