@swestash/agent-lens 0.16.0 → 0.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-lens.js +162 -22
- package/dist/agent-lens.js.map +1 -1
- package/package.json +1 -1
- package/web/404.html +2 -2
- package/web/assets/AboutView-Crn85usU.js +1 -0
- package/web/assets/{Dashboard-DF8Xb9E1.js → Dashboard-CH8nv5ZK.js} +2 -2
- package/web/assets/FileView-CtovgU1g.js +1 -0
- package/web/assets/{FilesView-DW_bHt2e.js → FilesView-38qLTWbj.js} +1 -1
- package/web/assets/SecurityView-CmKLXZP9.js +1 -0
- package/web/assets/SessionView-Bt-NmoU3.js +19 -0
- package/web/assets/{SkillView-BdZwKqK6.js → SkillView-DQEklf89.js} +1 -1
- package/web/assets/SkillsView-CNX1nAkf.js +1 -0
- package/web/assets/{WorkflowView-yNhKNcg9.js → WorkflowView-CtFEKBzS.js} +1 -1
- package/web/assets/{index-BuG6Awf5.js → index-C5nCASCF.js} +1 -1
- package/web/assets/index-DN9qB28e.css +1 -0
- package/web/assets/index-DYCDqLKI.js +69 -0
- package/web/assets/jsonish-iCEt12Ty.js +1 -0
- package/web/assets/theme-DzMGF9VA.js +1 -0
- package/web/assets/{useResetOn-BEUZVwM5.js → useResetOn-Bvmnyxvw.js} +1 -1
- package/web/index.html +2 -2
- package/web/assets/AboutView-BExwxt7F.js +0 -1
- package/web/assets/FileView-hDF8bAaa.js +0 -1
- package/web/assets/SecurityView-DPRI6HpG.js +0 -1
- package/web/assets/SessionView-eGmw43Bq.js +0 -15
- package/web/assets/SkillsView-DUrXsvh_.js +0 -1
- package/web/assets/index-B6dWnwqZ.css +0 -1
- package/web/assets/index-CMT9aRT7.js +0 -69
- package/web/assets/jsonish-DI8SpR-J.js +0 -1
- package/web/assets/theme-DiOdnv26.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{J as c,p as h,j as e,D as o,L as r,w as n}from"./index-DYCDqLKI.js";import{relPath as p,LinesDelta as m}from"./FilesView-38qLTWbj.js";function v(){const[i]=c(),l=i.get("path")??"",a=i.get("project")??"",t=new URLSearchParams({path:l});a&&t.set("project",a);const s=h(l?"/file?"+t.toString():null);return e.jsx(o,{state:s,empty:e.jsx("div",{className:"muted pad",children:"Not found."}),children:d=>e.jsx(j,{data:d})})}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:["📄 ",p(i.file_path,i.project_path)]}),e.jsxs("div",{className:"skill-head-meta muted",children:[e.jsx("span",{"data-tip":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:[n(i.first_ts)," · ",n(i.last_ts)]})]})]}),i.sessions.map(l=>{var t;const a=(t=l.changes.find(s=>s.event_uuid))==null?void 0:t.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","data-tip":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})," ",n(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","data-tip":"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(m,{added:s.lines_added,removed:s.lines_removed})}),e.jsx("td",{className:"muted","data-tip":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:n(s.timestamp)})]},s.id))})]})]},l.session_id)}),e.jsx("p",{className:"muted pad",children:"Tracked from Edit/Write tool calls plus unambiguous shell writes (heredoc, tee, sed -i, redirects) — other shell changes and edits made outside sessions aren’t captured."})]})}export{v as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as E,k as x,r as F,
|
|
1
|
+
import{i as E,k as x,r as F,p as C,j as e,H as P,E as k,n as D,I as n,L as I,w as K,P as $}from"./index-DYCDqLKI.js";const i=50,M={total:0,files:[]};function w(t,a){return a&&t.startsWith(a.replace(/\/$/,"")+"/")?t.slice(a.replace(/\/$/,"").length+1):t}function A({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}=E(["offset"]),f=x("/sources",[]),b=x("/projects",[]),[h,u]=F.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 r=t("sort","last_ts"),l=t("dir")==="asc"?"asc":"desc";function c(s,q){a({sort:s,dir:r===s?l==="asc"?"desc":"asc":q})}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:r,dir:l,onSort:c,defaultDir:"asc"}),e.jsx("th",{children:"Project"}),e.jsx(n,{label:"Sessions",sortKey:"sessions",active:r,dir:l,onSort:c,className:"num"}),e.jsx(n,{label:"Changes",sortKey:"changes",active:r,dir:l,onSort:c,className:"num"}),e.jsx("th",{className:"num",children:"+ / −"}),e.jsx(n,{label:"Last touched",sortKey:"last_ts",active:r,dir:l,onSort:c})]})}),e.jsx("tbody",{children:m.map(s=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx(I,{to:`/file?path=${encodeURIComponent(s.file_path)}${s.project_id?`&project=${encodeURIComponent(s.project_id)}`:""}`,className:"title","data-tip":s.file_path,children:w(s.file_path,s.project_path)})}),e.jsx("td",{children:s.project_path?e.jsx("span",{className:"tag","data-tip":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(A,{added:s.lines_added,removed:s.lines_removed})}),e.jsx("td",{children:K(s.last_ts)})]},(s.project_id??"")+"\0"+s.file_path))})]}),!j&&d>0&&e.jsx($,{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 plus unambiguous shell writes (heredoc, tee, sed -i, redirects) — other shell changes and edits made outside sessions aren’t captured."})]})}export{A as LinesDelta,G as default,w as relPath};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as ie,k as E,r as k,F as ae,p as ne,j as e,S as h,H as le,K as x,E as re,n as ce,I as $,P as oe,w as de,L as ue}from"./index-DYCDqLKI.js";import{u as I,S as he,a as pe}from"./useResetOn-Bvmnyxvw.js";const P=50,me={total:0,findings:[]},je=new Set;function ke(){const{get:t,set:a,clear:l}=ie(),n=E("/sources",[]),M=E("/projects",[]),[p,f]=k.useState(!1),[m,B]=k.useState(0),{sort:r,toggle:S}=ae("severity","desc"),y=t("severity"),b=t("category"),v=t("rule"),_=t("session"),R=t("source"),F=t("project"),T=t("from"),A=t("to"),d=t("status","open"),w=k.useMemo(()=>{const s=new URLSearchParams;for(const[c,u]of Object.entries({severity:y,category:b,rule:v,session:_,source:R,project:F,from:T,to:A,status:d}))u&&s.set(c,u);return s},[y,b,v,_,R,F,T,A,d]),i=E("/security/summary",null,[m]),W=E(h?null:"/security/mutes",[],[m]),L=`${w.toString()}|${r.key}|${r.dir}`,[C,G]=I(L,1),[o,O]=I(`${L}|${C}|${m}`,je),N=new URLSearchParams(w);N.set("sort",r.key),N.set("dir",r.dir),N.set("limit",String(P)),N.set("offset",String((C-1)*P));const{data:V,loading:D,error:Y}=ne("/security/findings?"+N.toString(),{deps:[m]}),[q,H]=I(`${L}|${C}|${m}`,null),J=q??Y,{total:j,findings:K}=V??me,g=k.useCallback(async s=>{f(!0),H(null);try{await s(),B(c=>c+1)}catch(c){H(String(c))}finally{f(!1)}},[]),X=k.useMemo(()=>new Map(((i==null?void 0:i.by_severity)??[]).map(s=>[s.severity,s.n])),[i]),Q=k.useMemo(()=>((i==null?void 0:i.by_rule)??[]).filter(s=>!b||s.category===b),[i,b]),Z=Math.max(1,Math.ceil(j/P)),ee=[...w.keys()].some(s=>s!=="status")||d!=="open",z=K.map(s=>s.id),se=z.length>0&&z.every(s=>o.has(s)),te=s=>O(c=>{const u=new Set(c);return u.has(s)?u.delete(s):u.add(s),u});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."]})]}),h&&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"+(y?"":" is-active"),onClick:()=>a({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+(y===s?" is-active":""),onClick:()=>a({severity:y===s?"":s}),"aria-pressed":y===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:()=>a({status:"dismissed",severity:""}),children:[i.dismissed," dismissed"]})," · ",e.jsxs("button",{type:"button",className:"linkish",onClick:()=>a({status:"muted",severity:""}),children:[i.muted," muted by rule"]})]}),e.jsxs("div",{className:"filters",children:[e.jsxs("select",{"aria-label":"Filter by status",value:d,onChange:s=>a({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:b,onChange:s=>{const c=s.target.value,u=!v||Q.some(U=>U.rule_id===v&&(!c||U.category===c));a({category:c,rule:u?v:""})},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:v,onChange:s=>a({rule:s.target.value}),children:[e.jsx("option",{value:"",children:"all rules"}),Q.map(s=>e.jsxs("option",{value:s.rule_id,children:[s.rule_id," (",s.n,")"]},s.rule_id))]}),e.jsxs("select",{"aria-label":"Filter by source",value:R,onChange:s=>a({source:s.target.value}),children:[e.jsx("option",{value:"",children:"all sources"}),n.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=>a({project:s}),options:[{value:"",label:"all projects"},...M.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=>a({from:s.target.value})})]}),e.jsxs("label",{className:"ctl",children:["to ",e.jsx("input",{type:"date",value:A,onChange:s=>a({to:s.target.value})})]}),_&&e.jsxs("span",{className:"tag filter-chip",children:["session ",_.slice(0,8),"… ",e.jsx("button",{type:"button",className:"linkish",onClick:()=>a({session:""}),children:"✕"})]}),ee&&e.jsx("button",{type:"button",className:"ghost",onClick:l,children:"clear filters"})]}),!h&&(o.size>0||d==="open"&&j>0)&&e.jsxs("div",{className:"triage-bar",role:"group","aria-label":"Triage actions",children:[o.size>0&&d!=="dismissed"&&e.jsxs("button",{type:"button",disabled:p,onClick:()=>g(()=>x("/security/dismiss",{ids:[...o]})),children:["✓ Mark ",o.size," safe"]}),o.size>0&&d==="dismissed"&&e.jsxs("button",{type:"button",disabled:p,onClick:()=>g(()=>x("/security/reopen",{ids:[...o]})),children:["↩ Reopen ",o.size]}),o.size>0&&e.jsx("button",{type:"button",className:"ghost",onClick:()=>O(new Set),children:"clear selection"}),d==="open"&&j>0&&e.jsxs("button",{type:"button",className:"ghost",disabled:p,onClick:()=>{confirm(`Dismiss all ${j} open findings matching the current filter as safe?`)&&g(()=>x("/security/dismiss-matching",{filter:Object.fromEntries(w)}))},"data-tip":"Mark every open finding matching the current filter as safe",children:["Dismiss all ",j," matching"]})]}),e.jsx(re,{error:J}),D?e.jsx(ce,{}):K.length===0?e.jsx("div",{className:"muted pad",role:"status",children:i&&i.total===0&&d==="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:[!h&&e.jsx("th",{className:"check-col",children:e.jsx("input",{type:"checkbox","aria-label":"Select all on this page",checked:se,onChange:s=>O(s.target.checked?new Set(z):new Set)})}),e.jsx($,{label:"Severity",sortKey:"severity",active:r.key,dir:r.dir,onSort:S}),e.jsx("th",{children:"Finding"}),e.jsx($,{label:"Category",sortKey:"category",active:r.key,dir:r.dir,onSort:S}),e.jsx("th",{children:"Evidence"}),e.jsx($,{label:"When",sortKey:"time",active:r.key,dir:r.dir,onSort:S}),e.jsx($,{label:"Session",sortKey:"session",active:r.key,dir:r.dir,onSort:S}),!h&&e.jsx("th",{children:"Actions"})]})}),e.jsx("tbody",{children:K.map(s=>e.jsx(ge,{f:s,selected:o.has(s.id),onToggle:()=>te(s.id),busy:p,onDismiss:()=>g(()=>x("/security/dismiss",{ids:[s.id]})),onReopen:()=>g(()=>x("/security/reopen",{ids:[s.id]})),onMute:()=>g(()=>x("/security/mute",{rule_id:s.rule_id,scope:"global"}))},s.id))})]}),!D&&j>P&&e.jsx(oe,{page:C,pages:Z,total:j,unit:"findings",onPage:G}),!h&&W.length>0&&e.jsx(xe,{mutes:W,busy:p,onUnmute:s=>g(()=>x("/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:a,onToggle:l,busy:n,onDismiss:M,onReopen:p,onMute:f}){const m=`/session/${t.session_id}${t.event_uuid?`#ev-${t.event_uuid}`:""}`;return e.jsxs("tr",{className:t.dismissed?"is-dismissed":"",children:[!h&&e.jsx("td",{className:"check-col",children:e.jsx("input",{type:"checkbox","aria-label":"Select finding",checked:a,onChange:l})}),e.jsxs("td",{children:[e.jsx(pe,{severity:t.severity}),t.dismissed?e.jsx("span",{className:"tag dismissed","data-tip":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","data-tip":"Tool the finding fired on",children:t.tool_name}),e.jsx("code",{"data-tip":t.evidence??"",children:t.evidence})]}),e.jsx("td",{className:"small muted","data-tip":t.started_at??"",children:de(t.started_at??null)}),e.jsxs("td",{className:"small",children:[e.jsx(ue,{to:m,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(/^.*\//,"")})]}),!h&&e.jsxs("td",{className:"finding-actions small",children:[t.dismissed?e.jsx("button",{type:"button",className:"linkish",disabled:n,onClick:p,children:"reopen"}):e.jsx("button",{type:"button",className:"linkish",disabled:n,onClick:M,children:"safe"}),e.jsx("button",{type:"button",className:"linkish",disabled:n,onClick:f,"data-tip":`Mute rule ${t.rule_id} everywhere`,children:"mute rule"})]})]})}function xe({mutes:t,busy:a,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(n=>e.jsxs("li",{children:[e.jsx("code",{children:n.rule_id}),e.jsxs("span",{className:"tag mute-scope",children:[n.scope,n.scope_id?`: ${n.scope_id}`:""]}),n.note&&e.jsx("span",{className:"muted small mute-note",children:n.note}),e.jsx("button",{type:"button",className:"linkish unmute",disabled:a,onClick:()=>l(n),children:"unmute"})]},`${n.rule_id}:${n.scope}:${n.scope_id}`))})]})}function ye({summary:t}){const a=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:n=>n.stopPropagation(),children:[l.framework_ref," ↗"]}),e.jsxs("span",{className:"muted small",children:[a.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};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import{S as Ts,j as s,p as ns,d as Es,q as ye,r as u,L as W,f as oe,t as as,a as Is,v as Os,b as Z,w as ls,s as As,x as Ee,e as ke,h as be,l as $s,y as Rs,z as Ds,i as Fs,E as Ls,n as Ps,A as Be}from"./index-DYCDqLKI.js";import{C as J,A as Me,p as X}from"./jsonish-iCEt12Ty.js";import{S as _e,a as rs,u as qs}from"./useResetOn-Bvmnyxvw.js";import{M as Bs,r as Hs}from"./index-C5nCASCF.js";import{u as Us}from"./theme-DzMGF9VA.js";function Ks({id:e}){return Ts?null:s.jsx(Gs,{id:e})}function Gs({id:e}){const{data:t}=ns("/sessions/"+e+"/location",{reset:!0});return t?s.jsx(J,{text:t.path,className:"copy-archive-path",label:"Copy archive path",title:"Copy archive path",tip:`Copies the path to this session's full raw trace, the archived .jsonl transcript with every event verbatim, so you can point another agent on this machine straight at it.
|
|
2
|
+
|
|
3
|
+
`+t.path+(t.exists?"":`
|
|
4
|
+
|
|
5
|
+
(that file is no longer on disk — retention has pruned it)`)}):null}function Ws({id:e}){const t=Es();return s.jsxs("details",{className:"export-menu col-customizer",ref:t,children:[s.jsx("summary",{className:"export","data-tip":"Download this session as a Markdown transcript, redacted by default, with a structure-only scrub and a verbatim option.",children:"⬇ Export Markdown"}),s.jsxs("div",{className:"col-menu",role:"group","aria-label":"Export options",children:[s.jsxs("a",{href:ye(e),download:!0,children:["Redacted ",s.jsx("span",{className:"muted small",children:"(secrets masked)"})]}),s.jsxs("a",{href:ye(e,"structure"),download:!0,children:["Structure only ",s.jsx("span",{className:"muted small",children:"(scrubbed)"})]}),s.jsxs("a",{className:"export-verbatim",href:ye(e,"off"),download:!0,children:["Verbatim ",s.jsx("span",{className:"muted small",children:"(unredacted)"})]})]})]})}function Js({c:e}){var c;const[t,n]=u.useState(!1),a=u.useId(),l=(c=e.signals)==null?void 0:c.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":t,"aria-controls":a,onClick:()=>n(r=>!r),children:["why ",t?"▾":"▸"]}),t&&(e.signals?s.jsx(Qs,{id:a,s:e.signals,category:e.category}):s.jsx("div",{id:a,className:"muted small pad",children:"No signals recorded for this session."}))]})}const Vs={loc:"Lines changed",files:"Files touched",turns:"Turns",tokens:"Work tokens",duration:"Duration",subagents:"Subagents"},He=e=>`${Math.max(0,Math.min(1,e))*100}%`;function Ue({counts:e}){const t=Object.entries(e).sort((n,a)=>a[1]-n[1]);return t.length===0?s.jsx("span",{className:"muted",children:"—"}):s.jsx("span",{className:"sig-chips",children:t.map(([n,a])=>s.jsxs("span",{className:"sig-chip",children:[n," ",s.jsxs("span",{className:"muted",children:["×",a]})]},n))})}function Qs({id:e,s:t,category:n}){const[a,l]=u.useState(!1),c=u.useId(),r=t.complexity_weights??{},i=t.complexity_subscores??{},h=Object.keys(r).map(x=>({key:x,weight:r[x],subscore:i[x]??0,pts:r[x]*(i[x]??0)*100})).sort((x,S)=>S.pts-x.pts),p=Math.max(...h.map(x=>x.pts),1e-4),f=Object.entries(t.category_scores??{}).map(([x,S])=>({k:x,v:S})).sort((x,S)=>S.v-x.v),g=Math.max(...f.map(x=>x.v),1e-4),j=f.filter(x=>x.v>.02||x.k===n),E=t.skills&&Object.keys(t.skills).length>0;return s.jsxs("div",{id:e,className:"signals-panel",children:[h.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:h.map(x=>s.jsxs("li",{className:"sig-bar-row",children:[s.jsx("span",{className:"sig-bar-label",children:Vs[x.key]??x.key}),s.jsx("span",{className:"sig-bar","aria-hidden":"true",children:s.jsx("span",{className:"sig-bar-fill",style:{width:He(x.pts/p)}})}),s.jsxs("span",{className:"sig-bar-val",children:[x.pts.toFixed(1)," pts"]}),s.jsxs("span",{className:"sig-bar-sub muted",children:[Math.round(x.subscore*100),"% intensity · weight ",Math.round(x.weight*100),"%"]})]},x.key))})]}),j.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 “",n,"” won"]})]}),s.jsx("ul",{className:"sig-bars",children:j.map(x=>s.jsxs("li",{className:"sig-bar-row"+(x.k===n?" is-win":""),children:[s.jsx("span",{className:"sig-bar-label",children:x.k}),s.jsx("span",{className:"sig-bar","aria-hidden":"true",children:s.jsx("span",{className:"sig-bar-fill",style:{width:He(x.v/g)}})}),s.jsx("span",{className:"sig-bar-val",children:x.v.toFixed(2)})]},x.k))})]}),s.jsxs("section",{className:"sig-section",children:[s.jsx("h4",{className:"sig-h",children:"Evidence"}),s.jsxs("dl",{className:"sig-grid",children:[t.tool_counts&&s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:"Tools"}),s.jsx("dd",{children:s.jsx(Ue,{counts:t.tool_counts})})]}),E&&s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:"Skills"}),s.jsx("dd",{children:s.jsx(Ue,{counts:t.skills})})]}),t.subagent_role&&s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:"Subagent role"}),s.jsx("dd",{children:t.subagent_role})]}),t.files&&t.files.length>0&&s.jsxs(s.Fragment,{children:[s.jsxs("dt",{children:["Files (",t.files.length,")"]}),s.jsx("dd",{className:"sig-files",children:t.files.join(", ")})]})]})]}),s.jsx("button",{className:"ghost small","aria-expanded":a,"aria-controls":c,onClick:()=>l(x=>!x),children:a?"Hide raw JSON ▴":"View raw JSON ▾"}),a&&s.jsx("pre",{id:c,className:"code signals",children:JSON.stringify(t,null,2)})]})}function Xs({f:e}){var r;const[t,n]=u.useState(!1),a=u.useId(),l=((r=e.signals)==null?void 0:r.modifiers)??{},c=Object.keys(l).filter(i=>l[i]!==!1&&l[i]!=null&&l[i]!=="");return s.jsxs("div",{className:"finding sev-border-"+e.severity,children:[s.jsxs("button",{className:"finding-head","aria-expanded":t,"aria-controls":a,onClick:()=>n(i=>!i),children:[s.jsx(rs,{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:t?"▾":"▸"})]}),t&&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}),c.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:"Context"}),s.jsx("dd",{children:c.map(i=>s.jsxs("span",{className:"sig-chip",children:[i,l[i]!==!0?s.jsxs("span",{className:"muted",children:[" ",String(l[i])]}):null]},i))})]})]}),s.jsxs(W,{className:"subagent-link small",to:`/security?rule=${encodeURIComponent(e.rule_id)}`,children:["see all “",e.rule_id,"” findings →"]})]})]})}function zs({findings:e}){if(!e.length)return null;const t=[...e].sort((n,a)=>_e.indexOf(n.severity)-_e.indexOf(a.severity));return s.jsx("div",{className:"tool-findings",children:t.map(n=>s.jsx(Xs,{f:n},n.id))})}function Ys({findings:e,sessionId:t}){const n=new Map;for(const l of e)n.set(l.severity,(n.get(l.severity)??0)+1);const a=_e.find(l=>n.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:_e.filter(l=>n.has(l)).map(l=>s.jsx(rs,{severity:l,count:n.get(l)},l))}),s.jsx(W,{className:"subagent-link small",to:`/security?session=${encodeURIComponent(t)}`,children:"view on Security page →"})]})}function Zs(e){const t={dirs:new Map,files:[]};for(const a of e){const l=a.display.startsWith("/"),c=(l?a.display.slice(1):a.display).split("/");l&&c.length>0&&(c[0]="/"+c[0]);let r=t;for(const i of c.slice(0,-1))r=r.dirs.get(i)??r.dirs.set(i,{dirs:new Map,files:[]}).get(i);r.files.push({name:c[c.length-1],path:a.path,list:a.list})}const n=a=>{for(const[l,c]of[...a.dirs.entries()])if(n(c),c.files.length===0&&c.dirs.size===1){const[r,i]=[...c.dirs.entries()][0];a.dirs.delete(l),a.dirs.set(l+"/"+r,i)}};return n(t),t}function is({node:e,depth:t}){const n={paddingLeft:`${.4+t*1.1}rem`};return s.jsxs(s.Fragment,{children:[[...e.dirs.entries()].sort(([a],[l])=>a.localeCompare(l)).map(([a,l])=>s.jsxs(u.Fragment,{children:[s.jsx("tr",{children:s.jsx("td",{colSpan:3,style:n,children:s.jsxs("span",{className:"muted",children:["📁 ",a,"/"]})})}),s.jsx(is,{node:l,depth:t+1})]},a)),[...e.files].sort((a,l)=>a.name.localeCompare(l.name)).map(a=>{const l=a.list.find(i=>i.event_uuid),c=a.list.reduce((i,h)=>i+(h.lines_added??0),0),r=a.list.reduce((i,h)=>i+(h.lines_removed??0),0);return s.jsxs("tr",{children:[s.jsx("td",{style:n,children:l!=null&&l.event_uuid?s.jsx("a",{href:`#ev-${l.event_uuid}`,className:"title","data-tip":a.path+" — jump to the first change",children:a.name}):s.jsx("span",{"data-tip":a.path,children:a.name})}),s.jsxs("td",{className:"num",children:[a.list.length,"× ",s.jsxs("span",{className:"muted",children:["(+",c," −",r,")"]})]}),s.jsx("td",{children:s.jsx(W,{className:"subagent-link small",to:`/file?path=${encodeURIComponent(a.path)}`,children:"history →"})})]},a.path)})]})}const Ke=7,Se=4;function et({changes:e,projectPath:t}){const n=new Map;for(const r of e)(n.get(r.file_path)??n.set(r.file_path,[]).get(r.file_path)).push(r);const a=r=>t&&r.startsWith(t.replace(/\/$/,"")+"/")?r.slice(t.replace(/\/$/,"").length+1):r,l=Zs([...n.entries()].map(([r,i])=>({display:a(r),path:r,list:i}))),c=[...n.entries()].filter(([,r])=>r.length>=Ke).sort((r,i)=>i[1].length-r[1].length);return s.jsxs("details",{className:"wf-run files-changed",children:[s.jsxs("summary",{children:["📄 ",n.size," ",n.size===1?"file":"files"," changed · ",e.length," ",e.length===1?"edit":"edits",c.length>0&&s.jsxs("span",{className:"muted",children:[" · ",c.length," edited ",Ke,"+ times"]})]}),c.length>0&&s.jsxs("p",{className:"muted files-rework",children:["Most reworked:"," ",c.slice(0,Se).map(([r,i],h)=>s.jsxs(u.Fragment,{children:[h>0&&", ",s.jsxs("span",{"data-tip":r,children:[a(r).split("/").pop()," (",i.length,"×)"]})]},r)),c.length>Se&&`, and ${c.length-Se} more`]}),s.jsx("table",{className:"sessions",children:s.jsx("tbody",{children:s.jsx(is,{node:l,depth:0})})})]})}function st({d:e}){var n;const t=e.session;return s.jsxs("div",{className:"detail-head",children:[s.jsx(W,{to:"/",className:"back",children:"← all sessions"}),s.jsx("h1",{children:t.title||t.id.slice(0,12)}),s.jsxs("div",{className:"detail-meta",children:[s.jsx("span",{children:s.jsx("b",{children:t.source_id})}),s.jsx("span",{className:"path",children:t.project_path}),t.is_sidechain?s.jsx("span",{className:"tag subagent",children:"subagent"}):null,e.parent&&s.jsxs("span",{className:"spawned-by",children:["↖ spawned by"," ",s.jsx(W,{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:[t.event_count," events"]}),s.jsxs("span",{"data-tip":as(t.token_split),children:[oe(t.tokens)," tok"]}),s.jsxs("span",{"data-tip":Os(t.unpriced_models),children:[Is(t.cost),(n=t.unpriced_models)!=null&&n.length?s.jsx("span",{className:"warn-tag",children:" ⚠"}):null]}),t.tool_call_count>0&&s.jsxs("span",{className:t.tool_failure_count>0?"tool-err-stat":"muted","data-tip":"Tool calls that returned is_error, of "+t.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:[t.tool_failure_count," failed",t.tool_rejection_count>0?` · ${t.tool_rejection_count} declined/blocked`:"",` of ${t.tool_call_count} tool calls`]}),s.jsx("span",{children:Z(t.duration_ms)}),s.jsx("span",{className:"muted",children:ls(t.started_at)}),s.jsx(Ks,{id:t.id}),s.jsx(Ws,{id:t.id})]}),e.classification&&s.jsx(Js,{c:e.classification}),e.findings&&e.findings.length>0&&s.jsx(Ys,{findings:e.findings,sessionId:t.id}),e.file_changes&&e.file_changes.length>0&&s.jsx(et,{changes:e.file_changes,projectPath:t.project_path??null})]})}function tt({search:e,turnCount:t,anyOpen:n,onToggleAll:a,hideTools:l,onToggleHideTools:c,format:r,onChooseFormat:i}){return s.jsxs(s.Fragment,{children:[e,s.jsxs("div",{className:"transcript-tools",children:[t>1&&s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"muted small",children:[t," turns"]}),s.jsx("button",{className:"ghost small",onClick:a,children:n?"Collapse all":"Expand all"})]}),s.jsxs("button",{className:"ghost small"+(l?" is-active":""),"aria-pressed":l,onClick:c,"data-tip":"Hide Bash/Edit/Skill and other tool calls — show only assistant answers, plans and questions",children:[l?"☑ ":"☐ ","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"})]})]})]})}const me=2,nt={hits:[],byTurn:new Map,total:0};function os(e){var t;return[e.input_json,e.result_summary,(t=e.full_result)==null?void 0:t.text].filter(Boolean).join(`
|
|
6
|
+
`)}function cs(e){const t=[];e.text&&t.push(e.text),e.thinking&&t.push(e.thinking);for(const n of e.toolCalls)t.push(os(n));return t.join(`
|
|
7
|
+
`).toLowerCase()}function at(e){return new Map(e.map(t=>[t.uuid,cs(t)]))}function lt(e,t){let n=0;for(let a=e.indexOf(t);a!==-1;a=e.indexOf(t,a+t.length))n++;return n}function rt(e,t,n){const a=n.trim().toLowerCase();if(a.length<me)return nt;const l=[],c=new Map;for(const r of e){const i=lt(t.get(r.uuid)??cs(r),a);i&&(l.push({uuid:r.uuid,turnId:r.turn_id??null,count:i}),r.turn_id&&c.set(r.turn_id,(c.get(r.turn_id)??0)+1))}return{hits:l,byTurn:c,total:l.length}}function it(e,t){return Ae(os(e),t)}function Ae(e,t){const n=t.trim().toLowerCase();return!e||n.length<me?!1:e.toLowerCase().includes(n)}function ds(e,t,n){return a=>{if(a.key==="Escape"){a.preventDefault(),n();return}if(a.key==="Enter"){if(a.shiftKey){a.preventDefault(),e();return}a.target.tagName!=="BUTTON"&&(a.preventDefault(),t())}}}function ot({query:e,total:t,index:n,onPrev:a,onNext:l,onClear:c,onBackToBox:r}){return s.jsxs("div",{className:"search-nav",role:"group","aria-label":"Search matches",tabIndex:-1,onKeyDown:ds(a,l,c),children:[s.jsx("button",{type:"button",className:"ghost small sn-back","aria-label":"Back to the search box",onClick:r,children:"🔍"}),s.jsxs("span",{className:"sn-term",children:[s.jsx("span",{className:"sn-q",children:e}),s.jsxs("span",{className:"sn-pos",children:[n+1,"/",t]})]}),s.jsx("button",{type:"button",className:"ghost small","aria-label":"Previous match",onClick:a,children:"◂"}),s.jsx("button",{type:"button",className:"ghost small","aria-label":"Next match",onClick:l,children:"▸"}),s.jsx("button",{type:"button",className:"ghost small","aria-label":"Clear search",onClick:c,children:"✕"})]})}const ct=150;function dt({query:e,onQuery:t,total:n,index:a,onPrev:l,onNext:c,inputRef:r}){const[i,h]=u.useState(e),p=u.useRef(0),f=u.useRef(null),[g,j]=u.useState(!0);u.useEffect(()=>{const b=f.current;if(!b||typeof IntersectionObserver>"u")return;const C=new IntersectionObserver(([D])=>j(D.isIntersecting));return C.observe(b),()=>C.disconnect()},[]);const E=u.useRef(e);E.current!==e&&(E.current=e,h(e)),u.useEffect(()=>()=>window.clearTimeout(p.current),[]);const x=b=>{h(b),window.clearTimeout(p.current),p.current=window.setTimeout(()=>t(b),ct)},S=()=>{var b;window.clearTimeout(p.current),h(""),t(""),(b=r.current)==null||b.focus()},I=i.trim().length>=me;return s.jsxs(s.Fragment,{children:[s.jsxs("form",{ref:f,className:"transcript-search",role:"search",onSubmit:b=>b.preventDefault(),onKeyDown:ds(l,c,S),children:[s.jsx("span",{className:"ts-icon","aria-hidden":"true",children:"🔍"}),s.jsx("input",{ref:r,type:"search","aria-label":"Find in this session",placeholder:"Find in session…",value:i,onChange:b=>x(b.target.value)}),s.jsx("span",{className:"ts-count muted small",role:"status","aria-live":"polite",children:I?n===0?"No matches":`${a+1} of ${n} message${n===1?"":"s"}`:""}),s.jsx("button",{type:"button",className:"ghost small","aria-label":"Previous match",disabled:n===0,onClick:l,children:"◂"}),s.jsx("button",{type:"button",className:"ghost small","aria-label":"Next match",disabled:n===0,onClick:c,children:"▸"}),i&&s.jsx("button",{type:"button",className:"ghost small","aria-label":"Clear search",onClick:S,children:"✕"})]}),n>0&&!g&&s.jsx(ot,{query:e,total:n,index:a,onPrev:l,onNext:c,onClear:S,onBackToBox:()=>{var b;return(b=r.current)==null?void 0:b.focus()}})]})}function ut({d:e}){const t=e.workflow_runs??[],n=e.children.filter(l=>!l.workflow_run_id),a=t.length>0;return s.jsxs("div",{className:"subagents",children:[s.jsxs("h2",{children:["Spawned subagents (",e.children.length,")"]}),t.map(l=>{const c=e.children.filter(r=>r.workflow_run_id===l.run_id);return s.jsxs("details",{className:"wf-run",children:[s.jsxs("summary",{children:[s.jsxs(W,{className:"wf-run-name",to:`/workflow/${l.run_id}`,onClick:r=>r.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:[c.length," agent",c.length===1?"":"s",l.turn_seq!=null?` · turn ${l.turn_seq+1}`:""," · ",s.jsx("code",{children:l.run_id})]})]}),s.jsx("ul",{children:c.map(r=>s.jsx(Me,{a:r},r.id))})]},l.run_id)}),n.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:[n.length," subagent",n.length===1?"":"s"]})]}),s.jsx("ul",{children:n.map(l=>s.jsx(Me,{a:l},l.id))})]}):s.jsx("ul",{children:n.map(l=>s.jsx(Me,{a:l},l.id))}))]})}const ht="command-name",mt="command-args",pt="local-command-caveat",ft=["local-command-stdout","local-command-stderr","command-output"],xt="task-notification",gt="task-id",jt="tool-use-id",Nt="status",wt="summary",Ge=ft.join("|");function ce(e,t){var n,a;return((a=(n=e.match(new RegExp(`<${t}>([\\s\\S]*?)</${t}>`)))==null?void 0:n[1])==null?void 0:a.trim())??null}function kt(e){var t,n;return((n=(t=e.match(new RegExp(`<(?:${Ge})>([\\s\\S]*?)</(?:${Ge})>`)))==null?void 0:t[1])==null?void 0:n.trim())??null}function We(e,t){const n=e===""?[]:e.split(`
|
|
8
|
+
`),a=t===""?[]:t.split(`
|
|
9
|
+
`),l=n.length,c=a.length;if(l*c>25e4)return[...n.map(f=>({type:"del",text:f})),...a.map(f=>({type:"add",text:f}))];const r=Array.from({length:l+1},()=>new Array(c+1).fill(0));for(let f=l-1;f>=0;f--)for(let g=c-1;g>=0;g--)r[f][g]=n[f]===a[g]?r[f+1][g+1]+1:Math.max(r[f+1][g],r[f][g+1]);const i=[];let h=0,p=0;for(;h<l&&p<c;)n[h]===a[p]?(i.push({type:"ctx",text:n[h]}),h++,p++):r[h+1][p]>=r[h][p+1]?(i.push({type:"del",text:n[h]}),h++):(i.push({type:"add",text:a[p]}),p++);for(;h<l;)i.push({type:"del",text:n[h++]});for(;p<c;)i.push({type:"add",text:a[p++]});return i}function us(e){if(!e)return null;try{const t=JSON.parse(e).plan;return typeof t=="string"&&t.trim()?t:null}catch{return null}}function _t(e){if(!e)return[];try{const t=JSON.parse(e).questions;return Array.isArray(t)?t:[]}catch{return[]}}function bt(e){if(!e)return{answers:{},annotations:{}};try{const t=JSON.parse(e);if(t&&typeof t=="object"&&t.answers)return{answers:t.answers,annotations:t.annotations??{}}}catch{}return{answers:{},annotations:{}}}function vt(e){if(!e)return null;try{const t=JSON.parse(e);if(!t||typeof t!="object")return null;const n=typeof t.command=="string"?t.command:"";return n.trim()?{command:n,description:typeof t.description=="string"?t.description:void 0,timeout:typeof t.timeout=="number"?t.timeout:void 0,run_in_background:t.run_in_background===!0,restart:t.restart===!0}:null}catch{return null}}function yt(e,t){if(!t)return null;try{const n=JSON.parse(t);if(!n||typeof n!="object"||typeof n.file_path!="string")return null;let a;if(e==="Write"){if(typeof n.content!="string")return null;a=[n.content===""?[]:n.content.split(`
|
|
10
|
+
`).map(r=>({type:"add",text:r}))]}else if(e==="MultiEdit"){if(!Array.isArray(n.edits)||(a=n.edits.filter(r=>{const i=r;return!!i&&typeof i.old_string=="string"&&typeof i.new_string=="string"}).map(r=>We(r.old_string,r.new_string)),a.length===0))return null}else{if(typeof n.old_string!="string"||typeof n.new_string!="string")return null;a=[We(n.old_string,n.new_string)]}let l=0,c=0;for(const r of a)for(const i of r)i.type==="add"?l++:i.type==="del"&&c++;return{file_path:n.file_path,kind:e,hunks:a,adds:l,dels:c}}catch{return null}}function Mt(e){const t=e.lastIndexOf("/");return t>=0?{dir:e.slice(0,t+1),base:e.slice(t+1)}:{dir:"",base:e}}function hs(e){const t=ce(e,ht);if(t){const a=ce(e,mt)??"";return{kind:"invocation",name:t.startsWith("/")?t:`/${t}`,args:a}}const n=kt(e);return n!=null?{kind:"output",stdout:n}:e.includes(`<${pt}>`)?{kind:"caveat"}:null}function ms(e){return e.includes(`<${xt}>`)?{taskId:ce(e,gt),toolUseId:ce(e,jt),status:ce(e,Nt),summary:ce(e,wt)}:null}function St(e){const t=hs(e);if((t==null?void 0:t.kind)==="invocation")return`⌘ ${t.name}${t.args?" "+t.args:""}`;if((t==null?void 0:t.kind)==="output")return"⌘ command output";if((t==null?void 0:t.kind)==="caveat")return"⌘ local command";const n=ms(e);return n?`🔔 task ${n.status??"notification"}`:e}const ps=u.createContext("markdown"),fs=u.createContext(new Map),xs=u.createContext(!1),gs=u.createContext(null),js=u.createContext(null),$e=u.createContext({query:"",activeUuid:null});function Ct({cmd:e}){return e.kind==="invocation"?s.jsxs("div",{className:"cmd",children:[s.jsxs("span",{className:"cmd-chip","data-tip":"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 Tt({n:e}){const t=u.useContext(fs),n=e.toolUseId?t.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]}),n&&s.jsx(W,{className:"subagent-link small",to:`/workflow/${n}`,children:"view workflow →"})]}),e.summary&&s.jsx("div",{className:"task-notif-summary",children:e.summary})]})}function Je({text:e,id:t}){return u.useContext(ps)==="raw"?s.jsx("div",{className:"text",id:t,children:e}):s.jsx("div",{className:"text md",id:t,children:s.jsx(Bs,{remarkPlugins:[Hs],components:Et,children:e})})}const Et={a:({node:e,...t})=>s.jsx("a",{...t,target:"_blank",rel:"noopener noreferrer"})};function Ns({text:e,uuid:t}){const n=e.length>1400||e.split(`
|
|
11
|
+
`).length>18,[a,l]=u.useState(!1),c=u.useContext($e),r=u.useId();if(!n)return s.jsx(Je,{text:e});const i=a||!!t&&c.activeUuid===t&&Ae(e,c.query);return s.jsxs("div",{className:"text-wrap"+(i?"":" is-clamped"),children:[s.jsx(Je,{text:e,id:r}),s.jsx("button",{className:"ghost small show-more","aria-expanded":i,"aria-controls":r,onClick:()=>l(!i),children:i?"Show less ▴":"Show more ▾"})]})}function ws({t:e}){const[t,n]=u.useState(!1),[a,l]=u.useState(!1),c=u.useId(),r=e.skill_name?`Skill · ${e.skill_name}`:e.tool_name==="Workflow"&&e.workflow_name?`Workflow · ${e.workflow_name}`:e.agent_type?`${e.tool_name} → ${e.agent_type}`:e.tool_name;return s.jsxs("div",{className:"tool "+(e.status==="error"?"tool-err":""),children:[s.jsxs("button",{className:"tool-head","aria-expanded":t,"aria-controls":c,onClick:()=>n(i=>!i),children:[s.jsxs("span",{className:"tool-name",children:["🔧 ",r]}),e.status&&s.jsx("span",{className:"tool-status",children:e.status}),e.total_duration_ms?s.jsx("span",{className:"muted",children:Z(e.total_duration_ms)}):null,s.jsx("span",{className:"chev",children:t?"▾":"▸"})]}),e.spawned_session_id&&s.jsx(W,{className:"subagent-link small",to:`/session/${e.spawned_session_id}`,children:"view subagent transcript →"}),e.workflow_run_id&&s.jsxs(W,{className:"subagent-link small",to:`/workflow/${e.workflow_run_id}`,children:["🔀 launched ",e.workflow_agent_count??0," agent",e.workflow_agent_count===1?"":"s"," · ",s.jsx("code",{children:e.workflow_run_id})," →"]}),e.skill_name&&s.jsxs(W,{className:"subagent-link small",to:`/skill/${encodeURIComponent(e.skill_name)}${e.skill_id?`?v=${e.skill_id}`:""}`,children:["📖 view skill",e.skill_id?" version":""," →"]}),t&&s.jsxs("div",{className:"tool-body",id:c,children:[e.input_json&&e.input_json!=="{}"&&s.jsxs("div",{className:"code-block",children:[s.jsx(J,{text:X(e.input_json),className:"copy-corner",title:"Copy tool input JSON"}),s.jsx("pre",{className:"code",children:X(e.input_json)})]}),e.result_summary&&s.jsx("div",{className:"result",children:e.result_summary}),e.full_result&&s.jsxs("div",{className:"full-result",children:[s.jsxs("button",{type:"button",className:"ghost small show-full","aria-expanded":a,onClick:()=>l(i=>!i),children:[a?"Hide":"Show"," full result (",(e.full_result.bytes/1024).toFixed(1)," KB)"]}),a&&s.jsxs("div",{className:"code-block",children:[s.jsx(J,{text:e.full_result.text,className:"copy-corner",title:"Copy full tool result"}),s.jsx("pre",{className:"code",children:e.full_result.text})]})]})]})]})}function It({plan:e}){return s.jsxs("div",{className:"plan-card",children:[s.jsx("div",{className:"plan-card-head",children:"📋 Approved plan"}),s.jsx(Ns,{text:e})]})}function Ot({t:e}){const[t,n]=u.useState(!1),a=u.useId(),l=_t(e.input_json),{answers:c,annotations:r}=bt(e.result_summary);return l.length===0?s.jsx(ws,{t:e}):s.jsxs("div",{className:"qa-card",children:[s.jsxs("div",{className:"qa-card-head",children:["🙋 Question",l.length===1?"":"s"," for the user"]}),l.map((i,h)=>{var S;const p=c[i.question],f=Array.isArray(p)?p:p!=null?[p]:[],g=new Set(f),j=new Set(i.options.map(I=>I.label)),E=f.filter(I=>!j.has(I)),x=(S=r[i.question])==null?void 0:S.notes;return s.jsxs("div",{className:"qa-q",children:[s.jsxs("div",{className:"qa-q-head",children:[i.header&&s.jsx("span",{className:"tag",children:i.header}),i.multiSelect&&s.jsx("span",{className:"muted small",children:"multi-select"})]}),s.jsx("div",{className:"qa-question",children:i.question}),s.jsxs("ul",{className:"qa-options",children:[i.options.map((I,b)=>{const C=g.has(I.label);return s.jsxs("li",{className:"qa-opt"+(C?" is-selected":""),children:[s.jsx("span",{className:"qa-mark","aria-hidden":"true",children:C?"☑":"☐"}),s.jsxs("span",{className:"qa-opt-body",children:[s.jsx("span",{className:"qa-opt-label",children:I.label}),I.description&&s.jsx("span",{className:"qa-opt-desc muted",children:I.description})]})]},b)}),E.map((I,b)=>s.jsxs("li",{className:"qa-opt is-selected",children:[s.jsx("span",{className:"qa-mark","aria-hidden":"true",children:"☑"}),s.jsxs("span",{className:"qa-opt-body",children:[s.jsx("span",{className:"qa-opt-label",children:I}),s.jsx("span",{className:"qa-opt-desc muted",children:"custom answer"})]})]},"c"+b))]}),x&&s.jsxs("div",{className:"qa-note",children:["📝 ",x]})]},h)}),s.jsxs("div",{className:"launch-actions",children:[s.jsx("button",{className:"ghost small","aria-expanded":t,"aria-controls":a,onClick:()=>n(i=>!i),children:t?"Hide raw JSON ▴":"View raw JSON ▾"}),s.jsx(J,{text:X(e.input_json??"{}")+(e.result_summary?`
|
|
12
|
+
|
|
13
|
+
`+X(e.result_summary):""),label:"JSON",title:"Copy raw question JSON"})]}),t&&s.jsxs("pre",{id:a,className:"code",children:[X(e.input_json??"{}"),e.result_summary?`
|
|
14
|
+
|
|
15
|
+
`+X(e.result_summary):""]})]})}function At({t:e}){const t=e.workflow_name?`Workflow · ${e.workflow_name}`:"Workflow";return s.jsxs("div",{className:"tool launch-tool",children:[s.jsxs("div",{className:"launch-tool-head",children:[s.jsxs("span",{className:"tool-name",children:["🔀 ",t]}),e.status&&s.jsx("span",{className:"tool-status",children:e.status})]}),e.workflow_run_id&&s.jsxs(W,{className:"subagent-link small",to:`/workflow/${e.workflow_run_id}`,children:["🔀 launched ",e.workflow_agent_count??0," agent",e.workflow_agent_count===1?"":"s"," · ",s.jsx("code",{children:e.workflow_run_id})," →"]}),e.result_summary&&s.jsx("div",{className:"result",children:e.result_summary})]})}function Ve(e,t,n){let a=t+2,l=!1;for(e[a]==="-"&&(l=!0,a++);e[a]===" "||e[a]===" ";)a++;let c="";(e[a]==="'"||e[a]==='"')&&(c=e[a],a++);let r="";if(c){for(;a<e.length&&e[a]!==c;)r+=e[a++];e[a]===c&&a++}else for(;a<e.length&&/[A-Za-z0-9_]/.test(e[a]);)r+=e[a++];return r&&n.push({delim:r,strip:l}),a-1}function $t(e){const t=e.split(`
|
|
16
|
+
`),n=[];let a="NORMAL",l=0;const c=[];let r=!1;for(const i of t){if(c.length>0){n.push({text:i,cont:!0});const h=c[0];(h.strip?i.replace(/^\t+/,""):i).trimEnd()===h.delim&&c.shift();continue}n.push({text:i,cont:a!=="NORMAL"||l>0||r}),r=!1;for(let h=0;h<i.length;h++){const p=i[h];if(a==="SQUOTE"){p==="'"&&(a="NORMAL");continue}if(a==="DQUOTE"){p==="\\"?h++:p==='"'?a="NORMAL":p==="$"&&i[h+1]==="("?(l++,h++):p===")"?l>0&&l--:p==="<"&&i[h+1]==="<"&&i[h+2]!=="<"&&i[h-1]!=="<"&&(h=Ve(i,h,c));continue}if(p==="\\")h++;else if(p==="'")a="SQUOTE";else if(p==='"')a="DQUOTE";else{if(p==="#"&&(h===0||/\s/.test(i[h-1])))break;p==="$"&&i[h+1]==="("?(l++,h++):p==="("?l++:p===")"?l>0&&l--:p==="<"&&i[h+1]==="<"&&i[h+2]!=="<"&&i[h-1]!=="<"&&(h=Ve(i,h,c))}}if(a==="NORMAL"&&l===0&&c.length===0){const h=i.replace(/\s+$/,""),p=h.match(/\\+$/);(p&&p[0].length%2===1||/(&&|\|\||\|)$/.test(h))&&(r=!0)}}return n}function Rt({t:e,bash:t}){const[n,a]=u.useState(!1),[l,c]=u.useState(!1),[r,i]=u.useState(!1),h=u.useId(),p=u.useId(),f=t.command.split(`
|
|
17
|
+
`)[0],g=$t(t.command);return s.jsxs("div",{className:"tool "+(e.status==="error"?"tool-err":""),children:[s.jsxs("button",{className:"tool-head","aria-expanded":n,"aria-controls":h,onClick:()=>a(j=>!j),children:[s.jsx("span",{className:"tool-name",children:"🖥 Bash"}),t.description?s.jsxs("span",{className:"bash-desc",children:["# ",t.description]}):!n&&s.jsx("span",{className:"bash-preview",children:f}),e.status&&s.jsx("span",{className:"tool-status",children:e.status}),e.total_duration_ms?s.jsx("span",{className:"muted",children:Z(e.total_duration_ms)}):null,s.jsx("span",{className:"chev",children:n?"▾":"▸"})]}),n&&s.jsxs("div",{className:"tool-body",id:h,children:[s.jsxs("div",{className:"shell code-block",children:[s.jsx(J,{text:t.command,className:"copy-corner",title:"Copy command"}),s.jsx("pre",{className:"shell-cmd",children:g.map((j,E)=>s.jsxs("span",{children:[s.jsx("span",{className:"shell-gutter"+(j.cont?" cont":""),"aria-hidden":"true",children:j.cont?" ":"$ "}),j.text,E<g.length-1?`
|
|
18
|
+
`:""]},E))})]}),(t.run_in_background||t.restart||t.timeout!=null)&&s.jsxs("div",{className:"bash-badges",children:[t.run_in_background&&s.jsx("span",{className:"bash-badge",children:"background"}),t.restart&&s.jsx("span",{className:"bash-badge",children:"restart"}),t.timeout!=null&&s.jsxs("span",{className:"bash-badge",children:["timeout ",Math.round(t.timeout/1e3),"s"]})]}),e.result_summary&&s.jsx("pre",{className:"shell-out",children:e.result_summary}),e.full_result&&s.jsxs("div",{className:"full-result",children:[s.jsxs("button",{type:"button",className:"ghost small show-full","aria-expanded":l,onClick:()=>c(j=>!j),children:[l?"Hide":"Show"," full result (",(e.full_result.bytes/1024).toFixed(1)," KB)"]}),l&&s.jsxs("div",{className:"code-block",children:[s.jsx(J,{text:e.full_result.text,className:"copy-corner",title:"Copy full tool result"}),s.jsx("pre",{className:"code",children:e.full_result.text})]})]}),s.jsxs("div",{className:"launch-actions",children:[s.jsx("button",{className:"ghost small","aria-expanded":r,"aria-controls":p,onClick:()=>i(j=>!j),children:r?"Hide raw JSON ▴":"View raw JSON ▾"}),s.jsx(J,{text:X(e.input_json??"{}"),label:"JSON",title:"Copy raw tool input JSON"})]}),r&&s.jsx("pre",{id:p,className:"code",children:X(e.input_json??"{}")})]})]})}const Dt={Edit:"✏️",MultiEdit:"✏️",Write:"📄"},Ce=400;function Ft({t:e,edit:t}){const[n,a]=u.useState(!1),[l,c]=u.useState(!1),[r,i]=u.useState(!1),h=u.useId(),p=u.useId(),{dir:f,base:g}=Mt(t.file_path);return s.jsxs("div",{className:"tool "+(e.status==="error"?"tool-err":""),children:[s.jsxs("button",{className:"tool-head","aria-expanded":n,"aria-controls":h,onClick:()=>a(j=>!j),children:[s.jsxs("span",{className:"tool-name",children:[Dt[t.kind]??"✏️"," ",t.kind]}),s.jsxs("span",{className:"edit-path",children:[s.jsx("span",{className:"base",children:g}),f&&s.jsx("span",{className:"dir",children:f.replace(/\/$/,"")})]}),s.jsxs("span",{className:"diff-stat",children:[t.adds>0&&s.jsxs("span",{className:"add",children:["+",t.adds]}),t.dels>0&&s.jsxs("span",{className:"del",children:["−",t.dels]})]}),e.status&&s.jsx("span",{className:"tool-status",children:e.status}),e.total_duration_ms?s.jsx("span",{className:"muted",children:Z(e.total_duration_ms)}):null,s.jsx("span",{className:"chev",children:n?"▾":"▸"})]}),n&&s.jsxs("div",{className:"tool-body",id:h,children:[t.hunks.map((j,E)=>s.jsxs("div",{className:"diff",children:[t.hunks.length>1&&s.jsxs("div",{className:"diff-hunk-sep",children:["edit ",E+1]}),j.slice(0,Ce).map((x,S)=>s.jsxs("div",{className:"diff-line "+x.type,children:[s.jsx("span",{className:"diff-sign","aria-hidden":"true",children:x.type==="add"?"+":x.type==="del"?"−":" "}),s.jsx("span",{className:"diff-text",children:x.text===""?" ":x.text})]},S)),j.length>Ce&&s.jsxs("div",{className:"diff-more",children:["… ",j.length-Ce," more lines — View raw JSON for the rest"]})]},E)),e.result_summary&&s.jsx("pre",{className:"shell-out",children:e.result_summary}),e.full_result&&s.jsxs("div",{className:"full-result",children:[s.jsxs("button",{type:"button",className:"ghost small show-full","aria-expanded":l,onClick:()=>c(j=>!j),children:[l?"Hide":"Show"," full result (",(e.full_result.bytes/1024).toFixed(1)," KB)"]}),l&&s.jsxs("div",{className:"code-block",children:[s.jsx(J,{text:e.full_result.text,className:"copy-corner",title:"Copy full tool result"}),s.jsx("pre",{className:"code",children:e.full_result.text})]})]}),s.jsxs("div",{className:"launch-actions",children:[s.jsx("button",{className:"ghost small","aria-expanded":r,"aria-controls":p,onClick:()=>i(j=>!j),children:r?"Hide raw JSON ▴":"View raw JSON ▾"}),s.jsx(J,{text:X(e.input_json??"{}"),label:"JSON",title:"Copy raw tool input JSON"})]}),r&&s.jsx("pre",{id:p,className:"code",children:X(e.input_json??"{}")})]})]})}function Lt({t:e,hideTools:t}){const n=e.findings??[],a=t&&n.length===0,l=Pt(e,a);return n.length===0?l:s.jsxs(s.Fragment,{children:[l,s.jsx(zs,{findings:n})]})}function Pt(e,t){if(e.tool_name==="ExitPlanMode"){const n=us(e.input_json);if(n)return s.jsx(It,{plan:n})}if(e.tool_name==="AskUserQuestion")return s.jsx(Ot,{t:e});if(e.tool_name==="Workflow")return s.jsx(At,{t:e});if(e.tool_name==="Bash"){const n=vt(e.input_json);if(n)return t?null:s.jsx(Rt,{t:e,bash:n})}if(e.tool_name==="Edit"||e.tool_name==="MultiEdit"||e.tool_name==="Write"){const n=yt(e.tool_name,e.input_json);if(n)return t?null:s.jsx(Ft,{t:e,edit:n})}return t?null:s.jsx(ws,{t:e})}function qt(e,t){return e.findings&&e.findings.length||e.tool_name==="AskUserQuestion"||e.tool_name==="Workflow"||e.tool_name==="ExitPlanMode"&&us(e.input_json)?!0:!t}function ks({e}){const[t,n]=u.useState(!1),a=u.useId(),l=u.useContext(xs),c=u.useContext(gs),r=u.useContext($e),i=u.useContext(js),h=t||r.activeUuid===e.uuid&&Ae(e.thinking,r.query),p=e.role||e.type,f=p==="user"?"👤":p==="assistant"?"🤖":"⚙️",g=b=>i===e.uuid||r.activeUuid===e.uuid&&it(b,r.query),j=e.toolCalls.filter(b=>qt(b,l)||g(b));if(!(e.text||e.thinking||j.length))return null;const x=e.text?hs(e.text):null,S=e.text&&!x?ms(e.text):null,I=e.text||e.thinking||"";return s.jsxs("div",{id:"ev-"+e.uuid,className:"event ev-"+p+(c===e.uuid?" ev-flagged":""),children:[s.jsxs("div",{className:"ev-meta",children:[s.jsxs("span",{className:"ev-who",children:[f," ",p]}),e.model&&s.jsx("span",{className:"tag",children:As(e.model)}),e.is_sidechain?s.jsx("span",{className:"tag subagent",children:"subagent"}):null,e.usage&&s.jsxs("span",{className:"muted ev-tokens","data-tip":as(e.usage),children:[oe(Ee(e.usage))," tok"]}),s.jsx("span",{className:"muted ev-time",children:ls(e.timestamp)}),I&&s.jsx(J,{text:I,className:"ev-copy copy-hover",title:"Copy message"})]}),e.thinking&&s.jsxs("div",{className:"thinking",children:[s.jsxs("button",{className:"thinking-toggle","aria-expanded":h,"aria-controls":a,onClick:()=>n(!h),children:["🧠 thinking ",h?"▾":"▸"]}),h&&s.jsxs("div",{className:"code-block",children:[s.jsx(J,{text:e.thinking,className:"copy-corner",title:"Copy thinking"}),s.jsx("pre",{id:a,className:"thinking-body",children:e.thinking})]})]}),e.text&&(x?s.jsx(Ct,{cmd:x}):S?s.jsx(Tt,{n:S}):s.jsx(Ns,{text:e.text,uuid:e.uuid})),j.map((b,C)=>s.jsx(Lt,{t:b,hideTools:l&&!g(b)},C))]})}function Bt({turn:e,events:t,matches:n=0,total:a,open:l,onToggle:c}){const r=u.useId();return s.jsxs("section",{className:"turn"+(l?" is-open":""),children:[s.jsxs("button",{className:"turn-head","aria-expanded":l,"aria-controls":r,onClick:c,children:[s.jsx("span",{className:"chev turn-chev","aria-hidden":"true",children:l?"▾":"▸"}),s.jsxs("span",{className:"turn-no",children:["turn ",e.seq+1]}),e.prompt_preview?s.jsx("span",{className:"turn-preview",children:St(e.prompt_preview)}):null,n>0&&s.jsx("span",{className:"turn-matches","data-tip":`${n} message${n===1?"":"s"} match the search`,children:n}),s.jsxs("span",{className:"turn-stats muted",children:[a!=null&&a>t.length?`${t.length} of ${a}`:t.length," msg",(a??t.length)===1?"":"s",e.duration_ms?" · "+Z(e.duration_ms):""]})]}),s.jsx("div",{id:r,className:"turn-body",role:"region","aria-label":`turn ${e.seq+1} messages`,children:l&&t.map(i=>s.jsx(ks,{e:i},i.uuid))})]})}function Ht(e,t){const n=new Map(t.map(l=>[l.id,l])),a=[];for(const l of e){const c=l.turn_id??null,r=a[a.length-1];r&&r.turnId===c?r.events.push(l):a.push({turnId:c,turn:c?n.get(c)??null:null,events:[l]})}return a}function Ut(e){const{data:t,error:n}=ns("/sessions/"+e,{reset:!0}),a=u.useMemo(()=>{const l=new Map;for(const c of(t==null?void 0:t.events)??[])for(const r of c.toolCalls)r.tool_name==="Workflow"&&r.id&&r.workflow_run_id&&l.set(r.id,r.workflow_run_id);return l},[t]);return{d:t,error:n,wfMap:a}}const Te="al-search";function Kt(e,t){u.useEffect(()=>{const n=e.current,a=CSS==null?void 0:CSS.highlights,l=globalThis.Highlight;if(!n||!a||!l)return;const c=t.trim().toLowerCase();let r=0;const i=()=>{var g;if(r=0,a.delete(Te),c.length<me)return;const p=[],f=document.createTreeWalker(n,NodeFilter.SHOW_TEXT);for(let j=f.nextNode();j;j=f.nextNode()){const E=(g=j.nodeValue)==null?void 0:g.toLowerCase();if(E)for(let x=E.indexOf(c);x!==-1;x=E.indexOf(c,x+c.length)){const S=new Range;S.setStart(j,x),S.setEnd(j,x+c.length),p.push(S)}}p.length&&a.set(Te,new l(...p))};i();const h=new MutationObserver(()=>{r||(r=requestAnimationFrame(i))});return h.observe(n,{childList:!0,subtree:!0,characterData:!0}),()=>{h.disconnect(),r&&cancelAnimationFrame(r),a.delete(Te)}},[e,t])}function Gt(e,t,n,a,l){const[c,r]=u.useState(null);u.useEffect(()=>{var p;const h=t?(p=e==null?void 0:e.find(f=>f.uuid===t))==null?void 0:p.turn_id:null;h&&l(f=>{if(!f.has(h))return f;const g=new Set(f);return g.delete(h),g})},[e,t,n,l]);const i=u.useRef(null);return u.useEffect(()=>{var g;if(!e||!t||!n){i.current=null;return}if(i.current===n)return;const h=document.getElementById("ev-"+t);if(!h)return;i.current=n;const p=((g=window.matchMedia)==null?void 0:g.call(window,"(prefers-reduced-motion: reduce)").matches)??!1;h.scrollIntoView({block:"center",behavior:p?"auto":"smooth"}),r(t);const f=window.setTimeout(()=>r(null),3e3);return()=>window.clearTimeout(f)},[e,t,n,a]),c}const Re="msgFormat",De="hideTools",Fe="timelineAxis",Le="timelineMetric";function ve(e){const t=$s(e,null);if(t!=null)return t;try{return localStorage.getItem("agentlens."+e)}catch{return null}}const _s=e=>e==="raw"?"raw":"markdown",bs=e=>e===!0||e===1||e==="1",vs=e=>e==="literal"?"literal":"compressed",ys=e=>e==="output"||e==="total"?e:"work";function Wt(){return _s(ve(Re))}function Jt(){return bs(ve(De))}function Vt(e){be(Re,e)}function Qt(e){be(De,e)}function Xt(){return vs(ve(Fe))}function zt(){return ys(ve(Le))}function Yt(e){be(Fe,e)}function Zt(e){be(Le,e)}async function en(){const[e,t,n,a]=await Promise.all([ke(Re),ke(De),ke(Fe),ke(Le)]);return{...e!=null?{format:_s(e)}:{},...t!=null?{hideTools:bs(t)}:{},...n!=null?{axisMode:vs(n)}:{},...a!=null?{metric:ys(a)}:{}}}const Qe=6e4,Xe=14,ze=3e4,sn=4,tn=3,nn=.5;function an(e){if(!e)return null;const t=Date.parse(e);return Number.isNaN(t)?null:t}const Ye=(e,t,n)=>e<t?t:e>n?n:e;function ln(e,t){var y;const n=t.gapMs??Qe,a=Math.max(t.width,0),l=e.map(m=>({uuid:m.uuid,t:an(m.timestamp)})).filter(m=>m.t!==null).filter(m=>!t.domain||m.t>=t.domain[0]&&m.t<=t.domain[1]).sort((m,k)=>m.t-k.t);if(l.length===0)return rn(a);const c=[],r=[],i=[];let h=0;for(let m=1;m<l.length;m++){const k=l[m].t-l[m-1].t;if(!(k<=n)){if((y=t.expandedGaps)!=null&&y.has(l[m-1].t)){i.push({t0:l[m-1].t,t1:l[m].t,durationMs:k});continue}c.push({from:h,to:m-1}),r.push(k),h=m}}c.push({from:h,to:l.length-1});const p=l[0].t,f=l[l.length-1].t,g=p===f,j=c.map(({from:m,to:k})=>g?{t0:l[m].t-ze,t1:l[k].t+ze}:{t0:l[m].t,t1:l[k].t}),E=Math.min(r.length*Xe,a),x=Math.max(a-E,0),S=j.map(m=>Math.max(m.t1-m.t0,0)),I=S.reduce((m,k)=>m+k,0),b=c.length?x*nn/c.length:0,C=c.map(m=>Math.max(sn,(m.to-m.from+1)*tn,b)),D=C.reduce((m,k)=>m+k,0),z=Math.max(x-D,0),Y=D<=x?C.map((m,k)=>m+(I>0?S[k]/I*z:z/c.length)):C.map(m=>m/(D||1)*x),M=[],$=[];let H=0;for(let m=0;m<c.length;m++){const k=Y[m];if(M.push({t0:j[m].t0,t1:j[m].t1,x0:H,x1:H+k}),H+=k,m<r.length){const R=Math.min(Xe,Math.max(a-H,0));$.push({afterSegment:m,t0:j[m].t1,t1:j[m+1].t0,x0:H,x1:H+R,durationMs:r[m]}),H+=R}}const te=l.map((m,k)=>{const R=l[k+1];if(!R)return{...m,durationMs:0};const v=R.t-m.t;return{...m,durationMs:v>n?0:v}}),G=M[0].t0,q=M[M.length-1].t1,V=m=>{const k=Ye(m,G,q);for(let R=0;R<M.length;R++){const v=M[R];if(k<=v.t1||R===M.length-1)return k<v.t0?v.x0:v.t1===v.t0?(v.x0+v.x1)/2:v.x0+(k-v.t0)/(v.t1-v.t0)*(v.x1-v.x0)}return M[M.length-1].x1},U=m=>{const k=Ye(m,0,H);for(let R=0;R<M.length;R++){const v=M[R];if(k<=v.x1||R===M.length-1){if(k<v.x0){const Q=$[R-1];return k-Q.x0<Q.x1-k?Q.t0:Q.t1}return v.x1===v.x0?v.t0:v.t0+(k-v.x0)/(v.x1-v.x0)*(v.t1-v.t0)}}return q},B=r.reduce((m,k)=>m+k,0),ee=i.map(m=>({...m,x0:V(m.t0),x1:V(m.t1)}));let T=0;for(let m=1;m<l.length;m++)l[m].t-l[m-1].t>Qe&&T++;return{points:te,segments:M,breaks:$,expanded:ee,width:a,domain:[p,f],spanMs:f-p,activeMs:Math.max(f-p-B,0),idleMs:B,collapsibleGaps:T,degenerate:g,x:V,t:U}}function rn(e){return{points:[],segments:[],breaks:[],expanded:[],width:e,domain:null,spanMs:0,activeMs:0,idleMs:0,collapsibleGaps:0,degenerate:!0,x:()=>0,t:()=>0}}function on(e){return e.toolCalls.some(t=>t.status==="error")?"tool-error":e.toolCalls.length?"tool":e.thinking&&!e.text?"thinking":e.role==="user"?"user":e.role==="assistant"?"assistant":"meta"}function cn(e,t){return e.usage?t==="output"?e.usage.output:t==="total"?Ee(e.usage)+e.usage.cache_read:Ee(e.usage):0}function dn(e){return e.usage?e.usage.input+e.usage.cache_creation+e.usage.cache_read:0}const Ze=["critical","high","medium","low","info"];function un({events:e,points:t,findings:n,fileChanges:a,turnSeqById:l,metric:c}){const r=new Map(e.map(f=>[f.uuid,f])),i=new Map;for(const f of n??[]){if(!f.event_uuid)continue;const g=i.get(f.event_uuid);(!g||Ze.indexOf(f.severity)<Ze.indexOf(g))&&i.set(f.event_uuid,f.severity)}const h=new Map;for(const f of a??[])f.event_uuid&&h.set(f.event_uuid,(h.get(f.event_uuid)??0)+1);const p=[];for(const f of t){const g=r.get(f.uuid);if(!g)continue;const j=g.turn_id!=null?l==null?void 0:l.get(g.turn_id):void 0;p.push({uuid:f.uuid,kind:on(g),turnSeq:j==null?null:j+1,t:f.t,durationMs:f.durationMs,value:cn(g,c),context:dn(g),error:g.toolCalls.some(E=>E.status==="error"),finding:i.get(f.uuid)??null,fileChange:(h.get(f.uuid)??0)>0,fileChangeCount:h.get(f.uuid)??0,spawn:g.toolCalls.some(E=>E.spawned_session_id)})}return p}function hn(e){return e.some(t=>t.usage)}const L=44,Ie=6,Ms=3,mn=L+Ms+Ie,pn=2,Ss=3,es=3;function fn(){const e=u.useRef(null),[t,n]=u.useState(0);return u.useEffect(()=>{if(!e.current||typeof ResizeObserver>"u")return;const a=new ResizeObserver(([l])=>n(l.contentRect.width));return a.observe(e.current),()=>a.disconnect()},[]),[e,t]}const xn=[{kind:"user",label:"user"},{kind:"assistant",label:"assistant"},{kind:"thinking",label:"thinking"},{kind:"tool",label:"tool"}];function ss(e,t){return t?`${Z(e)} before your next message`:`${Z(e)} mid-turn`}function Oe(e,t){const n=t.x(e.t),a=e.kind==="user"||e.kind==="meta";return{x:n,w:a?Ss:Math.max(pn,t.x(e.t+e.durationMs)-n-1)}}const ts=3,gn=12;function jn(e){const{events:t,findings:n,fileChanges:a,userPromptUuids:l,turnSeqById:c,axisMode:r,onAxisMode:i,metric:h,onMetric:p}=e,{range:f,onRange:g,onJump:j,domain:E,onDomain:x}=e,[S,I]=fn(),b=u.useRef(null),[C,D]=u.useState(null),[z,Y]=u.useState(()=>new Set),[M,$]=u.useState(0),[H,te]=u.useState(null),[G,q]=u.useState(null),{TIMELINE_COLORS:V,C:U}=Us(),B=hn(t);u.useEffect(()=>{if(!f)return;const o=N=>{if(N.key!=="Escape"||N.defaultPrevented)return;const _=N.target;_&&(_.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(_.tagName))||g(null)};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[f,g]);const ee=B?h:"work",T=ln(t,{width:I,gapMs:r==="literal"?1/0:void 0,...E?{domain:E}:{},expandedGaps:z}),y=un({events:t,points:T.points,findings:n,fileChanges:a,turnSeqById:c,metric:ee}),m=f&&!T.degenerate?[T.x(f[0]),T.x(f[1])]:null,k=6,R=o=>m?Math.abs(o-m[0])<=k?"start":Math.abs(o-m[1])<=k?"end":null:null,v=o=>o==="start"?m[1]:m[0],Q=(o,N)=>{const[_,O]=o<=N?[o,N]:[N,o];return[T.t(_),T.t(O)]},pe=o=>{let N=null;return y.forEach((_,O)=>{const{x:A,w:K}=Oe(_,T),F=o<A?A-o:o>A+K?o-(A+K):0;(!N||F<N.d)&&(N={uuid:_.uuid,d:F,i:O,x:A,w:K})}),N},P=y[Math.min(M,y.length-1)]??null,de=P?[`message ${Math.min(M,y.length-1)+1} of ${y.length}`,P.kind==="tool-error"?"tool error":P.kind,B&&P.value>0?`${oe(P.value)} tokens`:null,new Date(P.t).toLocaleTimeString(),P.finding?`${P.finding} security finding`:null,P.fileChange?"changed files":null].filter(Boolean).join(", "):"",ne=(o,N)=>{const _=Math.max(0,Math.min(o,y.length-1));if($(_),!N){te(null);return}const O=H??Math.min(M,y.length-1);te(O);const[A,K]=O<=_?[O,_]:[_,O];g([y[A].t,y[K].t])},le=o=>{if(y.length)switch(o.key){case"ArrowLeft":o.preventDefault(),ne(M-1,o.shiftKey);break;case"ArrowRight":o.preventDefault(),ne(M+1,o.shiftKey);break;case"Home":o.preventDefault(),ne(0,o.shiftKey);break;case"End":o.preventDefault(),ne(y.length-1,o.shiftKey);break;case"Enter":case" ":o.preventDefault(),P&&j(P.uuid);break}},ae=o=>{var _;const N=(_=b.current)==null?void 0:_.getBoundingClientRect();return N?o.clientX-N.left:0},fe=o=>{if(o.button!==0||T.degenerate)return;const N=ae(o),_=R(N),O={x:N,pointerId:o.pointerId,captured:!1};D(_?{kind:_,anchor:v(_),...O}:{kind:"new",anchor:N,...O})},xe=o=>{var A,K;const N=ae(o);if(!C){const F=pe(N);q(F&&F.d<=gn?{uuid:F.uuid,x:F.x,w:F.w}:null);return}const _=N,O=Math.abs(_-C.anchor)>=ts;O&&!C.captured&&((K=(A=o.currentTarget).setPointerCapture)==null||K.call(A,C.pointerId)),D({...C,x:_,captured:C.captured||O}),O&&g(Q(C.anchor,_))},ge=o=>{var _,O,A,K,F,Pe;if(!C)return;const N=ae(o);if(C.captured&&((O=(_=o.currentTarget).hasPointerCapture)!=null&&O.call(_,C.pointerId))&&((K=(A=o.currentTarget).releasePointerCapture)==null||K.call(A,C.pointerId)),D(null),Math.abs(N-C.anchor)<ts){const Cs=(Pe=(F=o.target)==null?void 0:F.closest)==null?void 0:Pe.call(F,".tl-break, .tl-expanded");if(C.kind==="new"&&!Cs){const qe=pe(N);qe&&j(qe.uuid)}return}g(Q(C.anchor,N))};if(t.length===0)return null;if(!T.domain)return s.jsx("div",{className:"timeline",ref:S,children:s.jsx("div",{className:"tl-caption muted",children:"No timing data for this session."})});const je=[`${T.points.length} message${T.points.length===1?"":"s"}`,T.spanMs>0?`${Z(T.spanMs)} span`:null,T.breaks.length?`${T.breaks.length} break${T.breaks.length===1?"":"s"}`:null].filter(Boolean).join(" · "),re=Math.max(0,...y.map(o=>o.context)),ue=re>0?y.filter(o=>o.context>0).map(o=>`${Oe(o,T).x.toFixed(1)},${(L-o.context/re*L).toFixed(1)}`).join(" "):"",se=y.map(o=>o.value).filter(o=>o>0).sort((o,N)=>o-N),ie=se.length?se[Math.min(Math.floor(se.length*.95),se.length-1)]:0,Ne=o=>!B||ie<=0?L*.6:o<=0?es:Math.max(es,Math.min(1,Math.sqrt(o)/Math.sqrt(ie))*L),we=new Set(y.map(o=>o.kind)),he=G?y.find(o=>o.uuid===G.uuid):void 0,d=G&&he?{mark:he,x:G.x,w:G.w}:null,w=o=>o==="tool-error"?V.toolError:o==="meta"?U.muted:V[o];return s.jsxs("div",{className:"timeline",ref:S,children:[s.jsxs("div",{className:"tl-head",children:[B&&s.jsxs("label",{className:"tl-ctl",children:[s.jsx("span",{className:"sr-only",children:"Mark height metric"}),s.jsxs("select",{value:h,onChange:o=>p(o.target.value),children:[s.jsx("option",{value:"work",children:"work tokens"}),s.jsx("option",{value:"output",children:"output tokens"}),s.jsx("option",{value:"total",children:"total (incl. cache read)"})]})]}),T.collapsibleGaps>0&&s.jsxs("button",{type:"button",className:"link-btn tl-axis",onClick:()=>i(r==="compressed"?"literal":"compressed"),"data-tip":r==="compressed"?"Idle gaps are collapsed. Switch to literal wall-clock.":"Literal wall-clock. Switch to collapsed idle gaps.",children:["time ⇄ ",r]}),s.jsx("span",{className:"tl-caption muted",children:je})]}),I>0&&s.jsxs("svg",{ref:b,className:"tl-svg"+(C?" is-dragging":""),width:I,height:mn,role:"group","aria-label":`Session timeline: ${je}. Use the arrow keys to move between messages, Enter to open one, Shift with the arrows to select a range.`,tabIndex:0,onKeyDown:le,onFocus:()=>$(o=>Math.min(o,Math.max(y.length-1,0))),onPointerDown:fe,onPointerMove:xe,onPointerUp:ge,onPointerCancel:ge,onPointerLeave:()=>q(null),children:[T.breaks.map((o,N)=>{const _=T.points.find(A=>A.t>=o.t1),O=!!_&&!!(l!=null&&l.has(_.uuid));return s.jsxs("g",{className:"tl-break",onDoubleClick:A=>{A.stopPropagation(),Y(K=>{const F=new Set(K);return F.has(o.t0)?F.delete(o.t0):F.add(o.t0),F})},children:[s.jsx("rect",{x:o.x0,y:0,width:o.x1-o.x0,height:L}),s.jsxs("title",{children:[ss(o.durationMs,O)," — double-click to show it to scale"]})]},"b"+N)}),T.expanded.map((o,N)=>s.jsxs("g",{className:"tl-expanded",onDoubleClick:_=>{_.stopPropagation(),Y(O=>{const A=new Set(O);return A.delete(o.t0),A})},children:[s.jsx("rect",{x:o.x0,y:0,width:Math.max(o.x1-o.x0,1),height:L}),s.jsxs("title",{children:[ss(o.durationMs,!1)," — shown in full; double-click to collapse it again"]})]},"x"+N)),y.map(o=>s.jsx(Nn,{m:o,scale:T,h:Ne(o.value),fill:w(o.kind)},o.uuid)),ue&&s.jsx("polyline",{className:"tl-context",points:ue}),d&&s.jsx("rect",{className:"tl-hover",x:d.x-1,y:0,width:d.w+2,height:L}),P&&s.jsx("rect",{className:"tl-cursor",x:T.x(P.t)-1,y:0,width:Math.max(Ss,2),height:L}),m&&s.jsxs("g",{className:"tl-sel",children:[s.jsx("rect",{className:"tl-sel-shade",x:0,y:0,width:Math.max(m[0],0),height:L}),s.jsx("rect",{className:"tl-sel-shade",x:m[1],y:0,width:Math.max(I-m[1],0),height:L}),s.jsx("rect",{className:"tl-sel-box",x:m[0],y:0,width:Math.max(m[1]-m[0],1),height:L}),s.jsx("rect",{className:"tl-sel-handle",x:m[0]-1,y:0,width:2,height:L}),s.jsx("rect",{className:"tl-sel-handle",x:m[1]-1,y:0,width:2,height:L})]}),s.jsx("g",{className:"tl-rail",transform:`translate(0, ${L+Ms})`,children:y.map(o=>{const N=T.x(o.t);return s.jsxs("g",{children:[o.error&&s.jsx("rect",{className:"tl-err",x:N,y:0,width:2,height:Ie}),o.finding&&s.jsx("rect",{className:"tl-find sev-"+o.finding,x:N,y:0,width:2,height:Ie}),o.fileChange&&s.jsx("rect",{className:"tl-file",x:N,y:1,width:3,height:3}),o.spawn&&s.jsx("path",{className:"tl-spawn",d:`M ${N-2} 0 L ${N+2} 0 L ${N} 4 Z`})]},"r"+o.uuid)})})]}),d&&s.jsxs("div",{className:"tl-tip"+(d.x>I*.6?" is-right":""),style:d.x>I*.6?{right:Math.max(I-d.x,0)}:{left:d.x},"aria-hidden":"true",children:[s.jsxs("div",{className:"tl-tip-head",children:[d.mark.turnSeq!=null&&s.jsxs("span",{className:"tl-tip-turn",children:["turn ",d.mark.turnSeq]}),s.jsx("span",{children:d.mark.kind==="tool-error"?"tool error":d.mark.kind})]}),s.jsxs("div",{className:"tl-tip-row muted",children:[new Date(d.mark.t).toLocaleTimeString(),B&&d.mark.value>0?` · ${oe(d.mark.value)} tok`:"",d.mark.durationMs>0?` · ${Z(d.mark.durationMs)}`:"",d.mark.context>0?` · ${oe(d.mark.context)} context`:""]}),(d.mark.error||d.mark.finding||d.mark.fileChange||d.mark.spawn)&&s.jsxs("div",{className:"tl-tip-row",children:[d.mark.error&&s.jsx("span",{className:"tl-tip-flag is-err",children:"tool error"}),d.mark.finding&&s.jsxs("span",{className:"tl-tip-flag sev-"+d.mark.finding,children:[d.mark.finding," finding"]}),d.mark.fileChange&&s.jsxs("span",{className:"tl-tip-flag",children:[d.mark.fileChangeCount," file",d.mark.fileChangeCount===1?"":"s"]}),d.mark.spawn&&s.jsx("span",{className:"tl-tip-flag",children:"subagent"})]})]}),s.jsx("div",{className:"sr-only","aria-live":"polite","aria-atomic":"true",children:de}),s.jsxs("div",{className:"tl-legend",children:[xn.filter(o=>we.has(o.kind)).map(o=>s.jsxs("span",{className:"tl-key",children:[s.jsx("span",{className:"tl-swatch",style:{background:w(o.kind)}}),o.label]},o.kind)),we.has("tool-error")&&s.jsxs("span",{className:"tl-key",children:[s.jsx("span",{className:"tl-swatch",style:{background:V.toolError}}),"tool error"]}),re>0&&s.jsxs("span",{className:"tl-key","data-tip":"Prompt size per message — input + cache-write + cache-read. Shape only; a fuller context is not a worse one.",children:[s.jsx("span",{className:"tl-swatch is-line"}),"context, peak ",oe(re)]})]})]})}function Nn({m:e,scale:t,h:n,fill:a}){const{x:l,w:c}=Oe(e,t);return s.jsx("rect",{className:"tl-mark",x:l,y:L-n,width:c,height:n,rx:2,fill:a})}function yn(){var he;const{id:e}=Rs(),{hash:t}=Ds(),{d:n,error:a,wfMap:l}=Ut(e),[c,r]=u.useState(new Set),[i,h]=u.useState(Wt),[p,f]=u.useState(Jt),[g,j]=u.useState(Xt),[E,x]=u.useState(zt);u.useEffect(()=>r(new Set),[e]),u.useEffect(()=>{en().then(d=>{d.format!==void 0&&h(d.format),d.hideTools!==void 0&&f(d.hideTools),d.axisMode!==void 0&&j(d.axisMode),d.metric!==void 0&&x(d.metric)})},[]);const S=d=>{h(d),Vt(d)},I=d=>{j(d),Yt(d)},b=d=>{x(d),Zt(d)},C=()=>f(d=>(Qt(!d),!d)),D=u.useMemo(()=>(n==null?void 0:n.events.filter(d=>d.text||d.thinking||d.toolCalls.length))??[],[n]),{get:z,set:Y}=Fs(),M=z("q"),$=u.useMemo(()=>{const d=Date.parse(z("from")),w=Date.parse(z("to"));return Number.isNaN(d)||Number.isNaN(w)?null:[d,w]},[z]),H=d=>Y(d?{from:new Date(d[0]).toISOString(),to:new Date(d[1]).toISOString()}:{from:"",to:""},{replace:!0}),[te,G]=u.useState(null);u.useEffect(()=>G(null),[e]);const q=u.useMemo(()=>$?D.filter(d=>{if(!d.timestamp)return!0;const w=Date.parse(d.timestamp);return Number.isNaN(w)||w>=$[0]&&w<=$[1]}):D,[D,$]),V=u.useMemo(()=>at(q),[q]),U=u.useMemo(()=>rt(q,V,M),[q,V,M]),B=((he=/^#ev-(.+)$/.exec(t))==null?void 0:he[1])??null,[ee,T]=qs(t+`
|
|
19
|
+
`+M,{idx:0,seq:0}),y=U.hits[ee.idx]??null,[m,k]=u.useState(null);u.useEffect(()=>k(null),[e]);const R=d=>k(w=>({uuid:d,nonce:((w==null?void 0:w.nonce)??0)+1})),v=M.trim().length>=me&&U.total===0;u.useEffect(()=>{var w;if(!v)return;const d=((w=window.matchMedia)==null?void 0:w.call(window,"(prefers-reduced-motion: reduce)").matches)??!1;window.scrollTo({top:0,behavior:d?"auto":"smooth"})},[v,M]);const Q=(m==null?void 0:m.uuid)??(y==null?void 0:y.uuid)??B,pe=m?`band:${m.uuid}:${m.nonce}`:y?`q:${M}:${ee.idx}:${ee.seq}`:t?`${t}${$?":ranged":""}`:null,P=Gt(n==null?void 0:n.events,Q,pe,c,r),[de,ne]=u.useState(!1);u.useEffect(()=>{if(!B||!$||!n)return;const d=n.events.find(o=>o.uuid===B),w=d!=null&&d.timestamp?Date.parse(d.timestamp):NaN;Number.isNaN(w)||w>=$[0]&&w<=$[1]||(Y({from:"",to:""}),ne(!0),R(B))},[B,$,n,Y]),u.useEffect(()=>{if(!de)return;const d=window.setTimeout(()=>ne(!1),6e3);return()=>window.clearTimeout(d)},[de]);const le=d=>{U.total&&T(w=>({idx:(w.idx+d+U.total)%U.total,seq:w.seq+1}))},ae=u.useRef({step:le,total:U.total});ae.current={step:le,total:U.total};const fe=u.useRef(null),xe=u.useRef(null);Kt(xe,M),u.useEffect(()=>{const d=w=>{var A;if(w.defaultPrevented||w.metaKey||w.ctrlKey||w.altKey)return;const o=w.target,N=!!o&&(o.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(o.tagName));if(w.key==="/"&&!N){w.preventDefault(),(A=fe.current)==null||A.focus();return}const _=document.activeElement,O=!_||_===document.body||_===document.documentElement;w.key==="Enter"&&O&&ae.current.total&&(w.preventDefault(),ae.current.step(w.shiftKey?-1:1))};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[]);const ge=u.useMemo(()=>new Map(((n==null?void 0:n.turns)??[]).map(d=>[d.id,d.seq])),[n]),je=u.useMemo(()=>new Set(((n==null?void 0:n.turns)??[]).map(d=>d.user_event_uuid).filter(d=>!!d)),[n]),re=u.useMemo(()=>({query:M,activeUuid:(y==null?void 0:y.uuid)??null}),[M,y]);if(a)return s.jsx(Ls,{error:a});if(!n)return s.jsx(Ps,{});const ue=Ht(q,n.turns),se=new Map;for(const d of D)d.turn_id&&se.set(d.turn_id,(se.get(d.turn_id)??0)+1);const ie=ue.filter(d=>d.turn).map(d=>d.turnId),Ne=ie.some(d=>!c.has(d)),we=d=>r(w=>{const o=new Set(w);return o.has(d)?o.delete(d):o.add(d),o});return s.jsxs("div",{className:"detail",children:[s.jsx(st,{d:n}),s.jsx(jn,{events:D,findings:n.findings,fileChanges:n.file_changes,userPromptUuids:je,turnSeqById:ge,axisMode:g,onAxisMode:I,metric:E,onMetric:b,range:$,onRange:H,onJump:R,domain:te,onDomain:G}),de&&s.jsx("div",{className:"tl-pill muted",role:"status",children:"Range cleared to show the linked message."}),$&&s.jsxs("div",{className:"tl-pill",role:"status",children:[s.jsxs("span",{className:"tl-pill-range",children:[Be($[0]),"–",Be($[1])]}),s.jsx("span",{className:"muted",children:q.length===0?"no messages in this range":`showing ${q.length} of ${D.length} messages`}),te?s.jsx("button",{type:"button",className:"link-btn",onClick:()=>G(null),children:"◂ full session"}):s.jsx("button",{type:"button",className:"link-btn",onClick:()=>G($),children:"⤢ zoom"}),s.jsx("button",{type:"button",className:"link-btn",onClick:()=>H(null),children:"clear ✕"})]}),n.children&&n.children.length>0&&s.jsx(ut,{d:n}),s.jsx(tt,{search:s.jsx(dt,{query:M,onQuery:d=>Y({q:d},{replace:!0}),total:U.total,index:ee.idx,onPrev:()=>le(-1),onNext:()=>le(1),inputRef:fe}),turnCount:ie.length,anyOpen:Ne,onToggleAll:()=>r(Ne?new Set(ie):new Set),hideTools:p,onToggleHideTools:C,format:i,onChooseFormat:S}),s.jsx(fs.Provider,{value:l,children:s.jsx(ps.Provider,{value:i,children:s.jsx(xs.Provider,{value:p,children:s.jsx(js.Provider,{value:Q,children:s.jsx(gs.Provider,{value:P,children:s.jsx($e.Provider,{value:re,children:s.jsxs("div",{className:"transcript",ref:xe,children:[D.length===0&&s.jsx("div",{className:"muted pad",role:"status",children:"This session has no rendered messages."}),D.length>0&&q.length===0&&s.jsx("div",{className:"muted pad",role:"status",children:"No messages in the selected time range."}),ue.map((d,w)=>d.turn?s.jsx(Bt,{turn:d.turn,events:d.events,matches:U.byTurn.get(d.turnId)??0,total:se.get(d.turnId),open:!c.has(d.turnId),onToggle:()=>we(d.turnId)},d.turnId):s.jsx("div",{className:"unturned",children:d.events.map(o=>s.jsx(ks,{e:o},o.uuid))},"unturned-"+w))]})})})})})})})]})}export{yn as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{y as x,
|
|
1
|
+
import{y as x,p as j,j as s,D as v,i as f,r as d,L as m,w as c}from"./index-DYCDqLKI.js";import{M as p,r as N}from"./index-C5nCASCF.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(p,{remarkPlugins:[N],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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as q,k,r as c,F,p as E,G as C,j as e,H as I,E as R,n as w,I as d,L as K,w as M,P as D}from"./index-DYCDqLKI.js";const u=50,$={name:t=>t.name,fired:t=>t.call_count,last_fired:t=>t.last_fired};function G(){const{params:t,get:l,set:n,pick:v}=q(),f=k("/sources",[]),y=k("/projects",[]),[h,m]=c.useState(l("q")),{sort:a,toggle:i}=F("fired","desc"),[N,j]=c.useState(1),p=v(["source","project","q"]),{data:x,loading:g,error:_}=E("/skills"+(p.toString()?"?"+p:""));function L(s){s.preventDefault(),n({q:h.trim()})}c.useEffect(()=>j(1),[t,a.key,a.dir]);const r=c.useMemo(()=>C(x??[],$[a.key],a.dir),[x,a.key,a.dir]),b=Math.max(1,Math.ceil(r.length/u)),o=Math.min(N,b),P=r.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"}),l("q")&&e.jsx("button",{type:"button",className:"ghost",onClick:()=>(m(""),n({q:""})),children:"clear"})]}),e.jsxs("select",{"aria-label":"Filter by source",value:l("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(I,{ariaLabel:"Filter by project",searchPlaceholder:"Find project…",value:l("project"),onChange:s=>n({project:s}),options:[{value:"",label:"all projects"},...y.map(s=>({value:s.id,label:s.path.replace(/^.*\//,"")}))]})]}),e.jsx(R,{error:_}),g?e.jsx(w,{}):r.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","data-tip":`${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&&r.length>0&&e.jsx(D,{page:o,pages:b,total:r.length,unit:"skills",onPage:j})]})}export{G as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as s,r as C,y as B,x as G,D as K,L as T,s as L,f as W,a as q,b as Y,v as z}from"./index-CMT9aRT7.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-DI8SpR-J.js";import{M as F,r as J}from"./index-BuG6Awf5.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 D(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=D(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=D(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(I,{value:r,depth:a+1})})]})}function I({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(I,{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}=B(),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 B,p as G,D as K,L as T,s as L,f as W,a as q,b as Y,w as z}from"./index-DYCDqLKI.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-iCEt12Ty.js";import{M as F,r as J}from"./index-C5nCASCF.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 D(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=D(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=D(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(I,{value:r,depth:a+1})})]})}function I({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(I,{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}=B(),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",{"data-tip":"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};
|