typebulb 0.61.10 → 0.61.12
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/SKILL.md +2 -2
- package/dist/agents/claude/client.js +1 -1
- package/dist/agents/claude/styles.css +3 -1
- package/dist/agents/codex/client.js +1 -1
- package/dist/agents/codex/styles.css +3 -1
- package/dist/agents/pi/client.js +1 -1
- package/dist/agents/pi/styles.css +3 -1
- package/dist/index.js +232 -232
- package/package.json +1 -1
package/SKILL.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: typebulb
|
|
3
3
|
description: "Author and run Typebulb bulbs — single-file markdown apps (TypeScript/TSX) that run locally via `npx typebulb` (full power: filesystem, database, `server.ts`, `tb.ai`) or render live inline in your coding agent's session through Typebulb's agent mirror (sandboxed, client-only). A bulb can be a visual widget (chart, simulation, diagram, calculator, UI), a full-stack tool with a Node backend, or an AI app that calls models at runtime. Covers the bulb format, the `tb.*` API, trust, and the local run/inline workflow. Use when the user wants a bulb, a quick local tool (visual, backend-backed, or AI-powered), or something visual rendered inline in the conversation."
|
|
4
|
-
version: 0.61.
|
|
4
|
+
version: 0.61.12
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
> Generated from typebulb v0.61.
|
|
7
|
+
> Generated from typebulb v0.61.12. `npx typebulb agent` prints the running version alongside the path to its packaged SKILL.md: if that version is newer than this one, replace this file with that one.
|
|
8
8
|
|
|
9
9
|
# typebulb
|
|
10
10
|
|
|
@@ -2202,7 +2202,7 @@ ${iSt(b)}`};let v=tSt(h.code,{jsxImportSource:p.ts?.jsxImportSource});if(v.error
|
|
|
2202
2202
|
`+T,M=a?.rows.find(j=>j.id===b);M?.status==="done"&&!h.has(B)&&h.set(B,M),M=h.get(B)??M;let N=M?.steps??[];p.push({kind:"row",num:b,title:T,status:M?.status??"",did:M?.did??"",note:M?.note??"",steps:N,cite:M?.evidence?.length?M.evidence:N,ms:0,spans:[]})}});for(let v of a?.offBrief??[])p.push({kind:"row",title:v.what,status:"off",did:"",note:v.note,steps:v.steps,cite:v.steps,ms:0,spans:[]});return s6n(p,o),p}function s6n(o,s){let a=o.filter(v=>v.kind==="row"),h=s.steps.map(v=>a.find(w=>X5n(v.n,w.steps))),p=h.find(Boolean);if(!p)return;let b=p;for(let v=0;v<h.length;v++)h[v]=b=h[v]??b;s.steps.forEach((v,w)=>{let S=h[w];S.ms+=v.wall;for(let T of v.parts){let B=S.spans.at(-1);B&&Math.abs(B.to-T.from)<1e3?B.to=Math.max(B.to,T.to):S.spans.push({...T})}})}function kTt(o,s,a,h){let p=o.tests,b=s&&s.followups===o.followups.length,v=o.followups.length?a.get(o.followups.at(-1))?.request:void 0;return[["Now",b?s.data.now:v?`Working on the latest follow-up: ${v}`:h?"\u2026":""],["Tests",p?`${p.state}${p.line?`, ${p.line}`:""}${p.ms!==void 0?`, took ${Ff(p.ms)}`:""} (step ${p.n})`:"",p?`tests-${p.state}`:void 0],["Time",o.span&&o.steps.length?`${Ff(o.toolMs)} in tools, ${Ff(Math.max(0,o.span-o.toolMs))} in the model${o.idle?`, ${Ff(o.idle)} stopped`:""}`:""],["Needs a decision",b?s.data.decision:"","warn"]].filter(([,S])=>S)}var o6n=["content","diff","new_string","new_source","edits"];function xTt(o,s){let a=new Map,h=v=>{let w=v.trim().replace(/^["']|["']$/g,"").replace(/\\/g,"/").replace(/^\/([a-zA-Z])\//,"$1:/"),S=hte(w,s).replace(/^\.\//,"");return!S||/^([a-zA-Z]:)?\//.test(S)?void 0:S},p=(v,w={})=>{let S=h(v);if(!S)return;let T=a.get(S)??{path:S};T.deleted=w.deleted,w.from&&(T.from=w.from),a.set(S,T)},b=(v,w)=>{let S=h(v),T=S?a.get(S):void 0;S&&a.delete(S),p(w,{from:T?.from??S})};for(let{tool:v}of o.steps){if(v.isError)continue;let w=v.input??{},S=!1;for(let[M,N]of Object.entries(w)){if(M==="command"||M==="cmd"||typeof N!="string"||!/^(---|\+\+\+) /m.test(N))continue;let j;for(let U of N.split(`
|
|
2203
2203
|
`)){let z=/^(---|\+\+\+) (?:[ab]\/)?(.+?)\s*$/.exec(U);if(z?.[1]==="---"){j=z[2];continue}if(z?.[1]==="+++"){S=!0,z[2]==="/dev/null"?j&&j!=="/dev/null"&&p(j,{deleted:!0}):p(z[2]);continue}let ee=/^\*\*\* Move to: (.+?)\s*$/.exec(U);ee&&j&&b(j,ee[1])}}let T=Sl(w.file_path)??Sl(w.filePath)??Sl(w.path);!S&&T&&o6n.some(M=>M in w)&&p(T);let B=vEe(v);if(B)for(let M of c6n(B))M.to?b(M.from,M.to):p(M.from,{deleted:!0})}return[...a.values()]}function c6n(o){let s=[];for(let a of o.split(/&&|\|\||[;|\n]/)){let h=a.trim().match(/"[^"]*"|'[^']*'|\S+/g)??[],p=h.indexOf("git"),b=h[p+1];if(p<0||b!=="rm"&&b!=="mv"||h.includes("--cached"))continue;let v=h.slice(p+2).filter(S=>!S.startsWith("-")).map(S=>S.replace(/^["']|["']$/g,""));if(b==="rm"){for(let S of v)s.push({from:S});continue}let w=v.pop();if(w)for(let S of v)s.push({from:S,to:v.length>1?`${w.replace(/\/+$/,"")}/${kC(S)}`:w})}return s}function ETt(o){let{d:s}=o,a=o.working?`running, step ${s.steps.length}${u6n(s,o.now)}`:`finished after ${s.steps.length} steps`,h=[`Sub-agent "${o.name}": ${a}, ${Ff(s.span)} active${s.lastAt?`, as of ${V5n(s.lastAt)}`:""}.`];h.push("",`Request: ${s.brief?o.plans.get(s.brief)?.request??"(not summarized yet)":kEe}`);for(let p of o.lines){if(p.kind==="group"){h.push("",`Follow-up: ${p.request||"(not summarized yet)"}`);continue}let b=p.ms?` (${Ff(p.ms)})`:"";h.push(`- ${p.title}: ${yEe(p.status||"pending")}.${p.did?` ${p.did}`:""}${b}`),p.note&&h.push(` Note: ${p.note}`)}o.edited.length&&h.push("","Edited:",...o.edited.map(mie)),o.facts.length&&h.push("");for(let[p,b]of o.facts)h.push(`${p}: ${b}`);return h.join(`
|
|
2204
2204
|
`)}var mie=o=>o.deleted?`${o.path} (deleted)`:o.from?`${o.path} (moved from ${o.from})`:o.path;function u6n(o,s){let a=[...o.steps].reverse().find(h=>h.tool.result===void 0&&h.tool.at);return a?`, waiting ${Ff(s-a.tool.at)} on ${bie(a.tool,60)}`:o.lastAt?`, last activity ${Ff(s-o.lastAt)} ago`:""}function CTt(o){let s=o??{},a=h=>Array.isArray(h)?h.filter(Array.isArray).map(p=>[Number(p[0]),p[1]===void 0?void 0:Number(p[1])]).filter(p=>p[0]>0):[];return{now:String(s.now??""),decision:String(s.decision??""),rows:(Array.isArray(s.rows)?s.rows:[]).map(h=>({id:Number(h.id),status:String(h.status??""),did:String(h.did??""),note:String(h.note??""),steps:a(h.steps),evidence:a(h.evidence)})),offBrief:(Array.isArray(s.offBrief)?s.offBrief:[]).map(h=>({what:String(h.what??""),note:String(h.note??""),steps:a(h.steps)}))}}function STt(o){let s=o;return{request:String(s?.request??""),subtasks:Array.isArray(s?.subtasks)?s.subtasks.map(a=>String(a).replace(/[.\s]+$/,"")):[]}}var a6n=12,c7=new Map,xEe=new Map,EEe=new Map,wie=class extends Wu{open=!1;#e=!1;#t=null;#r=[];#n=!1;#s=!1;#o=new Set;#i=new Map;#c="";#u=null;#f=!1;#h=!1;#d=!1;#a="";#p;#g=null;#l;bind(s){this.#l=s}toggle(){this.open=!this.open,this.sync(),this.#l?.onChange()}show(s,a){if(this.open=s,this.#t=null,this.#a="",this.#p=void 0,this.#n=!1,this.#u=a?.judged??null,this.#f=!!a,this.#d=!1,a){for(let[h,p]of Object.entries(a.plans))c7.set(h,p);for(let[h,p]of Object.entries(a.frozen))xEe.has(h)||xEe.set(h,p);a.judged&&EEe.set(a.judged.key,a.judged)}this.#g=this.#l?.msgs()??null}sync(){if(!this.open||!this.#l)return;let s=this.#l.msgs();if(s===this.#g)return;this.#g=null;let a=this.#l.working(),h=s.at(-1),p=`${s.length}:${h?.text.length??0}:${h?.tools.length??0}:${h?.tools.filter(S=>S.result!==void 0).length??0}:${a}`;if(p!==this.#a||!this.#t){let S=ATt(s);this.#t&&S.brief!==this.#t.brief&&(this.#u=null,this.#f=!1,this.#n=!1),this.#t=S,this.#r=xTt(S,this.#l.cwd()),this.#a=p,this.#s=a,this.#p=void 0,this.#l.onChange()}let b=this.#t;if(this.#c||!b.brief)return;let v=this.#p??=this.#b(b),w=v&&EEe.get(v.key);if(w&&w!==this.#u&&(this.#u=w,this.#l.onChange()),w&&!this.#f&&(this.#f=!0,this.#l.onChange()),!(this.#f&&!this.#d)){for(let S of[b.brief,...b.followups])c7.has(S)||this.#m({kind:"plan",text:S});!v||this.#h||(this.#d=!1,this.#u?.key!==v.key&&this.#m(v))}}#b(s){let a=vTt(s,c7,!this.#s);return a&&{kind:"status",...a}}async#m(s){let a=s.kind==="plan"?`plan
|
|
2205
|
-
`+s.text:s.key;if(this.#o.has(a)||this.#i.has(a))return;this.#o.add(a),s.kind==="status"&&(this.#h=!0);let h=this.#t?.brief;try{let p=await tb.server.childStatus(s.kind,s.kind==="plan"?s.text:s.payload);if(p?.ok&&s.kind==="plan")c7.set(s.text,STt(p.data));else if(p?.ok&&s.kind==="status"){let b={key:s.key,data:CTt(p.data),steps:s.steps,followups:s.followups,at:Date.now()};EEe.set(s.key,b),h===this.#t?.brief&&(this.#u=b,this.#f=!0)}else p?.setup?this.#c=p.error:this.#i.set(a,p?.error??"could not summarize")}catch{this.#i.set(a,"could not summarize")}s.kind==="status"&&(this.#h=!1),this.#o.delete(a),(this.#i.has(a)||this.#c)&&(this.#d=!1),this.#l?.onChange(),this.sync()}#v(){this.#i.clear(),this.#w()}#w(){this.#d=!0,this.sync(),this.#l?.onChange()}get#y(){return this.#d||this.#h||this.#o.size>0}#x(s){let a=this.#u,h=s.steps.length-(a?.steps??0),p=s.followups.length-(a?.followups??0);if(h<=0&&p<=0&&(!this.#p||a?.key===this.#p.key))return null;let b=[[h,"step"],[p,"message"]].filter(([v])=>v>0).map(([v,w])=>`${v} new ${w}${v===1?"":"s"}`);return b.length?`Refresh (${b.join(", ")})`:"Refresh"}#E(s){return yTt(s,c7,this.#u?.data,xEe)}#k(s){return kTt(s,this.#u,c7,this.#y)}view(){let s=this.#t;if(!s||(s.brief?!this.#f:!s.steps.length))return gt({class:"messages child-status",key:"child-status"},this.#c?gt({class:"note"},this.#c):this.#I()??gt({class:"child-status-pending"},"Loading\u2026"));let h=c7.get(s.brief),p=this.#E(s),b=this.#x(s);return gt({class:"messages child-status",key:"child-status"},this.#c?gt({class:"note"},this.#c):null,s.brief?this.#C(0,h?.request):gt({class:"child-status-pending"},kEe),s.brief?this.#D(p,s):null,this.#M(),this.#S(s),gt({class:"child-status-foot"},this.#I(),gt({class:"child-status-actions"},!s.brief||this.#c||this.#i.size?null:this.#y?ln({class:"shimmer-text shimmer-slow"},"Refreshing\u2026"):b?H0({onClick:v=>{v.preventDefault(),this.#w()}},b):ln({class:"current"},"Up to date"),H0({onClick:v=>{v.preventDefault(),this.#_()}},this.#e?"Copied":"Copy Status"),H0({onClick:v=>{v.preventDefault(),this.toggle()}},"Raw Transcript"))))}#_(){let s=this.#t;s&&(navigator.clipboard?.writeText(ETt({d:s,lines:this.#E(s),facts:this.#k(s),edited:this.#r,plans:c7,name:this.#l?.name()||"sub-agent",working:this.#s,now:Date.now()})),this.#e=!0,setTimeout(()=>{this.#e=!1,this.#l?.onChange()},900),this.#l?.onChange())}#C(s,a){return gt({class:["bubble","user",c6(s)],key:`cs-msg-${s}`},a?this.#T(`cs-msg-${s}`,a):this.#R())}#S(s){let a=this.#k(s);return a.length?gt({class:"child-status-head"},a.map(([h,p,b])=>gt({class:"child-status-fact"},ln({class:"child-status-label"},h),ln({class:["child-status-value",b??""]},p)))):null}#M(){let s=this.#r;if(!s.length)return null;let a=this.#n?s:s.slice(0,a6n);return gt({class:"child-status-edited"},ln({class:"child-status-label"},`Edited (${s.length})`),a.map(h=>gt({class:"cs-file"},h.deleted?mie(h):[H0({title:`Open ${h.path}`,onClick:p=>{p.preventDefault(),tb.server.openFile(h.path)}},h.path),mie(h).slice(h.path.length)])),s.length>a.length?H0({onClick:h=>{h.preventDefault(),this.#n=!0,this.#l?.onChange()}},`+${s.length-a.length} more`):null)}#D(s,a){return F6t({class:"cs-table"},H6t(ote(BF("Subtask"),BF("Status"),BF("Progress"),BF({class:"cs-time",title:a.idle?`${Ff(a.span)} of work; ${Ff(a.idle)} spent idle, waiting to be woken, is left out. Ticks mark each wake.`:void 0},a.span?`Timeline \xB7 ${Ff(a.span)}`:"Timeline"))),$6t(s.map(h=>h.kind==="group"?ote({class:"cs-group"},gM({colSpan:4},this.#C(h.idx,h.request||void 0))):this.#B(h,a))))}#B(s,a){let{status:h,did:p,note:b,cite:v,ms:w,spans:S}=s;return ote({class:h==="off"?"cs-off":""},gM(s.num?`${s.num}. ${s.title}`:s.title),gM(h?ln({class:["cs-status",h]},yEe(h)):ln({class:"cs-status"},"\u2026")),gM(p?ln(p," "):null,v.length?ln({class:"cs-cite"},v.map(([T,B],M)=>[M?", ":"",this.#N(T,B,a)])):null,b?gt({class:"cs-note"},b):null),gM({class:"cs-time"},w?this.#L(S,w,h,a.span,a.wakes):""))}#L(s,a,h,p,b){let v=w=>p?`${Math.min(100,Math.max(0,100*w/p))}%`:"0%";return gt({class:"cs-gantt-cell",title:`${Ff(a)} spent, starting ${Ff(s[0]?.from??0)} in`},gt({class:"cs-gantt"},s.map(w=>ln({class:["cs-seg",h],style:{left:v(w.from),width:v(w.to-w.from)}})),b.map(w=>ln({class:"cs-wake",style:{left:v(w)}}))),ln({class:"cs-mins"},Ff(a)))}#N(s,a,h){let p=h.steps[s-1],b=a&&a!==s?`${s}\u2013${a}`:String(s);return p?H0({title:"Show in the transcript",onClick:v=>{v.preventDefault(),this.open=!1,this.#l?.reveal(p.tool.id)}},b):b}#I(){let s=[...this.#i.values()][0];return s?gt({class:"child-status-note err"},`${s} \xB7 `,H0({onClick:a=>{a.preventDefault(),this.#v()}},"retry")):null}#R(){return gt({class:"child-status-pending"},this.#y?ln({class:"child-status-note shimmer-text shimmer-slow"},"summarizing\u2026"):ln({class:"child-status-note"},"not summarized yet"))}#T(s,a){return gt({class:"md",key:`${s}-${a.length}`,onMounted:o7(a)})}};var ITt=".typebulb/paste",TTt={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",bmp:"image/bmp"},u7=o=>o.label||o.kind||"agent",CEe=o=>`Open this ${o.kind?`${o.kind} `:""}agent's transcript`;function l6n(o){let s=new Set(o.map(v=>v.id)),a=new Map;for(let v of o){let w=v.parentId&&s.has(v.parentId)?v.parentId:"",S=a.get(w);S?S.push(v):a.set(w,[v])}let h=[],p=new Set,b=v=>{for(let w of a.get(v)??[])p.has(w.id)||(p.add(w.id),h.push(w),b(w.id))};b("");for(let v of o)p.has(v.id)||h.push(v);return h}var Aie=class extends iw{children=[];enabled=!1;statusEnabled=!1;viewing=null;status=new wie;#e=new Map;#t=[];#r=null;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=l6n((await tb.server.listChildren()).sort((h,p)=>h.mtime-p.mtime));if(this.open&&this.#t.length){let h=new Map(this.#t.map((p,b)=>[p,b]));s=s.map((p,b)=>[p,h.get(p.id)??this.#t.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.#n(),a&&(this.update(),this.keepBottom())}catch(s){console.error("[mirror] listChildren failed",s)}}syncFromPoll(s){let a=this.viewing?.id??null;return this.#r=s,this.#n(),s&&!this.viewing&&this.refresh(),(this.viewing?.id??null)!==a}reset(){this.children=[],this.#e.clear(),this.refresh()}#n(){this.viewing=this.#r?this.children.find(s=>s.id===this.#r)??null:null}async openChild(s,a){this.close(),this.parent.messageList.stickToBottomNextRender();try{await tb.server.openChild(s),this.#r=s,this.#n(),this.status.show(!!a,a),this.update()}catch(h){console.error("[mirror] openChild failed",h)}this.refresh()}async#s(s){let a=this.#e.get(s.id);if(a?.state!=="busy"){if(a?.state==="ready")return this.#e.delete(s.id),this.openChild(s.id,a.seed);this.#e.set(s.id,{state:"busy"}),this.update();try{let h=await tb.server.judgeChildStatus(s.id);if(h?.ok&&!h.error&&h.cached)return this.#e.delete(s.id),this.openChild(s.id,{plans:h.plans,frozen:h.frozen,judged:h.judged});this.#e.set(s.id,h?.ok&&!h.error?{state:"ready",seed:{plans:h.plans,frozen:h.frozen,judged:h.judged}}:{state:"failed",error:h?.error??"could not judge"})}catch{this.#e.set(s.id,{state:"failed",error:"could not judge"})}this.update()}}get#o(){return[...this.#e.values()].some(s=>s.state==="ready")}async closeChild(){this.parent.messageList.stickToBottomNextRender(),this.status.open=!1;try{await tb.server.closeChild(),this.#r=null,this.#n(),this.update()}catch(s){console.error("[mirror] closeChild failed",s)}}show(){this.beginOpen(),this.#t=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?gt({class:"children-wrap"}):gt({class:"children-wrap pop-center"},this.viewing?this.viewingPill():this.chip(s),this.open?this.popup():null)}chip(s){let a=this.running;return Ao({class:["pill","children-pill",NF(a>0),this.open?"on":"",this.#o?"status-ready":""],"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()}},ln({class:"glyph-img"},"\u{1F916}"),String(a),ln({class:"glyph-img"},"\u{1F916}"))}viewingPill(){let s=this.viewing,a=this.children.length;return Ao({class:["pill","glyph","children-pill","viewing","on",NF(s.state==="running"),this.#o?"status-ready":""],"data-tip":`${a} agent${a===1?"":"s"} \u2014 switch`,onClick:h=>{h.stopPropagation(),this.open?this.close():this.show()}},ln({class:"glyph-img"},"\u{1F916}"),ln({class:"children-doc-label",title:u7(s)},u7(s)),fte(()=>{this.closeChild()}))}popup(){let s=this.rows();return gt({class:"servers-pop children-pop"},s.length===0?this.emptyState("No agents in this session yet."):gt({class:"children-list",onScroll:()=>this.onListScroll()},s.map((a,h)=>this.row(a,h))),this.filterBox(this.children.length,"agent"))}row(s,a){return gt({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)}},ln({class:["children-dot",s.failing&&s.state!=="stopped"?"failing":s.state]}),ln({class:["children-label",s.state==="running"?"shimmer-text shimmer-slow":""]},u7(s)),s.kind?ln({class:"children-kind"},s.kind):null,s.model?ln({class:"children-model"},s.model):null,ln({class:"children-time"},s.started?Ff((s.state==="running"?Date.now():s.mtime)-s.started):""),s.failing?ln({class:"children-tokens failing",title:"Its latest reply is an API error, not the model's"},"error"):ln({class:"children-tokens"},s.tokens?PF(s.tokens):""),this.statusEnabled?this.#i(s):null)}#i(s){let a=this.#e.get(s.id),h=a?a.state==="busy"?"Working out where it stands\u2026":a.state==="ready"?"Ready: open its status":`${a.error}. Click to retry`:"Where this agent stands on each task (a few cheap model calls)";return ln({class:["children-status-link",a?.state==="busy"?"shimmer-text shimmer-slow":a?.state??""],"data-tip":h,onClick:p=>{p.stopPropagation(),this.#s(s)}},"status")}};var lD=class extends Wu{done=!1;#e;constructor(s){super(),this.#e=s}setText(s){this.#e=s}flash(){navigator.clipboard?.writeText(this.#e),this.done=!0,this.update(),setTimeout(()=>{this.done=!1,this.update()},600)}view(){return Ao({class:["overlay-pill","copy",this.done?"done":""],onClick:s=>{s.stopPropagation(),this.flash()}},this.done?"copied":"copy")}};var _Tt=new Map,MTt=(o,s)=>s+`
|
|
2205
|
+
`+s.text:s.key;if(this.#o.has(a)||this.#i.has(a))return;this.#o.add(a),s.kind==="status"&&(this.#h=!0);let h=this.#t?.brief;try{let p=await tb.server.childStatus(s.kind,s.kind==="plan"?s.text:s.payload);if(p?.ok&&s.kind==="plan")c7.set(s.text,STt(p.data));else if(p?.ok&&s.kind==="status"){let b={key:s.key,data:CTt(p.data),steps:s.steps,followups:s.followups,at:Date.now()};EEe.set(s.key,b),h===this.#t?.brief&&(this.#u=b,this.#f=!0)}else p?.setup?this.#c=p.error:this.#i.set(a,p?.error??"could not summarize")}catch{this.#i.set(a,"could not summarize")}s.kind==="status"&&(this.#h=!1),this.#o.delete(a),(this.#i.has(a)||this.#c)&&(this.#d=!1),this.#l?.onChange(),this.sync()}#v(){this.#i.clear(),this.#w()}#w(){this.#d=!0,this.sync(),this.#l?.onChange()}get#y(){return this.#d||this.#h||this.#o.size>0}#x(s){let a=this.#u,h=s.steps.length-(a?.steps??0),p=s.followups.length-(a?.followups??0);if(h<=0&&p<=0&&(!this.#p||a?.key===this.#p.key))return null;let b=[[h,"step"],[p,"message"]].filter(([v])=>v>0).map(([v,w])=>`${v} new ${w}${v===1?"":"s"}`);return b.length?`Refresh (${b.join(", ")})`:"Refresh"}#E(s){return yTt(s,c7,this.#u?.data,xEe)}#k(s){return kTt(s,this.#u,c7,this.#y)}view(){let s=this.#t;if(!s||(s.brief?!this.#f:!s.steps.length))return gt({class:"messages child-status",key:"child-status"},this.#c?gt({class:"note"},this.#c):this.#I()??gt({class:"child-status-pending"},"Loading\u2026"));let h=c7.get(s.brief),p=this.#E(s),b=this.#x(s);return gt({class:"messages child-status",key:"child-status"},this.#c?gt({class:"note"},this.#c):null,s.brief?this.#C(0,h?.request):gt({class:"child-status-pending"},kEe),s.brief?this.#D(p,s):null,this.#M(),this.#S(s),gt({class:"child-status-foot"},this.#I(),gt({class:"child-status-actions"},!s.brief||this.#c||this.#i.size?null:this.#y?ln({class:"shimmer-text shimmer-slow"},"Refreshing\u2026"):b?H0({onClick:v=>{v.preventDefault(),this.#w()}},b):ln({class:"current"},"Up to date"),H0({onClick:v=>{v.preventDefault(),this.#_()}},this.#e?"Copied":"Copy Status"),H0({onClick:v=>{v.preventDefault(),this.toggle()}},"Raw Transcript"))))}#_(){let s=this.#t;s&&(navigator.clipboard?.writeText(ETt({d:s,lines:this.#E(s),facts:this.#k(s),edited:this.#r,plans:c7,name:this.#l?.name()||"sub-agent",working:this.#s,now:Date.now()})),this.#e=!0,setTimeout(()=>{this.#e=!1,this.#l?.onChange()},900),this.#l?.onChange())}#C(s,a){return gt({class:["bubble","user",c6(s)],key:`cs-msg-${s}`},a?this.#T(`cs-msg-${s}`,a):this.#R())}#S(s){let a=this.#k(s);return a.length?gt({class:"child-status-head"},a.map(([h,p,b])=>gt({class:"child-status-fact"},ln({class:"child-status-label"},h),ln({class:["child-status-value",b??""]},p)))):null}#M(){let s=this.#r;if(!s.length)return null;let a=this.#n?s:s.slice(0,a6n);return gt({class:"child-status-edited"},ln({class:"child-status-label"},`Edited (${s.length})`),a.map(h=>gt({class:"cs-file"},h.deleted?mie(h):[H0({title:`Open ${h.path}`,onClick:p=>{p.preventDefault(),tb.server.openFile(h.path)}},h.path),mie(h).slice(h.path.length)])),s.length>a.length?H0({onClick:h=>{h.preventDefault(),this.#n=!0,this.#l?.onChange()}},`+${s.length-a.length} more`):null)}#D(s,a){return F6t({class:"cs-table"},H6t(ote(BF("Subtask"),BF("Status"),BF("Progress"),BF({class:"cs-time",title:a.idle?`${Ff(a.span)} of work; ${Ff(a.idle)} spent idle, waiting to be woken, is left out. Ticks mark each wake.`:void 0},a.span?`Timeline \xB7 ${Ff(a.span)}`:"Timeline"))),$6t(s.map(h=>h.kind==="group"?ote({class:"cs-group"},gM({colSpan:4},this.#C(h.idx,h.request||void 0))):this.#B(h,a))))}#B(s,a){let{status:h,did:p,note:b,cite:v,ms:w,spans:S}=s;return ote({class:h==="off"?"cs-off":""},gM(s.num?`${s.num}. ${s.title}`:s.title),gM(h?ln({class:["cs-status",h]},yEe(h)):ln({class:"cs-status"},"\u2026")),gM(p?ln(p," "):null,v.length?ln({class:"cs-cite"},v.map(([T,B],M)=>[M?", ":"",this.#N(T,B,a)])):null,b?gt({class:"cs-note"},b):null),gM({class:"cs-time"},w?this.#L(S,w,h,a.span,a.wakes):""))}#L(s,a,h,p,b){let v=w=>p?`${Math.min(100,Math.max(0,100*w/p))}%`:"0%";return gt({class:"cs-gantt-cell",title:`${Ff(a)} spent, starting ${Ff(s[0]?.from??0)} in`},gt({class:"cs-gantt"},s.map(w=>ln({class:["cs-seg",h],style:{left:v(w.from),width:v(w.to-w.from)}})),b.map(w=>ln({class:"cs-wake",style:{left:v(w)}}))),ln({class:"cs-mins"},Ff(a)))}#N(s,a,h){let p=h.steps[s-1],b=a&&a!==s?`${s}\u2013${a}`:String(s);return p?H0({title:"Show in the transcript",onClick:v=>{v.preventDefault(),this.open=!1,this.#l?.reveal(p.tool.id)}},b):b}#I(){let s=[...this.#i.values()][0];return s?gt({class:"child-status-note err"},`${s} \xB7 `,H0({onClick:a=>{a.preventDefault(),this.#v()}},"retry")):null}#R(){return gt({class:"child-status-pending"},this.#y?ln({class:"child-status-note shimmer-text shimmer-slow"},"summarizing\u2026"):ln({class:"child-status-note"},"not summarized yet"))}#T(s,a){return gt({class:"md",key:`${s}-${a.length}`,onMounted:o7(a)})}};var ITt=".typebulb/paste",TTt={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",bmp:"image/bmp"},u7=o=>o.label||o.kind||"agent",CEe=o=>`Open this ${o.kind?`${o.kind} `:""}agent's transcript`;function l6n(o){let s=new Set(o.map(v=>v.id)),a=new Map;for(let v of o){let w=v.parentId&&s.has(v.parentId)?v.parentId:"",S=a.get(w);S?S.push(v):a.set(w,[v])}let h=[],p=new Set,b=v=>{for(let w of a.get(v)??[])p.has(w.id)||(p.add(w.id),h.push(w),b(w.id))};b("");for(let v of o)p.has(v.id)||h.push(v);return h}var Aie=class extends iw{children=[];enabled=!1;statusEnabled=!1;viewing=null;status=new wie;#e=new Map;#t=[];#r=null;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=l6n((await tb.server.listChildren()).sort((h,p)=>h.mtime-p.mtime));if(this.open&&this.#t.length){let h=new Map(this.#t.map((p,b)=>[p,b]));s=s.map((p,b)=>[p,h.get(p.id)??this.#t.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.#n(),a&&(this.update(),this.keepBottom())}catch(s){console.error("[mirror] listChildren failed",s)}}syncFromPoll(s){let a=this.viewing?.id??null;return this.#r=s,this.#n(),s&&!this.viewing&&this.refresh(),(this.viewing?.id??null)!==a}reset(){this.children=[],this.#e.clear(),this.refresh()}#n(){this.viewing=this.#r?this.children.find(s=>s.id===this.#r)??null:null}async openChild(s,a){this.close(),this.parent.messageList.stickToBottomNextRender();try{await tb.server.openChild(s),this.#r=s,this.#n(),this.status.show(!!a,a),this.update()}catch(h){console.error("[mirror] openChild failed",h)}this.refresh()}async#s(s){let a=this.#e.get(s.id);if(a?.state!=="busy"){if(a?.state==="ready")return this.#e.delete(s.id),this.openChild(s.id,a.seed);this.#e.set(s.id,{state:"busy"}),this.update();try{let h=await tb.server.judgeChildStatus(s.id);if(h?.ok&&!h.error&&h.cached)return this.#e.delete(s.id),this.openChild(s.id,{plans:h.plans,frozen:h.frozen,judged:h.judged});this.#e.set(s.id,h?.ok&&!h.error?{state:"ready",seed:{plans:h.plans,frozen:h.frozen,judged:h.judged}}:{state:"failed",error:h?.error??"could not judge"})}catch{this.#e.set(s.id,{state:"failed",error:"could not judge"})}this.update()}}get#o(){return[...this.#e.values()].some(s=>s.state==="ready")}async closeChild(){this.parent.messageList.stickToBottomNextRender(),this.status.open=!1;try{await tb.server.closeChild(),this.#r=null,this.#n(),this.update()}catch(s){console.error("[mirror] closeChild failed",s)}}show(){this.beginOpen(),this.#t=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?gt({class:"children-wrap"}):gt({class:"children-wrap pop-center"},this.viewing?this.viewingPill():this.chip(s),this.open?this.popup():null)}chip(s){let a=this.running;return Ao({class:["pill","children-pill",NF(a>0),this.open?"on":"",this.#o?"status-ready":""],"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()}},ln({class:"glyph-img"},"\u{1F916}"),String(a),ln({class:"glyph-img"},"\u{1F916}"))}viewingPill(){let s=this.viewing,a=this.children.length;return Ao({class:["pill","glyph","children-pill","viewing","on",NF(s.state==="running"),this.#o?"status-ready":""],"data-tip":`${a} agent${a===1?"":"s"} \u2014 switch`,onClick:h=>{h.stopPropagation(),this.open?this.close():this.show()}},ln({class:"glyph-img"},"\u{1F916}"),ln({class:"children-doc-label",title:u7(s)},u7(s)),fte(()=>{this.closeChild()}))}popup(){let s=this.rows();return gt({class:["servers-pop","children-pop",this.statusEnabled?"with-status":""]},s.length===0?this.emptyState("No agents in this session yet."):gt({class:"children-list",onScroll:()=>this.onListScroll()},s.map((a,h)=>this.row(a,h))),this.filterBox(this.children.length,"agent"))}row(s,a){return gt({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)}},ln({class:["children-dot",s.failing&&s.state!=="stopped"?"failing":s.state]}),ln({class:["children-label",s.state==="running"?"shimmer-text shimmer-slow":""]},u7(s)),s.kind?ln({class:"children-kind"},s.kind):null,s.model?ln({class:"children-model"},s.effort?`${s.model} \xB7 ${s.effort}`:s.model):null,ln({class:"children-time"},s.started?Ff((s.state==="running"?Date.now():s.mtime)-s.started):""),s.failing?ln({class:"children-tokens failing",title:"Its latest reply is an API error, not the model's"},"error"):ln({class:"children-tokens"},s.tokens?PF(s.tokens):""),this.statusEnabled?this.#i(s):null)}#i(s){let a=this.#e.get(s.id),h=a?a.state==="busy"?"Working out where it stands\u2026":a.state==="ready"?"Ready: open its status":`${a.error}. Click to retry`:"Where this agent stands on each task (a few cheap model calls)";return ln({class:["children-status-link",a?.state==="busy"?"shimmer-text shimmer-slow":a?.state??""],"data-tip":h,onClick:p=>{p.stopPropagation(),this.#s(s)}},"status")}};var lD=class extends Wu{done=!1;#e;constructor(s){super(),this.#e=s}setText(s){this.#e=s}flash(){navigator.clipboard?.writeText(this.#e),this.done=!0,this.update(),setTimeout(()=>{this.done=!1,this.update()},600)}view(){return Ao({class:["overlay-pill","copy",this.done?"done":""],onClick:s=>{s.stopPropagation(),this.flash()}},this.done?"copied":"copy")}};var _Tt=new Map,MTt=(o,s)=>s+`
|
|
2206
2206
|
|
|
2207
2207
|
---
|
|
2208
2208
|
|
|
@@ -1202,7 +1202,9 @@ a.server-port:hover { text-decoration: underline; }
|
|
|
1202
1202
|
.children-pill { padding: 0 .3rem; }
|
|
1203
1203
|
.children-pill:not(.glyph) .glyph-img:first-child { margin-right: .12rem; }
|
|
1204
1204
|
.children-pill:not(.glyph) .glyph-img:last-child { margin-left: .12rem; }
|
|
1205
|
-
|
|
1205
|
+
/* The model cell carries effort too; a harness with a Status link (Codex has none) needs its width. */
|
|
1206
|
+
.children-pop { width: min(540px, calc(100vw - 2rem)); }
|
|
1207
|
+
.children-pop.with-status { width: min(600px, calc(100vw - 2rem)); }
|
|
1206
1208
|
.children-row.viewing .children-label { color: var(--accent); }
|
|
1207
1209
|
/* One dot carries the state: still working (the fold-marker green), finished (dim), killed by the
|
|
1208
1210
|
user (warn). Green because running is the LIVE-APP axis, the same one the launcher's running
|
|
@@ -2202,7 +2202,7 @@ ${KCt(b)}`};let v=JCt(h.code,{jsxImportSource:p.ts?.jsxImportSource});if(v.error
|
|
|
2202
2202
|
`+T,D=a?.rows.find(j=>j.id===b);D?.status==="done"&&!h.has(B)&&h.set(B,D),D=h.get(B)??D;let N=D?.steps??[];p.push({kind:"row",num:b,title:T,status:D?.status??"",did:D?.did??"",note:D?.note??"",steps:N,cite:D?.evidence?.length?D.evidence:N,ms:0,spans:[]})}});for(let v of a?.offBrief??[])p.push({kind:"row",title:v.what,status:"off",did:"",note:v.note,steps:v.steps,cite:v.steps,ms:0,spans:[]});return U5n(p,o),p}function U5n(o,s){let a=o.filter(v=>v.kind==="row"),h=s.steps.map(v=>a.find(w=>j5n(v.n,w.steps))),p=h.find(Boolean);if(!p)return;let b=p;for(let v=0;v<h.length;v++)h[v]=b=h[v]??b;s.steps.forEach((v,w)=>{let S=h[w];S.ms+=v.wall;for(let T of v.parts){let B=S.spans.at(-1);B&&Math.abs(B.to-T.from)<1e3?B.to=Math.max(B.to,T.to):S.spans.push({...T})}})}function hTt(o,s,a,h){let p=o.tests,b=s&&s.followups===o.followups.length,v=o.followups.length?a.get(o.followups.at(-1))?.request:void 0;return[["Now",b?s.data.now:v?`Working on the latest follow-up: ${v}`:h?"\u2026":""],["Tests",p?`${p.state}${p.line?`, ${p.line}`:""}${p.ms!==void 0?`, took ${Ff(p.ms)}`:""} (step ${p.n})`:"",p?`tests-${p.state}`:void 0],["Time",o.span&&o.steps.length?`${Ff(o.toolMs)} in tools, ${Ff(Math.max(0,o.span-o.toolMs))} in the model${o.idle?`, ${Ff(o.idle)} stopped`:""}`:""],["Needs a decision",b?s.data.decision:"","warn"]].filter(([,S])=>S)}var z5n=["content","diff","new_string","new_source","edits"];function dTt(o,s){let a=new Map,h=v=>{let w=v.trim().replace(/^["']|["']$/g,"").replace(/\\/g,"/").replace(/^\/([a-zA-Z])\//,"$1:/"),S=lte(w,s).replace(/^\.\//,"");return!S||/^([a-zA-Z]:)?\//.test(S)?void 0:S},p=(v,w={})=>{let S=h(v);if(!S)return;let T=a.get(S)??{path:S};T.deleted=w.deleted,w.from&&(T.from=w.from),a.set(S,T)},b=(v,w)=>{let S=h(v),T=S?a.get(S):void 0;S&&a.delete(S),p(w,{from:T?.from??S})};for(let{tool:v}of o.steps){if(v.isError)continue;let w=v.input??{},S=!1;for(let[D,N]of Object.entries(w)){if(D==="command"||D==="cmd"||typeof N!="string"||!/^(---|\+\+\+) /m.test(N))continue;let j;for(let U of N.split(`
|
|
2203
2203
|
`)){let z=/^(---|\+\+\+) (?:[ab]\/)?(.+?)\s*$/.exec(U);if(z?.[1]==="---"){j=z[2];continue}if(z?.[1]==="+++"){S=!0,z[2]==="/dev/null"?j&&j!=="/dev/null"&&p(j,{deleted:!0}):p(z[2]);continue}let ee=/^\*\*\* Move to: (.+?)\s*$/.exec(U);ee&&j&&b(j,ee[1])}}let T=Sl(w.file_path)??Sl(w.filePath)??Sl(w.path);!S&&T&&z5n.some(D=>D in w)&&p(T);let B=gEe(v);if(B)for(let D of K5n(B))D.to?b(D.from,D.to):p(D.from,{deleted:!0})}return[...a.values()]}function K5n(o){let s=[];for(let a of o.split(/&&|\|\||[;|\n]/)){let h=a.trim().match(/"[^"]*"|'[^']*'|\S+/g)??[],p=h.indexOf("git"),b=h[p+1];if(p<0||b!=="rm"&&b!=="mv"||h.includes("--cached"))continue;let v=h.slice(p+2).filter(S=>!S.startsWith("-")).map(S=>S.replace(/^["']|["']$/g,""));if(b==="rm"){for(let S of v)s.push({from:S});continue}let w=v.pop();if(w)for(let S of v)s.push({from:S,to:v.length>1?`${w.replace(/\/+$/,"")}/${kC(S)}`:w})}return s}function pTt(o){let{d:s}=o,a=o.working?`running, step ${s.steps.length}${W5n(s,o.now)}`:`finished after ${s.steps.length} steps`,h=[`Sub-agent "${o.name}": ${a}, ${Ff(s.span)} active${s.lastAt?`, as of ${F5n(s.lastAt)}`:""}.`];h.push("",`Request: ${s.brief?o.plans.get(s.brief)?.request??"(not summarized yet)":mEe}`);for(let p of o.lines){if(p.kind==="group"){h.push("",`Follow-up: ${p.request||"(not summarized yet)"}`);continue}let b=p.ms?` (${Ff(p.ms)})`:"";h.push(`- ${p.title}: ${bEe(p.status||"pending")}.${p.did?` ${p.did}`:""}${b}`),p.note&&h.push(` Note: ${p.note}`)}o.edited.length&&h.push("","Edited:",...o.edited.map(gie)),o.facts.length&&h.push("");for(let[p,b]of o.facts)h.push(`${p}: ${b}`);return h.join(`
|
|
2204
2204
|
`)}var gie=o=>o.deleted?`${o.path} (deleted)`:o.from?`${o.path} (moved from ${o.from})`:o.path;function W5n(o,s){let a=[...o.steps].reverse().find(h=>h.tool.result===void 0&&h.tool.at);return a?`, waiting ${Ff(s-a.tool.at)} on ${pie(a.tool,60)}`:o.lastAt?`, last activity ${Ff(s-o.lastAt)} ago`:""}function gTt(o){let s=o??{},a=h=>Array.isArray(h)?h.filter(Array.isArray).map(p=>[Number(p[0]),p[1]===void 0?void 0:Number(p[1])]).filter(p=>p[0]>0):[];return{now:String(s.now??""),decision:String(s.decision??""),rows:(Array.isArray(s.rows)?s.rows:[]).map(h=>({id:Number(h.id),status:String(h.status??""),did:String(h.did??""),note:String(h.note??""),steps:a(h.steps),evidence:a(h.evidence)})),offBrief:(Array.isArray(s.offBrief)?s.offBrief:[]).map(h=>({what:String(h.what??""),note:String(h.note??""),steps:a(h.steps)}))}}function bTt(o){let s=o;return{request:String(s?.request??""),subtasks:Array.isArray(s?.subtasks)?s.subtasks.map(a=>String(a).replace(/[.\s]+$/,"")):[]}}var Y5n=12,c7=new Map,wEe=new Map,AEe=new Map,bie=class extends mu{open=!1;#e=!1;#t=null;#r=[];#n=!1;#s=!1;#o=new Set;#i=new Map;#c="";#u=null;#f=!1;#h=!1;#d=!1;#a="";#p;#g=null;#l;bind(s){this.#l=s}toggle(){this.open=!this.open,this.sync(),this.#l?.onChange()}show(s,a){if(this.open=s,this.#t=null,this.#a="",this.#p=void 0,this.#n=!1,this.#u=a?.judged??null,this.#f=!!a,this.#d=!1,a){for(let[h,p]of Object.entries(a.plans))c7.set(h,p);for(let[h,p]of Object.entries(a.frozen))wEe.has(h)||wEe.set(h,p);a.judged&&AEe.set(a.judged.key,a.judged)}this.#g=this.#l?.msgs()??null}sync(){if(!this.open||!this.#l)return;let s=this.#l.msgs();if(s===this.#g)return;this.#g=null;let a=this.#l.working(),h=s.at(-1),p=`${s.length}:${h?.text.length??0}:${h?.tools.length??0}:${h?.tools.filter(S=>S.result!==void 0).length??0}:${a}`;if(p!==this.#a||!this.#t){let S=aTt(s);this.#t&&S.brief!==this.#t.brief&&(this.#u=null,this.#f=!1,this.#n=!1),this.#t=S,this.#r=dTt(S,this.#l.cwd()),this.#a=p,this.#s=a,this.#p=void 0,this.#l.onChange()}let b=this.#t;if(this.#c||!b.brief)return;let v=this.#p??=this.#b(b),w=v&&AEe.get(v.key);if(w&&w!==this.#u&&(this.#u=w,this.#l.onChange()),w&&!this.#f&&(this.#f=!0,this.#l.onChange()),!(this.#f&&!this.#d)){for(let S of[b.brief,...b.followups])c7.has(S)||this.#m({kind:"plan",text:S});!v||this.#h||(this.#d=!1,this.#u?.key!==v.key&&this.#m(v))}}#b(s){let a=lTt(s,c7,!this.#s);return a&&{kind:"status",...a}}async#m(s){let a=s.kind==="plan"?`plan
|
|
2205
|
-
`+s.text:s.key;if(this.#o.has(a)||this.#i.has(a))return;this.#o.add(a),s.kind==="status"&&(this.#h=!0);let h=this.#t?.brief;try{let p=await tb.server.childStatus(s.kind,s.kind==="plan"?s.text:s.payload);if(p?.ok&&s.kind==="plan")c7.set(s.text,bTt(p.data));else if(p?.ok&&s.kind==="status"){let b={key:s.key,data:gTt(p.data),steps:s.steps,followups:s.followups,at:Date.now()};AEe.set(s.key,b),h===this.#t?.brief&&(this.#u=b,this.#f=!0)}else p?.setup?this.#c=p.error:this.#i.set(a,p?.error??"could not summarize")}catch{this.#i.set(a,"could not summarize")}s.kind==="status"&&(this.#h=!1),this.#o.delete(a),(this.#i.has(a)||this.#c)&&(this.#d=!1),this.#l?.onChange(),this.sync()}#v(){this.#i.clear(),this.#w()}#w(){this.#d=!0,this.sync(),this.#l?.onChange()}get#y(){return this.#d||this.#h||this.#o.size>0}#x(s){let a=this.#u,h=s.steps.length-(a?.steps??0),p=s.followups.length-(a?.followups??0);if(h<=0&&p<=0&&(!this.#p||a?.key===this.#p.key))return null;let b=[[h,"step"],[p,"message"]].filter(([v])=>v>0).map(([v,w])=>`${v} new ${w}${v===1?"":"s"}`);return b.length?`Refresh (${b.join(", ")})`:"Refresh"}#E(s){return fTt(s,c7,this.#u?.data,wEe)}#k(s){return hTt(s,this.#u,c7,this.#y)}view(){let s=this.#t;if(!s||(s.brief?!this.#f:!s.steps.length))return Gt({class:"messages child-status",key:"child-status"},this.#c?Gt({class:"note"},this.#c):this.#I()??Gt({class:"child-status-pending"},"Loading\u2026"));let h=c7.get(s.brief),p=this.#E(s),b=this.#x(s);return Gt({class:"messages child-status",key:"child-status"},this.#c?Gt({class:"note"},this.#c):null,s.brief?this.#C(0,h?.request):Gt({class:"child-status-pending"},mEe),s.brief?this.#D(p,s):null,this.#M(),this.#S(s),Gt({class:"child-status-foot"},this.#I(),Gt({class:"child-status-actions"},!s.brief||this.#c||this.#i.size?null:this.#y?Mn({class:"shimmer-text shimmer-slow"},"Refreshing\u2026"):b?$0({onClick:v=>{v.preventDefault(),this.#w()}},b):Mn({class:"current"},"Up to date"),$0({onClick:v=>{v.preventDefault(),this.#_()}},this.#e?"Copied":"Copy Status"),$0({onClick:v=>{v.preventDefault(),this.toggle()}},"Raw Transcript"))))}#_(){let s=this.#t;s&&(navigator.clipboard?.writeText(pTt({d:s,lines:this.#E(s),facts:this.#k(s),edited:this.#r,plans:c7,name:this.#l?.name()||"sub-agent",working:this.#s,now:Date.now()})),this.#e=!0,setTimeout(()=>{this.#e=!1,this.#l?.onChange()},900),this.#l?.onChange())}#C(s,a){return Gt({class:["bubble","user",c6(s)],key:`cs-msg-${s}`},a?this.#T(`cs-msg-${s}`,a):this.#R())}#S(s){let a=this.#k(s);return a.length?Gt({class:"child-status-head"},a.map(([h,p,b])=>Gt({class:"child-status-fact"},Mn({class:"child-status-label"},h),Mn({class:["child-status-value",b??""]},p)))):null}#M(){let s=this.#r;if(!s.length)return null;let a=this.#n?s:s.slice(0,Y5n);return Gt({class:"child-status-edited"},Mn({class:"child-status-label"},`Edited (${s.length})`),a.map(h=>Gt({class:"cs-file"},h.deleted?gie(h):[$0({title:`Open ${h.path}`,onClick:p=>{p.preventDefault(),tb.server.openFile(h.path)}},h.path),gie(h).slice(h.path.length)])),s.length>a.length?$0({onClick:h=>{h.preventDefault(),this.#n=!0,this.#l?.onChange()}},`+${s.length-a.length} more`):null)}#D(s,a){return D6t({class:"cs-table"},L6t(ote(BF("Subtask"),BF("Status"),BF("Progress"),BF({class:"cs-time",title:a.idle?`${Ff(a.span)} of work; ${Ff(a.idle)} spent idle, waiting to be woken, is left out. Ticks mark each wake.`:void 0},a.span?`Timeline \xB7 ${Ff(a.span)}`:"Timeline"))),B6t(s.map(h=>h.kind==="group"?ote({class:"cs-group"},gM({colSpan:4},this.#C(h.idx,h.request||void 0))):this.#B(h,a))))}#B(s,a){let{status:h,did:p,note:b,cite:v,ms:w,spans:S}=s;return ote({class:h==="off"?"cs-off":""},gM(s.num?`${s.num}. ${s.title}`:s.title),gM(h?Mn({class:["cs-status",h]},bEe(h)):Mn({class:"cs-status"},"\u2026")),gM(p?Mn(p," "):null,v.length?Mn({class:"cs-cite"},v.map(([T,B],D)=>[D?", ":"",this.#N(T,B,a)])):null,b?Gt({class:"cs-note"},b):null),gM({class:"cs-time"},w?this.#L(S,w,h,a.span,a.wakes):""))}#L(s,a,h,p,b){let v=w=>p?`${Math.min(100,Math.max(0,100*w/p))}%`:"0%";return Gt({class:"cs-gantt-cell",title:`${Ff(a)} spent, starting ${Ff(s[0]?.from??0)} in`},Gt({class:"cs-gantt"},s.map(w=>Mn({class:["cs-seg",h],style:{left:v(w.from),width:v(w.to-w.from)}})),b.map(w=>Mn({class:"cs-wake",style:{left:v(w)}}))),Mn({class:"cs-mins"},Ff(a)))}#N(s,a,h){let p=h.steps[s-1],b=a&&a!==s?`${s}\u2013${a}`:String(s);return p?$0({title:"Show in the transcript",onClick:v=>{v.preventDefault(),this.open=!1,this.#l?.reveal(p.tool.id)}},b):b}#I(){let s=[...this.#i.values()][0];return s?Gt({class:"child-status-note err"},`${s} \xB7 `,$0({onClick:a=>{a.preventDefault(),this.#v()}},"retry")):null}#R(){return Gt({class:"child-status-pending"},this.#y?Mn({class:"child-status-note shimmer-text shimmer-slow"},"summarizing\u2026"):Mn({class:"child-status-note"},"not summarized yet"))}#T(s,a){return Gt({class:"md",key:`${s}-${a.length}`,onMounted:o7(a)})}};var mTt=".typebulb/paste",wTt={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",bmp:"image/bmp"},u7=o=>o.label||o.kind||"agent",vEe=o=>`Open this ${o.kind?`${o.kind} `:""}agent's transcript`;function X5n(o){let s=new Set(o.map(v=>v.id)),a=new Map;for(let v of o){let w=v.parentId&&s.has(v.parentId)?v.parentId:"",S=a.get(w);S?S.push(v):a.set(w,[v])}let h=[],p=new Set,b=v=>{for(let w of a.get(v)??[])p.has(w.id)||(p.add(w.id),h.push(w),b(w.id))};b("");for(let v of o)p.has(v.id)||h.push(v);return h}var mie=class extends x4{children=[];enabled=!1;statusEnabled=!1;viewing=null;status=new bie;#e=new Map;#t=[];#r=null;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=X5n((await tb.server.listChildren()).sort((h,p)=>h.mtime-p.mtime));if(this.open&&this.#t.length){let h=new Map(this.#t.map((p,b)=>[p,b]));s=s.map((p,b)=>[p,h.get(p.id)??this.#t.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.#n(),a&&(this.update(),this.keepBottom())}catch(s){console.error("[mirror] listChildren failed",s)}}syncFromPoll(s){let a=this.viewing?.id??null;return this.#r=s,this.#n(),s&&!this.viewing&&this.refresh(),(this.viewing?.id??null)!==a}reset(){this.children=[],this.#e.clear(),this.refresh()}#n(){this.viewing=this.#r?this.children.find(s=>s.id===this.#r)??null:null}async openChild(s,a){this.close(),this.parent.messageList.stickToBottomNextRender();try{await tb.server.openChild(s),this.#r=s,this.#n(),this.status.show(!!a,a),this.update()}catch(h){console.error("[mirror] openChild failed",h)}this.refresh()}async#s(s){let a=this.#e.get(s.id);if(a?.state!=="busy"){if(a?.state==="ready")return this.#e.delete(s.id),this.openChild(s.id,a.seed);this.#e.set(s.id,{state:"busy"}),this.update();try{let h=await tb.server.judgeChildStatus(s.id);if(h?.ok&&!h.error&&h.cached)return this.#e.delete(s.id),this.openChild(s.id,{plans:h.plans,frozen:h.frozen,judged:h.judged});this.#e.set(s.id,h?.ok&&!h.error?{state:"ready",seed:{plans:h.plans,frozen:h.frozen,judged:h.judged}}:{state:"failed",error:h?.error??"could not judge"})}catch{this.#e.set(s.id,{state:"failed",error:"could not judge"})}this.update()}}get#o(){return[...this.#e.values()].some(s=>s.state==="ready")}async closeChild(){this.parent.messageList.stickToBottomNextRender(),this.status.open=!1;try{await tb.server.closeChild(),this.#r=null,this.#n(),this.update()}catch(s){console.error("[mirror] closeChild failed",s)}}show(){this.beginOpen(),this.#t=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?Gt({class:"children-wrap"}):Gt({class:"children-wrap pop-center"},this.viewing?this.viewingPill():this.chip(s),this.open?this.popup():null)}chip(s){let a=this.running;return wu({class:["pill","children-pill",NF(a>0),this.open?"on":"",this.#o?"status-ready":""],"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()}},Mn({class:"glyph-img"},"\u{1F916}"),String(a),Mn({class:"glyph-img"},"\u{1F916}"))}viewingPill(){let s=this.viewing,a=this.children.length;return wu({class:["pill","glyph","children-pill","viewing","on",NF(s.state==="running"),this.#o?"status-ready":""],"data-tip":`${a} agent${a===1?"":"s"} \u2014 switch`,onClick:h=>{h.stopPropagation(),this.open?this.close():this.show()}},Mn({class:"glyph-img"},"\u{1F916}"),Mn({class:"children-doc-label",title:u7(s)},u7(s)),ate(()=>{this.closeChild()}))}popup(){let s=this.rows();return Gt({class:"servers-pop children-pop"},s.length===0?this.emptyState("No agents in this session yet."):Gt({class:"children-list",onScroll:()=>this.onListScroll()},s.map((a,h)=>this.row(a,h))),this.filterBox(this.children.length,"agent"))}row(s,a){return Gt({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)}},Mn({class:["children-dot",s.failing&&s.state!=="stopped"?"failing":s.state]}),Mn({class:["children-label",s.state==="running"?"shimmer-text shimmer-slow":""]},u7(s)),s.kind?Mn({class:"children-kind"},s.kind):null,s.model?Mn({class:"children-model"},s.model):null,Mn({class:"children-time"},s.started?Ff((s.state==="running"?Date.now():s.mtime)-s.started):""),s.failing?Mn({class:"children-tokens failing",title:"Its latest reply is an API error, not the model's"},"error"):Mn({class:"children-tokens"},s.tokens?PF(s.tokens):""),this.statusEnabled?this.#i(s):null)}#i(s){let a=this.#e.get(s.id),h=a?a.state==="busy"?"Working out where it stands\u2026":a.state==="ready"?"Ready: open its status":`${a.error}. Click to retry`:"Where this agent stands on each task (a few cheap model calls)";return Mn({class:["children-status-link",a?.state==="busy"?"shimmer-text shimmer-slow":a?.state??""],"data-tip":h,onClick:p=>{p.stopPropagation(),this.#s(s)}},"status")}};var lD=class extends mu{done=!1;#e;constructor(s){super(),this.#e=s}setText(s){this.#e=s}flash(){navigator.clipboard?.writeText(this.#e),this.done=!0,this.update(),setTimeout(()=>{this.done=!1,this.update()},600)}view(){return wu({class:["overlay-pill","copy",this.done?"done":""],onClick:s=>{s.stopPropagation(),this.flash()}},this.done?"copied":"copy")}};var ATt=new Map,vTt=(o,s)=>s+`
|
|
2205
|
+
`+s.text:s.key;if(this.#o.has(a)||this.#i.has(a))return;this.#o.add(a),s.kind==="status"&&(this.#h=!0);let h=this.#t?.brief;try{let p=await tb.server.childStatus(s.kind,s.kind==="plan"?s.text:s.payload);if(p?.ok&&s.kind==="plan")c7.set(s.text,bTt(p.data));else if(p?.ok&&s.kind==="status"){let b={key:s.key,data:gTt(p.data),steps:s.steps,followups:s.followups,at:Date.now()};AEe.set(s.key,b),h===this.#t?.brief&&(this.#u=b,this.#f=!0)}else p?.setup?this.#c=p.error:this.#i.set(a,p?.error??"could not summarize")}catch{this.#i.set(a,"could not summarize")}s.kind==="status"&&(this.#h=!1),this.#o.delete(a),(this.#i.has(a)||this.#c)&&(this.#d=!1),this.#l?.onChange(),this.sync()}#v(){this.#i.clear(),this.#w()}#w(){this.#d=!0,this.sync(),this.#l?.onChange()}get#y(){return this.#d||this.#h||this.#o.size>0}#x(s){let a=this.#u,h=s.steps.length-(a?.steps??0),p=s.followups.length-(a?.followups??0);if(h<=0&&p<=0&&(!this.#p||a?.key===this.#p.key))return null;let b=[[h,"step"],[p,"message"]].filter(([v])=>v>0).map(([v,w])=>`${v} new ${w}${v===1?"":"s"}`);return b.length?`Refresh (${b.join(", ")})`:"Refresh"}#E(s){return fTt(s,c7,this.#u?.data,wEe)}#k(s){return hTt(s,this.#u,c7,this.#y)}view(){let s=this.#t;if(!s||(s.brief?!this.#f:!s.steps.length))return Gt({class:"messages child-status",key:"child-status"},this.#c?Gt({class:"note"},this.#c):this.#I()??Gt({class:"child-status-pending"},"Loading\u2026"));let h=c7.get(s.brief),p=this.#E(s),b=this.#x(s);return Gt({class:"messages child-status",key:"child-status"},this.#c?Gt({class:"note"},this.#c):null,s.brief?this.#C(0,h?.request):Gt({class:"child-status-pending"},mEe),s.brief?this.#D(p,s):null,this.#M(),this.#S(s),Gt({class:"child-status-foot"},this.#I(),Gt({class:"child-status-actions"},!s.brief||this.#c||this.#i.size?null:this.#y?Mn({class:"shimmer-text shimmer-slow"},"Refreshing\u2026"):b?$0({onClick:v=>{v.preventDefault(),this.#w()}},b):Mn({class:"current"},"Up to date"),$0({onClick:v=>{v.preventDefault(),this.#_()}},this.#e?"Copied":"Copy Status"),$0({onClick:v=>{v.preventDefault(),this.toggle()}},"Raw Transcript"))))}#_(){let s=this.#t;s&&(navigator.clipboard?.writeText(pTt({d:s,lines:this.#E(s),facts:this.#k(s),edited:this.#r,plans:c7,name:this.#l?.name()||"sub-agent",working:this.#s,now:Date.now()})),this.#e=!0,setTimeout(()=>{this.#e=!1,this.#l?.onChange()},900),this.#l?.onChange())}#C(s,a){return Gt({class:["bubble","user",c6(s)],key:`cs-msg-${s}`},a?this.#T(`cs-msg-${s}`,a):this.#R())}#S(s){let a=this.#k(s);return a.length?Gt({class:"child-status-head"},a.map(([h,p,b])=>Gt({class:"child-status-fact"},Mn({class:"child-status-label"},h),Mn({class:["child-status-value",b??""]},p)))):null}#M(){let s=this.#r;if(!s.length)return null;let a=this.#n?s:s.slice(0,Y5n);return Gt({class:"child-status-edited"},Mn({class:"child-status-label"},`Edited (${s.length})`),a.map(h=>Gt({class:"cs-file"},h.deleted?gie(h):[$0({title:`Open ${h.path}`,onClick:p=>{p.preventDefault(),tb.server.openFile(h.path)}},h.path),gie(h).slice(h.path.length)])),s.length>a.length?$0({onClick:h=>{h.preventDefault(),this.#n=!0,this.#l?.onChange()}},`+${s.length-a.length} more`):null)}#D(s,a){return D6t({class:"cs-table"},L6t(ote(BF("Subtask"),BF("Status"),BF("Progress"),BF({class:"cs-time",title:a.idle?`${Ff(a.span)} of work; ${Ff(a.idle)} spent idle, waiting to be woken, is left out. Ticks mark each wake.`:void 0},a.span?`Timeline \xB7 ${Ff(a.span)}`:"Timeline"))),B6t(s.map(h=>h.kind==="group"?ote({class:"cs-group"},gM({colSpan:4},this.#C(h.idx,h.request||void 0))):this.#B(h,a))))}#B(s,a){let{status:h,did:p,note:b,cite:v,ms:w,spans:S}=s;return ote({class:h==="off"?"cs-off":""},gM(s.num?`${s.num}. ${s.title}`:s.title),gM(h?Mn({class:["cs-status",h]},bEe(h)):Mn({class:"cs-status"},"\u2026")),gM(p?Mn(p," "):null,v.length?Mn({class:"cs-cite"},v.map(([T,B],D)=>[D?", ":"",this.#N(T,B,a)])):null,b?Gt({class:"cs-note"},b):null),gM({class:"cs-time"},w?this.#L(S,w,h,a.span,a.wakes):""))}#L(s,a,h,p,b){let v=w=>p?`${Math.min(100,Math.max(0,100*w/p))}%`:"0%";return Gt({class:"cs-gantt-cell",title:`${Ff(a)} spent, starting ${Ff(s[0]?.from??0)} in`},Gt({class:"cs-gantt"},s.map(w=>Mn({class:["cs-seg",h],style:{left:v(w.from),width:v(w.to-w.from)}})),b.map(w=>Mn({class:"cs-wake",style:{left:v(w)}}))),Mn({class:"cs-mins"},Ff(a)))}#N(s,a,h){let p=h.steps[s-1],b=a&&a!==s?`${s}\u2013${a}`:String(s);return p?$0({title:"Show in the transcript",onClick:v=>{v.preventDefault(),this.open=!1,this.#l?.reveal(p.tool.id)}},b):b}#I(){let s=[...this.#i.values()][0];return s?Gt({class:"child-status-note err"},`${s} \xB7 `,$0({onClick:a=>{a.preventDefault(),this.#v()}},"retry")):null}#R(){return Gt({class:"child-status-pending"},this.#y?Mn({class:"child-status-note shimmer-text shimmer-slow"},"summarizing\u2026"):Mn({class:"child-status-note"},"not summarized yet"))}#T(s,a){return Gt({class:"md",key:`${s}-${a.length}`,onMounted:o7(a)})}};var mTt=".typebulb/paste",wTt={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",bmp:"image/bmp"},u7=o=>o.label||o.kind||"agent",vEe=o=>`Open this ${o.kind?`${o.kind} `:""}agent's transcript`;function X5n(o){let s=new Set(o.map(v=>v.id)),a=new Map;for(let v of o){let w=v.parentId&&s.has(v.parentId)?v.parentId:"",S=a.get(w);S?S.push(v):a.set(w,[v])}let h=[],p=new Set,b=v=>{for(let w of a.get(v)??[])p.has(w.id)||(p.add(w.id),h.push(w),b(w.id))};b("");for(let v of o)p.has(v.id)||h.push(v);return h}var mie=class extends x4{children=[];enabled=!1;statusEnabled=!1;viewing=null;status=new bie;#e=new Map;#t=[];#r=null;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=X5n((await tb.server.listChildren()).sort((h,p)=>h.mtime-p.mtime));if(this.open&&this.#t.length){let h=new Map(this.#t.map((p,b)=>[p,b]));s=s.map((p,b)=>[p,h.get(p.id)??this.#t.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.#n(),a&&(this.update(),this.keepBottom())}catch(s){console.error("[mirror] listChildren failed",s)}}syncFromPoll(s){let a=this.viewing?.id??null;return this.#r=s,this.#n(),s&&!this.viewing&&this.refresh(),(this.viewing?.id??null)!==a}reset(){this.children=[],this.#e.clear(),this.refresh()}#n(){this.viewing=this.#r?this.children.find(s=>s.id===this.#r)??null:null}async openChild(s,a){this.close(),this.parent.messageList.stickToBottomNextRender();try{await tb.server.openChild(s),this.#r=s,this.#n(),this.status.show(!!a,a),this.update()}catch(h){console.error("[mirror] openChild failed",h)}this.refresh()}async#s(s){let a=this.#e.get(s.id);if(a?.state!=="busy"){if(a?.state==="ready")return this.#e.delete(s.id),this.openChild(s.id,a.seed);this.#e.set(s.id,{state:"busy"}),this.update();try{let h=await tb.server.judgeChildStatus(s.id);if(h?.ok&&!h.error&&h.cached)return this.#e.delete(s.id),this.openChild(s.id,{plans:h.plans,frozen:h.frozen,judged:h.judged});this.#e.set(s.id,h?.ok&&!h.error?{state:"ready",seed:{plans:h.plans,frozen:h.frozen,judged:h.judged}}:{state:"failed",error:h?.error??"could not judge"})}catch{this.#e.set(s.id,{state:"failed",error:"could not judge"})}this.update()}}get#o(){return[...this.#e.values()].some(s=>s.state==="ready")}async closeChild(){this.parent.messageList.stickToBottomNextRender(),this.status.open=!1;try{await tb.server.closeChild(),this.#r=null,this.#n(),this.update()}catch(s){console.error("[mirror] closeChild failed",s)}}show(){this.beginOpen(),this.#t=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?Gt({class:"children-wrap"}):Gt({class:"children-wrap pop-center"},this.viewing?this.viewingPill():this.chip(s),this.open?this.popup():null)}chip(s){let a=this.running;return wu({class:["pill","children-pill",NF(a>0),this.open?"on":"",this.#o?"status-ready":""],"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()}},Mn({class:"glyph-img"},"\u{1F916}"),String(a),Mn({class:"glyph-img"},"\u{1F916}"))}viewingPill(){let s=this.viewing,a=this.children.length;return wu({class:["pill","glyph","children-pill","viewing","on",NF(s.state==="running"),this.#o?"status-ready":""],"data-tip":`${a} agent${a===1?"":"s"} \u2014 switch`,onClick:h=>{h.stopPropagation(),this.open?this.close():this.show()}},Mn({class:"glyph-img"},"\u{1F916}"),Mn({class:"children-doc-label",title:u7(s)},u7(s)),ate(()=>{this.closeChild()}))}popup(){let s=this.rows();return Gt({class:["servers-pop","children-pop",this.statusEnabled?"with-status":""]},s.length===0?this.emptyState("No agents in this session yet."):Gt({class:"children-list",onScroll:()=>this.onListScroll()},s.map((a,h)=>this.row(a,h))),this.filterBox(this.children.length,"agent"))}row(s,a){return Gt({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)}},Mn({class:["children-dot",s.failing&&s.state!=="stopped"?"failing":s.state]}),Mn({class:["children-label",s.state==="running"?"shimmer-text shimmer-slow":""]},u7(s)),s.kind?Mn({class:"children-kind"},s.kind):null,s.model?Mn({class:"children-model"},s.effort?`${s.model} \xB7 ${s.effort}`:s.model):null,Mn({class:"children-time"},s.started?Ff((s.state==="running"?Date.now():s.mtime)-s.started):""),s.failing?Mn({class:"children-tokens failing",title:"Its latest reply is an API error, not the model's"},"error"):Mn({class:"children-tokens"},s.tokens?PF(s.tokens):""),this.statusEnabled?this.#i(s):null)}#i(s){let a=this.#e.get(s.id),h=a?a.state==="busy"?"Working out where it stands\u2026":a.state==="ready"?"Ready: open its status":`${a.error}. Click to retry`:"Where this agent stands on each task (a few cheap model calls)";return Mn({class:["children-status-link",a?.state==="busy"?"shimmer-text shimmer-slow":a?.state??""],"data-tip":h,onClick:p=>{p.stopPropagation(),this.#s(s)}},"status")}};var lD=class extends mu{done=!1;#e;constructor(s){super(),this.#e=s}setText(s){this.#e=s}flash(){navigator.clipboard?.writeText(this.#e),this.done=!0,this.update(),setTimeout(()=>{this.done=!1,this.update()},600)}view(){return wu({class:["overlay-pill","copy",this.done?"done":""],onClick:s=>{s.stopPropagation(),this.flash()}},this.done?"copied":"copy")}};var ATt=new Map,vTt=(o,s)=>s+`
|
|
2206
2206
|
|
|
2207
2207
|
---
|
|
2208
2208
|
|
|
@@ -1202,7 +1202,9 @@ a.server-port:hover { text-decoration: underline; }
|
|
|
1202
1202
|
.children-pill { padding: 0 .3rem; }
|
|
1203
1203
|
.children-pill:not(.glyph) .glyph-img:first-child { margin-right: .12rem; }
|
|
1204
1204
|
.children-pill:not(.glyph) .glyph-img:last-child { margin-left: .12rem; }
|
|
1205
|
-
|
|
1205
|
+
/* The model cell carries effort too; a harness with a Status link (Codex has none) needs its width. */
|
|
1206
|
+
.children-pop { width: min(540px, calc(100vw - 2rem)); }
|
|
1207
|
+
.children-pop.with-status { width: min(600px, calc(100vw - 2rem)); }
|
|
1206
1208
|
.children-row.viewing .children-label { color: var(--accent); }
|
|
1207
1209
|
/* One dot carries the state: still working (the fold-marker green), finished (dim), killed by the
|
|
1208
1210
|
user (warn). Green because running is the LIVE-APP axis, the same one the launcher's running
|
package/dist/agents/pi/client.js
CHANGED
|
@@ -2202,7 +2202,7 @@ ${tSt(b)}`};let v=VCt(h.code,{jsxImportSource:p.ts?.jsxImportSource});if(v.error
|
|
|
2202
2202
|
`+T,M=a?.rows.find(j=>j.id===b);M?.status==="done"&&!h.has(B)&&h.set(B,M),M=h.get(B)??M;let N=M?.steps??[];p.push({kind:"row",num:b,title:T,status:M?.status??"",did:M?.did??"",note:M?.note??"",steps:N,cite:M?.evidence?.length?M.evidence:N,ms:0,spans:[]})}});for(let v of a?.offBrief??[])p.push({kind:"row",title:v.what,status:"off",did:"",note:v.note,steps:v.steps,cite:v.steps,ms:0,spans:[]});return r6n(p,o),p}function r6n(o,s){let a=o.filter(v=>v.kind==="row"),h=s.steps.map(v=>a.find(w=>W5n(v.n,w.steps))),p=h.find(Boolean);if(!p)return;let b=p;for(let v=0;v<h.length;v++)h[v]=b=h[v]??b;s.steps.forEach((v,w)=>{let C=h[w];C.ms+=v.wall;for(let T of v.parts){let B=C.spans.at(-1);B&&Math.abs(B.to-T.from)<1e3?B.to=Math.max(B.to,T.to):C.spans.push({...T})}})}function ATt(o,s,a,h){let p=o.tests,b=s&&s.followups===o.followups.length,v=o.followups.length?a.get(o.followups.at(-1))?.request:void 0;return[["Now",b?s.data.now:v?`Working on the latest follow-up: ${v}`:h?"\u2026":""],["Tests",p?`${p.state}${p.line?`, ${p.line}`:""}${p.ms!==void 0?`, took ${Ff(p.ms)}`:""} (step ${p.n})`:"",p?`tests-${p.state}`:void 0],["Time",o.span&&o.steps.length?`${Ff(o.toolMs)} in tools, ${Ff(Math.max(0,o.span-o.toolMs))} in the model${o.idle?`, ${Ff(o.idle)} stopped`:""}`:""],["Needs a decision",b?s.data.decision:"","warn"]].filter(([,C])=>C)}var i6n=["content","diff","new_string","new_source","edits"];function vTt(o,s){let a=new Map,h=v=>{let w=v.trim().replace(/^["']|["']$/g,"").replace(/\\/g,"/").replace(/^\/([a-zA-Z])\//,"$1:/"),C=pte(w,s).replace(/^\.\//,"");return!C||/^([a-zA-Z]:)?\//.test(C)?void 0:C},p=(v,w={})=>{let C=h(v);if(!C)return;let T=a.get(C)??{path:C};T.deleted=w.deleted,w.from&&(T.from=w.from),a.set(C,T)},b=(v,w)=>{let C=h(v),T=C?a.get(C):void 0;C&&a.delete(C),p(w,{from:T?.from??C})};for(let{tool:v}of o.steps){if(v.isError)continue;let w=v.input??{},C=!1;for(let[M,N]of Object.entries(w)){if(M==="command"||M==="cmd"||typeof N!="string"||!/^(---|\+\+\+) /m.test(N))continue;let j;for(let J of N.split(`
|
|
2203
2203
|
`)){let z=/^(---|\+\+\+) (?:[ab]\/)?(.+?)\s*$/.exec(J);if(z?.[1]==="---"){j=z[2];continue}if(z?.[1]==="+++"){C=!0,z[2]==="/dev/null"?j&&j!=="/dev/null"&&p(j,{deleted:!0}):p(z[2]);continue}let ee=/^\*\*\* Move to: (.+?)\s*$/.exec(J);ee&&j&&b(j,ee[1])}}let T=Sl(w.file_path)??Sl(w.filePath)??Sl(w.path);!C&&T&&i6n.some(M=>M in w)&&p(T);let B=vEe(v);if(B)for(let M of s6n(B))M.to?b(M.from,M.to):p(M.from,{deleted:!0})}return[...a.values()]}function s6n(o){let s=[];for(let a of o.split(/&&|\|\||[;|\n]/)){let h=a.trim().match(/"[^"]*"|'[^']*'|\S+/g)??[],p=h.indexOf("git"),b=h[p+1];if(p<0||b!=="rm"&&b!=="mv"||h.includes("--cached"))continue;let v=h.slice(p+2).filter(C=>!C.startsWith("-")).map(C=>C.replace(/^["']|["']$/g,""));if(b==="rm"){for(let C of v)s.push({from:C});continue}let w=v.pop();if(w)for(let C of v)s.push({from:C,to:v.length>1?`${w.replace(/\/+$/,"")}/${xC(C)}`:w})}return s}function yTt(o){let{d:s}=o,a=o.working?`running, step ${s.steps.length}${o6n(s,o.now)}`:`finished after ${s.steps.length} steps`,h=[`Sub-agent "${o.name}": ${a}, ${Ff(s.span)} active${s.lastAt?`, as of ${Y5n(s.lastAt)}`:""}.`];h.push("",`Request: ${s.brief?o.plans.get(s.brief)?.request??"(not summarized yet)":kEe}`);for(let p of o.lines){if(p.kind==="group"){h.push("",`Follow-up: ${p.request||"(not summarized yet)"}`);continue}let b=p.ms?` (${Ff(p.ms)})`:"";h.push(`- ${p.title}: ${yEe(p.status||"pending")}.${p.did?` ${p.did}`:""}${b}`),p.note&&h.push(` Note: ${p.note}`)}o.edited.length&&h.push("","Edited:",...o.edited.map(wie)),o.facts.length&&h.push("");for(let[p,b]of o.facts)h.push(`${p}: ${b}`);return h.join(`
|
|
2204
2204
|
`)}var wie=o=>o.deleted?`${o.path} (deleted)`:o.from?`${o.path} (moved from ${o.from})`:o.path;function o6n(o,s){let a=[...o.steps].reverse().find(h=>h.tool.result===void 0&&h.tool.at);return a?`, waiting ${Ff(s-a.tool.at)} on ${mie(a.tool,60)}`:o.lastAt?`, last activity ${Ff(s-o.lastAt)} ago`:""}function kTt(o){let s=o??{},a=h=>Array.isArray(h)?h.filter(Array.isArray).map(p=>[Number(p[0]),p[1]===void 0?void 0:Number(p[1])]).filter(p=>p[0]>0):[];return{now:String(s.now??""),decision:String(s.decision??""),rows:(Array.isArray(s.rows)?s.rows:[]).map(h=>({id:Number(h.id),status:String(h.status??""),did:String(h.did??""),note:String(h.note??""),steps:a(h.steps),evidence:a(h.evidence)})),offBrief:(Array.isArray(s.offBrief)?s.offBrief:[]).map(h=>({what:String(h.what??""),note:String(h.note??""),steps:a(h.steps)}))}}function xTt(o){let s=o;return{request:String(s?.request??""),subtasks:Array.isArray(s?.subtasks)?s.subtasks.map(a=>String(a).replace(/[.\s]+$/,"")):[]}}var c6n=12,u7=new Map,xEe=new Map,EEe=new Map,Aie=class extends Jc{open=!1;#e=!1;#t=null;#r=[];#n=!1;#s=!1;#o=new Set;#i=new Map;#c="";#u=null;#h=!1;#l=!1;#d=!1;#a="";#p;#b=null;#f;bind(s){this.#f=s}toggle(){this.open=!this.open,this.sync(),this.#f?.onChange()}show(s,a){if(this.open=s,this.#t=null,this.#a="",this.#p=void 0,this.#n=!1,this.#u=a?.judged??null,this.#h=!!a,this.#d=!1,a){for(let[h,p]of Object.entries(a.plans))u7.set(h,p);for(let[h,p]of Object.entries(a.frozen))xEe.has(h)||xEe.set(h,p);a.judged&&EEe.set(a.judged.key,a.judged)}this.#b=this.#f?.msgs()??null}sync(){if(!this.open||!this.#f)return;let s=this.#f.msgs();if(s===this.#b)return;this.#b=null;let a=this.#f.working(),h=s.at(-1),p=`${s.length}:${h?.text.length??0}:${h?.tools.length??0}:${h?.tools.filter(C=>C.result!==void 0).length??0}:${a}`;if(p!==this.#a||!this.#t){let C=bTt(s);this.#t&&C.brief!==this.#t.brief&&(this.#u=null,this.#h=!1,this.#n=!1),this.#t=C,this.#r=vTt(C,this.#f.cwd()),this.#a=p,this.#s=a,this.#p=void 0,this.#f.onChange()}let b=this.#t;if(this.#c||!b.brief)return;let v=this.#p??=this.#m(b),w=v&&EEe.get(v.key);if(w&&w!==this.#u&&(this.#u=w,this.#f.onChange()),w&&!this.#h&&(this.#h=!0,this.#f.onChange()),!(this.#h&&!this.#d)){for(let C of[b.brief,...b.followups])u7.has(C)||this.#g({kind:"plan",text:C});!v||this.#l||(this.#d=!1,this.#u?.key!==v.key&&this.#g(v))}}#m(s){let a=mTt(s,u7,!this.#s);return a&&{kind:"status",...a}}async#g(s){let a=s.kind==="plan"?`plan
|
|
2205
|
-
`+s.text:s.key;if(this.#o.has(a)||this.#i.has(a))return;this.#o.add(a),s.kind==="status"&&(this.#l=!0);let h=this.#t?.brief;try{let p=await tb.server.childStatus(s.kind,s.kind==="plan"?s.text:s.payload);if(p?.ok&&s.kind==="plan")u7.set(s.text,xTt(p.data));else if(p?.ok&&s.kind==="status"){let b={key:s.key,data:kTt(p.data),steps:s.steps,followups:s.followups,at:Date.now()};EEe.set(s.key,b),h===this.#t?.brief&&(this.#u=b,this.#h=!0)}else p?.setup?this.#c=p.error:this.#i.set(a,p?.error??"could not summarize")}catch{this.#i.set(a,"could not summarize")}s.kind==="status"&&(this.#l=!1),this.#o.delete(a),(this.#i.has(a)||this.#c)&&(this.#d=!1),this.#f?.onChange(),this.sync()}#v(){this.#i.clear(),this.#w()}#w(){this.#d=!0,this.sync(),this.#f?.onChange()}get#A(){return this.#d||this.#l||this.#o.size>0}#y(s){let a=this.#u,h=s.steps.length-(a?.steps??0),p=s.followups.length-(a?.followups??0);if(h<=0&&p<=0&&(!this.#p||a?.key===this.#p.key))return null;let b=[[h,"step"],[p,"message"]].filter(([v])=>v>0).map(([v,w])=>`${v} new ${w}${v===1?"":"s"}`);return b.length?`Refresh (${b.join(", ")})`:"Refresh"}#k(s){return wTt(s,u7,this.#u?.data,xEe)}#x(s){return ATt(s,this.#u,u7,this.#A)}view(){let s=this.#t;if(!s||(s.brief?!this.#h:!s.steps.length))return xt({class:"messages child-status",key:"child-status"},this.#c?xt({class:"note"},this.#c):this.#T()??xt({class:"child-status-pending"},"Loading\u2026"));let h=u7.get(s.brief),p=this.#k(s),b=this.#y(s);return xt({class:"messages child-status",key:"child-status"},this.#c?xt({class:"note"},this.#c):null,s.brief?this.#C(0,h?.request):xt({class:"child-status-pending"},kEe),s.brief?this.#D(p,s):null,this.#M(),this.#I(s),xt({class:"child-status-foot"},this.#T(),xt({class:"child-status-actions"},!s.brief||this.#c||this.#i.size?null:this.#A?xn({class:"shimmer-text shimmer-slow"},"Refreshing\u2026"):b?q0({onClick:v=>{v.preventDefault(),this.#w()}},b):xn({class:"current"},"Up to date"),q0({onClick:v=>{v.preventDefault(),this.#E()}},this.#e?"Copied":"Copy Status"),q0({onClick:v=>{v.preventDefault(),this.toggle()}},"Raw Transcript"))))}#E(){let s=this.#t;s&&(navigator.clipboard?.writeText(yTt({d:s,lines:this.#k(s),facts:this.#x(s),edited:this.#r,plans:u7,name:this.#f?.name()||"sub-agent",working:this.#s,now:Date.now()})),this.#e=!0,setTimeout(()=>{this.#e=!1,this.#f?.onChange()},900),this.#f?.onChange())}#C(s,a){return xt({class:["bubble","user",u6(s)],key:`cs-msg-${s}`},a?this.#_(`cs-msg-${s}`,a):this.#R())}#I(s){let a=this.#x(s);return a.length?xt({class:"child-status-head"},a.map(([h,p,b])=>xt({class:"child-status-fact"},xn({class:"child-status-label"},h),xn({class:["child-status-value",b??""]},p)))):null}#M(){let s=this.#r;if(!s.length)return null;let a=this.#n?s:s.slice(0,c6n);return xt({class:"child-status-edited"},xn({class:"child-status-label"},`Edited (${s.length})`),a.map(h=>xt({class:"cs-file"},h.deleted?wie(h):[q0({title:`Open ${h.path}`,onClick:p=>{p.preventDefault(),tb.server.openFile(h.path)}},h.path),wie(h).slice(h.path.length)])),s.length>a.length?q0({onClick:h=>{h.preventDefault(),this.#n=!0,this.#f?.onChange()}},`+${s.length-a.length} more`):null)}#D(s,a){return j6t({class:"cs-table"},$6t(lte(PF("Subtask"),PF("Status"),PF("Progress"),PF({class:"cs-time",title:a.idle?`${Ff(a.span)} of work; ${Ff(a.idle)} spent idle, waiting to be woken, is left out. Ticks mark each wake.`:void 0},a.span?`Timeline \xB7 ${Ff(a.span)}`:"Timeline"))),F6t(s.map(h=>h.kind==="group"?lte({class:"cs-group"},mM({colSpan:4},this.#C(h.idx,h.request||void 0))):this.#B(h,a))))}#B(s,a){let{status:h,did:p,note:b,cite:v,ms:w,spans:C}=s;return lte({class:h==="off"?"cs-off":""},mM(s.num?`${s.num}. ${s.title}`:s.title),mM(h?xn({class:["cs-status",h]},yEe(h)):xn({class:"cs-status"},"\u2026")),mM(p?xn(p," "):null,v.length?xn({class:"cs-cite"},v.map(([T,B],M)=>[M?", ":"",this.#N(T,B,a)])):null,b?xt({class:"cs-note"},b):null),mM({class:"cs-time"},w?this.#L(C,w,h,a.span,a.wakes):""))}#L(s,a,h,p,b){let v=w=>p?`${Math.min(100,Math.max(0,100*w/p))}%`:"0%";return xt({class:"cs-gantt-cell",title:`${Ff(a)} spent, starting ${Ff(s[0]?.from??0)} in`},xt({class:"cs-gantt"},s.map(w=>xn({class:["cs-seg",h],style:{left:v(w.from),width:v(w.to-w.from)}})),b.map(w=>xn({class:"cs-wake",style:{left:v(w)}}))),xn({class:"cs-mins"},Ff(a)))}#N(s,a,h){let p=h.steps[s-1],b=a&&a!==s?`${s}\u2013${a}`:String(s);return p?q0({title:"Show in the transcript",onClick:v=>{v.preventDefault(),this.open=!1,this.#f?.reveal(p.tool.id)}},b):b}#T(){let s=[...this.#i.values()][0];return s?xt({class:"child-status-note err"},`${s} \xB7 `,q0({onClick:a=>{a.preventDefault(),this.#v()}},"retry")):null}#R(){return xt({class:"child-status-pending"},this.#A?xn({class:"child-status-note shimmer-text shimmer-slow"},"summarizing\u2026"):xn({class:"child-status-note"},"not summarized yet"))}#_(s,a){return xt({class:"md",key:`${s}-${a.length}`,onMounted:c7(a)})}};var ETt=".typebulb/paste",CTt={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",bmp:"image/bmp"},a7=o=>o.label||o.kind||"agent",CEe=o=>`Open this ${o.kind?`${o.kind} `:""}agent's transcript`;function u6n(o){let s=new Set(o.map(v=>v.id)),a=new Map;for(let v of o){let w=v.parentId&&s.has(v.parentId)?v.parentId:"",C=a.get(w);C?C.push(v):a.set(w,[v])}let h=[],p=new Set,b=v=>{for(let w of a.get(v)??[])p.has(w.id)||(p.add(w.id),h.push(w),b(w.id))};b("");for(let v of o)p.has(v.id)||h.push(v);return h}var vie=class extends x4{children=[];enabled=!1;statusEnabled=!1;viewing=null;status=new Aie;#e=new Map;#t=[];#r=null;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=u6n((await tb.server.listChildren()).sort((h,p)=>h.mtime-p.mtime));if(this.open&&this.#t.length){let h=new Map(this.#t.map((p,b)=>[p,b]));s=s.map((p,b)=>[p,h.get(p.id)??this.#t.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.#n(),a&&(this.update(),this.keepBottom())}catch(s){console.error("[mirror] listChildren failed",s)}}syncFromPoll(s){let a=this.viewing?.id??null;return this.#r=s,this.#n(),s&&!this.viewing&&this.refresh(),(this.viewing?.id??null)!==a}reset(){this.children=[],this.#e.clear(),this.refresh()}#n(){this.viewing=this.#r?this.children.find(s=>s.id===this.#r)??null:null}async openChild(s,a){this.close(),this.parent.messageList.stickToBottomNextRender();try{await tb.server.openChild(s),this.#r=s,this.#n(),this.status.show(!!a,a),this.update()}catch(h){console.error("[mirror] openChild failed",h)}this.refresh()}async#s(s){let a=this.#e.get(s.id);if(a?.state!=="busy"){if(a?.state==="ready")return this.#e.delete(s.id),this.openChild(s.id,a.seed);this.#e.set(s.id,{state:"busy"}),this.update();try{let h=await tb.server.judgeChildStatus(s.id);if(h?.ok&&!h.error&&h.cached)return this.#e.delete(s.id),this.openChild(s.id,{plans:h.plans,frozen:h.frozen,judged:h.judged});this.#e.set(s.id,h?.ok&&!h.error?{state:"ready",seed:{plans:h.plans,frozen:h.frozen,judged:h.judged}}:{state:"failed",error:h?.error??"could not judge"})}catch{this.#e.set(s.id,{state:"failed",error:"could not judge"})}this.update()}}get#o(){return[...this.#e.values()].some(s=>s.state==="ready")}async closeChild(){this.parent.messageList.stickToBottomNextRender(),this.status.open=!1;try{await tb.server.closeChild(),this.#r=null,this.#n(),this.update()}catch(s){console.error("[mirror] closeChild failed",s)}}show(){this.beginOpen(),this.#t=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?xt({class:"children-wrap"}):xt({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",FF(a>0),this.open?"on":"",this.#o?"status-ready":""],"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()}},xn({class:"glyph-img"},"\u{1F916}"),String(a),xn({class:"glyph-img"},"\u{1F916}"))}viewingPill(){let s=this.viewing,a=this.children.length;return Po({class:["pill","glyph","children-pill","viewing","on",FF(s.state==="running"),this.#o?"status-ready":""],"data-tip":`${a} agent${a===1?"":"s"} \u2014 switch`,onClick:h=>{h.stopPropagation(),this.open?this.close():this.show()}},xn({class:"glyph-img"},"\u{1F916}"),xn({class:"children-doc-label",title:a7(s)},a7(s)),dte(()=>{this.closeChild()}))}popup(){let s=this.rows();return xt({class:"servers-pop children-pop"},s.length===0?this.emptyState("No agents in this session yet."):xt({class:"children-list",onScroll:()=>this.onListScroll()},s.map((a,h)=>this.row(a,h))),this.filterBox(this.children.length,"agent"))}row(s,a){return xt({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)}},xn({class:["children-dot",s.failing&&s.state!=="stopped"?"failing":s.state]}),xn({class:["children-label",s.state==="running"?"shimmer-text shimmer-slow":""]},a7(s)),s.kind?xn({class:"children-kind"},s.kind):null,s.model?xn({class:"children-model"},s.model):null,xn({class:"children-time"},s.started?Ff((s.state==="running"?Date.now():s.mtime)-s.started):""),s.failing?xn({class:"children-tokens failing",title:"Its latest reply is an API error, not the model's"},"error"):xn({class:"children-tokens"},s.tokens?EC(s.tokens):""),this.statusEnabled?this.#i(s):null)}#i(s){let a=this.#e.get(s.id),h=a?a.state==="busy"?"Working out where it stands\u2026":a.state==="ready"?"Ready: open its status":`${a.error}. Click to retry`:"Where this agent stands on each task (a few cheap model calls)";return xn({class:["children-status-link",a?.state==="busy"?"shimmer-text shimmer-slow":a?.state??""],"data-tip":h,onClick:p=>{p.stopPropagation(),this.#s(s)}},"status")}};var pD=class extends Jc{done=!1;#e;constructor(s){super(),this.#e=s}setText(s){this.#e=s}flash(){navigator.clipboard?.writeText(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 STt=new Map,ITt=(o,s)=>s+`
|
|
2205
|
+
`+s.text:s.key;if(this.#o.has(a)||this.#i.has(a))return;this.#o.add(a),s.kind==="status"&&(this.#l=!0);let h=this.#t?.brief;try{let p=await tb.server.childStatus(s.kind,s.kind==="plan"?s.text:s.payload);if(p?.ok&&s.kind==="plan")u7.set(s.text,xTt(p.data));else if(p?.ok&&s.kind==="status"){let b={key:s.key,data:kTt(p.data),steps:s.steps,followups:s.followups,at:Date.now()};EEe.set(s.key,b),h===this.#t?.brief&&(this.#u=b,this.#h=!0)}else p?.setup?this.#c=p.error:this.#i.set(a,p?.error??"could not summarize")}catch{this.#i.set(a,"could not summarize")}s.kind==="status"&&(this.#l=!1),this.#o.delete(a),(this.#i.has(a)||this.#c)&&(this.#d=!1),this.#f?.onChange(),this.sync()}#v(){this.#i.clear(),this.#w()}#w(){this.#d=!0,this.sync(),this.#f?.onChange()}get#A(){return this.#d||this.#l||this.#o.size>0}#y(s){let a=this.#u,h=s.steps.length-(a?.steps??0),p=s.followups.length-(a?.followups??0);if(h<=0&&p<=0&&(!this.#p||a?.key===this.#p.key))return null;let b=[[h,"step"],[p,"message"]].filter(([v])=>v>0).map(([v,w])=>`${v} new ${w}${v===1?"":"s"}`);return b.length?`Refresh (${b.join(", ")})`:"Refresh"}#k(s){return wTt(s,u7,this.#u?.data,xEe)}#x(s){return ATt(s,this.#u,u7,this.#A)}view(){let s=this.#t;if(!s||(s.brief?!this.#h:!s.steps.length))return xt({class:"messages child-status",key:"child-status"},this.#c?xt({class:"note"},this.#c):this.#T()??xt({class:"child-status-pending"},"Loading\u2026"));let h=u7.get(s.brief),p=this.#k(s),b=this.#y(s);return xt({class:"messages child-status",key:"child-status"},this.#c?xt({class:"note"},this.#c):null,s.brief?this.#C(0,h?.request):xt({class:"child-status-pending"},kEe),s.brief?this.#D(p,s):null,this.#M(),this.#I(s),xt({class:"child-status-foot"},this.#T(),xt({class:"child-status-actions"},!s.brief||this.#c||this.#i.size?null:this.#A?xn({class:"shimmer-text shimmer-slow"},"Refreshing\u2026"):b?q0({onClick:v=>{v.preventDefault(),this.#w()}},b):xn({class:"current"},"Up to date"),q0({onClick:v=>{v.preventDefault(),this.#E()}},this.#e?"Copied":"Copy Status"),q0({onClick:v=>{v.preventDefault(),this.toggle()}},"Raw Transcript"))))}#E(){let s=this.#t;s&&(navigator.clipboard?.writeText(yTt({d:s,lines:this.#k(s),facts:this.#x(s),edited:this.#r,plans:u7,name:this.#f?.name()||"sub-agent",working:this.#s,now:Date.now()})),this.#e=!0,setTimeout(()=>{this.#e=!1,this.#f?.onChange()},900),this.#f?.onChange())}#C(s,a){return xt({class:["bubble","user",u6(s)],key:`cs-msg-${s}`},a?this.#_(`cs-msg-${s}`,a):this.#R())}#I(s){let a=this.#x(s);return a.length?xt({class:"child-status-head"},a.map(([h,p,b])=>xt({class:"child-status-fact"},xn({class:"child-status-label"},h),xn({class:["child-status-value",b??""]},p)))):null}#M(){let s=this.#r;if(!s.length)return null;let a=this.#n?s:s.slice(0,c6n);return xt({class:"child-status-edited"},xn({class:"child-status-label"},`Edited (${s.length})`),a.map(h=>xt({class:"cs-file"},h.deleted?wie(h):[q0({title:`Open ${h.path}`,onClick:p=>{p.preventDefault(),tb.server.openFile(h.path)}},h.path),wie(h).slice(h.path.length)])),s.length>a.length?q0({onClick:h=>{h.preventDefault(),this.#n=!0,this.#f?.onChange()}},`+${s.length-a.length} more`):null)}#D(s,a){return j6t({class:"cs-table"},$6t(lte(PF("Subtask"),PF("Status"),PF("Progress"),PF({class:"cs-time",title:a.idle?`${Ff(a.span)} of work; ${Ff(a.idle)} spent idle, waiting to be woken, is left out. Ticks mark each wake.`:void 0},a.span?`Timeline \xB7 ${Ff(a.span)}`:"Timeline"))),F6t(s.map(h=>h.kind==="group"?lte({class:"cs-group"},mM({colSpan:4},this.#C(h.idx,h.request||void 0))):this.#B(h,a))))}#B(s,a){let{status:h,did:p,note:b,cite:v,ms:w,spans:C}=s;return lte({class:h==="off"?"cs-off":""},mM(s.num?`${s.num}. ${s.title}`:s.title),mM(h?xn({class:["cs-status",h]},yEe(h)):xn({class:"cs-status"},"\u2026")),mM(p?xn(p," "):null,v.length?xn({class:"cs-cite"},v.map(([T,B],M)=>[M?", ":"",this.#N(T,B,a)])):null,b?xt({class:"cs-note"},b):null),mM({class:"cs-time"},w?this.#L(C,w,h,a.span,a.wakes):""))}#L(s,a,h,p,b){let v=w=>p?`${Math.min(100,Math.max(0,100*w/p))}%`:"0%";return xt({class:"cs-gantt-cell",title:`${Ff(a)} spent, starting ${Ff(s[0]?.from??0)} in`},xt({class:"cs-gantt"},s.map(w=>xn({class:["cs-seg",h],style:{left:v(w.from),width:v(w.to-w.from)}})),b.map(w=>xn({class:"cs-wake",style:{left:v(w)}}))),xn({class:"cs-mins"},Ff(a)))}#N(s,a,h){let p=h.steps[s-1],b=a&&a!==s?`${s}\u2013${a}`:String(s);return p?q0({title:"Show in the transcript",onClick:v=>{v.preventDefault(),this.open=!1,this.#f?.reveal(p.tool.id)}},b):b}#T(){let s=[...this.#i.values()][0];return s?xt({class:"child-status-note err"},`${s} \xB7 `,q0({onClick:a=>{a.preventDefault(),this.#v()}},"retry")):null}#R(){return xt({class:"child-status-pending"},this.#A?xn({class:"child-status-note shimmer-text shimmer-slow"},"summarizing\u2026"):xn({class:"child-status-note"},"not summarized yet"))}#_(s,a){return xt({class:"md",key:`${s}-${a.length}`,onMounted:c7(a)})}};var ETt=".typebulb/paste",CTt={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",bmp:"image/bmp"},a7=o=>o.label||o.kind||"agent",CEe=o=>`Open this ${o.kind?`${o.kind} `:""}agent's transcript`;function u6n(o){let s=new Set(o.map(v=>v.id)),a=new Map;for(let v of o){let w=v.parentId&&s.has(v.parentId)?v.parentId:"",C=a.get(w);C?C.push(v):a.set(w,[v])}let h=[],p=new Set,b=v=>{for(let w of a.get(v)??[])p.has(w.id)||(p.add(w.id),h.push(w),b(w.id))};b("");for(let v of o)p.has(v.id)||h.push(v);return h}var vie=class extends x4{children=[];enabled=!1;statusEnabled=!1;viewing=null;status=new Aie;#e=new Map;#t=[];#r=null;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=u6n((await tb.server.listChildren()).sort((h,p)=>h.mtime-p.mtime));if(this.open&&this.#t.length){let h=new Map(this.#t.map((p,b)=>[p,b]));s=s.map((p,b)=>[p,h.get(p.id)??this.#t.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.#n(),a&&(this.update(),this.keepBottom())}catch(s){console.error("[mirror] listChildren failed",s)}}syncFromPoll(s){let a=this.viewing?.id??null;return this.#r=s,this.#n(),s&&!this.viewing&&this.refresh(),(this.viewing?.id??null)!==a}reset(){this.children=[],this.#e.clear(),this.refresh()}#n(){this.viewing=this.#r?this.children.find(s=>s.id===this.#r)??null:null}async openChild(s,a){this.close(),this.parent.messageList.stickToBottomNextRender();try{await tb.server.openChild(s),this.#r=s,this.#n(),this.status.show(!!a,a),this.update()}catch(h){console.error("[mirror] openChild failed",h)}this.refresh()}async#s(s){let a=this.#e.get(s.id);if(a?.state!=="busy"){if(a?.state==="ready")return this.#e.delete(s.id),this.openChild(s.id,a.seed);this.#e.set(s.id,{state:"busy"}),this.update();try{let h=await tb.server.judgeChildStatus(s.id);if(h?.ok&&!h.error&&h.cached)return this.#e.delete(s.id),this.openChild(s.id,{plans:h.plans,frozen:h.frozen,judged:h.judged});this.#e.set(s.id,h?.ok&&!h.error?{state:"ready",seed:{plans:h.plans,frozen:h.frozen,judged:h.judged}}:{state:"failed",error:h?.error??"could not judge"})}catch{this.#e.set(s.id,{state:"failed",error:"could not judge"})}this.update()}}get#o(){return[...this.#e.values()].some(s=>s.state==="ready")}async closeChild(){this.parent.messageList.stickToBottomNextRender(),this.status.open=!1;try{await tb.server.closeChild(),this.#r=null,this.#n(),this.update()}catch(s){console.error("[mirror] closeChild failed",s)}}show(){this.beginOpen(),this.#t=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?xt({class:"children-wrap"}):xt({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",FF(a>0),this.open?"on":"",this.#o?"status-ready":""],"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()}},xn({class:"glyph-img"},"\u{1F916}"),String(a),xn({class:"glyph-img"},"\u{1F916}"))}viewingPill(){let s=this.viewing,a=this.children.length;return Po({class:["pill","glyph","children-pill","viewing","on",FF(s.state==="running"),this.#o?"status-ready":""],"data-tip":`${a} agent${a===1?"":"s"} \u2014 switch`,onClick:h=>{h.stopPropagation(),this.open?this.close():this.show()}},xn({class:"glyph-img"},"\u{1F916}"),xn({class:"children-doc-label",title:a7(s)},a7(s)),dte(()=>{this.closeChild()}))}popup(){let s=this.rows();return xt({class:["servers-pop","children-pop",this.statusEnabled?"with-status":""]},s.length===0?this.emptyState("No agents in this session yet."):xt({class:"children-list",onScroll:()=>this.onListScroll()},s.map((a,h)=>this.row(a,h))),this.filterBox(this.children.length,"agent"))}row(s,a){return xt({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)}},xn({class:["children-dot",s.failing&&s.state!=="stopped"?"failing":s.state]}),xn({class:["children-label",s.state==="running"?"shimmer-text shimmer-slow":""]},a7(s)),s.kind?xn({class:"children-kind"},s.kind):null,s.model?xn({class:"children-model"},s.effort?`${s.model} \xB7 ${s.effort}`:s.model):null,xn({class:"children-time"},s.started?Ff((s.state==="running"?Date.now():s.mtime)-s.started):""),s.failing?xn({class:"children-tokens failing",title:"Its latest reply is an API error, not the model's"},"error"):xn({class:"children-tokens"},s.tokens?EC(s.tokens):""),this.statusEnabled?this.#i(s):null)}#i(s){let a=this.#e.get(s.id),h=a?a.state==="busy"?"Working out where it stands\u2026":a.state==="ready"?"Ready: open its status":`${a.error}. Click to retry`:"Where this agent stands on each task (a few cheap model calls)";return xn({class:["children-status-link",a?.state==="busy"?"shimmer-text shimmer-slow":a?.state??""],"data-tip":h,onClick:p=>{p.stopPropagation(),this.#s(s)}},"status")}};var pD=class extends Jc{done=!1;#e;constructor(s){super(),this.#e=s}setText(s){this.#e=s}flash(){navigator.clipboard?.writeText(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 STt=new Map,ITt=(o,s)=>s+`
|
|
2206
2206
|
|
|
2207
2207
|
---
|
|
2208
2208
|
|
|
@@ -1202,7 +1202,9 @@ a.server-port:hover { text-decoration: underline; }
|
|
|
1202
1202
|
.children-pill { padding: 0 .3rem; }
|
|
1203
1203
|
.children-pill:not(.glyph) .glyph-img:first-child { margin-right: .12rem; }
|
|
1204
1204
|
.children-pill:not(.glyph) .glyph-img:last-child { margin-left: .12rem; }
|
|
1205
|
-
|
|
1205
|
+
/* The model cell carries effort too; a harness with a Status link (Codex has none) needs its width. */
|
|
1206
|
+
.children-pop { width: min(540px, calc(100vw - 2rem)); }
|
|
1207
|
+
.children-pop.with-status { width: min(600px, calc(100vw - 2rem)); }
|
|
1206
1208
|
.children-row.viewing .children-label { color: var(--accent); }
|
|
1207
1209
|
/* One dot carries the state: still working (the fold-marker green), finished (dim), killed by the
|
|
1208
1210
|
user (warn). Green because running is the LIVE-APP axis, the same one the launcher's running
|