PageSourceSearch

https://app.trooper.so/assets/ActivityDrawer-D9AUHpj1.js

js trooper.so collected 2026-09-24 15:13:09 UTC 92,376 bytes, 7 lines download raw bytes

1import{j as e,r as h}from"./react-dIJTUJVE.js";import{c as sn,f as L,b as Se,a7 as Lt,g as Nr,aR as rn,dl as nn,aS as an,dm as ln,a3 as on,a2 as cn,a0 as He,dn as Wt,dp as ir,dq as dn,db as un,cx as kt,dr as mn,ds as st,dt as yr,aP as vr,du as xn,dv as cr,dw as Sr,dx as pn,dy as Ct,B as rt,dz as dr,dA as ur,dB as mr,dC as hn,dD as fn,dE as gn,aK as bn,bG as _t,bF as kr,Y as Yt,dF as jn,dG as wn,dH as Nn}from"./index-CO0FZyR6.js";import{cB as yn,V as vn,cC as Tr,E as Sn,cD as kn,cw as Tn,cE as _n,cF as Mn,cG as En,cH as Ln,cI as Zt,cJ as Gt,cK as Cn,cz as Mt,B as ct,X as $n,g as In,A as An,e as _r,k as Mr,cg as Er,aH as Pn,C as ls,cL as Kn,cM as qn,cN as Bn,cO as Fn,cP as Lr,a as os,cQ as Un}from"./App-gXf3oHlu.js";import{D as On,a as Hn,b as zn,c as Wn,d as Dn}from"./drawer-Dl47xAO3.js";import{T as Jn,a as Rn,b as Dt}from"./tabs-DXuZH2yH.js";import{e as Xn}from"./toolDiff-BSh_xQNF.js";import{S as Qn}from"./StreamingMarkdown-DTwUvmL6.js";import{a as Vn,c as Yn,C as Cr,d as Zn}from"./ConfirmDoubtsCard-CllpJzpj.js";import{r as nt}from"./apiResponse-DYkfnH0b.js";import{u as Gn,R as ea,S as ta}from"./ComposerStatusPanels-mCsxIJLR.js";import{l as sa,T as ra,R as _e}from"./ToolTimeline-BOvEDFdz.js";import"./api-url-D4bc_VHB.js";import{normalizeBridgeMediaUrl as na}from"./bridge-files-BViHNTCX.js";import{P as aa}from"./play-Cl8nMwLq.js";import{I as la}from"./info-BEm3Y2Z8.js";import{C as oa}from"./chevron-up-dmA6KFEN.js";import{r as es,M as $r}from"./index-OwaqD2Hs.js";import{r as ts}from"./index-Bwd2g-Nx.js";import"./firebase-C7EYTMAQ.js";import"./clamp-DyuOe9kr.js";import"./CompositeRoot-Cu-35UCh.js";import"./isElementDisabled-CwHw_lZC.js";import"./file-code-BgeGY7td.js";import"./toolEventOutputFiles-BwgIWEv0.js";import"./circle-C6ACG733.js";import"./core.esm-DYp12Gts.js";import"./useOpenClawDashboardServer-C8Jp2ZZ4.js";import"./circle-dashed-CX7hXyC4.js";import"./gauge-A_Q9QDDS.js";import"./network-CEmzZ-ZS.js";import"./arrow-up-right-J-gZmqxj.js";import"./pencil-Dp3ogvJ6.js";import"./codeFenceInfo-BywCTA3J.js";import"./extends-CF3RwP-h.js";import"./index-CvVbjaaV.js";import"./MermaidDiagram-B-VktCOl.js";import"./code-xml-BbyxFRAp.js";import"./zoom-out-Bb2rlrFE.js";import"./maximize-2-CuYxP28O.js";import"./settings-2-32WxFnAW.js";import"./composer-plugin-chip-NKUnXFQQ.js";import"./plugin-hero-gradient-0fDq60HP.js";import"./at-sign-qUCc96Oe.js";import"./app-window-DUDjsaTC.js";import"./file-image-DPINgP6b.js";import"./message-square-text-B_GYC8pG.js";import"./volume-2-B3UySZgt.js";import"./circle-question-mark-NEYP5Xh4.js";import"./ArtifactShareButton-DdK0r9b6.js";import"./link-2-Bxk-lsmj.js";import"./htmlDocumentTitle-Dhf1RWaV.js";import"./useArtifactPreviewSource-BKEwEQiX.js";import"./useBridgeFileAccessToken-_FMSFFKF.js";import"./file-DV0a0W_o.js";import"./table-PVC_roKx.js";import"./flask-conical-CA5GrFk_.js";import"./git-branch-BQ0bimpT.js";import"./workspaceTree-DLTdRSO1.js";/**
2 * @license lucide-react v0.563.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const ia=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M9 15h6",key:"cctwl0"}],["path",{d:"M12 18v-6",key:"17g6i2"}]],ca=sn("file-plus",ia);function da({addressText:t="Browser",className:s=""}){return e.jsxs("div",{className:L("flex h-8 shrink-0 items-center gap-2 border-b border-neutral-200/95 bg-gradient-to-b from-[#ececec] to-[#dedede] px-2.5 dark:border-neutral-700 dark:from-stone-800 dark:to-stone-900",s),children:[e.jsxs("svg",{width:"42",height:"10",viewBox:"0 0 42 10",className:"shrink-0","aria-hidden":!0,children:[e.jsx("circle",{cx:"5",cy:"5",r:"4",fill:"#ff5f57"}),e.jsx("circle",{cx:"21",cy:"5",r:"4",fill:"#febc2e"}),e.jsx("circle",{cx:"37",cy:"5",r:"4",fill:"#28c840"})]}),e.jsx("div",{className:"flex min-h-[22px] min-w-0 flex-1 items-center rounded-md border border-neutral-300/80 bg-white px-2 py-0.5 shadow-[inset_0_1px_0_rgba(255,255,255,0.9)] dark:border-neutral-600 dar
6k:bg-stone-950/80",children:e.jsx("span",{className:"w-full truncate text-center text-[10px] font-medium leading-tight text-neutral-600 dark:text-neutral-300",children:t})})]})}function ua({agentId:t}){const s=Se(a=>a.browserLiveView),n=s&&(!t||s.agentId===t),l=h.useMemo(()=>{if(!n)return"Live";const a=String((s==null?void 0:s.pageUrl)||"").trim();if(a)try{const w=new URL(a),S=w.hostname.replace(/^www\./,""),N=w.pathname+w.search;if(N&&N!=="/"){const k=N.length>24?`${N.slice(0,22)}…`:N;return`${S}${k}`}return S}catch{return a.length>48?`${a.slice(0,46)}…`:a}return String((s==null?void 0:s.domain)||"Live")},[n,s==null?void 0:s.pageUrl,s==null?void 0:s.domain]);if(!n||!s.screenshotBase64)return null;const o=s.screenshotBase64,d=o.startsWith("/9j/")?"image/jpeg":"image/png";return e.jsxs("div",{className:"mx-5 mb-3 overflow-hidden rounded-lg border border-neutral-300/90 bg-white shadow-[0_1px_3px_rgba(15,23,42,0.08)] dark:border-neutral-700 dark:bg-stone-950",children:[e.jsx(da,{addressText:l}),e.jsxs("div",{className:"flex items-center gap-1.5 border-b border-emerald-200/60 bg-emerald-50/50 px-3 py-0.5 dark:border-emerald-800/50 dark:bg-emerald-950/20",children:[e.jsx("div",{className:"h-1.5 w-1.5 shrink-0 animate-pulse rounded-full bg-emerald-500"}),e.jsx("span",{className:"text-[9px] font-medium uppercase tracking-wide text-emerald-700 dark:text-emerald-400",children:s.agentName?`${s.agentName} · live`:"Live"}),e.jsx(Lt,{className:"ml-auto h-3 w-3 text-emerald-600 dark:text-emerald-500","aria-hidden":!0})]}),e.jsx("img",{src:`data:${d};base64,${o}`,alt:"Live browser",className:"w-full object-contain bg-white dark:bg-stone-900",style:{maxHeight:300}})]})}const xr={read:{label:"Read",icon:an,className:"text-sky-600 bg-sky-50 ring-sky-100"},write:{label:"Write",icon:ca,className:"text-emerald-600 bg-emerald-50 ring-emerald-100"},edit:{label:"Edit",icon:nn,className:"text-amber-700 bg-amber-50 ring-amber-100"},touch:{label:"Used",icon:Nr,className:"text-neutral-600 bg-stone-50 ring-neutral-200/70"}};function ma({ops:t=[]}){return t.length?e.jsx("div",{className:"flex shrink-0 flex-wrap items-center justify-end gap-1",children:t.map(s=>{const n=xr[s]||xr.touch,l=n.icon;return e.jsxs("span",{className:L("inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium ring-1 ring-inset",n.className),children:[e.jsx(l,{className:"h-3 w-3",strokeWidth:2,"aria-hidden":!0}),n.label]},s)})}):null}function $t({icon:t,title:s,subtitle:n,badges:l=null,onClick:o,href:d,className:a=""}){const w=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-stone-50 ring-1 ring-neutral-200/60",children:e.jsx(t,{className:"h-3.5 w-3.5 text-neutral-500",strokeWidth:2,"aria-hidden":!0})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-[13px] font-medium leading-5 text-neutral-800",children:s}),n?e.jsx("span",{className:"mt-0.5 block truncate text-[11px] leading-snug text-neutral-500",children:n}):null]}),l,d?e.jsx(Sn,{className:"h-3.5 w-3.5 shrink-0 text-neutral-400",strokeWidth:2.25,"aria-hidden":!0}):null]}),S=L("flex items-center gap-2.5 rounded-xl bg-white px-3 py-2.5 ring-1 ring-neutral-200/55 transition-colors",(o||d)&&"hover:bg-stone-50/80 hover:ring-neutral-300/70",a);return d?e.jsx("a",{href:d,target:"_blank",rel:"noopener noreferrer",className:S,children:w}):o?e.jsx("button",{type:"button",onClick:o,className:L(S,"w-full text-left"),children:w}):e.jsx("div",{className:S,children:w})}function xa({item:t}){return e.jsx($t,{icon:vn,title:t.name,subtitle:t.path||t.detail||"Skill referenced in this run",onClick:t.path?()=>Tr(t.path):void 0})}function pa({item:t}){return e.jsx($t,{icon:Nr,title:t.name,subtitle:t.path,badges:e.jsx(ma,{ops:t.ops}),onClick:()=>Tr(t.path)})}function ha({item:t}){let s=t.domain||t.url;try{s=new URL(t.url).hostname.replace(/^www\./,"")}catch{}return e.jsx($t,{icon:rn,title:t.title||s||t.url,subtitle:t.url,href:t.url})}function fa({item:t}){const[s,n]=h.useState(!1),l=t.contentType||(String(t.base64||"").startsWith("/9j/")?"image/jpeg":"image/png"),o=t.base64?`data:${l};base64,${t.base64}`:"",d=t.url&&na(t.url)||"",a=o||d,w=!!(a&&!s),S=()=>{!w||typeof window>"u"||(window.__lightboxSrc=a,window.dispatchEvent(new CustomEvent("openclaw-lightbox",{detail:a})))};return w?e.jsxs("button",{type:"button",onClick:S,className:"group flex max-w-[280px] items-stretch gap-2.5 overflow-hidden rounded-xl bg-white p-2 text-left ring-1 ring-neutral-200/55 transition-colors hover:bg-stone-50/80 hover:ring-neutral-300/70",children:[e.jsx("img",{src:a,alt:t.title||"Run image preview",className:"h-16 w-24 shrink-0 rounded-lg border border-neutral-200 object-cover object-top bg-stone-50 transition group-hover:opacity-95",onError:()=>n(!0)}),e.jsxs("span",{className:"min-w-0 flex-1 self-center py-0.5 pr-1",children:[e.jsx("span",{className:"block truncate text-[13px] font-medium leading-5 text-neutral-800",children:t.title||"Image"}),e.jsx("span",{className:"mt-0.5 block text-[11px] text-neutral-500",children:"Tap to enlarge"})]})]}):null}function ga({item:t}){return e.jsx($t,{icon:aa,title:t.title||"Browser session recording",subt
6itle:"Watch the captured browser session",href:t.url})}function ba(t,s){return s==="skills"?e.jsx(xa,{item:t},t.id):s==="files"?e.jsx(pa,{item:t},t.id):s==="urls"?e.jsx(ha,{item:t},t.id):t.kind==="recording"?e.jsx(ga,{item:t},t.id):t.kind==="screenshot"||t.kind==="generated"?e.jsx(fa,{item:t},t.id):null}function ja({section:t}){return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1.5 flex items-center justify-between gap-2",children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-widest text-neutral-400",children:t.label}),e.jsx("span",{className:"text-[10px] tabular-nums text-neutral-400",children:t.items.length})]}),e.jsx("div",{className:"space-y-1.5",children:t.items.map(s=>ba(s,t.id))})]})}function wa({events:t=[],sessionRecordingUrl:s=null,sessionRecordingLabel:n="",className:l=""}){const o=h.useMemo(()=>yn(t,{sessionRecordingUrl:s,sessionRecordingLabel:n}),[t,n,s]);if(!o.hasContent)return null;const d=Array.isArray(o.groups)&&o.groups.length>0?o.groups:[{id:"evidence",label:"Supporting evidence",caption:"Skills, files, URLs, and media from this run",sections:o.sections}];return e.jsx("div",{className:L("space-y-6",l),children:d.map(a=>e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-widest text-neutral-400",children:a.label}),a.caption?e.jsx("p",{className:"mt-0.5 text-[11px] leading-snug text-neutral-400",children:a.caption}):null]}),e.jsx("div",{className:"space-y-4",children:a.sections.map(w=>e.jsx(ja,{section:w},`${a.id}-${w.id}`))})]},a.id))})}const ne={shell:"bg-white",chrome:"bg-white",chromeHairline:"border-b border-neutral-200/80",chromeSubtle:"bg-stone-50/60",chip:"rounded-full bg-stone-100 px-2.5 py-0.5 font-mono text-[11px] text-neutral-500 ring-1 ring-inset ring-neutral-200/60",line:"bg-stone-200"},be=Object.freeze([]),Ir="trooper-activity-drawer-view:",pr=500,Jt=500,Na=10,hr=1e3,ya=new Set(["text","message","assistant_message","subagent_text","thinking"]);function Tt(t){const s=(t==null?void 0:t.data)||{};if(ya.has(String((t==null?void 0:t.event)||""))){const n=String(s.text||s.content||"").trim();if(n)return`txt:${t.event}:${s.subAgentRunId||""}:${n.slice(0,400)}`}return(t==null?void 0:t.seq)!=null?`seq:${t.seq}`:s.eventId?`id:${t.event}:${s.eventId}`:`${t==null?void 0:t.event}:${s.toolCallId||s.index||""}:${(t==null?void 0:t.time)||0}`}function fr(t){return t.length>hr?t.slice(-hr):t}function va(t){const s=String(t||"").trim().toLowerCase();return/^(browser|chrome|brave|edge|firefox|chromium|pageagent|page agent|trooper page agent)$/.test(s)}function Sa(t){if(!t||typeof window>"u")return null;try{const s=window.sessionStorage.getItem(`${Ir}${t}`);return s?JSON.parse(s):null}catch{return null}}function ka(t,s){if(!(!t||typeof window>"u"))try{window.sessionStorage.setItem(`${Ir}${t}`,JSON.stringify(s))}catch{}}function Rt({text:t}){const[s,n]=h.useState(!1);return t?e.jsx(ct,{variant:"ghost",size:"icon",onClick:l=>{l.stopPropagation(),navigator.clipboard.writeText(t),Er(),n(!0),setTimeout(()=>n(!1),1500)},className:"absolute top-1.5 right-1.5 h-6 w-6 rounded-md bg-white/95 hover:bg-white text-neutral-400 hover:text-neutral-800 opacity-0 group-hover/pre:opacity-100 transition-all border border-neutral-200/60 shadow-[0_1px_2px_rgba(0,0,0,0.06)]",title:"Copy",children:s?e.jsx(_r,{className:"w-3 h-3 text-emerald-500"}):e.jsx(Mr,{className:"w-3 h-3"})}):null}function Ta({events:t,agentName:s}){const[n,l]=h.useState(!1),o=h.useMemo(()=>{const d=Array.isArray(t)?t:[],a=hn(d);return fn(a,{agentName:s,preserveProtocolTags:!0})},[t,s]);return o?e.jsxs(ct,{variant:"ghost",size:"sm",type:"button",onClick:()=>{navigator.clipboard.writeText(o),Er(),l(!0),setTimeout(()=>l(!1),1500)},className:"h-8 shrink-0 gap-1.5 rounded-lg px-2.5 text-[12px] font-medium text-neutral-500 hover:bg-stone-100 hover:text-neutral-900 transition-colors",title:"Copy the full run log to the clipboard",children:[n?e.jsx(_r,{className:"h-3.5 w-3.5 text-emerald-500"}):e.jsx(Mr,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:n?"Copied":"Copy log"})]}):null}function _a(t={}){const s=(t==null?void 0:t.data)||{},n=s.text||s.content||s.message||s.summary||t.text||t.content||"";return Ct(n||"").trim()}function gr(t=""){const s=Ct(t||"").trim();return!(!s||s.length<8||/^(?:looking at that now|thinking|working|running|processing|waiting for activity|the agent run failed before producing a reply)\.?$/i.test(s)||/^(?:source:\s*openclaw gateway|presence:\s*0 live|no native openclaw nodes are known)/i.test(s))}function ss(t=[],s=""){var n;if(gr(s))return!0;
6if(!Array.isArray(t))return!1;for(let l=t.length-1;l>=0;l-=1){const o=t[l]||{},d=String((o==null?void 0:o.event)||(o==null?void 0:o.type)||((n=o==null?void 0:o.data)==null?void 0:n.event)||"").toLowerCase(),a=(o==null?void 0:o.data)||{},w=String(a.role||a.senderType||a.authorType||a.sourceRole||"").toLowerCase();if(!(w==="user"||w==="human"||!(["text","message","assistant_message","final","outcome","done"].includes(d)||w==="assistant"||w==="agent"))&&gr(_a(o)))return!0}return!1}function Ma(t=""){const s=String(t||"").trim().toLowerCase();return s?s==="complete"||s==="done"||s==="success"||s==="succeeded"?"completed":s==="in_progress"||s==="in-progress"||s==="running"||s==="working"||s==="streaming"?"in progress":s==="error"||s==="failed"||s==="failure"?"failed":s:null}function br(t=[],s=null){var d;if(!Array.isArray(t)||t.length===0)return Number.NEGATIVE_INFINITY;let n=0,l=0,o=0;for(const a of t){const w=((d=a==null?void 0:a.data)==null?void 0:d.runId)||(a==null?void 0:a.runId)||null;if(!w){o+=1;continue}s&&String(w)===String(s)?n+=1:s?l+=1:n+=1}return s&&l>0?-1e6+t.length-l*100:s&&n>0?1e5+n*50+(ss(t)?5e3:0)+Math.min(t.length,200):(ss(t)?1e3:0)+Math.min(t.length,100)-o*.01}function jr(t=[],{preferredRunId:s=null}={}){const n=(Array.isArray(t)?t:[]).filter(l=>Array.isArray(l)&&l.length>0);return n.length===0?be:[...n].sort((l,o)=>br(o,s)-br(l,s))[0]||be}function Ea({event:t}){var o,d,a,w,S,N;const[s,n]=h.useState(!1),l=String((t==null?void 0:t.event)||"event");return e.jsxs("div",{className:"rounded-xl border border-neutral-200/80 overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>n(k=>!k),className:"flex w-full items-center gap-2 px-3 py-2 text-left hover:bg-stone-50 transition-colors text-[11px] select-none",children:[s?e.jsx(ls,{className:"h-3 w-3 shrink-0 text-neutral-400"}):e.jsx(os,{className:"h-3 w-3 shrink-0 text-neutral-400"}),e.jsx("span",{className:L("font-mono px-1.5 py-0.5 rounded-md text-[10px] font-semibold shrink-0",l==="tool_start"?"bg-amber-50 text-amber-700 border border-amber-200/60":l==="tool_result"?"bg-emerald-50 text-emerald-700 border border-emerald-200/60":l==="text"?"bg-stone-100 text-neutral-600 border border-neutral-200/60":l==="thinking"?"bg-violet-50 text-violet-600 border border-violet-200/60":"bg-stone-100 text-neutral-500 border border-neutral-200/60"),children:l}),e.jsx("span",{className:"text-neutral-600 truncate flex-1",children:Un(t)||((o=t.data)==null?void 0:o.tool)||((d=t.data)==null?void 0:d.name)||(l==="text"?jn(((a=t.data)==null?void 0:a.text)||((w=t.data)==null?void 0:w.content))?"External content":wn(((S=t.data)==null?void 0:S.text)||((N=t.data)==null?void 0:N.content)||"",{preserveProtocolTags:!0}).slice(0,80):"")||""}),e.jsx("span",{className:"text-neutral-400 shrink-0 tabular-nums",children:t.time?new Date(t.time).toLocaleTimeString():""})]}),s?e.jsx("pre",{className:"px-3 py-2.5 bg-stone-50 text-[11px] font-mono text-neutral-500 overflow-x-auto whitespace-pre-wrap break-all max-h-64 overflow-y-auto border-t border-neutral-200/80 leading-relaxed",children:JSON.stringify(t,null,2)}):null]})}function rs({agent:t,agentId:s,agentName:n,sizeClass:l="h-9 w-9"}){const o={...t||{},id:(t==null?void 0:t.id)||s,name:(t==null?void 0:t.name)||n};return e.jsx(An,{agent:o,sizeClass:l})}const Xt=(t="")=>["done","completed","failed","error","cancelled","stopped"].includes(String(t||"").toLowerCase()),La=new Set(["exec","bash","shell","sh","zsh","openclaw_exec","run_terminal_cmd","run_terminal_command","execute","execute_command","command","terminal","subprocess","process"]);function Me(t,s){if(!t||typeof t!="object")return"";for(const n of s){const l=t[n];if(typeof l=="string"&&l.trim())return l.trim();if(typeof l=="number"||typeof l=="boolean")return String(l)}return""}function ns(t){if(!t||typeof t!="string")return null;const s=t.trim();if(!s.startsWith("{")||!s.endsWith("}"))return null;try{const n=JSON.parse(s);return n&&typeof n=="object"?n:null}catch{return null}}function Qt(t=""){const s=String(t||"").trim().toLowerCase().replace(/[.-]/g,"_");return La.has(s)||s.includes("terminal")||s.includes("shell")||s.includes("exec")}function Ca(t={}){const s=t.params||{},n=t.args||t.arguments||{},l=t.input||{},o=ns(s),d=ns(n),a=["command","cmd","shell_command","shellCommand","line","script"];return Me(s,a)||Me(n,a)||Me(l,a)||Me(o,a)||Me(d,a)||Me(t,a)}function $a(t={}){const s=t.params||{},n=t.args||t.arguments||{},l=t.input||{},o=["cwd","workdir","workingDirectory","directory"];return Me(s,o)||Me(n,o)||Me(l,o)||Me(t,o)}function Ia(t=""){const s=Nn(t);return s.length>72?`${s.slice(0,69)}…`:s}function It(t){return t?new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):""}function ze({title:t,caption:s,children:n,className:l="",action:o=null}){return n?e.jsxs("section",{className:L("mb-4",l),children:[e.jsxs("div",{className:"mb-1.5 flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-widest text-neutral-400 leading-none",children:t}),s?e.jsx("div",{className:"mt-1 text-[11px] text-neutral-500 leading-snug",children:s}):null]}),o?e.jsx("div",{className:"shrink-0",children:o}):null]}),n]}):null}function Aa(t){if(!t)return{cleaned:"",toolLog:[],artifacts:[]};let s=[],n=[];return{cleaned:t.replace(/<!--\s*TOOL_LOG\s+([\s\S]*?)\s*\/TOOL_LOG\s*-->/g,(o,d)=>{try{const a=JSON.parse(d.trim());Array.isArray(a)&&(s=a)}catch{}return""}).replace(/<!--\s*TOOL_ACTIVITY[\s\S]*?-->/g,"").replace(/<!--[\s\S]*?-->/g,"").replace(/<artifact(?:\s+type="([^"]*)")?(?:\s+title="([^"]*)")?[^>]*>([\s\S]*?)<\/artifact>/gi,(o,d,a)=>(n.push({type:d||"code",title:a||"Artifact"}),"")).replace(/<(task)[^>]*>[\s\S]*?<\/\1>/gi,o=>"```xml\n"+o+"\n```").replace(/<(diff|plan|delivery)[^>]*>[\s\S]*?<\/\1>/gi,o=>
6"```xml\n"+o+"\n```").trim(),toolLog:s,artifacts:n}}const as={p:({children:t})=>e.jsx("div",{className:"mb-1.5 whitespace-pre-wrap break-words leading-relaxed last:mb-0 text-neutral-800",children:t}),a:({href:t,children:s})=>e.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"text-stone-700 underline decoration-stone-300/70 underline-offset-2 hover:text-neutral-900 hover:decoration-stone-500 transition-colors",children:s}),strong:({children:t})=>e.jsx("strong",{className:"font-semibold text-neutral-900",children:t}),ul:({children:t})=>e.jsx("ul",{className:"mb-2 list-disc pl-5 text-neutral-600 space-y-0.5",children:t}),ol:({children:t})=>e.jsx("ol",{className:"mb-2 list-decimal pl-5 text-neutral-600 space-y-0.5",children:t}),li:({children:t})=>e.jsx("li",{className:"break-words leading-relaxed",children:t}),h2:({children:t})=>e.jsx("h2",{className:"font-semibold mt-3.5 mb-1.5 text-[13px] text-neutral-900 tracking-tight",children:t}),h3:({children:t})=>e.jsx("h3",{className:"font-semibold mt-2.5 mb-1 text-[12px] text-neutral-800 tracking-tight",children:t}),h4:({children:t})=>e.jsx("h4",{className:"font-medium mt-2 mb-1 text-[12px] text-neutral-700",children:t}),pre:({children:t})=>e.jsx(e.Fragment,{children:t}),code:({inline:t,className:s,children:n})=>{const l=String(n).replace(/\n$/,""),o=/language-(\w+)/.exec(s||""),d=(o==null?void 0:o[1])||null;return t?e.jsx("code",{className:"px-1.5 py-0.5 bg-stone-100 border border-neutral-200/80 rounded-md text-[11px] font-mono text-neutral-700 break-all",children:n}):e.jsx("div",{className:"my-2 min-w-0",children:e.jsx(_e,{code:l,language:d,compact:!0})})},table:({children:t})=>e.jsx("div",{className:"my-2 overflow-x-auto rounded-xl border border-neutral-200/80",children:e.jsx("table",{className:"w-full text-[11px]",children:t})}),thead:({children:t})=>e.jsx("thead",{className:"bg-stone-50 text-neutral-500 font-medium",children:t}),th:({children:t})=>e.jsx("th",{className:"px-3 py-1.5 text-left border-b border-neutral-200/80 text-[10px] uppercase tracking-wider font-semibold text-neutral-400",children:t}),td:({children:t})=>e.jsx("td",{className:"px-3 py-1.5 border-b border-neutral-100 text-neutral-600",children:t}),tr:({children:t})=>e.jsx("tr",{className:"hover:bg-stone-50/60 transition-colors",children:t})};function Pa({tools:t}){return!t||t.length===0?null:e.jsx("div",{className:"mt-3 overflow-x-auto rounded-xl border border-neutral-200/80 bg-white",children:e.jsxs("table",{className:"w-full text-[11px]",children:[e.jsx("thead",{className:"bg-stone-50/80",children:e.jsx("tr",{children:["Tool","Parameters","Status","Result"].map((s,n)=>e.jsx("th",{className:L("px-3 py-2 text-[10px] uppercase tracking-wider font-semibold text-neutral-400 border-b border-neutral-200/80",n===2?"text-center w-12":"text-left"),children:s},s))})}),e.jsx("tbody",{children:t.map((s,n)=>e.jsxs("tr",{className:"hover:bg-stone-50/50 transition-colors",children:[e.jsx("td",{className:"px-3 py-2 border-b border-neutral-100 text-neutral-900 font-medium whitespace-nowrap",children:s.tool||"unknown"}),e.jsx("td",{className:"px-3 py-2 border-b border-neutral-100 text-neutral-500 max-w-[200px]",children:s.params?Object.entries(s.params).map(([l,o],d)=>e.jsxs("span",{className:"inline-flex items-baseline gap-0.5 mr-2",children:[e.jsxs("span",{className:"text-neutral-400 text-[10px]",children:[l,":"]}),e.jsx("span",{className:"text-neutral-600 truncate max-w-[120px] inline-block align-bottom",children:String(o).substring(0,60)})]},d)):e.jsx("span",{className:"text-neutral-300",children:"—"})}),e.jsx("td",{className:"px-3 py-2 border-b border-neutral-100 text-center",children:s.success===!1?"❌":"✅"}),e.jsx("td",{className:"px-3 py-2 border-b border-neutral-100 text-neutral-500 max-w-[200px] truncate",children:(s.summary||"").substring(0,80)})]},n))})]})})}function Ka({event:t,isLast:s,agent:n=null,agentName:l}){var Z,U,te,le,ie,pe,Te;const[o,d]=h.useState(!1),a=((Z=t.data)==null?void 0:Z.tool)||"unknown",w=String(a).toLowerCase(),S=kr(a),N=S.icon,k=(U=t.data)==null?void 0:U.success,P=((te=t.data)==null?void 0:te.summary)||"",C=((le=t.data)==null?void 0:le.raw)||"",ee=((ie=t.data)==null?void 0:ie.params)||{},x=ee&&typeof ee=="object"&&!Array.isArray(ee)?ee:ns(ee)||{},X=((pe=t.data)==null?void 0:pe.durationMs)||0,Q=Qt(a)?Ca(t.data||{}
6):"",ae=Qt(a)?$a(t.data||{}):"",K=Q||x.query||x.url||x.path||x.filePath||x.command||x.text||"",p=h.useMemo(()=>{var O;return Xn({tool:a,params:x,result:((O=t.data)==null?void 0:O.result)||null,summary:P,raw:C})},[a,x,(Te=t.data)==null?void 0:Te.result,P,C]),V=t.event==="tool_start",q=t.time,B=Q?`Running: ${Ia(Q)}`:_t(a,x)||S.label,Y=()=>{if(Qt(w)){const O=Q,z=ae;let c=C,E="";const A=C.match(/stderr[:\s]*([\s\S]*?)(?:\nstdout[:\s]*|$)/i),ue=C.match(/stdout[:\s]*([\s\S]*)$/i);A&&(E=A[1].trim()),ue&&(c=ue[1].trim());const We=(()=>{const ke=String(O||"").trim();return ke?ke.startsWith("$")?ke:`$ ${ke}`:""})();return e.jsxs("div",{className:"space-y-2.5",children:[O&&e.jsxs("div",{children:[e.jsx(D,{children:"Command"}),e.jsxs("div",{className:"relative group/pre min-w-0",children:[e.jsx(_e,{code:We,language:"bash",compact:!0}),e.jsx(Rt,{text:O})]})]}),z&&e.jsxs("div",{children:[e.jsx(D,{children:"Working directory"}),e.jsx(it,{children:z})]}),c&&e.jsxs("div",{children:[e.jsx(D,{children:"Output"}),e.jsxs("div",{className:"relative group/pre min-w-0",children:[e.jsx(_e,{code:c,compact:!0}),e.jsx(Rt,{text:c})]})]}),E&&e.jsxs("div",{children:[e.jsx(D,{danger:!0,children:"Error output"}),e.jsxs("div",{className:"relative group/pre",children:[e.jsx("pre",{className:"rounded-xl bg-red-50 border border-red-200/80 p-2.5 overflow-x-auto text-[11px] leading-relaxed whitespace-pre-wrap break-all text-red-700",children:E}),e.jsx(Rt,{text:E})]})]})]})}if(w==="memory_search"||w==="memory_get")return e.jsxs("div",{className:"space-y-2.5",children:[x.query&&e.jsxs("div",{children:[e.jsx(D,{children:"Query"}),e.jsx(it,{children:x.query})]}),x.path&&e.jsxs("div",{children:[e.jsx(D,{children:"Path"}),e.jsx(it,{children:x.path})]}),C&&e.jsxs("div",{children:[e.jsx(D,{children:"Matches"}),e.jsx("div",{className:"min-w-0",children:e.jsx(_e,{code:C,compact:!0})})]})]});if(w==="read"||w==="write"||w==="edit"||w==="apply_patch"||w.includes("diff")||w.includes("patch")){const O=x.path||x.file_path||x.filePath||"";return e.jsxs("div",{className:"space-y-2.5",children:[O&&e.jsxs("div",{children:[e.jsx(D,{children:"File"}),e.jsx(it,{mono:!0,children:O})]}),(p==null?void 0:p.diffText)&&e.jsxs("div",{children:[e.jsx(D,{children:"Changes"}),e.jsx(UnifiedDiffCard,{diffText:p.diffText})]}),C&&!(p!=null&&p.diffText)&&e.jsxs("div",{children:[e.jsx(D,{children:"Result"}),e.jsx("div",{className:"min-w-0",children:e.jsx(_e,{code:C,compact:!0})})]}),w==="write"&&(x.content||x.new_string)&&e.jsxs("div",{children:[e.jsx(D,{children:"Content written"}),e.jsx("div",{className:"min-w-0",children:e.jsx(_e,{code:`${(x.content||x.new_string||"").slice(0,2e3)}${(x.content||x.new_string||"").length>2e3?`
7…truncated`:""}`,language:(()=>{var c;const z=((c=(O||"").split(".").pop())==null?void 0:c.toLowerCase())||"";return z==="json"?"json":["yml","yaml"].includes(z)?"yaml":z==="py"?"python":z==="tsx"?"tsx":z==="jsx"?"jsx":z==="ts"?"typescript":["js","mjs","cjs"].includes(z)?"javascript":null})(),compact:!0})})]})]})}if(/^browser/i.test(w)||w==="browse"){const O=x.url||x.goto||"",z=x.action||x.kind||w.replace("browser_",""),c=x.selector||x.ref||x.element||"",E=x.text||"";return e.jsxs("div",{className:"space-y-2.5",children:[O&&e.jsxs("div",{children:[e.jsx(D,{children:"URL"}),e.jsx("a",{href:O,target:"_blank",rel:"noopener noreferrer",className:"text-[11px] text-stone-700 hover:underline break-all",children:O})]}),z&&z!=="browser"&&e.jsxs("div",{className:"text-[11px] text-neutral-500",children:[e.jsx("span",{className:"text-neutral-400",children:"Action:"})," ",z,c?` → ${c}`:"",E?` "${E}"`:""]}),C&&e.jsxs("div",{children:[e.jsx(D,{children:"Result"}),e.jsx("div",{className:"min-w-0",children:e.jsx(_e,{code:C,compact:!0})})]})]})}if(/search/i.test(w)&&w!=="memory_search"){const O=x.query||x.q||"";return e.jsxs("div",{className:"space-y-2.5",children:[O&&e.jsxs("div",{children:[e.jsx(D,{children:"Query"}),e.jsxs("div",{className:"text-[12px] font-medium text-neutral-900 bg-stone-50 border border-neutral-200/80 rounded-lg px-2.5 py-1.5 flex items-center gap-1.5",children:[e.jsx("span",{className:"text-neutral-400 text-[11px]",children:"🔍"}),O]})]}),C&&e.jsxs("div",{children:[e.jsx(D,{children:"Results"}),e.jsx("div",{className:"min-w-0",children:e.jsx(_e,{code:C,compact:!0})})]})]})}return e.jsxs("div",{className:"space-y-2.5",children:[Object.keys(x).length>0&&e.jsxs("div",{children:[e.jsx(D,{children:"Parameters"}),e.jsx("div",{className:"min-w-0",children:e.jsx(_e,{code:JSON.stringify(x,null,2),language:"json",compact:!0})})]}),P&&e.jsxs("div",{children:[e.jsx(D,{children:"Summary"}),e.jsx($r,{remarkPlugins:[es,ts],components:as,children:Yt(P)})]}),C&&C!==P&&e.jsxs("div",{children:[e.jsx(D,{children:"Raw result"}),e.jsx("div",{className:"min-w-0",children:e.jsx(_e,{code:C,compact:!0})})]})]})};return e.jsxs("div",{className:"flex gap-3 min-w-0 relative group/tool",children:[!s&&e.jsx("span",{className:L("absolute w-px",ne.line),style:{left:13,top:28,bottom:-8}}),e.jsx("div",{className:"relative flex-shrink-0 z-10",children:n?e.jsxs("div",{className:"relative",children:[e.jsx(rs,{agent:n,agentId:n.id,agentName:l,sizeClass:"h-7 w-7"}),e.jsx("div",{className:L("absolute -bottom-1 -right-1 w-4 h-4 rounded-full flex items-center justify-center border-2 border-white",V?"bg-amber-400 text-white":k===!1?"bg-red-400 text-white":"bg-stone-100 text-neutral-500"),
7children:e.jsx(N,{className:"w-2.5 h-2.5"})})]}):e.jsx("div",{className:L("w-7 h-7 rounded-full flex items-center justify-center border-2 transition-colors",V?"bg-amber-50 text-amber-500 border-amber-200":k===!1?"bg-red-50 text-red-500 border-red-200":"bg-white text-neutral-400 border-neutral-200"),children:e.jsx(N,{className:"w-3.5 h-3.5"})})}),e.jsxs("div",{className:"flex-1 min-w-0 pb-4",children:[e.jsxs(ct,{variant:"ghost",type:"button",onClick:()=>d(!o),className:"flex items-center gap-2 w-full text-left h-auto p-0 group/btn",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:L("text-[13px] font-medium truncate block leading-snug",V?"text-neutral-900":"text-neutral-500 group-hover/btn:text-neutral-800 transition-colors"),children:B}),K&&e.jsx("span",{className:"text-[11px] text-neutral-400 truncate block mt-0.5 leading-snug",children:K})]}),o?e.jsx(oa,{className:"w-3.5 h-3.5 text-neutral-400 flex-shrink-0"}):P||Object.keys(x).length>0||C?e.jsx(ls,{className:"w-3.5 h-3.5 text-neutral-400 flex-shrink-0"}):null,V?e.jsx(Mt,{size:14,className:"flex-shrink-0"}):e.jsxs("span",{className:"text-[11px] text-neutral-400 opacity-0 group-hover/tool:opacity-100 transition-opacity flex-shrink-0 tabular-nums",children:[X?`${(X/1e3).toFixed(1)}s`:"",q?` · ${It(q)}`:""]})]}),o&&e.jsx("div",{className:"mt-2.5 min-w-0 space-y-2 pl-3 border-l-2 border-neutral-200/70 text-[12px] text-neutral-600 leading-relaxed",children:Y()})]})]})}function D({children:t,danger:s=!1}){return e.jsx("div",{className:L("text-[10px] uppercase tracking-widest font-semibold mb-1 leading-none",s?"text-red-500":"text-neutral-400"),children:t})}function it({children:t,mono:s=!1}){return e.jsx("div",{className:L("text-[11px] text-neutral-800 rounded-lg border border-neutral-200/80 bg-stone-50 px-2.5 py-1.5 break-all",s&&"font-mono"),children:t})}function at({value:t,maxHeight:s="max-h-96"}){return e.jsx("pre",{className:L("overflow-auto rounded-xl border border-neutral-200/80 bg-stone-50 p-3.5 text-[11px] leading-relaxed text-neutral-600 whitespace-pre-wrap break-words",s),children:JSON.stringify(t??{},null,2)})}function Vt(t,s=10,n=6){const l=String(t||"").trim();return l?l.length<=s+n+1?l:`${l.slice(0,s)}…${l.slice(-n)}`:""}function lt({label:t,value:s,mono:n=!1,title:l}){if(s==null||s==="")return null;const o=String(s);return e.jsxs("div",{className:"grid grid-cols-[7.5rem_minmax(0,1fr)] items-start gap-x-3 gap-y-0.5 py-1.5",children:[e.jsx("span",{className:"text-[11px] font-medium text-neutral-400 pt-0.5",children:t}),e.jsx("span",{className:L("min-w-0 break-all text-[12px] text-neutral-800",n&&"font-mono text-[11px] text-neutral-600"),title:l||o,children:o})]})}function ot({title:t,caption:s,children:n,className:l}){return e.jsxs("section",{className:L("space-y-2.5",l),children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx("h3",{className:"text-[11px] font-semibold uppercase tracking-[0.08em] text-neutral-400",children:t}),s?e.jsx("p",{className:"text-[11px] leading-snug text-neutral-400",children:s}):null]}),n]})}function $e({title:t,meta:s,children:n,defaultOpen:l=!1}){const[o,d]=h.useState(!!l);return e.jsxs("div",{className:"rounded-xl border border-neutral-200/80 bg-white overflow-hidden",children:[e.jsxs("button",{type:"button",className:"flex w-full cursor-pointer items-center gap-2 px-3.5 py-2.5 text-left text-[12px] font-medium text-neutral-600 transition-colors hover:bg-stone-50 select-none","aria-expanded":o,onClick:a=>{a.preventDefault(),a.stopPropagation(),d(w=>!w)},onPointerDown:a=>a.stopPropagation(),children:[e.jsx(os,{className:L("h-3.5 w-3.5 shrink-0 text-neutral-400 transition-transform duration-150",o&&"rotate-90")}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:t}),s?e.jsx("span",{className:"shrink-0 text-[11px] font-normal text-neutral-400",children:s}):null]}),o?e.jsx("div",{className:"border-t border-neutral-100 px-3.5 py-3",children:n}):null]})}function Et(t,s="Unknown"){const n=String(t||"").trim();return n?n.replace(/[_-]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,l=>l.toUpperCase()):s}function qa(t){const s=String(t||"").trim().toLowerCase();return s?{web_app:"Web app",mac_app:"Mac app",mac_helper:"Mac helper",trooper_mac_helper:"Mac helper",chrome_extension:"Chrome extension",telegram:"Telegram",whatsapp:"WhatsApp",slack:"Slack",api:"API",automation:"Automation",background:"Backgroun
7d job",windows_app:"Windows app",mobile_app:"Mobile app",ios_app:"iOS app",android_app:"Android app",message_handler:"Message handler",task_comment:"Task comment"}[s]||Et(s):"Unknown"}function Ba(t){const s=String(t||"").trim().toLowerCase();return s?{mac_helper_overlay:"Mac helper overlay",web_chat:"Web chat",chrome_extension:"Chrome extension",message_handler:"Message handler"}[s]||Et(s):null}function wr(t,s=""){const n=Number(t);return!Number.isFinite(n)||n<=0?null:`${n.toLocaleString()}${s}`}function Ar(t){const s=(t==null?void 0:t.data)||{},n=[];for(const o of[s.text,s.content,s.rawContent,s.raw_text,s.rawText,s.full_text,s.fullText,s.message,s.summary,s.delta,s.chunk,s.finalText,s.final_text])typeof o=="string"&&o&&n.push(o);const l=n.some(o=>/<(?:audio_response|audio)\b|<screen_/i.test(o));try{const o=JSON.stringify(s);!l&&/<(?:audio_response|audio)\b|<screen_/i.test(o)&&n.push(o)}catch{}return n}function Fa(t=[],s=""){const n=[],l=[],o=new Set,d=new Set,a=(S,N)=>{const k=S.replace(/\s+/g," ").trim().toLowerCase();!k||o.has(k)||(o.add(k),n.push({text:S,event:(N==null?void 0:N.event)||"content",time:(N==null?void 0:N.time)||(N==null?void 0:N.timestamp)||null}))},w=(S,N)=>{const k=S.replace(/\s+/g," ").trim();!k||d.has(k)||(d.add(k),l.push({tag:S,event:(N==null?void 0:N.event)||"content",time:(N==null?void 0:N.time)||(N==null?void 0:N.timestamp)||null}))};for(const S of Array.isArray(t)?t:[])for(const N of Ar(S))ur(N).forEach(k=>a(k,S)),mr(N).forEach(k=>w(k,S));if(s){const S={event:"message_raw",time:null};ur(s).forEach(N=>a(N,S)),mr(s).forEach(N=>w(N,S))}return{audio:n,screen:l}}function ge({children:t,mono:s=!1}){return t?e.jsx("span",{className:L("inline-flex max-w-full items-center rounded-full border border-neutral-200 bg-white px-2 py-0.5 text-[11px] text-neutral-600",s&&"font-mono"),children:e.jsx("span",{className:"truncate",children:t})}):null}function Ua({source:t}){var P,C,ee,x,X,Q,ae;if(!t)return null;const s=t.nativeScreenContext||null,n=(s==null?void 0:s.desktopContext)||null,l=Ba(t.responseTarget||(s==null?void 0:s.responseTarget)),o=t.helperDeliveryId||(s==null?void 0:s.helperDeliveryId)||"",d=wr((P=t.helperTimings)==null?void 0:P.screenshotBytes," bytes"),a=wr(((C=t.helperTimings)==null?void 0:C.screenshotMs)||((ee=t.helperTimings)==null?void 0:ee.captureMs),"ms"),w=s!=null&&s.width&&(s!=null&&s.height)?`${s.width} x ${s.height}`:null,S=(n==null?void 0:n.frontmostApp)||((X=(x=n==null?void 0:n.apps)==null?void 0:x.find(K=>K==null?void 0:K.isActive))==null?void 0:X.name)||null,N=(n==null?void 0:n.frontmostWindow)||((ae=(Q=n==null?void 0:n.windows)==null?void 0:Q.find(K=>K==null?void 0:K.isActive))==null?void 0:ae.title)||null,k=(s==null?void 0:s.transcript)||null;return e.jsx(ze,{title:"Message source",caption:"Where this request entered Trooper",children:e.jsxs("div",{className:"rounded-xl border border-neutral-200/80 bg-stone-50/70 p-3.5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx("span",{className:"text-[12px] font-semibold text-neutral-900",children:qa(t.sourceSurface||(s==null?void 0:s.sourceSurface))}),l&&e.jsx(ge,{children:l}),t.channel&&e.jsxs(ge,{children:["#",t.channel]}),t.messageId&&e.jsx(ge,{mono:!0,children:String(t.messageId).slice(0,10)}),o&&e.jsx(ge,{mono:!0,children:String(o).slice(0,18)})]}),t.textPreview?(()=>{const K=Sr(t.textPreview);if(K)return e.jsx("div",{className:"mt-2.5",children:e.jsx(Cr,{answer:K})});const p=Ct(t.textPreview);return p?e.jsx("div",{className:"mt-2.5 rounded-lg border border-neutral-200/70 bg-white px-3 py-2.5 text-[13px] leading-relaxed text-neutral-700 whitespace-pre-wrap break-words",children:p}):null})():null,e.jsxs("div",{className:"mt-2.5 flex flex-wrap gap-1.5",children:[t.browserScreenshotSource&&e.jsx(ge,{children:Et(t.browserScreenshotSource)}),t.browserMode&&e.jsx(ge,{children:Et(t.browserMode)}),(s==null?void 0:s.contextId)&&e.jsx(ge,{mono:!0,children:String(s.contextId).slice(0,22)}),s!=null&&s.hasScreenshot?e.jsx(ge,{children:"Screenshot attached"}):null,s!=null&&s.hasAnnotations?e.jsx(ge,{children:s.annotationCount?`${s.annotationCount} annotations`:"Annotations attached"}):null,w&&e.jsx(ge,{children:w}),d&&e.jsx(ge,{children:d}),a&&e.jsx(ge,{children:a}),S&&e.jsx(ge,{children:S}),N&&e.jsx(ge,{children:N})]}),k!=null&&k.raw||k!=null&&k.refined?e.jsxs("div",{className:"mt-2 grid gap-2 sm:grid-cols-2",children:[k.raw&&e.jsxs("div",{children:[e.jsx(D,{children:"Speech input"}),e.jsx(it,{children:k.raw})]}),k.refined&&k.refined!==k.raw&&e.jsxs("div",{children:[e.jsx(D,{children:"Refined text"}),e.jsx(it,{children:k.refined})]})]}):null]})})}function Oa({evidence:t}){const s=(t==null?void 0:t.audio)||[],n=(t==null?void 0:t.screen)||[];return!s.length&&!n.length?null:e.jsx(ze,{title:"Mac helper protocol",caption:"Hidden speech and drawing payloads delivered with this run",className:"mb-3",children:e.jsxs("div",{className:"grid gap-3",children:[s.length>0&&e.jsxs("div",{className:"rounded-xl border border-neutral-200/80 bg-stone-50/70 p-3",children:[e.jsx(D,{children:"Spoken audio checkpoints"}),e.jsx("div",{className:"space-y-1.5",children:s.map((l,o)=>e.jsxs("div",{className:"rounded-lg border border-neutral-200/70 bg-white px-2.5 py-2 text-[12px] leading-relaxed text-neutral-700",children:[e.jsxs("div",{className:"mb-1 flex items-center gap-1.5 text-[10px] uppercase tracking-wider text-neutral-400",children:[e.jsx("span",{children:l.event}),l.time?e.jsx("span",{children:It(l.time)}):null]}),l.text]},`${l.event}-${o}-${l.text}`))})]}),n.length>0&&e.jsxs("div",{className:"rounded-xl border border-neutral-200/80 bg-stone-50/70 p-3",children:[e.jsx(D,{children:"Screen drawings and clicks"}),e.jsx("div",{className:"space-y-1.5",children:n.map((l,o)=>e.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words rounded-lg border border-neutral-200/70 bg-white px-2.5 py-2 font-mono text-[11px] leading-relaxed text-neutral-700",children:l.tag},`${l.event}-${o}-${l.tag}`))})]})]})})}function Ha({type:t,title:s}){const l={react:"⚛️",html:"🌐",code:"💻",text:"📄"}[t]||"📦";return e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5 rounded-xl border border-neutral-200/80 bg-white hover:bg-stone-50 transition-colors mt-2 mb-1 shadow-[0_1px_3px_rgba(28,25,23,0.05)] cursor-pointer",children:[e.jsx("span",{className:"text-base leading-none",children:l}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-[12px] font-semibold text-neutral-900 truncate leading-snug",children:s}),e.jsx("div",{className:"text-[10px] text-neutral-400 mt-0.5",children:t==="react"?"React component":t==="html"?"HTML":"Generated code"})]}),e.jsx("span",{className:"text-[11px] text-neutral-400 hover:text-neutral-700 transition-colors shrink-0",children:"↗"})]})}
7function za({label:t,detail:s,isLast:n,isError:l,time:o}){return e.jsxs("div",{className:"flex gap-3 min-w-0 relative",children:[!n&&e.jsx("span",{className:L("absolute w-px opacity-70",ne.line),style:{left:13,top:0,bottom:-8}}),e.jsx("div",{className:"w-7 flex-shrink-0 flex justify-center pt-1",children:e.jsx("div",{className:L("w-2.5 h-2.5 rounded-full border-2",l?"bg-red-400 border-red-200":t==="Completed"?"bg-emerald-500 border-emerald-200":t==="Started"?"bg-amber-400 border-amber-100":"bg-stone-300 border-neutral-200")})}),e.jsx("div",{className:"flex-1 min-w-0 pb-2.5",children:e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:L("text-[11px] font-semibold leading-snug",l?"text-red-600":t==="Completed"?"text-emerald-600":"text-neutral-500"),children:t}),s&&e.jsx("span",{className:"text-[11px] text-neutral-400 truncate leading-snug",children:s}),o&&e.jsx("span",{className:"text-[11px] text-neutral-400 ml-auto flex-shrink-0 tabular-nums",children:It(o)})]})})]})}function Wa({text:t,isLast:s,isStreaming:n=!1}){const{cleaned:l,toolLog:o,artifacts:d}=Aa(t);return!l&&o.length===0&&d.length===0?null:e.jsxs("div",{className:"flex gap-3 min-w-0 relative",children:[!s&&e.jsx("span",{className:L("absolute w-px opacity-70",ne.line),style:{left:13,top:0,bottom:-8}}),e.jsx("div",{className:"w-7 flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0 pb-4",children:[n&&e.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5 text-[11px] text-neutral-400",children:[e.jsx(Mt,{size:12,className:"shrink-0"}),e.jsx("span",{children:"Writing response…"})]}),l&&e.jsx("div",{className:L("text-[13px] text-neutral-800 leading-relaxed py-0.5 min-w-0",n&&"pl-2.5 border-l-2 border-violet-200/50"),children:n?e.jsx(Qn,{content:Yt(l),streaming:!0,remarkPlugins:[es,ts],components:as}):e.jsx($r,{remarkPlugins:[es,ts],components:as,children:Yt(l)})}),d.map((a,w)=>e.jsx(Ha,{type:a.type,title:a.title},w)),o.length>0&&e.jsx(Pa,{tools:o})]})]})}function Da(t={}){const s=Lr(t);if(s)return s;const n=Number(t.inputTokens||0),l=Number(t.outputTokens||0),o=Number(t.totalTokens||0);return n>0||l>0?`${Math.round(n).toLocaleString()} in · ${Math.round(l).toLocaleString()} out`:o>0?`${Math.round(o).toLocaleString()} tokens`:t.estimated?"estimated tokens pending":"no token usage reported"}function Ja({breakdown:t=null,runtimeUsage:s=null,run:n=null,forceVisible:l=!1}){var ae,K;const o=Array.isArray(t==null?void 0:t.rows)?t.rows.filter(Boolean):[],d=Array.isArray(s==null?void 0:s.models)?s.models:[],a=d.length?d.slice(0,3):l&&(n!=null&&n.model||(ae=n==null?void 0:n.metadata)!=null&&ae.model)?[{model:n.model||((K=n.metadata)==null?void 0:K.model)}]:[],w=!o.length&&l?a.map((p,V)=>{var ie,pe,Te;const q=p.model||p.id||p.fullLabel||(n==null?void 0:n.model)||((ie=n==null?void 0:n.metadata)==null?void 0:ie.model)||"",B=p.provider||p.routingProvider||((Te=(pe=s==null?void 0:s.providers)==null?void 0:pe[0])==null?void 0:Te.provider)||(n==null?void 0:n.provider)||"Provider",Y=Number((t==null?void 0:t.inputTokens)??(n==null?void 0:n.inputTokens)??0),Z=Number((t==null?void 0:t.outputTokens)??(n==null?void 0:n.outputTokens)??0),U=Number((t==null?void 0:t.totalTokens)??(n==null?void 0:n.totalTokens)??0),te=Kn({model:q,provider:B,run:n,runtimeUsage:s}),le=qn({model:te.model,provider:te.provider,usage:{inputTokens:Y,outputTokens:Z,totalTokens:U}});return{id:`fallback-${V}`,provider:te.provider||B,model:te.model||q,inputTokens:Y,outputTokens:Z,totalTokens:U,costUsd:le}}):[],S=o.length?o:w,N=Bn(S);if(!S.length&&!(t!=null&&t.totalCostUsd)&&!l)return null;const k=S.map(p=>Zt(p)),P=k.some(p=>p.id==="estimated"&&p.label.includes("message size")),C=k.some(p=>p.id==="estimated"),ee=k.some(p=>p.id==="unavailable"),x=k.some(p=>p.id!=="actual"),X=k.some(p=>p.id==="actual"),Q=S.length?P?"Approximate cost from message size — provider token metering was not reported for this run":ee?X||C?"Some provider charges are unavailable; the listed rows keep their own cost source":"Provider cost was not reported for this run":C?X?"Includes provider-reported charges and estimated rows":"Estimated from reported usage and configured pricing":"Provider-reported charges for this run":"Usage was recorded, but provider pricing was not available for this run";return e.jsx(ze,{title:"Run cost",caption:Q,className:"mt-6",children:e.jsxs("div",{className:"overflow-hidden rounded-xl border border-neutral-200 bg-white",children:[S.length?N.map((p,V)=>e.jsxs("div",{className:"min-h-0",children:[e.jsxs("div",{className:L("grid grid-cols-[minmax(0,1fr)_auto] gap-3 px-3 py-1.5 text-[10px] font-semibold uppercase tracking-wide text-neutral-400",V===0?"bg-stone-50":"border-t border-neutral-100 bg-stone-50/70"),children:[e.jsx("span",{children:N.length>1?p.label:"Provider · model / tool"}),e.jsx("span",{className:"text-right",children:V===0?"Cost":" "})]}),p.rows.map((q,B)=>{const Y=Zt(q),Z=Fn(q,{run:n,runtimeUsage:s});return e.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] gap-3 border-b border-neutral-100 px-3 py-2.5 last:border-b-0",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[e.jsx("div",{className:"truncate text-[12px] font-semibold text-neutral-800",children:Z.primary}),e.jsx("span",{title:Y.label,className:L("shrink-0 rounded-full px-1.5 py-0.5 text-[9px] font-semibold uppercase tracking-wide",Y.id==="actual"?"bg-emerald-50 text-emerald-700":Y.id==="unavailable"?"bg-stone-100 text-stone-500":"bg-amber-50 text-amber-700"),children:Y.shortLabel})]}),Z.secondary?e.jsx("div",{className:"truncate text-[11px] text-neutral-500",children:Z.secondary}):null,e.jsx("div",{className:"mt-0.5 text-[10px] tabular-nums text-neutral-400",children:Da(q)})]}),e.jsx("div",{className:"self-center text-right text-[12px] font-semibold tabular-nums text-neutral-700",children:Gt(q.costUsd,q)||(Lr(q)?Y.id==="unavailable"?"Cost unavailable":"$0.00":Number(q.inputTokens)>0||Number(q.outputTokens)>0||Number(q.totalTokens)>0?Y.id==="unavailable"?"Cost unavailable":"rate unavailable":"awaiting usage")})]},q.id||`${q.provider||"provider"}-${q.model||"model"}-${B}`)})]}
7,p.id)):e.jsx("div",{className:"px-3 py-3 text-[12px] text-neutral-500",children:"No provider usage payload was reported for this run, so Trooper cannot price it yet."}),t!=null&&t.totalCostUsd?e.jsxs("div",{className:"flex items-center justify-between gap-3 border-t border-neutral-100 bg-stone-50 px-3 py-2 text-[12px] font-semibold text-neutral-800",children:[e.jsx("span",{children:"Total"}),e.jsx("span",{className:"tabular-nums",title:x?"Includes estimates or excludes unavailable provider charges":"Provider-reported total",children:Gt(t.totalCostUsd,{costSource:x?"service_price_estimate":"provider_reported",estimated:x})})]}):null]})})}function Ra({events:t,aggregate:s=null,runtimeUsage:n=null,showRuntimeBadges:l=!0,hideTokenUsage:o=!1}){var x,X,Q,ae,K;const d=h.useMemo(()=>{var O,z,c;if(!(t!=null&&t.length))return null;const p=t.find(E=>E.event==="start"),V=[...t].reverse().find(E=>E.event==="done"),q=t.filter(E=>E.event==="tool_start"),B=t.filter(E=>E.event==="tool_result"),Y=B.filter(E=>{var A;return((A=E.data)==null?void 0:A.success)===!1}),Z=t.find(E=>{var A;return E.event==="model_start"&&((A=E.data)==null?void 0:A.model)}),U=yr(t),te=p&&V?V.time-p.time:0,le=[];for(const E of q){const A=(O=E.data)==null?void 0:O.index,ue=B.find(We=>{var ke;return((ke=We.data)==null?void 0:ke.index)===A&&We.time>E.time});ue&&le.push({tool:((z=E.data)==null?void 0:z.tool)||"?",ms:ue.time-E.time})}le.sort((E,A)=>A.ms-E.ms);const ie=new Map;for(const E of le){const A=String(E.tool||"?").trim()||"?",ue=ie.get(A)||{tool:A,totalMs:0,count:0};ue.totalMs+=E.ms,ue.count+=1,ie.set(A,ue)}const pe=[...ie.values()].sort((E,A)=>A.totalMs-E.totalMs),Te=pe.reduce((E,A)=>E+A.totalMs,0);return{totalMs:te,toolCount:q.length,errorCount:Y.length,model:(c=Z==null?void 0:Z.data)==null?void 0:c.model,usage:U,toolDurations:le,toolTotals:pe,totalToolMs:Te}},[t]),a=((x=s==null?void 0:s.latestContextBudget)==null?void 0:x.roundedUsage)!=null,w=((s==null?void 0:s.compactionCount)||0)>0,S=((X=n==null?void 0:n.providers)==null?void 0:X.slice(0,2))||[],N=((Q=n==null?void 0:n.models)==null?void 0:Q.slice(0,2))||[];if(!d||!d.totalMs&&!d.toolCount&&!a&&!w)return null;const k=p=>p<1e3?`${p}ms`:p<6e4?`${(p/1e3).toFixed(1)}s`:`${Math.floor(p/6e4)}m ${Math.floor(p%6e4/1e3)}s`,P=["bg-stone-600","bg-stone-400","bg-amber-500","bg-emerald-500","bg-stone-700","bg-amber-400","bg-stone-300","bg-emerald-600"],C=["text-stone-700","text-stone-500","text-amber-700","text-emerald-600","text-stone-600"],ee=!!(d.usage&&!o&&(Number(d.usage.inputTokens??d.usage.input_tokens)>0||Number(d.usage.outputTokens??d.usage.output_tokens)>0||Number(d.usage.totalTokens??d.usage.total_tokens)>0));return e.jsxs("div",{className:L("space-y-2 bg-white px-3 py-2.5 sm:px-4",ne.chromeHairline),children:[e.jsxs("div",{className:"flex flex-col gap-1.5 sm:flex-row sm:items-center sm:justify-between sm:gap-2",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-x-2.5 gap-y-1.5 text-[11px]",children:[l&&e.jsxs(e.Fragment,{children:[S.map(p=>e.jsx("span",{className:L(ne.chip,"font-sans"),children:p.label},`runtime-provider-${p.id}`)),N.length>0?N.map(p=>e.jsx("span",{className:ne.chip,children:p.label},`runtime-model-${p.id}`)):d.model?e.jsx("span",{className:ne.chip,children:gn(d.model).fullModelLabel||Pn(d.model)}):null]}),d.totalMs>0&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-neutral-500",children:[e.jsx(vr,{className:"h-3 w-3 shrink-0 opacity-50","aria-hidden":!0}),k(d.totalMs)]}),d.toolCount>0&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-neutral-500",children:[e.jsx(bn,{className:"h-3 w-3 shrink-0 opacity-50","aria-hidden":!0}),d.toolCount," tool",d.toolCount!==1?"s":""]}),a&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-neutral-500",children:[e.jsx(Lt,{className:"h-3 w-3 shrink-0 opacity-50","aria-hidden":!0}),s.latestContextBudget.roundedUsage,"% context"]}),w&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-neutral-500",children:[e.jsx(ls,{className:"h-3 w-3 shrink-0 opacity-50","aria-hidden":!0}),s.compactionCount," compact",s.compactionCount!==1?"s":""]}),d.errorCount>0&&e.jsxs("span",{className:"font-semibold text-red-600",children:[d.errorCount," failed"]})]}),ee&&e.jsxs("span",{className:"shrink-0 tabular-nums text-[11px] text-neutral-400",children:[((ae=d.usage.inputTokens??d.usage.input_tokens)==null?void 0:ae.toLocaleStr
7ing())||"?"," in"," · ",((K=d.usage.outputTokens??d.usage.output_tokens)==null?void 0:K.toLocaleString())||"?"," out"]})]}),d.totalToolMs>0&&d.toolTotals.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-widest text-neutral-400",title:"Each segment is that tool's share of all measured tool durations.",children:"Time by tool"}),e.jsx("div",{className:"flex h-1.5 overflow-hidden rounded-full bg-stone-200/80 ring-1 ring-inset ring-black/[0.04]",children:(()=>{const V=d.toolTotals,q=[];let B=0,Y=0;V.forEach((U,te)=>{te<10?q.push(U):(B+=U.totalMs,Y+=U.count)}),B>0&&q.push({tool:"__other__",totalMs:B,count:Y,_isOther:!0});const Z=d.totalToolMs||1;return q.map((U,te)=>{const le=Math.max(.5,U.totalMs/Z*100),ie=U._isOther?`Other tools (${U.count} calls) · ${k(U.totalMs)}`:`${_t(U.tool)} · ${k(U.totalMs)}${U.count>1?` · ${U.count}×`:""}`;return e.jsx("div",{className:`${P[te%P.length]} h-full min-w-[2px] transition-[width]`,style:{width:`${le}%`},title:ie},U._isOther?"__other__":U.tool)})})()}),e.jsx("div",{className:"grid max-h-[min(11rem,40vh)] grid-cols-1 gap-x-4 gap-y-1 overflow-y-auto text-[11px] sm:grid-cols-2",children:d.toolTotals.map((p,V)=>e.jsxs("div",{className:"flex min-w-0 items-baseline justify-between gap-2 pb-0.5",children:[e.jsxs("span",{className:L("min-w-0 truncate font-medium",C[V%C.length]),title:_t(p.tool),children:[_t(p.tool),p.count>1?e.jsxs("span",{className:"ml-1 font-normal text-neutral-400",children:["×",p.count]}):null]}),e.jsx("span",{className:"shrink-0 tabular-nums text-neutral-500",children:k(p.totalMs)})]},p.tool))})]})]})}function Gl({isOpen:t,onClose:s,events:n,agentName:l,agentAvatar:o,isLive:d,agentId:a,runI
7d:w,sessionKey:S,messageId:N=null,requestSource:k,debugTrace:P,streamingText:C,timelineEntries:ee,rawContent:x,suppressFinalResponse:X=!1,acpSessionId:Q=null,onOpenSideWorkspace:ae=null,verificationGate:K=null}){var Es,Ls,Cs,$s,Is,As,Ps,Ks,qs,Bs,Fs;const p=Se(r=>r.activeToolEvents),V=Se(r=>r.agents),q=Se(r=>r.streamingChunks),B=Se(r=>r.lastBrowserRecording),Y=Se(r=>r.liveRunsBySession),Z=Se(r=>r.typingAgents),U=Se(r=>r.browserLiveView),te=Se(r=>r.openClawLaneSessionEntries),le=Se(r=>r.toolTimeline),ie=h.useRef(null),[pe,Te]=h.useState("timeline"),[O,z]=h.useState(null),[c,E]=h.useState(null),[A,ue]=h.useState(null),[We,ke]=h.useState(!1),[Xa,Ie]=h.useState(!1),[At,Pr]=h.useState(0),[is,Pt]=h.useState(null),[cs,wt]=h.useState(be),Kr=Array.isArray(n)&&((Ls=(Es=[...n].reverse().find(r=>{var i;return(i=r==null?void 0:r.data)==null?void 0:i.runId}))==null?void 0:Es.data)==null?void 0:Ls.runId)||null,qr=Array.isArray(n)&&(($s=(Cs=[...n].reverse().find(r=>{var i;return(i=r==null?void 0:r.data)==null?void 0:i.sessionKey}))==null?void 0:Cs.data)==null?void 0:$s.sessionKey)||null,Br=h.useMemo(()=>{var i,b,T;if(!d||!a)return null;let r=null;for(const I of Object.values(p||{}))for(const u of I||[])((i=u==null?void 0:u.data)==null?void 0:i.agentId)!==a||!((b=u==null?void 0:u.data)!=null&&b.runId)||(!r||((u==null?void 0:u.time)||0)>=((r==null?void 0:r.time)||0))&&(r=u);return((T=r==null?void 0:r.data)==null?void 0:T.runId)||null},[d,a,p]),Fr=h.useMemo(()=>{var i,b,T;if(!d||!a)return null;let r=null;for(const I of Object.values(p||{}))for(const u of I||[])((i=u==null?void 0:u.data)==null?void 0:i.agentId)!==a||!((b=u==null?void 0:u.data)!=null&&b.sessionKey)||(!r||((u==null?void 0:u.time)||0)>=((r==null?void 0:r.time)||0))&&(r=u);return((T=r==null?void 0:r.data)==null?void 0:T.sessionKey)||null},[d,a,p]),f=w||Kr||Br||null,_=S||qr||Fr||null,j=h.useMemo(()=>a?ln(Y,a,{preferredSessionKey:_||null,preferredRunId:f||null}):null,[Y,a,_,f]),we=a&&(Z==null?void 0:Z[a])||null,Ur=!!(d&&we&&(!f||!(we!=null&&we.runId)||we.runId===f)&&(!_||!(we!=null&&we.sessionKey)||we.sessionKey===_)),ds=a&&((f?(Is=Object.values(q||{}).find(r=>(r==null?void 0:r.agentId)===a&&(r==null?void 0:r.runId)===f))==null?void 0:Is.text:(As=q==null?void 0:q[a])==null?void 0:As.text)||((Ps=Object.values(q||{}).find(r=>(r==null?void 0:r.agentId)===a&&(!f||(r==null?void 0:r.runId)===f)))==null?void 0:Ps.text)||(j==null?void 0:j.textBuffer))||"",Or=(j==null?void 0:j.browserLiveView)||((U==null?void 0:U.agentId)===a?U:null),Be=h.useMemo(()=>on([...Array.isArray(n)?n:[],...Array.isArray(O)?O:[]],x||""),[O,n,x]),Fe=h.useMemo(()=>{const r=Be&&((c==null?void 0:c.status)==="running"||(j==null?void 0:j.openClawSessionActive)===!0||(j==null?void 0:j.waitingForBackgroundCompletion)===!0||d===!0);if(Be&&!r||d===!1&&f)return!1;if(!(j&&!cn(j))){if((j==null?void 0:j.openClawSessionActive)===!0||(j==null?void 0:j.waitingForBackgroundCompletion)===!0)return!0}return c!=null&&c.status&&Xt(c.status)&&(c==null?void 0:c.openClawSessionActive)!==!0?!1:is===!0&&!f||(c==null?void 0:c.status)==="running"||c!=null&&c.openClawSessionActive?!0:!_||f&&!d?!1:(te||[]).some(i=>(i==null?void 0:i.sessionKey)===_&&((i==null?void 0:i.isLive)||["running","spawning","working","streaming","thinking","in_progress","in-progress","active"].includes(String((i==null?void 0:i.status)||"").toLowerCase())))},[is,_,f,d,te,c==null?void 0:c.status,c==null?void 0:c.openClawSessionActive,j,j==null?void 0:j.openClawSessionActive,j==null?void 0:j.waitingForBackgroundCompletion,Be]),v=!!((d||Fe||j&&!Xt(j==null?void 0:j.status))&&(!Be||Fe||(c==null?void 0:c.status)==="running")&&(Ur||Fe||j&&!Xt(j==null?void 0:j.status)||ds||Or||(j==null?void 0:j.openClawSessionActive)===!0)),[Hr,us]=h.useState(()=>Date.now());h.useEffect(()=>{if(!v)return;us(Date.now());const r=window.setInterval(()=>us(Date.now()),250);return()=>window.clearInterval(r)},[v]);const ms=Number((j==null?void 0:j.startedAt)||(c==null?void 0:c.startedAt)||0),xs=ms>0?Math.max(0,Hr-ms):0,De=f||_||(a?`live-agent:${a}`:null);h.useCallback(()=>{Ie(!1),Pr(r=>r+1)},[]),h.useEffect(()=>{Ie(!1)},[f]),h.useEffect(()=>{if(!t)return;const r=Sa(De);Te((r==null?void 0:r.activeTab)==="raw"?"raw":"timeline")},[t,De]),h.useEffect(()=>{!t||!De||ka(De,{activeTab:pe})},[t,De,pe]),h.useEffect(()=>{z(null),E(null),ue(null),wt(be),ke(!1),Ie(!1)},[De]),h.useEffect(()=>{if(!t||!_){Pt(null);return}let r=!1;const i=async()=>{var T,I,u,m,F,re;try{const fe=await rt(`/api/bridge/session-status?sessionKey=${encodeURIComponent(_)}`,{headers:{Accept:"application/json"}},{auth:!0});if(!fe.ok||r)return;const me=await nt(fe,{label:"session status"});if(me.nonJson||r)return;const M=String(((I=(T=me.data)==null?void 0:T.session)==null?void 0:I.status)||((m=(u=me.data)==null?void 0:u.session)==null?void 0:m.phase)||((re=(F=me.data)==null?void 0:F.session)==null?void 0:re.state)||"").toLowerCase(),ye=["idle","completed","complete","done","stopped","cancelled","canceled","error","failed"],je=["running","working","streaming","thinking","spawning","in_progress","in-progress","active"].includes(M)||M&&!ye.includes(M);Pt(je)}catch{r||Pt(null)}};i();const b=setInterval(i,5e3);return()=>{r=!0,clearInterval(b)}
7},[t,_,At]),h.useEffect(()=>{if(!t||!_||!v||f){wt(be);return}let r=!1;const i=Math.max(0,Number((c==null?void 0:c.startedAt)||0)-5e3),b=async()=>{var I,u;try{const m=new URLSearchParams({sessionKey:_,limit:"160"});a&&m.set("agentId",a),l&&m.set("agentName",l),(I=n==null?void 0:n[0])!=null&&I.channel&&m.set("channel",n[0].channel),i>0&&m.set("since",String(i));const F=await rt(`/api/bridge/session-tool-events?${m.toString()}`,{headers:{Accept:"application/json"}},{auth:!0});if(!F.ok||r)return;const re=await nt(F,{label:"session tool events"});if(re.nonJson||r)return;const me=(Array.isArray((u=re.data)==null?void 0:u.events)?re.data.events:[]).map(M=>{var Ke;const ye=M!=null&&M.data&&typeof M.data=="object"?M.data:{},je=ye.runId||(M==null?void 0:M.runId)||null;return{event:(M==null?void 0:M.event)||"tool_start",data:{...ye,..._&&!ye.sessionKey?{sessionKey:_}:{},...a&&!ye.agentId?{agentId:a}:{},...l&&!ye.agentName?{agentName:l}:{},...je?{runId:je}:{}},time:(M==null?void 0:M.time)||(M==null?void 0:M.timestamp)||((Ke=M==null?void 0:M.data)==null?void 0:Ke.time)||Date.now()}});wt(me)}catch{r||wt(be)}};b();const T=setInterval(b,2e3);return()=>{r=!0,T&&clearInterval(T)}},[t,v,_,f,a,l,n,c==null?void 0:c.startedAt,At]),h.useEffect(()=>{if(!t||!f){Fe||(z(null),E(null),ue(null));return}let r=!1,i=[],b=null;const T=v?2e3:5e3,I=async()=>{const m=b==null&&i.length===0;!r&&m&&ke(!0);try{const F=new URLSearchParams({limit:String(b==null?pr:Jt)});b!=null&&F.set("afterSeq",String(b));const[re,fe,me]=await Promise.all([rt(`/api/runs/${encodeURIComponent(f)}/events?${F.toString()}`,{headers:{Accept:"application/json"}},{auth:!0}),rt(`/api/runs/${encodeURIComponent(f)}`,{headers:{Accept:"application/json"}},{auth:!0}),rt(`/api/performance/runs/${encodeURIComponent(f)}`,{headers:{Accept:"application/json"}},{auth:!0})]);if(r)return;if(re.ok){const M=await nt(re,{label:"run events"});if(M.nonJson)Ie(!0),console.warn("[ActivityDrawer] Persisted run events returned non-JSON.",{runId:f,status:M.status,preview:M.textPreview});else{const{events:ye=[]}=M.data||{},je=ye.map(H=>{var W,xe;return dr({seq:Number.isFinite(Number(H.seq))?Number(H.seq):null,event:H.event,data:{...H.data||{},...f&&!((W=H.data)!=null&&W.runId)?{runId:f}:{},..._&&!((xe=H.data)!=null&&xe.sessionKey)?{sessionKey:_}:{}},time:H.timestamp||Date.now()},{preserveScreenshotBase64:H.event==="screenshot_frame"})});if(b==null)i=je;else if(je.length>0){const H=new Set(i.map(Tt));for(const W of je){const xe=Tt(W);H.has(xe)||(i.push(W),H.add(xe))}}const Ke=je.reduce((H,W)=>W.seq!=null&&W.seq>H?W.seq:H,b??-1);Ke>=0&&(b=Ke),i.sort((H,W)=>H.seq!=null&&W.seq!=null?H.seq-W.seq:(H.time||0)-(W.time||0)),i=fr(i);const St=[...i];if(z(St),!v&&je.length>=pr&&b!=null){let H=0;for(;!r&&H<Na;){H+=1;const W=new URLSearchParams({limit:String(Jt),afterSeq:String(b)}),xe=await rt(`/api/runs/${encodeURIComponent(f)}/events?${W.toString()}`,{headers:{Accept:"application/json"}},{auth:!0});if(!xe.ok||r)break;const ft=await nt(xe,{label:"run events page"});if(ft.nonJson)break;const{events:gt=[]}=ft.data||{};if(!gt.length)break;const et=gt.map(oe=>{var ve,jt;return dr({seq:Number.isFinite(Number(oe.seq))?Number(oe.seq):null,event:oe.event,data:{...oe.data||{},...f&&!((ve=oe.data)!=null&&ve.runId)?{runId:f}:{},..._&&!((jt=oe.data)!=null&&jt.sessionKey)?{sessionKey:_}:{}},time:oe.timestamp||Date.now()},{preserveScreenshotBase64:oe.event==="screenshot_frame"})}),bt=new Set(i.map(Tt));for(const oe of et){const ve=Tt(oe);bt.has(ve)||(i.push(oe),bt.add(ve))}const tt=et.reduce((oe,ve)=>ve.seq!=null&&ve.seq>oe?ve.seq:oe,b??-1);if(tt<0||tt===b||(b=tt,et.length<Jt))break}i.sort((W,xe)=>W.seq!=null&&xe.seq!=null?W.seq-xe.seq:(W.time||0)-(xe.time||0)),i=fr(i),z([...i])}}}else Ie(!0);if(fe.ok){const M=await nt(fe,{label:"run metadata"});M.nonJson?(Ie(!0),console.warn("[ActivityDrawer] Run metadata returned non-JSON.",{runId:f,status:M.status,preview:M.textPreview})):E(M.data)}else Ie(!0);if(me.ok){const M=await nt(me,{label:"performance run detail"});M.nonJson||ue(M.data||null)}else ue(null)}catch(F){Ie(!0),ue(null),console.warn("[ActivityDrawer] Failed to fetch run events:",F.message)}finally{r||ke(!1)}};I();const u=v?setInterval(()=>{r||I()},T):null;return()=>{r=!0,u&&clearInterval(u)}},[t,f,_,v,Fe,At,a,l]);const Je=h.useMemo(()=>
7{if(!v)return null;const r=(j==null?void 0:j.events)||[],i=f?(p==null?void 0:p[f])||[]:[],b=a?((p==null?void 0:p[a])||[]).filter(u=>{var F;const m=((F=u==null?void 0:u.data)==null?void 0:F.runId)||null;return!f||!m||m===f}):[],T=Object.entries(p||{}).filter(([u])=>u!==a&&u!==f).flatMap(([,u])=>u.filter(m=>{var F,re,fe;if(f){const me=((F=m==null?void 0:m.data)==null?void 0:F.runId)||null;return(!me||me===f)&&(((re=m==null?void 0:m.data)==null?void 0:re.agentId)===a||!a)}return((fe=m==null?void 0:m.data)==null?void 0:fe.agentId)===a||!a})),I=He([r,i,b,T]);return I.length===0?null:I},[v,f,p,a,j==null?void 0:j.events]),Re=h.useRef({key:null,events:null,text:""}),ps=String(f||_||a||"");Re.current.key!==ps&&(Re.current={key:ps,events:null,text:""});const zr=["done","completed","failed","error","cancelled","stopped"].includes(String((j==null?void 0:j.status)||"").toLowerCase()),hs=v||!!j&&!zr;Array.isArray(Je)&&Je.length>0&&(Re.current.events=Je);const Nt=Array.isArray(Je)&&Je.length>0?Je:hs?Re.current.events:null,R=h.useMemo(()=>({runId:f,sessionKey:_}),[f,_]),Ae=h.useMemo(()=>{const r=Wt(Array.isArray(O)?O:be,{runId:R.runId,sessionKey:null,keepUnscoped:!1});return ir(r,R)},[O,R]),Xe=h.useMemo(()=>
7{const r=dn(Array.isArray(n)?n:be,{runId:R.runId,sessionKey:R.runId?null:R.sessionKey,messageId:N||null,keepUnscoped:!R.runId});return ir(r,R)},[n,R,N]),G=a?V.find(r=>r.id===a):null,fs=o||(c==null?void 0:c.agentAvatar)||(c==null?void 0:c.agent_avatar)||(A==null?void 0:A.agentAvatar)||(A==null?void 0:A.agent_avatar)||null,gs=String(l||"").trim(),se=(G==null?void 0:G.name)||(va(gs)?"":gs)||(c==null?void 0:c.agentName)||(A==null?void 0:A.agentName)||(j==null?void 0:j.agentName)||(we==null?void 0:we.name)||"Agent",Wr=kn({...G||{},id:(G==null?void 0:G.id)||a||(c==null?void 0:c.agentId)||(c==null?void 0:c.agent_id)||se,name:(G==null?void 0:G.name)||se,role:G==null?void 0:G.role,character:G==null?void 0:G.character,...fs&&!(G!=null&&G.character)?{avatar:fs}:{}},V),Kt=v&&(ds||C)||"";Kt&&(Re.current.text=Kt);const Qe=Kt||(hs?Re.current.text:""),bs=h.useMemo(()=>{const r=Nt||be,i=!!(R.runId&&r.some(b=>{var I;const T=((I=b==null?void 0:b.data)==null?void 0:I.runId)||(b==null?void 0:b.runId)||null;return T&&String(T)===String(R.runI
7d)}));return Wt(r,{runId:R.runId,sessionKey:R.runId?null:R.sessionKey,keepUnscoped:!i})},[Nt,R]),Ee=h.useMemo(()=>!v&&R.runId?He([Ae,Xe]):He([Xe,bs,Ae,Wt(cs,{runId:R.runId,sessionKey:R.runId?null:R.sessionKey,keepUnscoped:!1})]),[v,Ae,Xe,bs,cs,R]),qt=h.useMemo(()=>{var r;return x!=null&&x.trim()?Vn({id:N,runId:f,sessionKey:_,rawContent:x},Ee,{at:((r=Ee.at(-1))==null?void 0:r.time)||Date.now()}):be},[Ee,x,N,f,_]),dt=h.useMemo(()=>{var i;const r=b=>qt.length>0?He([b,qt]):b;if(Ee.length>0)return Ee.some(T=>{var u,m;const I=String((T==null?void 0:T.event)||"").toLowerCase();return(I==="text"||I==="message")&&(((u=T==null?void 0:T.data)==null?void 0:u.text)||((m=T==null?void 0:T.data)==null?void 0:m.content))})||!(x!=null&&x.trim())?r(Ee):r([...Ee,{event:"text",data:{text:x,...f?{runId:f}:{},..._?{sessionKey:_}:{},...a?{agentId:a}:{},agentName:se},time:((i=Ee.at(-1))==null?void 0:i.time)||Date.now(),_synthetic:!0}]);if(v&&Qe){const b=He([(j==null?void 0:j.events)||[],Nt||[]]);return b.length>0?He([b,[{event:"text",data:{text:Qe,...f?{runId:f}:{},..._?{sessionKey:_}:{},...a?{agentId:a}:{},agentName:se},time:Date.now(),_synthetic:!0}]]):[{event:"text",data:{text:Qe,...f?{runId:f}:{},..._?{sessionKey:_}:{},...a?{agentId:a}:{},agentName:se},time:Date.now(),_synthetic:!0}]}return x!=null&&x.trim()?r([{event:"text",data:{text:x,...f?{runId:f}:{},..._?{sessionKey:_}:{},...a?{agentId:a}:{},agentName:se},time:Date.now(),_synthetic:!0}]):[]},[Ee,v,Qe,f,_,a,se,x,qt,j==null?void 0:j.events,Nt]),Dr=h.useDeferredValue(dt),Jr=h.useDeferredValue(Qe),Le=v?dt:Dr,js=v?Qe:Jr,Ve=h.useMemo(()=>v?un(Le,{maxEvents:120,windowMs:600*1e3}):Le,[Le,v]),Bt=h.useMemo(()=>kt(Ve),[Ve]),{events:Ne,loading:Rr}=Gn(Bt,{runId:f,sessionKey:_,enabled:t&&!v}),ce=v?Ve:jr([Ne,Ve,dt],{preferredRunId:f}),y=h.useMemo(()=>{const r=[...ce||[]].reverse().find(i=>["ai_context","openclaw_ai_request_context"].includes(String((i==null?void 0:i.event)||"").toLowerCase()));return(r==null?void 0:r.data)||null},[ce]),Ce=h.useMemo(()=>{if(k)return k;const r=(y==null?void 0:y.request)||null;return!r||typeof r!="object"||!r.sourceSurface&&!r.responseTarget&&!r.nativeScreenContext?null:{messageId:r.messageId||null,senderName:r.senderName||null,senderType:r.senderType||null,channel:r.channel||null,createdAt:r.createdAt||null,textPreview:r.userMessage||r.prompt||r.text||null,sourceSurface:r.sourceSurface||null,responseTarget:r.responseTarget||null,browserScreenshotSource:r.browserScreenshotSource||null,browserMode:r.browserMode||null,helperDeliveryId:r.helperDeliveryId||null,nativeScreenContext:r.nativeScreenContext||null,helperTimings:r.helperTimings||null}},[k,y]),Ft=h.useMemo(()=>Fa(ce,x||""),[ce,x]),Xr=!!(Ft.audio.length||Ft.screen.length),J=P||{},yt=h.useMemo(()=>(ce||[]).filter(r=>{const i=String((r==null?void 0:r.event)||"").toLowerCase();return i==="tool_start"||i==="tool_result"||i==="tool_update"}).map(r=>{const i=(r==null?void 0:r.data)||{},b=i.params||i.input||i.arguments||i.request||{},T=i.result||i.output||i.response||null,I=String((r==null?void 0:r.event)||i.event||"").toLowerCase().includes("error");return{event:r.event,tool:i.tool||i.name||i.toolName||i.command||i.action||"tool",command:i.command||b.command||i.action||null,params:b,result:T,error:i.error||(I?i.message:void 0),time:r.time||r.timestamp||i.time||null}}).slice(0,120),[ce]),ws=!!(y||P||c||A||f||_||Ce||Xr||yt.length),Qr=h.useMemo(()=>v?ce:Ne!=null&&Ne.length?Ne:ce,[ce,v,Ne]),he=h.useMemo(()=>{if(v)return Bt;if(f){const i=(Le!=null&&Le.length?Le:null)||(Ae!=null&&Ae.length?Ae:null)||Xe||be;return Ne!=null&&Ne.length?kt(He([i,Ne])):kt(i)}const r=kt(Le);return jr([r,Xe,Ne,Ve,dt],{preferredRunId:f})},[v,Bt,Ne,Le,Ve,dt,Xe,Ae,f]),Ue=h.useMemo(()=>{const r=Tn(he,{agentName:se,liveStreamingText:js,isLive:v,browserUrl:(B==null?void 0:B.url)||null,run:c});return X&&!v?{...r,messageContent:"",aggregate:r.aggregate?{...r.aggregate,visibleText:""}:r.aggregate}:r},[he,se,js,v,B==null?void 0:B.url,c,X]),Ut=Ue.aggregate,ut=Ue.semanticTimelineEntries,Ns=Ue.milestoneItems||be,mt=Ue.legacyTimelineItems,ys=Ue.hasSupportingEvidence,Ye=Array.isArray(ee)?ee:be,xt=h.useMemo(()=>a?mn(Array.isArray(le==null?void 0:le[a])?le[a]:[],{runId:f,sessionKey:f?null:_}):be,[a,le,f,_]),Oe=h.useMemo(()=>{let r=v?ut:st(ut);X&&!v&&(r=(r||[]).filter(u=>{var m,F;if((m=u==null?void 0:u.extra)!=null&&m._isLiveStream||u!=null&&u._isLiveStream||u!=null&&u._mainNarrative)return!1;if((u==null?void 0:u.type)==="thinking"){const re=String(u.label||"").trim();if(!!(u._internalReasoning||(F=u==null?void 0:u.extra)!=null&&F._internalReasoning||re==="Reasoning"||re==="Thinking"))return!0;
7if(re&&String(u.detail||"").length>=160)return!1}return!0}));const i=u=>(Array.isArray(u)?u:[]).filter(m=>(m==null?void 0:m.type)==="tool"||(m==null?void 0:m.type)==="subagent"||(m==null?void 0:m.type)==="skill"||(m==null?void 0:m.type)==="parallel"||(m==null?void 0:m.type)==="shell_batch"||(m==null?void 0:m.type)==="browser"||!!(m!=null&&m.tool)).length;if(!(xt.length>0&&v&&(xt.length>r.length||i(xt)>i(r)))){if(!v)return r;const u=ut.find(m=>{var F;return((F=m==null?void 0:m.extra)==null?void 0:F._isLiveStream)||(m==null?void 0:m._isLiveStream)});return u?st([...r.filter(m=>{var F;return!((F=m==null?void 0:m.extra)!=null&&F._isLiveStream)&&!(m!=null&&m._isLiveStream)}),u].filter(Boolean)):st(r)}const T=_n(r,xt);if(!v)return st(T);const I=ut.find(u=>{var m;return((m=u==null?void 0:u.extra)==null?void 0:m._isLiveStream)||(u==null?void 0:u._isLiveStream)});return I?st([...T.filter(u=>{var m;return!((m=u==null?void 0:u.extra)!=null&&m._isLiveStream)&&!(u!=null&&u._isLiveStream)}),I].filter(Boolean)):st(T)},[v,ut,xt,X]),Ot=Oe.length>0||Ut.sources.length>0||Ns.length>0,vs=Mn(he,{sessionRecordingUrl:(B==null?void 0:B.url)||null}),Vr=ys&&vs,Yr=v&&ys&&!vs,Ss=h.useMemo(()=>Yn({sessionKey:_,runId:f,agentId:a,agentName:se,isLive:v,events:he,laneEntries:te}),[se,v,f,_,te,a,he]),Zr=h.useMemo(()=>{const r=[...Array.isArray(Oe)?Oe:[],...Array.isArray(Ye)?Ye:[]];return sa(r)},[Oe,Ye]);h.useEffect(()=>{ie.current&&t&&(ie.current.scrollTop=ie.current.scrollHeight)},[mt.length,Oe.length,t]);const Ze=Wr,g=A||c||null,ks=h.useMemo(()=>ss(he,x||""),[he,x]),Ge=h.useMemo(()=>{if(v||Fe)return"in progress";const r=Ma((g==null?void 0:g.status)||(c==null?void 0:c.status)||""),i=(g==null?void 0:g.errorKind)||(c==null?void 0:c.errorKind)||null,b=new Set(["provider_credits","provider_auth","provider_region","model_unavailable","local_model_auth","local_model_unreachable","run_stopped","context_overflow","browser_policy","acp_auth_required","acp_quota_exhausted","org_server_down"]);return(r==="failed"||g!=null&&g.error||c!=null&&c.error)&&Be&&ks&&!b.has(String(i||""))?"completed":r==="failed"||(g!=null&&g.error||c!=null&&c.error)&&(i||/out of credits|no credits|auth|quota/i.test(String((g==null?void 0:g.error)||(c==null?void 0:c.error)||"")))?"failed":Be?"completed":r},[g==null?void 0:g.status,g==null?void 0:g.error,g==null?void 0:g.errorKind,c==null?void 0:c.status,c==null?void 0:c.error,c==null?void 0:c.errorKind,v,Fe,Be,ks]);c!=null&&c.sessionKey;const pt=h.useMemo(()=>{var i;if(Q)return String(Q);for(const b of Array.isArray(he)?he:[]){const T=((i=b==null?void 0:b.data)==null?void 0:i.acpSessionId)||(b==null?void 0:b.acpSessionId);if(T)return String(T)}const r=String(f||"");return r.startsWith("acp:")?r.slice(4):null},[Q,he,f]),Gr=h.useCallback(()=>{var r,i;if(pt){if(ae){ae({kind:"acp",sessionId:pt}),s==null||s();return}(i=(r=Se.getState()).focusAcpWorkspaceSession)==null||i.call(r,pt),s==null||s()}},[pt,ae,s]),Pe=Ue.runtimeUsage||{providers:[],models:[]},Ts=((Ks=Pe.providers)==null?void 0:Ks.slice(0,2))||[],_s=((qs=Pe.models)==null?void 0:qs.slice(0,3))||[],Ht=Ts.length>0||_s.length>0,vt=h.useMemo(()=>yr(he||[]),[he]),$=h.useMemo(()=>En(g,vt,Pe),[g,vt,Pe]),zt=h.useMemo(()=>($==null?void 0:$.totalCostUsd)||Ln(g,vt,Pe),[g,vt,$==null?void 0:$.totalCostUsd,Pe]),ht=h.useMemo(()=>{const r=(Array.isArray($==null?void 0:$.rows)?$.rows:[]).map(b=>Zt(b)),i=r.length>0&&r.every(b=>b.id==="actual");return{costSource:i?"provider_reported":"service_price_estimate",estimated:!i}},[$==null?void 0:$.rows]),Ms=Gt(zt,ht),en=(($==null?void 0:$.totalTokens)||(g==null?void 0:g.totalTokens)||0)>0,tn=h.useMemo(()=>Cn({inputTokens:($==null?void 0:$.inputTokens)??(g==null?void 0:g.inputTokens),outputTokens:($==null?void 0:$.outputTokens)??(g==null?void 0:g.outputTokens),totalTokens:($==null?void 0:$.totalTokens)??(g==null?void 0:g.totalTokens),costUsd:zt,...ht}),[g==null?void 0:g.inputTokens,g==null?void 0:g.outputTokens,g==null?void 0:g.totalTokens,$==null?void 0:$.inputTokens,$==null?void 0:$.outputTokens,$==null?void 0:$.totalTokens,zt,ht.costSource,ht.estimated]);return e.jsx(On,{open:t,onOpenChange:r=>{r||s==null||s()},modal:!0,swipeDirection:"down",children:e.jsxs(Hn,{children:[e.jsx(zn,{className:"z-drawer bg-black/40 backdrop-blur-[2px] sm:bg-transparent sm:backdrop-blur-none"}),e.jsx(Wn,{className:"z-drawer flex items-end justify-center overscroll-lock sm:items-stretch sm:justify-end",children:e.jsxs(Dn,{className:L("pointer-events-auto relative flex min-h-0 w-full flex-col overflow-hidden","max-h-[min(92dvh,calc(100dvh-env(safe-area-inset-bottom,0px)))]","rounded-t-3xl border border-neutral-200/80 border-b-0 bg-white","shadow-[0_-8px_32px_rgba(0,0,0,0.10),0_-1px_0_rgba(0,0,0,0.03)]","sm:h-full sm:max-h-none sm:rounded-none","sm:border-l sm:border-y-0 sm:border-r-0 sm:border-neutral-200/80","sm:shadow-[-4px_0_24px_rgba(28,25,23,0.07)]","sm:w-[clamp(36%,50vw,520px)]","safe-area-bottom max-sm:pt-0 sm:pt-[env(safe-area-inset-top,0px)]","duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:slide-out-to-bottom-8 data-[state=open]:slide-in-from-bottom-8","sm:data-[state=closed]:slide-out-to-right-8 sm:data-[state=open]:slide-in-from-right-8",ne.shell),role:"complementary","aria-label":"Run Timeline",children:[e.jsx("div",{className:"pointer-events-none mx-auto mt-2 h-1 w-9 shrink-0 rounded-full bg-stone-300 sm:hidden","aria-hidden":"true"}),e.jsxs("div",{className:L("flex items-start justify-between gap-3 px-4 py-3 sm:items-center sm:py-3.5",ne.chrome,ne.chromeHairline),children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[Ze||a?e.jsx(rs,{agent:Ze,agentId:a,agentName:se}):null,e.jsxs("div",{className:"min-w-0 flex-1 leading-tight",children:[e.jsx("div",{className:"truncate font-semibold text-[15px] text-neutral-900 tracking-tight",children:se}),e.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1.5",children:[e.jsx("span",{className:"text-[11px] text-neutral-400",children:"This run"}),f&&e.jsx("span",{className:L(ne.chip,"text-[11px]"),children:f.slice(0,8)}),(We||Rr)&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] text-neutral-400",children:[e.jsx(Mt,{size:9,className:"shrink-0"}),e.jsx("span",{children:"Syncing"})]}),pt&&e.jsxs(ct,{type:"button",size:"sm",variant:"outline",className:"h-6 gap-1 rounded-full border-emerald-200 bg-emerald-50 px-2 text-[10px] font-medium text-emerald-800 hover:bg-emerald-100",onClick:Gr,children:[e.jsx(Lt,{className:"h-3 w-3"})," Open terminal"]})]})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[e.jsx(Ta,{events:Qr,agentName:se}),e.jsx(ct,{variant:"ghost",size:"icon",type:"button",onClick:s,className:"mt-0.5 h-8 w-8 rounded-lg text-neutral-400 hover:text-neutral-900 hover:bg-stone-100 sm:mt-0 shrink-0 transition-colors","aria-label":"Close",children:e.jsx($n,{className:"h-4 w-4"})})]})]}),e.jsx(Jn,{value:pe,onValueChange:Te,className:"w-full",children:e.jsx("div",{className:L("flex w-full min-w-0 flex-row items-stretch px-3 py-2 sm:px-4",ne.chromeSubtle,ne.chromeHairline),children:e.jsx("div",{className:"flex min-w-0 
7w-full flex-1",children:e.jsxs(Rn,{className:"flex h-auto min-h-8 w-full min-w-0 flex-1 items-stretch gap-0.5 rounded-full bg-stone-100/90 p-0.5 ring-1 ring-neutral-200/50",children:[e.jsx(Dt,{value:"timeline",className:"h-7 min-w-0 flex-1 rounded-full px-1.5 text-[11px] font-medium shadow-none transition-all sm:min-w-[4.5rem] sm:px-3 data-[state=active]:bg-white data-[state=active]:text-neutral-900 data-[state=active]:shadow-sm data-[state=inactive]:text-neutral-500 data-[state=inactive]:hover:text-neutral-700",children:"Timeline"}),ws&&e.jsx(Dt,{value:"context",className:"h-7 min-w-0 flex-1 rounded-full px-1.5 text-[11px] font-medium shadow-none transition-all sm:px-3 data-[state=active]:bg-white data-[state=active]:text-neutral-900 data-[state=active]:shadow-sm data-[state=inactive]:text-neutral-500",children:"Context"}),e.jsxs(Dt,{value:"raw",className:"h-7 min-w-0 flex-1 rounded-full px-1.5 text-[11px] font-medium shadow-none transition-all sm:px-3 data-[state=active]:bg-white data-[state=active]:text-neutral-900 data-[state=active]:shadow-sm data-[state=inactive]:text-neutral-500",children:["Raw · ",(ce==null?void 0:ce.length)||0]})]})})})}),(g||Ht)&&e.jsx("div",{className:L("bg-white px-3 py-2 sm:px-4",ne.chromeHairline),children:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 text-[11px] text-neutral-500",children:[f&&e.jsx("span",{className:ne.chip,children:f.slice(0,8)}),Ts.map(r=>e.jsx("span",{className:L(ne.chip,"font-sans"),children:r.label},`runtime-provider-bar-${r.id}`)),_s.map(r=>e.jsx("span",{className:ne.chip,children:r.label},`runtime-model-bar-${r.id}`))]}),e.jsxs("div",{className:"flex shrink-0 flex-wrap items-center justify-end gap-x-3 gap-y-1 text-[11px]",children:[(v?xs:g!=null&&g.durationMs)?e.jsxs("span",{className:"inline-flex items-center gap-1 tabular-nums text-neutral-500",children:[e.jsx(vr,{className:"h-3 w-3 opacity-50 shrink-0","aria-hidden":!0}),v?xn(xs):g.durationMs<1e3?`${g.durationMs}ms`:`${(g.durationMs/1e3).toFixed(1)}s`]}):null,(g==null?void 0:g.totalTokens)>0&&e.jsxs("span",{className:"tabular-nums text-neutral-400",children:[(Bs=g.inputTokens)==null?void 0:Bs.toLocaleString()," in"," · ",(Fs=g.outputTokens)==null?void 0:Fs.toLocaleString()," out"]}),Ms?e.jsx("span",{className:"tabular-nums font-medium text-neutral-500",title:ht.estimated?"Estimated or partial total — see the run cost breakdown":"Provider-reported total",children:Ms}):null,Ge&&e.jsx("span",{className:L("inline-flex items-center rounded-full border px-2.5 py-0.5 text-[11px] font-medium capitalize",Ge==="completed"?"border-emerald-200 bg-emerald-50 text-emerald-700":Ge==="failed"?"border-red-200 bg-red-50 text-red-700":"border-amber-200 bg-amber-50 text-amber-800"),children:Ge})]})]})}),!Ot&&e.jsx(Ra,{events:he,aggregate:Ut,runtimeUsage:Pe,showRuntimeBadges:!(g||Ht),hideTokenUsage:en}),e.jsx("div",{ref:ie,className:"min-h-0 flex-1 overflow-y-auto bg-white",children:pe==="timeline"?e.jsxs("div",{className:"px-3 py-3 sm:px-4 sm:py-3.5",children:[(K==null?void 0:K.banner)&&(K==null?void 0:K.severity)&&K.severity!=="none"&&e.jsxs("div",{className:L("mb-3 flex items-start gap-1.5 rounded-md border px-2.5 py-2 text-[11px] leading-snug",K.severity==="warn"?"border-amber-200 bg-amber-50 text-amber-900":"border-sky-200 bg-sky-50 text-sky-900"),role:"status","data-verification-gate":"true",children:[K.severity==="warn"?e.jsx(In,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}):e.jsx(la,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium",children:K.severity==="warn"?"Verification soft gate":"Verification note"}),e.jsx("div",{className:"opacity-90",children:K.banner})]})]}),mt.length===0&&Oe.length===0&&Ns.length===0&&Ut.sources.length===0&&Ye.length===0?e.jsxs("div",{className:"rounded-xl border border-dashed border-neutral-200 bg-stone-50/60 px-4 py-12 text-center",children:[e.jsx(Mt,{size:18,className:"mx-auto mb-3 opacity-40"}),e.jsx("p",{className:"text-[13px] font-medium text-neutral-700",children:String(Ge||"").toLowerCase()==="queued"?"Queued":v?cr(j||{})==="working"?"Starting":cr(j||{}):"Waiting for activity"}),e.jsx("p",{className:"mt-1 text-[12px] text-neutral-400 leading-relaxed",children:String(Ge||"").toLowerCase()==="queued"?`Waiting for ${se} to start. Run steps and tools will appear here.`:v?`Waiting for ${se}'s first step. If this stays empty, the live stream has not attached yet.`:`Run steps and tools will appear here as ${se} works.`})]}):e.jsxs("div",{className:"flex flex-col gap-0",children:[!Zr&&e.jsx(ua,{agentId:a}),e.jsx(ea,{runModel:{...Ue,semanticTimelineEntries:Oe},isLive:v,showRuntimeUsage:!(g||Ht),thinkingTitle:"Activity",thinkingCaption:v?"Live steps from this run":null,defaultExpandShellBatches:!1,threadFooterTokenLineOverride:v?null:tn}),v&&!Ot&&Ye.length>0&&e.jsx(ze,{title:"Timeline",caption:"Live workflow from the current run",children:e.jsx(ra,{entries:Ye,isLive:!0,variant:"activity",defaultExpandShellBatches:!1})}),mt.length>0&&!Ot&&e.jsx(ze,{title:"Timeline",children:e.jsx("div",{className:"flex flex-col gap-0",children:mt.map((r,i)=>{var T,I,u;const b=i===mt.length-1;return r.type==="message_boundary"?e.jsxs("div",{className:"mb-1 mt-3 flex items-center gap-2.5 border-t border-neutral-100 py-2.5 first:mt-0 first:border-t-0",children:[Ze?e.jsx(rs,{agent:Ze,agentId:Ze.id,agentName:r.agentName,sizeClass:"h-6 w-6"}):e.jsx("div",{className:"w-6 h-6 rounded-full bg-neutral-900 text-white flex items-center justify-center text-[10px] font-bold shrink-0",children:(I=(T=r.agentName)==null?void 0:T.charAt(0))==null?void 0:I.toUpperCase()}),e.jsx("span",{className:"text-[12px] font-semibold text-neutral-900",children:r.agentName}),r.runId&&e.jsx("span",{className:ne.chip,children:r.runId.slice(0,8)}),e.jsx("span",{className:"text-[11px] text-neutral-400 ml-auto tabular-nums",children:r.time?It(r.time):""})]},i):r.type==="tool"?e.jsx(Ka,{event:r.event,isLast:b,agent:Ze,agentName:se}
7,i):r.type==="lifecycle"?e.jsx(za,{label:r.label,detail:r.detail,isLast:b,isError:r.isError,time:r.time},i):r.type==="prose"?e.jsx(Wa,{text:r.text,isLast:b,isStreaming:!!(((u=r==null?void 0:r.extra)==null?void 0:u._isLiveStream)??(r==null?void 0:r._isLiveStream))},i):null})})}),Yr&&e.jsx(ze,{title:"Deliverables",caption:"Will populate after this run settles.",children:e.jsx("div",{className:"rounded-xl bg-stone-50 px-3 py-2.5 text-[11px] text-neutral-400 ring-1 ring-neutral-200/60 leading-relaxed",children:"Created files and media will appear here after the current live stream finishes."})}),Vr&&e.jsx(wa,{events:he,sessionRecordingUrl:(B==null?void 0:B.url)||null,sessionRecordingLabel:B!=null&&B.agentName?`${B.agentName} recording`:""}),e.jsx(Ja,{breakdown:$,runtimeUsage:Pe,run:g,forceVisible:!!(g&&!v)}),Ss.some(r=>r==null?void 0:r.sessionKey)?e.jsx(ze,{title:"OpenClaw sessions",caption:"Native agent sessions observed during this run",children:e.jsx(ta,{entries:Ss,hideHeader:!0,emptyLabel:"No observed OpenClaw session for this lane yet."})}):null]})]}):pe==="context"&&ws?e.jsx("div",{className:"space-y-6 px-5 py-5 text-[12px]",children:(()=>{var M,ye,je,Ke,St,H,W,xe,ft,gt,et,bt,tt,oe,ve,jt,Us,Os,Hs,zs,Ws,Ds,Js,Rs,Xs,Qs,Vs,Ys,Zs,Gs,er,tr,sr,rr,nr,ar,lr;const r=(y==null?void 0:y.request)||{},i=String((Ce==null?void 0:Ce.textPreview)||((M=y==null?void 0:y.prompts)==null?void 0:M.userTask)||J.userMessage||r.task||r.userMessage||"").trim(),b=f||J.runId||r.runId||"",T=_||r.sessionKey||"",I=((ye=y==null?void 0:y.request)==null?void 0:ye.chatSessionId)||"",u=r.publicAgentName||r.agentName||J.agentName||"",m=r.model||((je=J.resultMeta)==null?void 0:je.fallbackModel)||"",F=!!Ce,re=F&&i&&String((Ce==null?void 0:Ce.textPreview)||"").trim()===i,fe=Sr(i),me=(()=>{if(fe)return[];const de=[x];for(const qe of ce||[])de.push(...Ar(qe));for(const qe of de){const or=pn(qe||"");if(or.length)return or}return[]})();return e.jsxs(e.Fragment,{children:[e.jsx(ot,{title:"Run identity",caption:"IDs for this agent turn — truncated for readability",children:e.jsxs("div",{className:"rounded-xl border border-neutral-200/80 bg-stone-50/60 px-3.5 py-1 divide-y divide-neutral-100/90",children:[e.jsx(lt,{label:"Run ID",value:b?Vt(b,14,8):null,mono:!0,title:b}),e.jsx(lt,{label:"Agent session",value:T?Vt(T,18,10):null,mono:!0,title:T}),e.jsx(lt,{label:"Chat session",value:I&&I!==T?Vt(I,16,8):null,mono:!0,title:I}),e.jsx(lt,{label:"Agent",value:u||null}),e.jsx(lt,{label:"Model",value:m||null,mono:!0}),e.jsx(lt,{label:"Mode",value:r.thinking||J.executionMode||null})]})}),F?e.jsx(Ua,{source:Ce}):null,e.jsx(Oa,{evidence:Ft}),i&&!re?e.jsx(ot,{title:"User message",children:e.jsx("div",{className:"rounded-xl border border-neutral-200/80 bg-white px-3.5 py-3 text-[13px] leading-relaxed text-neutral-800 whitespace-pre-wrap break-words",children:fe?e.jsx(Cr,{answer:fe}):Ct(i)||i})}):null,me.length>0?e.jsx(ot,{title:"Questions",caption:"Answer in the chat thread — this is the same form as the agent message",children:e.jsx(Zn,{blocks:me,readonly:!0})}):null,((Ke=J.installedSkills)==null?void 0:Ke.length)>0?e.jsx(ot,{title:"Skills",children:e.jsx("div",{className:"flex flex-wrap gap-1.5",children:J.installedSkills.map((de,qe)=>e.jsx("span",{className:"rounded-full border border-emerald-200/80 bg-emerald-50 px-2.5 py-0.5 text-[11px] font-medium text-emerald-700",children:de.name||de.id},de.id||de.name||qe))})}):null,(St=J.resultMeta)!=null&&St.error||(H=J.resultMeta)!=null&&H.fallback||(xe=(W=J.resultMeta)==null?void 0:W.lifecycle)!=null&&xe.length?e.jsx(ot,{title:"Result notes",caption:"Extra outcome detail (tokens are in the header)",children:e.jsxs("div",{className:"space-y-1.5 rounded-xl border border-neutral-200/80 bg-stone-50/70 px-3.5 py-3",children:[J.resultMeta.error?e.jsxs("p",{className:"text-[12px] text-red-600",children:["❌ ",J.resultMeta.error]}):null,J.resultMeta.fallback?e.jsxs("p",{className:"text-[12px] text-amber-700",children:["⚠ Fallback model: ",J.resultMeta.fallbackModel||"yes"]}):null,((ft=J.resultMeta.lifecycle)==null?void 0:ft.length)>
70?e.jsxs("p",{className:"text-[11px] text-neutral-500",children:["Lifecycle: ",J.resultMeta.lifecycle.map(de=>de.phase).join(" → "),J.resultMeta.lifecycle.find(de=>de.error)?e.jsxs("span",{className:"ml-1 text-red-500",children:["(",J.resultMeta.lifecycle.find(de=>de.error).error,")"]}):null]}):null]})}):null,e.jsx(ot,{title:"Advanced",caption:"Full payloads for debugging — collapsed by default",children:e.jsxs("div",{className:"space-y-2",children:[(gt=y==null?void 0:y.prompts)!=null&&gt.systemPrompt?e.jsx($e,{title:"System prompt sent to AI",meta:`${String(y.prompts.systemPrompt).length.toLocaleString()} chars`,children:e.jsx("div",{className:"max-h-[40vh] overflow-y-auto whitespace-pre-wrap break-words font-mono text-[11px] leading-relaxed text-neutral-600",children:y.prompts.systemPrompt})}):null,y!=null&&y.request&&Object.keys(y.request).length>0?e.jsx($e,{title:"Full AI request JSON",meta:"raw",children:e.jsx(at,{value:y.request,maxHeight:"max-h-64"})}):null,(bt=(et=y==null?void 0:y.context)==null?void 0:et.activeTabs)!=null&&bt.length||(ve=(oe=(tt=y==null?void 0:y.context)==null?void 0:tt.chrome)==null?void 0:oe.relevantTabs)!=null&&ve.length||(Us=(jt=y==null?void 0:y.context)==null?void 0:jt.chrome)!=null&&Us.activeTab?e.jsx($e,{title:"Chrome tabs & page",children:e.jsx(at,{value:{activeTab:((Hs=(Os=y.context)==null?void 0:Os.chrome)==null?void 0:Hs.activeTab)||null,relevantTabs:((Ws=(zs=y.context)==null?void 0:zs.chrome)==null?void 0:Ws.relevantTabs)||[],activeTabs:((Ds=y.context)==null?void 0:Ds.activeTabs)||[],selectedTab:((Js=y.context)==null?void 0:Js.selectedTab)||null,page:((Rs=y.context)==null?void 0:Rs.page)||null},maxHeight:"max-h-56"})}):null,(Qs=(Xs=y==null?void 0:y.context)==null?void 0:Xs.relevantHistory)!=null&&Qs.length||(Zs=(Ys=(Vs=y==null?void 0:y.context)==null?void 0:Vs.chrome)==null?void 0:Ys.relevantHistory)!=null&&Zs.length?e.jsx($e,{title:"Browser history hints",children:e.jsx(at,{value:((Gs=y.context)==null?void 0:Gs.relevantHistory)||((tr=(er=y.context)==null?void 0:er.chrome)==null?void 0:tr.relevantHistory)||[],maxHeight:"max-h-48"})}):null,(rr=(sr=y==null?void 0:y.context)==null?void 0:sr.macApps)!=null&&rr.length||(nr=y==null?void 0:y.context)!=null&&nr.desktop?e.jsx($e,{title:"Mac apps / desktop",children:e.jsx(at,{value:{desktop:((ar=y.context)==null?void 0:ar.desktop)||null,macApps:((lr=y.context)==null?void 0:lr.macApps)||[]},maxHeight:"max-h-48"})}):null,y!=null&&y.context&&Object.keys(y.context).length>0?e.jsx($e,{title:"Full sanitized OpenClaw context",meta:"raw",children:e.jsx(at,{value:y.context,maxHeight:"max-h-[45vh]"})}):null,yt.length>0?e.jsx($e,{title:"Commands & tool calls",meta:`${yt.length}`,children:e.jsx(at,{value:yt,maxHeight:"max-h-[45vh]"})}):null,J.promptParts&&Object.keys(J.promptParts).length>0?e.jsx($e,{title:"Prompt parts",children:e.jsx("div",{className:"space-y-2",children:Object.entries(J.promptParts).map(([de,qe])=>e.jsx($e,{title:de,meta:`${String(qe||"").length} chars`,children:e.jsx("div",{className:"max-h-48 overflow-y-auto whitespace-pre-wrap break-words font-mono text-[11px] text-neutral-500",children:qe||"(empty)"})},de))})}):null]})})]})})()}):e.jsx("div",{className:"px-3 py-3 space-y-1.5",children:!ce||ce.length===0?e.jsx("div",{className:"text-center py-12 text-neutral-400 text-[13px]",children:"No raw event data for this message."}):ce.map((r,i)=>e.jsx(Ea,{event:r},`${r.event||"event"}-${r.time||i}-${i}`))})})]})})]})})}function eo({onClick:t,events:s,agentName:n,isDone:l}){const o=Se(P=>P.browserLiveView),d=!l&&(o==null?void 0:o.screenshotBase64),a=s.filter(P=>{var C;return P.event==="tool_start"&&((C=P.data)==null?void 0:C.tool)!=="processing"}),w=s.filter(P=>{var C;return P.event==="tool_result"&&((C=P.data)==null?void 0:C.tool)!=="processing"}),S=[...s].reverse().find(P=>P.event==="tool_start"||P.event==="tool_result"),N=s[s.length-1],k=(()=>{var P,C,ee,x,X;if(l)return`Completed · ${w.length} tools used`;if((S==null?void 0:S.event)==="tool_start"){const Q=kr((P=S.data)==null?void 0:P.tool),ae=((ee=(C=S.data)==null?void 0:C.params)==null?void 0:ee.query)||((X=(x=S.data)==null?void 0:x.params)==null?void 0:X.url)||"";return ae?`${Q.label}: ${String(ae)}`:`Using ${Q.label}…`}return(N==null?void 0:N.event)==="text"?"Writing response…":(N==null?void 0:N.event)==="thinking"?"Thinking…":"Working…"})();return e.jsx(ct,{variant:"outline",onClick:t,className:"mx-4 mb-2 w-[calc(100%-2rem)] rounded-xl border-neutral-200/80 bg-white hover:bg-stone-50 overflow-hidden h-auto 
7shadow-[0_1px_3px_rgba(28,25,23,0.05)] transition-all hover:shadow-[0_2px_6px_rgba(28,25,23,0.08)]",children:e.jsxs("div",{className:"px-3.5 py-2.5 flex items-center gap-3 text-left w-full",children:[e.jsx("div",{className:L("w-1.5 h-1.5 rounded-full flex-shrink-0",l?"bg-emerald-500":"bg-emerald-400 animate-pulse"),title:l?"Completed":"Live"}),n&&e.jsx("span",{className:"text-[13px] font-semibold text-neutral-900",children:n}),e.jsx("span",{className:"flex-1 truncate text-[12px] text-neutral-500",children:k}),d&&e.jsx(Lt,{className:"w-3.5 h-3.5 text-emerald-500 flex-shrink-0"}),e.jsxs("span",{className:"text-[11px] text-neutral-400 flex-shrink-0 tabular-nums",children:[w.length,"/",a.length]}),e.jsx(os,{className:"w-3.5 h-3.5 text-neutral-400 flex-shrink-0"})]})})}export{eo as ActivityAccordionButton,Gl as default};

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.