typebulb 0.62.3 → 0.62.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2192,7 +2192,7 @@ ${nSt(b)}`};let v=ZCt(h.code,{jsxImportSource:p.ts?.jsxImportSource});if(v.error
2192
2192
  `).map(v=>v.replace(/\r$/,""));if(a.length&&a[a.length-1]===""&&a.pop(),s)return a.map(v=>({kind:"add",text:v}));let h=[],p=!1,b=!1;for(let v of a){if(v.startsWith("@@")){b&&h.push({kind:"gap",text:"\u22EF"}),b=!0,p=!0;continue}if(!p){v.startsWith("Binary file")&&h.push({kind:"ctx",text:v});continue}v.startsWith("\\")||(v.startsWith("+")?h.push({kind:"add",text:v.slice(1)}):v.startsWith("-")?h.push({kind:"del",text:v.slice(1)}):h.push({kind:"ctx",text:v.slice(1)}))}return h}function H5n(o,s,a){let h=$5n(o,s),p=o.length>F5n?"txt":a.split(".").pop()??"",b=[],v=[];for(let P of h)(P.kind==="ctx"||P.kind==="del")&&b.push(P.text),(P.kind==="ctx"||P.kind==="add")&&v.push(P.text);let w=dEe(b.join(`
2193
2193
  `),p),S=dEe(v.join(`
2194
2194
  `),p),T=0,B=0,D=[];for(let P of h){if(P.kind==="gap"){D.push('<div class="udiff-gap">\u22EF</div>');continue}let j=P.kind==="del"?w[T++]:(P.kind==="add"||T++,S[B++]);D.push(`<div class="udiff-line${P.kind==="add"?" udiff-add":P.kind==="del"?" udiff-del":""}">${j??""}</div>`)}return{kinds:h.map(P=>P.kind),bodyHtml:D.join("")}}var uie=class extends x4{files=[];repo=!0;root="";viewing;#e=0;#t=!1;#n=()=>document.getElementById(bEe);#r=new fte(this.#n);#s=[];#i=-1;keepOpenSelector=".gitdiff-wrap";filterId="gitdiff-filter";listSelector=".gitdiff-list";onActivate(s){let a=this.rows()[s];a&&this.openDiff(a)}onAttached(){this.refreshFiles(),setInterval(()=>this.refreshFiles(),3e3),setInterval(()=>{this.viewing&&this.refreshDiff()},1500)}rows(){let s=this.filter.trim().toLowerCase();return s?this.files.filter(a=>a.path.toLowerCase().includes(s)):this.files}async refreshFiles(){try{let{repo:s,root:a,files:h}=await tb.server.gitChangedFiles(),p=s!==this.repo||h.length!==this.files.length||h.some((b,v)=>{let w=this.files[v];return b.path!==w?.path||b.status!==w.status||b.add!==w.add||b.del!==w.del||b.binary!==w.binary});this.repo=s,this.root=a,this.files=h,p&&(this.update(),this.keepBottom())}catch(s){console.error("[mirror] gitChangedFiles failed",s)}}#o(s,a,h){this.viewing?.path!==s&&(this.#s=[]),this.viewing={path:s,status:a,text:h.text,truncated:!!h.truncated,...H5n(h.text,!!h.untracked,s)},this.#e++,this.update()}async openDiff(s){try{let a=await tb.server.gitDiff(s.path);if(!a.ok){console.error("[mirror] gitDiff failed:",a.error);return}this.#o(s.path,s.status,a),this.#t=!0,this.close()}catch(a){console.error("[mirror] gitDiff failed",a)}}async refreshDiff(){let s=this.viewing;if(s)try{let a=await tb.server.gitDiff(s.path);if(this.viewing!==s||!a.ok||a.text===s.text)return;this.#o(s.path,s.status,a)}catch(a){console.error("[mirror] gitDiff refresh failed",a)}}closeDoc(){this.#r.release(),this.viewing=void 0,this.update()}show(){this.beginOpen(),this.refreshFiles(),this.refreshList(),this.armClose(),this.focusFilter()}view(){let s=this.files.length;return!this.repo||s===0&&!this.viewing&&!this.open?ct({class:"gitdiff-wrap"}):ct({class:"gitdiff-wrap pop-center"},this.viewing?this.viewingPill():Po({class:["pill","glyph","gitdiff-pill",this.open?"on":""],"data-tip":`${s} changed file${s===1?"":"s"} \u2014 view a diff`,ariaLabel:`${s} changed file${s===1?"":"s"}`,onClick:a=>{a.stopPropagation(),this.open?this.close():this.show()}},Z1("diff"),en({class:"gitdiff-count"},String(s))),this.open?this.popup():null)}viewingPill(){let s=this.viewing,a=s.kinds.filter(p=>p==="add").length,h=s.kinds.filter(p=>p==="del").length;return Po({class:["pill","glyph","gitdiff-pill","viewing","on"],"data-tip":`${this.files.length} changed file${this.files.length===1?"":"s"} \u2014 switch file`,onClick:p=>{p.stopPropagation(),this.open?this.close():this.show()}},en({class:["gitdiff-status",`s-${s.status}`]},s.status),en({class:"gitdiff-doc-path",title:`Open ${s.path}`,onClick:p=>{p.stopPropagation(),tb.server.openFile(`${this.root}/${s.path}`)}},s.path),en({class:"gitdiff-counts"},en({class:"count-add"},`+${a}`),en({class:"count-del"},`\u2212${h}`)),ote(()=>this.closeDoc()))}popup(){let s=this.rows();return ct({class:"servers-pop gitdiff-pop"},s.length===0?this.emptyState("No changes in the working tree."):ct({class:"gitdiff-list",onScroll:()=>this.onListScroll()},s.map((a,h)=>this.row(a,h))),this.filterBox(this.files.length,"file"))}row(s,a){return ct({class:["gitdiff-row",a===this.highlighted?"active":"",this.viewing?.path===s.path?"viewing":""],onMouseEnter:()=>{this.highlighted!==a&&(this.highlighted=a,this.update())},onClick:h=>{h.stopPropagation(),this.openDiff(s)}},en({class:["gitdiff-status",`s-${s.status}`]},s.status),en({class:"gitdiff-path",title:s.path},s.path),s.add!==void 0||s.del!==void 0?en({class:"gitdiff-counts"},en({class:"count-add"},`+${s.add??0}`),en({class:"count-del"},`\u2212${s.del??0}`)):s.status==="U"?en({class:"gitdiff-counts"},en({class:"count-add"},"new")):en({class:"gitdiff-counts"},en({},s.binary?"binary":"\u2014")))}docView(){let s=this.viewing;return ct({class:"diff-doc",onKeyDown:a=>{a.key==="Escape"&&(a.stopPropagation(),this.closeDoc())}},ct({class:"diff-doc-scroll"},ct({class:"diff-doc-body",id:bEe,tabIndex:0,onMounted:a=>a.focus(),onScroll:()=>this.#r.sync()},s.kinds.length===0?ct({class:"diff-doc-empty"},"No changes."):ct({class:"diff-doc-code",key:`diff-code-${this.#e}`,onMounted:a=>{a.innerHTML=s.bodyHtml,this.#c(a),this.#u(a)}},""),s.truncated?ct({class:"diff-doc-trunc"},"Diff truncated \u2014 file too large to show in full."):null),s.kinds.length?this.#r.view(this.#s,{class:"diff-ruler",title:"Jump to a change",label:"Diff scroll position",controls:bEe}):null))}#c(s){if(!this.#t)return;this.#t=!1;let a=s.querySelector(".udiff-add, .udiff-del"),h=this.#n();a&&h&&(h.scrollTop=a.offsetTop-h.clientHeight/3)}#u(s){this.#i!==this.#e&&(this.#i=this.#e,requestAnimationFrame(()=>{this.#h(s),this.update(),this.#r.sync()}))}#h(s){let a=this.viewing,h=this.#n();if(!a||!h?.scrollHeight)return;let p=h.scrollHeight,b=[];for(let v=0;v<a.kinds.length;v++){let w=a.kinds[v];if(w!=="add"&&w!=="del")continue;let S=v;for(;S+1<a.kinds.length&&a.kinds[S+1]===w;)S++;let T=s.children[v],B=s.children[S];T&&B&&b.push({top:T.offsetTop/p,height:(B.offsetTop+B.offsetHeight-T.offsetTop)/p,class:w}),v=S}this.#s=b}};async function mEe(o){try{return await navigator.clipboard.writeText(o),!0}catch{}let s=document.createElement("textarea");s.value=o,s.style.cssText="position:fixed;top:0;left:0;opacity:0",document.body.appendChild(s),s.select();try{return document.execCommand("copy")}catch{return!1}finally{s.remove()}}var lD=class extends Jc{done=!1;#e;constructor(s){super(),this.#e=s}setText(s){this.#e=s}flash(){mEe(this.#e),this.done=!0,this.update(),setTimeout(()=>{this.done=!1,this.update()},600)}view(){return Po({class:["overlay-pill","copy",this.done?"done":""],onClick:s=>{s.stopPropagation(),this.flash()}},this.done?"copied":"copy")}};var gTt=".typebulb/paste",bTt={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",bmp:"image/bmp"},JC=o=>o.label||o.kind||"agent",wEe=o=>o.failing&&o.state!=="stopped"?"failing":o.state,AEe=o=>`Open this ${o.kind?`${o.kind} `:""}agent's transcript`;var mTt=8,wTt=30,q5n=3*6e4;var aie=o=>new Date(o).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});var vEe=o=>[o.runs?`${o.runs} run, ${o.failed} failed`:"",yEe(o)].filter(Boolean).join(", ")||"none",yEe=o=>o.lookups?`${o.lookups} ${o.lookups===1?"lookup":"lookups"}`:"";var vTt=o=>o.open.filter(s=>!s.interrupted);var yTt=(o,s)=>o.state==="running"?Math.max(0,s-o.asOf):0,kTt=(o,s)=>o.activeMs+yTt(o,s);function Q5n(o,s){let a=o.state==="finished"?vTt(o).filter(h=>h.background):[];return a.length?`finished, background call running ${Sl(s-(a[0].at??s))}${a.length>1?` (+${a.length-1} more)`:""}`:o.state}var kEe=(o,s)=>({state:Q5n(o,s),active:`${Sl(kTt(o,s))} active`,idle:o.idleMs?`${Sl(o.idleMs)} idle`:""}),G5n=(o,s)=>{let a=kEe(o,s);return[a.state,a.active,a.idle].filter(Boolean).join(" \xB7 ")},ATt=(o,s)=>o.interrupted?`${o.label}: interrupted, its process has ended`:`${o.label}, ${Sl(s-(o.at??s))}${o.background?" (background)":""}`,J5n=(o,s)=>`nothing open, last entry ${Sl(s-o.asOf)} ago`;function U5n(o,s){if(!o.open.length)return[`Now: ${J5n(o,s)}`,...o.latest?[`Latest: ${o.latest.label} \xB7 ${die(o.latest.run)}${o.latest.run.ms!==void 0?` after ${Sl(o.latest.run.ms)}`:""}`]:[]];let a=(h,p)=>h.said?[`${p}"${h.said}"`]:[];return o.open.length===1?[`Now: ${ATt(o.open[0],s)}`,...a(o.open[0]," ")]:["Now:",...o.open.flatMap(h=>[` ${ATt(h,s)}`,...a(h," ")])]}function z5n(o,s){let a=o.latest;return`latest: ${a.interrupted?"interrupted":a.open?`running ${Sl(s-(a.at??s))}`:`${die(a)}${a.ms!==void 0?` after ${Sl(a.ms)}`:""}`}${o.streak>=2?`, failed ${o.streak} in a row`:""}`}function xTt(o,s){let a=[`Sub-agent "${o.name}" (${o.id}): ${G5n(o,s)}${o.asOf?` \xB7 as of ${aie(o.asOf)}`:""}`,""];a.push(...U5n(o,s));let h=o.commands;a.push(`Commands: ${vEe(h)}`);let{shown:p,more:b}=CEe(h);for(let S of p){let T=hie(S);a.push(` ${S.cmd} \xD7${S.runs}${S.failed?`, ${S.failed} failed`:""}${T?` \xB7 ${T}`:""}`,` ${z5n(S,s)}`);let B=[S.latest.first,S.latest.last].filter(Boolean).map(D=>`"${D}"`).join(" \u2026 ");B&&a.push(` ${B}`)}b&&a.push(` ${SEe(b)}`),lie(h).runs&&a.push(` ${fie(h)}`),o.activeMs&&a.push(`Time: ${K5n(o,s)}`),o.narration.length&&a.push("Narration:",...o.narration.map(S=>` ${S}`)),a.push(`Files written: ${xEe(o)}`);for(let S of o.files){let T=S.also.length?` also ${W5n(S)}`:"";a.push(` ${pie(S)}${S.ignored?" (ignored)":S.committed?" (committed)":""}${T}`,...S.blind.map(B=>` ${B}`))}let{shown:v,earlier:w}=IEe(o);return a.push(`Files read: ${o.read.length||"none"}`,...w?[` +${w} earlier`]:[],...v.map(S=>` ${Y5n(S)}`)),a.join(`
2195
- `)}var xEe=o=>{let s=o.files.filter(a=>!a.committed&&!a.ignored).length;return o.files.length?`${o.files.length} (${s} uncommitted)`:"none"};function EEe(o,s){let a=o.toolMs+(vTt(o).some(h=>!h.background)?yTt(o,s):0);return{tools:a,model:Math.max(0,kTt(o,s)-a)}}var K5n=(o,s)=>{let a=EEe(o,s);return`${Sl(a.tools)} in tools, ${Sl(a.model)} in the model`},W5n=o=>o.also.map(s=>`"${s.name}" ${aie(s.at)}`).join(", "),ETt=o=>o.failed>0||o.long||o.runs>=3||o.tags.length>0,CEe=o=>{let s=o.groups.filter(ETt);return{shown:s.slice(0,mTt),more:Math.max(0,s.length-mTt)}},SEe=o=>`+${o} more like these`,lie=o=>{let s=o.groups.filter(a=>!ETt(a));return{runs:s.reduce((a,h)=>a+h.runs-h.open,0),ms:s.reduce((a,h)=>a+h.ms,0)}},fie=(o,s=!0)=>{let a=lie(o);return`${a.runs}${s?" other":""} ${a.runs===1?"run":"runs"} passed, ${Sl(a.ms)} in all`},hie=o=>[...o.tags,o.long?`over ${Sl(q5n)}`:""].filter(Boolean).join(", ");var die=o=>o.outcome&&o.outcome!=="completed"&&o.outcome!=="failed"&&o.exit===void 0?o.outcome:o.exit!==void 0?`exit ${o.exit}`:o.failed?"error":"ok",pie=o=>o.deleted?`${o.path} (deleted)`:o.from?`${o.path} (moved from ${o.from})`:o.path,Y5n=o=>o.times>1?`${o.path} \xD7${o.times}`:o.path,IEe=o=>({shown:o.read.slice(-wTt),earlier:Math.max(0,o.read.length-wTt)});var xdr=5*6e4,Edr=10*6e4,Cdr=2*6e4;var X5n=2e3,TEe=(o="cs-list",s="none")=>ct({class:o},ct({class:"cs-item cs-dim"},s)),CTt=o=>s=>{s.preventDefault(),tb.server.openFile(o)},_Ee=o=>`\u200E${o}\u200E`,gie=class extends Jc{open=!1;#e=null;#t="";#n="";#r=!1;#s=0;#i;bind(s){this.#i=s}toggle(){this.open=!this.open,this.sync(),this.#i?.onChange()}show(s){this.open=s,this.#e=null,this.#t="",this.#s=0,this.sync()}async sync(){let s=this.#i?.id();if(!(!this.open||!s||this.#r||Date.now()-this.#s<X5n)){this.#r=!0;try{let a=await tb.server.childStatus(s);s===this.#i?.id()&&(a?.ok?(this.#e=a.report,this.#t=""):this.#t=a?.error??"could not read its status")}catch{this.#t="could not read its status"}this.#r=!1,this.#s=Date.now(),this.#i?.onChange()}}view(){let s=this.#e;if(!s)return ct({class:"messages child-status",key:"child-status"},ct({class:"child-status-pending"},this.#t||"Loading\u2026"));let a=Date.now();return ct({class:"messages child-status",key:"child-status"},this.#h(s,a),this.#l(s,a),this.#a(s,a),this.#m(s),this.#b(s),this.#p(s),ct({class:"child-status-foot"},this.#t?ct({class:"child-status-note err"},this.#t):null,ct({class:"child-status-actions"},fg({onClick:h=>{h.preventDefault(),this.#o(s)}},this.#n||"Copy Status"),fg({onClick:h=>{h.preventDefault(),this.toggle()}},"Raw Transcript"))))}async#o(s){this.#n=await mEe(xTt(s,Date.now()))?"Copied":"Copy failed",setTimeout(()=>{this.#n="",this.#i?.onChange()},1500),this.#i?.onChange()}#c(s){this.open=!1,this.#i?.reveal(s)}#u(s,a){return fg({class:"cs-mono cs-link",title:"Show in the transcript",onClick:h=>{h.preventDefault(),this.#c(s)}},a)}#h(s,a){let h=EEe(s,a),p=kEe(s,a);return ct({class:"cs-header"},ct({class:"cs-title"},s.name),ct({class:["cs-subtitle",s.state==="failing"?"cs-bad":""]},ct({class:"cs-tile"},en({class:["children-dot",s.state==="finished"?"done":s.state]}),p.state),ct({class:"cs-tile"},p.active,s.activeMs?[en({class:"cs-tile-rule"}),en({class:"cs-time"},en(`${Sl(h.tools)} tools`),en(`${Sl(h.model)} model`))]:null),p.idle?ct({class:"cs-tile",title:"Time it sat finished, waiting for a message to wake it. Not counted in active time."},p.idle):null,s.asOf?ct({class:"cs-tile"},`last entry ${Sl(a-s.asOf)} ago`):null))}#l(s,a){let h=s.latest,p=[...s.open.map(b=>ct({class:"cs-item"},ct({class:"cs-item-main"},this.#u(b.id,b.label),ct({class:"cs-item-meta"},b.interrupted?en({class:"cs-pill bad"},"interrupted"):en({class:"cs-pill run"},`running ${Sl(a-(b.at??a))}`),b.background&&!b.interrupted?en({class:"cs-pill"},"background"):null)),b.said?ct({class:"cs-item-sub cs-mono"},b.said):null)),h?ct({class:"cs-item"},ct({class:"cs-item-main"},this.#u(h.id,h.label),ct({class:"cs-item-meta"},this.#f(h.run),h.run.ms!==void 0?en({class:"cs-dim"},Sl(h.run.ms)):null))):null].filter(Boolean);return p.length?ct({class:"cs-section"},ct({class:"cs-h"},"Now"),ct({class:"cs-list"},p)):null}#f(s){let a=die(s);return en({class:["cs-pill",s.failed?"bad":a==="ok"||a.startsWith("exit")?"ok":""]},a)}#a(s,a){let h=s.commands,{shown:p,more:b}=CEe(h),v=lie(h);return p.length?ct({class:"cs-section"},ct({class:"cs-h"},"Commands",en({class:"cs-count"},vEe(h))),ct({class:"cs-list"},p.map(w=>{let S=[w.latest.first,w.latest.last].filter(Boolean);return ct({class:"cs-item"},ct({class:"cs-item-main"},this.#u(w.latest.id,w.cmd),this.#d(w,a)),S.length?ct({class:"cs-item-sub cs-mono"},S.map((T,B)=>[B?en({class:"cs-dim"}," \u2026 "):null,T])):null)})),b?ct({class:"cs-more"},SEe(b)):null,v.runs?ct({class:"cs-more"},fie(h)):null):ct({class:"cs-section"},ct({class:"cs-h"},"Commands"),TEe("cs-list",[v.runs?fie(h,!1):"",yEe(h)].filter(Boolean).join(", ")||"none"))}#d(s,a){let h=s.latest,p=h.interrupted?en({class:"cs-pill bad"},"interrupted"):h.open?en({class:"cs-pill run"},`running ${Sl(a-(h.at??a))}`):this.#f(h);return ct({class:"cs-item-meta"},p,!h.open&&h.ms!==void 0?en({class:"cs-dim"},Sl(h.ms)):null,s.runs>1?en({class:"cs-dim"},`\xD7${s.runs}`):null,s.failed&&(s.runs>1||!h.failed)?en({class:"cs-bad"},`${s.failed} failed`):null,s.streak>=2?en({class:"cs-pill bad"},`failed ${s.streak} in a row`):null,hie(s)?en({class:"cs-pill warn"},hie(s)):null)}#b(s){return ct({class:"cs-section"},ct({class:"cs-h"},"Files written",s.files.length?en({class:"cs-count"},xEe(s)):null),s.files.length?ct({class:"cs-list cs-files"},s.files.map(a=>ct({class:"cs-item"},ct({class:"cs-item-main"},a.deleted?en({class:"cs-path",title:pie(a)},_Ee(pie(a))):fg({class:"cs-path cs-link",title:`Open ${a.path}`,onClick:CTt(a.path)},_Ee(a.path)),ct({class:"cs-item-meta"},a.from?en({class:"cs-dim"},`moved from ${a.from}`):null,en({class:["cs-pill",a.committed||a.ignored?"":"run"]},a.ignored?"ignored":a.committed?"committed":"uncommitted"))),a.also.length||a.blind.length?ct({class:"cs-item-sub"},a.also.length?ct({class:"cs-chips"},en({class:"cs-dim"},"also "),a.also.map(h=>en({class:"cs-chip"},h.name,en({class:"cs-dim"},` ${aie(h.at)}`)))):null,a.blind.map(h=>ct({class:"cs-blind"},h))):null))):TEe("cs-list cs-files"))}#m(s){return s.narration.length?ct({class:"cs-section"},ct({class:"cs-h"},"Narration"),ct({class:"cs-list cs-files"},s.narration.map(a=>ct({class:"cs-item"},a)))):null}#p(s){let{shown:a,earlier:h}=IEe(s);return ct({class:"cs-section"},ct({class:"cs-h"},"Files read",s.read.length?en({class:"cs-count"},`${s.read.length}`):null),s.read.length?ct({class:"cs-list cs-files"},h?ct({class:"cs-item cs-dim"},`+${h} earlier`):null,a.map(p=>ct({class:"cs-item"},ct({class:"cs-item-main"},fg({class:"cs-path cs-link",title:`Open ${p.path}`,onClick:CTt(p.path)},_Ee(p.path)),p.times>1?ct({class:"cs-item-meta"},en({class:"cs-dim"},`\xD7${p.times}`)):null)))):TEe("cs-list cs-files"))}};var bie=class extends x4{children=[];enabled=!1;viewing=null;status=new gie;#e=[];#t=null;#n=0;get swaps(){return this.#n}keepOpenSelector=".children-wrap";filterId="children-filter";listSelector=".children-list";onActivate(s){let a=this.rows()[s];a&&this.openChild(a.id)}onAttached(){setInterval(()=>{this.refresh()},3e3)}rows(){let s=this.filter.trim().toLowerCase();return s?this.children.filter(a=>[a.kind,a.label].filter(Boolean).join(" ").toLowerCase().includes(s)):this.children}get running(){return this.children.filter(s=>s.state==="running").length}async refresh(){if(this.enabled)try{let s=eyt((await tb.server.listChildren()).sort((h,p)=>h.mtime-p.mtime));if(this.open&&this.#e.length){let h=new Map(this.#e.map((p,b)=>[p,b]));s=s.map((p,b)=>[p,h.get(p.id)??this.#e.length+b]).sort((p,b)=>p[1]-b[1]).map(([p])=>p)}let a=s.length!==this.children.length||s.some((h,p)=>{let b=this.children[p];return h.id!==b?.id||h.state!==b.state||h.mtime!==b.mtime||h.tokens!==b.tokens})||s.some(h=>h.state==="running");this.children=s,this.#r(),a&&(this.update(),this.keepBottom())}catch(s){console.error("[mirror] listChildren failed",s)}}syncFromPoll(s,a){if(a!==this.#n)return!1;let h=this.viewing?.id??null;return this.#t=s,this.#r(),s&&!this.viewing&&this.refresh(),(this.viewing?.id??null)!==h}reset(){this.children=[],this.refresh()}#r(){this.viewing=this.#t?this.children.find(s=>s.id===this.#t)??null:null}async openChild(s,a=!1){this.close(),this.parent.messageList.stickToBottomNextRender(),this.#n++;try{await tb.server.openChild(s),this.#n++,this.#t=s,this.#r(),this.status.show(a),this.update()}catch(h){console.error("[mirror] openChild failed",h)}this.refresh()}async closeChild(){this.parent.messageList.stickToBottomNextRender(),this.status.open=!1,this.#n++;try{await tb.server.closeChild(),this.#n++,this.#t=null,this.#r(),this.update()}catch(s){console.error("[mirror] closeChild failed",s)}}show(){this.beginOpen(),this.#e=this.children.map(s=>s.id),this.refresh(),this.refreshList(),this.armClose(),this.focusFilter()}view(){let s=this.children.length;return!this.enabled||s===0&&!this.viewing&&!this.open?ct({class:"children-wrap"}):ct({class:"children-wrap pop-center"},this.viewing?this.viewingPill():this.chip(s),this.open?this.popup():null)}chip(s){let a=this.running;return Po({class:["pill","children-pill",NF(a>0),this.open?"on":""],"data-tip":a?`${a} of ${s} agent${s===1?"":"s"} still working \u2014 open one`:`${s} agent${s===1?"":"s"} this session spawned \u2014 open one`,ariaLabel:a?`Agents (${a} of ${s} running)`:`Agents (${s})`,onClick:h=>{h.stopPropagation(),this.open?this.close():this.show()}},en({class:"glyph-img"},"\u{1F916}"),String(a),en({class:"glyph-img"},"\u{1F916}"))}viewingPill(){let s=this.viewing,a=this.children.length;return Po({class:["pill","glyph","children-pill","viewing","on",NF(s.state==="running")],"data-tip":`${a} agent${a===1?"":"s"} \u2014 switch`,onClick:h=>{h.stopPropagation(),this.open?this.close():this.show()}},en({class:"glyph-img"},"\u{1F916}"),en({class:"children-doc-label",title:JC(s)},JC(s)),ote(()=>{this.closeChild()}))}popup(){let s=this.rows();return ct({class:["servers-pop","children-pop"]},s.length===0?this.emptyState("No agents in this session yet."):ct({class:"children-list",onScroll:()=>this.onListScroll()},s.map((a,h)=>this.row(a,h))),this.filterBox(this.children.length,"agent"))}row(s,a){return ct({class:["children-row",a===this.highlighted?"active":"",this.viewing?.id===s.id?"viewing":""],style:s.depth>1?{paddingLeft:`${(s.depth-1)*16+10}px`}:void 0,onMouseEnter:()=>{this.highlighted!==a&&(this.highlighted=a,this.update())},onClick:h=>{h.stopPropagation(),this.openChild(s.id)}},en({class:["children-dot",wEe(s)]}),en({class:["children-label",s.state==="running"?"shimmer-text shimmer-slow":""]},JC(s)),s.kind?en({class:"children-kind"},s.kind):null,s.model?en({class:"children-model"},s.effort?`${s.model} \xB7 ${s.effort}`:s.model):null,en({class:"children-time"},s.started?Sl((s.state==="running"?Date.now():s.mtime)-s.started):""),s.failing?en({class:"children-tokens failing",title:"Its latest reply is an API error, not the model's"},"error"):en({class:"children-tokens"},s.tokens?AC(s.tokens):""),en({class:"children-status-link","data-tip":"Where this agent stands: what it is waiting on, its commands, files and hand-backs",onClick:h=>{h.stopPropagation(),this.openChild(s.id,!0)}},"status"))}};var STt=new Map,ITt=(o,s)=>s+`
2195
+ `)}var xEe=o=>{let s=o.files.filter(a=>!a.committed&&!a.ignored).length;return o.files.length?`${o.files.length} (${s} uncommitted)`:"none"};function EEe(o,s){let a=o.toolMs+(vTt(o).some(h=>!h.background)?yTt(o,s):0);return{tools:a,model:Math.max(0,kTt(o,s)-a)}}var K5n=(o,s)=>{let a=EEe(o,s);return`${Sl(a.tools)} in tools, ${Sl(a.model)} in the model`},W5n=o=>o.also.map(s=>`"${s.name}" ${aie(s.at)}`).join(", "),ETt=o=>o.failed>0||o.long||o.runs>=3||o.tags.length>0,CEe=o=>{let s=o.groups.filter(ETt);return{shown:s.slice(0,mTt),more:Math.max(0,s.length-mTt)}},SEe=o=>`+${o} more like these`,lie=o=>{let s=o.groups.filter(a=>!ETt(a));return{runs:s.reduce((a,h)=>a+h.runs-h.open,0),hidden:s.reduce((a,h)=>a+h.hidden,0),ms:s.reduce((a,h)=>a+h.ms,0)}},fie=(o,s=!0)=>{let a=lie(o),h=a.runs-a.hidden,p=s?" other":"",b=S=>S===1?"run":"runs",v=`with ${a.hidden===1?"its":"their"} exit hidden by a pipe`;return`${h?`${h}${p} ${b(h)} passed${a.hidden?`, ${a.hidden} ${v}`:""}`:`${a.hidden}${p} ${b(a.hidden)} ${v}`}, ${Sl(a.ms)} in all`},hie=o=>[...o.tags,o.long?`over ${Sl(q5n)}`:""].filter(Boolean).join(", ");var die=o=>o.hidden?"exit hidden":o.outcome&&o.outcome!=="completed"&&o.outcome!=="failed"&&o.exit===void 0?o.outcome:o.exit!==void 0?`exit ${o.exit}`:o.failed?"error":"ok",pie=o=>o.deleted?`${o.path} (deleted)`:o.from?`${o.path} (moved from ${o.from})`:o.path,Y5n=o=>o.times>1?`${o.path} \xD7${o.times}`:o.path,IEe=o=>({shown:o.read.slice(-wTt),earlier:Math.max(0,o.read.length-wTt)});var Edr=5*6e4,Cdr=10*6e4,Sdr=2*6e4;var X5n=2e3,TEe=(o="cs-list",s="none")=>ct({class:o},ct({class:"cs-item cs-dim"},s)),CTt=o=>s=>{s.preventDefault(),tb.server.openFile(o)},_Ee=o=>`\u200E${o}\u200E`,gie=class extends Jc{open=!1;#e=null;#t="";#n="";#r=!1;#s=0;#i;bind(s){this.#i=s}toggle(){this.open=!this.open,this.sync(),this.#i?.onChange()}show(s){this.open=s,this.#e=null,this.#t="",this.#s=0,this.sync()}async sync(){let s=this.#i?.id();if(!(!this.open||!s||this.#r||Date.now()-this.#s<X5n)){this.#r=!0;try{let a=await tb.server.childStatus(s);s===this.#i?.id()&&(a?.ok?(this.#e=a.report,this.#t=""):this.#t=a?.error??"could not read its status")}catch{this.#t="could not read its status"}this.#r=!1,this.#s=Date.now(),this.#i?.onChange()}}view(){let s=this.#e;if(!s)return ct({class:"messages child-status",key:"child-status"},ct({class:"child-status-pending"},this.#t||"Loading\u2026"));let a=Date.now();return ct({class:"messages child-status",key:"child-status"},this.#h(s,a),this.#l(s,a),this.#a(s,a),this.#m(s),this.#b(s),this.#p(s),ct({class:"child-status-foot"},this.#t?ct({class:"child-status-note err"},this.#t):null,ct({class:"child-status-actions"},fg({onClick:h=>{h.preventDefault(),this.#o(s)}},this.#n||"Copy Status"),fg({onClick:h=>{h.preventDefault(),this.toggle()}},"Raw Transcript"))))}async#o(s){this.#n=await mEe(xTt(s,Date.now()))?"Copied":"Copy failed",setTimeout(()=>{this.#n="",this.#i?.onChange()},1500),this.#i?.onChange()}#c(s){this.open=!1,this.#i?.reveal(s)}#u(s,a){return fg({class:"cs-mono cs-link",title:"Show in the transcript",onClick:h=>{h.preventDefault(),this.#c(s)}},a)}#h(s,a){let h=EEe(s,a),p=kEe(s,a);return ct({class:"cs-header"},ct({class:"cs-title"},s.name),ct({class:["cs-subtitle",s.state==="failing"?"cs-bad":""]},ct({class:"cs-tile"},en({class:["children-dot",s.state==="finished"?"done":s.state]}),p.state),ct({class:"cs-tile"},p.active,s.activeMs?[en({class:"cs-tile-rule"}),en({class:"cs-time"},en(`${Sl(h.tools)} tools`),en(`${Sl(h.model)} model`))]:null),p.idle?ct({class:"cs-tile",title:"Time it sat finished, waiting for a message to wake it. Not counted in active time."},p.idle):null,s.asOf?ct({class:"cs-tile"},`last entry ${Sl(a-s.asOf)} ago`):null))}#l(s,a){let h=s.latest,p=[...s.open.map(b=>ct({class:"cs-item"},ct({class:"cs-item-main"},this.#u(b.id,b.label),ct({class:"cs-item-meta"},b.interrupted?en({class:"cs-pill bad"},"interrupted"):en({class:"cs-pill run"},`running ${Sl(a-(b.at??a))}`),b.background&&!b.interrupted?en({class:"cs-pill"},"background"):null)),b.said?ct({class:"cs-item-sub cs-mono"},b.said):null)),h?ct({class:"cs-item"},ct({class:"cs-item-main"},this.#u(h.id,h.label),ct({class:"cs-item-meta"},this.#f(h.run),h.run.ms!==void 0?en({class:"cs-dim"},Sl(h.run.ms)):null))):null].filter(Boolean);return p.length?ct({class:"cs-section"},ct({class:"cs-h"},"Now"),ct({class:"cs-list"},p)):null}#f(s){let a=die(s);return en({class:["cs-pill",s.failed?"bad":!s.hidden&&(a==="ok"||a.startsWith("exit"))?"ok":""]},a)}#a(s,a){let h=s.commands,{shown:p,more:b}=CEe(h),v=lie(h);return p.length?ct({class:"cs-section"},ct({class:"cs-h"},"Commands",en({class:"cs-count"},vEe(h))),ct({class:"cs-list"},p.map(w=>{let S=[w.latest.first,w.latest.last].filter(Boolean);return ct({class:"cs-item"},ct({class:"cs-item-main"},this.#u(w.latest.id,w.cmd),this.#d(w,a)),S.length?ct({class:"cs-item-sub cs-mono"},S.map((T,B)=>[B?en({class:"cs-dim"}," \u2026 "):null,T])):null)})),b?ct({class:"cs-more"},SEe(b)):null,v.runs?ct({class:"cs-more"},fie(h)):null):ct({class:"cs-section"},ct({class:"cs-h"},"Commands"),TEe("cs-list",[v.runs?fie(h,!1):"",yEe(h)].filter(Boolean).join(", ")||"none"))}#d(s,a){let h=s.latest,p=h.interrupted?en({class:"cs-pill bad"},"interrupted"):h.open?en({class:"cs-pill run"},`running ${Sl(a-(h.at??a))}`):this.#f(h);return ct({class:"cs-item-meta"},p,!h.open&&h.ms!==void 0?en({class:"cs-dim"},Sl(h.ms)):null,s.runs>1?en({class:"cs-dim"},`\xD7${s.runs}`):null,s.failed&&(s.runs>1||!h.failed)?en({class:"cs-bad"},`${s.failed} failed`):null,s.streak>=2?en({class:"cs-pill bad"},`failed ${s.streak} in a row`):null,hie(s)?en({class:"cs-pill warn"},hie(s)):null)}#b(s){return ct({class:"cs-section"},ct({class:"cs-h"},"Files written",s.files.length?en({class:"cs-count"},xEe(s)):null),s.files.length?ct({class:"cs-list cs-files"},s.files.map(a=>ct({class:"cs-item"},ct({class:"cs-item-main"},a.deleted?en({class:"cs-path",title:pie(a)},_Ee(pie(a))):fg({class:"cs-path cs-link",title:`Open ${a.path}`,onClick:CTt(a.path)},_Ee(a.path)),ct({class:"cs-item-meta"},a.from?en({class:"cs-dim"},`moved from ${a.from}`):null,en({class:["cs-pill",a.committed||a.ignored?"":"run"]},a.ignored?"ignored":a.committed?"committed":"uncommitted"))),a.also.length||a.blind.length?ct({class:"cs-item-sub"},a.also.length?ct({class:"cs-chips"},en({class:"cs-dim"},"also "),a.also.map(h=>en({class:"cs-chip"},h.name,en({class:"cs-dim"},` ${aie(h.at)}`)))):null,a.blind.map(h=>ct({class:"cs-blind"},h))):null))):TEe("cs-list cs-files"))}#m(s){return s.narration.length?ct({class:"cs-section"},ct({class:"cs-h"},"Narration"),ct({class:"cs-list cs-files"},s.narration.map(a=>ct({class:"cs-item"},a)))):null}#p(s){let{shown:a,earlier:h}=IEe(s);return ct({class:"cs-section"},ct({class:"cs-h"},"Files read",s.read.length?en({class:"cs-count"},`${s.read.length}`):null),s.read.length?ct({class:"cs-list cs-files"},h?ct({class:"cs-item cs-dim"},`+${h} earlier`):null,a.map(p=>ct({class:"cs-item"},ct({class:"cs-item-main"},fg({class:"cs-path cs-link",title:`Open ${p.path}`,onClick:CTt(p.path)},_Ee(p.path)),p.times>1?ct({class:"cs-item-meta"},en({class:"cs-dim"},`\xD7${p.times}`)):null)))):TEe("cs-list cs-files"))}};var bie=class extends x4{children=[];enabled=!1;viewing=null;status=new gie;#e=[];#t=null;#n=0;get swaps(){return this.#n}keepOpenSelector=".children-wrap";filterId="children-filter";listSelector=".children-list";onActivate(s){let a=this.rows()[s];a&&this.openChild(a.id)}onAttached(){setInterval(()=>{this.refresh()},3e3)}rows(){let s=this.filter.trim().toLowerCase();return s?this.children.filter(a=>[a.kind,a.label].filter(Boolean).join(" ").toLowerCase().includes(s)):this.children}get running(){return this.children.filter(s=>s.state==="running").length}async refresh(){if(this.enabled)try{let s=eyt((await tb.server.listChildren()).sort((h,p)=>h.mtime-p.mtime));if(this.open&&this.#e.length){let h=new Map(this.#e.map((p,b)=>[p,b]));s=s.map((p,b)=>[p,h.get(p.id)??this.#e.length+b]).sort((p,b)=>p[1]-b[1]).map(([p])=>p)}let a=s.length!==this.children.length||s.some((h,p)=>{let b=this.children[p];return h.id!==b?.id||h.state!==b.state||h.mtime!==b.mtime||h.tokens!==b.tokens})||s.some(h=>h.state==="running");this.children=s,this.#r(),a&&(this.update(),this.keepBottom())}catch(s){console.error("[mirror] listChildren failed",s)}}syncFromPoll(s,a){if(a!==this.#n)return!1;let h=this.viewing?.id??null;return this.#t=s,this.#r(),s&&!this.viewing&&this.refresh(),(this.viewing?.id??null)!==h}reset(){this.children=[],this.refresh()}#r(){this.viewing=this.#t?this.children.find(s=>s.id===this.#t)??null:null}async openChild(s,a=!1){this.close(),this.parent.messageList.stickToBottomNextRender(),this.#n++;try{await tb.server.openChild(s),this.#n++,this.#t=s,this.#r(),this.status.show(a),this.update()}catch(h){console.error("[mirror] openChild failed",h)}this.refresh()}async closeChild(){this.parent.messageList.stickToBottomNextRender(),this.status.open=!1,this.#n++;try{await tb.server.closeChild(),this.#n++,this.#t=null,this.#r(),this.update()}catch(s){console.error("[mirror] closeChild failed",s)}}show(){this.beginOpen(),this.#e=this.children.map(s=>s.id),this.refresh(),this.refreshList(),this.armClose(),this.focusFilter()}view(){let s=this.children.length;return!this.enabled||s===0&&!this.viewing&&!this.open?ct({class:"children-wrap"}):ct({class:"children-wrap pop-center"},this.viewing?this.viewingPill():this.chip(s),this.open?this.popup():null)}chip(s){let a=this.running;return Po({class:["pill","children-pill",NF(a>0),this.open?"on":""],"data-tip":a?`${a} of ${s} agent${s===1?"":"s"} still working \u2014 open one`:`${s} agent${s===1?"":"s"} this session spawned \u2014 open one`,ariaLabel:a?`Agents (${a} of ${s} running)`:`Agents (${s})`,onClick:h=>{h.stopPropagation(),this.open?this.close():this.show()}},en({class:"glyph-img"},"\u{1F916}"),String(a),en({class:"glyph-img"},"\u{1F916}"))}viewingPill(){let s=this.viewing,a=this.children.length;return Po({class:["pill","glyph","children-pill","viewing","on",NF(s.state==="running")],"data-tip":`${a} agent${a===1?"":"s"} \u2014 switch`,onClick:h=>{h.stopPropagation(),this.open?this.close():this.show()}},en({class:"glyph-img"},"\u{1F916}"),en({class:"children-doc-label",title:JC(s)},JC(s)),ote(()=>{this.closeChild()}))}popup(){let s=this.rows();return ct({class:["servers-pop","children-pop"]},s.length===0?this.emptyState("No agents in this session yet."):ct({class:"children-list",onScroll:()=>this.onListScroll()},s.map((a,h)=>this.row(a,h))),this.filterBox(this.children.length,"agent"))}row(s,a){return ct({class:["children-row",a===this.highlighted?"active":"",this.viewing?.id===s.id?"viewing":""],style:s.depth>1?{paddingLeft:`${(s.depth-1)*16+10}px`}:void 0,onMouseEnter:()=>{this.highlighted!==a&&(this.highlighted=a,this.update())},onClick:h=>{h.stopPropagation(),this.openChild(s.id)}},en({class:["children-dot",wEe(s)]}),en({class:["children-label",s.state==="running"?"shimmer-text shimmer-slow":""]},JC(s)),s.kind?en({class:"children-kind"},s.kind):null,s.model?en({class:"children-model"},s.effort?`${s.model} \xB7 ${s.effort}`:s.model):null,en({class:"children-time"},s.started?Sl((s.state==="running"?Date.now():s.mtime)-s.started):""),s.failing?en({class:"children-tokens failing",title:"Its latest reply is an API error, not the model's"},"error"):en({class:"children-tokens"},s.tokens?AC(s.tokens):""),en({class:"children-status-link","data-tip":"Where this agent stands: what it is waiting on, its commands, files and hand-backs",onClick:h=>{h.stopPropagation(),this.openChild(s.id,!0)}},"status"))}};var STt=new Map,ITt=(o,s)=>s+`
2196
2196
 
2197
2197
  ---
2198
2198