glove-foundry 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -727,6 +727,7 @@ var MemoryObservabilityAdapter = class {
727
727
  function categoryForAgentEvent(type) {
728
728
  if (type === "foundry.guidance.state") return "memory";
729
729
  if (type.startsWith("tool_")) return "tool";
730
+ if (type.startsWith("turn_")) return "run";
730
731
  if (type.startsWith("foundry.installation")) return "application";
731
732
  if (type.startsWith("foundry.layer") || type.startsWith("foundry.subscriber")) {
732
733
  return "extension";
@@ -5636,10 +5637,10 @@ function renderGloveMark() {
5636
5637
 
5637
5638
  // src/dashboard-run.ts
5638
5639
  var DASHBOARD_RUN_SCRIPT = String.raw`
5639
- const RUN_TABS=[["summary","Summary","overview"],["network","Network","network"],["console","Console","terminal"],["context","Context","context"]];
5640
+ const RUN_TABS=[["summary","Summary","overview"],["network","Network","network"],["console","Console","terminal"],["context","Context","context"],["composition","Composition","definitions"],["queues","Queues","integrations"],["chain","Call chain","agent"]];
5640
5641
  function runView(){
5641
5642
  const params=new URLSearchParams(location.search);const tab=params.get("tab");
5642
- return{tab:RUN_TABS.some(t=>t[0]===tab)?tab:"network",item:params.get("item")||"",pane:params.get("pane")||"",node:params.get("node")||"",request:params.get("request")||""};
5643
+ return{tab:RUN_TABS.some(t=>t[0]===tab)?tab:"network",item:params.get("item")||"",pane:params.get("pane")||"",node:params.get("node")||"",request:params.get("request")||"",cnode:params.get("cnode")||"",queue:params.get("queue")||""};
5643
5644
  }
5644
5645
  function setRunView(patch){
5645
5646
  const params=new URLSearchParams(location.search);
@@ -5734,23 +5735,66 @@ function netMatches(item,kind,term){
5734
5735
  const text=[item.name,item.model,item.fn,tracePreview(item.input,600),item.kind==="model"?(item.response||[]).map(message=>message.text).join(" "):tracePreview(item.result&&item.result.data,600)].join(" ").toLowerCase();
5735
5736
  return text.includes(term);
5736
5737
  }
5737
- function netRow(item,trace,selectedKey){
5738
+ /* Like DevTools' Timing tab: the phases of one row, in order. */
5739
+ function itemPhases(item){
5740
+ const phases=[];
5741
+ if(item.kind==="model"){
5742
+ if(Number.isFinite(item.ttftMs)){phases.push(["Waiting for the first token",item.ttftMs,"wait"]);phases.push(["Streaming the response",Math.max(0,item.durationMs-item.ttftMs),"run"])}
5743
+ else if(Number.isFinite(item.durationMs))phases.push(["Model request",item.durationMs,"run"]);
5744
+ }else if(item.kind==="tool"){
5745
+ if(item.queuedMs>0)phases.push(["Queued behind earlier calls",item.queuedMs,"queue"]);
5746
+ if(Number.isFinite(item.runMs)){phases.push([item.approval?"Waiting for approval":"Permission check and validation",Math.max(0,item.durationMs-item.runMs),"wait"]);phases.push(["Running",item.runMs,"run"])}
5747
+ else if(Number.isFinite(item.durationMs))phases.push(["Running",item.durationMs,"run"]);
5748
+ }else if(Number.isFinite(item.durationMs))phases.push(["Running",item.durationMs,"run"]);
5749
+ return phases;
5750
+ }
5751
+ function wfBar(item,trace){
5738
5752
  const span=Math.max(1,trace.end-trace.start);const pending=item.status==="pending";
5739
- const left=Number.isFinite(item.startAt)?Math.min(99.4,Math.max(0,(item.startAt-trace.start)/span*100)):0;
5740
- const width=Number.isFinite(item.durationMs)?Math.max(.6,item.durationMs/span*100):pending?100-left:.6;
5753
+ const pct=(ms)=>ms/span*100;
5754
+ const left=Number.isFinite(item.startAt)?Math.min(99.4,Math.max(0,pct(item.startAt-trace.start))):0;
5755
+ const width=Math.min(Number.isFinite(item.durationMs)?Math.max(.6,pct(item.durationMs)):pending?100-left:.6,100-left);
5756
+ const lead=item.queuedMs>0?Math.min(left,pct(item.queuedMs)):0;
5757
+ // The light part is waiting (first token, a permission check); the solid part is work.
5758
+ const waitMs=item.kind==="model"?item.ttftMs:item.kind==="tool"&&Number.isFinite(item.runMs)?item.durationMs-item.runMs:NaN;
5759
+ const wait=Number.isFinite(waitMs)&&Number.isFinite(item.durationMs)&&item.durationMs>0?Math.max(0,Math.min(100,waitMs/item.durationMs*100)):0;
5760
+ const tip=itemPhases(item).map(phase=>phase[0]+": "+durationText(phase[1])).join(" · ");
5761
+ return'<span class="wf-track" title="'+attr(tip)+'">'+(lead?'<span class="wf-queue" style="left:'+(left-lead).toFixed(2)+'%;width:'+lead.toFixed(2)+'%"></span>':"")
5762
+ +'<span class="wf-bar'+(pending?" pending":"")+'" style="left:'+left.toFixed(2)+'%;width:'+width.toFixed(2)+'%">'+(wait&&!pending?'<i class="wf-wait" style="width:'+wait.toFixed(1)+'%"></i>':"")+'</span></span>';
5763
+ }
5764
+ function turnLabel(turn){return"Turn "+turn.index+" · "+(turn.trigger==="events"?"events woke the agent":turn.trigger==="resume"?"resumed at its tool step":"request")}
5765
+ function turnRow(turn){
5766
+ const st={success:["ok","ok"],error:["err","failed"],aborted:["warn","aborted"],suspended:["warn","suspended"],pending:["live","running"]}[turn.status]||["",turn.status];
5767
+ return'<tr class="net-turn"><td colspan="7"><span>'+esc(turnLabel(turn))+'</span><span class="st '+st[0]+'">'+esc(st[1])+'</span><span class="muted mono">'+esc(Number.isFinite(turn.durationMs)?durationText(turn.durationMs):"")+'</span>'+(turn.error?'<span class="sum-msg">'+esc(tracePreview(turn.error,120))+'</span>':"")+'</td></tr>';
5768
+ }
5769
+ function netRow(item,trace,selectedKey){
5770
+ const pending=item.status==="pending";
5741
5771
  const failed=["error","aborted","denied","limit"].includes(item.status);
5742
- return'<tr class="net-row kind-'+attr(item.kind)+(item.purpose==="compaction"?" compaction":"")+(item.key===selectedKey?" selected":"")+(failed?" failed":"")+'" data-net-item="'+attr(item.key)+'">'
5772
+ return'<tr class="net-row kind-'+attr(item.kind)+(item.purpose==="compaction"?" compaction":"")+(item.key===selectedKey?" selected":"")+(failed?" failed":"")+(item.depth?" nested":"")+'" data-net-item="'+attr(item.key)+'"'+(item.depth?' style="--depth:'+Math.min(item.depth,6)+'"':"")+'>'
5743
5773
  +'<td class="c-name"><span class="net-name"><i class="net-glyph"></i><span><b>'+esc(item.name)+'</b><small>'+esc(itemSubtitle(item))+'</small></span></span></td>'
5744
5774
  +'<td class="c-type">'+esc(itemType(item))+'</td>'
5745
5775
  +'<td class="c-status">'+itemStatus(item)+'</td>'
5746
5776
  +'<td class="c-init">'+(item.initiator.key?'<button type="button" class="net-link" data-net-item="'+attr(item.initiator.key)+'">'+esc(item.initiator.label)+'</button>':'<span class="muted">'+esc(item.initiator.label)+'</span>')+'</td>'
5747
5777
  +'<td class="c-size">'+esc(itemSize(item))+'</td>'
5748
5778
  +'<td class="c-time">'+(pending?'<span class="st live">…</span>':esc(durationText(item.durationMs)))+'</td>'
5749
- +'<td class="c-wf"><span class="wf-track"><span class="wf-bar'+(pending?" pending":"")+'" style="left:'+left.toFixed(2)+'%;width:'+Math.min(width,100-left).toFixed(2)+'%"></span></span></td></tr>';
5779
+ +'<td class="c-wf">'+wfBar(item,trace)+'</td></tr>';
5780
+ }
5781
+ function modelPanes(item){return[["overview","Overview"],["prompt","Prompt"],["messages","Messages",item.messages.length],["context","Context",item.context.length],["tools","Tools",item.toolNames.length],["response","Response"],["timing","Timing"],["raw","Raw"]]}
5782
+ function toolPanes(){return[["overview","Overview"],["input","Input"],["result","Result"],["timing","Timing"],["raw","Raw"]]}
5783
+ function timingPane(item,run){
5784
+ const base=new Date(runStartedAt(run)).getTime();
5785
+ const phases=itemPhases(item);
5786
+ if(!phases.length)return'<p class="dt-note">'+(item.status==="pending"?"Still running.":"No timing recorded.")+'</p>';
5787
+ const total=phases.reduce((sum,phase)=>sum+phase[1],0)||1;
5788
+ const notes={"Waiting for the first token":"From sending the request to the first streamed text or tool call.","Streaming the response":"From the first token to the end of the response.","Queued behind earlier calls":"The model asked for this call; the calls before it in the same step ran first.","Permission check and validation":"Checking whether the call may run, then validating its input.","Waiting for approval":"A person had to decide before the call could run.","Running":"The tool itself."};
5789
+ return kv([
5790
+ Number.isFinite(item.askedAt)&&item.kind==="tool"?["Asked for",esc(offsetFrom(base,isoAt(item.askedAt)))]:null,
5791
+ Number.isFinite(item.startAt)?["Started",esc(offsetFrom(base,isoAt(item.startAt)))]:null,
5792
+ Number.isFinite(item.endAt)?["Finished",esc(offsetFrom(base,isoAt(item.endAt)))]:null,
5793
+ ])+'<div class="timing">'+phases.map((phase,index)=>{const left=phases.slice(0,index).reduce((sum,prior)=>sum+prior[1],0)/total*100;return'<div class="timing-row"><span class="timing-name">'+esc(phase[0])+'<small>'+esc(notes[phase[0]]||"")+'</small></span><span class="timing-track"><i class="timing-bar '+attr(phase[2])+'" style="left:'+Math.min(99,left).toFixed(1)+'%;width:'+Math.max(.8,phase[1]/total*100).toFixed(1)+'%"></i></span><span class="mono">'+esc(durationText(phase[1]))+'</span></div>'}).join("")
5794
+ +'<div class="timing-row total"><span class="timing-name">Total</span><span></span><span class="mono">'+esc(durationText(total))+'</span></div></div>'
5795
+ +(item.kind==="model"&&item.streamed?'<div class="dt-section">Streamed text</div><pre class="dt-pre">'+esc(item.streamed)+'</pre>':"");
5750
5796
  }
5751
- function modelPanes(item){return[["overview","Overview"],["prompt","Prompt"],["messages","Messages",item.messages.length],["context","Context",item.context.length],["tools","Tools",item.toolNames.length],["response","Response"],["raw","Raw"]]}
5752
- function toolPanes(){return[["overview","Overview"],["input","Input"],["result","Result"],["raw","Raw"]]}
5753
- function detailPanes(item){return item.kind==="model"?modelPanes(item):item.kind==="tool"?toolPanes():[["overview","Overview"],["raw","Raw"]]}
5797
+ function detailPanes(item){return item.kind==="model"?modelPanes(item):item.kind==="tool"?toolPanes():[["overview","Overview"],["timing","Timing"],["raw","Raw"]]}
5754
5798
  function kv(rows){return'<dl class="dt-kv">'+rows.filter(Boolean).map(row=>'<dt>'+esc(row[0])+'</dt><dd>'+row[1]+'</dd>').join("")+'</dl>'}
5755
5799
  function itemLink(key,label){return'<button type="button" class="net-link" data-net-item="'+attr(key)+'">'+esc(label)+'</button>'}
5756
5800
  function requestJson(item){return jsonText({model:item.model,system:item.systemPrompt??null,messages:item.messages,context:item.context,tools:item.tools||item.toolNames})}
@@ -5780,13 +5824,14 @@ function modelDetail(item,trace,run,pane){
5780
5824
  +(item.response||[]).map((message,index)=>traceMessageHtml(message,item.key+":r"+index,false)).join("");
5781
5825
  }
5782
5826
  if(pane==="raw")return'<div class="dt-bar"><span>'+count(item.events.length,"event")+'</span>'+copyButton(jsonText(item.events),"raw events")+'</div>'+jsonBlock(item.events.map(event=>({type:event.type,timestamp:event.timestamp,data:event.data})),item.key+":raw");
5827
+ if(pane==="timing")return timingPane(item,run);
5783
5828
  const fresh=item.messages.slice(item.newFrom);const calls=(item.response||[]).flatMap(message=>message.tool_calls||[]);
5784
5829
  return kv([
5785
5830
  ["Request",'<span class="mono">'+esc(item.id)+'</span> '+copyButton(item.id,"request id")],
5786
5831
  ["Model",esc(item.model||"—")],
5787
5832
  ["Status",itemStatus(item)+(item.error?' <span class="muted">'+esc(item.error)+'</span>':"")],
5788
5833
  ["Started",esc(offsetFrom(base,isoAt(item.startAt)))+' <span class="muted">'+esc(fmtTime(isoAt(item.startAt)))+'</span>'],
5789
- ["Duration",esc(durationText(item.durationMs))],
5834
+ ["Duration",esc(durationText(item.durationMs))+(Number.isFinite(item.ttftMs)?' <span class="muted">· first token after '+esc(durationText(item.ttftMs))+'</span>':"")],
5790
5835
  ["Tokens",esc(fmtTokens(item.tokensIn))+" in · "+esc(fmtTokens(item.tokensOut))+" out"+(item.cacheRead?" · "+esc(fmtTokens(item.cacheRead))+" read from cache":"")+(item.cacheWrite?" · "+esc(fmtTokens(item.cacheWrite))+" written to cache":"")],
5791
5836
  item.stopReason?["Stop reason",esc(item.stopReason)]:null,
5792
5837
  ["Initiator",item.initiator.key?itemLink(item.initiator.key,item.initiator.label):esc(item.initiator.label)],
@@ -5806,13 +5851,14 @@ function toolDetail(item,run,pane){
5806
5851
  return kv([["Status",itemStatus(item)],item.result.message?["Message",esc(item.result.message)]:null,["Size",esc(fmtBytes(jsonSize(item.result.data)))]])+(typeof item.result.data==="string"&&!/^\s*[\[{]/.test(item.result.data)?'<pre class="dt-pre">'+esc(item.result.data)+'</pre>':jsonBlock(item.result.data,item.key+":result"));
5807
5852
  }
5808
5853
  if(pane==="raw")return'<div class="dt-bar"><span>'+count(item.events.length,"event")+'</span>'+copyButton(jsonText(item.events),"raw events")+'</div>'+jsonBlock(item.events.map(event=>({type:event.type,timestamp:event.timestamp,data:event.data})),item.key+":raw");
5854
+ if(pane==="timing")return timingPane(item,run);
5809
5855
  if(item.kind==="subagent")return kv([["Subagent",esc(item.name)],["Status",itemStatus(item)],["Duration",esc(durationText(item.durationMs))],item.message?["Result",esc(item.message)]:null])+'<div class="dt-section">Prompt</div><pre class="dt-pre">'+esc(item.prompt||"")+'</pre>';
5810
5856
  return kv([
5811
5857
  item.id?["Call",'<span class="mono">'+esc(item.id)+'</span> '+copyButton(item.id,"call id")]:null,
5812
5858
  ["Tool",esc(item.name)+(item.via==="repl"?' <span class="muted">· '+esc(item.fn||"")+'() from the REPL</span>':"")],
5813
5859
  ["Status",itemStatus(item)],
5814
5860
  Number.isFinite(item.startAt)?["Started",esc(offsetFrom(base,isoAt(item.startAt)))]:null,
5815
- ["Duration",esc(durationText(item.durationMs))],
5861
+ ["Duration",esc(durationText(item.durationMs))+(item.queuedMs>0?' <span class="muted">· queued '+esc(durationText(item.queuedMs))+' first</span>':"")],
5816
5862
  ["Called by",item.initiator.key?itemLink(item.initiator.key,item.initiator.label):esc(item.initiator.label)],
5817
5863
  item.approval?["Approval",'<span class="st '+(item.approval.status==="approved"?"ok":item.approval.status==="pending"?"warn":"err")+'">'+esc(item.approval.status)+'</span> <span class="muted">requested '+esc(fmtTime(item.approval.requestedAt))+(item.approval.settledAt?", settled "+esc(fmtTime(item.approval.settledAt)):"")+'</span>']:null,
5818
5864
  item.result?["Result",esc(fmtBytes(jsonSize(item.result.data)))+" · "+'<button type="button" class="net-link" data-net-pane="result">view</button>']:null,
@@ -5826,6 +5872,15 @@ function netDetail(item,trace,run,view){
5826
5872
  +(item.kind==="model"&&item.request?'<span class="nd-actions">'+'<button type="button" class="button" data-copy="'+attr(requestJson(item))+'" title="The system prompt, messages, context and tools of this request as JSON">'+icon("copy")+'<span>Copy request</span></button></span>':"")
5827
5873
  +'</div><div class="nd-title"><b>'+esc(item.name)+'</b><span>'+esc(itemType(item))+(item.model?" · "+esc(item.model):"")+'</span></div><div class="nd-body" data-scroll-key="nd:'+attr(item.key+":"+pane)+'">'+body+'</div></aside>';
5828
5874
  }
5875
+ function netRows(visible,trace,selectedKey){
5876
+ // A run with more than one turn (a resume, an event wake) shows where each began.
5877
+ const divide=(trace.turns||[]).length>1;let shown=0;
5878
+ return visible.map(item=>{
5879
+ let head="";
5880
+ if(divide&&item.turn&&item.turn!==shown){shown=item.turn;const turn=trace.turns[item.turn-1];if(turn)head=turnRow(turn)}
5881
+ return head+netRow(item,trace,selectedKey);
5882
+ }).join("");
5883
+ }
5829
5884
  function runNetwork(run,trace,view){
5830
5885
  const term=state.network.filter.trim().toLowerCase();
5831
5886
  const visible=trace.items.filter(item=>netMatches(item,state.network.kind,term));
@@ -5836,7 +5891,7 @@ function runNetwork(run,trace,view){
5836
5891
  +'<div class="dt-chips" role="group" aria-label="Request type">'+kinds.map(kind=>'<button type="button" class="dt-chip'+(state.network.kind===kind[0]?" active":"")+'" data-net-kind="'+kind[0]+'">'+kind[1]+'</button>').join("")+'</div></div>';
5837
5892
  html+='<div class="net-split'+(selected?" has-detail":"")+'"><div class="net-list" data-scroll-key="net-list">';
5838
5893
  if(!trace.items.length)html+=empty("No requests recorded","Model requests and tool calls appear here as the run makes them. Runs recorded before request tracing, or with observability.modelRequests off, list only tool calls and responses.");
5839
- else html+='<table class="net-table">'+(selected?"":'<colgroup><col class="w-name"><col class="w-type"><col class="w-status"><col class="w-init"><col class="w-size"><col class="w-time"><col class="w-wf"></colgroup>')+'<thead><tr><th class="c-name">Name</th><th class="c-type">Type</th><th class="c-status">Status</th><th class="c-init">Initiator</th><th class="c-size" title="Tokens in → out for model requests, result size for tools">Size</th><th class="c-time">Time</th><th class="c-wf">Waterfall</th></tr></thead><tbody>'+visible.map(item=>netRow(item,trace,view.item)).join("")+'</tbody></table>'+(visible.length?"":empty("Nothing matches","Clear the filter to see every request."));
5894
+ else html+='<table class="net-table">'+(selected?"":'<colgroup><col class="w-name"><col class="w-type"><col class="w-status"><col class="w-init"><col class="w-size"><col class="w-time"><col class="w-wf"></colgroup>')+'<thead><tr><th class="c-name">Name</th><th class="c-type">Type</th><th class="c-status">Status</th><th class="c-init">Initiator</th><th class="c-size" title="Tokens in → out for model requests, result size for tools">Size</th><th class="c-time">Time</th><th class="c-wf">Waterfall</th></tr></thead><tbody>'+netRows(visible,trace,view.item)+'</tbody></table>'+(visible.length?"":empty("Nothing matches","Clear the filter to see every request."));
5840
5895
  html+='</div>'+(selected?netDetail(selected,trace,run,view):"")+'</div>';
5841
5896
  html+='<div class="net-foot"><span>'+(visible.length===trace.items.length?"":visible.length+" / ")+count(t.requests,"model request")+'</span><span>'+count(t.tools,"tool call")+'</span><span>'+esc(fmtTokens(t.tokensIn))+' in · '+esc(fmtTokens(t.tokensOut))+' out'+(t.cacheRead?" · "+esc(fmtTokens(t.cacheRead))+" cached":"")+'</span><span>model '+esc(durationText(t.modelMs))+' · tools '+esc(durationText(t.toolMs))+'</span>'+(t.errors?'<span class="st err">'+count(t.errors,"error")+'</span>':"")+'<span class="net-foot-right">finished in '+esc(durationText(runDurationMs(run)))+'</span></div>';
5842
5897
  return html;
@@ -5847,7 +5902,8 @@ const CONSOLE_LEVELS={default:["error","warn","info"],all:["error","warn","info"
5847
5902
  function revealKey(row){
5848
5903
  const type=String(row.type||"").replace(/^agent\./,"");const data=row.data||{};
5849
5904
  if(type==="model_request"||type==="model_request_end")return"m:"+data.request_id;
5850
- if(type==="tool_use")return data.id?"t:"+data.id:"";
5905
+ if(type==="tool_use"||type==="tool_use_start")return data.id?"t:"+data.id:"";
5906
+ if(type==="text_delta")return data.request_id?"m:"+data.request_id:"";
5851
5907
  if(type==="tool_use_result")return(data.id||data.call_id)?"t:"+(data.id||data.call_id):"";
5852
5908
  return"";
5853
5909
  }
@@ -5933,10 +5989,11 @@ function renderRun(id){
5933
5989
  +'<div><label>Agent instance</label><strong>'+(run.agentId?'<a class="link mono" href="/instances/'+attr(run.agentId)+'" data-link>'+esc(short(run.agentId))+'</a>':"Not recorded")+'</strong></div>'
5934
5990
  +'</div>';
5935
5991
  const errors=rows.filter(row=>row.level==="error").length;const warnings=rows.filter(row=>row.level==="warn").length;
5936
- const badge={network:trace.items.length?'<span class="dt-badge">'+trace.items.length+'</span>':"",console:(errors?'<span class="dt-badge err">'+errors+'</span>':"")+(warnings?'<span class="dt-badge warn">'+warnings+'</span>':"")};
5992
+ const crossings=buildQueues(events,run,trace).length;
5993
+ const badge={queues:crossings?'<span class="dt-badge">'+crossings+'</span>':"",network:trace.items.length?'<span class="dt-badge">'+trace.items.length+'</span>':"",console:(errors?'<span class="dt-badge err">'+errors+'</span>':"")+(warnings?'<span class="dt-badge warn">'+warnings+'</span>':"")};
5937
5994
  html+='<section class="devtools"><div class="dt-tabs" role="tablist" aria-label="Run views">'+RUN_TABS.map(tab=>'<button type="button" role="tab" class="dt-tab'+(view.tab===tab[0]?" active":"")+'" aria-selected="'+(view.tab===tab[0])+'" data-run-tab="'+tab[0]+'">'+icon(tab[2])+esc(tab[1])+(badge[tab[0]]||"")+'</button>').join("")
5938
- +(isLiveRun(run)?'<span class="dt-live"><i class="pulse-dot"></i>Live</span>':"")+'<span class="dt-hint">1–4 views · j / k requests · / filter · Esc close</span></div><div class="dt-body dt-'+view.tab+'">'
5939
- +(view.tab==="summary"?runSummary(run,events,trace):view.tab==="console"?runConsole(run,rows):view.tab==="context"?runContext(run,trace,events,view):runNetwork(run,trace,view))+'</div></section>';
5995
+ +(isLiveRun(run)?'<span class="dt-live"><i class="pulse-dot"></i>Live</span>':"")+'<span class="dt-hint">1–7 views · j / k requests · / filter · Esc close</span></div><div class="dt-body dt-'+view.tab+'">'
5996
+ +(view.tab==="summary"?runSummary(run,events,trace):view.tab==="console"?runConsole(run,rows):view.tab==="context"?runContext(run,trace,events,view):view.tab==="composition"?compositionView(run,trace,events,view):view.tab==="queues"?queuesView(run,trace,events,view):view.tab==="chain"?chainView(run,events):runNetwork(run,trace,view))+'</div></section>';
5940
5997
  $("content").innerHTML=html;
5941
5998
  bindRun(id,run,trace,events);
5942
5999
  }
@@ -5962,12 +6019,13 @@ function bindRun(id,run,trace,events){
5962
6019
  if(rerun)rerun.onclick=()=>openRunDrawer(state.instances.find(x=>x.id===run.agentId)?.definitionId,run.agentId,typeof run.input?.message?.text==="string"?run.input.message.text:typeof run.input?.message==="string"?run.input.message:"");
5963
6020
  const exportButton=document.querySelector("[data-export-trace]");
5964
6021
  if(exportButton)exportButton.onclick=()=>{const blob=new Blob([JSON.stringify({run,events},null,2)+"\n"],{type:"application/json"});const url=URL.createObjectURL(blob);const link=document.createElement("a");link.href=url;link.download="run-"+run.id+".json";document.body.appendChild(link);link.click();link.remove();setTimeout(()=>URL.revokeObjectURL(url),1000);toast("Trace exported")};
6022
+ bindRunFoundry(id);
5965
6023
  dataLinks();
5966
6024
  }
5967
6025
  /* Keys on the run page: 1-4 switch views, j/k walk the requests, Esc closes the open one. */
5968
6026
  function runKeys(e){
5969
6027
  const current=route();if(current.section!=="runs"||!current.id)return false;
5970
- const index=["1","2","3","4"].indexOf(e.key);
6028
+ const index=["1","2","3","4","5","6","7"].indexOf(e.key);
5971
6029
  if(index>=0){setRunView({tab:RUN_TABS[index][0]});rerenderRun(current.id);return true}
5972
6030
  const view=runView();
5973
6031
  if(view.tab==="network"&&(e.key==="j"||e.key==="k"||e.key==="ArrowDown"||e.key==="ArrowUp")){
@@ -5977,6 +6035,7 @@ function runKeys(e){
5977
6035
  e.preventDefault();selectRunItem(current.id,next.dataset.netItem);return true;
5978
6036
  }
5979
6037
  if(e.key==="Escape"&&view.item){setRunView({item:"",pane:""});rerenderRun(current.id);return true}
6038
+ if(e.key==="Escape"&&view.tab==="queues"&&view.queue){setRunView({queue:""});rerenderRun(current.id);return true}
5980
6039
  return false;
5981
6040
  }
5982
6041
  `;
@@ -5984,6 +6043,7 @@ function runKeys(e){
5984
6043
  // src/dashboard-trace.ts
5985
6044
  var DASHBOARD_TRACE_SCRIPT = String.raw`
5986
6045
  function traceTime(iso){const t=Date.parse(iso);return Number.isFinite(t)?t:NaN}
6046
+ function tracePlural(n,word){return n+" "+word+(n===1?"":"s")}
5987
6047
  function traceType(event){return String(event.type||"").replace(/^agent\./,"")}
5988
6048
  function tracePreview(value,limit){
5989
6049
  let text;
@@ -5994,9 +6054,15 @@ function tracePreview(value,limit){
5994
6054
  }
5995
6055
  function buildRunTrace(events,run){
5996
6056
  const ordered=[...(events||[])].sort((a,b)=>(a.sequence??0)-(b.sequence??0));
5997
- const prompts={},toolSets={},requests={},calls={},items=[],pendingByName={};
6057
+ const prompts={},toolSets={},requests={},calls={},items=[],pendingByName={},turns=[];
5998
6058
  const totals={requests:0,tools:0,tokensIn:0,tokensOut:0,cacheRead:0,cacheWrite:0,modelMs:0,toolMs:0,errors:0};
5999
- let open=null,previous=null,first=NaN,last=NaN;
6059
+ let first=NaN,last=NaN;
6060
+ // One frame per agent: the run's own, then one per subagent running inside it.
6061
+ const frames=[{open:null,previous:null,subagent:null}];
6062
+ const frame=()=>frames[frames.length-1];
6063
+ let turn=null;
6064
+ const place=(item)=>{const f=frame();item.depth=frames.length-1;if(f.subagent)item.parent=f.subagent.key;if(turn)item.turn=turn.index;return item};
6065
+ const requestFor=(data)=>(data.request_id&&requests[data.request_id])||frame().open;
6000
6066
  const runStart=run?traceTime(run.startedAt||run.createdAt):NaN;
6001
6067
  const runEnd=run&&run.completedAt?traceTime(run.completedAt):NaN;
6002
6068
  const runningTool=()=>{for(let i=items.length-1;i>=0;i--){const item=items[i];if(item.kind==="tool"&&item.status==="pending"&&!item.via)return item}return null};
@@ -6016,15 +6082,18 @@ function buildRunTrace(events,run){
6016
6082
  let newFrom=messages.length-added.length;
6017
6083
  // A run's first request carries the conversation so far; what's new starts at the run's own message.
6018
6084
  if(!base)for(let i=messages.length-1;i>=0;i--){const m=messages[i];if(m&&m.sender==="user"&&!m.framework_context&&!(m.tool_results||[]).length&&!m.is_compaction){newFrom=i;break}}
6019
- const initiator=data.purpose==="compaction"?{label:"compaction"}:previous&&previous.calls.length?{label:"after "+[...new Set(previous.calls.map(id=>calls[id]&&calls[id].name).filter(Boolean))].join(", "),key:previous.key}:previous?{label:"continues #"+previous.index,key:previous.key}:{label:"run input"};
6085
+ const f=frame();const previous=f.previous;
6086
+ const initiator=data.purpose==="compaction"?{label:"compaction"}:previous&&previous.calls.length?{label:"after "+[...new Set(previous.calls.map(id=>calls[id]&&calls[id].name).filter(Boolean))].join(", "),key:previous.key}:previous?{label:"continues #"+previous.index,key:previous.key}:f.subagent?{label:"subagent "+f.subagent.name,key:f.subagent.key}:turn&&turn.trigger!=="request"?{label:turn.trigger==="events"?"event wake":"resumed",key:"turn:"+turn.index}:{label:"run input"};
6020
6087
  const item={kind:"model",key:"m:"+data.request_id,id:data.request_id,index:++totals.requests,name:"#"+(totals.requests)+" "+(data.purpose==="compaction"?"compaction":"request"),model:data.model||"",purpose:data.purpose||"turn",status:"pending",startAt:at,endAt:NaN,durationMs:NaN,sequence:event.sequence,request:data,end:null,promptHash:data.system_prompt&&data.system_prompt.hash,promptChars:data.system_prompt&&data.system_prompt.chars,toolsHash:data.tools&&data.tools.hash,toolNames:(data.tools&&data.tools.names)||[],messages,newFrom,context:data.context||[],response:[],calls:[],initiator,events:[event]};
6021
- requests[data.request_id]=item;items.push(item);open=item;previous=item;continue;
6088
+ place(item);requests[data.request_id]=item;items.push(item);f.open=item;f.previous=item;continue;
6022
6089
  }
6023
6090
  if(type==="model_request_end"){
6024
6091
  const item=requests[data.request_id];if(!item)continue;
6025
6092
  item.end=data;item.events.push(event);item.status=data.status||"success";item.endAt=at;
6026
6093
  item.durationMs=Number.isFinite(data.duration_ms)?data.duration_ms:at-item.startAt;
6027
6094
  if(Number.isFinite(data.duration_ms)&&Number.isFinite(at))item.startAt=at-data.duration_ms;
6095
+ // Time to first token: waiting on the model, then streaming its answer.
6096
+ if(Number.isFinite(item.firstTokenAt))item.ttftMs=Math.max(0,Math.min(item.durationMs,item.firstTokenAt-item.startAt));
6028
6097
  item.tokensIn=data.tokens_in;item.tokensOut=data.tokens_out;item.cacheRead=data.cache_read_input_tokens;item.cacheWrite=data.cache_creation_input_tokens;
6029
6098
  item.response=data.response||[];item.error=data.error;
6030
6099
  totals.tokensIn+=data.tokens_in||0;totals.tokensOut+=data.tokens_out||0;totals.cacheRead+=data.cache_read_input_tokens||0;totals.cacheWrite+=data.cache_creation_input_tokens||0;
@@ -6034,38 +6103,68 @@ function buildRunTrace(events,run){
6034
6103
  if(!call.id)continue;
6035
6104
  item.calls.push(call.id);calls[call.id]=calls[call.id]||{name:call.tool_name,request:item};
6036
6105
  // Adapters that don't stream tool_use: the call starts when the response arrives.
6037
- if(!calls[call.id].item)calls[call.id].item=addTool({kind:"tool",key:"t:"+call.id,id:call.id,name:call.tool_name,input:call.input_args,status:"pending",startAt:at,endAt:NaN,durationMs:NaN,sequence:event.sequence,request:item.key,initiator:{label:"#"+item.index+" "+(item.purpose==="compaction"?"compaction":"request"),key:item.key},events:[]});
6106
+ if(!calls[call.id].item)calls[call.id].item=addTool(place({kind:"tool",key:"t:"+call.id,id:call.id,name:call.tool_name,input:call.input_args,status:"pending",startAt:at,askedAt:at,endAt:NaN,durationMs:NaN,sequence:event.sequence,request:item.key,initiator:{label:"#"+item.index+" "+(item.purpose==="compaction"?"compaction":"request"),key:item.key},events:[]}));
6038
6107
  }
6039
- if(open===item)open=null;continue;
6108
+ for(const f of frames)if(f.open===item)f.open=null;
6109
+ continue;
6110
+ }
6111
+ if(type==="text_delta"){
6112
+ const target=requestFor(data);
6113
+ if(target){if(!Number.isFinite(target.firstTokenAt))target.firstTokenAt=at;target.streamed=(target.streamed||"")+String(data.text||"")}
6114
+ continue;
6040
6115
  }
6041
6116
  if(type==="model_response_complete"||type==="model_response"){
6042
- const target=open||previous;
6043
- if(target&&(target===open||!target.stopReason)){target.stopReason=data.stop_reason;target.events.push(event);continue}
6117
+ const f=frame();const target=(data.request_id&&requests[data.request_id])||f.open||f.previous;
6118
+ if(target&&(target===f.open||target.id===data.request_id||!target.stopReason)){target.stopReason=data.stop_reason;target.events.push(event);continue}
6044
6119
  if(!target){
6045
6120
  // A runtime without request events: the response is all there is.
6046
6121
  const item={kind:"model",key:"m:"+(event.id||event.sequence),id:String(event.id||event.sequence),index:++totals.requests,name:"#"+totals.requests+" response",model:"",purpose:"turn",status:"success",startAt:at,endAt:at,durationMs:NaN,sequence:event.sequence,request:null,end:null,messages:[],newFrom:0,context:[],response:[{sender:"agent",text:data.text||"",tool_calls:data.tool_calls}],calls:[],toolNames:[],initiator:{label:"run"},stopReason:data.stop_reason,tokensIn:data.tokens_in,tokensOut:data.tokens_out,events:[event],legacy:true};
6047
- totals.tokensIn+=data.tokens_in||0;totals.tokensOut+=data.tokens_out||0;items.push(item);
6122
+ totals.tokensIn+=data.tokens_in||0;totals.tokensOut+=data.tokens_out||0;items.push(place(item));
6048
6123
  }
6049
6124
  continue;
6050
6125
  }
6051
6126
  if(type==="tool_use"){
6052
- const request=open||previous;
6053
- const item=addTool({kind:"tool",key:"t:"+(data.id||event.id||event.sequence),id:data.id,name:data.name||"tool",input:data.input,status:"pending",startAt:at,endAt:NaN,durationMs:NaN,sequence:event.sequence,request:request?request.key:null,initiator:request?{label:"#"+request.index+" "+(request.purpose==="compaction"?"compaction":"request"),key:request.key}:{label:"model"},events:[event]});
6127
+ const request=requestFor(data)||frame().previous;
6128
+ if(request&&!Number.isFinite(request.firstTokenAt))request.firstTokenAt=at;
6129
+ const item=addTool(place({kind:"tool",key:"t:"+(data.id||event.id||event.sequence),id:data.id,name:data.name||"tool",input:data.input,status:"pending",startAt:at,askedAt:at,endAt:NaN,durationMs:NaN,sequence:event.sequence,request:request?request.key:null,initiator:request?{label:"#"+request.index+" "+(request.purpose==="compaction"?"compaction":"request"),key:request.key}:{label:"model"},events:[event]}));
6054
6130
  if(data.id){calls[data.id]=calls[data.id]||{name:item.name,request};calls[data.id].item=item}
6055
6131
  continue;
6056
6132
  }
6133
+ if(type==="tool_use_start"){
6134
+ // The call starts running now: after the calls ahead of it, its permission check and validation.
6135
+ const name=data.name||"tool";
6136
+ let item=data.id&&calls[data.id]&&calls[data.id].item;
6137
+ if(!item)item=(pendingByName[name]||[]).find(candidate=>candidate.status==="pending"&&!candidate.via&&!Number.isFinite(candidate.runAt));
6138
+ if(!item){item=addTool(place({kind:"tool",key:"t:"+(data.id||event.id||event.sequence),id:data.id,name,input:data.input,status:"pending",startAt:at,askedAt:at,endAt:NaN,durationMs:NaN,sequence:event.sequence,request:null,initiator:{label:"model"},events:[]}));if(data.id){calls[data.id]=calls[data.id]||{name};calls[data.id].item=item}}
6139
+ item.runAt=at;item.waitedMs=Number.isFinite(data.waited_ms)?data.waited_ms:undefined;item.events.push(event);
6140
+ continue;
6141
+ }
6057
6142
  if(type==="tool_use_result"){
6058
6143
  const id=data.id||data.call_id;const name=data.name||data.tool_name||"tool";
6059
6144
  let item=id&&calls[id]&&calls[id].item;
6060
6145
  const queue=pendingByName[name]||[];
6061
6146
  if(!item)item=queue.find(candidate=>candidate.status==="pending"&&!candidate.via);
6062
- if(!item)item=addTool({kind:"tool",key:"t:"+(id||event.id||event.sequence),id,name,input:undefined,status:"pending",startAt:at,endAt:NaN,durationMs:NaN,sequence:event.sequence,request:null,initiator:{label:"model"},events:[]});
6147
+ if(!item)item=addTool(place({kind:"tool",key:"t:"+(id||event.id||event.sequence),id,name,input:undefined,status:"pending",startAt:at,endAt:NaN,durationMs:NaN,sequence:event.sequence,request:null,initiator:{label:"model"},events:[]}));
6063
6148
  const index=queue.indexOf(item);if(index>=0)queue.splice(index,1);
6064
6149
  item.events.push(event);item.result=data.result||{};item.status=(data.result&&data.result.status)||"success";item.endAt=at;
6150
+ if(item.status==="error"&&/^Permission denied for tool/.test(String(item.result.message||"")))item.status="denied";
6065
6151
  item.durationMs=Number.isFinite(data.duration_ms)?data.duration_ms:at-item.startAt;
6066
6152
  if(Number.isFinite(data.duration_ms)&&Number.isFinite(at))item.startAt=at-data.duration_ms;
6153
+ // Asked for, then queued behind the calls ahead of it, then checked, then run.
6154
+ if(Number.isFinite(item.askedAt))item.queuedMs=Math.max(0,item.startAt-item.askedAt);
6155
+ if(Number.isFinite(item.runAt))item.runMs=Math.max(0,at-item.runAt);
6067
6156
  if(Number.isFinite(item.durationMs))totals.toolMs+=item.durationMs;
6068
- if(item.status==="error")totals.errors++;
6157
+ if(item.status==="error"||item.status==="denied")totals.errors++;
6158
+ continue;
6159
+ }
6160
+ if(type==="turn_start"){
6161
+ // A subagent's turns sit inside its parent's; only the run's own are listed.
6162
+ if(frames.length===1){turn={kind:"turn",key:"turn:"+(turns.length+1),index:turns.length+1,id:data.turn_id,trigger:data.trigger||"request",status:"pending",startAt:at,endAt:NaN,durationMs:NaN,events:[event]};turns.push(turn)}
6163
+ continue;
6164
+ }
6165
+ if(type==="turn_end"){
6166
+ const ended=turns.find(candidate=>candidate.id===data.turn_id);
6167
+ if(ended){ended.status=data.status||"success";ended.endAt=at;ended.durationMs=Number.isFinite(data.duration_ms)?data.duration_ms:at-ended.startAt;if(Number.isFinite(data.duration_ms))ended.startAt=at-data.duration_ms;ended.error=data.error;ended.events.push(event)}
6069
6168
  continue;
6070
6169
  }
6071
6170
  if(/^foundry\.approval\./.test(type)){
@@ -6076,20 +6175,31 @@ function buildRunTrace(events,run){
6076
6175
  }
6077
6176
  if(/^foundry\.repl\.programmatic-tool\./.test(type)){
6078
6177
  const name=data.tool||"tool";
6079
- if(type==="foundry.repl.programmatic-tool.started"){const parent=runningTool();addTool({kind:"tool",via:"repl",key:"p:"+(event.id||event.sequence),name,fn:data.function,status:"pending",startAt:at,endAt:NaN,durationMs:NaN,sequence:event.sequence,request:parent?parent.request:null,initiator:parent?{label:parent.name+" (REPL)",key:parent.key}:{label:"REPL"},events:[event]});continue}
6178
+ if(type==="foundry.repl.programmatic-tool.started"){const parent=runningTool();addTool(place({kind:"tool",via:"repl",key:"p:"+(event.id||event.sequence),name,fn:data.function,status:"pending",startAt:at,endAt:NaN,durationMs:NaN,sequence:event.sequence,request:parent?parent.request:null,initiator:parent?{label:parent.name+" (REPL)",key:parent.key}:{label:"REPL"},events:[event]}));continue}
6080
6179
  const item=[...items].reverse().find(candidate=>candidate.via==="repl"&&candidate.name===name&&candidate.status==="pending");
6081
6180
  if(item){item.events.push(event);item.endAt=at;item.durationMs=data.durationMs;item.status=type.endsWith("completed")?"success":type.endsWith("failed")?"error":"denied";if(Number.isFinite(data.durationMs)&&Number.isFinite(at))item.startAt=at-data.durationMs;if(item.status!=="success")totals.errors++}
6082
6181
  else if(!type.endsWith("completed")){totals.tools++;totals.errors++;items.push({kind:"tool",via:"repl",key:"p:"+(event.id||event.sequence),name,fn:data.function,status:type.split(".").pop(),startAt:at,endAt:at,durationMs:0,sequence:event.sequence,initiator:{label:"REPL"},result:{status:"error",message:data.reason},events:[event]})}
6083
6182
  continue;
6084
6183
  }
6085
- if(type==="subagent_invoked"){items.push({kind:"subagent",key:"s:"+(event.id||event.sequence),name:data.name,prompt:data.prompt,status:"pending",startAt:at,endAt:NaN,durationMs:NaN,sequence:event.sequence,initiator:{label:"subagent"},events:[event]});continue}
6086
- if(type==="subagent_completed"){const item=[...items].reverse().find(candidate=>candidate.kind==="subagent"&&candidate.name===data.name&&candidate.status==="pending");if(item){item.status=data.status||"success";item.endAt=at;item.durationMs=at-item.startAt;item.message=data.message;item.events.push(event)}continue}
6184
+ if(type==="subagent_invoked"){
6185
+ const call=data.call_id&&calls[data.call_id]&&calls[data.call_id].item;
6186
+ const item=place({kind:"subagent",key:"s:"+(data.call_id||event.id||event.sequence),call:call?call.key:undefined,name:data.name,prompt:data.prompt,status:"pending",startAt:at,endAt:NaN,durationMs:NaN,sequence:event.sequence,initiator:call?{label:call.name,key:call.key}:{label:"subagent"},events:[event]});
6187
+ items.push(item);frames.push({open:null,previous:null,subagent:item});continue;
6188
+ }
6189
+ if(type==="subagent_completed"){
6190
+ const index=frames.findLastIndex(candidate=>candidate.subagent&&(data.call_id?candidate.subagent.key==="s:"+data.call_id:candidate.subagent.name===data.name));
6191
+ const item=index>0?frames[index].subagent:[...items].reverse().find(candidate=>candidate.kind==="subagent"&&candidate.name===data.name&&candidate.status==="pending");
6192
+ if(index>0)frames.splice(index);
6193
+ if(item){item.status=data.status||"success";item.endAt=at;item.durationMs=at-item.startAt;item.message=data.message;item.events.push(event)}
6194
+ continue;
6195
+ }
6087
6196
  }
6088
6197
  const start=Number.isFinite(runStart)?Math.min(runStart,Number.isFinite(first)?first:runStart):first;
6089
6198
  const live=run&&(run.status==="running"||run.status==="pending");
6090
6199
  const end=live?Math.max(Date.now(),Number.isFinite(last)?last:0):Number.isFinite(runEnd)?Math.max(runEnd,Number.isFinite(last)?last:runEnd):last;
6091
6200
  for(const item of items){if(item.kind==="model"){item.systemPrompt=prompts[item.promptHash];item.tools=toolSets[item.toolsHash]}}
6092
- return{items,prompts,toolSets,totals,start,end};
6201
+ for(const item of turns)if(item.status==="pending"&&!live&&Number.isFinite(end)){item.endAt=end;item.durationMs=end-item.startAt}
6202
+ return{items,turns,prompts,toolSets,totals,start,end};
6093
6203
  }
6094
6204
 
6095
6205
  /* Console levels follow DevTools: errors, warnings, info, and verbose detail hidden by default. */
@@ -6113,6 +6223,25 @@ function describeEvent(event){
6113
6223
  if(type==="model_response_complete"||type==="model_response")return level("verbose","Response"+(data.stop_reason?" ("+data.stop_reason+")":"")+": "+tracePreview(data.text||"",120));
6114
6224
  if(type==="text_delta")return level("verbose","Streamed text: "+tracePreview(data.text,160));
6115
6225
  if(type==="tool_use")return level("info","Tool call "+data.name+"("+tracePreview(data.input,100)+")");
6226
+ if(type==="tool_use_start")return level("verbose",data.name+" started"+(data.waited_ms>=1000?" after "+data.waited_ms+"ms of permission checks":""),"tool");
6227
+ if(type==="turn_start")return level("info",data.trigger==="events"?"Turn started: events woke the agent":data.trigger==="resume"?"Turn resumed at its tool step":"Turn started","run");
6228
+ if(type==="turn_end"){
6229
+ const time=Number.isFinite(data.duration_ms)?" after "+data.duration_ms+"ms":"";
6230
+ if(data.status==="error")return level("error","Turn failed"+time+(data.error?": "+tracePreview(data.error,140):""),"run");
6231
+ if(data.status==="aborted")return level("warn","Turn aborted"+time,"run");
6232
+ if(data.status==="suspended")return level("warn","Turn suspended"+time+": a tool call is waiting for a decision","run");
6233
+ return level("info","Turn finished"+time,"run");
6234
+ }
6235
+ if(type==="inbox_injected")return level("info","Inbox: "+(data.ids||[]).length+" resolved item"+((data.ids||[]).length===1?"":"s")+" joined the conversation "+(data.phase==="loop"?"between tool steps":"before the request")+((data.tags||[]).length?" ("+data.tags.join(", ")+")":""),"inbox");
6236
+ if(type==="event_received"){
6237
+ const what=(data.kind?data.kind+" from ":"")+data.source;const preview=data.preview?": "+tracePreview(data.preview,120):"";
6238
+ if(data.disposition==="dropped")return level("warn","Event dropped: "+what+preview,"queue");
6239
+ if(data.disposition==="duplicate")return level("verbose","Duplicate event ignored: "+what,"queue");
6240
+ return level("info","Event "+({queued:"queued",woke:"woke the agent",deferred:"deferred"}[data.disposition]||data.disposition)+": "+what+preview,"queue");
6241
+ }
6242
+ if(type==="event_injected")return level("info",tracePlural((data.ids||[]).length,"event")+" joined the conversation "+({loop:"between tool steps",request:"before the request",wake:"as the turn's message"}[data.phase]||""),"queue");
6243
+ if(type==="event_dropped")return level("warn","Event "+data.id+" dropped ("+data.reason+")","queue");
6244
+ if(type==="event_wake_failed")return level("error","A turn for "+tracePlural((data.ids||[]).length,"event")+" failed: "+tracePreview(data.message,140),"queue");
6116
6245
  if(type==="tool_use_result"){
6117
6246
  const status=data.result&&data.result.status;const name=data.name||data.tool_name;const time=Number.isFinite(data.duration_ms)?" in "+data.duration_ms+"ms":"";
6118
6247
  if(status==="error")return level("error",name+" failed"+time+": "+tracePreview(data.result.message||data.result.data,140));
@@ -6138,13 +6267,18 @@ function describeEvent(event){
6138
6267
  return level("verbose",type);
6139
6268
  }
6140
6269
  function buildConsole(events){
6141
- const rows=[];let stream=null;
6270
+ // A streamed reply is one line: chunks of one request join, wherever they arrive.
6271
+ const rows=[];let stream=null;const streams={};
6142
6272
  for(const event of [...(events||[])].sort((a,b)=>(a.sequence??0)-(b.sequence??0))){
6143
6273
  if(traceType(event)==="text_delta"){
6144
- if(!stream){stream={key:"c:"+(event.id||event.sequence),level:"verbose",source:"model",timestamp:event.timestamp,type:"text_delta",text:"",chunks:0,events:[]};rows.push(stream)}
6145
- stream.text+=String((event.data&&event.data.text)||"");stream.chunks++;stream.events.push(event);
6146
- stream.message="Streamed text ("+stream.chunks+" chunk"+(stream.chunks===1?"":"s")+"): "+tracePreview(stream.text,160);
6147
- stream.data={text:stream.text,chunks:stream.chunks};
6274
+ const request=event.data&&event.data.request_id;
6275
+ const current=request?streams[request]:stream;
6276
+ const row=current||{key:"c:"+(event.id||event.sequence),level:"verbose",source:"model",timestamp:event.timestamp,type:"text_delta",text:"",chunks:0,events:[]};
6277
+ if(!current){rows.push(row);if(request)streams[request]=row}
6278
+ stream=row;
6279
+ row.text+=String((event.data&&event.data.text)||"");row.chunks++;row.events.push(event);
6280
+ row.message="Streamed text ("+row.chunks+" chunk"+(row.chunks===1?"":"s")+"): "+tracePreview(row.text,160);
6281
+ row.data={text:row.text,chunks:row.chunks,...(request?{request_id:request}:{})};
6148
6282
  continue;
6149
6283
  }
6150
6284
  stream=null;
@@ -6155,6 +6289,366 @@ function buildConsole(events){
6155
6289
  }
6156
6290
  `;
6157
6291
 
6292
+ // src/dashboard-foundry.ts
6293
+ var DASHBOARD_FOUNDRY_SCRIPT = String.raw`
6294
+ function foundryAt(event){const t=Date.parse(event&&event.timestamp);return Number.isFinite(t)?t:NaN}
6295
+ function foundrySorted(events){return[...(events||[])].sort((a,b)=>(a.sequence??0)-(b.sequence??0))}
6296
+
6297
+ /* ---- Composition ---- */
6298
+ const COMPOSITION_LEGACY_STEPS={"foundry.application.transmission-tools.mounted":["transmissions","App transmissions"],"foundry.working-environment.mounted":["workbench","Working environment"]};
6299
+ function buildComposition(events){
6300
+ const ordered=foundrySorted(events);
6301
+ const result={composed:null,resolves:[],steps:[],tools:[],origins:{},apps:[],installations:[],playbooks:[],schedules:[],scheduled:[],delegates:[],durableSubagents:[],mesh:null,memory:[],layers:[],subscribers:[],hooks:[],skills:[],subagents:[],calls:[],workingEnvironment:null,repl:null,inboxes:null,delegation:null,startAt:NaN,endAt:NaN,durationMs:NaN,legacy:true};
6302
+ const open={};
6303
+ for(const event of ordered){
6304
+ const type=traceType(event);const data=event.data||{};const at=foundryAt(event);
6305
+ if(type==="foundry.assembly.resolve.start"){if(!(result.startAt<=at))result.startAt=at;open[data.field]={field:data.field,startAt:at,endAt:NaN,durationMs:NaN};result.resolves.push(open[data.field]);continue}
6306
+ if(type==="foundry.assembly.resolve.complete"){const item=open[data.field];if(item){item.endAt=at;item.durationMs=at-item.startAt;if(data.count!==undefined)item.count=data.count;delete open[data.field]}continue}
6307
+ if(type==="foundry.assembly.composed"){
6308
+ result.composed=data;result.legacy=false;result.endAt=at;
6309
+ if(Number.isFinite(data.durationMs)&&!(result.startAt<=at-data.durationMs))result.startAt=at-data.durationMs;
6310
+ result.steps=(data.steps||[]).map(step=>({...step,tools:[...(step.tools||[])]}));
6311
+ result.tools=[...(data.tools||[])];result.installations=data.installations||[];
6312
+ result.apps=data.apps||[];result.playbooks=data.playbooks||[];result.schedules=data.schedules||[];
6313
+ result.delegates=data.delegates||[];result.durableSubagents=data.durableSubagents||[];result.mesh=data.mesh||null;
6314
+ result.hooks=data.hooks||[];result.skills=data.skills||[];result.subagents=data.subagents||[];result.calls=data.calls||[];
6315
+ result.delegation=data.delegation||null;
6316
+ if(data.repl&&!result.repl)result.repl={};
6317
+ if(data.workingEnvironment&&!result.workingEnvironment)result.workingEnvironment={};
6318
+ continue;
6319
+ }
6320
+ if(type==="foundry.definition.memory.mounted"){result.memory.push(data.id);continue}
6321
+ if(type==="foundry.layer.mounted"){result.layers.push(data.id);continue}
6322
+ if(type==="foundry.subscriber.mounted"){result.subscribers.push(data.id);continue}
6323
+ if(type==="foundry.working-environment.mounted"){result.workingEnvironment={...(result.workingEnvironment||{}),...data}}
6324
+ if(type==="foundry.repl.mounted"){result.repl={...(result.repl||{}),...data};continue}
6325
+ if(type==="foundry.definition.inboxes.loaded"){result.inboxes=data;continue}
6326
+ if(type==="scheduled-action.created"){result.scheduled.push({id:data.commandId,recurring:data.recurring,nextRunAt:data.nextRunAt});continue}
6327
+ if(result.legacy){
6328
+ // Runs recorded before foundry.assembly.composed: what the mount events say.
6329
+ if(COMPOSITION_LEGACY_STEPS[type]&&(data.tools||[]).length){const step=COMPOSITION_LEGACY_STEPS[type];result.steps.push({step:step[0],label:step[1],tools:[...data.tools],ms:NaN})}
6330
+ if(type==="foundry.application.mcp.mounted")result.steps.push({step:"mcp",label:data.id,id:data.id,tools:[...(data.tools||[])],ms:NaN});
6331
+ if(type==="foundry.installation.completed"){result.installations.push({kind:data.kind,id:data.id});result.steps.push({step:"installation",label:data.id,kind:data.kind,id:data.id,tools:[],ms:NaN})}
6332
+ if(type==="foundry.definition.playbooks.composed")result.playbooks=(data.names||[]).map(name=>({name}));
6333
+ if(type==="foundry.definition.schedules.loaded")result.schedules=(data.names||[]).map(name=>({name}));
6334
+ if(type==="foundry.definition.delegates.loaded")result.delegates=(data.delegates||[]).map(agent=>({agent}));
6335
+ if(type==="foundry.mesh.mounted")result.mesh={hosted:true,threads:data.open,...(data.thread?{thread:data.thread}:{})};
6336
+ }
6337
+ if(type==="turn_start"&&!Number.isFinite(result.endAt))result.endAt=at;
6338
+ }
6339
+ if(Number.isFinite(result.startAt)&&Number.isFinite(result.endAt))result.durationMs=Math.max(0,result.endAt-result.startAt);
6340
+ for(const step of result.steps)for(const name of step.tools)if(!result.origins[name])result.origins[name]={step:step.step,label:step.label};
6341
+ if(!result.tools.length)result.tools=Object.keys(result.origins);
6342
+ return result;
6343
+ }
6344
+
6345
+ /* ---- Queues: what crossed the run's boundary ---- */
6346
+ function queueChannel(kind,source){
6347
+ const k=String(kind||"");
6348
+ if(k==="transmission"||/^foundry:route:/.test(String(source||"")))return"transmission";
6349
+ if(k==="agent-message")return"agent message";
6350
+ if(k==="mesh")return"mesh";
6351
+ if(/^delegation|^reply$/.test(k))return"delegation";
6352
+ if(/approval/.test(k))return"approval";
6353
+ return k||"event";
6354
+ }
6355
+ const QUEUE_PHASE={wake:"as the turn's message",request:"before the request",loop:"between tool steps"};
6356
+ function queueCommand(data){
6357
+ const type=data.type||"command";
6358
+ const timing=data.timing?(data.timing.kind==="at"?"at "+data.timing.at:data.timing.kind==="every"?"every "+Math.round(data.timing.intervalMs/1000)+"s":data.timing.kind==="cron"?data.timing.expression+" ("+data.timing.timezone+")":""):"";
6359
+ if(type==="transmit")return{channel:"transmission",title:"Transmission "+(data.routeId||data.transmissionId||""),preview:tracePreview(data.payload,160)};
6360
+ if(type==="spawn")return{channel:"spawn",title:"Spawn "+(data.definitionId||""),preview:tracePreview(data.message,160)};
6361
+ if(type==="schedule")return{channel:"schedule",title:"Schedule "+timing,preview:tracePreview(data.message,160)};
6362
+ if(/^schedule\./.test(type))return{channel:"schedule",title:"Schedule "+type.slice(9)+" "+(data.activationId||""),preview:data.patch?tracePreview(data.patch,160):""};
6363
+ if(type==="sleep")return{channel:"sleep",title:"Sleep until "+(data.wakeAt||""),preview:tracePreview(data.message,160)};
6364
+ if(type==="background")return{channel:"background",title:"Background run",preview:tracePreview(data.message,160)};
6365
+ if(type==="delegate")return{channel:"delegation",title:"Delegate to "+data.to,preview:tracePreview(data.task,160)};
6366
+ if(type==="delegate.reply")return{channel:"delegation",title:"Reply to worker",preview:tracePreview(data.message,160)};
6367
+ if(type==="delegate.ask")return{channel:"delegation",title:"Ask the delegator",preview:tracePreview(data.question,160)};
6368
+ if(type==="agent.message")return{channel:"agent message",title:"Message "+data.to,preview:tracePreview(data.message,160)};
6369
+ if(type==="mesh.send")return{channel:"mesh",title:"Mesh message to "+((data.message&&data.message.to)||""),preview:tracePreview(data.message&&(data.message.text||data.message.body||data.message),160)};
6370
+ if(/^mesh\./.test(type))return{channel:"mesh",title:"Mesh "+type.slice(5),preview:""};
6371
+ return{channel:"command",title:type,preview:""};
6372
+ }
6373
+ function buildQueues(events,run,trace){
6374
+ const ordered=foundrySorted(events);
6375
+ const rows=[];const byEvent={};const byCommand={};const byDelegation={};const approvals={};
6376
+ const models=((trace&&trace.items)||[]).filter(item=>item.kind==="model"&&!item.legacy);
6377
+ const seenAfter=(sequence)=>models.find(item=>(item.sequence??0)>sequence)||null;
6378
+ const source=run&&run.input&&run.input.source;
6379
+ if(run){
6380
+ const message=run.input&&run.input.message;
6381
+ const text=typeof message==="string"?message:Array.isArray(message)?message.filter(part=>part&&part.type==="text").map(part=>part.text).join(" "):"";
6382
+ const kind=(source&&source.kind)||"direct";
6383
+ const delegationTitle=source&&/^result:/.test(String(source.id||""))?"Delegation result":source&&/^delegation_/.test(String(source.id||""))?"Delegated task":"Delegation update";
6384
+ const titles={direct:"Message",transmission:"Transmission "+((source&&source.id)||""),activation:"Schedule or sleep fired",spawn:"Spawned",background:"Background run",delegation:delegationTitle,["agent-message"]:"Agent message",mesh:"Mesh thread"};
6385
+ const first=models[0]||null;
6386
+ rows.push({key:"q:trigger",dir:"in",channel:kind==="direct"?"message":queueChannel(kind),title:titles[kind]||kind,preview:tracePreview(text,200),status:"started the run",at:Date.parse(run.createdAt),seenBy:first?first.key:null,detail:{source:source||{kind:"direct"},...(source&&source.eventId?{eventId:source.eventId}:{}),...(source&&source.threadKey?{threadKey:source.threadKey}:{})},events:[]});
6387
+ }
6388
+ let turnSeen=false;
6389
+ for(const event of ordered){
6390
+ const type=traceType(event);const data=event.data||{};const at=foundryAt(event);
6391
+ if(type==="turn_start")turnSeen=true;
6392
+ if(type==="event_received"){
6393
+ const row={key:"q:e:"+data.id,dir:"in",channel:queueChannel(data.kind,data.source),title:data.source,preview:data.preview||"",status:data.disposition,at,seenBy:null,detail:{id:data.id,source:data.source,kind:data.kind,disposition:data.disposition},events:[event]};
6394
+ // The first delivery of an event turn is what started the run.
6395
+ if(!turnSeen&&rows[0]&&rows[0].key==="q:trigger"&&!rows[0].event&&source&&source.kind!=="direct"){rows[0].event=data.id;rows[0].events.push(event);byEvent[data.id]=rows[0];continue}
6396
+ byEvent[data.id]=row;rows.push(row);continue;
6397
+ }
6398
+ if(type==="event_injected"){
6399
+ for(const id of data.ids||[]){const row=byEvent[id];if(!row)continue;const seen=seenAfter(event.sequence??0);if(row.key!=="q:trigger")row.status="joined "+(QUEUE_PHASE[data.phase]||data.phase);row.injectedAt=at;row.seenBy=seen?seen.key:row.seenBy;row.events.push(event)}
6400
+ continue;
6401
+ }
6402
+ if(type==="event_dropped"){const row=byEvent[data.id];if(row){row.status="dropped ("+data.reason+")";row.events.push(event)}continue}
6403
+ if(type==="inbox_injected"){
6404
+ const seen=seenAfter(event.sequence??0);
6405
+ rows.push({key:"q:i:"+(event.id||event.sequence),dir:"in",channel:"inbox",title:"Resolved: "+(data.tags||[]).join(", "),preview:(data.ids||[]).join(", "),status:"joined "+(QUEUE_PHASE[data.phase]||data.phase),at,seenBy:seen?seen.key:null,detail:data,events:[event]});continue;
6406
+ }
6407
+ if(type==="tool_use"&&data.name==="glove_post_to_inbox"){
6408
+ const input=data.input||{};
6409
+ rows.push({key:"q:p:"+(data.id||event.sequence),dir:"out",channel:"inbox",title:"Posted: "+(input.tag||"item"),preview:tracePreview(input.request,200),status:input.blocking?"posted, blocking":"posted",at,call:data.id?"t:"+data.id:null,detail:input,events:[event]});continue;
6410
+ }
6411
+ if(type==="foundry.core.command"){
6412
+ if(data.type==="playbook.sync"||data.type==="schedule.sync")continue;
6413
+ const described=queueCommand(data);
6414
+ const row={key:"q:c:"+(data.id||event.sequence),dir:"out",...described,status:"sent",at,detail:data,events:[event]};
6415
+ if(data.id)byCommand[data.id]=row;if(data.delegationId)byDelegation[data.delegationId]=row;
6416
+ rows.push(row);continue;
6417
+ }
6418
+ if(type==="core.command.accepted"){const row=byCommand[data.commandId];if(row){row.status="accepted";if(data.childRunId)row.childRunId=data.childRunId;row.events.push(event)}continue}
6419
+ if(type==="core.command.failed"){const row=byCommand[data.command&&data.command.id];if(row){row.status="failed";row.error=data.error;row.events.push(event)}continue}
6420
+ if(type==="scheduled-action.created"){const row=byCommand[data.commandId];if(row){row.status="scheduled";row.nextRunAt=data.nextRunAt;row.events.push(event)}continue}
6421
+ if(type==="transmission.outbound.delivered"){const row=byCommand[data.commandId];if(row){row.status="delivered";row.events.push(event)}else rows.push({key:"q:o:"+(event.id||event.sequence),dir:"out",channel:"transmission",title:"Transmission "+(data.routeId||""),preview:"",status:"delivered",at,detail:data,events:[event]});continue}
6422
+ if(type==="delegation.started"){const row=byDelegation[data.delegationId];if(row){row.status="started";row.childRunId=data.workerRunId;row.events.push(event)}continue}
6423
+ if(type==="delegation.question"||type==="delegation.replied"){const row=[...rows].reverse().find(candidate=>candidate.dir==="out"&&candidate.detail&&candidate.detail.delegationId===data.delegationId&&candidate.status==="sent");if(row){row.status="delivered";row.events.push(event)}continue}
6424
+ if(type==="delegation.delivered"&&data.mode==="live"){
6425
+ // Answers and updates handed to this run while it ran: a waiting question is answered.
6426
+ const asked=[...rows].reverse().find(candidate=>candidate.dir==="out"&&candidate.detail&&candidate.detail.type==="delegate.ask"&&candidate.status!=="answered");
6427
+ if(asked){asked.status="answered";asked.events.push(event)}
6428
+ rows.push({key:"q:l:"+(event.id||event.sequence),dir:"in",channel:/^delegation_/.test(String(data.conversationId||""))?"delegation":"mailbox",title:asked?"Answer to: "+tracePreview(asked.preview,60):"Delivered while running",preview:tracePlural(data.count||1,"delivery")+" handed to the live run",status:"delivered",at,seenBy:null,detail:data,events:[event]});
6429
+ continue;
6430
+ }
6431
+ if(type==="foundry.approval.requested"){const row={key:"q:a:"+data.id,dir:"out",channel:"approval",title:"Approval for "+data.toolName,preview:tracePreview(data.toolInput,160),status:"waiting",at,detail:data,events:[event]};approvals[data.id]=row;rows.push(row);continue}
6432
+ if(type==="foundry.approval.settled"||type==="foundry.approval.failed"||type==="foundry.approval.unavailable"){
6433
+ const row=approvals[data.approvalId]||[...rows].reverse().find(candidate=>candidate.channel==="approval"&&candidate.detail.toolName===data.toolName&&candidate.status==="waiting");
6434
+ if(row){row.status=data.status||type.split(".").pop();row.settledAt=at;row.events.push(event)}continue;
6435
+ }
6436
+ }
6437
+ return rows.sort((a,b)=>(Number.isFinite(a.at)?a.at:0)-(Number.isFinite(b.at)?b.at:0));
6438
+ }
6439
+
6440
+ /* ---- Call chain: the run among the runs it came from and started ---- */
6441
+ const CHAIN_COMMANDS={spawn:"spawned",schedule:"scheduled",sleep:"woke from sleep",background:"background run",["agent.message"]:"messaged"};
6442
+ function buildRunChain(runId,runs,events){
6443
+ const byId={};for(const run of runs||[])byId[run.id]=run;
6444
+ const parents={};const children={};const seen=new Set();
6445
+ const link=(from,to,label,detail)=>{
6446
+ if(!from||!to||from===to)return;const key=from+">"+to+">"+label;if(seen.has(key))return;seen.add(key);
6447
+ const edge={from,to,label,...(detail?{detail}:{})};(children[from]=children[from]||[]).push(edge);(parents[to]=parents[to]||[]).push(edge);
6448
+ };
6449
+ const delegations={};const commands={};const replies=[];
6450
+ for(const event of foundrySorted(events)){
6451
+ const type=traceType(event);const data=event.data||{};
6452
+ if(type==="foundry.core.command"&&data.id){commands[data.id]={runId:event.runId,type:data.type};continue}
6453
+ if(type==="delegation.started"){delegations[data.delegationId]={to:data.to,runId:event.runId,workerRunId:data.workerRunId};link(event.runId,data.workerRunId,"delegated to "+data.to,data.delegationId);continue}
6454
+ if(type==="delegation.replied"){replies.push({from:event.runId,delegationId:data.delegationId});continue}
6455
+ if(type==="core.command.accepted"){link(event.runId,data.childRunId,CHAIN_COMMANDS[data.type]||data.type||"started");continue}
6456
+ if(type==="run.steered"){link(data.fromRunId,data.toRunId||event.runId,"steered");continue}
6457
+ }
6458
+ // Answers reach a worker that is still running.
6459
+ for(const reply of replies){const delegation=delegations[reply.delegationId];if(delegation)link(reply.from,delegation.workerRunId,"replied",reply.delegationId)}
6460
+ // What a run hears back arrives as a run of its own, named by what it answers.
6461
+ const COMMAND_EDGES={["delegate.ask"]:"asked",["delegate.reply"]:"replied",["agent.message"]:"messaged"};
6462
+ for(const run of runs||[]){
6463
+ const source=run.input&&run.input.source;
6464
+ if(!source||!source.id||source.kind==="direct")continue;
6465
+ const id=String(source.id);
6466
+ if(/^result:/.test(id)){link(id.slice(7),run.id,"reported back");continue}
6467
+ if(commands[id]){link(commands[id].runId,run.id,COMMAND_EDGES[commands[id].type]||commands[id].type);continue}
6468
+ const delegation=source.kind==="delegation"&&delegations[id];
6469
+ if(delegation&&run.id!==delegation.workerRunId&&run.agent!==delegation.to&&delegation.workerRunId)link(delegation.workerRunId,run.id,"reported back",id);
6470
+ }
6471
+ const node=(id,edge)=>{const run=byId[id];return{id,run:run||null,edge:edge||null}};
6472
+ const ancestors=[];const visited=new Set([runId]);let current=runId;
6473
+ while(parents[current]&&parents[current].length&&ancestors.length<12){const edge=parents[current][0];if(visited.has(edge.from))break;visited.add(edge.from);ancestors.unshift(node(edge.from,edge));current=edge.from}
6474
+ const top=ancestors.length?ancestors[0].run:byId[runId];
6475
+ const origin=top&&top.input&&top.input.source&&top.input.source.kind!=="direct"?{kind:top.input.source.kind,id:top.input.source.id,provider:top.input.source.provider,eventId:top.input.source.eventId,threadKey:top.input.source.threadKey}:null;
6476
+ const started=(id)=>{const run=byId[id];const at=run?Date.parse(run.createdAt):NaN;return Number.isFinite(at)?at:Infinity};
6477
+ const descend=(id,depth,path)=>[...(children[id]||[])].sort((a,b)=>started(a.to)-started(b.to)).map(edge=>{const child=node(edge.to,edge);child.children=depth<4&&!path.has(edge.to)?descend(edge.to,depth+1,new Set([...path,edge.to])):[];return child});
6478
+ const self=node(runId,parents[runId]&&parents[runId][0]);
6479
+ self.children=descend(runId,0,new Set([runId]));
6480
+ return{origin,ancestors,self,parents:parents[runId]||[]};
6481
+ }
6482
+ `;
6483
+
6484
+ // src/dashboard-run-foundry.ts
6485
+ var DASHBOARD_RUN_FOUNDRY_SCRIPT = String.raw`
6486
+ /* ---- Composition ---- */
6487
+ const COMPOSITION_NODES=[["Assembly","timeline","Timeline"],["Assembly","tools","Tools by origin"],["Capabilities","apps","Apps and installations"],["Capabilities","workbench","Working environment and REPL"],["Automation","playbooks","Playbooks"],["Automation","schedules","Schedules"],["Agents","delegates","Delegates and workers"],["Agents","mesh","Mesh"],["Extensions","extensions","Memory, layers and subscribers"],["Extensions","surface","Hooks, skills, subagents and calls"]];
6488
+ function toolCallCounts(trace){const counts={};for(const item of trace.items)if(item.kind==="tool"&&!item.via)counts[item.name]=(counts[item.name]||0)+1;return counts}
6489
+ function toolChip(name,counts,extra){
6490
+ const calls=counts[name]||0;
6491
+ return'<button type="button" class="cap tool-chip'+(calls?" called":"")+'" data-tool-filter="'+attr(name)+'" title="'+attr(calls?"Show its "+count(calls,"call")+" in Network":"Not called in this run")+'">'+esc(name)+(extra||"")+(calls?'<small>'+calls+'</small>':"")+'</button>';
6492
+ }
6493
+ function compositionTimeline(comp){
6494
+ const rows=[];
6495
+ for(const item of comp.resolves)rows.push({name:item.field,note:"resolve"+(item.count!==undefined?" · "+count(item.count,"item"):""),startAt:item.startAt,durationMs:item.durationMs,kind:"resolve"});
6496
+ if(comp.composed&&Number.isFinite(comp.endAt)){
6497
+ let at=comp.endAt-(comp.composed.durationMs||0);
6498
+ for(const step of comp.steps){rows.push({name:step.label,note:step.tools.length?count(step.tools.length,"tool"):step.kind||"",startAt:at,durationMs:step.ms,kind:step.step});at+=step.ms||0}
6499
+ }
6500
+ if(!rows.length)return empty("No assembly recorded","Runs record their assembly as they start. Runs from before Foundry recorded it, or handler-only runs, have none.");
6501
+ const start=Math.min(...rows.map(row=>row.startAt).filter(Number.isFinite));const end=Math.max(...rows.map(row=>row.startAt+(row.durationMs||0)).filter(Number.isFinite),comp.endAt||0);const span=Math.max(1,end-start);
6502
+ return'<p class="dt-note">How Foundry put this run’s agent together before its first turn'+(Number.isFinite(comp.durationMs)?", in "+esc(durationText(comp.durationMs)):"")+'. Definition fields resolve in parallel, then each step mounts its part.</p>'
6503
+ +'<table class="net-table comp-table"><thead><tr><th>Step</th><th></th><th class="c-time">Time</th><th class="c-wf">Waterfall</th></tr></thead><tbody>'
6504
+ +rows.map(row=>{const left=Number.isFinite(row.startAt)?(row.startAt-start)/span*100:0;const width=Math.max(.6,(row.durationMs||0)/span*100);return'<tr class="comp-row kind-'+attr(row.kind)+'"><td><b>'+esc(row.name)+'</b></td><td class="muted">'+esc(row.note)+'</td><td class="c-time mono">'+esc(durationText(row.durationMs))+'</td><td class="c-wf"><span class="wf-track"><span class="wf-bar" style="left:'+Math.min(99.4,left).toFixed(2)+'%;width:'+Math.min(width,100-left).toFixed(2)+'%"></span></span></td></tr>'}).join("")
6505
+ +'</tbody></table>';
6506
+ }
6507
+ function compositionTools(comp,trace,counts){
6508
+ const offered=(trace.items.filter(item=>item.kind==="model"&&!item.legacy).at(-1)||{}).toolNames||[];
6509
+ const unattributed=offered.filter(name=>!comp.origins[name]);
6510
+ const steps=comp.steps.filter(step=>step.tools.length);
6511
+ if(!steps.length&&!offered.length)return empty("No tools recorded","");
6512
+ return'<p class="dt-note">Each tool the agent had, under the step that added it. Click one to see its calls in Network.'+(comp.legacy?" This run was recorded before Foundry kept each step’s tools, so only steps that reported theirs are listed.":"")+'</p>'
6513
+ +steps.map(step=>'<section class="comp-group"><header><b>'+esc(step.label)+'</b>'+(step.kind?'<span class="muted">'+esc(step.kind)+'</span>':"")+'<span class="muted mono">'+count(step.tools.length,"tool")+'</span></header><div class="cap-list">'+step.tools.map(name=>toolChip(name,counts)).join("")+'</div></section>').join("")
6514
+ +(unattributed.length?'<section class="comp-group"><header><b>Offered, origin not recorded</b><span class="muted mono">'+count(unattributed.length,"tool")+'</span></header><div class="cap-list">'+unattributed.map(name=>toolChip(name,counts)).join("")+'</div></section>':"");
6515
+ }
6516
+ function compositionApps(comp,counts,instance){
6517
+ const installs=comp.installations.length?comp.installations:(instance?instance.installations:[]);
6518
+ const apps=comp.apps;
6519
+ if(!installs.length&&!apps.length)return empty("Nothing installed","Apps, MCP servers and shared tools installed on the instance appear here with the tools each gave the agent.");
6520
+ const stepFor=(install)=>comp.steps.find(step=>step.step==="installation"&&step.id===install.id);
6521
+ const mcp=comp.steps.find(step=>step.step==="mcp"&&!step.id);
6522
+ return'<p class="dt-note">What the instance has installed, and what each installation gave this run.</p>'
6523
+ +installs.map(install=>{
6524
+ const app=apps.find(item=>item.id===install.id);const step=stepFor(install);
6525
+ const tools=app?app.tools:step?step.tools.map(name=>({name})):[];
6526
+ return'<section class="comp-group"><header><b>'+esc(install.id)+'</b><span class="dt-badge">'+esc(install.kind)+'</span>'+(install.accountId?'<span class="muted">account '+esc(install.accountId)+'</span>':"")+(step&&Number.isFinite(step.ms)?'<span class="muted mono">'+esc(durationText(step.ms))+'</span>':"")+'</header>'
6527
+ +(app&&app.description?'<p class="dt-note">'+esc(app.description)+'</p>':"")
6528
+ +(tools.length?'<div class="cap-list">'+tools.map(tool=>toolChip(tool.name,counts,tool.readOnly===false?'<i class="tool-writes" title="Changes things">writes</i>':"")).join("")+'</div>':'<p class="dt-note">'+(install.kind==="mcp"?"Mounted with the other MCP servers below.":"No tools of its own.")+'</p>')
6529
+ +'</section>';
6530
+ }).join("")
6531
+ +(mcp&&mcp.tools.length?'<section class="comp-group"><header><b>MCP servers</b><span class="muted mono">'+count(mcp.tools.length,"tool")+'</span></header><div class="cap-list">'+mcp.tools.map(name=>toolChip(name,counts)).join("")+'</div></section>':"");
6532
+ }
6533
+ function compositionView(run,trace,events,view){
6534
+ const comp=buildComposition(events);const counts=toolCallCounts(trace);
6535
+ const instance=state.instances.find(item=>item.id===run.agentId);
6536
+ const node=COMPOSITION_NODES.some(entry=>entry[1]===view.cnode)?view.cnode:"timeline";
6537
+ const toolCount=comp.steps.reduce((sum,step)=>sum+step.tools.length,0);
6538
+ const counted={timeline:comp.steps.length+comp.resolves.length||"",tools:toolCount||"",apps:(comp.installations.length||(instance?instance.installations.length:0))||"",playbooks:(comp.playbooks.length||(instance?instance.playbooks.length:0))||"",schedules:comp.schedules.length||"",delegates:(comp.delegates.length+comp.durableSubagents.length)||"",extensions:(comp.memory.length+comp.layers.length+comp.subscribers.length)||"",surface:(comp.hooks.length+comp.skills.length+comp.subagents.length+comp.calls.length)||""};
6539
+ let tree="";let group="";
6540
+ COMPOSITION_NODES.forEach(entry=>{if(entry[0]!==group){group=entry[0];tree+='<div class="ctx-group">'+esc(group)+'</div>'}tree+='<button type="button" class="ctx-node'+(entry[1]===node?" active":"")+'" data-comp-node="'+entry[1]+'">'+esc(entry[2])+(counted[entry[1]]?'<small>'+esc(counted[entry[1]])+'</small>':"")+'</button>'});
6541
+ const list=(items,format)=>items.length?'<div class="cap-list">'+items.map(format).join("")+'</div>':'<p class="dt-note">None.</p>';
6542
+ let body="";
6543
+ if(node==="timeline")body=compositionTimeline(comp);
6544
+ else if(node==="tools")body=compositionTools(comp,trace,counts);
6545
+ else if(node==="apps")body=compositionApps(comp,counts,instance);
6546
+ else if(node==="playbooks"){
6547
+ const stored=instance?instance.playbooks:[];
6548
+ body='<p class="dt-note">Playbooks tell the agent how to handle what arrives on its transmissions. The definition composes them; the instance stores them.</p>'
6549
+ +'<div class="dt-section">Composed by the definition</div>'+list(comp.playbooks,item=>'<span class="cap">'+esc(item.name||item.id)+'</span>')
6550
+ +'<div class="dt-section">Stored on the instance</div>'+(stored.length?jsonBlock(stored,"comp:playbooks"):'<p class="dt-note">None.</p>');
6551
+ }
6552
+ else if(node==="schedules"){
6553
+ const activations=(state.activations||[]).filter(item=>item.agentId===run.agentId||item.createdByRunId===run.id);
6554
+ const timing=(t)=>!t?"":t.kind==="cron"?t.expression+" · "+t.timezone:t.kind==="every"?"every "+durationText(t.intervalMs):t.kind==="at"?"at "+fmtTime(t.at):"";
6555
+ body='<p class="dt-note">The definition’s schedules, synced when the run starts, and the instance’s activations: schedules and sleeps the runtime will fire.</p>'
6556
+ +'<div class="dt-section">Defined</div>'+(comp.schedules.length?kv(comp.schedules.map(item=>[item.name,esc(timing(item.timing))+(item.enabled===false?' <span class="st warn">disabled</span>':"")])):'<p class="dt-note">None.</p>')
6557
+ +(comp.scheduled.length?'<div class="dt-section">Created by this run</div>'+kv(comp.scheduled.map(item=>[short(item.id),(item.recurring?"recurring · ":"")+"next "+esc(fmtTime(item.nextRunAt))])):"")
6558
+ +'<div class="dt-section">Activations for this instance</div>'+(activations.length?'<table class="net-table"><thead><tr><th>Activation</th><th>Kind</th><th>Status</th><th>Next</th><th>Last run</th></tr></thead><tbody>'+activations.map(item=>'<tr><td class="mono">'+esc(item.scheduleName||short(item.id))+'</td><td>'+esc(item.kind||"")+'</td><td>'+esc(item.status||"")+'</td><td>'+esc(item.nextRunAt?fmtTime(item.nextRunAt):"—")+'</td><td>'+(item.lastRunId?'<a class="link mono" href="/runs/'+attr(item.lastRunId)+'" data-link>'+esc(short(item.lastRunId))+'</a>':"—")+'</td></tr>').join("")+'</tbody></table>':'<p class="dt-note">None.</p>');
6559
+ }
6560
+ else if(node==="delegates"){
6561
+ body='<p class="dt-note">Other agents this one can hand work to. Each delegation runs in the worker’s own conversation and reports back; see Call chain for the runs.</p>'
6562
+ +(comp.delegation?'<div class="dt-section">This run works for</div>'+kv([["Delegator",esc(comp.delegation.from)],["Task",esc(comp.delegation.task)],["Delegation",'<span class="mono">'+esc(comp.delegation.id)+'</span>']]):"")
6563
+ +'<div class="dt-section">Delegates</div>'+(comp.delegates.length?kv(comp.delegates.map(item=>[item.agent,esc(item.description||"")])):'<p class="dt-note">None.</p>')
6564
+ +'<div class="dt-section">Durable subagents</div>'+list(comp.durableSubagents,name=>'<span class="cap">'+esc(name)+'</span>')
6565
+ +(comp.composed?'<p class="dt-note">'+count(comp.composed.openDelegations||0,"delegation")+' open when the run started.</p>':"");
6566
+ }
6567
+ else if(node==="mesh")body=comp.mesh?kv([["Hosted mesh",comp.mesh.hosted?"mounted":"no"],["Your own transport",comp.mesh.transport?"mounted":"no"],["Open threads",esc(comp.mesh.threads??0)],comp.mesh.thread?["This run’s thread",'<span class="mono">'+esc(comp.mesh.thread)+'</span>']:null]):empty("No mesh","This agent doesn’t talk to peers over the mesh.");
6568
+ else if(node==="extensions")body='<div class="dt-section">Memory</div>'+list(comp.memory,id=>'<span class="cap">'+esc(id)+'</span>')+'<div class="dt-section">Layers</div>'+list(comp.layers,id=>'<span class="cap">'+esc(id)+'</span>')+'<div class="dt-section">Subscribers</div>'+list(comp.subscribers,id=>'<span class="cap">'+esc(id)+'</span>')+(comp.inboxes?'<div class="dt-section">Inbox</div><p class="dt-note">'+esc(count(comp.inboxes.count||0,"item"))+" loaded, "+esc(comp.inboxes.added||0)+" added, "+esc(comp.inboxes.updated||0)+' updated.</p>':"");
6569
+ else if(node==="surface")body='<div class="dt-section">Hooks</div>'+list(comp.hooks,name=>'<span class="cap">/'+esc(name)+'</span>')+'<div class="dt-section">Skills</div>'+list(comp.skills,name=>'<span class="cap">'+esc(name)+'</span>')+'<div class="dt-section">Subagents</div>'+list(comp.subagents,name=>'<span class="cap">'+esc(name)+'</span>')+'<div class="dt-section">Calls</div>'+list(comp.calls,call=>'<span class="cap">'+esc(call.name)+(call.exposed===false?' <small>not offered to the model</small>':"")+'</span>');
6570
+ else if(node==="workbench")body=(comp.workingEnvironment?'<div class="dt-section">Working environment</div>'+jsonBlock(comp.workingEnvironment,"comp:we"):'<div class="dt-section">Working environment</div><p class="dt-note">Not mounted.</p>')+(comp.repl?'<div class="dt-section">REPL</div>'+jsonBlock(comp.repl,"comp:repl"):'<div class="dt-section">REPL</div><p class="dt-note">Not mounted.</p>');
6571
+ return'<div class="ctx"><nav class="ctx-tree" aria-label="Composition">'+tree+'</nav><div class="ctx-view" data-scroll-key="comp:'+attr(node)+'">'+body+'</div></div>';
6572
+ }
6573
+
6574
+ /* ---- Queues ---- */
6575
+ function queueStatusClass(status){const s=String(status||"");return/fail|dropped|denied|rejected/.test(s)?"err":/waiting|deferred|queued|sent|posted/.test(s)?"warn":/joined|started|accepted|delivered|scheduled|approved|woke/.test(s)?"ok":""}
6576
+ function queuesView(run,trace,events,view){
6577
+ state.queues=state.queues||{filter:"",dir:"all"};
6578
+ const q=state.queues;const rows=buildQueues(events,run,trace);const term=q.filter.trim().toLowerCase();
6579
+ const visible=rows.filter(row=>(q.dir==="all"||row.dir===q.dir)&&(!term||(row.channel+" "+row.title+" "+row.preview+" "+row.status).toLowerCase().includes(term)));
6580
+ const selected=rows.find(row=>row.key===view.queue);const base=new Date(runStartedAt(run)).getTime();
6581
+ const models=Object.fromEntries(trace.items.filter(item=>item.kind==="model").map(item=>[item.key,item]));
6582
+ const inbound=rows.filter(row=>row.dir==="in").length;
6583
+ let html='<div class="dt-toolbar"><label class="dt-filter">'+icon("search")+'<input id="queue-filter" value="'+attr(q.filter)+'" placeholder="Filter by channel, source or content" aria-label="Filter messages" /></label>'
6584
+ +'<div class="dt-chips" role="group" aria-label="Direction">'+[["all","All"],["in","Inbound"],["out","Outbound"]].map(entry=>'<button type="button" class="dt-chip'+(q.dir===entry[0]?" active":"")+'" data-queue-dir="'+entry[0]+'">'+entry[1]+'</button>').join("")+'</div>'
6585
+ +'<span class="dt-summary">'+esc(inbound)+' in · '+esc(rows.length-inbound)+' out</span></div>';
6586
+ html+='<div class="net-split'+(selected?" has-detail":"")+'"><div class="net-list" data-scroll-key="queue-list">';
6587
+ if(!rows.length)html+=empty("Nothing crossed this run’s boundary","What starts a run, what arrives while it works and what it sends out appear here.");
6588
+ else html+='<table class="net-table q-table">'+(selected?"":'<colgroup><col style="width:34px"><col style="width:13%"><col><col style="width:16%"><col style="width:15%"><col style="width:80px"></colgroup>')+'<thead><tr><th class="q-dir"></th><th>Channel</th><th>What</th><th>Status</th><th title="Inbound: the model request that first saw it. Outbound: the run it started.">Reached</th><th class="c-time">Time</th></tr></thead><tbody>'
6589
+ +visible.map(row=>'<tr class="net-row q-row'+(row.key===view.queue?" selected":"")+'" data-queue-item="'+attr(row.key)+'"><td class="q-dir"><span class="q-arrow '+row.dir+'" title="'+(row.dir==="in"?"Inbound":"Outbound")+'">'+(row.dir==="in"?"↓":"↑")+'</span></td><td class="mono">'+esc(row.channel)+'</td><td><span class="net-name"><span><b>'+esc(row.title)+'</b><small>'+esc(row.preview)+'</small></span></span></td><td><span class="st '+queueStatusClass(row.status)+'">'+esc(row.status)+'</span></td><td>'+(row.seenBy&&models[row.seenBy]?itemLink(row.seenBy,models[row.seenBy].name):row.childRunId?'<a class="link mono" href="/runs/'+attr(row.childRunId)+'" data-link>'+esc(short(row.childRunId))+'</a>':'<span class="muted">—</span>')+'</td><td class="c-time mono">'+esc(offsetFrom(base,isoAt(row.at)))+'</td></tr>').join("")
6590
+ +'</tbody></table>'+(visible.length?"":empty("Nothing matches","Clear the filter to see every message."));
6591
+ html+='</div>'+(selected?queueDetail(selected,run,models):"")+'</div>';
6592
+ return html;
6593
+ }
6594
+ function queueDetail(row,run,models){
6595
+ const base=new Date(runStartedAt(run)).getTime();
6596
+ return'<aside class="net-detail" aria-label="'+attr(row.title)+'"><div class="nd-head"><button type="button" class="nd-close" data-queue-close title="Close (Esc)" aria-label="Close">'+icon("close")+'</button><span class="nd-tab active">Message</span></div>'
6597
+ +'<div class="nd-title"><b>'+esc(row.title)+'</b><span>'+(row.dir==="in"?"inbound":"outbound")+" · "+esc(row.channel)+'</span></div><div class="nd-body">'
6598
+ +kv([["Status",'<span class="st '+queueStatusClass(row.status)+'">'+esc(row.status)+'</span>'+(row.error?' <span class="muted">'+esc(row.error)+'</span>':"")],
6599
+ [row.dir==="in"?"Arrived":"Sent",esc(offsetFrom(base,isoAt(row.at)))+' <span class="muted">'+esc(fmtTime(isoAt(row.at)))+'</span>'],
6600
+ Number.isFinite(row.injectedAt)?["Joined the conversation",esc(offsetFrom(base,isoAt(row.injectedAt)))]:null,
6601
+ row.seenBy&&models[row.seenBy]?["First seen by",itemLink(row.seenBy,models[row.seenBy].name)]:null,
6602
+ row.call?["Tool call",itemLink(row.call,"Open in Network")]:null,
6603
+ row.childRunId?["Run",'<a class="link mono" href="/runs/'+attr(row.childRunId)+'" data-link>'+esc(row.childRunId)+'</a>']:null,
6604
+ row.nextRunAt?["Next run",esc(fmtTime(row.nextRunAt))]:null])
6605
+ +(row.preview?'<div class="dt-section">Content</div><pre class="dt-pre">'+esc(row.preview)+'</pre>':"")
6606
+ +'<div class="dt-section">Detail</div>'+jsonBlock(row.detail,row.key+":detail")
6607
+ +(row.events.length?'<div class="dt-section">Events</div>'+jsonBlock(row.events.map(event=>({type:event.type,timestamp:event.timestamp,data:event.data})),row.key+":raw"):"")
6608
+ +'</div></aside>';
6609
+ }
6610
+
6611
+ /* ---- Call chain ---- */
6612
+ function ensureChainEvents(id){
6613
+ state.chain=state.chain||{events:null,at:0,loading:false};
6614
+ const c=state.chain;if(c.loading||(c.events&&Date.now()-c.at<10000))return;
6615
+ c.loading=true;
6616
+ api("/api/events?category=system&limit=5000").then(events=>{c.events=events;c.at=Date.now()}).catch(()=>{c.events=c.events||[]}).finally(()=>{c.loading=false;if(route().id===id&&runView().tab==="chain")rerenderRun(id)});
6617
+ }
6618
+ function chainCard(node){
6619
+ const run=node.run;
6620
+ return'<div class="chain-card">'+(run?'<a class="link" href="/runs/'+attr(node.id)+'?tab=chain" data-link><b>'+esc(run.agent)+'</b></a> '+status(run.status)+' <span class="muted mono">'+esc(short(node.id))+'</span> <span class="muted">'+esc(fmtTime(run.createdAt))+(run.completedAt?" · "+esc(durationText(Date.parse(run.completedAt)-Date.parse(runStartedAt(run)))):"")+'</span>':'<span class="mono">'+esc(short(node.id))+'</span> <span class="muted">not retained</span>')+'</div>';
6621
+ }
6622
+ function chainNode(node,self){
6623
+ const run=node.run;const edge=node.edge;
6624
+ const head=run?'<a class="link" href="/runs/'+attr(node.id)+'?tab=chain" data-link><b>'+esc(run.agent)+'</b></a> '+status(run.status)+' <span class="muted mono">'+esc(short(node.id))+'</span> <span class="muted">'+esc(fmtTime(run.createdAt))+(run.completedAt?" · "+esc(durationText(Date.parse(run.completedAt)-Date.parse(runStartedAt(run)))):"")+'</span>':'<span class="mono">'+esc(short(node.id))+'</span> <span class="muted">not retained</span>';
6625
+ return'<div class="chain-node'+(self?" self":"")+'">'+(edge?'<span class="chain-edge">'+esc(edge.label)+'</span>':"")+'<div class="chain-card">'+head+'</div>'
6626
+ +((node.children||[]).length?'<div class="chain-children">'+node.children.map(child=>chainNode(child,false)).join("")+'</div>':"")+'</div>';
6627
+ }
6628
+ function chainView(run,events){
6629
+ ensureChainEvents(run.id);
6630
+ const loaded=state.chain&&state.chain.events;
6631
+ const all=(loaded||[]).concat(events);
6632
+ const chain=buildRunChain(run.id,state.runs,all);
6633
+ const origin=chain.origin?'<div class="chain-node origin"><div class="chain-card"><b>'+esc(chain.origin.kind)+'</b> '+esc([chain.origin.provider,chain.origin.id,chain.origin.eventId,chain.origin.threadKey].filter(Boolean).join(" · "))+'</div></div>':"";
6634
+ let html='<div class="dt-pad"><p class="dt-note">The runs this one came from and the runs it started: delegations and their reports, spawns, schedules and sleeps, steering. Each links to its own run.'+(loaded?"":" Loading the runtime’s events…")+'</p><div class="chain">'+origin;
6635
+ // Each ancestor, then how it led to the run below it.
6636
+ for(const ancestor of chain.ancestors)html+='<div class="chain-node">'+chainCard(ancestor)+'<span class="chain-edge">'+esc(ancestor.edge.label)+'</span></div>';
6637
+ html+=chainNode({...chain.self,edge:null},true)+'</div>';
6638
+ if(!chain.ancestors.length&&!(chain.self.children||[]).length&&!chain.origin)html+=empty("A run on its own","Nothing recorded started this run, and it started no other runs.");
6639
+ return html+'</div>';
6640
+ }
6641
+ function bindRunFoundry(id){
6642
+ document.querySelectorAll("[data-comp-node]").forEach(node=>node.onclick=()=>{setRunView({cnode:node.dataset.compNode});rerenderRun(id)});
6643
+ document.querySelectorAll("[data-tool-filter]").forEach(node=>node.onclick=()=>{state.network.filter=node.dataset.toolFilter;state.network.kind="tools";setRunView({tab:"network",item:""});rerenderRun(id)});
6644
+ document.querySelectorAll("[data-queue-item]").forEach(node=>node.onclick=event=>{if(event.target.closest("a,[data-net-item]"))return;setRunView({queue:node.dataset.queueItem});rerenderRun(id)});
6645
+ document.querySelectorAll("[data-queue-dir]").forEach(node=>node.onclick=()=>{state.queues.dir=node.dataset.queueDir;rerenderRun(id)});
6646
+ const close=document.querySelector("[data-queue-close]");if(close)close.onclick=()=>{setRunView({queue:""});rerenderRun(id)};
6647
+ const input=$("queue-filter");
6648
+ if(input)input.oninput=event=>{const caret=event.target.selectionStart;state.queues.filter=event.target.value;rerenderRun(id);const next=$("queue-filter");if(next){next.focus();try{next.setSelectionRange(caret,caret)}catch{}}};
6649
+ }
6650
+ `;
6651
+
6158
6652
  // src/dashboard-script.ts
6159
6653
  var ICON_PATHS_JSON = JSON.stringify(PHOSPHOR_ICON_PATHS);
6160
6654
  var DASHBOARD_SCRIPT = String.raw`
@@ -6234,7 +6728,9 @@ async function copyValue(button){
6234
6728
  }
6235
6729
 
6236
6730
  ${DASHBOARD_TRACE_SCRIPT}
6731
+ ${DASHBOARD_FOUNDRY_SCRIPT}
6237
6732
  ${DASHBOARD_RUN_SCRIPT}
6733
+ ${DASHBOARD_RUN_FOUNDRY_SCRIPT}
6238
6734
  /* ---- View state. Live updates repaint the page, so the parts a person is
6239
6735
  actively using -- scroll, focus, caret, expanded rows -- survive it. ---- */
6240
6736
  function captureView(){
@@ -7080,6 +7576,45 @@ tr.cursor,.definition-card.cursor{outline:1px solid var(--accent-soft);outline-o
7080
7576
  .kind-tool .wf-bar{background:var(--network)}
7081
7577
  .kind-subagent .wf-bar{background:var(--deploy)}
7082
7578
  .net-row.failed .wf-bar{background:var(--danger)}
7579
+ .wf-bar{overflow:hidden}
7580
+ .comp-table td{padding:6px 10px}
7581
+ .comp-row.kind-resolve .wf-bar{background:var(--interface)}
7582
+ .comp-row.kind-installation .wf-bar,.comp-row.kind-mcp .wf-bar{background:var(--network)}
7583
+ .comp-group{border:1px solid var(--border);border-radius:6px;padding:10px 12px;margin:0 0 10px}
7584
+ .comp-group>header{display:flex;gap:10px;align-items:baseline;margin-bottom:8px;font-size:12px}
7585
+ .comp-group>header .muted{font-size:10px}
7586
+ .comp-group>header .muted.mono{margin-left:auto}
7587
+ .tool-chip{cursor:pointer;border:1px solid var(--border);background:transparent;color:var(--text-secondary);font:10px var(--mono);padding:4px 8px;border-radius:4px}
7588
+ .tool-chip.called{color:var(--text-primary);border-color:var(--accent-dim)}
7589
+ .tool-chip small{margin-left:6px;padding:0 5px;border-radius:8px;background:var(--accent-dim);color:var(--text-primary);font-size:9px}
7590
+ .tool-chip:hover{border-color:var(--accent)}
7591
+ .tool-writes{margin-left:6px;font-style:normal;font-size:9px;color:var(--warning, #e0b25b)}
7592
+ .q-table .q-dir{width:28px;text-align:center}
7593
+ .q-arrow{font-weight:700}
7594
+ .q-arrow.in{color:var(--network)}
7595
+ .q-arrow.out{color:var(--accent)}
7596
+ .chain{display:grid;gap:4px;margin-top:10px}
7597
+ .chain-node{position:relative}
7598
+ .chain-edge{display:block;margin:6px 0 4px 14px;font:10px var(--mono);color:var(--text-tertiary)}
7599
+ .chain-edge::before{content:"↳ ";color:var(--text-tertiary)}
7600
+ .chain-card{display:flex;flex-wrap:wrap;gap:8px;align-items:center;padding:8px 12px;border:1px solid var(--border);border-radius:6px;background:rgba(20,29,24,.4);font-size:12px}
7601
+ .chain-card .muted{font-size:10px}
7602
+ .chain-node.self>.chain-card{border-color:var(--accent);box-shadow:inset 2px 0 0 var(--accent)}
7603
+ .chain-node.origin>.chain-card{border-style:dashed}
7604
+ .chain-children{margin-left:22px;padding-left:12px;border-left:1px dashed var(--border)}
7605
+ .wf-wait{position:absolute;left:0;top:0;bottom:0;background:rgba(255,255,255,.55);mix-blend-mode:soft-light}
7606
+ .wf-queue{position:absolute;top:5.5px;height:1px;background:var(--text-tertiary);opacity:.7}
7607
+ .net-row.nested .c-name{padding-left:calc(10px + var(--depth,1) * 16px)}
7608
+ .net-turn td{padding:7px 10px 5px;background:rgba(20,29,24,.55);border-top:1px solid var(--border);font:10px var(--mono);color:var(--text-secondary)}
7609
+ .net-turn td>span{margin-right:12px}
7610
+ .timing{display:grid;gap:6px;margin-top:12px}
7611
+ .timing-row{display:grid;grid-template-columns:minmax(150px,1.3fr) 2fr 70px;gap:12px;align-items:center;font-size:11px}
7612
+ .timing-row.total{border-top:1px solid var(--border);padding-top:6px;font-weight:600}
7613
+ .timing-name small{display:block;color:var(--text-tertiary);font-size:10px;margin-top:2px}
7614
+ .timing-track{position:relative;height:8px;background:rgba(255,255,255,.04);border-radius:2px}
7615
+ .timing-bar{position:absolute;left:0;top:0;bottom:0;border-radius:2px;background:var(--accent-soft)}
7616
+ .timing-bar.wait{background:rgba(255,255,255,.28)}
7617
+ .timing-bar.queue{background:var(--text-tertiary);opacity:.6}
7083
7618
  .wf-bar.pending{background:repeating-linear-gradient(90deg,var(--accent) 0 5px,transparent 5px 9px);opacity:.8}
7084
7619
  .net-split.has-detail .c-type,.net-split.has-detail .c-init,.net-split.has-detail .c-size,.net-split.has-detail .c-wf{display:none}
7085
7620
  .net-split.has-detail th.c-status,.net-split.has-detail th.c-time{width:72px}