@swestash/agent-lens 0.11.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -3
- package/dist/agent-lens.js +217 -175
- package/dist/agent-lens.js.map +1 -1
- package/package.json +1 -2
- package/web/404.html +2 -2
- package/web/assets/{AboutView-B6r8WJKS.js → AboutView-RYpZsHJe.js} +1 -1
- package/web/assets/Dashboard-CnnVKsdd.js +69 -0
- package/web/assets/{FileView-D3OB1c3e.js → FileView-d-4dV_l-.js} +1 -1
- package/web/assets/{FilesView-DYSJHOfO.js → FilesView-BxrnO6iD.js} +1 -1
- package/web/assets/{SecurityView-Dl5rRtT4.js → SecurityView-WSgyTWlP.js} +1 -1
- package/web/assets/{SessionView-77dXiwzp.js → SessionView-C6LlRN86.js} +1 -1
- package/web/assets/{SkillView-Bkwf24pB.js → SkillView-JC1Mui_Y.js} +1 -1
- package/web/assets/{SkillsView-CAGiD59V.js → SkillsView-e0CAy8dz.js} +1 -1
- package/web/assets/{WorkflowView-CR2GzUdU.js → WorkflowView-DbwB35tb.js} +1 -1
- package/web/assets/{index-BnVRCFL6.js → index-CBHS7Zas.js} +1 -1
- package/web/assets/{index-BxbXFMQG.js → index-Cw8bDSJv.js} +2 -2
- package/web/assets/index-_IDJiIIc.css +1 -0
- package/web/assets/{jsonish-B3QCD4cU.js → jsonish-vNRmfzgB.js} +1 -1
- package/web/assets/{severity-DTzxtVJn.js → severity-DyaWrmUf.js} +1 -1
- package/web/index.html +2 -2
- package/web/assets/Dashboard-C0axgFBI.js +0 -69
- package/web/assets/index-CeW4iDDs.css +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{D as d,x as h,j as e,A as o,L as r,w as t}from"./index-
|
|
1
|
+
import{D as d,x as h,j as e,A as o,L as r,w as t}from"./index-Cw8bDSJv.js";import{relPath as m,LinesDelta as p}from"./FilesView-BxrnO6iD.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{
|
|
1
|
+
import{k as q,m as x,r as E,x as C,j as e,F as P,E as k,o as D,S as n,L as K,w as $,P as I}from"./index-Cw8bDSJv.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(k,{error:S}),j?e.jsx(D,{}):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(K,{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:$(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 +1 @@
|
|
|
1
|
-
import{r as m,e as ie,h as P,B as ne,x as ae,j as e,G as p,F as le,H as y,E as re,m as ce,S as $,P as oe,w as de,L as ue}from"./index-BxbXFMQG.js";import{S as he,a as me}from"./severity-DTzxtVJn.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,Q]=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]),I=P(p?null:"/security/mutes",[],[j]),K=`${C.toString()}|${r.key}|${r.dir}`,[E,U]=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:V,loading:D,error:Y}=ae("/security/findings?"+f.toString(),{deps:[j]}),[q,B]=W(`${K}|${E}|${j}`,null),J=q??Y,{total:g,findings:O}=V??pe,x=m.useCallback(async s=>{S(!0),B(null);try{await s(),Q(c=>c+1)}catch(c){B(String(c))}finally{S(!1)}},[]),X=m.useMemo(()=>new Map(((i==null?void 0:i.by_severity)??[]).map(s=>[s.severity,s.n])),[i]),G=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||G.some(H=>H.rule_id===k&&(!c||H.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"}),G.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}),D?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))})]}),!D&&g>M&&e.jsx(oe,{page:E,pages:Z,total:g,unit:"findings",onPage:U}),!p&&I.length>0&&e.jsx(xe,{mutes:I,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
|
+
import{r as m,k as ie,m as P,B as ne,x as ae,j as e,G as p,F as le,H as y,E as re,o as ce,S as $,P as oe,w as de,L as ue}from"./index-Cw8bDSJv.js";import{S as he,a as me}from"./severity-DyaWrmUf.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,Q]=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]),I=P(p?null:"/security/mutes",[],[j]),K=`${C.toString()}|${r.key}|${r.dir}`,[E,U]=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:V,loading:D,error:Y}=ae("/security/findings?"+f.toString(),{deps:[j]}),[q,B]=W(`${K}|${E}|${j}`,null),J=q??Y,{total:g,findings:O}=V??pe,x=m.useCallback(async s=>{S(!0),B(null);try{await s(),Q(c=>c+1)}catch(c){B(String(c))}finally{S(!1)}},[]),X=m.useMemo(()=>new Map(((i==null?void 0:i.by_severity)??[]).map(s=>[s.severity,s.n])),[i]),G=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||G.some(H=>H.rule_id===k&&(!c||H.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"}),G.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}),D?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))})]}),!D&&g>M&&e.jsx(oe,{page:E,pages:Z,total:g,unit:"findings",onPage:U}),!p&&I.length>0&&e.jsx(xe,{mutes:I,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,4 +1,4 @@
|
|
|
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,v as ms,c as C,w as W,s as hs,x as ps,i as R,n as D,l as xs,y as fs,z as js,E as gs,m as Ns}from"./index-BxbXFMQG.js";import{S as I,a as V}from"./severity-DTzxtVJn.js";import{A as F,C as y,p as k}from"./jsonish-B3QCD4cU.js";import{M as ws,r as _s}from"./index-BnVRCFL6.js";function ks({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 ys({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(vs,{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 bs={loc:"Lines changed",files:"Files touched",turns:"Turns",tokens:"Work tokens",duration:"Duration",subagents:"Subagents"},L=e=>`${Math.max(0,Math.min(1,e))*100}%`;function P({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 vs({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:bs[d.key]??d.key}),s.jsx("span",{className:"sig-bar","aria-hidden":"true",children:s.jsx("span",{className:"sig-bar-fill",style:{width:L(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:L(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(P,{counts:n.tool_counts})})]}),f&&s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:"Skills"}),s.jsx("dd",{children:s.jsx(P,{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 Ss({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 Cs({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(Ss,{f:t},t.id))})}function Is({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 Ts(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 Os({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=Ts([...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 Fs({d:e}){var t;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.jsxs("span",{title:ms(n.unpriced_models),children:[us(n.cost),(t=n.unpriced_models)!=null&&t.length?s.jsx("span",{className:"warn-tag",children:" ⚠"}):null]}),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(ks,{id:n.id})]}),e.classification&&s.jsx(ys,{c:e.classification}),e.findings&&e.findings.length>0&&s.jsx(Is,{findings:e.findings,sessionId:n.id}),e.file_changes&&e.file_changes.length>0&&s.jsx(Os,{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 Ms({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{e as os,j as s,q as O,r as m,L as _,f as cs,t as ds,b as us,v as ms,c as C,w as W,s as hs,x as ps,h as R,i as D,l as xs,y as fs,z as js,E as gs,o as Ns}from"./index-Cw8bDSJv.js";import{S as I,a as V}from"./severity-DyaWrmUf.js";import{A as F,C as y,p as k}from"./jsonish-vNRmfzgB.js";import{M as ws,r as _s}from"./index-CBHS7Zas.js";function ks({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 ys({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(vs,{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 bs={loc:"Lines changed",files:"Files touched",turns:"Turns",tokens:"Work tokens",duration:"Duration",subagents:"Subagents"},L=e=>`${Math.max(0,Math.min(1,e))*100}%`;function P({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 vs({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:bs[d.key]??d.key}),s.jsx("span",{className:"sig-bar","aria-hidden":"true",children:s.jsx("span",{className:"sig-bar-fill",style:{width:L(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:L(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(P,{counts:n.tool_counts})})]}),f&&s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:"Skills"}),s.jsx("dd",{children:s.jsx(P,{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 Ss({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 Cs({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(Ss,{f:t},t.id))})}function Is({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 Ts(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 Os({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=Ts([...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 Fs({d:e}){var t;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.jsxs("span",{title:ms(n.unpriced_models),children:[us(n.cost),(t=n.unpriced_models)!=null&&t.length?s.jsx("span",{className:"warn-tag",children:" ⚠"}):null]}),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(ks,{id:n.id})]}),e.classification&&s.jsx(ys,{c:e.classification}),e.findings&&e.findings.length>0&&s.jsx(Is,{findings:e.findings,sessionId:n.id}),e.file_changes&&e.file_changes.length>0&&s.jsx(Os,{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 Ms({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(`
|
|
2
2
|
`),a=n===""?[]:n.split(`
|
|
3
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 z(e){if(!e)return null;try{const n=JSON.parse(e).plan;return typeof n=="string"&&n.trim()?n:null}catch{return null}}function $s(e){if(!e)return[];try{const n=JSON.parse(e).questions;return Array.isArray(n)?n:[]}catch{return[]}}function As(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 qs(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 Bs(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
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 Rs(e){const n=e.lastIndexOf("/");return n>=0?{dir:e.slice(0,n+1),base:e.slice(n+1)}:{dir:"",base:e}}function K(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=K(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 Hs({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(ws,{remarkPlugins:[_s],components:Js,children:e})})}const Js={a:({node:e,...n})=>s.jsx("a",{...n,target:"_blank",rel:"noopener noreferrer"})};function es({text:e}){const n=e.length>1400||e.split(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{y as x,x as j,j as s,A as v,
|
|
1
|
+
import{y as x,x as j,j as s,A as v,k as f,r as d,L as m,w as c}from"./index-Cw8bDSJv.js";import{M as N,r as p}from"./index-CBHS7Zas.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{
|
|
1
|
+
import{k as q,m as k,r as c,B as F,x as C,C as E,j as e,F as R,E as w,o as I,S as d,L as K,w as M,P as D}from"./index-Cw8bDSJv.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:v}=q(),f=k("/sources",[]),y=k("/projects",[]),[h,m]=c.useState(r("q")),{sort:a,toggle:i}=F("fired","desc"),[N,j]=c.useState(1),p=v(["source","project","q"]),{data:x,loading:g,error:_}=C("/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(()=>E(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"}),f.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,y as D,x as G,A as K,L as T,s as L,f as W,b as q,c as Y,w as z}from"./index-BxbXFMQG.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-B3QCD4cU.js";import{M as F,r as J}from"./index-BnVRCFL6.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]],y=x.filter(([o,c])=>_(c)&&o!=="script"),g=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=y.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})]})]}),g.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,y,g,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=((y=e.run)==null?void 0:y.total_tokens)??e.stats.total_tokens,n=((g=e.run)==null?void 0:g.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};
|
|
1
|
+
import{j as s,r as C,y as D,x as G,A as K,L as T,s as L,f as W,b as q,c as Y,w as z}from"./index-Cw8bDSJv.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-vNRmfzgB.js";import{M as F,r as J}from"./index-CBHS7Zas.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]],y=x.filter(([o,c])=>_(c)&&o!=="script"),g=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=y.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})]})]}),g.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,y,g,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=((y=e.run)==null?void 0:y.total_tokens)??e.stats.total_tokens,n=((g=e.run)==null?void 0:g.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};
|