cogpit 2.0.0 → 2.0.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/cli.js +93 -21
- package/dist/web/assets/{CommandPaletteHost-ChH6w0Bx.js → CommandPaletteHost-CyKWHB_t.js} +1 -1
- package/dist/web/assets/{ConfigBrowser-CPCH7_25.js → ConfigBrowser-CmApjOBh.js} +1 -1
- package/dist/web/assets/{HighlightedEditor-BPmH8BvC.js → HighlightedEditor-D4DdiaD3.js} +1 -1
- package/dist/web/assets/{KeyboardShortcutsDialog-CTbXz40Z.js → KeyboardShortcutsDialog-CaqJ90ox.js} +1 -1
- package/dist/web/assets/{MobileFileChanges-C5VoKbje.js → MobileFileChanges-BjHkXuyc.js} +1 -1
- package/dist/web/assets/{PreviewPanel-DoAf1W2k.js → PreviewPanel-DVORy2rT.js} +1 -1
- package/dist/web/assets/{ProjectFilesPanel-v_O7Awnm.js → ProjectFilesPanel-WiqiZyLW.js} +1 -1
- package/dist/web/assets/{ProjectSwitcherModal-CSZrCd3X.js → ProjectSwitcherModal-CxLemcBj.js} +1 -1
- package/dist/web/assets/{TerminalOutput-SImEU6_6.js → TerminalOutput-zSNcaPSy.js} +1 -1
- package/dist/web/assets/{ThemeSelectorModal-rjVBMgWC.js → ThemeSelectorModal-D0yWwDku.js} +1 -1
- package/dist/web/assets/{WorkflowsPanel-JVqgKAzY.js → WorkflowsPanel-Doy9QzhU.js} +1 -1
- package/dist/web/assets/{WorktreePanel-D94-oAau.js → WorktreePanel-CgWELvag.js} +1 -1
- package/dist/web/assets/{index-S7UMnH_y.js → index-BG9ZLZQ3.js} +1 -1
- package/dist/web/assets/{index-C5VcQtkE.js → index-BPqm0HzF.js} +1 -1
- package/dist/web/assets/{index-CNV6e3p0.js → index-C3E35E2A.js} +69 -69
- package/dist/web/assets/{index-C00ZsBZl.js → index-C4XoqTra.js} +1 -1
- package/dist/web/assets/session-parser.worker-DJxJ4O8Q.js +22 -0
- package/dist/web/index.html +1 -1
- package/package.json +1 -1
- package/dist/web/assets/session-parser.worker-BhyaigCR.js +0 -22
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as z,a as Ge,c as B,j as s}from"./vendor-react-gGw_S5I_.js";import{w as Qe,B as V,aG as He,aV as Ie,A as qe,aH as Ke,bb as Me,ad as Ce,ac as Fe,U as Te,bc as We,b1 as Xe,b0 as Je,a$ as Ze,bd as et,be as tt,bf as st,bg as nt,T as ue,bh as it,V as lt,aj as ot,bi as at,bj as rt,bk as ct,v as dt,ae as ut,bl as ft,E as mt,y as xt,z as ht,G as gt,H as pt,ah as bt,p as jt,bm as wt,bn as vt,q as Nt}from"./index-CNV6e3p0.js";import{E as yt,ah as St,ao as Ye,C as De,ap as ye,a2 as It,aq as qt,L as _t,ar as Tt,as as Ct,c as kt,m as At}from"./vendor-ui-BmLOQ5Or.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";const Et=4e3;function Rt(){const[l,e]=z.useState([]),[t,n]=z.useState(!1),[i,r]=z.useState(null),o=z.useRef(!1);z.useEffect(()=>(o.current=!1,()=>{o.current=!0}),[]);const c=z.useCallback(async()=>{try{const u=await Qe("/api/mission-control");if(o.current)return;if(!u.ok)throw new Error(`Mission Control request failed (${u.status})`);const x=await u.json();if(o.current)return;e(Array.isArray(x.summaries)?x.summaries:[]),r(null)}catch(u){if(o.current)return;r(u instanceof Error?u.message:"Failed to load Mission Control")}finally{o.current||n(!1)}},[]);z.useEffect(()=>{n(!0);const u=()=>{(typeof document>"u"||document.visibilityState==="visible")&&c()},x=()=>{document.visibilityState==="visible"&&c()};u();const j=setInterval(u,Et);return document.addEventListener("visibilitychange",x),()=>{clearInterval(j),document.removeEventListener("visibilitychange",x)}},[c]);const d=z.useMemo(()=>{const u=new Map;for(const x of l)u.set(x.sessionId,x);return u},[l]),p=z.useCallback(()=>{c()},[c]);return{summaries:d,loading:t,error:i,refresh:p}}const ke="data-view-transition-kind",Mt="(prefers-reduced-motion: reduce)";let de=null,$e=null;function Lt(l,e,t){t===null?l.removeAttribute(e):l.setAttribute(e,t)}function Dt(l,e){const t={root:l,kind:e,previousKind:l.getAttribute(ke)};return l.setAttribute(ke,e),$e=t,t}function Se(l){$e===l&&(l.root.getAttribute(ke)===l.kind&&Lt(l.root,ke,l.previousKind),$e=null)}function $t(){const l=de;if(l){de=null;try{l.transition.skipTransition()}catch{Se(l.tag);return}Se(l.tag)}}function Ft(){if(typeof window>"u"||typeof window.matchMedia!="function")return!1;try{return window.matchMedia(Mt).matches}catch{return!1}}function zt(l,{kind:e}){$t();const t=typeof document>"u"?null:document,n=t==null?void 0:t.startViewTransition;if(!t||!(typeof n=="function")||Ft())return l(),null;const r=Dt(t.documentElement,e);let o=!1,c=!1,d;const p=u=>{if(!o){o=!0;try{u?Ge.flushSync(l):l()}catch(x){throw c=!0,d=x,x}}};try{const u=n.call(t,()=>p(!0)),x={transition:u,tag:r};return de=x,u.ready.catch(()=>{}),u.updateCallbackDone.catch(()=>{}),u.finished.then(()=>{de===x&&(de=null),Se(r)},()=>{de===x&&(de=null),Se(r)}),u}catch{if(Se(r),c)throw d;return p(!1),null}}function Ot(l){const e={};for(const t of l)t.type==="boolean"?e[t.name]=t.defaultValue===!0:t.defaultValue!==void 0?e[t.name]=String(t.defaultValue):e[t.name]="";return e}function Vt(l,e){const t={};for(const n of l){const i=e[n.name];if(typeof i=="boolean"){t[n.name]=i;continue}i!==""&&(t[n.name]=n.type==="number"||n.type==="integer"?Number(i):i)}return t}function Ut(l,e){return l.every(t=>{if(!t.required)return!0;const n=e[t.name];return typeof n=="boolean"?!0:n===""?!1:t.type==="number"||t.type==="integer"?Number.isFinite(Number(n)):!0})}function Yt(l){const e=B.c(64),{request:t,responding:n,onAnswer:i}=l;let r;e[0]!==t.fields?(r=()=>Ot(t.fields),e[0]=t.fields,e[1]=r):r=e[1];const[o,c]=z.useState(r);let d;e[2]!==t.fields||e[3]!==o?(d=Ut(t.fields,o),e[2]=t.fields,e[3]=o,e[4]=d):d=e[4];const p=d,u=t.displayName||t.title||t.serverName;let x;e[5]===Symbol.for("react.memo_cache_sentinel")?(x=(y,q)=>{c(b=>({...b,[y]:q}))},e[5]=x):x=e[5];const j=x;let m;e[6]!==i||e[7]!==t.requestId?(m=()=>i(t.requestId,{action:"decline"}),e[6]=i,e[7]=t.requestId,e[8]=m):m=e[8];const h=m;if(t.mode==="url"&&t.url){const y=t.url;let q;e[9]!==t.message?(q=s.jsx("p",{className:"text-sm leading-relaxed text-foreground",children:t.message}),e[9]=t.message,e[10]=q):q=e[10];let b;e[11]!==y?(b=s.jsx("p",{className:"mt-1 truncate font-mono text-xs text-muted-foreground",title:y,children:y}),e[11]=y,e[12]=b):b=e[12];let M;e[13]!==i||e[14]!==t.requestId||e[15]!==y?(M=()=>{window.open(y,"_blank","noopener,noreferrer"),i(t.requestId,{action:"accept"})},e[13]=i,e[14]=t.requestId,e[15]=y,e[16]=M):M=e[16];let L;e[17]===Symbol.for("react.memo_cache_sentinel")?(L=s.jsx(yt,{"data-icon":"inline-end"}),e[17]=L):L=e[17];let k;e[18]!==n||e[19]!==M?(k=s.jsxs(V,{size:"sm",disabled:n,onClick:M,children:["Open link",L]}),e[18]=n,e[19]=M,e[20]=k):k=e[20];let D;e[21]!==h||e[22]!==n?(D=s.jsx(V,{variant:"ghost",size:"sm",disabled:n,onClick:h,children:"Decline"}),e[21]=h,e[22]=n,e[23]=D):D=e[23];let E;e[24]!==D||e[25]!==k?(E=s.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[k,D]}),e[24]=D,e[25]=k,e[26]=E):E=e[26];let _;return e[27]!==u||e[28]!==E||e[29]!==q||e[30]!==b?(_=s.jsxs(Oe,{server:u,children:[q,b,E]}),e[27]=u,e[28]=E,e[29]=q,e[30]=b,e[31]=_):_=e[31],_}let a;e[32]!==t.message?(a=s.jsx("p",{className:"text-sm leading-relaxed text-foreground",children:t.message}),e[32]=t.message,e[33]=a):a=e[33];let g;if(e[34]!==t.fields||e[35]!==t.requestId||e[36]!==n||e[37]!==o){let y;e[39]!==t.requestId||e[40]!==n||e[41]!==o?(y=q=>s.jsx(Bt,{id:`elicit-${t.requestId}-${q.name}`,field:q,value:o[q.name],disabled:n,onChange:b=>j(q.name,b)},q.name),e[39]=t.requestId,e[40]=n,e[41]=o,e[42]=y):y=e[42],g=t.fields.map(y),e[34]=t.fields,e[35]=t.requestId,e[36]=n,e[37]=o,e[38]=g}else g=e[38];let f;e[43]!==g?(f=s.jsx("div",{className:"mt-3 flex flex-col gap-3",children:g}),e[43]=g,e[44]=f):f=e[44];const S=n||!p;let I;e[45]!==i||e[46]!==t.fields||e[47]!==t.requestId||e[48]!==o?(I=()=>i(t.requestId,{action:"accept",content:Vt(t.fields,o)}),e[45]=i,e[46]=t.fields,e[47]=t.requestId,e[48]=o,e[49]=I):I=e[49];let C;e[50]!==S||e[51]!==I?(C=s.jsx(V,{size:"sm",disabled:S,onClick:I,children:"Send"}),e[50]=S,e[51]=I,e[52]=C):C=e[52];let T;e[53]!==h||e[54]!==n?(T=s.jsx(V,{variant:"ghost",size:"sm",disabled:n,onClick:h,children:"Decline"}),e[53]=h,e[54]=n,e[55]=T):T=e[55];let v;e[56]!==C||e[57]!==T?(v=s.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[C,T]}),e[56]=C,e[57]=T,e[58]=v):v=e[58];let N;return e[59]!==u||e[60]!==v||e[61]!==a||e[62]!==f?(N=s.jsxs(Oe,{server:u,children:[a,f,v]}),e[59]=u,e[60]=v,e[61]=a,e[62]=f,e[63]=N):N=e[63],N}function Bt(l){const e=B.c(55),{id:t,field:n,value:i,disabled:r,onChange:o}=l;if(n.type==="boolean"){const h=i===!0;let a;e[0]!==o?(a=I=>o(I===!0),e[0]=o,e[1]=a):a=e[1];let g;e[2]!==r||e[3]!==t||e[4]!==h||e[5]!==a?(g=s.jsx(Ke,{id:t,checked:h,disabled:r,onCheckedChange:a}),e[2]=r,e[3]=t,e[4]=h,e[5]=a,e[6]=g):g=e[6];let f;e[7]!==n?(f=s.jsx(Le,{field:n}),e[7]=n,e[8]=f):f=e[8];let S;return e[9]!==t||e[10]!==g||e[11]!==f?(S=s.jsxs(Me,{htmlFor:t,className:"items-start gap-2 font-normal",children:[g,f]}),e[9]=t,e[10]=g,e[11]=f,e[12]=S):S=e[12],S}if(n.type==="enum"){let h;e[13]!==n?(h=s.jsx(Le,{field:n}),e[13]=n,e[14]=h):h=e[14];let a;e[15]!==t||e[16]!==h?(a=s.jsx(Me,{htmlFor:t,children:h}),e[15]=t,e[16]=h,e[17]=a):a=e[17];let g;e[18]!==i?(g=typeof i=="string"&&i?[i]:[],e[18]=i,e[19]=g):g=e[19];let f;e[20]!==o?(f=N=>{N[0]&&o(N[0])},e[20]=o,e[21]=f):f=e[21];const S=n.label;let I;e[22]!==n.options?(I=n.options??[],e[22]=n.options,e[23]=I):I=e[23];let C;if(e[24]!==r||e[25]!==I){let N;e[27]!==r?(N=y=>s.jsx(Ce,{value:y.value,disabled:r,className:"w-full justify-start px-3",children:y.label},y.value),e[27]=r,e[28]=N):N=e[28],C=I.map(N),e[24]=r,e[25]=I,e[26]=C}else C=e[26];let T;e[29]!==n.label||e[30]!==t||e[31]!==g||e[32]!==f||e[33]!==C?(T=s.jsx(Fe,{id:t,value:g,onValueChange:f,orientation:"vertical",variant:"outline",size:"sm",className:"w-full items-stretch","aria-label":S,children:C}),e[29]=n.label,e[30]=t,e[31]=g,e[32]=f,e[33]=C,e[34]=T):T=e[34];let v;return e[35]!==a||e[36]!==T?(v=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[a,T]}),e[35]=a,e[36]=T,e[37]=v):v=e[37],v}let c;e[38]!==n?(c=s.jsx(Le,{field:n}),e[38]=n,e[39]=c):c=e[39];let d;e[40]!==t||e[41]!==c?(d=s.jsx(Me,{htmlFor:t,children:c}),e[40]=t,e[41]=c,e[42]=d):d=e[42];const p=n.type==="string"?"text":"number",u=typeof i=="string"?i:"";let x;e[43]!==o?(x=h=>o(h.target.value),e[43]=o,e[44]=x):x=e[44];let j;e[45]!==r||e[46]!==n.label||e[47]!==t||e[48]!==p||e[49]!==u||e[50]!==x?(j=s.jsx(He,{id:t,"aria-label":n.label,type:p,value:u,disabled:r,onChange:x}),e[45]=r,e[46]=n.label,e[47]=t,e[48]=p,e[49]=u,e[50]=x,e[51]=j):j=e[51];let m;return e[52]!==d||e[53]!==j?(m=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[d,j]}),e[52]=d,e[53]=j,e[54]=m):m=e[54],m}function Le(l){const e=B.c(8),{field:t}=l;let n;e[0]!==t.required?(n=t.required&&s.jsx("span",{className:"ml-0.5 text-warning",children:"*"}),e[0]=t.required,e[1]=n):n=e[1];let i;e[2]!==t.description?(i=t.description&&s.jsx("span",{className:"block text-xs font-normal text-muted-foreground",children:t.description}),e[2]=t.description,e[3]=i):i=e[3];let r;return e[4]!==t.label||e[5]!==n||e[6]!==i?(r=s.jsxs("span",{className:"min-w-0",children:[t.label,n,i]}),e[4]=t.label,e[5]=n,e[6]=i,e[7]=r):r=e[7],r}function Oe(l){const e=B.c(8),{server:t,children:n}=l;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsx(St,{className:"text-info"}),e[0]=i):i=e[0];let r;e[1]!==t?(r=s.jsxs(Ie,{children:[t," needs input"]}),e[1]=t,e[2]=r):r=e[2];let o;e[3]!==n?(o=s.jsx("div",{className:"col-start-2 mt-1 min-w-0",children:n}),e[3]=n,e[4]=o):o=e[4];let c;return e[5]!==r||e[6]!==o?(c=s.jsxs(qe,{className:"border-info/40 bg-info/5",children:[i,r,o]}),e[5]=r,e[6]=o,e[7]=c):c=e[7],c}const Pt=["allow","allow_always","deny"],Gt=[{decision:"allow",label:"Allow",variant:"default"},{decision:"deny",label:"Deny",variant:"destructive"},{decision:"allow_always",label:"Always",variant:"outline"}];function Qt(l,e){return(l.availableDecisions??Pt).includes(e)}function Ht(l){const e=B.c(22),{request:t,queued:n,responding:i,onRespond:r}=l;let o;if(e[0]!==r||e[1]!==n||e[2]!==t||e[3]!==i){let c;e[5]!==t?(c=S=>Qt(t,S.decision),e[5]=t,e[6]=c):c=e[6];const d=Gt.filter(c),p=d.some(Kt);let u;e[7]===Symbol.for("react.memo_cache_sentinel")?(u=s.jsx(Ye,{className:"text-warning"}),e[7]=u):u=e[7];const x=t.title||`Allow ${t.toolName}?`;let j;e[8]!==x?(j=s.jsx("span",{className:"min-w-0 flex-1 truncate",children:x}),e[8]=x,e[9]=j):j=e[9];let m;e[10]!==n?(m=n>0&&s.jsxs("span",{className:"shrink-0 font-mono text-xs text-warning",children:["+",n]}),e[10]=n,e[11]=m):m=e[11];let h;e[12]!==j||e[13]!==m?(h=s.jsxs(Ie,{className:"flex min-w-0 items-center gap-2",children:[j,m]}),e[12]=j,e[13]=m,e[14]=h):h=e[14];let a;e[15]!==t.toolName?(a=s.jsx("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:t.toolName}),e[15]=t.toolName,e[16]=a):a=e[16];let g;e[17]!==t.summary?(g=t.summary&&s.jsx("code",{className:"min-w-0 flex-1 truncate rounded bg-muted px-2 py-1 font-mono text-xs text-foreground",children:t.summary}),e[17]=t.summary,e[18]=g):g=e[18];let f;e[19]!==a||e[20]!==g?(f=s.jsxs("div",{className:"col-start-2 mt-2 flex min-w-0 items-center gap-2",children:[a,g]}),e[19]=a,e[20]=g,e[21]=f):f=e[21],o=s.jsxs(qe,{className:"border-warning/40 bg-warning/5",children:[u,h,f,p?s.jsx("div",{className:"col-start-2 mt-3 flex items-center gap-2",children:d.map(S=>{const{decision:I,label:C,variant:T}=S;return s.jsx(V,{size:"xs",variant:T,disabled:i,onClick:()=>r(t.requestId,I),children:C},I)})}):s.jsx("p",{className:"col-start-2 mt-2 text-xs text-warning",children:"Resolve this approval in its own provider"})]}),e[0]=r,e[1]=n,e[2]=t,e[3]=i,e[4]=o}else o=e[4];return o}function Kt(l){return l.decision!=="allow_always"}function Wt(l){return l.some(e=>e.options.length===0||e.options.some(t=>t.hasPreview))}function Xt(l){const e=B.c(63),{request:t,responding:n,gone:i,onAnswer:r,onOpenSession:o}=l,c=t.questions,[d,p]=z.useState(0);let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u={},e[0]=u):u=e[0];const x=z.useRef(u);let j;e[1]===Symbol.for("react.memo_cache_sentinel")?(j=new Set,e[1]=j):j=e[1];const[m,h]=z.useState(j);if(c.length===0)return null;if(Wt(c)){let w;e[2]!==c[0].question?(w=s.jsx("p",{className:"text-sm leading-relaxed text-foreground",children:c[0].question}),e[2]=c[0].question,e[3]=w):w=e[3];let $;e[4]===Symbol.for("react.memo_cache_sentinel")?($=s.jsx(De,{"data-icon":"inline-end"}),e[4]=$):$=e[4];let A;e[5]!==o?(A=s.jsxs(V,{variant:"outline",size:"sm",onClick:o,className:"mt-3",children:["Open full question",$]}),e[5]=o,e[6]=A):A=e[6];let P;return e[7]!==w||e[8]!==A?(P=s.jsxs(Ve,{children:[w,A]}),e[7]=w,e[8]=A,e[9]=P):P=e[9],P}const a=c[d];let g;e[10]!==a.question||e[11]!==d||e[12]!==r||e[13]!==c.length||e[14]!==t.toolUseId?(g=function($){const A={...x.current,[a.question]:$};if(d+1<c.length){x.current=A,h(new Set),p(d+1);return}r(t.toolUseId,A)},e[10]=a.question,e[11]=d,e[12]=r,e[13]=c.length,e[14]=t.toolUseId,e[15]=g):g=e[15];const f=g;let S;e[16]!==a.header?(S=a.header&&s.jsx(Te,{variant:"outline",className:"border-info/40 text-info",children:a.header}),e[16]=a.header,e[17]=S):S=e[17];let I;e[18]!==d||e[19]!==c.length?(I=c.length>1&&s.jsxs("span",{className:"ml-auto shrink-0 font-mono text-xs text-muted-foreground",children:[d+1," of ",c.length]}),e[18]=d,e[19]=c.length,e[20]=I):I=e[20];let C;e[21]!==S||e[22]!==I?(C=s.jsxs("div",{className:"flex items-baseline gap-1.5",children:[S,I]}),e[21]=S,e[22]=I,e[23]=C):C=e[23];let T;e[24]!==a.question?(T=s.jsx("p",{className:"mt-2 line-clamp-3 text-sm leading-relaxed text-foreground",title:a.question,children:a.question}),e[24]=a.question,e[25]=T):T=e[25];let v;e[26]!==m?(v=[...m],e[26]=m,e[27]=v):v=e[27];let N;e[28]!==f||e[29]!==a.multiSelect?(N=w=>{a.multiSelect?h(new Set(w)):w[0]&&f(w[0])},e[28]=f,e[29]=a.multiSelect,e[30]=N):N=e[30];const y=a.multiSelect,q=a.question;let b;if(e[31]!==a.options||e[32]!==n){let w;e[34]!==n?(w=$=>s.jsx(Jt,{option:$,disabled:n},$.label),e[34]=n,e[35]=w):w=e[35],b=a.options.map(w),e[31]=a.options,e[32]=n,e[33]=b}else b=e[33];let M;e[36]!==a.multiSelect||e[37]!==a.question||e[38]!==b||e[39]!==v||e[40]!==N?(M=s.jsx(Fe,{value:v,onValueChange:N,multiple:y,orientation:"vertical",variant:"outline",size:"sm",className:"mt-3 w-full items-stretch","aria-label":q,children:b}),e[36]=a.multiSelect,e[37]=a.question,e[38]=b,e[39]=v,e[40]=N,e[41]=M):M=e[41];let L;e[42]!==f||e[43]!==a.multiSelect||e[44]!==d||e[45]!==c.length||e[46]!==n||e[47]!==m?(L=a.multiSelect&&s.jsx(V,{size:"sm",disabled:n||m.size===0,onClick:()=>f(We(m)),children:d+1<c.length?"Next":"Send"}),e[42]=f,e[43]=a.multiSelect,e[44]=d,e[45]=c.length,e[46]=n,e[47]=m,e[48]=L):L=e[48];let k;e[49]===Symbol.for("react.memo_cache_sentinel")?(k=s.jsx(De,{"data-icon":"inline-end"}),e[49]=k):k=e[49];let D;e[50]!==o?(D=s.jsxs(V,{variant:"ghost",size:"sm",onClick:o,className:"ml-auto text-muted-foreground",children:["Open session",k]}),e[50]=o,e[51]=D):D=e[51];let E;e[52]!==L||e[53]!==D?(E=s.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[L,D]}),e[52]=L,e[53]=D,e[54]=E):E=e[54];let _;e[55]!==i?(_=i&&s.jsx("p",{className:"mt-2 text-xs text-warning",children:"This question may already be answered. Open the session to check."}),e[55]=i,e[56]=_):_=e[56];let O;return e[57]!==M||e[58]!==E||e[59]!==_||e[60]!==C||e[61]!==T?(O=s.jsxs(Ve,{children:[C,T,M,E,_]}),e[57]=M,e[58]=E,e[59]=_,e[60]=C,e[61]=T,e[62]=O):O=e[62],O}function Jt(l){const e=B.c(17),{option:t,disabled:n}=l;let i;e[0]!==t.label?(i=s.jsx("span",{className:"min-w-0 flex-1 truncate text-left",children:t.label}),e[0]=t.label,e[1]=i):i=e[1];const r=i;if(!t.description){let u;return e[2]!==n||e[3]!==r||e[4]!==t.label?(u=s.jsx(Ce,{value:t.label,disabled:n,className:"w-full justify-start px-3",children:r}),e[2]=n,e[3]=r,e[4]=t.label,e[5]=u):u=e[5],u}let o;e[6]!==n||e[7]!==t.label?(o=s.jsx(Ce,{value:t.label,disabled:n,className:"w-full justify-start px-3"}),e[6]=n,e[7]=t.label,e[8]=o):o=e[8];let c;e[9]!==r||e[10]!==o?(c=s.jsx(Je,{render:o,children:r}),e[9]=r,e[10]=o,e[11]=c):c=e[11];let d;e[12]!==t.description?(d=s.jsx(Xe,{side:"right",className:"max-w-72 text-left",children:t.description}),e[12]=t.description,e[13]=d):d=e[13];let p;return e[14]!==c||e[15]!==d?(p=s.jsxs(Ze,{children:[c,d]}),e[14]=c,e[15]=d,e[16]=p):p=e[16],p}function Ve(l){const e=B.c(4),{children:t}=l;let n,i;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx(ye,{className:"text-info"}),i=s.jsx(Ie,{children:"Answer to continue"}),e[0]=n,e[1]=i):(n=e[0],i=e[1]);let r;return e[2]!==t?(r=s.jsxs(qe,{className:"border-info/40 bg-info/5",children:[n,i,s.jsx("div",{className:"col-start-2 mt-1 min-w-0",children:t})]}),e[2]=t,e[3]=r):r=e[3],r}function Zt(l){const e=B.c(33),{request:t,responding:n,onChoose:i}=l;let r,o;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsx(Ye,{className:"text-warning"}),o=s.jsx(Ie,{children:"Claude declined this request"}),e[0]=r,e[1]=o):(r=e[0],o=e[1]);let c;e[2]!==t.originalModel?(c=s.jsxs("p",{className:"text-sm leading-relaxed text-foreground",children:[t.originalModel," would not answer. Retrying on a fallback model may work."]}),e[2]=t.originalModel,e[3]=c):c=e[3];let d;e[4]!==t.guidanceText?(d=t.guidanceText&&s.jsx("p",{className:"mt-1 text-sm leading-relaxed text-muted-foreground",children:t.guidanceText}),e[4]=t.guidanceText,e[5]=d):d=e[5];let p;e[6]!==i||e[7]!==t.requestId?(p=()=>i(t.requestId,"retry_fallback"),e[6]=i,e[7]=t.requestId,e[8]=p):p=e[8];let u;e[9]!==t.fallbackModel||e[10]!==n||e[11]!==p?(u=s.jsxs(V,{size:"sm",disabled:n,onClick:p,children:["Retry on ",t.fallbackModel]}),e[9]=t.fallbackModel,e[10]=n,e[11]=p,e[12]=u):u=e[12];let x;e[13]!==i||e[14]!==t.requestId?(x=()=>i(t.requestId,"edit_prompt"),e[13]=i,e[14]=t.requestId,e[15]=x):x=e[15];let j;e[16]!==n||e[17]!==x?(j=s.jsx(V,{variant:"outline",size:"sm",disabled:n,onClick:x,children:"Edit prompt"}),e[16]=n,e[17]=x,e[18]=j):j=e[18];let m;e[19]!==i||e[20]!==t.requestId?(m=()=>i(t.requestId,"cancelled"),e[19]=i,e[20]=t.requestId,e[21]=m):m=e[21];let h;e[22]!==n||e[23]!==m?(h=s.jsx(V,{variant:"ghost",size:"sm",disabled:n,className:"ml-auto text-muted-foreground",onClick:m,children:"Dismiss"}),e[22]=n,e[23]=m,e[24]=h):h=e[24];let a;e[25]!==h||e[26]!==u||e[27]!==j?(a=s.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[u,j,h]}),e[25]=h,e[26]=u,e[27]=j,e[28]=a):a=e[28];let g;return e[29]!==a||e[30]!==c||e[31]!==d?(g=s.jsxs(qe,{className:"border-warning/40 bg-warning/5",children:[r,o,s.jsxs("div",{className:"col-start-2 mt-1 min-w-0",children:[c,d,a]})]}),e[29]=a,e[30]=c,e[31]=d,e[32]=g):g=e[32],g}function Be(l){return l==="awaiting_approval"||l==="awaiting_prompt"||l==="awaiting_question"||l==="awaiting_answer"}function Ae(l){return l==="done"||l==="failed"}const Ue={awaiting_approval:0,awaiting_prompt:1,awaiting_question:2,awaiting_answer:3,running:4,failed:5,done:6};function es(l,e,t,n,i){return t?"awaiting_approval":n?"awaiting_prompt":i?"awaiting_question":l.agentStatus==="deferred"||l.agentStatus==="idle"&&e?"awaiting_answer":l.agentTerminalReason?"failed":e&&l.agentStatus&&st.has(l.agentStatus)?"running":"done"}const ts=6;function ss({sessions:l,procBySession:e,summaries:t,permissionsBySession:n,questionsBySession:i,elicitationsBySession:r,dialogsBySession:o,newlyCompleted:c,finishedLimit:d=ts,now:p=Date.now()}){const u=[];for(const m of et(l)){const h=n.get(m.sessionId)??[],a=i.get(m.sessionId)??[],g=r.get(m.sessionId)??[],f=o.get(m.sessionId)??[],S=h.length+a.length+g.length+f.length;m.teamName&&m.agentName&&S===0||u.push({session:m,state:es(m,tt(m,e,p),h.length>0,g.length>0||f.length>0,a.length>0),summary:t.get(m.sessionId)??null,permissions:h,questions:a,elicitations:g,dialogs:f})}const x=u.filter(m=>Ae(m.state)),j=[...x.filter(m=>c.has(m.session.sessionId)),...x.filter(m=>!c.has(m.session.sessionId))].slice(0,d);return[...u.filter(m=>!Ae(m.state)),...j].sort((m,h)=>Ue[m.state]-Ue[h.state])}function ns(l,e){switch(e){case"running":return l.filter(t=>t.state==="running");case"needs-you":return l.filter(t=>Be(t.state));case"finished":return l.filter(t=>Ae(t.state));default:return l}}function is(l){const e={total:l.length,running:0,needsYou:0,finished:0,failed:0};for(const t of l)t.state==="running"&&e.running++,Be(t.state)&&e.needsYou++,Ae(t.state)&&e.finished++,t.state==="failed"&&e.failed++;return e}function ls(l){return l>=90?"text-destructive":l>=70?"text-warning":"text-muted-foreground"}const os={awaiting_approval:{label:"Waiting for approval",text:"text-warning",shell:"border-warning/40 bg-warning/5",icon:ye},awaiting_prompt:{label:"Waiting for your input",text:"text-info",shell:"border-info/40 bg-info/5",icon:ye},awaiting_question:{label:"Waiting for your answer",text:"text-info",shell:"border-info/40 bg-info/5",icon:ye},awaiting_answer:{label:"Waiting for your answer",text:"text-warning",shell:"border-warning/40 bg-warning/5",icon:ye},running:{label:"Running",text:"text-info",shell:"border-border",icon:null},done:{label:"Done",text:"text-success",shell:"border-border",icon:qt},failed:{label:"Failed",text:"text-destructive",shell:"border-destructive/40",icon:It}};function as(l){const e=B.c(3),{icon:t}=l;if(!t){let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsx("span",{className:"size-2 shrink-0 rounded-full bg-info"}),e[0]=i):i=e[0],i}let n;return e[1]!==t?(n=s.jsx(t,{className:"size-3.5 shrink-0"}),e[1]=t,e[2]=n):n=e[2],n}const rs=z.memo(function(e){const t=B.c(88),{card:n,customName:i,projectLabel:r,responding:o,goneQuestions:c,compact:d,onOpen:p,onRespond:u,onAnswerQuestion:x,onAnswerElicitation:j,onChooseDialog:m}=e,h=d===void 0?!1:d,{session:a,state:g,summary:f,permissions:S,questions:I,elicitations:C,dialogs:T}=n,v=os[g],N=S[0],y=I[0],q=C[0],b=T[0],M=!!(N||y||q||b);let L;t[0]!==i||t[1]!==a?(L=nt(a,i),t[0]=i,t[1]=a,t[2]=L):L=t[2];const k=L,D=h&&"gap-1.5 py-2";let E;t[3]!==v.shell||t[4]!==D?(E=ue("motion-card motion-list-item group flex min-w-0 flex-col gap-2 rounded-lg border bg-card p-3 text-left transition-colors hover:border-foreground/20",v.shell,D),t[3]=v.shell,t[4]=D,t[5]=E):E=t[5];const _=`Open session ${k}`;let O;t[6]!==r?(O=s.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground",children:r}),t[6]=r,t[7]=O):O=t[7];let w;t[8]!==f?(w=(f==null?void 0:f.model)&&s.jsx("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:it(f.model)}),t[8]=f,t[9]=w):w=t[9];let $;t[10]===Symbol.for("react.memo_cache_sentinel")?($=s.jsx(De,{"data-icon":"inline-end",className:"shrink-0 text-transparent transition-colors group-hover:text-muted-foreground"}),t[10]=$):$=t[10];let A;t[11]!==O||t[12]!==w?(A=s.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[O,w,$]}),t[11]=O,t[12]=w,t[13]=A):A=t[13];const P=h?"truncate":"line-clamp-2";let G;t[14]!==P?(G=ue("text-sm font-medium leading-snug text-foreground",P),t[14]=P,t[15]=G):G=t[15];let ne;t[16]!==G||t[17]!==k?(ne=s.jsx("span",{className:G,children:k}),t[16]=G,t[17]=k,t[18]=ne):ne=t[18];let ie;t[19]!==p||t[20]!==ne||t[21]!==_||t[22]!==A?(ie=s.jsxs(V,{variant:"ghost",onClick:p,className:"-m-1 h-auto min-w-0 flex-col items-stretch justify-start gap-1 whitespace-normal p-1 text-left","aria-label":_,children:[A,ne]}),t[19]=p,t[20]=ne,t[21]=_,t[22]=A,t[23]=ie):ie=t[23];let le;t[24]!==v.text?(le=ue("flex items-center gap-1.5 text-xs font-medium",v.text),t[24]=v.text,t[25]=le):le=t[25];let se;t[26]!==v.icon?(se=s.jsx(as,{icon:v.icon}),t[26]=v.icon,t[27]=se):se=t[27];let oe;t[28]!==v.label?(oe=s.jsx("span",{className:"truncate",children:v.label}),t[28]=v.label,t[29]=oe):oe=t[29];const re=a.lastActivityAt||a.lastModified;let ae;t[30]!==re?(ae=lt(re),t[30]=re,t[31]=ae):ae=t[31];let Q;t[32]!==ae?(Q=s.jsx("span",{className:"ml-auto shrink-0 font-mono text-xs font-normal text-muted-foreground",children:ae}),t[32]=ae,t[33]=Q):Q=t[33];let H;t[34]!==le||t[35]!==se||t[36]!==oe||t[37]!==Q?(H=s.jsxs("div",{className:le,children:[se,oe,Q]}),t[34]=le,t[35]=se,t[36]=oe,t[37]=Q,t[38]=H):H=t[38];let K;t[39]!==u||t[40]!==S.length||t[41]!==N||t[42]!==o||t[43]!==a.sessionId?(K=N&&s.jsx(Ht,{request:N,queued:S.length-1,responding:o.has(N.requestId),onRespond:(U,Y)=>u(a.sessionId,U,Y)}),t[39]=u,t[40]=S.length,t[41]=N,t[42]=o,t[43]=a.sessionId,t[44]=K):K=t[44];let W;t[45]!==b||t[46]!==m||t[47]!==N||t[48]!==o||t[49]!==a.sessionId?(W=!N&&b&&s.jsx(Zt,{request:b,responding:o.has(b.requestId),onChoose:(U,Y)=>m(a.sessionId,U,Y)},b.requestId),t[45]=b,t[46]=m,t[47]=N,t[48]=o,t[49]=a.sessionId,t[50]=W):W=t[50];let X;t[51]!==b||t[52]!==q||t[53]!==j||t[54]!==N||t[55]!==o||t[56]!==a.sessionId?(X=!N&&!b&&q&&s.jsx(Yt,{request:q,responding:o.has(q.requestId),onAnswer:(U,Y)=>j(a.sessionId,U,Y)},q.requestId),t[51]=b,t[52]=q,t[53]=j,t[54]=N,t[55]=o,t[56]=a.sessionId,t[57]=X):X=t[57];let J;t[58]!==b||t[59]!==q||t[60]!==c||t[61]!==x||t[62]!==p||t[63]!==y||t[64]!==N||t[65]!==o||t[66]!==a.sessionId?(J=!N&&!b&&!q&&y&&s.jsx(Xt,{request:y,responding:o.has(y.toolUseId),gone:c.has(y.toolUseId),onAnswer:(U,Y)=>x(a.sessionId,U,Y),onOpenSession:p},y.toolUseId),t[58]=b,t[59]=q,t[60]=c,t[61]=x,t[62]=p,t[63]=y,t[64]=N,t[65]=o,t[66]=a.sessionId,t[67]=J):J=t[67];let Z;t[68]!==M||t[69]!==f?(Z=!M&&(f==null?void 0:f.currentTool)&&s.jsx(cs,{tool:f.currentTool}),t[68]=M,t[69]=f,t[70]=Z):Z=t[70];let ee;t[71]!==M||t[72]!==h||t[73]!==f?(ee=!h&&!M&&(f==null?void 0:f.lastAssistantText)&&s.jsx("p",{className:"line-clamp-4 text-sm leading-relaxed text-muted-foreground",children:f.lastAssistantText}),t[71]=M,t[72]=h,t[73]=f,t[74]=ee):ee=t[74];let te;t[75]!==f?(te=f&&s.jsx(ds,{summary:f}),t[75]=f,t[76]=te):te=t[76];let ce;return t[77]!==ie||t[78]!==H||t[79]!==K||t[80]!==W||t[81]!==X||t[82]!==J||t[83]!==Z||t[84]!==ee||t[85]!==te||t[86]!==E?(ce=s.jsxs("div",{className:E,children:[ie,H,K,W,X,J,Z,ee,te]}),t[77]=ie,t[78]=H,t[79]=K,t[80]=W,t[81]=X,t[82]=J,t[83]=Z,t[84]=ee,t[85]=te,t[86]=E,t[87]=ce):ce=t[87],ce});function cs(l){const e=B.c(7),{tool:t}=l;let n;e[0]!==t.name?(n=s.jsx("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:t.name}),e[0]=t.name,e[1]=n):n=e[1];let i;e[2]!==t.summary?(i=s.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-xs text-foreground/80",children:t.summary}),e[2]=t.summary,e[3]=i):i=e[3];let r;return e[4]!==n||e[5]!==i?(r=s.jsxs("div",{className:"flex min-w-0 items-center gap-2 rounded-md bg-muted/50 px-2.5 py-2",children:[n,i]}),e[4]=n,e[5]=i,e[6]=r):r=e[6],r}function ds(l){const e=B.c(11),{summary:t}=l,n=t.filesTotal,i=t.context,r=n.count>0,o=i!==null&&i.used>0;if(!r&&!o)return null;let c;e[0]!==n.additions||e[1]!==n.count||e[2]!==n.deletions||e[3]!==r?(c=r&&s.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsxs("span",{className:"truncate",children:[n.count," file",n.count===1?"":"s"]}),s.jsx(ot,{add:n.additions,del:n.deletions})]}),e[0]=n.additions,e[1]=n.count,e[2]=n.deletions,e[3]=r,e[4]=c):c=e[4];let d;e[5]!==i||e[6]!==o?(d=o&&s.jsxs("span",{className:ue("ml-auto shrink-0",ls(i.percent)),children:["ctx ",i.percent,"%"]}),e[5]=i,e[6]=o,e[7]=d):d=e[7];let p;return e[8]!==c||e[9]!==d?(p=s.jsxs("div",{className:"mt-auto flex items-center gap-2 border-t pt-2 font-mono text-xs text-muted-foreground",children:[c,d]}),e[8]=c,e[9]=d,e[10]=p):p=e[10],p}const us=8e3,fs=12,ms="Start Claude Code or Codex and every session shows up here",xs=[{id:"all",label:"All"},{id:"running",label:"Running"},{id:"needs-you",label:"Needs you"},{id:"finished",label:"Finished"}],hs=[{id:"grid",label:"Grid layout",Icon:_t},{id:"list",label:"List layout",Icon:Tt}];function vs(l){const e=B.c(117),{onSelectSession:t}=l,{sessions:n,procBySession:i,newlyCompleted:r,refresh:o}=at(),{summaries:c,loading:d,error:p,refresh:u}=Rt(),{permissionsBySession:x,questionsBySession:j,elicitationsBySession:m,dialogsBySession:h,responding:a,respond:g,answerQuestion:f,answerElicitation:S,answerDialog:I,refresh:C}=rt();let T;e[0]===Symbol.for("react.memo_cache_sentinel")?(T=new Set,e[0]=T):T=e[0];const[v,N]=z.useState(T),{names:y}=ct(),{names:q}=dt(),[b,M]=z.useState("all");let L;e[1]===Symbol.for("react.memo_cache_sentinel")?(L=ut("mission-control-layout"),e[1]=L):L=e[1];const[k,D]=ft(L,"grid");let E;e[2]!==h||e[3]!==m||e[4]!==r||e[5]!==x||e[6]!==i||e[7]!==j||e[8]!==n||e[9]!==c?(E=ss({sessions:n,procBySession:i,summaries:c,permissionsBySession:x,questionsBySession:j,elicitationsBySession:m,dialogsBySession:h,newlyCompleted:r}),e[2]=h,e[3]=m,e[4]=r,e[5]=x,e[6]=i,e[7]=j,e[8]=n,e[9]=c,e[10]=E):E=e[10];const _=E;let O;e[11]!==_?(O=is(_),e[11]=_,e[12]=O):O=e[12];const w=O;let $;e[13]!==_||e[14]!==b?($=ns(_,b),e[13]=_,e[14]=b,e[15]=$):$=e[15];const A=$;let P;e[16]!==C||e[17]!==o||e[18]!==u?(P=()=>{o(),u(),C()},e[16]=C,e[17]=o,e[18]=u,e[19]=P):P=e[19];const G=P;let ne,ie;e[20]!==o?(ne=()=>{const F=setInterval(()=>{document.visibilityState==="visible"&&o()},us);return()=>clearInterval(F)},ie=[o],e[20]=o,e[21]=ne,e[22]=ie):(ne=e[21],ie=e[22]),z.useEffect(ne,ie);let le;e[23]!==f?(le=async(F,R,Re)=>{(await f(F,R,Re)).ok||N(Pe=>new Set(Pe).add(R))},e[23]=f,e[24]=le):le=e[24];const se=le;let oe;e[25]!==_.length?(oe=function(R){_.length<=fs?zt(R,{kind:"fade"}):z.startTransition(R)},e[25]=_.length,e[26]=oe):oe=e[26];const re=oe;let ae;e[27]===Symbol.for("react.memo_cache_sentinel")?(ae=s.jsx("h2",{className:"truncate text-sm font-semibold",children:"Mission Control"}),e[27]=ae):ae=e[27];let Q;e[28]!==w.total?(Q=s.jsx(Te,{variant:"secondary",children:w.total}),e[28]=w.total,e[29]=Q):Q=e[29];let H;e[30]!==w.needsYou?(H=w.needsYou>0&&s.jsxs(Te,{variant:"outline",className:"border-warning/40 text-warning",children:[w.needsYou," need you"]}),e[30]=w.needsYou,e[31]=H):H=e[31];let K;e[32]!==w.failed?(K=w.failed>0&&s.jsxs(Te,{variant:"destructive",children:[w.failed," failed"]}),e[32]=w.failed,e[33]=K):K=e[33];let W;e[34]!==Q||e[35]!==H||e[36]!==K?(W=s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[ae,Q,H,K]}),e[34]=Q,e[35]=H,e[36]=K,e[37]=W):W=e[37];let X;e[38]!==b?(X=[b],e[38]=b,e[39]=X):X=e[39];let J;e[40]!==b||e[41]!==re?(J=F=>{const R=F.at(-1);R&&R!==b&&re(()=>M(R))},e[40]=b,e[41]=re,e[42]=J):J=e[42];let Z;e[43]!==w.needsYou?(Z=xs.map(F=>s.jsxs(Ce,{value:F.id,"aria-label":`Show ${F.label.toLowerCase()} sessions`,children:[F.label,F.id==="needs-you"&&w.needsYou>0&&s.jsx("span",{className:"font-mono text-warning",children:w.needsYou})]},F.id)),e[43]=w.needsYou,e[44]=Z):Z=e[44];let ee;e[45]!==X||e[46]!==J||e[47]!==Z?(ee=s.jsx(Fe,{value:X,onValueChange:J,variant:"outline",size:"sm",spacing:0,"aria-label":"Filter sessions",children:Z}),e[45]=X,e[46]=J,e[47]=Z,e[48]=ee):ee=e[48];let te;e[49]!==k||e[50]!==D||e[51]!==re?(te=hs.map(F=>{const{id:R,label:Re,Icon:ze}=F;return s.jsx(V,{variant:"ghost",size:"icon-xs","aria-label":Re,"aria-pressed":k===R,onClick:()=>{R!==k&&re(()=>D(R))},className:ue(k===R&&"bg-accent text-accent-foreground"),children:s.jsx(ze,{"data-icon":"inline-start"})},R)}),e[49]=k,e[50]=D,e[51]=re,e[52]=te):te=e[52];const ce=d&&"animate-spin";let U;e[53]!==ce?(U=ue(ce),e[53]=ce,e[54]=U):U=e[54];let Y;e[55]!==U?(Y=s.jsx(kt,{"data-icon":"inline-start",className:U}),e[55]=U,e[56]=Y):Y=e[56];let fe;e[57]!==G||e[58]!==Y?(fe=s.jsx(V,{variant:"ghost",size:"icon-xs","aria-label":"Refresh Mission Control",onClick:G,children:Y}),e[57]=G,e[58]=Y,e[59]=fe):fe=e[59];let me;e[60]!==te||e[61]!==fe?(me=s.jsxs("div",{className:"flex items-center gap-1",children:[te,fe]}),e[60]=te,e[61]=fe,e[62]=me):me=e[62];let xe;e[63]!==ee||e[64]!==me?(xe=s.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[ee,me]}),e[63]=ee,e[64]=me,e[65]=xe):xe=e[65];let he;e[66]!==W||e[67]!==xe?(he=s.jsxs("header",{className:"flex min-h-12 shrink-0 flex-wrap items-center gap-3 border-b px-4 py-2",children:[W,xe]}),e[66]=W,e[67]=xe,e[68]=he):he=e[68];let ge;e[69]!==p||e[70]!==G?(ge=p&&s.jsxs(qe,{variant:"destructive",className:"mb-4",children:[s.jsx(At,{}),s.jsx(Ie,{children:"Mission Control could not refresh"}),s.jsx(jt,{className:"truncate",children:p}),s.jsx(wt,{children:s.jsx(V,{variant:"outline",size:"xs",onClick:G,children:"Retry"})})]}),e[69]=p,e[70]=G,e[71]=ge):ge=e[71];let pe;e[72]!==_.length||e[73]!==b||e[74]!==d||e[75]!==A.length?(pe=A.length===0&&!d&&s.jsx(mt,{className:"min-h-64",children:s.jsxs(xt,{children:[s.jsx(ht,{variant:"icon",children:s.jsx(Ct,{})}),s.jsx(gt,{children:_.length===0?"No live sessions":`Nothing matches "${b}"`}),s.jsx(pt,{children:_.length===0?ms:"Try a different filter."})]})}),e[72]=_.length,e[73]=b,e[74]=d,e[75]=A.length,e[76]=pe):pe=e[76];let be;e[77]!==_.length||e[78]!==d||e[79]!==A.length?(be=A.length===0&&d&&_.length===0&&s.jsxs("div",{className:"flex items-center justify-center gap-2 py-16 text-sm text-muted-foreground",children:[s.jsx(bt,{}),"Loading sessions…"]}),e[77]=_.length,e[78]=d,e[79]=A.length,e[80]=be):be=e[80];const Ee=k==="grid"&&"md:grid-cols-2 2xl:grid-cols-3";let je;e[81]!==Ee?(je=ue("grid grid-cols-1 gap-3",Ee),e[81]=Ee,e[82]=je):je=e[82];let we;if(e[83]!==I||e[84]!==S||e[85]!==v||e[86]!==se||e[87]!==k||e[88]!==t||e[89]!==q||e[90]!==g||e[91]!==a||e[92]!==y||e[93]!==A){let F;e[95]!==I||e[96]!==S||e[97]!==v||e[98]!==se||e[99]!==k||e[100]!==t||e[101]!==q||e[102]!==g||e[103]!==a||e[104]!==y?(F=R=>s.jsx(rs,{card:R,compact:k==="list",customName:y[R.session.sessionId],projectLabel:q[R.session.dirName]??vt(R.session),responding:a,goneQuestions:v,onOpen:()=>t(R.session.dirName,R.session.fileName),onRespond:g,onAnswerQuestion:se,onAnswerElicitation:S,onChooseDialog:I},R.session.sessionId),e[95]=I,e[96]=S,e[97]=v,e[98]=se,e[99]=k,e[100]=t,e[101]=q,e[102]=g,e[103]=a,e[104]=y,e[105]=F):F=e[105],we=A.map(F),e[83]=I,e[84]=S,e[85]=v,e[86]=se,e[87]=k,e[88]=t,e[89]=q,e[90]=g,e[91]=a,e[92]=y,e[93]=A,e[94]=we}else we=e[94];let ve;e[106]!==je||e[107]!==we?(ve=s.jsx("div",{className:je,children:we}),e[106]=je,e[107]=we,e[108]=ve):ve=e[108];let Ne;e[109]!==ge||e[110]!==pe||e[111]!==be||e[112]!==ve?(Ne=s.jsx(Nt,{className:"flex-1",children:s.jsxs("div",{className:"p-4",children:[ge,pe,be,ve]})}),e[109]=ge,e[110]=pe,e[111]=be,e[112]=ve,e[113]=Ne):Ne=e[113];let _e;return e[114]!==he||e[115]!==Ne?(_e=s.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[he,Ne]}),e[114]=he,e[115]=Ne,e[116]=_e):_e=e[116],_e}export{vs as MissionControl};
|
|
1
|
+
import{r as z,a as Ge,c as B,j as s}from"./vendor-react-gGw_S5I_.js";import{w as Qe,B as V,aG as He,aV as Ie,A as qe,aH as Ke,bb as Me,ad as Ce,ac as Fe,U as Te,bc as We,b1 as Xe,b0 as Je,a$ as Ze,bd as et,be as tt,bf as st,bg as nt,T as ue,bh as it,V as lt,aj as ot,bi as at,bj as rt,bk as ct,v as dt,ae as ut,bl as ft,E as mt,y as xt,z as ht,G as gt,H as pt,ah as bt,p as jt,bm as wt,bn as vt,q as Nt}from"./index-C3E35E2A.js";import{E as yt,ah as St,ao as Ye,C as De,ap as ye,a2 as It,aq as qt,L as _t,ar as Tt,as as Ct,c as kt,m as At}from"./vendor-ui-BmLOQ5Or.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";const Et=4e3;function Rt(){const[l,e]=z.useState([]),[t,n]=z.useState(!1),[i,r]=z.useState(null),o=z.useRef(!1);z.useEffect(()=>(o.current=!1,()=>{o.current=!0}),[]);const c=z.useCallback(async()=>{try{const u=await Qe("/api/mission-control");if(o.current)return;if(!u.ok)throw new Error(`Mission Control request failed (${u.status})`);const x=await u.json();if(o.current)return;e(Array.isArray(x.summaries)?x.summaries:[]),r(null)}catch(u){if(o.current)return;r(u instanceof Error?u.message:"Failed to load Mission Control")}finally{o.current||n(!1)}},[]);z.useEffect(()=>{n(!0);const u=()=>{(typeof document>"u"||document.visibilityState==="visible")&&c()},x=()=>{document.visibilityState==="visible"&&c()};u();const j=setInterval(u,Et);return document.addEventListener("visibilitychange",x),()=>{clearInterval(j),document.removeEventListener("visibilitychange",x)}},[c]);const d=z.useMemo(()=>{const u=new Map;for(const x of l)u.set(x.sessionId,x);return u},[l]),p=z.useCallback(()=>{c()},[c]);return{summaries:d,loading:t,error:i,refresh:p}}const ke="data-view-transition-kind",Mt="(prefers-reduced-motion: reduce)";let de=null,$e=null;function Lt(l,e,t){t===null?l.removeAttribute(e):l.setAttribute(e,t)}function Dt(l,e){const t={root:l,kind:e,previousKind:l.getAttribute(ke)};return l.setAttribute(ke,e),$e=t,t}function Se(l){$e===l&&(l.root.getAttribute(ke)===l.kind&&Lt(l.root,ke,l.previousKind),$e=null)}function $t(){const l=de;if(l){de=null;try{l.transition.skipTransition()}catch{Se(l.tag);return}Se(l.tag)}}function Ft(){if(typeof window>"u"||typeof window.matchMedia!="function")return!1;try{return window.matchMedia(Mt).matches}catch{return!1}}function zt(l,{kind:e}){$t();const t=typeof document>"u"?null:document,n=t==null?void 0:t.startViewTransition;if(!t||!(typeof n=="function")||Ft())return l(),null;const r=Dt(t.documentElement,e);let o=!1,c=!1,d;const p=u=>{if(!o){o=!0;try{u?Ge.flushSync(l):l()}catch(x){throw c=!0,d=x,x}}};try{const u=n.call(t,()=>p(!0)),x={transition:u,tag:r};return de=x,u.ready.catch(()=>{}),u.updateCallbackDone.catch(()=>{}),u.finished.then(()=>{de===x&&(de=null),Se(r)},()=>{de===x&&(de=null),Se(r)}),u}catch{if(Se(r),c)throw d;return p(!1),null}}function Ot(l){const e={};for(const t of l)t.type==="boolean"?e[t.name]=t.defaultValue===!0:t.defaultValue!==void 0?e[t.name]=String(t.defaultValue):e[t.name]="";return e}function Vt(l,e){const t={};for(const n of l){const i=e[n.name];if(typeof i=="boolean"){t[n.name]=i;continue}i!==""&&(t[n.name]=n.type==="number"||n.type==="integer"?Number(i):i)}return t}function Ut(l,e){return l.every(t=>{if(!t.required)return!0;const n=e[t.name];return typeof n=="boolean"?!0:n===""?!1:t.type==="number"||t.type==="integer"?Number.isFinite(Number(n)):!0})}function Yt(l){const e=B.c(64),{request:t,responding:n,onAnswer:i}=l;let r;e[0]!==t.fields?(r=()=>Ot(t.fields),e[0]=t.fields,e[1]=r):r=e[1];const[o,c]=z.useState(r);let d;e[2]!==t.fields||e[3]!==o?(d=Ut(t.fields,o),e[2]=t.fields,e[3]=o,e[4]=d):d=e[4];const p=d,u=t.displayName||t.title||t.serverName;let x;e[5]===Symbol.for("react.memo_cache_sentinel")?(x=(y,q)=>{c(b=>({...b,[y]:q}))},e[5]=x):x=e[5];const j=x;let m;e[6]!==i||e[7]!==t.requestId?(m=()=>i(t.requestId,{action:"decline"}),e[6]=i,e[7]=t.requestId,e[8]=m):m=e[8];const h=m;if(t.mode==="url"&&t.url){const y=t.url;let q;e[9]!==t.message?(q=s.jsx("p",{className:"text-sm leading-relaxed text-foreground",children:t.message}),e[9]=t.message,e[10]=q):q=e[10];let b;e[11]!==y?(b=s.jsx("p",{className:"mt-1 truncate font-mono text-xs text-muted-foreground",title:y,children:y}),e[11]=y,e[12]=b):b=e[12];let M;e[13]!==i||e[14]!==t.requestId||e[15]!==y?(M=()=>{window.open(y,"_blank","noopener,noreferrer"),i(t.requestId,{action:"accept"})},e[13]=i,e[14]=t.requestId,e[15]=y,e[16]=M):M=e[16];let L;e[17]===Symbol.for("react.memo_cache_sentinel")?(L=s.jsx(yt,{"data-icon":"inline-end"}),e[17]=L):L=e[17];let k;e[18]!==n||e[19]!==M?(k=s.jsxs(V,{size:"sm",disabled:n,onClick:M,children:["Open link",L]}),e[18]=n,e[19]=M,e[20]=k):k=e[20];let D;e[21]!==h||e[22]!==n?(D=s.jsx(V,{variant:"ghost",size:"sm",disabled:n,onClick:h,children:"Decline"}),e[21]=h,e[22]=n,e[23]=D):D=e[23];let E;e[24]!==D||e[25]!==k?(E=s.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[k,D]}),e[24]=D,e[25]=k,e[26]=E):E=e[26];let _;return e[27]!==u||e[28]!==E||e[29]!==q||e[30]!==b?(_=s.jsxs(Oe,{server:u,children:[q,b,E]}),e[27]=u,e[28]=E,e[29]=q,e[30]=b,e[31]=_):_=e[31],_}let a;e[32]!==t.message?(a=s.jsx("p",{className:"text-sm leading-relaxed text-foreground",children:t.message}),e[32]=t.message,e[33]=a):a=e[33];let g;if(e[34]!==t.fields||e[35]!==t.requestId||e[36]!==n||e[37]!==o){let y;e[39]!==t.requestId||e[40]!==n||e[41]!==o?(y=q=>s.jsx(Bt,{id:`elicit-${t.requestId}-${q.name}`,field:q,value:o[q.name],disabled:n,onChange:b=>j(q.name,b)},q.name),e[39]=t.requestId,e[40]=n,e[41]=o,e[42]=y):y=e[42],g=t.fields.map(y),e[34]=t.fields,e[35]=t.requestId,e[36]=n,e[37]=o,e[38]=g}else g=e[38];let f;e[43]!==g?(f=s.jsx("div",{className:"mt-3 flex flex-col gap-3",children:g}),e[43]=g,e[44]=f):f=e[44];const S=n||!p;let I;e[45]!==i||e[46]!==t.fields||e[47]!==t.requestId||e[48]!==o?(I=()=>i(t.requestId,{action:"accept",content:Vt(t.fields,o)}),e[45]=i,e[46]=t.fields,e[47]=t.requestId,e[48]=o,e[49]=I):I=e[49];let C;e[50]!==S||e[51]!==I?(C=s.jsx(V,{size:"sm",disabled:S,onClick:I,children:"Send"}),e[50]=S,e[51]=I,e[52]=C):C=e[52];let T;e[53]!==h||e[54]!==n?(T=s.jsx(V,{variant:"ghost",size:"sm",disabled:n,onClick:h,children:"Decline"}),e[53]=h,e[54]=n,e[55]=T):T=e[55];let v;e[56]!==C||e[57]!==T?(v=s.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[C,T]}),e[56]=C,e[57]=T,e[58]=v):v=e[58];let N;return e[59]!==u||e[60]!==v||e[61]!==a||e[62]!==f?(N=s.jsxs(Oe,{server:u,children:[a,f,v]}),e[59]=u,e[60]=v,e[61]=a,e[62]=f,e[63]=N):N=e[63],N}function Bt(l){const e=B.c(55),{id:t,field:n,value:i,disabled:r,onChange:o}=l;if(n.type==="boolean"){const h=i===!0;let a;e[0]!==o?(a=I=>o(I===!0),e[0]=o,e[1]=a):a=e[1];let g;e[2]!==r||e[3]!==t||e[4]!==h||e[5]!==a?(g=s.jsx(Ke,{id:t,checked:h,disabled:r,onCheckedChange:a}),e[2]=r,e[3]=t,e[4]=h,e[5]=a,e[6]=g):g=e[6];let f;e[7]!==n?(f=s.jsx(Le,{field:n}),e[7]=n,e[8]=f):f=e[8];let S;return e[9]!==t||e[10]!==g||e[11]!==f?(S=s.jsxs(Me,{htmlFor:t,className:"items-start gap-2 font-normal",children:[g,f]}),e[9]=t,e[10]=g,e[11]=f,e[12]=S):S=e[12],S}if(n.type==="enum"){let h;e[13]!==n?(h=s.jsx(Le,{field:n}),e[13]=n,e[14]=h):h=e[14];let a;e[15]!==t||e[16]!==h?(a=s.jsx(Me,{htmlFor:t,children:h}),e[15]=t,e[16]=h,e[17]=a):a=e[17];let g;e[18]!==i?(g=typeof i=="string"&&i?[i]:[],e[18]=i,e[19]=g):g=e[19];let f;e[20]!==o?(f=N=>{N[0]&&o(N[0])},e[20]=o,e[21]=f):f=e[21];const S=n.label;let I;e[22]!==n.options?(I=n.options??[],e[22]=n.options,e[23]=I):I=e[23];let C;if(e[24]!==r||e[25]!==I){let N;e[27]!==r?(N=y=>s.jsx(Ce,{value:y.value,disabled:r,className:"w-full justify-start px-3",children:y.label},y.value),e[27]=r,e[28]=N):N=e[28],C=I.map(N),e[24]=r,e[25]=I,e[26]=C}else C=e[26];let T;e[29]!==n.label||e[30]!==t||e[31]!==g||e[32]!==f||e[33]!==C?(T=s.jsx(Fe,{id:t,value:g,onValueChange:f,orientation:"vertical",variant:"outline",size:"sm",className:"w-full items-stretch","aria-label":S,children:C}),e[29]=n.label,e[30]=t,e[31]=g,e[32]=f,e[33]=C,e[34]=T):T=e[34];let v;return e[35]!==a||e[36]!==T?(v=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[a,T]}),e[35]=a,e[36]=T,e[37]=v):v=e[37],v}let c;e[38]!==n?(c=s.jsx(Le,{field:n}),e[38]=n,e[39]=c):c=e[39];let d;e[40]!==t||e[41]!==c?(d=s.jsx(Me,{htmlFor:t,children:c}),e[40]=t,e[41]=c,e[42]=d):d=e[42];const p=n.type==="string"?"text":"number",u=typeof i=="string"?i:"";let x;e[43]!==o?(x=h=>o(h.target.value),e[43]=o,e[44]=x):x=e[44];let j;e[45]!==r||e[46]!==n.label||e[47]!==t||e[48]!==p||e[49]!==u||e[50]!==x?(j=s.jsx(He,{id:t,"aria-label":n.label,type:p,value:u,disabled:r,onChange:x}),e[45]=r,e[46]=n.label,e[47]=t,e[48]=p,e[49]=u,e[50]=x,e[51]=j):j=e[51];let m;return e[52]!==d||e[53]!==j?(m=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[d,j]}),e[52]=d,e[53]=j,e[54]=m):m=e[54],m}function Le(l){const e=B.c(8),{field:t}=l;let n;e[0]!==t.required?(n=t.required&&s.jsx("span",{className:"ml-0.5 text-warning",children:"*"}),e[0]=t.required,e[1]=n):n=e[1];let i;e[2]!==t.description?(i=t.description&&s.jsx("span",{className:"block text-xs font-normal text-muted-foreground",children:t.description}),e[2]=t.description,e[3]=i):i=e[3];let r;return e[4]!==t.label||e[5]!==n||e[6]!==i?(r=s.jsxs("span",{className:"min-w-0",children:[t.label,n,i]}),e[4]=t.label,e[5]=n,e[6]=i,e[7]=r):r=e[7],r}function Oe(l){const e=B.c(8),{server:t,children:n}=l;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsx(St,{className:"text-info"}),e[0]=i):i=e[0];let r;e[1]!==t?(r=s.jsxs(Ie,{children:[t," needs input"]}),e[1]=t,e[2]=r):r=e[2];let o;e[3]!==n?(o=s.jsx("div",{className:"col-start-2 mt-1 min-w-0",children:n}),e[3]=n,e[4]=o):o=e[4];let c;return e[5]!==r||e[6]!==o?(c=s.jsxs(qe,{className:"border-info/40 bg-info/5",children:[i,r,o]}),e[5]=r,e[6]=o,e[7]=c):c=e[7],c}const Pt=["allow","allow_always","deny"],Gt=[{decision:"allow",label:"Allow",variant:"default"},{decision:"deny",label:"Deny",variant:"destructive"},{decision:"allow_always",label:"Always",variant:"outline"}];function Qt(l,e){return(l.availableDecisions??Pt).includes(e)}function Ht(l){const e=B.c(22),{request:t,queued:n,responding:i,onRespond:r}=l;let o;if(e[0]!==r||e[1]!==n||e[2]!==t||e[3]!==i){let c;e[5]!==t?(c=S=>Qt(t,S.decision),e[5]=t,e[6]=c):c=e[6];const d=Gt.filter(c),p=d.some(Kt);let u;e[7]===Symbol.for("react.memo_cache_sentinel")?(u=s.jsx(Ye,{className:"text-warning"}),e[7]=u):u=e[7];const x=t.title||`Allow ${t.toolName}?`;let j;e[8]!==x?(j=s.jsx("span",{className:"min-w-0 flex-1 truncate",children:x}),e[8]=x,e[9]=j):j=e[9];let m;e[10]!==n?(m=n>0&&s.jsxs("span",{className:"shrink-0 font-mono text-xs text-warning",children:["+",n]}),e[10]=n,e[11]=m):m=e[11];let h;e[12]!==j||e[13]!==m?(h=s.jsxs(Ie,{className:"flex min-w-0 items-center gap-2",children:[j,m]}),e[12]=j,e[13]=m,e[14]=h):h=e[14];let a;e[15]!==t.toolName?(a=s.jsx("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:t.toolName}),e[15]=t.toolName,e[16]=a):a=e[16];let g;e[17]!==t.summary?(g=t.summary&&s.jsx("code",{className:"min-w-0 flex-1 truncate rounded bg-muted px-2 py-1 font-mono text-xs text-foreground",children:t.summary}),e[17]=t.summary,e[18]=g):g=e[18];let f;e[19]!==a||e[20]!==g?(f=s.jsxs("div",{className:"col-start-2 mt-2 flex min-w-0 items-center gap-2",children:[a,g]}),e[19]=a,e[20]=g,e[21]=f):f=e[21],o=s.jsxs(qe,{className:"border-warning/40 bg-warning/5",children:[u,h,f,p?s.jsx("div",{className:"col-start-2 mt-3 flex items-center gap-2",children:d.map(S=>{const{decision:I,label:C,variant:T}=S;return s.jsx(V,{size:"xs",variant:T,disabled:i,onClick:()=>r(t.requestId,I),children:C},I)})}):s.jsx("p",{className:"col-start-2 mt-2 text-xs text-warning",children:"Resolve this approval in its own provider"})]}),e[0]=r,e[1]=n,e[2]=t,e[3]=i,e[4]=o}else o=e[4];return o}function Kt(l){return l.decision!=="allow_always"}function Wt(l){return l.some(e=>e.options.length===0||e.options.some(t=>t.hasPreview))}function Xt(l){const e=B.c(63),{request:t,responding:n,gone:i,onAnswer:r,onOpenSession:o}=l,c=t.questions,[d,p]=z.useState(0);let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u={},e[0]=u):u=e[0];const x=z.useRef(u);let j;e[1]===Symbol.for("react.memo_cache_sentinel")?(j=new Set,e[1]=j):j=e[1];const[m,h]=z.useState(j);if(c.length===0)return null;if(Wt(c)){let w;e[2]!==c[0].question?(w=s.jsx("p",{className:"text-sm leading-relaxed text-foreground",children:c[0].question}),e[2]=c[0].question,e[3]=w):w=e[3];let $;e[4]===Symbol.for("react.memo_cache_sentinel")?($=s.jsx(De,{"data-icon":"inline-end"}),e[4]=$):$=e[4];let A;e[5]!==o?(A=s.jsxs(V,{variant:"outline",size:"sm",onClick:o,className:"mt-3",children:["Open full question",$]}),e[5]=o,e[6]=A):A=e[6];let P;return e[7]!==w||e[8]!==A?(P=s.jsxs(Ve,{children:[w,A]}),e[7]=w,e[8]=A,e[9]=P):P=e[9],P}const a=c[d];let g;e[10]!==a.question||e[11]!==d||e[12]!==r||e[13]!==c.length||e[14]!==t.toolUseId?(g=function($){const A={...x.current,[a.question]:$};if(d+1<c.length){x.current=A,h(new Set),p(d+1);return}r(t.toolUseId,A)},e[10]=a.question,e[11]=d,e[12]=r,e[13]=c.length,e[14]=t.toolUseId,e[15]=g):g=e[15];const f=g;let S;e[16]!==a.header?(S=a.header&&s.jsx(Te,{variant:"outline",className:"border-info/40 text-info",children:a.header}),e[16]=a.header,e[17]=S):S=e[17];let I;e[18]!==d||e[19]!==c.length?(I=c.length>1&&s.jsxs("span",{className:"ml-auto shrink-0 font-mono text-xs text-muted-foreground",children:[d+1," of ",c.length]}),e[18]=d,e[19]=c.length,e[20]=I):I=e[20];let C;e[21]!==S||e[22]!==I?(C=s.jsxs("div",{className:"flex items-baseline gap-1.5",children:[S,I]}),e[21]=S,e[22]=I,e[23]=C):C=e[23];let T;e[24]!==a.question?(T=s.jsx("p",{className:"mt-2 line-clamp-3 text-sm leading-relaxed text-foreground",title:a.question,children:a.question}),e[24]=a.question,e[25]=T):T=e[25];let v;e[26]!==m?(v=[...m],e[26]=m,e[27]=v):v=e[27];let N;e[28]!==f||e[29]!==a.multiSelect?(N=w=>{a.multiSelect?h(new Set(w)):w[0]&&f(w[0])},e[28]=f,e[29]=a.multiSelect,e[30]=N):N=e[30];const y=a.multiSelect,q=a.question;let b;if(e[31]!==a.options||e[32]!==n){let w;e[34]!==n?(w=$=>s.jsx(Jt,{option:$,disabled:n},$.label),e[34]=n,e[35]=w):w=e[35],b=a.options.map(w),e[31]=a.options,e[32]=n,e[33]=b}else b=e[33];let M;e[36]!==a.multiSelect||e[37]!==a.question||e[38]!==b||e[39]!==v||e[40]!==N?(M=s.jsx(Fe,{value:v,onValueChange:N,multiple:y,orientation:"vertical",variant:"outline",size:"sm",className:"mt-3 w-full items-stretch","aria-label":q,children:b}),e[36]=a.multiSelect,e[37]=a.question,e[38]=b,e[39]=v,e[40]=N,e[41]=M):M=e[41];let L;e[42]!==f||e[43]!==a.multiSelect||e[44]!==d||e[45]!==c.length||e[46]!==n||e[47]!==m?(L=a.multiSelect&&s.jsx(V,{size:"sm",disabled:n||m.size===0,onClick:()=>f(We(m)),children:d+1<c.length?"Next":"Send"}),e[42]=f,e[43]=a.multiSelect,e[44]=d,e[45]=c.length,e[46]=n,e[47]=m,e[48]=L):L=e[48];let k;e[49]===Symbol.for("react.memo_cache_sentinel")?(k=s.jsx(De,{"data-icon":"inline-end"}),e[49]=k):k=e[49];let D;e[50]!==o?(D=s.jsxs(V,{variant:"ghost",size:"sm",onClick:o,className:"ml-auto text-muted-foreground",children:["Open session",k]}),e[50]=o,e[51]=D):D=e[51];let E;e[52]!==L||e[53]!==D?(E=s.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[L,D]}),e[52]=L,e[53]=D,e[54]=E):E=e[54];let _;e[55]!==i?(_=i&&s.jsx("p",{className:"mt-2 text-xs text-warning",children:"This question may already be answered. Open the session to check."}),e[55]=i,e[56]=_):_=e[56];let O;return e[57]!==M||e[58]!==E||e[59]!==_||e[60]!==C||e[61]!==T?(O=s.jsxs(Ve,{children:[C,T,M,E,_]}),e[57]=M,e[58]=E,e[59]=_,e[60]=C,e[61]=T,e[62]=O):O=e[62],O}function Jt(l){const e=B.c(17),{option:t,disabled:n}=l;let i;e[0]!==t.label?(i=s.jsx("span",{className:"min-w-0 flex-1 truncate text-left",children:t.label}),e[0]=t.label,e[1]=i):i=e[1];const r=i;if(!t.description){let u;return e[2]!==n||e[3]!==r||e[4]!==t.label?(u=s.jsx(Ce,{value:t.label,disabled:n,className:"w-full justify-start px-3",children:r}),e[2]=n,e[3]=r,e[4]=t.label,e[5]=u):u=e[5],u}let o;e[6]!==n||e[7]!==t.label?(o=s.jsx(Ce,{value:t.label,disabled:n,className:"w-full justify-start px-3"}),e[6]=n,e[7]=t.label,e[8]=o):o=e[8];let c;e[9]!==r||e[10]!==o?(c=s.jsx(Je,{render:o,children:r}),e[9]=r,e[10]=o,e[11]=c):c=e[11];let d;e[12]!==t.description?(d=s.jsx(Xe,{side:"right",className:"max-w-72 text-left",children:t.description}),e[12]=t.description,e[13]=d):d=e[13];let p;return e[14]!==c||e[15]!==d?(p=s.jsxs(Ze,{children:[c,d]}),e[14]=c,e[15]=d,e[16]=p):p=e[16],p}function Ve(l){const e=B.c(4),{children:t}=l;let n,i;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx(ye,{className:"text-info"}),i=s.jsx(Ie,{children:"Answer to continue"}),e[0]=n,e[1]=i):(n=e[0],i=e[1]);let r;return e[2]!==t?(r=s.jsxs(qe,{className:"border-info/40 bg-info/5",children:[n,i,s.jsx("div",{className:"col-start-2 mt-1 min-w-0",children:t})]}),e[2]=t,e[3]=r):r=e[3],r}function Zt(l){const e=B.c(33),{request:t,responding:n,onChoose:i}=l;let r,o;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsx(Ye,{className:"text-warning"}),o=s.jsx(Ie,{children:"Claude declined this request"}),e[0]=r,e[1]=o):(r=e[0],o=e[1]);let c;e[2]!==t.originalModel?(c=s.jsxs("p",{className:"text-sm leading-relaxed text-foreground",children:[t.originalModel," would not answer. Retrying on a fallback model may work."]}),e[2]=t.originalModel,e[3]=c):c=e[3];let d;e[4]!==t.guidanceText?(d=t.guidanceText&&s.jsx("p",{className:"mt-1 text-sm leading-relaxed text-muted-foreground",children:t.guidanceText}),e[4]=t.guidanceText,e[5]=d):d=e[5];let p;e[6]!==i||e[7]!==t.requestId?(p=()=>i(t.requestId,"retry_fallback"),e[6]=i,e[7]=t.requestId,e[8]=p):p=e[8];let u;e[9]!==t.fallbackModel||e[10]!==n||e[11]!==p?(u=s.jsxs(V,{size:"sm",disabled:n,onClick:p,children:["Retry on ",t.fallbackModel]}),e[9]=t.fallbackModel,e[10]=n,e[11]=p,e[12]=u):u=e[12];let x;e[13]!==i||e[14]!==t.requestId?(x=()=>i(t.requestId,"edit_prompt"),e[13]=i,e[14]=t.requestId,e[15]=x):x=e[15];let j;e[16]!==n||e[17]!==x?(j=s.jsx(V,{variant:"outline",size:"sm",disabled:n,onClick:x,children:"Edit prompt"}),e[16]=n,e[17]=x,e[18]=j):j=e[18];let m;e[19]!==i||e[20]!==t.requestId?(m=()=>i(t.requestId,"cancelled"),e[19]=i,e[20]=t.requestId,e[21]=m):m=e[21];let h;e[22]!==n||e[23]!==m?(h=s.jsx(V,{variant:"ghost",size:"sm",disabled:n,className:"ml-auto text-muted-foreground",onClick:m,children:"Dismiss"}),e[22]=n,e[23]=m,e[24]=h):h=e[24];let a;e[25]!==h||e[26]!==u||e[27]!==j?(a=s.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[u,j,h]}),e[25]=h,e[26]=u,e[27]=j,e[28]=a):a=e[28];let g;return e[29]!==a||e[30]!==c||e[31]!==d?(g=s.jsxs(qe,{className:"border-warning/40 bg-warning/5",children:[r,o,s.jsxs("div",{className:"col-start-2 mt-1 min-w-0",children:[c,d,a]})]}),e[29]=a,e[30]=c,e[31]=d,e[32]=g):g=e[32],g}function Be(l){return l==="awaiting_approval"||l==="awaiting_prompt"||l==="awaiting_question"||l==="awaiting_answer"}function Ae(l){return l==="done"||l==="failed"}const Ue={awaiting_approval:0,awaiting_prompt:1,awaiting_question:2,awaiting_answer:3,running:4,failed:5,done:6};function es(l,e,t,n,i){return t?"awaiting_approval":n?"awaiting_prompt":i?"awaiting_question":l.agentStatus==="deferred"||l.agentStatus==="idle"&&e?"awaiting_answer":l.agentTerminalReason?"failed":e&&l.agentStatus&&st.has(l.agentStatus)?"running":"done"}const ts=6;function ss({sessions:l,procBySession:e,summaries:t,permissionsBySession:n,questionsBySession:i,elicitationsBySession:r,dialogsBySession:o,newlyCompleted:c,finishedLimit:d=ts,now:p=Date.now()}){const u=[];for(const m of et(l)){const h=n.get(m.sessionId)??[],a=i.get(m.sessionId)??[],g=r.get(m.sessionId)??[],f=o.get(m.sessionId)??[],S=h.length+a.length+g.length+f.length;m.teamName&&m.agentName&&S===0||u.push({session:m,state:es(m,tt(m,e,p),h.length>0,g.length>0||f.length>0,a.length>0),summary:t.get(m.sessionId)??null,permissions:h,questions:a,elicitations:g,dialogs:f})}const x=u.filter(m=>Ae(m.state)),j=[...x.filter(m=>c.has(m.session.sessionId)),...x.filter(m=>!c.has(m.session.sessionId))].slice(0,d);return[...u.filter(m=>!Ae(m.state)),...j].sort((m,h)=>Ue[m.state]-Ue[h.state])}function ns(l,e){switch(e){case"running":return l.filter(t=>t.state==="running");case"needs-you":return l.filter(t=>Be(t.state));case"finished":return l.filter(t=>Ae(t.state));default:return l}}function is(l){const e={total:l.length,running:0,needsYou:0,finished:0,failed:0};for(const t of l)t.state==="running"&&e.running++,Be(t.state)&&e.needsYou++,Ae(t.state)&&e.finished++,t.state==="failed"&&e.failed++;return e}function ls(l){return l>=90?"text-destructive":l>=70?"text-warning":"text-muted-foreground"}const os={awaiting_approval:{label:"Waiting for approval",text:"text-warning",shell:"border-warning/40 bg-warning/5",icon:ye},awaiting_prompt:{label:"Waiting for your input",text:"text-info",shell:"border-info/40 bg-info/5",icon:ye},awaiting_question:{label:"Waiting for your answer",text:"text-info",shell:"border-info/40 bg-info/5",icon:ye},awaiting_answer:{label:"Waiting for your answer",text:"text-warning",shell:"border-warning/40 bg-warning/5",icon:ye},running:{label:"Running",text:"text-info",shell:"border-border",icon:null},done:{label:"Done",text:"text-success",shell:"border-border",icon:qt},failed:{label:"Failed",text:"text-destructive",shell:"border-destructive/40",icon:It}};function as(l){const e=B.c(3),{icon:t}=l;if(!t){let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsx("span",{className:"size-2 shrink-0 rounded-full bg-info"}),e[0]=i):i=e[0],i}let n;return e[1]!==t?(n=s.jsx(t,{className:"size-3.5 shrink-0"}),e[1]=t,e[2]=n):n=e[2],n}const rs=z.memo(function(e){const t=B.c(88),{card:n,customName:i,projectLabel:r,responding:o,goneQuestions:c,compact:d,onOpen:p,onRespond:u,onAnswerQuestion:x,onAnswerElicitation:j,onChooseDialog:m}=e,h=d===void 0?!1:d,{session:a,state:g,summary:f,permissions:S,questions:I,elicitations:C,dialogs:T}=n,v=os[g],N=S[0],y=I[0],q=C[0],b=T[0],M=!!(N||y||q||b);let L;t[0]!==i||t[1]!==a?(L=nt(a,i),t[0]=i,t[1]=a,t[2]=L):L=t[2];const k=L,D=h&&"gap-1.5 py-2";let E;t[3]!==v.shell||t[4]!==D?(E=ue("motion-card motion-list-item group flex min-w-0 flex-col gap-2 rounded-lg border bg-card p-3 text-left transition-colors hover:border-foreground/20",v.shell,D),t[3]=v.shell,t[4]=D,t[5]=E):E=t[5];const _=`Open session ${k}`;let O;t[6]!==r?(O=s.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground",children:r}),t[6]=r,t[7]=O):O=t[7];let w;t[8]!==f?(w=(f==null?void 0:f.model)&&s.jsx("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:it(f.model)}),t[8]=f,t[9]=w):w=t[9];let $;t[10]===Symbol.for("react.memo_cache_sentinel")?($=s.jsx(De,{"data-icon":"inline-end",className:"shrink-0 text-transparent transition-colors group-hover:text-muted-foreground"}),t[10]=$):$=t[10];let A;t[11]!==O||t[12]!==w?(A=s.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[O,w,$]}),t[11]=O,t[12]=w,t[13]=A):A=t[13];const P=h?"truncate":"line-clamp-2";let G;t[14]!==P?(G=ue("text-sm font-medium leading-snug text-foreground",P),t[14]=P,t[15]=G):G=t[15];let ne;t[16]!==G||t[17]!==k?(ne=s.jsx("span",{className:G,children:k}),t[16]=G,t[17]=k,t[18]=ne):ne=t[18];let ie;t[19]!==p||t[20]!==ne||t[21]!==_||t[22]!==A?(ie=s.jsxs(V,{variant:"ghost",onClick:p,className:"-m-1 h-auto min-w-0 flex-col items-stretch justify-start gap-1 whitespace-normal p-1 text-left","aria-label":_,children:[A,ne]}),t[19]=p,t[20]=ne,t[21]=_,t[22]=A,t[23]=ie):ie=t[23];let le;t[24]!==v.text?(le=ue("flex items-center gap-1.5 text-xs font-medium",v.text),t[24]=v.text,t[25]=le):le=t[25];let se;t[26]!==v.icon?(se=s.jsx(as,{icon:v.icon}),t[26]=v.icon,t[27]=se):se=t[27];let oe;t[28]!==v.label?(oe=s.jsx("span",{className:"truncate",children:v.label}),t[28]=v.label,t[29]=oe):oe=t[29];const re=a.lastActivityAt||a.lastModified;let ae;t[30]!==re?(ae=lt(re),t[30]=re,t[31]=ae):ae=t[31];let Q;t[32]!==ae?(Q=s.jsx("span",{className:"ml-auto shrink-0 font-mono text-xs font-normal text-muted-foreground",children:ae}),t[32]=ae,t[33]=Q):Q=t[33];let H;t[34]!==le||t[35]!==se||t[36]!==oe||t[37]!==Q?(H=s.jsxs("div",{className:le,children:[se,oe,Q]}),t[34]=le,t[35]=se,t[36]=oe,t[37]=Q,t[38]=H):H=t[38];let K;t[39]!==u||t[40]!==S.length||t[41]!==N||t[42]!==o||t[43]!==a.sessionId?(K=N&&s.jsx(Ht,{request:N,queued:S.length-1,responding:o.has(N.requestId),onRespond:(U,Y)=>u(a.sessionId,U,Y)}),t[39]=u,t[40]=S.length,t[41]=N,t[42]=o,t[43]=a.sessionId,t[44]=K):K=t[44];let W;t[45]!==b||t[46]!==m||t[47]!==N||t[48]!==o||t[49]!==a.sessionId?(W=!N&&b&&s.jsx(Zt,{request:b,responding:o.has(b.requestId),onChoose:(U,Y)=>m(a.sessionId,U,Y)},b.requestId),t[45]=b,t[46]=m,t[47]=N,t[48]=o,t[49]=a.sessionId,t[50]=W):W=t[50];let X;t[51]!==b||t[52]!==q||t[53]!==j||t[54]!==N||t[55]!==o||t[56]!==a.sessionId?(X=!N&&!b&&q&&s.jsx(Yt,{request:q,responding:o.has(q.requestId),onAnswer:(U,Y)=>j(a.sessionId,U,Y)},q.requestId),t[51]=b,t[52]=q,t[53]=j,t[54]=N,t[55]=o,t[56]=a.sessionId,t[57]=X):X=t[57];let J;t[58]!==b||t[59]!==q||t[60]!==c||t[61]!==x||t[62]!==p||t[63]!==y||t[64]!==N||t[65]!==o||t[66]!==a.sessionId?(J=!N&&!b&&!q&&y&&s.jsx(Xt,{request:y,responding:o.has(y.toolUseId),gone:c.has(y.toolUseId),onAnswer:(U,Y)=>x(a.sessionId,U,Y),onOpenSession:p},y.toolUseId),t[58]=b,t[59]=q,t[60]=c,t[61]=x,t[62]=p,t[63]=y,t[64]=N,t[65]=o,t[66]=a.sessionId,t[67]=J):J=t[67];let Z;t[68]!==M||t[69]!==f?(Z=!M&&(f==null?void 0:f.currentTool)&&s.jsx(cs,{tool:f.currentTool}),t[68]=M,t[69]=f,t[70]=Z):Z=t[70];let ee;t[71]!==M||t[72]!==h||t[73]!==f?(ee=!h&&!M&&(f==null?void 0:f.lastAssistantText)&&s.jsx("p",{className:"line-clamp-4 text-sm leading-relaxed text-muted-foreground",children:f.lastAssistantText}),t[71]=M,t[72]=h,t[73]=f,t[74]=ee):ee=t[74];let te;t[75]!==f?(te=f&&s.jsx(ds,{summary:f}),t[75]=f,t[76]=te):te=t[76];let ce;return t[77]!==ie||t[78]!==H||t[79]!==K||t[80]!==W||t[81]!==X||t[82]!==J||t[83]!==Z||t[84]!==ee||t[85]!==te||t[86]!==E?(ce=s.jsxs("div",{className:E,children:[ie,H,K,W,X,J,Z,ee,te]}),t[77]=ie,t[78]=H,t[79]=K,t[80]=W,t[81]=X,t[82]=J,t[83]=Z,t[84]=ee,t[85]=te,t[86]=E,t[87]=ce):ce=t[87],ce});function cs(l){const e=B.c(7),{tool:t}=l;let n;e[0]!==t.name?(n=s.jsx("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:t.name}),e[0]=t.name,e[1]=n):n=e[1];let i;e[2]!==t.summary?(i=s.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-xs text-foreground/80",children:t.summary}),e[2]=t.summary,e[3]=i):i=e[3];let r;return e[4]!==n||e[5]!==i?(r=s.jsxs("div",{className:"flex min-w-0 items-center gap-2 rounded-md bg-muted/50 px-2.5 py-2",children:[n,i]}),e[4]=n,e[5]=i,e[6]=r):r=e[6],r}function ds(l){const e=B.c(11),{summary:t}=l,n=t.filesTotal,i=t.context,r=n.count>0,o=i!==null&&i.used>0;if(!r&&!o)return null;let c;e[0]!==n.additions||e[1]!==n.count||e[2]!==n.deletions||e[3]!==r?(c=r&&s.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsxs("span",{className:"truncate",children:[n.count," file",n.count===1?"":"s"]}),s.jsx(ot,{add:n.additions,del:n.deletions})]}),e[0]=n.additions,e[1]=n.count,e[2]=n.deletions,e[3]=r,e[4]=c):c=e[4];let d;e[5]!==i||e[6]!==o?(d=o&&s.jsxs("span",{className:ue("ml-auto shrink-0",ls(i.percent)),children:["ctx ",i.percent,"%"]}),e[5]=i,e[6]=o,e[7]=d):d=e[7];let p;return e[8]!==c||e[9]!==d?(p=s.jsxs("div",{className:"mt-auto flex items-center gap-2 border-t pt-2 font-mono text-xs text-muted-foreground",children:[c,d]}),e[8]=c,e[9]=d,e[10]=p):p=e[10],p}const us=8e3,fs=12,ms="Start Claude Code or Codex and every session shows up here",xs=[{id:"all",label:"All"},{id:"running",label:"Running"},{id:"needs-you",label:"Needs you"},{id:"finished",label:"Finished"}],hs=[{id:"grid",label:"Grid layout",Icon:_t},{id:"list",label:"List layout",Icon:Tt}];function vs(l){const e=B.c(117),{onSelectSession:t}=l,{sessions:n,procBySession:i,newlyCompleted:r,refresh:o}=at(),{summaries:c,loading:d,error:p,refresh:u}=Rt(),{permissionsBySession:x,questionsBySession:j,elicitationsBySession:m,dialogsBySession:h,responding:a,respond:g,answerQuestion:f,answerElicitation:S,answerDialog:I,refresh:C}=rt();let T;e[0]===Symbol.for("react.memo_cache_sentinel")?(T=new Set,e[0]=T):T=e[0];const[v,N]=z.useState(T),{names:y}=ct(),{names:q}=dt(),[b,M]=z.useState("all");let L;e[1]===Symbol.for("react.memo_cache_sentinel")?(L=ut("mission-control-layout"),e[1]=L):L=e[1];const[k,D]=ft(L,"grid");let E;e[2]!==h||e[3]!==m||e[4]!==r||e[5]!==x||e[6]!==i||e[7]!==j||e[8]!==n||e[9]!==c?(E=ss({sessions:n,procBySession:i,summaries:c,permissionsBySession:x,questionsBySession:j,elicitationsBySession:m,dialogsBySession:h,newlyCompleted:r}),e[2]=h,e[3]=m,e[4]=r,e[5]=x,e[6]=i,e[7]=j,e[8]=n,e[9]=c,e[10]=E):E=e[10];const _=E;let O;e[11]!==_?(O=is(_),e[11]=_,e[12]=O):O=e[12];const w=O;let $;e[13]!==_||e[14]!==b?($=ns(_,b),e[13]=_,e[14]=b,e[15]=$):$=e[15];const A=$;let P;e[16]!==C||e[17]!==o||e[18]!==u?(P=()=>{o(),u(),C()},e[16]=C,e[17]=o,e[18]=u,e[19]=P):P=e[19];const G=P;let ne,ie;e[20]!==o?(ne=()=>{const F=setInterval(()=>{document.visibilityState==="visible"&&o()},us);return()=>clearInterval(F)},ie=[o],e[20]=o,e[21]=ne,e[22]=ie):(ne=e[21],ie=e[22]),z.useEffect(ne,ie);let le;e[23]!==f?(le=async(F,R,Re)=>{(await f(F,R,Re)).ok||N(Pe=>new Set(Pe).add(R))},e[23]=f,e[24]=le):le=e[24];const se=le;let oe;e[25]!==_.length?(oe=function(R){_.length<=fs?zt(R,{kind:"fade"}):z.startTransition(R)},e[25]=_.length,e[26]=oe):oe=e[26];const re=oe;let ae;e[27]===Symbol.for("react.memo_cache_sentinel")?(ae=s.jsx("h2",{className:"truncate text-sm font-semibold",children:"Mission Control"}),e[27]=ae):ae=e[27];let Q;e[28]!==w.total?(Q=s.jsx(Te,{variant:"secondary",children:w.total}),e[28]=w.total,e[29]=Q):Q=e[29];let H;e[30]!==w.needsYou?(H=w.needsYou>0&&s.jsxs(Te,{variant:"outline",className:"border-warning/40 text-warning",children:[w.needsYou," need you"]}),e[30]=w.needsYou,e[31]=H):H=e[31];let K;e[32]!==w.failed?(K=w.failed>0&&s.jsxs(Te,{variant:"destructive",children:[w.failed," failed"]}),e[32]=w.failed,e[33]=K):K=e[33];let W;e[34]!==Q||e[35]!==H||e[36]!==K?(W=s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[ae,Q,H,K]}),e[34]=Q,e[35]=H,e[36]=K,e[37]=W):W=e[37];let X;e[38]!==b?(X=[b],e[38]=b,e[39]=X):X=e[39];let J;e[40]!==b||e[41]!==re?(J=F=>{const R=F.at(-1);R&&R!==b&&re(()=>M(R))},e[40]=b,e[41]=re,e[42]=J):J=e[42];let Z;e[43]!==w.needsYou?(Z=xs.map(F=>s.jsxs(Ce,{value:F.id,"aria-label":`Show ${F.label.toLowerCase()} sessions`,children:[F.label,F.id==="needs-you"&&w.needsYou>0&&s.jsx("span",{className:"font-mono text-warning",children:w.needsYou})]},F.id)),e[43]=w.needsYou,e[44]=Z):Z=e[44];let ee;e[45]!==X||e[46]!==J||e[47]!==Z?(ee=s.jsx(Fe,{value:X,onValueChange:J,variant:"outline",size:"sm",spacing:0,"aria-label":"Filter sessions",children:Z}),e[45]=X,e[46]=J,e[47]=Z,e[48]=ee):ee=e[48];let te;e[49]!==k||e[50]!==D||e[51]!==re?(te=hs.map(F=>{const{id:R,label:Re,Icon:ze}=F;return s.jsx(V,{variant:"ghost",size:"icon-xs","aria-label":Re,"aria-pressed":k===R,onClick:()=>{R!==k&&re(()=>D(R))},className:ue(k===R&&"bg-accent text-accent-foreground"),children:s.jsx(ze,{"data-icon":"inline-start"})},R)}),e[49]=k,e[50]=D,e[51]=re,e[52]=te):te=e[52];const ce=d&&"animate-spin";let U;e[53]!==ce?(U=ue(ce),e[53]=ce,e[54]=U):U=e[54];let Y;e[55]!==U?(Y=s.jsx(kt,{"data-icon":"inline-start",className:U}),e[55]=U,e[56]=Y):Y=e[56];let fe;e[57]!==G||e[58]!==Y?(fe=s.jsx(V,{variant:"ghost",size:"icon-xs","aria-label":"Refresh Mission Control",onClick:G,children:Y}),e[57]=G,e[58]=Y,e[59]=fe):fe=e[59];let me;e[60]!==te||e[61]!==fe?(me=s.jsxs("div",{className:"flex items-center gap-1",children:[te,fe]}),e[60]=te,e[61]=fe,e[62]=me):me=e[62];let xe;e[63]!==ee||e[64]!==me?(xe=s.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[ee,me]}),e[63]=ee,e[64]=me,e[65]=xe):xe=e[65];let he;e[66]!==W||e[67]!==xe?(he=s.jsxs("header",{className:"flex min-h-12 shrink-0 flex-wrap items-center gap-3 border-b px-4 py-2",children:[W,xe]}),e[66]=W,e[67]=xe,e[68]=he):he=e[68];let ge;e[69]!==p||e[70]!==G?(ge=p&&s.jsxs(qe,{variant:"destructive",className:"mb-4",children:[s.jsx(At,{}),s.jsx(Ie,{children:"Mission Control could not refresh"}),s.jsx(jt,{className:"truncate",children:p}),s.jsx(wt,{children:s.jsx(V,{variant:"outline",size:"xs",onClick:G,children:"Retry"})})]}),e[69]=p,e[70]=G,e[71]=ge):ge=e[71];let pe;e[72]!==_.length||e[73]!==b||e[74]!==d||e[75]!==A.length?(pe=A.length===0&&!d&&s.jsx(mt,{className:"min-h-64",children:s.jsxs(xt,{children:[s.jsx(ht,{variant:"icon",children:s.jsx(Ct,{})}),s.jsx(gt,{children:_.length===0?"No live sessions":`Nothing matches "${b}"`}),s.jsx(pt,{children:_.length===0?ms:"Try a different filter."})]})}),e[72]=_.length,e[73]=b,e[74]=d,e[75]=A.length,e[76]=pe):pe=e[76];let be;e[77]!==_.length||e[78]!==d||e[79]!==A.length?(be=A.length===0&&d&&_.length===0&&s.jsxs("div",{className:"flex items-center justify-center gap-2 py-16 text-sm text-muted-foreground",children:[s.jsx(bt,{}),"Loading sessions…"]}),e[77]=_.length,e[78]=d,e[79]=A.length,e[80]=be):be=e[80];const Ee=k==="grid"&&"md:grid-cols-2 2xl:grid-cols-3";let je;e[81]!==Ee?(je=ue("grid grid-cols-1 gap-3",Ee),e[81]=Ee,e[82]=je):je=e[82];let we;if(e[83]!==I||e[84]!==S||e[85]!==v||e[86]!==se||e[87]!==k||e[88]!==t||e[89]!==q||e[90]!==g||e[91]!==a||e[92]!==y||e[93]!==A){let F;e[95]!==I||e[96]!==S||e[97]!==v||e[98]!==se||e[99]!==k||e[100]!==t||e[101]!==q||e[102]!==g||e[103]!==a||e[104]!==y?(F=R=>s.jsx(rs,{card:R,compact:k==="list",customName:y[R.session.sessionId],projectLabel:q[R.session.dirName]??vt(R.session),responding:a,goneQuestions:v,onOpen:()=>t(R.session.dirName,R.session.fileName),onRespond:g,onAnswerQuestion:se,onAnswerElicitation:S,onChooseDialog:I},R.session.sessionId),e[95]=I,e[96]=S,e[97]=v,e[98]=se,e[99]=k,e[100]=t,e[101]=q,e[102]=g,e[103]=a,e[104]=y,e[105]=F):F=e[105],we=A.map(F),e[83]=I,e[84]=S,e[85]=v,e[86]=se,e[87]=k,e[88]=t,e[89]=q,e[90]=g,e[91]=a,e[92]=y,e[93]=A,e[94]=we}else we=e[94];let ve;e[106]!==je||e[107]!==we?(ve=s.jsx("div",{className:je,children:we}),e[106]=je,e[107]=we,e[108]=ve):ve=e[108];let Ne;e[109]!==ge||e[110]!==pe||e[111]!==be||e[112]!==ve?(Ne=s.jsx(Nt,{className:"flex-1",children:s.jsxs("div",{className:"p-4",children:[ge,pe,be,ve]})}),e[109]=ge,e[110]=pe,e[111]=be,e[112]=ve,e[113]=Ne):Ne=e[113];let _e;return e[114]!==he||e[115]!==Ne?(_e=s.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[he,Ne]}),e[114]=he,e[115]=Ne,e[116]=_e):_e=e[116],_e}export{vs as MissionControl};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
(function(){"use strict";function z(t){return t.type==="user"}function q(t){return t.type==="assistant"}function X(t){return t.type==="progress"}function H(t){return t.type==="system"}function Y(t){return t.type==="summary"}function St(t){return t.type==="queue-operation"}function tt(t){return t.type==="attachment"}function wt(t){return t.type==="user"&&t.isCompactSummary===!0}function et(t){return t.type==="system"&&t.subtype==="compact_boundary"}const It=/<(agent-message|teammate-message)([^>]*)>([\s\S]*?)<\/\1>/g,Et=[/\bteammate_id=(?:"([^"]*)"|'([^']*)')/,/\bfrom=(?:"([^"]*)"|'([^']*)')/];function Pt(t){for(const e of Et){const n=t.match(e),o=(n==null?void 0:n[1])??(n==null?void 0:n[2]);if(o)return o}return null}function K(t){let e=null,n=!1;const o=t.replace(It,(l,p,h,k)=>(n=!0,e===null&&(e=Pt(h)),k.trim()));return{sender:e,matched:n,body:n?o.trim():t}}function D(t){return typeof t=="string"?t:t.filter(e=>e.type==="text").map(e=>e.text).join(`
|
|
2
|
+
`)}function nt(t){return t?typeof t=="string"?t:t.map(e=>e.type==="text"?e.text:"").filter(Boolean).join(`
|
|
3
|
+
`):""}function st(t){if(!(t!=null&&t.trim()))return!1;const e=t.trimStart();return e.startsWith("<")?!e.includes("<task-notification>")&&!e.startsWith("<system-reminder>")&&!e.startsWith("<local-command-"):!0}const Bt=/<task-notification>[\s\S]*?<\/task-notification>/g,Ut=/<[^>]*>/g;function Nt(t){var n;if(((n=t.origin)==null?void 0:n.kind)==="task-notification")return!0;const e=D(t.message.content);return e.includes("<task-notification>")?e.replace(Bt,"").replace(Ut,"").trim()==="":!1}function Ft(t){if(!tt(t))return null;const e=t.attachment;if(!e||e.type!=="queued_command"||e.commandMode!=="prompt")return null;const n=e.prompt;if(n==null)return null;const o=typeof n=="string"?n:D(n);if(!st(o))return null;const l=e.origin;if((l==null?void 0:l.kind)==="peer"){const h=l.name??l.from??null;if(h)return{raw:o,sender:h,body:l.body??K(o).body}}if((l==null?void 0:l.kind)==="human")return{raw:o,sender:null,body:o};const p=K(o);return{raw:o,sender:p.sender,body:p.body}}const Rt=[["attributionAgent","agent"],["attributionSkill","skill"],["attributionPlugin","plugin"],["attributionMcpServer","mcpServer"],["attributionMcpTool","mcpTool"]];function Ot(t,e){let n=t;for(const[o,l]of Rt){const p=e[o];typeof p!="string"||!p||(n={...n,[l]:p})}return n}function $t(t,e){return t?{input_tokens:t.input_tokens+e.input_tokens,output_tokens:t.output_tokens+e.output_tokens,cache_creation_input_tokens:(t.cache_creation_input_tokens??0)+(e.cache_creation_input_tokens??0),cache_read_input_tokens:(t.cache_read_input_tokens??0)+(e.cache_read_input_tokens??0),speed:e.speed??t.speed}:{...e}}const Dt=/^This session is being continued from a previous conversation[\s\S]*?\n\nSummary:\s*\n/,jt=/\n+(?:If you need specific details from before compaction|(?:Please c|C)ontinue the conversation from where it left off)[\s\S]*$/;function Lt(t){return D(t).trim().replace(Dt,"").replace(jt,"").trim()}function Wt(t){if(t)return{trigger:t.trigger,preTokens:t.preTokens,postTokens:t.postTokens}}function j(t,e){return{id:t.uuid??crypto.randomUUID(),userMessage:e,contentBlocks:[],thinking:[],assistantText:[],toolCalls:[],subAgentActivity:[],timestamp:t.timestamp??"",durationMs:null,tokenUsage:null,model:null}}function zt(t){const e=[];let n=0;for(;n<t.length;){const o=t[n];if(o.kind==="tool_calls"){const l=o.toolCalls.findIndex(p=>p.name==="EnterPlanMode");if(l!==-1){const p=o.toolCalls[l],h=String(p.input.plan??""),k=o.timestamp,b=o.toolCalls.slice(0,l);b.length>0&&e.push({kind:"tool_calls",toolCalls:b,timestamp:o.timestamp});const T=[],A=o.toolCalls.slice(l+1),S=A.findIndex(x=>x.name==="ExitPlanMode");if(S!==-1){T.push(...A.slice(0,S));const x=A[S],P=x.input.path?String(x.input.path):void 0;let y="pending";x.result!==null&&(y=x.isError?"rejected":"approved"),e.push({kind:"plan_mode",plan:h,planFilePath:P,status:y,toolCalls:T,timestamp:k});const w=A.slice(S+1);w.length>0&&e.push({kind:"tool_calls",toolCalls:w,timestamp:o.timestamp}),n++;continue}else{T.push(...A);let x,P,y="pending",w=n+1;const C=[];for(;w<t.length;){const v=t[w];if(v.kind==="tool_calls"){const E=v.toolCalls.findIndex(B=>B.name==="ExitPlanMode");if(E!==-1){T.push(...v.toolCalls.slice(0,E)),x=v.toolCalls[E],P=x.input.path?String(x.input.path):void 0,x.result!==null&&(y=x.isError?"rejected":"approved");const B=v.toolCalls.slice(E+1);e.push({kind:"plan_mode",plan:h,planFilePath:P,status:y,toolCalls:T,timestamp:k}),e.push(...C),B.length>0&&e.push({kind:"tool_calls",toolCalls:B,timestamp:v.timestamp}),n=w+1;break}else T.push(...v.toolCalls),w++}else if(v.kind==="hook_event"||v.kind==="text"||v.kind==="queued_prompt"||v.kind==="agent_message")C.push(v),w++;else break}x||(e.push({kind:"plan_mode",plan:h,planFilePath:void 0,status:"pending",toolCalls:T,timestamp:k}),e.push(...C),n=w);continue}}}e.push(o),n++}return e}function qt(t){return t.contentBlocks.some(e=>e.kind==="agent_message")?{...t,contentBlocks:t.contentBlocks.map(e=>{if(e.kind!=="agent_message")return e;const{reply:n,...o}=e;return o})}:t}function ot(t){var o;const e=t.map(qt),n=new Map;for(const l of e)for(const p of l.contentBlocks){if(p.kind==="agent_message"){const h=n.get(p.sender);h?h.push(p):n.set(p.sender,[p]);continue}if(p.kind==="tool_calls")for(const h of p.toolCalls){if(h.name!=="SendMessage")continue;const k=h.input.to;if(typeof k!="string"||!k)continue;const b=(o=n.get(k))==null?void 0:o.shift();if(!b)continue;const T=h.input.summary;b.reply={summary:typeof T=="string"?T:"",timestamp:h.timestamp||p.timestamp||""}}}return e}function Kt(t){const e=[];let n=!1;for(let o=0;o<t.length;o++){const l=t[o];if(Y(l)||et(l)){n=!1;continue}if(z(l)&&!l.isMeta){const p=l.message.content;if(n&&Array.isArray(p)&&p.some(k=>k.type==="tool_result"))continue;e.push(o),n=!0;continue}q(l)&&!n&&(e.push(o),n=!0)}return e}function it(t){var B,N;const e=[];let n=null,o=null;function l(c){o&&(c.compactionSummary=o.summary,c.compactionMeta=o.meta,o=null)}let p=null;const h=new Map,k=new Set,b=new Map,T=new Map,A=new Set,S=new Map,x=[],P=new Map;function y(c,a){let s=P.get(c);s||(s=new Map,P.set(c,s)),s.set(a,(s.get(a)??0)+1)}function w(c,a){const s=P.get(c),u=s==null?void 0:s.get(a);return!s||!u?!1:(u===1?s.delete(a):s.set(a,u-1),!0)}function C(){for(const c of x)c.turn.contentBlocks.push(c.sender?{kind:"agent_message",sender:c.sender,body:c.body,timestamp:c.timestamp}:{kind:"queued_prompt",content:c.content,timestamp:c.timestamp});x.length=0}function v(c){if(!n)return;const a=b.get(c);if(!a||a.length===0)return;n.subAgentActivity.push(...a),b.delete(c);const s=A.has(c)?"background_agent":"sub_agent",u=T.get(c);if(u)u.messages.push(...a);else{const i={kind:s,messages:[...a]};n.contentBlocks.push(i),T.set(c,i)}}function E(){if(n){for(const c of n.toolCalls)v(c.id);for(const[c]of b)v(c);for(const c of n.contentBlocks)if(c.kind==="hook_event")for(const a of c.events){if(!(a.eventName==="PostToolUse"||a.eventName.startsWith("PostToolUse:"))||!a.toolUseId)continue;const u=n.toolCalls.find(i=>i.id===a.toolUseId);u&&(a.updatedToolOutput&&(u.outputReplacedByHook=!0),a.durationMs!==void 0&&(u.hookDurationMs=(u.hookDurationMs??0)+a.durationMs))}n.contentBlocks=zt(n.contentBlocks),e.push(n),n=null,T.clear()}}for(const c of t){if(Y(c)){E(),o={summary:c.summary};continue}if(et(c)){E(),o={meta:Wt(c.compactMetadata)};continue}if(wt(c)){E(),n=j(c,null),n.compactionSummary=Lt(c.message.content),n.compactionMeta=o==null?void 0:o.meta,o=null;continue}if(H(c)&&c.subtype==="away_summary"&&c.content){p={content:c.content,timestamp:c.timestamp};continue}if(St(c)){if(n&&c.operation==="enqueue"&&st(c.content)){const a=K(c.content);x.push({turn:n,content:c.content,timestamp:c.timestamp,sender:a.sender,body:a.body}),y(n,c.content)}continue}if(tt(c)){const a=Ft(c);n&&a!==null&&!w(n,a.raw)&&x.push({turn:n,content:a.raw,timestamp:((B=c.attachment)==null?void 0:B.timestamp)??c.timestamp,sender:a.sender,body:a.body});continue}if(x.length>0){const a=z(c)&&!c.isMeta?c.message.content:null;if(typeof a=="string"){const s=x.findIndex(u=>u.content===a);if(s>=0){const[u]=x.splice(s,1);w(u.turn,u.content)}}C()}if(z(c)&&!c.isMeta){const a=c.message.content;if(typeof a!="string"&&Array.isArray(a)&&a.some(u=>u.type==="tool_result")&&n){for(const i of a)if(i.type==="tool_result"){const r=h.get(i.tool_use_id);r&&(r.turn.toolCalls[r.index].result=nt(i.content),r.turn.toolCalls[r.index].isError=i.is_error===!0,h.delete(i.tool_use_id))}const u=c.toolUseResult;if(u!=null&&u.agentId){const i=((N=a.find(_=>_.type==="tool_result"))==null?void 0:N.tool_use_id)??"",r=S.get(i),m=A.has(i),d=[];if(Array.isArray(u.content))for(const _ of u.content)_.type==="text"&&d.push(_.text);const f={agentId:u.agentId,parentToolUseId:i||void 0,agentName:(r==null?void 0:r.name)??null,subagentType:(r==null?void 0:r.subagentType)??null,type:"assistant",content:u.content,toolCalls:[],thinking:[],text:d,timestamp:c.timestamp??"",tokenUsage:u.usage?{input_tokens:u.usage.input_tokens??0,output_tokens:u.usage.output_tokens??0,cache_creation_input_tokens:u.usage.cache_creation_input_tokens??0,cache_read_input_tokens:u.usage.cache_read_input_tokens??0}:null,model:null,isBackground:m,prompt:u.prompt,status:u.status,durationMs:u.totalDurationMs,toolUseCount:u.totalToolUseCount};if(!T.get(i)){n.subAgentActivity.push(f);const M={kind:m?"background_agent":"sub_agent",messages:[f]};n.contentBlocks.push(M),T.set(i,M)}}continue}if(Nt(c)){const s={kind:"task_notification",content:D(a),timestamp:c.timestamp};if(n){n.contentBlocks.push(s);continue}n=j(c,null),n.contentBlocks.push(s),l(n);continue}E(),n=j(c,c.message.content),l(n),p&&(n.contentBlocks.push({kind:"recap",content:p.content,timestamp:p.timestamp}),p=null);continue}if(q(c)){let a=function(){m.length>0&&(d.contentBlocks.push({kind:"tool_calls",toolCalls:[...m],timestamp:i}),m.length=0)},s=function(){if(r.length>0){const f=d.contentBlocks[d.contentBlocks.length-1];f&&f.kind==="thinking"?f.blocks.push(...r):d.contentBlocks.push({kind:"thinking",blocks:[...r],timestamp:i}),r.length=0}};n||(n=j(c,null),l(n)),n.model=c.message.model,c.effort&&(n.effort=c.effort),n.attribution=Ot(n.attribution,c);const u=c.message.id;k.has(u)||(k.add(u),n.tokenUsage=$t(n.tokenUsage,c.message.usage));const i=c.timestamp??"",r=[],m=[],d=n;for(const f of c.message.content)if(f.type==="thinking"){a();const g=f;if(!g.thinking)continue;n.thinking.push(g),r.push(g)}else if(f.type==="text"){a(),s();const g=/<thinking>([\s\S]*?)<\/thinking>/g;let _=f.text,M;for(;(M=g.exec(f.text))!==null;){const U=M[1].trim();if(U){const F={type:"thinking",thinking:U,signature:""};n.thinking.push(F),n.contentBlocks.push({kind:"thinking",blocks:[F],timestamp:i})}_=_.replace(M[0],"")}if(_=_.trim(),_){n.assistantText.push(_);const U=n.contentBlocks[n.contentBlocks.length-1];U&&U.kind==="text"?U.text.push(_):n.contentBlocks.push({kind:"text",text:[_],timestamp:i})}}else if(f.type==="tool_use"){s();const g={id:f.id,name:f.name,input:f.input,result:null,isError:!1,timestamp:c.timestamp??""},_=n.toolCalls.length;if(n.toolCalls.push(g),m.push(g),h.set(f.id,{turn:n,index:_}),f.name==="Task"||f.name==="Agent"){const M=f.input;M.run_in_background===!0&&A.add(f.id),S.set(f.id,{name:M.name??null,subagentType:M.subagent_type??null})}}s(),a();continue}if(X(c)&&c.data.type==="agent_progress"){const a=c.data,s=c.parentToolUseID??"";let u=null;if(a.message.type==="assistant"){const f=a.message.message,g=f.id,_=f.usage;_&&g&&!k.has(g)&&(k.add(g),u={input_tokens:_.input_tokens??0,output_tokens:_.output_tokens??0,cache_creation_input_tokens:_.cache_creation_input_tokens??0,cache_read_input_tokens:_.cache_read_input_tokens??0})}const i=a.message.type==="assistant"?a.message.message.model??null:null,r=S.get(s),m={agentId:a.agentId,parentToolUseId:s||void 0,agentName:(r==null?void 0:r.name)??null,subagentType:(r==null?void 0:r.subagentType)??null,type:a.message.type,content:a.message.message.content,toolCalls:[],thinking:[],text:[],timestamp:a.message.timestamp??c.timestamp??"",tokenUsage:u,model:i,isBackground:A.has(s)};if(a.message.type==="assistant"){const f=a.message.message.content;if(Array.isArray(f))for(const g of f)g.type==="thinking"?m.thinking.push(g.thinking):g.type==="text"?m.text.push(g.text):g.type==="tool_use"&&m.toolCalls.push({id:g.id,name:g.name,input:g.input,result:null,isError:!1,timestamp:a.message.timestamp??c.timestamp??""})}else if(a.message.type==="user"){const f=a.message.message.content;if(Array.isArray(f)){for(const g of f)if(g.type==="tool_result"){const _=b.get(s);if(_)for(const M of _){const U=M.toolCalls.find(F=>F.id===g.tool_use_id);U&&(U.result=nt(g.content),U.isError=g.is_error===!0)}}}}let d=b.get(s);d||(d=[],b.set(s,d)),d.push(m),n&&v(s);continue}if(X(c)&&c.data.type==="hook_progress"){const a=c.data,s=String(a.hook_event_name??a.hookEvent??"unknown"),u=a.hookSpecificOutput,i={eventName:s,source:a.source!==void 0?String(a.source):void 0,toolName:a.tool_name!==void 0?String(a.tool_name):void 0,toolUseId:a.tool_use_id!==void 0?String(a.tool_use_id):void 0,command:a.command!==void 0?String(a.command):void 0,output:a.output!==void 0?String(a.output):void 0,stderr:a.stderr!==void 0?String(a.stderr):void 0,exitCode:a.exit_code!==void 0?Number(a.exit_code):void 0,decision:a.decision!==void 0?String(a.decision):void 0,durationMs:a.duration_ms!==void 0?Number(a.duration_ms):void 0,updatedToolOutput:(u==null?void 0:u.updatedToolOutput)!==void 0?String(u.updatedToolOutput):void 0,sessionTitle:(u==null?void 0:u.sessionTitle)!==void 0?String(u.sessionTitle):void 0,worktreePath:(u==null?void 0:u.worktreePath)!==void 0?String(u.worktreePath):void 0,timestamp:c.timestamp??""};if(n){const r=n.contentBlocks[n.contentBlocks.length-1];r&&r.kind==="hook_event"?r.events.push(i):n.contentBlocks.push({kind:"hook_event",events:[i],timestamp:c.timestamp})}continue}if(H(c)&&c.subtype==="turn_duration"&&n){c.durationMs!==void 0&&c.durationMs!==null&&(n.durationMs=(n.durationMs??0)+c.durationMs);continue}}return C(),E(),ot(e)}function at(t,e){let n=0;for(const o of t)e[o.name]=(e[o.name]??0)+1,o.isError&&n++;return n}function rt(t,e){t.totalInputTokens+=e.input_tokens,t.totalOutputTokens+=e.output_tokens,t.totalCacheCreationTokens+=e.cache_creation_input_tokens??0,t.totalCacheReadTokens+=e.cache_read_input_tokens??0}function J(t){return{totalInputTokens:0,totalOutputTokens:0,totalCacheCreationTokens:0,totalCacheReadTokens:0,toolCallCounts:{},errorCount:0,totalDurationMs:0,turnCount:t}}function G(t){const e=J(t.length);for(const n of t){n.tokenUsage&&rt(e,n.tokenUsage),n.durationMs&&(e.totalDurationMs+=n.durationMs),e.errorCount+=at(n.toolCalls,e.toolCallCounts);for(const o of n.subAgentActivity)e.errorCount+=at(o.toolCalls,e.toolCallCounts),o.tokenUsage&&rt(e,o.tokenUsage)}return e}const lt={0:"\0",b:"\b",f:"\f",n:`
|
|
4
|
+
`,r:"\r",t:" ",v:"\v"};function ct(t,e){const n=t[e];if(n!=='"'&&n!=="'"&&n!=="`")return null;let o="",l=e+1;for(;l<t.length;){const p=t[l];if(p===n)return{endIndex:l+1,value:o};if(p!=="\\"){o+=p,l++;continue}if(l++,l>=t.length)return null;const h=t[l];if(h in lt){o+=lt[h],l++;continue}if(h===`
|
|
5
|
+
`){l++;continue}if(h==="\r"){l+=t[l+1]===`
|
|
6
|
+
`?2:1;continue}if(h==="x"&&/^[0-9a-fA-F]{2}$/.test(t.slice(l+1,l+3))){o+=String.fromCharCode(Number.parseInt(t.slice(l+1,l+3),16)),l+=3;continue}if(h==="u"){const k=t.slice(l+1).match(/^\{([0-9a-fA-F]+)\}/);if(k){const T=Number.parseInt(k[1],16);if(Number.isFinite(T)&&T<=1114111){o+=String.fromCodePoint(T),l+=k[0].length+1;continue}}const b=t.slice(l+1,l+5);if(/^[0-9a-fA-F]{4}$/.test(b)){o+=String.fromCharCode(Number.parseInt(b,16)),l+=5;continue}}o+=h,l++}return null}function ut(t){return t.includes("*** Begin Patch")&&t.includes("*** End Patch")}function Jt(t){if(!t.includes("apply_patch")||!t.includes("*** Begin Patch"))return[];const e=new Map;for(let h=0;h<t.length;h++){const k=ct(t,h);if(k){if(ut(k.value)){const b=t.slice(0,h).match(/(?:^|[;\n])\s*(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*$/);b&&e.set(b[1],k.value)}h=k.endIndex-1}}const n=[],o=new Set,l=/\btools\s*\.\s*apply_patch\s*\(/g;let p;for(;(p=l.exec(t))!==null;){let h=p.index+p[0].length;for(;/\s/.test(t[h]??"");)h++;const k=ct(t,h),b=k?null:t.slice(h).match(/^([A-Za-z_$][\w$]*)/),T=(k==null?void 0:k.value)??(b?e.get(b[1]):void 0);!T||!ut(T)||o.has(T)||(o.add(T),n.push(T))}return n}function pt(t,e){if(!e||t.startsWith("/")||/^[A-Za-z]:[\\/]/.test(t))return t;const n=e.replace(/[\\/]+$/,""),o=t.replace(/^\.[\\/]/,"");return/^[A-Za-z]:[\\/]/.test(e)?`${n}\\${o.replace(/\//g,"\\")}`:`${n}/${o}`}function dt(t,e,n,o=""){var b,T;const l=[],p=/^\*\*\*\s+(Update File|Add File|Delete File):\s*(.+)$/gm,h=[];let k;for(;(k=p.exec(t))!==null;)h.push({action:k[1],filePath:k[2].trim(),headerIdx:k.index,startIdx:k.index+k[0].length});for(let A=0;A<h.length;A++){const S=h[A],x=A+1<h.length?h[A+1].headerIdx:t.length,P=t.slice(S.startIdx,x),y=(T=(b=P.match(/^\*\*\*\s+Move to:\s*(.+)$/m))==null?void 0:b[1])==null?void 0:T.trim(),w=pt(S.filePath,o),C=pt(y||S.filePath,o),v=P.split(/^@@.*$/m).filter(c=>c.trim()),E=[],B=[];for(const c of v)for(const a of c.split(`
|
|
7
|
+
`))a.startsWith("-")?E.push(a.slice(1)):a.startsWith("+")?B.push(a.slice(1)):a.startsWith(" ")&&(E.push(a.slice(1)),B.push(a.slice(1)));const N=h.length>1?`${e}:file-${A}`:e;S.action==="Add File"?l.push({id:N,name:"Write",input:{file_path:C,content:B.join(`
|
|
8
|
+
`)},result:null,isError:!1,timestamp:n}):S.action==="Delete File"?l.push({id:N,name:"Edit",input:{file_path:C,old_string:E.join(`
|
|
9
|
+
`),new_string:""},result:null,isError:!1,timestamp:n}):l.push({id:N,name:"Edit",input:{file_path:C,...y?{old_path:w}:{},old_string:E.join(`
|
|
10
|
+
`),new_string:B.join(`
|
|
11
|
+
`)},result:null,isError:!1,timestamp:n})}return l}function Gt(t,e,n,o,l=""){return t==="apply_patch"?dt(e,n,o,l):Jt(e).flatMap((p,h)=>dt(p,`${n}:patch-${h}`,o,l))}function Zt(t,e,n){var k;if(!e||!/(?:apply[_ ]patch|invalid patch|invalid context|failed to (?:apply|find)|could not apply)/i.test(t))return new Set;const o=new Map;for(const b of n){const T=(k=b.id.match(/:patch-(\d+)(?::file-\d+)?$/))==null?void 0:k[1];if(T===void 0)continue;const A=Number(T),S=o.get(A)??[];S.push(b),o.set(A,S)}if(o.size===0)return new Set(n.map(b=>b.id));const l=t.toLowerCase().replaceAll("\\","/"),p=new Set;for(const[b,T]of o)T.some(A=>{const S=String(A.input.file_path??"").toLowerCase().replaceAll("\\","/");if(!S)return!1;const P=S.split("/").filter(Boolean).slice(-2).join("/");return l.includes(S)||P.includes("/")&&l.includes(P)})&&p.add(b);for(const b of l.matchAll(/\bpatch\s*(?:#|-)?\s*(\d+)\b/g)){const T=Number(b[1]);o.has(T)&&p.add(T)}p.size===0&&p.add(Math.max(...o.keys()));const h=Math.min(...p);for(const b of o.keys())b>=h&&p.add(b);return new Set([...p].flatMap(b=>{var T;return((T=o.get(b))==null?void 0:T.map(A=>A.id))??[]}))}function Z(t){return typeof t=="object"&&t!==null}const Qt=new Map([["spawn_agent","spawn_agent"],["spawnAgent","spawn_agent"],["wait_agent","wait_agent"],["waitAgent","wait_agent"],["send_message","send_message"],["sendMessage","send_message"],["followup_task","followup_task"],["followupTask","followup_task"],["list_agents","list_agents"],["listAgents","list_agents"],["interrupt_agent","interrupt_agent"],["interruptAgent","interrupt_agent"]]);function Vt(t){const e=t.split(/(?:__|[.:/])+/).filter(Boolean).at(-1)??t;return Qt.get(e)??t}function Q(t){if(!t)return!1;const e=t.match(/Process exited with code (\d+)/);if(e)return e[1]!=="0";const n=t.replace(/\b0\s+(?:fail(?:ed|ures?)?|errors?)\b/gi,"").replace(/\bno\s+(?:failures?|errors?)\b/gi,"");return/\b(error|failed|exception)\b/i.test(n)}function Xt(t){return{todos:(Array.isArray(t.plan)?t.plan:[]).filter(o=>Z(o)).map(o=>({content:typeof o.step=="string"?o.step:"",status:typeof o.status=="string"?o.status:"pending",activeForm:typeof o.step=="string"?o.step:""}))}}function Ht(t){return typeof t=="string"?t:Array.isArray(t)?t.filter(e=>Z(e)&&typeof e.text=="string").map(e=>e.text).join(""):""}function ft(t){const e=Ht(t);if(!e)return{text:"",isError:!1};try{const n=JSON.parse(e),o=typeof n.output=="string"?n.output:e,l=Z(n.metadata)?n.metadata:null,p=l?l.exit_code!==0&&l.exit_code!==void 0:Q(o);return{text:o,isError:p}}catch{return{text:e,isError:Q(e)}}}const Yt=["# AGENTS.md instructions for ","<recommended_plugins>","<environment_context>","<permissions instructions>","<collaboration_mode>","<skills_instructions>"];function te(t){var e,n;return((n=(e=globalThis.crypto)==null?void 0:e.randomUUID)==null?void 0:n.call(e))??`${t}-${Math.random().toString(36).slice(2,10)}`}function mt(t){try{return JSON.parse(t)}catch{return null}}function I(t){return typeof t=="object"&&t!==null}function gt(t){return!t||typeof t.type!="string"?!1:t.type==="session_meta"||t.type==="turn_context"||t.type==="event_msg"||t.type==="response_item"||t.type==="inter_agent_communication_metadata"||t.type==="compacted"||t.type==="world_state"}function L(t,e){const n=t==null?void 0:t.content;return Array.isArray(n)?n.filter(o=>I(o)&&o.type===e&&typeof o.text=="string").map(o=>o.text).join(`
|
|
12
|
+
`).trim():""}const ee=/^data:(image\/(?:png|jpeg|gif|webp));base64,(.+)$/is,ne=/^data:(audio\/(?:wav|x-wav|mpeg|mp4|webm|ogg));base64,(.+)$/is;function ht(t){if(typeof t!="string")return null;const e=ee.exec(t);return!(e!=null&&e[1])||!e[2]?null:{type:"image",source:{type:"base64",media_type:e[1].toLowerCase(),data:e[2]}}}function _t(t){if(typeof t!="string")return null;const e=ne.exec(t);return!(e!=null&&e[1])||!e[2]?null:{type:"audio",source:{type:"base64",media_type:e[1].toLowerCase(),data:e[2]}}}function se(t){return Array.isArray(t.images)?t.images.map(ht).filter(e=>e!==null):[]}function oe(t){return Array.isArray(t.audio)?t.audio.map(_t).filter(e=>e!==null):[]}function yt(t){return Array.isArray(t.content)?t.content.filter(e=>I(e)&&e.type==="input_image").map(e=>ht(e.image_url)).filter(e=>e!==null):[]}function kt(t){return Array.isArray(t.content)?t.content.filter(e=>I(e)&&e.type==="input_audio").map(e=>_t(e.audio_url)).filter(e=>e!==null):[]}function Tt(t,e,n=[],o=[],l=[]){const p=[...o.map(k=>`
|
|
13
|
+
`),...l.map(k=>`
|
|
14
|
+
[audio attachment](<${k}>)`)].join(""),h=t+p;return e.length===0&&n.length===0?h:[...e,...n,...h?[{type:"text",text:h}]:[]]}function ie(t){var h,k;const e=L(t,"input_text");if(!e)return{messageType:null,text:""};const n=e.match(/\r?\nPayload:\s*(?:\r?\n|$)/);if(!e.startsWith("Message Type:")||!n||n.index===void 0)return{messageType:null,text:e.trim()};const l=((k=(h=e.slice(0,n.index).match(/^Message Type:\s*([^\r\n]+)/))==null?void 0:h[1])==null?void 0:k.trim().toUpperCase())??null,p=e.slice(n.index+n[0].length).trim();return{messageType:l,text:p}}function O(t){return t.split(/[\\/]/).filter(Boolean).at(-1)??null}function ae(t){if(typeof t!="string")return"";const e=t.trim();return/^gAAAAA[A-Za-z0-9_-]+$/.test(e)?"":e}function V(t){const e=t.trim();return!e||Yt.some(n=>e.startsWith(n))?"":e}function re(t,e){return t?{input_tokens:t.input_tokens+e.input_tokens,output_tokens:t.output_tokens+e.output_tokens,cache_creation_input_tokens:(t.cache_creation_input_tokens??0)+(e.cache_creation_input_tokens??0),cache_read_input_tokens:(t.cache_read_input_tokens??0)+(e.cache_read_input_tokens??0)}:{...e}}function le(t){if(!I(t))return null;const e=typeof t.input_tokens=="number"?t.input_tokens:0,n=typeof t.output_tokens=="number"?t.output_tokens:0,o=typeof t.cache_write_input_tokens=="number"?t.cache_write_input_tokens:typeof t.cache_creation_input_tokens=="number"?t.cache_creation_input_tokens:0,l=typeof t.cached_input_tokens=="number"?Math.max(0,t.cached_input_tokens):null,p=l??(typeof t.cache_read_input_tokens=="number"?t.cache_read_input_tokens:0),h=l===null?e:Math.max(0,e-l);return h===0&&n===0&&o===0&&p===0?null:{input_tokens:h,output_tokens:n,cache_creation_input_tokens:o,cache_read_input_tokens:p}}function ce(t,e,n){if(!e)return;t.assistantText.push(e);const o=t.contentBlocks[t.contentBlocks.length-1];if(o&&o.kind==="text"){o.text.push(e);return}t.contentBlocks.push({kind:"text",text:[e],timestamp:n})}function ue(t,e,n){if(!e)return;const o={type:"thinking",thinking:e,signature:""};t.thinking.push(o);const l=t.contentBlocks[t.contentBlocks.length-1];if(l&&l.kind==="thinking"){l.blocks.push(o);return}t.contentBlocks.push({kind:"thinking",blocks:[o],timestamp:n})}function R(t,e,n){t.toolCalls.push(e);const o=t.contentBlocks[t.contentBlocks.length-1];if(o&&o.kind==="tool_calls"&&o.timestamp===n){o.toolCalls.push(e);return}t.contentBlocks.push({kind:"tool_calls",toolCalls:[e],timestamp:n})}function W(t,e,n){if(!e||!(e.userMessage!==null||e.assistantText.length>0||e.toolCalls.length>0||e.thinking.length>0||e.subAgentActivity.length>0))return null;if(e.timestamp&&n){const l=new Date(e.timestamp).getTime(),p=new Date(n).getTime();Number.isFinite(l)&&Number.isFinite(p)&&p>=l&&(e.durationMs=p-l)}return t.push(e),null}function bt(t){if(typeof t!="string"||!t.trim())return{};try{const e=JSON.parse(t);return I(e)?e:{value:e}}catch{return{raw:t}}}function $(t){if(typeof t=="string")return t;try{return JSON.stringify(t)}catch{return String(t??"")}}function Ct(...t){return t.find(e=>typeof e=="string")}function pe(t){return t.startsWith("exec-")}function de(t){if(!I(t))return{text:$(t),isError:!1};if("Err"in t)return{text:$(t.Err),isError:!0};const e=I(t.Ok)?t.Ok:null;if(!e)return{text:$(t),isError:!1};const n=ft(e.content);return{text:n.text||(e.structuredContent!==void 0?$(e.structuredContent):$(e)),isError:e.isError===!0||n.isError}}function fe(t,e,n){return{id:t?`${t}@${e}`:te("codex-turn"),userMessage:null,contentBlocks:[],thinking:[],assistantText:[],toolCalls:[],subAgentActivity:[],timestamp:e,durationMs:null,tokenUsage:null,model:n}}function Mt(t){return t.type==="event_msg"&&I(t.payload)&&t.payload.type==="user_message"&&typeof t.payload.message=="string"?V(t.payload.message):t.type==="response_item"&&I(t.payload)&&t.payload.type==="message"&&t.payload.role==="user"?V(L(t.payload,"input_text")):""}function me(t,e){if(t.type==="session_meta"||t.type==="event_msg"&&(e==null?void 0:e.type)==="task_started")return!1;if(t.type==="response_item"&&(e==null?void 0:e.type)==="message"){if(e.role==="developer"||e.role==="system")return!1;if(e.role==="user")return Mt(t)!==""||yt(e).length>0||kt(e).length>0}return!0}function ge(t){let e="",n="",o="",l="",p="",h,k="",b="",T="",A="",S=0,x=!1,P=null,y="/root",w="";for(const C of t){if(!I(C.payload))continue;if(C.type==="session_meta"){if(e||(e=typeof C.payload.id=="string"?C.payload.id:""),n||(n=typeof C.payload.cli_version=="string"?C.payload.cli_version:""),l||(l=typeof C.payload.cwd=="string"?C.payload.cwd:""),!h&&I(C.payload.branchedFrom)){const N=typeof C.payload.branchedFrom.sessionId=="string"?C.payload.branchedFrom.sessionId:"";N&&(h={sessionId:N,turnIndex:typeof C.payload.branchedFrom.turnIndex=="number"?C.payload.branchedFrom.turnIndex:null})}const E=I(C.payload.source)?C.payload.source:null;if(E&&I(E.subagent)){x=!0;const N=I(E.subagent.thread_spawn)?E.subagent.thread_spawn:null;N&&typeof N.agent_path=="string"&&(y=N.agent_path)}typeof C.payload.forked_from_id=="string"&&C.payload.forked_from_id&&(P=C.payload.forked_from_id);const B=I(C.payload.git)?C.payload.git:null;o||(o=B&&typeof B.branch=="string"?B.branch:"")}C.type==="turn_context"&&(p||(p=typeof C.payload.model=="string"?C.payload.model:""),l||(l=typeof C.payload.cwd=="string"?C.payload.cwd:""));const v=Mt(C);v&&v!==w&&(k||(k=v),b=v,w=v,S++,T||(T=C.timestamp??""),A=C.timestamp??A)}return A===""&&(A=T),{sessionId:e,version:n,gitBranch:o,cwd:l,model:p,slug:"",name:"",branchedFrom:h,firstUserMessage:k,lastUserMessage:b,timestamp:T,lastTimestamp:A,turnCount:S,isSubagent:x,parentSessionId:P,agentPath:y}}function xt(t){for(const e of t.split(`
|
|
15
|
+
`)){const n=e.trim();if(n)return gt(mt(n))}return!1}function At(t,e){const n=t.split(`
|
|
16
|
+
`).map(a=>a.trim()).filter(Boolean).map(mt).filter(gt),o=ge(n),l=[],p=new Map,h=new Map,k=new Map,b=new Map,T=new Map,A=new Map,S=new Map,x=new Map;function P(a,s,u,i={}){const r=T.get(a);let m=x.get(a);if(!m){const f={agentId:a,parentToolUseId:(r==null?void 0:r.parentToolCallId)||void 0,agentName:(r==null?void 0:r.nickname)??(r!=null&&r.agentPath?O(r.agentPath):null),subagentType:(r==null?void 0:r.agentType)??null,type:"assistant",content:null,toolCalls:[],thinking:[],text:[],timestamp:(r==null?void 0:r.timestamp)??u,tokenUsage:null,model:(r==null?void 0:r.model)??null,isBackground:!1,prompt:(r==null?void 0:r.message)||void 0,status:i.status??"running"};s.subAgentActivity.push(f);const g=s.contentBlocks[s.contentBlocks.length-1];(g==null?void 0:g.kind)==="sub_agent"?g.messages.push(f):s.contentBlocks.push({kind:"sub_agent",messages:[f],timestamp:u}),m={message:f,turn:s},x.set(a,m)}const d=m.message;if(r&&(d.parentToolUseId=r.parentToolCallId||d.parentToolUseId,d.agentName=r.nickname??(r.agentPath?O(r.agentPath):d.agentName),d.subagentType=r.agentType,d.model=r.model,d.prompt=r.message||d.prompt),i.text&&!d.text.includes(i.text)&&(d.text.push(i.text),d.content=d.text.join(`
|
|
17
|
+
|
|
18
|
+
`)),i.status){const f=new Set(["completed","failed","interrupted"]);if(i.status==="running"&&d.status&&f.has(d.status)||(d.status=i.status),f.has(i.status)&&d.timestamp&&u){const g=new Date(d.timestamp).getTime(),_=new Date(u).getTime();Number.isFinite(g)&&Number.isFinite(_)&&_>=g&&(d.durationMs=_-g)}}return d}let y=null,w=null,C=o.model||null,v="",E=null,B=!1;function N(a,s,u){const i=fe(a,s,u);return B||(i.isFragment=!0),E&&(i.compactionSummary=E,E=null),i}function c(a,s,u,i,r){const m=h.get(s);if(m){m.input={...m.input,...u},m.result=i,m.isError=i==="failed";return}const d={id:s,name:"WebSearch",input:u,result:i,isError:i==="failed",timestamp:r};h.set(s,d),R(a,d,r)}for(const a of n){const s=I(a.payload)?a.payload:void 0,u=a.timestamp??"";if(a.type==="compacted"){y=W(l,y,v),E="Conversation compacted",v=u;continue}if(a.type!=="world_state"){if(a.type==="turn_context"){y=W(l,y,v),w=typeof(s==null?void 0:s.turn_id)=="string"?s.turn_id:null,C=typeof(s==null?void 0:s.model)=="string"?s.model:C,v=u,B=!0;continue}if(a.type==="event_msg"&&(s==null?void 0:s.type)==="user_message"&&typeof s.message=="string"){y&&(y.assistantText.length>0||y.toolCalls.length>0||y.thinking.length>0)&&(y=W(l,y,v)),B=!0,y??(y=N(w,u,C));const i=(Array.isArray(s.local_images)?s.local_images:[]).filter(m=>typeof m=="string"&&m.length>0),r=(Array.isArray(s.local_audio)?s.local_audio:[]).filter(m=>typeof m=="string"&&m.length>0);y.userMessage=Tt(s.message,se(s),oe(s),i,r),y.isFragment=!1,y.timestamp=y.timestamp||u,v=u;continue}if(!(!y&&!me(a,s))){if(y??(y=N(w,u,C)),!y.model&&C&&(y.model=C),y.timestamp||(y.timestamp=u),u&&(v=u),a.type==="event_msg"&&(s==null?void 0:s.type)==="token_count"){const i=I(s.info)?s.info:null,r=i?le(i.last_token_usage):null;r&&(y.tokenUsage=re(y.tokenUsage,r));continue}if(a.type==="event_msg"&&(s==null?void 0:s.type)==="web_search_end"&&typeof s.call_id=="string"){const i={};typeof s.query=="string"&&s.query&&(i.query=s.query),I(s.action)&&(i.action=s.action),c(y,s.call_id,i,"completed",u);continue}if(a.type==="event_msg"&&(s==null?void 0:s.type)==="mcp_tool_call_end"&&typeof s.call_id=="string"&&I(s.invocation)){const i=s.invocation,r=typeof i.server=="string"?i.server:"mcp",m=typeof i.tool=="string"?i.tool:"tool",d=I(i.arguments)?i.arguments:{},f=de(s.result),g=p.get(s.call_id);g?(g.result=f.text,g.isError=f.isError,p.delete(s.call_id)):pe(s.call_id)||R(y,{id:s.call_id,name:`mcp__${r}__${m}`,input:d,result:f.text,isError:f.isError,timestamp:u},u);continue}if(a.type==="event_msg"&&(s==null?void 0:s.type)==="sub_agent_activity"&&typeof s.agent_thread_id=="string"&&typeof s.agent_path=="string"){const i=s.agent_thread_id,r=typeof s.event_id=="string"?s.event_id:"",m=typeof s.kind=="string"?s.kind:"started",d=r?b.get(r):void 0,f=A.get(s.agent_path),g=T.get(i)??(f?T.get(f):void 0);if(m!=="started"&&!g&&!d)continue;if(f&&f!==i&&!x.has(i)){const U=x.get(f);U&&(U.message.agentId=i,x.delete(f),x.set(i,U)),T.delete(f)}const _={agentId:i,nickname:(g==null?void 0:g.nickname)??O(s.agent_path)??(d==null?void 0:d.taskName)??null,agentPath:s.agent_path,message:(g==null?void 0:g.message)??(d==null?void 0:d.message)??"",model:(g==null?void 0:g.model)??(d==null?void 0:d.model)??null,agentType:(g==null?void 0:g.agentType)??(d==null?void 0:d.agentType)??null,timestamp:(g==null?void 0:g.timestamp)??(u||(d==null?void 0:d.timestamp)||""),parentToolCallId:(g==null?void 0:g.parentToolCallId)??r};T.set(i,_),A.set(s.agent_path,i),r&&(m==="started"||d)&&S.set(r,i),P(i,y,u,{status:m==="interrupted"?"interrupted":"running"});continue}if(!(a.type!=="response_item"||!s)){if(s.type==="reasoning"){const i=Array.isArray(s.summary)?s.summary.filter(r=>typeof r=="string").join(`
|
|
19
|
+
`):"";ue(y,i.trim(),u);continue}if(s.type==="message"&&s.role==="assistant"){ce(y,L(s,"output_text"),u);continue}if(s.type==="message"&&s.role==="user"&&y.userMessage===null){const i=V(L(s,"input_text")),r=yt(s),m=kt(s);(i||r.length>0||m.length>0)&&(y.userMessage=Tt(i,r,m),y.isFragment=!1,B=!0);continue}if(s.type==="web_search_call"&&typeof s.id=="string"){const i={};I(s.action)&&(i.action=s.action);const r=typeof s.status=="string"?s.status:"completed";c(y,s.id,i,r,u);continue}if(s.type==="tool_search_call"){const i=Ct(s.call_id,s.id)??"";if(i){const r={id:i,name:"ToolSearch",input:I(s.arguments)?s.arguments:{},result:null,isError:!1,timestamp:u};p.set(i,r),R(y,r,u)}continue}if(s.type==="tool_search_output"&&typeof s.call_id=="string"){const i=p.get(s.call_id);if(i){const r=Array.isArray(s.tools)?s.tools:[],m=r.filter(I).map(g=>Ct(g.name)??"").filter(Boolean),d=m.length>0?m.length:r.length,f=`Found ${d} tool${d===1?"":"s"}`;i.result=m.length>0?`${f}: ${m.join(", ")}`:f,i.isError=s.status==="failed",p.delete(s.call_id)}continue}if(s.type==="agent_message"&&typeof s.author=="string"){const i=s.author,r=typeof s.recipient=="string"?s.recipient:null,m=ie(s);if(m.messageType==="NEW_TASK")continue;const d=A.get(i),f=i.startsWith(`${o.agentPath}/`)&&(r===null||r===o.agentPath);if(!d&&!f)continue;const g=d??i;d||(T.set(g,{agentId:g,nickname:O(i),agentPath:i,message:"",model:null,agentType:null,timestamp:u,parentToolCallId:""}),A.set(i,g));let _;m.messageType==="FINAL_ANSWER"?_="completed":m.messageType==="ERROR"||m.messageType==="FAILED"?_="failed":m.messageType==="INTERRUPTED"?_="interrupted":m.messageType==="MESSAGE"&&(_="running"),P(g,y,u,{status:_,text:m.text||void 0});continue}if(s.type==="function_call"&&typeof s.call_id=="string"){const i=typeof s.name=="string"?s.name:"tool",r=Vt(i),m=bt(s.arguments);let d=r,f=m;r==="exec_command"?d="Bash":r==="update_plan"&&(d="TodoWrite",f=Xt(m)),r==="spawn_agent"&&b.set(s.call_id,{callId:s.call_id,message:ae(m.message),taskName:typeof m.task_name=="string"?m.task_name:null,model:typeof m.model=="string"?m.model:null,agentType:typeof m.agent_type=="string"?m.agent_type:null,timestamp:u});const g={id:s.call_id,name:d,input:f,result:null,isError:!1,timestamp:u};p.set(g.id,g),R(y,g,u);continue}if(s.type==="function_call_output"&&typeof s.call_id=="string"){const i=p.get(s.call_id);if(!i)continue;const r=typeof s.output=="string"?s.output:null;if(i.result=r,i.isError=Q(r),p.delete(s.call_id),i.name==="spawn_agent"&&r)try{const m=JSON.parse(r),d=typeof m.agent_id=="string"?m.agent_id:S.get(i.id)??"",f=typeof m.task_name=="string"?m.task_name:null,g=typeof m.nickname=="string"?m.nickname:f?O(f):null;if(d){const _=b.get(i.id),M=T.get(d),U={agentId:d,nickname:g??(M==null?void 0:M.nickname)??(_==null?void 0:_.taskName)??null,agentPath:f??(M==null?void 0:M.agentPath)??null,message:(M==null?void 0:M.message)??(_==null?void 0:_.message)??"",model:(M==null?void 0:M.model)??(_==null?void 0:_.model)??null,agentType:(M==null?void 0:M.agentType)??(_==null?void 0:_.agentType)??null,timestamp:(M==null?void 0:M.timestamp)??(_==null?void 0:_.timestamp)??u,parentToolCallId:(M==null?void 0:M.parentToolCallId)??i.id};T.set(d,U),S.set(i.id,d),U.agentPath&&A.set(U.agentPath,d),P(d,y,u,{status:"running"})}}catch{}if(i.name==="wait_agent"&&r&&y)try{const m=JSON.parse(r),d=I(m.status)?m.status:{};for(const[f,g]of Object.entries(d)){const _=I(g)?g:{},M=typeof _.completed=="string"?_.completed:"",U=typeof _.failed=="string"?_.failed:typeof _.error=="string"?_.error:"",F=typeof _.interrupted=="string"?_.interrupted:"",be=M?"completed":U?"failed":F?"interrupted":typeof _.status=="string"?_.status:"running";T.has(f)||T.set(f,{agentId:f,nickname:null,agentPath:null,message:"",model:null,agentType:null,timestamp:u,parentToolCallId:""}),P(f,y,u,{status:be,text:M||U||F||void 0})}}catch{}continue}if(s.type==="custom_tool_call"&&typeof s.call_id=="string"){const i=typeof s.name=="string"?s.name:"tool",r=typeof s.input=="string"?s.input:"",m=s.call_id,d=r?Gt(i,r,m,u,o.cwd):[];if(i!=="apply_patch"){const f={id:m,name:i==="exec_command"?"Bash":i,input:bt(r),result:null,isError:!1,timestamp:u};p.set(f.id,f),R(y,f,u)}for(const f of d)p.set(f.id,f),R(y,f,u);d.length>0&&k.set(m,{calls:d,direct:i==="apply_patch"});continue}if(s.type==="custom_tool_call_output"&&typeof s.call_id=="string"){const i=s.call_id,{text:r,isError:m}=ft(s.output),d=k.get(i);if(d){const g=d.direct&&m?new Set(d.calls.map(_=>_.id)):Zt(r,m,d.calls);for(const _ of d.calls){const M=p.get(_.id);M&&(M.result=r,M.isError=g.has(M.id),p.delete(M.id))}k.delete(i)}const f=p.get(i);f&&(f.result=r,f.isError=m,p.delete(i));continue}}}}}return W(l,y,v),{sessionId:o.sessionId,version:o.version,gitBranch:o.gitBranch,cwd:o.cwd,slug:o.slug,name:"",model:o.model,turns:l,stats:e!=null&&e.skipStats?J(l.length):G(l),rawMessages:e!=null&&e.skipStats?[]:n,branchedFrom:o.branchedFrom,agentKind:"codex"}}function vt(t){const e=[];for(const n of t.split(`
|
|
20
|
+
`)){const o=n.trim();if(o)try{e.push(JSON.parse(o))}catch{}}return e}function he(t){var n;const e=(n=t[0])==null?void 0:n.type;return e==="session_meta"||e==="turn_context"||e==="event_msg"||e==="response_item"||e==="compacted"||e==="world_state"||e==="inter_agent_communication_metadata"}function _e(t){return t.map(e=>JSON.stringify(e)).join(`
|
|
21
|
+
`)}function ye(t){const e={sessionId:"",version:"",gitBranch:"",cwd:"",slug:"",name:"",model:"",branchedFrom:void 0};for(const n of t)if(n.sessionId&&!e.sessionId&&(e.sessionId=n.sessionId),n.version&&!e.version&&(e.version=n.version),n.gitBranch&&!e.gitBranch&&(e.gitBranch=n.gitBranch),n.cwd&&!e.cwd&&(e.cwd=n.cwd),n.slug&&!e.slug&&(e.slug=n.slug),n.name&&!e.name&&(e.name=n.name),n.branchedFrom&&!e.branchedFrom&&(e.branchedFrom=n.branchedFrom),q(n)&&n.message.model&&!e.model&&(e.model=n.message.model),e.sessionId&&e.version&&e.gitBranch&&e.cwd&&e.model)break;return e}function ke(t,e){if(xt(t))return At(t,e);const n=vt(t),o=ye(n),l=it(n),p=e!=null&&e.skipStats?J(l.length):G(l);return{...o,turns:l,stats:p,rawMessages:e!=null&&e.skipStats?[]:n,agentKind:"claude"}}function Te(t,e){if(he(t.rawMessages)||xt(e)){const y=_e(t.rawMessages);return At(y?`${y}
|
|
22
|
+
${e}`:e)}const n=vt(e);if(n.length===0)return t;const o=t.rawMessages,l=[...o,...n],p=Kt(o),h=Math.max(0,t.turns.length-p.length);let k=Math.max(0,p.length-1);const b=new Set;for(const y of n)if(y.type==="progress"){const w=y.parentToolUseID;w&&b.add(w)}if(b.size>0)for(let y=k-1;y>=0;y--){const w=t.turns[h+y];if(w!=null&&w.toolCalls.some(C=>b.has(C.id))){k=y;break}}const T=p[k]??o.length,A=t.turns.slice(0,h+k),S=it(l.slice(T)),x=ot([...A,...S]),P=G(x);return{sessionId:t.sessionId,version:t.version,gitBranch:t.gitBranch,cwd:t.cwd,slug:t.slug,name:t.name,model:t.model||x.length>0&&x[x.length-1].model||"",turns:x,stats:P,rawMessages:l,branchedFrom:t.branchedFrom,agentKind:t.agentKind}}self.onmessage=t=>{const e=t.data;try{let n;e.type==="parse"?n=ke(e.text):n=Te(e.existing,e.newText),self.postMessage({type:"result",id:e.id,session:n})}catch(n){self.postMessage({type:"error",id:e.id,error:n instanceof Error?n.message:String(n)})}}})();
|
package/dist/web/index.html
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
.dark body { background: #09090b; color: #fafafa; }
|
|
16
16
|
body { background: #fafafa; color: #09090b; }
|
|
17
17
|
</style>
|
|
18
|
-
<script type="module" crossorigin src="/assets/index-
|
|
18
|
+
<script type="module" crossorigin src="/assets/index-C3E35E2A.js"></script>
|
|
19
19
|
<link rel="modulepreload" crossorigin href="/assets/vendor-react-gGw_S5I_.js">
|
|
20
20
|
<link rel="modulepreload" crossorigin href="/assets/vendor-ui-BmLOQ5Or.js">
|
|
21
21
|
<link rel="modulepreload" crossorigin href="/assets/vendor-markdown-BE1gYnO9.js">
|
package/package.json
CHANGED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
(function(){"use strict";function L(t){return t.type==="user"}function W(t){return t.type==="assistant"}function V(t){return t.type==="progress"}function X(t){return t.type==="system"}function H(t){return t.type==="summary"}function wt(t){return t.type==="queue-operation"}function Y(t){return t.type==="attachment"}function St(t){return t.type==="user"&&t.isCompactSummary===!0}function tt(t){return t.type==="system"&&t.subtype==="compact_boundary"}const It=/<(agent-message|teammate-message)([^>]*)>([\s\S]*?)<\/\1>/g,Et=[/\bteammate_id=(?:"([^"]*)"|'([^']*)')/,/\bfrom=(?:"([^"]*)"|'([^']*)')/];function Pt(t){for(const e of Et){const n=t.match(e),o=(n==null?void 0:n[1])??(n==null?void 0:n[2]);if(o)return o}return null}function z(t){let e=null,n=!1;const o=t.replace(It,(l,p,h,k)=>(n=!0,e===null&&(e=Pt(h)),k.trim()));return{sender:e,matched:n,body:n?o.trim():t}}function et(t){return typeof t=="string"?t:t.filter(e=>e.type==="text").map(e=>e.text).join(`
|
|
2
|
-
`)}function nt(t){return t?typeof t=="string"?t:t.map(e=>e.type==="text"?e.text:"").filter(Boolean).join(`
|
|
3
|
-
`):""}function st(t){if(!(t!=null&&t.trim()))return!1;const e=t.trimStart();return e.startsWith("<")?!e.includes("<task-notification>")&&!e.startsWith("<system-reminder>")&&!e.startsWith("<local-command-"):!0}function Bt(t){if(!Y(t))return null;const e=t.attachment;if(!e||e.type!=="queued_command"||e.commandMode!=="prompt")return null;const n=e.prompt;if(n==null)return null;const o=typeof n=="string"?n:et(n);if(!st(o))return null;const l=e.origin;if((l==null?void 0:l.kind)==="peer"){const h=l.name??l.from??null;if(h)return{raw:o,sender:h,body:l.body??z(o).body}}if((l==null?void 0:l.kind)==="human")return{raw:o,sender:null,body:o};const p=z(o);return{raw:o,sender:p.sender,body:p.body}}const Ut=[["attributionAgent","agent"],["attributionSkill","skill"],["attributionPlugin","plugin"],["attributionMcpServer","mcpServer"],["attributionMcpTool","mcpTool"]];function Ft(t,e){let n=t;for(const[o,l]of Ut){const p=e[o];typeof p!="string"||!p||(n={...n,[l]:p})}return n}function Nt(t,e){return t?{input_tokens:t.input_tokens+e.input_tokens,output_tokens:t.output_tokens+e.output_tokens,cache_creation_input_tokens:(t.cache_creation_input_tokens??0)+(e.cache_creation_input_tokens??0),cache_read_input_tokens:(t.cache_read_input_tokens??0)+(e.cache_read_input_tokens??0),speed:e.speed??t.speed}:{...e}}const Rt=/^This session is being continued from a previous conversation[\s\S]*?\n\nSummary:\s*\n/,$t=/\n+(?:If you need specific details from before compaction|(?:Please c|C)ontinue the conversation from where it left off)[\s\S]*$/;function Ot(t){return et(t).trim().replace(Rt,"").replace($t,"").trim()}function Dt(t){if(t)return{trigger:t.trigger,preTokens:t.preTokens,postTokens:t.postTokens}}function q(t,e){return{id:t.uuid??crypto.randomUUID(),userMessage:e,contentBlocks:[],thinking:[],assistantText:[],toolCalls:[],subAgentActivity:[],timestamp:t.timestamp??"",durationMs:null,tokenUsage:null,model:null}}function jt(t){const e=[];let n=0;for(;n<t.length;){const o=t[n];if(o.kind==="tool_calls"){const l=o.toolCalls.findIndex(p=>p.name==="EnterPlanMode");if(l!==-1){const p=o.toolCalls[l],h=String(p.input.plan??""),k=o.timestamp,b=o.toolCalls.slice(0,l);b.length>0&&e.push({kind:"tool_calls",toolCalls:b,timestamp:o.timestamp});const T=[],A=o.toolCalls.slice(l+1),w=A.findIndex(x=>x.name==="ExitPlanMode");if(w!==-1){T.push(...A.slice(0,w));const x=A[w],P=x.input.path?String(x.input.path):void 0;let y="pending";x.result!==null&&(y=x.isError?"rejected":"approved"),e.push({kind:"plan_mode",plan:h,planFilePath:P,status:y,toolCalls:T,timestamp:k});const S=A.slice(w+1);S.length>0&&e.push({kind:"tool_calls",toolCalls:S,timestamp:o.timestamp}),n++;continue}else{T.push(...A);let x,P,y="pending",S=n+1;const C=[];for(;S<t.length;){const v=t[S];if(v.kind==="tool_calls"){const E=v.toolCalls.findIndex(B=>B.name==="ExitPlanMode");if(E!==-1){T.push(...v.toolCalls.slice(0,E)),x=v.toolCalls[E],P=x.input.path?String(x.input.path):void 0,x.result!==null&&(y=x.isError?"rejected":"approved");const B=v.toolCalls.slice(E+1);e.push({kind:"plan_mode",plan:h,planFilePath:P,status:y,toolCalls:T,timestamp:k}),e.push(...C),B.length>0&&e.push({kind:"tool_calls",toolCalls:B,timestamp:v.timestamp}),n=S+1;break}else T.push(...v.toolCalls),S++}else if(v.kind==="hook_event"||v.kind==="text"||v.kind==="queued_prompt"||v.kind==="agent_message")C.push(v),S++;else break}x||(e.push({kind:"plan_mode",plan:h,planFilePath:void 0,status:"pending",toolCalls:T,timestamp:k}),e.push(...C),n=S);continue}}}e.push(o),n++}return e}function Lt(t){return t.contentBlocks.some(e=>e.kind==="agent_message")?{...t,contentBlocks:t.contentBlocks.map(e=>{if(e.kind!=="agent_message")return e;const{reply:n,...o}=e;return o})}:t}function ot(t){var o;const e=t.map(Lt),n=new Map;for(const l of e)for(const p of l.contentBlocks){if(p.kind==="agent_message"){const h=n.get(p.sender);h?h.push(p):n.set(p.sender,[p]);continue}if(p.kind==="tool_calls")for(const h of p.toolCalls){if(h.name!=="SendMessage")continue;const k=h.input.to;if(typeof k!="string"||!k)continue;const b=(o=n.get(k))==null?void 0:o.shift();if(!b)continue;const T=h.input.summary;b.reply={summary:typeof T=="string"?T:"",timestamp:h.timestamp||p.timestamp||""}}}return e}function Wt(t){const e=[];let n=!1;for(let o=0;o<t.length;o++){const l=t[o];if(H(l)||tt(l)){n=!1;continue}if(L(l)&&!l.isMeta){const p=l.message.content;if(n&&Array.isArray(p)&&p.some(k=>k.type==="tool_result"))continue;e.push(o),n=!0;continue}W(l)&&!n&&(e.push(o),n=!0)}return e}function it(t){var B,F;const e=[];let n=null,o=null;function l(u){o&&(u.compactionSummary=o.summary,u.compactionMeta=o.meta,o=null)}let p=null;const h=new Map,k=new Set,b=new Map,T=new Map,A=new Set,w=new Map,x=[],P=new Map;function y(u,r){let s=P.get(u);s||(s=new Map,P.set(u,s)),s.set(r,(s.get(r)??0)+1)}function S(u,r){const s=P.get(u),c=s==null?void 0:s.get(r);return!s||!c?!1:(c===1?s.delete(r):s.set(r,c-1),!0)}function C(){for(const u of x)u.turn.contentBlocks.push(u.sender?{kind:"agent_message",sender:u.sender,body:u.body,timestamp:u.timestamp}:{kind:"queued_prompt",content:u.content,timestamp:u.timestamp});x.length=0}function v(u){if(!n)return;const r=b.get(u);if(!r||r.length===0)return;n.subAgentActivity.push(...r),b.delete(u);const s=A.has(u)?"background_agent":"sub_agent",c=T.get(u);if(c)c.messages.push(...r);else{const i={kind:s,messages:[...r]};n.contentBlocks.push(i),T.set(u,i)}}function E(){if(n){for(const u of n.toolCalls)v(u.id);for(const[u]of b)v(u);for(const u of n.contentBlocks)if(u.kind==="hook_event")for(const r of u.events){if(!(r.eventName==="PostToolUse"||r.eventName.startsWith("PostToolUse:"))||!r.toolUseId)continue;const c=n.toolCalls.find(i=>i.id===r.toolUseId);c&&(r.updatedToolOutput&&(c.outputReplacedByHook=!0),r.durationMs!==void 0&&(c.hookDurationMs=(c.hookDurationMs??0)+r.durationMs))}n.contentBlocks=jt(n.contentBlocks),e.push(n),n=null,T.clear()}}for(const u of t){if(H(u)){E(),o={summary:u.summary};continue}if(tt(u)){E(),o={meta:Dt(u.compactMetadata)};continue}if(St(u)){E(),n=q(u,null),n.compactionSummary=Ot(u.message.content),n.compactionMeta=o==null?void 0:o.meta,o=null;continue}if(X(u)&&u.subtype==="away_summary"&&u.content){p={content:u.content,timestamp:u.timestamp};continue}if(wt(u)){if(n&&u.operation==="enqueue"&&st(u.content)){const r=z(u.content);x.push({turn:n,content:u.content,timestamp:u.timestamp,sender:r.sender,body:r.body}),y(n,u.content)}continue}if(Y(u)){const r=Bt(u);n&&r!==null&&!S(n,r.raw)&&x.push({turn:n,content:r.raw,timestamp:((B=u.attachment)==null?void 0:B.timestamp)??u.timestamp,sender:r.sender,body:r.body});continue}if(x.length>0){const r=L(u)&&!u.isMeta?u.message.content:null;if(typeof r=="string"){const s=x.findIndex(c=>c.content===r);if(s>=0){const[c]=x.splice(s,1);S(c.turn,c.content)}}C()}if(L(u)&&!u.isMeta){const r=u.message.content;if(typeof r!="string"&&Array.isArray(r)&&r.some(c=>c.type==="tool_result")&&n){for(const i of r)if(i.type==="tool_result"){const a=h.get(i.tool_use_id);a&&(a.turn.toolCalls[a.index].result=nt(i.content),a.turn.toolCalls[a.index].isError=i.is_error===!0,h.delete(i.tool_use_id))}const c=u.toolUseResult;if(c!=null&&c.agentId){const i=((F=r.find(_=>_.type==="tool_result"))==null?void 0:F.tool_use_id)??"",a=w.get(i),m=A.has(i),d=[];if(Array.isArray(c.content))for(const _ of c.content)_.type==="text"&&d.push(_.text);const f={agentId:c.agentId,parentToolUseId:i||void 0,agentName:(a==null?void 0:a.name)??null,subagentType:(a==null?void 0:a.subagentType)??null,type:"assistant",content:c.content,toolCalls:[],thinking:[],text:d,timestamp:u.timestamp??"",tokenUsage:c.usage?{input_tokens:c.usage.input_tokens??0,output_tokens:c.usage.output_tokens??0,cache_creation_input_tokens:c.usage.cache_creation_input_tokens??0,cache_read_input_tokens:c.usage.cache_read_input_tokens??0}:null,model:null,isBackground:m,prompt:c.prompt,status:c.status,durationMs:c.totalDurationMs,toolUseCount:c.totalToolUseCount};if(!T.get(i)){n.subAgentActivity.push(f);const M={kind:m?"background_agent":"sub_agent",messages:[f]};n.contentBlocks.push(M),T.set(i,M)}}continue}E(),n=q(u,u.message.content),l(n),p&&(n.contentBlocks.push({kind:"recap",content:p.content,timestamp:p.timestamp}),p=null);continue}if(W(u)){let r=function(){m.length>0&&(d.contentBlocks.push({kind:"tool_calls",toolCalls:[...m],timestamp:i}),m.length=0)},s=function(){if(a.length>0){const f=d.contentBlocks[d.contentBlocks.length-1];f&&f.kind==="thinking"?f.blocks.push(...a):d.contentBlocks.push({kind:"thinking",blocks:[...a],timestamp:i}),a.length=0}};n||(n=q(u,null),l(n)),n.model=u.message.model,u.effort&&(n.effort=u.effort),n.attribution=Ft(n.attribution,u);const c=u.message.id;k.has(c)||(k.add(c),n.tokenUsage=Nt(n.tokenUsage,u.message.usage));const i=u.timestamp??"",a=[],m=[],d=n;for(const f of u.message.content)if(f.type==="thinking"){r();const g=f;if(!g.thinking)continue;n.thinking.push(g),a.push(g)}else if(f.type==="text"){r(),s();const g=/<thinking>([\s\S]*?)<\/thinking>/g;let _=f.text,M;for(;(M=g.exec(f.text))!==null;){const U=M[1].trim();if(U){const N={type:"thinking",thinking:U,signature:""};n.thinking.push(N),n.contentBlocks.push({kind:"thinking",blocks:[N],timestamp:i})}_=_.replace(M[0],"")}if(_=_.trim(),_){n.assistantText.push(_);const U=n.contentBlocks[n.contentBlocks.length-1];U&&U.kind==="text"?U.text.push(_):n.contentBlocks.push({kind:"text",text:[_],timestamp:i})}}else if(f.type==="tool_use"){s();const g={id:f.id,name:f.name,input:f.input,result:null,isError:!1,timestamp:u.timestamp??""},_=n.toolCalls.length;if(n.toolCalls.push(g),m.push(g),h.set(f.id,{turn:n,index:_}),f.name==="Task"||f.name==="Agent"){const M=f.input;M.run_in_background===!0&&A.add(f.id),w.set(f.id,{name:M.name??null,subagentType:M.subagent_type??null})}}s(),r();continue}if(V(u)&&u.data.type==="agent_progress"){const r=u.data,s=u.parentToolUseID??"";let c=null;if(r.message.type==="assistant"){const f=r.message.message,g=f.id,_=f.usage;_&&g&&!k.has(g)&&(k.add(g),c={input_tokens:_.input_tokens??0,output_tokens:_.output_tokens??0,cache_creation_input_tokens:_.cache_creation_input_tokens??0,cache_read_input_tokens:_.cache_read_input_tokens??0})}const i=r.message.type==="assistant"?r.message.message.model??null:null,a=w.get(s),m={agentId:r.agentId,parentToolUseId:s||void 0,agentName:(a==null?void 0:a.name)??null,subagentType:(a==null?void 0:a.subagentType)??null,type:r.message.type,content:r.message.message.content,toolCalls:[],thinking:[],text:[],timestamp:r.message.timestamp??u.timestamp??"",tokenUsage:c,model:i,isBackground:A.has(s)};if(r.message.type==="assistant"){const f=r.message.message.content;if(Array.isArray(f))for(const g of f)g.type==="thinking"?m.thinking.push(g.thinking):g.type==="text"?m.text.push(g.text):g.type==="tool_use"&&m.toolCalls.push({id:g.id,name:g.name,input:g.input,result:null,isError:!1,timestamp:r.message.timestamp??u.timestamp??""})}else if(r.message.type==="user"){const f=r.message.message.content;if(Array.isArray(f)){for(const g of f)if(g.type==="tool_result"){const _=b.get(s);if(_)for(const M of _){const U=M.toolCalls.find(N=>N.id===g.tool_use_id);U&&(U.result=nt(g.content),U.isError=g.is_error===!0)}}}}let d=b.get(s);d||(d=[],b.set(s,d)),d.push(m),n&&v(s);continue}if(V(u)&&u.data.type==="hook_progress"){const r=u.data,s=String(r.hook_event_name??r.hookEvent??"unknown"),c=r.hookSpecificOutput,i={eventName:s,source:r.source!==void 0?String(r.source):void 0,toolName:r.tool_name!==void 0?String(r.tool_name):void 0,toolUseId:r.tool_use_id!==void 0?String(r.tool_use_id):void 0,command:r.command!==void 0?String(r.command):void 0,output:r.output!==void 0?String(r.output):void 0,stderr:r.stderr!==void 0?String(r.stderr):void 0,exitCode:r.exit_code!==void 0?Number(r.exit_code):void 0,decision:r.decision!==void 0?String(r.decision):void 0,durationMs:r.duration_ms!==void 0?Number(r.duration_ms):void 0,updatedToolOutput:(c==null?void 0:c.updatedToolOutput)!==void 0?String(c.updatedToolOutput):void 0,sessionTitle:(c==null?void 0:c.sessionTitle)!==void 0?String(c.sessionTitle):void 0,worktreePath:(c==null?void 0:c.worktreePath)!==void 0?String(c.worktreePath):void 0,timestamp:u.timestamp??""};if(n){const a=n.contentBlocks[n.contentBlocks.length-1];a&&a.kind==="hook_event"?a.events.push(i):n.contentBlocks.push({kind:"hook_event",events:[i],timestamp:u.timestamp})}continue}if(X(u)&&u.subtype==="turn_duration"&&n){n.durationMs=u.durationMs??null;continue}}return C(),E(),ot(e)}function at(t,e){let n=0;for(const o of t)e[o.name]=(e[o.name]??0)+1,o.isError&&n++;return n}function rt(t,e){t.totalInputTokens+=e.input_tokens,t.totalOutputTokens+=e.output_tokens,t.totalCacheCreationTokens+=e.cache_creation_input_tokens??0,t.totalCacheReadTokens+=e.cache_read_input_tokens??0}function J(t){return{totalInputTokens:0,totalOutputTokens:0,totalCacheCreationTokens:0,totalCacheReadTokens:0,toolCallCounts:{},errorCount:0,totalDurationMs:0,turnCount:t}}function K(t){const e=J(t.length);for(const n of t){n.tokenUsage&&rt(e,n.tokenUsage),n.durationMs&&(e.totalDurationMs+=n.durationMs),e.errorCount+=at(n.toolCalls,e.toolCallCounts);for(const o of n.subAgentActivity)e.errorCount+=at(o.toolCalls,e.toolCallCounts),o.tokenUsage&&rt(e,o.tokenUsage)}return e}const lt={0:"\0",b:"\b",f:"\f",n:`
|
|
4
|
-
`,r:"\r",t:" ",v:"\v"};function ct(t,e){const n=t[e];if(n!=='"'&&n!=="'"&&n!=="`")return null;let o="",l=e+1;for(;l<t.length;){const p=t[l];if(p===n)return{endIndex:l+1,value:o};if(p!=="\\"){o+=p,l++;continue}if(l++,l>=t.length)return null;const h=t[l];if(h in lt){o+=lt[h],l++;continue}if(h===`
|
|
5
|
-
`){l++;continue}if(h==="\r"){l+=t[l+1]===`
|
|
6
|
-
`?2:1;continue}if(h==="x"&&/^[0-9a-fA-F]{2}$/.test(t.slice(l+1,l+3))){o+=String.fromCharCode(Number.parseInt(t.slice(l+1,l+3),16)),l+=3;continue}if(h==="u"){const k=t.slice(l+1).match(/^\{([0-9a-fA-F]+)\}/);if(k){const T=Number.parseInt(k[1],16);if(Number.isFinite(T)&&T<=1114111){o+=String.fromCodePoint(T),l+=k[0].length+1;continue}}const b=t.slice(l+1,l+5);if(/^[0-9a-fA-F]{4}$/.test(b)){o+=String.fromCharCode(Number.parseInt(b,16)),l+=5;continue}}o+=h,l++}return null}function ut(t){return t.includes("*** Begin Patch")&&t.includes("*** End Patch")}function zt(t){if(!t.includes("apply_patch")||!t.includes("*** Begin Patch"))return[];const e=new Map;for(let h=0;h<t.length;h++){const k=ct(t,h);if(k){if(ut(k.value)){const b=t.slice(0,h).match(/(?:^|[;\n])\s*(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*$/);b&&e.set(b[1],k.value)}h=k.endIndex-1}}const n=[],o=new Set,l=/\btools\s*\.\s*apply_patch\s*\(/g;let p;for(;(p=l.exec(t))!==null;){let h=p.index+p[0].length;for(;/\s/.test(t[h]??"");)h++;const k=ct(t,h),b=k?null:t.slice(h).match(/^([A-Za-z_$][\w$]*)/),T=(k==null?void 0:k.value)??(b?e.get(b[1]):void 0);!T||!ut(T)||o.has(T)||(o.add(T),n.push(T))}return n}function pt(t,e){if(!e||t.startsWith("/")||/^[A-Za-z]:[\\/]/.test(t))return t;const n=e.replace(/[\\/]+$/,""),o=t.replace(/^\.[\\/]/,"");return/^[A-Za-z]:[\\/]/.test(e)?`${n}\\${o.replace(/\//g,"\\")}`:`${n}/${o}`}function dt(t,e,n,o=""){var b,T;const l=[],p=/^\*\*\*\s+(Update File|Add File|Delete File):\s*(.+)$/gm,h=[];let k;for(;(k=p.exec(t))!==null;)h.push({action:k[1],filePath:k[2].trim(),headerIdx:k.index,startIdx:k.index+k[0].length});for(let A=0;A<h.length;A++){const w=h[A],x=A+1<h.length?h[A+1].headerIdx:t.length,P=t.slice(w.startIdx,x),y=(T=(b=P.match(/^\*\*\*\s+Move to:\s*(.+)$/m))==null?void 0:b[1])==null?void 0:T.trim(),S=pt(w.filePath,o),C=pt(y||w.filePath,o),v=P.split(/^@@.*$/m).filter(u=>u.trim()),E=[],B=[];for(const u of v)for(const r of u.split(`
|
|
7
|
-
`))r.startsWith("-")?E.push(r.slice(1)):r.startsWith("+")?B.push(r.slice(1)):r.startsWith(" ")&&(E.push(r.slice(1)),B.push(r.slice(1)));const F=h.length>1?`${e}:file-${A}`:e;w.action==="Add File"?l.push({id:F,name:"Write",input:{file_path:C,content:B.join(`
|
|
8
|
-
`)},result:null,isError:!1,timestamp:n}):w.action==="Delete File"?l.push({id:F,name:"Edit",input:{file_path:C,old_string:E.join(`
|
|
9
|
-
`),new_string:""},result:null,isError:!1,timestamp:n}):l.push({id:F,name:"Edit",input:{file_path:C,...y?{old_path:S}:{},old_string:E.join(`
|
|
10
|
-
`),new_string:B.join(`
|
|
11
|
-
`)},result:null,isError:!1,timestamp:n})}return l}function qt(t,e,n,o,l=""){return t==="apply_patch"?dt(e,n,o,l):zt(e).flatMap((p,h)=>dt(p,`${n}:patch-${h}`,o,l))}function Jt(t,e,n){var k;if(!e||!/(?:apply[_ ]patch|invalid patch|invalid context|failed to (?:apply|find)|could not apply)/i.test(t))return new Set;const o=new Map;for(const b of n){const T=(k=b.id.match(/:patch-(\d+)(?::file-\d+)?$/))==null?void 0:k[1];if(T===void 0)continue;const A=Number(T),w=o.get(A)??[];w.push(b),o.set(A,w)}if(o.size===0)return new Set(n.map(b=>b.id));const l=t.toLowerCase().replaceAll("\\","/"),p=new Set;for(const[b,T]of o)T.some(A=>{const w=String(A.input.file_path??"").toLowerCase().replaceAll("\\","/");if(!w)return!1;const P=w.split("/").filter(Boolean).slice(-2).join("/");return l.includes(w)||P.includes("/")&&l.includes(P)})&&p.add(b);for(const b of l.matchAll(/\bpatch\s*(?:#|-)?\s*(\d+)\b/g)){const T=Number(b[1]);o.has(T)&&p.add(T)}p.size===0&&p.add(Math.max(...o.keys()));const h=Math.min(...p);for(const b of o.keys())b>=h&&p.add(b);return new Set([...p].flatMap(b=>{var T;return((T=o.get(b))==null?void 0:T.map(A=>A.id))??[]}))}function Z(t){return typeof t=="object"&&t!==null}const Kt=new Map([["spawn_agent","spawn_agent"],["spawnAgent","spawn_agent"],["wait_agent","wait_agent"],["waitAgent","wait_agent"],["send_message","send_message"],["sendMessage","send_message"],["followup_task","followup_task"],["followupTask","followup_task"],["list_agents","list_agents"],["listAgents","list_agents"],["interrupt_agent","interrupt_agent"],["interruptAgent","interrupt_agent"]]);function Zt(t){const e=t.split(/(?:__|[.:/])+/).filter(Boolean).at(-1)??t;return Kt.get(e)??t}function G(t){if(!t)return!1;const e=t.match(/Process exited with code (\d+)/);if(e)return e[1]!=="0";const n=t.replace(/\b0\s+(?:fail(?:ed|ures?)?|errors?)\b/gi,"").replace(/\bno\s+(?:failures?|errors?)\b/gi,"");return/\b(error|failed|exception)\b/i.test(n)}function Gt(t){return{todos:(Array.isArray(t.plan)?t.plan:[]).filter(o=>Z(o)).map(o=>({content:typeof o.step=="string"?o.step:"",status:typeof o.status=="string"?o.status:"pending",activeForm:typeof o.step=="string"?o.step:""}))}}function Qt(t){return typeof t=="string"?t:Array.isArray(t)?t.filter(e=>Z(e)&&typeof e.text=="string").map(e=>e.text).join(""):""}function ft(t){const e=Qt(t);if(!e)return{text:"",isError:!1};try{const n=JSON.parse(e),o=typeof n.output=="string"?n.output:e,l=Z(n.metadata)?n.metadata:null,p=l?l.exit_code!==0&&l.exit_code!==void 0:G(o);return{text:o,isError:p}}catch{return{text:e,isError:G(e)}}}const Vt=["# AGENTS.md instructions for ","<recommended_plugins>","<environment_context>","<permissions instructions>","<collaboration_mode>","<skills_instructions>"];function Xt(t){var e,n;return((n=(e=globalThis.crypto)==null?void 0:e.randomUUID)==null?void 0:n.call(e))??`${t}-${Math.random().toString(36).slice(2,10)}`}function mt(t){try{return JSON.parse(t)}catch{return null}}function I(t){return typeof t=="object"&&t!==null}function gt(t){return!t||typeof t.type!="string"?!1:t.type==="session_meta"||t.type==="turn_context"||t.type==="event_msg"||t.type==="response_item"||t.type==="inter_agent_communication_metadata"||t.type==="compacted"||t.type==="world_state"}function D(t,e){const n=t==null?void 0:t.content;return Array.isArray(n)?n.filter(o=>I(o)&&o.type===e&&typeof o.text=="string").map(o=>o.text).join(`
|
|
12
|
-
`).trim():""}const Ht=/^data:(image\/(?:png|jpeg|gif|webp));base64,(.+)$/is,Yt=/^data:(audio\/(?:wav|x-wav|mpeg|mp4|webm|ogg));base64,(.+)$/is;function ht(t){if(typeof t!="string")return null;const e=Ht.exec(t);return!(e!=null&&e[1])||!e[2]?null:{type:"image",source:{type:"base64",media_type:e[1].toLowerCase(),data:e[2]}}}function _t(t){if(typeof t!="string")return null;const e=Yt.exec(t);return!(e!=null&&e[1])||!e[2]?null:{type:"audio",source:{type:"base64",media_type:e[1].toLowerCase(),data:e[2]}}}function te(t){return Array.isArray(t.images)?t.images.map(ht).filter(e=>e!==null):[]}function ee(t){return Array.isArray(t.audio)?t.audio.map(_t).filter(e=>e!==null):[]}function yt(t){return Array.isArray(t.content)?t.content.filter(e=>I(e)&&e.type==="input_image").map(e=>ht(e.image_url)).filter(e=>e!==null):[]}function kt(t){return Array.isArray(t.content)?t.content.filter(e=>I(e)&&e.type==="input_audio").map(e=>_t(e.audio_url)).filter(e=>e!==null):[]}function Tt(t,e,n=[],o=[],l=[]){const p=[...o.map(k=>`
|
|
13
|
-
`),...l.map(k=>`
|
|
14
|
-
[audio attachment](<${k}>)`)].join(""),h=t+p;return e.length===0&&n.length===0?h:[...e,...n,...h?[{type:"text",text:h}]:[]]}function ne(t){var h,k;const e=D(t,"input_text");if(!e)return{messageType:null,text:""};const n=e.match(/\r?\nPayload:\s*(?:\r?\n|$)/);if(!e.startsWith("Message Type:")||!n||n.index===void 0)return{messageType:null,text:e.trim()};const l=((k=(h=e.slice(0,n.index).match(/^Message Type:\s*([^\r\n]+)/))==null?void 0:h[1])==null?void 0:k.trim().toUpperCase())??null,p=e.slice(n.index+n[0].length).trim();return{messageType:l,text:p}}function $(t){return t.split(/[\\/]/).filter(Boolean).at(-1)??null}function se(t){if(typeof t!="string")return"";const e=t.trim();return/^gAAAAA[A-Za-z0-9_-]+$/.test(e)?"":e}function Q(t){const e=t.trim();return!e||Vt.some(n=>e.startsWith(n))?"":e}function oe(t,e){return t?{input_tokens:t.input_tokens+e.input_tokens,output_tokens:t.output_tokens+e.output_tokens,cache_creation_input_tokens:(t.cache_creation_input_tokens??0)+(e.cache_creation_input_tokens??0),cache_read_input_tokens:(t.cache_read_input_tokens??0)+(e.cache_read_input_tokens??0)}:{...e}}function ie(t){if(!I(t))return null;const e=typeof t.input_tokens=="number"?t.input_tokens:0,n=typeof t.output_tokens=="number"?t.output_tokens:0,o=typeof t.cache_write_input_tokens=="number"?t.cache_write_input_tokens:typeof t.cache_creation_input_tokens=="number"?t.cache_creation_input_tokens:0,l=typeof t.cached_input_tokens=="number"?Math.max(0,t.cached_input_tokens):null,p=l??(typeof t.cache_read_input_tokens=="number"?t.cache_read_input_tokens:0),h=l===null?e:Math.max(0,e-l);return h===0&&n===0&&o===0&&p===0?null:{input_tokens:h,output_tokens:n,cache_creation_input_tokens:o,cache_read_input_tokens:p}}function ae(t,e,n){if(!e)return;t.assistantText.push(e);const o=t.contentBlocks[t.contentBlocks.length-1];if(o&&o.kind==="text"){o.text.push(e);return}t.contentBlocks.push({kind:"text",text:[e],timestamp:n})}function re(t,e,n){if(!e)return;const o={type:"thinking",thinking:e,signature:""};t.thinking.push(o);const l=t.contentBlocks[t.contentBlocks.length-1];if(l&&l.kind==="thinking"){l.blocks.push(o);return}t.contentBlocks.push({kind:"thinking",blocks:[o],timestamp:n})}function R(t,e,n){t.toolCalls.push(e);const o=t.contentBlocks[t.contentBlocks.length-1];if(o&&o.kind==="tool_calls"&&o.timestamp===n){o.toolCalls.push(e);return}t.contentBlocks.push({kind:"tool_calls",toolCalls:[e],timestamp:n})}function j(t,e,n){if(!e||!(e.userMessage!==null||e.assistantText.length>0||e.toolCalls.length>0||e.thinking.length>0||e.subAgentActivity.length>0))return null;if(e.timestamp&&n){const l=new Date(e.timestamp).getTime(),p=new Date(n).getTime();Number.isFinite(l)&&Number.isFinite(p)&&p>=l&&(e.durationMs=p-l)}return t.push(e),null}function bt(t){if(typeof t!="string"||!t.trim())return{};try{const e=JSON.parse(t);return I(e)?e:{value:e}}catch{return{raw:t}}}function O(t){if(typeof t=="string")return t;try{return JSON.stringify(t)}catch{return String(t??"")}}function Ct(...t){return t.find(e=>typeof e=="string")}function le(t){return t.startsWith("exec-")}function ce(t){if(!I(t))return{text:O(t),isError:!1};if("Err"in t)return{text:O(t.Err),isError:!0};const e=I(t.Ok)?t.Ok:null;if(!e)return{text:O(t),isError:!1};const n=ft(e.content);return{text:n.text||(e.structuredContent!==void 0?O(e.structuredContent):O(e)),isError:e.isError===!0||n.isError}}function ue(t,e,n){return{id:t?`${t}@${e}`:Xt("codex-turn"),userMessage:null,contentBlocks:[],thinking:[],assistantText:[],toolCalls:[],subAgentActivity:[],timestamp:e,durationMs:null,tokenUsage:null,model:n}}function Mt(t){return t.type==="event_msg"&&I(t.payload)&&t.payload.type==="user_message"&&typeof t.payload.message=="string"?Q(t.payload.message):t.type==="response_item"&&I(t.payload)&&t.payload.type==="message"&&t.payload.role==="user"?Q(D(t.payload,"input_text")):""}function pe(t,e){if(t.type==="session_meta"||t.type==="event_msg"&&(e==null?void 0:e.type)==="task_started")return!1;if(t.type==="response_item"&&(e==null?void 0:e.type)==="message"){if(e.role==="developer"||e.role==="system")return!1;if(e.role==="user")return Mt(t)!==""||yt(e).length>0||kt(e).length>0}return!0}function de(t){let e="",n="",o="",l="",p="",h,k="",b="",T="",A="",w=0,x=!1,P=null,y="/root",S="";for(const C of t){if(!I(C.payload))continue;if(C.type==="session_meta"){if(e||(e=typeof C.payload.id=="string"?C.payload.id:""),n||(n=typeof C.payload.cli_version=="string"?C.payload.cli_version:""),l||(l=typeof C.payload.cwd=="string"?C.payload.cwd:""),!h&&I(C.payload.branchedFrom)){const F=typeof C.payload.branchedFrom.sessionId=="string"?C.payload.branchedFrom.sessionId:"";F&&(h={sessionId:F,turnIndex:typeof C.payload.branchedFrom.turnIndex=="number"?C.payload.branchedFrom.turnIndex:null})}const E=I(C.payload.source)?C.payload.source:null;if(E&&I(E.subagent)){x=!0;const F=I(E.subagent.thread_spawn)?E.subagent.thread_spawn:null;F&&typeof F.agent_path=="string"&&(y=F.agent_path)}typeof C.payload.forked_from_id=="string"&&C.payload.forked_from_id&&(P=C.payload.forked_from_id);const B=I(C.payload.git)?C.payload.git:null;o||(o=B&&typeof B.branch=="string"?B.branch:"")}C.type==="turn_context"&&(p||(p=typeof C.payload.model=="string"?C.payload.model:""),l||(l=typeof C.payload.cwd=="string"?C.payload.cwd:""));const v=Mt(C);v&&v!==S&&(k||(k=v),b=v,S=v,w++,T||(T=C.timestamp??""),A=C.timestamp??A)}return A===""&&(A=T),{sessionId:e,version:n,gitBranch:o,cwd:l,model:p,slug:"",name:"",branchedFrom:h,firstUserMessage:k,lastUserMessage:b,timestamp:T,lastTimestamp:A,turnCount:w,isSubagent:x,parentSessionId:P,agentPath:y}}function xt(t){for(const e of t.split(`
|
|
15
|
-
`)){const n=e.trim();if(n)return gt(mt(n))}return!1}function At(t,e){const n=t.split(`
|
|
16
|
-
`).map(r=>r.trim()).filter(Boolean).map(mt).filter(gt),o=de(n),l=[],p=new Map,h=new Map,k=new Map,b=new Map,T=new Map,A=new Map,w=new Map,x=new Map;function P(r,s,c,i={}){const a=T.get(r);let m=x.get(r);if(!m){const f={agentId:r,parentToolUseId:(a==null?void 0:a.parentToolCallId)||void 0,agentName:(a==null?void 0:a.nickname)??(a!=null&&a.agentPath?$(a.agentPath):null),subagentType:(a==null?void 0:a.agentType)??null,type:"assistant",content:null,toolCalls:[],thinking:[],text:[],timestamp:(a==null?void 0:a.timestamp)??c,tokenUsage:null,model:(a==null?void 0:a.model)??null,isBackground:!1,prompt:(a==null?void 0:a.message)||void 0,status:i.status??"running"};s.subAgentActivity.push(f);const g=s.contentBlocks[s.contentBlocks.length-1];(g==null?void 0:g.kind)==="sub_agent"?g.messages.push(f):s.contentBlocks.push({kind:"sub_agent",messages:[f],timestamp:c}),m={message:f,turn:s},x.set(r,m)}const d=m.message;if(a&&(d.parentToolUseId=a.parentToolCallId||d.parentToolUseId,d.agentName=a.nickname??(a.agentPath?$(a.agentPath):d.agentName),d.subagentType=a.agentType,d.model=a.model,d.prompt=a.message||d.prompt),i.text&&!d.text.includes(i.text)&&(d.text.push(i.text),d.content=d.text.join(`
|
|
17
|
-
|
|
18
|
-
`)),i.status){const f=new Set(["completed","failed","interrupted"]);if(i.status==="running"&&d.status&&f.has(d.status)||(d.status=i.status),f.has(i.status)&&d.timestamp&&c){const g=new Date(d.timestamp).getTime(),_=new Date(c).getTime();Number.isFinite(g)&&Number.isFinite(_)&&_>=g&&(d.durationMs=_-g)}}return d}let y=null,S=null,C=o.model||null,v="",E=null,B=!1;function F(r,s,c){const i=ue(r,s,c);return B||(i.isFragment=!0),E&&(i.compactionSummary=E,E=null),i}function u(r,s,c,i,a){const m=h.get(s);if(m){m.input={...m.input,...c},m.result=i,m.isError=i==="failed";return}const d={id:s,name:"WebSearch",input:c,result:i,isError:i==="failed",timestamp:a};h.set(s,d),R(r,d,a)}for(const r of n){const s=I(r.payload)?r.payload:void 0,c=r.timestamp??"";if(r.type==="compacted"){y=j(l,y,v),E="Conversation compacted",v=c;continue}if(r.type!=="world_state"){if(r.type==="turn_context"){y=j(l,y,v),S=typeof(s==null?void 0:s.turn_id)=="string"?s.turn_id:null,C=typeof(s==null?void 0:s.model)=="string"?s.model:C,v=c,B=!0;continue}if(r.type==="event_msg"&&(s==null?void 0:s.type)==="user_message"&&typeof s.message=="string"){y&&(y.assistantText.length>0||y.toolCalls.length>0||y.thinking.length>0)&&(y=j(l,y,v)),B=!0,y??(y=F(S,c,C));const i=(Array.isArray(s.local_images)?s.local_images:[]).filter(m=>typeof m=="string"&&m.length>0),a=(Array.isArray(s.local_audio)?s.local_audio:[]).filter(m=>typeof m=="string"&&m.length>0);y.userMessage=Tt(s.message,te(s),ee(s),i,a),y.isFragment=!1,y.timestamp=y.timestamp||c,v=c;continue}if(!(!y&&!pe(r,s))){if(y??(y=F(S,c,C)),!y.model&&C&&(y.model=C),y.timestamp||(y.timestamp=c),c&&(v=c),r.type==="event_msg"&&(s==null?void 0:s.type)==="token_count"){const i=I(s.info)?s.info:null,a=i?ie(i.last_token_usage):null;a&&(y.tokenUsage=oe(y.tokenUsage,a));continue}if(r.type==="event_msg"&&(s==null?void 0:s.type)==="web_search_end"&&typeof s.call_id=="string"){const i={};typeof s.query=="string"&&s.query&&(i.query=s.query),I(s.action)&&(i.action=s.action),u(y,s.call_id,i,"completed",c);continue}if(r.type==="event_msg"&&(s==null?void 0:s.type)==="mcp_tool_call_end"&&typeof s.call_id=="string"&&I(s.invocation)){const i=s.invocation,a=typeof i.server=="string"?i.server:"mcp",m=typeof i.tool=="string"?i.tool:"tool",d=I(i.arguments)?i.arguments:{},f=ce(s.result),g=p.get(s.call_id);g?(g.result=f.text,g.isError=f.isError,p.delete(s.call_id)):le(s.call_id)||R(y,{id:s.call_id,name:`mcp__${a}__${m}`,input:d,result:f.text,isError:f.isError,timestamp:c},c);continue}if(r.type==="event_msg"&&(s==null?void 0:s.type)==="sub_agent_activity"&&typeof s.agent_thread_id=="string"&&typeof s.agent_path=="string"){const i=s.agent_thread_id,a=typeof s.event_id=="string"?s.event_id:"",m=typeof s.kind=="string"?s.kind:"started",d=a?b.get(a):void 0,f=A.get(s.agent_path),g=T.get(i)??(f?T.get(f):void 0);if(m!=="started"&&!g&&!d)continue;if(f&&f!==i&&!x.has(i)){const U=x.get(f);U&&(U.message.agentId=i,x.delete(f),x.set(i,U)),T.delete(f)}const _={agentId:i,nickname:(g==null?void 0:g.nickname)??$(s.agent_path)??(d==null?void 0:d.taskName)??null,agentPath:s.agent_path,message:(g==null?void 0:g.message)??(d==null?void 0:d.message)??"",model:(g==null?void 0:g.model)??(d==null?void 0:d.model)??null,agentType:(g==null?void 0:g.agentType)??(d==null?void 0:d.agentType)??null,timestamp:(g==null?void 0:g.timestamp)??(c||(d==null?void 0:d.timestamp)||""),parentToolCallId:(g==null?void 0:g.parentToolCallId)??a};T.set(i,_),A.set(s.agent_path,i),a&&(m==="started"||d)&&w.set(a,i),P(i,y,c,{status:m==="interrupted"?"interrupted":"running"});continue}if(!(r.type!=="response_item"||!s)){if(s.type==="reasoning"){const i=Array.isArray(s.summary)?s.summary.filter(a=>typeof a=="string").join(`
|
|
19
|
-
`):"";re(y,i.trim(),c);continue}if(s.type==="message"&&s.role==="assistant"){ae(y,D(s,"output_text"),c);continue}if(s.type==="message"&&s.role==="user"&&y.userMessage===null){const i=Q(D(s,"input_text")),a=yt(s),m=kt(s);(i||a.length>0||m.length>0)&&(y.userMessage=Tt(i,a,m),y.isFragment=!1,B=!0);continue}if(s.type==="web_search_call"&&typeof s.id=="string"){const i={};I(s.action)&&(i.action=s.action);const a=typeof s.status=="string"?s.status:"completed";u(y,s.id,i,a,c);continue}if(s.type==="tool_search_call"){const i=Ct(s.call_id,s.id)??"";if(i){const a={id:i,name:"ToolSearch",input:I(s.arguments)?s.arguments:{},result:null,isError:!1,timestamp:c};p.set(i,a),R(y,a,c)}continue}if(s.type==="tool_search_output"&&typeof s.call_id=="string"){const i=p.get(s.call_id);if(i){const a=Array.isArray(s.tools)?s.tools:[],m=a.filter(I).map(g=>Ct(g.name)??"").filter(Boolean),d=m.length>0?m.length:a.length,f=`Found ${d} tool${d===1?"":"s"}`;i.result=m.length>0?`${f}: ${m.join(", ")}`:f,i.isError=s.status==="failed",p.delete(s.call_id)}continue}if(s.type==="agent_message"&&typeof s.author=="string"){const i=s.author,a=typeof s.recipient=="string"?s.recipient:null,m=ne(s);if(m.messageType==="NEW_TASK")continue;const d=A.get(i),f=i.startsWith(`${o.agentPath}/`)&&(a===null||a===o.agentPath);if(!d&&!f)continue;const g=d??i;d||(T.set(g,{agentId:g,nickname:$(i),agentPath:i,message:"",model:null,agentType:null,timestamp:c,parentToolCallId:""}),A.set(i,g));let _;m.messageType==="FINAL_ANSWER"?_="completed":m.messageType==="ERROR"||m.messageType==="FAILED"?_="failed":m.messageType==="INTERRUPTED"?_="interrupted":m.messageType==="MESSAGE"&&(_="running"),P(g,y,c,{status:_,text:m.text||void 0});continue}if(s.type==="function_call"&&typeof s.call_id=="string"){const i=typeof s.name=="string"?s.name:"tool",a=Zt(i),m=bt(s.arguments);let d=a,f=m;a==="exec_command"?d="Bash":a==="update_plan"&&(d="TodoWrite",f=Gt(m)),a==="spawn_agent"&&b.set(s.call_id,{callId:s.call_id,message:se(m.message),taskName:typeof m.task_name=="string"?m.task_name:null,model:typeof m.model=="string"?m.model:null,agentType:typeof m.agent_type=="string"?m.agent_type:null,timestamp:c});const g={id:s.call_id,name:d,input:f,result:null,isError:!1,timestamp:c};p.set(g.id,g),R(y,g,c);continue}if(s.type==="function_call_output"&&typeof s.call_id=="string"){const i=p.get(s.call_id);if(!i)continue;const a=typeof s.output=="string"?s.output:null;if(i.result=a,i.isError=G(a),p.delete(s.call_id),i.name==="spawn_agent"&&a)try{const m=JSON.parse(a),d=typeof m.agent_id=="string"?m.agent_id:w.get(i.id)??"",f=typeof m.task_name=="string"?m.task_name:null,g=typeof m.nickname=="string"?m.nickname:f?$(f):null;if(d){const _=b.get(i.id),M=T.get(d),U={agentId:d,nickname:g??(M==null?void 0:M.nickname)??(_==null?void 0:_.taskName)??null,agentPath:f??(M==null?void 0:M.agentPath)??null,message:(M==null?void 0:M.message)??(_==null?void 0:_.message)??"",model:(M==null?void 0:M.model)??(_==null?void 0:_.model)??null,agentType:(M==null?void 0:M.agentType)??(_==null?void 0:_.agentType)??null,timestamp:(M==null?void 0:M.timestamp)??(_==null?void 0:_.timestamp)??c,parentToolCallId:(M==null?void 0:M.parentToolCallId)??i.id};T.set(d,U),w.set(i.id,d),U.agentPath&&A.set(U.agentPath,d),P(d,y,c,{status:"running"})}}catch{}if(i.name==="wait_agent"&&a&&y)try{const m=JSON.parse(a),d=I(m.status)?m.status:{};for(const[f,g]of Object.entries(d)){const _=I(g)?g:{},M=typeof _.completed=="string"?_.completed:"",U=typeof _.failed=="string"?_.failed:typeof _.error=="string"?_.error:"",N=typeof _.interrupted=="string"?_.interrupted:"",ye=M?"completed":U?"failed":N?"interrupted":typeof _.status=="string"?_.status:"running";T.has(f)||T.set(f,{agentId:f,nickname:null,agentPath:null,message:"",model:null,agentType:null,timestamp:c,parentToolCallId:""}),P(f,y,c,{status:ye,text:M||U||N||void 0})}}catch{}continue}if(s.type==="custom_tool_call"&&typeof s.call_id=="string"){const i=typeof s.name=="string"?s.name:"tool",a=typeof s.input=="string"?s.input:"",m=s.call_id,d=a?qt(i,a,m,c,o.cwd):[];if(i!=="apply_patch"){const f={id:m,name:i==="exec_command"?"Bash":i,input:bt(a),result:null,isError:!1,timestamp:c};p.set(f.id,f),R(y,f,c)}for(const f of d)p.set(f.id,f),R(y,f,c);d.length>0&&k.set(m,{calls:d,direct:i==="apply_patch"});continue}if(s.type==="custom_tool_call_output"&&typeof s.call_id=="string"){const i=s.call_id,{text:a,isError:m}=ft(s.output),d=k.get(i);if(d){const g=d.direct&&m?new Set(d.calls.map(_=>_.id)):Jt(a,m,d.calls);for(const _ of d.calls){const M=p.get(_.id);M&&(M.result=a,M.isError=g.has(M.id),p.delete(M.id))}k.delete(i)}const f=p.get(i);f&&(f.result=a,f.isError=m,p.delete(i));continue}}}}}return j(l,y,v),{sessionId:o.sessionId,version:o.version,gitBranch:o.gitBranch,cwd:o.cwd,slug:o.slug,name:"",model:o.model,turns:l,stats:e!=null&&e.skipStats?J(l.length):K(l),rawMessages:e!=null&&e.skipStats?[]:n,branchedFrom:o.branchedFrom,agentKind:"codex"}}function vt(t){const e=[];for(const n of t.split(`
|
|
20
|
-
`)){const o=n.trim();if(o)try{e.push(JSON.parse(o))}catch{}}return e}function fe(t){var n;const e=(n=t[0])==null?void 0:n.type;return e==="session_meta"||e==="turn_context"||e==="event_msg"||e==="response_item"||e==="compacted"||e==="world_state"||e==="inter_agent_communication_metadata"}function me(t){return t.map(e=>JSON.stringify(e)).join(`
|
|
21
|
-
`)}function ge(t){const e={sessionId:"",version:"",gitBranch:"",cwd:"",slug:"",name:"",model:"",branchedFrom:void 0};for(const n of t)if(n.sessionId&&!e.sessionId&&(e.sessionId=n.sessionId),n.version&&!e.version&&(e.version=n.version),n.gitBranch&&!e.gitBranch&&(e.gitBranch=n.gitBranch),n.cwd&&!e.cwd&&(e.cwd=n.cwd),n.slug&&!e.slug&&(e.slug=n.slug),n.name&&!e.name&&(e.name=n.name),n.branchedFrom&&!e.branchedFrom&&(e.branchedFrom=n.branchedFrom),W(n)&&n.message.model&&!e.model&&(e.model=n.message.model),e.sessionId&&e.version&&e.gitBranch&&e.cwd&&e.model)break;return e}function he(t,e){if(xt(t))return At(t,e);const n=vt(t),o=ge(n),l=it(n),p=e!=null&&e.skipStats?J(l.length):K(l);return{...o,turns:l,stats:p,rawMessages:e!=null&&e.skipStats?[]:n,agentKind:"claude"}}function _e(t,e){if(fe(t.rawMessages)||xt(e)){const y=me(t.rawMessages);return At(y?`${y}
|
|
22
|
-
${e}`:e)}const n=vt(e);if(n.length===0)return t;const o=t.rawMessages,l=[...o,...n],p=Wt(o),h=Math.max(0,t.turns.length-p.length);let k=Math.max(0,p.length-1);const b=new Set;for(const y of n)if(y.type==="progress"){const S=y.parentToolUseID;S&&b.add(S)}if(b.size>0)for(let y=k-1;y>=0;y--){const S=t.turns[h+y];if(S!=null&&S.toolCalls.some(C=>b.has(C.id))){k=y;break}}const T=p[k]??o.length,A=t.turns.slice(0,h+k),w=it(l.slice(T)),x=ot([...A,...w]),P=K(x);return{sessionId:t.sessionId,version:t.version,gitBranch:t.gitBranch,cwd:t.cwd,slug:t.slug,name:t.name,model:t.model||x.length>0&&x[x.length-1].model||"",turns:x,stats:P,rawMessages:l,branchedFrom:t.branchedFrom,agentKind:t.agentKind}}self.onmessage=t=>{const e=t.data;try{let n;e.type==="parse"?n=he(e.text):n=_e(e.existing,e.newText),self.postMessage({type:"result",id:e.id,session:n})}catch(n){self.postMessage({type:"error",id:e.id,error:n instanceof Error?n.message:String(n)})}}})();
|