@standardagents/builder 0.41.22 → 0.41.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/built-in-routes.js +387 -134
  2. package/dist/built-in-routes.js.map +1 -1
  3. package/dist/client/{ApiKeysView-D4g6ZNWG.js → ApiKeysView-CJYLO_ua.js} +1 -1
  4. package/dist/client/{CenteredContentView-B3WUhJPU.js → CenteredContentView-V1sCsISI.js} +1 -1
  5. package/dist/client/{CompositionView-pL0H07yI.js → CompositionView-hqbZ8f7d.js} +1 -1
  6. package/dist/client/{ConfirmDialog.vue_vue_type_script_setup_true_lang-uehuZFVv.js → ConfirmDialog.vue_vue_type_script_setup_true_lang-CYrgsA6b.js} +1 -1
  7. package/dist/client/{CopyButton.vue_vue_type_script_setup_true_lang-vwNMv4kh.js → CopyButton.vue_vue_type_script_setup_true_lang-DFIJfKuD.js} +1 -1
  8. package/dist/client/{DataTable.vue_vue_type_script_setup_true_lang-lgIAQ4Oz.js → DataTable.vue_vue_type_script_setup_true_lang-IvRbPHup.js} +1 -1
  9. package/dist/client/{JsonViewer-BsC-w_01.js → JsonViewer-C6FsqOlJ.js} +1 -1
  10. package/dist/client/{LoginView-DriOurmS.js → LoginView-san5UrfX.js} +1 -1
  11. package/dist/client/{MarketplaceView-7pl01VFg.js → MarketplaceView-B89Shmm7.js} +1 -1
  12. package/dist/client/{Modal.vue_vue_type_script_setup_true_lang-CQE6ME9a.js → Modal.vue_vue_type_script_setup_true_lang-BLzEXJtn.js} +1 -1
  13. package/dist/client/{ModelModal.vue_vue_type_script_setup_true_lang-Dv-GVzNy.js → ModelModal.vue_vue_type_script_setup_true_lang-DTd4Jp3K.js} +1 -1
  14. package/dist/client/{ModelsView-BDxyu8pj.js → ModelsView-DWLrrwGf.js} +1 -1
  15. package/dist/client/{PromptEditView-Brn_lMum.js → PromptEditView-PHQ8rLZn.js} +1 -1
  16. package/dist/client/{PromptModal-BeqgBmpj.js → PromptModal-Bk5rLNB7.js} +1 -1
  17. package/dist/client/{PromptsView-Dgu1UMES.js → PromptsView-gugjlK3M.js} +1 -1
  18. package/dist/client/{ProvidersView-B3SPkaxt.js → ProvidersView-DVV8Q1Sw.js} +1 -1
  19. package/dist/client/ThreadInspectorPane.vue_vue_type_script_setup_true_lang-BvsyovVV.js +22 -0
  20. package/dist/client/{ThreadsView-D0hT0NXg.js → ThreadsView-Doxz0NfK.js} +1 -1
  21. package/dist/client/{ToolsView-BitH87Mf.js → ToolsView-BZfq0wpk.js} +1 -1
  22. package/dist/client/{UsersView-BArKqDfJ.js → UsersView-D5sXzAHz.js} +1 -1
  23. package/dist/client/{VariablesView-BJtT_XLQ.js → VariablesView-BlEY-E07.js} +1 -1
  24. package/dist/client/assets/{ThreadInspectorPane-C9Lp8kxl.css → ThreadInspectorPane-DczJCBBm.css} +1 -1
  25. package/dist/client/{index-CAiyJVjz.js → index-CdsRfG1j.js} +2 -2
  26. package/dist/client/index.html +1 -1
  27. package/dist/{index-BhIiPl8o.d.ts → index-Dn0rBA1H.d.ts} +4 -2
  28. package/dist/index.d.ts +3 -3
  29. package/dist/index.js +196 -35
  30. package/dist/index.js.map +1 -1
  31. package/dist/plugin.js +1 -1
  32. package/dist/plugin.js.map +1 -1
  33. package/dist/{resolver-D30lNT4L.d.ts → resolver-C6zKX6kw.d.ts} +11 -5
  34. package/dist/runtime.d.ts +2 -2
  35. package/dist/runtime.js +195 -34
  36. package/dist/runtime.js.map +1 -1
  37. package/dist/test.d.ts +1 -1
  38. package/package.json +5 -5
  39. package/dist/client/ThreadInspectorPane.vue_vue_type_script_setup_true_lang-DaArzwIz.js +0 -22
@@ -1,22 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["syntax-D68HCEYm.js","vendor-c_uwtQ-S.js","vue-DrmMqJdu.js","formkit-Cu5ivce0.js"])))=>i.map(i=>d[i]);
2
- import{d as at,z as N,e as n,k as Be,g as Pt,m as K,B as At,an as Vt,c as C,w as xe,r as b,O as Jt,a5 as Qr,ao as Zr,J as c,a4 as ha,C as Xr,D as es,b as o,f as t,q as m,j as z,s as st,u as f,h as et,a as Ht,Z as kn,o as Et,ap as ts,aq as Ft,ag as It,F as Re,l as Ke,K as Ye,n as bt,ar as dr,as as ur,ah as Bt,at as ns,au as as,av as oa,aw as cr,ax as fr,x as ft,ay as Fn,az as rs,aA as pr,aB as ss,X as os,Y as ls,aC as vr,y as wt,aD as Pn,aE as Tt,_ as la,aF as is,a3 as $t,aG as ds,am as xn,aH as us,aI as Nn,aJ as gr,aK as mr,aL as cs,al as fs,aM as hr,aN as xr,aO as ps,aP as br,aQ as vs,aR as yr,aS as kr,aT as gs,aU as ms,aV as hs,aW as xs,aX as bs,L as Wt,aY as ys,aZ as ln,a_ as ia,a$ as Hn,P as Ot,H as ks,b0 as _r,b1 as _s,b2 as ws,b3 as $s,b4 as Jn,b5 as Cs,b6 as Ss,b7 as Ts,b8 as Ta,b9 as zn,ba as Is,bb as As,bc as Ia,bd as Aa,be as da,bf as ua,W as Es,bg as Ls,bh as Rs,bi as Ea}from"./vue-DrmMqJdu.js";import{o as Ms,P as wr,b as Ze,Q as Ds,R as Fs,S as xa,U as Ps,V as ca,W as La,H as $r,X as Ns,Y as Ra,Z as zs,p as js,q as Bs,I as Os,t as pt,$ as Ma,a0 as Cr,a1 as Sr,G as nt,a2 as Tr,j as bn,a3 as jn,a4 as Vs,L as fa,a5 as Gn,_ as Sn,e as gn,f as vn,a6 as Hs,a7 as qs,a8 as Us,u as Ws,F as Lt,x as Ks,g as Da,a9 as Js,B as Gs,D as Ys,E as Qs,aa as Zs,ab as Xs,C as eo}from"./index-CAiyJVjz.js";import{e as to,p as no}from"./vendor-c_uwtQ-S.js";import{_ as Ir}from"./Modal.vue_vue_type_script_setup_true_lang-CQE6ME9a.js";import{u as ao}from"./timeAgo-Bi5TtiK2.js";import{_ as qn,u as ro}from"./CopyButton.vue_vue_type_script_setup_true_lang-vwNMv4kh.js";import{_ as mt,W as so,a as oo,b as lo,c as io,d as uo,e as dn}from"./monaco-DI2r3M8m.js";import{J as mn}from"./JsonViewer-BsC-w_01.js";import{_ as co}from"./ConfirmDialog.vue_vue_type_script_setup_true_lang-uehuZFVv.js";import{u as Ar,_ as Er,b as Tn,c as fo,P as po}from"./PromptModal-BeqgBmpj.js";const vo=at({__name:"UiMenuItem",props:{active:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},as:{default:"button"}},emits:["click"],setup(e,{emit:s}){const a=e,l=s;function r(i){a.disabled||l("click",i)}return(i,p)=>(n(),N(At(e.as),{type:e.as==="button"?"button":void 0,disabled:e.as==="button"?e.disabled:void 0,onClick:r,class:K(["w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors",[e.disabled?"opacity-50 cursor-not-allowed":"hover:bg-neutral-100 dark:hover:bg-neutral-800 cursor-pointer",e.active?"bg-accent-50 dark:bg-accent-950/30":""]])},{default:Be(()=>[Pt(i.$slots,"default")]),_:3},8,["type","disabled","class"]))}});async function hn(e){const s=await wr(e);if(!s.ok)throw new Error(`Request failed for ${e}`);return s.json()}async function go(e){if(!e)return null;try{return(await hn(`/prompts/${encodeURIComponent(e)}`)).prompt}catch{return null}}async function Rk(e){if(!e)return null;try{return await hn(`/tools/${encodeURIComponent(e)}`)}catch{return null}}function mo(e){const s=e?.env??e?.tenvs;return!s||typeof s!="object"?{}:s}function Lr(e){return Object.keys(mo(e)).filter(s=>s.trim().length>0)}function ho(e){const s=e?.variables||[],a=new Map;for(const l of s){const r=l.name?.trim();r&&a.set(r,{...l,name:r})}for(const l of Lr(e))a.has(l)||a.set(l,{name:l,type:"text",required:!1,description:"Default value set on this prompt."});return Array.from(a.values())}function Mk(e){return e?!e.packed&&e.id===e.name:!1}function xo(e,s){return s?.type?s.type:e.startsWith("provider:")?"provider":e.startsWith("mcp:")?"mcp":"unknown"}function bo(e){return e.startsWith("provider:")?e.slice(9):e.startsWith("mcp:")?e.slice(4):e}function yo(e,s){if(!e)return null;const a=s[e];if(a)return a;for(const l of Object.values(s))if(l.name===e)return l;return null}function ko(e,s,a={}){const l=s[e.name],r=l?.model;return{name:e.name,displayName:bo(e.name),kind:xo(e.name,l),description:l?.description||"",variables:l?.variables||[],model:r,resolvedModel:yo(r,a),config:e}}function _o(e){return e.as?.trim()||e.agent}function wo(e){const s=_o(e),a=e.immediate;return{name:s,displayName:s,kind:"subagent",description:e.description||"",variables:[],config:{name:s,blocking:e.blocking,optional:e.optional??null,immediate:a&&typeof a=="object"?{name_env:a.nameEnv??null,description_env:a.descriptionEnv??null,scoped_env:a.scopedEnv??[]}:a},relationship:e}}function Dk(e,s,a,l){const r=s==="a"?e.side_a_backing:e.side_b_backing,i=Ms(s,r,s==="a"?e.side_a_label:e.side_b_label),p=(s==="a"?e.side_a_handler:e.side_b_handler)||null,u=(s==="a"?e.side_a_subagents:e.side_b_subagents)||[],I=s==="a"?e.side_a_agent_prompt:e.side_b_agent_prompt,S=s==="a"?e.side_a_stop_on_response:e.side_b_stop_on_response,y=s==="a"?e.side_a_stop_tool:e.side_b_stop_tool,v=s==="a"?e.side_a_max_steps:e.side_b_max_steps,k=[s==="a"?e.side_a_session_stop_tool:e.side_b_session_stop_tool,s==="a"?e.side_a_session_fail_tool:e.side_b_session_fail_tool,s==="a"?e.side_a_session_status_tool:e.side_b_session_status_tool].filter(Y=>!!Y),j=(a?.tools||[]).map(Y=>ko(Y,l.toolsCatalog,l.models)),$=u.map(wo),W=[...j,...$],U=W.filter(Y=>Y.kind==="handoff"||Y.kind==="subagent");return{id:s,agentName:e.name,label:i,mode:r==="human"?"human":r==="handler"?"handler":"ai",backing:r,handlerName:p,promptName:I||null,stopOnResponse:S,stopTool:y,maxSteps:v,sessionStopTool:s==="a"?e.side_a_session_stop_tool:e.side_b_session_stop_tool,sessionTools:k,prompt:a,model:a&&l.models[a.model_id]||null,tools:W,hooks:(a?.hooks||[]).map(Y=>l.hooks[Y]||{id:Y,hook:"unknown"}),variables:ho(a),variableEnvNames:Lr(a),outgoingAgents:U}}function Rr(e){if(!e)return!1;if(e instanceof Error&&e.name==="AbortError")return!0;const s=String(e);return s.includes("signal is aborted")||s.includes("The operation was aborted")||s.includes("aborted a request")}function $o(e){const{limit:s=50,offset:a=0,agentId:l=null,userId:r=null,search:i=null,startDate:p=null,endDate:u=null,sort:I="activity",executingOnly:S=!1,includeTerminated:y=!0,autoFetch:v=!0}=e||{},k=C(()=>{const ee=new URLSearchParams,G=typeof s=="number"?s:s.value,R=typeof a=="number"?a:a.value,H=typeof l=="string"?l:l?.value,D=typeof r=="string"?r:r?.value,X=typeof i=="string"?i:i?.value,Se=typeof p=="number"?p:p?.value,ne=typeof u=="number"?u:u?.value;ee.append("limit",G.toString()),ee.append("offset",R.toString()),H&&(ee.append("agent_id",H),ee.append("include_children","1")),D&&ee.append("user_id",D),X&&ee.append("search",X),Se&&ee.append("startDate",Se.toString()),ne&&ee.append("endDate",ne.toString());const Le=typeof I=="string"?I:I.value;return Le&&ee.append("sort",Le),(typeof S=="boolean"?S:S.value)&&ee.append("executing","1"),(typeof y=="boolean"?y:y.value)||ee.append("terminated","0"),Ze(`/api/threads?${ee.toString()}`)}),{data:j,error:$,isFetching:W,isFinished:U,execute:Y,abort:ue}=Vt(k,{immediate:v,refetch:!0}).get().json(),ae=C(()=>j.value?.threads||[]),oe=C(()=>j.value?.total||0),ve=C(()=>j.value?.hasMore||!1);return{threads:ae,total:oe,hasMore:ve,error:$,isFetching:W,isFinished:U,refetch:Y,abort:ue}}function Co(){const{data:e,error:s,isFetching:a,execute:l}=Vt(Ze("/api/threads/owners"),{immediate:!0}).get().json();return{owners:C(()=>e.value?.owners||[]),error:s,isFetching:a,refetch:l}}function ba(e){const s=C(()=>{const y=typeof e=="string"?e:e?.value;return y?Ze(`/api/threads/${y}`):""}),{data:a,error:l,isFetching:r,isFinished:i,execute:p,abort:u}=Vt(s,{immediate:!1,refetch:!0}).get().json();xe(s,y=>{y?p():(u(),a.value=null)},{immediate:!0});const I=C(()=>a.value?{id:a.value.thread.id,agent_id:a.value.thread.agent_id,user_id:a.value.thread.user_id,tags:a.value.thread.tags||[],parent:a.value.thread.parent??null,terminated:a.value.thread.terminated??null,created_at:a.value.thread.created_at,agent:a.value.agent||{id:"",title:"Unknown",side_a_label:null,side_b_label:null},stats:a.value.stats}:null),S=C(()=>Rr(l.value)?null:l.value);return{thread:I,error:S,isFetching:r,isFinished:i,refetch:p,abort:u}}const Mr=3,Fa=3e4;let Bn=!1,un=null,En=0;function ya(){return Bn}function ka(e={}){if(Bn)return Promise.resolve("halt");if(un)return un;if(Date.now()<En)return Promise.resolve("retry");const s=e.fetch??fetch;return un=(async()=>{try{const a=await s(Ze("/api/auth/me"),Ds({credentials:"same-origin"}));return a.status===401||a.status===403?(Bn=!0,Fs(e),"halt"):(En=Date.now()+Fa,"retry")}catch{return En=Date.now()+Fa,"retry"}finally{un=null}})(),un}function Dr(){Bn=!1,En=0}function Fr(e){const s=e*.25;return Math.max(0,Math.round(e-s+Math.random()*s*2))}async function Fk(){return ya()?!1:await ka()==="retry"}const So={key:0,class:"flex min-h-[500px] items-center justify-center"},To={class:"flex min-h-0 min-w-0 flex-1 flex-col"},Io={key:0,class:"sticky top-0 z-10 flex min-w-0 shrink-0 items-center gap-2 border-b border-neutral-200 bg-neutral-50/95 px-3 backdrop-blur dark:border-neutral-800 dark:bg-neutral-950/95"},Ao={class:"min-w-0 flex-1"},Eo={class:"edit-sections-query"},Lo=at({__name:"AgentModal",props:{modelValue:{type:Boolean},editAgent:{},mode:{},apiError:{},readonly:{type:Boolean,default:!1},saving:{type:Boolean,default:!1},inline:{type:Boolean,default:!1},inlineGlobalNotice:{type:Boolean,default:!1},inlineAccentTabs:{type:Boolean,default:!1},inlineFlatSections:{type:Boolean,default:!1},surfaceSection:{default:null}},emits:["update:modelValue","save"],setup(e,{expose:s,emit:a}){const l=e,r=a,i=C(()=>l.mode==="edit"),p=C(()=>!!l.surfaceSection),u=C(()=>l.inline&&l.inlineFlatSections),I=C(()=>l.inline||p.value),S=C(()=>I.value?{config:xa}:{}),y=C(()=>i.value&&(l.editAgent?.id||l.editAgent?.name)||""),v=Ps(()=>y.value,{autoload:!1}),k=b(null),j=["basics","side-a","side-b","variables"],{activeTab:$,scrollToSection:W}=Ar(k,j);function U(le){return le==="human"?js:le==="handler"?Bs:Os}function Y(le,we){return`Side ${le} (${we==="human"?"Human":we==="handler"?"Handler":"Prompt"})`}const ue=C(()=>[{id:"basics",label:"Basics",icon:ca},{id:"side-a",label:"Side A",icon:U(v.sideABacking.value)},{id:"side-b",label:"Side B",icon:U(v.sideBBacking.value)},{id:"variables",label:"Variables",icon:La}]),ae=b(!1),oe=b(!1),ve=b(null);let ee=0;const G=C(()=>JSON.stringify({name:v.name.value,title:v.title.value,sideABacking:v.sideABacking.value,sideBBacking:v.sideBBacking.value,exposeAsTool:v.exposeAsTool.value,toolDescription:v.toolDescription.value,maxSessionTurns:v.maxSessionTurns.value,sideALabel:v.sideALabel.value,sideAAgentPrompt:v.sideAAgentPrompt.value,sideAHandler:v.sideAHandler.value,sideASubagents:v.sideASubagents.value,sideAStopOnResponse:v.sideAStopOnResponse.value,sideAStopOnToolCall:v.sideAStopOnToolCall.value,sideAStopTool:v.sideAStopTool.value,sideAStopToolResponseProperty:v.sideAStopToolResponseProperty.value,sideAManualStopCondition:v.sideAManualStopCondition.value,sideAMaxSteps:v.sideAMaxSteps.value,sideAEndConversationTool:v.sideAEndConversationTool.value,sideBLabel:v.sideBLabel.value,sideBAgentPrompt:v.sideBAgentPrompt.value,sideBHandler:v.sideBHandler.value,sideBSubagents:v.sideBSubagents.value,sideBStopOnResponse:v.sideBStopOnResponse.value,sideBStopOnToolCall:v.sideBStopOnToolCall.value,sideBStopTool:v.sideBStopTool.value,sideBStopToolResponseProperty:v.sideBStopToolResponseProperty.value,sideBMaxSteps:v.sideBMaxSteps.value,sideBEndConversationTool:v.sideBEndConversationTool.value,agentEnv:v.agentEnv.value})),R=C(()=>oe.value?"Saved":l.inline&&i.value?"Save Agent Changes":i.value?"Update Agent":"Create Agent"),H=C(()=>l.saving||l.inline&&!ae.value),D=C(()=>p.value||l.inline?{class:l.inline?"flex h-full min-w-0 flex-col":"min-w-0"}:{modelValue:l.modelValue,title:i.value?"Edit Agent":"Create Agent",width:"max-w-5xl",contentPadding:!1});function X(){oe.value=!1,ve.value=null}function Se(){et().then(()=>{ae.value=!!v.formNode.value?.context?.state.dirty})}function ne(le){v.handleFormNode(le),le.on("commit",Se),le.on("reset",Se),le.on("message-added",Se),le.on("message-updated",Se),le.on("message-removed",Se),Se()}async function Le(){const le=++ee;await et();const we=v.formNode.value;if(!we||le!==ee){ae.value=!1;return}await we.settled,we.reset(we.value),await et(),le===ee&&(ae.value=!1)}async function B(){await Le(),oe.value=!0,ve.value=G.value}async function re(){X(),v.resetForm(),await et(),i.value&&y.value?await v.load():await v.loadPrerequisites(),await Le()}async function Ce(){const le=await v.prepareSubmit();le&&r("save",le)}function ze(){v.resetForm(),X(),r("update:modelValue",!1)}async function Ve(){X(),await re()}function Te(le){return!l.surfaceSection||l.surfaceSection===le}return xe(()=>l.modelValue,async le=>{le?await re():(ee+=1,v.resetForm(),X(),ae.value=!1)},{immediate:!0}),xe(()=>y.value,async(le,we)=>{!l.modelValue||le===we||await re()}),xe(G,le=>{oe.value&&ve.value!==null&&le!==ve.value&&X()}),xe(ae,le=>{le&&X()}),s({formNode:v.formNode,markSaveSucceeded:B,markCurrentFormCleanAfterSettle:Le,resetSaveSuccess:X}),(le,we)=>{const ce=Jt("FormKit");return n(),N(At(e.inline||p.value?"div":Ir),Qr(D.value,Zr(e.inline||p.value?void 0:{"update:modelValue":te=>le.$emit("update:modelValue",te)})),{default:Be(()=>[(n(),N(At(I.value?c(ha):"div"),Xr(es(S.value)),{default:Be(()=>[c(v).isLoading.value?(n(),o("div",So,[...we[0]||(we[0]=[t("span",{class:"text-neutral-500"},"Loading agent data...",-1)])])):(n(),N(ce,{key:1,type:"form",id:"agent-form",actions:!1,disabled:e.readonly||e.saving,onSubmit:Ce,onNode:ne,"dirty-behavior":"compare","outer-class":"$reset flex min-h-0 min-w-0 flex-1 flex-col","form-class":"$reset flex-1 min-h-0 min-w-0 flex flex-col"},{default:Be(()=>[t("div",To,[p.value?m("",!0):(n(),o("nav",Io,[Pt(le.$slots,"nav-leading",{},void 0,!0),t("div",Ao,[z(c(Er),{tabs:ue.value,"active-tab":c($),"accent-active":e.inlineAccentTabs,orientation:"horizontal",onSelect:c(W)},null,8,["tabs","active-tab","accent-active","onSelect"])])])),t("div",{ref_key:"contentRef",ref:k,class:K(["min-h-0 flex-1 overflow-y-auto",p.value?"p-5":u.value?"bg-neutral-100 dark:bg-neutral-950":"bg-neutral-100 p-5 dark:bg-neutral-950"])},[t("div",Eo,[e.inlineGlobalNotice?(n(),o("div",{key:0,class:K(["edit-sections-notice rounded-md border border-amber-300 bg-amber-50 px-3 py-2 text-sm text-amber-800 dark:border-amber-700 dark:bg-amber-950/30 dark:text-amber-200",u.value?"mx-5 mb-4 mt-5":"mb-4"])}," Changes here are global and will affect all new messages across all threads. ",2)):m("",!0),t("div",{class:K([u.value?"space-y-4 pb-5":"space-y-4","edit-sections-stack"])},[e.apiError?(n(),N(c($r),{key:0,variant:"error"},{default:Be(()=>[st(f(e.apiError),1)]),_:1})):m("",!0),Te("identity")?(n(),N(c(Tn),{key:1,id:"section-basics",title:"Basics",icon:c(ca),flat:u.value},{default:Be(()=>[z(Ns,{form:c(v),"is-edit-mode":i.value},null,8,["form","is-edit-mode"])]),_:1},8,["icon","flat"])):m("",!0),Te("side-a")?(n(),N(c(Tn),{key:2,id:"section-side-a",title:Y("A",c(v).sideABacking.value),icon:U(c(v).sideABacking.value),flat:u.value},{default:Be(()=>[z(Ra,{form:c(v),side:"a"},null,8,["form"])]),_:1},8,["title","icon","flat"])):m("",!0),Te("side-b")?(n(),N(c(Tn),{key:3,id:"section-side-b",title:Y("B",c(v).sideBBacking.value),icon:U(c(v).sideBBacking.value),flat:u.value},{default:Be(()=>[z(Ra,{form:c(v),side:"b"},null,8,["form"])]),_:1},8,["title","icon","flat"])):m("",!0),Te("variables")?(n(),N(c(Tn),{key:4,id:"section-variables",title:"Variables",icon:c(La),flat:u.value},{default:Be(()=>[z(zs,{form:c(v),readonly:e.readonly},null,8,["form","readonly"])]),_:1},8,["icon","flat"])):m("",!0)],2)])],2)]),p.value?m("",!0):(n(),N(fo,{key:0,"form-id":"agent-form","form-node":c(v).formNode.value,readonly:e.readonly,inline:e.inline,saving:e.saving,dirty:ae.value,"save-succeeded":oe.value,"save-label":R.value,"save-disabled":H.value,"cancel-label":e.readonly?"Close":"Cancel",onCancel:ze,onDiscard:Ve},null,8,["form-node","readonly","inline","saving","dirty","save-succeeded","save-label","save-disabled","cancel-label"]))]),_:3},8,["disabled"]))]),_:3},16))]),_:3},16)}}}),Ro=pt(Lo,[["__scopeId","data-v-46ef9002"]]);function Pr(){const e=Ze("/api/agents"),{data:s,error:a,isFetching:l,isFinished:r,execute:i}=Vt(e,{immediate:!0}).get().json();return{agents:C(()=>s.value?.agents||[]),error:a,isFetching:l,isFinished:r,refetch:i}}function en(e,s,...a){}function _a(e){return!!e&&typeof e=="object"}function tn(e){return typeof e=="string"?e:null}function Ln(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function Mo(e){if(_a(e)&&!(typeof e.name!="string"||typeof e.title!="string"))return{name:e.name,title:e.title,side_a_backing:Ma(e.side_a_backing),side_b_backing:Ma(e.side_b_backing),description:tn(e.description)??void 0,icon:tn(e.icon)??void 0}}function Do(e){return!_a(e)||typeof e.id!="string"||typeof e.agent_name!="string"||typeof e.created_at!="number"?null:{id:e.id,agent_name:e.agent_name,user_id:tn(e.user_id),tags:Array.isArray(e.tags)?e.tags.filter(s=>typeof s=="string"):null,parent:tn(e.parent),terminated:Ln(e.terminated),created_at:e.created_at,last_activity_at:Ln(e.last_activity_at),executing:e.executing===!0,last_message_preview:tn(e.last_message_preview),last_message_at:Ln(e.last_message_at),agent:Mo(e.agent)}}function Fo(e){if(!_a(e))return null;if(e.type==="thread_deleted")return typeof e.threadId=="string"?{type:e.type,threadId:e.threadId}:null;if(e.type==="thread_activity")return typeof e.threadId=="string"&&typeof e.last_activity_at=="number"?{type:e.type,threadId:e.threadId,last_activity_at:e.last_activity_at,executing:e.executing===!0,...e.last_message_preview!==void 0?{last_message_preview:tn(e.last_message_preview)}:{},...e.last_message_at!==void 0?{last_message_at:Ln(e.last_message_at)}:{}}:null;if(e.type==="thread_created"||e.type==="thread_updated"){const s=Do(e.thread);return s?{type:e.type,thread:s}:null}return null}function Po(e){return e==="admin"?"all":"user"}function No(e="user"){return e==="all"?"/api/events?scope=all":"/api/events"}function zo(e){const{autoConnect:s=!0,onEvent:a,scope:l="user"}=e||{};let r=l;const i=b(null),p=b(!1),u=b(null);let I=0,S=null,y=null,v=!0,k=null,j=0,$=!1,W=0;const U=3e4,Y=3e4,ue=()=>{S&&(clearTimeout(S),S=null),y&&(clearInterval(y),y=null)};let ae=0;const oe=()=>{y&&clearInterval(y),ae=Date.now(),y=setInterval(()=>{i.value&&i.value.readyState===WebSocket.OPEN&&Date.now()-ae>=Y&&i.value.send("stream_ping")},Y)},ve=()=>{const X=Fr(Math.min(1e3*Math.pow(2,I),U));I++,en(),S=setTimeout(()=>{v&&G()},X)},ee=()=>{if(!(!v||ya())){if(j>=Mr){ka().then(X=>{X==="halt"||!v||ve()});return}ve()}},G=()=>{R()},R=async()=>{const X=++W;$=!1,i.value&&(k=null,i.value.close());const Se=window.location.protocol==="https:"?"wss:":"ws:",ne=window.location.host;try{const Le=await Cr(`${Se}//${ne}${Ze(No(r))}`);if(X!==W||!v)return;const B=new WebSocket(Le);i.value=B,k=B,B.onopen=()=>{k===B&&(p.value=!0,u.value=null,I=0,j=0,$=!0,Dr(),oe(),en("AgentBuilderEvents","WebSocket connected"))},B.onmessage=re=>{if(k===B){ae=Date.now();try{if(typeof re.data=="string"&&(re.data==="pong"||re.data==="stream_pong"))return;const Ce=Fo(JSON.parse(re.data));Ce&&a&&a(Ce)}catch{u.value="Failed to parse event update"}}},B.onerror=re=>{k===B&&(u.value="WebSocket connection error")},B.onclose=()=>{k===B&&(p.value=!1,$||j++,ue(),en("AgentBuilderEvents","WebSocket disconnected"),ee())}}catch(Le){u.value=Le instanceof Error?Le.message:"Failed to create WebSocket",ee()}},H=(X=r)=>{r=X,v=!0,I=0,G()},D=()=>{W++,v=!1,ue(),k=null,i.value&&(i.value.close(),i.value=null),p.value=!1,I=0};return s&&H(),Ht(()=>{D()}),{wsConnected:p,wsError:u,connect:H,disconnect:D}}const jo={class:"relative inline-flex items-center"},Bo={key:0,class:"inline-block w-2 h-2 rounded-full bg-green-500 dark:bg-green-400"},Oo={key:1,class:"inline-block w-2 h-2 rounded-full bg-neutral-400 dark:bg-neutral-600"},Vo={key:0},Ho={key:1},Nr=at({__name:"StatusDot",props:{connected:{type:Boolean},error:{type:Boolean}},setup(e){const s=b(!1),a=b(null);return(l,r)=>(n(),o("div",jo,[t("span",{class:"p-0.5 cursor-default outline-none",tabindex:"-1",onMouseenter:r[0]||(r[0]=i=>s.value=!0),onMouseleave:r[1]||(r[1]=i=>s.value=!1)},[e.connected?(n(),o("span",Bo)):(n(),o("span",Oo))],32),z(kn,{"enter-active-class":"transition-opacity duration-150","enter-from-class":"opacity-0","enter-to-class":"opacity-100","leave-active-class":"transition-opacity duration-100","leave-from-class":"opacity-100","leave-to-class":"opacity-0"},{default:Be(()=>[s.value?(n(),o("div",{key:0,ref_key:"popoverRef",ref:a,class:K(["absolute top-full left-1/2 -translate-x-1/2 mt-1 px-2 py-1 text-xs rounded shadow-lg whitespace-nowrap z-50 border",{"bg-green-50 dark:bg-green-950 border-green-200 dark:border-green-800 text-green-700 dark:text-green-300":e.connected,"bg-neutral-50 dark:bg-neutral-900 border-neutral-200 dark:border-neutral-700 text-neutral-600 dark:text-neutral-400":!e.connected}])},[e.connected?(n(),o("span",Vo,"Live - Connected")):(n(),o("span",Ho,"Offline"))],2)):m("",!0)]),_:1})]))}}),qo={class:"relative min-w-0"},Uo={class:"truncate flex-1 text-left"},Wo={key:0},Ko=["onClick"],Jo={class:"border-t border-neutral-200 dark:border-neutral-700"},Go={class:"flex items-center justify-between"},Yo={class:"space-y-4 date-filter-inputs"},Qo=at({__name:"DateFilterDropdown",props:{startDate:{},endDate:{}},emits:["update:startDate","update:endDate"],setup(e,{emit:s}){const a=e,l=s,r=b(!1),i=b(!1),p=b(null),u=b(null),I=b(""),S=b(""),y=[{label:"All time",value:"all",getRange:()=>({startDate:null,endDate:null})},{label:"Today",value:"today",getRange:()=>{const G=new Date,R=new Date(G.getFullYear(),G.getMonth(),G.getDate());return{startDate:Math.floor(R.getTime()/1e3),endDate:null}}},{label:"Last 3 days",value:"3days",getRange:()=>{const G=new Date,R=new Date(G.getFullYear(),G.getMonth(),G.getDate()-2);return{startDate:Math.floor(R.getTime()/1e3),endDate:null}}},{label:"Last 7 days",value:"7days",getRange:()=>{const G=new Date,R=new Date(G.getFullYear(),G.getMonth(),G.getDate()-6);return{startDate:Math.floor(R.getTime()/1e3),endDate:null}}},{label:"Last 30 days",value:"30days",getRange:()=>{const G=new Date,R=new Date(G.getFullYear(),G.getMonth(),G.getDate()-29);return{startDate:Math.floor(R.getTime()/1e3),endDate:null}}}],v=C(()=>{if(!a.startDate&&!a.endDate)return"all";for(const G of y){const R=G.getRange();if(R.startDate===a.startDate&&R.endDate===a.endDate)return G.value}return"custom"}),k=C(()=>{if(!a.startDate&&!a.endDate)return"All time";const G=y.find(H=>H.value===v.value);if(G&&v.value!=="custom")return G.label;const R=H=>new Date(H*1e3).toLocaleDateString("en-US",{month:"short",day:"numeric"});return a.startDate&&a.endDate?`${R(a.startDate)} - ${R(a.endDate)}`:a.startDate?`From ${R(a.startDate)}`:a.endDate?`Until ${R(a.endDate)}`:"Custom"}),j=C(()=>a.startDate!==null||a.endDate!==null);function $(){if(!p.value||!u.value)return;const G=p.value.getBoundingClientRect();u.value.style.position="fixed",u.value.style.top=`${G.bottom+8}px`,u.value.style.left=`${G.left}px`;const R=i.value?280:180;u.value.style.minWidth=`${G.width}px`,u.value.style.maxWidth=`${Math.max(G.width,R)}px`,u.value.style.width="auto",u.value.style.margin="0"}function W(){r.value?U():(r.value=!0,et(()=>{if(u.value&&(u.value.setAttribute("popover","auto"),u.value.addEventListener("toggle",Y),"showPopover"in u.value))try{u.value.showPopover()}catch{}$()}))}function U(){if(u.value){if("hidePopover"in u.value)try{u.value.hidePopover()}catch{}u.value.removeEventListener("toggle",Y)}r.value=!1,i.value=!1}function Y(G){G.target===u.value&&(r.value=G.newState==="open",r.value&&$())}function ue(G){const R=G.getRange();l("update:startDate",R.startDate),l("update:endDate",R.endDate),U()}function ae(){const G=I.value?Math.floor(new Date(I.value).getTime()/1e3):null,R=S.value?Math.floor(new Date(S.value+"T23:59:59").getTime()/1e3):null;l("update:startDate",G),l("update:endDate",R),U()}function oe(G){G.stopPropagation(),l("update:startDate",null),l("update:endDate",null)}const ve=G=>{const R=G.target;u.value&&!u.value.contains(R)&&p.value&&!p.value.contains(R)&&U()},ee=G=>{G.key==="Escape"&&r.value&&(U(),p.value?.focus())};return Et(()=>{document.addEventListener("click",ve),document.addEventListener("keydown",ee),window.addEventListener("resize",$),window.addEventListener("scroll",$,!0)}),Ht(()=>{document.removeEventListener("click",ve),document.removeEventListener("keydown",ee),window.removeEventListener("resize",$),window.removeEventListener("scroll",$,!0)}),xe(i,G=>{G&&(a.startDate&&(I.value=new Date(a.startDate*1e3).toISOString().split("T")[0]),a.endDate?S.value=new Date(a.endDate*1e3).toISOString().split("T")[0]:S.value=new Date().toISOString().split("T")[0]),et($)}),(G,R)=>{const H=Jt("FormKit");return n(),o("div",qo,[t("button",{ref_key:"triggerRef",ref:p,type:"button",onClick:W,class:K(["w-full flex items-center gap-1 px-2 py-1 text-xs rounded-sm border transition-colors min-w-0 focus:outline-none focus:ring-2 focus:ring-accent-500/30",[j.value?"agents-border-selected agents-surface-selected agents-text-selected-muted":"border-zinc-300 dark:border-zinc-600 hover:border-accent-400 dark:hover:border-accent-500 bg-white dark:bg-transparent text-zinc-700 dark:text-zinc-300"]])},[z(c(ts),{size:14,class:"shrink-0 text-zinc-400"}),t("span",Uo,f(k.value),1),j.value?(n(),N(c(Ft),{key:0,size:14,class:"shrink-0 text-zinc-400 hover:text-zinc-600 dark:hover:text-zinc-200",onClick:oe})):(n(),N(c(It),{key:1,size:14,class:K(["shrink-0 text-zinc-400",r.value?"rotate-180":""])},null,8,["class"]))],2),r.value?(n(),o("div",{key:0,ref_key:"popoverRef",ref:u,class:"dropdown-popover z-[9999]"},[z(c(Sr),{"max-height":i.value?void 0:"max-h-48",shadow:!1},{default:Be(()=>[i.value?(n(),o("div",{key:1,class:"p-2.5 space-y-2.5",onClick:R[4]||(R[4]=Ye(()=>{},["stop"]))},[t("div",Go,[R[6]||(R[6]=t("span",{class:"text-xs font-medium"},"Custom range",-1)),t("button",{type:"button",onClick:R[1]||(R[1]=Ye(D=>i.value=!1,["stop"])),class:"text-[10px] text-neutral-500 hover:text-black dark:hover:text-white"}," ← Back ")]),t("div",Yo,[z(H,{modelValue:I.value,"onUpdate:modelValue":R[2]||(R[2]=D=>I.value=D),type:"datepicker",label:"From","picker-only":"",popover:"",format:"MMM D, YYYY","value-format":"YYYY-MM-DD",sequence:["day"]},null,8,["modelValue"]),z(H,{modelValue:S.value,"onUpdate:modelValue":R[3]||(R[3]=D=>S.value=D),type:"datepicker",label:"To","picker-only":"",popover:"",format:"MMM D, YYYY","value-format":"YYYY-MM-DD",sequence:["day"]},null,8,["modelValue"])]),t("button",{type:"button",onClick:ae,class:"w-full py-1.5 text-xs font-medium bg-black dark:bg-white text-white dark:text-black rounded-sm hover:opacity-90 transition-opacity"}," Apply ")])):(n(),o("div",Wo,[(n(),o(Re,null,Ke(y,D=>t("button",{key:D.value,type:"button",onClick:X=>ue(D),class:K(["w-full px-2.5 py-1.5 text-left text-xs agents-surface-hover transition-colors flex items-center gap-2",v.value===D.value?"agents-surface-selected agents-text-selected":""])},[t("span",{class:K(["w-1.5 h-1.5 rounded-full border border-accent-500",v.value===D.value?"bg-accent-500":""])},null,2),st(" "+f(D.label),1)],10,Ko)),64)),t("div",Jo,[t("button",{type:"button",onClick:R[0]||(R[0]=Ye(D=>i.value=!0,["stop"])),class:K(["w-full px-2.5 py-1.5 text-left text-xs agents-surface-hover transition-colors flex items-center gap-2",v.value==="custom"?"agents-surface-selected agents-text-selected":""])},[t("span",{class:K(["w-1.5 h-1.5 rounded-full border border-accent-500",v.value==="custom"?"bg-accent-500":""])},null,2),R[5]||(R[5]=st(" Custom range... ",-1))],2)])]))]),_:1},8,["max-height"])],512)):m("",!0)])}}}),Zo=pt(Qo,[["__scopeId","data-v-753faf78"]]),an=at({__name:"TimeAgo",props:{timestamp:{}},setup(e){const s=e,a=ao(()=>s.timestamp);return(l,r)=>(n(),o("span",null,f(c(a)),1))}}),pa="name:",Pa=["bg-sky-400/70 dark:bg-sky-500/70","bg-emerald-400/70 dark:bg-emerald-500/70","bg-amber-400/70 dark:bg-amber-500/70","bg-rose-400/70 dark:bg-rose-500/70","bg-violet-400/70 dark:bg-violet-500/70"],Xo=(e,s)=>s.created_at-e.created_at,yn=e=>e.last_activity_at??e.created_at,va=e=>e.executing===!0&&!e.terminated,el=e=>{const s=new Map,a=new Map(e.map(l=>[l.id,l]));for(const l of e){const r=yn(l);let i=l;const p=new Set;for(;i&&!p.has(i.id);){p.add(i.id);const u=s.get(i.id);(u===void 0||u<r)&&s.set(i.id,r),i=i.parent?a.get(i.parent):void 0}}return s},zr=e=>{const s=new Set,a=new Map(e.map(l=>[l.id,l]));for(const l of e){if(!va(l))continue;let r=l;const i=new Set;for(;r&&!i.has(r.id);)i.add(r.id),s.add(r.id),r=r.parent?a.get(r.parent):void 0}return s},tl=(e,s,a)=>{const l=r=>s.get(r.id)??yn(r);return(r,i)=>{const p=a.has(r.id),u=a.has(i.id);if(p!==u)return p?-1:1;if(e==="created")return i.created_at-r.created_at;if(e==="oldest")return r.created_at-i.created_at;const I=l(i)-l(r);return I!==0?I:i.created_at-r.created_at}},Rn=(e,s)=>`${e}::${s}`,jr=e=>{const s=e.tags.find(l=>l.startsWith(pa));if(!s)return null;const a=s.slice(pa.length).trim();return a.length>0?a:null},Yn=e=>{const s=e.last_message_preview?.trim();return s||null},nl=e=>yn(e)>e.created_at,Rt=e=>e.tags.filter(s=>!s.startsWith(pa)),al=e=>jr(e)||e.agent.title||e.agent.name,rl=e=>e.id.startsWith("__draft_")?"--------":e.id.slice(0,8),Qn=e=>jr(e)?e.agent.title||e.agent.name:null,Na=e=>Array.from({length:Math.min(Math.max(e,0),6)},(s,a)=>12+a*8),za=e=>Pa[e%Pa.length],ja=e=>({left:`${e}px`}),sl=(e,s,a="activity")=>{if(e.length===0)return[];const l=el(e),r=zr(e),i=tl(a,l,r),p=new Map(e.map($=>[$.id,$])),u=new Map,I=[];for(const $ of e){const W=$.parent;if(W&&p.has(W)){const U=u.get(W)??[];U.push($),u.set(W,U);continue}I.push($)}I.sort(i);for(const $ of u.values())$.sort(i);const S=[],y=new Set,v=$=>{if(y.has($.id))return;y.add($.id);const W=u.get($.id);if(W)for(const U of W)v(U)},k=($,W,U)=>{if(y.has($.id))return;y.add($.id),S.push({kind:"thread",thread:$,depth:W,isNested:W>0,clusterId:U});const Y=u.get($.id);if(!Y)return;const ue=new Map;for(const ae of Y){const oe=ae.agent_id||ae.agent?.name||ae.id,ve=ue.get(oe);ve?ve.push(ae):ue.set(oe,[ae])}for(const[ae,oe]of ue.entries()){if(oe.length>1){const ve=Rn($.id,ae),ee=s(ve);if(S.push({kind:"directory",key:ve,depth:W+1,label:oe[0]?.agent?.title||oe[0]?.agent?.name||ae,count:oe.length,open:ee,clusterId:U,working:oe.some(G=>r.has(G.id))}),!ee){for(const G of oe)v(G);continue}for(const G of oe)k(G,W+2,U);continue}k(oe[0],W+1,U)}};for(const $ of I)k($,0,$.id);const j=e.filter($=>!y.has($.id)).sort(i);for(const $ of j)k($,$.parent?1:0,$.parent??$.id);return S},ol=["id","onClick"],ll=["title"],il=["title"],dl={key:0,class:"text-emerald-600 dark:text-emerald-400"},ul=["title"],cl={key:2,class:"space-y-0.5"},fl={key:0,class:"flex flex-wrap gap-1 min-w-0"},pl={key:3,class:"flex items-center gap-1"},vl={key:0,class:"text-[10px] text-neutral-400"},gl=["onClick"],ml={class:"flex items-center gap-2"},hl={key:0,class:"thread-working-dot shrink-0",title:"A thread in this group is executing","aria-label":"Working"},xl=at({__name:"ThreadListRows",props:{rows:{},selectedThreadId:{},workingClusterIds:{},clusterHasNestedRows:{},isThreadFlashing:{type:Function},isDirectoryFlashing:{type:Function},hasRowTopGap:{type:Function},hasRowBottomBorder:{type:Function}},emits:["selectThread","toggleDirectory"],setup(e,{emit:s}){const a=e,l=s,r=i=>a.workingClusterIds.has(i);return(i,p)=>(n(!0),o(Re,null,Ke(e.rows,(u,I)=>(n(),o(Re,{key:u.kind==="thread"?u.thread.id:u.key},[u.kind==="thread"?(n(),o("button",{key:0,id:`thread-${u.thread.id}`,class:K(["w-full text-left cursor-pointer rounded-lg px-3 transition-colors relative",[u.isNested?e.selectedThreadId===u.thread.id?"py-1.5":"py-1.5 bg-neutral-50/40 dark:bg-neutral-900/20":"py-2",e.hasRowTopGap(I)?"mt-1":"",e.hasRowBottomBorder(I)&&e.clusterHasNestedRows[u.clusterId]?"mb-1":"",u.thread.terminated?"opacity-50 text-neutral-500 dark:text-neutral-500":"",e.selectedThreadId===u.thread.id?"agents-surface-selected":"agents-surface-hover"]]),style:bt(u.depth>0?{paddingLeft:`${12+Math.min(u.depth,6)*8}px`}:void 0),onClick:S=>l("selectThread",u.thread.id)},[(n(!0),o(Re,null,Ke(c(Na)(u.depth),(S,y)=>(n(),o("span",{key:`thread-line-${y}`,class:K(["pointer-events-none absolute inset-y-1 w-px rounded-full",c(za)(y)]),style:bt(c(ja)(S)),"aria-hidden":"true"},null,6))),128)),t("div",{class:K(["flex items-center gap-2",!u.isNested||c(Rt)(u.thread).length>0||c(Qn)(u.thread)?"mb-0.5":""])},[r(u.thread.id)?(n(),o("span",{key:0,class:"thread-working-dot shrink-0",title:u.thread.executing?"Executing now":"Subagent executing","aria-label":"Working"},null,8,ll)):u.thread.terminated?(n(),N(c(dr),{key:1,size:12,class:"shrink-0 text-neutral-500 dark:text-neutral-400"})):m("",!0),t("span",{class:K(["font-medium truncate flex-1 min-w-0",[e.selectedThreadId===u.thread.id?"agents-text-selected":"",e.isThreadFlashing(u.thread.id)?"thread-list-green-flash":""]])},f(c(al)(u.thread)),3),t("span",{class:K(["flex-shrink-0 text-[10px]",e.selectedThreadId===u.thread.id?"agents-text-selected-muted":"text-neutral-400 dark:text-neutral-500"]),title:c(nl)(u.thread)?`Last activity ${new Date(c(yn)(u.thread)*1e3).toLocaleString()} · Created ${new Date(u.thread.created_at*1e3).toLocaleString()}`:`Created ${new Date(u.thread.created_at*1e3).toLocaleString()} · no activity recorded`},[r(u.thread.id)?(n(),o("span",dl," working ")):(n(),N(an,{key:1,timestamp:c(yn)(u.thread)*1e6},null,8,["timestamp"]))],10,il)],2),c(Yn)(u.thread)?(n(),o("div",{key:0,class:K(["mb-0.5 truncate text-[11px]",e.selectedThreadId===u.thread.id?"agents-text-selected":"text-neutral-600 dark:text-neutral-300"]),title:c(Yn)(u.thread)||""},f(c(Yn)(u.thread)),11,ul)):m("",!0),c(Qn)(u.thread)?(n(),o("div",{key:1,class:K(["mb-0.5 truncate text-[10px]",e.selectedThreadId===u.thread.id?"agents-text-selected-muted":"text-neutral-400 dark:text-neutral-500"])},f(c(Qn)(u.thread)),3)):m("",!0),u.isNested?c(Rt)(u.thread).length>0?(n(),o("div",pl,[(n(!0),o(Re,null,Ke(c(Rt)(u.thread).slice(0,3),S=>(n(),o("span",{key:S,class:"inline-block px-1.5 py-0.5 rounded text-[10px] truncate max-w-[120px] bg-neutral-200 dark:bg-neutral-800 text-neutral-600 dark:text-neutral-400"},f(S),1))),128)),c(Rt)(u.thread).length>3?(n(),o("span",vl," +"+f(c(Rt)(u.thread).length-3),1)):m("",!0)])):m("",!0):(n(),o("div",cl,[t("span",{class:K(["block max-w-[80px] truncate font-mono text-[10px]",e.selectedThreadId===u.thread.id?"agents-text-selected-muted":"text-neutral-400 dark:text-neutral-500"])},f(c(rl)(u.thread)),3),c(Rt)(u.thread).length>0?(n(),o("div",fl,[(n(!0),o(Re,null,Ke(c(Rt)(u.thread).slice(0,3),S=>(n(),o("span",{key:S,class:K(["inline-block px-1.5 py-0.5 rounded text-[10px] truncate max-w-[60px]",e.selectedThreadId===u.thread.id?"agents-surface-selected-strong agents-text-selected":"bg-neutral-200 dark:bg-neutral-800 text-neutral-600 dark:text-neutral-400"])},f(S),3))),128)),c(Rt)(u.thread).length>3?(n(),o("span",{key:0,class:K(["text-[10px]",e.selectedThreadId===u.thread.id?"agents-text-selected-muted":"text-neutral-400"])}," +"+f(c(Rt)(u.thread).length-3),3)):m("",!0)])):m("",!0)]))],14,ol)):(n(),o("button",{key:1,type:"button",class:"w-full rounded-lg text-left px-3 py-1.5 bg-neutral-50/25 dark:bg-neutral-900/10 hover:bg-neutral-100 dark:hover:bg-neutral-800/40 transition-colors relative",style:bt({paddingLeft:`${12+Math.min(u.depth,6)*8}px`}),onClick:S=>l("toggleDirectory",u.key)},[(n(!0),o(Re,null,Ke(c(Na)(u.depth),(S,y)=>(n(),o("span",{key:`directory-line-${y}`,class:K(["pointer-events-none absolute inset-y-1 w-px rounded-full",c(za)(y)]),style:bt(c(ja)(S)),"aria-hidden":"true"},null,6))),128)),t("div",ml,[u.working?(n(),o("span",hl)):(n(),N(c(ur),{key:1,size:13,class:"text-neutral-500 dark:text-neutral-400 shrink-0"})),t("span",{class:K(["truncate flex-1 min-w-0 text-[11px] font-medium text-neutral-600 dark:text-neutral-300",e.isDirectoryFlashing(u.key)?"thread-list-green-flash":""])},f(u.label)+" ("+f(u.count)+") ",3),u.open?(n(),N(c(It),{key:2,size:14,class:"text-neutral-500 dark:text-neutral-400 shrink-0"})):(n(),N(c(Bt),{key:3,size:14,class:"text-neutral-500 dark:text-neutral-400 shrink-0"}))])],12,gl))],64))),128))}}),bl=pt(xl,[["__scopeId","data-v-ce56afa5"]]),yl={class:"flex flex-col flex-1 min-h-0 overflow-visible"},kl={class:"px-3 border-b border-neutral-300 dark:border-neutral-700 h-12 flex items-center shrink-0"},_l={class:"flex items-center w-full min-w-0"},wl={key:0,class:"shrink-0 text-xs font-mono text-neutral-500 dark:text-neutral-400"},$l=["title"],Cl={class:"ml-auto flex shrink-0 items-center gap-1"},Sl=["title","aria-label","aria-pressed"],Tl={key:0,class:"px-3 py-2 border-b border-neutral-200 dark:border-neutral-800 shrink-0 space-y-2"},Il={class:"relative"},Al={class:"flex items-center gap-2 w-full"},El={class:"relative flex-1 min-w-0"},Ll=["value"],Rl=["aria-pressed"],Ml=["aria-pressed"],Dl={key:0},Fl={class:"flex items-center gap-2 w-full"},Pl={key:0,class:"flex-1 min-w-0"},Nl={key:0,class:"p-4 flex justify-center"},zl={key:1,class:"p-4 text-red-600 dark:text-red-400"},jl={key:2,class:"text-neutral-500 dark:text-neutral-400 text-center py-12"},Bl={key:1,class:"text-base"},Ol={key:3,class:"px-2 py-2"},Vl={key:0,class:"p-3 flex justify-center"},Hl={key:1,class:"p-3 text-center text-[10px] text-neutral-400 dark:text-neutral-500"},Ba="agents.threads.sort",ql=50,Oa=1800,Ul=at({__name:"ThreadListPane",props:{selectedThreadId:{},optimisticThread:{},agentId:{},showCollapseButton:{type:Boolean}},emits:["selectThread","collapse","createThread","threadsLoaded"],setup(e,{expose:s,emit:a}){const l=e,r=a,i=b(""),p=b(null),u=b(!1),I=b(null),S=b(null),y=b(null),v=b(!1),k=b(!0),j=b(null),$=[{value:"activity",label:"Recent activity"},{value:"created",label:"Newest"},{value:"oldest",label:"Oldest"}],U=b((()=>{try{const P=localStorage.getItem(Ba);if($.some(q=>q.value===P))return P}catch{}return"activity"})());xe(U,P=>{try{localStorage.setItem(Ba,P)}catch{}});const{owners:Y}=Co(),ue=C(()=>Y.value.filter(P=>P.user_id).map(P=>({value:P.user_id,label:`${P.display_name||P.username||P.email||P.user_id} (${P.thread_count})`}))),ae=C(()=>ue.value.length>1),oe=b(!1),ve=C(()=>l.agentId!=null);xe(()=>l.agentId,P=>{P!=null&&(S.value=P),oe.value=!1},{immediate:!0});const ee=b(null),{agents:G,isFetching:R}=Pr(),H=C(()=>G.value.map(P=>({value:P.name,label:P.title||P.name}))),D=b(0),X=b([]),Se=b(!1),ne=b(!1),Le=ss(P=>{p.value=P||null},300);xe(i,P=>{Le(P)});const B=C(()=>{let P=0;return p.value&&P++,S.value&&!ve.value&&P++,y.value&&P++,v.value&&P++,k.value||P++,(j.value||ee.value)&&P++,P});function re(){i.value="",p.value=null,ve.value||(S.value=null),y.value=null,v.value=!1,k.value=!0,j.value=null,ee.value=null}async function Ce(){u.value=!0,await et(),I.value?.focus(),I.value?.select()}function ze(){re(),u.value=!1}function Ve(){u.value?ze():Ce()}const{threads:Te,hasMore:le,isFetching:we,isFinished:ce,error:te,refetch:ie}=$o({limit:ql,offset:D,search:p,agentId:S,userId:y,startDate:j,endDate:ee,sort:U,executingOnly:v,includeTerminated:k}),me=b([]),Q=b(new Set);xe([p,S,y,v,k,U,j,ee],()=>{D.value=0,X.value=[],me.value=[],Q.value.clear(),Se.value=!1,ne.value=!1}),xe(Te,P=>{if(D.value===0){const q=new Map(X.value.map(Ie=>[Ie.id,Ie]));X.value=P.map(Ie=>{const _e=q.get(Ie.id);if(!_e)return Ie;const Ge=Ie.last_message_at??0;return(_e.last_message_at??0)<=Ge?Ie:{...Ie,last_message_at:_e.last_message_at,..._e.last_message_preview!==void 0?{last_message_preview:_e.last_message_preview}:{},..._e.last_activity_at!==void 0&&(Ie.last_activity_at??0)<_e.last_activity_at?{last_activity_at:_e.last_activity_at,executing:_e.executing}:{}}})}else{const q=new Set(X.value.map(_e=>_e.id)),Ie=P.filter(_e=>!q.has(_e.id));X.value=[...X.value,...Ie],ne.value=!0}Se.value=!1});const Me=b({}),Ne=b({}),Ue=b({}),We=new Set,E=P=>Me.value[P]??!1,fe=P=>{Me.value[P]=!E(P)},be=P=>{Ne.value[P]=!0;const q=setTimeout(()=>{delete Ne.value[P],We.delete(q)},Oa);We.add(q)},Pe=P=>{Ue.value[P]=!0;const q=setTimeout(()=>{delete Ue.value[P],We.delete(q)},Oa);We.add(q)};Ht(()=>{We.forEach(P=>clearTimeout(P)),We.clear()});const J=P=>Ne.value[P]===!0,ke=P=>Ue.value[P]===!0,ye=P=>{if(S.value&&P.agent_id!==S.value&&P.origin_agent_id!==S.value&&!P.parent||y.value&&P.user_id!==y.value||v.value&&!va(P)&&!P.parent||!k.value&&P.terminated||j.value&&P.created_at<j.value||ee.value&&P.created_at>ee.value)return!1;if(p.value){const q=p.value.toLowerCase(),Ie=P.id.toLowerCase().includes(q),_e=P.tags.some(Ge=>Ge.toLowerCase().includes(q));if(!Ie&&!_e)return!1}return!0},Ae=C(()=>{const P=X.value.filter(Ge=>!Q.value.has(Ge.id)),q=new Set(P.map(Ge=>Ge.id)),_e=[...me.value.filter(Ge=>!q.has(Ge.id)&&!Q.value.has(Ge.id)),...P];return l.optimisticThread&&!_e.some(Ge=>Ge.id===l.optimisticThread?.id)&&_e.unshift(l.optimisticThread),_e.sort(Xo)}),V=C(()=>Ae.value.filter(P=>!P.parent).length),$e=C(()=>zr(Ae.value)),pe=C(()=>Ae.value.filter(va).length),Fe=C(()=>sl(Ae.value,E,U.value)),tt=P=>{const q=Fe.value[P],Ie=Fe.value[P+1];return q?Ie?q.clusterId!==Ie.clusterId:!0:!1},Qe=P=>{const q=Fe.value[P],Ie=Fe.value[P-1];if(!q||!Ie||q.clusterId!==Ie.clusterId)return!1;const _e=q.kind==="directory"||q.kind==="thread"&&q.isNested,Ge=Ie.kind==="thread"&&!Ie.isNested;return _e&&Ge},lt=C(()=>{const P={};for(const q of Fe.value)if(!P[q.clusterId]){if(q.kind==="directory"){P[q.clusterId]=!0;continue}if(q.kind==="thread"&&q.isNested){P[q.clusterId]=!0;continue}P[q.clusterId]=!1}return P}),he=b(null);function O(){Se.value||we.value||!le.value||(Se.value=!0,D.value=X.value.length)}const{arrivedState:se}=ns(he,{offset:{bottom:100}});xe(()=>se.bottom,P=>{P&&le.value&&!we.value&&!Se.value&&O()});const He=P=>{const q=G.value.find(_e=>_e.name===P.agent_name),Ie=P.agent;return{id:P.id,agent_id:P.agent_name,origin_agent_id:P.origin_agent_name??P.agent_name,user_id:P.user_id,tags:P.tags||[],parent:P.parent??null,terminated:P.terminated??null,created_at:P.created_at,last_activity_at:P.last_activity_at??P.created_at,executing:P.executing===!0,last_message_preview:P.last_message_preview??null,last_message_at:P.last_message_at??null,agent:{name:P.agent_name,title:Ie?.title||q?.title,side_a_backing:Ie?.side_a_backing??q?.side_a_backing??null,side_b_backing:Ie?.side_b_backing??q?.side_b_backing??null}}},de=async P=>{if(P.type==="thread_created"){const q=He(P.thread);if(!ye(q))return;if(q.parent)if(Ae.value.filter(_e=>_e.parent===q.parent&&_e.agent_id===q.agent_id).length+1>1){const _e=Rn(q.parent,q.agent_id);Pe(_e),E(_e)&&be(q.id)}else be(q.id);me.value.unshift(q)}else if(P.type==="thread_updated"){const q=He(P.thread),Ie=Ae.value.find(d=>d.id===q.id);if(!ye(q)){me.value=me.value.filter(d=>d.id!==q.id),X.value=X.value.filter(d=>d.id!==q.id);return}Q.value.delete(q.id);const _e=me.value.findIndex(d=>d.id===q.id);_e>=0&&(me.value[_e]=q);const Ge=X.value.findIndex(d=>d.id===q.id);if(Ge>=0?X.value[Ge]=q:_e===-1&&me.value.unshift(q),!!q.terminated&&!Ie?.terminated)if(q.parent)if((Ae.value.filter(h=>h.parent===q.parent&&h.agent_id===q.agent_id).length||1)>1){const h=Rn(q.parent,q.agent_id);Pe(h),E(h)&&be(q.id)}else be(q.id);else be(q.id)}else if(P.type==="thread_activity"){const q=Ie=>{const _e=Ie.findIndex(Ge=>Ge.id===P.threadId);_e!==-1&&(Ie[_e]={...Ie[_e],...P.last_activity_at!==void 0?{last_activity_at:P.last_activity_at}:{},...P.executing!==void 0?{executing:P.executing}:{},...P.last_message_preview!==void 0?{last_message_preview:P.last_message_preview}:{},...P.last_message_at!==void 0?{last_message_at:P.last_message_at}:{}})};q(X.value),q(me.value)}else P.type==="thread_deleted"&&(Q.value.add(P.threadId),me.value=me.value.filter(q=>q.id!==P.threadId))},{wsConnected:L,wsError:ge,connect:je}=zo({autoConnect:!1,onEvent:de});let Je=!1;Ht(()=>{Je=!0}),(async()=>{let P;try{const q=await wr("/auth/me");q.ok&&(P=(await q.json()).user?.role)}catch{}Je||je(Po(P))})(),xe(()=>D.value,P=>{P===0&&(me.value=[])}),xe(()=>[l.selectedThreadId,Ae.value],([P,q])=>{if(!P||q.length===0)return;const Ie=new Map(q.map(Ge=>[Ge.id,Ge]));let _e=Ie.get(P);for(;_e&&_e.parent;){const Ge=Rn(_e.parent,_e.agent_id);Me.value[Ge]=!0,_e=Ie.get(_e.parent)}},{immediate:!0}),xe(()=>({rows:Fe.value,finished:ce.value}),({rows:P,finished:q})=>{const Ie=P.find(_e=>_e.kind==="thread");q&&!oe.value&&(oe.value=!0,r("threadsLoaded",Ie?.thread.id??null,Ae.value.map(_e=>_e.id)))},{immediate:!0}),s({refetch:ie});const qe=P=>{r("selectThread",P)};return(P,q)=>{const Ie=Jt("FormKit");return n(),o("div",yl,[t("div",kl,[t("div",_l,[t("button",{onClick:q[0]||(q[0]=Ye(_e=>r("collapse"),["stop"])),type:"button",class:"-ml-1 flex min-w-0 items-center gap-2 rounded px-1.5 py-1 text-left transition-colors hover:bg-black/10 dark:hover:bg-white/15",title:"Collapse Threads pane","aria-label":"Collapse Threads pane"},[z(c(as),{size:18,class:"shrink-0"}),q[12]||(q[12]=t("h2",{class:"truncate text-base font-bold"},"Threads",-1)),!c(we)&&V.value>0?(n(),o("span",wl," ("+f(V.value)+") ",1)):m("",!0),!c(L)||c(ge)?(n(),N(Nr,{key:1,class:"shrink-0",connected:c(L),error:c(ge)},null,8,["connected","error"])):m("",!0)]),pe.value>0?(n(),o("span",{key:0,class:"ml-1 inline-flex shrink-0 items-center gap-1 whitespace-nowrap rounded-full bg-emerald-500/10 px-1.5 py-0.5 text-[10px] font-medium text-emerald-700 dark:text-emerald-400",title:`${pe.value} thread${pe.value===1?"":"s"} executing right now`},[q[13]||(q[13]=t("span",{class:"thread-working-dot shrink-0","aria-hidden":"true"},null,-1)),t("span",null,f(pe.value),1)],8,$l)):m("",!0),t("div",Cl,[t("button",{type:"button",class:K(["inline-flex h-7 w-7 items-center justify-center rounded-md border border-neutral-300 bg-white text-neutral-700 transition-colors hover:border-neutral-500 hover:bg-neutral-50 hover:text-black dark:border-neutral-700 dark:bg-neutral-950 dark:text-neutral-300 dark:hover:border-neutral-500 dark:hover:bg-neutral-900 dark:hover:text-white",u.value?"agents-border-selected agents-text-selected bg-white dark:bg-neutral-950":""]),title:u.value?"Hide search":"Search threads","aria-label":u.value?"Hide search":"Search threads","aria-pressed":u.value,onClick:Ye(Ve,["stop"])},[z(c(oa),{size:16})],10,Sl),t("button",{onClick:q[1]||(q[1]=_e=>r("createThread")),type:"button",class:"inline-flex h-7 w-7 items-center justify-center rounded-md border border-neutral-300 bg-white text-neutral-700 transition-colors hover:border-neutral-500 hover:bg-neutral-50 hover:text-black dark:border-neutral-700 dark:bg-neutral-950 dark:text-neutral-300 dark:hover:border-neutral-500 dark:hover:bg-neutral-900 dark:hover:text-white",title:"New thread","aria-label":"New thread"},[z(c(cr),{size:16})]),e.showCollapseButton!==!1?(n(),o("button",{key:0,onClick:q[2]||(q[2]=_e=>r("collapse")),type:"button",class:"inline-flex h-7 w-7 items-center justify-center rounded-md text-neutral-700 transition-colors hover:bg-black/10 hover:text-black dark:text-neutral-300 dark:hover:bg-white/15 dark:hover:text-white",title:"Collapse pane","aria-label":"Collapse pane"},[z(c(fr),{size:17})])):m("",!0)])])]),u.value||B.value>0?(n(),o("div",Tl,[t("div",Il,[z(c(oa),{size:14,class:"pointer-events-none absolute left-2 top-1/2 -translate-y-1/2 text-neutral-400"}),ft(t("input",{ref_key:"threadSearchInputRef",ref:I,"onUpdate:modelValue":q[3]||(q[3]=_e=>i.value=_e),type:"search",placeholder:"Search threads...",class:"h-8 w-full rounded-md border border-neutral-300 bg-white pl-7 pr-8 text-sm text-neutral-950 outline-none transition-colors placeholder:text-neutral-400 focus:border-[var(--agents-accent-border)] dark:border-neutral-700 dark:bg-neutral-950 dark:text-neutral-50"},null,512),[[Fn,i.value]]),i.value?(n(),o("button",{key:0,type:"button",class:"absolute right-1.5 top-1/2 inline-flex h-5 w-5 -translate-y-1/2 items-center justify-center rounded text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-800 dark:hover:bg-neutral-800 dark:hover:text-neutral-100",title:"Clear search","aria-label":"Clear search",onClick:q[4]||(q[4]=_e=>{i.value="",p.value=null,Ce()})},[z(c(Ft),{size:13})])):m("",!0)]),t("div",Al,[t("label",El,[z(c(rs),{size:12,class:"pointer-events-none absolute left-2 top-1/2 -translate-y-1/2 text-neutral-400"}),ft(t("select",{"onUpdate:modelValue":q[5]||(q[5]=_e=>U.value=_e),class:"h-8 w-full appearance-none rounded-md border border-neutral-300 bg-white pl-6 pr-2 text-xs text-neutral-700 outline-none transition-colors focus:border-[var(--agents-accent-border)] dark:border-neutral-700 dark:bg-neutral-950 dark:text-neutral-200","aria-label":"Sort threads"},[(n(),o(Re,null,Ke($,_e=>t("option",{key:_e.value,value:_e.value},f(_e.label),9,Ll)),64))],512),[[pr,U.value]])]),t("button",{type:"button",class:K(["h-8 shrink-0 rounded-md border px-2 text-[11px] transition-colors",v.value?"border-emerald-500/60 bg-emerald-500/10 text-emerald-700 dark:text-emerald-400":"border-neutral-300 text-neutral-500 hover:text-neutral-900 dark:border-neutral-700 dark:text-neutral-400 dark:hover:text-neutral-100"]),"aria-pressed":v.value,title:"Show only threads that are executing right now",onClick:q[6]||(q[6]=_e=>v.value=!v.value)}," Working ",10,Rl),t("button",{type:"button",class:K(["h-8 shrink-0 rounded-md border px-2 text-[11px] transition-colors",k.value?"border-neutral-300 text-neutral-500 hover:text-neutral-900 dark:border-neutral-700 dark:text-neutral-400 dark:hover:text-neutral-100":"agents-border-selected agents-text-selected"]),"aria-pressed":!k.value,title:"Hide threads that have finished",onClick:q[7]||(q[7]=_e=>k.value=!k.value)}," Open ",10,Ml)]),ae.value?(n(),o("div",Dl,[z(Ie,{type:"selectSearch",size:"sm","active-highlight":"",value:y.value||"",options:ue.value,placeholder:"All owners","search-placeholder":"Search owners...",onInput:q[8]||(q[8]=_e=>y.value=_e||null)},null,8,["value","options"])])):m("",!0),t("div",Fl,[ve.value?m("",!0):(n(),o("div",Pl,[z(Ie,{type:"selectSearch",size:"sm","active-highlight":"",value:S.value||"",options:H.value,placeholder:"All agents","search-placeholder":"Search agents...",loading:c(R),onInput:q[9]||(q[9]=_e=>S.value=_e||null)},null,8,["value","options","loading"])])),z(Zo,{startDate:j.value,"onUpdate:startDate":q[10]||(q[10]=_e=>j.value=_e),endDate:ee.value,"onUpdate:endDate":q[11]||(q[11]=_e=>ee.value=_e),class:K(ve.value?"w-full":"flex-1 min-w-0")},null,8,["startDate","endDate","class"]),B.value>0?(n(),o("button",{key:1,onClick:re,type:"button",class:"text-[10px] font-mono text-neutral-400 hover:text-neutral-900 dark:hover:text-neutral-100 transition-colors whitespace-nowrap"}," Clear ")):(n(),o("button",{key:2,onClick:ze,type:"button",class:"text-[10px] font-mono text-neutral-400 hover:text-neutral-900 dark:hover:text-neutral-100 transition-colors whitespace-nowrap"}," Close "))])])):m("",!0),t("div",{ref_key:"scrollContainerRef",ref:he,class:"flex-1 overflow-y-auto text-xs min-h-0"},[c(we)&&X.value.length===0?(n(),o("div",Nl,[z(nt)])):c(te)?(n(),o("div",zl," Error: "+f(c(te)),1)):Fe.value.length===0?(n(),o("div",jl,[B.value>0?(n(),o(Re,{key:0},[q[14]||(q[14]=t("p",{class:"text-base mb-2"},"No matching threads",-1)),t("button",{onClick:re,type:"button",class:"text-xs text-accent-600 dark:text-accent-400 hover:underline"}," Clear filters ")],64)):(n(),o("p",Bl,"No threads found"))])):(n(),o("div",Ol,[z(bl,{rows:Fe.value,"selected-thread-id":e.selectedThreadId,"working-cluster-ids":$e.value,"cluster-has-nested-rows":lt.value,"is-thread-flashing":J,"is-directory-flashing":ke,"has-row-top-gap":Qe,"has-row-bottom-border":tt,onSelectThread:qe,onToggleDirectory:fe},null,8,["rows","selected-thread-id","working-cluster-ids","cluster-has-nested-rows"]),Se.value||c(we)&&X.value.length>0?(n(),o("div",Vl,[z(nt)])):ne.value&&!c(le)&&Fe.value.length>0?(n(),o("div",Hl," All "+f(V.value)+" threads loaded ",1)):m("",!0)]))],512)])}}}),Pk=pt(Ul,[["__scopeId","data-v-bd361989"]]);function ga(e){return!!e&&typeof e=="object"}function Wl(e){if(ga(e)&&!Array.isArray(e))return e;if(typeof e=="string")try{const s=JSON.parse(e);return ga(s)&&!Array.isArray(s)?s:void 0}catch{return}}function Kl(e){const s=b(null),a=b(!1),l=b(null);let r=null;try{r=Tr()}catch{}const i=r?.messages??b([]),p=C(()=>r?.groupedMessages?.value?r.groupedMessages.value:r?.workblocks?.value?r.workblocks.value:i.value),u=C(()=>r?.status.value==="connected"),I=b(null);r?.loading??b(!1);const S=C(()=>{const B=r?.runStatus?.value;return B?B.state==="running":i.value.some(re=>re.status==="pending")});function y(B){if(!s.value?.agent)return null;const re=s.value.agent,Ce=B==="assistant"?"A":"B";return Ce==="A"&&re.side_a_label?re.side_a_label:Ce==="B"&&re.side_b_label?re.side_b_label:null}function v(B){const re=B.path??"",Ce=B.name??re.split("/").pop()??"attachment";return{id:B.id||`att-${re||Ce||Math.random().toString(36).slice(2)}`,type:"file",path:re,name:Ce,mimeType:B.mimeType||B.mediaType||"application/octet-stream",width:B.width,height:B.height,description:B.description}}function k(B){if(B){if(Array.isArray(B))return B.length>0?B.map(v):void 0;try{const re=JSON.parse(B);return Array.isArray(re)&&re.length>0?re.filter(ga).map(v):void 0}catch{return}}}function j(B,re){const Ce=[];B.reasoning_content&&Ce.push({id:`${B.id}-reasoning`,type:"reasoning",content:B.reasoning_content,created_at:B.created_at});const ze=new Map;for(const le of B.workItems)le.type==="tool_result"&&le.tool_call_id&&ze.set(le.tool_call_id,le);for(const le of B.workItems){if(le.type==="content"){if(!le.content)continue;Ce.push({id:le.id,type:"content",content:le.content,created_at:le.created_at??B.created_at});continue}if(le.type!=="tool_call")continue;const we=le.tool_call_id||le.id,ce=ze.get(we);let te="pending";if(ce){const ie=(ce.content||"").toLowerCase(),me=ie.includes("failed")||ie.includes("error"),Q=ie.length<500;te=ce.status==="error"||me&&Q?"failed":"success"}Ce.push({id:le.id,type:"tool_call",content:le.name||"",created_at:B.created_at,tool_name:le.name,tool_call_id:we,tool_arguments:le.content||void 0,response:ce?.content||null,response_status:te,response_log_id:null,log_id:null})}const Ve=Ce.some(le=>le.type==="tool_call"&&le.response_status==="pending"),Te=B.status!=="pending"&&!Ve;return{type:"work",id:B.id,role:"assistant",items:Ce,created_at:B.created_at,updated_at:B.updated_at??B.response_completed_at??B.created_at,request_sent_at:B.request_sent_at??B.created_at,response_completed_at:B.response_completed_at??(Te?B.updated_at??B.created_at:null),isComplete:Te,sideLabel:y("assistant"),status:B.status}}function $(B){return B==="assistant"?"assistant":"user"}function W(B){for(let re=B.length-1;re>=0;re--){const Ce=(B[re].content||"").trim();if(Ce.length>0)return Ce}return""}function U(B){const re=new Set,Ce=[];for(const ze of B){const Ve=k(ze.attachments);if(Ve?.length)for(const Te of Ve)re.has(Te.path)||(re.add(Te.path),Ce.push(Te))}return Ce.length>0?Ce:void 0}function Y(B){if(!B)return!1;if(B.tool_status==="error"||B.status==="failed")return!0;const re=(B.content||"").toLowerCase();return re?re.includes("failed to execute tool")||re.includes("has reported a failure")||re.includes("execution stopped before completion"):!1}function ue(B){const re=B.messages||[],Ce=re[re.length-1],ze=Ce?$(Ce.role):"assistant",Ve=Ce?.log_id??null,Te=(B.subagent_status||"").toLowerCase(),le=Y(Ce)||Te.includes("error")||Te.includes("failed"),we=W(re),ce=U(re),te=re.filter(ie=>{const me=k(ie.attachments);return!!ie.content||!!ie.status||!!(me&&me.length>0)}).map(ie=>({id:ie.id,role:ie.role,content:ie.content||"",created_at:ie.created_at,silent:ie.silent,attachments:k(ie.attachments)}));return{type:"subagent",id:B.id,role:ze,created_at:B.created_at,updated_at:B.updated_at,subagentId:B.subagent_id,subagentName:B.subagent_name??null,subagentTitle:B.subagent_title??null,subagentThreadName:B.subagent_thread_name??null,subagentStatus:B.subagent_status??null,subagentHasError:le,subagentRelationship:B.subagent_relationship??null,subagentBlocking:B.subagent_blocking??null,messages:te,messageCount:re.length,latestContent:we,attachments:ce,log_id:Ve,sideLabel:y(ze),silent:re.length>0&&re.every(ie=>!!ie.silent)}}function ae(B){const re=(B.subagents||[]).map(ze=>ue(ze)),Ce=re.reduce((ze,Ve)=>ze?Ve.updated_at>ze.updated_at?Ve:ze:Ve,null);return{type:"subagent_group",id:B.id,role:Ce?.role??"assistant",created_at:B.created_at,updated_at:B.updated_at,subagents:re,count:re.length,log_id:Ce?.log_id??null,sideLabel:Ce?.sideLabel??y("assistant"),silent:re.every(ze=>!!ze.silent)}}function oe(B){return{type:"status",id:B.id,role:"system",content:B.content,created_at:B.created_at,statusKind:B.status_kind??null,subagentId:B.subagent_id??null}}const ve=C(()=>{const B=[],Ce=p.value.filter(Ve=>(Ve.depth??0)===0);let ze=[];for(let Ve=0;Ve<Ce.length;Ve++){const Te=Ce[Ve];if(B[B.length-1]?.role,"type"in Te&&Te.type==="workblock"){const me=j(Te);B.push(me),Te.attachments&&Te.attachments.length>0&&ze.push(...Te.attachments.map(v));continue}if("type"in Te&&Te.type==="subagent_block"){ze=[],B.push(ue(Te));continue}if("type"in Te&&Te.type==="subagent_group_block"){ze=[],B.push(ae(Te));continue}if("type"in Te&&Te.type==="status"){ze=[],B.push(oe(Te));continue}const we=Te,ce=we.role;if(we.role==="tool")continue;const te=k(we.attachments);let ie;if((ze.length>0||te)&&(ie=[...ze,...te||[]],ze=[]),we.content||ce==="system"||we.status==="pending"||ie?.length){const me={type:"text",id:we.id,role:ce,content:we.content||"",attachments:ie?.length?ie:void 0,created_at:we.created_at,log_id:we.log_id||null,sideLabel:y(ce),isOptimistic:we.isOptimistic,status:we.status,silent:we.silent,metadata:Wl(we.metadata)};B.push(me)}}return B});async function ee(){if(!e.value){s.value=null;return}try{const B=await fetch(Ze(`/api/threads/${e.value}`));B.ok&&(s.value=await B.json())}catch{s.value=null}}async function G(B){if(e.value){if(r?.deleteMessage){await r.deleteMessage(B);return}try{if(!(await fetch(Ze(`/api/threads/${e.value}/messages/${B}`),{method:"DELETE"})).ok)throw new Error("Failed to delete message")}catch(re){throw re}}}async function R(B,re){if(e.value)try{if(!(await fetch(Ze(`/api/threads/${e.value}/messages/${B}`),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:re})})).ok)throw new Error("Failed to update message")}catch(Ce){throw Ce}}xe(e,async B=>{B?(a.value=!0,await ee(),a.value=!1):s.value=null},{immediate:!0});const H=r?.sendMessage,D=r?.stopExecution,X=r?.attachments??b([]),Se=r?.addAttachment??(()=>{}),ne=r?.removeAttachment??(()=>{}),Le=r?.clearAttachments??(()=>{});return{messages:ve,threadInfo:s,isFetching:a,error:l,wsConnected:u,wsError:I,isExecuting:S,sendMessage:H,stopThread:D,attachments:X,addAttachment:Se,removeAttachment:ne,clearAttachments:Le,deleteMessageById:G,updateMessageContent:R}}const Zn="__shiki_highlighter__";let In=null;async function Jl(){return typeof window<"u"&&window[Zn]?window[Zn]:In||(In=Promise.all([mt(()=>import("./syntax-D68HCEYm.js").then(e=>e.d),__vite__mapDeps([0,1])),mt(()=>import("./syntax-D68HCEYm.js").then(e=>e.e),__vite__mapDeps([0,1])),mt(()=>import("./syntax-D68HCEYm.js").then(e=>e.f),__vite__mapDeps([0,1])),mt(()=>import("./syntax-D68HCEYm.js").then(e=>e.g),__vite__mapDeps([0,1])),mt(()=>import("./syntax-D68HCEYm.js").then(e=>e.i),__vite__mapDeps([0,1])),mt(()=>import("./syntax-D68HCEYm.js").then(e=>e.k),__vite__mapDeps([0,1])),mt(()=>import("./syntax-D68HCEYm.js").then(e=>e.l),__vite__mapDeps([0,1])),mt(()=>import("./syntax-D68HCEYm.js").then(e=>e.m),__vite__mapDeps([0,1])),mt(()=>import("./syntax-D68HCEYm.js").then(e=>e.n),__vite__mapDeps([0,1])),mt(()=>import("./syntax-D68HCEYm.js").then(e=>e.s),__vite__mapDeps([0,1])),mt(()=>import("./syntax-D68HCEYm.js").then(e=>e.o),__vite__mapDeps([0,1])),mt(()=>import("./syntax-D68HCEYm.js").then(e=>e.p),__vite__mapDeps([0,1])),mt(()=>import("./vue-DrmMqJdu.js").then(e=>e.bk),__vite__mapDeps([2,3,1,0])),mt(()=>import("./syntax-D68HCEYm.js").then(e=>e.y),__vite__mapDeps([0,1])),mt(()=>import("./syntax-D68HCEYm.js").then(e=>e.q),__vite__mapDeps([0,1])),mt(()=>import("./syntax-D68HCEYm.js").then(e=>e.r),__vite__mapDeps([0,1]))]).then(async([{createHighlighterCore:e},{createJavaScriptRegexEngine:s},a,l,r,i,p,u,I,S,y,v,k,j,$,W])=>{const U=await e({themes:[$.default,W.default],langs:[a.default,l.default,r.default,i.default,p.default,u.default,I.default,S.default,y.default,v.default,k.default,j.default],engine:s()});return typeof window<"u"&&(window[Zn]=U),U}),In)}const Gl={class:"code-block"},Yl={key:0,class:"text-xs text-neutral-500 p-2"},Ql=["innerHTML"],jt=at({__name:"CodeBlock",props:{code:{},language:{}},setup(e){const s=e,a=b(""),l=b(!0),r={bash:"bash",cjs:"javascript",htm:"html",js:"javascript",jsonl:"json",md:"markdown",mjs:"javascript",sh:"bash",shell:"bash",text:"text",ts:"typescript",txt:"text",yml:"yaml"},i=new Set(["bash","css","html","javascript","jsx","json","markdown","shellscript","tsx","typescript","vue","yaml"]),p=y=>{const v=y?.trim().toLowerCase()||"text";return r[v]??v},u=y=>y.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),I=y=>`<pre class="shiki shiki-text"><code>${u(y)}</code></pre>`,S=async()=>{const y=s.code??"";if(!y){a.value='<pre class="shiki"><code></code></pre>',l.value=!1;return}try{const v=await Jl(),k=p(s.language);i.has(k)?a.value=v.codeToHtml(y,{lang:k,themes:{light:"github-light",dark:"github-dark"}}):a.value=I(y)}catch{a.value=I(y)}finally{l.value=!1}};return Et(()=>{S()}),xe(()=>s.code,()=>{S()}),xe(()=>s.language,()=>{S()}),(y,v)=>(n(),o("div",Gl,[l.value?(n(),o("div",Yl,"Loading...")):(n(),o("div",{key:1,innerHTML:a.value,class:"code-content"},null,8,Ql))]))}}),Zl={key:0,class:"absolute inset-0 flex items-center justify-center bg-neutral-100 dark:bg-neutral-800"},Xl={key:1,class:"absolute inset-0 flex items-center justify-center bg-neutral-100 dark:bg-neutral-800 text-neutral-400"},ei=["src","alt"],ti={key:2,class:"pointer-events-none absolute inset-0 flex items-center justify-center bg-black/0 group-hover:bg-black/35 transition-colors"},ni={class:"text-xs text-neutral-600 dark:text-neutral-300 truncate max-w-[100px]"},Xn=at({__name:"FileAttachment",props:{attachment:{},threadId:{},showRemove:{type:Boolean}},emits:["remove"],setup(e,{emit:s}){const a=os(),l=ls(),r=e,i=s,p=b(!0),u=b(!1),I=C(()=>r.attachment.mimeType.startsWith("image/")),S=C(()=>!!r.attachment.thumbnailBase64),y=C(()=>{if(!r.threadId||!r.attachment.path)return"";const U=r.attachment.path.startsWith("/")?r.attachment.path.slice(1):r.attachment.path;return Ze(`/api/threads/${r.threadId}/fs/${U}`)}),v=C(()=>I.value?r.attachment.thumbnailBase64?`data:image/webp;base64,${r.attachment.thumbnailBase64}`:y.value:"");function k(){p.value=!1,u.value=!1}function j(){p.value=!1,u.value=!0}function $(){i("remove",r.attachment.id)}function W(){if(!r.attachment.path){y.value&&window.open(y.value,"_blank");return}a.replace({query:{...l.query,inspector:"files",filePath:r.attachment.path},hash:l.hash})}return(U,Y)=>(n(),o("div",{class:K(["relative group inline-flex items-center overflow-hidden rounded-2xl bg-neutral-100 dark:bg-neutral-800/60 ring-1 ring-black/5 dark:ring-white/10 transition-all hover:ring-black/10 dark:hover:ring-white/20 hover:shadow-sm",{"w-[256px] h-[256px]":I.value,"px-2.5 py-1.5":!I.value,"cursor-pointer":I.value&&y.value}]),onClick:Y[0]||(Y[0]=ue=>I.value&&y.value?W():void 0)},[I.value?(n(),o(Re,{key:0},[p.value&&!u.value&&!S.value?(n(),o("div",Zl,[...Y[1]||(Y[1]=[t("div",{class:"w-4 h-4 border-2 border-neutral-300 border-t-neutral-600 rounded-full animate-spin"},null,-1)])])):m("",!0),u.value&&!S.value?(n(),o("div",Xl,[z(c(vr),{size:24})])):m("",!0),ft(t("img",{src:v.value||y.value,alt:e.attachment.name,class:"w-full h-full object-cover",onLoad:k,onError:j},null,40,ei),[[wt,!p.value&&!u.value||S.value]]),y.value?(n(),o("div",ti,[...Y[2]||(Y[2]=[t("span",{class:"rounded-full bg-white/90 px-3 py-1 text-xs font-medium text-neutral-900 opacity-0 group-hover:opacity-100 transition-opacity shadow-sm"}," View ",-1)])])):m("",!0)],64)):(n(),o(Re,{key:1},[z(c(Pn),{size:14,class:"text-neutral-500 mr-1 flex-shrink-0"}),t("span",ni,f(e.attachment.name),1)],64)),e.showRemove?(n(),o("button",{key:2,onClick:Ye($,["stop"]),class:"absolute -top-1 -right-1 w-4 h-4 rounded-full bg-red-500 text-white flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity"},[z(c(Ft),{size:10})])):m("",!0)],2))}});function ai(e){const s=l=>!!l.path&&(l.mimeType||"").startsWith("image/"),a=[...e.attachments||[]].reverse().find(s);if(a)return a;for(let l=e.messages.length-1;l>=0;l--){const r=[...e.messages[l].attachments||[]].reverse().find(s);if(r)return r}return null}function ri(e){if(e.silent!==!0||!e.metadata)return null;const s=e.metadata.subagent_id??e.metadata.subagentId;if(typeof s!="string")return null;const a=s.trim();return a.length>0?a:null}const si=/https:\/\/[^\s"'<>()\][]+/g;function Br(e){if(!e)return null;const s=e.match(si);if(!s)return null;for(const a of s){const l=a.replace(/[.,;:!?]+$/,"");let r;try{r=new URL(l)}catch{continue}if(r.protocol==="https:"&&r.pathname.endsWith("/settings/billing"))return r.toString()}return null}let ea=null,Va=null;function oi(){return typeof window>"u"?null:((!ea||Va!==window)&&(ea=no(window),Va=window),ea)}function Ha(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function li(e){const s=e.trim().replace(/[\u0000-\u0020\u007f]+/g,"");return/^data:image\/(?:gif|jpe?g|png|webp);base64,/i.test(s)||/^(?:https?:|mailto:|tel:)/i.test(s)||/^[#/?]/.test(s)?!0:s.length>0&&!s.includes(":")&&!s.includes("&")}function ii(e){const s=Ha((e??"").trim()),a=to.parse(s,{async:!1,gfm:!0,breaks:!0,walkTokens(r){(r.type==="link"||r.type==="image")&&"href"in r&&typeof r.href=="string"&&!li(r.href)&&(r.href="")}}),l=oi();return l?.isSupported?l.sanitize(a,{USE_PROFILES:{html:!0},FORBID_TAGS:["style","form","input","button"],FORBID_ATTR:["style"]}):Ha(a)}const di=["onMouseenter","onMouseleave","onClick"],ui=["onClick"],ci={key:0,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"3",stroke:"currentColor",class:"w-3 h-3 text-white"},fi={key:1,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"2.5",stroke:"currentColor",class:"w-3 h-3 text-white"},pi={key:0,class:"w-full text-center text-xs text-neutral-400 dark:text-neutral-500 py-1"},vi={key:0,class:"mb-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-[10px] font-semibold uppercase leading-none tracking-wider text-neutral-400 dark:text-neutral-500"},gi={key:0,class:"break-all font-mono font-normal normal-case tracking-normal"},mi=["contenteditable","onInput"],hi=["innerHTML"],xi=["href"],bi={key:4,class:"inline-flex items-center gap-1 rounded-full bg-neutral-100 dark:bg-neutral-800/60 px-3 py-2"},yi={key:0,class:"inline-flex items-center gap-1.5"},ki={key:1,class:"inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-[4px] border agents-border-selected agents-surface-selected text-[8px] font-semibold leading-none agents-text-selected","aria-hidden":"true"},_i=["title","onClick"],wi={key:0,class:"flex flex-wrap gap-2 px-4"},$i=["onClick","onMouseenter"],Ci={key:0,class:"flex items-center gap-2 px-4 py-2 min-w-0"},Si={key:0,class:"truncate text-neutral-700 dark:text-neutral-300 min-w-0"},Ti={key:1,class:"truncate text-neutral-600 dark:text-neutral-400 min-w-0"},Ii={class:"text-neutral-500 dark:text-neutral-400 flex-shrink-0"},Ai={class:"work-op-strip","aria-label":"Operation statuses"},Ei=["title"],Li={key:1,class:"px-4 py-2 space-y-2.5"},Ri={class:"flex items-center gap-2"},Mi={class:"min-w-0 truncate text-neutral-700 dark:text-neutral-300"},Di={class:"shrink-0 text-neutral-500 dark:text-neutral-400"},Fi={class:"work-op-strip","aria-label":"Operation statuses"},Pi=["title"],Ni={key:0,class:"space-y-1"},zi=["onClick","onMouseenter"],ji=["title"],Bi={class:"font-mono font-medium text-neutral-800 dark:text-neutral-100 flex-shrink-0"},Oi={key:2,class:"text-neutral-500 dark:text-neutral-400 truncate flex-1 min-w-0"},Vi={key:0,class:"pl-5 mt-2 space-y-3"},Hi={key:0},qi={class:"divide-y divide-neutral-100/80 rounded-md bg-white px-2.5 py-1.5 ring-1 ring-neutral-200/70 dark:divide-neutral-800/70 dark:bg-neutral-950/60 dark:ring-neutral-800/70"},Ui={class:"pt-1 font-mono text-[12px] text-neutral-500 dark:text-neutral-500"},Wi={class:"min-w-0"},Ki={key:1,class:"break-words text-neutral-800 dark:text-neutral-200"},Ji={key:1},Gi={class:"text-[10px] font-semibold uppercase tracking-wider text-neutral-400 dark:text-neutral-500 mb-1"},Yi=["onClick","onMouseenter"],Qi={key:0,class:"m-0 whitespace-pre-wrap break-words font-mono text-[11px] leading-relaxed"},Zi={key:1},Xi=["onClick"],ed={key:0,class:"pl-5 mt-2 whitespace-pre-wrap break-words rounded-md bg-white dark:bg-neutral-950/60 ring-1 ring-neutral-200/70 dark:ring-neutral-800/70 px-2.5 py-2 text-neutral-700 dark:text-neutral-300"},td={key:2,class:"pl-5 pb-1 break-words text-neutral-600 dark:text-neutral-400"},nd={class:"flex items-center justify-between gap-3 border-b border-neutral-100 px-3 py-2 dark:border-neutral-900"},ad={class:"min-w-0"},rd={class:"truncate text-[12px] font-medium text-neutral-800 dark:text-neutral-100"},sd={class:"rounded-full bg-neutral-100 px-2 py-0.5 text-[10px] text-neutral-500 ring-1 ring-inset ring-neutral-200 dark:bg-neutral-900 dark:text-neutral-400 dark:ring-neutral-800"},od={class:"divide-y divide-neutral-100 dark:divide-neutral-900"},ld=["onClick"],id={class:"flex items-center gap-3"},dd=["src"],ud={class:"min-w-0 flex-1"},cd={class:"flex items-center gap-2"},fd={class:"truncate text-[13px] font-medium text-neutral-900 dark:text-neutral-50"},pd={class:"mt-0.5 truncate text-[11px] text-neutral-500 dark:text-neutral-400"},vd=["src"],gd={class:"shrink-0 rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] leading-none text-neutral-500 dark:bg-neutral-900 dark:text-neutral-400"},md={class:"ml-11 mt-1 truncate text-[11px] text-neutral-500 dark:text-neutral-400"},hd={key:0,class:"ml-12 mt-1.5 space-y-1.5 border-l border-neutral-200 pl-2.5 dark:border-neutral-800"},xd={class:"flex items-center gap-2 text-[10px] text-neutral-500 dark:text-neutral-400"},bd={class:"font-medium uppercase text-neutral-600 dark:text-neutral-300"},yd={key:0,class:"italic"},kd=["innerHTML"],_d={key:1,class:"mt-2 flex flex-wrap gap-2"},wd=["onClick"],$d={class:"flex items-center gap-3"},Cd=["src"],Sd={class:"min-w-0 flex-1"},Td={class:"flex items-center gap-2"},Id={class:"truncate text-[13px] font-medium text-neutral-900 dark:text-neutral-50"},Ad={class:"mt-0.5 truncate text-[11px] text-neutral-500 dark:text-neutral-400"},Ed=["src"],Ld={class:"shrink-0 rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] leading-none text-neutral-500 dark:bg-neutral-900 dark:text-neutral-400"},Rd={class:"ml-12 mt-1 truncate text-[11px] text-neutral-500 dark:text-neutral-400"},Md={key:0,class:"ml-12 mt-2 space-y-1.5 border-l border-neutral-200 pl-2.5 dark:border-neutral-800"},Dd={class:"flex items-center gap-2 text-[10px] text-neutral-500 dark:text-neutral-400"},Fd={class:"font-medium uppercase text-neutral-600 dark:text-neutral-300"},Pd={key:0,class:"italic"},Nd=["innerHTML"],zd={key:1,class:"mt-2 flex flex-wrap gap-2"},jd=at({__name:"AgentMessages",props:{messages:{},threadId:{},selectedMessageId:{},selectedLogId:{},selectedEffectId:{},hoveredLogId:{},isEditMode:{type:Boolean},selectedForDelete:{},editedMessages:{},assistantAvatarSrc:{},userAvatarSrc:{}},emits:["messageClick","messageHover","selectionChange","messageEdit"],setup(e,{expose:s,emit:a}){const l=e,r=a;function i(g){const x=l.selectedForDelete?.has(g)??!1;r("selectionChange",g,!x)}function p(g,x){const De=g.target.innerText;r("messageEdit",x,De)}function u(g){return!!g&&typeof g=="object"&&!Array.isArray(g)}function I(g){return g.type==="text"?ri(g):null}function S(g){return ii(Je(g))}function y(g){const x=g.content??"";return g.status!=="failed"&&!x.includes("[ERROR]")?null:Br(x)}function v(g){return l.editedMessages?.has(g)??!1}const k=b(new Map);function j(g,x){x?k.value.set(g,x):k.value.delete(g)}function $(g,x){j(g,x instanceof HTMLElement?x:null)}function W(g){const x=l.messages.findIndex(_=>_.log_id===g);if(x<=0)return-1;for(let _=x-1;_>=0;_--){const De=l.messages[_];if(De.role==="user")return _;if(De.role==="assistant"&&De.log_id)break}return-1}function U(g){for(let x=0;x<l.messages.length;x++){const _=l.messages[x];if(_.log_id===g||_.type==="work"&&_.items&&_.items.some(Xe=>Xe.log_id===g||Xe.response_log_id===g))return x}return-1}function Y(g,x){const De=U(g);if(De===-1)return!1;const Z=k.value.get(De);if(!Z)return!1;const Xe=l.messages[De];let yt=null;if(Xe.role==="assistant"&&Xe.log_id){const Ct=W(Xe.log_id);yt=Ct!==-1?k.value.get(Ct):null}const kt=x.getBoundingClientRect(),on=Z.getBoundingClientRect();if(on.top<kt.top){const Wn=(yt||Z).getBoundingClientRect().top-kt.top-10;x.scrollBy({top:Wn,behavior:"smooth"})}else if(on.bottom>kt.bottom){const Ct=on.bottom-kt.bottom+10;x.scrollBy({top:Ct,behavior:"smooth"})}else if(yt){const Ct=yt.getBoundingClientRect();if(Ct.top<kt.top){const Cn=Ct.top-kt.top-10;x.scrollBy({top:Cn,behavior:"smooth"})}}return!0}function ue(g){for(const x of l.messages){if(x.type!=="work")continue;if(x.items.some(Z=>Z.log_id===g||Z.response_log_id===g))return!0}return!1}s({scrollToLogId:Y,hasWorkblockForLogId:ue});function ae(g){const x=l.messages[g];if(x.log_id)return x.log_id;if(x.role==="user")for(let _=g+1;_<l.messages.length;_++){const De=l.messages[_];if(De.log_id)return De.log_id;if(De.role==="user")break}return null}function oe(g){if(g.type!=="text")return null;const x=g.metadata;if(!u(x))return null;const _=x.scheduledEffect;return u(_)?_:null}function ve(g){const x=oe(g);return typeof x?.id=="string"?x.id:null}function ee(g){const x=oe(g);return typeof x?.name=="string"?x.name:null}function G(g){return ve(g)!==null}function R(g){const x=ve(g),_=ee(g);return _&&x?`${_} (${x})`:_||"Scheduled effect"}function H(g){if(g.type!=="text")return null;const x=oe(g),_=typeof x?.id=="string"?x.id:null;return _?{id:_,name:typeof x?.name=="string"?x.name:null}:null}function D(g,x){return x?ae(g)===x:!1}function X(g,x){if(l.isEditMode||g.silent||g.role==="user"&&!G(g))return"";const _=ve(g),De=!!ae(x)||G(g);return D(x,l.selectedLogId??null)||_&&_===l.selectedEffectId?"message-log-state message-log-state--selected":ae(x)&&D(x,l.hoveredLogId??null)?"message-log-state message-log-state--hovered":De?"message-log-state":""}function Se(g){const x=ae(g);x&&r("messageHover",x)}function ne(g){ae(g)&&r("messageHover",null)}function Le(g){const x=l.messages[g],_=ae(g),De=H(x);(_||De)&&r("messageClick",x.id,_,De)}function B(g){const x=l.messages[g],_=H(x);_&&r("messageClick",x.id,ae(g),_)}const re=b(new Set),Ce=b(new Set),ze=b(new Set),Ve=b(new Set);function Te(g){re.value.has(g)?re.value.delete(g):re.value.add(g)}function le(g){Ce.value.has(g)?Ce.value.delete(g):Ce.value.add(g)}function we(g){ze.value.has(g)?ze.value.delete(g):ze.value.add(g)}function ce(g){Ve.value.has(g)?Ve.value.delete(g):Ve.value.add(g)}function te(g){if(!g)return{};try{const x=JSON.parse(g);return x&&typeof x=="object"&&!Array.isArray(x)?x:{raw:x}}catch{return{raw:g}}}function ie(g){if(!g)return null;const x=te(g),_=Object.keys(x);if(_.length===0)return null;const De=x[_[0]];return typeof De=="string"?se(E(De)):JSON.stringify(De)}const me={bash:"bash",css:"css",html:"html",js:"javascript",jsx:"jsx",json:"json",md:"markdown",mjs:"javascript",sh:"bash",ts:"typescript",tsx:"tsx",vue:"vue",yaml:"yaml",yml:"yaml"};function Q(g){if(typeof g!="string")return null;const x=g.split("?")[0]?.split("#")[0]?.split(".").pop()?.toLowerCase();return x?me[x]??null:null}function Me(g){if(typeof g!="string")return null;const x=g.toLowerCase();return x.includes("json")?"json":x.includes("typescript")?"typescript":x.includes("javascript")?"javascript":x.includes("html")?"html":x.includes("css")?"css":x.includes("markdown")?"markdown":x.includes("yaml")||x.includes("yml")?"yaml":x.includes("shell")||x.includes("bash")?"bash":null}function Ne(g){try{return JSON.stringify(JSON.parse(g),null,2)}catch{return null}}function Ue(g){try{return JSON.parse(g)}catch{return null}}function We(g){return g&&typeof g=="object"&&!Array.isArray(g)?g:null}function E(g){return g.replace(/\\r\\n/g,`
3
- `).replace(/\\n/g,`
4
- `).replace(/\\t/g," ")}function fe(g){const x=E(g);return x.includes(`
5
- `)||/(^|\s)(import|export|const|let|function|async|return|class|interface|type)\s/.test(x)||/<\/?[a-z][\s\S]*>/i.test(x)||/\b(Response|Request|fetch|console)\b/.test(x)}function be(g){const x=E(g).trim();return x?/^\s*</.test(x)||/<\/[a-z][\s\S]*>/i.test(x)?"html":/^\s*[{[]/.test(x)&&Ne(x)?"json":/\b(interface|type|Request|Response)\b/.test(x)||/\bimport\s+.+\s+from\s+["']/.test(x)||/\bexport\s+(default\s+)?(async\s+)?function\b/.test(x)?"typescript":/\b(import|export|const|let|function|async|return|class)\b/.test(x)?"javascript":/^#!.*\b(bash|sh)\b/.test(x)?"bash":null:null}function Pe(g,x,_){const De=g.toLowerCase(),Z=Q(_.path)||Q(_.filePath)||Q(_.filename)||Q(_.name),Xe=Me(_.mimeType)||Me(_.mime_type)||Me(_.contentType)||Me(_.content_type);return typeof x=="string"&&(De.includes("content")||De.includes("code")||De.includes("source"))?Xe||Z||be(x)||"text":typeof x!="string"||Array.isArray(x)||x&&typeof x=="object"?"json":be(x)||"text"}function J(g,x,_){if(Array.isArray(x)||x&&typeof x=="object")return!0;if(typeof x!="string")return!1;const De=g.toLowerCase();return _!=="text"||x.length>120||fe(x)||De.includes("content")||De.includes("body")||De.includes("schema")||De.includes("payload")}function ke(g,x){return typeof g!="string"?JSON.stringify(g,null,2):x==="json"?Ne(g)||g:E(g)}function ye(g){const x=te(g);return Object.entries(x).map(([_,De])=>{const Z=Pe(_,De,x);return{key:_,language:Z,code:ke(De,Z),isBlock:J(_,De,Z)}})}function Ae(g){const x=We(g);if(!x||typeof x.content!="string")return null;const _=Me(x.mimeType)||Me(x.mime_type)||Me(x.contentType)||Me(x.content_type)||Q(x.path)||Q(x.filePath)||Q(x.name)||be(x.content)||"text";return{code:E(x.content),language:_}}function V(g){const x=Je(g),_=Ue(x),De=Ae(_);if(De)return De;if(_!==null)return{code:JSON.stringify(_,null,2),language:"json"};const Z=E(x);return{code:Z,language:Z.includes("```")?"markdown":"text"}}function $e(g){return E(Je(g))}function pe(g){return O(g.items)?se(O(g.items)||""):he(g)}function Fe(g){return g.type==="tool_call"?g.response_status==="failed"?"work-op-square--failed":g.response_status==="success"?"work-op-square--success":"work-op-square--pending":g.type==="content"?"work-op-square--success":"work-op-square--neutral"}function tt(g){if(g.type==="tool_call"){const x=g.tool_name||"Tool call";return g.response_status==="failed"?`${x} failed`:g.response_status==="success"?`${x} succeeded`:`${x} pending`}return g.type}function Qe(g){return new Date(g/1e3).toLocaleTimeString()}function lt(g){const x=Math.round(g/1e6);if(x<1)return"< 1s";if(x<60)return`${x}s`;const _=Math.floor(x/60),De=x%60;return`${_}m ${De}s`}function he(g){if(g.status==="pending")return"...";if(!g.isComplete)return"Working...";let x;return g.request_sent_at&&g.response_completed_at?x=g.response_completed_at-g.request_sent_at:x=g.updated_at-g.created_at,`Worked for ${lt(x)}`}function O(g){const x=g.filter(_=>_.type==="content");if(x.length===0){const _=g.filter(De=>De.type==="reasoning");return _.length>0?_[_.length-1].content:null}return x[x.length-1].content}function se(g){const _=g.trim().split(`
6
- `)[0];return _.length>60?_.substring(0,60):_}function He(g){return l.selectedMessageId===g.id?!0:l.selectedLogId?g.items.some(x=>x.log_id===l.selectedLogId||x.response_log_id===l.selectedLogId):!1}function de(g){return!!(l.selectedLogId&&(g.log_id===l.selectedLogId||g.response_log_id===l.selectedLogId))}function L(g){return l.hoveredLogId?g.items.some(x=>x.log_id===l.hoveredLogId||x.response_log_id===l.hoveredLogId):!1}function ge(g){return!!(l.hoveredLogId&&(g.log_id===l.hoveredLogId||g.response_log_id===l.hoveredLogId))}function je(g){const x=[];for(const _ of g.items)_.log_id&&x.push(_.log_id),_.response_log_id&&x.push(_.response_log_id);return x}function Je(g){return g?g.trim():""}function qe(g,x){if(g.type!=="text")return;const _=g.attachments;if(!_?.length)return;if(g.silent)return _;const De=l.messages[x-1];if(!De||De.type!=="text"||!De.silent||!(De.content||"").trim().startsWith("Initial asset attachment path:"))return _;const Xe=new Set((De.attachments||[]).map(kt=>kt.path));if(Xe.size===0)return _;const yt=_.filter(kt=>!Xe.has(kt.path));return yt.length>0?yt:void 0}function P(g){return g.subagentThreadName||g.subagentTitle||g.subagentRelationship||g.subagentName||"Subagent"}function q(g){return g.subagentId.slice(0,8)}function Ie(g){const x=g.subagentRelationship;return!x||x===P(g)?null:x}function _e(g){return jn(g.subagentName||g.subagentTitle||g.subagentId)}function Ge(g){return(g.subagentStatus||"running").toLowerCase()}function A(g){return ut(g)?"error":F(g)?"queued":Ee(g)?"awaiting human":Yt(g)?"running":"complete"}function d(g){return ut(g)?"bg-red-50 text-red-700 ring-red-200 dark:bg-red-950/40 dark:text-red-300 dark:ring-red-900":Ee(g)?"bg-amber-50 text-amber-700 ring-amber-200 dark:bg-amber-950/40 dark:text-amber-300 dark:ring-amber-900":Yt(g)?"bg-blue-50 text-blue-700 ring-blue-200 dark:bg-blue-950/40 dark:text-blue-300 dark:ring-blue-900":F(g)?"bg-neutral-100 text-neutral-600 ring-neutral-200 dark:bg-neutral-800 dark:text-neutral-300 dark:ring-neutral-700":"bg-emerald-50 text-emerald-700 ring-emerald-200 dark:bg-emerald-950/40 dark:text-emerald-300 dark:ring-emerald-900"}function h(g){return Je(g.latestContent||"").split(`
7
- `).find(Boolean)||"No activity yet"}function F(g){const x=Ge(g);return x==="pending"||x==="queued"}function Ee(g){return Ge(g)==="awaiting_human"}function ot(g){return g==="tool"?"Initialization":g==="user"?"Subagent":g==="assistant"?"Assistant":"System"}function vt(g){return ut(g)?"Reported failure to parent":F(g)?"Queued":Ee(g)?"Waiting for human input":Yt(g)?"Working":"Returned result to parent"}function gt(g){if(!l.threadId)return null;const x=ai(g);if(!x)return null;const _=x.path.startsWith("/")?x.path.slice(1):x.path;return Ze(`/api/threads/${l.threadId}/fs/${_}`)}function ut(g){return g.subagentHasError===!0}function Yt(g){if(ut(g)||F(g)||Ee(g))return!1;const x=Ge(g);return x!=="idle"&&x!=="terminated"}function _n(g){if(g.type==="status")return!0;if(g.type!=="text"||g.role!=="system")return!1;if(rn(g)!==null)return!0;const x=g.content||"";return x.includes("Execution stopped")?!0:/subagents?\s+started:/i.test(x)}function rn(g){if(g.type!=="text"||g.role!=="system")return null;const x=g.metadata;return!u(x)||x.user_command!==!0?null:((g.content||"").split(`
8
- `,1)[0]??"").replace(/^\$\s*/,"").trim()||"(command)"}function wn(g){const x=rn(g);return x!==null?`User ran command: ${x}`:g.content||""}function $n(g){const x=g?.trim();return x?x.charAt(0).toUpperCase():"A"}function sn(g){return g.role==="assistant"?l.assistantAvatarSrc??null:g.role==="user"?l.userAvatarSrc??null:null}return(g,x)=>(n(),o("div",null,[(n(!0),o(Re,null,Ke(e.messages,(_,De)=>(n(),o("div",{key:_.id,ref_for:!0,ref:Z=>$(De,Z),class:"flex items-center gap-2 pb-3",onMouseenter:Z=>Se(De),onMouseleave:Z=>ne(De),onClick:Z=>e.isEditMode?i(_.id):Le(De)},[e.isEditMode&&_.role!=="system"?(n(),o("button",{key:0,onClick:Ye(Z=>i(_.id),["stop"]),class:K(["flex-shrink-0 w-6 h-6 rounded-full border-2 flex items-center justify-center transition-all",{"border-red-500 bg-red-500":e.selectedForDelete?.has(_.id),"border-green-500 bg-green-500":!e.selectedForDelete?.has(_.id)&&v(_.id),"border-neutral-400 dark:border-neutral-500 bg-transparent hover:border-neutral-500 dark:hover:border-neutral-400":!e.selectedForDelete?.has(_.id)&&!v(_.id)}])},[e.selectedForDelete?.has(_.id)?(n(),o("svg",ci,[...x[5]||(x[5]=[t("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M4.5 12.75l6 6 9-13.5"},null,-1)])])):v(_.id)?(n(),o("svg",fi,[...x[6]||(x[6]=[t("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L6.832 19.82a4.5 4.5 0 0 1-1.897 1.13l-2.685.8.8-2.685a4.5 4.5 0 0 1 1.13-1.897L16.863 4.487Zm0 0L19.5 7.125"},null,-1)])])):m("",!0)],10,ui)):m("",!0),t("div",{class:K(["flex-1 flex items-center gap-2 min-w-0",{"justify-start":_.type==="subagent"||_.type==="subagent_group"||_.role==="assistant","justify-end":_.type!=="subagent"&&_.type!=="subagent_group"&&_.role==="user","justify-center":_.type==="status"||_.role==="system","cursor-pointer":(ae(De)||H(_))&&!e.isEditMode}])},[_n(_)?(n(),o("div",pi,f(wn(_)),1)):_.type==="text"?(n(),o("div",{key:1,class:K(["flex flex-col gap-2",{"w-full max-w-none items-start":_.role==="assistant","max-w-[72%] items-end":_.role==="user","max-w-[80%] items-center":_.role!=="assistant"&&_.role!=="user"}])},[t("div",{class:K(["message-text-frame",[X(_,De),{"w-full":_.role==="assistant"}]])},[t("div",{class:K(["message-text-surface transition-all",[_.silent?"border-l-2 border-neutral-300 dark:border-neutral-700 pl-3.5 pr-4 py-2.5 text-[13px] leading-5 text-neutral-600 dark:text-neutral-400 min-h-[2.5rem]":_.role==="assistant"?"bg-transparent text-neutral-900 dark:text-neutral-100 rounded-2xl px-4 py-2.5 text-[15px] leading-7 min-h-[2.5rem]":_.role==="user"?"agents-surface-message agents-text-selected rounded-2xl px-4 py-2.5 text-[15px] leading-7 min-h-[2.5rem]":"bg-neutral-100 text-neutral-600 dark:bg-neutral-900 dark:text-neutral-400 text-[13px] leading-5 rounded-2xl px-4 py-2.5 min-h-[2.5rem]",{"opacity-60":_.isOptimistic},{"ring-2 ring-green-500 dark:ring-green-400":e.isEditMode&&v(_.id),"border border-dashed border-neutral-400 dark:border-neutral-500":e.isEditMode&&_.role!=="system"&&!v(_.id)}]])},[_.silent?(n(),o("div",vi,[x[7]||(x[7]=t("span",null,"silent",-1)),I(_)?(n(),o("span",gi," from subagent "+f(I(_)),1)):m("",!0)])):m("",!0),e.isEditMode&&(_.content||e.isEditMode)?(n(),o("div",{key:1,class:K(["whitespace-pre-wrap break-words outline-none",_.silent?"text-[11px] leading-4":"text-[15px] leading-7"]),contenteditable:e.isEditMode&&_.role!=="system",onInput:Z=>p(Z,_.id),onClick:x[0]||(x[0]=Z=>e.isEditMode&&Z.stopPropagation())},f(Je(_.content)),43,mi)):_.content?(n(),o("div",{key:2,class:K(["markdown-content break-words outline-none",_.silent?"text-[13px] leading-5":"text-[15px] leading-7"]),innerHTML:S(_.content)},null,10,hi)):m("",!0),!e.isEditMode&&y(_)?(n(),o("a",{key:3,href:y(_),target:"_blank",rel:"noopener noreferrer",class:"mt-2 inline-flex items-center gap-1.5 rounded-full bg-red-600 px-3.5 py-1.5 text-xs font-semibold text-white transition-colors hover:bg-red-700 dark:bg-red-500 dark:text-red-950 dark:hover:bg-red-400",onClick:x[1]||(x[1]=Ye(()=>{},["stop"]))},[...x[8]||(x[8]=[st(" Add credits ",-1),t("svg",{class:"h-3 w-3",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},[t("path",{"fill-rule":"evenodd",d:"M4.25 5.5a.75.75 0 0 0-.75.75v8.5c0 .414.336.75.75.75h8.5a.75.75 0 0 0 .75-.75v-4a.75.75 0 0 1 1.5 0v4A2.25 2.25 0 0 1 12.75 17h-8.5A2.25 2.25 0 0 1 2 14.75v-8.5A2.25 2.25 0 0 1 4.25 4h5a.75.75 0 0 1 0 1.5h-5Z","clip-rule":"evenodd"}),t("path",{"fill-rule":"evenodd",d:"M6.194 12.753a.75.75 0 0 0 1.06.053L16.5 4.44v2.81a.75.75 0 0 0 1.5 0v-4.5a.75.75 0 0 0-.75-.75h-4.5a.75.75 0 0 0 0 1.5h2.553l-9.056 8.194a.75.75 0 0 0-.053 1.06Z","clip-rule":"evenodd"})],-1)])],8,xi)):_.status==="pending"?(n(),o("div",bi,[...x[9]||(x[9]=[t("span",{class:"typing-dot",style:{"animation-delay":"0ms"}},null,-1),t("span",{class:"typing-dot",style:{"animation-delay":"150ms"}},null,-1),t("span",{class:"typing-dot",style:{"animation-delay":"300ms"}},null,-1)])])):m("",!0)],2),_.status!=="pending"?(n(),o("div",{key:0,class:K(["text-[10px] mt-1 flex items-center gap-2 px-4",{"justify-start":_.role==="assistant","justify-end":_.role==="user","justify-center":_.role==="system"}])},[_.sideLabel?(n(),o("span",yi,[sn(_)?(n(),N(bn,{key:0,icon:sn(_),seed:_.sideLabel,class:"h-4 w-4 shrink-0 rounded-[4px] object-cover"},null,8,["icon","seed"])):(n(),o("span",ki,f($n(_.sideLabel)),1)),t("span",{class:K(_.silent?"text-neutral-400 dark:text-neutral-500":"text-neutral-500 dark:text-neutral-400")},f(_.sideLabel),3)])):m("",!0),G(_)?(n(),o("button",{key:1,type:"button",class:"inline-flex cursor-pointer items-center gap-1 rounded px-0.5 text-neutral-500 transition-colors hover:text-neutral-900 dark:text-neutral-400 dark:hover:text-neutral-100",title:R(_),onClick:Ye(Z=>B(De),["stop"])},[z(c(Tt),{size:11,class:"shrink-0"}),x[10]||(x[10]=t("span",null,"via Scheduled Effect",-1))],8,_i)):m("",!0),t("span",{class:K(_.silent?"text-neutral-400 dark:text-neutral-500":"text-neutral-500 dark:text-neutral-400")},f(Qe(_.created_at)),3)],2)):m("",!0)],2),qe(_,De)?.length&&e.threadId?(n(),o("div",wi,[(n(!0),o(Re,null,Ke(qe(_,De),Z=>(n(),N(Xn,{key:Z.id,attachment:Z,threadId:e.threadId},null,8,["attachment","threadId"]))),128))])):m("",!0)],2)):_.type==="work"?(n(),o("div",{key:2,class:K(["w-full text-[13px] leading-5 transition-all rounded-xl bg-neutral-100 dark:bg-neutral-900/70 ring-1 ring-neutral-300/80 dark:ring-neutral-700",{"cursor-pointer":!e.isEditMode,"text-neutral-700 dark:text-neutral-300":!_.silent,"text-neutral-500 dark:text-neutral-400 opacity-90":_.silent,"agents-ring-selected ring-2":!e.isEditMode&&(He(_)||L(_))}]),onClick:Z=>!e.isEditMode&&(Te(_.id),je(_)[0]&&r("messageClick",_.id,je(_)[0])),onMouseenter:Z=>!e.isEditMode&&je(_)[0]&&r("messageHover",je(_)[0]),onMouseleave:x[4]||(x[4]=Z=>!e.isEditMode&&r("messageHover",null))},[re.value.has(_.id)?(n(),o("div",Li,[t("div",Ri,[z(c(It),{size:14,class:"flex-shrink-0 text-neutral-400 dark:text-neutral-500"}),t("span",Mi,f(pe(_)),1),x[12]||(x[12]=t("span",{class:"text-neutral-400 dark:text-neutral-600"},"·",-1)),t("span",Di,f(_.items.length)+" op"+f(_.items.length!==1?"s":""),1),t("div",Fi,[(n(!0),o(Re,null,Ke(_.items,Z=>(n(),o("span",{key:Z.id,class:K(["work-op-square",Fe(Z)]),title:tt(Z)},null,10,Pi))),128))])]),(n(!0),o(Re,null,Ke(_.items,Z=>(n(),o("div",{key:Z.id},[Z.type==="tool_call"?(n(),o("div",Ni,[t("div",{onClick:Ye(Xe=>{le(Z.id),Z.log_id&&r("messageClick",_.id,Z.log_id)},["stop"]),onMouseenter:Ye(Xe=>Z.log_id&&r("messageHover",Z.log_id),["stop"]),onMouseleave:x[2]||(x[2]=Ye(Xe=>r("messageHover",null),["stop"])),class:K(["flex items-center gap-2 cursor-pointer rounded-md hover:bg-neutral-100/70 dark:hover:bg-neutral-800/50 transition-colors min-w-0 -mx-1 px-1 py-0.5",{"ring-1 agents-ring-selected":de(Z)||ge(Z)}])},[Ce.value.has(Z.id)?(n(),N(c(It),{key:1,size:14,class:"flex-shrink-0 text-neutral-400 dark:text-neutral-500"})):(n(),N(c(Bt),{key:0,size:14,class:"flex-shrink-0 text-neutral-400 dark:text-neutral-500"})),t("span",{class:K(["work-op-square",Fe(Z)]),title:tt(Z),"aria-hidden":"true"},null,10,ji),t("span",Bi,f(Z.tool_name),1),ie(Z.tool_arguments)?(n(),o("span",Oi,f(ie(Z.tool_arguments)),1)):m("",!0)],42,zi),Ce.value.has(Z.id)?(n(),o("div",Vi,[Z.tool_arguments?(n(),o("div",Hi,[x[13]||(x[13]=t("div",{class:"text-[10px] font-semibold uppercase tracking-wider text-neutral-400 dark:text-neutral-500 mb-1"},"Arguments",-1)),t("div",qi,[(n(!0),o(Re,null,Ke(ye(Z.tool_arguments),Xe=>(n(),o("div",{key:Xe.key,class:"grid grid-cols-[5.5rem_minmax(0,1fr)] gap-x-3 gap-y-1 py-1.5 first:pt-0 last:pb-0"},[t("div",Ui,f(Xe.key),1),t("div",Wi,[Xe.isBlock?(n(),N(jt,{key:0,code:Xe.code,language:Xe.language},null,8,["code","language"])):(n(),o("span",Ki,f(Xe.code),1))])]))),128))])])):m("",!0),Z.response?(n(),o("div",Ji,[t("div",Gi,f(Z.response_status==="failed"?"Error":"Response"),1),t("div",{class:K(["cursor-pointer rounded-md px-2.5 py-2 text-neutral-800 ring-1 ring-neutral-200/70 dark:text-neutral-200 dark:ring-neutral-800/70",{"bg-rose-50/70 text-rose-800 ring-rose-200/70 dark:bg-rose-950/30 dark:text-rose-200 dark:ring-rose-900/60":Z.response_status==="failed","bg-white dark:bg-neutral-950/60":Z.response_status!=="failed","ring-1 agents-ring-selected":e.selectedLogId&&Z.response_log_id===e.selectedLogId||e.hoveredLogId&&Z.response_log_id===e.hoveredLogId&&Z.response_log_id!==e.selectedLogId}]),onClick:Ye(Xe=>Z.response_log_id&&r("messageClick",_.id,Z.response_log_id),["stop"]),onMouseenter:Ye(Xe=>Z.response_log_id&&r("messageHover",Z.response_log_id),["stop"]),onMouseleave:x[3]||(x[3]=Ye(Xe=>r("messageHover",null),["stop"]))},[Z.response_status==="failed"?(n(),o("pre",Qi,f($e(Z.response)),1)):(n(),N(jt,{key:1,code:V(Z.response).code,language:V(Z.response).language},null,8,["code","language"]))],42,Yi)])):m("",!0)])):m("",!0)])):Z.type==="reasoning"?(n(),o("div",Zi,[t("button",{onClick:Ye(Xe=>we(Z.id),["stop"]),class:"flex items-center gap-2 -mx-1 px-1 py-0.5 rounded-md hover:bg-neutral-100/70 dark:hover:bg-neutral-800/50 transition-colors"},[ze.value.has(Z.id)?(n(),N(c(It),{key:1,size:14,class:"flex-shrink-0 text-neutral-400 dark:text-neutral-500"})):(n(),N(c(Bt),{key:0,size:14,class:"flex-shrink-0 text-neutral-400 dark:text-neutral-500"})),x[14]||(x[14]=t("span",{class:"font-medium text-neutral-800 dark:text-neutral-100"},"Reasoning",-1))],8,Xi),ze.value.has(Z.id)?(n(),o("div",ed,f(Je(Z.content)),1)):m("",!0)])):Z.type==="content"?(n(),o("div",td,f(Je(Z.content)),1)):m("",!0)]))),128))])):(n(),o("div",Ci,[z(c(Bt),{size:14,class:"flex-shrink-0 text-neutral-400 dark:text-neutral-500"}),O(_.items)?(n(),o("span",Si,f(se(O(_.items)||"")),1)):(n(),o("span",Ti,f(he(_)),1)),x[11]||(x[11]=t("span",{class:"text-neutral-400 dark:text-neutral-600 flex-shrink-0"},"·",-1)),t("span",Ii,f(_.items.length)+" op"+f(_.items.length!==1?"s":""),1),t("div",Ai,[(n(!0),o(Re,null,Ke(_.items,Z=>(n(),o("span",{key:Z.id,class:K(["work-op-square",Fe(Z)]),title:tt(Z)},null,10,Ei))),128))])]))],42,$i)):_.type==="subagent_group"?(n(),o("div",{key:3,class:K(["w-full rounded-xl border border-neutral-200 bg-white text-xs text-neutral-800 shadow-sm transition-all dark:border-neutral-800 dark:bg-neutral-950 dark:text-neutral-100",{"border-dashed bg-transparent text-neutral-700 dark:text-neutral-200":_.silent,"ring-2 agents-ring-selected":!e.isEditMode&&(D(De,e.selectedLogId)||D(De,e.hoveredLogId))}])},[t("div",nd,[t("div",ad,[x[15]||(x[15]=t("div",{class:"text-[10px] font-medium uppercase text-neutral-400"}," Subagent activity ",-1)),t("div",rd,f(_.count)+" active profile"+f(_.count===1?"":"s"),1)]),t("span",sd,f(_.count),1)]),t("div",od,[(n(!0),o(Re,null,Ke(_.subagents,Z=>(n(),o("div",{key:Z.id,class:"px-3 py-2"},[t("button",{type:"button",class:"w-full rounded-lg px-1 py-1 text-left transition-colors hover:bg-neutral-50 dark:hover:bg-neutral-900/70",onClick:Ye(Xe=>ce(Z.id),["stop"])},[t("div",id,[t("img",{src:_e(Z),alt:"",class:"h-8 w-8 shrink-0 rounded-lg object-cover ring-1 ring-neutral-200 dark:ring-neutral-800"},null,8,dd),t("div",ud,[t("div",cd,[t("span",fd,f(P(Z)),1),t("span",{class:K(["shrink-0 rounded-full px-1.5 py-0.5 text-[10px] leading-none ring-1 ring-inset",d(Z)])},f(A(Z)),3)]),t("div",pd,[st(f(vt(Z)),1),Ie(Z)?(n(),o(Re,{key:0},[st(" · "+f(Ie(Z)),1)],64)):m("",!0),st(" · ref "+f(q(Z)),1)])]),gt(Z)?(n(),o("img",{key:0,src:gt(Z),alt:"",loading:"lazy",class:"h-8 w-8 shrink-0 rounded-md object-cover ring-1 ring-neutral-200 dark:ring-neutral-800"},null,8,vd)):m("",!0),t("span",gd,f(Z.messageCount),1),Ve.value.has(Z.id)?(n(),N(c(It),{key:1,size:14,class:"shrink-0 text-neutral-400"})):(n(),N(c(Bt),{key:2,size:14,class:"shrink-0 text-neutral-400"}))]),t("div",md,f(h(Z)),1)],8,ld),Ve.value.has(Z.id)?(n(),o("div",hd,[(n(!0),o(Re,null,Ke(Z.messages,Xe=>(n(),o("div",{key:Xe.id,class:"rounded-md border border-neutral-200 bg-neutral-50 px-2 py-1.5 dark:border-neutral-800 dark:bg-neutral-900/60"},[t("div",xd,[t("span",bd,f(ot(Xe.role)),1),t("span",null,f(Qe(Xe.created_at)),1),Xe.silent?(n(),o("span",yd,"silent")):m("",!0)]),Xe.content?(n(),o("div",{key:0,class:"markdown-content mt-0.5 break-words text-[11px] leading-4 text-neutral-700 dark:text-neutral-200",innerHTML:S(Xe.content)},null,8,kd)):m("",!0),Xe.attachments?.length&&e.threadId?(n(),o("div",_d,[(n(!0),o(Re,null,Ke(Xe.attachments,yt=>(n(),N(Xn,{key:yt.id,attachment:yt,threadId:e.threadId},null,8,["attachment","threadId"]))),128))])):m("",!0)]))),128))])):m("",!0)]))),128))])],2)):_.type==="subagent"?(n(),o("div",{key:4,class:K(["w-full rounded-xl border border-neutral-200 bg-white px-3 py-3 text-xs text-neutral-800 shadow-sm transition-all dark:border-neutral-800 dark:bg-neutral-950 dark:text-neutral-100",{"border-dashed bg-transparent text-neutral-700 dark:text-neutral-200":_.silent,"ring-2 agents-ring-selected":!e.isEditMode&&(D(De,e.selectedLogId)||D(De,e.hoveredLogId))}])},[t("button",{type:"button",class:"w-full rounded-lg text-left transition-colors hover:bg-neutral-50 dark:hover:bg-neutral-900/70",onClick:Ye(Z=>ce(_.id),["stop"])},[t("div",$d,[t("img",{src:_e(_),alt:"",class:"h-9 w-9 shrink-0 rounded-lg object-cover ring-1 ring-neutral-200 dark:ring-neutral-800"},null,8,Cd),t("div",Sd,[t("div",Td,[t("span",Id,f(P(_)),1),t("span",{class:K(["shrink-0 rounded-full px-1.5 py-0.5 text-[10px] leading-none ring-1 ring-inset",d(_)])},f(A(_)),3)]),t("div",Ad,[st(f(vt(_)),1),Ie(_)?(n(),o(Re,{key:0},[st(" · "+f(Ie(_)),1)],64)):m("",!0),st(" · ref "+f(q(_)),1)])]),gt(_)?(n(),o("img",{key:0,src:gt(_),alt:"",loading:"lazy",class:"h-9 w-9 shrink-0 rounded-md object-cover ring-1 ring-neutral-200 dark:ring-neutral-800"},null,8,Ed)):m("",!0),t("span",Ld,f(_.messageCount),1),Ve.value.has(_.id)?(n(),N(c(It),{key:1,size:14,class:"shrink-0 text-neutral-400"})):(n(),N(c(Bt),{key:2,size:14,class:"shrink-0 text-neutral-400"}))]),t("div",Rd,f(h(_)),1)],8,wd),Ve.value.has(_.id)?(n(),o("div",Md,[(n(!0),o(Re,null,Ke(_.messages,Z=>(n(),o("div",{key:Z.id,class:"rounded-md border border-neutral-200 bg-neutral-50 px-2 py-1.5 dark:border-neutral-800 dark:bg-neutral-900/60"},[t("div",Dd,[t("span",Fd,f(ot(Z.role)),1),t("span",null,f(Qe(Z.created_at)),1),Z.silent?(n(),o("span",Pd,"silent")):m("",!0)]),Z.content?(n(),o("div",{key:0,class:"markdown-content mt-0.5 break-words text-[11px] leading-4 text-neutral-700 dark:text-neutral-200",innerHTML:S(Z.content)},null,8,Nd)):m("",!0),Z.attachments?.length&&e.threadId?(n(),o("div",zd,[(n(!0),o(Re,null,Ke(Z.attachments,Xe=>(n(),N(Xn,{key:Xe.id,attachment:Xe,threadId:e.threadId},null,8,["attachment","threadId"]))),128))])):m("",!0)]))),128))])):m("",!0)],2)):m("",!0)],2)],40,di))),128))]))}}),Bd=pt(jd,[["__scopeId","data-v-cc41609f"]]),Od=at({__name:"ThreadVariableForm",props:{modelValue:{},scanned:{default:()=>[]},disabled:{type:Boolean,default:!1},requireRequiredValues:{type:Boolean,default:!0},groupName:{default:"env"}},emits:["update:modelValue"],setup(e,{emit:s}){const a=e,l=s,r=p=>p&&typeof p=="object"&&!Array.isArray(p)?p:{},i=C({get:()=>r(a.modelValue),set:p=>l("update:modelValue",r(p))});return(p,u)=>{const I=Jt("FormKit");return n(),N(I,{type:"group",name:e.groupName,modelValue:i.value,"onUpdate:modelValue":u[1]||(u[1]=S=>i.value=S),"outer-class":"$reset",classes:{outer:"$remove:mb-4 mb-0"}},{default:Be(()=>[z(Vs,{modelValue:i.value,"onUpdate:modelValue":u[0]||(u[0]=S=>i.value=S),scanned:e.scanned,"allow-declaration-edit":!1,"allow-secret-values":!0,"allow-secret-declarations":!0,"require-required-values":e.requireRequiredValues,"show-custom-rows":!1,disabled:e.disabled,thin:""},null,8,["modelValue","scanned","require-required-values","disabled"])]),_:1},8,["name","modelValue"])}}}),Vd={key:0,class:"create-thread-inline-header flex h-12 shrink-0 items-center border-b border-neutral-300 px-7 dark:border-neutral-700"},Hd={class:"text-base font-bold"},qd={class:"hidden"},Ud={class:"create-thread-scroll flex-1 overflow-y-auto p-6"},Wd={class:"space-y-4"},Kd={key:1},Jd={class:"px-3 py-2 rounded-lg border border-neutral-200 dark:border-neutral-700 bg-neutral-50 dark:bg-neutral-900 text-sm text-neutral-700 dark:text-neutral-300"},Gd={key:2},Yd={class:"flex items-center justify-between mb-1"},Qd={key:0,class:"flex items-center gap-1.5 ml-auto"},Zd={key:0},Xd={key:1},eu={key:2},tu={key:3,class:"space-y-4"},nu={key:4,class:"text-center text-sm text-neutral-500"},au={key:5,class:"space-y-3"},ru={key:6,class:"text-center text-sm text-neutral-500"},su={key:7,class:"create-thread-inline-actions flex flex-col items-end gap-2"},ou={class:"create-thread-action-buttons flex gap-2"},lu={key:0,class:"create-thread-footer p-6 border-t border-neutral-200 dark:border-neutral-700 flex-shrink-0"},iu={class:"create-thread-footer-row flex justify-between items-center"},du={class:"create-thread-action-buttons flex gap-2"},qa="__optional__",uu=at({__name:"CreateThreadModal",props:{modelValue:{type:Boolean},editThread:{},lockedAgentId:{},inline:{type:Boolean}},emits:["update:modelValue","thread-created","thread-updated"],setup(e,{emit:s}){const a=e,l=s,r=C(()=>!!a.editThread),i=b(""),p=b(!1),u=b(!1),I=b(""),S=b([]),y=b(!1),v=b({}),k=b(null),j=ce=>ce&&typeof ce=="object"&&!Array.isArray(ce)?ce:{},$=ce=>ce==null?"":String(ce),W=ce=>$(ce).split(",").map(te=>te.trim()).filter(te=>te.length>0),U=ce=>{const te=j(ce),ie={};for(const[me,Q]of Object.entries(te)){if(me.startsWith(qa)||/^(text|checkbox)_\d+$/.test(me))continue;const Me=$(Q);Me&&(ie[me]=Me)}for(const[me,Q]of Object.entries(te)){if(!me.startsWith(qa)||!Array.isArray(Q))continue;let Me=0;for(const Ne of Q){const Ue=j(Ne);if(Object.values(Ue).some(E=>$(E).trim().length>0)){for(const[E,fe]of Object.entries(Ue)){if(/^(text|checkbox)_\d+$/.test(E))continue;const be=$(fe),Pe=Me===0?E:`${E}__${Me+1}`;if(Me===0){be&&(ie[Pe]=be);continue}ie[Pe]=be}Me+=1}}}return ie},Y=(ce,te)=>{const ie=new Map;for(const Q of te||[])ie.set(Q.property,Q.type==="secret"?"secret":"text");const me={};for(const Q of Object.keys(ce)){const Me=Q.replace(/__\d+$/,"");me[Q]=ie.get(Me)||"secret"}return me},ue=ce=>{const te=new URL(Ze(`/api/variables/agents/${encodeURIComponent(ce)}`),window.location.origin);return te.searchParams.set("include_optional_disabled","1"),te.toString()},ae=()=>({include_subagents:!1,agent_id:r.value?a.editThread?.agent_id||"":a.lockedAgentId||"",tags_csv:r.value&&a.editThread?.tags?.join(", ")||"",data:{},env:{}}),oe=ce=>{k.value=ce},ve=ce=>{const te=j(ce),ie=$(te.agent_id),me=!!te.include_subagents;return i.value!==ie&&(i.value=ie),p.value!==me&&(p.value=me),""},{data:ee,isFetching:G,execute:R}=Vt(Ze("/api/agents"),{immediate:!1}).json(),H=C(()=>{if(!ee.value)return[];const ce=ee.value?.agents||[];return r.value||p.value?ce:ce.filter(te=>fa(te))}),D=()=>H.value.map(ce=>({value:ce.id,label:ce.title})),X=C(()=>!a.lockedAgentId||!ee.value?a.lockedAgentId||"":(ee.value?.agents||[]).find(ie=>ie.id===a.lockedAgentId)?.title||a.lockedAgentId),Se=C(()=>!i.value||!ee.value?null:(ee.value?.agents||[]).find(te=>te.id===i.value)||null),{data:ne,isFetching:Le,execute:B}=Vt(C(()=>Se.value?.side_a_agent_prompt?Ze(`/api/prompts/${encodeURIComponent(Se.value.side_a_agent_prompt)}`):""),{immediate:!1}).json(),re=C(()=>{if(!ne.value)return null;const te=(ne.value.prompt||ne.value).required_schema;if(!te)return null;try{return typeof te=="string"?JSON.parse(te):te}catch{return null}}),Ce=C(()=>{const ce=re.value;return!ce||!ce.properties?[]:Object.entries(ce.properties).map(([te,ie])=>({name:te,type:Array.isArray(ie.type)?ie.type[0]||"string":ie.type||"string",description:typeof ie.description=="string"?ie.description:"",required:ce.required?.includes(te)||!1,enum:ie.enum}))}),ze=C(()=>S.value.length>0),Ve=async ce=>{if(!ce){S.value=[];return}y.value=!0;try{const te=await fetch(ue(ce));if(!te.ok){S.value=[];return}const ie=await te.json();S.value=ie.variables||[]}catch{S.value=[]}finally{y.value=!1}};xe(i,async ce=>{v.value={},ce&&Se.value?.side_a_agent_prompt?await B():ne.value=null,ce?await Ve(ce):S.value=[]}),xe([p,H,r],()=>{r.value||!i.value||H.value.some(te=>te.id===i.value)||(i.value="",k.value?.at("agent_id")?.input(""))});const Te=()=>{i.value=r.value?a.editThread?.agent_id||"":a.lockedAgentId||"",p.value=!1,I.value="",v.value={},gn(k),S.value=[],ne.value=null,k.value?.reset(ae())},le=async ce=>{u.value=!0,I.value="",gn(k);const te=j(ce),ie=W(te.tags_csv);try{if(r.value){const E=await fetch(Ze(`/api/threads/${a.editThread.id}`),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({tags:ie})});if(!E.ok){const fe=await E.json();vn(fe,k);return}l("thread-updated"),Te(),l("update:modelValue",!1);return}const me={agent_id:$(te.agent_id),tags:ie.length>0?ie:void 0},Q=j(te.data);Object.keys(Q).length>0&&(me.data=Q);const Me=U(te.env);Object.keys(Me).length>0&&(me.env=Me,me.env_types=Y(Me,S.value));const Ne=await fetch(Ze("/api/threads"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(me)});if(!Ne.ok){const E=await Ne.json();vn(E,k);return}const We=(await Ne.json()).threadId;if(!We){vn({error:"Thread created but ID not found in response"},k);return}l("thread-created",We),Te(),l("update:modelValue",!1)}catch(me){const Q=(me instanceof Error?me.message:"")||`Failed to ${r.value?"update":"create"} thread`;vn({error:Q},k)||(I.value=Q)}finally{u.value=!1}},we=()=>{Te(),l("update:modelValue",!1)};return xe(()=>a.modelValue,async ce=>{ce&&(a.lockedAgentId&&(p.value=!0),await R(),Te(),a.lockedAgentId&&(i.value=a.lockedAgentId,await et(),k.value?.at("agent_id")?.input(a.lockedAgentId)))},{immediate:!0}),(ce,te)=>{const ie=Jt("FormKit");return e.modelValue?(n(),N(At(e.inline?"div":Ir),{key:0,"model-value":e.modelValue,"onUpdate:modelValue":te[1]||(te[1]=me=>ce.$emit("update:modelValue",me)),title:r.value?"Edit Thread":"Create New Thread",width:"max-w-3xl","content-padding":!1,class:K(["create-thread-shell",e.inline?"flex h-full min-h-0 flex-col bg-white dark:bg-neutral-950":""])},{default:Be(()=>[z(c(ha),{config:c(xa)},{default:Be(()=>[e.inline?(n(),o("div",Vd,[t("h3",Hd,f(r.value?"Edit Thread":"Create New Thread"),1)])):m("",!0),z(ie,{type:"form",id:"create-thread-form",actions:!1,onSubmit:le,onNode:oe,"form-class":"$reset flex-1 min-h-0 flex flex-col"},{default:Be(({value:me})=>[t("span",qd,f(ve(me)),1),t("div",Ud,[t("div",Wd,[I.value?(n(),N(c($r),{key:0,variant:"error"},{default:Be(()=>[st(f(I.value),1)]),_:1})):m("",!0),e.lockedAgentId?(n(),o("div",Kd,[z(ie,{type:"hidden",name:"agent_id",value:e.lockedAgentId},null,8,["value"]),te[2]||(te[2]=t("label",{class:"block text-zinc-700 dark:text-zinc-300 text-xs font-bold mb-1"},"Agent",-1)),t("div",Jd,f(X.value),1)])):(n(),o("div",Gd,[t("div",Yd,[te[4]||(te[4]=t("label",{class:"block text-zinc-700 dark:text-zinc-300 text-xs font-bold"}," Agent ",-1)),r.value?m("",!0):(n(),o("div",Qd,[te[3]||(te[3]=t("span",{class:"text-[11px] text-neutral-500 dark:text-neutral-400"}," Include subagents ",-1)),z(ie,{type:"toggle",name:"include_subagents",value:!1,"on-value":!0,"off-value":!1,"on-value-label":"","off-value-label":"",disabled:c(G),classes:{outer:"$remove:mb-4 mb-0",wrapper:"$remove:items-center flex items-center",label:"$remove:hidden",inner:"h-4",track:"h-4 w-7 rounded-full",thumb:"h-3 w-3",valueLabel:"$remove:hidden"}},null,8,["disabled"])]))]),z(ie,{type:"selectSearch",name:"agent_id",value:i.value,options:D,disabled:c(G)||r.value,placeholder:"Select an agent...",validation:"required","validation-visibility":"submit"},null,8,["value","disabled"]),z(c(Gn),{class:"mt-1"},{default:Be(()=>[r.value?(n(),o("span",Zd,"Agent cannot be changed after thread creation")):p.value?(n(),o("span",Xd,"Choose which agent will handle this conversation (subagents included)")):(n(),o("span",eu,"Choose which agent will handle this conversation"))]),_:1})])),!r.value&&Ce.value.length>0&&!c(Le)?(n(),o("div",tu,[te[5]||(te[5]=t("h4",{class:"text-sm font-medium text-neutral-700 dark:text-neutral-300"}," Required Information ",-1)),z(ie,{type:"group",name:"data","outer-class":"$reset",classes:{outer:"$remove:mb-4 mb-0"}},{default:Be(()=>[(n(!0),o(Re,null,Ke(Ce.value,Q=>(n(),o("div",{key:Q.name,class:"space-y-2"},[Q.enum?(n(),N(ie,{key:0,type:"selectSearch",name:Q.name,label:Q.name,options:[{value:"",label:"Select..."},...Q.enum.map(Me=>({value:Me,label:Me}))],validation:Q.required?"required":"","validation-visibility":"submit"},null,8,["name","label","options","validation"])):Q.type==="string"?(n(),N(ie,{key:1,type:"text",name:Q.name,label:Q.name,placeholder:Q.description,validation:Q.required?"required":"","validation-visibility":"submit"},null,8,["name","label","placeholder","validation"])):Q.type==="number"||Q.type==="integer"?(n(),N(ie,{key:2,type:"number",name:Q.name,label:Q.name,placeholder:Q.description,validation:Q.required?"required":"","validation-visibility":"submit"},null,8,["name","label","placeholder","validation"])):Q.type==="boolean"?(n(),N(ie,{key:3,type:"checkbox",name:Q.name,label:Q.name,validation:Q.required?"required":"","validation-visibility":"submit"},null,8,["name","label","validation"])):(n(),N(ie,{key:4,type:"textarea",name:Q.name,label:Q.name,placeholder:Q.description||`Enter ${Q.name} (JSON format)`,validation:Q.required?"required":"","validation-visibility":"submit",rows:3},null,8,["name","label","placeholder","validation"])),Q.description?(n(),N(c(Gn),{key:5,class:"mt-1"},{default:Be(()=>[st(f(Q.description),1)]),_:2},1024)):m("",!0)]))),128))]),_:1})])):m("",!0),!r.value&&c(Le)?(n(),o("div",nu," Loading agent requirements... ")):m("",!0),!r.value&&ze.value?(n(),o("div",au,[te[6]||(te[6]=t("h4",{class:"text-sm font-medium text-neutral-700 dark:text-neutral-300"}," Variables ",-1)),te[7]||(te[7]=t("p",{class:"text-xs text-neutral-500 dark:text-neutral-400"}," Required variables must be resolved before a new thread can be created. ",-1)),z(Od,{modelValue:v.value,"onUpdate:modelValue":te[0]||(te[0]=Q=>v.value=Q),"group-name":"env",scanned:S.value,disabled:u.value,"require-required-values":!0},null,8,["modelValue","scanned","disabled"])])):m("",!0),!r.value&&y.value?(n(),o("div",ru," Scanning environment variables... ")):m("",!0),t("div",null,[z(ie,{type:"text",name:"tags_csv",value:r.value&&a.editThread?.tags?.join(", ")||"",label:"Tags",placeholder:"research, urgent, production"},null,8,["value"]),z(c(Gn),{class:"mt-1"},{default:Be(()=>[...te[8]||(te[8]=[st(" Comma-separated tags to help organize and search threads ",-1)])]),_:1})]),e.inline?(n(),o("div",su,[z(c(la),{node:k.value||void 0},null,8,["node"]),t("div",ou,[z(c(Sn),{variant:"ghost",size:"sm",disabled:u.value,onClick:we},{default:Be(()=>[...te[9]||(te[9]=[st(" Cancel ",-1)])]),_:1},8,["disabled"]),z(c(Sn),{variant:"primary",size:"sm",disabled:u.value||c(G),loading:u.value,type:"submit",form:"create-thread-form"},{default:Be(()=>[...te[10]||(te[10]=[st(" Create Thread ",-1)])]),_:1},8,["disabled","loading"])])])):m("",!0)])]),e.inline?m("",!0):(n(),o("div",lu,[t("div",iu,[z(c(la),{node:k.value||void 0},null,8,["node"]),t("div",du,[z(c(Sn),{variant:"ghost",size:"sm",disabled:u.value,onClick:we},{default:Be(()=>[...te[11]||(te[11]=[st(" Cancel ",-1)])]),_:1},8,["disabled"]),z(c(Sn),{variant:"primary",size:"sm",disabled:u.value||c(G),loading:u.value,type:"submit",form:"create-thread-form"},{default:Be(()=>[r.value?(n(),o(Re,{key:0},[st(f(u.value?"Updating...":"Update Thread"),1)],64)):(n(),o(Re,{key:1},[st(f(u.value?"Creating...":"Create Thread"),1)],64))]),_:1},8,["disabled","loading"])])])]))]),_:1})]),_:1},8,["config"])]),_:1},8,["model-value","title","class"])):m("",!0)}}}),cu=pt(uu,[["__scopeId","data-v-95b38d65"]]),fu=["accept"],pu=["disabled"],vu=at({__name:"FileUpload",props:{isProcessing:{type:Boolean},accept:{},buttonClass:{}},emits:["filesSelected"],setup(e,{expose:s,emit:a}){const l=e,r=a,i=b(null),p=C(()=>l.accept||"image/*,.pdf,.txt,.md,.json,.csv");function u(){i.value?.click()}function I(y){const v=y.target;v.files&&v.files.length>0&&(r("filesSelected",v.files),v.value="")}function S(y){const v=y.clipboardData?.items;if(!v)return;const k=[];for(let j=0;j<v.length;j++){const $=v[j];if($.kind==="file"){const W=$.getAsFile();W&&k.push(W)}}if(k.length>0){const j=new DataTransfer;k.forEach($=>j.items.add($)),r("filesSelected",j.files)}}return s({handlePaste:S}),(y,v)=>(n(),o(Re,null,[t("input",{ref_key:"fileInputRef",ref:i,type:"file",accept:p.value,multiple:"",class:"hidden",onChange:I},null,40,fu),t("button",{type:"button",onClick:u,class:K(["p-1.5 hover:bg-neutral-100 dark:hover:bg-neutral-800 rounded-lg transition-colors text-neutral-500 hover:text-neutral-700 dark:hover:text-neutral-300",[e.buttonClass,{"opacity-50 cursor-not-allowed":e.isProcessing}]]),disabled:e.isProcessing,title:"Attach files","aria-label":"Attach files"},[z(c(is),{size:18})],10,pu)],64))}}),gu={class:"absolute bottom-0 left-4 right-4 z-20 pb-4 pt-8 min-w-0 overflow-hidden bg-gradient-to-t from-white via-white/95 to-white/0 dark:from-neutral-900 dark:via-neutral-900/95 dark:to-neutral-900/0"},mu={key:0,class:"mb-2 rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300"},hu={key:1,class:"mb-2 flex flex-wrap gap-2"},xu={key:0,class:"w-16 h-16 rounded-lg overflow-hidden border border-neutral-200 dark:border-neutral-700 bg-neutral-100 dark:bg-neutral-800"},bu=["src","alt"],yu={key:1,class:"w-full h-full flex items-center justify-center"},ku={key:1,class:"h-16 px-3 rounded-lg border border-neutral-200 dark:border-neutral-700 bg-neutral-100 dark:bg-neutral-800 flex items-center gap-2"},_u=["title"],wu=["onClick"],$u=["title","aria-label"],Cu=["src"],Su=["disabled","placeholder"],Tu=["disabled"],Iu={key:0,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"2",stroke:"currentColor",class:"w-4 h-4"},Au={key:1,class:"w-4 h-4"},Eu=at({__name:"MessageComposer",props:{attachments:{},assistantAvatarSrc:{},assistantAvatarSeed:{},userAvatarSrc:{},sideALabel:{},sideBLabel:{},isExecuting:{type:Boolean},isProcessingFiles:{type:Boolean},sendMessage:{type:Function},stopThread:{type:Function},addFiles:{type:Function},removeAttachment:{type:Function}},emits:["sent"],setup(e,{expose:s,emit:a}){const l=e,r=a,i=b(null),p=b(null),u=b(""),I=b("B"),S=b(!1),y=b(!1),v=b(null),k=C(()=>l.attachments.length>0),j=C(()=>I.value==="A"?l.sideALabel:l.sideBLabel),$=C(()=>`Message from ${j.value}...`),W=b($.value);let U=null;const Y=()=>{U&&(clearTimeout(U),U=null)};xe($,R=>{Y(),W.value="";const H=D=>{W.value=R.slice(0,D),D<R.length&&(U=setTimeout(()=>H(D+1),16))};U=setTimeout(()=>H(1),20)},{immediate:!0}),$t(Y);const ue=(R=p.value)=>{if(!R){S.value=!1;return}const H=R.style.minHeight;R.style.minHeight="0px",R.style.height="auto";const D=R.scrollHeight,X=Math.min(D,160);R.style.height=`${X}px`,R.style.minHeight=H,S.value=D>52||u.value.includes(`
9
- `)},ae=R=>{ue(R.target instanceof HTMLTextAreaElement?R.target:void 0)};xe(u,async()=>{await et(),ue()});const oe=async()=>{I.value=I.value==="A"?"B":"A",await et(),p.value?.focus()},ve=async()=>{if(!(u.value.trim().length>0)&&!k.value||y.value)return;v.value=null;const H=u.value,D=I.value==="A"?"assistant":"user";u.value="",S.value=!1,await et(),ue(),y.value=!0;try{await l.sendMessage({role:D,content:H}),r("sent")}catch{v.value="Message could not be sent. Please try again."}finally{y.value=!1,await et(),p.value?.focus()}},ee=R=>{R.key==="Enter"&&!R.shiftKey&&(R.preventDefault(),ve())},G=async()=>{try{v.value=null,await l.stopThread()}catch{v.value="Thread execution could not be stopped. Please try again."}};return s({focusInput:async()=>{await et(),p.value?.focus()}}),(R,H)=>(n(),o("div",gu,[v.value?(n(),o("div",mu,f(v.value),1)):m("",!0),e.attachments.length>0?(n(),o("div",hu,[(n(!0),o(Re,null,Ke(e.attachments,D=>(n(),o("div",{key:D.id,class:"relative group"},[D.isImage?(n(),o("div",xu,[D.previewUrl?(n(),o("img",{key:0,src:D.previewUrl,alt:D.name,class:"w-full h-full object-cover"},null,8,bu)):(n(),o("div",yu,[...H[2]||(H[2]=[t("div",{class:"w-4 h-4 border-2 border-neutral-300 border-t-neutral-600 rounded-full animate-spin"},null,-1)])]))])):(n(),o("div",ku,[t("span",{class:"text-xs text-neutral-600 dark:text-neutral-300 max-w-[80px] truncate",title:D.name},f(D.name),9,_u)])),t("button",{onClick:Ye(X=>e.removeAttachment(D.id),["stop"]),class:"absolute -top-1 -right-1 w-4 h-4 rounded-full bg-neutral-600 dark:bg-neutral-500 text-white flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity hover:bg-red-500"},[...H[3]||(H[3]=[t("span",{class:"text-[10px] font-bold leading-none"},"x",-1)])],8,wu)]))),128))])):m("",!0),t("div",{class:K(["mx-auto max-w-3xl rounded-[28px] border border-neutral-200 bg-white/95 p-2 backdrop-blur transition-[border-radius] dark:border-neutral-700 dark:bg-neutral-900/95",S.value?"grid grid-cols-[auto_auto_1fr_auto] grid-rows-[auto_auto] gap-x-2 gap-y-2":"flex items-end gap-2"])},[t("button",{onClick:oe,type:"button",class:K(["sender-avatar-switch relative h-8 w-9 shrink-0 self-center",S.value?"col-start-1 row-start-2":""]),title:`Sending as ${j.value}. Click to switch.`,"aria-label":`Sending as ${j.value}. Click to switch.`},[z(bn,{icon:e.assistantAvatarSrc,seed:e.assistantAvatarSeed??e.sideALabel,class:K(["sender-avatar rounded-lg border-2 border-white bg-white object-cover shadow-sm ring-1 ring-black/10 dark:border-neutral-900 dark:bg-neutral-900 dark:ring-white/15",I.value==="A"?"sender-avatar--front":"sender-avatar--back"])},null,8,["icon","seed","class"]),t("img",{src:e.userAvatarSrc,alt:"",class:K(["sender-avatar rounded-lg border-2 border-white bg-white object-cover shadow-sm ring-1 ring-black/10 dark:border-neutral-900 dark:bg-neutral-900 dark:ring-white/15",I.value==="B"?"sender-avatar--front":"sender-avatar--back"])},null,10,Cu)],10,$u),t("div",{class:K(S.value?"col-start-2 row-start-2 self-center":"")},[z(vu,{ref_key:"fileUploadRef",ref:i,"is-processing":!1,"button-class":S.value?"":"-translate-y-[0.1875rem]",onFilesSelected:e.addFiles},null,8,["button-class","onFilesSelected"])],2),ft(t("textarea",{ref_key:"messageTextarea",ref:p,"onUpdate:modelValue":H[0]||(H[0]=D=>u.value=D),onKeydown:ee,onPaste:H[1]||(H[1]=D=>i.value?.handlePaste(D)),disabled:y.value,placeholder:W.value,rows:"1",class:K(["resize-none bg-transparent text-sm text-black focus:outline-none disabled:opacity-50 dark:text-white",S.value?"col-span-4 row-start-1 min-h-24 w-full px-3 py-3":"min-h-9 flex-1 px-1 py-2"]),style:{"max-height":"160px"},onInput:ae},null,42,Su),[[Fn,u.value]]),e.isExecuting?(n(),o("button",{key:1,id:"stop-thread-button",onClick:G,class:K(["h-9 w-9 shrink-0 rounded-full flex items-center justify-center transition-all bg-red-600 text-white dark:bg-red-500 hover:bg-red-700 dark:hover:bg-red-600",S.value?"col-start-4 row-start-2 justify-self-end":""]),title:"Stop execution"},[...H[5]||(H[5]=[t("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"2",stroke:"currentColor",class:"w-4 h-4"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M5.25 7.5A2.25 2.25 0 017.5 5.25h9a2.25 2.25 0 012.25 2.25v9a2.25 2.25 0 01-2.25 2.25h-9a2.25 2.25 0 01-2.25-2.25v-9z"})],-1)])],2)):(n(),o("button",{key:0,id:"send-message-button",onClick:ve,disabled:!u.value.trim()&&!k.value||y.value||e.isProcessingFiles,class:K(["h-9 w-9 shrink-0 rounded-full flex items-center justify-center transition-all",[S.value?"col-start-4 row-start-2 justify-self-end":"",{"bg-accent-600 text-white hover:bg-accent-700 dark:bg-accent-500 dark:hover:bg-accent-400":(u.value.trim()||k.value)&&!y.value&&!e.isProcessingFiles,"bg-neutral-200 text-neutral-400 dark:bg-neutral-700 dark:text-neutral-600":!u.value.trim()&&!k.value||y.value||e.isProcessingFiles}]]),title:"Send message (Enter)"},[y.value?(n(),o("div",Au,[z(nt)])):(n(),o("svg",Iu,[...H[4]||(H[4]=[t("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M4.5 10.5 12 3m0 0 7.5 7.5M12 3v18"},null,-1)])]))],10,Tu))],2)]))}}),Lu=pt(Eu,[["__scopeId","data-v-bd07533d"]]),Ru={class:"bg-white dark:bg-neutral-900 rounded-lg border border-neutral-200 dark:border-neutral-800 overflow-hidden"},Mu=["disabled"],Du={key:1,class:"flex items-center gap-2 p-3 text-xs text-neutral-500 dark:text-neutral-400"},Fu={class:"p-3 space-y-3"},Pu={class:"flex flex-wrap gap-x-4 gap-y-1 text-xs"},Nu={class:"ml-1 font-mono font-semibold text-neutral-800 dark:text-neutral-100"},zu={class:"ml-1 font-mono text-neutral-600 dark:text-neutral-400"},ju={key:0,class:"flex flex-wrap gap-x-4 gap-y-1 text-xs"},Bu={class:"ml-1 font-mono text-neutral-600 dark:text-neutral-400"},Ou={class:"ml-1 font-mono text-neutral-600 dark:text-neutral-400"},Vu={class:"ml-1 font-mono text-neutral-600 dark:text-neutral-400"},Hu={key:0},qu={class:"ml-1 font-mono text-neutral-600 dark:text-neutral-400"},Uu={key:1,class:"w-full text-[11px]"},Wu={class:"border-b border-neutral-200 dark:border-neutral-800"},Ku={key:0,class:"text-right py-1.5 font-medium text-neutral-500 dark:text-neutral-400 uppercase text-[10px]"},Ju={key:1,class:"text-right py-1.5 font-medium text-neutral-500 dark:text-neutral-400 uppercase text-[10px]"},Gu={key:2,class:"text-right py-1.5 font-medium text-neutral-500 dark:text-neutral-400 uppercase text-[10px]"},Yu=["title"],Qu={class:"text-right py-1.5 font-mono text-neutral-600 dark:text-neutral-400"},Zu={key:0,class:"text-right py-1.5 font-mono text-neutral-600 dark:text-neutral-400"},Xu={key:1,class:"text-right py-1.5 font-mono text-neutral-600 dark:text-neutral-400"},ec={key:2,class:"text-right py-1.5 font-mono text-neutral-600 dark:text-neutral-400"},tc={class:"text-right py-1.5 font-mono text-neutral-600 dark:text-neutral-400"},nc={key:2,class:"text-[10px] text-neutral-400 dark:text-neutral-500"},ac={key:3,class:"w-full text-[11px]"},rc={class:"border-b border-neutral-200 dark:border-neutral-800"},sc={key:0,class:"text-right py-1.5 font-medium text-neutral-500 dark:text-neutral-400 uppercase text-[10px]"},oc={key:1,class:"text-right py-1.5 font-medium text-neutral-500 dark:text-neutral-400 uppercase text-[10px]"},lc={key:2,class:"text-right py-1.5 font-medium text-neutral-500 dark:text-neutral-400 uppercase text-[10px]"},ic=["title"],dc={class:"text-right py-1.5 font-mono text-neutral-600 dark:text-neutral-400"},uc={key:0,class:"text-right py-1.5 font-mono text-neutral-600 dark:text-neutral-400"},cc={key:1,class:"text-right py-1.5 font-mono text-neutral-600 dark:text-neutral-400"},fc={key:2,class:"text-right py-1.5 font-mono text-neutral-600 dark:text-neutral-400"},pc={class:"text-right py-1.5 font-mono text-neutral-600 dark:text-neutral-400"},vc=at({__name:"ThreadUsageCostCard",props:{expanded:{type:Boolean},loading:{type:Boolean},costData:{},hideHeader:{type:Boolean}},emits:["toggle"],setup(e,{emit:s}){const a=e,l=s,r=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:4,maximumFractionDigits:6}),i=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumSignificantDigits:3}),p=v=>r.format(v),u=v=>v==null?"—":v===0?"$0":i.format(v),I=C(()=>{const v=a.costData;return v?(v.inputCost??0)>0||(v.cachedCost??0)>0||(v.outputCost??0)>0||(v.routerFeeCost??0)>0:!1}),S=v=>{if(v.isRoot)return"This thread";const k=v.agentName||"subagent";return v.threadName?`${k} · ${v.threadName}`:k},y=v=>(v.threads?.length??0)>1;return(v,k)=>(n(),o("div",Ru,[e.hideHeader?m("",!0):(n(),o("button",{key:0,onClick:k[0]||(k[0]=j=>l("toggle")),disabled:e.loading,type:"button",class:"w-full flex items-center gap-2 px-3 py-2.5 text-left hover:bg-neutral-50 dark:hover:bg-neutral-800 transition-colors disabled:opacity-50"},[z(c(ds),{size:14,class:"shrink-0 text-neutral-400"}),k[1]||(k[1]=t("span",{class:"flex-1 text-xs font-medium text-neutral-700 dark:text-neutral-200"},"Usage & Cost",-1)),e.loading?(n(),N(nt,{key:0,size:"xs"})):(n(),N(c(It),{key:1,size:14,class:K(["shrink-0 text-neutral-400 transition-transform duration-200",{"-rotate-180":e.expanded}])},null,8,["class"]))],8,Mu)),e.hideHeader&&e.loading?(n(),o("div",Du,[z(nt,{size:"xs"}),k[2]||(k[2]=t("span",null,"Loading cost breakdown...",-1))])):(n(),N(kn,{key:2,"enter-active-class":"transition-all duration-200 ease-out","enter-from-class":"opacity-0 max-h-0","enter-to-class":"opacity-100 max-h-[480px]","leave-active-class":"transition-all duration-150 ease-in","leave-from-class":"opacity-100 max-h-[480px]","leave-to-class":"opacity-0 max-h-0"},{default:Be(()=>[(e.hideHeader||e.expanded)&&e.costData?(n(),o("div",{key:0,class:K(["overflow-hidden",{"border-t border-neutral-100 dark:border-neutral-800":!e.hideHeader}])},[t("div",Fu,[t("div",Pu,[t("div",null,[k[3]||(k[3]=t("span",{class:"text-neutral-500 dark:text-neutral-400"},"Total:",-1)),t("span",Nu,f(p(e.costData.totalCost)),1)]),t("div",null,[k[4]||(k[4]=t("span",{class:"text-neutral-500 dark:text-neutral-400"},"Per msg:",-1)),t("span",zu,f(p(e.costData.avgCostPerMessage)),1)])]),I.value?(n(),o("div",ju,[t("div",null,[k[5]||(k[5]=t("span",{class:"text-neutral-500 dark:text-neutral-400"},"Input:",-1)),t("span",Bu,f(u(e.costData.inputCost)),1)]),t("div",null,[k[6]||(k[6]=t("span",{class:"text-neutral-500 dark:text-neutral-400"},"Cached:",-1)),t("span",Ou,f(u(e.costData.cachedCost)),1)]),t("div",null,[k[7]||(k[7]=t("span",{class:"text-neutral-500 dark:text-neutral-400"},"Output:",-1)),t("span",Vu,f(u(e.costData.outputCost)),1)]),(e.costData.routerFeeCost??0)>0?(n(),o("div",Hu,[k[8]||(k[8]=t("span",{class:"text-neutral-500 dark:text-neutral-400"},"Router fee:",-1)),t("span",qu,f(u(e.costData.routerFeeCost)),1)])):m("",!0)])):m("",!0),y(e.costData)?(n(),o("table",Uu,[t("thead",null,[t("tr",Wu,[k[9]||(k[9]=t("th",{class:"text-left py-1.5 font-medium text-neutral-500 dark:text-neutral-400 uppercase text-[10px]"},"Thread",-1)),k[10]||(k[10]=t("th",{class:"text-right py-1.5 font-medium text-neutral-500 dark:text-neutral-400 uppercase text-[10px] w-10"},"Reqs",-1)),I.value?(n(),o("th",Ku,"In")):m("",!0),I.value?(n(),o("th",Ju,"Cached")):m("",!0),I.value?(n(),o("th",Gu,"Out")):m("",!0),k[11]||(k[11]=t("th",{class:"text-right py-1.5 font-medium text-neutral-500 dark:text-neutral-400 uppercase text-[10px]"},"Cost",-1))])]),t("tbody",null,[(n(!0),o(Re,null,Ke(e.costData.threads,j=>(n(),o("tr",{key:j.threadId},[t("td",{class:"py-1.5 truncate max-w-[110px] text-neutral-700 dark:text-neutral-300",title:j.threadId},f(S(j)),9,Yu),t("td",Qu,f(j.requestCount),1),I.value?(n(),o("td",Zu,f(u(j.inputCost)),1)):m("",!0),I.value?(n(),o("td",Xu,f(u(j.cachedCost)),1)):m("",!0),I.value?(n(),o("td",ec,f(u(j.outputCost)),1)):m("",!0),t("td",tc,f(p(j.totalCost)),1)]))),128))])])):m("",!0),e.costData.truncated?(n(),o("p",nc," Large subtree — some subagent threads were not included. ")):m("",!0),e.costData.modelBreakdown.length>0?(n(),o("table",ac,[t("thead",null,[t("tr",rc,[k[12]||(k[12]=t("th",{class:"text-left py-1.5 font-medium text-neutral-500 dark:text-neutral-400 uppercase text-[10px]"},"Model",-1)),k[13]||(k[13]=t("th",{class:"text-right py-1.5 font-medium text-neutral-500 dark:text-neutral-400 uppercase text-[10px] w-10"},"Reqs",-1)),I.value?(n(),o("th",sc,"In")):m("",!0),I.value?(n(),o("th",oc,"Cached")):m("",!0),I.value?(n(),o("th",lc,"Out")):m("",!0),k[14]||(k[14]=t("th",{class:"text-right py-1.5 font-medium text-neutral-500 dark:text-neutral-400 uppercase text-[10px]"},"Cost",-1))])]),t("tbody",null,[(n(!0),o(Re,null,Ke(e.costData.modelBreakdown,j=>(n(),o("tr",{key:j.modelName},[t("td",{class:"py-1.5 truncate max-w-[110px] text-neutral-700 dark:text-neutral-300",title:j.modelName},f(j.modelName),9,ic),t("td",dc,f(j.requestCount),1),I.value?(n(),o("td",uc,f(u(j.inputCost)),1)):m("",!0),I.value?(n(),o("td",cc,f(u(j.cachedCost)),1)):m("",!0),I.value?(n(),o("td",fc,f(u(j.outputCost)),1)):m("",!0),t("td",pc,f(p(j.totalCost)),1)]))),128))])])):m("",!0)])],2)):m("",!0)]),_:1}))]))}}),gc={class:"flex flex-col h-full min-w-0 overflow-hidden"},mc={class:"pl-7 pr-4 border-b border-neutral-300 dark:border-neutral-700 h-12 flex items-center shrink-0"},hc={class:"flex items-center justify-between w-full"},xc={class:"flex items-center gap-2"},bc={class:"font-mono"},yc={class:"flex-1 min-h-0 flex flex-col overflow-hidden relative"},kc={key:0,class:"shrink-0 border-b border-neutral-200 bg-neutral-50 p-3 dark:border-neutral-800 dark:bg-neutral-950"},_c={key:0,class:"text-neutral-500 dark:text-neutral-400 text-center py-8"},wc={key:1,class:"flex justify-center py-8"},$c={key:2,class:"text-red-600 dark:text-red-400 text-center py-8"},Cc={key:0,class:"text-neutral-500 dark:text-neutral-400 text-center py-8"},Sc={key:1,class:"p-3 bg-white dark:bg-neutral-900 border-t border-neutral-300 dark:border-neutral-700"},Tc={key:0,class:"mb-2 rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300"},Ic={class:"flex items-center justify-end gap-2"},Ac=["disabled"],Ec=4e3,Nk=at({__name:"MessagesPane",props:{threadId:{},selectedMessageId:{},selectedLogId:{},selectedEffectId:{},hoveredLogId:{},showCollapseButton:{type:Boolean},createThreadDraft:{type:Boolean},lockedAgentId:{}},emits:["collapse","messageClick","messageHover","messageCountChanged","logsDeleted","cancelCreateThread","threadCreated","filesChanged"],setup(e,{expose:s,emit:a}){const l=e,r=a,i=b(!1),p=b(new Set),u=b(new Map),I=()=>{i.value=!i.value,i.value||(p.value=new Set,u.value=new Map)},S=(he,O)=>{const se=new Set(p.value);O?se.add(he):se.delete(he),p.value=se},y=(he,O)=>{const se=new Map(u.value);se.set(he,O),u.value=se},v=()=>{i.value=!1,p.value=new Set,u.value=new Map},k=C(()=>p.value.size),j=C(()=>{let he=0;for(const[O]of u.value)p.value.has(O)||he++;return he}),$=C(()=>{const he=k.value,O=j.value;return he>0&&O>0?`Delete (${he}), Update (${O})`:he>0?`Delete (${he})`:O>0?`Save changes (${O})`:"Delete"}),W=C(()=>k.value>0||j.value>0),U=async()=>{if(!l.threadId||!W.value)return;ie.value=null;const he=[];for(const O of p.value){const se=Y.value.find(He=>He.id===O);se&&"log_id"in se&&se.log_id&&he.push(se.log_id)}try{for(const[O,se]of u.value)p.value.has(O)||await H(O,se);for(const O of p.value)await R(O);he.length>0&&r("logsDeleted",he)}catch{ie.value="Message changes could not be applied. Please try again."}finally{v()}},{messages:Y,threadInfo:ue,isFetching:ae,error:oe,wsConnected:ve,wsError:ee,isExecuting:G,deleteMessageById:R,updateMessageContent:H,stopThread:D,sendMessage:X,attachments:Se,addAttachment:ne,removeAttachment:Le}=Kl(C(()=>l.threadId)),{thread:B}=ba(C(()=>l.threadId)),{theme:re}=Hs();xe(()=>Y.value.length,he=>r("messageCountChanged",he),{immediate:!0});const Ce=C(()=>{const he=[];for(const O of Y.value){const se=O,He=se.attachments||[];for(const de of He)de.path&&he.push(de.path);if(typeof se.content=="string")for(const de of se.content.matchAll(/\/attachments\/[^\s"'`),]+/g))he.push(de[0])}for(const O of Se.value)O.path&&he.push(O.path);return he.sort().join(`
10
- `)});xe(Ce,(he,O)=>{he&&he!==O&&r("filesChanged")});const ze=C(()=>!1),Ve=he=>{ne(he)},Te=b(null),le=b(null),we=b(null);s({scrollToLogId:he=>le.value&&Te.value?le.value.scrollToLogId(he,Te.value):!1,hasWorkblockForLogId:he=>le.value?le.value.hasWorkblockForLogId(he):!1,messageCount:C(()=>Y.value.length),focusComposer:()=>we.value?.focusInput()});const ie=b(null),me=b(!1),Q=b(!1),Me=b(null),Ne=he=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:4,maximumFractionDigits:6}).format(he);let Ue=!1,We=!1;async function E(){if(!l.threadId){Me.value=null;return}if(Ue){We=!0;return}Ue=!0,Q.value=!0;try{const he=await fetch(Ze(`/api/threads/${l.threadId}/cost`));if(!he.ok)throw new Error("Failed to fetch cost breakdown");Me.value=await he.json()}catch{Me.value=null,me.value=!1}finally{Q.value=!1,Ue=!1,We&&(We=!1,ke())}}const fe=C(()=>Q.value&&!Me.value?"...":Ne(Me.value?.totalCost??0)),be=async()=>{me.value=!me.value,me.value&&!Me.value&&await E()},Pe=async()=>{await et(),Te.value&&(Te.value.scrollTop=Te.value.scrollHeight)};xe(()=>Y.value.length,async()=>{await Pe()}),xe(()=>l.threadId,async he=>{Me.value=null,me.value=!1,he&&E(),he&&await Pe()});let J=null;function ke(){l.threadId&&(J&&clearTimeout(J),J=setTimeout(()=>{J=null,E()},Ec))}xe(()=>Y.value.length,(he,O)=>{O!==void 0&&l.threadId&&ke()}),$t(()=>{J&&clearTimeout(J)}),xe(ae,async(he,O)=>{O&&!he&&await Pe()});const ye=he=>{const O=ue.value?.agent||B.value?.agent;return Us(he==="A"?"a":"b",O)},Ae=C(()=>ye("A")),V=C(()=>ye("B")),$e=()=>{const he=ue.value?.agent||B.value?.agent;return he?typeof he.id=="string"?he.id:typeof he.name=="string"?he.name:l.threadId||"thread":l.threadId||"thread"},pe=C(()=>{const he=ue.value?.agent||B.value?.agent;if(!he)return null;const O=typeof he.icon=="string"?he.icon:"",se=typeof he.id=="string"?he.id:typeof he.name=="string"?he.name:"";return O||(se?jn(se):null)}),Fe=(he,O)=>typeof window>"u"?O:window.getComputedStyle(document.documentElement).getPropertyValue(he).trim()||O,tt=C(()=>{const he=ye("B");return he.trim().toLowerCase()==="human"?(re.value,qs({bg:Fe("--accent-100","#f5f5f5"),fg:Fe("--accent-600","#737373"),border:Fe("--accent-300","#d4d4d4")})):jn(`${$e()}:side-b:${he}`)}),Qe=async he=>{if(!l.threadId||!X)throw new Error("Thread is not ready for messages");await X(he),await Pe()},lt=async()=>{l.threadId&&await D()};return(he,O)=>(n(),o("div",gc,[t("div",mc,[t("div",hc,[t("button",{onClick:O[0]||(O[0]=Ye(se=>r("collapse"),["stop"])),type:"button",class:"-ml-1 flex items-center gap-2 rounded px-1.5 py-1 text-left transition-colors hover:bg-black/10 dark:hover:bg-white/15",title:"Collapse Messages pane","aria-label":"Collapse Messages pane"},[z(c(xn),{size:18,class:"shrink-0"}),O[6]||(O[6]=t("h2",{class:"text-base font-bold"},"Messages",-1)),e.threadId?(n(),N(Nr,{key:0,connected:c(ve),error:c(ee)},null,8,["connected","error"])):m("",!0)]),t("div",xc,[e.threadId?(n(),o("button",{key:0,onClick:Ye(be,["stop"]),type:"button",class:K(["inline-flex h-8 items-center gap-1.5 rounded-md bg-neutral-100 px-2 text-xs font-medium text-neutral-600 transition-colors hover:bg-neutral-200 hover:text-neutral-900 dark:bg-neutral-800 dark:text-neutral-300 dark:hover:bg-neutral-700 dark:hover:text-neutral-100",{"bg-neutral-200 text-neutral-900 dark:bg-neutral-700 dark:text-neutral-100":me.value}]),title:"Toggle cost breakdown"},[t("span",bc,f(fe.value),1)],2)):m("",!0),e.threadId&&c(Y).length>0?(n(),o("button",{key:1,onClick:I,type:"button",class:K(["p-1 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",{"bg-neutral-200 dark:bg-neutral-800":i.value}]),title:"Edit messages"},[z(c(us),{size:20})],2)):m("",!0),e.showCollapseButton!==!1?(n(),o("button",{key:2,onClick:O[1]||(O[1]=se=>r("collapse")),type:"button",class:"p-1 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",title:"Collapse pane"},[z(c(fr),{size:20})])):m("",!0)])])]),t("div",yc,[e.threadId&&me.value&&!e.createThreadDraft?(n(),o("div",kc,[z(vc,{expanded:!0,loading:Q.value,"cost-data":Me.value,"hide-header":"",onToggle:be},null,8,["loading","cost-data"])])):m("",!0),t("div",{ref_key:"messagesContainer",ref:Te,class:K(["flex-1 min-h-0 overflow-y-auto overflow-x-hidden p-4 pb-28 space-y-4",e.createThreadDraft?"!p-0 !pb-0":""])},[e.createThreadDraft?(n(),N(cu,{key:0,inline:"","model-value":!0,"locked-agent-id":e.lockedAgentId,"onUpdate:modelValue":O[2]||(O[2]=se=>{se||r("cancelCreateThread")}),onThreadCreated:O[3]||(O[3]=se=>r("threadCreated",se))},null,8,["locked-agent-id"])):(n(),o(Re,{key:1},[e.threadId?c(ae)?(n(),o("div",wc,[z(nt)])):c(oe)?(n(),o("div",$c," Error loading messages: "+f(c(oe)),1)):(n(),o(Re,{key:3},[e.threadId&&c(Y).length===0?(n(),o("div",Cc," No messages yet ")):(n(),N(Bd,{key:1,ref_key:"agentMessagesRef",ref:le,messages:c(Y),threadId:e.threadId,selectedMessageId:e.selectedMessageId,selectedLogId:e.selectedLogId,selectedEffectId:e.selectedEffectId,hoveredLogId:e.hoveredLogId,isEditMode:i.value,selectedForDelete:p.value,editedMessages:u.value,assistantAvatarSrc:pe.value,userAvatarSrc:tt.value,onMessageClick:O[4]||(O[4]=(se,He,de)=>r("messageClick",se,He,de)),onMessageHover:O[5]||(O[5]=se=>r("messageHover",se)),onSelectionChange:S,onMessageEdit:y},null,8,["messages","threadId","selectedMessageId","selectedLogId","selectedEffectId","hoveredLogId","isEditMode","selectedForDelete","editedMessages","assistantAvatarSrc","userAvatarSrc"]))],64)):(n(),o("div",_c," Select a thread to view messages "))],64))],2),e.threadId&&i.value?(n(),o("div",Sc,[ie.value?(n(),o("div",Tc,f(ie.value),1)):m("",!0),t("div",Ic,[t("button",{onClick:v,class:"px-4 py-2 rounded-lg font-medium text-sm transition-colors bg-neutral-200 text-black hover:bg-neutral-300 dark:bg-neutral-700 dark:text-white dark:hover:bg-neutral-600"}," Cancel "),t("button",{onClick:U,disabled:!W.value,class:K(["px-4 py-2 rounded-lg font-medium text-sm transition-colors",{"bg-red-600 text-white hover:bg-red-700":W.value&&k.value>0,"bg-black text-white hover:bg-neutral-800 dark:bg-white dark:text-black dark:hover:bg-neutral-200":W.value&&k.value===0,"bg-neutral-200 text-neutral-400 dark:bg-neutral-700 dark:text-neutral-500 cursor-not-allowed":!W.value}])},f($.value),11,Ac)])])):e.threadId?(n(),N(Lu,{key:2,ref_key:"messageComposerRef",ref:we,attachments:c(Se),"assistant-avatar-src":pe.value,"assistant-avatar-seed":$e(),"user-avatar-src":tt.value,"side-a-label":Ae.value,"side-b-label":V.value,"is-executing":c(G),"is-processing-files":ze.value,"send-message":Qe,"stop-thread":lt,"add-files":Ve,"remove-attachment":c(Le),onSent:Pe},null,8,["attachments","assistant-avatar-src","assistant-avatar-seed","user-avatar-src","side-a-label","side-b-label","is-executing","is-processing-files","remove-attachment"])):m("",!0)])]))}});function Ua(e){return!!e&&typeof e=="object"}function ct(e){return typeof e=="string"?e:null}function ht(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function Lc(e){return typeof e!="string"?null:/^(?:platform-router|runtime|(?:provider|tool|hook):[A-Za-z0-9._/@-]+)$/.test(e)?e:null}function rt(e,s){return Object.prototype.hasOwnProperty.call(e,s)}function Rc(e){if(!Ua(e))return null;const s=e.type,a=e.log_id;return typeof a!="string"||a.length===0?null:s==="log_queued_tools"?typeof e.queued_tools=="string"?{type:s,log_id:a,queued_tools:e.queued_tools}:null:s==="log_data"&&Ua(e.data)?{type:s,log_id:a,data:Dc(e.data)}:null}const Mc=["app_level","app_message","app_data","app_status","app_request","app_response","app_error","app_trigger"];function Dc(e){const s={};if(rt(e,"message_id")){const a=ct(e.message_id);a!==null&&(s.message_id=a)}if(rt(e,"provider")){const a=ct(e.provider);a!==null&&(s.provider=a)}if(rt(e,"actual_provider")&&(s.actual_provider=ct(e.actual_provider)),rt(e,"standard_agents_router_used")&&typeof e.standard_agents_router_used=="boolean"&&(s.standard_agents_router_used=e.standard_agents_router_used),rt(e,"model")){const a=ct(e.model);a!==null&&(s.model=a)}rt(e,"model_name")&&(s.model_name=ct(e.model_name)),rt(e,"prompt_name")&&(s.prompt_name=ct(e.prompt_name)),rt(e,"tools_called")&&(s.tools_called=ct(e.tools_called)),rt(e,"queued_tools")&&(s.queued_tools=ct(e.queued_tools)),rt(e,"provider_tools")&&(s.provider_tools=ct(e.provider_tools)),rt(e,"parent_log_id")&&(s.parent_log_id=ct(e.parent_log_id)),rt(e,"retry_of_log_id")&&(s.retry_of_log_id=ct(e.retry_of_log_id)),rt(e,"error")&&(s.error=ct(e.error)),rt(e,"error_origin")&&(s.error_origin=Lc(e.error_origin)),rt(e,"cost_total")&&(s.cost_total=ht(e.cost_total)),rt(e,"input_tokens")&&(s.input_tokens=ht(e.input_tokens)),rt(e,"cached_tokens")&&(s.cached_tokens=ht(e.cached_tokens)),rt(e,"output_tokens")&&(s.output_tokens=ht(e.output_tokens)),rt(e,"reasoning_tokens")&&(s.reasoning_tokens=ht(e.reasoning_tokens)),rt(e,"total_tokens")&&(s.total_tokens=ht(e.total_tokens)),rt(e,"latency_ms")&&(s.latency_ms=ht(e.latency_ms)),rt(e,"time_to_first_token_ms")&&(s.time_to_first_token_ms=ht(e.time_to_first_token_ms)),rt(e,"generation_ms")&&(s.generation_ms=ht(e.generation_ms)),rt(e,"finish_reason")&&(s.finish_reason=ct(e.finish_reason)),rt(e,"error_type")&&(s.error_type=ct(e.error_type)),rt(e,"cost_input")&&(s.cost_input=ht(e.cost_input)),rt(e,"cost_cached")&&(s.cost_cached=ht(e.cost_cached)),rt(e,"cost_output")&&(s.cost_output=ht(e.cost_output)),rt(e,"kind")&&(s.kind=ct(e.kind));for(const a of Mc)rt(e,a)&&(s[a]=ct(e[a]));if(rt(e,"app_duration_ms")&&(s.app_duration_ms=ht(e.app_duration_ms)),rt(e,"app_cost")&&(s.app_cost=ht(e.app_cost)),rt(e,"content")&&(s.content=ct(e.content)),rt(e,"reasoning_content")&&(s.reasoning_content=ct(e.reasoning_content)),rt(e,"is_complete")&&typeof e.is_complete=="boolean"&&(s.is_complete=e.is_complete),rt(e,"created_at")){const a=ht(e.created_at);a!==null&&(s.created_at=a)}return s}function Fc(e,s){return{id:e,message_id:s.message_id??"",provider:s.provider??"",actual_provider:s.actual_provider??null,standard_agents_router_used:s.standard_agents_router_used??!1,model:s.model??"",model_name:s.model_name??null,prompt_name:s.prompt_name??null,tools_called:s.tools_called??null,queued_tools:s.queued_tools??null,provider_tools:s.provider_tools??null,parent_log_id:s.parent_log_id??null,retry_of_log_id:s.retry_of_log_id??null,error:s.error??null,error_origin:s.error_origin??null,cost_total:s.cost_total??null,is_complete:s.is_complete??!1,created_at:s.created_at??0}}function Pc(e,s,a){if(s.type==="log_queued_tools")return{...e,queued_tools:s.queued_tools};const l=a.get(s.log_id);return l?{...e,queued_tools:l}:e}function Nc(e,s){const a=new Map(e.pendingQueuedTools),l=e.realtimeLogs.findIndex(S=>S.id===s.log_id),r=l>=0?e.realtimeLogs[l]:null,i=e.httpLogs.find(S=>S.id===s.log_id)??null;if(s.type==="log_queued_tools"&&!r&&!i)return a.set(s.log_id,s.queued_tools),{...e,pendingQueuedTools:a};const p=r??i??Fc(s.log_id,s.type==="log_data"?s.data:{}),u=Pc(s.type==="log_data"?{...p,...s.data,id:s.log_id}:p,s,a);a.delete(s.log_id);const I=l>=0?e.realtimeLogs.map((S,y)=>y===l?u:S):[...e.realtimeLogs,u];return{...e,realtimeLogs:I,pendingQueuedTools:a}}function zc(e,s){const{limit:a=100,offset:l=0,order:r="desc",autoFetch:i=!0,enableWebSocket:p=!1}=s||{};C(()=>!!(typeof e=="string"?e:e?.value));const u=C(()=>{const Q=typeof e=="string"?e:e?.value;if(!Q)return"";const Me=new URLSearchParams,Ne=typeof a=="number"?a:a.value,Ue=typeof l=="number"?l:l.value,We=typeof r=="string"?r:r.value;return Me.append("limit",Ne.toString()),Me.append("offset",Ue.toString()),Me.append("order",We),Ze(`/api/threads/${Q}/logs?${Me.toString()}`)}),{data:I,error:S,isFetching:y,isFinished:v,execute:k,abort:j}=Vt(u,{immediate:!1}).get().json();xe([u,()=>i],([Q,Me])=>{Q&&Me&&k()},{immediate:!0});const $=C(()=>Rr(S.value)?null:S.value),W=C(()=>I.value?.logs||[]),U=C(()=>I.value?.total||0),Y=C(()=>I.value?.hasMore||!1),ue=b(null),ae=b(!1),oe=b(null),ve=b([]),ee=new Map;let G=0,R=null,H=null,D=!0,X=null,Se=0,ne=!1,Le=0;const B=3e4,re=3e4,Ce=()=>{R&&(clearTimeout(R),R=null),H&&(clearInterval(H),H=null)};let ze=0;const Ve=()=>{H&&clearInterval(H),ze=Date.now(),H=setInterval(()=>{ue.value&&ue.value.readyState===WebSocket.OPEN&&Date.now()-ze>=re&&ue.value.send("stream_ping")},re)},Te=()=>{const Q=Fr(Math.min(1e3*Math.pow(2,G),B));G++,en(),R=setTimeout(()=>{D&&we()},Q)},le=()=>{if(!(!D||!p||ya())){if(Se>=Mr){ka().then(Q=>{Q==="halt"||!D||Te()});return}Te()}},we=()=>{ce()},ce=async()=>{const Q=typeof e=="string"?e:e?.value;if(!Q||!p)return;const Me=++Le;ne=!1,ue.value&&(X=null,ue.value.close()),G===0&&(ve.value=[]);const Ne=window.location.protocol==="https:"?"wss:":"ws:",Ue=window.location.host;try{const We=await Cr(`${Ne}//${Ue}${Ze(`/api/threads/${Q}/logs`)}`);if(Me!==Le||!D)return;const E=new WebSocket(We);ue.value=E,X=E,E.onopen=()=>{X===E&&(ae.value=!0,oe.value=null,G=0,Se=0,ne=!0,Dr(),Ve(),en("Logs WebSocket","Connected"))},E.onmessage=fe=>{if(X===E&&(ze=Date.now(),!(fe.data==="pong"||fe.data==="stream_pong")))try{const be=Rc(JSON.parse(fe.data));if(be){const Pe=Nc({realtimeLogs:ve.value,httpLogs:W.value,pendingQueuedTools:ee},be);ve.value=Pe.realtimeLogs,ee.clear(),Pe.pendingQueuedTools.forEach((J,ke)=>{ee.set(ke,J)})}}catch{oe.value="Failed to parse log update"}},E.onerror=fe=>{X===E&&(oe.value="WebSocket connection error")},E.onclose=()=>{X===E&&(ae.value=!1,ne||Se++,Ce(),en("Logs WebSocket","Disconnected"),le())}}catch(We){oe.value=We instanceof Error?We.message:"Failed to create WebSocket",le()}},te=()=>{Le++,D=!1,Ce(),X=null,ue.value&&(ue.value.close(),ue.value=null),ae.value=!1,G=0,ve.value=[],ee.clear()},ie=()=>{D=!0,G=0,we()};return Ht(()=>{te()}),{logs:C(()=>{if(!p)return W.value;const Q=new Map;W.value.forEach(Ue=>Q.set(Ue.id,Ue)),ve.value.forEach(Ue=>Q.set(Ue.id,Ue));const Me=typeof r=="string"?r:r.value;return Array.from(Q.values()).sort((Ue,We)=>Me==="desc"?We.created_at-Ue.created_at:Ue.created_at-We.created_at)}),total:U,hasMore:Y,error:$,isFetching:y,isFinished:v,refetch:k,abort:j,wsConnected:ae,wsError:oe,connectWebSocket:ie,disconnectWebSocket:te}}function jc(e){if(!e)return null;try{const s=JSON.parse(e);return s.messages===void 0?null:JSON.stringify(s.messages)}catch{return null}}function Bc(e,s){const a=C(()=>{const I=e.value,S=s.value;return!I||!S?null:Ze(`/api/threads/${I}/logs/${S}`)}),{data:l,error:r,isFetching:i,execute:p}=Vt(a,{immediate:!1}).get().json();return xe([e,s],([I,S])=>{I&&S&&p()},{immediate:!0}),{logDetails:C(()=>{const I=l.value;return I?I.message_history!=null?I:{...I,message_history:jc(I.request_body)}:null}),error:r,isFetching:i,refetch:p}}function Oc(e){const s=new Set,a=new Map;for(const l of e){const r=l.cached_tokens;if(r==null||!l.prompt_name)continue;const i=`${l.prompt_name}::${l.model_name??l.model}`,p=a.get(i);p!==void 0&&r<p&&s.add(l.id),a.set(i,r)}return s}const Vc={class:"min-h-0 flex-1 overflow-hidden"},Hc=["aria-valuenow","title"],qc={class:"relative m-2 h-[calc(100%-1rem)] overflow-hidden rounded-lg border border-neutral-300 bg-white dark:border-neutral-700 dark:bg-neutral-900"},Uc=at({__name:"InspectorResizablePane",props:{heightPercent:{},storageKey:{},minMainHeight:{default:180},minDetailHeight:{default:260},title:{default:"Resize details"}},emits:["update:heightPercent"],setup(e,{emit:s}){const a=e,l=s,r=b(null),i=b(!1),p=($,W,U)=>Math.min(U,Math.max(W,$)),u=$=>p($,20,80),I=()=>{if(!a.storageKey||typeof window>"u")return;const $=window.localStorage.getItem(a.storageKey),W=$?Number.parseFloat($):Number.NaN;Number.isFinite(W)&&l("update:heightPercent",u(W))},S=()=>{!a.storageKey||typeof window>"u"||window.localStorage.setItem(a.storageKey,a.heightPercent.toFixed(2))},y=$=>{if(!r.value)return;const W=r.value.getBoundingClientRect();if(W.height<=0)return;const U=W.bottom-$.clientY,Y=a.minDetailHeight/W.height*100,ue=100-a.minMainHeight/W.height*100;l("update:heightPercent",p(U/W.height*100,Math.min(Y,ue),Math.max(Y,ue)))},v=()=>{i.value&&(i.value=!1,document.body.style.cursor="",document.body.style.userSelect="",window.removeEventListener("pointermove",y),window.removeEventListener("pointerup",v),window.removeEventListener("pointercancel",v),S())},k=$=>{$.preventDefault(),$.currentTarget instanceof HTMLElement&&$.currentTarget.setPointerCapture($.pointerId),i.value=!0,document.body.style.cursor="row-resize",document.body.style.userSelect="none",y($),window.addEventListener("pointermove",y),window.addEventListener("pointerup",v),window.addEventListener("pointercancel",v)},j=$=>{const W=$.shiftKey?10:4;$.key==="ArrowUp"?($.preventDefault(),l("update:heightPercent",u(a.heightPercent+W)),S()):$.key==="ArrowDown"&&($.preventDefault(),l("update:heightPercent",u(a.heightPercent-W)),S())};return Et(I),$t(v),($,W)=>(n(),o("div",{ref_key:"root",ref:r,class:"flex h-full min-h-0 flex-col overflow-hidden"},[t("div",Vc,[Pt($.$slots,"main",{},void 0,!0)]),z(kn,{name:"inspector-slide-up"},{default:Be(()=>[$.$slots.detail?(n(),o("div",{key:0,class:"relative shrink-0 overflow-hidden border-t border-neutral-300 bg-neutral-100 dark:border-neutral-700 dark:bg-neutral-950",style:bt({height:`${e.heightPercent}%`})},[t("div",{class:K(["absolute inset-x-0 top-0 z-20 h-2 -translate-y-1 cursor-row-resize transition-colors hover:bg-neutral-200/70 dark:hover:bg-neutral-800/70",i.value?"bg-neutral-200/70 dark:bg-neutral-800/70":""]),role:"separator","aria-orientation":"horizontal","aria-valuenow":Math.round(e.heightPercent),"aria-valuemin":"20","aria-valuemax":"80",tabindex:"0",title:e.title,onPointerdown:k,onKeydown:j},null,42,Hc),t("div",qc,[Pt($.$slots,"detail",{},void 0,!0)])],4)):m("",!0)]),_:3})],512))}}),Un=pt(Uc,[["__scopeId","data-v-45799e53"]]),cn=new WeakMap,Wc=e=>1-Math.pow(1-e,3),Kc=()=>typeof window<"u"&&window.matchMedia?.("(prefers-reduced-motion: reduce)").matches,ta=(e,s,a)=>Math.min(Math.max(e,s),a),On=(e,s)=>{const a=s.duration??80,l=Math.max(0,e.scrollHeight-e.clientHeight),r=Math.max(0,e.scrollWidth-e.clientWidth),i=s.top===void 0?e.scrollTop:ta(s.top,0,l),p=s.left===void 0?e.scrollLeft:ta(s.left,0,r),u=cn.get(e);if(u!==void 0&&(window.cancelAnimationFrame(u),cn.delete(e)),a<=0||Kc()){e.scrollTo({top:i,left:p,behavior:"auto"});return}const I=e.scrollTop,S=e.scrollLeft,y=i-I,v=p-S;if(Math.abs(y)<1&&Math.abs(v)<1){e.scrollTo({top:i,left:p,behavior:"auto"});return}const k=window.performance.now(),j=$=>{const W=ta(($-k)/a,0,1),U=Wc(W);e.scrollTo({top:I+y*U,left:S+v*U,behavior:"auto"}),W<1?cn.set(e,window.requestAnimationFrame(j)):cn.delete(e)};cn.set(e,window.requestAnimationFrame(j))},Jc={class:"text-xs font-semibold"},Gc={key:0,class:"font-normal text-neutral-500 dark:text-neutral-400"},Yc={class:"flex items-center gap-2"},Qc={class:"text-neutral-500 text-xs"},Zc=at({__name:"CollapsibleSection",props:{title:{},subtitle:{},sectionId:{},expanded:{type:Boolean},scrollContainer:{},copyContent:{},stickyOffset:{}},emits:["toggle"],setup(e,{expose:s,emit:a}){const l=e,r=a,i=b(null),p=b(!1);let u=null,I=null;const S=()=>{u?.disconnect(),I?.disconnect(),u=null,I=null},y=()=>{et(()=>{if(!l.expanded||!i.value||!l.scrollContainer){p.value=!1;return}const $=l.scrollContainer.clientHeight;p.value=i.value.scrollHeight>$*2})},v=()=>{S(),!(typeof ResizeObserver>"u")&&(i.value&&(u=new ResizeObserver(y),u.observe(i.value)),l.scrollContainer&&(I=new ResizeObserver(y),I.observe(l.scrollContainer)))};xe(()=>[l.expanded,l.scrollContainer],async([$])=>{await et(),v(),$?y():p.value=!1},{immediate:!0,flush:"post"}),Et(async()=>{await et(),v(),y()}),$t(S);const k=()=>{if(i.value&&l.scrollContainer){const W=i.value.offsetTop-(l.stickyOffset??88);On(l.scrollContainer,{top:W})}},j=()=>{if(i.value&&l.scrollContainer){const $=i.value.offsetTop+i.value.offsetHeight,W=l.scrollContainer.clientHeight,U=$-W;On(l.scrollContainer,{top:U})}};return s({checkHeight:y,contentRef:i}),($,W)=>(n(),o("div",null,[t("div",{class:"collapsible-sticky-header sticky z-[5] flex h-9 w-full cursor-pointer items-center justify-between rounded border border-neutral-300 bg-neutral-50 px-3 transition-colors hover:bg-neutral-100 dark:border-neutral-700 dark:bg-neutral-950 dark:hover:bg-neutral-950",onClick:W[1]||(W[1]=U=>r("toggle"))},[t("span",Jc,[st(f(e.title)+" ",1),e.subtitle?(n(),o("span",Gc,"("+f(e.subtitle)+")",1)):m("",!0)]),t("div",Yc,[p.value&&e.expanded?(n(),o(Re,{key:0},[t("button",{onClick:Ye(k,["stop"]),class:"text-[10px] text-neutral-500 hover:text-neutral-700 dark:hover:text-neutral-300"},"↑ Top"),t("button",{onClick:Ye(j,["stop"]),class:"text-[10px] text-neutral-500 hover:text-neutral-700 dark:hover:text-neutral-300"},"↓ Bottom")],64)):m("",!0),Pt($.$slots,"actions",{},void 0,!0),e.copyContent?(n(),o("span",{key:1,class:"inline-flex",onClick:W[0]||(W[0]=Ye(()=>{},["stop"]))},[z(qn,{content:e.copyContent,variant:"ghost",size:"xs"},null,8,["content"])])):m("",!0),t("span",Qc,f(e.expanded?"▼":"▶"),1)])]),ft(t("div",{ref_key:"contentRef",ref:i,class:"border-x border-b border-neutral-300 dark:border-neutral-700 rounded-b"},[Pt($.$slots,"default",{},void 0,!0)],512),[[wt,e.expanded]])]))}}),Mt=pt(Zc,[["__scopeId","data-v-634445ea"]]),Xc={class:"flex shrink-0 items-center"},e0=["disabled"],t0=["disabled"],Or=at({__name:"LogDetailsNav",props:{hasPrevious:{type:Boolean},hasNext:{type:Boolean}},emits:["previous","next"],setup(e,{emit:s}){const a=s;return(l,r)=>(n(),o("div",Xc,[t("button",{onClick:r[0]||(r[0]=i=>a("previous")),disabled:!e.hasPrevious,class:"inline-flex h-7 w-7 items-center justify-center rounded-l border border-neutral-300 text-neutral-500 transition-colors hover:bg-neutral-100 hover:text-neutral-900 disabled:opacity-30 dark:border-neutral-700 dark:text-neutral-400 dark:hover:bg-neutral-800 dark:hover:text-neutral-100","aria-label":"Previous log",title:"Previous log"},[...r[2]||(r[2]=[t("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[t("polyline",{points:"15 18 9 12 15 6"})],-1)])],8,e0),t("button",{onClick:r[1]||(r[1]=i=>a("next")),disabled:!e.hasNext,class:"-ml-px inline-flex h-7 w-7 items-center justify-center rounded-r border border-neutral-300 text-neutral-500 transition-colors hover:bg-neutral-100 hover:text-neutral-900 disabled:opacity-30 dark:border-neutral-700 dark:text-neutral-400 dark:hover:bg-neutral-800 dark:hover:text-neutral-100","aria-label":"Next log",title:"Next log"},[...r[3]||(r[3]=[t("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[t("polyline",{points:"9 18 15 12 9 6"})],-1)])],8,t0)]))}}),n0=["width","height","aria-label"],a0=["stroke-dasharray"],na=2.5,r0=at({__name:"ContextWindowDonut",props:{pct:{},size:{default:20}},setup(e){const s=e,a=(20-na)/2,l=2*Math.PI*a,r=C(()=>Math.max(0,Math.min(100,s.pct))),i=C(()=>{const u=r.value/100*l;return`${r.value>0?Math.max(u,1.5):0} ${l}`}),p=C(()=>r.value>=90?"stroke-red-500 dark:stroke-red-400":r.value>=75?"stroke-amber-500 dark:stroke-amber-400":"stroke-blue-500 dark:stroke-blue-400");return(u,I)=>(n(),o("svg",{width:e.size,height:e.size,viewBox:"0 0 20 20",class:"shrink-0 -rotate-90",role:"img","aria-label":`${r.value}% of context window used`},[t("circle",{cx:"10",cy:"10",r:a,fill:"none","stroke-width":na,class:"stroke-neutral-200 dark:stroke-neutral-700"}),t("circle",{cx:"10",cy:"10",r:a,fill:"none","stroke-width":na,"stroke-linecap":"round","stroke-dasharray":i.value,class:K(p.value)},null,10,a0)],8,n0))}});function ma(e,s){if(!s)return e;const a=`${s}/`;return e.startsWith(a)?e.slice(a.length):e}function Wa(e,s){const a=s.model,l=s.model_name||s.model;if(!a&&!l)return null;const r=ma(l,s.provider);return e.find(i=>i.id===a)||e.find(i=>i.name===a)||e.find(i=>i.model===s.model)||e.find(i=>i.id===l)||e.find(i=>i.name===l)||e.find(i=>i.model===r)||null}function s0(e,s){if(!e||e<=0)return null;const a=s?.capabilities?.maxContextTokens;return!a||a<=0?null:{pct:Math.min(100,Math.round(e/a*100)),inputTokens:e,maxContextTokens:a}}const o0=new Set(["pending","processing","completed","failed","agent_canceled","user_canceled"]);function Ut(e,s){return typeof e=="number"&&Number.isFinite(e)?e:s}function Ka(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function l0(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function i0(e){return typeof e=="string"&&o0.has(e)?e:"pending"}function d0(e){const s=e&&typeof e=="object"?e:{},l=(Array.isArray(s.effects)?s.effects:[]).filter(r=>!!r&&typeof r=="object").filter(r=>typeof r.id=="string"&&typeof r.name=="string").map(r=>({id:r.id,name:r.name,args:l0(r.args),scheduledAt:Ut(r.scheduledAt,0),createdAt:Ut(r.createdAt,0),status:i0(r.status),attempts:Ut(r.attempts,0),error:typeof r.error=="string"?r.error:null,completedAt:Ka(r.completedAt),manualRun:r.manualRun===!0,manualRunAt:Ka(r.manualRunAt),replayedFrom:typeof r.replayedFrom=="string"?r.replayedFrom:null}));return{effects:l,total:Ut(s.total,l.length),upcomingCount:Ut(s.upcomingCount,l.filter(r=>r.status==="pending").length),limit:Ut(s.limit,l.length),offset:Ut(s.offset,0)}}function Vn(e){return!Number.isFinite(e)||e<=0?0:e>9999999999?Math.floor(e/1e3):e}function Dt(e){if(!e)return"Unknown";const s=Vn(e);return s?new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(new Date(s)):"Unknown"}function u0(e){const s=Math.abs(Math.trunc(e)),a=Math.max(1,Math.round(s/1e3));if(a<60)return`${a}s`;const l=Math.floor(a/60),r=a%60;if(l<60)return r>0?`${l}m ${r}s`:`${l}m`;const i=Math.floor(l/60),p=l%60;if(i<24)return p>0?`${i}h ${p}m`:`${i}h`;const u=Math.floor(i/24),I=i%24;return I>0?`${u}d ${I}h`:`${u}d`}function c0(e){if(!e.completedAt)return"";const s=Vn(e.scheduledAt),a=Vn(e.completedAt);if(!s||!a)return"";const l=a-s;if(l===0||Math.abs(l)<5e3)return"";const r=l>0?"+":"-",i=l>0?"late":"early";return`${r}${u0(l)} ${i}`}function f0(e,s=Date.now()){const a=Vn(e);if(!a)return"";const l=a-s;return l<=0?"Due now":l<6e4?`in ${Math.ceil(l/1e3)}s`:l<60*6e4?`in ${Math.ceil(l/6e4)}m`:l<1440*6e4?`in ${Math.ceil(l/(60*6e4))}h`:`in ${Math.ceil(l/(1440*6e4))}d`}function Ja(e){const s=JSON.stringify(e,null,2);return s===void 0?"{}":s}function p0(e){const s=Object.keys(e);if(s.length===0)return"No arguments";const a=JSON.stringify(e);return a?a.length>96?`${a.slice(0,93)}...`:a:`${s.length} ${s.length===1?"argument":"arguments"}`}function Xt(e){return e.status==="pending"||e.status==="processing"}function An(e,s){return e<s?-1:e>s?1:0}function zt(e){return typeof e=="number"&&Number.isFinite(e)?e:0}function v0(e,s){const a=Xt(e),l=Xt(s);return a!==l?a?-1:1:a&&l?An(zt(e.scheduledAt),zt(s.scheduledAt))||An(zt(e.createdAt),zt(s.createdAt))||e.id.localeCompare(s.id):An(zt(s.createdAt),zt(e.createdAt))||An(zt(s.scheduledAt),zt(e.scheduledAt))||e.id.localeCompare(s.id)}function g0(e){return[...e].sort(v0)}function Ga(e,s){return e.id===s.id}function m0(e){return`'${e.replace(/'/g,"'\\''")}'`}function h0(e,s){return e.split(/\r?\n/).some(a=>a===s)}function x0(e){const s="AGENTBUILDER_JSON";let a=s,l=2;for(;h0(e,a);)a=`${s}_${l}`,l+=1;return a}function b0(e,s){const a=x0(s),l=`${e.trim()} <<'${a}'`,r=`node -e ${m0(["let s='';","process.stdin.on('data',c=>s+=c);","process.stdin.on('end',()=>{"," const m=s.match(/\\r?\\n\\r?\\n/);"," if(!m){process.stdout.write(s);return;}"," const head=s.slice(0,m.index);"," const body=s.slice(m.index+m[0].length).trim();"," process.stdout.write(head+'\\n\\n');"," try{process.stdout.write(JSON.stringify(JSON.parse(body),null,2)+'\\n');}"," catch{process.stdout.write(body+'\\n');}","});"].join(""))}`;return[`${l} | ${r}`,s,a].join(`
11
- `)}const y0="provider:";function k0(e){return e?.toLowerCase()==="openrouter"}function _0(e){if(e.actual_provider&&k0(e.provider))return{provider:"openrouter",model:`${y0}${e.actual_provider}`};const s=e.actual_provider||e.provider;return s?{provider:s}:null}function w0(e){const s=e.provider||e.actual_provider;if(!s)return null;const a=e.model_name||e.model||void 0;return a?{provider:s,model:a}:{provider:s}}const $0={openai:"OpenAI",openrouter:"OpenRouter",xai:"xAI"};function wa(e){const s=e.trim(),a=$0[s.toLowerCase()];return a||s.replace(/[_-]+/g," ").replace(/\b\w/g,l=>l.toUpperCase())}function C0(e){return typeof e!="string"?null:/^(?:platform-router|runtime|(?:provider|tool|hook):[A-Za-z0-9._/@-]+)$/.test(e)?e:null}function Mn(e){if(!e)return null;if(e==="platform-router")return"Platform router";if(e==="runtime")return"Runtime";const s=e.indexOf(":"),a=e.slice(0,s),l=wa(e.slice(s+1));return a==="provider"?l:a==="tool"?`Tool · ${l}`:`Hook · ${l}`}function S0(e,s){if(!s)return e;if(s==="platform-router")return`Platform router error: ${e}`;if(s==="runtime")return`Runtime error: ${e}`;const a=s.indexOf(":"),l=s.slice(0,a),r=wa(s.slice(a+1));return l==="provider"?`${r} error: ${e}`:l==="tool"?`Tool error (${r}): ${e}`:`Hook error (${r}): ${e}`}function T0(e){const s=e.actual_provider||e.provider;if(!s)return e.standard_agents_router_used?"Platform router":null;const a=wa(s);return e.standard_agents_router_used?`Platform router → ${a}`:`Direct → ${a}`}function dt(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function Gt(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}function Ya(e){if(!e)return"N/A";const s=Gt(e);return s===null?e:JSON.stringify(s,null,2)}function nn(e){const s=Gt(e);return Array.isArray(s)?s:[]}function I0(e){const s=dt(Gt(e)),a=Array.isArray(s.choices)?s.choices:[],l=dt(a[0]),r=dt(l.message);return Array.isArray(r.tool_calls)?r.tool_calls:[]}function A0(e){const s=dt(Gt(e)),a=Array.isArray(s.choices)?s.choices:[],l=dt(a[0]),r=dt(l.message);return Array.isArray(r.reasoning_details)?r.reasoning_details:[]}function E0(e){const s=dt(Gt(e)),a=Array.isArray(s.choices)?s.choices:[],l=dt(a[0]),r=dt(l.message);return typeof r.content=="string"?r.content:""}function L0(e){const s=dt(Gt(e)),a=Array.isArray(s.choices)?s.choices:[],l=dt(a[0]),r=dt(l.message);return Array.isArray(r.images)?r.images:[]}function R0(e){const s=new Map,a=nn(e);for(const l of a){const r=dt(l),i=r.tool_call_id;typeof i=="string"&&s.set(i,{content:r.content,status:typeof r.status=="string"?r.status:void 0,tool_name:typeof r.tool_name=="string"?r.tool_name:void 0,timestamp:typeof r.timestamp=="number"?r.timestamp:void 0})}return s}function Qa(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function M0(e){const s=[],a=new Set,l=nn(e);for(const r of l){const i=dt(r),p=typeof i.id=="string"?i.id:null;if(!p||a.has(p))continue;const u=typeof i.name=="string"?i.name:null,I=Qa(i.scheduledAt),S=Qa(i.createdAt),y=typeof i.status=="string"?i.status:null;a.add(p),s.push({id:p,name:u,scheduledAt:I,createdAt:S,status:y,reference:{id:p,name:u}})}return s}function D0(e){const s=dt(e);return typeof s.id=="string"&&(typeof s.type=="string"||typeof s.name=="string")&&typeof s.status=="string"}function F0(e){return nn(e).filter(D0).map(s=>{const a=dt(s),l=s.name??s.type;return{...a,name:l,type:s.type??l,raw:a}})}function P0(e){const s=[];for(const a of e.toolCalls){const l=dt(a),r=dt(l.function);s.push({id:typeof l.id=="string"?l.id:`tool-${s.length}`,name:typeof r.name=="string"?r.name:"Unknown",isProvider:!1,isQueued:!1,function:{name:typeof r.name=="string"?r.name:"Unknown",arguments:typeof r.arguments=="string"?r.arguments:void 0}})}for(const a of e.queuedTools){const l=dt(a),r=dt(l.function);s.push({id:typeof l.id=="string"?l.id:`queued-${s.length}`,name:typeof r.name=="string"?r.name:"Unknown",isProvider:!1,isQueued:!0,function:{name:typeof r.name=="string"?r.name:"Unknown",arguments:typeof r.arguments=="string"?r.arguments:void 0},queuedAt:typeof l.queued_at=="number"?l.queued_at:void 0})}for(const a of e.providerToolCalls){const l=a.name??a.type;s.push({id:a.id,name:l,isProvider:!0,isQueued:!1,providerType:l,status:a.status,rawProviderTool:a.raw,result:a.result,metadata:a.metadata})}return s}function N0(e){if(e.rawProviderTool)return JSON.stringify(e.rawProviderTool,null,2);const s={id:e.id,name:e.name,type:e.providerType??e.name,status:e.status??"completed"};return e.result!==void 0&&(s.result=e.result),e.metadata!==void 0&&(s.metadata=e.metadata),JSON.stringify(s,null,2)}function z0(e){return e?e.replace(/\\n/g,`
12
- `).replace(/\\t/g," ").replace(/\n{3,}/g,`
13
-
14
- `).trim():""}function j0(e){const s=dt(Gt(e)),a=dt(s._metadata),l=dt(a.visionFiltering);if(l.enabled!==!0)return null;const r=Number(l.removedUserImageParts||0),i=Number(l.removedToolImageAttachments||0),p=r+i;return p>0?{removedUserImageParts:r,removedToolImageAttachments:i,totalRemoved:p}:null}function B0(e){return{baseten:"Baseten",cloudflare:"Cloudflare",cerebras:"Cerebras",google:"Google",groq:"Groq",openai:"OpenAI",openrouter:"OpenRouter",xai:"xAI"}[e]||e.charAt(0).toUpperCase()+e.slice(1)}const Vr=["baseten","cloudflare","cerebras","google","groq","openai","openrouter","xai"];function Hr(e){return typeof e=="string"&&Vr.includes(e)}function O0(e){const s=e?.toLowerCase();return Hr(s)?s:"standard"}const V0={class:"flex flex-col gap-2 px-3 pt-3 pb-2 sm:flex-row sm:items-start sm:justify-between"},H0={class:"flex min-w-0 flex-1 flex-wrap items-center gap-x-2 gap-y-1.5"},q0={class:"min-w-32 flex-1 basis-36 truncate text-base font-semibold text-neutral-900 dark:text-neutral-100"},U0={class:"hidden items-center gap-1 lg:flex"},W0={key:0,class:"inline-flex items-center gap-1 rounded bg-neutral-100 py-0.5 pl-1 pr-1.5 font-mono text-[10px] uppercase tracking-wide text-neutral-600 dark:bg-neutral-800 dark:text-neutral-400"},K0=["src","alt"],J0={key:1,class:"inline-flex items-center gap-1 rounded bg-neutral-100 py-0.5 pl-1 pr-1.5 font-mono text-[10px] text-neutral-600 dark:bg-neutral-800 dark:text-neutral-400"},G0=["src","alt"],Y0={class:"flex shrink-0 items-center justify-end gap-2 self-end sm:self-start"},Q0=["disabled","title"],Z0={key:1},X0={class:"flex flex-col gap-1.5 px-3 pb-2 sm:flex-row sm:items-center sm:justify-between"},ef={class:"flex min-w-0 flex-wrap items-center gap-0.5"},tf={class:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 font-mono text-[11px] text-neutral-500 tabular-nums sm:justify-end dark:text-neutral-400"},nf={class:"truncate"},af={class:"text-red-600 dark:text-red-400"},rf={class:"mb-3 grid grid-cols-2 gap-px overflow-hidden rounded-lg border border-neutral-200 bg-neutral-200 sm:grid-cols-4 dark:border-neutral-800 dark:bg-neutral-800"},sf={class:"flex flex-col gap-0.5 bg-white px-3 py-2 dark:bg-neutral-900"},of={class:"flex min-h-5 items-center gap-1.5 text-[10px] font-medium uppercase tracking-wide text-neutral-500 dark:text-neutral-400"},lf={class:"font-mono text-base font-semibold tabular-nums text-neutral-900 dark:text-neutral-100"},df={key:1},uf={key:0,class:"text-[10px] font-normal text-neutral-400"},cf={key:0,class:"font-mono text-[10px] tabular-nums text-neutral-500 dark:text-neutral-400"},ff={key:1,class:"font-mono text-[10px] tabular-nums text-neutral-400 dark:text-neutral-500"},pf={class:"flex flex-col gap-0.5 bg-white px-3 py-2 dark:bg-neutral-900"},vf={class:"flex min-h-5 items-center gap-1.5 text-[10px] font-medium uppercase tracking-wide text-neutral-500 dark:text-neutral-400"},gf={class:"font-mono text-base font-semibold tabular-nums text-neutral-900 dark:text-neutral-100"},mf={key:1},hf={key:0,class:"font-mono text-[10px] tabular-nums text-neutral-500 dark:text-neutral-400"},xf={key:1,class:"font-mono text-[10px] tabular-nums text-neutral-500 dark:text-neutral-400"},bf={class:"flex flex-col gap-0.5 bg-white px-3 py-2 dark:bg-neutral-900"},yf={class:"flex min-h-5 items-center gap-1.5 text-[10px] font-medium uppercase tracking-wide text-neutral-500 dark:text-neutral-400"},kf={class:"font-mono text-base font-semibold tabular-nums text-neutral-900 dark:text-neutral-100"},_f={key:1},wf={key:0,class:"font-mono text-[10px] tabular-nums text-neutral-500 dark:text-neutral-400"},$f={class:"flex flex-col gap-0.5 bg-white px-3 py-2 dark:bg-neutral-900"},Cf={class:"flex min-h-5 items-center gap-1.5 text-[10px] font-medium uppercase tracking-wide text-neutral-500 dark:text-neutral-400"},Sf={class:"font-mono text-base font-semibold tabular-nums text-neutral-900 dark:text-neutral-100"},Tf={key:0},If={key:1},Af={key:0,class:"font-mono text-[10px] tabular-nums text-neutral-500 dark:text-neutral-400"},Ef={key:0,class:"mb-3 border border-neutral-200 bg-white px-3 py-2 text-xs dark:border-neutral-800 dark:bg-neutral-900"},Lf={class:"flex flex-wrap items-center gap-x-2 gap-y-1"},Rf={key:0,class:"font-mono text-neutral-700 dark:text-neutral-200"},Mf={key:1,class:"truncate font-mono text-[11px] text-neutral-400"},Df={key:1,class:"mb-3 border border-neutral-200 bg-white px-3 py-2 text-xs dark:border-neutral-800 dark:bg-neutral-900"},Ff={class:"mb-2 flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wide text-neutral-500 dark:text-neutral-400"},Pf={class:"space-y-1.5"},Nf=["onClick"],zf={class:"flex min-w-0 items-baseline gap-2"},jf={class:"min-w-0 truncate font-mono text-xs font-medium text-neutral-800 dark:text-neutral-100"},Bf={class:"truncate font-mono text-[11px] text-neutral-400"},Of={class:"mt-1 flex min-w-0 flex-wrap gap-x-3 gap-y-1 text-[11px] text-neutral-500 dark:text-neutral-400"},Vf={key:0},Hf={key:1,class:"min-w-0 truncate"},qf={key:2,class:"min-w-0 truncate"},Uf={key:2,class:"mb-3 overflow-hidden rounded-lg border border-red-300 bg-red-50 dark:border-red-800 dark:bg-red-950/30"},Wf={class:"flex items-start justify-between gap-3 border-b border-red-200 px-3 py-2 dark:border-red-900"},Kf={class:"min-w-0"},Jf={class:"text-[10px] font-semibold uppercase tracking-wide text-red-700 dark:text-red-300"},Gf={class:"flex min-w-0 flex-wrap items-center gap-1.5"},Yf={class:"truncate text-sm font-semibold text-red-900 dark:text-red-100"},Qf={key:0,class:"inline-flex rounded-full border border-red-300 bg-white px-2 py-0.5 font-mono text-[10px] font-semibold text-red-800 dark:border-red-700 dark:bg-red-950 dark:text-red-200"},Zf={key:1,class:"inline-flex rounded-full bg-red-100 px-2 py-0.5 font-mono text-[10px] text-red-700 dark:bg-red-900/50 dark:text-red-300"},Xf={key:0,class:"whitespace-pre-wrap break-words bg-white px-3 py-2 text-sm leading-relaxed text-red-900 dark:bg-black/30 dark:text-red-100"},ep={key:1,class:"border-t border-red-200 bg-white px-3 py-2 dark:border-red-900 dark:bg-black/30"},tp=["href"],np={key:2,class:"border-t border-red-200 dark:border-red-900"},ap={class:"bg-white dark:bg-black/30"},rp={key:1,class:"m-0 max-h-[400px] overflow-auto whitespace-pre-wrap break-words px-3 py-2 font-mono text-[11px] leading-relaxed text-red-900 dark:text-red-100"},sp={key:3,class:"border-t border-red-200 dark:border-red-900"},op={class:"cursor-pointer px-3 py-2 text-xs font-medium text-red-800 hover:bg-red-100/70 dark:text-red-200 dark:hover:bg-red-900/30"},lp={key:0,class:"ml-1 font-mono text-[10px] opacity-80"},ip={key:0,class:"whitespace-pre-wrap break-words bg-white px-3 py-2 text-sm leading-relaxed text-red-900 dark:bg-black/30 dark:text-red-100"},dp={key:1,class:"border-t border-red-200 dark:border-red-900"},up={class:"bg-white dark:bg-black/30"},cp={key:1,class:"m-0 max-h-[400px] overflow-auto whitespace-pre-wrap break-words px-3 py-2 font-mono text-[11px] leading-relaxed text-red-900 dark:text-red-100"},fp={class:"log-details-tabs sticky top-[var(--logdetails-tabs-top)] z-10 -mx-3 mb-3 flex h-10 items-center gap-1 border-b border-neutral-200 bg-white/95 px-3 backdrop-blur dark:border-neutral-800 dark:bg-neutral-900/95"},pp={class:"space-y-2"},vp={class:"mb-2 flex flex-wrap items-center gap-2"},gp=["value"],mp={key:1,class:"text-xs text-red-600 dark:text-red-400"},hp={key:0,class:"mb-2 rounded border border-amber-300 dark:border-amber-700 bg-amber-50 dark:bg-amber-950/30 p-2"},xp={class:"mt-1 text-xs text-amber-700 dark:text-amber-300"},bp=["onClick"],yp={class:"font-mono"},kp={class:"text-neutral-500"},_p={class:"px-2 py-2 bg-white dark:bg-neutral-950 border-t border-neutral-200 dark:border-neutral-800"},wp={key:0,class:"text-xs text-neutral-600 dark:text-neutral-400 mb-2"},$p={class:"bg-white dark:bg-neutral-900"},Cp={class:"space-y-2"},Sp={key:0,class:"overflow-hidden rounded-md border border-amber-200 bg-amber-50/40 dark:border-amber-900/40 dark:bg-amber-950/20"},Tp={class:"m-0 max-h-[280px] overflow-auto whitespace-pre-wrap break-words px-3 py-2 font-mono text-xs leading-relaxed text-amber-900/90 dark:text-amber-200/80"},Ip={key:1,class:"overflow-hidden rounded-md border border-neutral-200 dark:border-neutral-800"},Ap={class:"flex items-center gap-1.5 border-b border-neutral-200 px-3 py-1.5 text-[10px] font-medium uppercase tracking-wide text-neutral-500 dark:border-neutral-800 dark:text-neutral-400"},Ep={key:0,class:"log-details-pulse text-emerald-500"},Lp={class:"m-0 max-h-[480px] overflow-auto whitespace-pre-wrap break-words bg-white px-3 py-2 font-mono text-xs leading-relaxed text-neutral-800 dark:bg-neutral-950 dark:text-neutral-200"},Rp={class:"divide-y divide-neutral-200 bg-white dark:divide-neutral-800 dark:bg-neutral-950"},Mp=["onClick"],Dp={class:"flex min-w-0 items-center gap-2"},Fp={class:"truncate font-mono text-xs font-semibold text-neutral-900 dark:text-neutral-100"},Pp={class:"font-mono text-[10px] text-neutral-400 dark:text-neutral-500"},Np={class:"flex shrink-0 items-center gap-2"},zp={key:0,class:"rounded bg-emerald-100 px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-emerald-700 dark:bg-emerald-900/40 dark:text-emerald-300",title:"Programmatically called with state.queueTool()"},jp={class:"text-[10px] text-neutral-400 dark:text-neutral-500"},Bp={class:"@container border-t border-neutral-200 bg-neutral-50/40 dark:border-neutral-800 dark:bg-neutral-950/40"},Op={key:0,class:"grid grid-cols-1 @[640px]:grid-cols-2 @[640px]:divide-x divide-neutral-200 dark:divide-neutral-800"},Vp={class:"px-3 py-2"},Hp={class:"mb-1 flex items-center gap-2 text-[10px] font-medium uppercase tracking-wide text-neutral-500 dark:text-neutral-400"},qp={key:0,class:"font-mono normal-case tracking-normal text-emerald-600 dark:text-emerald-400"},Up={class:"border-t border-neutral-200 px-3 py-2 @[640px]:border-t-0 dark:border-neutral-800"},Wp={key:0,class:"m-0 max-h-[400px] overflow-auto whitespace-pre-wrap break-words font-mono text-[11px] leading-relaxed text-neutral-800 dark:text-neutral-200"},Kp={key:1,class:"font-mono text-[11px] italic text-neutral-400 dark:text-neutral-500"},Jp={key:1,class:"px-3 py-2"},Gp={class:"flex flex-wrap gap-2 bg-white px-3 py-2 dark:bg-neutral-950"},Yp=["src","alt"],Qp={key:1,class:"flex h-[100px] w-[100px] items-center justify-center rounded-md bg-neutral-100 text-xs text-neutral-500 dark:bg-neutral-900 dark:text-neutral-400"},Zp={class:"m-0 max-h-[480px] overflow-auto whitespace-pre-wrap break-words bg-white px-3 py-2 font-mono text-xs leading-relaxed text-neutral-800 dark:bg-neutral-950 dark:text-neutral-200"},Xp={class:"divide-y divide-neutral-200 bg-white dark:divide-neutral-800 dark:bg-neutral-950"},ev={class:"mb-1.5 flex flex-wrap items-center gap-1.5 text-[10px]"},tv={class:"rounded bg-purple-100 px-1.5 py-0.5 font-mono font-medium uppercase tracking-wide text-purple-700 dark:bg-purple-900/40 dark:text-purple-300"},nv={key:0,class:"font-mono text-neutral-500 dark:text-neutral-400"},av={key:1,class:"text-neutral-500 dark:text-neutral-400"},rv={key:2,class:"text-neutral-500 dark:text-neutral-400"},sv={key:0,class:"whitespace-pre-wrap break-words font-mono text-xs leading-relaxed text-neutral-800 dark:text-neutral-200"},ov={class:"whitespace-pre-wrap break-words font-mono text-xs leading-relaxed text-neutral-800 dark:text-neutral-200"},lv={key:0,class:"mt-2 border-t border-neutral-200 pt-2 dark:border-neutral-800"},iv={class:"break-all font-mono text-[11px] text-neutral-700 dark:text-neutral-300"},dv={key:2,class:"break-all font-mono text-[11px] text-neutral-700 dark:text-neutral-300"},uv={key:3,class:"m-0 overflow-x-auto whitespace-pre-wrap break-words font-mono text-[11px] leading-relaxed text-neutral-700 dark:text-neutral-300"},Qt="inline-flex h-6 w-6 items-center justify-center rounded text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-900 dark:text-neutral-500 dark:hover:bg-neutral-800 dark:hover:text-neutral-100",cv=12,fv=40,pv=36,vv=8,Za="__agentbuilder_system_prompt_view__",gv=at({__name:"LogDetails",props:{log:{},threadId:{},hasPrevious:{type:Boolean},hasNext:{type:Boolean}},emits:["close","previous","next","effectClick"],setup(e,{emit:s}){const a=e,l=s,r=b("response"),i=b(new Set),p=b(new Set),{copying:u,copied:I,error:S,copy:y}=ro(),{activeSurface:v,openEditSurface:k}=Ws(),j=b(null),$=b(null),W=b(null),U=b(null),Y=b(null),ue=b(null),ae=b(null),oe=b(null),ve=b(60),ee=b(100);let G=null;const R=()=>{const T=W.value?.offsetHeight;if(!T)return;const w=Math.max(0,Math.round(T-cv));ve.value=w,ee.value=w+fv},H=()=>{G?.disconnect(),G=null,!(!W.value||typeof ResizeObserver>"u")&&(G=new ResizeObserver(R),G.observe(W.value))};Et(async()=>{await et(),R(),H()}),$t(()=>{G?.disconnect(),G=null});const D=b(new Set(["system_prompt","request_body","tools","reasoning_content","reasoning_details"])),X=(T,w)=>T instanceof Error?T.message:w,Se=T=>a.threadId?T.startsWith("data:")||T.startsWith("http")?T:Ze(`/api/threads/${a.threadId}/fs${T}`):null,ne=C(()=>nn(a.log.tools_schema)),Le=C(()=>I0(a.log.response_body)),B=C(()=>R0(a.log.tool_results)),re=C(()=>A0(a.log.response_body)),Ce=C(()=>z0(a.log.reasoning_content)),ze=C(()=>L0(a.log.response_body)),Ve=C(()=>!a.log.is_complete),Te=C(()=>a.log.is_complete?E0(a.log.response_body)||a.log.content||"":a.log.content??""),le=C(()=>F0(a.log.provider_tools)),we=C(()=>nn(a.log.queued_tools)),ce=C(()=>P0({toolCalls:Le.value,queuedTools:we.value,providerToolCalls:le.value})),te=T=>{i.value.has(T)?i.value.delete(T):i.value.add(T)},ie=T=>{p.value.has(T)?p.value.delete(T):p.value.add(T)},me=T=>{D.value.has(T)?D.value.delete(T):D.value.add(T)},Q=T=>!D.value.has(T),Me=C(()=>nn(a.log.errors)),Ne=C(()=>{const T=Me.value.map(w=>{if(typeof w=="string")return{type:a.log.error_type||"error",origin:a.log.error_origin??null,message:w};if(!w||typeof w!="object")return{type:a.log.error_type||"error",origin:a.log.error_origin??null,message:String(w??"")};const M=w;return{type:typeof M.type=="string"?M.type:a.log.error_type||"error",origin:C0(M.origin)??a.log.error_origin??null,message:typeof M.message=="string"?M.message:JSON.stringify(M)}}).filter(w=>w.message);return T.length>0?T:a.log.error?[{type:a.log.error_type||"error",origin:a.log.error_origin??null,message:a.log.error}]:[]}),Ue=T=>/\\[nrt"\\]/.test(T),We=T=>{const w="__AGENTBUILDER_ESCAPED_BACKSLASH__";return T.replace(/\\\\/g,w).replace(/\\n/g,`
15
- `).replace(/\\r/g,"\r").replace(/\\t/g," ").replace(/\\"/g,'"').replace(new RegExp(w,"g"),"\\")},E=T=>{const w=T.trim();if(!w.startsWith("{")&&!w.startsWith("["))return null;const M=w[0],Oe=M==="{"?"}":"]";let it=0,_t=!1,St=!1;for(let xt=0;xt<w.length;xt++){const Nt=w[xt];if(St){St=!1;continue}if(_t){Nt==="\\"?St=!0:Nt==='"'&&(_t=!1);continue}if(Nt==='"'){_t=!0;continue}if(Nt===M)it++;else if(Nt===Oe&&(it--,it===0)){const qt=w.slice(0,xt+1);try{return{value:JSON.parse(qt),rest:w.slice(xt+1)}}catch{return null}}}return null},fe=T=>{const w=T.indexOf(`
16
-
17
- Stack trace:`),M=T.indexOf(`
18
-
19
- Error Details:`);let Oe=T.length;return w>=0&&(Oe=Math.min(Oe,w)),M>=0&&(Oe=Math.min(Oe,M)),T.slice(0,Oe)},be=T=>{let w=fe(T).trim(),M=!1;for(let St=0;St<5&&!(!w.startsWith("{")&&!w.startsWith("["));St++){const xt=E(w);if(!xt||typeof xt.value!="object"||xt.value===null)break;const Nt=xt.value,qt=Nt.error,Kn=typeof qt=="object"&&qt!==null?qt.message:typeof qt=="string"?qt:Nt.message;if(typeof Kn!="string"||Kn.trim().length===0)break;M=!0,w=Kn.trim()}if(M)return w;const Oe=Ue(T)?We(T):T,it=fe(Oe).trim(),_t=it.split(`
20
- `).find(St=>St.trim().length>0);return _t&&_t.length<600?_t.trim():it},Pe=T=>{if(!T)return{isJson:!1,text:""};const w=T.trim();if(w.startsWith("{")||w.startsWith("["))try{const Oe=JSON.parse(w);if(Oe&&typeof Oe=="object")return{isJson:!0,text:JSON.stringify(Oe,null,2)}}catch{}return{isJson:!1,text:Ue(T)?We(T):T}},J=C(()=>Ne.value.map(T=>{const w=be(T.message),M=S0(w,T.origin),Oe=Pe(T.message),it=Oe.text.trim().length>0&&Oe.text.trim()!==w.trim();return{...T,originLabel:Mn(T.origin),human:M,details:Oe,hasMoreDetails:it}})),ke=C(()=>{const T=J.value[0]?.origin;return T&&T!=="platform-router"&&!T.startsWith("provider:")?null:T0(a.log)}),ye=C(()=>{for(const T of J.value){const w=Br(T.message);if(w)return w}return null}),Ae=b("standard"),V=b(null),$e=b(!1),pe=b(null);let Fe=0;const tt=Vr,Qe=()=>{Ae.value=O0(a.log.provider)},lt=async(T,w)=>{const M=++Fe;if(T==="standard"){V.value=null,pe.value=null,$e.value=!1;return}if(!a.threadId||!w){pe.value="Missing thread or log ID",$e.value=!1;return}$e.value=!0,pe.value=null;try{const Oe=await fetch(Ze(`/api/threads/${a.threadId}/logs/${w}/inspect/${T}`));if(!Oe.ok){const it=await Oe.json();throw new Error(it.error||"Failed to inspect")}if(M!==Fe)return;V.value=await Oe.json()}catch(Oe){if(M!==Fe)return;pe.value=X(Oe,"Failed to fetch inspected request"),V.value=null}finally{M===Fe&&($e.value=!1)}};xe(()=>a.log.id,Qe,{immediate:!0}),xe([()=>a.log.id,Ae],async([T,w])=>{V.value=null,pe.value=null,await lt(w,T)},{immediate:!0}),xe(r,async()=>{await et();const T=$.value,w=U.value;if(!T||!w)return;const M=T.getBoundingClientRect(),Oe=w.getBoundingClientRect(),it=T.scrollTop+(Oe.top-M.top)-ee.value;T.scrollTop>it&&On(T,{top:it})});const he=C(()=>{if(Ae.value==="standard"||!V.value)return a.log.message_history;const{body:T,messagesPath:w}=V.value,M=w&&T?T[w]:T;return JSON.stringify(M,null,2)}),O=T=>{if(!T)return null;try{return JSON.parse(T)}catch{return T}},se=T=>!!T&&typeof T=="object"&&!Array.isArray(T),He=C(()=>{const T=O(a.log.source_message_metadata);return se(T)?T:null}),de=C(()=>{const T=He.value;if(!T)return null;const w=T.scheduledEffect;if(!se(w))return null;const M=typeof w.id=="string"?w.id:null,Oe=typeof w.name=="string"?w.name:null;return M?{id:M,name:Oe,reference:{id:M,name:Oe}}:null}),L=C(()=>M0(a.log.scheduled_effects)),ge=C(()=>{const T=O(he.value);return Array.isArray(T)?T.filter(w=>!!w&&typeof w=="object").map(w=>({role:typeof w.role=="string"?w.role:"message",raw:w})):[]}),je=T=>T.role==="system"&&typeof T.raw.content=="string"&&typeof a.log.system_prompt=="string"&&T.raw.content.trim()===a.log.system_prompt.trim(),Je=C(()=>ge.value.some(T=>je(T))),qe=C(()=>ge.value.length===0?he.value:ge.value.map(T=>{const w={...T.raw};return je(T)&&(w.content=`[${Za}]`),w})),P=C(()=>{const T=[];return Je.value&&T.push({token:Za,label:"view system prompt",action:"view-system-prompt"}),T}),q=T=>{T.action==="view-system-prompt"&&Ie()},Ie=async()=>{D.value.has("system_prompt")&&(D.value.delete("system_prompt"),D.value=new Set(D.value)),await et();const T=$.value,w=ae.value?.contentRef;!T||!w||On(T,{top:w.offsetTop-ee.value-pv-vv})},_e=C(()=>Ae.value==="standard"||!V.value?a.log.request_body:JSON.stringify(V.value.body,null,2)),Ge=C(()=>Ae.value==="standard"||!V.value?null:`${Ae.value} format`),A=C(()=>j0(a.log.request_body));xe(()=>a.log,()=>{et(()=>{R(),Y.value?.checkHeight(),ue.value?.checkHeight(),ae.value?.checkHeight(),oe.value?.checkHeight()})});const d=C(()=>a.log.error_type==="user_interrupted"||!a.log.error_type&&/interrupted by user|stopped by user/i.test(a.log.error??"")?{kind:"stopped",label:"Stopped",dot:"bg-neutral-400 dark:bg-neutral-500",text:"text-neutral-600 dark:text-neutral-300"}:a.log.error||Ne.value.length>0?{kind:"error",label:"Failed",dot:"bg-red-500",text:"text-red-700 dark:text-red-300"}:a.log.is_complete?{kind:"success",label:"Success",dot:"bg-emerald-500",text:"text-emerald-700 dark:text-emerald-300"}:{kind:"live",label:"Live",dot:"bg-amber-500",text:"text-amber-700 dark:text-amber-300"}),h=T=>T==null?null:T.toLocaleString("en-US"),F=T=>T==null?null:`${T.toLocaleString("en-US")} ms`,Ee=T=>T==null?null:`$${T.toFixed(6)}`,ot=C(()=>{const T=a.log.total_tokens;return!(T==null||T===0&&(a.log.error||Ne.value.length>0))}),vt=C(()=>{const T=a.log.cost_total;return!(T==null||T===0&&(a.log.error||Ne.value.length>0))}),gt=C(()=>ot.value?a.log.total_tokens.toLocaleString("en-US"):null),ut=C(()=>{if(!ot.value)return null;const T=a.log.input_tokens??0,w=a.log.output_tokens??0;return`${T.toLocaleString()} in → ${w.toLocaleString()} out`}),Yt=C(()=>{if(!ot.value)return null;const T=[],w=a.log.reasoning_tokens;w&&w>0&&T.push(`${w.toLocaleString()} reasoning`);const M=a.log.cached_tokens,Oe=a.log.input_tokens;if(M&&M>0)if(Oe&&Oe>0){const it=Math.round(M/Oe*100);T.push(`${M.toLocaleString()} cached (${it}%)`)}else T.push(`${M.toLocaleString()} cached`);return T.length>0?T.join(" · "):null}),_n=C(()=>{if(!vt.value)return null;const T=a.log.cost_input,w=a.log.cost_cached,M=a.log.cost_output;if(T==null||M==null)return null;const Oe=[`$${T.toFixed(6)} in`];w!=null&&Oe.push(`$${w.toFixed(6)} cached`),Oe.push(`$${M.toFixed(6)} out`);const it=a.log.cost_router_fee;if(it!=null&&it>0){const _t=a.log.router_fee_percent;Oe.push(_t?`$${it.toFixed(6)} router fee (${_t}%)`:`$${it.toFixed(6)} router fee`)}return Oe.join(" · ")}),rn=C(()=>F(a.log.time_to_first_token_ms)),wn=C(()=>{const T=a.log.generation_ms,w=a.log.output_tokens;if(!T||T<=0||w==null||w<=0)return null;const M=w/(T/1e3);return`${M>=10?Math.round(M):M.toFixed(1)} tok/s`}),$n=C(()=>F(a.log.latency_ms)),sn=T=>T?T.length>10?`${T.slice(0,8)}…`:T:"",g=C(()=>{const T=_0(a.log);if(!T)return null;const w=T.model?`?model=${encodeURIComponent(T.model)}`:"";return Ze(`/api/providers/${encodeURIComponent(T.provider)}/icon${w}`)}),x=C(()=>{const T=w0(a.log);return T?.model?Ze(`/api/providers/${encodeURIComponent(T.provider)}/icon?model=${encodeURIComponent(T.model)}`):null}),_=(T,w,M)=>{if(!a.log.prompt_name)return;const Oe=w.currentTarget;Oe instanceof HTMLElement&&k({target:{entityType:"prompt",entityId:a.log.prompt_name,section:T,defaultToolTab:M},anchorEl:Oe,threadId:a.threadId??null,showGlobalNotice:!0})},De=(T,w)=>a.log.prompt_name?Ks(v.value?.target,{entityType:"prompt",entityId:a.log.prompt_name,section:T,defaultToolTab:w}):!1,Z=async()=>{if(j.value)return j.value;const T=await fetch(Ze("/api/models"));if(!T.ok)return[];const w=await T.json();return j.value=w.models||[],j.value};Et(()=>{Z().catch(()=>{})});const Xe=C(()=>{const T=j.value;return T?s0(a.log.input_tokens,Wa(T,a.log)):null}),yt=C(()=>{const T=Xe.value;return T?`${T.pct}% of context window — ${T.inputTokens.toLocaleString("en-US")} of ${T.maxContextTokens.toLocaleString("en-US")} tokens`:""}),kt=async T=>{const w=T.currentTarget;if(!(w instanceof HTMLElement))return;const M=a.log.model,Oe=a.log.model_name||a.log.model;if(!M&&!Oe)return;const it=a.log.provider,_t=ma(Oe,it),St=await Z(),xt=Wa(St,a.log);k({target:{entityType:"model",entityId:xt?.id||xt?.name||M||Oe},anchorEl:w,editData:xt||{id:M||Oe,name:M||Oe,model:_t,provider:it,provider_id:it},threadId:a.threadId??null,showGlobalNotice:!0})},on=()=>{const T=v.value?.target;if(T?.entityType!=="model")return!1;const w=ma(a.log.model_name||a.log.model,a.log.provider);return[a.log.model,a.log.model_name,w].includes(T.entityId)},Ct=()=>a.log.provider?.toLowerCase(),Cn=async()=>{const T=Ct();if(!a.threadId||!a.log.id||!T||!Hr(T))return null;try{const w=await fetch(Ze(`/api/threads/${a.threadId}/logs/${a.log.id}/inspect/${T}`));return w.ok?await w.json():null}catch{return null}},Wn=async()=>{try{if(!a.log.request_body||!a.log.model)throw new Error("Missing request data");const T=await fetch(Ze(`/api/models/${encodeURIComponent(a.log.model)}/curl-data`));if(!T.ok)throw new Error("Failed to fetch model data");const w=await T.json(),M=await Cn(),Oe=M?.body?JSON.stringify(M.body,null,2):Ya(a.log.request_body);await y(b0(w.curl,Oe))}catch(T){S.value=`Failed to copy cURL: ${X(T,"Unknown error")}`}};return(T,w)=>(n(),o("div",{ref_key:"scrollContainer",ref:$,class:"log-details-root h-full overflow-y-auto bg-white p-3 dark:bg-neutral-900",style:bt({"--logdetails-tabs-top":`${ve.value}px`,"--logdetails-sticky-stack":`${ee.value}px`})},[t("div",{ref_key:"stickyHeaderRef",ref:W,class:"log-details-sticky-header sticky -top-3 z-20 -mx-3 -mt-3 mb-3 overflow-hidden rounded-t-lg border-b border-neutral-200 bg-white/95 backdrop-blur dark:border-neutral-800 dark:bg-neutral-900/95"},[t("div",V0,[t("div",H0,[z(Or,{"has-previous":e.hasPrevious,"has-next":e.hasNext,onPrevious:w[0]||(w[0]=M=>l("previous")),onNext:w[1]||(w[1]=M=>l("next"))},null,8,["has-previous","has-next"]),t("span",{class:K(["inline-flex shrink-0 items-center gap-1.5 rounded-full border border-neutral-200 bg-white px-2 py-0.5 text-[11px] font-medium dark:border-neutral-800 dark:bg-neutral-950",d.value.text])},[t("span",{class:K(["inline-block h-1.5 w-1.5 rounded-full",[d.value.dot,d.value.kind==="live"?"log-details-pulse":""]])},null,2),st(" "+f(d.value.label),1)],2),t("h3",q0,f(e.log.prompt_name||e.log.model_name||e.log.model),1),t("div",U0,[e.log.actual_provider||e.log.provider?(n(),o("span",W0,[g.value?(n(),o("img",{key:0,src:g.value,alt:e.log.actual_provider||e.log.provider||"provider",class:"h-3 w-3 shrink-0 rounded-[2px] object-contain"},null,8,K0)):m("",!0),t("span",null,f(e.log.actual_provider||e.log.provider),1)])):m("",!0),e.log.model_name||e.log.model?(n(),o("span",J0,[x.value?(n(),o("img",{key:0,src:x.value,alt:e.log.model_name||e.log.model||"model",class:"h-3 w-3 shrink-0 rounded-[2px] object-contain"},null,8,G0)):m("",!0),t("span",null,f(e.log.model_name||e.log.model),1),z(c(Lt),{content:"Model config",position:"bottom",disabled:on()},{default:Be(()=>[t("button",{type:"button",class:"-mr-0.5 inline-flex h-4 w-4 items-center justify-center rounded text-neutral-400 transition-colors hover:text-neutral-900 dark:text-neutral-500 dark:hover:text-neutral-100","aria-label":"Edit model config",onClick:w[2]||(w[2]=Ye(M=>kt(M),["stop"]))},[z(c(Nn),{size:12})])]),_:1},8,["disabled"])])):m("",!0)])]),t("div",Y0,[t("button",{onClick:Wn,disabled:c(u)||!e.log.request_body,class:"rounded bg-neutral-900 px-3 py-1 text-xs font-medium text-white transition-opacity hover:opacity-80 disabled:cursor-not-allowed disabled:opacity-50 dark:bg-neutral-100 dark:text-neutral-900",title:c(S)||(e.log.request_body?"Copy cURL command":"No request data available")},[c(u)?(n(),N(nt,{key:0,size:"xs"})):(n(),o("span",Z0,f(c(I)?"Copied!":"Copy cURL"),1))],8,Q0),t("button",{onClick:w[3]||(w[3]=M=>l("close")),class:"inline-flex h-7 w-7 items-center justify-center rounded border border-neutral-300 text-neutral-500 transition-colors hover:bg-neutral-100 hover:text-neutral-900 dark:border-neutral-700 dark:text-neutral-400 dark:hover:bg-neutral-800 dark:hover:text-neutral-100","aria-label":"Close details",title:"Close"},[...w[23]||(w[23]=[t("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[t("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t("line",{x1:"6",y1:"6",x2:"18",y2:"18"})],-1)])])])]),t("div",X0,[t("div",ef,[e.log.prompt_name?(n(),N(c(Lt),{key:0,content:"Prompt basics",position:"bottom",disabled:De("basic")},{default:Be(()=>[t("button",{type:"button",class:K(Qt),"aria-label":"Edit prompt basics",onClick:w[4]||(w[4]=Ye(M=>_("basic",M),["stop"]))},[z(c(gr),{size:14})])]),_:1},8,["disabled"])):m("",!0),e.log.prompt_name?(n(),N(c(Lt),{key:1,content:"Prompt text",position:"bottom",disabled:De("prompt")},{default:Be(()=>[t("button",{type:"button",class:K(Qt),"aria-label":"Edit prompt text",onClick:w[5]||(w[5]=Ye(M=>_("prompt",M),["stop"]))},[z(c(xn),{size:14})])]),_:1},8,["disabled"])):m("",!0),e.log.prompt_name?(n(),N(c(Lt),{key:2,content:"Prompt config",position:"bottom",disabled:De("behavior")},{default:Be(()=>[t("button",{type:"button",class:K(Qt),"aria-label":"Edit prompt config",onClick:w[6]||(w[6]=Ye(M=>_("behavior",M),["stop"]))},[z(c(mr),{size:14})])]),_:1},8,["disabled"])):m("",!0),e.log.prompt_name?(n(),N(c(Lt),{key:3,content:"Prompt input schema",position:"bottom",disabled:De("schema")},{default:Be(()=>[t("button",{type:"button",class:K(Qt),"aria-label":"Edit input schema",onClick:w[7]||(w[7]=Ye(M=>_("schema",M),["stop"]))},[z(c(cs),{size:14})])]),_:1},8,["disabled"])):m("",!0),e.log.prompt_name?(n(),N(c(Lt),{key:4,content:"Prompt variables",position:"bottom",disabled:De("variables")},{default:Be(()=>[t("button",{type:"button",class:K(Qt),"aria-label":"Edit prompt variables",onClick:w[8]||(w[8]=Ye(M=>_("variables",M),["stop"]))},[z(c(fs),{size:14})])]),_:1},8,["disabled"])):m("",!0),e.log.prompt_name?(n(),N(c(Lt),{key:5,content:"Prompt tools",position:"bottom",disabled:De("tools","functions")},{default:Be(()=>[t("button",{type:"button",class:K(Qt),"aria-label":"Edit prompt tools",onClick:w[9]||(w[9]=Ye(M=>_("tools",M,"functions"),["stop"]))},[z(c(hr),{size:14})])]),_:1},8,["disabled"])):m("",!0)]),t("div",tf,[z(an,{timestamp:e.log.created_at},null,8,["timestamp"]),e.log.finish_reason?(n(),o(Re,{key:0},[w[24]||(w[24]=t("span",{"aria-hidden":"true",class:"text-neutral-300 dark:text-neutral-700"},"·",-1)),t("span",null,"finish: "+f(e.log.finish_reason),1)],64)):m("",!0),e.log.id?(n(),o(Re,{key:1},[w[25]||(w[25]=t("span",{"aria-hidden":"true",class:"text-neutral-300 dark:text-neutral-700"},"·",-1)),t("span",nf,"log "+f(sn(e.log.id)),1)],64)):m("",!0),c(S)?(n(),o(Re,{key:2},[w[26]||(w[26]=t("span",{"aria-hidden":"true",class:"text-neutral-300 dark:text-neutral-700"},"·",-1)),t("span",af,f(c(S)),1)],64)):m("",!0)])])],512),t("div",rf,[t("div",sf,[t("div",of,[z(c(xr),{size:11,"stroke-width":2.25}),w[27]||(w[27]=t("span",null,"Performance",-1))]),t("div",lf,[!e.log.is_complete&&!e.log.time_to_first_token_ms?(n(),N(nt,{key:0,size:"xs"})):(n(),o("span",df,[st(f(rn.value??"—"),1),rn.value?(n(),o("span",uf," latency")):m("",!0)]))]),wn.value?(n(),o("div",cf,f(wn.value),1)):m("",!0),$n.value?(n(),o("div",ff,f($n.value)+" total ",1)):m("",!0)]),t("div",pf,[t("div",vf,[Xe.value?(n(),N(c(Lt),{key:0,content:yt.value},{default:Be(()=>[z(r0,{pct:Xe.value.pct},null,8,["pct"])]),_:1},8,["content"])):(n(),N(c(ps),{key:1,size:11,"stroke-width":2.25})),w[28]||(w[28]=t("span",null,"Tokens",-1))]),t("div",gf,[!e.log.is_complete&&!ot.value?(n(),N(nt,{key:0,size:"xs"})):(n(),o("span",mf,f(gt.value??"—"),1))]),ut.value?(n(),o("div",hf,f(ut.value),1)):m("",!0),Yt.value?(n(),o("div",xf,f(Yt.value),1)):m("",!0)]),t("div",bf,[t("div",yf,[z(c(br),{size:11,"stroke-width":2.25}),w[29]||(w[29]=t("span",null,"Cost",-1))]),t("div",kf,[!e.log.is_complete&&!vt.value?(n(),N(nt,{key:0,size:"xs"})):(n(),o("span",_f,f(vt.value?Ee(e.log.cost_total):"—"),1))]),_n.value?(n(),o("div",wf,f(_n.value),1)):m("",!0)]),t("div",$f,[t("div",Cf,[z(c(vs),{size:11,"stroke-width":2.25}),w[30]||(w[30]=t("span",null,"Context",-1))]),t("div",Sf,[e.log.message_history_length!==null&&e.log.message_history_length!==void 0?(n(),o("span",Tf,f(h(e.log.message_history_length))+" msg ",1)):(n(),o("span",If,"—"))]),ne.value.length>0?(n(),o("div",Af,f(ne.value.length)+" tool"+f(ne.value.length===1?"":"s")+" available ",1)):m("",!0)])]),de.value?(n(),o("div",Ef,[t("div",Lf,[t("button",{type:"button",class:"inline-flex items-center gap-1 rounded px-1 py-0.5 text-neutral-600 transition-colors hover:bg-neutral-100 hover:text-neutral-950 dark:text-neutral-300 dark:hover:bg-neutral-800 dark:hover:text-neutral-50",title:"Open responsible scheduled effect",onClick:w[10]||(w[10]=M=>l("effectClick",de.value.reference))},[z(c(Tt),{size:12,class:"shrink-0"}),w[31]||(w[31]=t("span",null,"via Scheduled Effect",-1))]),de.value.name?(n(),o("span",Rf,f(de.value.name),1)):m("",!0),de.value.id?(n(),o("span",Mf,f(de.value.id),1)):m("",!0)])])):m("",!0),L.value.length>0?(n(),o("div",Df,[t("div",Ff,[z(c(Tt),{size:11,class:"shrink-0"}),t("span",null,f(L.value.length===1?"Scheduled effect created":`${L.value.length} scheduled effects created`),1)]),t("div",Pf,[(n(!0),o(Re,null,Ke(L.value,M=>(n(),o("button",{key:M.id,type:"button",class:"block w-full rounded border border-transparent px-2 py-1.5 text-left transition-colors hover:border-neutral-200 hover:bg-neutral-50 dark:hover:border-neutral-800 dark:hover:bg-neutral-950",title:"Open scheduled effect",onClick:Oe=>l("effectClick",M.reference)},[t("span",zf,[t("span",jf,f(M.name||"scheduled_effect"),1),t("span",Bf,f(M.id),1)]),t("span",Of,[M.scheduledAt?(n(),o("span",Vf,[w[32]||(w[32]=t("span",{class:"text-neutral-400 dark:text-neutral-500"},"scheduled",-1)),st(" "+f(c(Dt)(M.scheduledAt)),1)])):m("",!0),M.createdAt?(n(),o("span",Hf,[w[33]||(w[33]=t("span",{class:"text-neutral-400 dark:text-neutral-500"},"created",-1)),st(" "+f(c(Dt)(M.createdAt)),1)])):m("",!0),M.status?(n(),o("span",qf,[w[34]||(w[34]=t("span",{class:"text-neutral-400 dark:text-neutral-500"},"status",-1)),st(" "+f(M.status),1)])):m("",!0)])],8,Nf))),128))])])):m("",!0),J.value.length>0?(n(),o("div",Uf,[t("div",Wf,[t("div",Kf,[t("div",Jf,f(J.value.length>1?`${J.value.length} errors`:"Error"),1),t("div",Gf,[t("span",Yf,f(J.value[0].type||"error"),1),J.value[0].originLabel?(n(),o("span",Qf,f(J.value[0].originLabel),1)):m("",!0),ke.value?(n(),o("span",Zf,f(ke.value),1)):m("",!0)])]),J.value[0].human?(n(),N(qn,{key:0,content:J.value[0].human,variant:"ghost",size:"xs"},null,8,["content"])):m("",!0)]),J.value[0].human?(n(),o("p",Xf,f(J.value[0].human),1)):m("",!0),ye.value?(n(),o("div",ep,[t("a",{href:ye.value,target:"_blank",rel:"noopener noreferrer",class:"inline-flex items-center gap-1.5 rounded-full bg-red-600 px-3 py-1 text-xs font-semibold text-white transition-colors hover:bg-red-700 dark:bg-red-500 dark:hover:bg-red-400 dark:text-red-950"},[...w[35]||(w[35]=[st(" Add credits ",-1),t("svg",{class:"h-3 w-3",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},[t("path",{"fill-rule":"evenodd",d:"M4.25 5.5a.75.75 0 0 0-.75.75v8.5c0 .414.336.75.75.75h8.5a.75.75 0 0 0 .75-.75v-4a.75.75 0 0 1 1.5 0v4A2.25 2.25 0 0 1 12.75 17h-8.5A2.25 2.25 0 0 1 2 14.75v-8.5A2.25 2.25 0 0 1 4.25 4h5a.75.75 0 0 1 0 1.5h-5Z","clip-rule":"evenodd"}),t("path",{"fill-rule":"evenodd",d:"M6.194 12.753a.75.75 0 0 0 1.06.053L16.5 4.44v2.81a.75.75 0 0 0 1.5 0v-4.5a.75.75 0 0 0-.75-.75h-4.5a.75.75 0 0 0 0 1.5h2.553l-9.056 8.194a.75.75 0 0 0-.053 1.06Z","clip-rule":"evenodd"})],-1)])],8,tp)])):m("",!0),J.value[0].hasMoreDetails?(n(),o("details",np,[w[36]||(w[36]=t("summary",{class:"cursor-pointer px-3 py-1.5 text-[11px] font-medium text-neutral-500 hover:bg-red-100/40 hover:text-neutral-800 dark:text-neutral-400 dark:hover:bg-red-900/20 dark:hover:text-neutral-200"}," Show full details ",-1)),t("div",ap,[J.value[0].details.isJson?(n(),N(jt,{key:0,code:J.value[0].details.text,language:"json"},null,8,["code"])):(n(),o("pre",rp,f(J.value[0].details.text),1))])])):m("",!0),J.value.length>1?(n(),o("div",sp,[(n(!0),o(Re,null,Ke(J.value.slice(1),(M,Oe)=>(n(),o("details",{key:Oe,class:"border-b border-red-200 last:border-b-0 dark:border-red-900"},[t("summary",op,[t("span",null,f(M.type),1),M.originLabel?(n(),o("span",lp," · "+f(M.originLabel),1)):m("",!0)]),M.human?(n(),o("p",ip,f(M.human),1)):m("",!0),M.hasMoreDetails?(n(),o("details",dp,[w[37]||(w[37]=t("summary",{class:"cursor-pointer px-3 py-1.5 text-[11px] font-medium text-neutral-500 hover:bg-red-100/40 hover:text-neutral-800 dark:text-neutral-400 dark:hover:bg-red-900/20 dark:hover:text-neutral-200"}," Show full details ",-1)),t("div",up,[M.details.isJson?(n(),N(jt,{key:0,code:M.details.text,language:"json"},null,8,["code"])):(n(),o("pre",cp,f(M.details.text),1))])])):m("",!0)]))),128))])):m("",!0)])):m("",!0),t("div",fp,[t("button",{onClick:w[11]||(w[11]=M=>r.value="request"),type:"button",class:K(["inline-flex h-7 items-center gap-1.5 rounded px-3 text-sm font-medium transition-colors",r.value==="request"?"bg-neutral-900 text-white dark:bg-neutral-100 dark:text-neutral-900":"text-neutral-500 hover:bg-neutral-100 hover:text-neutral-900 dark:text-neutral-400 dark:hover:bg-neutral-800 dark:hover:text-neutral-100"])},[z(c(yr),{size:13,"stroke-width":2.25}),w[38]||(w[38]=t("span",null,"Request",-1))],2),t("button",{onClick:w[12]||(w[12]=M=>r.value="response"),type:"button",class:K(["inline-flex h-7 items-center gap-1.5 rounded px-3 text-sm font-medium transition-colors",r.value==="response"?"bg-neutral-900 text-white dark:bg-neutral-100 dark:text-neutral-900":"text-neutral-500 hover:bg-neutral-100 hover:text-neutral-900 dark:text-neutral-400 dark:hover:bg-neutral-800 dark:hover:text-neutral-100"])},[z(c(kr),{size:13,"stroke-width":2.25}),w[39]||(w[39]=t("span",null,"Response",-1))],2)]),t("div",{ref_key:"tabContentRef",ref:U,class:"space-y-3"},[ft(t("div",pp,[t("div",vp,[w[41]||(w[41]=t("label",{for:"request-provider-view",class:"text-[10px] font-medium uppercase tracking-wide text-neutral-500 dark:text-neutral-400"}," View as ",-1)),ft(t("select",{id:"request-provider-view","onUpdate:modelValue":w[13]||(w[13]=M=>Ae.value=M),class:"h-8 min-w-[11rem] rounded border border-neutral-200 bg-white px-2 text-xs font-medium text-neutral-900 shadow-sm transition-colors hover:bg-neutral-50 focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500 dark:border-neutral-800 dark:bg-neutral-900 dark:text-neutral-100 dark:hover:bg-neutral-800/60"},[w[40]||(w[40]=t("option",{value:"standard"},"Standard Agents",-1)),(n(!0),o(Re,null,Ke(c(tt),M=>(n(),o("option",{key:M,value:M},f(c(B0)(M)),9,gp))),128))],512),[[pr,Ae.value]]),$e.value?(n(),N(nt,{key:0,size:"xs"})):m("",!0),pe.value?(n(),o("span",mp,f(pe.value),1)):m("",!0)]),A.value?(n(),o("div",hp,[w[42]||(w[42]=t("div",{class:"text-xs font-semibold text-amber-800 dark:text-amber-200"}," Vision Input Filtered For This Request ",-1)),t("div",xp," This model does not support image input. Removed "+f(A.value.removedUserImageParts)+" user image part(s) and "+f(A.value.removedToolImageAttachments)+" tool image attachment(s) before sending the request. Stored thread messages remain unchanged. ",1)])):m("",!0),ne.value.length>0?(n(),N(Mt,{key:1,ref_key:"toolsSectionRef",ref:Y,title:`Available Tools (${ne.value.length})`,"section-id":"tools",expanded:Q("tools"),"scroll-container":$.value,"sticky-offset":ee.value,onToggle:w[14]||(w[14]=M=>me("tools"))},{default:Be(()=>[(n(!0),o(Re,null,Ke(ne.value,(M,Oe)=>(n(),o("div",{key:Oe,class:"border-b border-neutral-200 dark:border-neutral-800 last:border-b-0"},[t("button",{onClick:it=>te(Oe),class:"w-full px-2 py-1.5 text-left hover:bg-neutral-50 dark:hover:bg-neutral-900 transition-colors flex items-center justify-between text-xs"},[t("span",yp,f(M.function?.name||M.name||"Unknown"),1),t("span",kp,f(i.value.has(Oe)?"▼":"▶"),1)],8,bp),ft(t("div",_p,[M.function?.description||M.description?(n(),o("div",wp,f(M.function?.description||M.description),1)):m("",!0),z(jt,{code:JSON.stringify(M,null,2),language:"json"},null,8,["code"])],512),[[wt,i.value.has(Oe)]])]))),128))]),_:1},8,["title","expanded","scroll-container","sticky-offset"])):m("",!0),e.log.message_history?(n(),N(Mt,{key:2,ref_key:"messagesSectionRef",ref:ue,title:`Messages (${e.log.message_history_length||0} messages)`,subtitle:Ge.value,"section-id":"messages",expanded:Q("messages"),"scroll-container":$.value,"sticky-offset":ee.value,"copy-content":he.value,onToggle:w[15]||(w[15]=M=>me("messages"))},{default:Be(()=>[z(mn,{json:qe.value,"thread-id":e.threadId,actions:P.value,onAction:q},null,8,["json","thread-id","actions"])]),_:1},8,["title","subtitle","expanded","scroll-container","sticky-offset","copy-content"])):m("",!0),e.log.system_prompt?(n(),N(Mt,{key:3,ref_key:"systemPromptSectionRef",ref:ae,title:"System Prompt","section-id":"system_prompt",expanded:Q("system_prompt"),"scroll-container":$.value,"sticky-offset":ee.value,"copy-content":e.log.system_prompt,onToggle:w[16]||(w[16]=M=>me("system_prompt"))},{default:Be(()=>[t("div",$p,[z(jt,{code:e.log.system_prompt,language:"markdown"},null,8,["code"])])]),_:1},8,["expanded","scroll-container","sticky-offset","copy-content"])):m("",!0),e.log.request_body?(n(),N(Mt,{key:4,ref_key:"requestBodySectionRef",ref:oe,title:"Full Request Body",subtitle:Ge.value,"section-id":"request_body",expanded:Q("request_body"),"scroll-container":$.value,"sticky-offset":ee.value,"copy-content":_e.value,onToggle:w[17]||(w[17]=M=>me("request_body"))},{default:Be(()=>[z(mn,{json:_e.value,"thread-id":e.threadId},null,8,["json","thread-id"])]),_:1},8,["subtitle","expanded","scroll-container","sticky-offset","copy-content"])):m("",!0)],512),[[wt,r.value==="request"]]),ft(t("div",Cp,[Ve.value&&e.log.reasoning_content?(n(),o("div",Sp,[w[43]||(w[43]=t("div",{class:"flex items-center gap-1.5 border-b border-amber-200 px-3 py-1.5 text-[10px] font-medium uppercase tracking-wide text-amber-700 dark:border-amber-900/40 dark:text-amber-300"},[t("span",{class:"log-details-pulse"},"●"),t("span",null,"Thinking")],-1)),t("pre",Tp,f(Ce.value),1)])):m("",!0),Te.value?(n(),o("div",Ip,[t("div",Ap,[Ve.value?(n(),o("span",Ep,"●")):m("",!0),w[44]||(w[44]=t("span",null,"Response",-1))]),t("pre",Lp,f(Te.value),1)])):m("",!0),ce.value.length>0?(n(),N(Mt,{key:2,title:`Tools Called (${ce.value.length})`,"section-id":"tools_called",expanded:Q("tools_called"),"scroll-container":$.value,"sticky-offset":ee.value,onToggle:w[18]||(w[18]=M=>me("tools_called"))},{default:Be(()=>[t("div",Rp,[(n(!0),o(Re,null,Ke(ce.value,M=>(n(),o("div",{key:M.id},[t("button",{onClick:Oe=>ie(M.id),type:"button",class:"flex w-full items-center justify-between gap-3 px-3 py-2 text-left transition-colors hover:bg-neutral-50 dark:hover:bg-neutral-900"},[t("div",Dp,[t("span",Fp,f(M.name),1),t("span",Pp,f(sn(M.id)),1)]),t("div",Np,[M.isQueued?(n(),o("span",zp,"queued")):m("",!0),M.isProvider?(n(),N(c(Lt),{key:1,content:"Model tool call from the upstream provider's native response, before AgentBuilder normalization.",position:"top",wide:""},{default:Be(()=>[...w[45]||(w[45]=[t("span",{class:"rounded bg-purple-100 px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-purple-700 dark:bg-purple-900/30 dark:text-purple-300"},"provider",-1)])]),_:1})):m("",!0),M.isProvider&&M.status?(n(),o("span",{key:2,class:K(["text-[10px] font-medium uppercase tracking-wide",M.status==="completed"?"text-emerald-600 dark:text-emerald-400":M.status==="failed"?"text-red-600 dark:text-red-400":"text-amber-600 dark:text-amber-400"])},f(M.status),3)):m("",!0),M.isProvider?m("",!0):(n(),o("span",{key:3,class:K(["text-[10px] font-medium uppercase tracking-wide",B.value.has(M.id)?"text-emerald-600 dark:text-emerald-400":"text-neutral-400 dark:text-neutral-500"])},f(B.value.has(M.id)?"returned":"no result"),3)),t("span",jp,f(p.value.has(M.id)?"▼":"▶"),1)])],8,Mp),ft(t("div",Bp,[M.isProvider?(n(),o("div",Jp,[w[49]||(w[49]=t("div",{class:"mb-1 text-[10px] font-medium uppercase tracking-wide text-neutral-500 dark:text-neutral-400"},"Provider payload",-1)),z(jt,{code:c(N0)(M),language:"json"},null,8,["code"])])):(n(),o("div",Op,[t("div",Vp,[t("div",Hp,[w[47]||(w[47]=t("span",null,"Arguments",-1)),M.isQueued&&M.queuedAt?(n(),o("span",qp,[w[46]||(w[46]=st(" queued ",-1)),z(an,{timestamp:M.queuedAt},null,8,["timestamp"])])):m("",!0)]),z(jt,{code:c(Ya)(M.function?.arguments||"{}"),language:"json"},null,8,["code"])]),t("div",Up,[w[48]||(w[48]=t("div",{class:"mb-1 text-[10px] font-medium uppercase tracking-wide text-neutral-500 dark:text-neutral-400"}," Result ",-1)),B.value.has(M.id)?(n(),o("pre",Wp,f(B.value.get(M.id)?.content||"No content"),1)):(n(),o("div",Kp," no result captured "))])]))],512),[[wt,p.value.has(M.id)]])]))),128))])]),_:1},8,["title","expanded","scroll-container","sticky-offset"])):m("",!0),ze.value.length>0?(n(),N(Mt,{key:3,title:`Generated Images (${ze.value.length})`,subtitle:"returned by the model","section-id":"generated_images",expanded:Q("generated_images"),"scroll-container":$.value,"sticky-offset":ee.value,onToggle:w[19]||(w[19]=M=>me("generated_images"))},{default:Be(()=>[t("div",Gp,[(n(!0),o(Re,null,Ke(ze.value,(M,Oe)=>(n(),o("div",{key:Oe,class:"relative"},[M.image_url?.url?(n(),o("img",{key:0,src:Se(M.image_url.url)||M.image_url.url,alt:`Generated image ${Oe+1}`,class:"max-w-[300px] max-h-[300px] rounded-md ring-1 ring-neutral-200 object-contain dark:ring-neutral-800"},null,8,Yp)):(n(),o("div",Qp," No URL "))]))),128))])]),_:1},8,["title","expanded","scroll-container","sticky-offset"])):m("",!0),e.log.reasoning_content&&!Ve.value?(n(),N(Mt,{key:4,title:"Reasoning Content",subtitle:"internal trace · not shown to users","section-id":"reasoning_content",expanded:Q("reasoning_content"),"scroll-container":$.value,"sticky-offset":ee.value,"copy-content":Ce.value||e.log.reasoning_content,onToggle:w[20]||(w[20]=M=>me("reasoning_content"))},{default:Be(()=>[t("pre",Zp,f(Ce.value),1)]),_:1},8,["expanded","scroll-container","sticky-offset","copy-content"])):m("",!0),re.value.length>0?(n(),N(Mt,{key:5,title:`Reasoning Details (${re.value.length} blocks)`,subtitle:"structured trace from provider","section-id":"reasoning_details",expanded:Q("reasoning_details"),"scroll-container":$.value,"sticky-offset":ee.value,"copy-content":JSON.stringify(re.value,null,2),onToggle:w[21]||(w[21]=M=>me("reasoning_details"))},{default:Be(()=>[t("div",Xp,[(n(!0),o(Re,null,Ke(re.value,(M,Oe)=>(n(),o("div",{key:Oe,class:"px-3 py-2"},[t("div",ev,[t("span",tv,f((M.type||"unknown").replace("reasoning.","")),1),M.id?(n(),o("span",nv," id "+f(M.id),1)):m("",!0),M.format?(n(),o("span",av," · "+f(M.format),1)):m("",!0),M.index!==void 0?(n(),o("span",rv," · index "+f(M.index),1)):m("",!0)]),M.type==="reasoning.summary"&&M.summary?(n(),o("div",sv,f(M.summary),1)):M.type==="reasoning.text"&&M.text?(n(),o(Re,{key:1},[t("div",ov,f(M.text),1),M.signature?(n(),o("div",lv,[w[50]||(w[50]=t("div",{class:"mb-0.5 text-[10px] font-medium uppercase tracking-wide text-neutral-500 dark:text-neutral-400"}," Signature ",-1)),t("div",iv,f(M.signature),1)])):m("",!0)],64)):M.type==="reasoning.encrypted"&&M.data?(n(),o("div",dv,f(M.data),1)):(n(),o("pre",uv,f(JSON.stringify(M,null,2)),1))]))),128))])]),_:1},8,["title","expanded","scroll-container","sticky-offset","copy-content"])):m("",!0),e.log.response_body?(n(),N(Mt,{key:6,title:"Full Response Body","section-id":"response_body",expanded:Q("response_body"),"scroll-container":$.value,"sticky-offset":ee.value,"copy-content":e.log.response_body,onToggle:w[22]||(w[22]=M=>me("response_body"))},{default:Be(()=>[z(mn,{json:e.log.response_body,"thread-id":e.threadId},null,8,["json","thread-id"])]),_:1},8,["expanded","scroll-container","sticky-offset","copy-content"])):m("",!0)],512),[[wt,r.value==="response"]])],512)],4))}}),mv=pt(gv,[["__scopeId","data-v-8dc804e6"]]),hv=new Set(["success","error","skipped"]),xv=new Set(["debug","info","warn","error"]);function qr(e){return e.kind==="app"}function Ur(e){try{return{ok:!0,value:JSON.parse(e)}}catch{return{ok:!1}}}function Xa(e){if(e==null||e==="")return null;const s=Ur(e);return s.ok?typeof s.value=="string"?{format:"text",content:s.value}:{format:"json",content:JSON.stringify(s.value,null,2)}:{format:"text",content:e}}function bv(e){if(!e)return null;const s=Ur(e);if(!s.ok||!s.value||typeof s.value!="object")return null;const a=s.value;return typeof a.kind!="string"||a.kind.length===0?null:{kind:a.kind,id:typeof a.id=="string"&&a.id?a.id:null,summary:typeof a.summary=="string"&&a.summary?a.summary:null}}function yv(e){return e==null||!Number.isFinite(e)?null:e>=1e4?`${(e/1e3).toFixed(1)} s`:`${Math.round(e).toLocaleString("en-US")} ms`}function kv(e){return e==null||!Number.isFinite(e)?null:`$${e.toFixed(6)}`}function Wr(e){const s=e.app_level&&xv.has(e.app_level)?e.app_level:"info",a=e.app_status&&hv.has(e.app_status)?e.app_status:null,l=bv(e.app_trigger),r=e.app_message||null;return{name:e.model,badge:a??s,tone:a??s,level:s,message:r,trigger:l,triggerLine:l?[l.kind,l.summary,l.id].filter(Boolean).join(" · "):null,summary:r??l?.summary??null,durationLabel:yv(e.app_duration_ms),costLabel:kv(e.app_cost),request:Xa(e.app_request),response:Xa(e.app_response),error:e.app_error||null,data:e.app_data||null}}const Kr={success:"bg-emerald-100 text-emerald-700 dark:bg-emerald-950 dark:text-emerald-300",error:"bg-red-100 text-red-700 dark:bg-red-950 dark:text-red-300",skipped:"bg-neutral-100 text-neutral-600 dark:bg-neutral-800 dark:text-neutral-300",warn:"bg-amber-100 text-amber-800 dark:bg-amber-950 dark:text-amber-300",info:"bg-sky-100 text-sky-700 dark:bg-sky-950 dark:text-sky-300",debug:"bg-neutral-100 text-neutral-500 dark:bg-neutral-900 dark:text-neutral-400"},_v={class:"h-full overflow-y-auto bg-white p-3 dark:bg-neutral-900"},wv={class:"sticky -top-3 z-20 -mx-3 -mt-3 mb-3 overflow-hidden rounded-t-lg border-b border-neutral-200 bg-white/95 backdrop-blur dark:border-neutral-800 dark:bg-neutral-900/95"},$v={class:"flex items-start justify-between gap-2 px-3 pt-3 pb-2"},Cv={class:"flex min-w-0 flex-1 flex-wrap items-center gap-x-2 gap-y-1.5"},Sv={class:"min-w-32 flex-1 basis-36 truncate font-mono text-base font-semibold text-neutral-900 dark:text-neutral-100"},Tv={class:"space-y-1 px-3 pb-2"},Iv={key:0,class:"whitespace-pre-wrap break-words text-sm text-neutral-700 dark:text-neutral-300"},Av={key:1,class:"flex min-w-0 items-center gap-1.5 text-[11px] text-neutral-500 dark:text-neutral-400"},Ev=["title"],Lv={class:"flex flex-wrap items-center gap-x-2 font-mono text-[11px] tabular-nums text-neutral-500 dark:text-neutral-400"},Rv={class:"mb-3 grid grid-cols-3 gap-px overflow-hidden rounded-lg border border-neutral-200 bg-neutral-200 dark:border-neutral-800 dark:bg-neutral-800"},Mv={class:"flex flex-col gap-0.5 bg-white px-3 py-2 dark:bg-neutral-900"},Dv={class:"flex min-h-5 items-center gap-1.5 text-[10px] font-medium uppercase tracking-wide text-neutral-500 dark:text-neutral-400"},Fv={class:"font-mono text-base font-semibold tabular-nums text-neutral-900 dark:text-neutral-100"},Pv={class:"flex flex-col gap-0.5 bg-white px-3 py-2 dark:bg-neutral-900"},Nv={class:"flex min-h-5 items-center gap-1.5 text-[10px] font-medium uppercase tracking-wide text-neutral-500 dark:text-neutral-400"},zv={class:"font-mono text-base font-semibold tabular-nums text-neutral-900 dark:text-neutral-100"},jv={class:"flex flex-col gap-0.5 bg-white px-3 py-2 dark:bg-neutral-900"},Bv={class:"flex min-h-5 items-center gap-1.5 text-[10px] font-medium uppercase tracking-wide text-neutral-500 dark:text-neutral-400"},Ov={class:"font-mono text-base font-semibold text-neutral-900 dark:text-neutral-100"},Vv={class:"-mx-3 mb-3 flex h-10 items-center gap-1 border-b border-neutral-200 bg-white/95 px-3 backdrop-blur dark:border-neutral-800 dark:bg-neutral-900/95"},Hv=["onClick"],qv={class:"space-y-3"},Uv={key:0,class:"overflow-hidden rounded-lg border border-red-300 bg-red-50 dark:border-red-800 dark:bg-red-950/30"},Wv={class:"flex items-center justify-between gap-3 border-b border-red-200 px-3 py-2 dark:border-red-900"},Kv={class:"whitespace-pre-wrap break-words bg-white px-3 py-2 text-sm leading-relaxed text-red-900 dark:bg-black/30 dark:text-red-100"},Jv={key:1,class:"whitespace-pre-wrap break-words rounded-lg border border-neutral-200 bg-neutral-50 p-3 font-mono text-xs text-neutral-800 dark:border-neutral-800 dark:bg-neutral-950 dark:text-neutral-200"},Gv={key:2,class:"py-4 text-center text-xs text-neutral-500 dark:text-neutral-400"},Yv={key:3,class:"overflow-hidden rounded-lg border border-neutral-200 dark:border-neutral-800"},Qv={class:"border-t border-neutral-200 p-2 dark:border-neutral-800"},Zv=at({__name:"AppLogDetails",props:{log:{},threadId:{},hasPrevious:{type:Boolean},hasNext:{type:Boolean}},emits:["close","previous","next"],setup(e,{emit:s}){const a=e,l=s,r=C(()=>Wr(a.log)),i=b("response"),p=C(()=>[{id:"request",label:"Request",icon:yr},{id:"response",label:"Response",icon:kr}]),u=C(()=>i.value==="request"?r.value.request:r.value.response),I=S=>S.length>10?`${S.slice(0,8)}…`:S;return(S,y)=>(n(),o("div",_v,[t("div",wv,[t("div",$v,[t("div",Cv,[z(Or,{"has-previous":e.hasPrevious,"has-next":e.hasNext,onPrevious:y[0]||(y[0]=v=>l("previous")),onNext:y[1]||(y[1]=v=>l("next"))},null,8,["has-previous","has-next"]),t("span",{class:K(["shrink-0 rounded-full px-2 py-0.5 font-mono text-[10px] font-semibold uppercase",c(Kr)[r.value.tone]])},f(r.value.badge),3),t("h3",Sv,f(r.value.name),1)]),t("button",{onClick:y[2]||(y[2]=v=>l("close")),class:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded border border-neutral-300 text-neutral-500 transition-colors hover:bg-neutral-100 hover:text-neutral-900 dark:border-neutral-700 dark:text-neutral-400 dark:hover:bg-neutral-800 dark:hover:text-neutral-100","aria-label":"Close details",title:"Close"},[...y[3]||(y[3]=[t("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[t("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t("line",{x1:"6",y1:"6",x2:"18",y2:"18"})],-1)])])]),t("div",Tv,[r.value.message?(n(),o("p",Iv,f(r.value.message),1)):m("",!0),r.value.triggerLine?(n(),o("div",Av,[y[4]||(y[4]=t("span",{class:"font-medium uppercase tracking-wide text-[10px]"},"Trigger",-1)),t("span",{class:"truncate font-mono",title:r.value.triggerLine},f(r.value.triggerLine),9,Ev)])):m("",!0),t("div",Lv,[z(an,{timestamp:e.log.created_at},null,8,["timestamp"]),y[5]||(y[5]=t("span",{"aria-hidden":"true",class:"text-neutral-300 dark:text-neutral-700"},"·",-1)),t("span",null,"log "+f(I(e.log.id)),1)])])]),t("div",Rv,[t("div",Mv,[t("div",Dv,[z(c(xr),{size:11,"stroke-width":2.25}),y[6]||(y[6]=t("span",null,"Performance",-1))]),t("div",Fv,f(r.value.durationLabel??"—"),1)]),t("div",Pv,[t("div",Nv,[z(c(br),{size:11,"stroke-width":2.25}),y[7]||(y[7]=t("span",null,"Cost",-1))]),t("div",zv,f(r.value.costLabel??"—"),1)]),t("div",jv,[t("div",Bv,[z(c(gs),{size:11,"stroke-width":2.25}),y[8]||(y[8]=t("span",null,"Level",-1))]),t("div",Ov,f(r.value.level),1)])]),t("div",Vv,[(n(!0),o(Re,null,Ke(p.value,v=>(n(),o("button",{key:v.id,onClick:k=>i.value=v.id,type:"button",class:K(["inline-flex h-7 items-center gap-1.5 rounded px-3 text-sm font-medium transition-colors",i.value===v.id?"bg-neutral-900 text-white dark:bg-neutral-100 dark:text-neutral-900":"text-neutral-500 hover:bg-neutral-100 hover:text-neutral-900 dark:text-neutral-400 dark:hover:bg-neutral-800 dark:hover:text-neutral-100"])},[(n(),N(At(v.icon),{size:13,"stroke-width":2.25})),t("span",null,f(v.label),1)],10,Hv))),128))]),t("div",qv,[i.value==="response"&&r.value.error?(n(),o("div",Uv,[t("div",Wv,[y[9]||(y[9]=t("span",{class:"text-[10px] font-semibold uppercase tracking-wide text-red-700 dark:text-red-300"},"Error",-1)),z(qn,{content:r.value.error,variant:"ghost",size:"xs"},null,8,["content"])]),t("p",Kv,f(r.value.error),1)])):m("",!0),u.value?(n(),o(Re,{key:1},[u.value.format==="json"?(n(),N(mn,{key:0,json:u.value.content,"thread-id":e.threadId,"show-copy-button":""},null,8,["json","thread-id"])):(n(),o("pre",Jv,f(u.value.content),1))],64)):i.value==="response"&&r.value.error?m("",!0):(n(),o("p",Gv," No "+f(i.value)+" recorded for this entry. ",1)),r.value.data?(n(),o("details",Yv,[y[10]||(y[10]=t("summary",{class:"cursor-pointer px-3 py-2 text-xs font-medium text-neutral-600 hover:bg-neutral-50 dark:text-neutral-300 dark:hover:bg-neutral-800/60"}," Data ",-1)),t("div",Qv,[z(mn,{json:r.value.data,"thread-id":e.threadId},null,8,["json","thread-id"])])])):m("",!0)])]))}}),Xv=["aria-selected","data-log-level"],eg={role:"cell",class:"whitespace-nowrap px-3 py-2 text-xs"},tg={class:"flex min-w-0 items-center gap-1 whitespace-nowrap"},ng={key:0,class:"mr-1 text-neutral-400 dark:text-neutral-600"},ag={role:"cell",class:"whitespace-nowrap px-3 py-2"},rg={class:"font-mono text-xs"},sg={role:"cell",class:"whitespace-nowrap px-3 py-2 font-mono text-xs"},og={class:"flex min-w-0 items-center gap-1.5"},lg=["title"],ig={key:0,class:"shrink-0 font-mono text-[10px] text-neutral-400 dark:text-neutral-500"},dg=at({__name:"AppLogRow",props:{log:{},depth:{},selected:{type:Boolean},highlighted:{type:Boolean},detailsOpen:{type:Boolean}},emits:["select","navigate","hover"],setup(e,{emit:s}){const a=e,l=s,r=C(()=>Wr(a.log));return(i,p)=>(n(),o("div",{role:"row",tabindex:"0","aria-selected":e.selected,"data-log-level":r.value.level,class:K(["logs-grid-row logs-row logs-row-divider group relative cursor-pointer border-b transition-colors",{"last:border-b-0":e.detailsOpen,"logs-row-error":r.value.tone==="error","logs-row-selected":e.selected,"agents-surface-selected agents-text-selected agents-border-selected":e.selected,"agents-surface-hover":!e.selected&&e.highlighted}]),onClick:p[0]||(p[0]=u=>l("select")),onKeydown:p[1]||(p[1]=u=>l("navigate",u)),onMouseenter:p[2]||(p[2]=u=>l("hover",!0)),onMouseleave:p[3]||(p[3]=u=>l("hover",!1))},[t("div",eg,[t("div",tg,[e.depth>0?(n(),o("span",ng,"└─")):m("",!0),t("span",{class:K(["rounded-full px-1.5 py-0.5 font-mono text-[9px] font-semibold uppercase",c(Kr)[r.value.tone]])},f(r.value.badge),3)])]),t("div",ag,[t("span",rg,f(r.value.name),1)]),t("div",sg,f(r.value.costLabel??"—"),1),t("div",{role:"cell",class:K(["min-w-0 overflow-hidden whitespace-nowrap px-3 py-2 text-xs",e.selected?"text-neutral-800 dark:text-neutral-100":"text-neutral-600 dark:text-neutral-400"])},[t("span",og,[t("span",{class:"min-w-0 truncate",title:r.value.summary??void 0},f(r.value.summary??"—"),9,lg),r.value.durationLabel?(n(),o("span",ig,f(r.value.durationLabel),1)):m("",!0)])],2),t("div",{role:"cell",class:K(["whitespace-nowrap px-3 py-2 text-right text-xs",e.selected?"text-neutral-800 dark:text-neutral-100":"text-neutral-500 dark:text-neutral-500"])},[z(an,{timestamp:e.log.created_at},null,8,["timestamp"])],2)],42,Xv))}}),ug=pt(dg,[["__scopeId","data-v-e84e0db7"]]),cg={class:"min-w-full"},fg=["disabled"],pg={key:1},vg={key:2},gg={key:3},mg={role:"table",class:"logs-grid w-full text-sm"},hg={role:"row",class:"logs-grid-row sticky top-0 z-20 bg-white after:absolute after:inset-x-0 after:bottom-0 after:h-px after:bg-neutral-300 dark:bg-black dark:after:bg-neutral-700"},xg=["aria-selected","onClick","onKeydown","onMouseenter"],bg={role:"cell",class:"whitespace-nowrap px-3 py-2 text-xs"},yg={class:"flex min-w-0 items-center gap-1 whitespace-nowrap"},kg={key:0,class:"text-neutral-400 dark:text-neutral-600 mr-1"},_g={key:3},wg={role:"cell",class:"whitespace-nowrap px-3 py-2"},$g={class:"flex min-w-0 items-center gap-2 whitespace-nowrap"},Cg={key:0,class:"inline-flex text-neutral-500 dark:text-neutral-400",title:"Stopped by user"},Sg={key:1,class:"text-red-600 dark:text-red-400",title:"Error"},Tg=["title"],Ig={class:"font-mono text-xs"},Ag={role:"cell",class:"whitespace-nowrap px-3 py-2 font-mono text-xs"},Eg={key:1,class:"inline-flex items-center gap-1"},Lg={key:0,class:"inline-flex shrink-0",title:"Cached tokens dropped vs the previous request for this prompt (prompt cache miss)","aria-label":"Cached tokens dropped vs the previous request for this prompt (prompt cache miss)"},Rg={key:1,class:"text-neutral-400"},Mg=["title"],Dg={class:"min-w-0 overflow-hidden text-ellipsis whitespace-nowrap"},Fg={key:0,class:"text-emerald-600 dark:text-emerald-400",title:"Programmatically called with state.queueTool()"},Pg={key:1},Ng={key:2},zg={key:0,class:"shrink-0 rounded border border-neutral-200 bg-neutral-50 px-1 py-px text-[10px] font-medium text-neutral-500 dark:border-neutral-800 dark:bg-neutral-900 dark:text-neutral-400"},jg=at({__name:"LogsTable",props:{logs:{},hasMore:{type:Boolean},isLoadingMore:{type:Boolean},isLoadingForLog:{type:Boolean},autoLoadEnabled:{type:Boolean},detailsOpen:{type:Boolean},selectedLogIdForDetails:{},selectedLogId:{},hoveredLogId:{},cacheDecreasedLogIds:{}},emits:["loadMore","selectLog","navigateLog","logHover","rowRef"],setup(e,{emit:s}){const a=e;function l(R){if(R instanceof Element)return R;if(R&&typeof R=="object"&&"$el"in R){const H=R.$el;return H instanceof Element?H:null}return null}function r(R){return R.error_type==="user_interrupted"?!0:!R.error_type&&/interrupted by user|stopped by user/i.test(R.error??"")}const i=s,p=b(null),u=b(0),I=b(null);let S=null,y=!1;const v=()=>{S?.disconnect(),S=null,y=!1;const R=I.value;if(!R||typeof IntersectionObserver>"u")return;const H=R.closest(".logs-list-container");H&&(S=new IntersectionObserver(D=>{y=D.some(X=>X.isIntersecting),y&&a.autoLoadEnabled&&!a.isLoadingMore&&i("loadMore")},{root:H,threshold:0}),S.observe(R))};xe(I,()=>v()),xe(()=>a.isLoadingMore,async(R,H)=>{!H||R||(await et(),y&&a.hasMore&&a.autoLoadEnabled&&i("loadMore"))}),$t(()=>{S?.disconnect(),S=null});let k=null,j=null;const $=new Map,W=R=>{if(!R)return[];try{const H=JSON.parse(R);return Array.isArray(H)?H:[]}catch{return[]}},U=R=>[...W(R.tools_called).map(H=>({name:H,isProgrammatic:!1})),...W(R.provider_tools).map(H=>({name:H.name||H.type||"provider_tool",isProgrammatic:!1})),...W(R.queued_tools).map(H=>({name:H.function?.name||"unknown",isProgrammatic:!0}))],Y=R=>R==null?"—":`$${R.toFixed(6)}`,ue=R=>R.map(H=>H.name).join(", "),ae=()=>j||(typeof document>"u"?null:(j=document.createElement("canvas").getContext("2d"),j&&(j.font="12px ui-sans-serif, system-ui, sans-serif"),j)),oe=R=>{const H=$.get(R);if(H!==void 0)return H;const X=ae()?.measureText(R).width??R.length*7;return $.set(R,X),X},ve=(R,H)=>{const D=oe(ue(R)),X=R.filter(Le=>Le.isProgrammatic).length*14,Se=H>0?oe(`+${H} more`)+18:0,ne=H>0?6:0;return D+X+Se+ne},ee=R=>{const H=ue(R);if(R.length<=1)return{tools:R,hiddenCount:0,title:H};const D=u.value-24;if(D<=0)return{tools:R.slice(0,1),hiddenCount:R.length-1,title:H};for(let X=R.length;X>0;X-=1){const Se=R.slice(0,X),ne=R.length-X;if(ve(Se,ne)<=D)return{tools:Se,hiddenCount:ne,title:H}}return{tools:R.slice(0,1),hiddenCount:R.length-1,title:H}},G=()=>{u.value=p.value?.clientWidth??0};return Et(async()=>{await et(),G(),typeof ResizeObserver<"u"&&p.value&&(k=new ResizeObserver(G),k.observe(p.value))}),$t(()=>{k?.disconnect(),k=null}),(R,H)=>(n(),o("div",cg,[e.hasMore?(n(),o("div",{key:0,ref_key:"loadOlderSentinelRef",ref:I,class:"border-b border-neutral-200 dark:border-neutral-800"},[t("button",{onClick:H[0]||(H[0]=D=>i("loadMore")),disabled:e.isLoadingMore||e.isLoadingForLog,type:"button",class:"w-full px-3 py-2 text-xs font-medium text-neutral-500 dark:text-neutral-400 hover:bg-neutral-100 dark:hover:bg-neutral-900 transition-colors disabled:cursor-not-allowed flex items-center justify-center gap-2"},[e.isLoadingMore||e.isLoadingForLog?(n(),N(nt,{key:0,size:"xs"})):m("",!0),e.isLoadingForLog?(n(),o("span",pg,"Loading to find log...")):e.isLoadingMore?(n(),o("span",vg,"Loading older logs...")):(n(),o("span",gg,"Load older logs"))],8,fg)],512)):m("",!0),t("div",mg,[t("div",hg,[H[2]||(H[2]=t("div",{role:"columnheader",class:"whitespace-nowrap px-3 py-1.5 text-left text-xs font-semibold"}," Prompt ",-1)),H[3]||(H[3]=t("div",{role:"columnheader",class:"whitespace-nowrap px-3 py-1.5 text-left text-xs font-semibold"}," Model ",-1)),H[4]||(H[4]=t("div",{role:"columnheader",class:"whitespace-nowrap px-3 py-1.5 text-left text-xs font-semibold"}," Cost ",-1)),t("div",{ref_key:"toolsHeaderRef",ref:p,role:"columnheader",class:"min-w-0 whitespace-nowrap px-3 py-1.5 text-left text-xs font-semibold"}," Tools Called ",512),H[5]||(H[5]=t("div",{role:"columnheader",class:"whitespace-nowrap px-3 py-1.5 text-right text-xs font-semibold"}," Called At ",-1))]),(n(!0),o(Re,null,Ke(e.logs,D=>(n(),o(Re,{key:D.id},[c(qr)(D)?(n(),N(ug,{key:0,ref_for:!0,ref:X=>i("rowRef",D.id,l(X)),log:D,depth:D.depth,selected:e.selectedLogIdForDetails===D.id,highlighted:D.id===a.selectedLogId||D.id===a.hoveredLogId,"details-open":e.detailsOpen,onSelect:X=>i("selectLog",D),onNavigate:X=>i("navigateLog",X,D),onHover:X=>i("logHover",X?D.id:null)},null,8,["log","depth","selected","highlighted","details-open","onSelect","onNavigate","onHover"])):(n(),o("div",{key:1,ref_for:!0,ref:X=>i("rowRef",D.id,X),role:"row",tabindex:"0","aria-selected":e.selectedLogIdForDetails===D.id,class:K(["logs-grid-row logs-row logs-row-divider group relative cursor-pointer border-b transition-colors",{"last:border-b-0":e.detailsOpen,"logs-row-error":D.error&&!r(D),"logs-row-selected":e.selectedLogIdForDetails===D.id,"agents-surface-selected agents-text-selected agents-border-selected":e.selectedLogIdForDetails===D.id,"agents-surface-hover":e.selectedLogIdForDetails!==D.id&&(D.id===a.selectedLogId||D.id===a.hoveredLogId)}]),onClick:X=>i("selectLog",D),onKeydown:X=>i("navigateLog",X,D),onMouseenter:X=>i("logHover",D.id),onMouseleave:H[1]||(H[1]=X=>i("logHover",null))},[t("div",bg,[t("div",yg,[D.depth>0?(n(),o("span",kg,"└─")):m("",!0),D.retry_of_log_id?(n(),N(c(ms),{key:1,size:14,class:"text-neutral-500 dark:text-neutral-400 flex-shrink-0"})):m("",!0),!D.is_complete&&!D.prompt_name?(n(),N(nt,{key:2,size:"xs"})):(n(),o("span",_g,f(D.prompt_name||"—"),1))])]),t("div",wg,[t("div",$g,[r(D)?(n(),o("span",Cg,[z(c(hs),{size:12,class:"mt-0.5"})])):D.error?(n(),o("span",Sg," ✕ ")):m("",!0),D.error&&!r(D)&&c(Mn)(D.error_origin)?(n(),o("span",{key:2,class:"max-w-28 truncate rounded-full bg-red-100 px-1.5 py-0.5 font-mono text-[9px] font-semibold text-red-700 dark:bg-red-950 dark:text-red-300",title:`Error origin: ${c(Mn)(D.error_origin)}`},f(c(Mn)(D.error_origin)),9,Tg)):m("",!0),t("span",Ig,f(D.model_name||D.model),1)])]),t("div",Ag,[!D.is_complete&&(D.cost_total===null||D.cost_total===void 0)?(n(),N(nt,{key:0,size:"xs"})):(n(),o("span",Eg,[st(f(Y(D.cost_total))+" ",1),e.cacheDecreasedLogIds?.has(D.id)?(n(),o("span",Lg,[z(c(xs),{size:12,class:"text-amber-500 dark:text-amber-400"})])):m("",!0)]))]),t("div",{role:"cell",class:K(["min-w-0 overflow-hidden whitespace-nowrap px-3 py-2 text-xs",e.selectedLogIdForDetails===D.id?"text-neutral-800 dark:text-neutral-100":"text-neutral-600 dark:text-neutral-400"])},[!D.is_complete&&U(D).length===0?(n(),N(nt,{key:0,size:"xs"})):U(D).length===0?(n(),o("span",Rg,"—")):(n(),o("span",{key:2,class:"flex min-w-0 items-center gap-1.5",title:ee(U(D)).title},[t("span",Dg,[(n(!0),o(Re,null,Ke(ee(U(D)).tools,(X,Se)=>(n(),o(Re,{key:Se},[X.isProgrammatic?(n(),o("span",Fg,[z(c(bs),{size:11,class:"inline-block -mt-0.5 mr-0.5"}),st(f(X.name),1)])):(n(),o("span",Pg,f(X.name),1)),Se<ee(U(D)).tools.length-1?(n(),o("span",Ng,", ")):m("",!0)],64))),128))]),ee(U(D)).hiddenCount>0?(n(),o("span",zg," +"+f(ee(U(D)).hiddenCount)+" more ",1)):m("",!0)],8,Mg))],2),t("div",{role:"cell",class:K(["whitespace-nowrap px-3 py-2 text-right text-xs",e.selectedLogIdForDetails===D.id?"text-neutral-800 dark:text-neutral-100":"text-neutral-500 dark:text-neutral-500"])},[z(an,{timestamp:D.created_at},null,8,["timestamp"])],2)],42,xg))],64))),128))])]))}}),Bg=pt(jg,[["__scopeId","data-v-367ef0b6"]]),Og={key:0,class:"text-neutral-500 dark:text-neutral-400 text-center py-12"},Vg={key:1,class:"flex justify-center py-12"},Hg={key:2,class:"text-red-600 dark:text-red-400 text-center py-12"},qg={key:3,class:"text-neutral-500 dark:text-neutral-400 text-center py-12"},Ug={key:0,class:"flex h-full flex-col items-center justify-center gap-3 text-neutral-500 dark:text-neutral-400"},Wg={key:3,class:"absolute inset-0 flex items-center justify-center bg-white/20 pointer-events-none dark:bg-black/20"},er=20,Kg=20,tr="agentbuilder.threads.logDetailsSplitPercent",nr=50,Jg=600,Gg=at({__name:"LogsPane",props:{threadId:{},selectedLogId:{},hoveredLogId:{}},emits:["logClick","logHover","logsLoaded","effectClick"],setup(e,{expose:s,emit:a}){const l=e,r=a,i=b(0),p=b(er),{logs:u,hasMore:I,isFetching:S,error:y,connectWebSocket:v,disconnectWebSocket:k,refetch:j}=zc(C(()=>l.threadId),{limit:C(()=>p.value),offset:C(()=>i.value),enableWebSocket:!0,order:"desc"}),$=b([]),W=b(!0),U=b(null),Y=b(null),ue=b(null),ae=b(!1),oe=b(!1);let ve=null;const ee=b(new Map),H=b(((L,ge,je)=>Math.min(je,Math.max(ge,L)))(((L,ge)=>{if(typeof window>"u")return ge;const je=window.localStorage.getItem(L),Je=je?Number.parseFloat(je):Number.NaN;return Number.isFinite(Je)?Je:ge})(tr,55),35,70)),D=async()=>{await et(),Y.value&&(Qe(),Y.value.scrollTop=Y.value.scrollHeight)},X=()=>{const L=Y.value;L&&(ae.value||ve||(Qe(),L.scrollTop=L.scrollHeight))};let Se=null;const ne=()=>{Se?.disconnect(),!(typeof ResizeObserver>"u")&&Se&&(Y.value&&Se.observe(Y.value),ue.value&&Se.observe(ue.value))};Et(()=>{typeof ResizeObserver<"u"&&(Se=new ResizeObserver(()=>X()),ne())}),xe([Y,ue],()=>ne()),$t(()=>{Se?.disconnect(),Se=null});const Le=b(null);xe(u,async L=>{if(i.value===0){const ge=$.value.length;$.value=[...L].reverse(),W.value&&$.value.length>0?(await D(),W.value=!1):!ae.value&&$.value.length>ge&&await D()}else{const ge=[...L].reverse(),je=new Map,Je=$.value[0]?.created_at??Number.POSITIVE_INFINITY;$.value.forEach(q=>je.set(q.id,q)),ge.forEach(q=>je.set(q.id,q));const qe=Array.from(je.values()).sort((q,Ie)=>q.created_at-Ie.created_at),P=qe.filter(q=>q.created_at<Je).length;if($.value=qe,ve&&P>0){const q=ve;ve=null,await et();const Ie=Y.value;Ie&&(Qe(),Ie.scrollTop=q.scrollTop+(Ie.scrollHeight-q.scrollHeight)),oe.value=!1}}},{deep:!0,immediate:!0}),xe(S,(L,ge)=>{if(ge&&!L&&i.value===0&&l.threadId&&Le.value!==l.threadId&&$.value.length>0){Le.value=l.threadId;const je=$.value[$.value.length-1];r("logsLoaded",je?.id??null)}});const{logDetails:B,isFetching:re,refetch:Ce}=Bc(C(()=>l.threadId),C(()=>U.value)),ze=L=>({endpoint:null,request_body:null,request_headers:null,response_body:null,response_headers:null,status_code:null,reasoning_content:null,input_tokens:null,cached_tokens:null,output_tokens:null,reasoning_tokens:null,total_tokens:null,latency_ms:null,time_to_first_token_ms:null,generation_ms:null,finish_reason:null,error_type:null,cost_input:null,cost_cached:null,cost_output:null,cost_router_fee:null,router_fee_percent:null,message_history_length:null,tools_available:null,tools_schema:null,message_history:null,system_prompt:null,errors:null,tool_results:null,scheduled_effects:null,source_message_role:null,source_message_content:null,source_message_created_at:null,source_message_metadata:null,...L}),Ve=C(()=>U.value?$.value.find(L=>L.id===U.value)??null:null),Te=C(()=>{const L=Ve.value;return L?B.value?{...B.value,...L}:ze(L):null});xe(()=>({id:Ve.value?.id??null,isComplete:Ve.value?.is_complete??!1}),(L,ge)=>{!L.id||!L.isComplete||ge?.id!==L.id||ge.isComplete||Ce()});const le=b(null);xe(Te,L=>{L?le.value=L:U.value||(le.value=null)},{immediate:!0});const we=C(()=>U.value?de.value.findIndex(L=>L.id===U.value):-1),ce=C(()=>we.value>0),te=C(()=>we.value>=0&&we.value<de.value.length-1),ie=()=>{if(ce.value){const L=de.value[we.value-1];Ue(L)}},me=()=>{if(te.value){const L=de.value[we.value+1];Ue(L)}},Q=async L=>{await et(),ee.value.get(L)?.focus({preventScroll:!0})},Me=(L,ge)=>{const je=de.value.findIndex(P=>P.id===ge.id);if(je<0)return;let Je=je;if(L.key==="ArrowDown")Je=Math.min(de.value.length-1,je+1);else if(L.key==="ArrowUp")Je=Math.max(0,je-1);else if(L.key==="Home")Je=0;else if(L.key==="End")Je=de.value.length-1;else return;L.preventDefault();const qe=de.value[Je];qe&&(Ue(qe),Q(qe.id))},Ne=L=>{if(!Y.value)return;const ge=ee.value.get(L);if(!ge)return;const je=Y.value,Je=ge.getBoundingClientRect(),qe=je.getBoundingClientRect(),P=je.querySelectorAll(".sticky");let q=0;P.forEach(Ge=>{q+=Ge.getBoundingClientRect().height}),q+=16;const Ie=Je.top<qe.top+q,_e=Je.bottom>qe.bottom;Ie?(Qe(),je.scrollBy({top:Je.top-qe.top-q,behavior:"smooth"})):_e&&(Qe(),je.scrollBy({top:Je.bottom-qe.bottom,behavior:"smooth"}))},Ue=L=>{r("logClick",L.id),U.value=L.id;const ge=$.value[$.value.length-1];ge&&ge.id!==L.id&&(ae.value=!0)},We=(L,ge)=>{ge?ee.value.set(L,ge):ee.value.delete(L)},E=(L,ge)=>{We(L,ge instanceof HTMLElement?ge:null)};xe(U,async L=>{L&&(await et(),Ne(L))}),xe(()=>l.selectedLogId,L=>{L&&(U.value=L)},{immediate:!0});const fe=L=>{U.value=L},be=async L=>{await et();const ge=ee.value.get(L);if(ge&&Y.value){const je=Y.value,Je=ge.getBoundingClientRect(),qe=je.getBoundingClientRect(),P=je.querySelector("thead"),q=je.querySelector(":scope > div > div.sticky");let Ie=0;P&&(Ie+=P.getBoundingClientRect().height),q&&(Ie+=q.getBoundingClientRect().height),Ie+=40;const _e=Je.top<qe.top+Ie,Ge=Je.bottom>qe.bottom;_e?(Qe(),je.scrollBy({top:Je.top-qe.top-Ie,behavior:"smooth"})):Ge&&(Qe(),je.scrollBy({top:Je.bottom-qe.bottom,behavior:"smooth"}))}},Pe=L=>{if(L.length===0)return;const ge=new Set(L);$.value=$.value.filter(je=>!ge.has(je.id))},J=b(!1),ke=L=>$.value.some(ge=>ge.id===L),ye=L=>$.value.find(ge=>ge.id===L)??null,Ae=(L,ge=3e3)=>new Promise(je=>{const Je=xe(()=>$.value.length,P=>{P!==L&&(clearTimeout(qe),Je(),je(!0))}),qe=setTimeout(()=>{Je(),je(!1)},ge)});s({scrollToLog:be,selectLogById:fe,removeLogsByIds:Pe,loadUntilLogId:async L=>{if(ke(L))return!0;if(!I.value)return!1;J.value=!0;const ge=100,je=50,Je=p.value;try{let qe=0;for(;I.value&&!ke(L)&&qe<je;){qe++;const P=$.value.length;if(i.value+=p.value,p.value=ge,await j(),!await Ae(P))break}return ke(L)}finally{p.value=Je,i.value=Math.max(0,$.value.length-Je),J.value=!1}},hasLog:ke,getLog:ye,setLoadingForLog:L=>{J.value=L},waitForLogRow:async(L,ge=2e3)=>{const je=Date.now();for(;Date.now()-je<ge;){if(ee.value.has(L))return!0;if(!de.value.some(qe=>qe.id===L)){await et(),await new Promise(qe=>setTimeout(qe,16));continue}await et(),await new Promise(qe=>setTimeout(qe,16))}return!1}});const Fe=()=>{if(oe.value||!I.value||S.value)return;oe.value=!0;const L=Y.value;ve={scrollHeight:L?.scrollHeight??0,scrollTop:L?.scrollTop??0},i.value+=p.value,p.value=Kg};xe(S,(L,ge)=>{ge&&!L&&oe.value&&setTimeout(()=>{ve&&(ve=null,oe.value=!1)},300)}),xe(()=>l.threadId,async L=>{L?(k(),v()):k(),i.value=0,p.value=er,$.value=[],U.value=null,ae.value=!1,W.value=!0,ve=null,oe.value=!1},{immediate:!0});let tt=0;const Qe=()=>{tt=Date.now()},lt=L=>L.scrollHeight-L.scrollTop-L.clientHeight,he=()=>{const L=Y.value;if(L){if(lt(L)<nr){ae.value=!1;return}Date.now()-tt>Jg&&(ae.value=!0)}},O=L=>{L.deltaY<0&&(ae.value=!0)},se=()=>{const L=Y.value;L&&lt(L)>=nr&&(ae.value=!0)},He=C(()=>Oc($.value)),de=C(()=>{const L=new Map,ge=new Map;$.value.forEach(qe=>{L.set(qe.id,qe);const P=qe.parent_log_id;P&&(ge.has(P)||ge.set(P,[]),ge.get(P).push(qe))});const je=[],Je=(qe,P)=>{je.push({...qe,depth:P}),(ge.get(qe.id)||[]).forEach(Ie=>{Je(Ie,P+1)})};return $.value.forEach(qe=>{qe.parent_log_id||Je(qe,0)}),je});return(L,ge)=>(n(),N(Un,{"height-percent":H.value,"onUpdate:heightPercent":ge[4]||(ge[4]=je=>H.value=je),"storage-key":tr,title:"Resize logs and details"},Wt({main:Be(()=>[t("div",{ref_key:"logsScrollContainer",ref:Y,class:"logs-list-container h-full overflow-y-auto overflow-x-auto",onScroll:he,onWheelPassive:O,onTouchmovePassive:se},[e.threadId?c(S)&&i.value===0?(n(),o("div",Vg,[z(nt)])):c(y)?(n(),o("div",Hg," Error loading logs: "+f(c(y)),1)):$.value.length===0?(n(),o("div",qg," No logs yet ")):(n(),o("div",{key:4,ref_key:"logsContentRef",ref:ue},[z(Bg,{logs:de.value,"has-more":c(I),"is-loading-more":oe.value,"is-loading-for-log":J.value,"auto-load-enabled":!W.value&&!J.value,"cache-decreased-log-ids":He.value,"details-open":!!Te.value,"selected-log-id-for-details":U.value,"selected-log-id":l.selectedLogId,"hovered-log-id":l.hoveredLogId,onLoadMore:Fe,onSelectLog:Ue,onNavigateLog:Me,onLogHover:ge[0]||(ge[0]=je=>r("logHover",je)),onRowRef:E},null,8,["logs","has-more","is-loading-more","is-loading-for-log","auto-load-enabled","cache-decreased-log-ids","details-open","selected-log-id-for-details","selected-log-id","hovered-log-id"])],512)):(n(),o("div",Og," Select a thread to view logs "))],544)]),_:2},[le.value||J.value&&U.value?{name:"detail",fn:Be(()=>[J.value&&!Te.value?(n(),o("div",Ug,[z(nt),ge[5]||(ge[5]=t("span",{class:"text-sm"},"Loading log...",-1))])):le.value&&c(qr)(le.value)?(n(),N(Zv,{key:1,log:le.value,"thread-id":e.threadId,"has-previous":ce.value,"has-next":te.value,onClose:ge[1]||(ge[1]=je=>U.value=null),onPrevious:ie,onNext:me},null,8,["log","thread-id","has-previous","has-next"])):le.value?(n(),N(mv,{key:2,log:le.value,"thread-id":e.threadId,"has-previous":ce.value,"has-next":te.value,onClose:ge[2]||(ge[2]=je=>U.value=null),onPrevious:ie,onNext:me,onEffectClick:ge[3]||(ge[3]=je=>r("effectClick",je))},null,8,["log","thread-id","has-previous","has-next"])):m("",!0),c(re)&&le.value?(n(),o("div",Wg,[z(nt)])):m("",!0)]),key:"0"}:void 0]),1032,["height-percent"]))}}),Yg=pt(Gg,[["__scopeId","data-v-edb1372e"]]),Qg={class:"code-editor flex min-h-0 flex-col"},Zg={key:0,class:"mt-1 text-sm text-red-500"},Xg=at({__name:"CodeEditor",props:{modelValue:{},language:{default:"plaintext"},readonly:{type:Boolean,default:!1},error:{default:null},rows:{},height:{},placeholder:{},minimap:{type:Boolean,default:!1},lineNumbers:{default:"on"},wordWrap:{default:"off"},formatOnBlur:{type:Boolean,default:!1},framed:{type:Boolean,default:!0}},emits:["update:modelValue","blur"],setup(e,{emit:s}){self.MonacoEnvironment={getWorker(ae,oe){return oe==="json"?new so:oe==="css"||oe==="scss"||oe==="less"?new oo:oe==="html"||oe==="handlebars"||oe==="razor"?new lo:oe==="typescript"||oe==="javascript"?new io:new uo}};const a=e,l=s,r={bash:"shell",js:"javascript",md:"markdown",sh:"shell",text:"plaintext",ts:"typescript",txt:"plaintext"},i=b(null);let p=null,u=null,I=!1,S=!1;const y=C(()=>{const ae=a.language?.trim().toLowerCase()||"plaintext";return r[ae]??ae}),v=C(()=>a.height?a.height:a.rows?`${a.rows*1.5}rem`:"100%"),k=()=>document.documentElement.classList.contains("dark"),j=()=>{S||(S=!0,dn.defineTheme("agentbuilder-light",{base:"vs",inherit:!0,rules:[{token:"comment",foreground:"6A737D",fontStyle:"italic"},{token:"keyword",foreground:"D73A49"},{token:"number",foreground:"005CC5"},{token:"regexp",foreground:"032F62"},{token:"string",foreground:"22863A"},{token:"type",foreground:"6F42C1"},{token:"delimiter",foreground:"24292F"},{token:"identifier",foreground:"24292F"},{token:"tag",foreground:"22863A"},{token:"attribute.name",foreground:"6F42C1"}],colors:{"editor.background":"#FFFFFF","editor.foreground":"#24292F","editorCursor.foreground":"#0969DA","editorIndentGuide.activeBackground1":"#8C959F","editorIndentGuide.background1":"#D0D7DE","editorLineNumber.activeForeground":"#0969DA","editorLineNumber.foreground":"#6E7781","editor.lineHighlightBackground":"#F6F8FA","editor.selectionBackground":"#0969DA33","editor.inactiveSelectionBackground":"#AFD0F366"}}),dn.defineTheme("agentbuilder-dark",{base:"vs-dark",inherit:!0,rules:[{token:"comment",foreground:"8B949E",fontStyle:"italic"},{token:"keyword",foreground:"FF7B72"},{token:"number",foreground:"79C0FF"},{token:"regexp",foreground:"A5D6FF"},{token:"string",foreground:"A5D6FF"},{token:"type",foreground:"D2A8FF"},{token:"delimiter",foreground:"C9D1D9"},{token:"identifier",foreground:"C9D1D9"},{token:"tag",foreground:"7EE787"},{token:"attribute.name",foreground:"D2A8FF"}],colors:{"editor.background":"#0D1117","editor.foreground":"#C9D1D9","editorCursor.foreground":"#58A6FF","editorIndentGuide.activeBackground1":"#6E7681","editorIndentGuide.background1":"#30363D","editorLineNumber.activeForeground":"#58A6FF","editorLineNumber.foreground":"#6E7681","editor.lineHighlightBackground":"#161B22","editor.selectionBackground":"#1F6FEB55","editor.inactiveSelectionBackground":"#1F6FEB33"}}))},$=()=>k()?"agentbuilder-dark":"agentbuilder-light",W=()=>({acceptSuggestionOnCommitCharacter:!0,automaticLayout:!0,bracketPairColorization:{enabled:!0},cursorBlinking:"smooth",detectIndentation:!1,fixedOverflowWidgets:!0,folding:!0,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas, monospace',fontSize:13,formatOnPaste:!0,formatOnType:!0,glyphMargin:!1,lineDecorationsWidth:8,lineHeight:21,lineNumbers:a.lineNumbers,lineNumbersMinChars:3,minimap:{enabled:a.minimap},padding:{top:10,bottom:10},placeholder:a.placeholder,quickSuggestions:{comments:"off",other:"on",strings:"on"},readOnly:a.readonly,renderLineHighlight:"line",scrollBeyondLastLine:!1,scrollbar:{horizontal:"auto",horizontalScrollbarSize:10,vertical:"auto",verticalScrollbarSize:10},smoothScrolling:!0,tabSize:2,wordWrap:a.wordWrap}),U=()=>{p&&dn.setTheme($())},Y=()=>{if(!(!p||a.readonly||y.value!=="json"))try{const ae=p.getValue(),oe=JSON.stringify(JSON.parse(ae),null,2);oe!==ae&&(I=!0,p.setValue(oe),l("update:modelValue",oe),I=!1)}catch{}},ue=()=>{i.value&&(j(),p=dn.create(i.value,{value:a.modelValue||"",language:y.value,theme:$(),...W()}),i.value.__monacoEditor=p,p.onDidChangeModelContent(()=>{!I&&p&&l("update:modelValue",p.getValue())}),p.onDidBlurEditorText(()=>{l("blur"),a.formatOnBlur&&Y()}))};return Et(async()=>{await et(),ue(),u=new MutationObserver(U),u.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]})}),Ht(()=>{u?.disconnect(),u=null,i.value&&delete i.value.__monacoEditor,p?.dispose(),p=null}),xe(()=>a.modelValue,ae=>{p&&p.getValue()!==ae&&(I=!0,p.setValue(ae||""),I=!1)}),xe(y,ae=>{const oe=p?.getModel();oe&&dn.setModelLanguage(oe,ae)}),xe(()=>[a.readonly,a.minimap,a.lineNumbers,a.wordWrap,a.placeholder,a.framed],()=>{p?.updateOptions(W())}),(ae,oe)=>(n(),o("div",Qg,[t("div",{class:K(["min-h-0 flex-1 overflow-hidden bg-white dark:bg-neutral-950",[e.framed?"rounded border":"",e.framed&&e.error?"border-red-500":"",e.framed&&!e.error?"border-neutral-200 dark:border-neutral-800":""]]),style:bt({height:v.value})},[t("div",{ref_key:"containerRef",ref:i,class:"monaco-editor-container h-full w-full"},null,512)],6),e.error?(n(),o("div",Zg,f(e.error),1)):m("",!0)]))}}),$a=pt(Xg,[["__scopeId","data-v-12a765de"]]);function Jr(e){const s=e.delayMs??150,a=e.isHidden??(()=>typeof document<"u"&&document.visibilityState==="hidden");let l=null,r=!1,i=!1,p=!1;const u=()=>{l||i||p||!r||a()||(l=setTimeout(()=>{if(l=null,p||!r||a())return;r=!1,i=!0;let S=!1;Promise.resolve().then(()=>e.refresh()).then(y=>{S=y!==!1,S||(r=!0)}).catch(()=>{r=!0}).finally(()=>{i=!1,S&&r&&u()})},s))},I=()=>{!r||a()||u()};return{notify(){r=!0,u()},onVisible(){I()},flush(){I()},cancel(){p=!0,l&&clearTimeout(l),l=null,r=!1}}}function Ca(e){let s=null;try{s=Tr()}catch{return{available:!1}}const a=Object.entries(e.events).map(([i,p])=>s.onEvent(i,p)),l=xe(s.status,(i,p)=>{i==="connected"&&p!=="connected"&&e.onConnected()}),r=()=>{l();for(const i of a)try{i()}catch{}};return ys()&&Ht(r),{available:!0}}const em={class:"h-full min-h-0 overflow-hidden"},tm={class:"flex h-full min-h-0 flex-col overflow-hidden"},nm={class:"flex items-center gap-2 border-b border-neutral-200 px-3 py-2 dark:border-neutral-800"},am={class:"flex min-w-0 flex-1 items-center gap-2"},rm={class:"hidden shrink-0 text-xs tabular-nums text-neutral-500 sm:block"},sm=["disabled"],om={class:"min-h-0 flex-1 overflow-auto"},lm={key:0,class:"py-12 text-center text-sm text-neutral-500"},im={key:1,class:"flex justify-center py-12"},dm={key:2,class:"py-12 text-center text-sm text-red-600 dark:text-red-400"},um={key:3,class:"py-12 text-center text-sm text-neutral-500"},cm={key:4,class:"flex h-full min-h-0 flex-col"},fm={key:0,class:"border-b border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700 dark:border-red-900/70 dark:bg-red-950/30 dark:text-red-300"},pm={class:"min-h-0 flex-1 overflow-auto bg-white dark:bg-neutral-950"},vm={class:"w-full min-w-[70rem] table-fixed text-left text-xs"},gm={class:"divide-y divide-neutral-100 dark:divide-neutral-900"},mm={key:0,class:"text-[10px] font-semibold uppercase tracking-wide text-neutral-500 dark:text-neutral-400"},hm={scope:"rowgroup",colspan:"8",class:"sticky top-[28px] z-[9] border-y border-neutral-200 bg-neutral-50/95 px-4 py-2 text-left font-semibold dark:border-neutral-800 dark:bg-neutral-900/95"},xm={class:"ml-1 rounded bg-neutral-200 px-1.5 py-0.5 text-[9px] text-neutral-600 dark:bg-neutral-800 dark:text-neutral-300"},bm=["aria-selected","onClick","onKeydown"],ym={class:"whitespace-nowrap px-4 py-2 align-middle"},km={class:"flex items-center gap-1.5"},_m=["disabled","title","aria-label","onClick"],wm=["disabled","title","aria-label","onClick"],$m={key:2,class:"px-2 text-neutral-300 dark:text-neutral-700"},Cm={class:"whitespace-nowrap px-4 py-2 align-middle"},Sm={class:"min-w-0 px-3 py-2 align-middle"},Tm={class:"truncate font-mono text-xs text-neutral-950 dark:text-neutral-100"},Im=["title"],Am={key:0,class:"mt-0.5 truncate text-[11px] font-medium text-neutral-500 dark:text-neutral-400"},Em={key:1,class:"mt-1 inline-flex max-w-full items-center gap-1 rounded border border-accent-200/80 bg-accent-50/70 px-1.5 py-0.5 text-[10px] font-medium leading-none text-accent-700 dark:border-accent-900/70 dark:bg-accent-950/25 dark:text-accent-300"},Lm={class:"truncate"},Rm={class:"whitespace-nowrap px-3 py-2 align-middle text-xs text-neutral-500 dark:text-neutral-400"},Mm={class:"whitespace-nowrap px-3 py-2 align-middle"},Dm={class:"text-xs font-medium text-neutral-800 dark:text-neutral-100"},Fm={key:0,class:"text-[11px] text-neutral-400"},Pm={class:"whitespace-nowrap px-3 py-2 align-middle text-xs text-neutral-500 dark:text-neutral-400"},Nm={class:"whitespace-nowrap px-3 py-2 text-right align-middle text-xs tabular-nums text-neutral-500"},zm={class:"min-w-0 px-4 py-2 align-middle"},jm=["title"],Bm={key:0,class:"mt-0.5 truncate text-[11px] text-red-600 dark:text-red-400"},Om=["disabled"],Vm={class:"flex h-full min-h-0 flex-col overflow-hidden"},Hm={class:"flex items-center gap-3 border-b border-neutral-200 px-3 py-2 dark:border-neutral-800"},qm={class:"min-w-0 flex-1"},Um={class:"truncate font-mono text-sm font-medium text-neutral-950 dark:text-neutral-100"},Wm={class:"truncate text-[11px] text-neutral-500"},Km={key:0,class:"mt-0.5 text-[11px] font-medium text-neutral-500 dark:text-neutral-400"},Jm={class:"flex shrink-0 items-center gap-2"},Gm=["disabled","title","aria-label"],Ym=["disabled","title","aria-label"],Qm={class:"grid shrink-0 grid-cols-2 gap-x-4 gap-y-2 border-b border-neutral-200 px-3 py-3 text-xs dark:border-neutral-800"},Zm={class:"mt-0.5 text-neutral-900 dark:text-neutral-100"},Xm={class:"mt-0.5 text-neutral-900 dark:text-neutral-100"},eh={class:"mt-0.5 text-neutral-900 dark:text-neutral-100"},th={class:"mt-0.5 tabular-nums text-neutral-900 dark:text-neutral-100"},nh={class:"mt-0.5"},ah={key:0,class:"inline-flex items-center gap-1 rounded border border-accent-200/80 bg-accent-50/80 px-1.5 py-0.5 text-[10px] font-medium text-accent-700 dark:border-accent-900/70 dark:bg-accent-950/30 dark:text-accent-300"},rh={key:1,class:"text-neutral-900 dark:text-neutral-100"},sh={key:0,class:"mt-0.5 text-[11px] text-neutral-500 dark:text-neutral-400"},oh={key:0},lh={class:"mt-0.5 inline-flex max-w-full items-center gap-1 rounded border border-accent-200/80 bg-accent-50/70 px-1.5 py-0.5 text-[10px] font-medium text-accent-700 dark:border-accent-900/70 dark:bg-accent-950/25 dark:text-accent-300"},ih={class:"truncate font-mono"},dh={key:0,class:"border-b border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700 dark:border-red-900/70 dark:bg-red-950/30 dark:text-red-300"},uh={class:"flex min-h-0 flex-1 flex-col overflow-hidden"},ch={class:"flex items-start gap-2"},fh={class:"min-w-0"},ph={class:"font-medium text-neutral-950 dark:text-neutral-100"},vh={class:"mt-1 text-neutral-500 dark:text-neutral-400"},gh={class:"mt-1 truncate text-neutral-500 dark:text-neutral-400"},mh={class:"font-mono text-neutral-700 dark:text-neutral-200"},hh={class:"mt-1 truncate font-mono text-[11px] text-neutral-400"},xh={class:"mt-3 flex justify-end gap-2"},ar=100,bh=1e3,yh="agentbuilder.threads.effectDetailSplitPercent",kh=260,_h=at({__name:"ThreadEffectsPane",props:{threadId:{},active:{type:Boolean,default:!0},selectedEffectId:{},selectedEffectRef:{}},emits:["count-changed"],setup(e,{expose:s,emit:a}){const l=e,r=a,i=b([]),p=b(0),u=b(0),I=b(!1),S=b(!1),y=b(null),v=b(null),k=b(Date.now()),j=b(null),$=b(50),W=b(new Map),U=b(null),Y=b(null),ue=b(null),ae=b("run"),oe=b(null),ve=b(null);let ee=null,G=!1,R=0;const H=C(()=>i.value.length<p.value),D=C(()=>i.value.filter(Xt)),X=C(()=>i.value.filter(d=>!Xt(d))),Se=C(()=>{const d=[];return D.value.length>0&&(d.push({type:"section",key:"section-upcoming",label:"Upcoming",count:D.value.length}),d.push(...D.value.map(h=>({type:"effect",key:h.id,effect:h})))),X.value.length>0&&(d.push({type:"section",key:"section-history",label:"History",count:X.value.length}),d.push(...X.value.map(h=>({type:"effect",key:h.id,effect:h})))),d}),ne=C(()=>j.value?i.value.find(d=>d.id===j.value)??null:null),Le=C(()=>ue.value?i.value.find(d=>d.id===ue.value)??null:null),B=C(()=>ve.value?{top:`${ve.value.top}px`,left:`${ve.value.left}px`}:{}),re=C(()=>!!ne.value),Ce=C(()=>ne.value?Ja(ne.value.args):"{}"),ze=C(()=>{if(!l.threadId)return"";if(p.value===0)return"No effects";const d=Math.max(p.value-u.value,X.value.length);return`${u.value} upcoming | ${d} history | ${i.value.length} of ${p.value}`});function Ve(){return!!l.threadId&&l.active!==!1&&!I.value&&!S.value&&!G}function Te(d){const h=d?i.value.find(F=>F.id===d):null;if(h){j.value=h.id;return}if(d){j.value=d;return}j.value&&i.value.some(F=>F.id===j.value)||(j.value=i.value[0]?.id??null)}function le(d){j.value=d.id}function we(d,h){h instanceof HTMLElement?W.value.set(d,h):W.value.delete(d)}async function ce(d){await et(),W.value.get(d)?.focus({preventScroll:!0})}async function te(d){await et();const h=W.value.get(d);h?.scrollIntoView({block:"nearest"}),h?.focus({preventScroll:!0})}async function ie(d){j.value=d,Te(d),await te(d)}async function me(d){if(d.id){await ie(d.id);return}const h=i.value.find(F=>Ga(F,d));h&&await ie(h.id)}function Q(d){if(d.id)return Te(d.id),!0;const h=i.value.find(F=>Ga(F,d));return h?(Te(h.id),!0):!1}function Me(d,h){const F=i.value.findIndex(vt=>vt.id===h.id);if(F<0)return;let Ee=F;if(d.key==="ArrowDown")Ee=Math.min(i.value.length-1,F+1);else if(d.key==="ArrowUp")Ee=Math.max(0,F-1);else if(d.key==="Home")Ee=0;else if(d.key==="End")Ee=i.value.length-1;else return;d.preventDefault();const ot=i.value[Ee];ot&&(le(ot),ce(ot.id))}function Ne(d){switch(d){case"pending":return"Pending";case"processing":return"Running";case"completed":return"Completed";case"failed":return"Failed";case"agent_canceled":case"user_canceled":return"Cancelled"}}function Ue(d){switch(d){case"pending":return"bg-sky-50 text-sky-700 dark:bg-sky-950/40 dark:text-sky-300";case"processing":return"bg-amber-50 text-amber-700 dark:bg-amber-950/40 dark:text-amber-300";case"completed":return"bg-emerald-50 text-emerald-700 dark:bg-emerald-950/40 dark:text-emerald-300";case"failed":return"bg-red-50 text-red-700 dark:bg-red-950/40 dark:text-red-300";case"agent_canceled":return"bg-neutral-100 text-neutral-700 dark:bg-neutral-800 dark:text-neutral-300";case"user_canceled":return"bg-red-50 text-red-700 dark:bg-red-950/40 dark:text-red-300"}}function We(d){return Xt(d)?f0(d.scheduledAt,k.value):Dt(d.scheduledAt)}function E(d){return Xt(d)?Dt(d.scheduledAt):""}function fe(d){return d.status==="pending"?"Not run":d.status==="processing"?"Running":Pe(d)?"-":Dt(d.completedAt)}function be(d){return d.split("-")[0]||d}function Pe(d){return d.status==="agent_canceled"||d.status==="user_canceled"}function J(d){return d.status==="agent_canceled"?"agent cancelled":d.status==="user_canceled"?"user cancelled":""}function ke(d){return d.replayedFrom?"Manual rerun":d.manualRun?"Manual run":""}function ye(d){return d.replayedFrom?`Manual rerun of ${be(d.replayedFrom)}`:d.manualRun?"Manual run":""}function Ae(d){return Pe(d)?"":c0(d)}function V(d){const h=Ae(d);return h.startsWith("-")?"text-sky-700 dark:text-sky-300":h.startsWith("+")?"text-orange-700 dark:text-orange-300":"text-neutral-500 dark:text-neutral-400"}function $e(d){return d.status==="pending"?(d.scheduledAt>9999999999?Math.floor(d.scheduledAt/1e3):d.scheduledAt)<=k.value?"Complete overdue effect":"Run scheduled effect now":d.status==="completed"||d.status==="failed"||Pe(d)?"Replay effect":"Effect is running"}function pe(d){return d.status==="pending"?(d.scheduledAt>9999999999?Math.floor(d.scheduledAt/1e3):d.scheduledAt)<=k.value?"Complete":"Run now":d.status==="completed"||d.status==="failed"||Pe(d)?"Replay":"Run"}function Fe(d){return d.status==="pending"||d.status==="completed"||d.status==="failed"||Pe(d)}function tt(d){return d.status==="pending"}function Qe(d){return tt(d)?"Cancel scheduled effect":"Effect cannot be cancelled"}function lt(d){return ae.value==="cancel"?Qe(d):$e(d)}function he(d){return ae.value==="cancel"?"Cancel effect":pe(d)}function O(d){return ae.value==="cancel"?"This will keep the effect in history as user cancelled.":d.status==="pending"?"This will execute the scheduled effect now for this thread.":"This will create a new immediate run linked back to this effect."}function se(d,h){return ue.value===d.id&&ae.value===h}function He(d){const h=d.getBoundingClientRect(),F=8,Ee=Math.min(Math.max(h.right+F,F),Math.max(F,window.innerWidth-kh-F)),ot=Math.min(Math.max(h.top-F,F),Math.max(F,window.innerHeight-160));ve.value={top:ot,left:Ee}}function de(d,h,F="run"){if(!(F==="cancel"?tt(d):Fe(d))||U.value)return;const ot=h.currentTarget;ot instanceof HTMLElement&&(L(),ue.value=d.id,ae.value=F,He(ot),document.addEventListener("pointerdown",ge),document.addEventListener("keydown",je),window.addEventListener("resize",L),window.addEventListener("scroll",L,!0))}function L(){ue.value=null,ae.value="run",ve.value=null,document.removeEventListener("pointerdown",ge),document.removeEventListener("keydown",je),window.removeEventListener("resize",L),window.removeEventListener("scroll",L,!0)}function ge(d){const h=d.target;h instanceof Node&&(oe.value?.contains(h)||L())}function je(d){d.key==="Escape"&&L()}async function Je(d){if(!(!l.threadId||!Fe(d)||U.value)){L(),y.value=null,U.value=d.id,Y.value="run";try{const h=await fetch(Ze(`/api/threads/${l.threadId}/effects/${d.id}/run`),{method:"POST"});if(!h.ok)throw new Error(await q(h,"Failed to run effect"));await Ie()}catch(h){y.value=h instanceof Error?h.message:"Failed to run effect",await Ie({quiet:!0})}finally{U.value=null,Y.value=null}}}async function qe(d){if(!(!l.threadId||!tt(d)||U.value)){L(),y.value=null,U.value=d.id,Y.value="cancel";try{const h=await fetch(Ze(`/api/threads/${l.threadId}/effects/${d.id}/cancel`),{method:"POST"});if(!h.ok)throw new Error(await q(h,"Failed to cancel effect"));await Ie()}catch(h){y.value=h instanceof Error?h.message:"Failed to cancel effect",await Ie({quiet:!0})}finally{U.value=null,Y.value=null}}}async function P(d){if(ae.value==="cancel"){await qe(d);return}await Je(d)}async function q(d,h){try{const F=await d.json();return typeof F.error=="string"?F.error:h}catch{return h}}async function Ie(d={}){if(!l.threadId){i.value=[],p.value=0,u.value=0,j.value=null;return}const h=++R,F=d.append===!0,Ee=d.quiet===!0;Ee&&(G=!0),Ee||(F?S.value=!0:I.value=!0),Ee||(v.value=null),Ee||(y.value=null);const ot=new URLSearchParams,vt=Math.min(Math.max(i.value.length,ar),200);ot.set("limit",String(F?ar:vt)),ot.set("offset",String(F?i.value.length:0));try{const gt=await fetch(Ze(`/api/threads/${l.threadId}/effects?${ot}`));if(!gt.ok)throw new Error(await q(gt,"Failed to load effects"));const ut=d0(await gt.json());return h!==R?void 0:(i.value=g0(F?[...i.value,...ut.effects]:ut.effects),p.value=ut.total,u.value=ut.upcomingCount,k.value=Date.now(),l.selectedEffectRef?!Ee&&l.active!==!1?await me(l.selectedEffectRef):Q(l.selectedEffectRef):Te(l.selectedEffectId||j.value),!0)}catch(gt){return h===R&&(!Ee||i.value.length===0)&&(v.value=gt instanceof Error?gt.message:"Failed to load effects"),!1}finally{Ee&&(G=!1),h===R&&!Ee&&(I.value=!1,S.value=!1)}}const _e=()=>{typeof document<"u"&&document.visibilityState==="visible"&&Ge.onVisible()},Ge=Jr({refresh:async()=>Ve()?(k.value=Date.now(),await Ie({quiet:!0})):!1}),A=Ca({events:{effect_changed:()=>Ge.notify()},onConnected:()=>Ge.notify()});return xe(()=>l.threadId,()=>{i.value=[],p.value=0,u.value=0,j.value=null,v.value=null,y.value=null,L(),Ie()},{immediate:!0}),xe(()=>l.selectedEffectId,d=>{d&&ie(d)}),xe(()=>l.selectedEffectRef,d=>{d&&me(d)}),xe(u,d=>r("count-changed",d),{immediate:!0}),xe(()=>[l.threadId,l.active!==!1,D.value.length>0],([d,h,F])=>{ee&&clearInterval(ee),ee=null,!(!d||!h||!F)&&(ee=setInterval(()=>{k.value=Date.now()},bh))},{immediate:!0}),xe(()=>l.active,d=>{if(!d){L();return}A.available||Ge.notify(),Ge.flush()}),xe(Ve,d=>{d&&Ge.flush()}),typeof document<"u"&&document.addEventListener("visibilitychange",_e),$t(()=>{ee&&clearInterval(ee),Ge.cancel(),L(),typeof document<"u"&&document.removeEventListener("visibilitychange",_e)}),s({selectEffectById:ie,selectEffectByReference:me}),(d,h)=>(n(),o("div",em,[z(Un,{"height-percent":$.value,"onUpdate:heightPercent":h[4]||(h[4]=F=>$.value=F),"storage-key":yh,title:"Resize effects browser and detail"},Wt({main:Be(()=>[t("div",tm,[t("div",nm,[t("div",am,[z(c(Tt),{size:15,class:"shrink-0 text-neutral-400"}),h[7]||(h[7]=t("div",{class:"truncate text-sm font-medium text-neutral-900 dark:text-neutral-100"}," Effects ",-1))]),t("div",rm,f(ze.value),1),t("button",{type:"button",class:"inline-flex h-8 w-8 items-center justify-center rounded text-neutral-500 transition-colors hover:bg-neutral-100 hover:text-neutral-950 disabled:opacity-50 dark:hover:bg-neutral-800 dark:hover:text-neutral-50",disabled:!e.threadId||I.value,title:"Refresh effects","aria-label":"Refresh effects",onClick:h[0]||(h[0]=F=>Ie())},[I.value?(n(),N(nt,{key:0,size:"xs"})):(n(),N(c(Hn),{key:1,size:15}))],8,sm)]),t("div",om,[e.threadId?I.value&&i.value.length===0?(n(),o("div",im,[z(nt)])):v.value?(n(),o("div",dm,f(v.value),1)):i.value.length===0?(n(),o("div",um,[z(c(Tt),{class:"mx-auto mb-2 h-8 w-8 opacity-40"}),h[8]||(h[8]=st(" No effects scheduled or completed ",-1))])):(n(),o("div",cm,[y.value?(n(),o("div",fm,f(y.value),1)):m("",!0),t("div",pm,[t("table",vm,[h[9]||(h[9]=t("colgroup",null,[t("col",{class:"w-24"}),t("col",{class:"w-28"}),t("col",{class:"w-56"}),t("col",{class:"w-36"}),t("col",{class:"w-40"}),t("col",{class:"w-36"}),t("col",{class:"w-20"}),t("col")],-1)),h[10]||(h[10]=t("thead",{class:"sticky top-0 z-10 border-b border-neutral-200 bg-neutral-50 text-[10px] font-medium uppercase tracking-wide text-neutral-500 dark:border-neutral-800 dark:bg-neutral-900/60 dark:text-neutral-400"},[t("tr",null,[t("th",{scope:"col",class:"px-4 py-2 font-medium"}," Actions "),t("th",{scope:"col",class:"px-4 py-2 font-medium"},"Status"),t("th",{scope:"col",class:"px-3 py-2 font-medium"},"Effect"),t("th",{scope:"col",class:"px-3 py-2 font-medium"},"Created"),t("th",{scope:"col",class:"px-3 py-2 font-medium"}," Scheduled "),t("th",{scope:"col",class:"px-3 py-2 font-medium"}," Completed "),t("th",{scope:"col",class:"px-3 py-2 text-right font-medium"}," Attempts "),t("th",{scope:"col",class:"px-4 py-2 font-medium"}," Arguments ")])],-1)),t("tbody",gm,[(n(!0),o(Re,null,Ke(Se.value,F=>(n(),o(Re,{key:F.key},[F.type==="section"?(n(),o("tr",mm,[t("th",hm,[t("span",null,f(F.label),1),t("span",xm,f(F.count),1)])])):(n(),o("tr",{key:1,ref_for:!0,ref:Ee=>we(F.effect.id,Ee),tabindex:"0","aria-selected":j.value===F.effect.id,class:K(["cursor-pointer transition-colors focus:outline-none",j.value===F.effect.id?"agents-surface-selected":"hover:bg-neutral-50 dark:hover:bg-neutral-900"]),onClick:Ee=>le(F.effect),onKeydown:[Ot(Ye(Ee=>le(F.effect),["prevent"]),["enter"]),Ot(Ye(Ee=>le(F.effect),["prevent"]),["space"]),Ee=>Me(Ee,F.effect)]},[t("td",ym,[t("div",km,[Fe(F.effect)?(n(),o("button",{key:0,type:"button",class:K(["inline-flex h-7 w-7 items-center justify-center rounded border border-neutral-300 bg-white text-neutral-950 transition-colors hover:border-neutral-400 hover:bg-neutral-50 disabled:cursor-not-allowed disabled:text-neutral-400 disabled:opacity-70 dark:border-black dark:bg-black dark:text-white dark:hover:border-neutral-950 dark:hover:bg-neutral-950 dark:disabled:text-neutral-600",{"ring-2 ring-black/10 dark:ring-white/20":se(F.effect,"run")}]),disabled:!Fe(F.effect)||!!U.value,title:$e(F.effect),"aria-label":$e(F.effect),onClick:Ye(Ee=>de(F.effect,Ee,"run"),["stop"])},[U.value===F.effect.id&&Y.value==="run"?(n(),N(nt,{key:0,size:"xs"})):F.effect.status==="completed"||F.effect.status==="failed"||Pe(F.effect)?(n(),N(c(ln),{key:1,size:14})):(n(),N(c(ia),{key:2,size:14}))],10,_m)):m("",!0),tt(F.effect)?(n(),o("button",{key:1,type:"button",class:K(["inline-flex h-7 w-7 items-center justify-center rounded border border-red-200 bg-red-50 text-red-700 transition-colors hover:border-red-300 hover:bg-red-100 disabled:cursor-not-allowed disabled:opacity-60 dark:border-red-950 dark:bg-red-950/30 dark:text-red-300 dark:hover:border-red-900 dark:hover:bg-red-950/50",{"ring-2 ring-red-500/20":se(F.effect,"cancel")}]),disabled:!!U.value,title:Qe(F.effect),"aria-label":Qe(F.effect),onClick:Ye(Ee=>de(F.effect,Ee,"cancel"),["stop"])},[U.value===F.effect.id&&Y.value==="cancel"?(n(),N(nt,{key:0,size:"xs"})):(n(),N(c(Ft),{key:1,size:14}))],10,wm)):m("",!0),!Fe(F.effect)&&!tt(F.effect)?(n(),o("span",$m," - ")):m("",!0)])]),t("td",Cm,[t("span",{class:K(["inline-flex rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide",Ue(F.effect.status)])},f(Ne(F.effect.status)),3)]),t("td",Sm,[t("div",Tm,f(F.effect.name),1),t("div",{class:"truncate text-[11px] text-neutral-400",title:F.effect.id},f(be(F.effect.id)),9,Im),J(F.effect)?(n(),o("div",Am,f(J(F.effect)),1)):m("",!0),ye(F.effect)?(n(),o("div",Em,[F.effect.replayedFrom?(n(),N(c(ln),{key:0,size:10,class:"shrink-0"})):(n(),N(c(Tt),{key:1,size:10,class:"shrink-0"})),t("span",Lm,f(ye(F.effect)),1)])):m("",!0)]),t("td",Rm,f(c(Dt)(F.effect.createdAt)),1),t("td",Mm,[t("div",Dm,f(We(F.effect)),1),E(F.effect)?(n(),o("div",Fm,f(E(F.effect)),1)):m("",!0)]),t("td",Pm,[t("div",null,f(fe(F.effect)),1),Ae(F.effect)?(n(),o("div",{key:0,class:K(["mt-0.5 text-[11px] font-medium",V(F.effect)])},f(Ae(F.effect)),3)):m("",!0)]),t("td",Nm,f(F.effect.attempts),1),t("td",zm,[t("div",{class:"truncate font-mono text-[11px] text-neutral-500 dark:text-neutral-400",title:c(Ja)(F.effect.args)},f(c(p0)(F.effect.args)),9,jm),F.effect.error?(n(),o("div",Bm,f(F.effect.error),1)):m("",!0)])],42,bm))],64))),128))])])]),H.value?(n(),o("button",{key:1,type:"button",class:"m-3 flex items-center justify-center gap-2 rounded border border-neutral-200 px-3 py-2 text-sm font-medium text-neutral-600 transition-colors hover:bg-neutral-50 disabled:opacity-50 dark:border-neutral-800 dark:text-neutral-300 dark:hover:bg-neutral-900",disabled:S.value,onClick:h[1]||(h[1]=F=>Ie({append:!0}))},[S.value?(n(),N(nt,{key:0,size:"xs"})):m("",!0),h[11]||(h[11]=t("span",null,"Load more",-1))],8,Om)):m("",!0)])):(n(),o("div",lm," Select a thread to view effects "))])])]),_:2},[re.value&&ne.value?{name:"detail",fn:Be(()=>[t("div",Vm,[t("div",Hm,[z(c(Tt),{size:15,class:"shrink-0 text-neutral-400"}),t("div",qm,[t("div",Um,f(ne.value.name),1),t("div",Wm,f(ne.value.id),1),J(ne.value)?(n(),o("div",Km,f(J(ne.value)),1)):m("",!0)]),t("span",{class:K(["shrink-0 rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide",Ue(ne.value.status)])},f(Ne(ne.value.status)),3),t("div",Jm,[Fe(ne.value)?(n(),o("button",{key:0,type:"button",class:K(["inline-flex h-8 shrink-0 items-center gap-1.5 rounded border border-neutral-300 bg-white px-2 text-xs font-medium text-neutral-950 transition-colors hover:border-neutral-400 hover:bg-neutral-50 disabled:cursor-not-allowed disabled:text-neutral-400 disabled:opacity-70 dark:border-black dark:bg-black dark:text-white dark:hover:border-neutral-950 dark:hover:bg-neutral-950 dark:disabled:text-neutral-600",{"ring-2 ring-black/10 dark:ring-white/20":se(ne.value,"run")}]),disabled:!Fe(ne.value)||!!U.value,title:$e(ne.value),"aria-label":$e(ne.value),onClick:h[2]||(h[2]=Ye(F=>de(ne.value,F,"run"),["stop"]))},[U.value===ne.value.id&&Y.value==="run"?(n(),N(nt,{key:0,size:"xs"})):ne.value.status==="completed"||ne.value.status==="failed"||Pe(ne.value)?(n(),N(c(ln),{key:1,size:14})):(n(),N(c(ia),{key:2,size:14})),t("span",null,f(pe(ne.value)),1)],10,Gm)):m("",!0),tt(ne.value)?(n(),o("button",{key:1,type:"button",class:K(["inline-flex h-8 shrink-0 items-center gap-1.5 rounded border border-red-200 bg-red-50 px-2 text-xs font-medium text-red-700 transition-colors hover:border-red-300 hover:bg-red-100 disabled:cursor-not-allowed disabled:opacity-60 dark:border-red-950 dark:bg-red-950/30 dark:text-red-300 dark:hover:border-red-900 dark:hover:bg-red-950/50",{"ring-2 ring-red-500/20":se(ne.value,"cancel")}]),disabled:!!U.value,title:Qe(ne.value),"aria-label":Qe(ne.value),onClick:h[3]||(h[3]=Ye(F=>de(ne.value,F,"cancel"),["stop"]))},[U.value===ne.value.id&&Y.value==="cancel"?(n(),N(nt,{key:0,size:"xs"})):(n(),N(c(Ft),{key:1,size:14})),h[12]||(h[12]=t("span",null,"Cancel",-1))],10,Ym)):m("",!0)])]),t("div",Qm,[t("div",null,[h[13]||(h[13]=t("div",{class:"text-[10px] font-medium uppercase tracking-wide text-neutral-500"}," Created ",-1)),t("div",Zm,f(c(Dt)(ne.value.createdAt)),1)]),t("div",null,[h[14]||(h[14]=t("div",{class:"text-[10px] font-medium uppercase tracking-wide text-neutral-500"}," Scheduled ",-1)),t("div",Xm,f(c(Dt)(ne.value.scheduledAt)),1)]),t("div",null,[h[15]||(h[15]=t("div",{class:"text-[10px] font-medium uppercase tracking-wide text-neutral-500"}," Completed ",-1)),t("div",eh,f(fe(ne.value)),1),Ae(ne.value)?(n(),o("div",{key:0,class:K(["mt-0.5 text-[11px] font-medium",V(ne.value)])},f(Ae(ne.value)),3)):m("",!0)]),t("div",null,[h[16]||(h[16]=t("div",{class:"text-[10px] font-medium uppercase tracking-wide text-neutral-500"}," Attempts ",-1)),t("div",th,f(ne.value.attempts),1)]),t("div",null,[h[17]||(h[17]=t("div",{class:"text-[10px] font-medium uppercase tracking-wide text-neutral-500"}," Source ",-1)),t("div",nh,[ke(ne.value)?(n(),o("span",ah,[ne.value.replayedFrom?(n(),N(c(ln),{key:0,size:10,class:"shrink-0"})):(n(),N(c(Tt),{key:1,size:10,class:"shrink-0"})),st(" "+f(ke(ne.value)),1)])):(n(),o("span",rh,"Automatic"))]),ne.value.manualRunAt?(n(),o("div",sh,f(c(Dt)(ne.value.manualRunAt)),1)):m("",!0)]),ne.value.replayedFrom?(n(),o("div",oh,[h[18]||(h[18]=t("div",{class:"text-[10px] font-medium uppercase tracking-wide text-neutral-500"}," Rerun Of ",-1)),t("div",lh,[z(c(ln),{size:10,class:"shrink-0"}),t("span",ih,f(ne.value.replayedFrom),1)])])):m("",!0)]),ne.value.error?(n(),o("div",dh,f(ne.value.error),1)):m("",!0),t("div",uh,[h[19]||(h[19]=t("div",{class:"border-b border-neutral-200 px-3 py-2 text-[10px] font-medium uppercase tracking-wide text-neutral-500 dark:border-neutral-800"}," Arguments ",-1)),z($a,{"model-value":Ce.value,class:"min-h-0 flex-1",language:"json",readonly:"","word-wrap":"on",framed:!1},null,8,["model-value"])])])]),key:"0"}:void 0]),1032,["height-percent"]),(n(),N(ks,{to:"body"},[e.active&&Le.value&&ve.value?(n(),o("div",{key:0,ref_key:"actionPopoverRef",ref:oe,class:"fixed z-[9999] w-[260px] border border-neutral-200 bg-white p-3 text-xs shadow-lg dark:border-neutral-800 dark:bg-neutral-950",style:bt(B.value),onClick:h[6]||(h[6]=Ye(()=>{},["stop"]))},[t("div",ch,[ae.value==="cancel"?(n(),N(c(Ft),{key:0,size:14,class:"mt-0.5 shrink-0 text-red-600 dark:text-red-300"})):(n(),N(c(Tt),{key:1,size:14,class:"mt-0.5 shrink-0 text-amber-600 dark:text-amber-300"})),t("div",fh,[t("div",ph,f(lt(Le.value)),1),t("div",vh,f(O(Le.value)),1),t("div",gh,[t("span",mh,f(Le.value.name),1)]),t("div",hh,f(Le.value.id),1)])]),t("div",xh,[t("button",{type:"button",class:"rounded border border-neutral-200 px-2 py-1 text-neutral-600 transition-colors hover:bg-neutral-50 hover:text-neutral-950 dark:border-neutral-800 dark:text-neutral-300 dark:hover:bg-neutral-900 dark:hover:text-neutral-50",onClick:L},f(ae.value==="cancel"?"Keep scheduled":"Cancel"),1),t("button",{type:"button",class:K(["rounded px-2 py-1 font-medium transition-opacity hover:opacity-85",ae.value==="cancel"?"bg-red-600 text-white hover:opacity-85 dark:bg-red-500 dark:text-white":"bg-neutral-900 text-white dark:bg-neutral-100 dark:text-neutral-950"]),onClick:h[5]||(h[5]=F=>P(Le.value))},f(he(Le.value)),3)])],4)):m("",!0)]))]))}}),Kt=e=>(e.startsWith("/")?e:`/${e}`).replace(/\/+/g,"/"),Dn=(e,s,a)=>{const l=Kt(e),r=Kt(s),i=Kt(a);return l===r?i:l.startsWith(`${r}/`)?`${i}${l.slice(r.length)}`:l},aa=e=>e.mimeType.startsWith("image/"),Sa=(e,s)=>aa(e)!==aa(s)?aa(e)?-1:1:e.path.localeCompare(s.path);function Gr(e,s){const a=s,l=typeof a?.path=="string"?a.path:null,r=a?.file;if(!l||!r||typeof r!="object"||r.isDirectory)return null;const i=Kt(l),p={path:i,name:typeof r.name=="string"&&r.name?r.name:i.split("/").filter(Boolean).pop()??i,mimeType:typeof r.mimeType=="string"&&r.mimeType?r.mimeType:"application/octet-stream",size:typeof r.size=="number"?r.size:0,isDirectory:!1,createdAt:typeof r.createdAt=="number"?r.createdAt:void 0,updatedAt:typeof r.updatedAt=="number"?r.updatedAt:void 0},u=e.filter(I=>I.path!==i);return u.push(p),u.sort(Sa)}function wh(e,s){const a=s;if(typeof a?.path!="string")return null;const l=Kt(a.path),r=`${l}/`;return e.filter(i=>i.path!==l&&!i.path.startsWith(r))}function $h(e,s){const a=s;if(typeof a?.from!="string"||typeof a.path!="string")return null;const l=Kt(a.from),r=Kt(a.path);let i=e.map(p=>{const u=Dn(p.path,l,r);return u===p.path?p:{...p,path:u,name:u.split("/").filter(Boolean).pop()??u}});return a.file&&a.file.isDirectory!==!0&&(i=Gr(i,{path:r,file:a.file})??i),i.sort(Sa)}const Ch={class:"flex h-full min-h-0 flex-col overflow-hidden"},Sh={class:"flex items-center justify-between gap-3 border-b border-neutral-200 px-3 py-2 dark:border-neutral-800"},Th={class:"min-w-0 flex items-center gap-1 overflow-hidden text-xs","aria-label":"File path"},Ih=["onClick"],Ah={class:"flex shrink-0 items-center gap-1"},Eh=["disabled"],Lh=["disabled"],Rh={class:"min-h-0 flex-1 overflow-auto p-3"},Mh={key:0,class:"py-12 text-center text-sm text-neutral-500"},Dh={key:1,class:"flex justify-center py-12"},Fh={key:2,class:"py-12 text-center text-sm text-red-600 dark:text-red-400"},Ph={key:3,class:"py-12 text-center text-sm text-neutral-500"},Nh={key:4,class:"space-y-0.5"},zh=["onClick","onDblclick","onKeydown"],jh={key:1,class:"w-3 shrink-0"},Bh={key:3,class:"flex h-7 w-7 shrink-0 items-center justify-center overflow-hidden rounded border border-neutral-200 bg-neutral-100 dark:border-neutral-700 dark:bg-neutral-900"},Oh=["src","alt"],Vh={key:4,class:"flex h-7 w-7 shrink-0 items-center justify-center rounded border border-neutral-200 bg-neutral-100 dark:border-neutral-700 dark:bg-neutral-900"},Hh={class:"min-w-0 flex-1 truncate"},qh={key:5,class:"text-[10px] text-neutral-400"},Uh={key:6,class:"text-[10px] text-neutral-400"},Wh={key:5,class:"grid grid-cols-[repeat(auto-fill,minmax(112px,1fr))] gap-3"},Kh=["onClick","onKeydown"],Jh={class:"mb-2 flex aspect-square items-center justify-center overflow-hidden rounded bg-neutral-100 dark:bg-neutral-950"},Gh=["src","alt"],Yh={class:"truncate text-xs font-medium"},Qh={class:"mt-0.5 text-[10px] text-neutral-400"},Zh={class:"flex h-full min-h-0 flex-col overflow-hidden"},Xh={class:"flex items-center justify-between border-b border-neutral-200 px-3 py-2 dark:border-neutral-800"},ex={class:"min-w-0"},tx={class:"truncate text-sm font-semibold"},nx={class:"truncate text-[11px] font-mono text-neutral-500"},ax={class:"flex shrink-0 items-center gap-1.5"},rx=["disabled"],sx=["href","download"],ox={key:0,class:"grid grid-cols-[120px_minmax(0,1fr)] gap-2 text-sm"},lx={class:"font-mono"},ix={class:"break-all font-mono"},dx={key:1,class:"flex h-full items-center justify-center"},ux={key:2,class:"text-sm text-red-600 dark:text-red-400"},cx=["src","alt"],fx={key:0,class:"mb-3 rounded border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/70 dark:bg-red-950/30 dark:text-red-300"},px={key:5,class:"grid grid-cols-[120px_minmax(0,1fr)] gap-2 text-sm"},vx={class:"font-mono"},gx={class:"font-mono"},mx={class:"break-all font-mono"},hx="agentbuilder.threads.filePreviewSplitPercent",xx=at({__name:"ThreadFilesPane",props:{threadId:{},path:{},refreshKey:{},active:{type:Boolean,default:!0}},emits:["update:path","count-changed"],setup(e,{emit:s}){const a=e,l=s,r=b([]),i=b(!1),p=b(!1),u=b(!1),I=b(null),S=b("tree"),y=b("/"),v=b(null),k=b(new Set(["/"])),j=b(!1),$=b(null),W=b(!1),U=b(null),Y=b(""),ue=b(null),ae=b(50),oe=b(null),ve=b(new Map);let ee=!1;const G=A=>(A.startsWith("/")?A:`/${A}`).replace(/\/+/g,"/"),R=A=>A.replace(/^\/+/,"").split("/").map(d=>encodeURIComponent(d)).join("/"),H=(A,d="")=>{const h=typeof A=="string"?A:A.path;if(!a.threadId)return"";const F=d?`?${d}`:"";return Ze(`/api/threads/${a.threadId}/fs/${R(h)}${F}`)},D=A=>H(A),X=A=>{const d=A.name.toLowerCase();return d.endsWith(".vue")?"html":A.mimeType.includes("json")||d.endsWith(".json")?"json":d.endsWith(".md")||d.endsWith(".markdown")?"markdown":d.endsWith(".ts")||d.endsWith(".tsx")?"typescript":d.endsWith(".js")||d.endsWith(".jsx")?"javascript":d.endsWith(".css")?"css":d.endsWith(".scss")?"scss":d.endsWith(".html")?"html":d.endsWith(".yml")||d.endsWith(".yaml")?"yaml":d.endsWith(".sh")||d.endsWith(".bash")?"shell":d.endsWith(".py")?"python":d.endsWith(".xml")||A.mimeType.includes("xml")?"xml":"plaintext"},Se=A=>{if(!A)return"0 B";const d=["B","KB","MB","GB"],h=Math.min(Math.floor(Math.log(A)/Math.log(1024)),d.length-1);return`${(A/1024**h).toFixed(h===0?0:1)} ${d[h]}`},ne=A=>`${A} ${A===1?"item":"items"}`,Le=A=>A?.mimeType?.startsWith("image/"),B=new Set([".bash",".css",".html",".js",".jsx",".json",".md",".markdown",".py",".scss",".sh",".ts",".tsx",".txt",".vue",".xml",".yaml",".yml"]),re=A=>{if(!A)return!1;const d=A.name.toLowerCase();return A.mimeType.startsWith("text/")||A.mimeType.includes("json")||A.mimeType.includes("xml")||A.mimeType.includes("javascript")||A.mimeType.includes("typescript")||[...B].some(h=>d.endsWith(h))},Ce=A=>A?Le(A)?vr:A.mimeType.startsWith("audio/")?Cs:A.mimeType.startsWith("video/")?Ss:re(A)?A.mimeType.includes("json")||A.mimeType.includes("javascript")?Ts:gr:Pn:Pn,ze=()=>{const A=new Set(["/"]);for(const d of r.value){const h=G(d.path).split("/").filter(Boolean);let F="";for(const Ee of h.slice(0,-1))F+="/"+Ee,A.add(F)}return A},Ve=()=>{k.value=ze()},Te=async(A,d)=>{try{const h=await A.json();return typeof h.error=="string"?h.error:d}catch{return d}},le=A=>A?`${A.path}|${A.size}|${A.updatedAt??""}|${A.mimeType}`:"",we=async(A={})=>{if(!a.threadId){r.value=[];return}const d=A.quiet===!0;if(!(d&&ee)){d?ee=!0:(i.value=!0,I.value=null);try{const h=await fetch(Ze(`/api/threads/${a.threadId}/fs?find=**/*&type=file`));if(!h.ok)throw new Error("Failed to load files");const F=await h.json();r.value=(F.files||[]).filter(Ee=>!Ee.isDirectory).map(Ee=>({...Ee,path:G(Ee.path)})).sort(Sa),S.value==="tree"&&r.value.length>0&&!j.value&&(Ve(),j.value=!0)}catch(h){d||(I.value=h instanceof Error?h.message:"Failed to load files")}finally{d?ee=!1:i.value=!1}}},ce=C(()=>{const A={type:"directory",name:"",path:"/",children:[]},d=new Map([["/",A]]);for(const F of r.value){const Ee=G(F.path).split("/").filter(Boolean);let ot=A,vt="";for(const gt of Ee.slice(0,-1)){vt=`${vt}/${gt}`;let ut=d.get(vt);ut||(ut={type:"directory",name:gt,path:vt,children:[]},d.set(vt,ut),ot.children.push(ut)),ot=ut}ot.children.push({type:"file",name:F.name||Ee[Ee.length-1],path:F.path,file:F,children:[]})}const h=F=>{F.children.sort((Ee,ot)=>Ee.type!==ot.type?Ee.type==="directory"?-1:1:Ee.name.localeCompare(ot.name)),F.children.forEach(h)};return h(A),A}),te=C(()=>{if(y.value==="/")return ce.value;const A=y.value.split("/").filter(Boolean);let d=ce.value;for(const h of A){const F=d.children.find(Ee=>Ee.type==="directory"&&Ee.name===h);if(!F)return ce.value;d=F}return d}),ie=C(()=>te.value.children),me=C(()=>[...ie.value].sort((A,d)=>A.type!==d.type?A.type==="file"?-1:1:A.file&&d.file&&Le(A.file)!==Le(d.file)?Le(A.file)?-1:1:A.name.localeCompare(d.name))),Q=C(()=>{const A=[],d=(h,F)=>{for(const Ee of h)A.push({node:Ee,depth:F}),Ee.type==="directory"&&k.value.has(Ee.path)&&d(Ee.children,F+1)};return d(te.value.children,0),A}),Me=C(()=>{if(S.value==="tree"){const A=y.value!=="/"?[{key:"__up__",kind:"up"}]:[];return A.push(...Q.value.map(d=>({key:d.node.path,kind:"node",node:d.node}))),A}return me.value.map(A=>({key:A.path,kind:"node",node:A}))}),Ne=C(()=>v.value?r.value.find(A=>A.path===v.value)??null:null),Ue=C(()=>Ne.value?X(Ne.value):"plaintext"),We=C(()=>le(Ne.value)),E=C(()=>!!Ne.value&&$.value!==null&&re(Ne.value)),fe=C(()=>E.value&&Y.value!==($.value??"")),be=C(()=>{const A=Ne.value;if(!A)return!1;const d=A.mimeType.toLowerCase();return Le(A)||re(A)||d==="application/pdf"||d.startsWith("audio/")||d.startsWith("video/")}),Pe=(A,d)=>{if(A.path===d)return A;for(const h of A.children){const F=Pe(h,d);if(F)return F}return null},J=C(()=>{if(!v.value)return null;const A=Pe(ce.value,v.value);return A?.type==="directory"?A:null}),ke=C(()=>{const A=y.value.split("/").filter(Boolean),d=[{label:"Files",path:"/"}];let h="";for(const F of A)h+=`/${F}`,d.push({label:F,path:h});return d}),ye=A=>{if(v.value=A.path,A.type==="directory"){y.value=A.path,k.value.add(A.path),k.value=new Set(k.value);return}},Ae=A=>{v.value=A.path,k.value.has(A.path)?k.value.delete(A.path):k.value.add(A.path),k.value=new Set(k.value)},V=async(A,d={})=>{const h=d.quiet===!0;if(!(fe.value&&v.value===A.path)&&(h||($.value=null,U.value=null,Y.value=""),!!re(A))){h||(W.value=!0);try{const F=await fetch(H(A));if(!F.ok)throw new Error("Failed to load preview");const Ee=await F.text();v.value===A.path&&!fe.value&&($.value=Ee,Y.value=Ee,U.value=null)}catch(F){h||(U.value=F instanceof Error?F.message:"Failed to load preview")}finally{h||(W.value=!1)}}},$e=async()=>{!Ne.value||!re(Ne.value)||fe.value||await V(Ne.value,{quiet:!0})},pe=async()=>{!a.threadId||p.value||u.value||(await we({quiet:!0}),await $e())},Fe=A=>{const d=Gr(r.value,A);if(!d)return;r.value=d;const h=A?.path;typeof h=="string"&&v.value===G(h)&&$e()},lt=Ca({events:{file_moved:A=>{const d=$h(r.value,A),h=A;!d||typeof h?.from!="string"||typeof h.path!="string"||(r.value=d,y.value=Dn(y.value,h.from,h.path),v.value&&(v.value=Dn(v.value,h.from,h.path)),k.value=new Set([...k.value].map(F=>Dn(F,h.from,h.path))))},file_created:Fe,file_updated:Fe,file_deleted:A=>{const d=wh(r.value,A);d&&(r.value=d)}},onConnected:()=>{pe()}}),he=A=>{const d=new TextEncoder().encode(A);let h="";for(const F of d)h+=String.fromCharCode(F);return btoa(h)},O=()=>{Y.value=$.value??"",ue.value=null},se=async()=>{const A=Ne.value;if(!(!A||!a.threadId)){u.value=!0,ue.value=null;try{const d=await fetch(H(A),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:he(Y.value),mimeType:A.mimeType||"text/plain"})});if(!d.ok)throw new Error(await Te(d,"Failed to save file"));$.value=Y.value,await we({quiet:!0})}catch(d){ue.value=d instanceof Error?d.message:"Failed to save file"}finally{u.value=!1}}},He=async A=>{const d=A.target;if(!(!a.threadId||!d.files?.length)){p.value=!0,I.value=null;try{for(const h of Array.from(d.files)){const F=y.value==="/"?`/${h.name}`:`${y.value}/${h.name}`;if(!(await fetch(H(F),{method:"POST",headers:{"Content-Type":h.type||"application/octet-stream"},body:h})).ok)throw new Error(`Failed to upload ${h.name}`)}await we()}catch(h){I.value=h instanceof Error?h.message:"Upload failed"}finally{p.value=!1,d.value=""}}},de=b(new Set);xe(()=>a.threadId,()=>{y.value=G(a.path||"/"),v.value=null,$.value=null,U.value=null,Y.value="",ue.value=null,k.value=new Set(["/"]),j.value=!1,de.value=new Set,we()},{immediate:!0}),xe(r,A=>{l("count-changed",A.length)},{immediate:!0}),xe(()=>a.refreshKey,()=>{a.threadId&&we()}),xe(()=>a.active,A=>{A&&!lt.available&&pe()});const L=b(!1),ge=A=>{const d=A.lastIndexOf("/");return d<=0?"/":A.slice(0,d)},je=A=>{const d=A.split("/").filter(Boolean);let h="";k.value.add("/");for(let F=0;F<d.length-1;F++)h+="/"+d[F],k.value.add(h);k.value=new Set(k.value)},Je=()=>{const A=ge(y.value);y.value=A,v.value=A==="/"?null:A,k.value.add(A),k.value=new Set(k.value)},qe=(A,d)=>{d instanceof HTMLElement?ve.value.set(A,d):ve.value.delete(A)},P=async A=>{await et(),ve.value.get(A)?.focus({preventScroll:!0})},q=A=>{A.kind==="node"&&ye(A.node)},Ie=(A,d)=>{const h=Me.value,F=h.findIndex(ot=>ot.key===A);if(F<0)return;const Ee=h[Math.min(h.length-1,Math.max(0,F+d))];Ee&&(q(Ee),P(Ee.key))},_e=A=>{const d=Me.value,h=A==="start"?d[0]:d[d.length-1];h&&(q(h),P(h.key))},Ge=(A,d)=>{if(A.key==="ArrowDown"){A.preventDefault(),Ie(d.key,1);return}if(A.key==="ArrowUp"){A.preventDefault(),Ie(d.key,-1);return}if(A.key==="Home"){A.preventDefault(),_e("start");return}if(A.key==="End"){A.preventDefault(),_e("end");return}S.value!=="tree"||d.kind!=="node"||d.node.type!=="directory"||(A.key==="ArrowRight"&&!k.value.has(d.node.path)?(A.preventDefault(),k.value.add(d.node.path),k.value=new Set(k.value)):A.key==="ArrowLeft"&&k.value.has(d.node.path)&&(A.preventDefault(),k.value.delete(d.node.path),k.value=new Set(k.value)))};return xe([()=>a.path,r],async([A])=>{const d=G(A||"/");let h=r.value.find(Ee=>Ee.path===d&&!Ee.isDirectory);const F=d!=="/"&&/\.[a-z0-9]+$/i.test(d);if(!h&&F&&A&&!de.value.has(d)&&(de.value.add(d),await we(),h=r.value.find(Ee=>Ee.path===d&&!Ee.isDirectory)),h){const Ee=S.value==="tree"?"/":ge(d);v.value=d,je(d),y.value!==Ee&&(L.value=!0,y.value=Ee)}else y.value!==d&&(L.value=!0,y.value=d)}),xe(S,A=>{A==="tree"&&(r.value.length>0&&!j.value&&(Ve(),j.value=!0),Ne.value&&y.value!=="/"&&(je(Ne.value.path),L.value=!0,y.value="/"))}),xe(y,A=>{if(L.value){L.value=!1;return}l("update:path",G(A))}),xe(v,()=>{$.value=null,U.value=null,Y.value="",ue.value=null}),xe(We,()=>{const A=Ne.value;A?V(A):(Y.value="",ue.value=null,$.value=null,U.value=null)}),xe(J,()=>{Y.value="",ue.value=null,$.value=null,U.value=null}),(A,d)=>(n(),N(Un,{"height-percent":ae.value,"onUpdate:heightPercent":d[5]||(d[5]=h=>ae.value=h),"storage-key":hx,title:"Resize files and preview"},Wt({main:Be(()=>[t("div",Ch,[t("div",Sh,[t("nav",Th,[(n(!0),o(Re,null,Ke(ke.value,(h,F)=>(n(),o(Re,{key:h.path},[F>0?(n(),N(c(Bt),{key:0,size:13,class:"shrink-0 text-neutral-300 dark:text-neutral-600"})):m("",!0),t("button",{type:"button",class:K(["min-w-0 truncate rounded border px-1.5 py-1 font-medium transition-colors",F===ke.value.length-1?"border-transparent agents-surface-selected agents-text-selected shadow-sm":"border-transparent text-neutral-500 hover:bg-neutral-100 hover:text-neutral-900 dark:text-neutral-400 dark:hover:bg-neutral-800 dark:hover:text-neutral-100"]),onClick:Ee=>y.value=h.path},f(h.label),11,Ih)],64))),128))]),t("div",Ah,[t("button",{type:"button",class:K(["inline-flex h-7 w-7 items-center justify-center rounded border",S.value==="tree"?"border-transparent agents-surface-selected agents-text-selected":"border-transparent text-neutral-500 hover:bg-neutral-100 dark:hover:bg-neutral-800"]),title:"Tree view",onClick:d[0]||(d[0]=h=>S.value="tree")},[z(c(_s),{size:15})],2),t("button",{type:"button",class:K(["inline-flex h-7 w-7 items-center justify-center rounded border",S.value==="grid"?"border-transparent agents-surface-selected agents-text-selected":"border-transparent text-neutral-500 hover:bg-neutral-100 dark:hover:bg-neutral-800"]),title:"Grid view",onClick:d[1]||(d[1]=h=>S.value="grid")},[z(c(ws),{size:15})],2),t("button",{type:"button",class:"inline-flex h-7 w-7 items-center justify-center rounded text-neutral-500 hover:bg-neutral-100 hover:text-neutral-950 disabled:opacity-50 dark:hover:bg-neutral-800 dark:hover:text-neutral-50",disabled:!e.threadId||i.value,title:"Refresh files",onClick:we},[i.value?(n(),N(nt,{key:0,size:"xs"})):(n(),N(c(Hn),{key:1,size:15}))],8,Eh),t("input",{ref_key:"fileInput",ref:oe,type:"file",multiple:"",class:"hidden",onChange:He},null,544),t("button",{type:"button",class:"inline-flex h-7 w-7 items-center justify-center rounded text-neutral-500 hover:bg-neutral-100 hover:text-neutral-950 disabled:opacity-50 dark:hover:bg-neutral-800 dark:hover:text-neutral-50",disabled:!e.threadId||p.value,title:"Upload files",onClick:d[2]||(d[2]=h=>oe.value?.click())},[p.value?(n(),N(nt,{key:0,size:"xs"})):(n(),N(c($s),{key:1,size:15}))],8,Lh)])]),t("div",Rh,[e.threadId?i.value?(n(),o("div",Dh,[z(nt)])):I.value?(n(),o("div",Fh,f(I.value),1)):r.value.length===0?(n(),o("div",Ph," No files yet ")):S.value==="tree"?(n(),o("div",Nh,[y.value!=="/"?(n(),o("button",{key:0,ref:h=>qe("__up__",h),type:"button",class:"flex w-full items-center gap-2 rounded py-1.5 pr-2 text-left text-xs hover:bg-neutral-100 dark:hover:bg-neutral-800",style:{paddingLeft:"8px"},onClick:Je,onKeydown:d[3]||(d[3]=h=>Ge(h,{key:"__up__",kind:"up"}))},[d[6]||(d[6]=t("span",{class:"w-3 shrink-0"},null,-1)),z(c(Jn),{size:15,class:"shrink-0 text-amber-500"}),d[7]||(d[7]=t("span",{class:"min-w-0 flex-1 font-mono"},"..",-1))],544)):m("",!0),(n(!0),o(Re,null,Ke(Q.value,h=>(n(),o("button",{key:h.node.path,ref_for:!0,ref:F=>qe(h.node.path,F),type:"button",class:K(["flex w-full items-center gap-2 rounded py-1.5 pr-2 text-left text-xs",v.value===h.node.path?"agents-surface-selected agents-text-selected":"hover:bg-neutral-100 dark:hover:bg-neutral-800"]),style:bt({paddingLeft:`${8+h.depth*18}px`}),onClick:F=>h.node.type==="directory"?Ae(h.node):ye(h.node),onDblclick:F=>h.node.type==="directory"?ye(h.node):void 0,onKeydown:F=>Ge(F,{key:h.node.path,kind:"node",node:h.node})},[h.node.type==="directory"?(n(),N(c(Bt),{key:0,size:12,class:K(["shrink-0 text-neutral-400 transition-transform",k.value.has(h.node.path)?"rotate-90":""])},null,8,["class"])):(n(),o("span",jh)),h.node.type==="directory"?(n(),N(c(Jn),{key:2,size:15,class:"shrink-0 text-amber-500"})):h.node.file&&Le(h.node.file)?(n(),o("span",Bh,[t("img",{src:D(h.node.file),alt:h.node.name,class:"h-full w-full object-cover",loading:"lazy"},null,8,Oh)])):(n(),o("span",Vh,[(n(),N(At(Ce(h.node.file)),{size:15,class:"text-neutral-500"}))])),t("span",Hh,f(h.node.name),1),h.node.type==="directory"?(n(),o("span",qh,f(ne(h.node.children.length)),1)):(n(),o("span",Uh,f(Se(h.node.file?.size||0)),1))],46,zh))),128))])):(n(),o("div",Wh,[(n(!0),o(Re,null,Ke(me.value,h=>(n(),o("button",{key:h.path,ref_for:!0,ref:F=>qe(h.path,F),type:"button",class:K(["group min-w-0 rounded-lg border p-2 text-left",v.value===h.path?"agents-border-selected agents-surface-selected":"border-neutral-200 bg-white hover:border-neutral-300 hover:bg-neutral-50 dark:border-neutral-800 dark:bg-neutral-900 dark:hover:border-neutral-700 dark:hover:bg-neutral-800"]),onClick:F=>ye(h),onKeydown:F=>Ge(F,{key:h.path,kind:"node",node:h})},[t("div",Jh,[h.file&&Le(h.file)?(n(),o("img",{key:0,src:D(h.file),alt:h.name,class:"h-full w-full object-cover",loading:"lazy"},null,8,Gh)):h.type==="directory"?(n(),N(c(Jn),{key:1,size:28,class:"text-amber-500"})):(n(),N(At(Ce(h.file)),{key:2,size:28,class:"text-neutral-500"}))]),t("div",Yh,f(h.name),1),t("div",Qh,f(h.type==="directory"?ne(h.children.length):Se(h.file?.size||0)),1)],42,Kh))),128))])):(n(),o("div",Mh," Select a thread to view files "))])])]),_:2},[Ne.value||J.value?{name:"detail",fn:Be(()=>[t("div",Zh,[t("div",Xh,[t("div",ex,[t("div",tx,f(Ne.value?.name||J.value?.name||"Files"),1),t("div",nx,f(Ne.value?.path||J.value?.path),1)]),t("div",ax,[Ne.value&&E.value?(n(),o(Re,{key:0},[t("button",{type:"button",class:"inline-flex h-8 items-center gap-1.5 rounded bg-neutral-900 px-2.5 text-sm font-medium text-white transition-colors hover:bg-neutral-700 disabled:opacity-50 dark:bg-neutral-100 dark:text-neutral-950 dark:hover:bg-neutral-300",disabled:u.value||!fe.value,onClick:se},[u.value?(n(),N(nt,{key:0,size:"xs"})):(n(),N(c(_r),{key:1,size:14})),d[8]||(d[8]=t("span",null,"Save",-1))],8,rx),fe.value?(n(),o("button",{key:0,type:"button",class:"inline-flex h-8 w-8 items-center justify-center rounded text-neutral-500 transition-colors hover:bg-neutral-100 hover:text-neutral-950 dark:hover:bg-neutral-800 dark:hover:text-neutral-50",title:"Cancel","aria-label":"Cancel file edit",onClick:O},[z(c(Ft),{size:15})])):m("",!0)],64)):m("",!0),Ne.value?(n(),o("a",{key:1,href:H(Ne.value),target:"_blank",rel:"noopener noreferrer",download:be.value?void 0:Ne.value.name,class:"shrink-0 rounded border border-neutral-200 px-2 py-1 text-xs font-medium hover:bg-neutral-50 dark:border-neutral-700 dark:hover:bg-neutral-800"},f(be.value?"Open":"Download"),9,sx)):m("",!0)])]),t("div",{class:K(["min-h-0 flex-1",$.value!==null&&!W.value&&!U.value&&!J.value&&!Le(Ne.value)?"flex flex-col overflow-hidden p-3":"overflow-auto p-3"])},[J.value?(n(),o("dl",ox,[d[9]||(d[9]=t("dt",{class:"text-neutral-500"},"Type",-1)),d[10]||(d[10]=t("dd",{class:"font-mono"},"directory",-1)),d[11]||(d[11]=t("dt",{class:"text-neutral-500"},"Items",-1)),t("dd",lx,f(ne(J.value.children.length)),1),d[12]||(d[12]=t("dt",{class:"text-neutral-500"},"Path",-1)),t("dd",ix,f(J.value.path),1)])):W.value?(n(),o("div",dx,[z(nt)])):U.value?(n(),o("div",ux,f(U.value),1)):Le(Ne.value)?(n(),o("img",{key:3,src:H(Ne.value),alt:Ne.value.name,class:"mx-auto max-h-full max-w-full rounded border border-neutral-200 object-contain dark:border-neutral-800"},null,8,cx)):$.value!==null?(n(),o(Re,{key:4},[ue.value?(n(),o("div",fx,f(ue.value),1)):m("",!0),E.value?(n(),N($a,{key:1,modelValue:Y.value,"onUpdate:modelValue":d[4]||(d[4]=h=>Y.value=h),language:Ue.value,class:"min-h-[12rem] flex-1",framed:!1},null,8,["modelValue","language"])):m("",!0)],64)):(n(),o("dl",px,[d[13]||(d[13]=t("dt",{class:"text-neutral-500"},"Type",-1)),t("dd",vx,f(Ne.value.mimeType||"application/octet-stream"),1),d[14]||(d[14]=t("dt",{class:"text-neutral-500"},"Size",-1)),t("dd",gx,f(Se(Ne.value.size)),1),d[15]||(d[15]=t("dt",{class:"text-neutral-500"},"Path",-1)),t("dd",mx,f(Ne.value.path),1)]))],2)])]),key:"0"}:void 0]),1032,["height-percent"]))}});function bx(e){const s=e&&typeof e=="object"?e:{},a=Array.isArray(s.values)?s.values:[];return{values:a.filter(l=>!!l&&typeof l=="object").filter(l=>typeof l.key=="string").map(l=>({key:l.key,value:l.value,serialized:typeof l.serialized=="string"?l.serialized:Yr(l.value),size:typeof l.size=="number"&&Number.isFinite(l.size)?l.size:0,updatedAt:typeof l.updatedAt=="number"&&Number.isFinite(l.updatedAt)?l.updatedAt:0,parseError:typeof l.parseError=="string"?l.parseError:void 0})),total:typeof s.total=="number"&&Number.isFinite(s.total)?s.total:a.length,limit:typeof s.limit=="number"&&Number.isFinite(s.limit)?s.limit:a.length,offset:typeof s.offset=="number"&&Number.isFinite(s.offset)?s.offset:0,search:typeof s.search=="string"?s.search:null}}function Yr(e){const s=JSON.stringify(e,null,2);return s===void 0?"":s}function yx(e){try{const s=JSON.parse(e);return s===null?{ok:!1,error:"Use delete to remove a key"}:{ok:!0,value:s}}catch(s){return{ok:!1,error:s instanceof Error?s.message:"Invalid JSON"}}}function ra(e,s){return s?"unknown":Array.isArray(e)?"array":typeof e=="string"?"string":typeof e=="number"?"number":typeof e=="boolean"?"boolean":e&&typeof e=="object"?"object":"unknown"}function kx(e,s){if(s)return"Stored value is not valid JSON";if(Array.isArray(e))return`${e.length} ${e.length===1?"item":"items"}`;if(typeof e=="string")return e.length>80?`${e.slice(0,77)}...`:e;if(typeof e=="number"||typeof e=="boolean")return String(e);if(e&&typeof e=="object"){const a=Object.keys(e).length;return`${a} ${a===1?"key":"keys"}`}return"Unknown"}function rr(e){if(!Number.isFinite(e)||e<=0)return"0 B";const s=["B","KB","MB"],a=Math.min(Math.floor(Math.log(e)/Math.log(1024)),s.length-1);return`${(e/1024**a).toFixed(a===0?0:1)} ${s[a]}`}function sr(e){if(!Number.isFinite(e)||e<=0)return"Unknown";const s=e>9999999999?Math.floor(e/1e3):e;return new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(new Date(s))}const _x={class:"flex h-full min-h-0 flex-col overflow-hidden"},wx={class:"flex items-center gap-2 border-b border-neutral-200 px-3 py-2 dark:border-neutral-800"},$x={class:"relative min-w-0 flex-1"},Cx={class:"hidden shrink-0 text-xs tabular-nums text-neutral-500 sm:block"},Sx=["disabled"],Tx=["disabled"],Ix={class:"min-h-0 flex-1 overflow-auto"},Ax={key:0,class:"py-12 text-center text-sm text-neutral-500"},Ex={key:1,class:"flex justify-center py-12"},Lx={key:2,class:"py-12 text-center text-sm text-red-600 dark:text-red-400"},Rx={key:3,class:"py-12 text-center text-sm text-neutral-500"},Mx={key:4,class:"flex min-h-full flex-col"},Dx={class:"min-h-0 flex-1 overflow-auto bg-white dark:bg-neutral-950"},Fx={class:"w-full min-w-[52rem] table-fixed text-left text-xs"},Px={class:"divide-y divide-neutral-100 dark:divide-neutral-900"},Nx=["aria-selected","onClick","onKeydown"],zx={class:"whitespace-nowrap px-4 py-2 align-middle"},jx={class:"font-mono text-xs font-normal text-neutral-950 dark:text-neutral-100"},Bx={class:"min-w-0 px-3 py-2 align-middle"},Ox={class:"truncate text-xs text-neutral-500 dark:text-neutral-400"},Vx={class:"whitespace-nowrap px-3 py-2 align-middle"},Hx={class:"whitespace-nowrap px-3 py-2 text-right align-middle text-[11px] tabular-nums text-neutral-400"},qx={class:"whitespace-nowrap px-4 py-2 text-right align-middle text-[11px] text-neutral-400"},Ux=["disabled"],Wx={class:"flex h-full min-h-0 flex-col overflow-hidden"},Kx={class:"flex items-center justify-between gap-3 border-b border-neutral-200 px-3 py-2 dark:border-neutral-800"},Jx={class:"min-w-0 flex-1"},Gx={key:0,class:"flex items-center gap-2"},Yx={key:1,class:"mt-0.5 truncate text-[11px] text-neutral-500"},Qx={class:"flex shrink-0 items-center gap-1.5"},Zx=["disabled"],Xx=["disabled"],eb={class:"flex min-h-0 flex-1 flex-col overflow-hidden p-3"},tb={key:0,class:"mb-3 rounded border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/70 dark:bg-red-950/30 dark:text-red-300"},nb="agentbuilder.threads.kvStoreDetailSplitPercent",or=100,Zt=`{
21
-
22
- }`,ab=at({__name:"ThreadKvStorePane",props:{threadId:{},active:{type:Boolean,default:!0}},emits:["count-changed"],setup(e,{emit:s}){const a=e,l=s,r=b([]),i=b(0),p=b(""),u=b(!1),I=b(!1),S=b(!1),y=b(!1),v=b(null),k=b(null),j=b(null),$=b("view"),W=b(""),U=b(Zt),Y=b(null),ue=b(Zt),ae=b(50),oe=b(new Map);let ve=null,ee=!1,G=0;const R=()=>{typeof document<"u"&&document.visibilityState==="visible"&&be.onVisible()},H=C(()=>j.value?r.value.find(J=>J.key===j.value)??null:null),D=C(()=>r.value.length<i.value),X=C(()=>{const J=r.value.length;return a.threadId?i.value===0?p.value.trim()?"No matches":"No values":`${J} of ${i.value}`:""}),Se=C(()=>ra(H.value?.value,H.value?.parseError)),ne=C(()=>H.value?.parseError?"text":"json"),Le=C(()=>$.value==="create"),B=C(()=>Le.value||!!H.value),re=C(()=>B.value&&(W.value!==(Y.value??"")||U.value!==ue.value)),Ce=C(()=>!re.value&&H.value?.parseError?H.value.parseError:null);function ze(J){switch(J){case"object":return"bg-sky-50 text-sky-700 dark:bg-sky-950/40 dark:text-sky-300";case"array":return"bg-violet-50 text-violet-700 dark:bg-violet-950/40 dark:text-violet-300";case"string":return"bg-emerald-50 text-emerald-700 dark:bg-emerald-950/40 dark:text-emerald-300";case"number":return"bg-amber-50 text-amber-700 dark:bg-amber-950/40 dark:text-amber-300";case"boolean":return"bg-pink-50 text-pink-700 dark:bg-pink-950/40 dark:text-pink-300";default:return"bg-red-50 text-red-700 dark:bg-red-950/40 dark:text-red-300"}}async function Ve(J,ke){try{const ye=await J.json();return typeof ye.error=="string"?ye.error:ke}catch{return ke}}function Te(J){if(Le.value||re.value)return;const ke=J?r.value.find(ye=>ye.key===J):null;if(ke){j.value=ke.key;return}j.value&&r.value.some(ye=>ye.key===j.value)||(j.value=r.value[0]?.key??null)}function le(){return!!a.threadId&&a.active&&!Le.value&&!re.value&&!u.value&&!I.value&&!S.value&&!y.value&&!ee}async function we(J={}){if(!a.threadId){r.value=[],i.value=0,j.value=null;return}const ke=++G,ye=J.append===!0,Ae=J.quiet===!0;Ae&&(ee=!0),Ae||(ye?I.value=!0:u.value=!0),Ae||(v.value=null);const V=new URLSearchParams,$e=Math.min(Math.max(r.value.length,or),200);V.set("limit",String(ye?or:$e)),V.set("offset",String(ye?r.value.length:0));const pe=p.value.trim();pe&&V.set("search",pe);try{const Fe=await fetch(Ze(`/api/threads/${a.threadId}/kv?${V}`));if(!Fe.ok)throw new Error(await Ve(Fe,"Failed to load key-value store"));const tt=bx(await Fe.json());return ke!==G?void 0:(r.value=ye?[...r.value,...tt.values]:tt.values,i.value=tt.total,Te(J.preferredKey),!0)}catch(Fe){return ke===G&&(!Ae||r.value.length===0)&&(v.value=Fe instanceof Error?Fe.message:"Failed to load key-value store"),!1}finally{Ae&&(ee=!1),ke===G&&!Ae&&(u.value=!1,I.value=!1)}}function ce(){ve&&clearTimeout(ve),ve=setTimeout(()=>{we()},250)}function te(J){j.value=J.key,$.value="view",k.value=null,me(J)}function ie(){Y.value=null,ue.value=Zt,W.value="",U.value=Zt}function me(J){if(!J){ie();return}const ke=J.parseError?J.serialized:Yr(J.value);Y.value=J.key,ue.value=ke,W.value=J.key,U.value=ke,k.value=null}function Q(J,ke){ke instanceof HTMLElement?oe.value.set(J,ke):oe.value.delete(J)}async function Me(J){await et(),oe.value.get(J)?.focus({preventScroll:!0})}function Ne(J,ke){const ye=r.value.findIndex($e=>$e.key===ke.key);if(ye<0)return;let Ae=ye;if(J.key==="ArrowDown")Ae=Math.min(r.value.length-1,ye+1);else if(J.key==="ArrowUp")Ae=Math.max(0,ye-1);else if(J.key==="Home")Ae=0;else if(J.key==="End")Ae=r.value.length-1;else return;J.preventDefault();const V=r.value[Ae];V&&(te(V),Me(V.key))}function Ue(){j.value=null,Y.value=null,ue.value=Zt,W.value="",U.value=Zt,k.value=null,$.value="create"}function We(){if(k.value=null,Le.value){$.value="view",Te();return}me(H.value)}async function E(){if(!a.threadId)return;const J=W.value;if(!J.trim()){k.value="Key is required";return}const ke=yx(U.value);if(!ke.ok){k.value=ke.error;return}S.value=!0,k.value=null;try{const ye=await fetch(Ze(`/api/threads/${a.threadId}/kv`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:J,value:ke.value,previousKey:Le.value?void 0:Y.value})});if(!ye.ok)throw new Error(await Ve(ye,"Failed to save value"));j.value=J,$.value="view",await we({preferredKey:J})}catch(ye){k.value=ye instanceof Error?ye.message:"Failed to save value"}finally{S.value=!1}}async function fe(){if(!a.threadId||!H.value)return;const J=H.value.key;if(window.confirm(`Delete ${J}?`)){y.value=!0,v.value=null;try{const ke=new URLSearchParams({key:J}),ye=await fetch(Ze(`/api/threads/${a.threadId}/kv?${ke}`),{method:"DELETE"});if(!ye.ok)throw new Error(await Ve(ye,"Failed to delete value"));j.value=null,$.value="view",ie(),await we()}catch(ke){v.value=ke instanceof Error?ke.message:"Failed to delete value"}finally{y.value=!1}}}xe(()=>a.threadId,()=>{p.value="",$.value="view",k.value=null,ie(),we()},{immediate:!0}),xe(p,ce),xe(i,J=>{p.value.trim()||l("count-changed",J)},{immediate:!0}),xe(H,J=>{Le.value||re.value||me(J)});const be=Jr({refresh:async()=>le()?await we({preferredKey:j.value,quiet:!0}):!1}),Pe=Ca({events:{kv_changed:()=>be.notify()},onConnected:()=>be.notify()});return xe(()=>a.active,J=>{J&&(Pe.available||be.notify(),be.flush())}),xe(le,J=>{J&&be.flush()}),typeof document<"u"&&document.addEventListener("visibilitychange",R),$t(()=>{ve&&clearTimeout(ve),be.cancel(),typeof document<"u"&&document.removeEventListener("visibilitychange",R)}),(J,ke)=>(n(),N(Un,{"height-percent":ae.value,"onUpdate:heightPercent":ke[6]||(ke[6]=ye=>ae.value=ye),"storage-key":nb,title:"Resize key-value browser and detail"},Wt({main:Be(()=>[t("div",_x,[t("div",wx,[t("div",$x,[z(c(oa),{size:14,class:"pointer-events-none absolute left-2 top-1/2 -translate-y-1/2 text-neutral-400"}),ft(t("input",{"onUpdate:modelValue":ke[0]||(ke[0]=ye=>p.value=ye),type:"search",class:"h-8 w-full rounded border border-neutral-300 bg-white pl-7 pr-2 text-sm outline-none focus:border-accent-500 focus:ring-1 focus:ring-accent-500 dark:border-neutral-700 dark:bg-neutral-950",placeholder:"Search keys and values",onKeydown:ke[1]||(ke[1]=Ot(Ye(ye=>we(),["prevent"]),["enter"]))},null,544),[[Fn,p.value]])]),t("div",Cx,f(X.value),1),t("button",{type:"button",class:"inline-flex h-8 w-8 items-center justify-center rounded text-neutral-500 transition-colors hover:bg-neutral-100 hover:text-neutral-950 disabled:opacity-50 dark:hover:bg-neutral-800 dark:hover:text-neutral-50",disabled:!e.threadId||u.value,title:"Refresh values","aria-label":"Refresh values",onClick:ke[2]||(ke[2]=ye=>we())},[u.value?(n(),N(nt,{key:0,size:"xs"})):(n(),N(c(Hn),{key:1,size:15}))],8,Sx),t("button",{type:"button",class:"inline-flex h-8 items-center gap-1.5 rounded bg-neutral-900 px-2.5 text-sm font-medium text-white transition-colors hover:bg-neutral-700 disabled:opacity-50 dark:bg-neutral-100 dark:text-neutral-950 dark:hover:bg-neutral-300",disabled:!e.threadId,onClick:Ue},[z(c(cr),{size:15}),ke[7]||(ke[7]=t("span",null,"New",-1))],8,Tx)]),t("div",Ix,[e.threadId?u.value&&r.value.length===0?(n(),o("div",Ex,[z(nt)])):v.value?(n(),o("div",Lx,f(v.value),1)):r.value.length===0?(n(),o("div",Rx,[z(c(Ta),{class:"mx-auto mb-2 h-8 w-8 opacity-40"}),st(" "+f(p.value.trim()?"No matching values":"No stored values"),1)])):(n(),o("div",Mx,[t("div",Dx,[t("table",Fx,[ke[8]||(ke[8]=t("colgroup",null,[t("col",{class:"w-[23rem]"}),t("col"),t("col",{class:"w-24"}),t("col",{class:"w-20"}),t("col",{class:"w-32"})],-1)),ke[9]||(ke[9]=t("thead",{class:"sticky top-0 z-10 border-b border-neutral-200 bg-neutral-50 text-[10px] font-medium uppercase tracking-wide text-neutral-500 dark:border-neutral-800 dark:bg-neutral-900/60 dark:text-neutral-400"},[t("tr",null,[t("th",{scope:"col",class:"px-4 py-2 font-medium"},"Key"),t("th",{scope:"col",class:"px-3 py-2 font-medium"},"Value"),t("th",{scope:"col",class:"px-3 py-2 text-left font-medium"},"Type"),t("th",{scope:"col",class:"px-3 py-2 text-right font-medium"},"Size"),t("th",{scope:"col",class:"px-4 py-2 text-right font-medium"},"Updated")])],-1)),t("tbody",Px,[(n(!0),o(Re,null,Ke(r.value,ye=>(n(),o("tr",{key:ye.key,ref_for:!0,ref:Ae=>Q(ye.key,Ae),tabindex:"0","aria-selected":j.value===ye.key,class:K(["cursor-pointer transition-colors focus:outline-none",j.value===ye.key?"agents-surface-selected":"hover:bg-neutral-50 dark:hover:bg-neutral-900"]),onClick:Ae=>te(ye),onKeydown:[Ot(Ye(Ae=>te(ye),["prevent"]),["enter"]),Ot(Ye(Ae=>te(ye),["prevent"]),["space"]),Ae=>Ne(Ae,ye)]},[t("td",zx,[t("div",jx,f(ye.key),1)]),t("td",Bx,[t("div",Ox,f(c(kx)(ye.value,ye.parseError)),1)]),t("td",Vx,[t("span",{class:K(["inline-flex rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide",ze(c(ra)(ye.value,ye.parseError))])},f(c(ra)(ye.value,ye.parseError)),3)]),t("td",Hx,f(c(rr)(ye.size)),1),t("td",qx,f(c(sr)(ye.updatedAt)),1)],42,Nx))),128))])])]),D.value?(n(),o("button",{key:0,type:"button",class:"m-3 flex items-center justify-center gap-2 rounded border border-neutral-200 px-3 py-2 text-sm font-medium text-neutral-600 transition-colors hover:bg-neutral-50 disabled:opacity-50 dark:border-neutral-800 dark:text-neutral-300 dark:hover:bg-neutral-900",disabled:I.value,onClick:ke[3]||(ke[3]=ye=>we({append:!0}))},[I.value?(n(),N(nt,{key:0,size:"xs"})):m("",!0),ke[10]||(ke[10]=t("span",null,"Load more",-1))],8,Ux)):m("",!0)])):(n(),o("div",Ax," Select a thread to view its key-value store "))])])]),_:2},[B.value?{name:"detail",fn:Be(()=>[t("div",Wx,[t("div",Kx,[t("div",Jx,[B.value?(n(),o("div",Gx,[z(c(Ta),{size:15,class:"shrink-0 text-neutral-400"}),ft(t("input",{"onUpdate:modelValue":ke[4]||(ke[4]=ye=>W.value=ye),type:"text",class:"h-8 min-w-0 flex-1 rounded border border-neutral-300 bg-white px-2 font-mono text-sm outline-none focus:border-accent-500 focus:ring-1 focus:ring-accent-500 dark:border-neutral-700 dark:bg-neutral-950",placeholder:"key"},null,512),[[Fn,W.value]]),H.value?(n(),o("span",{key:0,class:K(["shrink-0 rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide",ze(Se.value)])},f(Se.value),3)):m("",!0)])):m("",!0),H.value?(n(),o("div",Yx,f(c(rr)(H.value.size))+" | "+f(c(sr)(H.value.updatedAt)),1)):m("",!0)]),t("div",Qx,[B.value?(n(),o(Re,{key:0},[t("button",{type:"button",class:"inline-flex h-8 items-center gap-1.5 rounded bg-neutral-900 px-2.5 text-sm font-medium text-white transition-colors hover:bg-neutral-700 disabled:opacity-50 dark:bg-neutral-100 dark:text-neutral-950 dark:hover:bg-neutral-300",disabled:S.value||!re.value,onClick:E},[S.value?(n(),N(nt,{key:0,size:"xs"})):(n(),N(c(_r),{key:1,size:14})),ke[11]||(ke[11]=t("span",null,"Save",-1))],8,Zx),re.value?(n(),o("button",{key:0,type:"button",class:"inline-flex h-8 w-8 items-center justify-center rounded text-neutral-500 transition-colors hover:bg-neutral-100 hover:text-neutral-950 dark:hover:bg-neutral-800 dark:hover:text-neutral-50",title:"Cancel","aria-label":"Cancel",onClick:We},[z(c(Ft),{size:15})])):m("",!0),H.value?(n(),N(qn,{key:1,content:U.value,variant:"ghost",size:"xs"},null,8,["content"])):m("",!0),H.value?(n(),o("button",{key:2,type:"button",class:"inline-flex h-8 w-8 items-center justify-center rounded text-red-600 transition-colors hover:bg-red-50 disabled:opacity-50 dark:text-red-400 dark:hover:bg-red-950/30",disabled:y.value,title:"Delete value","aria-label":"Delete value",onClick:fe},[y.value?(n(),N(nt,{key:0,size:"xs"})):(n(),N(c(zn),{key:1,size:15}))],8,Xx)):m("",!0)],64)):m("",!0)])]),t("div",eb,[k.value?(n(),o("div",tb,f(k.value),1)):m("",!0),B.value?(n(),N($a,{key:1,modelValue:U.value,"onUpdate:modelValue":ke[5]||(ke[5]=ye=>U.value=ye),class:"min-h-0 flex-1",language:ne.value,error:Ce.value,"word-wrap":"on","format-on-blur":"",framed:!1,placeholder:"{\\n \\n}"},null,8,["modelValue","language","error"])):m("",!0)])])]),key:"0"}:void 0]),1032,["height-percent"]))}}),rb=["onClick"],sb=["value","placeholder","disabled"],ob=at({__name:"TagInput",props:{modelValue:{},placeholder:{},disabled:{type:Boolean}},emits:["update:modelValue"],setup(e,{emit:s}){const a=e,l=s,r=b(""),i=b(null),p=v=>{const k=v.trim().toLowerCase();k&&!a.modelValue.includes(k)&&l("update:modelValue",[...a.modelValue,k]),r.value="",et(()=>i.value?.focus())},u=v=>{const k=[...a.modelValue];k.splice(v,1),l("update:modelValue",k)},I=v=>{const k=v.target.value;if(k.includes(",")){const j=k.split(",");j.forEach(($,W)=>{W<j.length-1?p($):r.value=$})}else r.value=k},S=v=>{v.key==="Enter"?(v.preventDefault(),p(r.value)):v.key==="Backspace"&&!r.value&&a.modelValue.length>0&&u(a.modelValue.length-1)},y=()=>{i.value?.focus()};return(v,k)=>(n(),o("div",{class:K(["flex flex-wrap items-center gap-1.5 min-h-[32px] px-2 py-1.5 bg-white dark:bg-neutral-950 border border-neutral-200 dark:border-neutral-800 rounded-md cursor-text focus-within:ring-2 focus-within:ring-accent-500/20 focus-within:border-accent-500 transition-colors",{"opacity-50 cursor-not-allowed":e.disabled}]),onClick:y},[(n(!0),o(Re,null,Ke(e.modelValue,(j,$)=>(n(),o("span",{key:j,class:"inline-flex items-center gap-1 px-2 py-0.5 text-xs font-medium bg-accent-100 dark:bg-accent-900/30 text-accent-700 dark:text-accent-300 rounded"},[st(f(j)+" ",1),e.disabled?m("",!0):(n(),o("button",{key:0,type:"button",onClick:Ye(W=>u($),["stop"]),class:"hover:text-accent-900 dark:hover:text-accent-100 transition-colors"},[z(c(Ft),{size:12})],8,rb))]))),128)),t("input",{ref_key:"inputRef",ref:i,type:"text",value:r.value,placeholder:e.modelValue.length===0?e.placeholder:"",disabled:e.disabled,class:"flex-1 min-w-[60px] bg-transparent border-none outline-none text-xs text-neutral-900 dark:text-neutral-100 placeholder:text-neutral-400 disabled:cursor-not-allowed",onInput:I,onKeydown:S},null,40,sb)],2))}}),lb={class:"thread-basic-info-card bg-white dark:bg-neutral-900 rounded-lg border border-neutral-200 dark:border-neutral-800 overflow-hidden"},ib={class:"p-3 space-y-2"},db={class:"text-[10px] text-neutral-500 dark:text-neutral-400"},ub=["title"],cb={class:"flex-1 text-[11px] font-mono text-neutral-600 dark:text-neutral-400 truncate"},fb={class:"thread-basic-info-row flex items-center gap-2"},pb={class:"thread-basic-info-control flex-1 flex items-center gap-1.5"},vb={key:1,class:"text-xs text-neutral-700 dark:text-neutral-200"},gb={key:2,class:"text-[9px] px-1.5 py-0.5 rounded bg-neutral-100 dark:bg-neutral-800 text-neutral-500 dark:text-neutral-400 uppercase tracking-wide shrink-0"},mb={class:"thread-basic-info-row flex items-start gap-2"},hb=at({__name:"ThreadBasicInfoCard",props:{thread:{},copiedId:{type:Boolean},canChangeAgent:{type:Boolean},localAgentId:{},agentOptions:{},isFetchingAgents:{type:Boolean},isSavingAgent:{type:Boolean},localTags:{},isSavingTags:{type:Boolean}},emits:["copyId","agentChange","tagsChange"],setup(e,{emit:s}){const a=s,l=r=>new Date(r*1e3).toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});return(r,i)=>{const p=Jt("FormKit");return n(),o("div",lb,[t("div",ib,[t("div",db,[i[3]||(i[3]=t("span",{class:"font-medium uppercase tracking-wide"},"Created",-1)),i[4]||(i[4]=t("span",{class:"mx-1"},"·",-1)),st(" "+f(l(e.thread.created_at)),1)]),t("div",{class:"flex items-center gap-1 px-2 py-1.5 bg-neutral-50 dark:bg-neutral-950 rounded border border-neutral-200 dark:border-neutral-800 cursor-pointer hover:border-neutral-300 dark:hover:border-neutral-700 transition-colors group",onClick:i[0]||(i[0]=u=>a("copyId")),title:e.copiedId?"Copied!":"Click to copy"},[t("code",cb,f(e.thread.id),1),t("span",{class:K(["shrink-0 transition-colors",e.copiedId?"text-green-600 dark:text-green-400":"text-neutral-400 group-hover:text-neutral-600 dark:group-hover:text-neutral-300"])},[e.copiedId?(n(),N(c(dr),{key:0,size:12})):(n(),N(c(Is),{key:1,size:12}))],2)],8,ub),t("div",fb,[i[5]||(i[5]=t("label",{class:"thread-basic-info-label shrink-0 text-[10px] font-medium text-neutral-500 dark:text-neutral-400 uppercase tracking-wide w-10"},"Agent",-1)),t("div",pb,[e.canChangeAgent?(n(),N(p,{key:0,type:"selectSearch","model-value":e.localAgentId,options:e.agentOptions,loading:e.isFetchingAgents||e.isSavingAgent,disabled:e.isSavingAgent,size:"sm",placeholder:"Select...","outer-class":"!mb-0 flex-1",onInput:i[1]||(i[1]=u=>a("agentChange",String(u)))},null,8,["model-value","options","loading","disabled"])):(n(),o("span",vb,f(e.thread.agent.title),1)),c(Da)(e.thread.agent.side_a_backing,e.thread.agent.side_b_backing)?(n(),o("span",gb,f(c(Da)(e.thread.agent.side_a_backing,e.thread.agent.side_b_backing)),1)):m("",!0)])]),t("div",mb,[i[6]||(i[6]=t("label",{class:"thread-basic-info-label shrink-0 text-[10px] font-medium text-neutral-500 dark:text-neutral-400 uppercase tracking-wide w-10 pt-2"},"Tags",-1)),z(ob,{"model-value":e.localTags,"onUpdate:modelValue":i[2]||(i[2]=u=>a("tagsChange",u)),disabled:e.isSavingTags,placeholder:"Add tags...",class:"flex-1"},null,8,["model-value","disabled"])])])])}}}),xb=pt(hb,[["__scopeId","data-v-65127345"]]),bb={class:"thread-dev-tools-card bg-white dark:bg-neutral-900 rounded-lg border border-neutral-200 dark:border-neutral-800 overflow-hidden"},yb={key:0,class:"overflow-hidden border-t border-neutral-100 dark:border-neutral-800"},kb={class:"p-3 space-y-3"},_b={class:"thread-dev-tools-action-row flex items-center gap-2"},wb=["value"],$b=["disabled"],Cb={class:"pt-2 border-t border-neutral-100 dark:border-neutral-800"},Sb=["disabled"],Tb=at({__name:"ThreadDeveloperToolsCard",props:{expanded:{type:Boolean},showSideSelector:{type:Boolean},selectedSide:{},isContinuing:{type:Boolean},isDeleting:{type:Boolean}},emits:["toggle","updateSelectedSide","continueExecution","deleteThread"],setup(e,{emit:s}){const a=s;return(l,r)=>(n(),o("div",bb,[t("button",{onClick:r[0]||(r[0]=i=>a("toggle")),type:"button",class:"w-full flex items-center gap-2 px-3 py-2.5 text-left hover:bg-neutral-50 dark:hover:bg-neutral-800 transition-colors"},[z(c(hr),{size:14,class:"shrink-0 text-neutral-400"}),r[4]||(r[4]=t("span",{class:"flex-1 text-xs font-medium text-neutral-700 dark:text-neutral-200"},"Developer Tools",-1)),z(c(It),{size:14,class:K(["shrink-0 text-neutral-400 transition-transform duration-200",{"-rotate-180":e.expanded}])},null,8,["class"])]),z(kn,{"enter-active-class":"transition-all duration-200 ease-out","enter-from-class":"opacity-0 max-h-0","enter-to-class":"opacity-100 max-h-[150px]","leave-active-class":"transition-all duration-150 ease-in","leave-from-class":"opacity-100 max-h-[150px]","leave-to-class":"opacity-0 max-h-0"},{default:Be(()=>[e.expanded?(n(),o("div",yb,[t("div",kb,[t("div",_b,[e.showSideSelector?(n(),o("select",{key:0,value:e.selectedSide,class:"text-xs px-2 py-1.5 border border-neutral-200 dark:border-neutral-700 rounded bg-white dark:bg-neutral-800 text-neutral-700 dark:text-neutral-300",onChange:r[1]||(r[1]=i=>a("updateSelectedSide",i.target.value))},[...r[5]||(r[5]=[t("option",{value:"a"},"Side A",-1),t("option",{value:"b"},"Side B",-1)])],40,wb)):m("",!0),t("button",{onClick:r[2]||(r[2]=i=>a("continueExecution")),disabled:e.isContinuing,class:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium bg-neutral-800 dark:bg-neutral-200 text-white dark:text-neutral-900 rounded hover:bg-neutral-700 dark:hover:bg-neutral-300 transition-colors disabled:opacity-50"},[z(c(ia),{size:12}),t("span",null,f(e.isContinuing?"Running...":"Continue"),1)],8,$b),r[6]||(r[6]=t("span",{class:"thread-dev-tools-hint text-[10px] text-neutral-500 dark:text-neutral-400"},"Resume without new message",-1))]),t("div",Cb,[t("button",{onClick:r[3]||(r[3]=i=>a("deleteThread")),disabled:e.isDeleting,class:"flex items-center gap-1.5 text-xs font-medium text-red-600 dark:text-red-400 hover:text-red-700 dark:hover:text-red-300 transition-colors disabled:opacity-50"},[z(c(zn),{size:12}),t("span",null,f(e.isDeleting?"Deleting...":"Delete Thread"),1)],8,Sb)])])])):m("",!0)]),_:1})]))}}),Ib=pt(Tb,[["__scopeId","data-v-49880e1f"]]),Ab=new Set(["healthy","observing","recovered","parked","idle","unreachable"]);function Eb(e){if(!e||typeof e!="object")return{available:!1,armed:!1,checkins:[]};const s=e,a=Array.isArray(s.history)?s.history:[],l=[];for(const r of a){if(!r||typeof r!="object")continue;const i=r,p=typeof i.at=="number"&&Number.isFinite(i.at)?i.at:null,u=typeof i.verdict=="string"&&Ab.has(i.verdict)?i.verdict:null;p===null||u===null||l.push({at:p,verdict:u,action:typeof i.action=="string"?i.action:"",executing:typeof i.executing=="boolean"?i.executing:null,incompleteLogs:typeof i.incompleteLogs=="number"?i.incompleteLogs:null,silenceMs:typeof i.silenceMs=="number"?i.silenceMs:null,probeMs:typeof i.probeMs=="number"?i.probeMs:0,error:typeof i.error=="string"?i.error:void 0})}return{available:!0,armed:s.armed===!0,checkins:l}}function Lb(e){switch(e){case"healthy":return"healthy";case"observing":return"observing";case"recovered":return"recovered";case"parked":return"parked";case"idle":return"stood down";case"unreachable":return"unreachable"}}function Rb(e){switch(e){case"healthy":return"bg-emerald-50 text-emerald-700 dark:bg-emerald-950/40 dark:text-emerald-300";case"recovered":return"bg-sky-50 text-sky-700 dark:bg-sky-950/40 dark:text-sky-300";case"observing":return"bg-amber-50 text-amber-700 dark:bg-amber-950/40 dark:text-amber-300";case"parked":case"unreachable":return"bg-red-50 text-red-700 dark:bg-red-950/40 dark:text-red-300";case"idle":return"bg-neutral-100 text-neutral-700 dark:bg-neutral-800 dark:text-neutral-300"}}function Mb(e){const s=new Date(e);if(Number.isNaN(s.getTime()))return"—";const a=l=>String(l).padStart(2,"0");return`${a(s.getHours())}:${a(s.getMinutes())}:${a(s.getSeconds())}`}const Db={class:"thread-watchdog-card bg-white dark:bg-neutral-900 rounded-lg border border-neutral-200 dark:border-neutral-800 overflow-hidden"},Fb={class:"w-full flex items-center gap-2 px-3 py-2.5"},Pb={class:"px-3 pb-3"},Nb={key:0,class:"text-[11px] text-neutral-400 dark:text-neutral-500"},zb={key:1,class:"text-[11px] text-neutral-400 dark:text-neutral-500"},jb={key:0,class:"text-[11px] text-neutral-400 dark:text-neutral-500"},Bb={key:1,class:"space-y-1"},Ob=["title"],Vb={class:"shrink-0 tabular-nums text-neutral-400 dark:text-neutral-500"},Hb={class:"min-w-0 truncate text-neutral-600 dark:text-neutral-300"},qb={class:"mt-2.5 flex items-center gap-2"},Ub=["disabled"],Wb={key:2,class:"mt-1.5 text-[11px] text-red-600 dark:text-red-400"},Kb=5,Jb=at({__name:"ThreadWatchdogCard",props:{watchdog:{},isChecking:{type:Boolean},checkError:{}},emits:["runCheck"],setup(e,{emit:s}){const a=s;return(l,r)=>(n(),o("div",Db,[t("div",Fb,[z(c(As),{size:14,class:"shrink-0 text-neutral-400"}),r[1]||(r[1]=t("span",{class:"flex-1 text-xs font-medium text-neutral-700 dark:text-neutral-200"},"Watchdog",-1)),e.watchdog?.available?(n(),o("span",{key:0,class:K(["inline-flex rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide",e.watchdog.armed?"bg-emerald-50 text-emerald-700 dark:bg-emerald-950/40 dark:text-emerald-300":"bg-neutral-100 text-neutral-700 dark:bg-neutral-800 dark:text-neutral-300"])},f(e.watchdog.armed?"armed":"standing by"),3)):m("",!0)]),t("div",Pb,[e.watchdog?e.watchdog.available?(n(),o(Re,{key:2},[e.watchdog.checkins.length===0?(n(),o("p",jb," No check-ins yet — the watchdog arms when the thread executes. ")):(n(),o("ul",Bb,[(n(!0),o(Re,null,Ke(e.watchdog.checkins.slice(0,Kb),i=>(n(),o("li",{key:i.at,class:"flex items-baseline gap-2 text-[11px]",title:i.error},[t("span",Vb,f(c(Mb)(i.at)),1),t("span",{class:K(["shrink-0 inline-flex rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide",c(Rb)(i.verdict)])},f(c(Lb)(i.verdict)),3),t("span",Hb,f(i.action),1)],8,Ob))),128))])),t("div",qb,[t("button",{onClick:r[0]||(r[0]=i=>a("runCheck")),disabled:e.isChecking,type:"button",class:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium bg-neutral-800 dark:bg-neutral-200 text-white dark:text-neutral-900 rounded hover:bg-neutral-700 dark:hover:bg-neutral-300 transition-colors disabled:opacity-50"},[z(c(Hn),{size:12,class:K({"animate-spin":e.isChecking})},null,8,["class"]),t("span",null,f(e.isChecking?"Checking...":"Run check now"),1)],8,Ub),r[2]||(r[2]=t("span",{class:"text-[10px] text-neutral-400 dark:text-neutral-500"}," Finalizes lost requests and resumes a stuck thread. Safe when healthy. ",-1))]),e.checkError?(n(),o("p",Wb,f(e.checkError),1)):m("",!0)],64)):(n(),o("p",zb," Not available on this deployment (requires builder 0.26+). ")):(n(),o("p",Nb," Loading watchdog state… "))])]))}}),Gb={key:0,class:"flex justify-center py-6"},Yb={key:1,class:"text-red-600 dark:text-red-400 text-center py-4 text-xs"},Qb={class:"thread-settings-variables-card bg-white dark:bg-neutral-900 rounded-lg border border-neutral-200 dark:border-neutral-800 overflow-hidden"},Zb={key:0,class:"text-xs text-neutral-500 dark:text-neutral-400"},Xb={key:1,class:"space-y-2"},ey={class:"thread-settings-variable-name min-w-0 flex items-center gap-1.5"},ty=["title"],ny={key:0,class:"shrink-0 rounded bg-red-100 px-1 py-0.5 text-[8px] uppercase tracking-wide text-red-700 dark:bg-red-900 dark:text-red-300"},ay=["disabled","onClick","title"],ry=["disabled","onClick"],sy={key:1,class:"h-7 w-7"},oy={class:"mt-3 border-t border-neutral-100 dark:border-neutral-800 pt-3 space-y-2"},ly=["disabled","onClick","title"],iy=["disabled","onClick"],dy=["disabled"],uy=["disabled"],cy={key:1},fy={key:0,class:"text-[10px] text-red-600 dark:text-red-400"},lr="**********",py=at({__name:"MetadataSlidePane",props:{threadId:{},show:{type:Boolean},embedded:{type:Boolean}},emits:["close","threadDeleted","editThread","threadUpdated"],setup(e,{emit:s}){const a=e,l=s,{thread:r,isFetching:i,error:p,refetch:u}=ba(C(()=>a.threadId)),{agents:I,isFetching:S}=Pr(),y=b(!1),v=b(!1),k=b(!1),j=b(!1),$=b(!!a.embedded),W=b(!1),U=b("a"),Y=b(!1),ue=b(!1);let ae=null,oe=0;const ve=()=>({id:`new-env-${oe++}`,name:"",value:"",secret:!0}),ee=b([]),G=b({}),R=b({}),H=b({}),D=b({}),X=b({}),Se=b([ve()]),ne=b(null),Le=b(null),B=b(null),re=b(""),Ce=b([]),ze=b(!1),Ve=(O,se)=>O instanceof Error?O.message:se,Te=(O,se)=>{vn(se?{error:O,fieldErrors:se}:{error:O},B)||(Le.value=O)},le=C(()=>I.value?I.value.filter(O=>fa(O)).map(O=>({value:O.id,label:O.title})):[]),we=C(()=>r.value?fa(r.value.agent):!1),ce=C(()=>r.value?Js(r.value.agent):!1),te=C(()=>ee.value.filter(O=>!X.value[O.property])),ie=async()=>{r.value&&(await navigator.clipboard.writeText(r.value.id),Y.value=!0,ae&&clearTimeout(ae),ae=setTimeout(()=>{Y.value=!1,ae=null},2e3))};Ht(()=>{ae&&clearTimeout(ae)});const me=async O=>{if(!(!a.threadId||!O||O===r.value?.agent.id)){k.value=!0;try{const se=await fetch(Ze(`/api/threads/${a.threadId}`),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({agent_id:O})});if(!se.ok){const He=await se.json();throw new Error(He.error||"Failed to update agent")}await u(),l("threadUpdated")}catch{re.value=r.value?.agent.id||""}finally{k.value=!1}}},Q=async O=>{if(a.threadId){Ce.value=O,ze.value=!0,j.value=!0;try{const se=await fetch(Ze(`/api/threads/${a.threadId}`),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({tags:O})});if(!se.ok){const He=await se.json();throw new Error(He.error||"Failed to update tags")}l("threadUpdated")}catch{Ce.value=r.value?.tags||[]}finally{j.value=!1,ze.value=!1}}},Me=()=>{a.embedded&&($.value=!0)},Ne=O=>O.defined?(O.defined.type==="agent"||O.defined.type==="prompt")&&O.defined.name?`${O.defined.type}:${O.defined.name}`:O.defined.type==="account"?"user":O.defined.type:"missing",Ue=O=>/^[A-Za-z_][A-Za-z0-9_]*$/.test(O.trim()),We=(O={})=>({outer:"$remove:mb-4 $remove:mb-3.5 !mb-0 min-w-0",wrapper:"$remove:flex-1 flex min-w-0",inner:"$reset min-w-0",input:["$reset block h-8 w-full min-w-0 rounded border border-neutral-200 bg-white px-2 py-1.5 text-xs text-neutral-700 placeholder:text-neutral-400 disabled:opacity-60 dark:border-neutral-800 dark:bg-neutral-950 dark:text-neutral-200",O.mono?"font-mono":""].filter(Boolean).join(" "),help:"$remove:hidden hidden",messages:"$remove:formkit-messages hidden"}),E=O=>{const se={},He={};for(const de of O)se[de.property]=de.type==="secret"&&de.defined?lr:de.value??"",He[de.property]=de.type==="secret";G.value=se,R.value=He,H.value={},D.value={},X.value={}},fe=O=>{R.value={...R.value,[O]:!R.value[O]},D.value={...D.value,[O]:!0}},be=O=>{H.value={...H.value,[O]:!0}},Pe=O=>{X.value={...X.value,[O]:!0},Le.value=null,gn(B)},J=()=>{Se.value=[...Se.value,ve()]},ke=O=>{const se=Se.value.filter(He=>He.id!==O);Se.value=se.length>0?se:[ve()]},ye=async()=>{if(!a.threadId||!r.value?.agent?.id){ee.value=[],E([]);return}ue.value=!0;try{const O=await fetch(Ze(`/api/variables/agents/${encodeURIComponent(r.value.agent.id)}?thread_id=${encodeURIComponent(a.threadId)}`));if(!O.ok){ee.value=[];return}const se=await O.json();ee.value=se.variables||[],E(ee.value)}catch{ee.value=[],E([])}finally{ue.value=!1}},Ae=async(O,se=[],He={})=>{if(!a.threadId)return;Le.value=null;const de=await fetch(Ze(`/api/threads/${a.threadId}`),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({env_patch:O,env_type_patch:He,env_delete:se})});if(!de.ok){const L=await de.json().catch(()=>({}));throw new Error(L.error||"Failed to update variable")}await u(),await ye(),l("threadUpdated")},V=async()=>{if(ne.value)return;const O={},se={},He=Object.keys(X.value).filter(L=>X.value[L]);for(const L of te.value){if(!H.value[L.property]&&!D.value[L.property])continue;if(!Ue(L.property)){Te(`Invalid env name: ${L.property}`,{[`env_${L.property}`]:`Invalid env name: ${L.property}`});return}const ge=G.value[L.property]??"";ge!==lr&&(O[L.property]=ge),(D.value[L.property]||H.value[L.property])&&(se[L.property]=R.value[L.property]?"secret":"text")}const de=new Set;for(const L of Se.value){const ge=L.name.trim(),je=L.value.length>0;if(!(!ge&&!je)){if(!ge||!Ue(ge)){Te("Use a valid env name like WEATHER_API_KEY",{[`${L.id}_name`]:"Use a valid env name like WEATHER_API_KEY"});return}if(de.has(ge)){Te(`Duplicate env name: ${ge}`,{[`${L.id}_name`]:`Duplicate env name: ${ge}`});return}de.add(ge),O[ge]=L.value,se[ge]=L.secret?"secret":"text"}}if(Object.keys(O).length===0&&Object.keys(se).length===0&&He.length===0){Te("No env changes to save");return}ne.value="__all__";try{await Ae(O,He,se),Se.value=[ve()]}catch(L){Te(Ve(L,"Failed to save variables"))}finally{ne.value=null}},$e=b(null),pe=b(!1),Fe=b(null),tt=async()=>{if(a.threadId)try{const O=await fetch(Ze(`/api/threads/${a.threadId}/diagnostics`));if(!O.ok){$e.value={available:!1,armed:!1,checkins:[]};return}const se=await O.json();$e.value=Eb(se?.watchdog??null)}catch{$e.value={available:!1,armed:!1,checkins:[]}}},Qe=async()=>{if(!(!a.threadId||pe.value)){pe.value=!0,Fe.value=null;try{const O=await fetch(Ze(`/api/threads/${a.threadId}/revive`),{method:"POST"});if(!O.ok){const se=await O.json().catch(()=>null);throw new Error(se?.error||"Watchdog check failed")}}catch(O){Fe.value=Ve(O,"Watchdog check failed")}finally{pe.value=!1,await tt()}}},lt=async()=>{if(a.threadId){W.value=!0;try{const O=await fetch(Ze(`/api/threads/${a.threadId}/continue`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({side:U.value})});if(!O.ok){const se=await O.json();throw new Error(se.error||"Failed to continue execution")}}catch{U.value="a"}finally{W.value=!1}}},he=async()=>{if(a.threadId){v.value=!0;try{const O=await fetch(Ze(`/api/threads/${a.threadId}`),{method:"DELETE"});if(!O.ok){const se=await O.json();throw new Error(se.error||"Failed to delete thread")}l("threadDeleted",a.threadId)}catch{y.value=!1}finally{v.value=!1}}};return xe(()=>r.value,O=>{O&&(re.value=O.agent.id,ze.value||(Ce.value=O.tags||[]))},{immediate:!0}),xe(()=>a.show,O=>{O?(ye(),tt(),Me()):($.value=!1,ee.value=[],G.value={},R.value={},H.value={},D.value={},X.value={},Se.value=[ve()],Le.value=null,gn(B),ue.value=!1,$e.value=null,Fe.value=null)},{immediate:!0}),xe(()=>a.threadId,()=>{$.value=!1,ee.value=[],G.value={},R.value={},H.value={},D.value={},X.value={},Se.value=[ve()],Le.value=null,gn(B),$e.value=null,Fe.value=null,a.show&&(ye(),tt(),Me())}),xe(()=>r.value?.agent?.id,()=>{a.show&&(ye(),Me())}),(O,se)=>{const He=Jt("FormKit");return n(),N(kn,{"enter-active-class":e.embedded?"":"transition-all duration-300 ease-out","enter-from-class":e.embedded?"":"max-h-0 opacity-0","enter-to-class":e.embedded?"":"max-h-[500px] opacity-100","leave-active-class":e.embedded?"":"transition-all duration-200 ease-in","leave-from-class":e.embedded?"":"max-h-[500px] opacity-100","leave-to-class":e.embedded?"":"max-h-0 opacity-0"},{default:Be(()=>[e.show&&e.threadId?(n(),o("div",{key:0,class:K(["thread-settings-pane",e.embedded?"h-full overflow-y-auto bg-neutral-100 dark:bg-neutral-950":"overflow-hidden bg-neutral-100 dark:bg-neutral-950"])},[t("div",{class:K(["thread-settings-layout",e.embedded?"grid grid-cols-1 gap-3 p-3":"max-h-[500px] overflow-y-auto p-3 space-y-3"])},[c(i)?(n(),o("div",Gb,[z(nt)])):c(p)?(n(),o("div",Yb," Error: "+f(c(p)),1)):c(r)?(n(),o(Re,{key:2},[z(xb,{thread:c(r),"copied-id":Y.value,"can-change-agent":we.value,"local-agent-id":re.value,"agent-options":le.value,"is-fetching-agents":c(S),"is-saving-agent":k.value,"local-tags":Ce.value,"is-saving-tags":j.value,onCopyId:ie,onAgentChange:me,onTagsChange:Q},null,8,["thread","copied-id","can-change-agent","local-agent-id","agent-options","is-fetching-agents","is-saving-agent","local-tags","is-saving-tags"]),t("div",Qb,[se[5]||(se[5]=t("div",{class:"px-3 py-2.5 border-b border-neutral-100 dark:border-neutral-800"},[t("div",{class:"text-xs font-medium text-neutral-700 dark:text-neutral-200"}," Variables ")],-1)),z(He,{type:"form",id:"thread-variable-form",actions:!1,disabled:ne.value!==null,onSubmit:V,onNode:se[0]||(se[0]=de=>B.value=de),"form-class":"$reset p-3"},{default:Be(()=>[z(c(la),{node:B.value||void 0},null,8,["node"]),ue.value?(n(),o("div",Zb," Loading variables... ")):m("",!0),!ue.value&&te.value.length>0?(n(),o("div",Xb,[(n(!0),o(Re,null,Ke(te.value,de=>(n(),o("div",{key:de.property,class:"thread-settings-variable-row grid grid-cols-[minmax(90px,1fr)_minmax(0,1.6fr)_auto_auto] items-center gap-1.5"},[t("div",ey,[t("span",{class:"truncate text-[11px] font-mono text-neutral-700 dark:text-neutral-200",title:`${de.property} (${Ne(de)})`},f(de.property),9,ty),de.required?(n(),o("span",ny," req ")):m("",!0)]),z(He,{type:R.value[de.property]?"password":"text",name:`env_${de.property}`,modelValue:G.value[de.property],"onUpdate:modelValue":L=>G.value[de.property]=L,placeholder:"Value",disabled:ne.value!==null,"outer-class":"$reset mb-0",classes:We(),onInput:L=>be(de.property)},null,8,["type","name","modelValue","onUpdate:modelValue","disabled","classes","onInput"]),t("button",{type:"button",class:K(["inline-flex h-7 w-7 shrink-0 items-center justify-center rounded hover:bg-neutral-50 disabled:opacity-50 dark:hover:bg-neutral-800",R.value[de.property]?"text-neutral-950 dark:text-neutral-50":"text-neutral-300 dark:text-neutral-600"]),disabled:ne.value!==null,onClick:L=>fe(de.property),title:R.value[de.property]?"Treat as secret":"Treat as text"},[R.value[de.property]?(n(),N(c(Ia),{key:0,size:13})):(n(),N(c(Aa),{key:1,size:13}))],10,ay),de.defined&&de.defined.type==="thread"?(n(),o("button",{key:0,type:"button",class:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded text-neutral-300 hover:bg-red-50 hover:text-red-600 disabled:opacity-50 dark:text-neutral-600 dark:hover:bg-red-950 dark:hover:text-red-400",disabled:ne.value!==null,onClick:L=>Pe(de.property),title:"Remove env"},[z(c(zn),{size:13})],8,ry)):(n(),o("div",sy))]))),128))])):m("",!0),t("div",oy,[(n(!0),o(Re,null,Ke(Se.value,de=>(n(),o("div",{key:de.id,class:"thread-settings-new-env-row grid grid-cols-[minmax(90px,1fr)_minmax(0,1.6fr)_auto_auto] items-center gap-1.5"},[z(He,{type:"text",name:`${de.id}_name`,modelValue:de.name,"onUpdate:modelValue":L=>de.name=L,placeholder:"FOOBAR",disabled:ne.value!==null,validation:"envName","validation-visibility":"submit","outer-class":"$reset mb-0",classes:We({mono:!0}),onKeydown:Ot(Ye(V,["prevent"]),["enter"])},null,8,["name","modelValue","onUpdate:modelValue","disabled","classes","onKeydown"]),z(He,{type:de.secret?"password":"text",name:`${de.id}_value`,modelValue:de.value,"onUpdate:modelValue":L=>de.value=L,placeholder:"Value",disabled:ne.value!==null,"outer-class":"$reset mb-0",classes:We(),onKeydown:Ot(Ye(V,["prevent"]),["enter"])},null,8,["type","name","modelValue","onUpdate:modelValue","disabled","classes","onKeydown"]),t("button",{type:"button",class:K(["inline-flex h-7 w-7 shrink-0 items-center justify-center rounded hover:bg-neutral-50 disabled:opacity-50 dark:hover:bg-neutral-800",de.secret?"text-neutral-950 dark:text-neutral-50":"text-neutral-300 dark:text-neutral-600"]),disabled:ne.value!==null,onClick:L=>de.secret=!de.secret,title:de.secret?"Treat as secret":"Treat as text"},[de.secret?(n(),N(c(Ia),{key:0,size:13})):(n(),N(c(Aa),{key:1,size:13}))],10,ly),t("button",{type:"button",class:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded text-neutral-300 hover:bg-red-50 hover:text-red-600 disabled:opacity-50 dark:text-neutral-600 dark:hover:bg-red-950 dark:hover:text-red-400",disabled:ne.value!==null,onClick:L=>ke(de.id),title:"Remove new row"},[z(c(zn),{size:13})],8,iy)]))),128)),t("button",{type:"button",class:"text-[11px] font-medium text-neutral-500 hover:text-neutral-800 disabled:opacity-50 dark:text-neutral-400 dark:hover:text-neutral-200",disabled:ne.value!==null,onClick:J}," Add another env ",8,dy),t("button",{type:"submit",form:"thread-variable-form",class:"inline-flex w-full items-center justify-center rounded border border-neutral-200 px-2 py-1.5 text-[11px] font-medium text-neutral-600 hover:bg-neutral-50 disabled:opacity-50 dark:border-neutral-700 dark:text-neutral-300 dark:hover:bg-neutral-800",disabled:ne.value!==null},[ne.value==="__all__"?(n(),N(nt,{key:0,size:"xs"})):(n(),o("span",cy,"Save envs"))],8,uy),Le.value?(n(),o("p",fy,f(Le.value),1)):m("",!0)])]),_:1},8,["disabled"])]),z(Jb,{watchdog:$e.value,"is-checking":pe.value,"check-error":Fe.value,onRunCheck:Qe},null,8,["watchdog","is-checking","check-error"]),z(Ib,{expanded:$.value,"show-side-selector":ce.value,"selected-side":U.value,"is-continuing":W.value,"is-deleting":v.value,onToggle:se[1]||(se[1]=de=>$.value=!$.value),onUpdateSelectedSide:se[2]||(se[2]=de=>U.value=de),onContinueExecution:lt,onDeleteThread:se[3]||(se[3]=de=>y.value=!0)},null,8,["expanded","show-side-selector","selected-side","is-continuing","is-deleting"])],64)):m("",!0)],2),z(co,{modelValue:y.value,"onUpdate:modelValue":se[4]||(se[4]=de=>y.value=de),title:"Delete Thread?",message:"This will permanently delete all messages, logs, and associated data. This action cannot be undone.","confirm-text":"Delete","cancel-text":"Cancel",onConfirm:he},null,8,["modelValue"])],2)):m("",!0)]),_:1},8,["enter-active-class","enter-from-class","enter-to-class","leave-active-class","leave-from-class","leave-to-class"])}}}),vy=pt(py,[["__scopeId","data-v-88b29d41"]]),gy={class:"relative -ml-3 flex min-w-0 w-72 shrink-0 self-stretch border-r border-neutral-200 dark:border-neutral-800"},my={key:1,class:"flex h-5 w-5 shrink-0 items-center justify-center"},hy={class:"min-w-0 flex-1"},xy={class:"block truncate font-medium text-neutral-900 dark:text-neutral-100"},by={class:"block truncate text-[10px] leading-tight text-neutral-500 dark:text-neutral-400"},yy={key:1,class:"absolute left-0 top-full z-30 w-[22rem] overflow-hidden rounded-b-lg border border-neutral-200 bg-white shadow-xl dark:border-neutral-700 dark:bg-neutral-900"},ky={class:"flex items-center justify-end border-b border-neutral-100 px-1 py-1 dark:border-neutral-800"},_y={class:"max-h-[min(30rem,70vh)] overflow-y-auto py-1.5 text-[12px]"},wy={key:0,class:"flex items-center gap-2 px-3 py-3 text-xs text-neutral-500 dark:text-neutral-400"},$y={key:1,class:"px-3 py-3 text-xs text-red-600 dark:text-red-400"},Cy={key:2,class:"px-3 py-3 text-xs text-neutral-500 dark:text-neutral-400"},Sy=["onClick"],Ty={key:1,class:"relative z-[1] mt-px flex h-5 w-5 shrink-0 items-center justify-center"},Iy={class:"relative z-[1] min-w-0 flex-1"},Ay={class:"block truncate text-xs font-medium"},Ey={class:"block truncate text-[10px] leading-tight text-neutral-500 dark:text-neutral-400"},sa=at({__name:"ThreadAgentConfigurationSelector",props:{nodes:{},selectedNode:{},pinned:{type:Boolean},loading:{type:Boolean},error:{},baseIndentPx:{},levelIndentPx:{}},emits:["select","pin","unpin"],setup(e,{emit:s}){const a=e,l=s,r=b(!1);function i(S){return S?.kind==="subprompt"?"text-fuchsia-600 dark:text-fuchsia-400":"text-sky-600 dark:text-sky-400"}function p(S){l("select",S),r.value=!1}function u(){a.pinned||(r.value=!r.value)}function I(){l("pin"),r.value=!1}return(S,y)=>(n(),o("div",gy,[t("button",{type:"button",class:K(["flex h-full min-w-0 w-full items-center gap-2 bg-transparent px-3 py-1.5 text-left text-xs transition-colors hover:bg-accent-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent-500 dark:hover:bg-accent-950/30",e.pinned?"cursor-default":""]),onClick:u,onKeydown:y[0]||(y[0]=Ot(Ye(v=>r.value=!1,["stop"]),["escape"]))},[e.selectedNode?.avatarSrc?(n(),N(bn,{key:0,icon:e.selectedNode.avatarSrc,seed:e.selectedNode.avatarSeed??e.selectedNode.label,class:"h-5 w-5 shrink-0 rounded object-cover ring-1 ring-black/10 dark:ring-white/15"},null,8,["icon","seed"])):(n(),o("span",my,[e.selectedNode?.kind==="model"?(n(),N(c(Nn),{key:0,size:15,class:"text-violet-600 dark:text-violet-400"})):e.selectedNode?.kind==="handler"?(n(),N(c(da),{key:1,size:15,class:"text-emerald-600 dark:text-emerald-400"})):(n(),N(c(xn),{key:2,size:15,class:K(i(e.selectedNode))},null,8,["class"]))])),t("span",hy,[t("span",xy,f(e.selectedNode?.label||"Agent Configuration"),1),t("span",by,f(e.selectedNode?.subtitle||"Select configuration item"),1)]),e.pinned?m("",!0):(n(),N(c(It),{key:2,size:14,class:K(["shrink-0 text-neutral-400",r.value?"rotate-180":""])},null,8,["class"]))],34),e.pinned?(n(),o("button",{key:0,type:"button",class:"inline-flex h-7 w-7 items-center justify-center rounded-md text-neutral-500 transition-colors hover:bg-neutral-100 hover:text-neutral-900 dark:text-neutral-400 dark:hover:bg-neutral-800 dark:hover:text-neutral-100",title:"Unpin configuration tree",onClick:y[1]||(y[1]=v=>l("unpin"))},[z(c(ua),{size:14})])):m("",!0),r.value&&!e.pinned?(n(),o("div",yy,[t("div",ky,[t("button",{type:"button",class:"inline-flex h-7 w-7 items-center justify-center rounded-md text-neutral-500 transition-colors hover:bg-accent-50 hover:text-accent-900 dark:text-neutral-400 dark:hover:bg-accent-950/30 dark:hover:text-accent-100",title:"Pin as sidebar",onClick:I},[z(c(ua),{size:14})])]),t("div",_y,[e.loading?(n(),o("div",wy,[z(nt,{size:"xs"}),y[2]||(y[2]=t("span",null,"Loading configuration...",-1))])):e.error?(n(),o("div",$y,f(e.error),1)):e.nodes.length===0?(n(),o("div",Cy," No agent configuration available. ")):(n(!0),o(Re,{key:3},Ke(e.nodes,({node:v,depth:k})=>(n(),o("button",{key:v.key,type:"button",class:K(["group relative flex w-full items-start gap-1.5 px-2 py-1.5 text-left leading-tight transition-colors",e.selectedNode?.key===v.key?"bg-accent-50 text-accent-900 hover:bg-accent-100 dark:bg-accent-950/30 dark:text-accent-100 dark:hover:bg-accent-900/40":"text-neutral-700 hover:bg-accent-50 hover:text-accent-900 dark:text-neutral-300 dark:hover:bg-accent-950/30 dark:hover:text-accent-100"]),style:bt({paddingLeft:`${e.baseIndentPx+k*e.levelIndentPx}px`}),onClick:j=>p(v.key)},[(n(!0),o(Re,null,Ke(k,j=>(n(),o("span",{key:j,"aria-hidden":"true",class:"pointer-events-none absolute inset-y-0 w-px bg-neutral-200 dark:bg-neutral-800",style:bt({left:`${e.baseIndentPx+(j-1)*e.levelIndentPx}px`})},null,4))),128)),v.avatarSrc?(n(),N(bn,{key:0,icon:v.avatarSrc,seed:v.avatarSeed??v.label,class:"relative z-[1] mt-px h-5 w-5 shrink-0 rounded object-cover ring-1 ring-black/10 dark:ring-white/15"},null,8,["icon","seed"])):(n(),o("span",Ty,[v.kind==="model"?(n(),N(c(Nn),{key:0,size:15,class:"text-violet-600 dark:text-violet-400"})):v.kind==="handler"?(n(),N(c(da),{key:1,size:15,class:"text-emerald-600 dark:text-emerald-400"})):(n(),N(c(xn),{key:2,size:15,class:K(i(v))},null,8,["class"]))])),t("span",Iy,[t("span",Ay,f(v.label),1),t("span",Ey,f(v.subtitle),1)])],14,Sy))),128))])])):m("",!0)]))}}),Ly={class:"h-full min-h-0 min-w-0 overflow-hidden bg-neutral-100 dark:bg-neutral-950"},Ry={key:1,class:"flex h-full items-center justify-center text-sm text-neutral-500 dark:text-neutral-400"},My=at({__name:"ThreadAgentSettingsPane",props:{agentId:{},agentName:{},agentTitle:{},active:{type:Boolean}},emits:["saved"],setup(e,{emit:s}){const a=e,l=s,{saving:r,apiError:i,saveAgent:p}=Gs(),u=b(null),I=C(()=>a.agentId?{id:a.agentId,name:a.agentName||a.agentId,title:a.agentTitle||a.agentName||a.agentId}:null);async function S(y){if(!a.agentId)return;(await p({mode:"edit",data:y,editingId:a.agentId,formNode:u.value?.formNode})).ok&&(await u.value?.markSaveSucceeded(),l("saved",y))}return xe(()=>a.active,y=>{y===!1&&u.value?.resetSaveSuccess()}),(y,v)=>(n(),o("div",Ly,[I.value?(n(),N(Ro,{key:0,ref_key:"agentModalRef",ref:u,"model-value":!0,"edit-agent":I.value,mode:"edit",inline:"","inline-global-notice":"","inline-accent-tabs":"",saving:c(r),"api-error":c(i),onSave:S},{"nav-leading":Be(()=>[Pt(y.$slots,"nav-leading")]),_:3},8,["edit-agent","saving","api-error"])):(n(),o("div",Ry," No agent configured "))]))}}),Dy={class:"flex h-full min-h-0 min-w-0 flex-col overflow-hidden bg-neutral-100 dark:bg-neutral-950"},Fy={key:0,class:"sticky top-0 z-10 flex min-w-0 shrink-0 items-center gap-2 border-b border-neutral-200 bg-neutral-50/95 px-3 backdrop-blur dark:border-neutral-800 dark:bg-neutral-950/95"},Py={key:0,class:"min-w-0 flex-1"},Ny={key:1,class:"min-h-0 min-w-0 flex-1"},zy={key:2,class:"flex h-full items-center justify-center text-sm text-neutral-500 dark:text-neutral-400"},jy=at({__name:"ThreadModelSettingsPane",props:{modelId:{},modelName:{},modelProvider:{},modelActual:{},model:{},active:{type:Boolean}},emits:["saved"],setup(e,{emit:s}){const a=e,l=s,{saving:r,saveModel:i}=Ys(),p=b(null),u=b(null),I=["basics","capabilities","fallbacks"],{activeTab:S,scrollToSection:y}=Ar(u,I),v=[{id:"basics",label:"Basic",icon:ca},{id:"capabilities",label:"Capabilities",icon:Qs},{id:"fallbacks",label:"Fallback Models",icon:Zs}],k=C(()=>a.modelId?{id:a.model?.id||a.modelId,name:a.model?.name||a.modelName||a.modelId,provider:a.model?.provider||a.modelProvider||"",model:a.model?.model||a.modelActual||a.modelId,fallbacks:a.model?.fallbacks,capabilities:a.model?.capabilities,providerTools:a.model?.providerTools}:null);async function j(W){!k.value?.id||!(await i({mode:"edit",data:W,editingId:k.value.id,formNode:p.value?.formNode})).ok||(p.value?.markCurrentPayloadClean?.(),l("saved"))}function $(W){u.value=W}return xe(()=>a.active,()=>{p.value?.markCurrentPayloadClean?.()}),(W,U)=>(n(),o("div",Dy,[k.value||W.$slots["nav-leading"]?(n(),o("nav",Fy,[Pt(W.$slots,"nav-leading"),k.value?(n(),o("div",Py,[z(c(Er),{tabs:v,"active-tab":c(S),"accent-active":"",orientation:"horizontal",onSelect:c(y)},null,8,["active-tab","onSelect"])])):m("",!0)])):m("",!0),k.value?(n(),o("div",Ny,[z(c(ha),{config:c(xa)},{default:Be(()=>[z(Xs,{ref_key:"modelPaneRef",ref:p,"edit-model":k.value,mode:"edit",saving:c(r),"show-global-notice":"",page:"","body-ref":$,onSave:j},null,8,["edit-model","saving"])]),_:1},8,["config"])])):m("",!0),k.value?m("",!0):(n(),o("div",zy," No model configured "))]))}}),By={class:"h-full min-h-0 min-w-0 overflow-hidden bg-neutral-100 dark:bg-neutral-950"},Oy={key:1,class:"flex h-full items-center justify-center text-sm text-neutral-500 dark:text-neutral-400"},Vy=at({__name:"ThreadPromptSettingsPane",props:{promptName:{},active:{type:Boolean}},emits:["saved"],setup(e,{emit:s}){const a=e,l=s,{saving:r,apiError:i,savePrompt:p}=eo(),u=b(0),I=b(0),S=C(()=>a.promptName?{id:a.promptName,name:a.promptName}:null);async function y(v){if(!a.promptName)return;(await p({mode:"edit",data:v,editingId:a.promptName})).ok&&(u.value+=1,l("saved"))}return xe(()=>a.active,v=>{v===!1&&(I.value+=1)}),(v,k)=>(n(),o("div",By,[S.value?(n(),N(po,{key:0,"model-value":!0,"edit-prompt":S.value,mode:"edit",inline:"","inline-global-notice":"","inline-accent-tabs":"","save-success-key":u.value,"reset-success-key":I.value,saving:c(r),"api-error":c(i),onSave:y},{"nav-leading":Be(()=>[Pt(v.$slots,"nav-leading")]),_:3},8,["edit-prompt","save-success-key","reset-success-key","saving","api-error"])):(n(),o("div",Oy," No prompt configured "))]))}}),Hy={class:"flex h-full min-h-0 flex-col overflow-hidden bg-neutral-100 dark:bg-neutral-950"},qy={class:"flex min-h-0 min-w-0 flex-1"},Uy={key:0,class:"flex h-full w-64 shrink-0 flex-col border-r border-neutral-200 bg-white dark:border-neutral-800 dark:bg-neutral-900"},Wy={class:"flex h-8 shrink-0 items-center justify-end border-b border-neutral-200 px-1 dark:border-neutral-800"},Ky={class:"min-h-0 flex-1 overflow-y-auto py-1.5 text-[12px]"},Jy={key:0,class:"flex items-center gap-2 px-3 py-3 text-xs text-neutral-500 dark:text-neutral-400"},Gy={key:1,class:"px-3 py-3 text-xs text-red-600 dark:text-red-400"},Yy={key:2,class:"px-3 py-3 text-xs text-neutral-500 dark:text-neutral-400"},Qy=["onClick"],Zy={key:1,class:"relative z-[1] mt-px flex h-5 w-5 shrink-0 items-center justify-center"},Xy={class:"relative z-[1] min-w-0 flex-1"},ek={class:"block truncate text-xs font-medium"},tk={class:"block truncate text-[10px] leading-tight text-neutral-500 dark:text-neutral-400"},nk={class:"min-w-0 flex-1 overflow-hidden"},ak={key:3,class:"flex h-full items-center justify-center gap-2 text-sm text-neutral-500 dark:text-neutral-400"},rk={key:4,class:"flex h-full items-center justify-center text-sm text-red-600 dark:text-red-400"},sk={key:5,class:"flex h-full flex-col items-center justify-center gap-1 px-6 text-center text-sm text-neutral-500 dark:text-neutral-400"},ok={class:"font-mono text-neutral-700 dark:text-neutral-200"},lk={key:6,class:"flex h-full items-center justify-center text-sm text-neutral-500 dark:text-neutral-400"},ir=5,fn=7,pn=9,ik=at({__name:"ThreadAgentConfigurationPane",props:{agentId:{},agentName:{},agentTitle:{},sideAPromptName:{},sideBPromptName:{},active:{type:Boolean}},emits:["agentSaved","saved"],setup(e,{emit:s}){const a=e,l=s,r=b(null),i=b(null),p=b(!1),u=b(null),I=b({}),S=b({}),y=new Map,v=new Map,k=Es("agentbuilder.threadAgentConfiguration.pinnedTree",!1);let j=0;const $=C(()=>a.agentName||a.agentId||null),W=C(()=>!r.value||!i.value?null:R(r.value,i.value)),U=C(()=>W.value?G(W.value):null),Y=C(()=>{if(!r.value)return[];const E=[],fe=(be,Pe)=>{E.push({node:be,depth:Pe});for(const J of be.children)fe(J,Pe+1)};return fe(r.value,0),E}),ue=C(()=>{const E=W.value;return!E||!ee(E)?null:E}),ae=C(()=>{const E=W.value;return!E||!E.promptName||E.kind!=="prompt"&&E.kind!=="subprompt"?null:E}),oe=C(()=>{const E=W.value;return!E||E.kind!=="model"||!E.modelId?null:E}),ve=C(()=>W.value||r.value);function ee(E){return E.kind==="agent"||E.kind==="handoff"||E.kind==="subagent"}function G(E){return E.kind==="model"?`model:${E.modelId||E.modelName}`:E.promptName?`prompt:${E.promptName}`:`agent:${E.agentName||E.agentId}`}function R(E,fe){if(E.key===fe)return E;for(const be of E.children){const Pe=R(be,fe);if(Pe)return Pe}return null}function H(E,fe){if(G(E)===fe)return E;for(const be of E.children){const Pe=H(be,fe);if(Pe)return Pe}return null}async function D(){if(!(Object.keys(I.value).length>0))try{I.value=await hn("/tools")}catch{I.value={}}}async function X(){if(!(Object.keys(S.value).length>0))try{const E=await hn("/models"),fe={};for(const be of E.models||[])fe[be.id]=be,fe[be.name]=be;S.value=fe}catch{S.value={}}}async function Se(E){if(y.has(E))return y.get(E)??null;try{const fe=await hn(`/agents/${encodeURIComponent(E)}`);return y.set(E,fe.agent),fe.agent}catch{return y.set(E,null),null}}async function ne(E){if(v.has(E))return v.get(E)??null;const fe=await go(E);return v.set(E,fe),fe}function Le(E){const fe=I.value[E.name]?.type;return fe==="prompt"?"subprompt":fe==="handoff"||fe==="agent"?"handoff":null}function B(E){if(!E)return null;const fe=S.value[E];return fe||Object.values(S.value).find(be=>be.name===E)||null}function re(E,fe){if(!E.model_id)return null;const be=B(E.model_id),Pe=be?.provider||E.model_provider||null,J=be?.model||null,ke=[Pe,J].filter(Boolean).join(" · ");return{key:`${fe}/model:${be?.id||E.model_id}`,kind:"model",label:be?.name||E.model_name||E.model_id,subtitle:ke||"Model",model:be,modelId:be?.id||E.model_id,modelName:be?.name||E.model_name||E.model_id,modelProvider:Pe||void 0,modelActual:J||E.model_id,children:[]}}async function Ce(E,fe,be,Pe,J,ke,ye){const Ae=await Se(E),V=Ae?.name||E,$e=Ae?.id||E,pe=Ae?.title||ye||V,Fe={key:`${be}/agent:${V}`,kind:fe,label:pe,subtitle:fe==="agent"?"Agent":fe==="handoff"?"Handoff agent":"Sub-agent",agentId:$e,agentName:V,agentTitle:pe,avatarSrc:Ae?.icon||jn(V),avatarSeed:V,children:[]};if(Pe>=ir)return Fe;if(J.has(V))return Fe.subtitle=`${Fe.subtitle} · already shown`,Fe;const tt=new Set(J).add(V),Qe=ze(Ae,fe==="agent"),lt=(await Promise.all(Qe.map((He,de)=>le(He.name,"prompt",`${Fe.key}/prompt:${de}:${He.name}`,Pe+1,tt,new Set(ke),He.label)))).filter(He=>!!He),he=Ve(Ae).map(He=>({key:`${Fe.key}/handler:${He.side}:${He.name}`,kind:"handler",label:He.name,subtitle:He.label,children:[]})),O=Te(Ae),se=await Promise.all(O.map((He,de)=>Ce(He.agent,"subagent",`${Fe.key}/subagent:${de}:${He.name}`,Pe+1,new Set(tt),new Set(ke),He.name!==He.agent?He.name:void 0)));return Fe.children=[...lt,...he,...se],Fe}function ze(E,fe){if(E){const Pe=[];return E.side_a_backing==="prompt"&&E.side_a_agent_prompt&&Pe.push({name:E.side_a_agent_prompt,label:`${E.side_a_label||"Side A"} prompt`}),E.side_b_backing==="prompt"&&E.side_b_agent_prompt&&Pe.push({name:E.side_b_agent_prompt,label:`${E.side_b_label||"Side B"} prompt`}),Pe}if(!fe)return[];const be=[];return a.sideAPromptName&&be.push({name:a.sideAPromptName,label:"Side A prompt"}),a.sideBPromptName&&be.push({name:a.sideBPromptName,label:"Side B prompt"}),be}function Ve(E){if(!E)return[];const fe=[];return E.side_a_backing==="handler"&&fe.push({side:"a",name:E.side_a_handler||"Handler",label:`${E.side_a_label||"Side A"} handler`}),E.side_b_backing==="handler"&&fe.push({side:"b",name:E.side_b_handler||"Handler",label:`${E.side_b_label||"Side B"} handler`}),fe}function Te(E){return E?[...E.side_a_subagents||[],...E.side_b_subagents||[]].map(fe=>({agent:fe.agent,name:fe.as?.trim()||fe.agent})):[]}async function le(E,fe,be,Pe,J,ke,ye){const Ae=await ne(E),V={key:be,kind:fe,label:Ae?.name||E,subtitle:fe==="subprompt"?"Subprompt":ye,promptName:Ae?.name||E,children:[]};if(Pe>=ir||!Ae)return V;if(ke.has(Ae.name))return V.subtitle=`${V.subtitle} · already shown`,V;const $e=new Set(ke).add(Ae.name),pe=[],Fe=re(Ae,V.key);Fe&&pe.push(Fe);for(const tt of Ae.tools||[]){const Qe=Le(tt);if(Qe)if(Qe==="subprompt"){const lt=await le(tt.name,"subprompt",`${V.key}/subprompt:${tt.name}`,Pe+1,new Set(J),$e,"Subprompt");lt&&pe.push(lt)}else pe.push(await Ce(tt.name,Qe,`${V.key}/${Qe}:${tt.name}`,Pe+1,new Set(J),$e))}return V.children=pe,V}async function we(){const E=$.value;if(!a.active||!E)return;const fe=++j,be=U.value;p.value=!0,u.value=null;try{await Promise.all([D(),X()]);const Pe=await Ce(E,"agent","root",0,new Set,new Set,a.agentTitle);if(fe!==j)return;r.value=Pe;const J=be?H(Pe,be):null;i.value=J?.key||Pe.key}catch{fe===j&&(r.value=null,i.value=null,u.value="Agent configuration could not be loaded.")}finally{fe===j&&(p.value=!1)}}function ce(E){i.value=E.key}function te(E){i.value=E}function ie(E){return E.kind==="subprompt"?"text-fuchsia-600 dark:text-fuchsia-400":"text-sky-600 dark:text-sky-400"}function me(E){return E.kind==="model"?"text-violet-600 dark:text-violet-400":E.kind==="handler"?"text-emerald-600 dark:text-emerald-400":ie(E)}function Q(){k.value=!0}function Me(){k.value=!1}function Ne(E){W.value?.key===r.value?.key&&l("agentSaved",E),l("saved"),we()}function Ue(){l("saved"),we()}function We(){S.value={},l("saved"),we()}return xe(()=>[a.active,a.agentId,a.agentName,a.sideAPromptName,a.sideBPromptName],()=>{a.active&&we()},{immediate:!0}),(E,fe)=>(n(),o("div",Hy,[t("div",qy,[c(k)?(n(),o("aside",Uy,[t("div",Wy,[t("button",{type:"button",class:"inline-flex h-7 w-7 items-center justify-center rounded-md text-accent-700 transition-colors hover:bg-accent-50 hover:text-accent-900 dark:text-accent-300 dark:hover:bg-accent-950/30 dark:hover:text-accent-100",title:"Unpin configuration tree",onClick:Me},[z(c(ua),{size:14})])]),t("div",Ky,[p.value?(n(),o("div",Jy,[z(nt,{size:"xs"}),fe[0]||(fe[0]=t("span",null,"Loading configuration...",-1))])):u.value?(n(),o("div",Gy,f(u.value),1)):Y.value.length===0?(n(),o("div",Yy," No agent configuration available. ")):(n(!0),o(Re,{key:3},Ke(Y.value,({node:be,depth:Pe})=>(n(),o("button",{key:be.key,type:"button",class:K(["group relative flex w-full items-start gap-1.5 px-2 py-1.5 text-left leading-tight transition-colors",i.value===be.key?"bg-accent-50 text-accent-900 hover:bg-accent-100 dark:bg-accent-950/30 dark:text-accent-100 dark:hover:bg-accent-900/40":"text-neutral-700 hover:bg-accent-50 hover:text-accent-900 dark:text-neutral-300 dark:hover:bg-accent-950/30 dark:hover:text-accent-100"]),style:bt({paddingLeft:`${fn+Pe*pn}px`}),onClick:J=>ce(be)},[(n(!0),o(Re,null,Ke(Pe,J=>(n(),o("span",{key:J,"aria-hidden":"true",class:"pointer-events-none absolute inset-y-0 w-px bg-neutral-200 dark:bg-neutral-800",style:bt({left:`${fn+(J-1)*pn}px`})},null,4))),128)),be.avatarSrc?(n(),N(bn,{key:0,icon:be.avatarSrc,seed:be.avatarSeed??be.label,class:"relative z-[1] mt-px h-5 w-5 shrink-0 rounded object-cover ring-1 ring-black/10 dark:ring-white/15"},null,8,["icon","seed"])):(n(),o("span",Zy,[be.kind==="model"?(n(),N(c(Nn),{key:0,size:15,class:"text-violet-600 dark:text-violet-400"})):be.kind==="handler"?(n(),N(c(da),{key:1,size:15,class:K(me(be))},null,8,["class"])):(n(),N(c(xn),{key:2,size:15,class:K(me(be))},null,8,["class"]))])),t("span",Xy,[t("span",ek,f(be.label),1),t("span",tk,f(be.subtitle),1)])],14,Qy))),128))])])):m("",!0),t("section",nk,[ue.value?(n(),N(My,{key:ue.value.key,class:"h-full","agent-id":ue.value.agentId||ue.value.agentName||null,"agent-name":ue.value.agentName,"agent-title":ue.value.agentTitle,active:e.active,onSaved:Ne},Wt({_:2},[c(k)?void 0:{name:"nav-leading",fn:Be(()=>[z(sa,{nodes:Y.value,"selected-node":ve.value,pinned:c(k),loading:p.value,error:u.value,"base-indent-px":fn,"level-indent-px":pn,onSelect:te,onPin:Q,onUnpin:Me},null,8,["nodes","selected-node","pinned","loading","error"])]),key:"0"}]),1032,["agent-id","agent-name","agent-title","active"])):ae.value?(n(),N(Vy,{key:ae.value.key,class:"h-full","prompt-name":ae.value.promptName||null,active:e.active,onSaved:Ue},Wt({_:2},[c(k)?void 0:{name:"nav-leading",fn:Be(()=>[z(sa,{nodes:Y.value,"selected-node":ve.value,pinned:c(k),loading:p.value,error:u.value,"base-indent-px":fn,"level-indent-px":pn,onSelect:te,onPin:Q,onUnpin:Me},null,8,["nodes","selected-node","pinned","loading","error"])]),key:"0"}]),1032,["prompt-name","active"])):oe.value?(n(),N(jy,{key:oe.value.key,class:"h-full","model-id":oe.value.modelId||null,"model-name":oe.value.modelName,"model-provider":oe.value.modelProvider,"model-actual":oe.value.modelActual,model:oe.value.model||null,active:e.active,onSaved:We},Wt({_:2},[c(k)?void 0:{name:"nav-leading",fn:Be(()=>[z(sa,{nodes:Y.value,"selected-node":ve.value,pinned:c(k),loading:p.value,error:u.value,"base-indent-px":fn,"level-indent-px":pn,onSelect:te,onPin:Q,onUnpin:Me},null,8,["nodes","selected-node","pinned","loading","error"])]),key:"0"}]),1032,["model-id","model-name","model-provider","model-actual","model","active"])):p.value?(n(),o("div",ak,[z(nt,{size:"xs"}),fe[1]||(fe[1]=t("span",null,"Loading configuration...",-1))])):u.value?(n(),o("div",rk,f(u.value),1)):W.value?.kind==="handler"?(n(),o("div",sk,[t("span",ok,f(W.value.label),1),fe[2]||(fe[2]=t("span",null,"Handlers are deterministic code in agents/handlers/ and have no editable settings here.",-1))])):(n(),o("div",lk," Select an item to edit. "))])])]))}}),dk={class:"flex h-full min-h-0 flex-col overflow-hidden"},uk={class:"flex h-12 shrink-0 items-center justify-between border-b border-neutral-300 px-4 dark:border-neutral-700"},ck=["id","aria-selected","aria-controls","onClick"],fk={class:"min-w-0 max-w-[11rem] truncate"},pk=["aria-expanded"],vk={key:0,class:"absolute right-0 top-full z-50 mt-1"},gk={class:"min-w-0 truncate"},mk={key:0,class:"ml-auto inline-flex h-4 min-w-4 shrink-0 items-center justify-center rounded-full bg-neutral-100 px-1 text-[10px] font-semibold leading-none tabular-nums text-neutral-500 dark:bg-neutral-800 dark:text-neutral-400"},hk={class:"pointer-events-none absolute -left-[9999px] top-0 flex h-8 items-center gap-1 opacity-0"},xk={class:"max-w-[11rem] truncate"},bk={key:0,class:"inline-flex h-4 min-w-4 shrink-0 items-center justify-center rounded-full px-1 text-[10px] font-semibold leading-none tabular-nums"},yk={type:"button",tabindex:"-1",class:"inline-flex h-8 w-8 items-center justify-center rounded-md"},kk={class:"min-h-0 flex-1 overflow-hidden"},zk=at({__name:"ThreadInspectorPane",props:{threadId:{},agentId:{},agentName:{},agentTitle:{},sideAPromptName:{},sideBPromptName:{},selectedLogId:{},selectedEffectId:{},selectedEffectRef:{},hoveredLogId:{},activeTab:{},filePath:{},filesRefreshKey:{}},emits:["logClick","logHover","logsLoaded","threadDeleted","editThread","threadUpdated","update:activeTab","update:filePath"],setup(e,{expose:s,emit:a}){const l=e,r=a,i=b(l.activeTab??"logs"),p=b(null),u=b(null),{thread:I,refetch:S}=ba(C(()=>l.threadId)),y=b(),v=b(),k=b(),j=b(0),$=b(0),W=b(0),U=C(()=>I.value?.agent?.id||l.agentId||null),Y=C(()=>I.value?.agent?.name||l.agentName||U.value||null),ue=C(()=>k.value!==void 0?k.value:I.value?.agent?.title||l.agentTitle||Y.value||null),ae=C(()=>y.value!==void 0?y.value:I.value?.agent?.side_a_agent_prompt||l.sideAPromptName||null),oe=C(()=>v.value!==void 0?v.value:I.value?.agent?.side_b_agent_prompt||l.sideBPromptName||null),ve=C(()=>{const V=[{id:"logs",label:"Logs",icon:Ls},{id:"files",label:"Files",icon:Pn,count:j.value},{id:"kv",label:"KV Store",icon:Rs,count:$.value},{id:"effects",label:"Effects",icon:Tt,count:W.value}];return U.value&&V.push({id:"config",label:"Agent Configuration",icon:ur}),V.push({id:"info",label:"Thread Settings",icon:mr}),V}),ee=b({}),G=b({}),R=b(null),H=b(null),D=b(null),X=b(0),Se=b({}),ne=b(36),Le=b({left:0,width:0}),B=b(!1);let re=null;const Ce=V=>(V.id==="files"||V.id==="kv"||V.id==="effects")&&typeof V.count=="number"&&V.count>0,ze=V=>V>99?"99+":String(V),Ve=(V,$e)=>{$e instanceof HTMLButtonElement?ee.value[V]=$e:delete ee.value[V]},Te=(V,$e)=>{$e instanceof HTMLButtonElement?G.value[V]=$e:delete G.value[V]},le=V=>{const $e=V instanceof HTMLButtonElement?V:null;H.value=$e},we=()=>{const V={};for(const $e of ve.value){const pe=G.value[$e.id];pe&&(V[$e.id]=Math.ceil(pe.getBoundingClientRect().width))}Se.value=V,H.value&&(ne.value=Math.ceil(H.value.getBoundingClientRect().width))},ce=()=>{X.value=Math.floor(R.value?.getBoundingClientRect().width??0)},te=()=>{ce(),we(),et(We)},ie=C(()=>{const V=ve.value,$e=X.value;if(!$e)return V;const pe=4;if(V.reduce((O,se)=>O+(Se.value[se.id]??88),0)+Math.max(0,V.length-1)*pe<=$e)return V;const tt=Math.max(0,$e-ne.value-pe),Qe=[];let lt=0;for(const O of V){const se=Se.value[O.id]??88,He=lt+se+(Qe.length>0?pe:0);He<=tt&&(Qe.push(O.id),lt=He)}if(!Qe.includes(i.value)&&V.some(O=>O.id===i.value)){const O=Se.value[i.value]??88;for(;Qe.length>0&&lt+O+(Qe.length>0?pe:0)>tt;){const se=Qe.pop();if(!se)break;lt-=(Se.value[se]??88)+(Qe.length>0?pe:0)}Qe.push(i.value)}const he=new Set(Qe);return V.filter(O=>he.has(O.id))}),me=C(()=>{const V=new Set(ie.value.map($e=>$e.id));return ve.value.filter($e=>!V.has($e.id))}),Q=()=>{B.value=!1},Me=()=>{B.value=!B.value},Ne=V=>{if(!B.value)return;const $e=V.target;D.value?.contains($e)||Q()},Ue=V=>{V.key==="Escape"&&B.value&&(Q(),H.value?.focus())},We=()=>{const V=ee.value[i.value];if(!V||!ie.value.some($e=>$e.id===i.value)){Le.value={left:0,width:0};return}Le.value={left:V.offsetLeft,width:V.offsetWidth}},E=V=>(Ae("logs"),V()),fe=V=>(Ae("effects"),V()),be=V=>{const $e=typeof V.title=="string"?V.title:null,pe=typeof V.side_a_agent_prompt=="string"?V.side_a_agent_prompt:null,Fe=typeof V.side_b_agent_prompt=="string"?V.side_b_agent_prompt:null;k.value=$e,y.value=pe,v.value=Fe,l.threadId&&S(),r("threadUpdated")},Pe=V=>{j.value=V},J=V=>{$.value=V},ke=V=>{W.value=V},ye=V=>{fe(()=>u.value?.selectEffectByReference(V))},Ae=V=>{ve.value.some($e=>$e.id===V)||(V="logs"),i.value=V,Q(),et(We),r("update:activeTab",V)};return xe(()=>l.activeTab,V=>{V&&V!==i.value&&(i.value=V),et(We)}),xe(ve,V=>{V.some($e=>$e.id===i.value)?et(te):Ae("logs")}),xe(()=>U.value,()=>{k.value=void 0,y.value=void 0,v.value=void 0}),xe(()=>l.threadId,()=>{j.value=0,$.value=0,W.value=0}),xe(ie,()=>{et(We)}),xe(me,V=>{V.length===0&&Q()}),Et(()=>{et(te),R.value&&(re=new ResizeObserver(te),re.observe(R.value)),window.addEventListener("resize",te),document.addEventListener("pointerdown",Ne),document.addEventListener("keydown",Ue)}),$t(()=>{re?.disconnect(),window.removeEventListener("resize",te),document.removeEventListener("pointerdown",Ne),document.removeEventListener("keydown",Ue)}),s({scrollToLog:V=>E(()=>p.value?.scrollToLog(V)),selectLogById:V=>E(()=>p.value?.selectLogById(V)),removeLogsByIds:V=>p.value?.removeLogsByIds(V),loadUntilLogId:V=>E(()=>p.value?.loadUntilLogId(V)),hasLog:V=>p.value?.hasLog(V)??!1,getLog:V=>p.value?.getLog(V)??null,setLoadingForLog:V=>E(()=>p.value?.setLoadingForLog(V)),waitForLogRow:V=>E(()=>p.value?.waitForLogRow(V)),selectEffectById:V=>fe(()=>u.value?.selectEffectById(V)),selectEffectByReference:V=>fe(()=>u.value?.selectEffectByReference(V))}),(V,$e)=>(n(),o("div",dk,[t("div",uk,[t("div",{ref_key:"tabListRef",ref:R,class:"relative flex h-8 min-w-0 flex-1 items-center gap-1 overflow-visible",role:"tablist","aria-label":"Thread inspector"},[t("div",{class:K(["pointer-events-none absolute bottom-0 top-0 rounded-md bg-neutral-900 dark:bg-neutral-100 transition-transform duration-300 ease-out",Le.value.width>0?"opacity-100":"opacity-0"]),style:bt({width:`${Le.value.width}px`,transform:`translateX(${Le.value.left}px)`})},null,6),(n(!0),o(Re,null,Ke(ie.value,pe=>(n(),o("button",{key:pe.id,ref_for:!0,ref:Fe=>Ve(pe.id,Fe),id:`thread-inspector-tab-${pe.id}`,type:"button",role:"tab","aria-selected":i.value===pe.id,"aria-controls":`thread-inspector-panel-${pe.id}`,class:K(["relative z-10 inline-flex h-8 min-w-0 shrink items-center justify-center gap-1.5 rounded-md px-2.5 text-sm font-medium transition-colors",i.value===pe.id?"text-white dark:text-neutral-900":"text-neutral-500 hover:text-neutral-900 dark:text-neutral-400 dark:hover:text-neutral-100"]),onClick:Fe=>Ae(pe.id)},[(n(),N(At(pe.icon),{size:15,class:"shrink-0"})),t("span",fk,f(pe.label),1),Ce(pe)?(n(),o("span",{key:0,class:K(["inline-flex h-4 min-w-4 shrink-0 items-center justify-center rounded-full px-1 text-[10px] font-semibold leading-none tabular-nums",i.value===pe.id?"bg-white/20 text-current dark:bg-black/10":"bg-neutral-100 text-neutral-500 dark:bg-neutral-800 dark:text-neutral-400"])},f(ze(pe.count??0)),3)):m("",!0)],10,ck))),128)),me.value.length>0?(n(),o("div",{key:0,ref_key:"overflowRootRef",ref:D,class:"relative z-20 shrink-0"},[t("button",{ref:le,type:"button",class:K(["inline-flex h-8 w-8 items-center justify-center rounded-md text-neutral-500 transition-colors hover:bg-neutral-100 hover:text-neutral-900 dark:text-neutral-400 dark:hover:bg-neutral-800 dark:hover:text-neutral-100",B.value?"bg-neutral-100 text-neutral-900 dark:bg-neutral-800 dark:text-neutral-100":""]),"aria-label":"More inspector tabs","aria-expanded":B.value,"aria-haspopup":"menu",onClick:Ye(Me,["stop"])},[z(c(Ea),{size:17})],10,pk),B.value?(n(),o("div",vk,[z(c(Sr),{width:"w-56",shadow:{offsetX:4,offsetY:4,intensity:.32}},{default:Be(()=>[(n(!0),o(Re,null,Ke(me.value,pe=>(n(),N(c(vo),{key:pe.id,active:i.value===pe.id,onClick:Fe=>Ae(pe.id)},{default:Be(()=>[(n(),N(At(pe.icon),{class:"h-4 w-4 shrink-0 text-neutral-500 dark:text-neutral-400"})),t("span",gk,f(pe.label),1),Ce(pe)?(n(),o("span",mk,f(ze(pe.count??0)),1)):m("",!0)]),_:2},1032,["active","onClick"]))),128))]),_:1})])):m("",!0)],512)):m("",!0),t("div",hk,[(n(!0),o(Re,null,Ke(ve.value,pe=>(n(),o("button",{key:`measure-${pe.id}`,ref_for:!0,ref:Fe=>Te(pe.id,Fe),type:"button",tabindex:"-1",class:"inline-flex h-8 shrink-0 items-center justify-center gap-1.5 rounded-md px-2.5 text-sm font-medium"},[(n(),N(At(pe.icon),{size:15,class:"shrink-0"})),t("span",xk,f(pe.label),1),Ce(pe)?(n(),o("span",bk,f(ze(pe.count??0)),1)):m("",!0)]))),128)),t("button",yk,[z(c(Ea),{size:17})])])],512)]),t("div",kk,[ft(z(Yg,{id:"thread-inspector-panel-logs",role:"tabpanel","aria-labelledby":"thread-inspector-tab-logs",ref_key:"logsPaneRef",ref:p,class:"h-full","thread-id":e.threadId,"selected-log-id":e.selectedLogId,"hovered-log-id":e.hoveredLogId,onLogClick:$e[0]||($e[0]=pe=>r("logClick",pe)),onLogHover:$e[1]||($e[1]=pe=>r("logHover",pe)),onLogsLoaded:$e[2]||($e[2]=pe=>r("logsLoaded",pe)),onEffectClick:ye},null,8,["thread-id","selected-log-id","hovered-log-id"]),[[wt,i.value==="logs"]]),ft(z(xx,{id:"thread-inspector-panel-files",role:"tabpanel","aria-labelledby":"thread-inspector-tab-files",class:"h-full","thread-id":e.threadId,path:e.filePath,"refresh-key":e.filesRefreshKey,active:i.value==="files","onUpdate:path":$e[3]||($e[3]=pe=>r("update:filePath",pe)),onCountChanged:Pe},null,8,["thread-id","path","refresh-key","active"]),[[wt,i.value==="files"]]),ft(z(ab,{id:"thread-inspector-panel-kv",role:"tabpanel","aria-labelledby":"thread-inspector-tab-kv",class:"h-full","thread-id":e.threadId,active:i.value==="kv",onCountChanged:J},null,8,["thread-id","active"]),[[wt,i.value==="kv"]]),ft(z(_h,{id:"thread-inspector-panel-effects",role:"tabpanel","aria-labelledby":"thread-inspector-tab-effects",ref_key:"effectsPaneRef",ref:u,class:"h-full","thread-id":e.threadId,active:i.value==="effects","selected-effect-id":e.selectedEffectId,"selected-effect-ref":e.selectedEffectRef,onCountChanged:ke},null,8,["thread-id","active","selected-effect-id","selected-effect-ref"]),[[wt,i.value==="effects"]]),ft(z(vy,{id:"thread-inspector-panel-info",role:"tabpanel","aria-labelledby":"thread-inspector-tab-info",class:"h-full","thread-id":e.threadId,show:i.value==="info",embedded:"",onThreadDeleted:$e[4]||($e[4]=pe=>r("threadDeleted",pe)),onEditThread:$e[5]||($e[5]=pe=>r("editThread")),onThreadUpdated:$e[6]||($e[6]=pe=>r("threadUpdated"))},null,8,["thread-id","show"]),[[wt,i.value==="info"]]),U.value?ft((n(),N(ik,{key:0,id:"thread-inspector-panel-config",role:"tabpanel","aria-labelledby":"thread-inspector-tab-config",class:"h-full","agent-id":U.value,"agent-name":Y.value,"agent-title":ue.value,"side-a-prompt-name":ae.value,"side-b-prompt-name":oe.value,active:i.value==="config",onAgentSaved:be,onSaved:$e[7]||($e[7]=pe=>r("threadUpdated"))},null,8,["agent-id","agent-name","agent-title","side-a-prompt-name","side-b-prompt-name","active"])),[[wt,i.value==="config"]]):m("",!0)])]))}});export{Ro as A,cu as C,Pk as T,Nk as _,go as a,Dk as b,ko as c,Rk as d,Lr as e,hn as f,ho as g,zk as h,en as i,Fk as r,Mk as s,ba as u};