1import{fj as _,r as x,j as e,fl as O,gB as H,gC as P,gD as V,u as J,a as U,gE as Q,e as g,s as W,L,fk as X}from"./index-w9IQLG3n.js";const Z=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],E=_("activity",Z);const G=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],Y=_("circle-alert",G);const ee=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],te=_("circle-check",ee);const ae=[["path",{d:"M10.1 2.182a10 10 0 0 1 3.8 0",key:"5ilxe3"}],["path",{d:"M13.9 21.818a10 10 0 0 1-3.8 0",key:"11zvb9"}],["path",{d:"M17.609 3.721a10 10 0 0 1 2.69 2.7",key:"1iw5b2"}],["path",{d:"M2.182 13.9a10 10 0 0 1 0-3.8",key:"c0bmvh"}],["path",{d:"M20.279 17.609a10 10 0 0 1-2.7 2.69",key:"1ruxm7"}],["path",{d:"M21.818 10.1a10 10 0 0 1 0 3.8",key:"qkgqxc"}],["path",{d:"M3.721 6.391a10 10 0 0 1 2.7-2.69",key:"1mcia2"}],["path",{d:"M6.391 20.279a10 10 0 0 1-2.69-2.7",key:"1fvljs"}]],se=_("circle-dashed",ae);const re=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],ne=_("circle-dot",re);const oe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],R=_("circle-question-mark",oe);const ie=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],le=_("circle-x",ie);const ce=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],de=_("copy",ce);const ue=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],me=_("external-link",ue);const pe=[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 17.5v-11",key:"1jc1ny"}]],xe=_("receipt",pe);const he=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]],_e=_("shield-alert",he);const fe=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],be=_("shield-check",fe);function ge(s){const i=[...s].sort((n,o)=>{const a=n.started_at??n.ended_at??"",p=o.started_at??o.ended_at??"";return a.localeCompare(p)}),l=[],d=new Map;for(const n of i){const o=`${n.stage}::${n.agent??"_"}`;let a=d.get(o);a||(a={key:o,stage:n.stage,agent:n.agent,terminal:n,heartbeats:[],retries:0,earliest_at:n.started_at??n.ended_at,total_cost_usd:0,total_input_tokens:0,total_output_tokens:0,total_duration_ms:0},d.set(o,a),l.push(a)),a.total_cost_usd+=Number(n.cost_usd)||0,a.total_input_tokens+=n.input_tokens??0,a.total_output_tokens+=n.output_tokens??0,a.total_duration_ms+=n.duration_ms??0,n.status==="retried"?(a.retries+=1,a.heartbeats.push(n)):n.status==="done"||n.status==="failed"?a.terminal=n:(a.heartbeats.push(n),a.terminal.status!=="done"&&a.terminal.status!=="failed"&&(a.terminal=n))}return l}function ye(s){const i="shrink-0";return s==="done"?e.jsx(te,{className:i,size:18,color:"var(--color-mint-deep, #5A8F4A)"}):s==="failed"?e.jsx(le,{className:i,size:18,color:"var(--ember, #7F5AF0)"}):s==="retried"?e.jsx(H,{className:i,size:18,color:"var(--color-sun-deep, #B8830A)"}):s==="running"?e.jsx(ne,{className:i+" animate-pulse",size:18,color:"var(--color-ember, #7F5AF0)"}):s==="queued"?e.jsx(se,{className:i,size:18,color:"var(--color-ink-faint, #9A9A9F)"}):e.jsx(Y,{className:i,size:18,color:"var(--color-ink-mute, #6E6E72)"})}function je(s){return s?s<1e3?`${s}ms`:`${(s/1e3).toFixed(1)}s`:"â"}function ve(s){return s?s<.001?`$${s.toFixed(5)}`:`$${s.toFixed(4)}`:"â"}function ke(s,i){if(!s&&!i)return"â";const l=d=>d>=1e3?`${(d/1e3).toFixed(1)}k`:String(d);return`${l(s)}â${l(i)}`}function Ne({events:s}){const i=x.useMemo(()=>ge(s),[s]),[l,d]=x.useState(new Set),n=o=>{d(a=>
1{const p=new Set(a);return p.has(o)?p.delete(o):p.add(o),p})};return i.length===0?e.jsx("p",{className:"text-ink-mute text-[14px]",children:"No task_events recorded for this run. The orchestrator may have failed before emitting any events."}):e.jsxs("ol",{className:"relative space-y-3",children:[e.jsx("div",{"aria-hidden":!0,className:"absolute left-[14px] top-3 bottom-3 w-px",style:{background:"var(--color-pebble)"}}),i.map(o=>{const a=o.terminal,p=l.has(o.key),v=!!(a.error_msg||a.error_code);return e.jsxs("li",{className:"relative pl-9",children:[e.jsx("div",{className:"absolute left-0 top-1",children:ye(a.status)}),e.jsxs("div",{className:"rounded-md border px-4 py-3",style:{background:"var(--color-paper)",borderColor:a.status==="failed"?"var(--ember, #7F5AF0)":"var(--color-pebble)"},children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-3 gap-y-1",children:[e.jsx("span",{className:"mono text-[24px] uppercase tracking-wide",children:o.stage}),o.agent&&e.jsx("span",{className:"text-[13px] font-semibold",children:o.agent}),e.jsx("span",{className:"mono text-[20px] uppercase rounded-full px-1.5 py-0.5",style:{background:a.status==="done"?"color-mix(in oklab, var(--color-mint-deep) 12%, transparent)":a.status==="failed"?"color-mix(in oklab, var(--ember) 12%, transparent)":"var(--color-pebble)",color:a.status==="done"?"var(--color-mint-deep)":a.status==="failed"?"var(--ember)":"var(--color-ink-mute)"},children:a.status}),o.retries>0&&e.jsxs("span",{className:"mono text-[20px] uppercase rounded-full px-1.5 py-0.5",style:{background:"color-mix(in oklab, var(--color-sun-deep) 14%, transparent)",color:"var(--color-sun-deep, #B8830A)"},title:"Retried",children:["â» ",o.retries," retr",o.retries===1?"y":"ies"]}),e.jsxs("span",{className:"ml-auto flex items-center gap-3 mono text-[22px] text-ink-mute",children:[e.jsx("span",{title:"Total duration across heartbeats",children:je(o.total_duration_ms||a.duration_ms)}),e.jsx("span",{title:"Total cost",children:ve(o.total_cost_usd)}),e.jsx("span",{title:"Input â output tokens",children:ke(o.total_input_tokens,o.total_output_tokens)})]})]}),a.micro_event&&e.jsx("p",{className:"mt-1.5 text-[13px] text-ink",children:a.micro_event}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-0.5 mono text-[22px] text-ink-faint",children:[a.model&&e.jsxs("span",{children:["model: ",a.model]}),o.heartbeats.length>0&&e.jsxs("span",{children:["· ",o.heartbeats.length," heartbeat",o.heartbeats.length===1?"":"s"," folded"]}),o.earliest_at&&e.jsxs("span",{children:["· started ",new Date(o.earliest_at).toLocaleTimeString()]})]}),v&&e.jsxs("div",{className:"mt-2",children:[e.jsxs("button",{type:"button",onClick:()=>n(o.key),className:"flex items-center gap-1 text-[24px] mono",style:{color:"var(--ember)"},children:[e.jsx(O,{size:12,style:{transform:p?"rotate(90deg)":"rotate(0)",transition:"transform 120ms ease"}}),a.error_code?`error: ${a.error_code}`:"error"]}),p&&a.error_msg&&e.jsx("pre",{className:"mt-2 max-h-64 overflow-auto whitespace-pre-wrap rounded p-2 mono text-[22px]",style:{background:"var(--color-paper-warm)",color:"var(--color-ink)",border:"1px solid var(--color-pebble)"},children:a.error_msg})]})]})]},o.key)})]})}function we(s){return s?{timeout:"Stage timed out",rate_limit:"Hit upstream rate limit",invalid_response:"Agent returned a malformed payload",validator_failed:"Output failed schema validation",api_error:"Upstream API errored",no_credits:"Workspace ran out of credits mid-run",cancelled:"Run was cancelled"}[s]??s.replace(/_/g," "):"Run failed"}function Me({failed:s,context:i}){return e.jsx("article",{className:"rounded-md border p-5",style:{background:"color-mix(in oklab, var(--ember) 5%, var(--color-paper))",borderColor:"var(--ember)"},children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(P,{size:22,color:"var(--ember)",className:"shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-3",children:[e.jsx("h3",{className:"display text-ink",style:{fontSize:18},children:we(s.error_code)}),e.jsxs("span",{className:"mono text-[22px] uppercase text-ink-mute",children:["stage: ",s.stage,s.agent?` · ${s.agent}`:""]}),s.error_code&&e.jsx("span",{className:"mono text-[20px] uppercase rounded-full px-1.5 py-0.5",style:{background:"color-mix(in oklab, var(--ember) 15%, transparent)",color:"var(--ember)"},children:s.error_code})]}),s.started_at&&e.jsxs("p",{className:"mt-1 mono text-[22px] text-ink-faint",children:["failed at ",new Date(s.started_at).toLocaleStr
1ing(),s.cost_usd?` · burned $${Number(s.cost_usd).toFixed(4)}`:""]}),s.error_msg&&e.jsxs("details",{className:"mt-3",children:[e.jsx("summary",{className:"mono text-[24px] cursor-pointer text-ink-mute hover:text-ink",children:"Full error message"}),e.jsx("pre",{className:"mt-2 max-h-80 overflow-auto whitespace-pre-wrap rounded p-3 mono text-[22px]",style:{background:"var(--color-paper-warm)",color:"var(--color-ink)",border:"1px solid var(--color-pebble)"},children:s.error_msg})]}),i.length>0&&e.jsxs("div",{className:"mt-4",children:[e.jsxs("p",{className:"mono text-[22px] uppercase text-ink-mute mb-2",children:["Last ",i.length," event",i.length===1?"":"s"," before failure"]}),e.jsx("ol",{className:"space-y-1.5",children:i.map((l,d)=>e.jsxs("li",{className:"rounded border px-3 py-2 text-[13px]",style:{background:"var(--color-paper)",borderColor:"var(--color-pebble)"},children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2 mono text-[20px] uppercase text-ink-mute",children:[e.jsx("span",{children:l.stage}),l.agent&&e.jsxs("span",{children:["· ",l.agent]}),e.jsxs("span",{children:["· ",l.status]}),l.started_at&&e.jsx("span",{className:"ml-auto text-ink-faint",children:new Date(l.started_at).toLocaleTimeString()})]}),l.micro_event&&e.jsx("p",{className:"mt-1 text-ink",children:l.micro_event})]},d))})]})]})]})})}function qe({events:s}){const i=x.useMemo(()=>{const n=new Map;for(const o of s){if(!o.cost_usd)continue;const a=n.get(o.stage)??{stage:o.stage,cost:0,in_tokens:0,out_tokens:0};a.cost+=Number(o.cost_usd)||0,a.in_tokens+=o.input_tokens??0,a.out_tokens+=o.output_tokens??0,n.set(o.stage,a)}return Array.from(n.values()).sort((o,a)=>a.cost-o.cost)},[s]);if(i.length===0)return e.jsx("p",{className:"text-ink-mute text-[14px]",children:"No cost data captured on this run yet."});const l=i[0]?.cost??0,d=i.reduce((n,o)=>n+o.cost,0);return e.jsxs("div",{children:[e.jsx("div",{className:"space-y-1.5",children:i.map(n=>{const o=l>0?Math.max(2,n.cost/l*100):0,a=d>0?Math.round(n.cost/d*100):0;return e.jsxs("div",{className:"grid grid-cols-[1fr_auto] items-center gap-3",children:[e.jsxs("div",{className:"grid grid-cols-[180px_1fr_70px] items-center gap-3",children:[e.jsx("span",{className:"mono text-[24px] truncate",title:n.stage,children:n.stage}),e.jsx("div",{className:"relative h-4 rounded-sm",style:{background:"var(--color-pebble)"},children:e.jsx("div",{className:"absolute inset-y-0 left-0 rounded-sm",style:{width:`${o}%`,background:"var(--color-ember, #7F5AF0)",opacity:.85}})}),e.jsxs("span",{className:"mono text-[22px] text-right",children:["$",n.cost.toFixed(4)]})]}),e.jsxs("span",{className:"mono text-[20px] text-ink-faint w-12 text-right",children:[a,"%"]})]},n.stage)})}),e.jsxs("div",{className:"mt-3 mono text-[22px] text-ink-mute",children:["Total across stages: $",d.toFixed(4)]})]})}function Ce({p:s}){const[i,l]=x.useState(!1),d=JSON.stringify(s.data,null,2),n=Math.round(d.length/102.4)/10,o=async()=>{try{await navigator.clipboard.writeText(d),l(!0),setTimeout(()=>l(!1),1500)}catch{}};return e.jsxs("details",{className:"rounded-md border",style:{background:"var(--color-paper)",borderColor:"var(--color-pebble)"},children:[e.jsxs("summary",{className:"flex items-center gap-3 px-4 py-2.5 cursor-pointer",style:{color:"var(--color-ink)"},children:[e.jsx("span",{className:"mono text-[24px] uppercase tracking-wide",children:s.label}),s.note&&e.jsx("span",{className:"text-[13px] text-ink-mute",children:s.note}),e.jsxs("span",{className:"ml-auto mono text-[22px] text-ink-faint",children:[n," KB"]})]}),e.jsxs("div",{className:"border-t",style:{borderColor:"var(--color-pebble)"},children:[e.jsx("div",{className:"flex justify-end px-3 py-2",children:e.jsxs("button",{type:"button",onClick:o,className:"flex items-center gap-1 rounded border px-2 py-1 text-[22px] mono hover:bg-pebble/50",style:{borderColor:"var(--color-pebble)",color:"var(--color-ink-mute)"},children:[i?e.jsx(V,{size:12}):e.jsx(de,{size:12}),i?"copied":"copy JSON"]})}),e.jsx("pre",{className:"overflow-auto whitespace-pre p-3 mono text-[22px]",style:{maxHeight:480,background:"var(--color-paper-warm)",color:"var(--color-ink)",borderTop:"1px solid var(--color-pebble)"},children:d})]})]})}function Fe({payloads:s}){const i=s.filter(l=>l.data!==null&&l.data!==void 0&&!(Array.isArray(l.data)&&l.data.length===0));return i.length===0?e.jsx("p",{className:"text-ink-mute text-[14px]",children:"No agent payloads captured for this run."}):e.jsx("div",{className:"space-y-2",children:i.map(l=>e.jsx(Ce,{p:l},l.label))})}const b=W;function Le(){const s=J(),i=U();x.useEffect(()=>{i.isFetched&&!i.data?.is_staff&&s({to:"/dashboard",replace:!0})},[i.isFetched,i.data,s]);const l=!!i.data?.is_staff,d=!i.isFetched,{runId:n}=Q.useParams(),o=g({enabled:l,queryKey:["staff_run_events",n],queryFn:async()=>{const{data:t}=await b.from("task_events").select("id, run_id, pipeline, stage, agent, status, started_at, ended_at, duration_ms, model, input_tokens, output_tokens, cost_usd, error_code, error_msg, micro_event, user_visible").eq("run_id",n).order("started_at",{ascending:!0});return t??[]}}),a=g({enabled:l,queryKey:["staff_run_buildrun",n],queryFn:async()=>{const{data:t}=await b.from("build_runs").select("id, audit_id, run_id, status, tier, workspace_id, customer_id, current_stage, patch_round, final_verdict, cost_usd_total, duration_seconds, brief_payload, design_dna, references_map, wireframe_lo, assembled_html, assembly_report, error_code, error_msg, created_at, updated_at").eq("run_id",n).maybeSingle();return t??null}}),p=g({enabled:l&&!!a.data?.id,queryKey:["staff_run_sections",a.data?.id],queryFn:async()=>
1{if(!a.data?.id)return[];const{data:t}=await b.from("build_sections").select("id, section_id, section_order, patch_round, cost_usd, section_html, model, validators_passed, deviations").eq("build_run_id",a.data.id).is("superseded_at",null).order("section_order",{ascending:!0});return t??[]}}),v=g({enabled:l&&!!a.data?.id,queryKey:["staff_run_concepts",a.data?.id],queryFn:async()=>{if(!a.data?.id)return[];const{data:t}=await b.from("build_image_concepts").select("id, section_id, slot_role, decision, picked_url, alt").eq("build_run_id",a.data.id);return t??[]}}),m=g({enabled:l,queryKey:["staff_run_audit",n,a.data?.audit_id??null],queryFn:async()=>{if(a.data?.audit_id){const{data:r}=await b.from("audits").select("id, source_url, audit_type, status, job_id, idempotency_key, workspace_id, customer_id, created_at, summary").eq("id",a.data.audit_id).maybeSingle();return r??null}const{data:t}=await b.from("audits").select("id, source_url, audit_type, status, job_id, idempotency_key, workspace_id, customer_id, created_at, summary").eq("run_id",n).maybeSingle();return t??null}}),$=g({enabled:l,queryKey:["staff_run_assessments",n],queryFn:async()=>{const{data:t}=await b.from("agent_self_assessments").select("stage, agent, confidence, input_completeness, source_workability, what_held_back, uncertainty_areas, created_at").eq("run_id",n).order("created_at",{ascending:!0});return t??[]}}),z=g({enabled:l,queryKey:["staff_run_feedback",n],queryFn:async()=>{const{data:t}=await b.from("agent_feedback").select("agent, stage, rating, reason_codes, notes_text, created_at").eq("run_id",n).order("created_at",{ascending:!0});return t??[]}}),j=g({enabled:l&&!!a.data?.id,queryKey:["staff_run_critiques",a.data?.id],queryFn:async()=>{if(!a.data?.id)return[];const{data:t}=await b.from("build_critiques").select("round, verdict, overall_score, one_line_summary, patch_list, agent_attribution_rollup, created_at").eq("build_run_id",a.data.id).order("round",{ascending:!0});return t??[]}}),M=g({enabled:l&&!!m.data?.job_id,queryKey:["staff_run_credit_txns",m.data?.job_id],queryFn:async()=>{if(!m.data?.job_id)return[];const{data:t}=await b.from("credit_txns").select("id, credits_delta, txn_type, reason, idempotency_key, created_at, job_id").eq("job_id",m.data.job_id).order("created_at",{ascending:!0});return t??[]}}),u=o.data??[],D=u[0]?.pipeline??(a.data?"build":"audit"),T=x.useMemo(()=>{const t=Number(a.data?.cost_usd_total);return Number.isFinite(t)&&t>0?t:u.reduce((r,c)=>r+(Number(c.cost_usd)||0),0)},[u,a.data]),k=x.useMemo(()=>{const t=u.map(r=>r.started_at).filter(Boolean);return t.length?t.reduce((r,c)=>r<c?r:c):null},[u]),N=x.useMemo(()=>{const t=u.map(r=>r.ended_at).filter(Boolean);return t.length?t.reduce((r,c)=>r>c?r:c):null},[u]),S=x.useMemo(()=>a.data?.duration_seconds?a.data.duration_seconds:k&&N?Math.max(0,Math.round((+new Date(N)-+new Date(k))/1e3)):null,[a.data,k,N]),q=x.useMemo(()=>a.data?.status?a.data.status:u.some(t=>t.status==="failed")?"failed":u.length===0?"unknown":u.every(t=>t.status==="done")?"done":u.some(t=>t.status==="running")?"running":"in-progress",[a.data,u]),w=x.useMemo(()=>{const t=[...u].reverse().find(r=>r.status==="failed");return t?{stage:t.stage,agent:t.agent,error_code:t.error_code,error_msg:t.error_msg,cost_usd:t.cost_usd,started_at:t.started_at}:null},[u]),K=x.useMemo(()=>{if(!w)return[];const t=u.findIndex(r=>r.status==="failed");return t<0?[]:u.slice(Math.max(0,t-3),t).filter(r=>r.micro_event||r.status!=="running").map(r=>({stage:r.stage,agent:r.agent,micro_event:r.micro_event,status:r.status,started_at:r.started_at}))},[w,u]),I=x.useMemo(()=>{const t=M.data??[];if(t.length===0)return null;const r=t.filter(f=>f.credits_delta<0).reduce((f,C)=>f+C.credits_delta,0),c=t.filter(f=>f.credits_delta>0&&(f.txn_type.toLowerCase().includes("refund")||(f.reason??"").toLowerCase().includes("refund"))).reduce((f,C)=>f+C.credits_delta,0);return{charged:Math.abs(r),refunded:c,remainder:Math.abs(r)-c,runFailed:q==="failed"}},[M.data,q]),A=x.useMemo(()=>{const t=a.data,r=[];return t?.brief_payload&&r.push({label:"brief_payload",note:"Atlas output",data:t.brief_payload}),t?.design_dna&&r.push({label:"design_dna",note:"Vela output",data:t.design_dna}),t?.references_map&&r.push({label:"references_map",note:"Forager output",data:t.references_map}),t?.wireframe_lo&&r.push({label:"wireframe_lo",note:"Verse output",data:t.wireframe_lo}),v.data?.length&&r.push({label:"image_concepts",note:"Iris output",data:v.data}),t?.assembly_report&&r.push({label:"assembly_report",note:"Mason rollup",data:t.assembly_report}),p.data?.length&&r.push({label:"build_sections",note:`${p.data.length} sections`,data:p.data.map(c=>({section_id:c.section_id,section_order:c.section_order,patch_round:c.patch_round,cost_usd:c.cost_usd,model:c.model,validators_passed:c.validators_passed,deviations:c.deviations,section_html_excerpt:typeof c.section_html=="string"?c.section_html.slice(0,400)+(c.section_html.length>400?"â¦":""):null}))}),j.data?.length&&r.push({label:"build_critiques",note:`${j.data.length} rounds`,data:j.data.map(c=>({round:c.round,verdict:c.verdict,overall_score:c.overall_score,one_line_summary:c.one_line_summary,patch_list:c.patch_list}))}),m.data?.summary&&r.push({label:"audit.summary",note:"Audit JSON",data:m.data.summary}),r},[a.data,p.data,j.data,m.data,v.data]);
1return d?e.jsx("main",{className:"min-h-screen app-canvas"}):l?e.jsx("section",{className:"px-4 py-10 md:px-8 app-canvas min-h-screen",children:e.jsxs("div",{className:"mx-auto max-w-[1280px]",children:[e.jsxs("div",{className:"mb-4 flex items-center gap-3 text-[13px] text-ink-mute",children:[e.jsxs(L,{to:"/staff/agent-health",className:"flex items-center gap-1 hover:text-ink",children:[e.jsx(X,{size:12})," agent health"]}),e.jsx("span",{className:"text-ink-faint",children:"/"}),e.jsxs("span",{className:"mono",children:["runs / ",n.slice(0,8)]})]}),e.jsxs("header",{className:"mb-8 rounded-md border p-5",style:{background:"var(--color-paper-warm)",borderColor:"var(--color-pebble)"},children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-4 gap-y-2",children:[e.jsxs("h1",{className:"display",style:{fontSize:"clamp(22px, 3vw, 36px)"},children:["Run ",e.jsx("span",{className:"mono text-ember",children:n.slice(0,8)})]}),e.jsx("span",{className:"mono uppercase text-[22px] text-ink-mute",children:D}),e.jsx($e,{status:q}),m.data?.source_url&&e.jsxs("a",{href:m.data.source_url,target:"_blank",rel:"noreferrer",className:"ml-auto flex items-center gap-1 text-[13px] text-ink-mute hover:text-ink",children:[e.jsx(me,{size:12}),e.jsx("span",{className:"truncate max-w-[280px]",children:m.data.source_url})]})]}),e.jsxs("dl",{className:"mt-4 grid grid-cols-2 gap-x-6 gap-y-2 sm:grid-cols-3 lg:grid-cols-4 text-[13px]",children:[e.jsx(h,{label:"started",children:e.jsx("span",{className:"mono",children:k?new Date(k).toLocaleString():"â"})}),e.jsx(h,{label:"finished",children:e.jsx("span",{className:"mono",children:N?new Date(N).toLocaleString():"â"})}),e.jsx(h,{label:"duration",children:e.jsx("span",{className:"mono",children:S!=null?`${S}s`:"â"})}),e.jsx(h,{label:"total cost",children:e.jsxs("span",{className:"mono",children:["$",T.toFixed(4)]})}),e.jsx(h,{label:"events",children:e.jsx("span",{className:"mono",children:u.length})}),a.data?.tier&&e.jsx(h,{label:"tier",children:e.jsx("span",{className:"mono",children:a.data.tier})}),a.data?.current_stage&&e.jsx(h,{label:"current_stage",children:e.jsx("span",{className:"mono",children:a.data.current_stage})}),a.data?.patch_round!=null&&e.jsx(h,{label:"patch_round",children:e.jsx("span",{className:"mono",children:a.data.patch_round})}),a.data?.final_verdict&&e.jsx(h,{label:"final_verdict",children:e.jsx("span",{className:"mono",children:a.data.final_verdict})}),e.jsx(h,{label:"workspace",children:e.jsx("span",{className:"mono truncate block max-w-[200px]",children:a.data?.workspace_id??m.data?.workspace_id??"â"})}),e.jsx(h,{label:"customer",children:e.jsx("span",{className:"mono truncate block max-w-[200px]",children:a.data?.customer_id??m.data?.customer_id??"â"})}),m.data?.idempotency_key&&e.jsx(h,{label:"idempotency_key",children:e.jsx("span",{className:"mono truncate block max-w-[200px]",children:m.data.idempotency_key})}),m.data?.id&&e.jsx(h,{label:"audit",children:e.jsx(L,{to:"/audit/$auditId",params:{auditId:m.data.id},className:"mono underline decoration-dotted hover:text-ember",children:m.data.id.slice(0,8)})})]})]}),w&&e.jsx("section",{className:"mb-8",children:e.jsx(Me,{failed:w,context:K})}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-[1fr_320px] mb-10",children:[e.jsxs("section",{children:[e.jsx(y,{icon:e.jsx(E,{size:16}),label:"Stage timeline"}),e.jsx("div",{className:"paper-card p-4",children:e.jsx(Ne,{events:u})})]}),e.jsxs("aside",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx(y,{icon:e.jsx(xe,{size:16}),label:"Credits"}),e.jsx(ze,{refund:I,loading:M.isLoading})]}),e.jsxs("div",{children:[e.jsx(y,{icon:e.jsx(E,{size:16}),label:"Cost by stage"}),e.jsx("div",{className:"paper-card p-4",children:e.jsx(qe,{events:u})})]})]})]}),e.jsxs("section",{className:"mb-10",children:[e.jsx(y,{icon:e.jsx(R,{size:16}),label:"Agent self-assessments"}),($.data??[]).length===0?e.jsx("p",{className:"text-ink-mute text-[14px]",children:"No self-assessment data for this run."}):e.jsx("div",{className:"grid gap-3 md:grid-cols-2",children:($.data??[]).map((t,r)=>e.jsxs("article",{className:"paper-card p-4",children:[e.jsx("div",{className:"flex items-center justify-between gap-3",children:e.jsxs("div",{children:[e.jsx("span",{className:"font-semibold",children:t.agent}),e.jsx("span",{className:"ml-2 text-ink-mute text-[24px] mono uppercase",children:t.stage})]})}),e.jsxs("div",{className:"mt-2 flex gap-4 mono text-[24px]",children:[e.jsx(F,{label:"conf",value:t.confidence}),e.jsx(F,{label:"inputs",value:t.input_completeness}),e.jsx(F,{label:"source",value:t.source_workability})]}),t.what_held_back&&e.jsxs("p",{className:"mt-2 text-[13px] italic text-ink-mute",children:["â",t.what_held_back,"â"]}
1),t.uncertainty_areas&&t.uncertainty_areas.length>0&&e.jsx("ul",{className:"mt-2 text-[13px] text-ink-mute",children:t.uncertainty_areas.map((c,f)=>e.jsxs("li",{children:["· ",c]},f))})]},r))})]}),(j.data??[]).length>0&&e.jsxs("section",{className:"mb-10",children:[e.jsx(y,{icon:e.jsx(be,{size:16}),label:"Hawk critiques"}),e.jsx("div",{className:"space-y-4",children:(j.data??[]).map(t=>e.jsxs("article",{className:"paper-card p-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"mono text-[24px] uppercase text-ink-mute",children:["Round ",t.round]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("span",{className:"mono text-[24px] uppercase",style:{color:Se(t.verdict)},children:t.verdict}),e.jsxs("span",{className:"mono",style:{color:B(t.overall_score)},children:[t.overall_score,"/100"]})]})]}),t.one_line_summary&&e.jsx("p",{className:"mt-2 text-[14px]",children:t.one_line_summary}),t.agent_attribution_rollup&&e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:Object.entries(t.agent_attribution_rollup).filter(([r,c])=>typeof c=="number"&&c>0&&r!=="top_blamed_agent").map(([r,c])=>e.jsxs("span",{className:"mono text-[22px] uppercase rounded-full px-2 py-0.5",style:{background:"var(--color-pebble)",color:"var(--color-ink)"},children:[r,": ",String(c)]},r))}),t.patch_list&&t.patch_list.length>0&&e.jsxs("details",{className:"mt-3",children:[e.jsxs("summary",{className:"text-[13px] text-ink-mute cursor-pointer",children:[t.patch_list.length," patches"]}),e.jsx("ul",{className:"mt-2 space-y-2 text-[13px]",children:t.patch_list.map(r=>e.jsxs("li",{className:"rounded-md border border-pebble p-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"mono",children:[r.severity," · ",r.failure_mode," · ",r.section_id]}),e.jsxs("span",{className:"mono text-[20px] uppercase rounded-full px-2 py-0.5",style:{background:`var(--agent-${r.responsible_agent}, var(--color-pebble))`,color:"white"},children:[r.responsible_agent," (",r.attribution_confidence,"%)"]})]}),e.jsx("p",{className:"mt-1 text-ink-mute",children:r.instruction}),r.attribution_reasoning&&e.jsx("p",{className:"mt-1 italic text-ink-faint",children:r.attribution_reasoning})]},r.patch_id))})]})]},t.round))})]}),(z.data??[]).length>0&&e.jsxs("section",{className:"mb-10",children:[e.jsx(y,{icon:e.jsx(_e,{size:16}),label:"User feedback"}),e.jsx("div",{className:"space-y-2",children:(z.data??[]).map((t,r)=>e.jsxs("article",{className:"paper-card p-3 text-[13px]",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"font-semibold",children:t.agent}),e.jsx("span",{className:"text-ink-mute mono text-[22px] uppercase",children:t.stage}),e.jsx("span",{className:"mono text-[22px] uppercase",style:{color:t.rating==="thumbs-up"?"var(--color-mint-deep)":"var(--color-accent)"},children:t.rating==="thumbs-up"?"Up":"Down"})]}),e.jsx("span",{className:"mono text-[22px] text-ink-faint",children:new Date(t.created_at).toLocaleString()})]}),t.notes_text&&e.jsxs("p",{className:"mt-1 italic text-ink-mute",children:["â",t.notes_text,"â"]}),t.reason_codes&&t.reason_codes.length>0&&e.jsx("p",{className:"mt-1 text-[13px] text-ink-faint",children:t.reason_codes.join(" · ")})]},r))})]}),A.length>0&&e.jsxs("section",{className:"mb-10",children:[e.jsx(y,{icon:e.jsx(R,{size:16}),label:"Raw payloads"}),e.jsx(Fe,{payloads:A})]})]})}):null}function h({label:s,children:i}){return e.jsxs("div",{children:[e.jsx("dt",{className:"mono text-[20px] uppercase tracking-wide text-ink-faint",children:s}),e.jsx("dd",{className:"mt-0.5 text-[13px] text-ink",children:i})]})}function y({icon:s,label:i}){return e.jsxs("h2",{className:"display text-ink mb-3 flex items-center gap-2",style:{fontSize:20},children:[e.jsx("span",{className:"text-ink-mute",children:s}),i]})}function $e({status:s}){const i=s==="done"||s==="succeeded"?"color-mix(in oklab, var(--color-mint-deep) 14%, transparent)":s==="failed"?"color-mix(in oklab, var(--color-accent) 14%, transparent)":s==="running"||s==="in-progress"?"color-mix(in oklab, var(--color-ember) 14%, transparent)":"var(--color-pebble)",l=s==="done"||s==="succeeded"?"var(--color-mint-deep)":s==="failed"?"var(--color-accent)":s==="running"||s==="in-progress"?"var(--color-ember)":"var(--color-ink-mute)";return e.jsx("span",{className:"mono text-[20px] uppercase rounded-full px-2 py-0.5",style:{background:i,color:l},children:s})}function F({label:s,value:i}){return e.jsxs("span",{className:"rounded-md px-2 py-0.5",style:{background:"var(--color-pebble)",color:B(i)},children:[s," ",i]})}function ze({refund:s,loading:i}){if(i)return e.jsx("div",{className:"paper-card p-4 text-[13px] text-ink-mute",children:"Loading credit ledgerâ¦"});if(!s)return e.jsx("div",{className:"paper-card p-4 text-[13px] text-ink-mute",children:"No linked job_id â credit history not available for this run."});const{charged:l,refunded:d,remainder:n,runFailed:o}=s;return l===0?e.jsx("div",{className:"paper-card p-4 text-[13px] text-ink-mute",children:"No credits were charged on this run."}):d>=l?e.jsxs("div",{className:"paper-card p-4 text-[13px]",style:{borderLeft:"3px solid var(--color-mint-deep)"},children:[e.jsxs("div",{className:"font-semibold",style:{color:"var(--color-mint-deep)"}
1,children:["â refunded ",d," credit",d===1?"":"s"]}),e.jsxs("div",{className:"mt-1 mono text-[22px] text-ink-mute",children:["charged: ",l," · refunded: ",d]})]}):o&&d===0?e.jsxs("div",{className:"paper-card p-4 text-[13px]",style:{borderLeft:"3px solid var(--color-accent)"},children:[e.jsx("div",{className:"font-semibold",style:{color:"var(--color-accent)"},children:"â still pending refund"}),e.jsxs("div",{className:"mt-1 mono text-[22px] text-ink-mute",children:["charged: ",l," · refunded: 0 · check worker logs"]})]}):e.jsxs("div",{className:"paper-card p-4 text-[13px]",children:[e.jsx("div",{className:"text-ink-mute",children:"partial run · no refund expected"}),e.jsxs("div",{className:"mt-1 mono text-[22px] text-ink-mute",children:["charged: ",l," · refunded: ",d," · remainder: ",n]})]})}function B(s){return s>=80?"var(--color-mint-deep, #5A8F4A)":s>=60?"var(--color-ink-mute, #6E6E72)":"var(--color-accent, #7F5AF0)"}function Se(s){return s==="ship"?"var(--color-mint-deep, #5A8F4A)":s==="patch-required"?"var(--color-accent-deep, #C73912)":"var(--color-accent, #7F5AF0)"}export{Le as component};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.