ompchamber 1.2.0 → 1.2.1

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.
@@ -24,7 +24,7 @@
24
24
  href="https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap"
25
25
  />
26
26
  <!--app-head-->
27
- <script defer src="/static/js/markdown-vendor.71e43278b3.js"></script><script defer src="/static/js/shiki-vendor.cb8452ddcd.js"></script><script defer src="/static/js/77.8022a800b5.js"></script><script defer src="/static/js/index.57b39ffa7f.js"></script><link href="/static/css/index.b938f4a693.css" rel="stylesheet"></head>
27
+ <script defer src="/static/js/markdown-vendor.71e43278b3.js"></script><script defer src="/static/js/shiki-vendor.cb8452ddcd.js"></script><script defer src="/static/js/77.8022a800b5.js"></script><script defer src="/static/js/index.5fe7a2cb64.js"></script><link href="/static/css/index.b938f4a693.css" rel="stylesheet"></head>
28
28
  <body>
29
29
  <div id="app"></div>
30
30
  <!--app-bootstrap-->
@@ -1,4 +1,4 @@
1
- /*! LICENSE: index.57b39ffa7f.js.LICENSE.txt */
1
+ /*! LICENSE: index.5fe7a2cb64.js.LICENSE.txt */
2
2
  (()=>{"use strict";var e,t,n,r,i,s={vp(e,t,n){n.d(t,{T:()=>H});var r=n("j"),i=n("H"),s=n("XT7"),a=n("HA"),l=n("rt"),o=n("DU"),c=n("L");let d=["math","annotation","annotation-xml","semantics","mrow","mi","mn","mo","mspace","ms","mtext","mroot","mfrac","msqrt","mstyle","merror","mpadded","mphantom","mtable","mtr","mtd","mlabeledtr","munder","mover","munderover","msup","msub","msubsup","mtext","mtd","menclose"],u=["svg","path","polyline","rect","circle","line"],p=["viewBox","d","points","x","y","x1","y1","x2","y2","width","height","rx","ry","cx","cy","r","fill","stroke","stroke-width","stroke-linecap","stroke-linejoin","xmlns","aria-hidden","aria-label"],m=["svg","g","line","path","rect","circle","ellipse","polygon","polyline","text","tspan","title","desc","marker","defs","style","use","symbol","foreignObject","html","head","body","div","span","p","br","img"],h=["id","class","style","transform","viewBox","width","height","xmlns","x","y","x1","y1","x2","y2","cx","cy","r","rx","ry","d","points","fill","stroke","stroke-width","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-opacity","fill-opacity","opacity","font-family","font-size","font-weight","font-style","text-anchor","dominant-baseline","alignment-baseline","text-decoration","direction","marker-end","marker-start","marker-mid","markerWidth","markerHeight","refX","refY","orient","markerUnits","preserveAspectRatio","version","dx","dy","dy1","dy2","rowspan","colspan","start","aria-roledescription","aria-describedby","role","aria-hidden","aria-label","data-mermaid-theme","overflow","visibility","rel","src","alt"],f=["href","xlink:href"],x=null,g="math-pending";function b(){return x||(x=n.e(121).then(n.bind(n,"Bi")).then(e=>e.default).catch(e=>(console.error("[katex] load failed",e),null))),x}async function v(e){let t=[...e.querySelectorAll(`.${g}`)];if(0===t.length)return{rendered:0,failed:0};let n=await b();if(!n)return{rendered:0,failed:t.length};let r=0;for(let e of t)e.isConnected&&(!function(e,t){let n=e.dataset.math??"",r="1"===e.dataset.mathDisplay;try{e.innerHTML=function(e){if(!e||"u"<typeof window||!window.document)return e;let t=`<div data-katex-wrap>${e}</div>`;try{let e=c.A.sanitize(t,{USE_PROFILES:{html:!0,mathMl:!0},ADD_ATTR:["class","aria-hidden","encoding","style","data-katex-wrap"]}),n=document.createElement("div");return n.innerHTML=e,n.querySelector("[data-katex-wrap]")?.innerHTML??e}catch{return e}}(t.renderToString(n,{throwOnError:!1,displayMode:r})),e.classList.remove(g),e.removeAttribute("data-math"),e.removeAttribute("data-math-display")}catch{e.textContent=n,e.classList.remove(g)}}(e,n),r+=1);return{rendered:r,failed:0}}function k(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function y(e,t){let n=k(e),r=`<span class="${g}" data-math="${n}"${t?' data-math-display="1"':""}></span>`;return t?`<p>${r}</p>`:r}let w=new s.Dz({gfm:!0,breaks:!0});function N(e,t){let n=e.replace(/"/g,"&quot;");return`<div class="code-block">
3
3
  <button type="button" class="code-copy-float" data-copy="${n}" aria-label="Copy code">
4
4
  <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>
@@ -16,7 +16,7 @@ ${r}`}function ns(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1
16
16
  .dot-anim-2 { animation: bounce-dot 1.2s infinite both 0.2s; }
17
17
  .dot-anim-3 { animation: bounce-dot 1.2s infinite both 0.4s; }
18
18
  `}),(0,r.FD)("div",{className:"flex items-center space-x-2 min-w-0",children:[(0,r.FD)("div",{className:"relative w-4 h-4 rounded flex items-center justify-center shrink-0",children:[(0,r.Y)("div",{className:"absolute -inset-[1.5px] rounded-[5px] animate-spin",style:{background:"conic-gradient(from 0deg, #ff453a, #ff9f0a, #ffd60a, #30d158, #64d2ff, #0a84ff, #bf5af2, #ff375f, #ff453a)",animationDuration:"1.2s"}}),(0,r.Y)("div",{className:"relative w-full h-full rounded-[3px] bg-ink flex items-center justify-center text-canvas z-10 shadow-2xs",children:(0,r.Y)(J.A,{size:10,className:"text-canvas"})})]}),(0,r.FD)("div",{className:"flex items-center space-x-1.5 min-w-0 truncate",children:[d&&(0,r.Y)("span",{className:"text-ink/55 truncate shrink",children:d}),(0,r.Y)("span",{className:"font-semibold text-ink truncate",children:t}),(0,r.Y)("span",{className:"text-ink/40 shrink-0",children:"•"}),(0,r.FD)("span",{className:"text-ink/75 flex items-center space-x-1 shrink-0 font-medium",children:[(0,r.Y)("span",{className:"transition-all duration-300",children:c}),(0,r.FD)("span",{className:"inline-flex tracking-wider text-ink/80 ml-0.5",children:[(0,r.Y)("span",{className:"dot-anim-1 inline-block",children:"."}),(0,r.Y)("span",{className:"dot-anim-2 inline-block",children:"."}),(0,r.Y)("span",{className:"dot-anim-3 inline-block",children:"."})]})]})]})]})]})}function is(e){let t=e.length-1;for(;t>=0&&r1(e[t]);)t--;return t}function ia(e){let t=Array(e.length),n=-1;for(let r=0;r<e.length;r++)t[r]=n,r1(e[r])||(n=r);return t}function il(e,t){let n=e.length,r=Array(n).fill(null),i=is(e),s=-1;for(let a=0;a<n;a++){let l=e[a];if("user"===l.role){s=-1;continue}if(r1(l)||(s=a),a!==n-1&&e[a+1]?.role!=="user"||s<0)continue;let o=e[s];t&&s===i&&"ai"===o.role||(r[a]={msg:o,ownerIndex:s,durationMs:function(e,t){var n;let r=(n=e[t],"number"==typeof n?.completedAt&&Number.isFinite(n.completedAt)?n.completedAt:r9(n));if(null===r)return null;let i=null;for(let n=t-1;n>=0;n--){if(e[n]?.role==="user"){i=r9(e[n]);break}let t=r9(e[n]);null!==t&&(i=t)}return null===i||r<=i?null:r-i}(e,s)??o.durationMs??null})}return r}function io(e){let{className:t="",folders:n=[],selectedFolderId:s,setSelectedFolderId:a,inputValue:l,setInputValue:o,inputAttachments:c,setInputAttachments:d,onSend:u,isGenerating:p,appSettings:m={},messages:h=[],provider:f,providerNames:x,modelName:g,modelNames:b,rootPath:v,onThinkingLevelChange:k,onModelChange:y,sessionModel:F,sessionThinkingLevel:C,accessMode:S,onAccessModeChange:T,composerModelRef:$,deferredComposerPickRef:z,generatingVerb:j,variant:L="desktop"}=e,[M,E]=(0,i.J0)(!1),P=(0,i.li)(null);(0,A.W)(P,()=>E(!1));let I=(0,i.li)(null),R=(0,i.Kr)(()=>n?.find(e=>e.id===s),[n,s]),{streamingIdx:O,footers:J}=(0,i.Kr)(()=>({streamingIdx:is(h),footers:il(h,p)}),[h,p]);return(0,i.vJ)(()=>{I.current&&(I.current.scrollTop=I.current.scrollHeight)},[h.length]),(0,r.Y)("div",{className:`flex flex-col h-full bg-canvas ${"mobile"===L?"px-3 py-4":"p-8"} ${t}`,style:"mobile"===L?{paddingBottom:"max(1rem, env(safe-area-inset-bottom, 0px))"}:void 0,children:(0,r.FD)("div",{className:`mx-auto w-full max-w-[970px] flex flex-col min-h-0 space-y-3 ${h.length>0?"flex-1":"my-auto justify-center"}`,children:[0===h.length&&(0,r.FD)("div",{className:"relative shrink-0",ref:P,children:[(0,r.FD)("button",{type:"button",onClick:()=>E(!M),className:"group flex items-center space-x-1.5 px-1.5 py-1 rounded-md text-xs font-medium text-ink/75 hover:text-ink hover:bg-ink/5 focus-visible:bg-ink/5 transition-all outline-none cursor-pointer select-none",children:[(0,r.Y)(N.A,{size:13,className:"text-ink/50 group-hover:text-ink/80 transition-colors flex-shrink-0"}),(0,r.Y)("span",{className:"flex items-center space-x-1 max-w-[260px] truncate tracking-tight",children:(0,r.Y)("span",{children:R?R.name:"Select Workspace Context"})}),(0,r.Y)(Y.A,{size:13,className:`text-ink/40 group-hover:text-ink/70 flex-shrink-0 transition-transform duration-150 ${M?"rotate-180 text-ink/70":""}`})]}),M&&(0,r.FD)("div",{className:"absolute bottom-full left-0 mb-1.5 w-64 bg-paper border border-ink/10 rounded-lg shadow-lg z-50 flex flex-col overflow-hidden text-xs py-1",children:[(0,r.Y)("div",{className:"px-3 py-1.5 text-[10px] uppercase tracking-wider text-ink/40 font-semibold border-b border-ink/5",children:"Target Workspace"}),(0,r.Y)("div",{className:"max-h-56 scrollbar-overlay-container scrollbar-overlay-static py-1",children:0===n.length?(0,r.Y)("div",{className:"px-3 py-2 text-ink/40 italic",children:"No workspaces available"}):n.map(e=>(0,r.FD)("button",{type:"button",onClick:()=>{a(e.id),E(!1)},className:`w-full text-left px-3 py-1.5 flex items-center justify-between transition-colors cursor-pointer ${s===e.id?"bg-ink/10 text-ink font-semibold":"text-ink/80 hover:bg-ink/5 hover:text-ink"}`,children:[(0,r.FD)("div",{className:"flex items-center space-x-2 truncate pr-2",children:[(0,r.Y)(N.A,{size:12,className:s===e.id?"text-ink flex-shrink-0":"text-ink/50 flex-shrink-0"}),(0,r.Y)("span",{className:"truncate font-medium",children:e.name})]}),s===e.id&&(0,r.Y)(D.A,{size:12,className:"text-ink flex-shrink-0"})]},e.id))})]})]}),h.length>0&&(0,r.Y)("div",{ref:I,className:"flex-1 min-h-0 overflow-y-auto scroll-smooth overscroll-contain",children:(0,r.Y)("div",{className:"mx-auto w-full max-w-[970px]",children:h.map((e,t)=>{let n=h[t-1],i=p&&t===O&&"ai"===e.role,s="user"!==e.role&&n&&"user"!==n.role,a=J[t];return(0,r.FD)(w.FK,{children:[(0,r.Y)(r2,{msg:e,isStreaming:i,className:s?"mt-1":"mt-8"}),a&&(0,r.Y)(it,{msg:a.msg,provider:f,providerNames:x,modelName:g,modelNames:b,thinkingLevel:C??void 0,durationMs:a.durationMs})]},e.id)})})}),p&&(0,r.Y)(ii,{modelName:g,generatingVerb:j,provider:f,providerNames:x}),(0,r.Y)(to,{value:l,onChange:o,rootPath:v,attachments:c,onAttachmentsChange:d,onSend:u,isGenerating:p,disabled:!s,className:"w-full shrink-0",appSettings:m,onThinkingLevelChange:k,onModelChange:y,sessionModel:F,sessionThinkingLevel:C,accessMode:S,onAccessModeChange:T,composerModelRef:$,deferredComposerPickRef:z,variant:L})]})})}let ic=[{role:"user",width:"58%",lines:1},{role:"ai",width:"100%",lines:3},{role:"user",width:"40%",lines:1},{role:"ai",width:"92%",lines:2},{role:"user",width:"52%",lines:2},{role:"ai",width:"100%",lines:4}];function id(e){let{row:t,index:n}=e;return(0,r.Y)("div",{className:`flex ${"user"===t.role?"justify-end":"justify-start"} mb-3`,children:(0,r.Y)("div",{className:"rounded-lg bg-ink/5 border border-ink/5 px-3 py-2 space-y-1.5",style:{width:t.width,maxWidth:"85%"},children:Array.from({length:t.lines},(e,i)=>(0,r.Y)("div",{className:"h-2.5 rounded bg-ink/8 animate-pulse",style:{width:i===t.lines-1?"62%":"100%",animationDelay:`${120*n+60*i}ms`}},i))})})}function iu(){let e=(0,i.Kr)(()=>ic,[]);return(0,r.FD)("div",{"aria-hidden":!0,className:"flex flex-col h-full min-h-0 overflow-hidden",children:[(0,r.Y)("div",{className:"flex-1 min-h-0 overflow-hidden px-3 py-3 pb-8 sm:p-4 sm:pb-10",children:(0,r.Y)("div",{className:"mx-auto w-full max-w-[970px]",children:e.map((e,t)=>(0,r.Y)(id,{row:e,index:t},t))})}),(0,r.Y)("div",{className:"flex-shrink-0 px-3 pt-1 pb-3 sm:p-4 sm:pt-1",children:(0,r.Y)("div",{className:"mx-auto w-full max-w-[970px]",children:(0,r.FD)("div",{className:"rounded-md border border-ink/20 bg-paper p-3 space-y-2",children:[(0,r.Y)("div",{className:"h-9 rounded bg-ink/8 animate-pulse",style:{animationDelay:"720ms"}}),(0,r.FD)("div",{className:"flex items-center justify-between",children:[(0,r.Y)("div",{className:"h-5 w-28 rounded bg-ink/8 animate-pulse",style:{animationDelay:"840ms"}}),(0,r.Y)("div",{className:"h-7 w-7 rounded bg-ink/8 animate-pulse",style:{animationDelay:"960ms"}})]})]})})})]})}function ip(){return(0,r.Y)("div",{className:"flex justify-center py-2",role:"status",children:(0,r.FD)("div",{className:"flex items-center gap-1.5 text-ink/40 text-[11px] font-mono",children:[(0,r.Y)("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-ink/30 animate-pulse"}),(0,r.Y)("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-ink/30 animate-pulse",style:{animationDelay:"150ms"}}),(0,r.Y)("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-ink/30 animate-pulse",style:{animationDelay:"300ms"}})]})})}function im(e){let{content:t,isOmpSession:n,undoing:s,onClose:a,onConfirm:l}=e;return(0,i.vJ)(()=>{let e=e=>{"Escape"!==e.key||s||(e.preventDefault(),a())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[a,s]),(0,r.Y)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-ink/40 animate-in fade-in duration-200 p-4",onClick:s?void 0:a,role:"dialog","aria-modal":"true","aria-label":"Confirm undo",children:(0,r.FD)("div",{className:"bg-paper border border-ink/20 rounded-xl shadow-xl w-[min(94vw,420px)] overflow-hidden",onClick:e=>e.stopPropagation(),children:[(0,r.FD)("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-ink/10",children:[(0,r.Y)(td.A,{size:16,className:"text-ink/70 shrink-0"}),(0,r.Y)("h2",{className:"text-[13px] font-semibold text-ink",children:"Undo message?"})]}),(0,r.FD)("div",{className:"px-4 py-4 space-y-3",children:[(0,r.Y)("div",{className:"rounded-lg border border-ink/10 bg-canvas/50 px-3 py-2 text-[12px] text-ink/80 leading-relaxed max-h-28 overflow-y-auto scrollbar-overlay-container",children:t||"Empty message or attachment-only prompt"}),(0,r.Y)("p",{className:"text-[11.5px] leading-relaxed text-ink/60",children:n?"The timeline and agent context rewind to before this message. Its reply and everything after it are removed; the text returns to the composer for editing.":"This message and everything after it are removed from the timeline. The text returns to the composer for editing."})]}),(0,r.FD)("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-ink/10",children:[(0,r.Y)("button",{type:"button",onClick:a,disabled:s,className:"px-3 py-1.5 rounded border border-ink/20 text-ink/70 hover:bg-ink/5 hover:text-ink transition-colors cursor-pointer text-xs disabled:opacity-40 disabled:cursor-not-allowed",children:"Cancel"}),(0,r.FD)("button",{type:"button",autoFocus:!s,onClick:l,disabled:s,className:"flex items-center gap-2 px-3 py-1.5 rounded bg-ink text-canvas hover:bg-ink/90 transition-colors cursor-pointer text-xs font-medium disabled:opacity-60 disabled:cursor-not-allowed",children:[s&&(0,r.Y)(tW.A,{size:13,className:"animate-spin shrink-0"}),s?"Rewinding…":"Undo"]})]})]})})}function ih(e){let{initialContent:t,onClose:n,onSend:s,appSettings:a,accessMode:l,onAccessModeChange:o,composerModelRef:c}=e,[d,u]=(0,i.J0)(t),[p,m]=(0,i.J0)([]);return(0,r.Y)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-ink/40 animate-in fade-in duration-200 p-4",children:(0,r.FD)("div",{className:"bg-canvas border border-ink/15 rounded-xl shadow-xl w-full max-w-2xl max-h-[90vh] flex flex-col overflow-hidden",onClick:e=>e.stopPropagation(),children:[(0,r.FD)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-ink/10 bg-paper",children:[(0,r.Y)("h2",{className:"text-[13px] font-semibold text-ink",children:"New Chat"}),(0,r.Y)("button",{onClick:n,className:"p-1 rounded hover:bg-ink/10 text-ink/60 hover:text-ink transition-colors",children:(0,r.Y)(C.A,{size:14})})]}),(0,r.FD)("div",{className:"p-4 flex-1 scrollbar-overlay-container scrollbar-overlay-static",children:[(0,r.Y)("p",{className:"text-xs text-ink/60 mb-3",children:"Start a new session in this workspace based on the selected message."}),(0,r.Y)(to,{value:d,onChange:u,attachments:p,onAttachmentsChange:m,onSend:e=>{s(d,e),n()},isGenerating:!1,appSettings:a,accessMode:l,onAccessModeChange:o,composerModelRef:c})]})]})})}var ix=n("Kv"),ig=n("M"),ib=n("Uo"),iv=n("T");function ik(e){if("string"==typeof e)return e;if(!Array.isArray(e))return"";let t=[];for(let n of e)(0,n3.u)(n)&&"text"===n.type&&"string"==typeof n.text&&t.push(n.text);return t.join("\n")}function iy(e,t){if(!e)return"";for(let n of t){let t=e[n];if("string"==typeof t)return t}return""}let iw=["command","cmd","CommandLine","commandLine"],iN=["path","TargetFile","targetFile","FilePath","filePath","AbsolutePath","file"],iY=new Set(["aborted","error"]);function iD(e){if("number"==typeof e&&Number.isFinite(e))return e;if("string"==typeof e){let t=new Date(e).getTime();return Number.isNaN(t)?void 0:t}}function iA(e){return"string"==typeof e?e:e&&"object"==typeof e?ik(e.content):""}function iF(e){let t,n=!(arguments.length>1)||void 0===arguments[1]||arguments[1];if("custom"===e.role){if("session_exit"===e.customType)return null;let t=e.content,n=("string"==typeof t?t:Array.isArray(t)?t.map(e=>e&&"object"==typeof e&&"text"===e.type?e.text??"":"").join(""):"").replace(/<\/?system-notice[^>]*>/g,"").trim();return n?{id:"string"==typeof e.id?e.id:`notice-${Date.now()}`,role:"ai",content:"",notice:n}:null}let r=function(e){let t={toolCalls:[],inlineOutputs:new Map,textParts:[]};if("string"==typeof e)return t.textParts.push(e),t;if(!Array.isArray(e))return t;for(let n of e)if((0,n3.u)(n))if("thinking"===n.type)"string"==typeof n.thinking?t.thinking=n.thinking:"string"==typeof n.text&&(t.thinking=n.text);else if("toolCall"===n.type){let e="string"==typeof n.id?n.id:`tool-${Math.random().toString(36).slice(2,10)}`,r="string"==typeof n.name?n.name:"tool",i=n.arguments??n.input,s=(0,n3.u)(i)?i:void 0,a=iy(s,iw),l=iy(s,iN)||(s?(0,rC.f$)(s):void 0),o="string"==typeof s?.i?s.i:void 0,c=a||l;t.toolCalls.push({id:e,name:r,title:c?`${r} — ${c}`:r,intent:o,target:l||void 0,command:a||void 0,input:s&&Object.keys(s).length>0?s:void 0}),o&&!t.intent&&(t.intent=o),t.inlineOutputs.set(e,"")}else if("toolResult"===n.type){let e="string"==typeof n.toolCallId?n.toolCallId:void 0,r="string"==typeof n.text?n.text:"";if(e&&t.inlineOutputs.has(e))t.inlineOutputs.set(e,r);else if(r&&t.toolCalls.length>0){let e=t.toolCalls[t.toolCalls.length-1];t.inlineOutputs.set(e.id,r)}}else"text"===n.type&&"string"==typeof n.text&&t.textParts.push(n.text);return t}(e.content),i="string"==typeof e.id?e.id:`msg-${e.timestamp??Date.now()}-ai`,s="user"===e.role?"user":"ai",a="number"==typeof e.timestamp?nY(e.timestamp):void 0,l="string"==typeof e.attribution?e.attribution:void 0,o=iD(e.timestamp)??iD(e.startedAt),c="number"==typeof e.duration?e.duration:"number"==typeof e.durationMs?e.durationMs:void 0,d=iD(e.completedAt)??(void 0!==o&&void 0!==c?o+c:void 0),u="string"==typeof e.provider?e.provider:void 0,p=-1===(t=r.textParts.findIndex(e=>{let t=tJ(e);return void 0!==t&&tI(t.tag)}))?void 0:t;if("developer"===e.role||"system"===e.role||void 0!==p){let e=void 0!==p?r.textParts[p]:r.textParts.join("\n"),t=void 0!==p?e.trim():e.replace(/<\/?system-reminder[^>]*>/g,"").trim();return t?{id:i,role:"ai",date:a?`Today, ${a}`:void 0,timestamp:a,content:"",notice:t}:null}if("user"===s){let t=r.textParts.join("\n");return{id:i,role:s,date:a?`Today, ${a}`:void 0,timestamp:a,startedAt:o,content:function(e){let t=e.match(/(?:^|\n{2})\s*Attached file: /);if(!t||void 0===t.index)return e;let n=e.slice(0,t.index),r=e.slice(t.index+t[0].length);return/^[^\n]+\n```[a-z]*\n/.test(r)?n.trim():e}(t),attribution:l,attachments:[...function(e){if(!Array.isArray(e))return[];let t=[],n=0;for(let r of e){if(!(0,n3.u)(r)||"image"!==r.type)continue;let e="string"==typeof r.data?r.data:void 0,i="string"==typeof r.mimeType?r.mimeType:"image/png";if(!e)continue;n+=1;let s=(i.split("/")[1]||"png").replace(/[^a-z0-9]/gi,"")||"png",a=e.startsWith("blob:sha256:");t.push({id:`att-${n}`,name:`attachment-${n}.${s}`,preview:a?"":`data:${i};base64,${e}`,type:i,...a?{blobRef:e}:{}})}return t}(e.content),...(function(e){let t,n=[],r=/(?:^|\n{2})Attached file: ([^\n]+)\n(`{3,})[a-zA-Z0-9_-]*\n/g;for(;null!==(t=r.exec(e));){let i=t[1].trim(),s=t[2],a=t.index+t[0].length,l=`
19
- ${s}`,o=a,c=-1;for(;o<=e.length;){let t=e.indexOf(l,o);if(-1===t)break;let n=e.slice(t+l.length);if(""===n||n.startsWith("\n")||/^\n{2}Attached file: /.test(n)){c=t;break}o=t+l.length}-1!==c&&(n.push({name:i,content:e.slice(a,c)}),r.lastIndex=c+l.length)}return n})(t).map((e,t)=>({id:`text-${t+1}`,name:e.name,type:"text/plain",preview:"",content:e.content}))].map(e=>({id:e.id,name:e.name,preview:e.preview,type:e.type,..."content"in e?{content:e.content}:{}}))}}let m=r.toolCalls.map(e=>{var t,r;let i,s,a,l;return t=e,r={streaming:n},s=t.input,a=(0,n3.u)(s)?Object.fromEntries(Object.entries(s).filter(e=>{let[t]=e;return"i"!==t})):s,l=r.isError?"error":void 0!==r.output?"success":r.streaming?"running":"success",{id:t.id,type:(i=(t.name||"").toLowerCase()).includes("bash")||i.includes("terminal")||i.includes("shell")||i.includes("run")?"bash":i.includes("write")||i.includes("edit")||i.includes("patch")||i.includes("apply")?"edit_file":i.includes("create")?"create_file":i.includes("read")||i.includes("view")||i.includes("list")?"read_file":i.includes("grep")||i.includes("glob")?"grep":i.includes("search")||i.includes("find")?"search_fs":i.includes("web")||i.includes("fetch")||i.includes("http")?"web_search":i.includes("todo")?"todo":i.includes("task")?"task":i.includes("lsp")?"lsp":i.includes("eval")?"eval":i.includes("github")?"github":i.includes("security")?"security_scan":"custom",name:t.name,title:t.title,intent:t.intent,target:t.target,command:t.command,input:a&&Object.keys(a).length>0?a:void 0,output:r.output,status:l}}),h={id:i,role:s,date:a?`Today, ${a}`:void 0,timestamp:a,attribution:l,model:"string"==typeof e.model?e.model:void 0,provider:u,startedAt:o,completedAt:d,durationMs:c,usage:e.usage&&"object"==typeof e.usage?e.usage:void 0,content:r.textParts.join("\n"),intent:r.intent,thinking:r.thinking?{thought:r.thinking,isGenerating:n}:e.thinking,toolCalls:m.length>0?m:e.toolCalls,summary:"string"==typeof e.summary?e.summary:void 0,error:e.error??function(e){let t;if("string"==typeof(t=e.stopReason)&&iY.has(t)||"number"==typeof e.errorStatus||"string"==typeof e.errorMessage)return{status:"number"==typeof e.errorStatus?e.errorStatus:void 0,id:"number"==typeof e.errorId?e.errorId:void 0,message:"string"==typeof e.errorMessage?e.errorMessage:void 0,stopReason:"string"==typeof e.stopReason?e.stopReason:void 0}}(e)};return h.content||h.thinking||h.toolCalls&&0!==h.toolCalls.length||h.intent||h.error||h.summary||h.notice?h:null}function iC(e,t){let n=[];for(let r of e){if((0,n3.u)(r)){let e="string"==typeof r.type?r.type:"";if("custom"===e||"custom_message"===e){let e="string"==typeof r.customType?r.customType:"";if("session_exit"===e)continue;if("launch-completion"===e||"string"==typeof r.content){let e=("string"==typeof r.content?r.content:"").replace(/<\/?system-notice[^>]*>/g,"").trim();e&&n.push({id:"string"==typeof r.id?r.id:`notice-${Date.now()}`,role:"ai",content:"",notice:e,date:"string"==typeof r.timestamp?new Date(r.timestamp).toISOString():void 0});continue}}if(e&&"message"!==e)continue}let e=function(e){if(!(0,n3.u)(e))return null;let t=(0,n3.u)(e.message)?e.message:null;if(!t)return e;let n={...t};return void 0===n.id&&"string"==typeof e.id&&(n.id=e.id),void 0===n.timestamp&&"number"==typeof e.timestamp&&(n.timestamp=e.timestamp),n}(r);if(!e)continue;if("toolResult"===e.role){let t="string"==typeof e.toolCallId?e.toolCallId:void 0,r=ik(e.content),i=(0,n3.u)(e.details)?e.details:void 0,s=!0===e.isError;for(let a=n.length-1;a>=0;a--){let l=n[a].toolCalls?.find(n=>t?n.id===t:n.name===e.toolName);if(l){r&&(l.output=r),i&&(l.details=i),l.status=s?"error":"success";break}}continue}let i=iF(e,t);i&&n.push(i)}return n}function iS(e,t){if(0===t.length)return e;let n=new Map(e.map((e,t)=>[e.id,t])),r=[...e];for(let e of t){let t=n.get(e.id);void 0===t?(n.set(e.id,r.length),r.push(e)):r[t]=e}return r}function iT(e,t,n){if(!(0,n3.u)(e)||!Array.isArray(e.messages))return null;let r="number"==typeof e.fromByte?e.fromByte:t;return{sessionFile:"string"==typeof e.sessionFile&&e.sessionFile?e.sessionFile:n??"",fromByte:r,nextByte:"number"==typeof e.nextByte?e.nextByte:r,reset:!0===e.reset,messages:e.messages,totalBytes:"number"==typeof e.totalBytes?e.totalBytes:void 0}}async function i$(e,t,n,r){try{let i=await fetch(`/api/agent/${encodeURIComponent(e)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"get_subagent_messages",subagentId:t,...n?{sessionFile:n}:{},fromByte:r})});if(!i.ok)return null;let s=await i.json().catch(()=>null),a=(0,n3.u)(s)&&"data"in s?s.data:s;return iT(a,r,n)}catch{return null}}let iz=new Map;async function ij(e,t,n){let r=`/api/sessions/${encodeURIComponent(e)}/subagents/${encodeURIComponent(t)}?fromByte=${n}`,i=iz.get(r);if(i)return i;let s=()=>{},a=new Promise(e=>{s=()=>{iz.get(r)===a&&iz.delete(r)},(async()=>{try{let t=await fetch(r);if(!t.ok)return e(null);let i=await t.json().catch(()=>null),s=(0,n3.u)(i)&&"page"in i?i.page:i;if(null==s)return e(null);e(iT(s,n,void 0))}catch{e(null)}})()});return a.then(s,s),iz.set(r,a),a}let iL={pending:"started",running:"started",completed:"completed",failed:"failed",aborted:"aborted"};function iM(e){return"completed"===e||"failed"===e||"aborted"===e}function iE(e,t){if(!e||e.id!==t.id)return t;let n={...e,...t,agent:"subagent"!==t.agent?t.agent:e.agent,index:e.index>=0?e.index:t.index,status:iM(e.status)&&!iM(t.status)?e.status:t.status},r={...e.progress,...t.progress};return Object.keys(r).length>0?n.progress=r:delete n.progress,n}function iP(e){let[t,n]=(0,i.J0)(void 0),r=(0,i.li)(e);return r.current=e,(0,i.vJ)(()=>{let e=!0,t=async()=>{try{let t=await (0,z.xo)();if(!e)return;let i=r.current(t);void 0!==i&&n(i)}catch{}};t();let i=(0,z.Sy)(t);return()=>{e=!1,i()}},[]),t}function iI(e){if(e.modelList?.length)return Object.fromEntries(e.modelList.map(e=>[e.id,e.name||e.id]))}var iR=n("V7");let iO={started:"running",completed:"done",failed:"failed",aborted:"aborted"};function iJ(e){let{sessionId:t,subagent:n,onBack:s,provider:a,providerNames:l,className:o=""}=e,{messages:c,isLoading:d,status:u,isActive:p}=function(e,t,n){let[r,s]=(0,i.J0)([]),[a,l]=(0,i.J0)(t),[o,c]=(0,i.J0)(!1),d=t?.id??null,u=!!(e&&d),p=(0,i.li)(0),m=(0,i.li)(e);m.current=e;let h=(0,i.li)(t);h.current=t;let f=(0,i.li)(n);f.current=n;let x=(0,i.li)(0),g=(0,i.li)(void 0),b=(0,i.li)(!1),v=(0,i.li)(!1),k=(0,i.li)(!1),y=(0,i.li)(null),w=(0,i.li)(()=>{}),N=(0,i.hb)(async()=>{let e=m.current,t=h.current;if(!e||!t||!b.current)return;if(v.current){k.current=!0;return}v.current=!0;let n=p.current;try{let r=await i$(e,t.id,g.current,x.current);if(n!==p.current||!r)return;g.current=r.sessionFile||g.current;let i=iC(r.messages,!0);r.reset?(s(i),x.current=r.nextByte):(s(e=>iS(e,i)),x.current=Math.max(x.current,r.nextByte))}finally{v.current=!1,k.current&&(k.current=!1,w.current())}},[]);return(0,i.vJ)(()=>{t&&l(e=>iE(e,t))},[t]),(0,i.vJ)(()=>{if(!u)return;let e=e=>{if("Escape"!==e.key||e.defaultPrevented)return;let t=e.target instanceof HTMLElement?e.target:null,n=t?.tagName;"INPUT"===n||"TEXTAREA"===n||t?.isContentEditable||f.current()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[u]),(0,i.vJ)(()=>{if(!e||!d){s([]),l(null),c(!1);return}let t=++p.current,n=h.current,r=()=>t===p.current,i=n?.source==="history";s([]),l(n),c(!0),x.current=0,g.current=n?.sessionFile,b.current=!1;let a=()=>{null===y.current&&(y.current=window.setTimeout(()=>{y.current=null,N()},150))};w.current=a;let o=async()=>{let t=0,a=g.current,o=i||!n?.sessionFile,u=[];for(let n=0;n<20;n++){let n=o?await ij(e,d,t):await i$(e,d,a,t);if(!r()||!n&&!o&&0===t&&(o=!0,n=await ij(e,d,0),!r()))return;if(!n)break;a=n.sessionFile||a;let i=iC(n.messages,!1);if(u=n.reset?i:iS(u,i),n.nextByte<=t||(t=n.nextByte,void 0!==n.totalBytes&&t>=n.totalBytes))break}r()&&(g.current=a,x.current=t,b.current=!o,s(e=>iS(e,u)),c(!1),o&&l(e=>e&&!iM(e.status)?{...e,status:"completed"}:e))},u=t=>{let n=t.detail;return n&&n.sessionId===e?n:null},m=e=>{let t=u(e);if(!t)return;let n=(0,iv.bH)(t.payload);n&&n.id===d&&(l(e=>iE(e,n)),a())},f=e=>{let t=u(e);if(!t)return;let n=(0,n3.u)(t.payload)?t.payload:null;if(!n)return;let r="string"==typeof n.id?n.id:null;if(r&&r!==d)return;if(!r){let e="number"==typeof n.index?n.index:null;if(null===e||e!==(h.current?.index??-1))return}let i=(0,iv.mq)(n);i&&l(e=>{if(!e||e.id!==d)return e;let t={...e,progress:{...e.progress,...i}};return i.status&&!iM(e.status)&&(t.status=iL[i.status]??e.status),t})},v=e=>{let t=u(e);if(!t)return;let n=(0,n3.u)(t.payload)?t.payload:null;n&&n.id===d&&a()};return i||(window.addEventListener("subagent_lifecycle",m),window.addEventListener("subagent_progress",f),window.addEventListener("subagent_event",v)),o(),()=>{p.current+=1,b.current=!1,null!==y.current&&(window.clearTimeout(y.current),y.current=null),i||(window.removeEventListener("subagent_lifecycle",m),window.removeEventListener("subagent_progress",f),window.removeEventListener("subagent_event",v))}},[e,d,N]),{messages:r,isLoading:o,status:a,isActive:u}}(t,n,s),m=iP(iI)??{},h=(0,i.li)(null),f=u?.status??n?.status??"started",x="started"===f;(0,i.vJ)(()=>{let e=h.current;if(!e)return;let t=requestAnimationFrame(()=>{e.scrollTop=e.scrollHeight});return()=>cancelAnimationFrame(t)},[c.length,x]);let{streamingIdx:g,footers:b,prevNonNoticeIdx:v}=(0,i.Kr)(()=>({streamingIdx:is(c),footers:il(c,x),prevNonNoticeIdx:ia(c)}),[c,x]);if(!n||!p)return null;let k=u?.progress??n.progress,y=k?.resolvedModel??n.agent,N=(0,iR.Ti)(u??n),Y=(0,t0.Rk)(k?.tokens),D=Y?`${Y} tok`:"",A=u?.task??u?.assignment??u?.description??n.task??n.assignment??n.description,F=A?A.replace(/\$0(\.00*)?/g,"").trim():void 0;return(0,r.FD)("div",{className:`flex flex-col h-full min-h-0 overflow-hidden bg-canvas ${o}`,children:[(0,r.FD)("div",{className:"flex items-center gap-2.5 border-b border-ink/15 bg-paper px-3 py-2 flex-shrink-0",children:[(0,r.Y)("button",{type:"button",onClick:s,title:"Back to session",className:"flex items-center justify-center w-7 h-7 rounded-md border border-ink/15 text-ink/70 hover:text-ink hover:bg-ink/5 transition-colors shrink-0 cursor-pointer",children:(0,r.Y)(ix.A,{size:14})}),(0,r.Y)(ib.l,{status:f,live:x,size:12}),(0,r.Y)(J.A,{size:13,className:"text-ink/60 shrink-0"}),(0,r.FD)("div",{className:"min-w-0 flex-1",children:[(0,r.FD)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,r.Y)("span",{className:"font-mono text-[12px] font-semibold text-ink truncate",children:N}),(0,r.Y)("span",{className:"shrink-0 rounded bg-ink/5 px-1.5 py-0.5 font-mono text-[9px] uppercase tracking-wider text-ink/50",children:iO[f]})]}),(0,r.Y)("p",{className:"truncate text-[11px] text-ink/55 font-sans",children:F??"Subagent transcript"})]}),D&&(0,r.Y)("span",{className:"hidden sm:inline shrink-0 font-mono text-[10px] text-ink/45",children:D})]}),(0,r.Y)("div",{ref:h,className:"flex-1 min-h-0 overflow-y-auto overscroll-contain scrollbar-overlay-container timeline-scrollbar-visible p-4 pb-10",children:(0,r.Y)("div",{className:"mx-auto w-full max-w-[970px]",children:d&&0===c.length?(0,r.FD)("div",{className:"flex items-center justify-center gap-2 py-12 text-[11px] font-mono text-ink/50",children:[(0,r.Y)(tW.A,{size:14,className:"animate-spin"}),(0,r.Y)("span",{children:"Loading transcript…"})]}):0===c.length?(0,r.Y)("div",{className:"py-12 text-center text-[11.5px] font-mono text-ink/45",children:"No transcript messages yet."}):c.map((e,t)=>{let n=x&&t===g&&"ai"===e.role,i=v[t],s=i>=0?c[i]:null,o=!!("user"!==e.role&&s&&"user"!==s.role),d=b[t];return(0,r.FD)(w.FK,{children:[(0,r.Y)(r2,{msg:e,isStreaming:n,isPrevAssistant:o,className:r1(e)?"mt-3 mb-1":o?"mt-1":"mt-3"}),d&&(0,r.Y)(it,{msg:d.msg,provider:a,providerNames:l,modelName:y,modelNames:m,durationMs:d.durationMs})]},e.id)})})}),(0,r.Y)("div",{className:"flex-shrink-0 p-4 pt-1",children:(0,r.Y)("div",{className:"mx-auto w-full max-w-[970px]",children:(0,r.FD)("div",{className:"flex items-center justify-center gap-2 rounded-lg border border-ink/15 bg-paper px-3 py-2 text-[11px] font-mono text-ink/50 select-none",children:[(0,r.Y)(ig.A,{size:11,className:"text-ink/45"}),(0,r.Y)("span",{children:"Read-only transcript — subagents cannot receive messages"})]})})})]})}var i_=n("zi");let iW=(0,a.ph)(function(e){let{messages:t,isGenerating:n,provider:s,providerNames:a,modelName:l,modelNames:o,thinkingLevel:c,onUndo:d,onRetry:u,onNewChat:p,isMobile:m=!1}=e,{streamingIdx:h,footers:f,prevNonNoticeIdx:x}=(0,i.Kr)(()=>({streamingIdx:is(t),footers:il(t,n),prevNonNoticeIdx:ia(t)}),[t,n]);return(0,r.Y)(r.FK,{children:t.map((e,i)=>{let g=t[i-1],b=n&&i===h&&"ai"===e.role,v="user"!==e.role&&g&&"user"!==g.role&&!r1(g),k=x[i],y=k>=0?t[k]:null,N=!!("user"!==e.role&&y&&"user"!==y.role),Y=f[i];return(0,r.FD)(w.FK,{children:[(0,r.Y)(r2,{msg:e,isStreaming:b,onUndo:d,onNewChat:p,isPrevAssistant:N,className:r1(e)?"mt-3 mb-1":v?"mt-1":"mt-3"}),Y&&(0,r.Y)(it,{msg:Y.msg,provider:s,providerNames:a,modelName:l,modelNames:o,thinkingLevel:c,durationMs:Y.durationMs,onRetry:u,onNewChat:p,isMobile:m})]},e.id)})})});function iU(e){let{turns:t,jumping:n,onJumpTurn:s}=e,[a,l]=(0,i.J0)(null);if(0===t.length)return null;let o=`clamp(2px, calc(60vh / ${t.length}), 7px)`;return(0,r.Y)("div",{className:`absolute right-0.5 top-1/2 -translate-y-1/2 z-20 flex flex-col items-center py-4 w-6 max-h-[min(60vh,100%)] ${n?"animate-pulse":""}`,role:"navigation","aria-label":`Jump to your message (${t.length} turns)`,onMouseLeave:()=>l(null),children:t.map((e,n)=>{let i=a===n;return(0,r.FD)("div",{className:"relative flex min-h-0 items-center justify-center w-full cursor-pointer",style:{height:o},onMouseEnter:()=>l(n),onClick:()=>s(e),children:[(0,r.Y)("button",{type:"button",className:`block h-px rounded-full transition-all duration-200 ease-out ${(e=>{if(null===a)return"w-3";let t=Math.abs(e-a);return 0===t?"w-6":1===t?"w-4":"w-3"})(n)} ${i?"bg-ink h-[2px]":"bg-ink/25"}`,"aria-label":`Jump to your message #${n+1}`}),(0,r.FD)("div",{className:`absolute right-full mr-3 top-1/2 -translate-y-1/2 w-64 p-3 bg-ink text-canvas text-xs rounded-md shadow-lg pointer-events-none transition-opacity duration-200 z-30 ${i?"opacity-100":"opacity-0"}`,children:[(0,r.FD)("div",{className:"flex items-center justify-between gap-2 pb-1.5 mb-1.5 border-b border-canvas/20 font-mono text-[10px] uppercase tracking-wider text-canvas/60",children:[(0,r.FD)("span",{children:["#",n+1," of ",t.length]}),nA(e)&&(0,r.Y)("span",{children:nA(e)})]}),(0,r.Y)("div",{className:"line-clamp-3 whitespace-pre-wrap leading-relaxed",children:e.preview.trim()||"(no text)"}),(0,r.Y)("div",{className:"absolute top-1/2 -right-1 -translate-y-1/2 w-2 h-2 bg-ink rotate-45"})]})]},`minimap-${e.id}`)})})}function iK(e){let{isMobile:t,userTurns:n,jumpingTurn:i,onJumpTurn:s,scrollRef:a,contentRef:l,handleScroll:o,isScrolling:c,loadingOlder:d,hasMore:u,loadOlderError:p,loadOlder:m,messages:h,isGenerating:f,provider:x,providerNames:g,modelName:b,modelNames:v,thinkingLevel:k,onUndo:y,onRetry:w,onNewChat:N,showScrollBottom:Y,jumpToBottom:D}=e;return(0,r.FD)(r.FK,{children:[!t&&(0,r.Y)(iU,{turns:n,jumping:i,onJumpTurn:s}),(0,r.Y)("div",{ref:a,onScroll:o,className:`flex-1 scrollbar-overlay-container overscroll-contain scroll-smooth overflow-x-hidden ${t?"px-3 py-3 pb-8":"p-4 pb-10"} ${c?"timeline-scrollbar-visible":"timeline-scrollbar-hidden"}`,children:(0,r.FD)("div",{ref:l,className:"mx-auto w-full max-w-[970px]",children:[(d||u||p)&&(0,r.Y)("div",{className:"pb-1",children:d?(0,r.Y)(ip,{}):(0,r.Y)("button",{type:"button",onClick:m,className:`block mx-auto px-3 py-1 rounded-full border text-[11px] font-mono transition-colors ${p?"border-error/40 text-error hover:border-error":"border-ink/15 text-ink/50 hover:text-ink hover:border-ink/30"}`,children:p?"Failed to load — retry":"Load earlier messages"})}),(0,r.Y)(iW,{messages:h,isGenerating:f,provider:x,providerNames:g,modelName:b,modelNames:v,thinkingLevel:k,onUndo:y,onRetry:w,onNewChat:N,isMobile:t})]})}),Y&&(0,r.Y)("div",{className:"absolute bottom-4 left-1/2 transform -translate-x-1/2 z-20",children:(0,r.Y)("button",{onClick:()=>D("smooth"),className:"flex items-center justify-center w-8 h-8 rounded-full border border-ink/20 bg-paper text-ink/60 hover:text-ink hover:bg-ink/5 transition-all shadow-sm",title:"Scroll to bottom",children:(0,r.Y)(i_.A,{size:16})})})]})}var iq=n("n"),iB=n("mO");let iH={running:"thinking…",complete:"complete",cancelled:"cancelled",failed:"failed",interrupted:"interrupted"};function iG(e){let{topics:t,activeTopicId:n,onSelectTopic:s,onDeleteTopic:a,onCloseMenu:l}=e,o=(0,i.li)(null);return(0,i.vJ)(()=>{let e=e=>{let t=e.target instanceof Element?e.target:null;o.current?.contains(t)||t?.closest("[data-btw-menu-anchor]")||l()};return document.addEventListener("pointerdown",e),()=>document.removeEventListener("pointerdown",e)},[l]),(0,i.vJ)(()=>{let e=e=>{"Escape"===e.key&&l()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[l]),(0,r.FD)("div",{ref:o,role:"menu","aria-label":"Side question history",className:"absolute left-0 top-full mt-1 z-50 bg-paper border border-ink/15 rounded-lg shadow-xl min-w-[280px] max-h-72 overflow-y-auto scrollbar-overlay-container scrollbar-overlay-static p-1",children:[0===t.length&&(0,r.Y)("div",{className:"px-2.5 py-2 text-[12px] text-ink/50",children:"No side questions yet."}),t.map(e=>{let t=e.turns.length,i=e.turns[t-1];return(0,r.FD)("div",{className:`group flex items-center rounded ${e.id===n?"bg-ink/5":"hover:bg-ink/5"}`,children:[(0,r.FD)("button",{type:"button",role:"menuitem",onClick:()=>{s(e.id),l()},className:"flex-1 min-w-0 text-left px-2.5 py-2 rounded cursor-pointer",children:[(0,r.Y)("div",{className:"truncate text-[12px] text-ink",children:e.title}),(0,r.FD)("div",{className:"text-[11px] text-ink/50",children:[t," turn",1===t?"":"s",i?` \xb7 ${iH[i.status]}`:""]})]}),(0,r.Y)("button",{type:"button",onClick:()=>a(e.id),className:"p-1.5 mr-1 rounded text-ink/40 opacity-0 group-hover:opacity-100 focus-visible:opacity-100 hover:text-error hover:bg-error/10 transition-colors cursor-pointer","aria-label":`Delete side question: ${e.title}`,title:"Delete this side question",children:(0,r.Y)(iB.A,{size:12,strokeWidth:2})})]},e.id)})]})}let iV="p-1.5 rounded text-ink/45 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:bg-transparent disabled:hover:text-ink/45";function iZ(e){let{value:t,onChange:n,onSubmit:s,onNewQuestion:a,onClose:l,running:o,topics:c,activeTopicId:d,onSelectTopic:u,onDeleteTopic:p,canPromote:m,onPromote:h}=e,f=(0,i.li)(null),[x,g]=(0,i.J0)(!1);return(0,i.vJ)(()=>{let e=f.current;e&&(e.style.height="auto",e.style.height=`${e.scrollHeight}px`)},[t]),(0,r.FD)("div",{className:"bg-paper border border-ink/20 rounded-2xl shadow-sm flex items-center gap-1 pl-1.5 pr-2 py-1 focus-within:border-ink transition-colors",children:[(0,r.Y)("button",{type:"button",onClick:()=>{a(),f.current?.focus()},disabled:o,className:iV,"aria-label":"New side question",title:"New side question",children:(0,r.Y)(iq.A,{size:14,strokeWidth:2})}),(0,r.Y)("textarea",{ref:f,rows:1,value:t,onInput:e=>n(e.currentTarget.value),onKeyDown:e=>{if("Escape"===e.key){e.preventDefault(),l();return}"Enter"!==e.key||e.shiftKey||e.isComposing||229===e.keyCode||(e.preventDefault(),s())},placeholder:"Ask your question","aria-label":"Ask your question",className:"flex-1 min-w-0 bg-transparent text-[13px] text-ink placeholder-ink/40 resize-none outline-none py-1.5 max-h-32 leading-6"}),c.length>0&&(0,r.FD)("div",{className:"relative",children:[(0,r.Y)("button",{type:"button",onClick:()=>g(e=>!e),className:iV,"aria-label":"Side question history",title:"Side question history","aria-expanded":x,"data-btw-menu-anchor":"",children:(0,r.Y)(Y.A,{size:14,strokeWidth:2})}),x&&(0,r.Y)(iG,{topics:c,activeTopicId:d,onSelectTopic:u,onDeleteTopic:p,onCloseMenu:()=>g(!1)})]}),m&&(0,r.Y)("button",{type:"button",onClick:h,className:iV,"aria-label":"Promote answer into chat",title:"Promote answer into chat",children:(0,r.Y)(np.A,{size:14,strokeWidth:2})}),(0,r.Y)("button",{type:"button",onClick:l,className:iV,"aria-label":"Close side questions",title:"Close side questions",children:(0,r.Y)(C.A,{size:14,strokeWidth:2})})]})}function iQ(e){let{status:t}=e;return"complete"===t?null:"running"===t?(0,r.FD)("div",{className:"flex items-center gap-1.5 text-[11px] text-ink/50",children:[(0,r.Y)("span",{className:"w-1.5 h-1.5 rounded-full bg-ink/40 animate-pulse"}),(0,r.Y)("span",{children:"Thinking…"})]}):"cancelled"===t?(0,r.Y)("div",{className:"text-[11px] text-ink/50",children:"Cancelled"}):(0,r.Y)("div",{className:"text-[11px] text-error",children:"failed"===t?"Failed":"Interrupted"})}function iX(e){let{topic:t,liveAnswer:n,error:s}=e,a=(0,i.li)(null),l=t?.turns??[],o=(0,i.Kr)(()=>l.reduce((e,t)=>e+t.question.length+t.answer.length,0)+n.length,[l,n]);(0,i.vJ)(()=>{let e=a.current;e&&(e.scrollTop=e.scrollHeight)},[o]);let c=l.length-1;return(0,r.FD)("div",{ref:a,className:"flex-1 min-h-0 overflow-y-auto scrollbar-overlay-container scrollbar-overlay-static px-4 py-3 space-y-4",children:[s&&(0,r.Y)("div",{className:"bg-error/10 border border-error/30 text-error rounded-lg px-3 py-2 text-[12px]",children:s}),null===t?(0,r.Y)("div",{className:"flex h-full items-center justify-center px-4 text-center text-[12px] text-ink/50",children:"Start a side question — the answer stays out of this chat's transcript."}):l.map((e,t)=>{let i=t===c&&""!==n&&("running"===e.status||n.length>e.answer.length)?n:e.answer;return(0,r.FD)("div",{className:"space-y-2",children:[(0,r.Y)("div",{className:"ml-auto max-w-[85%] w-fit bg-ink/[0.06] border border-ink/10 rounded-xl px-3.5 py-2.5 text-[13px] text-ink break-words",children:(0,r.Y)(tf.T,{content:e.question})}),""!==i&&(0,r.Y)("div",{className:"px-1 text-[13px] text-ink leading-relaxed",children:(0,r.Y)(tf.T,{content:i})}),(0,r.Y)(iQ,{status:e.status})]},e.index)})]})}function i0(e){let{value:t,onChange:n,onSubmit:s,onStop:a,running:l,modelLabel:o,provider:c,attachments:d,onFilesSelected:u,onRemoveAttachment:p}=e,m=(0,i.li)(null),h=(0,i.li)(null),f=t.trim().length>0||d.length>0,x=c?r7(c):"";return(0,i.vJ)(()=>{let e=h.current;e&&(e.focus(),e.setSelectionRange(e.value.length,e.value.length))},[]),(0,i.vJ)(()=>{let e=h.current;e&&(e.style.height="auto",e.style.height=`${e.scrollHeight}px`)},[t]),(0,r.FD)("div",{className:"bg-paper border border-ink/20 rounded-2xl shadow-lg flex flex-col overflow-hidden",children:[(0,r.Y)("textarea",{ref:h,rows:1,value:t,onInput:e=>n(e.currentTarget.value),onKeyDown:e=>{"Escape"===e.key?e.currentTarget.blur():"Enter"!==e.key||e.shiftKey||!e.isComposing&&229!==e.keyCode&&(e.preventDefault(),f&&s())},placeholder:"Ask in this btw session...",className:"w-full bg-transparent text-[13px] text-ink placeholder-ink/40 resize-none outline-none px-3.5 pt-3 pb-1 max-h-32"}),d.length>0&&(0,r.Y)("div",{className:"flex items-center flex-wrap gap-1.5 px-3 pt-2",children:d.map(e=>(0,r.FD)("div",{className:"relative flex items-center bg-canvas border border-ink/10 rounded-md p-0.5 pr-6 text-xs",children:[(0,r.Y)("div",{className:"w-6 h-6 flex items-center justify-center bg-ink/5 rounded-sm mr-1.5 text-ink/60",children:(0,r.Y)(eS.A,{size:12,strokeWidth:2})}),(0,r.Y)("span",{className:"truncate max-w-[120px] font-mono text-[10px] text-ink/80",children:e.name}),(0,t0.z3)(e.size)&&(0,r.Y)("span",{className:"ml-1.5 font-mono text-[10px] text-ink/40",children:(0,t0.z3)(e.size)}),(0,r.Y)("button",{type:"button",onClick:()=>p(e.id),className:"absolute right-0.5 top-1/2 -translate-y-1/2 p-0.5 text-ink/40 hover:text-error hover:bg-error/10 rounded transition-colors cursor-pointer","aria-label":`Remove ${e.name}`,title:"Remove attachment",children:(0,r.Y)(C.A,{size:10,strokeWidth:2})})]},e.id))}),(0,r.FD)("div",{className:"flex items-center justify-between px-2 pb-2",children:[(0,r.FD)("div",{className:"flex items-center gap-0.5",children:[(0,r.Y)("button",{type:"button",onClick:()=>m.current?.click(),className:"p-1.5 rounded text-ink/60 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer","aria-label":"Attach files",title:"Attach files",children:(0,r.Y)(eC.A,{size:14,strokeWidth:2})}),(0,r.Y)("span",{className:"p-1.5 text-ink/40","aria-label":"Side answers never use tools",title:"Side answers never use tools",children:(0,r.Y)(tS.A,{size:14,strokeWidth:2})})]}),(0,r.FD)("div",{className:"flex items-center gap-2 min-w-0",children:[(x||o)&&(0,r.FD)("div",{className:"flex items-baseline gap-1.5 min-w-0",children:[x&&(0,r.Y)("span",{className:"text-[10px] text-ink/40 shrink-0",children:x}),o&&(0,r.Y)("span",{className:"text-[11px] text-ink/70 truncate",children:o})]}),l?(0,r.Y)("button",{type:"button",onClick:a,className:"bg-ink text-canvas rounded p-1.5 cursor-pointer","aria-label":"Stop side answer",title:"Stop side answer",children:(0,r.Y)(S.A,{size:14,strokeWidth:2})}):(0,r.Y)("button",{type:"button",onClick:s,disabled:!f,className:"bg-ink text-canvas hover:bg-ink/80 rounded p-1.5 cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed","aria-label":"Send side question",title:"Send side question",children:(0,r.Y)(T.A,{size:14,strokeWidth:2})})]})]}),(0,r.Y)("input",{type:"file",accept:"image/*",multiple:!0,className:"hidden",ref:m,onChange:e=>{let t=e.currentTarget.files;t&&t.length>0&&u(Array.from(t)),m.current&&(m.current.value="")}})]})}async function i1(e){return Promise.all(e.filter(e=>e.type.startsWith("image/")).map(async e=>{let t=await function(e){let{promise:t,resolve:n}=Promise.withResolvers(),r=new FileReader;return r.onload=()=>{let e="string"==typeof r.result?r.result:"",t=e.indexOf(",");n(t>=0?e.slice(t+1):void 0)},r.onerror=()=>n(void 0),r.readAsDataURL(e),t}(e);return{id:`btw-${e.name}-${e.size}-${e.lastModified}`,name:e.name,size:e.size,...t?{dataBase64:t}:{}}}))}let i5={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",bmp:"image/bmp",svg:"image/svg+xml",avif:"image/avif"};function i2(e){let{mode:t,modelName:n,provider:s}=e,[a,l]=(0,i.J0)([]),o=t.activeTopic?.turns[t.activeTopic.turns.length-1],c=!!t.activeTopic&&!t.runningTopicId&&!t.busy&&o?.status==="complete",d=(t.activeTopic?.turns.length??0)>0||!!t.error;return(0,r.FD)("div",{className:"flex flex-col gap-2",children:[d&&(0,r.Y)("div",{className:"bg-paper border border-ink/15 rounded-2xl shadow-xl flex flex-col max-h-[45vh] overflow-hidden",children:(0,r.Y)(iX,{topic:t.activeTopic,liveAnswer:t.liveAnswer,error:t.error})}),(0,r.Y)(iZ,{value:t.askDraft,onChange:t.setAskDraft,onSubmit:t.submitAsk,onNewQuestion:t.resetQuestion,onClose:t.exit,running:!!t.runningTopicId,topics:t.topics,activeTopicId:t.activeTopic?.id??null,onSelectTopic:t.selectTopic,onDeleteTopic:t.removeTopic,canPromote:c,onPromote:()=>void t.promote()}),(0,r.Y)(i0,{value:t.followUpDraft,onChange:t.setFollowUpDraft,onSubmit:()=>{t.submitFollowUp(t.followUpDraft,a.filter(e=>"string"==typeof e.dataBase64).map(e=>{var t;let n;return{type:"image",data:e.dataBase64,mimeType:i5[(n=(t=e.name).lastIndexOf("."))>=0?t.slice(n+1).toLowerCase():""]??"image/png"}})),l([])},onStop:t.abort,running:!!t.runningTopicId,modelLabel:t.activeTopic?.model?.name??n,provider:t.activeTopic?.model?.provider??s,attachments:a,onFilesSelected:e=>{i1(e).then(e=>l(t=>[...t,...e]))},onRemoveAttachment:e=>l(t=>t.filter(t=>t.id!==e))})]})}var i4=n("Kn");function i3(e,t){let n=new EventSource(e),r=!1;return n.onopen=()=>{r||t.onOpen()},n.onmessage=e=>{let n;if(!r){try{n=JSON.parse(e.data)}catch{return}t.onFrame(n)}},n.onerror=()=>{r||n.readyState===EventSource.CLOSED&&t.onClose()},{close:()=>{r=!0,n.onopen=null,n.onmessage=null,n.onerror=null,n.close()}}}function i8(e,t){let n=null,r=null,i=0,s=!1,a=!1,l=()=>{let o=new WebSocket(e);n=o,o.onopen=()=>{a||(i=0,s=!0,t.onOpen())},o.onmessage=e=>{let n;if(!a){try{n=JSON.parse(String(e.data))}catch{return}t.onFrame(n)}},o.onclose=()=>{n=null,a||(t.onClose(),!s||(i+=1)>4||(r=setTimeout(()=>{r=null,a||l()},Math.min(500*2**(i-1),8e3))))}};return l(),{close:()=>{a=!0,null!==r&&(clearTimeout(r),r=null);let e=n;n=null,e&&(e.onopen=null,e.onmessage=null,e.onclose=null,e.onerror=null,e.close())}}}class i6 extends Error{code;constructor(e,t){super(e),this.name="BtwRequestError",this.code=t}}async function i9(e,t,n){let r=await fetch(`/api/btw/${encodeURIComponent(e)}`,{method:t,...n?{headers:{"Content-Type":"application/json"},body:JSON.stringify(n)}:{}}),i=await r.json().catch(()=>null);if(!r.ok||!i?.success)throw new i6(i?.error??`Side question request failed (${r.status})`,i?.code);return i.data}var i7=n("NO"),se=n("FL");let st="Describe the attached image.";var sn=n("b");let sr={steer:"steer",followup:"follow-up"};function si(e){let{queue:t,onReorder:n,onRemove:s,isSteering:a=!1,onEdit:l,onSendNow:o}=e,c=(0,i.li)(null),d=(0,i.li)(null),u=()=>{if(null===c.current||null===d.current)return;let e=t.map(e=>e.id),r=e.splice(c.current,1)[0];e.splice(d.current,0,r),c.current=null,d.current=null,n?.(e)};if(0===t.length)return null;let p=a?"steer":"followup";return(0,r.Y)("div",{className:"max-h-[150px] scrollbar-overlay-container scrollbar-overlay-static mb-2 space-y-1",children:t.map((e,t)=>(0,r.FD)("div",{draggable:!0,onDragStart:()=>{c.current=t},onDragEnter:()=>{d.current=t},onDragEnd:u,onDragOver:e=>e.preventDefault(),className:"flex items-center gap-2 px-2 py-1.5 bg-paper border border-ink/10 rounded shadow-sm text-xs group hover:border-ink/30 transition-colors",children:[(0,r.Y)("div",{className:"cursor-grab text-ink/40 group-hover:text-ink/80",children:(0,r.Y)(I.A,{size:14})}),(0,r.Y)("span",{className:`shrink-0 text-[9px] font-mono uppercase tracking-wider px-1 py-px rounded ${"steer"===p?"bg-error/10 text-error":"bg-ink/10 text-ink/70"}`,children:sr[p]}),(0,r.Y)("div",{className:"flex-1 truncate text-ink/80 pr-2",children:e.text||(e.attachments.length>0?`[${e.attachments.length} attachment${e.attachments.length>1?"s":""}]`:"Empty message")}),o&&"followup"===p&&(0,r.Y)("button",{onClick:()=>o(e),className:"text-ink/40 hover:text-ink/80 opacity-0 group-hover:opacity-100 transition-opacity",title:"Send Now (Steering)",children:(0,r.Y)(T.A,{size:12})}),l&&(0,r.Y)("button",{onClick:()=>l(e),className:"text-ink/40 hover:text-ink/80 opacity-0 group-hover:opacity-100 transition-opacity",title:"Edit",children:(0,r.Y)(sn.A,{size:12})}),s&&(0,r.Y)("button",{onClick:()=>s(e.id),className:"text-ink/40 hover:text-error opacity-0 group-hover:opacity-100 transition-opacity",title:"Remove",children:(0,r.Y)(C.A,{size:14})})]},e.id))})}function ss(e){let{isMobile:t,sessionId:n,isGenerating:a,modelName:l,generatingVerb:o,provider:c,providerNames:d,messageQueue:u,onRemoveQueueItem:p,onReorderQueue:m,onEditQueueItem:h,onSendNowQueueItem:f,steeringQueue:x,setSteeringQueue:g,inputValue:b,setInputValue:v,rootPath:k,attachments:y,setAttachments:w,onSend:N,onStop:Y,appSettings:D,onThinkingLevelChange:A,onModelChange:F,accessMode:C,onAccessModeChange:S,composerModelRef:T,deferredComposerPickRef:$,sessionModel:z,sessionThinkingLevel:j,variant:L}=e,M=function(e,t){let[n,r]=(0,se.bL)("chat.btwOpen",!1),[a,l]=(0,se.bL)("chat.btwAsk",""),[o,c]=(0,se.bL)("chat.btwFollowUp",""),[d,u]=(0,se.bL)("chat.btwTopicId",null),[,p]=(0,s.o)(),m=function(e,t){let[n,r]=(0,i.J0)(null),[s,a]=(0,i.J0)(null),[l,o]=(0,i.J0)(null),[c,d]=(0,i.J0)(!1),{enabled:u,transport:p}=t,m=(0,i.li)(e);m.current=e,(0,i.vJ)(()=>{var t;if(!u||!e)return;let n=(t={onOpen:()=>{},onFrame:e=>{switch(e.type){case"btw_state":r(e.state),a(t=>{if(!t)return null;let n=e.state.topics.find(e=>e.id===t.topicId),r=n?.turns.find(e=>e.index===t.turnIndex);return r&&"running"===r.status?t:null});break;case"btw_delta":a(t=>t&&t.topicId===e.topicId&&t.turnIndex===e.turnIndex?{...t,text:t.text+e.text}:{topicId:e.topicId,turnIndex:e.turnIndex,text:e.text});break;case"btw_error":o(e.message)}},onClose:()=>{}},"sse"===p?i3((0,i4.Ec)(e),t):i8((0,i4.oU)(e),t));return i9(e,"GET").then(r).catch(e=>o(e instanceof Error?e.message:String(e))),()=>n.close()},[u,e,p]);let h=(0,i.hb)(async e=>{let t=m.current;if(!t)return null;d(!0);try{let n=await e(t);return r(n),n}catch(e){return o(e instanceof i6||e instanceof Error?e.message:String(e)),null}finally{d(!1)}},[]),f=(0,i.hb)(async(e,t,n)=>{o(null);let r=await h(r=>{var i;return i9(r,"POST",{action:"ask",question:(i={question:e,images:t,topicId:n}).question,...i.topicId?{topicId:i.topicId}:{},...i.images?.length?{images:i.images}:{}})});return a(null),r&&!r.runningTopicId&&o("The side question was accepted but did not start running."),r},[h]),x=(0,i.hb)(async e=>{o(null),await h(t=>i9(t,"POST",{action:"abort",topicId:e}))},[h]),g=(0,i.hb)(async e=>{o(null),await h(t=>i9(t,"POST",{action:"delete",topicId:e}))},[h]);return{state:n,live:s,error:l,busy:c,ask:f,abort:x,promote:(0,i.hb)(async e=>{let t=m.current;if(!t)return null;o(null),d(!0);try{return(await i9(t,"POST",{action:"promote",topicId:e})).sessionId}catch(e){return o(e instanceof i6||e instanceof Error?e.message:String(e)),null}finally{d(!1)}},[]),remove:g,clearError:(0,i.hb)(()=>o(null),[])}}(e,{enabled:n&&!!e,transport:(0,i4.ul)(t)}),h=m.state?.topics??[],f=h.find(e=>e.id===d)??h[h.length-1]??null,x=m.state?.runningTopicId??null,g=m.live&&m.live.topicId===f?.id?m.live:null,b=(0,i.hb)(e=>{e&&u(e.topics[e.topics.length-1]?.id??null)},[u]);(0,i7.sY)("omp:btw",e=>{let t=e.detail,n=t?.question?.trim();r(!0),(n||t?.images?.length)&&(l(""),m.ask(n||st,t?.images).then(b))});let v=(0,i.hb)(()=>{let e=a.trim();e&&(l(""),m.ask(e).then(b))},[a,m,l,b]),k=(0,i.hb)((e,t)=>{let n=e.trim();(n||t?.length)&&(c(""),m.ask(n||st,t,f?.id).then(e=>{f||b(e)}))},[f,m,c,b]),y=(0,i.hb)(async()=>{if(!f)return null;let e=await m.promote(f.id);return e?(r(!1),u(null),p(t=>{let n=new URLSearchParams(t);return n.set("sessionId",e),n.has("subagent")&&n.delete("subagent"),n}),window.dispatchEvent(new CustomEvent("omp:session-updated",{detail:{sessionId:e}})),e):null},[f,m,r,u,p]),w=(0,i.hb)(e=>{e===d&&u(null),m.remove(e)},[d,m,u]);return{open:n,topics:h,activeTopic:f,runningTopicId:x,busy:m.busy,liveAnswer:g?g.text:"",error:m.error,askDraft:a,followUpDraft:o,setAskDraft:l,setFollowUpDraft:c,enter:()=>r(!0),exit:()=>r(!1),resetQuestion:()=>{l(""),u(null),m.clearError()},submitAsk:v,submitFollowUp:k,abort:()=>{x&&m.abort(x)},promote:y,removeTopic:w,selectTopic:e=>{u(e),m.clearError()},clearError:m.clearError}}(n,D);return(0,r.Y)("div",{className:`bg-transparent border-t-0 flex-shrink-0 space-y-2 ${t?"px-3 pt-1":"p-4 pt-1"}`,style:t?{paddingBottom:"max(0.75rem, env(safe-area-inset-bottom, 0px))"}:void 0,children:(0,r.FD)("div",{className:"relative mx-auto w-full max-w-[970px]",children:[a&&(0,r.Y)(ii,{modelName:l,generatingVerb:o,provider:c,providerNames:d}),(0,r.Y)(si,{queue:u,onRemove:p,onReorder:m,onEdit:h,onSendNow:f}),(0,r.Y)(si,{queue:x,onRemove:e=>g(t=>t.filter(t=>t.id!==e)),onReorder:e=>g(t=>{let n=new Map(t.map(e=>[e.id,e]));return e.map(e=>n.get(e)).filter(e=>!!e)}),isSteering:!0}),M.open?(0,r.Y)(i2,{mode:M,modelName:l,provider:c}):(0,r.Y)(to,{value:b,onChange:v,rootPath:k,attachments:y,onAttachmentsChange:w,onSend:N,isGenerating:a,onStop:Y,appSettings:D,onThinkingLevelChange:A,onModelChange:F,accessMode:C,onAccessModeChange:S,composerModelRef:T,deferredComposerPickRef:$,sessionModel:z,sessionThinkingLevel:j,variant:L})]})})}var sa=n("zG");function sl(e){let t,n=(0,sa.oJ)(e.name)??"",r=sa.YT[n.toLowerCase()]??n.toLowerCase(),i=(t={...(0,n3.u)(e.args)?e.args:(0,n3.u)(e.input)?e.input:{}},e.command&&void 0===(0,sa.oJ)(t.command)&&void 0===(0,sa.oJ)(t.cmd)&&(t.command=e.command),e.target&&void 0===(0,sa.oJ)(t.path)&&(t.path=e.target),t),s=(0,sa.oJ)(e.intent)??(0,sa.Up)(i,["i"]),a=function(e,t){let n=(0,sa.Up)(e,["path","target"])??(0,sa.oJ)(t.target)??(0,sa.oJ)(t.command);if(n&&n.startsWith("xd://"))return n.slice(5).split(/[/?#\s]/)[0]||void 0}(i,e);if(a){let e=a.startsWith("mcp__")?a.slice(5):void 0,t=e?`Running ${e}`:sa.Qq[a]??`Running ${a}`,n=(0,sa.qL)(e??a,function(e){let{path:t,target:n,command:r,i:i,...s}=e,a=e.content;if("string"!=typeof a)return s;try{let e=JSON.parse(a);if((0,n3.u)(e))return{...s,...e}}catch{}let l=a.trim().split("\n",1)[0]?.trim();return l?{...s,prose:l}:s}(i));return n?(0,sa.xv)(`${t} ${n}`):s?(0,sa.xv)(s):(0,sa.xv)(t)}let l=sa.K$[r]??(r?`Running ${r}`:"Working"),o=(0,sa.qL)(r,i);return o?(0,sa.xv)(`${l} ${o}`):s?(0,sa.xv)(s):(0,sa.xv)(l)}var so=n("K");function sc(e,t,n){let r=e.toolResultsRef.current;r&&function(e,t,n){var r;for(e.set(t,{...n,output:(r=n.output).length<=2e5?r:`…[truncated]
19
+ ${s}`,o=a,c=-1;for(;o<=e.length;){let t=e.indexOf(l,o);if(-1===t)break;let n=e.slice(t+l.length);if(""===n||n.startsWith("\n")||/^\n{2}Attached file: /.test(n)){c=t;break}o=t+l.length}-1!==c&&(n.push({name:i,content:e.slice(a,c)}),r.lastIndex=c+l.length)}return n})(t).map((e,t)=>({id:`text-${t+1}`,name:e.name,type:"text/plain",preview:"",content:e.content}))].map(e=>({id:e.id,name:e.name,preview:e.preview,type:e.type,..."content"in e?{content:e.content}:{}}))}}let m=r.toolCalls.map(e=>{var t,r;let i,s,a,l;return t=e,r={streaming:n},s=t.input,a=(0,n3.u)(s)?Object.fromEntries(Object.entries(s).filter(e=>{let[t]=e;return"i"!==t})):s,l=r.isError?"error":void 0!==r.output?"success":r.streaming?"running":"success",{id:t.id,type:(i=(t.name||"").toLowerCase()).includes("bash")||i.includes("terminal")||i.includes("shell")||i.includes("run")?"bash":i.includes("write")||i.includes("edit")||i.includes("patch")||i.includes("apply")?"edit_file":i.includes("create")?"create_file":i.includes("read")||i.includes("view")||i.includes("list")?"read_file":i.includes("grep")||i.includes("glob")?"grep":i.includes("search")||i.includes("find")?"search_fs":i.includes("web")||i.includes("fetch")||i.includes("http")?"web_search":i.includes("todo")?"todo":i.includes("task")?"task":i.includes("lsp")?"lsp":i.includes("eval")?"eval":i.includes("github")?"github":i.includes("security")?"security_scan":"custom",name:t.name,title:t.title,intent:t.intent,target:t.target,command:t.command,input:a&&Object.keys(a).length>0?a:void 0,output:r.output,status:l}}),h={id:i,role:s,date:a?`Today, ${a}`:void 0,timestamp:a,attribution:l,model:"string"==typeof e.model?e.model:void 0,provider:u,startedAt:o,completedAt:d,durationMs:c,usage:e.usage&&"object"==typeof e.usage?e.usage:void 0,content:r.textParts.join("\n"),intent:r.intent,thinking:r.thinking?{thought:r.thinking,isGenerating:n}:e.thinking,toolCalls:m.length>0?m:e.toolCalls,summary:"string"==typeof e.summary?e.summary:void 0,error:e.error??function(e){let t;if("string"==typeof(t=e.stopReason)&&iY.has(t)||"number"==typeof e.errorStatus||"string"==typeof e.errorMessage)return{status:"number"==typeof e.errorStatus?e.errorStatus:void 0,id:"number"==typeof e.errorId?e.errorId:void 0,message:"string"==typeof e.errorMessage?e.errorMessage:void 0,stopReason:"string"==typeof e.stopReason?e.stopReason:void 0}}(e)};return h.content||h.thinking||h.toolCalls&&0!==h.toolCalls.length||h.intent||h.error||h.summary||h.notice?h:null}function iC(e,t){let n=[];for(let r of e){if((0,n3.u)(r)){let e="string"==typeof r.type?r.type:"";if("custom"===e||"custom_message"===e){let e="string"==typeof r.customType?r.customType:"";if("session_exit"===e)continue;if("launch-completion"===e||"string"==typeof r.content){let e=("string"==typeof r.content?r.content:"").replace(/<\/?system-notice[^>]*>/g,"").trim();e&&n.push({id:"string"==typeof r.id?r.id:`notice-${Date.now()}`,role:"ai",content:"",notice:e,date:"string"==typeof r.timestamp?new Date(r.timestamp).toISOString():void 0});continue}}if(e&&"message"!==e)continue}let e=function(e){if(!(0,n3.u)(e))return null;let t=(0,n3.u)(e.message)?e.message:null;if(!t)return e;let n={...t};return void 0===n.id&&"string"==typeof e.id&&(n.id=e.id),void 0===n.timestamp&&"number"==typeof e.timestamp&&(n.timestamp=e.timestamp),n}(r);if(!e)continue;if("toolResult"===e.role){let t="string"==typeof e.toolCallId?e.toolCallId:void 0,r=ik(e.content),i=(0,n3.u)(e.details)?e.details:void 0,s=!0===e.isError;for(let a=n.length-1;a>=0;a--){let l=n[a].toolCalls?.find(n=>t?n.id===t:n.name===e.toolName);if(l){r&&(l.output=r),i&&(l.details=i),l.status=s?"error":"success";break}}continue}let i=iF(e,t);i&&n.push(i)}return n}function iS(e,t){if(0===t.length)return e;let n=new Map(e.map((e,t)=>[e.id,t])),r=[...e];for(let e of t){let t=n.get(e.id);void 0===t?(n.set(e.id,r.length),r.push(e)):r[t]=e}return r}function iT(e,t,n){if(!(0,n3.u)(e)||!Array.isArray(e.messages))return null;let r="number"==typeof e.fromByte?e.fromByte:t;return{sessionFile:"string"==typeof e.sessionFile&&e.sessionFile?e.sessionFile:n??"",fromByte:r,nextByte:"number"==typeof e.nextByte?e.nextByte:r,reset:!0===e.reset,messages:e.messages,totalBytes:"number"==typeof e.totalBytes?e.totalBytes:void 0}}async function i$(e,t,n,r){try{let i=await fetch(`/api/agent/${encodeURIComponent(e)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"get_subagent_messages",subagentId:t,...n?{sessionFile:n}:{},fromByte:r})});if(!i.ok)return null;let s=await i.json().catch(()=>null),a=(0,n3.u)(s)&&"data"in s?s.data:s;return iT(a,r,n)}catch{return null}}let iz=new Map;async function ij(e,t,n){let r=`/api/sessions/${encodeURIComponent(e)}/subagents/${encodeURIComponent(t)}?fromByte=${n}`,i=iz.get(r);if(i)return i;let s=()=>{},a=new Promise(e=>{s=()=>{iz.get(r)===a&&iz.delete(r)},(async()=>{try{let t=await fetch(r);if(!t.ok)return e(null);let i=await t.json().catch(()=>null),s=(0,n3.u)(i)&&"page"in i?i.page:i;if(null==s)return e(null);e(iT(s,n,void 0))}catch{e(null)}})()});return a.then(s,s),iz.set(r,a),a}let iL={pending:"started",running:"started",completed:"completed",failed:"failed",aborted:"aborted"};function iM(e){return"completed"===e||"failed"===e||"aborted"===e}function iE(e,t){if(!e||e.id!==t.id)return t;let n={...e,...t,agent:"subagent"!==t.agent?t.agent:e.agent,index:e.index>=0?e.index:t.index,status:iM(e.status)&&!iM(t.status)?e.status:t.status},r={...e.progress,...t.progress};return Object.keys(r).length>0?n.progress=r:delete n.progress,n}function iP(e){let[t,n]=(0,i.J0)(void 0),r=(0,i.li)(e);return r.current=e,(0,i.vJ)(()=>{let e=!0,t=async()=>{try{let t=await (0,z.xo)();if(!e)return;let i=r.current(t);void 0!==i&&n(i)}catch{}};t();let i=(0,z.Sy)(t);return()=>{e=!1,i()}},[]),t}function iI(e){if(e.modelList?.length)return Object.fromEntries(e.modelList.map(e=>[e.id,e.name||e.id]))}var iR=n("V7");let iO={started:"running",completed:"done",failed:"failed",aborted:"aborted"};function iJ(e){let{sessionId:t,subagent:n,onBack:s,provider:a,providerNames:l,className:o=""}=e,{messages:c,isLoading:d,status:u,isActive:p}=function(e,t,n){let[r,s]=(0,i.J0)([]),[a,l]=(0,i.J0)(t),[o,c]=(0,i.J0)(!1),d=t?.id??null,u=!!(e&&d),p=(0,i.li)(0),m=(0,i.li)(e);m.current=e;let h=(0,i.li)(t);h.current=t;let f=(0,i.li)(n);f.current=n;let x=(0,i.li)(0),g=(0,i.li)(void 0),b=(0,i.li)(!1),v=(0,i.li)(!1),k=(0,i.li)(!1),y=(0,i.li)(null),w=(0,i.li)(()=>{}),N=(0,i.hb)(async()=>{let e=m.current,t=h.current;if(!e||!t||!b.current)return;if(v.current){k.current=!0;return}v.current=!0;let n=p.current;try{let r=await i$(e,t.id,g.current,x.current);if(n!==p.current||!r)return;g.current=r.sessionFile||g.current;let i=iC(r.messages,!0);r.reset?(s(i),x.current=r.nextByte):(s(e=>iS(e,i)),x.current=Math.max(x.current,r.nextByte))}finally{v.current=!1,k.current&&(k.current=!1,w.current())}},[]);return(0,i.vJ)(()=>{t&&l(e=>iE(e,t))},[t]),(0,i.vJ)(()=>{if(!u)return;let e=e=>{if("Escape"!==e.key||e.defaultPrevented)return;let t=e.target instanceof HTMLElement?e.target:null,n=t?.tagName;"INPUT"===n||"TEXTAREA"===n||t?.isContentEditable||f.current()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[u]),(0,i.vJ)(()=>{if(!e||!d){s([]),l(null),c(!1);return}let t=++p.current,n=h.current,r=()=>t===p.current,i=n?.source==="history";s([]),l(n),c(!0),x.current=0,g.current=n?.sessionFile,b.current=!1;let a=()=>{null===y.current&&(y.current=window.setTimeout(()=>{y.current=null,N()},150))};w.current=a;let o=async()=>{let t=0,a=g.current,o=i||!n?.sessionFile,u=[];for(let n=0;n<20;n++){let n=o?await ij(e,d,t):await i$(e,d,a,t);if(!r()||!n&&!o&&0===t&&(o=!0,n=await ij(e,d,0),!r()))return;if(!n)break;a=n.sessionFile||a;let i=iC(n.messages,!1);if(u=n.reset?i:iS(u,i),n.nextByte<=t||(t=n.nextByte,void 0!==n.totalBytes&&t>=n.totalBytes))break}r()&&(g.current=a,x.current=t,b.current=!o,s(e=>iS(e,u)),c(!1),o&&l(e=>e&&!iM(e.status)?{...e,status:"completed"}:e))},u=t=>{let n=t.detail;return n&&n.sessionId===e?n:null},m=e=>{let t=u(e);if(!t)return;let n=(0,iv.bH)(t.payload);n&&n.id===d&&(l(e=>iE(e,n)),a())},f=e=>{let t=u(e);if(!t)return;let n=(0,n3.u)(t.payload)?t.payload:null;if(!n)return;let r="string"==typeof n.id?n.id:null;if(r&&r!==d)return;if(!r){let e="number"==typeof n.index?n.index:null;if(null===e||e!==(h.current?.index??-1))return}let i=(0,iv.mq)(n);i&&l(e=>{if(!e||e.id!==d)return e;let t={...e,progress:{...e.progress,...i}};return i.status&&!iM(e.status)&&(t.status=iL[i.status]??e.status),t})},v=e=>{let t=u(e);if(!t)return;let n=(0,n3.u)(t.payload)?t.payload:null;n&&n.id===d&&a()};return i||(window.addEventListener("subagent_lifecycle",m),window.addEventListener("subagent_progress",f),window.addEventListener("subagent_event",v)),o(),()=>{p.current+=1,b.current=!1,null!==y.current&&(window.clearTimeout(y.current),y.current=null),i||(window.removeEventListener("subagent_lifecycle",m),window.removeEventListener("subagent_progress",f),window.removeEventListener("subagent_event",v))}},[e,d,N]),{messages:r,isLoading:o,status:a,isActive:u}}(t,n,s),m=iP(iI)??{},h=(0,i.li)(null),f=u?.status??n?.status??"started",x="started"===f;(0,i.vJ)(()=>{let e=h.current;if(!e)return;let t=requestAnimationFrame(()=>{e.scrollTop=e.scrollHeight});return()=>cancelAnimationFrame(t)},[c.length,x]);let{streamingIdx:g,footers:b,prevNonNoticeIdx:v}=(0,i.Kr)(()=>({streamingIdx:is(c),footers:il(c,x),prevNonNoticeIdx:ia(c)}),[c,x]);if(!n||!p)return null;let k=u?.progress??n.progress,y=k?.resolvedModel??n.agent,N=(0,iR.Ti)(u??n),Y=(0,t0.Rk)(k?.tokens),D=Y?`${Y} tok`:"",A=u?.task??u?.assignment??u?.description??n.task??n.assignment??n.description,F=A?A.replace(/\$0(\.00*)?/g,"").trim():void 0;return(0,r.FD)("div",{className:`flex flex-col h-full min-h-0 overflow-hidden bg-canvas ${o}`,children:[(0,r.FD)("div",{className:"flex items-center gap-2.5 border-b border-ink/15 bg-paper px-3 py-2 flex-shrink-0",children:[(0,r.Y)("button",{type:"button",onClick:s,title:"Back to session",className:"flex items-center justify-center w-7 h-7 rounded-md border border-ink/15 text-ink/70 hover:text-ink hover:bg-ink/5 transition-colors shrink-0 cursor-pointer",children:(0,r.Y)(ix.A,{size:14})}),(0,r.Y)(ib.l,{status:f,live:x,size:12}),(0,r.Y)(J.A,{size:13,className:"text-ink/60 shrink-0"}),(0,r.FD)("div",{className:"min-w-0 flex-1",children:[(0,r.FD)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,r.Y)("span",{className:"font-mono text-[12px] font-semibold text-ink truncate",children:N}),(0,r.Y)("span",{className:"shrink-0 rounded bg-ink/5 px-1.5 py-0.5 font-mono text-[9px] uppercase tracking-wider text-ink/50",children:iO[f]})]}),(0,r.Y)("p",{className:"truncate text-[11px] text-ink/55 font-sans",children:F??"Subagent transcript"})]}),D&&(0,r.Y)("span",{className:"hidden sm:inline shrink-0 font-mono text-[10px] text-ink/45",children:D})]}),(0,r.Y)("div",{ref:h,className:"flex-1 min-h-0 overflow-y-auto overscroll-contain scrollbar-overlay-container timeline-scrollbar-visible p-4 pb-10",children:(0,r.Y)("div",{className:"mx-auto w-full max-w-[970px]",children:d&&0===c.length?(0,r.FD)("div",{className:"flex items-center justify-center gap-2 py-12 text-[11px] font-mono text-ink/50",children:[(0,r.Y)(tW.A,{size:14,className:"animate-spin"}),(0,r.Y)("span",{children:"Loading transcript…"})]}):0===c.length?(0,r.Y)("div",{className:"py-12 text-center text-[11.5px] font-mono text-ink/45",children:"No transcript messages yet."}):c.map((e,t)=>{let n=x&&t===g&&"ai"===e.role,i=v[t],s=i>=0?c[i]:null,o=!!("user"!==e.role&&s&&"user"!==s.role),d=b[t];return(0,r.FD)(w.FK,{children:[(0,r.Y)(r2,{msg:e,isStreaming:n,isPrevAssistant:o,className:r1(e)?"mt-3 mb-1":o?"mt-1":"mt-3"}),d&&(0,r.Y)(it,{msg:d.msg,provider:a,providerNames:l,modelName:y,modelNames:m,durationMs:d.durationMs})]},e.id)})})}),(0,r.Y)("div",{className:"flex-shrink-0 p-4 pt-1",children:(0,r.Y)("div",{className:"mx-auto w-full max-w-[970px]",children:(0,r.FD)("div",{className:"flex items-center justify-center gap-2 rounded-lg border border-ink/15 bg-paper px-3 py-2 text-[11px] font-mono text-ink/50 select-none",children:[(0,r.Y)(ig.A,{size:11,className:"text-ink/45"}),(0,r.Y)("span",{children:"Read-only transcript — subagents cannot receive messages"})]})})})]})}var i_=n("zi");let iW=(0,a.ph)(function(e){let{messages:t,isGenerating:n,provider:s,providerNames:a,modelName:l,modelNames:o,thinkingLevel:c,onUndo:d,onRetry:u,onNewChat:p,isMobile:m=!1}=e,{streamingIdx:h,footers:f,prevNonNoticeIdx:x}=(0,i.Kr)(()=>({streamingIdx:is(t),footers:il(t,n),prevNonNoticeIdx:ia(t)}),[t,n]);return(0,r.Y)(r.FK,{children:t.map((e,i)=>{let g=t[i-1],b=n&&i===h&&"ai"===e.role,v="user"!==e.role&&g&&"user"!==g.role&&!r1(g),k=x[i],y=k>=0?t[k]:null,N=!!("user"!==e.role&&y&&"user"!==y.role),Y=f[i];return(0,r.FD)(w.FK,{children:[(0,r.Y)(r2,{msg:e,isStreaming:b,onUndo:d,onNewChat:p,isPrevAssistant:N,className:r1(e)?"mt-3 mb-1":v?"mt-1":"mt-3"}),Y&&(0,r.Y)(it,{msg:Y.msg,provider:s,providerNames:a,modelName:l,modelNames:o,thinkingLevel:c,durationMs:Y.durationMs,onRetry:u,onNewChat:p,isMobile:m})]},e.id)})})});function iU(e){let{turns:t,jumping:n,onJumpTurn:s}=e,[a,l]=(0,i.J0)(null);if(0===t.length)return null;let o=`clamp(2px, calc(60vh / ${t.length}), 7px)`;return(0,r.Y)("div",{className:`absolute right-0.5 top-1/2 -translate-y-1/2 z-20 flex flex-col items-center py-4 w-6 max-h-[min(60vh,100%)] ${n?"animate-pulse":""}`,role:"navigation","aria-label":`Jump to your message (${t.length} turns)`,onMouseLeave:()=>l(null),children:t.map((e,n)=>{let i=a===n;return(0,r.FD)("div",{className:"relative flex min-h-0 items-center justify-center w-full cursor-pointer",style:{height:o},onMouseEnter:()=>l(n),onClick:()=>s(e),children:[(0,r.Y)("button",{type:"button",className:`block h-px rounded-full transition-all duration-200 ease-out ${(e=>{if(null===a)return"w-3";let t=Math.abs(e-a);return 0===t?"w-6":1===t?"w-4":"w-3"})(n)} ${i?"bg-ink h-[2px]":"bg-ink/25"}`,"aria-label":`Jump to your message #${n+1}`}),(0,r.FD)("div",{className:`absolute right-full mr-3 top-1/2 -translate-y-1/2 w-64 p-3 bg-ink text-canvas text-xs rounded-md shadow-lg pointer-events-none transition-opacity duration-200 z-30 ${i?"opacity-100":"opacity-0"}`,children:[(0,r.FD)("div",{className:"flex items-center justify-between gap-2 pb-1.5 mb-1.5 border-b border-canvas/20 font-mono text-[10px] uppercase tracking-wider text-canvas/60",children:[(0,r.FD)("span",{children:["#",n+1," of ",t.length]}),nA(e)&&(0,r.Y)("span",{children:nA(e)})]}),(0,r.Y)("div",{className:"line-clamp-3 whitespace-pre-wrap leading-relaxed",children:e.preview.trim()||"(no text)"}),(0,r.Y)("div",{className:"absolute top-1/2 -right-1 -translate-y-1/2 w-2 h-2 bg-ink rotate-45"})]})]},`minimap-${e.id}`)})})}function iK(e){let{isMobile:t,userTurns:n,jumpingTurn:i,onJumpTurn:s,scrollRef:a,contentRef:l,handleScroll:o,isScrolling:c,loadingOlder:d,hasMore:u,loadOlderError:p,loadOlder:m,messages:h,isGenerating:f,provider:x,providerNames:g,modelName:b,modelNames:v,thinkingLevel:k,onUndo:y,onRetry:w,onNewChat:N,showScrollBottom:Y,jumpToBottom:D}=e;return(0,r.FD)(r.FK,{children:[!t&&(0,r.Y)(iU,{turns:n,jumping:i,onJumpTurn:s}),(0,r.Y)("div",{ref:a,onScroll:o,className:`flex-1 scrollbar-overlay-container overscroll-contain scroll-smooth overflow-x-hidden ${t?"px-3 py-3 pb-8":"p-4 pb-10"} ${c?"timeline-scrollbar-visible":"timeline-scrollbar-hidden"}`,children:(0,r.FD)("div",{ref:l,className:"mx-auto w-full max-w-[970px]",children:[(d||u||p)&&(0,r.Y)("div",{className:"pb-1",children:d?(0,r.Y)(ip,{}):(0,r.Y)("button",{type:"button",onClick:m,className:`block mx-auto px-3 py-1 rounded-full border text-[11px] font-mono transition-colors ${p?"border-error/40 text-error hover:border-error":"border-ink/15 text-ink/50 hover:text-ink hover:border-ink/30"}`,children:p?"Failed to load — retry":"Load earlier messages"})}),(0,r.Y)(iW,{messages:h,isGenerating:f,provider:x,providerNames:g,modelName:b,modelNames:v,thinkingLevel:k,onUndo:y,onRetry:w,onNewChat:N,isMobile:t})]})}),Y&&(0,r.Y)("div",{className:"absolute bottom-4 left-1/2 transform -translate-x-1/2 z-20",children:(0,r.Y)("button",{onClick:()=>D("smooth"),className:"flex items-center justify-center w-8 h-8 rounded-full border border-ink/20 bg-paper text-ink/60 hover:text-ink hover:bg-ink/5 transition-all shadow-sm",title:"Scroll to bottom",children:(0,r.Y)(i_.A,{size:16})})})]})}var iq=n("n"),iB=n("mO");let iH={running:"thinking…",complete:"complete",cancelled:"cancelled",failed:"failed",interrupted:"interrupted"};function iG(e){let{topics:t,activeTopicId:n,onSelectTopic:s,onDeleteTopic:a,onCloseMenu:l}=e,o=(0,i.li)(null);return(0,i.vJ)(()=>{let e=e=>{let t=e.target instanceof Element?e.target:null;o.current?.contains(t)||t?.closest("[data-btw-menu-anchor]")||l()};return document.addEventListener("pointerdown",e),()=>document.removeEventListener("pointerdown",e)},[l]),(0,i.vJ)(()=>{let e=e=>{"Escape"===e.key&&l()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[l]),(0,r.FD)("div",{ref:o,role:"menu","aria-label":"Side question history",className:"absolute left-0 top-full mt-1 z-50 bg-paper border border-ink/15 rounded-lg shadow-xl min-w-[280px] max-h-72 overflow-y-auto scrollbar-overlay-container scrollbar-overlay-static p-1",children:[0===t.length&&(0,r.Y)("div",{className:"px-2.5 py-2 text-[12px] text-ink/50",children:"No side questions yet."}),t.map(e=>{let t=e.turns.length,i=e.turns[t-1];return(0,r.FD)("div",{className:`group flex items-center rounded ${e.id===n?"bg-ink/5":"hover:bg-ink/5"}`,children:[(0,r.FD)("button",{type:"button",role:"menuitem",onClick:()=>{s(e.id),l()},className:"flex-1 min-w-0 text-left px-2.5 py-2 rounded cursor-pointer",children:[(0,r.Y)("div",{className:"truncate text-[12px] text-ink",children:e.title}),(0,r.FD)("div",{className:"text-[11px] text-ink/50",children:[t," turn",1===t?"":"s",i?` \xb7 ${iH[i.status]}`:""]})]}),(0,r.Y)("button",{type:"button",onClick:()=>a(e.id),className:"p-1.5 mr-1 rounded text-ink/40 opacity-0 group-hover:opacity-100 focus-visible:opacity-100 hover:text-error hover:bg-error/10 transition-colors cursor-pointer","aria-label":`Delete side question: ${e.title}`,title:"Delete this side question",children:(0,r.Y)(iB.A,{size:12,strokeWidth:2})})]},e.id)})]})}let iV="p-1.5 rounded text-ink/45 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:bg-transparent disabled:hover:text-ink/45";function iZ(e){let{value:t,onChange:n,onSubmit:s,onNewQuestion:a,onClose:l,running:o,topics:c,activeTopicId:d,onSelectTopic:u,onDeleteTopic:p,canPromote:m,onPromote:h}=e,f=(0,i.li)(null),[x,g]=(0,i.J0)(!1);return(0,i.vJ)(()=>{let e=f.current;e&&(e.style.height="auto",e.style.height=`${e.scrollHeight}px`)},[t]),(0,r.FD)("div",{className:"bg-paper border border-ink/20 rounded-2xl shadow-sm flex items-center gap-1 pl-1.5 pr-2 py-1 focus-within:border-ink transition-colors",children:[(0,r.Y)("button",{type:"button",onClick:()=>{a(),f.current?.focus()},disabled:o,className:iV,"aria-label":"New side question",title:"New side question",children:(0,r.Y)(iq.A,{size:14,strokeWidth:2})}),(0,r.Y)("textarea",{ref:f,rows:1,value:t,onInput:e=>n(e.currentTarget.value),onKeyDown:e=>{if("Escape"===e.key){e.preventDefault(),l();return}"Enter"!==e.key||e.shiftKey||e.isComposing||229===e.keyCode||(e.preventDefault(),s())},placeholder:"Ask your question","aria-label":"Ask your question",className:"flex-1 min-w-0 bg-transparent text-[13px] text-ink placeholder-ink/40 resize-none outline-none py-1.5 max-h-32 leading-6"}),c.length>0&&(0,r.FD)("div",{className:"relative",children:[(0,r.Y)("button",{type:"button",onClick:()=>g(e=>!e),className:iV,"aria-label":"Side question history",title:"Side question history","aria-expanded":x,"data-btw-menu-anchor":"",children:(0,r.Y)(Y.A,{size:14,strokeWidth:2})}),x&&(0,r.Y)(iG,{topics:c,activeTopicId:d,onSelectTopic:u,onDeleteTopic:p,onCloseMenu:()=>g(!1)})]}),m&&(0,r.Y)("button",{type:"button",onClick:h,className:iV,"aria-label":"Promote answer into chat",title:"Promote answer into chat",children:(0,r.Y)(np.A,{size:14,strokeWidth:2})}),(0,r.Y)("button",{type:"button",onClick:l,className:iV,"aria-label":"Close side questions",title:"Close side questions",children:(0,r.Y)(C.A,{size:14,strokeWidth:2})})]})}function iQ(e){let{status:t}=e;return"complete"===t?null:"running"===t?(0,r.FD)("div",{className:"flex items-center gap-1.5 text-[11px] text-ink/50",children:[(0,r.Y)("span",{className:"w-1.5 h-1.5 rounded-full bg-ink/40 animate-pulse"}),(0,r.Y)("span",{children:"Thinking…"})]}):"cancelled"===t?(0,r.Y)("div",{className:"text-[11px] text-ink/50",children:"Cancelled"}):(0,r.Y)("div",{className:"text-[11px] text-error",children:"failed"===t?"Failed":"Interrupted"})}function iX(e){let{topic:t,liveAnswer:n,error:s}=e,a=(0,i.li)(null),l=t?.turns??[],o=(0,i.Kr)(()=>l.reduce((e,t)=>e+t.question.length+t.answer.length,0)+n.length,[l,n]);(0,i.vJ)(()=>{let e=a.current;e&&(e.scrollTop=e.scrollHeight)},[o]);let c=l.length-1;return(0,r.FD)("div",{ref:a,className:"flex-1 min-h-0 overflow-y-auto scrollbar-overlay-container scrollbar-overlay-static px-4 py-3 space-y-4",children:[s&&(0,r.Y)("div",{className:"bg-error/10 border border-error/30 text-error rounded-lg px-3 py-2 text-[12px]",children:s}),null===t?(0,r.Y)("div",{className:"flex h-full items-center justify-center px-4 text-center text-[12px] text-ink/50",children:"Start a side question — the answer stays out of this chat's transcript."}):l.map((e,t)=>{let i=t===c&&""!==n&&("running"===e.status||n.length>e.answer.length)?n:e.answer;return(0,r.FD)("div",{className:"space-y-2",children:[(0,r.Y)("div",{className:"ml-auto max-w-[85%] w-fit bg-ink/[0.06] border border-ink/10 rounded-xl px-3.5 py-2.5 text-[13px] text-ink break-words",children:(0,r.Y)(tf.T,{content:e.question})}),""!==i&&(0,r.Y)("div",{className:"px-1 text-[13px] text-ink leading-relaxed",children:(0,r.Y)(tf.T,{content:i})}),(0,r.Y)(iQ,{status:e.status})]},e.index)})]})}function i0(e){let{value:t,onChange:n,onSubmit:s,onStop:a,running:l,modelLabel:o,provider:c,providerNames:d,attachments:u,onFilesSelected:p,onRemoveAttachment:m}=e,h=(0,i.li)(null),f=(0,i.li)(null),x=t.trim().length>0||u.length>0,g=c?r7(c,d):"";return(0,i.vJ)(()=>{let e=f.current;e&&(e.focus(),e.setSelectionRange(e.value.length,e.value.length))},[]),(0,i.vJ)(()=>{let e=f.current;e&&(e.style.height="auto",e.style.height=`${e.scrollHeight}px`)},[t]),(0,r.FD)("div",{className:"bg-paper border border-ink/20 rounded-2xl shadow-lg flex flex-col overflow-hidden",children:[(0,r.Y)("textarea",{ref:f,rows:1,value:t,onInput:e=>n(e.currentTarget.value),onKeyDown:e=>{"Escape"===e.key?e.currentTarget.blur():"Enter"!==e.key||e.shiftKey||!e.isComposing&&229!==e.keyCode&&(e.preventDefault(),x&&s())},placeholder:"Ask in this btw session...",className:"w-full bg-transparent text-[13px] text-ink placeholder-ink/40 resize-none outline-none px-3.5 pt-3 pb-1 max-h-32"}),u.length>0&&(0,r.Y)("div",{className:"flex items-center flex-wrap gap-1.5 px-3 pt-2",children:u.map(e=>(0,r.FD)("div",{className:"relative flex items-center bg-canvas border border-ink/10 rounded-md p-0.5 pr-6 text-xs",children:[(0,r.Y)("div",{className:"w-6 h-6 flex items-center justify-center bg-ink/5 rounded-sm mr-1.5 text-ink/60",children:(0,r.Y)(eS.A,{size:12,strokeWidth:2})}),(0,r.Y)("span",{className:"truncate max-w-[120px] font-mono text-[10px] text-ink/80",children:e.name}),(0,t0.z3)(e.size)&&(0,r.Y)("span",{className:"ml-1.5 font-mono text-[10px] text-ink/40",children:(0,t0.z3)(e.size)}),(0,r.Y)("button",{type:"button",onClick:()=>m(e.id),className:"absolute right-0.5 top-1/2 -translate-y-1/2 p-0.5 text-ink/40 hover:text-error hover:bg-error/10 rounded transition-colors cursor-pointer","aria-label":`Remove ${e.name}`,title:"Remove attachment",children:(0,r.Y)(C.A,{size:10,strokeWidth:2})})]},e.id))}),(0,r.FD)("div",{className:"flex items-center justify-between px-2 pb-2",children:[(0,r.FD)("div",{className:"flex items-center gap-0.5",children:[(0,r.Y)("button",{type:"button",onClick:()=>h.current?.click(),className:"p-1.5 rounded text-ink/60 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer","aria-label":"Attach files",title:"Attach files",children:(0,r.Y)(eC.A,{size:14,strokeWidth:2})}),(0,r.Y)("span",{className:"p-1.5 text-ink/40","aria-label":"Side answers never use tools",title:"Side answers never use tools",children:(0,r.Y)(tS.A,{size:14,strokeWidth:2})})]}),(0,r.FD)("div",{className:"flex items-center gap-2 min-w-0",children:[(g||o)&&(0,r.FD)("div",{className:"flex items-baseline gap-1.5 min-w-0",children:[g&&(0,r.Y)("span",{className:"text-[10px] text-ink/40 shrink-0",children:g}),o&&(0,r.Y)("span",{className:"text-[11px] text-ink/70 truncate",children:o})]}),l?(0,r.Y)("button",{type:"button",onClick:a,className:"bg-ink text-canvas rounded p-1.5 cursor-pointer","aria-label":"Stop side answer",title:"Stop side answer",children:(0,r.Y)(S.A,{size:14,strokeWidth:2})}):(0,r.Y)("button",{type:"button",onClick:s,disabled:!x,className:"bg-ink text-canvas hover:bg-ink/80 rounded p-1.5 cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed","aria-label":"Send side question",title:"Send side question",children:(0,r.Y)(T.A,{size:14,strokeWidth:2})})]})]}),(0,r.Y)("input",{type:"file",accept:"image/*",multiple:!0,className:"hidden",ref:h,onChange:e=>{let t=e.currentTarget.files;t&&t.length>0&&p(Array.from(t)),h.current&&(h.current.value="")}})]})}async function i1(e){return Promise.all(e.filter(e=>e.type.startsWith("image/")).map(async e=>{let t=await function(e){let{promise:t,resolve:n}=Promise.withResolvers(),r=new FileReader;return r.onload=()=>{let e="string"==typeof r.result?r.result:"",t=e.indexOf(",");n(t>=0?e.slice(t+1):void 0)},r.onerror=()=>n(void 0),r.readAsDataURL(e),t}(e);return{id:`btw-${e.name}-${e.size}-${e.lastModified}`,name:e.name,size:e.size,...t?{dataBase64:t}:{}}}))}let i5={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",bmp:"image/bmp",svg:"image/svg+xml",avif:"image/avif"};function i2(e){let{mode:t,modelName:n,provider:s,providerNames:a}=e,[l,o]=(0,i.J0)([]),c=t.activeTopic?.turns[t.activeTopic.turns.length-1],d=!!t.activeTopic&&!t.runningTopicId&&!t.busy&&!t.activeTopic?.promotedSessionId&&c?.status==="complete",u=(t.activeTopic?.turns.length??0)>0||!!t.error;return(0,r.FD)("div",{className:"flex flex-col gap-2",children:[u&&(0,r.Y)("div",{className:"bg-paper border border-ink/15 rounded-2xl shadow-xl flex flex-col max-h-[45vh] overflow-hidden",children:(0,r.Y)(iX,{topic:t.activeTopic,liveAnswer:t.liveAnswer,error:t.error})}),(0,r.Y)(iZ,{value:t.askDraft,onChange:t.setAskDraft,onSubmit:t.submitAsk,onNewQuestion:t.resetQuestion,onClose:t.exit,running:!!t.runningTopicId,topics:t.topics,activeTopicId:t.activeTopic?.id??null,onSelectTopic:t.selectTopic,onDeleteTopic:t.removeTopic,canPromote:d,onPromote:()=>void t.promote()}),(0,r.Y)(i0,{value:t.followUpDraft,onChange:t.setFollowUpDraft,onSubmit:()=>{t.submitFollowUp(t.followUpDraft,l.filter(e=>"string"==typeof e.dataBase64).map(e=>{var t;let n;return{type:"image",data:e.dataBase64,mimeType:i5[(n=(t=e.name).lastIndexOf("."))>=0?t.slice(n+1).toLowerCase():""]??"image/png"}})),o([])},onStop:t.abort,running:!!t.runningTopicId,modelLabel:t.activeTopic?.model?.name??n,provider:t.activeTopic?.model?.provider??s,providerNames:a,attachments:l,onFilesSelected:e=>{i1(e).then(e=>o(t=>[...t,...e]))},onRemoveAttachment:e=>o(t=>t.filter(t=>t.id!==e))})]})}var i4=n("Kn");function i3(e,t){let n=new EventSource(e),r=!1;return n.onopen=()=>{r||t.onOpen()},n.onmessage=e=>{let n;if(!r){try{n=JSON.parse(e.data)}catch{return}t.onFrame(n)}},n.onerror=()=>{r||n.readyState===EventSource.CLOSED&&t.onClose()},{close:()=>{r=!0,n.onopen=null,n.onmessage=null,n.onerror=null,n.close()}}}function i8(e,t){let n=null,r=null,i=0,s=!1,a=!1,l=()=>{let o=new WebSocket(e);n=o,o.onopen=()=>{a||(i=0,s=!0,t.onOpen())},o.onmessage=e=>{let n;if(!a){try{n=JSON.parse(String(e.data))}catch{return}t.onFrame(n)}},o.onclose=()=>{n=null,a||(t.onClose(),!s||(i+=1)>4||(r=setTimeout(()=>{r=null,a||l()},Math.min(500*2**(i-1),8e3))))}};return l(),{close:()=>{a=!0,null!==r&&(clearTimeout(r),r=null);let e=n;n=null,e&&(e.onopen=null,e.onmessage=null,e.onclose=null,e.onerror=null,e.close())}}}class i6 extends Error{code;constructor(e,t){super(e),this.name="BtwRequestError",this.code=t}}async function i9(e,t,n){let r=await fetch(`/api/btw/${encodeURIComponent(e)}`,{method:t,...n?{headers:{"Content-Type":"application/json"},body:JSON.stringify(n)}:{}}),i=await r.json().catch(()=>null);if(!r.ok||!i?.success)throw new i6(i?.error??`Side question request failed (${r.status})`,i?.code);return i.data}var i7=n("NO"),se=n("FL");let st="Describe the attached image.";var sn=n("b");let sr={steer:"steer",followup:"follow-up"};function si(e){let{queue:t,onReorder:n,onRemove:s,isSteering:a=!1,onEdit:l,onSendNow:o}=e,c=(0,i.li)(null),d=(0,i.li)(null),u=()=>{if(null===c.current||null===d.current)return;let e=t.map(e=>e.id),r=e.splice(c.current,1)[0];e.splice(d.current,0,r),c.current=null,d.current=null,n?.(e)};if(0===t.length)return null;let p=a?"steer":"followup";return(0,r.Y)("div",{className:"max-h-[150px] scrollbar-overlay-container scrollbar-overlay-static mb-2 space-y-1",children:t.map((e,t)=>(0,r.FD)("div",{draggable:!0,onDragStart:()=>{c.current=t},onDragEnter:()=>{d.current=t},onDragEnd:u,onDragOver:e=>e.preventDefault(),className:"flex items-center gap-2 px-2 py-1.5 bg-paper border border-ink/10 rounded shadow-sm text-xs group hover:border-ink/30 transition-colors",children:[(0,r.Y)("div",{className:"cursor-grab text-ink/40 group-hover:text-ink/80",children:(0,r.Y)(I.A,{size:14})}),(0,r.Y)("span",{className:`shrink-0 text-[9px] font-mono uppercase tracking-wider px-1 py-px rounded ${"steer"===p?"bg-error/10 text-error":"bg-ink/10 text-ink/70"}`,children:sr[p]}),(0,r.Y)("div",{className:"flex-1 truncate text-ink/80 pr-2",children:e.text||(e.attachments.length>0?`[${e.attachments.length} attachment${e.attachments.length>1?"s":""}]`:"Empty message")}),o&&"followup"===p&&(0,r.Y)("button",{onClick:()=>o(e),className:"text-ink/40 hover:text-ink/80 opacity-0 group-hover:opacity-100 transition-opacity",title:"Send Now (Steering)",children:(0,r.Y)(T.A,{size:12})}),l&&(0,r.Y)("button",{onClick:()=>l(e),className:"text-ink/40 hover:text-ink/80 opacity-0 group-hover:opacity-100 transition-opacity",title:"Edit",children:(0,r.Y)(sn.A,{size:12})}),s&&(0,r.Y)("button",{onClick:()=>s(e.id),className:"text-ink/40 hover:text-error opacity-0 group-hover:opacity-100 transition-opacity",title:"Remove",children:(0,r.Y)(C.A,{size:14})})]},e.id))})}function ss(e){let{isMobile:t,sessionId:n,isGenerating:a,modelName:l,generatingVerb:o,provider:c,providerNames:d,messageQueue:u,onRemoveQueueItem:p,onReorderQueue:m,onEditQueueItem:h,onSendNowQueueItem:f,steeringQueue:x,setSteeringQueue:g,inputValue:b,setInputValue:v,rootPath:k,attachments:y,setAttachments:w,onSend:N,onStop:Y,appSettings:D,onThinkingLevelChange:A,onModelChange:F,accessMode:C,onAccessModeChange:S,composerModelRef:T,deferredComposerPickRef:$,sessionModel:z,sessionThinkingLevel:j,variant:L}=e,M=function(e,t){let[n,r]=(0,se.bL)("chat.btwOpen",!1),[a,l]=(0,se.bL)("chat.btwAsk",""),[o,c]=(0,se.bL)("chat.btwFollowUp",""),[d,u]=(0,se.bL)("chat.btwTopicId",null),[,p]=(0,s.o)(),m=function(e,t){let[n,r]=(0,i.J0)(null),[s,a]=(0,i.J0)(null),[l,o]=(0,i.J0)(null),[c,d]=(0,i.J0)(!1),{enabled:u,transport:p}=t,m=(0,i.li)(e);m.current=e,(0,i.vJ)(()=>{var t;if(!u||!e)return;let n=(t={onOpen:()=>{},onFrame:e=>{switch(e.type){case"btw_state":r(e.state),a(t=>{if(!t)return null;let n=e.state.topics.find(e=>e.id===t.topicId),r=n?.turns.find(e=>e.index===t.turnIndex);return r&&"running"===r.status?t:null});break;case"btw_delta":a(t=>t&&t.topicId===e.topicId&&t.turnIndex===e.turnIndex?{...t,text:t.text+e.text}:{topicId:e.topicId,turnIndex:e.turnIndex,text:e.text});break;case"btw_error":o(e.message)}},onClose:()=>{}},"sse"===p?i3((0,i4.Ec)(e),t):i8((0,i4.oU)(e),t));return i9(e,"GET").then(r).catch(e=>o(e instanceof Error?e.message:String(e))),()=>n.close()},[u,e,p]);let h=(0,i.hb)(async e=>{let t=m.current;if(!t)return null;d(!0);try{let n=await e(t);return r(n),n}catch(e){return o(e instanceof i6||e instanceof Error?e.message:String(e)),null}finally{d(!1)}},[]),f=(0,i.hb)(async(e,t,n)=>{o(null);let r=await h(r=>{var i;return i9(r,"POST",{action:"ask",question:(i={question:e,images:t,topicId:n}).question,...i.topicId?{topicId:i.topicId}:{},...i.images?.length?{images:i.images}:{}})});return a(null),r&&!r.runningTopicId&&o("The side question was accepted but did not start running."),r},[h]),x=(0,i.hb)(async e=>{o(null),await h(t=>i9(t,"POST",{action:"abort",topicId:e}))},[h]),g=(0,i.hb)(async e=>{o(null),await h(t=>i9(t,"POST",{action:"delete",topicId:e}))},[h]);return{state:n,live:s,error:l,busy:c,ask:f,abort:x,promote:(0,i.hb)(async e=>{let t=m.current;if(!t)return null;o(null),d(!0);try{return(await i9(t,"POST",{action:"promote",topicId:e})).sessionId}catch(e){return o(e instanceof i6||e instanceof Error?e.message:String(e)),null}finally{d(!1)}},[]),remove:g,clearError:(0,i.hb)(()=>o(null),[])}}(e,{enabled:n&&!!e,transport:(0,i4.ul)(t)}),h=m.state?.topics??[],f=h.find(e=>e.id===d)??h[h.length-1]??null,x=m.state?.runningTopicId??null,g=m.live&&m.live.topicId===f?.id?m.live:null,b=(0,i.hb)(e=>{e&&u(e.topics[e.topics.length-1]?.id??null)},[u]);(0,i7.sY)("omp:btw",e=>{let t=e.detail,n=t?.question?.trim();r(!0),(n||t?.images?.length)&&(l(""),m.ask(n||st,t?.images).then(b))});let v=(0,i.hb)(()=>{let e=a.trim();e&&(l(""),m.ask(e).then(b))},[a,m,l,b]),k=(0,i.hb)((e,t)=>{let n=e.trim();(n||t?.length)&&(c(""),m.ask(n||st,t,f?.id).then(e=>{f||b(e)}))},[f,m,c,b]),y=(0,i.hb)(async()=>{if(!f)return null;let e=await m.promote(f.id);return e?(r(!1),u(null),p(t=>{let n=new URLSearchParams(t);return n.set("sessionId",e),n.has("subagent")&&n.delete("subagent"),n}),window.dispatchEvent(new CustomEvent("omp:session-updated",{detail:{sessionId:e}})),e):null},[f,m,r,u,p]),w=(0,i.hb)(e=>{e===d&&u(null),m.remove(e)},[d,m,u]);return{open:n,topics:h,activeTopic:f,runningTopicId:x,busy:m.busy,liveAnswer:g?g.text:"",error:m.error,askDraft:a,followUpDraft:o,setAskDraft:l,setFollowUpDraft:c,enter:()=>r(!0),exit:()=>r(!1),resetQuestion:()=>{l(""),u(null),m.clearError()},submitAsk:v,submitFollowUp:k,abort:()=>{x&&m.abort(x)},promote:y,removeTopic:w,selectTopic:e=>{u(e),m.clearError()},clearError:m.clearError}}(n,D);return(0,r.Y)("div",{className:`bg-transparent border-t-0 flex-shrink-0 space-y-2 ${t?"px-3 pt-1":"p-4 pt-1"}`,style:t?{paddingBottom:"max(0.75rem, env(safe-area-inset-bottom, 0px))"}:void 0,children:(0,r.FD)("div",{className:"relative mx-auto w-full max-w-[970px]",children:[a&&(0,r.Y)(ii,{modelName:l,generatingVerb:o,provider:c,providerNames:d}),(0,r.Y)(si,{queue:u,onRemove:p,onReorder:m,onEdit:h,onSendNow:f}),(0,r.Y)(si,{queue:x,onRemove:e=>g(t=>t.filter(t=>t.id!==e)),onReorder:e=>g(t=>{let n=new Map(t.map(e=>[e.id,e]));return e.map(e=>n.get(e)).filter(e=>!!e)}),isSteering:!0}),M.open?(0,r.Y)(i2,{mode:M,modelName:l,provider:c,providerNames:d}):(0,r.Y)(to,{value:b,onChange:v,rootPath:k,attachments:y,onAttachmentsChange:w,onSend:N,isGenerating:a,onStop:Y,appSettings:D,onThinkingLevelChange:A,onModelChange:F,accessMode:C,onAccessModeChange:S,composerModelRef:T,deferredComposerPickRef:$,sessionModel:z,sessionThinkingLevel:j,variant:L})]})})}var sa=n("zG");function sl(e){let t,n=(0,sa.oJ)(e.name)??"",r=sa.YT[n.toLowerCase()]??n.toLowerCase(),i=(t={...(0,n3.u)(e.args)?e.args:(0,n3.u)(e.input)?e.input:{}},e.command&&void 0===(0,sa.oJ)(t.command)&&void 0===(0,sa.oJ)(t.cmd)&&(t.command=e.command),e.target&&void 0===(0,sa.oJ)(t.path)&&(t.path=e.target),t),s=(0,sa.oJ)(e.intent)??(0,sa.Up)(i,["i"]),a=function(e,t){let n=(0,sa.Up)(e,["path","target"])??(0,sa.oJ)(t.target)??(0,sa.oJ)(t.command);if(n&&n.startsWith("xd://"))return n.slice(5).split(/[/?#\s]/)[0]||void 0}(i,e);if(a){let e=a.startsWith("mcp__")?a.slice(5):void 0,t=e?`Running ${e}`:sa.Qq[a]??`Running ${a}`,n=(0,sa.qL)(e??a,function(e){let{path:t,target:n,command:r,i:i,...s}=e,a=e.content;if("string"!=typeof a)return s;try{let e=JSON.parse(a);if((0,n3.u)(e))return{...s,...e}}catch{}let l=a.trim().split("\n",1)[0]?.trim();return l?{...s,prose:l}:s}(i));return n?(0,sa.xv)(`${t} ${n}`):s?(0,sa.xv)(s):(0,sa.xv)(t)}let l=sa.K$[r]??(r?`Running ${r}`:"Working"),o=(0,sa.qL)(r,i);return o?(0,sa.xv)(`${l} ${o}`):s?(0,sa.xv)(s):(0,sa.xv)(l)}var so=n("K");function sc(e,t,n){let r=e.toolResultsRef.current;r&&function(e,t,n){var r;for(e.set(t,{...n,output:(r=n.output).length<=2e5?r:`…[truncated]
20
20
  ${r.slice(-2e5)}`});e.size>200;){let t=e.keys().next().value;if(void 0===t)break;e.delete(t)}}(r,t,n)}function sd(e,t){let n="string"==typeof e.toolCallId?e.toolCallId:void 0;n&&t.toolResultsRef.current?.set(n,{output:ik(e.content),details:e.details&&"object"==typeof e.details?e.details:void 0})}function su(e,t){if(!e.toolCalls?.length)return e;let n=e.toolCalls.map(e=>{let n=t.toolResultsRef.current?.get(e.id);return n?{...e,output:n.output,details:e.details||n.details||void 0,status:n.isError?"error":"success"}:e});return{...e,toolCalls:n}}function sp(e,t){if(!e)return;let n=t.lastToolMessageRef.current;n?.toolCalls?.some(t=>t.id===e)&&t.onMessageUpdate?.(su(n,t))}function sm(e,t){e&&e!==t.activityRef.current&&(t.activityRef.current=e,t.callbacksRef.current?.onActivity?.(e))}function sh(e){return{...e,onMessageUpdate:e.callbacksRef.current?.onMessageUpdate}}var sf=n("g0");let sx={websocket:function(e,t){return i8((0,i4.qq)(e),t)},sse:function(e,t){return i3((0,i4._m)(e),t)}};function sg(e,t,n){return fetch(`/api/agent/${encodeURIComponent(e)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),...n?{signal:n}:{}})}async function sb(e){let t=new AbortController,n=setTimeout(()=>t.abort(),1e4);try{if(await sg(e,{type:"abort"},t.signal).then(()=>!0,()=>!1))return;await sg(e,{type:"force_reset"}).catch(()=>null)}finally{clearTimeout(n)}}function sv(e){return`/api/sessions/${encodeURIComponent(e)}/queue`}async function sk(e){if(!e.ok)return null;let t=await e.json().catch(()=>null);return Array.isArray(t?.queue)?t.queue:null}let sy="u"<typeof window?i.vJ:i.Nf,sw=/^\/btw(?:\s+([\s\S]*))?$/i;var sN=n("G1");async function sY(e,t){let{sessionId:n,prompt:r,model:i,workspaceName:s,attachments:a,signal:l}=e,o={id:`msg-${Date.now()}-ai`,role:"ai",date:`Today, ${nY()}`,content:""},c=!1;try{let e=await fetch("/api/chat/stream",{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify({sessionId:n,prompt:r,model:i,workspaceName:s,attachments:a?.map(e=>({name:e.name||e.file?.name,preview:e.preview}))}),signal:l});if(!e.ok||!e.body)throw Error(`SSE stream connection failed: HTTP ${e.status}`);if(await (0,sN.o)(e,(e,n)=>{try{let r=JSON.parse(n);switch(e){case"init":o.id=r.id||o.id,o.date=r.date||o.date,t.onInit?.(r);break;case"thinking_start":o.thinking={thought:"",isGenerating:!0},t.onThinkingStart?.(r);break;case"thinking_chunk":"object"==typeof o.thinking?o.thinking.thought=(o.thinking.thought||"")+r.delta:o.thinking={thought:r.delta,isGenerating:!0},t.onThinkingChunk?.(r);break;case"thinking_end":o.thinking={thought:r.thought,summary:r.summary,duration:r.duration,isGenerating:!1},t.onThinkingEnd?.(r);break;case"tool_start":o.toolCalls=[...o.toolCalls||[],r],t.onToolStart?.(r);break;case"tool_output_chunk":o.toolCalls=(o.toolCalls||[]).map(e=>e.id===r.id?{...e,output:(e.output||"")+r.delta}:e),t.onToolOutputChunk?.(r);break;case"tool_end":o.toolCalls=(o.toolCalls||[]).map(e=>e.id===r.id?{...e,...r}:e),t.onToolEnd?.(r);break;case"content_start":t.onContentStart?.();break;case"content_chunk":o.content=(o.content||"")+r.delta,t.onContentChunk?.(r);break;case"content_end":t.onContentEnd?.();break;case"summary":o.summary=r.summary,t.onSummary?.(r);break;case"done":return r.message&&(o=r.message),c=!0,t.onDone?.(r),!0;case"error":throw Error(r.error||"Stream error")}}catch(e){console.warn("SSE chunk parse error:",e)}},l),l?.aborted)return null;return c||t.onDone?.({message:o}),o}catch(n){if(l?.aborted)return null;return console.warn("Streaming failed, invoking fallback response handler:",n),t.onError?.(n),await sD(e,t)}}async function sD(e,t){let{sessionId:n,prompt:r,model:i,workspaceName:s}=e,a=nY(),l={id:`msg-${Date.now()}-ai`,role:"ai",date:`Today, ${a}`,timestamp:a,thinking:{duration:"1.2s",thought:`1. User prompt: "${r}".
21
21
  2. Target workspace: ${s||"Workspace"}.
22
22
  3. Fallback resolution complete.`,summary:"Execute workspace diagnostics and fallback resolution."},toolCalls:[{id:`tc-${Date.now()}-fallback`,type:"bash",title:"Diagnostic Command",target:"bun --version",command:"bun --version",output:"Bun v1.2.4 (fallback mode)",status:"success",duration:"35ms"}],content:`I've processed your request: **"${r||"Workspace status"}"**.
@@ -31,4 +31,4 @@ ${e.content}
31
31
  ${i}`});return[i.trim(),...s].filter(Boolean).join("\n\n")}var s$=n("ng");function sz(e,t){let n=null,r=0,i=[],s=()=>{n=null;let r=i;if(i=[],r.length){for(let t of r)e(t.updater);t?.()}},a=()=>{r+=1,null!==n&&cancelAnimationFrame(n),n=null};return{queue(e,t){let a=void 0===t?-1:i.findIndex(e=>e.key===t);-1!==a?i[a]={key:t,updater:e}:i.push({key:t,updater:e}),(()=>{if(null!==n)return;let e=++r;n=requestAnimationFrame(()=>{e===r&&s()})})()},flush(){a(),s()},cancel(){a(),i=[]}}}let sj=[250,250,500,500,1e3,1e3,2e3,2e3,2e3,2e3,2e3,2e3];function sL(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Date.now()+3e3,n=document.getElementById(e);n?n.scrollIntoView({behavior:"smooth",block:"center"}):Date.now()>=t||requestAnimationFrame(()=>sL(e,t))}var sM=n("Fb");function sE(e,t){let n=e[t];return"string"==typeof n?n:void 0}let sP=()=>{},sI=()=>{},sR=sz(e=>sP(e),()=>sI());function sO(){sR.flush(),sR.cancel()}function sJ(){sR.cancel()}var s_=n("So"),sW=n("Np"),sU=n("B");function sK(e){var t;return t=e.connectedProviders,t?.length?Object.fromEntries(t.filter(e=>e.name?.trim()).map(e=>[e.id,e.name])):{}}var sq=n("oZ"),sB=n("wu"),sH=n("Gb"),sG=n("A9");function sV(e){let{className:t="",appSettings:n={},onSessionTitle:a,variant:l="desktop"}=e,{folders:c}=(0,sG.k)(),d="mobile"===l,{sessionId:u,selectedFolderId:m,setSelectedFolderId:f,sessionData:x,localMessages:g,isGenerating:b,hasMore:v,loadingOlder:k,loadOlderError:w,sessionLoading:N,loadOlder:Y,userTurns:D,jumpingTurn:A,jumpToUserTurn:F,generatingVerb:C,messageQueue:S,removeMessage:T,reorderMessages:$,steeringQueue:z,setSteeringQueue:j,inputValue:L,setInputValue:M,inputAttachments:E,setInputAttachments:P,scrollRef:I,contentRef:R,showScrollBottom:O,isScrolling:J,handleScroll:_,jumpToBottom:W,handleSend:U,handleEditQueueItem:K,handleSendNowQueueItem:q,handleUndo:B,handleRetry:H,submitNewChat:G,stopGenerating:V,handleThinkingLevelChange:Z,handleModelChange:Q,accessMode:X,handleAccessModeChange:ee,composerModelRef:et,deferredComposerPickRef:en,extensionDialogs:er,resolveExtensionDialog:ei,respondToExtensionUi:es}=function(){let e,{folders:t=[],appSettings:n={}}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},[r,a]=(0,s.o)(),l=r.get("sessionId"),o=r.get("folderId"),[c,d]=(0,i.J0)(null);(0,i.vJ)(()=>{d(o?parseInt(o,10):null)},[o]);let u=(0,i.hb)(e=>{d(e),a(t=>(e?t.set("folderId",String(e)):t.delete("folderId"),t),{replace:!0})},[a]),p=(0,i.li)(()=>{}),{scrollRef:m,contentRef:h,showScrollBottom:f,isScrolling:x,handleScroll:g,scrollToBottom:b,jumpToBottom:v}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=(0,i.li)(e.onScrollTop);t.current=e.onScrollTop??t.current;let n=(0,i.li)(null),[r,s]=(0,i.J0)(null),[a,l]=(0,i.J0)(!1),[o,c]=(0,i.J0)(!1),d=(0,i.li)(null),u=(0,i.li)(!0),p=(0,i.li)(0),m=(0,i.hb)(e=>{s(e)},[]),h=(0,i.hb)(()=>{let e=n.current;e&&l(e.scrollHeight-e.scrollTop-e.clientHeight>=100)},[]),f=(0,i.hb)(()=>{let e=n.current;e&&(e.scrollTop<p.current-1&&(u.current=!1),e.scrollHeight-e.scrollTop-e.clientHeight<100&&(u.current=!0),p.current=e.scrollTop,e.scrollTop<=40&&t.current?.()),h(),c(!0),d.current&&clearTimeout(d.current),d.current=setTimeout(()=>c(!1),600)},[h]),x=(0,i.hb)(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"smooth",t=n.current;!t||u.current&&t.scrollTo({top:t.scrollHeight,behavior:e})},[]),g=(0,i.hb)(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"smooth",t=n.current;t&&(u.current=!0,t.scrollTo({top:t.scrollHeight,behavior:e}))},[]);return(0,i.vJ)(()=>{if(h(),"u"<typeof ResizeObserver)return;let e=n.current,t=new ResizeObserver(h);return e&&t.observe(e),r&&t.observe(r),()=>t.disconnect()},[r,h]),(0,i.vJ)(()=>()=>{d.current&&clearTimeout(d.current)},[]),{scrollRef:n,contentRef:m,showScrollBottom:a,isScrolling:o,followRef:u,handleScroll:f,scrollToBottom:x,jumpToBottom:g}}({onScrollTop:()=>p.current()}),[k,y]=(0,se.bL)("chat.draft","");(e=(0,i.li)(y)).current=y,(0,i.vJ)(()=>{let t=t=>{let n=t instanceof CustomEvent?t.detail:null;if(!(0,n3.u)(n))return;let r=sE(n,"url");if(!r)return;let i=sE(n,"title");e.current(e=>{let t=e&&!e.endsWith("\n")?"\n\n":e?"\n":"",n=i?`
32
32
  Judul: ${i}`:"";return`${e}${t}[Konteks halaman browser]
33
33
  URL: ${r}${n}
34
- (Lanjutkan dari halaman ini.)`})};return window.addEventListener(sM.j,t),()=>window.removeEventListener(sM.j,t)},[]);let[w,N]=(0,se.bL)("chat.draftAttachments",[]),[Y,D]=(0,i.J0)([]),A=!!l?.startsWith("new-");!function(e){let{sessionId:t,messages:n,scrollRef:r,scrollToBottom:s,enabled:a}=e,l=(0,i.li)(null),o=(0,i.li)(null);sy(()=>{if(l.current!==t){l.current=t,o.current=null;return}a&&t&&0!==n.length&&o.current!==t&&r.current&&(o.current=t,s("instant"))},[t,n,a,r,s])}({sessionId:l,messages:Y,scrollRef:m,scrollToBottom:b,enabled:!A});let[F,C]=(0,i.J0)(!1),S=(0,i.li)(!1),T=(0,i.li)([]);T.current=Y;let[$,z]=(0,i.J0)(""),j=(0,i.li)(null),L=(0,i.li)(l);L.current=l;let M=(0,i.hb)(e=>{S.current=e,C(e)},[]),E=(0,i.li)(!1),P=(0,i.li)(null),I=(0,i.li)(!1),R=(0,i.li)(null),O=(0,i.li)([]),J=!!l&&!String(l).startsWith("new-")&&Number.isNaN(Number(l)),_=(0,i.li)(null),{sessionData:W,adoptedSessionIdRef:U,refreshSessionMeta:K,seedSession:q,hasMore:B,loadingOlder:H,loadOlderError:G,sessionLoading:V,loadOlder:Z,jumpToTurn:Q}=function(e){let{sessionId:t,setLocalMessages:n,setGenerating:r,isGeneratingRef:s,aiPlaceholderIdRef:a,localMessagesRef:l,optimisticUserIdRef:o,cancelStreamingCoalescer:c,metaRefreshedRef:d,scrollRef:u}=e,[p,m]=(0,i.J0)(null),[h,f]=(0,i.J0)(!1),x=(0,i.li)(null),g=(0,i.li)(null),b=(0,i.li)(null),v=(0,i.li)(null),k=(0,i.hb)(e=>{e.model&&"object"==typeof e.model&&(b.current=e.model);let t=e.model??(s.current?b.current??void 0:void 0),n=e.thinkingLevel??v.current??void 0;m({...e,model:t,thinkingLevel:n})},[]),y=(0,i.li)(t);y.current=t;let{hasMore:w,loadingOlder:N,loadOlderError:Y,loadOlder:D,jumpToTurn:A,resetPages:F,applyWindow:C}=function(e){let{sessionId:t,sessionIdRef:n,setLocalMessages:r,scrollRef:s}=e,[a,l]=(0,i.J0)(!1),[o,c]=(0,i.J0)(0),[d,u]=(0,i.J0)(!1),[p,m]=(0,i.J0)(!1),[h,f]=(0,i.J0)(0),x=(0,i.li)(!1),g=(0,i.li)(!1),b=(0,i.li)(0);b.current=o;let v=(0,i.li)(null),k=(0,i.hb)(()=>{l(!1),c(0),b.current=0,x.current=!1,u(!1),m(!1)},[]),y=(0,i.hb)((e,t)=>{"boolean"==typeof e&&l(e),"number"==typeof t&&c(t)},[]),w=(0,i.hb)(async(e,n)=>{if(!t)return null;let r=null===n?"":`&limit=${n}`,i=await fetch(`/api/chat/${t}?before=${e}${r}`);if(!i.ok)throw Error(`HTTP ${i.status}`);let s=await i.json();return{messages:s.session?.messages??[],hasMore:s.hasMore,oldestIndex:s.oldestIndex}},[t]),N=(0,i.hb)(()=>{let e=s?.current;e&&(v.current={prevHeight:e.scrollHeight,prevTop:e.scrollTop})},[s]),Y=(0,i.hb)(()=>{let e=s?.current;if(!e){g.current=!1;return}let t=e.scrollTop,n=0,r=()=>{if(e.scrollTop===t?n+=1:(n=0,t=e.scrollTop),n>=5){g.current=!1;return}requestAnimationFrame(r)};requestAnimationFrame(r)},[s]),D=(0,i.hb)(()=>{!t||t.startsWith("new-")||!a||x.current||g.current||(x.current=!0,u(!0),m(!1),N(),w(o,null).then(e=>{if(!e||n.current!==t)return;let i=e.messages;if(y(e.hasMore,e.oldestIndex),0===i.length){v.current=null;return}r(e=>[...i,...e]),f(e=>e+1)}).catch(()=>{n.current===t&&m(!0)}).finally(()=>{x.current=!1,u(!1)}))},[t,n,a,o,w,N,r,y]),A=(0,i.hb)(async(e,i)=>{if(!t||t.startsWith("new-"))return!1;if(i<0||i>=b.current)return!0;if(x.current)return!1;x.current=!0,g.current=!0,u(!0),m(!1);let s=b.current,l=a,o=!1,c=0;try{for(;!o&&s>i&&c<40;){c+=1;let a=await w(s,Math.min(300,s-i));if(!a||n.current!==t)return!1;let d=a.messages;if(0===d.length)break;let u="number"==typeof a.oldestIndex?a.oldestIndex:Math.max(0,s-d.length);if(r(e=>[...d,...e]),o=d.some(t=>t.id===e),u>=s)break;s=u,l=a.hasMore}}catch{return n.current===t&&m(!0),!1}finally{x.current=!1,u(!1)}return y(l,s),c>0&&f(e=>e+1),Y(),o},[t,n,a,w,r,y,Y]);return(0,i.Nf)(()=>{let e=v.current;if(!e)return;let t=s?.current;if(!t)return;v.current=null;let n=t.scrollHeight-e.prevHeight;n>0&&(t.scrollTop=e.prevTop+n)},[h,s]),{hasMore:a,loadingOlder:d,loadOlderError:p,loadOlder:D,jumpToTurn:A,resetPages:k,applyWindow:y}}({sessionId:t,sessionIdRef:y,setLocalMessages:n,scrollRef:u}),S=(0,i.hb)(e=>{let t=()=>y.current===e||g.current===e;if(!t())return;let n=0,r=()=>{t()&&fetch(`/api/chat/${encodeURIComponent(e)}`).then(e=>e.json()).then(i=>{if(!i?.session||!t())return;if(k(i.session),(i.session.messages?.length??0)>0)return void window.dispatchEvent(new CustomEvent("omp:session-updated",{detail:{sessionId:e}}));let s=sj[n];n+=1,void 0!==s&&setTimeout(r,s)}).catch(()=>{})};r()},[k]),T=(0,i.hb)(e=>{e.model&&(b.current=e.model),e.thinkingLevel&&(v.current=e.thinkingLevel),m(t=>({...t??{},...e.model?{model:e.model}:{},...e.thinkingLevel?{thinkingLevel:e.thinkingLevel}:{}}))},[]),$=(0,i.hb)(()=>s.current&&!!a.current,[a]);return(0,i.vJ)(()=>{let e=!0;if(f(!0),t!==x.current){let e=t&&!t.startsWith("new-")&&x.current?.startsWith("new-"),i=s.current&&g.current===t;e||i||(n([]),r(!1),g.current=null,b.current=null,m(null),v.current=null,a.current=null,o.current=null,c()),F(),d.current=null,x.current=t}return t?fetch(`/api/chat/${t}`).then(e=>e.json()).then(r=>{if(e)if(f(!1),r?.session){k(r.session);let e=r.session.messages||[],i=$();if(e.length>0&&!i)if(s.current){let t=e.map(e=>e.id);n([...e,...l.current.filter(e=>!t.includes(e.id))])}else n(e);else t.startsWith("new-")||i||n([]);C(r.hasMore,r.oldestIndex)}else m(null),$()||n([])}).catch(t=>{console.error("Error loading session from API:",t),e&&f(!1),e&&!$()&&(m(null),n([]))}):(m(null),n([])),()=>{e=!1}},[t,k,$,n,r]),{sessionData:p,hasMore:w,loadingOlder:N,loadOlderError:Y,sessionLoading:h,loadOlder:D,jumpToTurn:A,adoptedSessionIdRef:g,refreshSessionMeta:S,seedSession:T}}({sessionId:l,setLocalMessages:D,setGenerating:M,isGeneratingRef:S,aiPlaceholderIdRef:_,localMessagesRef:T,optimisticUserIdRef:R,cancelStreamingCoalescer:sJ,metaRefreshedRef:P,scrollRef:m});p.current=Z;let{turns:X,jumping:ee,jumpToTurn:et}=function(e){let{sessionId:t,messages:n,jumpToTurn:r}=e,[s,a]=(0,i.J0)(null),[l,o]=(0,i.J0)(!1),c=(0,i.Kr)(()=>{let e=[];for(let t of n)"user"===t.role&&e.push({id:t.id,index:-1,preview:(t.content??"").slice(0,220),date:t.date,timestamp:t.timestamp});return e},[n]),d=(0,i.Kr)(()=>{for(let e=n.length-1;e>=0;e-=1)if(n[e]?.role==="user")return n[e].id;return""},[n]);return(0,i.vJ)(()=>{if(!t||t.startsWith("new-"))return void a(null);let e=!0;return fetch(`/api/chat/${encodeURIComponent(t)}/turns`).then(e=>e.ok?e.json():null).then(t=>{e&&t&&Array.isArray(t.turns)&&a(t.turns)}).catch(()=>{}),()=>{e=!1}},[t,d]),{turns:(0,i.Kr)(()=>{if(!s)return c;let e=new Set(s.map(e=>e.id)),t=c.filter(t=>!e.has(t.id));return t.length>0?[...s,...t]:s},[s,c]),jumping:l,jumpToTurn:async(e,t)=>{if(t<0)return sL(e),!0;o(!0);try{let n=await r(e,t);return n&&sL(e),n}finally{o(!1)}}}}({sessionId:l,messages:Y,jumpToTurn:Q}),en=(0,i.li)(null),er=(0,i.li)(null),ei=(0,i.li)(null),es=(0,i.li)(null);(0,i.vJ)(()=>{es.current=null},[l]);let[ea,el]=(0,i.J0)(()=>{var e,t;return"string"==typeof(t=e=n.omp_access_mode)&&ed.some(e=>e===t)?e:"always-ask"}),eo=(0,i.li)(ea);eo.current=ea;let ec=(0,i.hb)(e=>{el(e),eo.current=e,(0,s_.cz)("omp_access_mode",e)},[]),eu=(0,i.hb)(e=>{l&&fetch(`/api/chat/${l}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messages:e})}).catch(e=>console.error("Error persisting messages via API:",e))},[l]),{messageQueue:ep,enqueueMessage:em,removeMessage:eh,reorderMessages:ef,steeringQueue:ex,setSteeringQueue:eg}=function(e){let[t,n]=(0,i.J0)([]),[r,s]=(0,se.bL)("chat.steeringQueue",[]),a=(0,i.li)(0),l=(0,i.li)(!1),o=(0,i.hb)(()=>{if(!e)return void n([]);let t=++a.current;fetch(sv(e)).then(e=>sk(e)).then(e=>{l.current||a.current!==t||n(e??[])}).catch(()=>{})},[e]);(0,i.vJ)(()=>{l.current=!1,o();let e=()=>o();return window.addEventListener("focus",e),()=>{l.current=!0,window.removeEventListener("focus",e)}},[o]),(0,i.vJ)(()=>{e&&0!==t.length&&fetch(`${sv(e)}/deliver`,{method:"POST"}).catch(()=>{})},[e,t.length>0]);let c=(0,i.hb)(t=>{if(!e)return;let r={...t,id:`queue-${Date.now()}`};n(e=>[...e,r]),fetch(sv(e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}).then(e=>sk(e)).then(e=>{e&&n(e)}).catch(()=>{})},[e]),d=(0,i.hb)((t,r)=>{e&&fetch(`${sv(e)}/${encodeURIComponent(t)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:r})}).then(e=>sk(e)).then(e=>{e&&n(e)}).catch(()=>{})},[e]);return{messageQueue:t,enqueueMessage:c,editMessageText:d,removeMessage:(0,i.hb)(t=>{e&&(n(e=>e.filter(e=>e.id!==t)),fetch(`${sv(e)}/${encodeURIComponent(t)}`,{method:"DELETE"}).then(e=>sk(e)).then(e=>{e&&n(e)}).catch(()=>{}))},[e]),reorderMessages:(0,i.hb)(t=>{e&&(n(e=>{let n=new Map(e.map(e=>[e.id,e]));return t.map(e=>n.get(e)).filter(e=>!!e)}),fetch(sv(e),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({orderedIds:t})}).then(e=>sk(e)).then(e=>{e&&n(e)}).catch(()=>{}))},[e]),refresh:o,steeringQueue:r,setSteeringQueue:s}}(l),{pending:eb,enqueue:ev,resolve:ek,withdraw:ey}=function(e){let[t,n]=(0,i.J0)([]);(0,i.vJ)(()=>{n([])},[e]);let r=(0,i.hb)(e=>{n(t=>t.some(t=>t.id===e.id)?t:[...t,e])},[]);return{pending:t,enqueue:r,resolve:(0,i.hb)(e=>{n(t=>t.some(t=>t.id===e)?t.filter(t=>t.id!==e):t)},[]),withdraw:(0,i.hb)(e=>{n(t=>t.filter(t=>t.id!==e))},[])}}(l),ew=function(e,t,n){let[r,s]=(0,i.J0)({isGenerating:!1,connected:!1,error:null}),a=(0,i.li)(t);a.current=t;let l=(0,i.li)(e);l.current=e;let o=(0,i.li)(new Map),c=(0,i.li)(null),d=(0,i.li)(!1),u=(0,i.li)(""),p=(0,i.li)(void 0),m=(0,i.li)(new Set),{connect:h,disconnect:f}=function(e){let{setState:t,callbacksRef:n,toolResultsRef:r,lastToolMessageRef:s,interruptPendingRef:a,activityRef:l,currentThinkingLevelRef:o,fileMutatingCallsRef:c,transport:d}=e,u=(0,i.li)(null);(0,i.vJ)(()=>((0,sf.dX)({transport:d,connected:!1}),()=>(0,sf.dX)({transport:d,connected:!1})),[d]);let p=(0,i.hb)(()=>{let e=u.current;u.current=null,e?.close(),t(e=>({...e,connected:!1})),(0,sf.dX)({transport:d,connected:!1})},[t,d]);return{connect:(0,i.hb)(e=>{p(),u.current=sx[d](e,{onOpen:()=>{t(e=>({...e,connected:!0})),(0,sf.dX)({transport:d,connected:!0}),n.current?.onConnected?.()},onFrame:i=>{!function(e,t){let n=t.callbacksRef.current;switch(e.type){case"agent_start":t.setState(e=>({...e,isGenerating:!0,error:null})),t.toolResultsRef.current?.clear(),t.fileMutatingCallsRef.current?.clear(),t.lastToolMessageRef.current=null,t.interruptPendingRef.current=!1,t.currentThinkingLevelRef.current=void 0,sm(sa.n1.thinking,t),n?.onAgentStart?.();break;case"turn_start":sm(sa.n1.thinking,t),n?.onTurnStart?.();break;case"message_start":case"message_update":{let r=e.message;if(!r)break;if("toolResult"===r.role){sd(r,t),sm(sa.n1.thinking,t);break}sm(function(e){if(!(0,n3.u)(e))return;let t=(0,sa.oJ)(e.type);if(t){if(t.startsWith("thinking"))return sa.n1.thinking;if(t.startsWith("text"))return sa.n1.writing;if("toolcall_start"===t||"toolcall_delta"===t){let t=function(e){let t=e.partial;if(!(0,n3.u)(t))return;let n=t.content;if(!Array.isArray(n))return;let r="number"==typeof e.contentIndex?e.contentIndex:n.length-1,i=n[r];if((0,n3.u)(i)&&"toolCall"===i.type)return i}(e);if(!t)return;return sl({name:(0,sa.oJ)(t.name),args:t.arguments})}if("toolcall_end"===t){let t=e.toolCall;if(!(0,n3.u)(t))return;return sl({name:(0,sa.oJ)(t.name),args:t.arguments})}}}(e.assistantMessageEvent),t),"message_start"===e.type&&n?.onTurnStart?.();let i=iF(r);i&&("user"!==i.role&&t.currentThinkingLevelRef.current&&(i.thinkingLevel=t.currentThinkingLevelRef.current),n?.onMessageUpdate?.(i));break}case"message_end":{let r=e.message;if(!r)break;if("toolResult"===r.role){sd(r,sh(t));break}if("custom"===r.role)break;if("user"===r.role){let e=ik(r.content);e&&n?.onQueuedMessageDelivered?.(e);break}let i=iF(r,!1);if(!i)break;"user"!==i.role&&t.currentThinkingLevelRef.current&&(i.thinkingLevel=t.currentThinkingLevelRef.current);let s=su(i,t);s.toolCalls?.length&&(t.lastToolMessageRef.current=s),n?.onMessageEnd?.(s);break}case"tool_execution_start":{let r="string"==typeof e.toolCallId?e.toolCallId:void 0;sm(sl({name:"string"==typeof e.toolName?e.toolName:void 0,args:e.args,intent:"string"==typeof e.intent?e.intent:void 0}),t),r&&t.toolResultsRef.current?.set(r,{output:""}),r&&(0,so.Y)({toolName:e.toolName,args:e.args})&&t.fileMutatingCallsRef.current?.add(r);let i=t.lastToolMessageRef.current;i?.toolCalls?.some(e=>e.id===r)&&(t.lastToolMessageRef.current={...i,toolCalls:i.toolCalls.map(e=>({...e,status:"running"}))},n?.onMessageUpdate?.(t.lastToolMessageRef.current));break}case"tool_execution_update":{let n="string"==typeof e.toolCallId?e.toolCallId:void 0,r=iA(e.partialResult);if(!n||!r)break;let i=t.toolResultsRef.current?.get(n)?.output??"";sc(t,n,{output:i+r}),sp(n,sh(t));break}case"tool_execution_end":{let n="string"==typeof e.toolCallId?e.toolCallId:void 0;if(!n)break;sm(sa.n1.thinking,t),sc(t,n,{output:iA(e.result),isError:!0===e.isError,details:e.details&&"object"==typeof e.details?e.details:void 0}),sp(n,sh(t)),"u">typeof window&&t.fileMutatingCallsRef.current?.delete(n)&&window.dispatchEvent(new CustomEvent(so.s,{detail:{sessionId:t.sessionId}}));break}case"agent_end":{t.setState(e=>({...e,isGenerating:!1})),t.activityRef.current="";let r=function(e,t,n){let r;if(!1===e.isTerminal)return{};let i=e.messages;if(!Array.isArray(i))return{};for(let e of i){if(!e||"object"!=typeof e||Array.isArray(e)||"assistant"!==e.role||"aborted"!==e.stopReason&&"error"!==e.stopReason)continue;let i=iF(e,!1);if(!i)continue;let s=su(i,t);s.toolCalls?.length&&(t.lastToolMessageRef.current=s),n?.onMessageEnd?.(s),"string"==typeof e.errorMessage&&(r=e.errorMessage)}return{errorMessage:r}}(e,t,n??void 0);if(t.interruptPendingRef.current){t.interruptPendingRef.current=!1;break}n?.onAgentEnd?.({errorMessage:r.errorMessage??("string"==typeof e.errorMessage?e.errorMessage:void 0),message:"string"==typeof e.message?e.message:void 0});break}case"prompt_error":{let r="string"==typeof e.errorMessage?e.errorMessage:"Prompt failed";t.setState(e=>({...e,isGenerating:!1,error:r})),t.interruptPendingRef.current=!1,t.activityRef.current="",n?.onPromptError?.(r);break}case"prompt_result":!1===e.agentInvoked&&(t.setState(e=>({...e,isGenerating:!1})),t.activityRef.current="",n?.onPromptSettled?.());break;case"command_output":{let t="string"==typeof e.text?e.text.trim():"";t&&n?.onCommandOutput?.(t);break}case"session_info_update":{let t="string"==typeof e.title?e.title.trim():"";t&&n?.onSessionTitleChanged?.(t);break}case"notice":n?.onNotice?.("string"==typeof e.level?e.level:"info","string"==typeof e.message?e.message:"");break;case"extension_ui_request":n?.onExtensionUiRequest?.(e);break;case"subagent_lifecycle":case"subagent_progress":case"subagent_event":{let n=e.payload;if(null==n||"object"!=typeof n)break;window.dispatchEvent(new CustomEvent(e.type,{detail:{sessionId:t.sessionId,payload:n}}));break}case"model_changed":n?.onModelChanged?.();break;case"thinking_level_changed":var r;t.currentThinkingLevelRef.current="string"==typeof(r=e.thinkingLevel)&&r.trim()?r.trim():"off"}}(i,{sessionId:e,setState:t,callbacksRef:n,toolResultsRef:r,lastToolMessageRef:s,interruptPendingRef:a,activityRef:l,currentThinkingLevelRef:o,fileMutatingCallsRef:c})},onClose:()=>{t(e=>({...e,connected:!1})),(0,sf.dX)({transport:d,connected:!1})}})},[p,t,n,r,s,a,l,o,c,d]),disconnect:p}}({setState:s,callbacksRef:a,toolResultsRef:o,lastToolMessageRef:c,interruptPendingRef:d,activityRef:u,currentThinkingLevelRef:p,fileMutatingCallsRef:m,transport:n});(0,i.vJ)(()=>{if(!e)return;o.current.clear(),m.current.clear(),c.current=null,u.current="";let t=!1;return fetch(`/api/agent/${encodeURIComponent(e)}`).then(e=>e.ok?e.json():null).then(n=>{if(t||!n?.running)return;let r=n.state;for(let t of((n.busy||r?.isStreaming||r?.isPromptRunning)&&(h(e),a.current.onResumeStream?.()),n.pendingUiRequests??[]))a.current.onExtensionUiRequest?.(t)}).catch(()=>{}),()=>{t=!0,f()}},[e,f,h]);let{sendPrompt:x,sendNewPrompt:g}=function(e){let{sessionIdRef:t,connect:n,setState:r}=e;return{sendPrompt:(0,i.hb)(async(e,i,s)=>{let a=t.current;if(!a)return!1;r(e=>({...e,isGenerating:!0,error:null}));try{(await fetch(`/api/agent/${encodeURIComponent(a)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"get_state",...s?.accessMode?{accessMode:s.accessMode}:{}})})).ok&&n(a);let t=await fetch(`/api/agent/${encodeURIComponent(a)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"prompt",message:e,...i?.length?{images:i}:{},...s?.accessMode?{accessMode:s.accessMode}:{}})}),l=await t.json().catch(()=>({}));if(!t.ok||l.error)return r(e=>({...e,isGenerating:!1,error:l.error??`HTTP ${t.status}`})),!1;return window.dispatchEvent(new CustomEvent("omp:session-updated",{detail:{sessionId:a}})),!0}catch(e){return r(t=>({...t,isGenerating:!1,error:e instanceof Error?e.message:String(e)})),!1}},[n,t,r]),sendNewPrompt:(0,i.hb)(async(e,t,i,s)=>{r(e=>({...e,isGenerating:!0,error:null}));try{let a=await fetch("/api/agent/new",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"ensure_session",cwd:t,...s?.model?s.model:{},...s?.thinkingLevel?{thinkingLevel:s.thinkingLevel}:{},...s?.accessMode?{accessMode:s.accessMode}:{}})}),l=await a.json().catch(()=>({}));if(!a.ok||!l.sessionId)return r(e=>({...e,isGenerating:!1,error:l.error??`HTTP ${a.status}`})),null;let o=l.sessionId;n(o);let c=await fetch(`/api/agent/${encodeURIComponent(o)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"prompt",message:e,...i?.length?{images:i}:{}})}),d=await c.json().catch(()=>({}));if(!c.ok||d.error)return r(e=>({...e,isGenerating:!1,error:d.error??`HTTP ${c.status}`})),null;return window.dispatchEvent(new CustomEvent("omp:session-updated",{detail:{sessionId:o}})),{sessionId:o,model:l.model??null}}catch(e){return r(t=>({...t,isGenerating:!1,error:e instanceof Error?e.message:String(e)})),null}},[n,r])}}({sessionIdRef:l,connect:h,setState:s}),b=(0,i.hb)(async()=>{let e=l.current;e&&(d.current=!1,await sb(e),s(e=>({...e,isGenerating:!1})))},[]),v=(0,i.hb)(async(e,t)=>{let n=l.current;if(!n)return!1;d.current=!0,s(e=>({...e,isGenerating:!0,error:null}));try{let r=await fetch(`/api/agent/${encodeURIComponent(n)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"abort_and_prompt",message:e,...t?.length?{images:t}:{}})}),i=await r.json().catch(()=>({}));if(!r.ok||i.error)return d.current=!1,s(e=>({...e,isGenerating:!1,error:i.error??`HTTP ${r.status}`})),!1;return!0}catch(e){return d.current=!1,s(t=>({...t,isGenerating:!1,error:e instanceof Error?e.message:String(e)})),!1}},[]),k=(0,i.hb)(async(e,t)=>{let n=l.current;if(!n)return!1;try{let r=await fetch(`/api/agent/${encodeURIComponent(n)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"follow_up",message:e,...t?.length?{images:t}:{}})}),i=await r.json().catch(()=>({}));if(!r.ok||i.error)return s(e=>({...e,error:i.error??`HTTP ${r.status}`})),!1;return!0}catch(e){return s(t=>({...t,error:e instanceof Error?e.message:String(e)})),!1}},[]),y=(0,i.hb)(async(e,t)=>{let n=l.current;if(n)try{await fetch(`/api/agent/${encodeURIComponent(n)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"set_model",provider:e,modelId:t})})}catch{}},[]),w=(0,i.hb)(async e=>{let t=l.current;if(t)try{await fetch(`/api/agent/${encodeURIComponent(t)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"set_thinking_level",level:e})})}catch{}},[]),N=(0,i.hb)(async(e,t)=>{let n=l.current;if(n)try{await fetch(`/api/agent/${encodeURIComponent(n)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"extension_ui_response",id:e.id,...t})})}catch{}},[]);return{...r,sendPrompt:x,sendNewPrompt:g,sendInterruptAndReply:v,sendFollowUp:k,abort:b,setModel:y,setThinkingLevel:w,respondToExtensionUi:N,disconnect:f}}(J?l:null,function(e){var t;let{setGenerating:n,setGeneratingVerb:r,scrollToBottom:i,adoptedSessionIdRef:s,sessionIdRef:a,metaRefreshedRef:l,firstAssistantRef:o,refreshSessionMeta:c,setLocalMessages:d,aiPlaceholderIdRef:u,optimisticUserIdRef:p,pendingUserDisplaysRef:m,persistMessages:h,abortControllerRef:f,appSettings:x,enqueueExtensionDialog:g,withdrawExtensionDialog:b}=e;return t=()=>i("smooth"),sP=d,sI=t,{onAgentStart:()=>{n(!0),r(sa.n1.thinking),setTimeout(()=>i("smooth"),50),o.current=!1;let e=s.current??a.current;e&&(window.dispatchEvent(new CustomEvent("omp:session-updated",{detail:{sessionId:e}})),l.current!==e&&(l.current=e,setTimeout(()=>c(e),100)))},onTurnStart:()=>{let e=s.current??a.current;e&&"u">typeof window&&window.dispatchEvent(new CustomEvent("omp:session-updated",{detail:{sessionId:e}}))},onResumeStream:()=>{n(!0),r(sa.n1.thinking),setTimeout(()=>i("smooth"),50),o.current=!1;let e=s.current??a.current;e&&window.dispatchEvent(new CustomEvent("omp:session-updated",{detail:{sessionId:e}}))},onActivity:e=>{r(e)},onMessageUpdate:e=>{var t;"user"===e.role||r1(e)||(p.current=null),t=e.id,sR.queue(t=>{let n=u.current;if(r1(e)){if(t.some(t=>t.id===e.id))return t;if(n&&t.some(e=>e.id===n)){let r=t.findIndex(e=>e.id===n);return[...t.slice(0,r),e,...t.slice(r)]}return[...t,e]}if("user"===e.role){if(t.some(t=>t.id===e.id))return t;let r=p.current;if(r){let n=t.findIndex(e=>e.id===r);if(-1!==n){let r={...e,id:e.id,content:t[n].content,date:t[n].date,attachments:e.attachments?.length?e.attachments:t[n].attachments};return[...t.slice(0,n),r,...t.slice(n+1)]}}let i=m.current.find(t=>e.content===t.sent||e.content.startsWith(t.sent)||t.sent.startsWith(e.content)),s=i?{...e,content:i.display}:e;if(n&&t.some(e=>e.id===n)){let e=t.findIndex(e=>e.id===n);return[...t.slice(0,e),s,...t.slice(e)]}return[...t,s]}if(n&&t.some(e=>e.id===n))return t.map(t=>t.id===n?e:t);let r=t.findIndex(t=>t.id===e.id);return -1!==r?[...t.slice(0,r),e,...t.slice(r+1)]:[...t,e]},t)},onMessageEnd:e=>{if("ai"===e.role&&!r1(e)&&!o.current){o.current=!0;let e=s.current??a.current;e&&"u">typeof window&&window.dispatchEvent(new CustomEvent("omp:session-updated",{detail:{sessionId:e}}))}sR.flush(),"user"!==e.role&&(p.current=null),d(t=>{let n,r=u.current;if("user"===e.role){let n,i=p.current;if(t.some(t=>t.id===e.id))n=t.map(t=>t.id===e.id?e:t);else if(i&&t.some(e=>e.id===i))n=t.map(t=>t.id===i?{...e,id:e.id,content:t.content,date:t.date,attachments:e.attachments?.length?e.attachments:t.attachments}:t);else if(r&&t.some(e=>e.id===r)){let i=t.findIndex(e=>e.id===r);n=[...t.slice(0,i),e,...t.slice(i)]}else n=[...t,e];return h(n),n}if(r&&t.some(e=>e.id===r))n=t.map(t=>t.id===r?e:t);else{let r=t.findIndex(t=>t.id===e.id);n=-1!==r?[...t.slice(0,r),e,...t.slice(r+1)]:[...t,e]}return u.current=null,h(n),n})},onAgentEnd:()=>{sO(),n(!1),f.current=null,p.current=null,m.current=[],(0,s$.s4)(x),setTimeout(()=>i("smooth"),50);let e=s.current??a.current;e&&c(e)},onModelChanged:()=>{let e=s.current??a.current;e&&setTimeout(()=>c(e),150)},onPromptError:e=>{n(!1),f.current=null,console.error("OMP prompt error:",e)},onPromptSettled:()=>{sO(),n(!1),f.current=null,p.current=null;let e=u.current;u.current=null,e&&d(t=>t.some(t=>t.id===e)?t.filter(t=>t.id!==e):t)},onCommandOutput:e=>{let t={id:`cmdout-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,role:"ai",content:"",notice:e};d(n=>{let r=u.current;if(r){let e=n.findIndex(e=>e.id===r);if(-1!==e)return[...n.slice(0,e),t,...n.slice(e)]}return n.some(t=>t.notice===e)?n:[...n,t]})},onSessionTitleChanged:()=>{let e=s.current??a.current;e&&c(e)},onNotice:(e,t)=>{console.info("OMP notice:",t)},onExtensionUiRequest:e=>{"select"===e.method||"confirm"===e.method||"input"===e.method||"editor"===e.method?g(e):"cancel"===e.method&&b(e.targetId)}}}({setGenerating:M,setGeneratingVerb:z,scrollToBottom:b,adoptedSessionIdRef:U,sessionIdRef:L,metaRefreshedRef:P,firstAssistantRef:I,refreshSessionMeta:K,setLocalMessages:D,aiPlaceholderIdRef:_,optimisticUserIdRef:R,pendingUserDisplaysRef:O,persistMessages:eu,abortControllerRef:j,appSettings:n,enqueueExtensionDialog:ev,withdrawExtensionDialog:ey}),(0,i4.ul)(n)),{steerOmpAgent:eN,executeSend:eY}=function(e){let{folders:t,selectedFolderId:n,sessionId:r,isOmpSession:s,appSettings:a,ompAgent:l,setLocalMessages:o,persistMessages:c,setGenerating:d,setGeneratingVerb:u,scrollToBottom:p,jumpToBottom:m,aiPlaceholderIdRef:h,adoptedSessionIdRef:f,optimisticUserIdRef:x,pendingUserDisplaysRef:g,seedSession:b,pendingComposerModelRef:v,pendingThinkingLevelRef:k,deferredComposerPickRef:y,accessModeRef:w,abortControllerRef:N,setInputValue:Y,setSearchParams:D}=e,A=(0,i.hb)(async(e,t)=>{let n=await eR(t),r=await sT(e,n);g.current=[...g.current.slice(-7),{sent:r,display:e}];let i=t.map(eP).filter(e=>null!==e);return{promptText:r,images:i.length?i:void 0}},[]);return{steerOmpAgent:(0,i.hb)(async(e,t)=>{await eG(l,y);let{promptText:n,images:r}=await A(e,t);await l.sendInterruptAndReply(n,r)||Y(e)},[l,A,Y,y]),executeSend:(0,i.hb)(async(e,i,g)=>{let Y=g?.model??null,A=Y?.accessMode??w.current,F=nY(),C=`msg-${Date.now()}-user`,S=`msg-${Date.now()+1}-ai`,T=await eR(i),$=new Map(T.map(e=>[e.id,e.content])),z=Date.now(),j={id:C,role:"user",date:`Today, ${F}`,startedAt:z,content:e,attachments:i.map(e=>({name:ej(e),preview:e.dataBase64?`data:${eL(e)};base64,${e.dataBase64}`:e.preview,type:eL(e),size:eM(e),content:$.get(e.id)}))},L={id:S,role:"ai",date:`Today, ${F}`,startedAt:z,content:""};if(o(e=>{let t=[...e,j,L];return c(t.filter(e=>e.id!==S)),t}),d(!0),u(sa.n1.thinking),setTimeout(()=>m("smooth"),50),s){h.current=S,x.current=C,Y||await eG(l,y),Y&&(await l.setModel(Y.provider,Y.modelId),"auto"!==Y.thinkingLevel&&await l.setThinkingLevel(Y.thinkingLevel));let t=i.map(eP).filter(e=>null!==e),n=await sT(e,T);await l.sendPrompt(n,t.length?t:void 0,{accessMode:A})||(o(e=>e.filter(e=>e.id!==C&&e.id!==S)),h.current=null,x.current=null,d(!1));return}if(!s){let r=t.find(e=>String(e.id)===String(n)),s=r?.project_path||r?.name;if(s){let t=i.map(eP).filter(e=>null!==e),n=await sT(e,T);x.current=C;let r=v.current,a=k.current,o=await l.sendNewPrompt(n,s,t.length?t:void 0,{model:r,thinkingLevel:a,accessMode:w.current});if(o){f.current=o.sessionId,h.current=S,b({model:o.model,thinkingLevel:a}),v.current=null,k.current=null,fetch(`/api/chat/${encodeURIComponent(o.sessionId)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messages:[j]})}).catch(e=>console.error("Error persisting spawned user turn:",e)),D(e=>{let t=new URLSearchParams(e);return t.set("sessionId",o.sessionId),t},{replace:!0});return}}}x.current=null,N.current&&N.current.abort();let M=new AbortController;N.current=M;let E=t.find(e=>String(e.id)===String(n)),P=E?.name||"Workspace";await sY({sessionId:r||`session-${Date.now()}`,prompt:e,workspaceName:P,attachments:i,signal:M.signal},function(e){let{aiPlaceholderId:t,setLocalMessages:n,persistMessages:r,setGenerating:i,setGeneratingVerb:s,abortControllerRef:a,appSettings:l,scrollToBottom:o}=e,c=!1,d=sz(e=>n(e),()=>{c&&(c=!1,o("smooth"))}),u=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];t&&(c=!0),d.queue(e)};return{onInit:e=>{u(n=>n.map(n=>n.id===t?{...n,id:e.id,date:e.date}:n))},onThinkingStart:()=>{s(sa.n1.thinking),u(e=>e.map(e=>e.id===t||"ai"===e.role?{...e,thinking:{thought:"",isGenerating:!0}}:e)),setTimeout(()=>o("smooth"),50)},onThinkingChunk:e=>{u(n=>n.map(r=>{if(r.id===t||"ai"===r.role&&n[n.length-1]?.id===r.id){let t="object"==typeof r.thinking&&r.thinking.thought||"";return{...r,thinking:{thought:t+e.delta,isGenerating:!0}}}return r}),!0)},onThinkingEnd:e=>{u(n=>n.map(r=>r.id===t||"ai"===r.role&&n[n.length-1]?.id===r.id?{...r,thinking:{thought:e.thought,summary:e.summary,duration:e.duration,isGenerating:!1}}:r))},onToolStart:e=>{s(sl({name:e.name??e.type,input:e.input,command:e.command,target:e.target,intent:e.intent})),u(n=>n.map(r=>r.id===t||"ai"===r.role&&n[n.length-1]?.id===r.id?{...r,toolCalls:[...r.toolCalls||[],e]}:r)),setTimeout(()=>o("smooth"),50)},onToolOutputChunk:e=>{u(n=>n.map(r=>r.id===t||"ai"===r.role&&n[n.length-1]?.id===r.id?{...r,toolCalls:(r.toolCalls||[]).map(t=>t.id===e.id?{...t,output:(t.output||"")+e.delta}:t)}:r),!0)},onToolEnd:e=>{s(sa.n1.thinking),u(n=>n.map(r=>r.id===t||"ai"===r.role&&n[n.length-1]?.id===r.id?{...r,toolCalls:(r.toolCalls||[]).map(t=>t.id===e.id?{...t,...e}:t)}:r))},onContentChunk:e=>{s(sa.n1.writing),u(n=>n.map(r=>r.id===t||"ai"===r.role&&n[n.length-1]?.id===r.id?{...r,content:(r.content||"")+e.delta}:r),!0)},onSummary:e=>{u(n=>n.map(r=>r.id===t||"ai"===r.role&&n[n.length-1]?.id===r.id?{...r,summary:e.summary}:r))},onDone:e=>{d.flush(),n(n=>{let i=n.map(r=>r.id===t||"ai"===r.role&&n[n.length-1]?.id===r.id?e.message:r);return r(i),i}),i(!1),a.current=null,(0,s$.s4)(l),setTimeout(()=>o("smooth"),50)},onError:()=>{i(!1),a.current=null}}}({aiPlaceholderId:S,setLocalMessages:o,persistMessages:c,setGenerating:d,setGeneratingVerb:u,abortControllerRef:N,appSettings:a,scrollToBottom:p}))},[a,t,s,l,n,r,p,m,c,b,v,k,y,w])}}({folders:t,selectedFolderId:c,sessionId:l,isOmpSession:J,appSettings:n,ompAgent:ew,setLocalMessages:D,persistMessages:eu,setGenerating:M,setGeneratingVerb:z,scrollToBottom:b,jumpToBottom:v,aiPlaceholderIdRef:_,adoptedSessionIdRef:U,optimisticUserIdRef:R,pendingUserDisplaysRef:O,seedSession:q,pendingComposerModelRef:en,pendingThinkingLevelRef:er,deferredComposerPickRef:es,accessModeRef:eo,abortControllerRef:j,setInputValue:y,setSearchParams:a}),{handleSend:eD,handleEditQueueItem:eA,handleSendNowQueueItem:eF,handleUndo:eC,handleRetry:eS,submitNewChat:eT,stopGenerating:e$,handleThinkingLevelChange:ez,handleModelChange:eE}=function(e){let{inputValue:t,setInputValue:n,setInputAttachments:r,isGenerating:s,isOmpSession:a,sessionId:l,appSettings:o,messageQueue:c,enqueueMessage:d,removeMessage:u,executeSend:p,steerOmpAgent:m,ompAgent:h,abortControllerRef:f,setGenerating:x,stopHoldRef:g,persistMessages:b,setLocalMessages:v,pendingComposerModelRef:k,pendingThinkingLevelRef:y,composerModelRef:w,deferredComposerPickRef:N,accessModeRef:Y,setSearchParams:D}=e,A=(0,i.hb)(async(e,r)=>{let i=t.trim();if(i||0!==e.length){if(g.current=!1,function(e,t){let n=sw.exec(e);if(!n)return!1;let r=t.map(e=>eP(e)).filter(e=>null!==e);return window.dispatchEvent(new CustomEvent("omp:btw",{detail:{question:n[1]?.trim()??"",...r.length?{images:r}:{}}})),!0}(i,e))return void n("");if(s){if(r?.steering){n(""),a?await m(i,e):(f.current&&(f.current.abort(),f.current=null),x(!1),p(i,e));return}if("steering"===(o.omp_chamber_settings?.followUpBehavior??o.followUpBehavior??"queue")&&a){n(""),await m(i,e);return}let t=w.current,s=t?{...t,accessMode:Y.current}:null;n(""),eI(e).then(e=>{d({text:i,attachments:e,model:s})});return}n(""),p(i,e)}},[t,s,p,d,a,o,m,n,f,x,g,w,Y]),F=(0,i.hb)(e=>{n(e.text),r(e.attachments),u(e.id)},[u,n,r]),C=(0,i.hb)(async e=>{g.current=!1,u(e.id),s?a?m(e.text,e.attachments):(f.current&&(f.current.abort(),f.current=null),x(!1),setTimeout(()=>p(e.text,e.attachments,{model:e.model}),0)):p(e.text,e.attachments,{model:e.model})},[s,p,u,a,m,f,x,g]),S=(0,i.hb)(async(e,t)=>{if(s&&(a?h.abort():f.current&&(f.current.abort(),f.current=null),x(!1)),t&&n(t),a&&l){if(!(await fetch(`/api/chat/${encodeURIComponent(l)}/rewind`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({entryId:e})})).ok)return!1;let t=await fetch(`/api/chat/${encodeURIComponent(l)}`).then(e=>e.json()).catch(()=>null),n=t?.session?.messages??[];return n.length>0&&v(n),!0}return v(t=>{let n=t.findIndex(t=>t.id===e),r=-1!==n?t.slice(0,n):t;return b(r),r}),!0},[s,a,l,b,f,x,n,v]),T=(0,i.hb)(e=>{s&&(a?h.abort():f.current&&(f.current.abort(),f.current=null),x(!1)),v(t=>{let n=t.findIndex(t=>t.id===e);if(n>0&&"user"===t[n-1].role){let e=t[n-1];setTimeout(()=>{let t=Array.isArray(e.attachments)?e.attachments:[];p(e.content,t)},0);let r=t.slice(0,n-1);return b(r),r}return t})},[s,p,b,a,h,f,x,v]),$=(0,i.hb)((e,t)=>{let n=`new-${Date.now()}`;D(e=>{let t=new URLSearchParams(e);return t.set("sessionId",n),t},{replace:!0}),v([]),setTimeout(()=>{p(e,t)},0)},[D,p,v]),z=(0,i.hb)(()=>(g.current=!0,a?h.abort():f.current&&(f.current.abort(),f.current=null),x(!1),c.length),[a,h,f,x,c.length,g]);return{handleSend:A,handleEditQueueItem:F,handleSendNowQueueItem:C,handleUndo:S,handleRetry:T,submitNewChat:$,stopGenerating:z,handleThinkingLevelChange:(0,i.hb)(e=>{if("auto"!==e){if(!a){y.current=e;return}if(s)return void eq(N,{thinkingLevel:e});eB(N,{thinkingLevel:e}),h.setThinkingLevel(e)}},[s,a,h,y,N]),handleModelChange:(0,i.hb)((e,t)=>{if(!a){k.current={provider:e,modelId:t};return}s?eq(N,{provider:e,modelId:t}):(eB(N,{provider:e,modelId:t}),eH(h,{provider:e,modelId:t}))},[s,a,h,k,N])}}({inputValue:k,setInputValue:y,setInputAttachments:N,isGenerating:F,isOmpSession:J,sessionId:l,appSettings:n,messageQueue:ep,enqueueMessage:em,removeMessage:eh,executeSend:eY,steerOmpAgent:eN,ompAgent:ew,abortControllerRef:j,setGenerating:M,stopHoldRef:E,persistMessages:eu,setLocalMessages:D,pendingComposerModelRef:en,pendingThinkingLevelRef:er,composerModelRef:ei,deferredComposerPickRef:es,accessModeRef:eo,setSearchParams:a});return{sessionId:l,folderId:o,isOmpSession:J,selectedFolderId:c,setSelectedFolderId:u,sessionData:W,localMessages:Y,isGenerating:F,hasMore:B,loadingOlder:H,loadOlderError:G,sessionLoading:V,loadOlder:Z,userTurns:X,jumpingTurn:ee,jumpToUserTurn:et,generatingVerb:$,messageQueue:ep,removeMessage:eh,reorderMessages:ef,steeringQueue:ex,setSteeringQueue:eg,inputValue:k,setInputValue:y,inputAttachments:w,setInputAttachments:N,scrollRef:m,contentRef:h,showScrollBottom:f,isScrolling:x,handleScroll:g,scrollToBottom:b,jumpToBottom:v,handleSend:eD,handleEditQueueItem:eA,handleSendNowQueueItem:eF,handleUndo:eC,handleRetry:eS,submitNewChat:eT,stopGenerating:e$,handleThinkingLevelChange:ez,handleModelChange:eE,accessMode:ea,handleAccessModeChange:ec,composerModelRef:ei,deferredComposerPickRef:es,extensionDialogs:eb,resolveExtensionDialog:ek,respondToExtensionUi:ew.respondToExtensionUi}}({folders:c,appSettings:n}),{toasts:ea,pushToast:el,dismissToast:eo}=(0,sq.Y)(),{framesByTool:ec,modalRequest:eu}=(0,i.Kr)(()=>(function(e,t){let n=new Map;if(0===t.length)return{framesByTool:n,modalRequest:null};let r=new Map;for(let t of e)for(let e of t.toolCalls??[]){if("ask"!==("string"==typeof e.name&&e.name?e.name:e.type)&&"ask"!==e.title)continue;let t=h(e);t.length>0&&r.set(e.id,t)}let i=new Map,s=new Set,a=null;for(let e of t){let t="string"==typeof e.title?p(e.title):"",n=null;if(t){for(let[e,i]of r)if(i.some(e=>p(e.question)===t)){n=e;break}}n||"confirm"===e.method||(n=a),n&&(s.add(e),a=n,i.set(n,[...i.get(n)??[],e]))}for(let[e,t]of i)n.set(e,function(e,t){let n=e.map(()=>[]);if(0===e.length)return n;let r=e.map(e=>p(e.question)),i=0;for(let e of t){let t="string"==typeof e.title?p(e.title):"",s=r.indexOf(t);s>i?i=s:-1===s&&"select"===e.method&&n[i].some(e=>"select"===e.method)&&i+1<n.length&&(i+=1),n[i].push(e)}return n}(r.get(e)??[],t));return{framesByTool:n,modalRequest:t.find(e=>!s.has(e))??null}})(g,er),[g,er]),ep=(0,i.hb)((e,t)=>{es(e,t),ei(e.id)},[es,ei]),em=(0,i.Kr)(()=>({framesByTool:ec,respond:ep}),[ec,ep]),[eh,ef]=(0,i.J0)(null),{pendingUndo:ex,undoing:eg,requestUndo:eb,closeUndoConfirm:ev,confirmUndo:ek}=function(e){let[t,n]=(0,i.J0)(null),[r,s]=(0,i.J0)(!1),a=(0,i.hb)((e,t)=>{n({id:e,content:t??""})},[]),l=(0,i.hb)(()=>n(null),[]),o=(0,i.hb)(async()=>{!t||r||(s(!0),await e(t.id,t.content)&&n(null),s(!1))},[e,t,r]);return{pendingUndo:t,undoing:r,requestUndo:a,closeUndoConfirm:l,confirmUndo:o}}(B),[ey,ew]=(0,s.o)(),eN=(0,i.hb)(()=>{let e=V();0!==e&&el(`Stopped. ${e} message${e>1?"s":""} still queued — nothing was sent.`,"success",{action:{label:"Send now",onClick:()=>{let e=S[0];e&&q(e)}},duration:8e3})},[V,el,S,q]),{activeSubagent:eY,back:eD}=function(e,t,n){let[r,s]=(0,i.J0)(null);return(0,i.vJ)(()=>{let e=e=>{let t=e.detail,r=t?.subagent,i=t?.sessionId;r&&i&&(s(r),n(e=>(e.get("sessionId")===i&&e.get("subagent")===r.id||(e.set("sessionId",i),e.set("subagent",r.id)),e),{replace:!1}))};return window.addEventListener("omp:view-subagent",e),()=>window.removeEventListener("omp:view-subagent",e)},[n]),(0,i.vJ)(()=>{if(!t)return void s(null);if(r?.id===t||!e)return;let n=!1;return fetch(`/api/sessions/${encodeURIComponent(e)}/subagents`).then(e=>e.ok?e.json():null).then(e=>{if(n||!e?.subagents)return;let r=e.subagents.find(e=>(0,n3.u)(e)&&e.id===t);r&&s((0,sU.Nh)(r))}).catch(()=>{}),()=>{n=!0}},[e,t]),{activeSubagent:r,back:(0,i.hb)(()=>{s(null),n(e=>(e.has("subagent")&&e.delete("subagent"),e),{replace:!0})},[n])}}(u,ey.get("subagent"),ew);!function(e,t,n){let[r,s]=(0,i.J0)(null);(0,i.vJ)(()=>{s(null)},[e]),(0,i.vJ)(()=>{let t=t=>{let n=t.detail;n?.sessionId&&n.title&&String(n.sessionId)===String(e)&&s(n.title)};return window.addEventListener("omp:session-renamed",t),()=>window.removeEventListener("omp:session-renamed",t)},[e]),(0,i.vJ)(()=>{let i=(0,sW.fN)(e)?(0,sW.g2)(e):null;n?.(i??r??t??null)},[e,t,r,n])}(u,x?.title,a);let eA=(0,i.hb)(e=>{F(e.id,e.index)},[F]),eF=(0,i.hb)(e=>ef(e),[]),eC=iP(iI)??{},eS=iP(sK)??{},eT="object"==typeof x?.model?x.model.provider:void 0,e$="object"==typeof x?.model?eC[x.model.modelId]??x.model.modelId:x?.model,ez=!!u?.startsWith("new-"),eE=(0,sH.M)(c,u,m),eO=!ez&&N&&0===g.length;return!u||ez?(0,r.Y)(io,{className:t,folders:c,selectedFolderId:m,setSelectedFolderId:f,rootPath:eE,inputValue:L,setInputValue:M,inputAttachments:E,setInputAttachments:P,onSend:U,isGenerating:b,appSettings:n,messages:g,provider:eT,providerNames:eS,modelName:e$,modelNames:eC,onThinkingLevelChange:Z,onModelChange:Q,accessMode:X,onAccessModeChange:ee,composerModelRef:et,deferredComposerPickRef:en,sessionModel:"object"==typeof x?.model?x.model:null,sessionThinkingLevel:x?.thinkingLevel,generatingVerb:C,variant:l}):(0,r.Y)(y.Provider,{value:em,children:(0,r.FD)("div",{className:`flex flex-col h-full min-h-0 overflow-hidden bg-canvas relative ${t}`,children:[eO?(0,r.Y)(iu,{}):(0,r.FD)(r.FK,{children:[(0,r.Y)("div",{className:"relative flex-1 min-h-0 flex flex-col",children:eY?(0,r.Y)(iJ,{sessionId:u,subagent:eY,onBack:eD,provider:eT,providerNames:eS}):(0,r.Y)(iK,{isMobile:d,userTurns:D,jumpingTurn:A,onJumpTurn:eA,scrollRef:I,contentRef:R,handleScroll:_,isScrolling:J,loadingOlder:k,hasMore:v,loadOlderError:w,loadOlder:Y,messages:g,isGenerating:b,provider:eT,providerNames:eS,modelName:e$,modelNames:eC,thinkingLevel:x?.thinkingLevel,onUndo:eb,onRetry:H,onNewChat:eF,showScrollBottom:O,jumpToBottom:W})}),!eY&&(0,r.Y)(ss,{isMobile:d,sessionId:u,isGenerating:b,modelName:e$,generatingVerb:C,provider:eT,providerNames:eS,messageQueue:S,onRemoveQueueItem:T,onReorderQueue:$,onEditQueueItem:K,onSendNowQueueItem:q,steeringQueue:z,setSteeringQueue:j,inputValue:L,setInputValue:M,rootPath:eE,attachments:E,setAttachments:P,onSend:U,onStop:eN,appSettings:n,onThinkingLevelChange:Z,onModelChange:Q,accessMode:X,onAccessModeChange:ee,composerModelRef:et,deferredComposerPickRef:en,sessionModel:"object"==typeof x?.model?x.model:null,sessionThinkingLevel:x?.thinkingLevel,variant:l})]}),ex&&(0,r.Y)(im,{isOmpSession:!!u&&!u.startsWith("new-")&&Number.isNaN(Number(u)),content:ex.content,undoing:eg,onClose:ev,onConfirm:ek}),null!==eh&&(0,r.Y)(ih,{initialContent:eh,onClose:()=>ef(null),onSend:G,appSettings:n,accessMode:X,onAccessModeChange:ee,composerModelRef:et}),eu&&(0,r.Y)(o,{request:eu,onRespond:ep}),(0,r.Y)(sB.y,{toasts:ea,onDismiss:eo})]})})}},A9(e,t,n){n.d(t,{O:()=>d,k:()=>u});var r=n("j"),i=n("H"),s=n("G"),a=n("X"),l=n("Af"),o=n("ng");let c=(0,s.q6)(null);function d(e){var t;let n,{children:s,initialFolders:d=[]}=e,u=(0,a.L)(),[p,m]=(0,i.J0)(!1),h=(0,i.li)(!1),f=(0,i.li)(new Set);(0,i.vJ)(()=>{h.current||(h.current=!0,u.load("/api/sessions/list"))},[]),(0,i.vJ)(()=>{u.data&&m(!0)},[u.data]);let x=(0,i.Kr)(()=>()=>{"idle"===u.state&&u.load("/api/sessions/list")},[u]),g=!!u.data?.folders?.some(e=>e.sessions?.some(e=>"stream"===e.streamStatus));t=u.data?.folders??[],n=(0,i.li)(null),(0,i.vJ)(()=>{let e=new Set;for(let n of t)for(let t of n.sessions??[])t.awaitingInput&&e.add(String(t.id));let r=n.current;if(n.current=e,r){for(let t of e)if(!r.has(t))return void(0,o.Rn)()}},[t]),(0,l.n)(x,!g,3e4);let b=(0,i.hb)(e=>{let t=String(e),n=u.data?.folders?.flatMap(e=>e.sessions??[]).find(e=>String(e.id)===t)?.streamStatus;!n||"stream"===n||f.current.has(t)||(f.current.add(t),fetch(`/api/sessions/${encodeURIComponent(t)}/stream-seen`,{method:"POST"}).then(()=>{"idle"===u.state&&u.load("/api/sessions/list")}).catch(()=>{f.current.delete(t)}))},[u]),v=(0,i.Kr)(()=>{let e=u.data,t=f.current;if(t.size&&e?.folders)for(let n of e.folders)for(let e of n.sessions??[])"stream"===e.streamStatus&&t.delete(String(e.id));return{folders:(e?.folders??d).map(e=>t.size?{...e,sessions:(e.sessions??[]).map(e=>t.has(String(e.id))&&e.streamStatus&&"stream"!==e.streamStatus?{...e,streamStatus:void 0}:e)}:e),isMock:e?.isMock??!1,initializing:!p,refresh:x,markSeen:b,hasSeen:e=>t.has(String(e))}},[u.data,d,p,x,b]);return(0,r.Y)(c.Provider,{value:v,children:s})}function u(){let e=(0,i.NT)(c);return e||{folders:[],isMock:!1,initializing:!0,refresh:()=>{},markSeen:()=>{},hasSeen:()=>!1}}},z4(e,t,n){n.d(t,{K:()=>f});var r=n("H"),i=n("s");function s(e){let t=-1/0;for(let n of e.sessions??[]){let e=function(e){if(!e)return 0/0;let t=Date.parse(e);return Number.isFinite(t)?t:0/0}(n.updated_at??n.created_at);e>t&&(t=e)}return t}function a(e){let t=-1/0;for(let n of e.sessions??[]){let e=Number(n.id);Number.isFinite(e)&&e>t&&(t=e)}return t}function l(e){let t=Number(e.id);return Number.isFinite(t)?t:-1/0}function o(e,t){return e===t?0:e>t?-1:1}function c(e,t){return e===t?0:e>t?1:-1}let d=["A-Z","Z-A","LATEST_SESSION","LATEST_ADDED"];var u=n("Np"),p=n("A9"),m=n("NO"),h=n("So");function f(){let e,t,n,f,x,g,b,v,k,y,w=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},N=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{includePendingSessions:Y=!1,onSelectSession:D,onAfterSelect:A}=N,{folders:F,initializing:C,refresh:S,markSeen:T,hasSeen:$}=(0,p.k)(),[z,j]=(0,i.o)(),L=z.get("sessionId"),M=L?Number.isNaN(Number(L))?L:Number(L):null,E=(0,r.li)(S);E.current=S;let P=(0,r.hb)(()=>E.current(),[]);(e=(0,r.li)(P)).current=P,t=(0,r.li)(void 0),n=(0,r.li)(0),(0,r.vJ)(()=>{let r=()=>{n.current=Date.now(),e.current()},i=()=>{let e=Date.now()-n.current;if(e>=1e3){clearTimeout(t.current),t.current=void 0,r();return}clearTimeout(t.current),t.current=setTimeout(()=>{t.current=void 0,r()},1e3-e)};return window.addEventListener("omp:session-updated",i),()=>{window.removeEventListener("omp:session-updated",i),void 0!==t.current&&(clearTimeout(t.current),t.current=void 0)}},[]),(0,m.sY)("omp:workspace-updated",()=>E.current());let[I,R]=(0,r.J0)(""),[O,J]=(0,r.J0)(!1),[_,W]=(0,r.J0)(!1),[U,K]=(0,r.J0)(()=>{var e;return"string"==typeof(e=w.omp_sidebar_sort)&&d.includes(e)?w.omp_sidebar_sort:"A-Z"}),q=(0,r.li)(null),B=(0,r.hb)(e=>{q.current&&clearTimeout(q.current),q.current=setTimeout(()=>{(0,h.cz)("omp_sidebar_sort",e)},200)},[]);(0,r.vJ)(()=>()=>{q.current&&clearTimeout(q.current)},[]);let H=(0,r.Kr)(()=>(function(e){let t={};for(let n of e)for(let e of n.sessions??[])e.streamStatus&&(t[String(e.id)]=e.streamStatus);return t})(F),[F]);x=null!==(f=null===M?null:String(M))?H[f]:void 0,g=(0,r.li)(null),(b=(0,r.li)(P)).current=P,(v=(0,r.li)($)).current=$,(0,r.vJ)(()=>{if(!x||"stream"===x||v.current?.(f))return;let e=`${f}:${x}`;g.current!==e&&(g.current=e,fetch(`/api/sessions/${encodeURIComponent(f)}/stream-seen`,{method:"POST"}).then(e=>e.json()).then(e=>{!1===e.deleted&&(g.current=null),b.current()}).catch(()=>{g.current=null}))},[f,x]),(k=(0,r.li)(Object.values(H).includes("stream"))).current=Object.values(H).includes("stream"),(y=(0,r.li)(P)).current=P,(0,r.vJ)(()=>{let e=setInterval(()=>{k.current&&y.current()},8e3);return()=>clearInterval(e)},[]);let G=(0,r.Kr)(()=>{let e=[...F];if(Y){let t=e.some(e=>e.sessions?.some(e=>String(e.id)===String(L))),n=L&&!t?L:null;if(n){let t=z.get("folderId"),r=t?e.find(e=>String(e.id)===String(t)):e[0],i=!!r?.sessions?.some(e=>String(e.id)===String(n));if(r&&!i){let t=(0,u.fd)(n),i=Number.isFinite(t)?new Date(t).toISOString():new Date().toISOString();e=e.map(e=>{if(e.id!==r.id)return e;let t={id:n,folder_id:e.id,title:(0,u.g2)(n),created_at:i,updated_at:i};return{...e,isExpanded:!0,sessions:[t,...e.sessions||[]]}})}}}if(I.trim()){let t=I.toLowerCase();e=Y?e.filter(e=>{let n=e.name.toLowerCase().includes(t),r=e.sessions?.some(e=>e.title.toLowerCase().includes(t));return n||r}).map(e=>{let n=e.sessions?.filter(n=>e.name.toLowerCase().includes(t)||n.title.toLowerCase().includes(t));return{...e,sessions:n,isExpanded:!0}}):e.map(e=>{let n=e.name.toLowerCase().includes(t),r=(e.sessions||[]).filter(e=>e.title.toLowerCase().includes(t));return n?e:{...e,sessions:r}}).filter(e=>e.sessions&&e.sessions.length>0)}return e=[...e].sort((e,t)=>(function(e,t,n){let r=!!e.isPinned;if(r!==!!t.isPinned)return r?-1:1;switch(n){case"Z-A":{let n=t.name.localeCompare(e.name);return 0!==n?n:c(l(e),l(t))}case"LATEST_SESSION":{let n=o(s(e),s(t));if(0!==n)return n;let r=o(a(e),a(t));if(0!==r)return r;let i=o(l(e),l(t));return 0!==i?i:e.name.localeCompare(t.name)}case"LATEST_ADDED":{let n=o(l(e),l(t));return 0!==n?n:e.name.localeCompare(t.name)}default:{let n=e.name.localeCompare(t.name);return 0!==n?n:c(l(e),l(t))}}})(e,t,U))},[F,I,U,L,z,Y]);return{folders:F,initializing:C,refresh:P,activeSessionId:M,sessionParam:L,searchQuery:I,setSearchQuery:R,showArchived:O,setShowArchived:J,optionsOpen:_,setOptionsOpen:W,sortOption:U,handleSortChange:e=>{K(e),W(!1),B(e)},processedFolders:G,sessionStatus:H,handleSelectSession:e=>{T(e),D?D(e):j(t=>(t.set("sessionId",e.toString()),t.has("subagent")&&t.delete("subagent"),t),{replace:!0}),A?.()}}}},FE(e,t,n){var r=n("H"),i=n("g0");function s(){let[e,t]=(0,r.J0)(i.aK);return(0,r.vJ)(()=>{let e=e=>{let n=e.detail;n&&t({transport:n.transport,connected:n.connected})};return window.addEventListener(i.rt,e),t((0,i.aK)()),()=>window.removeEventListener(i.rt,e)},[]),e}n.d(t,{H:()=>s})},pH(e,t,n){async function r(e){if(!e)return!1;try{if(navigator.clipboard&&window.isSecureContext)return await navigator.clipboard.writeText(e),!0}catch(e){}try{let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.left="-999999px",t.style.top="-999999px",t.setAttribute("readonly",""),document.body.appendChild(t),t.focus(),t.select();let n=document.execCommand("copy");return document.body.removeChild(t),n}catch(e){return console.error("Failed to copy text: ",e),!1}}n.d(t,{l:()=>r})},P6(e,t,n){var r=n("H");function i(e,t){let[n,i]=(0,r.J0)(!1),[s,a]=(0,r.J0)(e),l=(0,r.li)(null),o=(0,r.li)(!1);(0,r.vJ)(()=>{n&&l.current?.select()},[n]);let c=()=>{let n=s.trim();i(!1),n&&n!==e&&t?.(n)},d=()=>{o.current=!0,i(!1)};return{isEditing:n,draft:s,setDraft:a,inputRef:l,startRename:()=>{o.current=!1,a(e),i(!0)},commitRename:c,cancelRename:d,handleKeyDown:e=>{"Enter"===e.key?(e.preventDefault(),c()):"Escape"===e.key&&(e.preventDefault(),d())},handleBlur:()=>{if(o.current){o.current=!1;return}c()}}}n.d(t,{B:()=>i})},ng(e,t,n){n("H");var r=n("So");function i(){if("u">typeof window)try{let e=window.AudioContext||window.webkitAudioContext;if(!e)return;let t=new e;"suspended"===t.state&&t.resume();let n=t.currentTime,r=t.createOscillator(),i=t.createGain();r.type="sine",r.frequency.setValueAtTime(587.33,n),r.frequency.exponentialRampToValueAtTime(880,n+.1),i.gain.setValueAtTime(0,n),i.gain.linearRampToValueAtTime(.14,n+.02),i.gain.exponentialRampToValueAtTime(1e-4,n+.32),r.connect(i),i.connect(t.destination),r.start(n),r.stop(n+.32);let s=t.createOscillator(),a=t.createGain();s.type="sine",s.frequency.setValueAtTime(880,n+.06),s.frequency.exponentialRampToValueAtTime(1174.66,n+.18),a.gain.setValueAtTime(0,n+.06),a.gain.linearRampToValueAtTime(.1,n+.08),a.gain.exponentialRampToValueAtTime(1e-4,n+.42),s.connect(a),a.connect(t.destination),s.start(n+.06),s.stop(n+.42),setTimeout(()=>{try{t.close()}catch{}},550)}catch(e){console.warn("Unable to play notification audio chime:",e)}}function s(e){if("u"<typeof window)return!0;let t=(0,r.BF)(["chatCompletionSound","soundAlerts"],e);return void 0===t||!!t}function a(e){s(e)&&i()}function l(){s()&&function(){if("u">typeof window)try{let e=window.AudioContext||window.webkitAudioContext;if(!e)return;let t=new e;"suspended"===t.state&&t.resume();let n=t.currentTime;for(let e of[{at:0,frequency:880,duration:.18,peak:.11},{at:.16,frequency:659.25,duration:.46,peak:.13}]){let r=t.createOscillator(),i=t.createGain();r.type="triangle",r.frequency.setValueAtTime(e.frequency,n+e.at),i.gain.setValueAtTime(0,n+e.at),i.gain.linearRampToValueAtTime(e.peak,n+e.at+.015),i.gain.exponentialRampToValueAtTime(1e-4,n+e.at+e.duration),r.connect(i),i.connect(t.destination),r.start(n+e.at),r.stop(n+e.at+e.duration)}setTimeout(()=>{try{t.close()}catch{}},800)}catch(e){console.warn("Unable to play input-required audio cue:",e)}}()}n.d(t,{$E:()=>i,Rn:()=>l,s4:()=>a})},oj(e,t,n){var r=n("H");function i(e,t){(0,r.vJ)(()=>{let n=n=>{!e.current||e.current.contains(n.target)||t(n)};return document.addEventListener("mousedown",n),document.addEventListener("touchstart",n),()=>{document.removeEventListener("mousedown",n),document.removeEventListener("touchstart",n)}},[e,t])}n.d(t,{W:()=>i})},jo(e,t,n){var r=n("H");function i(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:600,[t,n]=(0,r.J0)(!1),i=(0,r.li)(null),s=(0,r.hb)(()=>{n(!0),i.current&&clearTimeout(i.current),i.current=setTimeout(()=>n(!1),e)},[e]);return(0,r.vJ)(()=>()=>{i.current&&clearTimeout(i.current)},[]),{isScrolling:t,handleScroll:s}}function s(e){return e?"scrollbar-overlay-scrolling":"scrollbar-overlay"}n.d(t,{K:()=>i,p:()=>s})},NR(e,t,n){var r=n("H");function i(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:7,[n,i]=(0,r.J0)(e);return{visibleCount:n,showMore:(0,r.hb)(()=>i(e=>e+t),[t])}}n.d(t,{y:()=>i})},Po(e,t,n){var r=n("H"),i=n("eh");function s(){let[e,t]=(0,r.J0)(()=>(0,i.nv)());return(0,r.vJ)(()=>{let e=(0,i.Eu)(()=>t(!0)),n=(0,i.LT)(()=>t(!0));return()=>{e(),n()}},[]),e}n.d(t,{w:()=>s})},oZ(e,t,n){var r=n("H");function i(){let[e,t]=(0,r.J0)([]),n=(0,r.li)(0);return{toasts:e,pushToast:function(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"error",i=arguments.length>2?arguments[2]:void 0;n.current+=1,t(t=>[...t,{id:n.current,message:e,type:r,...i}])},dismissToast:e=>{t(t=>t.filter(t=>t.id!==e))}}}n.d(t,{Y:()=>i})},DO(e,t,n){var r=n("H");function i(e,t){return"object"!=typeof e||null===e?t:"error"in e&&"string"==typeof e.error?e.error:"message"in e&&"string"==typeof e.message?e.message:t}function s(){let[e,t]=(0,r.J0)(null),[n,s]=(0,r.J0)(!1),[a,l]=(0,r.J0)(null),[o,c]=(0,r.J0)(null),d=(0,r.li)(null),u=(0,r.li)(!1),p=(0,r.hb)(()=>{if(d.current)return d.current;let e=(async()=>{s(!0),c(null);try{let e=await fetch("/api/updates/check"),n=await e.json();if(!e.ok)throw Error(i(n,`Update check failed (HTTP ${e.status})`));t(n)}catch(e){c(e instanceof Error?e.message:"Unable to check for updates.")}finally{s(!1),d.current=null}})();return d.current=e,e},[]),m=(0,r.hb)(async e=>{l(e),c(null);try{let t=await fetch("/api/updates/apply",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({target:e})}),n=await t.json();if("object"!=typeof n||null===n||!("success"in n)||"boolean"!=typeof n.success||!("target"in n)||"ompchamber"!==n.target&&"omp"!==n.target||!("manual"in n)||"boolean"!=typeof n.manual||!("message"in n)||"string"!=typeof n.message)throw Error(i(n,`Update failed (HTTP ${t.status})`));return await p(),n}catch(e){return c(e instanceof Error?e.message:"Unable to apply the update."),null}finally{l(null)}},[p]);return(0,r.vJ)(()=>{u.current||(u.current=!0,p())},[]),{info:e,checking:n,applying:a,error:o,hasUpdate:!!(e?.ompchamber.updateAvailable||e?.omp.updateAvailable),check:p,apply:m}}n.d(t,{M:()=>s})},c(e,t,n){var r=n("H");function i(e,t){let{enabled:n,intervalMs:i,guardInFlight:s=!1}=t,a=(0,r.li)(e);a.current=e,(0,r.vJ)(()=>{if(!n||i<=0)return;let e="u"<typeof document||"visible"===document.visibilityState,t=!1,r=()=>{if(!s)return void a.current();if(t)return;let e=a.current();if(!e||"function"!=typeof e.then)return;t=!0;let n=()=>{t=!1};Promise.resolve(e).then(n,n)},l=setInterval(()=>{e&&r()},i),o=()=>{let t="visible"===document.visibilityState;t&&!e&&r(),e=t};return document.addEventListener("visibilitychange",o),()=>{clearInterval(l),document.removeEventListener("visibilitychange",o)}},[n,i,s])}n.d(t,{t:()=>i})},NO(e,t,n){var r=n("H");function i(e,t,n,i){let s=(0,r.li)(n);s.current=n,(0,r.vJ)(()=>{let n=e=>s.current(e);return e.addEventListener(t,n,i),()=>e.removeEventListener(t,n,i)},[e,t,i])}function s(e,t,n){i(window,e,t,n)}function a(e,t,n){i(document,e,t,n)}function l(e,t,n){i(window,e,t,n)}n.d(t,{MN:()=>s,sY:()=>l,zo:()=>a})},so(e,t,n){var r=n("H"),i=n("LQ"),s=n("c"),a=n("NO");function l(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:".",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,l=!(arguments.length>3)||void 0===arguments[3]||arguments[3],o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,[c,d]=(0,r.J0)([]),[u,p]=(0,r.J0)(!1),m=(0,r.hb)(()=>{if(!l)return;p(!0);let n=new URLSearchParams;e&&n.set("root",e),t&&"."!==t&&n.set("repo",t),n.set("t",String(Date.now())),fetch(`/api/fs/git?${n.toString()}`).then(e=>e.json()).then(e=>{Array.isArray(e.changes)?d(e.changes):d([])}).catch(()=>d([])).finally(()=>p(!1))},[l,e,t]);(0,r.vJ)(()=>{m()},[m,n]),(0,s.t)(m,{enabled:l,intervalMs:o}),(0,a.MN)("focus",()=>{l&&m()}),(0,a.zo)("visibilitychange",()=>{l&&m()});let h=(0,r.li)(void 0),f=(0,r.hb)(()=>{l&&void 0===h.current&&(h.current=setTimeout(()=>{h.current=void 0,m()},1e3))},[l,m]);(0,r.vJ)(()=>()=>{void 0!==h.current&&clearTimeout(h.current)},[]),(0,a.sY)("omp:session-updated",f),(0,a.sY)("omp:workspace-updated",f);let{fileMap:x,folderMap:g}=(0,r.Kr)(()=>(0,i._)(c),[c]);return{changes:c,fileMap:x,folderMap:g,isLoading:u,refreshGitStatus:m}}n.d(t,{e:()=>l})},Af(e,t,n){var r=n("H"),i=n("K"),s=n("c");function a(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:5e3;(0,s.t)(e,{enabled:t,intervalMs:n,guardInFlight:!0})}function l(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:500,s=(0,r.li)(e);s.current=e,(0,r.vJ)(()=>{let e;if(!t)return;let r=()=>{clearTimeout(e),e=window.setTimeout(()=>{e=void 0,("u"<typeof document||"visible"===document.visibilityState)&&s.current()},n)};return window.addEventListener(i.s,r),()=>{window.removeEventListener(i.s,r),clearTimeout(e)}},[t,n])}n.d(t,{n:()=>a,w:()=>l})},As(e,t,n){var r=n("H");let i=(0,n("G").q6)(null);function s(){let e=(0,r.NT)(i);if(!e)throw Error("useSessionState used outside SessionStateProvider");return e}n.d(t,{O:()=>s},{b:i})},FL(e,t,n){var r=n("H"),i=n("SS"),s=n("As");function a(e,t){let{sessionId:n,ready:a}=(0,s.O)(),l=(0,i.WV)(n,e),[o,c]=(0,r.J0)(void 0===l?t:l),d=(0,r.li)(n);(0,r.vJ)(()=>{if(d.current!==n&&(d.current=n),!a)return;let r=(0,i.WV)(n,e);c(void 0===r?t:r)},[n,a,e]);let u=t=>{let r="function"==typeof t?t((0,i.WV)(n,e)??o):t;c(r),(0,i.qI)(n,e,r)};return a||void 0===l||l===o?[o,u,a]:[l,u,a]}function l(){let{sessionId:e,ready:t}=(0,s.O)();return{sessionId:e,ready:t,read:(t,n)=>{let r=(0,i.WV)(e,t);return void 0===r?n:r},hydrate:t=>(0,i.E9)(e,t)}}n.d(t,{bL:()=>a,p0:()=>l},{LO:a})},U(e,t,n){var r=n("H"),i=n("X");function s(e,t){let[n,s]=(0,r.J0)(!1),a=(0,i.L)(),l=(0,i.L)(),o=(0,i.L)();return(0,r.vJ)(()=>{(a.data?.success||l.data?.success)&&window.dispatchEvent(new CustomEvent("omp:workspace-updated"))},[l.data,a.data]),{confirmDelete:n,requestDelete:()=>s(!0),cancelDelete:()=>s(!1),handlePin:()=>{"number"==typeof e.id&&(a.submit({isPinned:String(!e.isPinned)},{method:"POST",action:`/api/folders/${e.id}/pin`}),t())},handleDelete:()=>{"number"==typeof e.id&&(l.submit({},{method:"POST",action:`/api/folders/${e.id}/delete`}),s(!1),t())},handleArchive:e=>{let n=1!==e.is_archived;o.submit({archived:String(n)},{method:"POST",action:`/api/sessions/${e.id}/archive`}),t()},handleRename:async(e,n)=>{try{let t=new FormData;if(t.set("name",n),!(await fetch(`/api/sessions/${encodeURIComponent(String(e.id))}/rename`,{method:"POST",body:t})).ok)return}catch{return}window.dispatchEvent(new CustomEvent("omp:session-renamed",{detail:{sessionId:String(e.id),title:n}})),t()}}}n.d(t,{C:()=>s})},X(e,t,n){var r=n("H");async function i(e){let t=await e.text();if(t)try{return JSON.parse(t)}catch{return}}function s(){let[e,t]=(0,r.J0)(void 0),[n,s]=(0,r.J0)("idle"),a=(0,r.li)(!0),l=(0,r.li)(null);(0,r.vJ)(()=>(a.current=!0,()=>{a.current=!1,l.current?.abort(),l.current=null}),[]);let o=(0,r.hb)(async(e,n,r)=>{l.current?.abort();let o=new AbortController;l.current=o,s(r);try{let r=await fetch(e,{...n,signal:o.signal}),s=await i(r);a.current&&l.current===o&&t(s)}catch{}finally{a.current&&l.current===o&&(l.current=null,s("idle"))}},[]);return{data:e,state:n,load:(0,r.hb)(e=>o(e,{method:"GET"},"loading"),[o]),submit:(0,r.hb)((e,t)=>o(t.action,{method:(t.method??"POST").toUpperCase(),body:function(e){if(e instanceof FormData)return e;let t=new URLSearchParams;for(let[n,r]of Object.entries(e))null!=r&&t.set(n,String(r));return t}(e),headers:e instanceof FormData?void 0:{"content-type":"application/x-www-form-urlencoded"}},"submitting"),[o])}}n.d(t,{L:()=>s})},s(e,t,n){var r=n("G");let i=new Set,s="u"<typeof window?"":window.location.search;function a(){for(let e of i)e()}function l(e){return i.add(e),()=>i.delete(e)}function o(e){if("string"==typeof e)return e.startsWith("?")?e:`?${e}`;if(e instanceof URLSearchParams)return e.toString()?`?${e.toString()}`:"";let t=new URLSearchParams;for(let[n,r]of Object.entries(e))null!=r&&t.set(n,String(r));return t.toString()?`?${t.toString()}`:""}function c(){return s}function d(){let e=(0,r.rz)(l,c),t=(0,r.hb)((e,t)=>{var n;let r=(n=new URLSearchParams(s),"function"==typeof e?o(e(new URLSearchParams(n))):o(e)),i=`${window.location.pathname}${r}${window.location.hash}`;t?.replace?window.history.replaceState(null,"",i):window.history.pushState(null,"",i),s=r,a()},[]);return[new URLSearchParams(e),t]}"u">typeof window&&window.addEventListener("popstate",function(){let e="u"<typeof window?"":window.location.search;e!==s&&(s=e,a())}),n.d(t,{o:()=>d})},l(e,t,n){var r=n("j"),i=n("v"),s=n("H"),a=n("G"),l=n("s");function o(e,t,n){return Math.min(Math.max(e,t),n)}function c(e,t){return"number"==typeof e?e:"string"==typeof e&&parseFloat(e)||t}let d=(0,a.q6)(null);function u(e){let{orientation:t,id:n,groupRef:i,onLayoutChanged:l,className:o,children:c}=e,u=(0,s.li)(new Map),p=(0,s.li)(l??null);p.current=l??null;let m=(0,a.Kr)(()=>({orientation:t,panels:u,onLayoutChanged:p}),[t]);return(0,r.Y)(d.Provider,{value:m,children:(0,r.Y)("div",{ref:i,"data-panel-group":"","data-panel-group-id":n,className:o,style:{display:"flex",flex:"1 1 0%",flexDirection:"horizontal"===t?"row":"column",minWidth:0,minHeight:0},children:c})})}function p(e){let{id:t,panelRef:n,defaultSize:i,minSize:s=0,maxSize:l,collapsed:u=!1,filler:p=!1,className:m,style:h,children:f}=e,x=(0,a.NT)(d);if(!x)throw Error(`<Panel id="${t}"> must be rendered inside a <Group>`);let{orientation:g,panels:b}=x,v=c(s,0),k=null!=l?c(l,Number.MAX_SAFE_INTEGER):Number.MAX_SAFE_INTEGER,y=(0,a.li)(null),[w,N]=(0,a.J0)(()=>p?null:o(c(i,v),v,k)),Y=(0,a.li)(w);Y.current=w,(0,a.vJ)(()=>(b.current.set(t,{id:t,isFiller:p,minSize:v,maxSize:k,setSize:e=>N(e),getSize:()=>Y.current}),()=>{b.current.delete(t)}),[t]),(0,a.vJ)(()=>{let e=b.current.get(t);e&&(e.minSize=v,e.maxSize=k)});let D=(0,a.li)(null);(0,a.vJ)(()=>{if(p||null==i)return;let e=c(i,v);D.current!==e&&(D.current=e,N(o(e,v,k)))},[i,p,v,k]),(0,a.vJ)(()=>{if(n)return n.current={resize:e=>{N(o(e,v,k))},getSize:()=>{let e=Y.current;return null!=e?{inPixels:e}:null}},()=>{n.current=null}},[n,v,k]);let A=p?{flex:"1 1 0%",minWidth:"horizontal"===g?v:0,minHeight:"horizontal"===g?0:v,overflow:"hidden",position:"relative"}:{flex:"0 1 auto",width:"horizontal"===g?u?0:w??void 0:void 0,height:"horizontal"===g?void 0:u?0:w??void 0,minWidth:"horizontal"===g?u?0:v:void 0,minHeight:"horizontal"===g?void 0:u?0:v,maxWidth:null!=l?k:void 0,transition:`${"horizontal"===g?"width":"height"} 200ms cubic-bezier(0.22, 1, 0.36, 1)`,overflow:"hidden",position:"relative"};return(0,r.Y)("div",{ref:y,"data-panel":"","data-panel-id":t,"data-panel-collapsed":u?"":void 0,className:m,style:{...A,...h},children:f})}function m(e){let{className:t,style:n,children:i}=e,l=(0,a.NT)(d),c=(0,a.li)(null);if(!l)throw Error("<Separator> must be rendered inside a <Group>");let{orientation:u,panels:p,onLayoutChanged:m}=l,{dragging:h,guidePx:f,onPointerDown:x}=function(e,t,n,r){let[i,a]=(0,s.J0)(!1),[l,c]=(0,s.J0)(null),d=(0,s.li)(null);return(0,s.vJ)(()=>()=>d.current?.(),[]),{dragging:i,guidePx:l,onPointerDown:i=>{let s,l=e.current;if(!l||0!==i.button)return;let u=(e,t)=>{let n=e;for(;n;){if(n.hasAttribute("data-separator")||n.hasAttribute("data-panel-collapsed")){n="previous"===t?n.previousElementSibling:n.nextElementSibling;continue}return n instanceof HTMLElement&&n.hasAttribute("data-panel")?n:null}return null},p=u(l.previousElementSibling,"previous"),m=u(l.nextElementSibling,"next"),h=p?n.current.get(p.getAttribute("data-panel-id")??""):void 0,f=m?n.current.get(m.getAttribute("data-panel-id")??""):void 0;if(!h||!f||!p||!m)return;i.preventDefault(),a(!0);let x="horizontal"===t,g=x?i.clientX:i.clientY,b=e=>x?e.getBoundingClientRect().width:e.getBoundingClientRect().height,v=b(p),k=b(m),y=null,w=e=>{h.setSize(e.a),f.isFiller||f.setSize(e.b)},N=e=>{var t,n;let r=x?e.clientX:e.clientY,i=(t={size:v,min:h.minSize,max:h.maxSize},n={size:k,min:f.minSize,max:f.maxSize},o(r-g,Math.max(t.min-t.size,n.size-n.max),Math.min(t.max-t.size,n.size-n.min)));y={a:o(v+i,h.minSize,h.maxSize),b:o(k-i,f.minSize,f.maxSize)},c(r),void 0===s&&(s=setTimeout(()=>{s=void 0,y&&w(y)},100))},Y=()=>{window.removeEventListener("pointermove",N),window.removeEventListener("pointerup",Y),window.removeEventListener("pointercancel",Y),clearTimeout(s),d.current=null,a(!1),c(null),y&&w(y);let e={};for(let[t,r]of n.current){let n=r.getSize();null!=n&&(e[t]=n)}r.current?.(e,{isUserInteraction:!0})};window.addEventListener("pointermove",N),window.addEventListener("pointerup",Y),window.addEventListener("pointercancel",Y),d.current=Y}}}(c,u,p,m);return(0,r.FD)("div",{ref:c,"data-separator":"",role:"separator","aria-orientation":"horizontal"===u?"vertical":"horizontal",className:t,style:n,onPointerDown:x,onDragStart:e=>e.preventDefault(),children:[i,h&&(0,r.Y)("div",{style:{position:"fixed",inset:0,zIndex:9999,cursor:"horizontal"===u?"col-resize":"row-resize"}}),null!==f&&(0,r.Y)("div",{"aria-hidden":"true",style:{position:"fixed",..."horizontal"===u?{left:`${f}px`,top:0,bottom:0,width:"1px"}:{top:`${f}px`,left:0,right:0,height:"1px"},zIndex:9998,pointerEvents:"none",background:"var(--theme-ink)",opacity:.35}})]})}var h=n("g"),f=n("r");function x(e){let{onNewSession:t}=e;return(0,r.FD)(r.FK,{children:[(0,r.Y)("div",{className:"h-14 flex-shrink-0 flex items-center px-4 border-b border-ink/10 titlebar-drag-region select-none",style:{paddingLeft:"max(1rem, env(titlebar-area-x, 0px))"},children:(0,r.FD)("span",{className:"font-bold text-sm tracking-tight flex items-center",children:[(0,r.Y)("span",{className:"text-transparent bg-clip-text bg-gradient-to-r from-orange-600 to-amber-500 font-extrabold text-[15px] tracking-tighter",children:"OMP"}),(0,r.Y)("span",{className:"ml-[1px]",children:"Chamber"})]})}),(0,r.Y)("div",{className:"px-3 pt-3 titlebar-no-drag",children:(0,r.FD)("button",{onClick:t,className:"w-full flex items-center justify-center space-x-2 py-2 bg-ink text-canvas rounded text-xs font-semibold hover:bg-ink/90 transition-colors cursor-pointer",children:[(0,r.Y)(f.A,{size:14}),(0,r.Y)("span",{children:"New Session"})]})})]})}var g=n("D"),b=n("O"),v=n("n"),k=n("t3"),y=n("p7"),w=n("Sj"),N=n("x"),Y=n("S"),D=n("E");function A(e){let{isSearchVisible:t,searchQuery:n,showArchived:i,optionsOpen:s,sortOption:a,onToggleSearch:l,onSearchChange:o,onToggleArchived:c,onHideArchived:d,onToggleOptions:u,onCloseOptions:p,onSortChange:m,onNewWorkspace:h,onScheduler:f,onRefresh:x,onClose:A}=e;return(0,r.FD)("div",{className:"p-3 border-b border-ink/10 flex flex-col space-y-3",children:[(0,r.FD)("div",{className:"flex items-center justify-between px-1 text-ink/60",children:[(0,r.FD)("div",{className:"flex space-x-3 items-center",children:[(0,r.Y)(g.A,{size:14,className:"hover:text-ink cursor-pointer",onClick:h}),(0,r.Y)(b.A,{size:14,className:"hover:text-ink cursor-pointer",onClick:f}),(0,r.Y)("span",{title:"Refresh sessions",onClick:x,className:"inline-flex cursor-pointer",children:(0,r.Y)(v.A,{size:14,className:"hover:text-ink"})})]}),(0,r.FD)("div",{className:"flex space-x-3 items-center relative",children:[(0,r.Y)(k.A,{size:14,className:`cursor-pointer transition-colors ${t?"text-ink":"hover:text-ink"}`,onClick:l}),(0,r.Y)("span",{title:i?"Hide Archive":"Show Archive",onClick:c,className:"inline-flex cursor-pointer",children:(0,r.Y)(y.A,{size:14,className:`transition-colors ${i?"text-ink":"hover:text-ink"}`})}),(0,r.FD)("div",{className:"relative",children:[(0,r.Y)(w.A,{size:14,className:`cursor-pointer transition-colors ${s?"text-ink":"hover:text-ink"}`,onClick:u}),s&&(0,r.Y)("div",{className:"absolute right-0 top-full mt-2 w-48 bg-paper border border-ink/10 rounded shadow-lg z-50 py-1",onMouseLeave:p,children:(0,r.Y)(D.i,{variant:"desktop",sortOption:a,onSortChange:m})})]}),(0,r.Y)(N.A,{size:14,className:"hover:text-ink cursor-pointer ml-1",onClick:A})]})]}),t&&(0,r.Y)("div",{className:"pt-1",children:(0,r.Y)("input",{type:"text",placeholder:"Search workspaces & sessions...",value:n,onChange:e=>o(e.currentTarget.value),autoFocus:!0,className:"w-full bg-ink/5 border border-ink/10 rounded px-2.5 py-1.5 outline-none focus:border-ink/30 text-xs text-ink placeholder-ink/40 transition-colors"})}),i&&(0,r.FD)("div",{className:"flex items-center justify-between bg-amber-500/10 border border-amber-500/20 text-amber-900 rounded px-2.5 py-1.5 text-[10px] font-medium",children:[(0,r.FD)("div",{className:"flex items-center space-x-1.5",children:[(0,r.Y)(y.A,{size:10}),(0,r.Y)("span",{children:"Showing Archived"})]}),(0,r.Y)("button",{className:"hover:text-amber-950",onClick:d,children:(0,r.Y)(Y.A,{size:10})})]})]})}var F=n("vB"),C=n("wU");function S(e){let{onSettings:t,onInfo:n,updateAvailable:i,onUpdateClick:s}=e;return(0,r.FD)("div",{className:"p-3 border-t border-ink/10 flex items-center justify-between text-ink/60 shrink-0",children:[(0,r.FD)("div",{className:"flex space-x-3",children:[(0,r.Y)(F.A,{size:16,className:"hover:text-ink cursor-pointer",onClick:t}),(0,r.Y)(C.A,{size:16,className:"hover:text-ink cursor-pointer",onClick:n})]}),i&&(0,r.Y)("button",{type:"button",onClick:s,className:"px-2 py-0.5 rounded-full border border-ink/20 text-[10px] font-semibold text-ink hover:border-ink/40",children:"update"})]})}var T=n("a"),$=n("X"),z=n("oj"),j=n("NR"),L=n("U"),M=n("Go"),E=n("Nf"),P=n("WO"),I=n("t"),R=n("z"),O=n("b"),J=n("HZ"),_=n("P6");function W(e){let{title:t,isActive:n=!1,isArchived:i=!1,status:s,awaitingInput:a=!1,onClick:l,onArchive:o,onRename:c,expandable:d=!1,isExpanded:u=!1,hasSubagents:p=!1,onToggleExpand:m}=e,h=!!(d&&p&&m),f=h&&!(a||"stream"===s),{isEditing:x,draft:g,setDraft:b,inputRef:v,startRename:k,handleKeyDown:w,handleBlur:N}=(0,_.B)(t,c);return(0,r.FD)("div",{onClick:x?void 0:l,className:`group/item relative flex items-center w-full rounded-lg px-2 py-1.5 cursor-pointer text-xs transition-colors select-none ${n?"bg-ink/10 font-medium text-ink":"text-ink/75 hover:text-ink hover:bg-ink/5"}`,children:[(0,r.FD)("span",{className:"relative w-4 h-4 shrink-0",children:[h&&m&&(0,r.Y)("button",{type:"button",onClick:e=>{e.stopPropagation(),m(e)},title:u?"Collapse subagents":"Expand subagents","aria-expanded":u,className:`peer absolute inset-0 flex items-center justify-center rounded cursor-pointer transition-opacity ${f?"text-ink/60 hover:text-ink":"text-ink/40 hover:text-ink pointer-events-none opacity-0 group-hover/item:pointer-events-auto group-hover/item:opacity-100 focus-visible:opacity-100"}`,children:u?(0,r.Y)(M.A,{size:13}):(0,r.Y)(E.A,{size:13})}),!!(a||s)&&!f&&(0,r.Y)("span",{className:`pointer-events-none absolute inset-0 flex items-center justify-center text-ink/60 transition-opacity ${h?"group-hover/item:opacity-0 peer-focus-visible:opacity-0":""}`,children:a?(0,r.Y)(P.A,{size:12,className:"animate-pulse text-ink/80"}):"stream"===s?(0,r.Y)(I.A,{size:12,className:"animate-spin"}):(0,r.Y)(R.A,{size:12})})]}),(0,r.Y)("span",{className:"w-2 shrink-0"}),x?(0,r.Y)("input",{ref:v,autoFocus:!0,value:g,onChange:e=>b(e.currentTarget.value),onClick:e=>e.stopPropagation(),onKeyDown:w,onBlur:N,className:"flex-1 min-w-0 bg-paper border border-ink/25 rounded px-1 py-0.5 text-xs text-ink outline-none focus:border-ink/50"}):(0,r.Y)("span",{className:"flex-1 min-w-0 truncate leading-snug",children:t.charAt(0).toUpperCase()+t.slice(1)}),!x&&(c||o)&&(0,r.FD)("div",{className:"absolute right-1.5 top-1/2 -translate-y-1/2 flex items-center gap-0.5 opacity-0 group-hover/item:opacity-100 transition-opacity",children:[c&&(0,r.Y)("button",{type:"button",onClick:e=>{e.stopPropagation(),k()},title:"Rename session",className:"p-1 text-ink/40 hover:text-ink bg-paper/90 hover:bg-ink/10 rounded shadow-xs cursor-pointer",children:(0,r.Y)(O.A,{size:12})}),o&&(0,r.Y)("button",{type:"button",onClick:e=>{e.stopPropagation(),o()},title:i?"Unarchive session":"Archive session",className:"p-1 text-ink/40 hover:text-ink bg-paper/90 hover:bg-ink/10 rounded shadow-xs cursor-pointer",children:i?(0,r.Y)(J.A,{size:12}):(0,r.Y)(y.A,{size:12})})]})]})}var U=n("Uo"),K=n("oS"),q=n("B"),B=n("V7"),H=n("T");let G={pending:"started",running:"started",completed:"completed",failed:"failed",aborted:"aborted"};function V(e){let{sessionId:t,isActiveSession:n}=e,[i]=(0,l.o)(),a=i.get("subagent"),[o,c]=(0,s.J0)([]),[d,u]=(0,s.J0)(!1);(0,s.vJ)(()=>{let e=!1,n=String(t);return c([]),u(!0),(0,q.wv)(n).then(t=>{if(e||!t)return;let n=t.map(q.Nh);c(e=>(0,H.j8)(e,n))}).finally(()=>{e||u(!1)}),()=>{e=!0}},[t]),(0,s.vJ)(()=>{if(!n)return;let e=!1,r=String(t),i=Date.now(),s=e=>{let t=e.detail;return t&&t.sessionId===r?t:null},a=e=>{let t=(0,H.bH)(s(e)?.payload);t&&c(e=>(0,H.j8)(e,[t]))},l=e=>{let t=function(e){let t=(0,H.mq)(e);if(!(0,K.u)(e)||!(0,K.u)(e.progress))return t;let n=(0,H.mq)(e.progress);return n?{...n,id:n.id??t?.id,index:n.index??t?.index}:t}(s(e)?.payload);t&&c(e=>e.map(e=>{if(void 0!==t.id){if(e.id!==t.id)return e}else if(void 0===t.index||t.index<0||e.index!==t.index)return e;let n=t.status&&"started"===e.status?G[t.status]??e.status:e.status;return{...e,status:n,progress:{...e.progress,...t},lastUpdate:Date.now()}}))};return window.addEventListener("subagent_lifecycle",a),window.addEventListener("subagent_progress",l),fetch(`/api/agent/${encodeURIComponent(r)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"get_subagents"})}).then(e=>e.ok?e.json():null).then(t=>{if(e||!(0,K.u)(t))return;let n="data"in t?t.data:t;c(e=>(0,H.j8)(e,(0,H.vG)(n),i))}).catch(()=>{}),()=>{e=!0,window.removeEventListener("subagent_lifecycle",a),window.removeEventListener("subagent_progress",l)}},[n,t]);let p=d?"Loading subagents…":0===o.length?"No subagent activity":null;return(0,r.Y)("div",{className:"pl-6 pr-0 space-y-0.5 py-0.5",children:p?(0,r.FD)("div",{className:"px-2 py-1 text-xs italic text-ink/40 flex items-center",children:[(0,r.Y)("span",{className:"w-4 h-4 shrink-0"}),(0,r.Y)("span",{className:"w-2 shrink-0"}),(0,r.Y)("span",{className:"flex-1 min-w-0 truncate",children:p})]}):o.map(e=>{let i=(0,B.us)(e),s=e.task??e.assignment??e.description??i,l=e.id===a;return(0,r.FD)("button",{type:"button",title:s,onClick:()=>window.dispatchEvent(new CustomEvent("omp:view-subagent",{detail:{sessionId:String(t),subagent:e}})),className:`w-full flex items-center text-left text-xs rounded-md px-2 py-1 cursor-pointer transition-colors select-none group/subagent ${l?"bg-ink/10 font-medium text-ink":"text-ink/70 hover:text-ink hover:bg-ink/5"}`,children:[(0,r.Y)("span",{className:"w-4 h-4 flex items-center justify-center shrink-0",children:(0,r.Y)(U.l,{status:e.status,live:n&&"started"===e.status,size:11})}),(0,r.Y)("span",{className:"w-2 shrink-0"}),(0,r.Y)("span",{className:"flex-1 min-w-0 truncate leading-snug",children:i})]},e.id)})})}var Z=n("C4"),Q=n("So");let X="omp_sidebar_expanded_sessions";var ee=n("A"),et=n("A9");function en(e){let{folder:t,activeSessionId:n,onSelectSession:i,onNewSessionForFolder:a,forceExpanded:o=!1,showArchived:c=!1,sessionStatus:d={}}=e,[u,p]=(0,s.J0)(t.isExpanded||!1),[m,h]=(0,s.J0)(!1),{visibleCount:x,showMore:g}=(0,j.y)(),[b]=(0,l.o)(),v=b.get("subagent"),k=b.get("sessionId"),[y,N]=(0,s.J0)(()=>new Set);(0,s.vJ)(()=>{let e,t=Array.isArray(e=(0,Q.BF)(X))?new Set(e.filter(e=>"string"==typeof e)):new Set;t&&t.size>0&&N(t)},[]),(0,s.vJ)(()=>{"boolean"==typeof t.isExpanded&&p(t.isExpanded)},[t.isExpanded]),(0,s.vJ)(()=>{v&&k&&N(e=>{if(e.has(k))return e;let t=new Set(e);return t.add(k),t})},[v,k]);let Y=(0,s.li)(null),{refresh:D}=(0,et.k)(),A=(0,$.L)(),{confirmDelete:F,requestDelete:C,cancelDelete:S,handlePin:M,handleDelete:E,handleArchive:P,handleRename:I}=(0,L.C)(t,D);(0,s.vJ)(()=>{A.data?.success&&window.dispatchEvent(new CustomEvent("omp:workspace-updated"))},[A.data]),(0,z.W)(Y,()=>{h(!1),S()});let R=t.sessions,O=(0,ee.x)(t.icon),J=(R||[]).filter(e=>c?1===e.is_archived:1!==e.is_archived),_=J.slice(0,x),U=J.length>x;return(0,r.FD)("div",{className:"space-y-1",children:[(0,r.FD)("div",{className:"group flex items-center justify-between h-7 text-xs font-semibold text-ink px-2 hover:bg-ink/5 rounded-md transition-colors select-none",children:[(0,r.FD)("div",{className:"flex-1 h-full flex items-center cursor-pointer min-w-0",onClick:()=>{let e=!u;p(e),"number"==typeof t.id&&A.submit({isExpanded:String(e)},{method:"POST",action:`/api/folders/${t.id}/toggle`})},children:[(0,r.Y)("span",{className:"w-4 h-4 flex items-center justify-center shrink-0",children:t.customIconUrl?(0,r.Y)("img",{src:t.customIconUrl,alt:"",className:"w-[15px] h-[15px] rounded-xs object-contain shrink-0",referrerPolicy:"no-referrer"}):(0,r.Y)(O,{size:15,className:"text-ink/75",style:{color:t.accentColor||void 0}})}),(0,r.Y)("span",{className:"w-2 shrink-0"}),t.isPinned&&(0,r.Y)(T.A,{size:11,className:"text-ink/60 shrink-0 mr-1.5"}),(0,r.Y)("span",{className:"truncate text-[13px] font-semibold tracking-tight",children:t.name})]}),(0,r.FD)("div",{className:`items-center space-x-0.5 pl-1 ${m?"flex":"hidden group-hover:flex"}`,children:[(0,r.Y)("button",{type:"button",title:"New Session",className:"w-5 h-5 flex items-center justify-center text-ink/40 hover:text-ink hover:bg-ink/10 rounded cursor-pointer transition-colors",onClick:e=>{e.stopPropagation(),a(t.id)},children:(0,r.Y)(f.A,{size:12})}),(0,r.FD)("div",{className:"relative flex items-center",ref:Y,children:[(0,r.Y)("button",{type:"button",title:"Workspace Options",className:"w-5 h-5 flex items-center justify-center text-ink/40 hover:text-ink hover:bg-ink/10 rounded cursor-pointer transition-colors",onClick:e=>{e.stopPropagation(),h(!m)},children:(0,r.Y)(w.A,{size:12})}),m&&(0,r.Y)("div",{className:"absolute right-0 top-full mt-1 w-44 bg-paper border border-ink/15 rounded-md shadow-lg z-50 py-1 text-xs",children:(0,r.Y)(Z.t,{variant:"desktop",isPinned:t.isPinned,confirmDelete:F,onPin:()=>{M(),h(!1)},onDelete:()=>{E(),h(!1)},onRequestDelete:C,onCancelDelete:S})})]})]})]}),(o||u)&&(0,r.FD)("div",{className:"space-y-0.5",children:[_.map(e=>{let t=String(e.id),s=null!==n?String(n)===t:1===e.is_active,a=s&&k===t&&!!v,l=null!==n&&t===String(n),o=!!e.hasSubagents,c=o&&y.has(t);return(0,r.FD)("div",{className:"space-y-0.5",children:[(0,r.Y)(W,{title:e.title,isActive:s&&!a,isArchived:1===e.is_archived,status:d[t],awaitingInput:!!e.awaitingInput,onClick:()=>i(e.id),onArchive:()=>P(e),onRename:String(e.id).startsWith("new-")?void 0:t=>void I(e,t),expandable:o,hasSubagents:o,isExpanded:c,onToggleExpand:()=>{N(e=>{let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),(0,Q.cz)(X,[...n].slice(-50)),n})}}),o&&c&&(0,r.Y)(V,{sessionId:e.id,isActiveSession:l})]},e.id)}),U&&!o&&(0,r.FD)("button",{type:"button",onClick:g,className:"flex items-center text-xs text-ink/45 hover:text-ink/80 w-full text-left py-1.5 px-2 rounded-lg hover:bg-ink/5 transition-colors cursor-pointer select-none",children:[(0,r.Y)("span",{className:"w-4 h-4 shrink-0"}),(0,r.Y)("span",{className:"w-2 shrink-0"}),(0,r.Y)("span",{className:"truncate leading-snug",children:"Show more sessions"})]}),0===J.length&&(0,r.Y)("div",{className:"px-3 py-2 text-[11px] text-ink/40 italic",children:c?"No archived sessions.":"No sessions."})]})]})}var er=n("jo");function ei(e){let{folders:t,activeSessionId:n,searchQuery:i,showArchived:s,sessionStatus:a,isScrolling:l,onScroll:o,onSelectSession:c,onNewSessionForFolder:d}=e;return(0,r.Y)("div",{onScroll:o,className:`flex-1 scrollbar-overlay-container p-2 space-y-4 ${(0,er.p)(l)}`,children:0===t.length?(0,r.Y)("div",{className:"text-center py-8 text-xs text-ink/40",children:i?"No results found.":"No workspaces available."}):t.map(e=>(0,r.Y)(en,{folder:e,activeSessionId:n,onSelectSession:c,onNewSessionForFolder:d,forceExpanded:!!i,showArchived:s,sessionStatus:a},e.id))})}let es=[3,2];function ea(){return(0,r.Y)("div",{className:"flex-1 p-2 space-y-4","aria-hidden":"true",children:es.map((e,t)=>(0,r.FD)("div",{className:"space-y-1.5",children:[(0,r.FD)("div",{className:"flex items-center gap-2 px-1 py-1.5",children:[(0,r.Y)("span",{className:"w-3.5 h-3.5 rounded-sm animate-pulse bg-ink/10"}),(0,r.Y)("span",{className:"h-3 w-24 rounded animate-pulse bg-ink/10"})]}),Array.from({length:e},(e,t)=>(0,r.FD)("div",{className:"flex items-center gap-2 rounded px-2 py-1.5",children:[(0,r.Y)("span",{className:"w-4 h-4 rounded-full animate-pulse bg-ink/10"}),(0,r.Y)("span",{className:"h-3 rounded animate-pulse bg-ink/10",style:{width:`${58-t%3*12}%`}})]},t))]},t))})}var el=n("wu"),eo=n("wm"),ec=n("oZ"),ed=n("DO"),eu=n("z4");function ep(e){let{className:t="",onClose:n,appSettings:i={}}=e,{folders:a,initializing:o,refresh:c,activeSessionId:d,sessionParam:u,searchQuery:p,setSearchQuery:m,showArchived:f,setShowArchived:g,optionsOpen:b,setOptionsOpen:v,sortOption:k,handleSortChange:y,processedFolders:w,sessionStatus:N,handleSelectSession:Y}=(0,eu.K)(i,{includePendingSessions:!0}),[,D]=(0,l.o)(),[F,C]=(0,s.J0)(!1),[T,$]=(0,s.J0)(!1),[z,j]=(0,s.J0)(!1),[L,M]=(0,s.J0)(!1),E=(0,ed.M)(),{toasts:P,pushToast:I,dismissToast:R}=(0,ec.Y)(),[O,J]=(0,s.J0)(!1),{isScrolling:_,handleScroll:W}=(0,er.K)(),U=e=>{let t=(0,eo.l)(a,u,e);t&&(0,eo.r)(t,i.omp_access_mode)};return(0,r.FD)(r.FK,{children:[(0,r.FD)("aside",{className:`flex flex-col bg-paper h-full ${t}`,children:[(0,r.Y)(x,{onNewSession:()=>{U(),D(e=>{let t=e.get("sessionId"),n=new URLSearchParams(e);if(n.set("sessionId",`new-${Date.now()}`),t){let e=a.find(e=>e.sessions?.some(e=>String(e.id)===String(t)));e&&n.set("folderId",e.id.toString())}else n.delete("folderId");return n},{replace:!0})}}),(0,r.Y)(A,{isSearchVisible:O,searchQuery:p,showArchived:f,optionsOpen:b,sortOption:k,onToggleSearch:()=>J(!O),onSearchChange:m,onToggleArchived:()=>g(!f),onHideArchived:()=>g(!1),onToggleOptions:()=>v(!b),onCloseOptions:()=>v(!1),onSortChange:y,onNewWorkspace:()=>j(!0),onScheduler:()=>M(!0),onRefresh:c,onClose:n}),o?(0,r.Y)(ea,{}):(0,r.Y)(ei,{folders:w,activeSessionId:d,searchQuery:p,showArchived:f,sessionStatus:N,isScrolling:_,onScroll:W,onSelectSession:Y,onNewSessionForFolder:e=>{U(e),D(t=>{let n=new URLSearchParams(t);return n.set("sessionId",`new-${Date.now()}`),n.set("folderId",e.toString()),n},{replace:!0})}}),(0,r.Y)(S,{onSettings:()=>C(!0),onInfo:()=>$(!0),updateAvailable:E.hasUpdate,onUpdateClick:()=>{$(!0),E.check()}})]}),(0,r.Y)(h.bB,{isOpen:F,onClose:()=>C(!1),appSettings:i}),(0,r.Y)(h.VT,{isOpen:T,onClose:()=>$(!1),updates:E,onToast:I}),(0,r.Y)(h.xV,{isOpen:z,onClose:()=>j(!1),onCreate:async e=>{let{name:t,path:n}=e,r=await fetch("/api/folders",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t,path:n})}),i=await r.json().catch(()=>({}));if(!r.ok||!i.success)throw Error(i.error||`HTTP ${r.status}`);window.location.reload()}}),(0,r.Y)(h.Lo,{isOpen:L,onClose:()=>M(!1)}),(0,r.Y)(el.y,{toasts:P,onDismiss:R})]})}var em=n("u"),eh=n("Gb"),ef=n("FL"),ex=n("As"),eg=n("NO"),eb=n("zI"),ev=n("f"),ek=n("b5"),ey=n("Pf"),ew=n("se"),eN=n("tC");let eY=()=>{let{isInstallable:e,isInstalled:t,isIOS:n,install:i}=function(){let[e,t]=(0,s.J0)(null),[n,r]=(0,s.J0)(!1),[i,a]=(0,s.J0)(!1);(0,s.vJ)(()=>{r(window.matchMedia("(display-mode: standalone)").matches||!0===window.navigator.standalone);let e=window.navigator.userAgent.toLowerCase();a(/iphone|ipad|ipod/.test(e));let n=e=>{e.preventDefault(),t(e)},i=()=>{r(!0),t(null)};return window.addEventListener("beforeinstallprompt",n),window.addEventListener("appinstalled",i),()=>{window.removeEventListener("beforeinstallprompt",n),window.removeEventListener("appinstalled",i)}},[]);let l=async()=>{if(!e)return!1;await e.prompt();let{outcome:n}=await e.userChoice;return"accepted"===n&&(r(!0),t(null),!0)};return{isInstallable:!!e,isInstalled:n,isIOS:i,install:l}}(),[a,l]=(0,s.J0)(!1);return t?null:e?(0,r.Y)("button",{onClick:i,className:"p-1.5 rounded hover:bg-ink/10 transition-colors text-ink/60 hover:text-ink",title:"Install OMPChamber",children:(0,r.Y)(eN.A,{size:16})}):n?(0,r.FD)(r.FK,{children:[(0,r.Y)("button",{onClick:()=>l(!0),className:"p-1.5 rounded hover:bg-ink/10 transition-colors text-ink/60 hover:text-ink",title:"Install on iOS",children:(0,r.Y)(eN.A,{size:16})}),a&&(0,r.Y)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-ink/20 p-4",children:(0,r.FD)("div",{className:"w-full max-w-sm rounded bg-paper border border-ink/10 p-6 shadow-xl text-ink",children:[(0,r.Y)("h3",{className:"text-sm font-semibold",children:"Install on iPhone / iPad"}),(0,r.FD)("p",{className:"mt-2 text-xs opacity-80",children:["1. Tap the ",(0,r.Y)("strong",{children:"Share"})," button in Safari toolbar.",(0,r.Y)("br",{}),"2. Scroll down and tap ",(0,r.Y)("strong",{children:"Add to Home Screen"}),"."]}),(0,r.Y)("button",{onClick:()=>l(!1),className:"mt-4 w-full rounded bg-ink text-canvas py-2 text-xs font-semibold hover:bg-ink/90",children:"Close"})]})})]}):null};var eD=n("R2");function eA(e){let{sessionTitle:t,showLeftPanel:n,showEditor:i,showRightPanel:s,streamStatus:a,onSwitchToMobile:l,onToggleEditor:o,onToggleRightPanel:c,onToggleLeftPanel:d}=e;return(0,r.FD)("header",{className:"h-14 flex-shrink-0 border-b border-ink/10 bg-paper flex items-center justify-between pr-4 z-20 titlebar-drag-region select-none",style:{paddingLeft:n?void 0:"max(1rem, env(titlebar-area-x, 0px))",paddingRight:"max(1rem, calc(100vw - env(titlebar-area-width, 100vw)))"},children:[(0,r.FD)("div",{className:"flex items-center space-x-2 px-4 min-w-0",children:[!n&&(0,r.FD)(r.FK,{children:[(0,r.Y)("button",{type:"button",onClick:d,className:"p-1.5 rounded hover:bg-ink/10 transition-colors text-ink/60 hover:text-ink cursor-pointer flex-shrink-0 titlebar-no-drag",title:"Expand Sidebar","aria-label":"Expand Sidebar",children:(0,r.Y)(eb.A,{size:16})}),(0,r.FD)("span",{className:"font-bold text-sm tracking-tight hidden sm:flex items-center flex-shrink-0",children:[(0,r.Y)("span",{className:"text-transparent bg-clip-text bg-gradient-to-r from-orange-600 to-amber-500 font-extrabold text-[15px] tracking-tighter",children:"OMP"}),(0,r.Y)("span",{className:"ml-[1px]",children:"Chamber"})]}),t&&(0,r.Y)("span",{className:"text-ink/30 text-xs select-none flex-shrink-0",children:"/"})]}),t&&(0,r.FD)("div",{className:"flex items-center space-x-2 titlebar-no-drag",children:[(0,r.Y)("span",{className:"font-bold text-sm tracking-tight hidden sm:flex items-center",children:(0,r.Y)("span",{className:"font-semibold text-xs text-ink truncate",children:t.charAt(0).toUpperCase()+t.slice(1)})}),(0,r.Y)(w.A,{size:14,className:"text-ink/40 hover:text-ink cursor-pointer flex-shrink-0"})]})]}),(0,r.Y)("div",{className:"flex items-center space-x-3 titlebar-no-drag",children:(0,r.FD)("div",{className:"flex items-center space-x-1",children:[(0,r.Y)(eD.c,{status:a}),l&&(0,r.Y)("button",{type:"button",onClick:l,className:"p-1.5 rounded hover:bg-ink/10 transition-colors text-ink/60 hover:text-ink cursor-pointer",title:"Switch to Mobile View",children:(0,r.Y)(ev.A,{size:16})}),(0,r.Y)(eY,{}),(0,r.Y)("button",{type:"button",onClick:o,className:`p-1.5 rounded hover:bg-ink/10 transition-colors cursor-pointer ${i?"text-ink":"text-ink/40"}`,title:"Toggle Editor Layout",children:(0,r.Y)(ek.A,{size:16})}),(0,r.Y)("button",{type:"button",onClick:c,className:`p-1.5 rounded hover:bg-ink/10 transition-colors cursor-pointer ${s?"text-ink":"text-ink/40"}`,title:"Toggle Right Panel",children:s?(0,r.Y)(ey.A,{size:16}):(0,r.Y)(ew.A,{size:16})})]})})]})}var eF=n("bQ"),eC=n("nG"),eS=n("oE"),eT=n("Asb"),e$=n("vZ"),ez=n("N"),ej=n("Oj"),eL=n("lW"),eM=n("SJ"),eE=n("so"),eP=n("ET");let eI={context:{title:"Context & Telemetry",icon:(0,r.Y)(eS.A,{size:16})},files:{title:"Files",icon:(0,r.Y)(eT.A,{size:16})},search:{title:"Search",icon:(0,r.Y)(k.A,{size:16})},git:{title:"Source Control",icon:(0,r.Y)(e$.A,{size:16})},terminal:{title:"Terminal (Bun)",icon:(0,r.Y)(ez.A,{size:16})},"user-browser":{title:"Browser (Anda)",icon:(0,r.Y)(ej.A,{size:16})},browser:{title:"Browser Agent",icon:(0,r.Y)(eL.A,{size:16})},usage:{title:"Usage",icon:(0,r.Y)(eM.A,{size:16})}};function eR(e){let{activePanel:t,onChangePanel:n,isPanelOpen:i,hasActiveContext:s,activeProjectPath:a,refreshKey:l}=e,{changes:o}=(0,eE.e)(a??void 0,".",l,s,15e3),c=o.length>0;return(0,r.FD)("nav",{className:"w-11 flex-shrink-0 border-l border-ink/10 bg-paper flex flex-col items-center py-3 space-y-2 z-10",children:[(0,r.Y)("div",{className:"flex flex-col items-center space-y-1 w-full",children:eP.G7.map(e=>{let s=i&&t===e;return(0,r.FD)("button",{className:`relative w-full h-10 flex items-center justify-center transition-colors border-l-2 ${s?"text-ink border-ink bg-ink/5":"text-ink/40 border-transparent hover:text-ink hover:bg-ink/5"}`,onClick:()=>n(e),title:eI[e].title,children:[eI[e].icon,"git"===e&&c&&(0,r.Y)("span",{className:"absolute top-1.5 right-1.5 w-1.5 h-1.5 rounded-full bg-info",title:"Ada perubahan git"})]},e)})}),(0,r.Y)("div",{className:"flex-1"})]})}function eO(){return(0,r.Y)(m,{className:"relative w-[3px] outline-none group flex justify-center cursor-col-resize z-10",children:(0,r.Y)("div",{className:"h-full w-[1px] bg-ink/10 group-hover:bg-ink/40 group-active:bg-ink/60 group-hover:w-[3px] transition-all"})})}let eJ={editor:.6,diff:.6},e_={editor:600,diff:720};function eW(e){let{stored:t,defaultFraction:n,defaultPx:r,available:i,min:s,siblingMin:a,handleCount:l}=e;if(null===i||i<=0)return Math.max(s,Math.round(t?.px??r));let o=Math.max(s,Math.floor(i-400-a-3*l));return Math.min(Math.max(Math.round((t?.fraction??(t?.px!=null?Math.min(1,t.px/i):n))*i),s),o)}function eU(e){if("number"==typeof e)return Number.isFinite(e)&&e>0?{px:Math.round(e)}:void 0;if(!e||"object"!=typeof e)return;let t=Number.isFinite(e.px)&&e.px>0?Math.round(e.px):void 0,n=Number.isFinite(e.fraction)&&e.fraction>0&&e.fraction<=1?e.fraction:void 0;if(void 0!==t||void 0!==n)return{...void 0!==t?{px:t}:{},...void 0!==n?{fraction:n}:{}}}let eK=(0,a.RZ)(()=>Promise.all([n.e("f7"),n.e("yx"),n.e("q8")]).then(n.bind(n,"o3")).then(e=>({default:e.Editor})));function eq(e){let{children:t}=e;return(0,r.Y)(a.tY,{fallback:(0,r.Y)("div",{className:"w-full h-full flex items-center justify-center text-ink/40",children:(0,r.Y)("span",{className:"text-xs font-mono",children:"Loading…"})}),children:t})}function eB(e){let{appSettings:t,showEditor:n,editorPanelRef:i,showRightPanel:a,activeRightPanel:l,rightPanelRef:o,panelWidths:c,editorWidthMode:d,hasActiveContext:m,activeProjectPath:h,openedFiles:f,activeFileId:x,refreshKey:g,onSetActiveFileId:b,onCloseFile:v,onOpenFile:k,onRefreshWorkspace:y,onChangeRightPanel:w,onToggleRightPanel:N,onSessionTitle:Y,onPanelWidths:D}=e,A=(0,s.li)(null),F=function(e){let[t,n]=(0,s.J0)(null);return(0,s.vJ)(()=>{let t=e.current;if(!t||"u"<typeof ResizeObserver)return;let r=new ResizeObserver(()=>{n(t.clientWidth||null)});return r.observe(t),n(t.clientWidth||null),()=>r.disconnect()},[e]),t}(A),C=(0,s.Kr)(()=>({}),[]),S=(0,s.Kr)(()=>eP.G7.map(e=>({view:e,Comp:(0,eC.SU)(C,e)})),[C]),T=+!!n+ +!!a,$=eW({stored:c[d],defaultFraction:eJ[d],defaultPx:e_[d],available:F,min:320,siblingMin:a?eP.lw[l]:0,handleCount:T}),z=eW({stored:c.right?.[l],defaultFraction:eP.Cx[l],defaultPx:eP.qv[l],available:F,min:eP.lw[l],siblingMin:320*!!n,handleCount:T});return(0,r.FD)("div",{className:"flex flex-1 overflow-hidden",children:[(0,r.FD)(u,{orientation:"horizontal",id:"ompchamber-layout",className:"flex-1 min-w-0",groupRef:A,onLayoutChanged:()=>{let e,t,n;D((e={},t=i.current?.getSize()?.inPixels,n=o.current?.getSize()?.inPixels,null!=t&&t>0&&(e[d]={px:Math.round(t),...F?{fraction:t/F}:{}}),null!=n&&n>0&&(e.right={[l]:{px:Math.round(n),...F?{fraction:n/F}:{}}}),e))},children:[(0,r.Y)(p,{id:"center-panel",filler:!0,minSize:400,children:(0,r.Y)(eF.E,{className:"w-full h-full",appSettings:t,onSessionTitle:Y})}),n&&(0,r.Y)(eO,{}),(0,r.Y)(p,{panelRef:i,id:"editor-panel",defaultSize:$,minSize:320,collapsed:!n,children:(0,r.Y)(eq,{children:(0,r.Y)(eK,{className:"w-full h-full",openedFiles:f,activeFileId:x,onSelectFile:b,onCloseFile:v,refreshKey:g,onFileSaved:y})})}),a&&(0,r.Y)(eO,{}),(0,r.Y)(p,{panelRef:o,id:"right-panel",defaultSize:z,minSize:eP.lw[l],collapsed:!a,children:(0,r.Y)(eq,{children:S.map(e=>{let{view:t,Comp:n}=e,i=l===t;return(0,r.Y)("div",{className:i?"w-full h-full":"hidden",children:(0,r.Y)(n,{className:"w-full h-full",enabled:"terminal"===t?m:m&&i,active:i,refreshKey:g,rootPath:h??void 0,onRefresh:y,onOpenFile:k,onClose:N})},t)})})})]}),(0,r.Y)(eR,{activePanel:l,onChangePanel:w,isPanelOpen:a,hasActiveContext:m,activeProjectPath:h,refreshKey:g})]})}var eH=n("FE");function eG(e){let{sessionId:t,onSwitchToMobile:n,appSettings:i={}}=e,{folders:a}=(0,et.k)(),[o,c]=(0,ef.bL)("layout.showRightPanel",i.showRightPanel??!0),[d,m]=(0,ef.bL)("layout.activeRightPanel",i.activeRightPanel??"files"),[h,f]=(0,ef.bL)("layout.showLeftPanel",i.showLeftPanel??!0),{widths:x,commitWidths:g}=function(e,t){let n=(0,s.Kr)(()=>(function(e,t){var n;if(!e||"object"!=typeof e)return{};let r={},i="number"==typeof(n=e.left)&&Number.isFinite(n)&&n>0?Math.round(n):void 0;for(let t of(void 0!==i&&(r.left=i),["editor","diff"])){let n=eU(e[t]);void 0!==n&&(r[t]=n)}let s={};if(e.right&&"object"==typeof e.right)for(let[t,n]of Object.entries(e.right)){if(!(0,eP.ls)(t))continue;let e=eU(n);void 0!==e&&(s[t]=e)}else{let n=eU(e.right);void 0!==n&&(s[t]=n)}return Object.keys(s).length>0&&(r.right=s),r})(e.desktopLayoutSizes,t),[e.desktopLayoutSizes,t]),[r,i]=(0,ef.bL)("layout.panelWidths",n);return{widths:r,commitWidths:(0,s.hb)(e=>{i(t=>(function(e,t){let n={...e,...t};if(t.right){let r={...e.right};for(let[n,i]of Object.entries(t.right))(0,eP.ls)(n)&&i&&(r[n]={...e.right?.[n],...i});n.right=r}for(let r of["editor","diff"])t[r]&&(n[r]={...e[r],...t[r]});return n})(t,e))},[i])}}(i,d),b=(0,s.li)(null),v=(0,s.li)(null),k=(0,s.li)(null),[y,w]=(0,ef.bL)("layout.userToggledEditor",i.userToggledEditor??null),[N]=(0,l.o)(),Y=N.get("folderId"),D=(0,s.Kr)(()=>{let e=(0,eh.t)(a,t||"").folder;return e||(Y?a.find(e=>String(e.id)===String(Y))??null:null)},[a,t,Y]),A=D?.project_path??null,F=!!D,{openedFiles:C,activeFileId:S,setActiveFileId:T,handleOpenFile:$,handleCloseFile:z}=function(e,t,n){let[r,i]=(0,ef.bL)("layout.openedFiles",[]),[a,l]=(0,ef.bL)("layout.activeFileId",null),o=(0,s.li)(void 0),{ready:c}=(0,ex.O)(),d=(0,s.li)(void 0);(0,s.vJ)(()=>{o.current===e||(o.current=e,c&&d.current!==e&&(d.current=e,i([]),l(null)))},[e,t,c,i,l]);let u=(0,s.hb)(t=>{let r={...t,root:t.root??e??void 0};i(e=>{let t=e.find(e=>e.id===r.id||!e.isDiff&&e.path&&r.path&&e.path===r.path);return t?(l(t.id),e):[...e,r]}),l(r.id),n?.()},[e,n,i,l]),p=(0,s.hb)(t=>{let r=t.file.replace(/^\/+/,""),s=r.split("/").pop()||r,a=!!t.staged,o=`diff-${a?"staged":"working"}-${r}`,c={id:o,name:`${s} (Diff)`,path:r,isDiff:!0,diffStatus:t.status||"M",diffStaged:a,repo:t.repo||".",root:t.root??e??void 0};i(e=>{let t=e.find(e=>e.id===o||e.isDiff&&e.path===r&&e.diffStaged===a);return t?(l(t.id),e):[...e,c]}),l(o),n?.()},[e,n,i,l]),m=(0,s.hb)(e=>{i(t=>{let n=t.filter(t=>t.id!==e);return a===e&&l(n.length>0?n[n.length-1].id:null),n})},[a,i,l]);return(0,eg.sY)("omp:open-file",e=>{if(!e.detail||!e.detail.path)return;let t=e.detail.path.replace(/^\/+/,""),n=e.detail.name||t.split("/").pop()||"file",r=0;for(let e=0;e<t.length;e++)r=(r<<5)-r+t.charCodeAt(e)|0;u({id:e.detail.id||Math.abs(r)||Date.now(),name:n,path:t,content:e.detail.content})}),(0,eg.sY)("omp:open-diff",e=>{e.detail&&e.detail.file&&p(e.detail)}),{openedFiles:r,activeFileId:a,setActiveFileId:l,handleOpenFile:u,handleOpenDiff:p,handleCloseFile:m}}(A,t||"",(0,s.hb)(()=>{w(!0)},[w])),j=C.length>0&&(y??!0),L=(0,s.Kr)(()=>C.find(e=>String(e.id)===String(S))?.isDiff?"diff":"editor",[C,S]),[M,E]=(0,s.J0)(!1),[P,I]=(0,s.J0)("appearance"),[R,O]=(0,s.J0)(!1),[J,_]=(0,s.J0)(0),[W,U]=(0,s.J0)(null),K=(0,eH.H)();(0,eg.MN)("keydown",e=>{(e.metaKey||e.ctrlKey)&&","===e.key&&(e.preventDefault(),I("appearance"),O(!1),E(e=>!e))}),(0,eg.sY)("omp:open-settings",e=>{e.detail?.category?I(e.detail.category):I("appearance"),O(!!e.detail?.autoOpenAdd),E(!0)});let q=e=>{f(e)},B=()=>{c(!o)};return(0,r.FD)("div",{className:"flex flex-col h-screen w-screen overflow-hidden bg-canvas text-ink font-sans selection:bg-ink selection:text-canvas",children:[(0,r.Y)("div",{className:"flex flex-1 overflow-hidden",children:(0,r.FD)(u,{orientation:"horizontal",id:"ompchamber-main",onLayoutChanged:()=>{let e=k.current?.getSize()?.inPixels;null!=e&&e>0&&g({left:Math.round(e)})},children:[(0,r.Y)(p,{panelRef:k,id:"left-panel",defaultSize:x.left??280,minSize:264,maxSize:500,collapsed:!h,children:(0,r.Y)(ep,{className:"w-full h-full",onClose:()=>q(!1),appSettings:i})}),h&&(0,r.Y)(eO,{}),(0,r.Y)(p,{id:"main-right-stack",filler:!0,minSize:0,children:(0,r.FD)("div",{className:"flex flex-col h-full",children:[(0,r.Y)(eA,{sessionTitle:W,showLeftPanel:h,showEditor:j,showRightPanel:o,streamStatus:K,onSwitchToMobile:n,onToggleEditor:()=>{w(!j)},onToggleRightPanel:B,onToggleLeftPanel:()=>q(!h)}),(0,r.Y)(eB,{appSettings:i,showEditor:j,editorPanelRef:b,showRightPanel:o,activeRightPanel:d,rightPanelRef:v,panelWidths:x,editorWidthMode:L,hasActiveContext:F,activeProjectPath:A,openedFiles:C,activeFileId:S,refreshKey:J,onSetActiveFileId:T,onCloseFile:z,onOpenFile:$,onRefreshWorkspace:()=>_(e=>e+1),onChangeRightPanel:e=>{let t=o,n=d;d===e&&o?t=!1:(n=e,t=!0),c(t),m(n)},onToggleRightPanel:B,onSessionTitle:U,onPanelWidths:g})]})})]})}),(0,r.Y)(em.b,{isOpen:M,onClose:()=>{E(!1),O(!1)},initialCategory:P,autoOpenAddProvider:R,appSettings:i})]})}var eV=n("SS");function eZ(e){let{sessionId:t,children:n}=e,i=t||"1",[a,l]=(0,s.J0)(!1),o=(0,s.li)(null);(0,s.vJ)(()=>{let e=o.current;if(o.current=i,e!==i){if((0,eV.Y1)(i),e&&e.startsWith("new-")&&!i.startsWith("new-")){(0,eV.vy)(e,i),l(!0);return}if(i.startsWith("new-")){(0,eV.l5)(i),l(!0);return}l(!1),(0,eV.D4)(e).then(()=>(0,eV.L6)(i)).then(()=>{o.current===i&&l(!0)})}},[i]);let c=(0,s.Kr)(()=>({sessionId:i,ready:a}),[i,a]);return(0,r.Y)(ex.b.Provider,{value:c,children:n})}let eQ=(0,a.RZ)(()=>Promise.all([n.e("f7"),n.e("yx"),n.e("g")]).then(n.bind(n,"Wh")).then(e=>({default:e.MobileLayoutWrapper})));var eX=n("eh");let e0=document.getElementById("app"),e1=window.__OMP_BOOTSTRAP__;(0,Q.x9)(e1?.appSettings),(0,eX.iv)(),e0&&(0,i.Qv)((0,r.Y)(function(e){let{initialIsMobile:t=!1,appSettings:n={}}=e,[i]=(0,l.o)(),o=i.get("sessionId")||"1",[c,d]=(0,s.J0)(t),u=(0,s.li)(!1);return((0,s.vJ)(()=>{let e=()=>{let e=window.innerWidth<768,t=window.matchMedia("(pointer: coarse)").matches,n=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Mobile|mobile|CriOS/i.test(navigator.userAgent),r=t&&window.innerHeight<550&&window.innerWidth<1024;return e||n||r};u.current||d(e());let t=()=>{u.current||d(e())};return window.addEventListener("resize",t),window.addEventListener("orientationchange",t),()=>{window.removeEventListener("resize",t),window.removeEventListener("orientationchange",t)}},[]),c)?(0,r.Y)(eZ,{sessionId:o,children:(0,r.Y)(et.O,{children:(0,r.Y)(a.tY,{fallback:null,children:(0,r.Y)(eQ,{onDesktopToggle:()=>{u.current=!0,d(!1)},appSettings:n})})})}):(0,r.Y)(eZ,{sessionId:o,children:(0,r.Y)(et.O,{children:(0,r.Y)(eG,{sessionId:o,onSwitchToMobile:()=>{u.current=!0,d(!0)},appSettings:n})})})},{initialIsMobile:e1?.initialIsMobile,appSettings:e1?.appSettings}),e0)},Fb(e,t,n){let r="omp:browser-include-page";function i(e){"u">typeof window&&window.dispatchEvent(new CustomEvent(r,{detail:e}))}n.d(t,{q:()=>i},{j:r})},ns(e,t,n){var r=n("Sm");let i="agent",s="command",a=new Map,l=new Map;async function o(e){let t=await fetch(e);if(!t.ok)throw Error(`GET ${e} failed: ${t.status}`);let n=await t.json();if(!n||"object"!=typeof n)throw Error(`GET ${e} returned malformed JSON`);return n}async function c(){let e=a.get(i);if(e&&e.expiresAt>Date.now())return e.data;let t=l.get(i);if(t)return t;let n=(async()=>{try{let e=(await o("/api/settings/agents")).agents.map(e=>({id:`agent-${e.name}`,name:e.name,description:e.description,kind:"agent",source:"agent",token:`@${e.name}`}));return a.set(i,{data:e,expiresAt:Date.now()+3e5}),e}finally{l.delete(i)}})();return l.set(i,n),n}async function d(e){let t,n=(t=e??"",`file::${t}`),r=a.get(n);if(r&&r.expiresAt>Date.now())return r.data;let i=l.get(n);if(i)return i;let s=(async()=>{try{let t=e?`?root=${encodeURIComponent(e)}`:"",r=await o(`/api/fs/list${t}`),i=(Array.isArray(r.files)?r.files:[]).map(e=>({id:`file-${e.path}`,name:e.path,description:"",kind:"file",source:"file",token:/\s/.test(e.path)?`@"file:${e.path}"`:`@file:${e.path}`,path:e.path}));return a.set(n,{data:i,expiresAt:Date.now()+3e5}),i}catch{return[]}finally{l.delete(n)}})();return l.set(n,s),s}async function u(){let e=a.get(s);if(e&&e.expiresAt>Date.now())return e.data;let t=l.get(s);if(t)return t;let n=(async()=>{try{let[e,t]=await Promise.all([o("/api/settings/commands"),o("/api/settings/skills")]),n=function(e,t){let n=[],i=new Set;for(let t of[...r.kn,...e]){let e=t.name.toLowerCase();if(i.has(e))continue;i.add(e);let r=t.description??"";n.push({id:`command-${t.name}`,name:t.name,description:t.inputHint?r?`${t.inputHint} - ${r}`:t.inputHint:r,kind:t.name.toLowerCase().startsWith("skill:")?"skill":"command",source:t.name.toLowerCase().startsWith("skill:")?"skill":"command",token:`/${t.name}`,...t.aliases?.length?{aliases:t.aliases}:{},...t.subcommands?.length?{subcommands:t.subcommands}:{},...t.inputHint?{inputHint:t.inputHint}:{}})}for(let e of t){let t=e.name.toLowerCase(),r=`skill:${t}`;i.has(t)||i.has(r)||(i.add(r),n.push({id:`skill-${e.name}`,name:r,description:e.description,kind:"skill",source:"skill",token:`/${r}`}))}return n}(e.commands,t.skills);return a.set(s,{data:n,expiresAt:Date.now()+3e5}),n}finally{l.delete(s)}})();return l.set(s,n),n}function p(e,t){return"mention"===e?Promise.all([c(),d(t??null)]).then(e=>{let[t,n]=e;return[...t,...n]}):u()}async function m(){try{return(await c()).map(e=>e.name)}catch{return[]}}function h(e){if(e){a.delete(e),l.delete(e);return}a.clear(),l.clear()}n.d(t,{O7:()=>m,SA:()=>h,bF:()=>p})},Sm(e,t,n){let r=/[\s([{]/,i=[{id:"chamber-btw",name:"btw",description:"Ask a side question, or browse this session's BTW history",scope:"system",template:"",isBuiltIn:!0,inputHint:"[question]"}];function s(e,t,n,r){for(let n=0;n<t;n+=1)if(""!==(e[n]??"").trim())return!0;return""!==n.slice(0,r).trim()}function a(e,t){let n,i=Math.max(0,Math.min(t,e.length)),a=e.slice(0,i),l=e.split("\n"),o=(a.match(/\n/g)??[]).length,c=a.lastIndexOf("\n")+1,d=a.slice(c),u=(n=d.trimStart()).startsWith("/")?d.length-n.length:null,p=function(e){let t=/(?:^|\s)\/([^\s/]*)$/.exec(e);if(!t||void 0===t.index)return null;let n=t[0].indexOf("/");return t.index+n}(d),m=null!==p&&s(l,o,d,p),h=null!==u&&s(l,o,d,u),f=m?p:h?null:u;if(null!==f){let e=d.slice(f),t=e.indexOf(" ");if(-1===t)return{kind:"command",query:e.slice(1),start:c+f,end:i,phase:"name",replaceFrom:c+f,...m?{midPrompt:!0}:{}};if(!m){let n=c+f+t+1;return{kind:"command",query:a.slice(n),start:c+f,end:i,phase:"args",replaceFrom:n,command:e.slice(1,t)}}}for(let e=d.length-1;e>=0;e--){let t=d[e];if(/\s/.test(t))break;if("@"===t){if(0===e||r.test(d[e-1])){let t=c+e;return{kind:"mention",query:a.slice(t+1),start:t,end:i,phase:"name",replaceFrom:t}}break}}return null}function l(e){return e.insertWithoutSpace?e.token:`${e.token} `}function o(e,t){let n;return!!t&&"command"===e.kind&&"name"===e.phase&&t.name.toLowerCase()===e.query.toLowerCase()&&(n=t.name.toLowerCase(),i.some(e=>e.name.toLowerCase()===n))}function c(e,t,n){return{value:e.slice(0,t.replaceFrom)+n+e.slice(t.end),caret:t.replaceFrom+n.length}}n.d(t,{Ct:()=>l,Rc:()=>c,an:()=>o,eC:()=>a},{kn:i,yG:"/skill:"})},K(e,t,n){var r=n("oS"),i=n("zG");let s={edit:!0,write:!0,ast_edit:!0,bash:!0};function a(e){let t="string"==typeof e.toolName?e.toolName.toLowerCase():"",n=i.YT[t]??t;if(!s[n])return!1;let a=(0,r.u)(e.args)?e.args:{},l=(0,i.oJ)(a.path)??(0,i.oJ)(a.target);return!("write"===n&&"string"==typeof l&&l.startsWith("xd://"))}n.d(t,{Y:()=>a},{s:"omp:files-mutated"})},g0(e,t,n){var r=n("Kn");let i="omp:stream-status",s={transport:(0,r.ul)(),connected:!1};function a(){return s}function l(e){e.transport===s.transport&&e.connected===s.connected||(s=e,"u">typeof window&&window.dispatchEvent(new CustomEvent(i,{detail:e})))}n.d(t,{aK:()=>a,dX:()=>l},{rt:i})},Kn(e,t,n){var r=n("So");function i(e){let t="https:"===window.location.protocol?"wss:":"ws:";return`${t}//${window.location.host}/api/agent/${encodeURIComponent(e)}/ws`}function s(e){return`/api/agent/${encodeURIComponent(e)}/events`}function a(e){let t="https:"===window.location.protocol?"wss:":"ws:";return`${t}//${window.location.host}/api/btw/${encodeURIComponent(e)}/ws`}function l(e){return`/api/btw/${encodeURIComponent(e)}/events`}function o(e){let t=(0,r.BF)("streamTransport",e);return"sse"===t||"websocket"===t?t:"websocket"}n.d(t,{Ec:()=>l,_m:()=>s,oU:()=>a,qq:()=>i,ul:()=>o})},G1(e,t,n){function r(e,t){let n=function(e){let t=e.trim();if(!t)return null;let n="message",r=[];for(let e of t.split("\n"))!e.startsWith(":")&&(e.startsWith("event:")?n=e.replace(/^event:\s*/,"").trim():e.startsWith("data:")&&r.push(e.replace(/^data:\s*/,"")));return 0===r.length?null:{event:n,data:r.join("\n")}}(e);return!!n&&!0===t(n.event,n.data)}async function i(e,t,n){let i=e.body?.getReader();if(!i)return;let s=new TextDecoder("utf-8"),a="";try{for(;;){if(n?.aborted){try{await i.cancel()}catch{}return}let{done:e,value:l}=await i.read();if(e)break;let o=(a+=s.decode(l,{stream:!0})).split("\n\n");for(let e of(a=o.pop()??"",o))if(r(e,t))return}a&&r(a,t)}finally{try{i.releaseLock()}catch{}}}n.d(t,{o:()=>i})},zG(e,t,n){var r=n("oS"),i=n("e");function s(e){if("string"!=typeof e)return;let t=e.trim();return t.length>0?t:void 0}function a(e,t){for(let n of t){let t=e[n],r=s(t);if(r)return r;if(Array.isArray(t)){let e=t.find(e=>void 0!==s(e));if(void 0!==e)return s(e)}}}function l(e){return e.length<=72?e:`${e.slice(0,71)}…`}function o(e){if(e)return/^["'`]/.test(e)?e:`"${e}"`}function c(e,t){switch(e){case"read":case"write":case"edit":return a(t,["path","file","AbsolutePath","TargetFile"])??(0,i.f$)(t);case"ast_edit":return a(t,["paths","path"]);case"ast_grep":{let e=o(a(t,["pat"]));return e?`for ${e}`:void 0}case"bash":return a(t,["command","cmd","CommandLine"]);case"grep":{let e=a(t,["pattern"]),n=a(t,["path","paths"]);if(!e)return n;return n?`for ${o(e)} in ${n}`:`for ${o(e)}`}case"glob":return a(t,["path","pattern"]);case"web_search":{let e=o(a(t,["query"]));return e?`for ${e}`:void 0}case"task":let n,l,c,d;return n=s(t.name),l=(Array.isArray(t.tasks)?t.tasks:[]).find(r.u),c=n??(l?s(l.name):void 0),d=s(t.agent)??(l?s(l.agent):void 0),c&&d?`to ${c} (${d})`:c?`to ${c}`:d?`to ${d}`:void 0;case"hub":return[a(t,["op"]),a(t,["name"])].filter(Boolean).join(" ")||void 0;case"todo":{let e=a(t,["op"]);return e?`\xb7 ${e}`:void 0}case"eval":{let e=a(t,["language"]);return e?`in ${e}`:void 0}case"lsp":return[a(t,["action"]),a(t,["symbol","file"])].filter(Boolean).join(" ")||void 0;case"debug":return a(t,["action","program"]);case"github":return[a(t,["op"]),a(t,["repo","pr","query"])].filter(Boolean).join(" ")||void 0;case"ask":let u=(Array.isArray(t.questions)?t.questions:[]).find(r.u);if(u)return s(u.header)??s(u.question);return;case"checkpoint":return a(t,["goal"]);case"manage_skill":return a(t,["name"]);case"recall":return o(a(t,["query"]));case"reflect":{let e=o(a(t,["query"]));return e?`on ${e}`:void 0}case"security_scan":return a(t,["target_kind","include_paths"]);case"retain":let p;return(p=(Array.isArray(t.items)?t.items:[]).find(r.u))?o(s(p.content)):void 0;default:return a(t,["path","command","query","pattern","name","target","prose"])}}n.d(t,{Up:()=>a,oJ:()=>s,qL:()=>c,xv:()=>l},{K$:{read:"Reading",write:"Writing",edit:"Editing",ast_edit:"Rewriting AST",ast_grep:"Searching AST",bash:"Running",grep:"Searching",glob:"Finding",task:"Delegating",todo:"Updating plan",hub:"Hub",eval:"Running code",lsp:"Running LSP",debug:"Debugging",github:"GitHub",web_search:"Searching the web",ask:"Asking you",checkpoint:"Checkpointing",rewind:"Rewinding",context_notes:"Updating context notes",new_context:"Starting a fresh context",security_scan:"Scanning for vulnerabilities",manage_skill:"Updating skill",learn:"Recording a lesson",retain:"Retaining memory",recall:"Recalling memory",reflect:"Reflecting",think:"Thinking",yield:"Wrapping up",goal:"Tracking goal"},Qq:{lsp:"Running LSP",ast_edit:"Rewriting AST",ast_grep:"Searching AST",resolve:"Applying edit proposal",reject:"Discarding edit proposal",report_issue:"Reporting tool issue",debug:"Debugging",browser:"Driving the browser"},YT:{read_file:"read",view_file:"read",read_file_content:"read",edit_file:"edit",replace_file_content:"edit",multi_edit_file:"edit",write_to_file:"write",create_file:"write",search_fs:"grep",terminal:"bash",run_command:"bash"},n1:{thinking:"Thinking",writing:"Writing response"}})},pm(e,t,n){var r=n("U8");function i(e){return(0,r.Rk)(e)}n.d(t,{F:()=>i})},eh(e,t,n){n.d(t,{iv:()=>w,tn:()=>v,F:()=>D,nv:()=>N,LT:()=>F,Eu:()=>Y,sT:()=>A});var r=n("CU"),i=n("he"),s=n("h3"),a=n("g1");let l={typescript:()=>n.e("zn").then(n.bind(n,"tt")),tsx:()=>n.e("ta").then(n.bind(n,"Xl")),javascript:()=>n.e("jsc").then(n.bind(n,"lK")),jsx:()=>n.e("px").then(n.bind(n,"rz")),json:()=>n.e("zj").then(n.bind(n,"BB")),markdown:()=>n.e("2v").then(n.bind(n,"sN")),css:()=>n.e("n").then(n.bind(n,"d2")),bash:()=>Promise.all([n.e(2),n.e(6)]).then(n.bind(n,"ks")),diff:()=>n.e("0w").then(n.bind(n,"SP")),yaml:()=>n.e("ho").then(n.bind(n,"n1")),html:()=>Promise.all([n.e("jsc"),n.e("n"),n.e("aa")]).then(n.bind(n,"w1")),python:()=>n.e("jd").then(n.bind(n,"hE")),go:()=>n.e("cf").then(n.bind(n,"K1")),rust:()=>n.e("hk").then(n.bind(n,"nb")),sql:()=>n.e("r").then(n.bind(n,"le")),toml:()=>n.e("x0").then(n.bind(n,"DJ")),java:()=>n.e("f8").then(n.bind(n,"lj")),c:()=>n.e("4e").then(n.bind(n,"Gd")),cpp:()=>Promise.all([n.e("4e"),n.e("y6")]).then(n.bind(n,"gB")),csharp:()=>n.e("4k").then(n.bind(n,"Ku")),ruby:()=>Promise.all([n.e("jsc"),n.e("n"),n.e("zn"),n.e("aa"),n.e("4e"),n.e("f8"),n.e("r"),n.e("ta"),n.e("y6"),n.e("px"),n.e(2),n.e("yv"),n.e("ct")]).then(n.bind(n,"eV")),php:()=>Promise.all([n.e("jsc"),n.e("n"),n.e("aa"),n.e("f8"),n.e("r"),n.e(4)]).then(n.bind(n,"eZ")),kotlin:()=>n.e("7l").then(n.bind(n,"hRx")),swift:()=>n.e(0).then(n.bind(n,"ep")),scala:()=>n.e("js").then(n.bind(n,"h3S")),lua:()=>Promise.all([n.e("4e"),n.e("hd")]).then(n.bind(n,"rF")),perl:()=>Promise.all([n.e("jsc"),n.e("n"),n.e("aa"),n.e("f8"),n.e("r"),n.e("i")]).then(n.bind(n,"cr")),dockerfile:()=>n.e("b").then(n.bind(n,"BZ")),ini:()=>n.e("3p").then(n.bind(n,"BD")),properties:()=>n.e("1b").then(n.bind(n,"LU")),zig:()=>n.e("3u").then(n.bind(n,"p9")),elixir:()=>Promise.all([n.e("jsc"),n.e("n"),n.e("aa"),n.e("jll")]).then(n.bind(n,"xu")),dart:()=>n.e("4q").then(n.bind(n,"Cu")),ocaml:()=>n.e("8j").then(n.bind(n,"uA")),haskell:()=>n.e("a").then(n.bind(n,"IX")),nix:()=>n.e("p").then(n.bind(n,"jG")),hcl:()=>n.e("yq").then(n.bind(n,"ka")),graphql:()=>Promise.all([n.e("jsc"),n.e("zn"),n.e("ta"),n.e("px"),n.e("yv")]).then(n.bind(n,"ok")),solidity:()=>n.e("w").then(n.bind(n,"me")),r:()=>n.e(37).then(n.bind(n,"pO")),julia:()=>Promise.all([n.e("jsc"),n.e("4e"),n.e("r"),n.e("y6"),n.e("jd"),n.e("t9")]).then(n.bind(n,"zu")),erlang:()=>Promise.all([n.e("2v"),n.e("y")]).then(n.bind(n,"EY")),clojure:()=>n.e("3d").then(n.bind(n,"lF")),scheme:()=>n.e("az").then(n.bind(n,"wE")),racket:()=>n.e(8).then(n.bind(n,"aB")),protobuf:()=>n.e("1p").then(n.bind(n,"bT")),makefile:()=>n.e("d").then(n.bind(n,"nt")),powershell:()=>n.e("j").then(n.bind(n,"dQ")),json5:()=>n.e("bq").then(n.bind(n,"VH")),less:()=>n.e("c").then(n.bind(n,"i")),scss:()=>Promise.all([n.e("n"),n.e("x")]).then(n.bind(n,"DD")),sass:()=>n.e("zo").then(n.bind(n,"Bc")),stylus:()=>n.e("ky").then(n.bind(n,"uc")),"objective-c":()=>n.e(7).then(n.bind(n,"BG")),groovy:()=>n.e("7e").then(n.bind(n,"tf")),vue:()=>Promise.all([n.e("jsc"),n.e("n"),n.e("zn"),n.e("aa"),n.e("zx")]).then(n.bind(n,"Z")),svelte:()=>Promise.all([n.e("jsc"),n.e("n"),n.e("zn"),n.e("dp")]).then(n.bind(n,"jIY")),astro:()=>Promise.all([n.e("jsc"),n.e("n"),n.e("zn"),n.e("ta"),n.e("o")]).then(n.bind(n,"CuL")),xml:()=>Promise.all([n.e("f8"),n.e("da")]).then(n.bind(n,"rDW"))},o=["typescript","tsx","javascript","jsx","json","bash","python","markdown","yaml","diff"],c=new Map,d=new Set,u=new Set,p={text:!0,plain:!0,plaintext:!0,txt:!0,ansi:!0,none:!0};function m(e){return!0===p[e]||d.has(e)}function h(e,t){if(m(t))return Promise.resolve();let n=c.get(t);if(n)return n;let r=l[t];if(!r)return Promise.resolve();let i=e.loadLanguage(r).then(()=>{for(let e of(d.add(t),u))e()}).catch(()=>{}).finally(()=>{c.delete(t)});return c.set(t,i),i}async function f(e,t){await Promise.all(t.map(t=>h(e,t)))}let x=null,g=!1,b=new Set;function v(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}async function k(){if("u"<typeof window)return null;try{let e=await (0,r.tz)({themes:[s.A,a.A],langs:[],engine:(0,i.l)({forgiving:!0})});x=e,g=!0;let t=[...b];for(let e of(b.clear(),t))try{e()}catch{}return f(e,o),e}catch(e){return console.error("[shiki] highlighter boot failed",e),null}}let y=null;function w(){return y||(y=k()),y}function N(){return g}function Y(e){return g?(e(),()=>{}):(b.add(e),()=>{b.delete(e)})}function D(){return g?x:null}function A(e){return!!x&&(h(x,e),m(e))}let F=function(e){return u.add(e),()=>{u.delete(e)}}},DU(e,t,n){n.d(t,{sQ:()=>s,wY:()=>o,PH:()=>c,O9:()=>d,rw:()=>a,Bl:()=>function e(t){if(null==t)return{isValid:!1};if("object"==typeof t)try{let e=JSON.stringify(t,null,2),n=e.split("\n").length;return{isValid:!0,data:t,pretty:e,linesCount:n}}catch{return{isValid:!1}}if("string"!=typeof t)return{isValid:!1};let n=t.trim();if(!n)return{isValid:!1};let r=n.match(/^```(?:json)?\s*([\s\S]*?)\s*```$/i);r&&(n=r[1].trim());let i=n.match(/^(?:user\s+(?:selected|responded|answered|response)|response|result|output):\s*([\s\S]+)$/i);if(i){let e=i[1].trim();(e.startsWith("{")&&e.endsWith("}")||e.startsWith("[")&&e.endsWith("]"))&&(n=e)}if(n.startsWith('"')&&n.endsWith('"')||n.startsWith("'")&&n.endsWith("'"))try{let t=JSON.parse(n);if("object"==typeof t&&null!==t){let e=JSON.stringify(t,null,2);return{isValid:!0,data:t,pretty:e,linesCount:e.split("\n").length}}if("string"==typeof t){let n=e(t);if(n.isValid)return n}}catch{}if(n.startsWith("{")||n.startsWith("["))try{let e=JSON.parse(n);if(null!==e&&"object"==typeof e){let t=JSON.stringify(e,null,2),n=t.split("\n").length;return{isValid:!0,data:e,pretty:t,linesCount:n}}}catch{}let s=n.indexOf("{"),a=n.lastIndexOf("}");if(-1!==s&&a>s){let e=n.slice(s,a+1);try{let t=JSON.parse(e);if(null!==t&&"object"==typeof t){let e=JSON.stringify(t,null,2);return{isValid:!0,data:t,pretty:e,linesCount:e.split("\n").length}}}catch{}}let l=n.indexOf("["),o=n.lastIndexOf("]");if(-1!==l&&o>l){let e=n.slice(l,o+1);try{let t=JSON.parse(e);if(Array.isArray(t)){let e=JSON.stringify(t,null,2);return{isValid:!0,data:t,pretty:e,linesCount:e.split("\n").length}}}catch{}}return{isValid:!1}}});var r=n("eh");let i={light:"one-light",dark:"one-dark-pro"};function s(e){if(!e)return"javascript";let t=e.split("?")[0].split("#")[0].replace(/:\d+(?:-\d+)?$/,"");switch(t.split(".").pop()?.toLowerCase()){case"ts":return"typescript";case"tsx":return"tsx";case"js":case"mjs":case"cjs":default:return"javascript";case"jsx":return"jsx";case"json":return"json";case"md":case"markdown":return"markdown";case"css":return"css";case"sh":case"bash":case"zsh":case"env":return"bash";case"diff":case"patch":return"diff";case"yaml":case"yml":return"yaml";case"html":return"html";case"svg":case"xml":return"xml";case"py":return"python";case"go":return"go";case"rs":return"rust";case"sql":return"sql";case"toml":return"toml";case"java":return"java";case"c":case"h":return"c";case"cpp":case"cc":case"hpp":return"cpp";case"cs":return"csharp";case"rb":return"ruby";case"php":return"php";case"kt":case"kts":return"kotlin";case"swift":return"swift";case"scala":return"scala";case"lua":return"lua";case"pl":return"perl";case"dockerfile":return"dockerfile";case"ini":case"cfg":case"conf":return"ini";case"properties":return"properties";case"zig":return"zig";case"ex":case"exs":return"elixir";case"dart":return"dart";case"ml":case"mli":return"ocaml";case"hs":return"haskell";case"nix":return"nix";case"tf":case"tfvars":case"hcl":return"hcl";case"graphql":case"gql":return"graphql";case"sol":return"solidity";case"r":return"r";case"jl":return"julia";case"erl":return"erlang";case"clj":case"cljs":case"cljc":case"edn":return"clojure";case"scm":case"ss":return"scheme";case"rkt":return"racket";case"proto":return"protobuf";case"makefile":case"mk":return"makefile";case"ps1":case"psm1":return"powershell";case"json5":return"json5";case"less":return"less";case"scss":return"scss";case"sass":return"sass";case"styl":return"stylus";case"vue":return"vue";case"svelte":return"svelte";case"astro":return"astro";case"mm":case"m":return"objective-c";case"groovy":case"gvy":case"gradle":return"groovy"}}function a(e){if(!e||e.length<5)return!1;let t=e.trim();if(t.startsWith("{")&&t.endsWith("}")||t.startsWith("[")&&t.endsWith("]"))try{return JSON.parse(t),!0}catch{}return[/^(?:import|export)\s+.+from\s+['"][^'"]+['"]/m,/^(?:const|let|var|function|class|interface|type|enum)\s+[A-Za-z0-9_$]+/m,/(?:=>|\bconsole\.(?:log|error|warn)|return\s+|async\s+function)/,/^\s*\d+:\s*(?:import|const|let|function|\/\/|\/\*|<|[A-Za-z])/m,/^\s*\[[A-Za-z0-9_./-]+\.[a-zA-Z0-9]+\]\s*\n\d+:/m].some(e=>e.test(t))}function l(e,t){return(0,r.sT)(t)||e.getLoadedLanguages().includes(t)?t:"javascript"}function o(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"javascript";if(!e)return"";let n=(0,r.F)();if(!n)return(0,r.tn)(e);let s=l(n,t);try{return`<span class="shiki">${n.codeToHtml(e,{lang:s,themes:i,defaultColor:!1,structure:"inline"})}</span>`}catch{return(0,r.tn)(e)}}function c(e){return o(e,"json")}function d(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"javascript",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s=e.split("\n");if(!e)return s;let a=(0,r.F)();if(!a)return s.map(r.tn);let o=l(a,t);try{let{tokens:t}=a.codeToTokens(e,{lang:o,themes:i,defaultColor:!1,tokenizeMaxLineLength:n.maxLineLength??0});if(t.length!==s.length)return s.map(r.tn);return t.map(e=>e.map(e=>{let t=(0,r.tn)(e.content);if(!e.htmlStyle)return t;let n=Object.entries(e.htmlStyle).map(e=>{let[t,n]=e;return`${t}:${n}`}).join(";");return n?`<span style="${n}">${t}</span>`:t}).join(""))}catch{return s.map(r.tn)}}},U8(e,t,n){function r(e){if(null!=e){if("string"==typeof e)return e;if(Number.isFinite(e)&&!(e<=0)){if(e>=1e6){let t=e/1e6;return`${Number.isInteger(t)?t:t.toFixed(1)}M`}if(e>=1e3){let t=e/1e3;return`${Number.isInteger(t)?t:t.toFixed(1)}K`}return String(e)}}}function i(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;return"number"!=typeof e||!Number.isFinite(e)||e<=0?"":`$${e.toFixed(t)}`}function s(e){return"number"!=typeof e||!Number.isFinite(e)||e<0?"":e<1024?`${Math.round(e)} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(2)} MB`}function a(e){return"number"!=typeof e||!Number.isFinite(e)||e<0?"":`$${e.toFixed(2)}`}n.d(t,{$g:()=>a,BD:()=>i,Rk:()=>r,z3:()=>s})},JK(e,t,n){let r={png:"image/png",apng:"image/apng",jpg:"image/jpeg",jpeg:"image/jpeg",jfif:"image/jpeg",gif:"image/gif",webp:"image/webp",avif:"image/avif",bmp:"image/bmp",ico:"image/x-icon",tif:"image/tiff",tiff:"image/tiff"};function i(e){return r[function(e){if(!e)return"";let t=e.split("?")[0].split("#")[0].split(/[/\\]/).pop()??"",n=t.lastIndexOf(".");return n>0?t.slice(n+1).toLowerCase():""}(e)]??null}n.d(t,{CC:()=>i})},LQ(e,t,n){function r(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n="M",r="Modified",i="text-info",s="bg-info/10 text-info border-info/25",a=(e||"").trim().toUpperCase();if(t){let e=a[0]||"M";"A"===e?(n="A",r="Added (Staged)",i="text-success",s="bg-success/10 text-success border-success/25"):"D"===e?(n="D",r="Deleted (Staged)",i="text-error",s="bg-error/10 text-error border-error/25"):"R"===e?(n="R",r="Renamed (Staged)",i="text-meta",s="bg-meta/10 text-meta border-meta/25"):"U"===e||"?"===e?(n="U",r="Untracked",i="text-success",s="bg-success/10 text-success border-success/25"):(n="M",r="Modified (Staged)",i="text-info",s="bg-info/10 text-info border-info/25")}else if("??"===a||"?"===a||"U"===a||"UNTRACKED"===a)n="U",r="Untracked",i="text-success",s="bg-success/10 text-success border-success/25";else{let e=a[1]||a[0]||"M";"A"===e?(n="A",r="Added",i="text-success",s="bg-success/10 text-success border-success/25"):"D"===e?(n="D",r="Deleted",i="text-error",s="bg-error/10 text-error border-error/25"):"R"===e?(n="R",r="Renamed",i="text-meta",s="bg-meta/10 text-meta border-meta/25"):"U"===e||"?"===e?(n="U",r="Untracked",i="text-success",s="bg-success/10 text-success border-success/25"):(n="M",r="Modified",i="text-info",s="bg-info/10 text-info border-info/25")}return{charStatus:n,label:r,colorClass:i,badgeBgClass:s,isStaged:t}}function i(e){let t=new Map,n=new Map;if(!Array.isArray(e))return{fileMap:t,folderMap:n};for(let r of e){if(!r||!r.file)continue;let e=r.file.replace(/^\/+/,"");t.set(e,r);let i=e.split("/");i.pop();let s="";for(let e of i){s=s?`${s}/${e}`:e;let t=n.get(s)||{count:0,hasModified:!1,hasUntracked:!1,hasStaged:!1,hasDeleted:!1,colorClass:"text-info"};t.count+=1,(r.staged||r.status&&" "!==r.status[0]&&"?"!==r.status[0])&&(t.hasStaged=!0),"??"===r.status?t.hasUntracked=!0:r.status?.includes("D")?t.hasDeleted=!0:t.hasModified=!0,t.hasModified||t.hasStaged?t.colorClass="text-info":t.hasUntracked?t.colorClass="text-success":t.hasDeleted&&(t.colorClass="text-error"),n.set(s,t)}}return{fileMap:t,folderMap:n}}n.d(t,{R:()=>r,_:()=>i})},tZ(e,t,n){function r(e){let t=new URLSearchParams({path:e.path});return e.root&&t.set("root",e.root),e.repo&&"."!==e.repo&&t.set("repo",e.repo),`/api/fs/raw?${t.toString()}`}function i(e,t){let n=t.replace(/^(?:\.?[/\\])+/,"").replace(/[/\\]+$/,""),r=(e??"").replace(/[/\\]+$/,"");return r?n?`${r}${r.includes("\\")&&!r.includes("/")?"\\":"/"}${n}`:r:n}n.d(t,{A:()=>i,l:()=>r})},W9(e,t,n){let r=null,i=null;function s(){return i&&i.expiresAt>Date.now()?Promise.resolve(i.data):r||(r=fetch("/api/models").then(e=>e.ok?e.json():Promise.reject(Error(`GET /api/models failed: ${e.status}`))).then(e=>(i={data:e,expiresAt:Date.now()+6e4},e)).finally(()=>{r=null}))}function a(){i=null}function l(){i=null,window.dispatchEvent(new CustomEvent("omp:models-updated"))}function o(e){return window.addEventListener("omp:models-updated",e),()=>window.removeEventListener("omp:models-updated",e)}n.d(t,{$P:()=>l,Sy:()=>o,kn:()=>a,xo:()=>s})},Np(e,t,n){let r="new-";function i(e){return String(e).padStart(2,"0")}function s(e){return!!e?.startsWith(r)}function a(e){return e?.startsWith(r)?Number(e.slice(r.length)):0/0}function l(e){let t=a(e);return function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Date;return Number.isNaN(e.getTime())?"New Session":`New Session - ${e.getFullYear()}-${i(e.getMonth()+1)}-${i(e.getDate())}T${i(e.getHours())}:${i(e.getMinutes())}:${i(e.getSeconds())}`}(Number.isFinite(t)?new Date(t):new Date)}n.d(t,{fN:()=>s,fd:()=>a,g2:()=>l})},e(e,t,n){let r=["input","_input","patch"],i=/#([0-9a-fA-F]{4})$/,s=/^(PUT|CUT)\b/;function a(e){let t=e[0];return e.length>=2&&('"'===t||"'"===t)&&t===e[e.length-1]?e.slice(1,-1):e}function l(e){if(e)for(let t of r){let n=e[t];if("string"!=typeof n)continue;let r=function(e){let t,n=[];for(let r of e.replace(/^\uFEFF/,"").split("\n")){let e=r.endsWith("\r")?r.slice(0,-1):r,l=function(e){let t=e.trimEnd();if(!t.startsWith("["))return;let n=(t.endsWith("]")?t.slice(1,-1):t.slice(1)).trim(),r=i.exec(n),s=a((r?n.slice(0,r.index):n).trim());return s?{path:s,tag:r?.[1]}:void 0}(e);if(l){t={path:l.path,tag:l.tag,removed:!1,ops:[]},n.push(t);continue}if(!t)continue;let o=e.trim();if("REM"===o){t.removed=!0;continue}if(o.startsWith("MV ")){t.moveTo=a(o.slice(3).trim())||void 0;continue}if(s.test(o)){t.ops.push({verb:o.slice(0,3),spec:o.slice(3).trim().replace(/:$/,""),body:[]});continue}let c=t.ops[t.ops.length-1];c&&e.startsWith("+")&&c.body.push(e)}return n}(n);if(r.length>0)return{text:n,sections:r}}}function o(e){return l(e)?.sections[0].path}n.d(t,{I:()=>l,f$:()=>o})},wm(e,t,n){function r(e,t){e&&fetch("/api/agent/prewarm",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,...t?{accessMode:t}:{}})}).catch(()=>{})}function i(e,t,n){let r=void 0!==n?e.find(e=>String(e.id)===String(n)):e.find(e=>e.sessions?.some(e=>String(e.id)===String(t)))??e.find(e=>!!e.project_path);return r?.project_path||r?.name||null}n.d(t,{l:()=>i,r:()=>r})},B(e,t,n){var r=n("oS");function i(e){return(0,r.u)(e)&&"string"==typeof e.id&&e.id.length>0&&"string"==typeof e.agent&&e.agent.length>0&&"string"==typeof e.status&&"number"==typeof e.index}async function s(e){try{let t=await fetch(`/api/sessions/${encodeURIComponent(e)}/subagents`);if(!t.ok)return null;let n=await t.json().catch(()=>null);if(!(0,r.u)(n))return null;let s=(0,r.u)(n.data)?n.data:n;if(!Array.isArray(s.subagents))return null;return s.subagents.filter(i)}catch{return null}}function a(e){let t={...e,source:"history",lastUpdate:0},n={};return void 0!==e.lastIntent&&(n.lastIntent=e.lastIntent),void 0!==e.toolCount&&(n.toolCount=e.toolCount),void 0!==e.requests&&(n.requests=e.requests),void 0!==e.tokens&&(n.tokens=e.tokens),void 0!==e.contextTokens&&(n.contextTokens=e.contextTokens),void 0!==e.contextWindow&&(n.contextWindow=e.contextWindow),void 0!==e.cost&&(n.cost=e.cost),void 0!==e.durationMs&&(n.durationMs=e.durationMs),void 0!==e.resolvedModel&&(n.resolvedModel=e.resolvedModel),Object.keys(n).length>0&&(t.progress=n),t}n.d(t,{Nh:()=>a,wv:()=>s})},V7(e,t,n){let r=/^#{1,6}\s+\S/,i=/^#{1,6}\s+target\s*:?\s*$/i,s=/^complete (the )?assignment\b/i;function a(e){for(let t of e){let e=t.trim();if(e)return e}}function l(e){if(!e)return;let t=e.split("\n"),n=t.findIndex(e=>i.test(e.trim()));if(-1!==n){let e=t.slice(n+1),i=e.findIndex(e=>r.test(e.trim())),s=a(-1===i?e:e.slice(0,i));if(s)return s}return a(t.filter(e=>{let t=e.trim();return!r.test(t)&&!s.test(t)}))}function o(e){let t=e.modelRole??e.progress?.modelRole;return t?`${e.id} (${e.agent}:${t})`:`${e.id} (${e.agent})`}function c(e){let t=l(e.task)??l(e.assignment)??e.description,n=`${e.id} (${e.agent})`;return t?`${n}: ${t}`:n}n.d(t,{Ti:()=>o,us:()=>c})},T(e,t,n){var r=n("oS");function i(e){return"string"==typeof e&&e.length>0?e:void 0}function s(e){return"number"==typeof e&&Number.isFinite(e)?e:void 0}function a(e){return"bundled"===e||"user"===e||"project"===e?e:void 0}function l(e){var t;if(!(0,r.u)(e))return;let n={},l=s(e.index);void 0!==l&&(n.index=l);let o=i(e.id);void 0!==o&&(n.id=o);let c=i(e.agent);void 0!==c&&(n.agent=c);let d=a(e.agentSource);void 0!==d&&(n.agentSource=d);let u="pending"===(t=e.status)||"running"===t||"completed"===t||"failed"===t||"aborted"===t?t:void 0;void 0!==u&&(n.status=u);let p=i(e.task);void 0!==p&&(n.task=p);let m=i(e.assignment);void 0!==m&&(n.assignment=m);let h=i(e.description);void 0!==h&&(n.description=h);let f=i(e.lastIntent);void 0!==f&&(n.lastIntent=f);let x=i(e.currentTool);void 0!==x&&(n.currentTool=x);let g=i(e.currentToolArgs);void 0!==g&&(n.currentToolArgs=g);let b=s(e.currentToolStartMs);void 0!==b&&(n.currentToolStartMs=b),Array.isArray(e.recentTools)&&(n.recentTools=e.recentTools),Array.isArray(e.recentOutput)&&(n.recentOutput=e.recentOutput.filter(e=>"string"==typeof e));let v=s(e.toolCount);void 0!==v&&(n.toolCount=v);let k=s(e.requests);void 0!==k&&(n.requests=k);let y=s(e.tokens);void 0!==y&&(n.tokens=y);let w=s(e.contextTokens);void 0!==w&&(n.contextTokens=w);let N=s(e.contextWindow);void 0!==N&&(n.contextWindow=N);let Y=s(e.cost);void 0!==Y&&(n.cost=Y);let D=s(e.durationMs);void 0!==D&&(n.durationMs=D),("string"==typeof e.modelOverride||Array.isArray(e.modelOverride)&&e.modelOverride.every(e=>"string"==typeof e))&&(n.modelOverride=e.modelOverride);let A=i(e.modelRole);void 0!==A&&(n.modelRole=A);let F=i(e.resolvedModel);if(void 0!==F&&(n.resolvedModel=F),"boolean"==typeof e.resolvedModelIsFallback&&(n.resolvedModelIsFallback=e.resolvedModelIsFallback),(0,r.u)(e.retryState)){let t=s(e.retryState.attempt),r=s(e.retryState.maxAttempts),a=s(e.retryState.delayMs),l=i(e.retryState.errorMessage),o=s(e.retryState.startedAtMs);void 0!==t&&void 0!==r&&void 0!==a&&void 0!==l&&void 0!==o&&(n.retryState={attempt:t,maxAttempts:r,delayMs:a,errorMessage:l,startedAtMs:o})}if((0,r.u)(e.retryFailure)){let t=s(e.retryFailure.attempt),r=i(e.retryFailure.errorMessage);void 0!==t&&void 0!==r&&(n.retryFailure={attempt:t,errorMessage:r})}return void 0!==e.inflightTaskDetails&&(n.inflightTaskDetails=e.inflightTaskDetails),(0,r.u)(e.extractedToolData)&&(n.extractedToolData=e.extractedToolData),Object.keys(n).length>0?n:void 0}function o(e){if(!(0,r.u)(e))return;let t=i(e.id),n=i(e.status);if(!t||!n||"started"!==n&&"completed"!==n&&"failed"!==n&&"aborted"!==n)return;let l={id:t,agent:i(e.agent)??"subagent",status:n,index:s(e.index)??-1,lastUpdate:Date.now(),source:"live"},o=a(e.agentSource);void 0!==o&&(l.agentSource=o);let c=i(e.description);void 0!==c&&(l.description=c);let d=i(e.sessionFile);void 0!==d&&(l.sessionFile=d);let u=i(e.parentToolCallId);return void 0!==u&&(l.parentToolCallId=u),"boolean"==typeof e.detached&&(l.detached=e.detached),l}function c(e){if(!(0,r.u)(e))return[];let t=e.subagents;if(!Array.isArray(t))return[];let n=[];for(let e of t){let t=function(e){let t;if(!(0,r.u)(e))return;let n=i(e.id),o=i(e.agent);if(!n||!o)return;if("started"===e.status||"completed"===e.status||"failed"===e.status||"aborted"===e.status)t=e.status;else{if("pending"!==e.status&&"running"!==e.status)return;t="started"}let c={id:n,agent:o,status:t,index:s(e.index)??-1,source:"live"},d=a(e.agentSource);void 0!==d&&(c.agentSource=d);let u=i(e.description);void 0!==u&&(c.description=u);let p=i(e.task);void 0!==p&&(c.task=p);let m=i(e.assignment);void 0!==m&&(c.assignment=m);let h=i(e.sessionFile);void 0!==h&&(c.sessionFile=h);let f=i(e.parentToolCallId);void 0!==f&&(c.parentToolCallId=f),c.lastUpdate=s(e.lastUpdate)??Date.now();let x=l(e.progress);return void 0!==x&&(c.progress=x),c}(e);t&&n.push(t)}return n}function d(e,t){return(e.batchSeq??Number.MAX_SAFE_INTEGER)-(t.batchSeq??Number.MAX_SAFE_INTEGER)||e.index-t.index||e.id.localeCompare(t.id)}function u(e,t,n){let r=new Map(e.map(e=>[e.id,e]));for(let e of t){let t=r.get(e.id);if(!t){r.set(e.id,e);continue}let i=t.batchSeq??e.batchSeq;if(void 0!==n&&(t.lastUpdate??0)>=n||"history"===e.source&&"history"!==t.source){i!==t.batchSeq&&r.set(e.id,{...t,batchSeq:i});continue}if("history"!==e.source&&"history"===t.source){r.set(e.id,{...e,batchSeq:i});continue}r.set(e.id,{...t,...e,batchSeq:i})}return[...r.values()].sort(d)}n.d(t,{bH:()=>o,j8:()=>u,mq:()=>l,vG:()=>c})},So(e,t,n){let r="omp_chamber_settings",i=null,s={};function a(e){s={...e?.[r]??{}};let t={...e??{}};delete t[r],i={...t,...s}}function l(e){return i||a(e),i??{}}function o(e,t){let n=Array.isArray(e)?e:[e],r=l(t);for(let e of n)if(void 0!==r[e])return r[e]}function c(e,t){return l(t),{...e,...s}}function d(e,t){i={...l(),[e]:t},p({[e]:t})}function u(e){s={...s,...e},i={...l(),...e},p({[r]:s})}function p(e){fetch("/api/settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).catch(()=>{})}n.d(t,{BF:()=>o,cm:()=>c,cz:()=>d,l1:()=>u,x9:()=>a})},oS(e,t,n){function r(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}n.d(t,{u:()=>r})},Gb(e,t,n){function r(e,t){if(!t)return{folder:null,projectPath:null};for(let n of e)if((n.sessions||[]).some(e=>String(e.id)===String(t)))return{folder:n,projectPath:n.project_path??null};return{folder:null,projectPath:null}}function i(e,t,n){let i=r(e,t).folder,s=null!=n?e.find(e=>String(e.id)===String(n))??null:null;return(i??s)?.project_path??null}n.d(t,{M:()=>i,t:()=>r})},A(e,t,n){var r=n("g6"),i=n("AB"),s=n("N"),a=n("h"),l=n("al"),o=n("nv"),c=n("nT"),d=n("w"),u=n("Oj"),p=n("Gh"),m=n("R"),h=n("HJ"),f=n("DK"),x=n("f"),g=n("z9"),b=n("Fx"),v=n("F9"),k=n("bt"),y=n("YO"),w=n("by");let N={default:r.A,code:i.A,terminal:s.A,rocket:a.A,flask:l.A,gamepad:o.A,briefcase:c.A,home:d.A,globe:u.A,leaf:p.A,shield:m.A,palette:h.A,server:f.A,smartphone:x.A,database:g.A,lightbulb:b.A,music:v.A,camera:k.A,book:y.A,heart:w.A};function Y(e){return N[e||"default"]||r.A}n.d(t,{x:()=>Y})},ET(e,t,n){let r=["context","files","search","git","terminal","user-browser","browser","usage"];function i(e){return"string"==typeof e&&r.includes(e)}n.d(t,{ls:()=>i},{Cx:{context:.45,files:.22,search:.22,git:.4,terminal:.6,"user-browser":.45,browser:.45,usage:.48},G7:r,lw:{files:200,search:200,git:260,terminal:320,context:420,"user-browser":320,browser:320,usage:420},qv:{context:536,files:268,search:268,git:268,terminal:640,"user-browser":804,browser:804,usage:536}})},SS(e,t,n){let r=new Map,i=new Map,s=new Set,a=new Map,l=new Map;function o(e){let t=r.get(e);void 0!==t&&(r.delete(e),r.set(e,t)),i.set(e,Date.now())}function c(e){let t=Date.now(),n=e=>{r.delete(e),s.delete(e),a.delete(e),i.delete(e);let t=l.get(e);t&&(clearTimeout(t),l.delete(e))};for(let[r,s]of i)!(t-s<=6e5)&&r!==e&&(a.get(r)||n(r));for(;r.size>10;){let t=!1;for(let i of r.keys())if(i!==e&&!a.get(i)){n(i),t=!0;break}if(!t)break}}function d(e,t){if(e)return o(e),r.get(e)?.[t]}function u(e,t,n){if(!e)return;let i=r.get(e)??{};i[t]=n,r.set(e,i),o(e),a.set(e,!0),p(e),c(e)}function p(e){let t=l.get(e);t&&clearTimeout(t),l.set(e,setTimeout(()=>{l.delete(e),m(e)},600))}async function m(e){if("u"<typeof window||!e||!a.get(e))return;a.set(e,!1);let t=r.get(e)??{};try{await fetch(`/api/sessions/${encodeURIComponent(e)}/state`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({state:t})})}catch(t){console.warn("session-state persist failed:",t),a.set(e,!0)}}function h(e){if(!e||"u"<typeof window)return Promise.resolve();let t=l.get(e);return t&&(clearTimeout(t),l.delete(e)),m(e)}async function f(e){if(e){if("u"<typeof window)return void s.add(e);try{let t=await fetch(`/api/sessions/${encodeURIComponent(e)}/state`);if(t.ok){let n=await t.json(),i=n.state&&"object"==typeof n.state?n.state:{},s=r.get(e)??{},l=!0===a.get(e)?{...i,...s}:i;r.set(e,l),o(e)}}catch(e){console.warn("session-state load failed:",e)}s.add(e),c(e)}}function x(e,t){e&&(r.set(e,{...r.get(e)??{},...t}),o(e),s.add(e),c(e))}function g(e){e&&s.add(e)}function b(e){e&&i.set(e,Date.now())}function v(e){return i.get(e)}function k(e,t){let n=r.get(e);n&&r.set(t,{...n,...r.get(t)??{}}),o(t),s.add(t),a.set(t,!0),p(t),r.delete(e),s.delete(e),a.delete(e),i.delete(e),c(t)}n.d(t,{D4:()=>h,E9:()=>x,L6:()=>f,R7:()=>v,WV:()=>d,Y1:()=>b,l5:()=>g,qI:()=>u,vy:()=>k})},P(e){e.exports={rE:"1.2.0"}}},a={};function l(e){var t=a[e];if(void 0!==t)return t.exports;var n=a[e]={exports:{}};return s[e].call(n.exports,n,n.exports,l),n.exports}l.m=s,l.d=(e,t,n)=>{var r=(t,n)=>{for(var r in t)l.o(t,r)&&!l.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,[n]:t[r]})};r(t,"get"),r(n,"value")},l.f={},l.e=e=>Promise.all(Object.keys(l.f).reduce((t,n)=>(l.f[n](e,t),t),[])),l.u=e=>"static/js/async/"+(121===e?"katex-vendor":e)+"."+({0:"8e59f2eb5b","0k":"5852e6b4fa","0w":"9ed36d5860",1:"f387c12b63",12:"d091f91c99",121:"de6a87c308",13:"8f810a8a6c",19:"6fe909d55a","1b":"23f1141a38","1k":"a411fe5b43","1p":"0d5cddda96",2:"b589f1733b","2v":"96165101de",3:"0cacc08423",37:"b28b2f61cd","3d":"5085fb913f","3j":"357c80ff38","3p":"bcf32a0983","3r":"3a69e98ee0","3u":"1228460e2a","3y":"3186ecdd63",4:"9442eeb472","4e":"678285ca55","4k":"33a0c7eeb4","4q":"aad20dab25",5:"ebaf8b89cc",51:"95bcae98af","5b":"d88304bc13","5j":"d6407c4248","5o":"88316d4460",6:"f034c9b528",66:"86544ad741","6o":"5b1a06a382",7:"e4a9288dd0",73:"308dff4da8","7e":"a1cc9bfd88","7g":"db82aca7ba","7l":"fadbbc0583",8:"5067439d8c","8j":"ea110663fb",a:"bce4542392",aa:"65d3852576",ar:"ad5c8822a8",az:"d656062b0f",b:"b4f6f06515",bi:"09688ba75c",bq:"586bc738d1",c:"797d933882",c0:"0af1e640d3",ca:"8a52cfd447",cf:"d34fff5d67",ct:"b74928f7a3",cx:"9c8268d542",d:"a5fc8fe1b3",da:"f62c70f6c8",dp:"1725d6432c",e:"6443e739a2",f:"ab50467719",f7:"46971e9d6d",f8:"bbf0dbae70",g:"ee41bfed7f",h:"4e790471e4",h1:"d7091cef78",h3:"216e9798ab",hd:"0da931b622",hk:"ba7fb04d41",hn:"b645041e00",ho:"475a5e1ae4",hp:"e9fe2e395a",hs:"e7c59d8090",i:"7c148e8440",id:"573df20f29",j:"ab925882d8",jd:"63886a1f09",jg:"d86ebd4013",jl:"4911fa3383",jll:"11313b455a",js:"67182759ef",jsc:"23b70d6f40",jse:"334588ff5d",jz:"72eb929106",k:"d16cd09ae7",ka:"c1990ecaa3",ku:"29c8a59d0c",ky:"8dab1dade0",l:"12dd34e1be",l9:"949710adaf",ls:"9d9a01026c",m:"2e1ea3db9e",m3:"d2b05f9604",ma:"2c261b04dd",me:"8ace414f80",ms:"98960af4eb",mt:"853be2b5aa",n:"a9f1c51701",na:"a36cd532d6",nk:"fc7e58325e",o:"36353dfb88",oc:"eb22093f05",og:"53f068804c",ot:"84c71b308f",p:"48ecfcd14e",px:"783b6f91f2",q:"b453193538",q5:"88b50ffa95",q8:"7f1b48e9cd",qs:"2a9ddb3c72",r:"51010ad87c",rd:"cb6bf495bb",s:"aad2ecebc6",t:"4dca0e2ba8",t9:"d44f57d518",ta:"973534bbec",tr:"2a0d2b7600",u:"0871ac5b22",ud:"3065bfee31",up:"ea990da0ff",uw:"8890abbabc",v:"7d28d3c241",vp:"9b13bf8610",vt:"20406a5604",w:"08ac210f60",wt:"ad92393a90",x:"563f72ca6b",x0:"475516418f",x1:"fe8af17016",xl:"a3c562a58c",xn:"6360379f71",xnl:"feb0021e50",y:"1a9ed7a5d8",y6:"43c57defe4",yb:"8c1342401d",ybq:"4491f2f2dc",yg:"5a94e1fc8a",yq:"917ddd7ba2",ys:"00687cf82d",yv:"2fa22f009a",yx:"af2936c368",z:"56f61a4374",zi:"5fdb07b86a",zj:"654f37e8ff",zn:"966d6f1cc6",zo:"26213b40c0",zx:"e9f4105e00"})[e]+".js",l.miniCssF=e=>""+e+".css",l.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),e={},l.l=function(t,n,r,i){if(e[t])return void e[t].push(n);if(void 0!==r)for(var s,a,o=document.getElementsByTagName("script"),c=0;c<o.length;c++){var d=o[c];if(d.getAttribute("src")==t||d.getAttribute("data-rspack")=="ompchamber:"+r){s=d;break}}s||(a=!0,(s=document.createElement("script")).timeout=120,l.nc&&s.setAttribute("nonce",l.nc),s.setAttribute("data-rspack","ompchamber:"+r),s.src=t),e[t]=[n];var u=function(n,r){s.onerror=s.onload=null,clearTimeout(p);var i=e[t];if(delete e[t],s.parentNode&&s.parentNode.removeChild(s),i&&i.forEach(function(e){return e(r)}),n)return n(r)},p=setTimeout(u.bind(null,void 0,{type:"timeout",target:s}),12e4);s.onerror=u.bind(null,s.onerror),s.onload=u.bind(null,s.onload),a&&document.head.appendChild(s)},l.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t=[],l.O=(e,n,r,i)=>{if(n){i=i||0;for(var s=t.length;s>0&&t[s-1][2]>i;s--)t[s]=t[s-1];t[s]=[n,r,i];return}for(var a=1/0,s=0;s<t.length;s++){for(var[n,r,i]=t[s],o=!0,c=0;c<n.length;c++)(!1&i||a>=i)&&Object.keys(l.O).every(e=>l.O[e](n[c]))?n.splice(c--,1):(o=!1,i<a&&(a=i));if(o){t.splice(s--,1);var d=r();void 0!==d&&(e=d)}}return e},l.p="/",n={qz:0},l.f.j=function(e,t){var r=l.o(n,e)?n[e]:void 0;if(0!==r)if(r)t.push(r[2]);else{var i=new Promise((t,i)=>r=n[e]=[t,i]);t.push(r[2]=i);var s=l.p+l.u(e),a=Error();l.l(s,function(t){if(l.o(n,e)&&(0!==(r=n[e])&&(n[e]=void 0),r)){var i=t&&("load"===t.type?"missing":t.type),s=t&&t.target&&t.target.src;a.message="Loading chunk "+e+" failed.\n("+i+": "+s+")",a.name="ChunkLoadError",a.type=i,a.request=s,r[1](a)}},"chunk-"+e,e)}},l.O.j=e=>0===n[e],r=(e,t)=>{var r,i,[s,a,o]=t,c=0;if(s.some(e=>0!==n[e])){for(r in a)l.o(a,r)&&(l.m[r]=a[r]);if(o)var d=o(l)}for(e&&e(t);c<s.length;c++)i=s[c],l.o(n,i)&&n[i]&&n[i][0](),n[i]=0;return l.O(d)},(i=self.rspackChunkompchamber=self.rspackChunkompchamber||[]).forEach(r.bind(null,0)),i.push=r.bind(null,i.push.bind(i));var o=l.O(void 0,["a3","9","77"],()=>l("l"));o=l.O(o)})();
34
+ (Lanjutkan dari halaman ini.)`})};return window.addEventListener(sM.j,t),()=>window.removeEventListener(sM.j,t)},[]);let[w,N]=(0,se.bL)("chat.draftAttachments",[]),[Y,D]=(0,i.J0)([]),A=!!l?.startsWith("new-");!function(e){let{sessionId:t,messages:n,scrollRef:r,scrollToBottom:s,enabled:a}=e,l=(0,i.li)(null),o=(0,i.li)(null);sy(()=>{if(l.current!==t){l.current=t,o.current=null;return}a&&t&&0!==n.length&&o.current!==t&&r.current&&(o.current=t,s("instant"))},[t,n,a,r,s])}({sessionId:l,messages:Y,scrollRef:m,scrollToBottom:b,enabled:!A});let[F,C]=(0,i.J0)(!1),S=(0,i.li)(!1),T=(0,i.li)([]);T.current=Y;let[$,z]=(0,i.J0)(""),j=(0,i.li)(null),L=(0,i.li)(l);L.current=l;let M=(0,i.hb)(e=>{S.current=e,C(e)},[]),E=(0,i.li)(!1),P=(0,i.li)(null),I=(0,i.li)(!1),R=(0,i.li)(null),O=(0,i.li)([]),J=!!l&&!String(l).startsWith("new-")&&Number.isNaN(Number(l)),_=(0,i.li)(null),{sessionData:W,adoptedSessionIdRef:U,refreshSessionMeta:K,seedSession:q,hasMore:B,loadingOlder:H,loadOlderError:G,sessionLoading:V,loadOlder:Z,jumpToTurn:Q}=function(e){let{sessionId:t,setLocalMessages:n,setGenerating:r,isGeneratingRef:s,aiPlaceholderIdRef:a,localMessagesRef:l,optimisticUserIdRef:o,cancelStreamingCoalescer:c,metaRefreshedRef:d,scrollRef:u}=e,[p,m]=(0,i.J0)(null),[h,f]=(0,i.J0)(!1),x=(0,i.li)(null),g=(0,i.li)(null),b=(0,i.li)(null),v=(0,i.li)(null),k=(0,i.hb)(e=>{e.model&&"object"==typeof e.model&&(b.current=e.model);let t=e.model??(s.current?b.current??void 0:void 0),n=e.thinkingLevel??v.current??void 0;m({...e,model:t,thinkingLevel:n})},[]),y=(0,i.li)(t);y.current=t;let{hasMore:w,loadingOlder:N,loadOlderError:Y,loadOlder:D,jumpToTurn:A,resetPages:F,applyWindow:C}=function(e){let{sessionId:t,sessionIdRef:n,setLocalMessages:r,scrollRef:s}=e,[a,l]=(0,i.J0)(!1),[o,c]=(0,i.J0)(0),[d,u]=(0,i.J0)(!1),[p,m]=(0,i.J0)(!1),[h,f]=(0,i.J0)(0),x=(0,i.li)(!1),g=(0,i.li)(!1),b=(0,i.li)(0);b.current=o;let v=(0,i.li)(null),k=(0,i.hb)(()=>{l(!1),c(0),b.current=0,x.current=!1,u(!1),m(!1)},[]),y=(0,i.hb)((e,t)=>{"boolean"==typeof e&&l(e),"number"==typeof t&&c(t)},[]),w=(0,i.hb)(async(e,n)=>{if(!t)return null;let r=null===n?"":`&limit=${n}`,i=await fetch(`/api/chat/${t}?before=${e}${r}`);if(!i.ok)throw Error(`HTTP ${i.status}`);let s=await i.json();return{messages:s.session?.messages??[],hasMore:s.hasMore,oldestIndex:s.oldestIndex}},[t]),N=(0,i.hb)(()=>{let e=s?.current;e&&(v.current={prevHeight:e.scrollHeight,prevTop:e.scrollTop})},[s]),Y=(0,i.hb)(()=>{let e=s?.current;if(!e){g.current=!1;return}let t=e.scrollTop,n=0,r=()=>{if(e.scrollTop===t?n+=1:(n=0,t=e.scrollTop),n>=5){g.current=!1;return}requestAnimationFrame(r)};requestAnimationFrame(r)},[s]),D=(0,i.hb)(()=>{!t||t.startsWith("new-")||!a||x.current||g.current||(x.current=!0,u(!0),m(!1),N(),w(o,null).then(e=>{if(!e||n.current!==t)return;let i=e.messages;if(y(e.hasMore,e.oldestIndex),0===i.length){v.current=null;return}r(e=>[...i,...e]),f(e=>e+1)}).catch(()=>{n.current===t&&m(!0)}).finally(()=>{x.current=!1,u(!1)}))},[t,n,a,o,w,N,r,y]),A=(0,i.hb)(async(e,i)=>{if(!t||t.startsWith("new-"))return!1;if(i<0||i>=b.current)return!0;if(x.current)return!1;x.current=!0,g.current=!0,u(!0),m(!1);let s=b.current,l=a,o=!1,c=0;try{for(;!o&&s>i&&c<40;){c+=1;let a=await w(s,Math.min(300,s-i));if(!a||n.current!==t)return!1;let d=a.messages;if(0===d.length)break;let u="number"==typeof a.oldestIndex?a.oldestIndex:Math.max(0,s-d.length);if(r(e=>[...d,...e]),o=d.some(t=>t.id===e),u>=s)break;s=u,l=a.hasMore}}catch{return n.current===t&&m(!0),!1}finally{x.current=!1,u(!1)}return y(l,s),c>0&&f(e=>e+1),Y(),o},[t,n,a,w,r,y,Y]);return(0,i.Nf)(()=>{let e=v.current;if(!e)return;let t=s?.current;if(!t)return;v.current=null;let n=t.scrollHeight-e.prevHeight;n>0&&(t.scrollTop=e.prevTop+n)},[h,s]),{hasMore:a,loadingOlder:d,loadOlderError:p,loadOlder:D,jumpToTurn:A,resetPages:k,applyWindow:y}}({sessionId:t,sessionIdRef:y,setLocalMessages:n,scrollRef:u}),S=(0,i.hb)(e=>{let t=()=>y.current===e||g.current===e;if(!t())return;let n=0,r=()=>{t()&&fetch(`/api/chat/${encodeURIComponent(e)}`).then(e=>e.json()).then(i=>{if(!i?.session||!t())return;if(k(i.session),(i.session.messages?.length??0)>0)return void window.dispatchEvent(new CustomEvent("omp:session-updated",{detail:{sessionId:e}}));let s=sj[n];n+=1,void 0!==s&&setTimeout(r,s)}).catch(()=>{})};r()},[k]),T=(0,i.hb)(e=>{e.model&&(b.current=e.model),e.thinkingLevel&&(v.current=e.thinkingLevel),m(t=>({...t??{},...e.model?{model:e.model}:{},...e.thinkingLevel?{thinkingLevel:e.thinkingLevel}:{}}))},[]),$=(0,i.hb)(()=>s.current&&!!a.current,[a]);return(0,i.vJ)(()=>{let e=!0;if(f(!0),t!==x.current){let e=t&&!t.startsWith("new-")&&x.current?.startsWith("new-"),i=s.current&&g.current===t;e||i||(n([]),r(!1),g.current=null,b.current=null,m(null),v.current=null,a.current=null,o.current=null,c()),F(),d.current=null,x.current=t}return t?fetch(`/api/chat/${t}`).then(e=>e.json()).then(r=>{if(e)if(f(!1),r?.session){k(r.session);let e=r.session.messages||[],i=$();if(e.length>0&&!i)if(s.current){let t=e.map(e=>e.id);n([...e,...l.current.filter(e=>!t.includes(e.id))])}else n(e);else t.startsWith("new-")||i||n([]);C(r.hasMore,r.oldestIndex)}else m(null),$()||n([])}).catch(t=>{console.error("Error loading session from API:",t),e&&f(!1),e&&!$()&&(m(null),n([]))}):(m(null),n([])),()=>{e=!1}},[t,k,$,n,r]),{sessionData:p,hasMore:w,loadingOlder:N,loadOlderError:Y,sessionLoading:h,loadOlder:D,jumpToTurn:A,adoptedSessionIdRef:g,refreshSessionMeta:S,seedSession:T}}({sessionId:l,setLocalMessages:D,setGenerating:M,isGeneratingRef:S,aiPlaceholderIdRef:_,localMessagesRef:T,optimisticUserIdRef:R,cancelStreamingCoalescer:sJ,metaRefreshedRef:P,scrollRef:m});p.current=Z;let{turns:X,jumping:ee,jumpToTurn:et}=function(e){let{sessionId:t,messages:n,jumpToTurn:r}=e,[s,a]=(0,i.J0)(null),[l,o]=(0,i.J0)(!1),c=(0,i.Kr)(()=>{let e=[];for(let t of n)"user"===t.role&&e.push({id:t.id,index:-1,preview:(t.content??"").slice(0,220),date:t.date,timestamp:t.timestamp});return e},[n]),d=(0,i.Kr)(()=>{for(let e=n.length-1;e>=0;e-=1)if(n[e]?.role==="user")return n[e].id;return""},[n]);return(0,i.vJ)(()=>{if(!t||t.startsWith("new-"))return void a(null);let e=!0;return fetch(`/api/chat/${encodeURIComponent(t)}/turns`).then(e=>e.ok?e.json():null).then(t=>{e&&t&&Array.isArray(t.turns)&&a(t.turns)}).catch(()=>{}),()=>{e=!1}},[t,d]),{turns:(0,i.Kr)(()=>{if(!s)return c;let e=new Set(s.map(e=>e.id)),t=c.filter(t=>!e.has(t.id));return t.length>0?[...s,...t]:s},[s,c]),jumping:l,jumpToTurn:async(e,t)=>{if(t<0)return sL(e),!0;o(!0);try{let n=await r(e,t);return n&&sL(e),n}finally{o(!1)}}}}({sessionId:l,messages:Y,jumpToTurn:Q}),en=(0,i.li)(null),er=(0,i.li)(null),ei=(0,i.li)(null),es=(0,i.li)(null);(0,i.vJ)(()=>{es.current=null},[l]);let[ea,el]=(0,i.J0)(()=>{var e,t;return"string"==typeof(t=e=n.omp_access_mode)&&ed.some(e=>e===t)?e:"always-ask"}),eo=(0,i.li)(ea);eo.current=ea;let ec=(0,i.hb)(e=>{el(e),eo.current=e,(0,s_.cz)("omp_access_mode",e)},[]),eu=(0,i.hb)(e=>{l&&fetch(`/api/chat/${l}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messages:e})}).catch(e=>console.error("Error persisting messages via API:",e))},[l]),{messageQueue:ep,enqueueMessage:em,removeMessage:eh,reorderMessages:ef,steeringQueue:ex,setSteeringQueue:eg}=function(e){let[t,n]=(0,i.J0)([]),[r,s]=(0,se.bL)("chat.steeringQueue",[]),a=(0,i.li)(0),l=(0,i.li)(!1),o=(0,i.hb)(()=>{if(!e)return void n([]);let t=++a.current;fetch(sv(e)).then(e=>sk(e)).then(e=>{l.current||a.current!==t||n(e??[])}).catch(()=>{})},[e]);(0,i.vJ)(()=>{l.current=!1,o();let e=()=>o();return window.addEventListener("focus",e),()=>{l.current=!0,window.removeEventListener("focus",e)}},[o]),(0,i.vJ)(()=>{e&&0!==t.length&&fetch(`${sv(e)}/deliver`,{method:"POST"}).catch(()=>{})},[e,t.length>0]);let c=(0,i.hb)(t=>{if(!e)return;let r={...t,id:`queue-${Date.now()}`};n(e=>[...e,r]),fetch(sv(e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}).then(e=>sk(e)).then(e=>{e&&n(e)}).catch(()=>{})},[e]),d=(0,i.hb)((t,r)=>{e&&fetch(`${sv(e)}/${encodeURIComponent(t)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:r})}).then(e=>sk(e)).then(e=>{e&&n(e)}).catch(()=>{})},[e]);return{messageQueue:t,enqueueMessage:c,editMessageText:d,removeMessage:(0,i.hb)(t=>{e&&(n(e=>e.filter(e=>e.id!==t)),fetch(`${sv(e)}/${encodeURIComponent(t)}`,{method:"DELETE"}).then(e=>sk(e)).then(e=>{e&&n(e)}).catch(()=>{}))},[e]),reorderMessages:(0,i.hb)(t=>{e&&(n(e=>{let n=new Map(e.map(e=>[e.id,e]));return t.map(e=>n.get(e)).filter(e=>!!e)}),fetch(sv(e),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({orderedIds:t})}).then(e=>sk(e)).then(e=>{e&&n(e)}).catch(()=>{}))},[e]),refresh:o,steeringQueue:r,setSteeringQueue:s}}(l),{pending:eb,enqueue:ev,resolve:ek,withdraw:ey}=function(e){let[t,n]=(0,i.J0)([]);(0,i.vJ)(()=>{n([])},[e]);let r=(0,i.hb)(e=>{n(t=>t.some(t=>t.id===e.id)?t:[...t,e])},[]);return{pending:t,enqueue:r,resolve:(0,i.hb)(e=>{n(t=>t.some(t=>t.id===e)?t.filter(t=>t.id!==e):t)},[]),withdraw:(0,i.hb)(e=>{n(t=>t.filter(t=>t.id!==e))},[])}}(l),ew=function(e,t,n){let[r,s]=(0,i.J0)({isGenerating:!1,connected:!1,error:null}),a=(0,i.li)(t);a.current=t;let l=(0,i.li)(e);l.current=e;let o=(0,i.li)(new Map),c=(0,i.li)(null),d=(0,i.li)(!1),u=(0,i.li)(""),p=(0,i.li)(void 0),m=(0,i.li)(new Set),{connect:h,disconnect:f}=function(e){let{setState:t,callbacksRef:n,toolResultsRef:r,lastToolMessageRef:s,interruptPendingRef:a,activityRef:l,currentThinkingLevelRef:o,fileMutatingCallsRef:c,transport:d}=e,u=(0,i.li)(null);(0,i.vJ)(()=>((0,sf.dX)({transport:d,connected:!1}),()=>(0,sf.dX)({transport:d,connected:!1})),[d]);let p=(0,i.hb)(()=>{let e=u.current;u.current=null,e?.close(),t(e=>({...e,connected:!1})),(0,sf.dX)({transport:d,connected:!1})},[t,d]);return{connect:(0,i.hb)(e=>{p(),u.current=sx[d](e,{onOpen:()=>{t(e=>({...e,connected:!0})),(0,sf.dX)({transport:d,connected:!0}),n.current?.onConnected?.()},onFrame:i=>{!function(e,t){let n=t.callbacksRef.current;switch(e.type){case"agent_start":t.setState(e=>({...e,isGenerating:!0,error:null})),t.toolResultsRef.current?.clear(),t.fileMutatingCallsRef.current?.clear(),t.lastToolMessageRef.current=null,t.interruptPendingRef.current=!1,t.currentThinkingLevelRef.current=void 0,sm(sa.n1.thinking,t),n?.onAgentStart?.();break;case"turn_start":sm(sa.n1.thinking,t),n?.onTurnStart?.();break;case"message_start":case"message_update":{let r=e.message;if(!r)break;if("toolResult"===r.role){sd(r,t),sm(sa.n1.thinking,t);break}sm(function(e){if(!(0,n3.u)(e))return;let t=(0,sa.oJ)(e.type);if(t){if(t.startsWith("thinking"))return sa.n1.thinking;if(t.startsWith("text"))return sa.n1.writing;if("toolcall_start"===t||"toolcall_delta"===t){let t=function(e){let t=e.partial;if(!(0,n3.u)(t))return;let n=t.content;if(!Array.isArray(n))return;let r="number"==typeof e.contentIndex?e.contentIndex:n.length-1,i=n[r];if((0,n3.u)(i)&&"toolCall"===i.type)return i}(e);if(!t)return;return sl({name:(0,sa.oJ)(t.name),args:t.arguments})}if("toolcall_end"===t){let t=e.toolCall;if(!(0,n3.u)(t))return;return sl({name:(0,sa.oJ)(t.name),args:t.arguments})}}}(e.assistantMessageEvent),t),"message_start"===e.type&&n?.onTurnStart?.();let i=iF(r);i&&("user"!==i.role&&t.currentThinkingLevelRef.current&&(i.thinkingLevel=t.currentThinkingLevelRef.current),n?.onMessageUpdate?.(i));break}case"message_end":{let r=e.message;if(!r)break;if("toolResult"===r.role){sd(r,sh(t));break}if("custom"===r.role)break;if("user"===r.role){let e=ik(r.content);e&&n?.onQueuedMessageDelivered?.(e);break}let i=iF(r,!1);if(!i)break;"user"!==i.role&&t.currentThinkingLevelRef.current&&(i.thinkingLevel=t.currentThinkingLevelRef.current);let s=su(i,t);s.toolCalls?.length&&(t.lastToolMessageRef.current=s),n?.onMessageEnd?.(s);break}case"tool_execution_start":{let r="string"==typeof e.toolCallId?e.toolCallId:void 0;sm(sl({name:"string"==typeof e.toolName?e.toolName:void 0,args:e.args,intent:"string"==typeof e.intent?e.intent:void 0}),t),r&&t.toolResultsRef.current?.set(r,{output:""}),r&&(0,so.Y)({toolName:e.toolName,args:e.args})&&t.fileMutatingCallsRef.current?.add(r);let i=t.lastToolMessageRef.current;i?.toolCalls?.some(e=>e.id===r)&&(t.lastToolMessageRef.current={...i,toolCalls:i.toolCalls.map(e=>({...e,status:"running"}))},n?.onMessageUpdate?.(t.lastToolMessageRef.current));break}case"tool_execution_update":{let n="string"==typeof e.toolCallId?e.toolCallId:void 0,r=iA(e.partialResult);if(!n||!r)break;let i=t.toolResultsRef.current?.get(n)?.output??"";sc(t,n,{output:i+r}),sp(n,sh(t));break}case"tool_execution_end":{let n="string"==typeof e.toolCallId?e.toolCallId:void 0;if(!n)break;sm(sa.n1.thinking,t),sc(t,n,{output:iA(e.result),isError:!0===e.isError,details:e.details&&"object"==typeof e.details?e.details:void 0}),sp(n,sh(t)),"u">typeof window&&t.fileMutatingCallsRef.current?.delete(n)&&window.dispatchEvent(new CustomEvent(so.s,{detail:{sessionId:t.sessionId}}));break}case"agent_end":{t.setState(e=>({...e,isGenerating:!1})),t.activityRef.current="";let r=function(e,t,n){let r;if(!1===e.isTerminal)return{};let i=e.messages;if(!Array.isArray(i))return{};for(let e of i){if(!e||"object"!=typeof e||Array.isArray(e)||"assistant"!==e.role||"aborted"!==e.stopReason&&"error"!==e.stopReason)continue;let i=iF(e,!1);if(!i)continue;let s=su(i,t);s.toolCalls?.length&&(t.lastToolMessageRef.current=s),n?.onMessageEnd?.(s),"string"==typeof e.errorMessage&&(r=e.errorMessage)}return{errorMessage:r}}(e,t,n??void 0);if(t.interruptPendingRef.current){t.interruptPendingRef.current=!1;break}n?.onAgentEnd?.({errorMessage:r.errorMessage??("string"==typeof e.errorMessage?e.errorMessage:void 0),message:"string"==typeof e.message?e.message:void 0});break}case"prompt_error":{let r="string"==typeof e.errorMessage?e.errorMessage:"Prompt failed";t.setState(e=>({...e,isGenerating:!1,error:r})),t.interruptPendingRef.current=!1,t.activityRef.current="",n?.onPromptError?.(r);break}case"prompt_result":!1===e.agentInvoked&&(t.setState(e=>({...e,isGenerating:!1})),t.activityRef.current="",n?.onPromptSettled?.());break;case"command_output":{let t="string"==typeof e.text?e.text.trim():"";t&&n?.onCommandOutput?.(t);break}case"session_info_update":{let t="string"==typeof e.title?e.title.trim():"";t&&n?.onSessionTitleChanged?.(t);break}case"notice":n?.onNotice?.("string"==typeof e.level?e.level:"info","string"==typeof e.message?e.message:"");break;case"extension_ui_request":n?.onExtensionUiRequest?.(e);break;case"subagent_lifecycle":case"subagent_progress":case"subagent_event":{let n=e.payload;if(null==n||"object"!=typeof n)break;window.dispatchEvent(new CustomEvent(e.type,{detail:{sessionId:t.sessionId,payload:n}}));break}case"model_changed":n?.onModelChanged?.();break;case"thinking_level_changed":var r;t.currentThinkingLevelRef.current="string"==typeof(r=e.thinkingLevel)&&r.trim()?r.trim():"off"}}(i,{sessionId:e,setState:t,callbacksRef:n,toolResultsRef:r,lastToolMessageRef:s,interruptPendingRef:a,activityRef:l,currentThinkingLevelRef:o,fileMutatingCallsRef:c})},onClose:()=>{t(e=>({...e,connected:!1})),(0,sf.dX)({transport:d,connected:!1})}})},[p,t,n,r,s,a,l,o,c,d]),disconnect:p}}({setState:s,callbacksRef:a,toolResultsRef:o,lastToolMessageRef:c,interruptPendingRef:d,activityRef:u,currentThinkingLevelRef:p,fileMutatingCallsRef:m,transport:n});(0,i.vJ)(()=>{if(!e)return;o.current.clear(),m.current.clear(),c.current=null,u.current="";let t=!1;return fetch(`/api/agent/${encodeURIComponent(e)}`).then(e=>e.ok?e.json():null).then(n=>{if(t||!n?.running)return;let r=n.state;for(let t of((n.busy||r?.isStreaming||r?.isPromptRunning)&&(h(e),a.current.onResumeStream?.()),n.pendingUiRequests??[]))a.current.onExtensionUiRequest?.(t)}).catch(()=>{}),()=>{t=!0,f()}},[e,f,h]);let{sendPrompt:x,sendNewPrompt:g}=function(e){let{sessionIdRef:t,connect:n,setState:r}=e;return{sendPrompt:(0,i.hb)(async(e,i,s)=>{let a=t.current;if(!a)return!1;r(e=>({...e,isGenerating:!0,error:null}));try{(await fetch(`/api/agent/${encodeURIComponent(a)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"get_state",...s?.accessMode?{accessMode:s.accessMode}:{}})})).ok&&n(a);let t=await fetch(`/api/agent/${encodeURIComponent(a)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"prompt",message:e,...i?.length?{images:i}:{},...s?.accessMode?{accessMode:s.accessMode}:{}})}),l=await t.json().catch(()=>({}));if(!t.ok||l.error)return r(e=>({...e,isGenerating:!1,error:l.error??`HTTP ${t.status}`})),!1;return window.dispatchEvent(new CustomEvent("omp:session-updated",{detail:{sessionId:a}})),!0}catch(e){return r(t=>({...t,isGenerating:!1,error:e instanceof Error?e.message:String(e)})),!1}},[n,t,r]),sendNewPrompt:(0,i.hb)(async(e,t,i,s)=>{r(e=>({...e,isGenerating:!0,error:null}));try{let a=await fetch("/api/agent/new",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"ensure_session",cwd:t,...s?.model?s.model:{},...s?.thinkingLevel?{thinkingLevel:s.thinkingLevel}:{},...s?.accessMode?{accessMode:s.accessMode}:{}})}),l=await a.json().catch(()=>({}));if(!a.ok||!l.sessionId)return r(e=>({...e,isGenerating:!1,error:l.error??`HTTP ${a.status}`})),null;let o=l.sessionId;n(o);let c=await fetch(`/api/agent/${encodeURIComponent(o)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"prompt",message:e,...i?.length?{images:i}:{}})}),d=await c.json().catch(()=>({}));if(!c.ok||d.error)return r(e=>({...e,isGenerating:!1,error:d.error??`HTTP ${c.status}`})),null;return window.dispatchEvent(new CustomEvent("omp:session-updated",{detail:{sessionId:o}})),{sessionId:o,model:l.model??null}}catch(e){return r(t=>({...t,isGenerating:!1,error:e instanceof Error?e.message:String(e)})),null}},[n,r])}}({sessionIdRef:l,connect:h,setState:s}),b=(0,i.hb)(async()=>{let e=l.current;e&&(d.current=!1,await sb(e),s(e=>({...e,isGenerating:!1})))},[]),v=(0,i.hb)(async(e,t)=>{let n=l.current;if(!n)return!1;d.current=!0,s(e=>({...e,isGenerating:!0,error:null}));try{let r=await fetch(`/api/agent/${encodeURIComponent(n)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"abort_and_prompt",message:e,...t?.length?{images:t}:{}})}),i=await r.json().catch(()=>({}));if(!r.ok||i.error)return d.current=!1,s(e=>({...e,isGenerating:!1,error:i.error??`HTTP ${r.status}`})),!1;return!0}catch(e){return d.current=!1,s(t=>({...t,isGenerating:!1,error:e instanceof Error?e.message:String(e)})),!1}},[]),k=(0,i.hb)(async(e,t)=>{let n=l.current;if(!n)return!1;try{let r=await fetch(`/api/agent/${encodeURIComponent(n)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"follow_up",message:e,...t?.length?{images:t}:{}})}),i=await r.json().catch(()=>({}));if(!r.ok||i.error)return s(e=>({...e,error:i.error??`HTTP ${r.status}`})),!1;return!0}catch(e){return s(t=>({...t,error:e instanceof Error?e.message:String(e)})),!1}},[]),y=(0,i.hb)(async(e,t)=>{let n=l.current;if(n)try{await fetch(`/api/agent/${encodeURIComponent(n)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"set_model",provider:e,modelId:t})})}catch{}},[]),w=(0,i.hb)(async e=>{let t=l.current;if(t)try{await fetch(`/api/agent/${encodeURIComponent(t)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"set_thinking_level",level:e})})}catch{}},[]),N=(0,i.hb)(async(e,t)=>{let n=l.current;if(n)try{await fetch(`/api/agent/${encodeURIComponent(n)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"extension_ui_response",id:e.id,...t})})}catch{}},[]);return{...r,sendPrompt:x,sendNewPrompt:g,sendInterruptAndReply:v,sendFollowUp:k,abort:b,setModel:y,setThinkingLevel:w,respondToExtensionUi:N,disconnect:f}}(J?l:null,function(e){var t;let{setGenerating:n,setGeneratingVerb:r,scrollToBottom:i,adoptedSessionIdRef:s,sessionIdRef:a,metaRefreshedRef:l,firstAssistantRef:o,refreshSessionMeta:c,setLocalMessages:d,aiPlaceholderIdRef:u,optimisticUserIdRef:p,pendingUserDisplaysRef:m,persistMessages:h,abortControllerRef:f,appSettings:x,enqueueExtensionDialog:g,withdrawExtensionDialog:b}=e;return t=()=>i("smooth"),sP=d,sI=t,{onAgentStart:()=>{n(!0),r(sa.n1.thinking),setTimeout(()=>i("smooth"),50),o.current=!1;let e=s.current??a.current;e&&(window.dispatchEvent(new CustomEvent("omp:session-updated",{detail:{sessionId:e}})),l.current!==e&&(l.current=e,setTimeout(()=>c(e),100)))},onTurnStart:()=>{let e=s.current??a.current;e&&"u">typeof window&&window.dispatchEvent(new CustomEvent("omp:session-updated",{detail:{sessionId:e}}))},onResumeStream:()=>{n(!0),r(sa.n1.thinking),setTimeout(()=>i("smooth"),50),o.current=!1;let e=s.current??a.current;e&&window.dispatchEvent(new CustomEvent("omp:session-updated",{detail:{sessionId:e}}))},onActivity:e=>{r(e)},onMessageUpdate:e=>{var t;"user"===e.role||r1(e)||(p.current=null),t=e.id,sR.queue(t=>{let n=u.current;if(r1(e)){if(t.some(t=>t.id===e.id))return t;if(n&&t.some(e=>e.id===n)){let r=t.findIndex(e=>e.id===n);return[...t.slice(0,r),e,...t.slice(r)]}return[...t,e]}if("user"===e.role){if(t.some(t=>t.id===e.id))return t;let r=p.current;if(r){let n=t.findIndex(e=>e.id===r);if(-1!==n){let r={...e,id:e.id,content:t[n].content,date:t[n].date,attachments:e.attachments?.length?e.attachments:t[n].attachments};return[...t.slice(0,n),r,...t.slice(n+1)]}}let i=m.current.find(t=>e.content===t.sent||e.content.startsWith(t.sent)||t.sent.startsWith(e.content)),s=i?{...e,content:i.display}:e;if(n&&t.some(e=>e.id===n)){let e=t.findIndex(e=>e.id===n);return[...t.slice(0,e),s,...t.slice(e)]}return[...t,s]}if(n&&t.some(e=>e.id===n))return t.map(t=>t.id===n?e:t);let r=t.findIndex(t=>t.id===e.id);return -1!==r?[...t.slice(0,r),e,...t.slice(r+1)]:[...t,e]},t)},onMessageEnd:e=>{if("ai"===e.role&&!r1(e)&&!o.current){o.current=!0;let e=s.current??a.current;e&&"u">typeof window&&window.dispatchEvent(new CustomEvent("omp:session-updated",{detail:{sessionId:e}}))}sR.flush(),"user"!==e.role&&(p.current=null),d(t=>{let n,r=u.current;if("user"===e.role){let n,i=p.current;if(t.some(t=>t.id===e.id))n=t.map(t=>t.id===e.id?e:t);else if(i&&t.some(e=>e.id===i))n=t.map(t=>t.id===i?{...e,id:e.id,content:t.content,date:t.date,attachments:e.attachments?.length?e.attachments:t.attachments}:t);else if(r&&t.some(e=>e.id===r)){let i=t.findIndex(e=>e.id===r);n=[...t.slice(0,i),e,...t.slice(i)]}else n=[...t,e];return h(n),n}if(r&&t.some(e=>e.id===r))n=t.map(t=>t.id===r?e:t);else{let r=t.findIndex(t=>t.id===e.id);n=-1!==r?[...t.slice(0,r),e,...t.slice(r+1)]:[...t,e]}return u.current=null,h(n),n})},onAgentEnd:()=>{sO(),n(!1),f.current=null,p.current=null,m.current=[],(0,s$.s4)(x),setTimeout(()=>i("smooth"),50);let e=s.current??a.current;e&&c(e)},onModelChanged:()=>{let e=s.current??a.current;e&&setTimeout(()=>c(e),150)},onPromptError:e=>{n(!1),f.current=null,console.error("OMP prompt error:",e)},onPromptSettled:()=>{sO(),n(!1),f.current=null,p.current=null;let e=u.current;u.current=null,e&&d(t=>t.some(t=>t.id===e)?t.filter(t=>t.id!==e):t)},onCommandOutput:e=>{let t={id:`cmdout-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,role:"ai",content:"",notice:e};d(n=>{let r=u.current;if(r){let e=n.findIndex(e=>e.id===r);if(-1!==e)return[...n.slice(0,e),t,...n.slice(e)]}return n.some(t=>t.notice===e)?n:[...n,t]})},onSessionTitleChanged:()=>{let e=s.current??a.current;e&&c(e)},onNotice:(e,t)=>{console.info("OMP notice:",t)},onExtensionUiRequest:e=>{"select"===e.method||"confirm"===e.method||"input"===e.method||"editor"===e.method?g(e):"cancel"===e.method&&b(e.targetId)}}}({setGenerating:M,setGeneratingVerb:z,scrollToBottom:b,adoptedSessionIdRef:U,sessionIdRef:L,metaRefreshedRef:P,firstAssistantRef:I,refreshSessionMeta:K,setLocalMessages:D,aiPlaceholderIdRef:_,optimisticUserIdRef:R,pendingUserDisplaysRef:O,persistMessages:eu,abortControllerRef:j,appSettings:n,enqueueExtensionDialog:ev,withdrawExtensionDialog:ey}),(0,i4.ul)(n)),{steerOmpAgent:eN,executeSend:eY}=function(e){let{folders:t,selectedFolderId:n,sessionId:r,isOmpSession:s,appSettings:a,ompAgent:l,setLocalMessages:o,persistMessages:c,setGenerating:d,setGeneratingVerb:u,scrollToBottom:p,jumpToBottom:m,aiPlaceholderIdRef:h,adoptedSessionIdRef:f,optimisticUserIdRef:x,pendingUserDisplaysRef:g,seedSession:b,pendingComposerModelRef:v,pendingThinkingLevelRef:k,deferredComposerPickRef:y,accessModeRef:w,abortControllerRef:N,setInputValue:Y,setSearchParams:D}=e,A=(0,i.hb)(async(e,t)=>{let n=await eR(t),r=await sT(e,n);g.current=[...g.current.slice(-7),{sent:r,display:e}];let i=t.map(eP).filter(e=>null!==e);return{promptText:r,images:i.length?i:void 0}},[]);return{steerOmpAgent:(0,i.hb)(async(e,t)=>{await eG(l,y);let{promptText:n,images:r}=await A(e,t);await l.sendInterruptAndReply(n,r)||Y(e)},[l,A,Y,y]),executeSend:(0,i.hb)(async(e,i,g)=>{let Y=g?.model??null,A=Y?.accessMode??w.current,F=nY(),C=`msg-${Date.now()}-user`,S=`msg-${Date.now()+1}-ai`,T=await eR(i),$=new Map(T.map(e=>[e.id,e.content])),z=Date.now(),j={id:C,role:"user",date:`Today, ${F}`,startedAt:z,content:e,attachments:i.map(e=>({name:ej(e),preview:e.dataBase64?`data:${eL(e)};base64,${e.dataBase64}`:e.preview,type:eL(e),size:eM(e),content:$.get(e.id)}))},L={id:S,role:"ai",date:`Today, ${F}`,startedAt:z,content:""};if(o(e=>{let t=[...e,j,L];return c(t.filter(e=>e.id!==S)),t}),d(!0),u(sa.n1.thinking),setTimeout(()=>m("smooth"),50),s){h.current=S,x.current=C,Y||await eG(l,y),Y&&(await l.setModel(Y.provider,Y.modelId),"auto"!==Y.thinkingLevel&&await l.setThinkingLevel(Y.thinkingLevel));let t=i.map(eP).filter(e=>null!==e),n=await sT(e,T);await l.sendPrompt(n,t.length?t:void 0,{accessMode:A})||(o(e=>e.filter(e=>e.id!==C&&e.id!==S)),h.current=null,x.current=null,d(!1));return}if(!s){let r=t.find(e=>String(e.id)===String(n)),s=r?.project_path||r?.name;if(s){let t=i.map(eP).filter(e=>null!==e),n=await sT(e,T);x.current=C;let r=v.current,a=k.current,o=await l.sendNewPrompt(n,s,t.length?t:void 0,{model:r,thinkingLevel:a,accessMode:w.current});if(o){f.current=o.sessionId,h.current=S,b({model:o.model,thinkingLevel:a}),v.current=null,k.current=null,fetch(`/api/chat/${encodeURIComponent(o.sessionId)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messages:[j]})}).catch(e=>console.error("Error persisting spawned user turn:",e)),D(e=>{let t=new URLSearchParams(e);return t.set("sessionId",o.sessionId),t},{replace:!0});return}}}x.current=null,N.current&&N.current.abort();let M=new AbortController;N.current=M;let E=t.find(e=>String(e.id)===String(n)),P=E?.name||"Workspace";await sY({sessionId:r||`session-${Date.now()}`,prompt:e,workspaceName:P,attachments:i,signal:M.signal},function(e){let{aiPlaceholderId:t,setLocalMessages:n,persistMessages:r,setGenerating:i,setGeneratingVerb:s,abortControllerRef:a,appSettings:l,scrollToBottom:o}=e,c=!1,d=sz(e=>n(e),()=>{c&&(c=!1,o("smooth"))}),u=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];t&&(c=!0),d.queue(e)};return{onInit:e=>{u(n=>n.map(n=>n.id===t?{...n,id:e.id,date:e.date}:n))},onThinkingStart:()=>{s(sa.n1.thinking),u(e=>e.map(e=>e.id===t||"ai"===e.role?{...e,thinking:{thought:"",isGenerating:!0}}:e)),setTimeout(()=>o("smooth"),50)},onThinkingChunk:e=>{u(n=>n.map(r=>{if(r.id===t||"ai"===r.role&&n[n.length-1]?.id===r.id){let t="object"==typeof r.thinking&&r.thinking.thought||"";return{...r,thinking:{thought:t+e.delta,isGenerating:!0}}}return r}),!0)},onThinkingEnd:e=>{u(n=>n.map(r=>r.id===t||"ai"===r.role&&n[n.length-1]?.id===r.id?{...r,thinking:{thought:e.thought,summary:e.summary,duration:e.duration,isGenerating:!1}}:r))},onToolStart:e=>{s(sl({name:e.name??e.type,input:e.input,command:e.command,target:e.target,intent:e.intent})),u(n=>n.map(r=>r.id===t||"ai"===r.role&&n[n.length-1]?.id===r.id?{...r,toolCalls:[...r.toolCalls||[],e]}:r)),setTimeout(()=>o("smooth"),50)},onToolOutputChunk:e=>{u(n=>n.map(r=>r.id===t||"ai"===r.role&&n[n.length-1]?.id===r.id?{...r,toolCalls:(r.toolCalls||[]).map(t=>t.id===e.id?{...t,output:(t.output||"")+e.delta}:t)}:r),!0)},onToolEnd:e=>{s(sa.n1.thinking),u(n=>n.map(r=>r.id===t||"ai"===r.role&&n[n.length-1]?.id===r.id?{...r,toolCalls:(r.toolCalls||[]).map(t=>t.id===e.id?{...t,...e}:t)}:r))},onContentChunk:e=>{s(sa.n1.writing),u(n=>n.map(r=>r.id===t||"ai"===r.role&&n[n.length-1]?.id===r.id?{...r,content:(r.content||"")+e.delta}:r),!0)},onSummary:e=>{u(n=>n.map(r=>r.id===t||"ai"===r.role&&n[n.length-1]?.id===r.id?{...r,summary:e.summary}:r))},onDone:e=>{d.flush(),n(n=>{let i=n.map(r=>r.id===t||"ai"===r.role&&n[n.length-1]?.id===r.id?e.message:r);return r(i),i}),i(!1),a.current=null,(0,s$.s4)(l),setTimeout(()=>o("smooth"),50)},onError:()=>{i(!1),a.current=null}}}({aiPlaceholderId:S,setLocalMessages:o,persistMessages:c,setGenerating:d,setGeneratingVerb:u,abortControllerRef:N,appSettings:a,scrollToBottom:p}))},[a,t,s,l,n,r,p,m,c,b,v,k,y,w])}}({folders:t,selectedFolderId:c,sessionId:l,isOmpSession:J,appSettings:n,ompAgent:ew,setLocalMessages:D,persistMessages:eu,setGenerating:M,setGeneratingVerb:z,scrollToBottom:b,jumpToBottom:v,aiPlaceholderIdRef:_,adoptedSessionIdRef:U,optimisticUserIdRef:R,pendingUserDisplaysRef:O,seedSession:q,pendingComposerModelRef:en,pendingThinkingLevelRef:er,deferredComposerPickRef:es,accessModeRef:eo,abortControllerRef:j,setInputValue:y,setSearchParams:a}),{handleSend:eD,handleEditQueueItem:eA,handleSendNowQueueItem:eF,handleUndo:eC,handleRetry:eS,submitNewChat:eT,stopGenerating:e$,handleThinkingLevelChange:ez,handleModelChange:eE}=function(e){let{inputValue:t,setInputValue:n,setInputAttachments:r,isGenerating:s,isOmpSession:a,sessionId:l,appSettings:o,messageQueue:c,enqueueMessage:d,removeMessage:u,executeSend:p,steerOmpAgent:m,ompAgent:h,abortControllerRef:f,setGenerating:x,stopHoldRef:g,persistMessages:b,setLocalMessages:v,pendingComposerModelRef:k,pendingThinkingLevelRef:y,composerModelRef:w,deferredComposerPickRef:N,accessModeRef:Y,setSearchParams:D}=e,A=(0,i.hb)(async(e,r)=>{let i=t.trim();if(i||0!==e.length){if(g.current=!1,function(e,t){let n=sw.exec(e);if(!n)return!1;let r=t.map(e=>eP(e)).filter(e=>null!==e);return window.dispatchEvent(new CustomEvent("omp:btw",{detail:{question:n[1]?.trim()??"",...r.length?{images:r}:{}}})),!0}(i,e))return void n("");if(s){if(r?.steering){n(""),a?await m(i,e):(f.current&&(f.current.abort(),f.current=null),x(!1),p(i,e));return}if("steering"===(o.omp_chamber_settings?.followUpBehavior??o.followUpBehavior??"queue")&&a){n(""),await m(i,e);return}let t=w.current,s=t?{...t,accessMode:Y.current}:null;n(""),eI(e).then(e=>{d({text:i,attachments:e,model:s})});return}n(""),p(i,e)}},[t,s,p,d,a,o,m,n,f,x,g,w,Y]),F=(0,i.hb)(e=>{n(e.text),r(e.attachments),u(e.id)},[u,n,r]),C=(0,i.hb)(async e=>{g.current=!1,u(e.id),s?a?m(e.text,e.attachments):(f.current&&(f.current.abort(),f.current=null),x(!1),setTimeout(()=>p(e.text,e.attachments,{model:e.model}),0)):p(e.text,e.attachments,{model:e.model})},[s,p,u,a,m,f,x,g]),S=(0,i.hb)(async(e,t)=>{if(s&&(a?h.abort():f.current&&(f.current.abort(),f.current=null),x(!1)),t&&n(t),a&&l){if(!(await fetch(`/api/chat/${encodeURIComponent(l)}/rewind`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({entryId:e})})).ok)return!1;let t=await fetch(`/api/chat/${encodeURIComponent(l)}`).then(e=>e.json()).catch(()=>null),n=t?.session?.messages??[];return n.length>0&&v(n),!0}return v(t=>{let n=t.findIndex(t=>t.id===e),r=-1!==n?t.slice(0,n):t;return b(r),r}),!0},[s,a,l,b,f,x,n,v]),T=(0,i.hb)(e=>{s&&(a?h.abort():f.current&&(f.current.abort(),f.current=null),x(!1)),v(t=>{let n=t.findIndex(t=>t.id===e);if(n>0&&"user"===t[n-1].role){let e=t[n-1];setTimeout(()=>{let t=Array.isArray(e.attachments)?e.attachments:[];p(e.content,t)},0);let r=t.slice(0,n-1);return b(r),r}return t})},[s,p,b,a,h,f,x,v]),$=(0,i.hb)((e,t)=>{let n=`new-${Date.now()}`;D(e=>{let t=new URLSearchParams(e);return t.set("sessionId",n),t},{replace:!0}),v([]),setTimeout(()=>{p(e,t)},0)},[D,p,v]),z=(0,i.hb)(()=>(g.current=!0,a?h.abort():f.current&&(f.current.abort(),f.current=null),x(!1),c.length),[a,h,f,x,c.length,g]);return{handleSend:A,handleEditQueueItem:F,handleSendNowQueueItem:C,handleUndo:S,handleRetry:T,submitNewChat:$,stopGenerating:z,handleThinkingLevelChange:(0,i.hb)(e=>{if("auto"!==e){if(!a){y.current=e;return}if(s)return void eq(N,{thinkingLevel:e});eB(N,{thinkingLevel:e}),h.setThinkingLevel(e)}},[s,a,h,y,N]),handleModelChange:(0,i.hb)((e,t)=>{if(!a){k.current={provider:e,modelId:t};return}s?eq(N,{provider:e,modelId:t}):(eB(N,{provider:e,modelId:t}),eH(h,{provider:e,modelId:t}))},[s,a,h,k,N])}}({inputValue:k,setInputValue:y,setInputAttachments:N,isGenerating:F,isOmpSession:J,sessionId:l,appSettings:n,messageQueue:ep,enqueueMessage:em,removeMessage:eh,executeSend:eY,steerOmpAgent:eN,ompAgent:ew,abortControllerRef:j,setGenerating:M,stopHoldRef:E,persistMessages:eu,setLocalMessages:D,pendingComposerModelRef:en,pendingThinkingLevelRef:er,composerModelRef:ei,deferredComposerPickRef:es,accessModeRef:eo,setSearchParams:a});return{sessionId:l,folderId:o,isOmpSession:J,selectedFolderId:c,setSelectedFolderId:u,sessionData:W,localMessages:Y,isGenerating:F,hasMore:B,loadingOlder:H,loadOlderError:G,sessionLoading:V,loadOlder:Z,userTurns:X,jumpingTurn:ee,jumpToUserTurn:et,generatingVerb:$,messageQueue:ep,removeMessage:eh,reorderMessages:ef,steeringQueue:ex,setSteeringQueue:eg,inputValue:k,setInputValue:y,inputAttachments:w,setInputAttachments:N,scrollRef:m,contentRef:h,showScrollBottom:f,isScrolling:x,handleScroll:g,scrollToBottom:b,jumpToBottom:v,handleSend:eD,handleEditQueueItem:eA,handleSendNowQueueItem:eF,handleUndo:eC,handleRetry:eS,submitNewChat:eT,stopGenerating:e$,handleThinkingLevelChange:ez,handleModelChange:eE,accessMode:ea,handleAccessModeChange:ec,composerModelRef:ei,deferredComposerPickRef:es,extensionDialogs:eb,resolveExtensionDialog:ek,respondToExtensionUi:ew.respondToExtensionUi}}({folders:c,appSettings:n}),{toasts:ea,pushToast:el,dismissToast:eo}=(0,sq.Y)(),{framesByTool:ec,modalRequest:eu}=(0,i.Kr)(()=>(function(e,t){let n=new Map;if(0===t.length)return{framesByTool:n,modalRequest:null};let r=new Map;for(let t of e)for(let e of t.toolCalls??[]){if("ask"!==("string"==typeof e.name&&e.name?e.name:e.type)&&"ask"!==e.title)continue;let t=h(e);t.length>0&&r.set(e.id,t)}let i=new Map,s=new Set,a=null;for(let e of t){let t="string"==typeof e.title?p(e.title):"",n=null;if(t){for(let[e,i]of r)if(i.some(e=>p(e.question)===t)){n=e;break}}n||"confirm"===e.method||(n=a),n&&(s.add(e),a=n,i.set(n,[...i.get(n)??[],e]))}for(let[e,t]of i)n.set(e,function(e,t){let n=e.map(()=>[]);if(0===e.length)return n;let r=e.map(e=>p(e.question)),i=0;for(let e of t){let t="string"==typeof e.title?p(e.title):"",s=r.indexOf(t);s>i?i=s:-1===s&&"select"===e.method&&n[i].some(e=>"select"===e.method)&&i+1<n.length&&(i+=1),n[i].push(e)}return n}(r.get(e)??[],t));return{framesByTool:n,modalRequest:t.find(e=>!s.has(e))??null}})(g,er),[g,er]),ep=(0,i.hb)((e,t)=>{es(e,t),ei(e.id)},[es,ei]),em=(0,i.Kr)(()=>({framesByTool:ec,respond:ep}),[ec,ep]),[eh,ef]=(0,i.J0)(null),{pendingUndo:ex,undoing:eg,requestUndo:eb,closeUndoConfirm:ev,confirmUndo:ek}=function(e){let[t,n]=(0,i.J0)(null),[r,s]=(0,i.J0)(!1),a=(0,i.hb)((e,t)=>{n({id:e,content:t??""})},[]),l=(0,i.hb)(()=>n(null),[]),o=(0,i.hb)(async()=>{!t||r||(s(!0),await e(t.id,t.content)&&n(null),s(!1))},[e,t,r]);return{pendingUndo:t,undoing:r,requestUndo:a,closeUndoConfirm:l,confirmUndo:o}}(B),[ey,ew]=(0,s.o)(),eN=(0,i.hb)(()=>{let e=V();0!==e&&el(`Stopped. ${e} message${e>1?"s":""} still queued — nothing was sent.`,"success",{action:{label:"Send now",onClick:()=>{let e=S[0];e&&q(e)}},duration:8e3})},[V,el,S,q]),{activeSubagent:eY,back:eD}=function(e,t,n){let[r,s]=(0,i.J0)(null);return(0,i.vJ)(()=>{let e=e=>{let t=e.detail,r=t?.subagent,i=t?.sessionId;r&&i&&(s(r),n(e=>(e.get("sessionId")===i&&e.get("subagent")===r.id||(e.set("sessionId",i),e.set("subagent",r.id)),e),{replace:!1}))};return window.addEventListener("omp:view-subagent",e),()=>window.removeEventListener("omp:view-subagent",e)},[n]),(0,i.vJ)(()=>{if(!t)return void s(null);if(r?.id===t||!e)return;let n=!1;return fetch(`/api/sessions/${encodeURIComponent(e)}/subagents`).then(e=>e.ok?e.json():null).then(e=>{if(n||!e?.subagents)return;let r=e.subagents.find(e=>(0,n3.u)(e)&&e.id===t);r&&s((0,sU.Nh)(r))}).catch(()=>{}),()=>{n=!0}},[e,t]),{activeSubagent:r,back:(0,i.hb)(()=>{s(null),n(e=>(e.has("subagent")&&e.delete("subagent"),e),{replace:!0})},[n])}}(u,ey.get("subagent"),ew);!function(e,t,n){let[r,s]=(0,i.J0)(null);(0,i.vJ)(()=>{s(null)},[e]),(0,i.vJ)(()=>{let t=t=>{let n=t.detail;n?.sessionId&&n.title&&String(n.sessionId)===String(e)&&s(n.title)};return window.addEventListener("omp:session-renamed",t),()=>window.removeEventListener("omp:session-renamed",t)},[e]),(0,i.vJ)(()=>{let i=(0,sW.fN)(e)?(0,sW.g2)(e):null;n?.(i??r??t??null)},[e,t,r,n])}(u,x?.title,a);let eA=(0,i.hb)(e=>{F(e.id,e.index)},[F]),eF=(0,i.hb)(e=>ef(e),[]),eC=iP(iI)??{},eS=iP(sK)??{},eT="object"==typeof x?.model?x.model.provider:void 0,e$="object"==typeof x?.model?eC[x.model.modelId]??x.model.modelId:x?.model,ez=!!u?.startsWith("new-"),eE=(0,sH.M)(c,u,m),eO=!ez&&N&&0===g.length;return!u||ez?(0,r.Y)(io,{className:t,folders:c,selectedFolderId:m,setSelectedFolderId:f,rootPath:eE,inputValue:L,setInputValue:M,inputAttachments:E,setInputAttachments:P,onSend:U,isGenerating:b,appSettings:n,messages:g,provider:eT,providerNames:eS,modelName:e$,modelNames:eC,onThinkingLevelChange:Z,onModelChange:Q,accessMode:X,onAccessModeChange:ee,composerModelRef:et,deferredComposerPickRef:en,sessionModel:"object"==typeof x?.model?x.model:null,sessionThinkingLevel:x?.thinkingLevel,generatingVerb:C,variant:l}):(0,r.Y)(y.Provider,{value:em,children:(0,r.FD)("div",{className:`flex flex-col h-full min-h-0 overflow-hidden bg-canvas relative ${t}`,children:[eO?(0,r.Y)(iu,{}):(0,r.FD)(r.FK,{children:[(0,r.Y)("div",{className:"relative flex-1 min-h-0 flex flex-col",children:eY?(0,r.Y)(iJ,{sessionId:u,subagent:eY,onBack:eD,provider:eT,providerNames:eS}):(0,r.Y)(iK,{isMobile:d,userTurns:D,jumpingTurn:A,onJumpTurn:eA,scrollRef:I,contentRef:R,handleScroll:_,isScrolling:J,loadingOlder:k,hasMore:v,loadOlderError:w,loadOlder:Y,messages:g,isGenerating:b,provider:eT,providerNames:eS,modelName:e$,modelNames:eC,thinkingLevel:x?.thinkingLevel,onUndo:eb,onRetry:H,onNewChat:eF,showScrollBottom:O,jumpToBottom:W})}),!eY&&(0,r.Y)(ss,{isMobile:d,sessionId:u,isGenerating:b,modelName:e$,generatingVerb:C,provider:eT,providerNames:eS,messageQueue:S,onRemoveQueueItem:T,onReorderQueue:$,onEditQueueItem:K,onSendNowQueueItem:q,steeringQueue:z,setSteeringQueue:j,inputValue:L,setInputValue:M,rootPath:eE,attachments:E,setAttachments:P,onSend:U,onStop:eN,appSettings:n,onThinkingLevelChange:Z,onModelChange:Q,accessMode:X,onAccessModeChange:ee,composerModelRef:et,deferredComposerPickRef:en,sessionModel:"object"==typeof x?.model?x.model:null,sessionThinkingLevel:x?.thinkingLevel,variant:l})]}),ex&&(0,r.Y)(im,{isOmpSession:!!u&&!u.startsWith("new-")&&Number.isNaN(Number(u)),content:ex.content,undoing:eg,onClose:ev,onConfirm:ek}),null!==eh&&(0,r.Y)(ih,{initialContent:eh,onClose:()=>ef(null),onSend:G,appSettings:n,accessMode:X,onAccessModeChange:ee,composerModelRef:et}),eu&&(0,r.Y)(o,{request:eu,onRespond:ep}),(0,r.Y)(sB.y,{toasts:ea,onDismiss:eo})]})})}},A9(e,t,n){n.d(t,{O:()=>d,k:()=>u});var r=n("j"),i=n("H"),s=n("G"),a=n("X"),l=n("Af"),o=n("ng");let c=(0,s.q6)(null);function d(e){var t;let n,{children:s,initialFolders:d=[]}=e,u=(0,a.L)(),[p,m]=(0,i.J0)(!1),h=(0,i.li)(!1),f=(0,i.li)(new Set);(0,i.vJ)(()=>{h.current||(h.current=!0,u.load("/api/sessions/list"))},[]),(0,i.vJ)(()=>{u.data&&m(!0)},[u.data]);let x=(0,i.Kr)(()=>()=>{"idle"===u.state&&u.load("/api/sessions/list")},[u]),g=!!u.data?.folders?.some(e=>e.sessions?.some(e=>"stream"===e.streamStatus));t=u.data?.folders??[],n=(0,i.li)(null),(0,i.vJ)(()=>{let e=new Set;for(let n of t)for(let t of n.sessions??[])t.awaitingInput&&e.add(String(t.id));let r=n.current;if(n.current=e,r){for(let t of e)if(!r.has(t))return void(0,o.Rn)()}},[t]),(0,l.n)(x,!g,3e4);let b=(0,i.hb)(e=>{let t=String(e),n=u.data?.folders?.flatMap(e=>e.sessions??[]).find(e=>String(e.id)===t)?.streamStatus;!n||"stream"===n||f.current.has(t)||(f.current.add(t),fetch(`/api/sessions/${encodeURIComponent(t)}/stream-seen`,{method:"POST"}).then(()=>{"idle"===u.state&&u.load("/api/sessions/list")}).catch(()=>{f.current.delete(t)}))},[u]),v=(0,i.Kr)(()=>{let e=u.data,t=f.current;if(t.size&&e?.folders)for(let n of e.folders)for(let e of n.sessions??[])"stream"===e.streamStatus&&t.delete(String(e.id));return{folders:(e?.folders??d).map(e=>t.size?{...e,sessions:(e.sessions??[]).map(e=>t.has(String(e.id))&&e.streamStatus&&"stream"!==e.streamStatus?{...e,streamStatus:void 0}:e)}:e),isMock:e?.isMock??!1,initializing:!p,refresh:x,markSeen:b,hasSeen:e=>t.has(String(e))}},[u.data,d,p,x,b]);return(0,r.Y)(c.Provider,{value:v,children:s})}function u(){let e=(0,i.NT)(c);return e||{folders:[],isMock:!1,initializing:!0,refresh:()=>{},markSeen:()=>{},hasSeen:()=>!1}}},z4(e,t,n){n.d(t,{K:()=>f});var r=n("H"),i=n("s");function s(e){let t=-1/0;for(let n of e.sessions??[]){let e=function(e){if(!e)return 0/0;let t=Date.parse(e);return Number.isFinite(t)?t:0/0}(n.updated_at??n.created_at);e>t&&(t=e)}return t}function a(e){let t=-1/0;for(let n of e.sessions??[]){let e=Number(n.id);Number.isFinite(e)&&e>t&&(t=e)}return t}function l(e){let t=Number(e.id);return Number.isFinite(t)?t:-1/0}function o(e,t){return e===t?0:e>t?-1:1}function c(e,t){return e===t?0:e>t?1:-1}let d=["A-Z","Z-A","LATEST_SESSION","LATEST_ADDED"];var u=n("Np"),p=n("A9"),m=n("NO"),h=n("So");function f(){let e,t,n,f,x,g,b,v,k,y,w=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},N=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{includePendingSessions:Y=!1,onSelectSession:D,onAfterSelect:A}=N,{folders:F,initializing:C,refresh:S,markSeen:T,hasSeen:$}=(0,p.k)(),[z,j]=(0,i.o)(),L=z.get("sessionId"),M=L?Number.isNaN(Number(L))?L:Number(L):null,E=(0,r.li)(S);E.current=S;let P=(0,r.hb)(()=>E.current(),[]);(e=(0,r.li)(P)).current=P,t=(0,r.li)(void 0),n=(0,r.li)(0),(0,r.vJ)(()=>{let r=()=>{n.current=Date.now(),e.current()},i=()=>{let e=Date.now()-n.current;if(e>=1e3){clearTimeout(t.current),t.current=void 0,r();return}clearTimeout(t.current),t.current=setTimeout(()=>{t.current=void 0,r()},1e3-e)};return window.addEventListener("omp:session-updated",i),()=>{window.removeEventListener("omp:session-updated",i),void 0!==t.current&&(clearTimeout(t.current),t.current=void 0)}},[]),(0,m.sY)("omp:workspace-updated",()=>E.current());let[I,R]=(0,r.J0)(""),[O,J]=(0,r.J0)(!1),[_,W]=(0,r.J0)(!1),[U,K]=(0,r.J0)(()=>{var e;return"string"==typeof(e=w.omp_sidebar_sort)&&d.includes(e)?w.omp_sidebar_sort:"A-Z"}),q=(0,r.li)(null),B=(0,r.hb)(e=>{q.current&&clearTimeout(q.current),q.current=setTimeout(()=>{(0,h.cz)("omp_sidebar_sort",e)},200)},[]);(0,r.vJ)(()=>()=>{q.current&&clearTimeout(q.current)},[]);let H=(0,r.Kr)(()=>(function(e){let t={};for(let n of e)for(let e of n.sessions??[])e.streamStatus&&(t[String(e.id)]=e.streamStatus);return t})(F),[F]);x=null!==(f=null===M?null:String(M))?H[f]:void 0,g=(0,r.li)(null),(b=(0,r.li)(P)).current=P,(v=(0,r.li)($)).current=$,(0,r.vJ)(()=>{if(!x||"stream"===x||v.current?.(f))return;let e=`${f}:${x}`;g.current!==e&&(g.current=e,fetch(`/api/sessions/${encodeURIComponent(f)}/stream-seen`,{method:"POST"}).then(e=>e.json()).then(e=>{!1===e.deleted&&(g.current=null),b.current()}).catch(()=>{g.current=null}))},[f,x]),(k=(0,r.li)(Object.values(H).includes("stream"))).current=Object.values(H).includes("stream"),(y=(0,r.li)(P)).current=P,(0,r.vJ)(()=>{let e=setInterval(()=>{k.current&&y.current()},8e3);return()=>clearInterval(e)},[]);let G=(0,r.Kr)(()=>{let e=[...F];if(Y){let t=e.some(e=>e.sessions?.some(e=>String(e.id)===String(L))),n=L&&!t?L:null;if(n){let t=z.get("folderId"),r=t?e.find(e=>String(e.id)===String(t)):e[0],i=!!r?.sessions?.some(e=>String(e.id)===String(n));if(r&&!i){let t=(0,u.fd)(n),i=Number.isFinite(t)?new Date(t).toISOString():new Date().toISOString();e=e.map(e=>{if(e.id!==r.id)return e;let t={id:n,folder_id:e.id,title:(0,u.g2)(n),created_at:i,updated_at:i};return{...e,isExpanded:!0,sessions:[t,...e.sessions||[]]}})}}}if(I.trim()){let t=I.toLowerCase();e=Y?e.filter(e=>{let n=e.name.toLowerCase().includes(t),r=e.sessions?.some(e=>e.title.toLowerCase().includes(t));return n||r}).map(e=>{let n=e.sessions?.filter(n=>e.name.toLowerCase().includes(t)||n.title.toLowerCase().includes(t));return{...e,sessions:n,isExpanded:!0}}):e.map(e=>{let n=e.name.toLowerCase().includes(t),r=(e.sessions||[]).filter(e=>e.title.toLowerCase().includes(t));return n?e:{...e,sessions:r}}).filter(e=>e.sessions&&e.sessions.length>0)}return e=[...e].sort((e,t)=>(function(e,t,n){let r=!!e.isPinned;if(r!==!!t.isPinned)return r?-1:1;switch(n){case"Z-A":{let n=t.name.localeCompare(e.name);return 0!==n?n:c(l(e),l(t))}case"LATEST_SESSION":{let n=o(s(e),s(t));if(0!==n)return n;let r=o(a(e),a(t));if(0!==r)return r;let i=o(l(e),l(t));return 0!==i?i:e.name.localeCompare(t.name)}case"LATEST_ADDED":{let n=o(l(e),l(t));return 0!==n?n:e.name.localeCompare(t.name)}default:{let n=e.name.localeCompare(t.name);return 0!==n?n:c(l(e),l(t))}}})(e,t,U))},[F,I,U,L,z,Y]);return{folders:F,initializing:C,refresh:P,activeSessionId:M,sessionParam:L,searchQuery:I,setSearchQuery:R,showArchived:O,setShowArchived:J,optionsOpen:_,setOptionsOpen:W,sortOption:U,handleSortChange:e=>{K(e),W(!1),B(e)},processedFolders:G,sessionStatus:H,handleSelectSession:e=>{T(e),D?D(e):j(t=>(t.set("sessionId",e.toString()),t.has("subagent")&&t.delete("subagent"),t),{replace:!0}),A?.()}}}},FE(e,t,n){var r=n("H"),i=n("g0");function s(){let[e,t]=(0,r.J0)(i.aK);return(0,r.vJ)(()=>{let e=e=>{let n=e.detail;n&&t({transport:n.transport,connected:n.connected})};return window.addEventListener(i.rt,e),t((0,i.aK)()),()=>window.removeEventListener(i.rt,e)},[]),e}n.d(t,{H:()=>s})},pH(e,t,n){async function r(e){if(!e)return!1;try{if(navigator.clipboard&&window.isSecureContext)return await navigator.clipboard.writeText(e),!0}catch(e){}try{let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.left="-999999px",t.style.top="-999999px",t.setAttribute("readonly",""),document.body.appendChild(t),t.focus(),t.select();let n=document.execCommand("copy");return document.body.removeChild(t),n}catch(e){return console.error("Failed to copy text: ",e),!1}}n.d(t,{l:()=>r})},P6(e,t,n){var r=n("H");function i(e,t){let[n,i]=(0,r.J0)(!1),[s,a]=(0,r.J0)(e),l=(0,r.li)(null),o=(0,r.li)(!1);(0,r.vJ)(()=>{n&&l.current?.select()},[n]);let c=()=>{let n=s.trim();i(!1),n&&n!==e&&t?.(n)},d=()=>{o.current=!0,i(!1)};return{isEditing:n,draft:s,setDraft:a,inputRef:l,startRename:()=>{o.current=!1,a(e),i(!0)},commitRename:c,cancelRename:d,handleKeyDown:e=>{"Enter"===e.key?(e.preventDefault(),c()):"Escape"===e.key&&(e.preventDefault(),d())},handleBlur:()=>{if(o.current){o.current=!1;return}c()}}}n.d(t,{B:()=>i})},ng(e,t,n){n("H");var r=n("So");function i(){if("u">typeof window)try{let e=window.AudioContext||window.webkitAudioContext;if(!e)return;let t=new e;"suspended"===t.state&&t.resume();let n=t.currentTime,r=t.createOscillator(),i=t.createGain();r.type="sine",r.frequency.setValueAtTime(587.33,n),r.frequency.exponentialRampToValueAtTime(880,n+.1),i.gain.setValueAtTime(0,n),i.gain.linearRampToValueAtTime(.14,n+.02),i.gain.exponentialRampToValueAtTime(1e-4,n+.32),r.connect(i),i.connect(t.destination),r.start(n),r.stop(n+.32);let s=t.createOscillator(),a=t.createGain();s.type="sine",s.frequency.setValueAtTime(880,n+.06),s.frequency.exponentialRampToValueAtTime(1174.66,n+.18),a.gain.setValueAtTime(0,n+.06),a.gain.linearRampToValueAtTime(.1,n+.08),a.gain.exponentialRampToValueAtTime(1e-4,n+.42),s.connect(a),a.connect(t.destination),s.start(n+.06),s.stop(n+.42),setTimeout(()=>{try{t.close()}catch{}},550)}catch(e){console.warn("Unable to play notification audio chime:",e)}}function s(e){if("u"<typeof window)return!0;let t=(0,r.BF)(["chatCompletionSound","soundAlerts"],e);return void 0===t||!!t}function a(e){s(e)&&i()}function l(){s()&&function(){if("u">typeof window)try{let e=window.AudioContext||window.webkitAudioContext;if(!e)return;let t=new e;"suspended"===t.state&&t.resume();let n=t.currentTime;for(let e of[{at:0,frequency:880,duration:.18,peak:.11},{at:.16,frequency:659.25,duration:.46,peak:.13}]){let r=t.createOscillator(),i=t.createGain();r.type="triangle",r.frequency.setValueAtTime(e.frequency,n+e.at),i.gain.setValueAtTime(0,n+e.at),i.gain.linearRampToValueAtTime(e.peak,n+e.at+.015),i.gain.exponentialRampToValueAtTime(1e-4,n+e.at+e.duration),r.connect(i),i.connect(t.destination),r.start(n+e.at),r.stop(n+e.at+e.duration)}setTimeout(()=>{try{t.close()}catch{}},800)}catch(e){console.warn("Unable to play input-required audio cue:",e)}}()}n.d(t,{$E:()=>i,Rn:()=>l,s4:()=>a})},oj(e,t,n){var r=n("H");function i(e,t){(0,r.vJ)(()=>{let n=n=>{!e.current||e.current.contains(n.target)||t(n)};return document.addEventListener("mousedown",n),document.addEventListener("touchstart",n),()=>{document.removeEventListener("mousedown",n),document.removeEventListener("touchstart",n)}},[e,t])}n.d(t,{W:()=>i})},jo(e,t,n){var r=n("H");function i(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:600,[t,n]=(0,r.J0)(!1),i=(0,r.li)(null),s=(0,r.hb)(()=>{n(!0),i.current&&clearTimeout(i.current),i.current=setTimeout(()=>n(!1),e)},[e]);return(0,r.vJ)(()=>()=>{i.current&&clearTimeout(i.current)},[]),{isScrolling:t,handleScroll:s}}function s(e){return e?"scrollbar-overlay-scrolling":"scrollbar-overlay"}n.d(t,{K:()=>i,p:()=>s})},NR(e,t,n){var r=n("H");function i(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:7,[n,i]=(0,r.J0)(e);return{visibleCount:n,showMore:(0,r.hb)(()=>i(e=>e+t),[t])}}n.d(t,{y:()=>i})},Po(e,t,n){var r=n("H"),i=n("eh");function s(){let[e,t]=(0,r.J0)(()=>(0,i.nv)());return(0,r.vJ)(()=>{let e=(0,i.Eu)(()=>t(!0)),n=(0,i.LT)(()=>t(!0));return()=>{e(),n()}},[]),e}n.d(t,{w:()=>s})},oZ(e,t,n){var r=n("H");function i(){let[e,t]=(0,r.J0)([]),n=(0,r.li)(0);return{toasts:e,pushToast:function(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"error",i=arguments.length>2?arguments[2]:void 0;n.current+=1,t(t=>[...t,{id:n.current,message:e,type:r,...i}])},dismissToast:e=>{t(t=>t.filter(t=>t.id!==e))}}}n.d(t,{Y:()=>i})},DO(e,t,n){var r=n("H");function i(e,t){return"object"!=typeof e||null===e?t:"error"in e&&"string"==typeof e.error?e.error:"message"in e&&"string"==typeof e.message?e.message:t}function s(){let[e,t]=(0,r.J0)(null),[n,s]=(0,r.J0)(!1),[a,l]=(0,r.J0)(null),[o,c]=(0,r.J0)(null),d=(0,r.li)(null),u=(0,r.li)(!1),p=(0,r.hb)(()=>{if(d.current)return d.current;let e=(async()=>{s(!0),c(null);try{let e=await fetch("/api/updates/check"),n=await e.json();if(!e.ok)throw Error(i(n,`Update check failed (HTTP ${e.status})`));t(n)}catch(e){c(e instanceof Error?e.message:"Unable to check for updates.")}finally{s(!1),d.current=null}})();return d.current=e,e},[]),m=(0,r.hb)(async e=>{l(e),c(null);try{let t=await fetch("/api/updates/apply",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({target:e})}),n=await t.json();if("object"!=typeof n||null===n||!("success"in n)||"boolean"!=typeof n.success||!("target"in n)||"ompchamber"!==n.target&&"omp"!==n.target||!("manual"in n)||"boolean"!=typeof n.manual||!("message"in n)||"string"!=typeof n.message)throw Error(i(n,`Update failed (HTTP ${t.status})`));return await p(),n}catch(e){return c(e instanceof Error?e.message:"Unable to apply the update."),null}finally{l(null)}},[p]);return(0,r.vJ)(()=>{u.current||(u.current=!0,p())},[]),{info:e,checking:n,applying:a,error:o,hasUpdate:!!(e?.ompchamber.updateAvailable||e?.omp.updateAvailable),check:p,apply:m}}n.d(t,{M:()=>s})},c(e,t,n){var r=n("H");function i(e,t){let{enabled:n,intervalMs:i,guardInFlight:s=!1}=t,a=(0,r.li)(e);a.current=e,(0,r.vJ)(()=>{if(!n||i<=0)return;let e="u"<typeof document||"visible"===document.visibilityState,t=!1,r=()=>{if(!s)return void a.current();if(t)return;let e=a.current();if(!e||"function"!=typeof e.then)return;t=!0;let n=()=>{t=!1};Promise.resolve(e).then(n,n)},l=setInterval(()=>{e&&r()},i),o=()=>{let t="visible"===document.visibilityState;t&&!e&&r(),e=t};return document.addEventListener("visibilitychange",o),()=>{clearInterval(l),document.removeEventListener("visibilitychange",o)}},[n,i,s])}n.d(t,{t:()=>i})},NO(e,t,n){var r=n("H");function i(e,t,n,i){let s=(0,r.li)(n);s.current=n,(0,r.vJ)(()=>{let n=e=>s.current(e);return e.addEventListener(t,n,i),()=>e.removeEventListener(t,n,i)},[e,t,i])}function s(e,t,n){i(window,e,t,n)}function a(e,t,n){i(document,e,t,n)}function l(e,t,n){i(window,e,t,n)}n.d(t,{MN:()=>s,sY:()=>l,zo:()=>a})},so(e,t,n){var r=n("H"),i=n("LQ"),s=n("c"),a=n("NO");function l(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:".",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,l=!(arguments.length>3)||void 0===arguments[3]||arguments[3],o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,[c,d]=(0,r.J0)([]),[u,p]=(0,r.J0)(!1),m=(0,r.hb)(()=>{if(!l)return;p(!0);let n=new URLSearchParams;e&&n.set("root",e),t&&"."!==t&&n.set("repo",t),n.set("t",String(Date.now())),fetch(`/api/fs/git?${n.toString()}`).then(e=>e.json()).then(e=>{Array.isArray(e.changes)?d(e.changes):d([])}).catch(()=>d([])).finally(()=>p(!1))},[l,e,t]);(0,r.vJ)(()=>{m()},[m,n]),(0,s.t)(m,{enabled:l,intervalMs:o}),(0,a.MN)("focus",()=>{l&&m()}),(0,a.zo)("visibilitychange",()=>{l&&m()});let h=(0,r.li)(void 0),f=(0,r.hb)(()=>{l&&void 0===h.current&&(h.current=setTimeout(()=>{h.current=void 0,m()},1e3))},[l,m]);(0,r.vJ)(()=>()=>{void 0!==h.current&&clearTimeout(h.current)},[]),(0,a.sY)("omp:session-updated",f),(0,a.sY)("omp:workspace-updated",f);let{fileMap:x,folderMap:g}=(0,r.Kr)(()=>(0,i._)(c),[c]);return{changes:c,fileMap:x,folderMap:g,isLoading:u,refreshGitStatus:m}}n.d(t,{e:()=>l})},Af(e,t,n){var r=n("H"),i=n("K"),s=n("c");function a(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:5e3;(0,s.t)(e,{enabled:t,intervalMs:n,guardInFlight:!0})}function l(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:500,s=(0,r.li)(e);s.current=e,(0,r.vJ)(()=>{let e;if(!t)return;let r=()=>{clearTimeout(e),e=window.setTimeout(()=>{e=void 0,("u"<typeof document||"visible"===document.visibilityState)&&s.current()},n)};return window.addEventListener(i.s,r),()=>{window.removeEventListener(i.s,r),clearTimeout(e)}},[t,n])}n.d(t,{n:()=>a,w:()=>l})},As(e,t,n){var r=n("H");let i=(0,n("G").q6)(null);function s(){let e=(0,r.NT)(i);if(!e)throw Error("useSessionState used outside SessionStateProvider");return e}n.d(t,{O:()=>s},{b:i})},FL(e,t,n){var r=n("H"),i=n("SS"),s=n("As");function a(e,t){let{sessionId:n,ready:a}=(0,s.O)(),l=(0,i.WV)(n,e),[o,c]=(0,r.J0)(void 0===l?t:l),d=(0,r.li)(n);(0,r.vJ)(()=>{if(d.current!==n&&(d.current=n),!a)return;let r=(0,i.WV)(n,e);c(void 0===r?t:r)},[n,a,e]);let u=t=>{let r="function"==typeof t?t((0,i.WV)(n,e)??o):t;c(r),(0,i.qI)(n,e,r)};return a||void 0===l||l===o?[o,u,a]:[l,u,a]}function l(){let{sessionId:e,ready:t}=(0,s.O)();return{sessionId:e,ready:t,read:(t,n)=>{let r=(0,i.WV)(e,t);return void 0===r?n:r},hydrate:t=>(0,i.E9)(e,t)}}n.d(t,{bL:()=>a,p0:()=>l},{LO:a})},U(e,t,n){var r=n("H"),i=n("X");function s(e,t){let[n,s]=(0,r.J0)(!1),a=(0,i.L)(),l=(0,i.L)(),o=(0,i.L)();return(0,r.vJ)(()=>{(a.data?.success||l.data?.success)&&window.dispatchEvent(new CustomEvent("omp:workspace-updated"))},[l.data,a.data]),{confirmDelete:n,requestDelete:()=>s(!0),cancelDelete:()=>s(!1),handlePin:()=>{"number"==typeof e.id&&(a.submit({isPinned:String(!e.isPinned)},{method:"POST",action:`/api/folders/${e.id}/pin`}),t())},handleDelete:()=>{"number"==typeof e.id&&(l.submit({},{method:"POST",action:`/api/folders/${e.id}/delete`}),s(!1),t())},handleArchive:e=>{let n=1!==e.is_archived;o.submit({archived:String(n)},{method:"POST",action:`/api/sessions/${e.id}/archive`}),t()},handleRename:async(e,n)=>{try{let t=new FormData;if(t.set("name",n),!(await fetch(`/api/sessions/${encodeURIComponent(String(e.id))}/rename`,{method:"POST",body:t})).ok)return}catch{return}window.dispatchEvent(new CustomEvent("omp:session-renamed",{detail:{sessionId:String(e.id),title:n}})),t()}}}n.d(t,{C:()=>s})},X(e,t,n){var r=n("H");async function i(e){let t=await e.text();if(t)try{return JSON.parse(t)}catch{return}}function s(){let[e,t]=(0,r.J0)(void 0),[n,s]=(0,r.J0)("idle"),a=(0,r.li)(!0),l=(0,r.li)(null);(0,r.vJ)(()=>(a.current=!0,()=>{a.current=!1,l.current?.abort(),l.current=null}),[]);let o=(0,r.hb)(async(e,n,r)=>{l.current?.abort();let o=new AbortController;l.current=o,s(r);try{let r=await fetch(e,{...n,signal:o.signal}),s=await i(r);a.current&&l.current===o&&t(s)}catch{}finally{a.current&&l.current===o&&(l.current=null,s("idle"))}},[]);return{data:e,state:n,load:(0,r.hb)(e=>o(e,{method:"GET"},"loading"),[o]),submit:(0,r.hb)((e,t)=>o(t.action,{method:(t.method??"POST").toUpperCase(),body:function(e){if(e instanceof FormData)return e;let t=new URLSearchParams;for(let[n,r]of Object.entries(e))null!=r&&t.set(n,String(r));return t}(e),headers:e instanceof FormData?void 0:{"content-type":"application/x-www-form-urlencoded"}},"submitting"),[o])}}n.d(t,{L:()=>s})},s(e,t,n){var r=n("G");let i=new Set,s="u"<typeof window?"":window.location.search;function a(){for(let e of i)e()}function l(e){return i.add(e),()=>i.delete(e)}function o(e){if("string"==typeof e)return e.startsWith("?")?e:`?${e}`;if(e instanceof URLSearchParams)return e.toString()?`?${e.toString()}`:"";let t=new URLSearchParams;for(let[n,r]of Object.entries(e))null!=r&&t.set(n,String(r));return t.toString()?`?${t.toString()}`:""}function c(){return s}function d(){let e=(0,r.rz)(l,c),t=(0,r.hb)((e,t)=>{var n;let r=(n=new URLSearchParams(s),"function"==typeof e?o(e(new URLSearchParams(n))):o(e)),i=`${window.location.pathname}${r}${window.location.hash}`;t?.replace?window.history.replaceState(null,"",i):window.history.pushState(null,"",i),s=r,a()},[]);return[new URLSearchParams(e),t]}"u">typeof window&&window.addEventListener("popstate",function(){let e="u"<typeof window?"":window.location.search;e!==s&&(s=e,a())}),n.d(t,{o:()=>d})},l(e,t,n){var r=n("j"),i=n("v"),s=n("H"),a=n("G"),l=n("s");function o(e,t,n){return Math.min(Math.max(e,t),n)}function c(e,t){return"number"==typeof e?e:"string"==typeof e&&parseFloat(e)||t}let d=(0,a.q6)(null);function u(e){let{orientation:t,id:n,groupRef:i,onLayoutChanged:l,className:o,children:c}=e,u=(0,s.li)(new Map),p=(0,s.li)(l??null);p.current=l??null;let m=(0,a.Kr)(()=>({orientation:t,panels:u,onLayoutChanged:p}),[t]);return(0,r.Y)(d.Provider,{value:m,children:(0,r.Y)("div",{ref:i,"data-panel-group":"","data-panel-group-id":n,className:o,style:{display:"flex",flex:"1 1 0%",flexDirection:"horizontal"===t?"row":"column",minWidth:0,minHeight:0},children:c})})}function p(e){let{id:t,panelRef:n,defaultSize:i,minSize:s=0,maxSize:l,collapsed:u=!1,filler:p=!1,className:m,style:h,children:f}=e,x=(0,a.NT)(d);if(!x)throw Error(`<Panel id="${t}"> must be rendered inside a <Group>`);let{orientation:g,panels:b}=x,v=c(s,0),k=null!=l?c(l,Number.MAX_SAFE_INTEGER):Number.MAX_SAFE_INTEGER,y=(0,a.li)(null),[w,N]=(0,a.J0)(()=>p?null:o(c(i,v),v,k)),Y=(0,a.li)(w);Y.current=w,(0,a.vJ)(()=>(b.current.set(t,{id:t,isFiller:p,minSize:v,maxSize:k,setSize:e=>N(e),getSize:()=>Y.current}),()=>{b.current.delete(t)}),[t]),(0,a.vJ)(()=>{let e=b.current.get(t);e&&(e.minSize=v,e.maxSize=k)});let D=(0,a.li)(null);(0,a.vJ)(()=>{if(p||null==i)return;let e=c(i,v);D.current!==e&&(D.current=e,N(o(e,v,k)))},[i,p,v,k]),(0,a.vJ)(()=>{if(n)return n.current={resize:e=>{N(o(e,v,k))},getSize:()=>{let e=Y.current;return null!=e?{inPixels:e}:null}},()=>{n.current=null}},[n,v,k]);let A=p?{flex:"1 1 0%",minWidth:"horizontal"===g?v:0,minHeight:"horizontal"===g?0:v,overflow:"hidden",position:"relative"}:{flex:"0 1 auto",width:"horizontal"===g?u?0:w??void 0:void 0,height:"horizontal"===g?void 0:u?0:w??void 0,minWidth:"horizontal"===g?u?0:v:void 0,minHeight:"horizontal"===g?void 0:u?0:v,maxWidth:null!=l?k:void 0,transition:`${"horizontal"===g?"width":"height"} 200ms cubic-bezier(0.22, 1, 0.36, 1)`,overflow:"hidden",position:"relative"};return(0,r.Y)("div",{ref:y,"data-panel":"","data-panel-id":t,"data-panel-collapsed":u?"":void 0,className:m,style:{...A,...h},children:f})}function m(e){let{className:t,style:n,children:i}=e,l=(0,a.NT)(d),c=(0,a.li)(null);if(!l)throw Error("<Separator> must be rendered inside a <Group>");let{orientation:u,panels:p,onLayoutChanged:m}=l,{dragging:h,guidePx:f,onPointerDown:x}=function(e,t,n,r){let[i,a]=(0,s.J0)(!1),[l,c]=(0,s.J0)(null),d=(0,s.li)(null);return(0,s.vJ)(()=>()=>d.current?.(),[]),{dragging:i,guidePx:l,onPointerDown:i=>{let s,l=e.current;if(!l||0!==i.button)return;let u=(e,t)=>{let n=e;for(;n;){if(n.hasAttribute("data-separator")||n.hasAttribute("data-panel-collapsed")){n="previous"===t?n.previousElementSibling:n.nextElementSibling;continue}return n instanceof HTMLElement&&n.hasAttribute("data-panel")?n:null}return null},p=u(l.previousElementSibling,"previous"),m=u(l.nextElementSibling,"next"),h=p?n.current.get(p.getAttribute("data-panel-id")??""):void 0,f=m?n.current.get(m.getAttribute("data-panel-id")??""):void 0;if(!h||!f||!p||!m)return;i.preventDefault(),a(!0);let x="horizontal"===t,g=x?i.clientX:i.clientY,b=e=>x?e.getBoundingClientRect().width:e.getBoundingClientRect().height,v=b(p),k=b(m),y=null,w=e=>{h.setSize(e.a),f.isFiller||f.setSize(e.b)},N=e=>{var t,n;let r=x?e.clientX:e.clientY,i=(t={size:v,min:h.minSize,max:h.maxSize},n={size:k,min:f.minSize,max:f.maxSize},o(r-g,Math.max(t.min-t.size,n.size-n.max),Math.min(t.max-t.size,n.size-n.min)));y={a:o(v+i,h.minSize,h.maxSize),b:o(k-i,f.minSize,f.maxSize)},c(r),void 0===s&&(s=setTimeout(()=>{s=void 0,y&&w(y)},100))},Y=()=>{window.removeEventListener("pointermove",N),window.removeEventListener("pointerup",Y),window.removeEventListener("pointercancel",Y),clearTimeout(s),d.current=null,a(!1),c(null),y&&w(y);let e={};for(let[t,r]of n.current){let n=r.getSize();null!=n&&(e[t]=n)}r.current?.(e,{isUserInteraction:!0})};window.addEventListener("pointermove",N),window.addEventListener("pointerup",Y),window.addEventListener("pointercancel",Y),d.current=Y}}}(c,u,p,m);return(0,r.FD)("div",{ref:c,"data-separator":"",role:"separator","aria-orientation":"horizontal"===u?"vertical":"horizontal",className:t,style:n,onPointerDown:x,onDragStart:e=>e.preventDefault(),children:[i,h&&(0,r.Y)("div",{style:{position:"fixed",inset:0,zIndex:9999,cursor:"horizontal"===u?"col-resize":"row-resize"}}),null!==f&&(0,r.Y)("div",{"aria-hidden":"true",style:{position:"fixed",..."horizontal"===u?{left:`${f}px`,top:0,bottom:0,width:"1px"}:{top:`${f}px`,left:0,right:0,height:"1px"},zIndex:9998,pointerEvents:"none",background:"var(--theme-ink)",opacity:.35}})]})}var h=n("g"),f=n("r");function x(e){let{onNewSession:t}=e;return(0,r.FD)(r.FK,{children:[(0,r.Y)("div",{className:"h-14 flex-shrink-0 flex items-center px-4 border-b border-ink/10 titlebar-drag-region select-none",style:{paddingLeft:"max(1rem, env(titlebar-area-x, 0px))"},children:(0,r.FD)("span",{className:"font-bold text-sm tracking-tight flex items-center",children:[(0,r.Y)("span",{className:"text-transparent bg-clip-text bg-gradient-to-r from-orange-600 to-amber-500 font-extrabold text-[15px] tracking-tighter",children:"OMP"}),(0,r.Y)("span",{className:"ml-[1px]",children:"Chamber"})]})}),(0,r.Y)("div",{className:"px-3 pt-3 titlebar-no-drag",children:(0,r.FD)("button",{onClick:t,className:"w-full flex items-center justify-center space-x-2 py-2 bg-ink text-canvas rounded text-xs font-semibold hover:bg-ink/90 transition-colors cursor-pointer",children:[(0,r.Y)(f.A,{size:14}),(0,r.Y)("span",{children:"New Session"})]})})]})}var g=n("D"),b=n("O"),v=n("n"),k=n("t3"),y=n("p7"),w=n("Sj"),N=n("x"),Y=n("S"),D=n("E");function A(e){let{isSearchVisible:t,searchQuery:n,showArchived:i,optionsOpen:s,sortOption:a,onToggleSearch:l,onSearchChange:o,onToggleArchived:c,onHideArchived:d,onToggleOptions:u,onCloseOptions:p,onSortChange:m,onNewWorkspace:h,onScheduler:f,onRefresh:x,onClose:A}=e;return(0,r.FD)("div",{className:"p-3 border-b border-ink/10 flex flex-col space-y-3",children:[(0,r.FD)("div",{className:"flex items-center justify-between px-1 text-ink/60",children:[(0,r.FD)("div",{className:"flex space-x-3 items-center",children:[(0,r.Y)(g.A,{size:14,className:"hover:text-ink cursor-pointer",onClick:h}),(0,r.Y)(b.A,{size:14,className:"hover:text-ink cursor-pointer",onClick:f}),(0,r.Y)("span",{title:"Refresh sessions",onClick:x,className:"inline-flex cursor-pointer",children:(0,r.Y)(v.A,{size:14,className:"hover:text-ink"})})]}),(0,r.FD)("div",{className:"flex space-x-3 items-center relative",children:[(0,r.Y)(k.A,{size:14,className:`cursor-pointer transition-colors ${t?"text-ink":"hover:text-ink"}`,onClick:l}),(0,r.Y)("span",{title:i?"Hide Archive":"Show Archive",onClick:c,className:"inline-flex cursor-pointer",children:(0,r.Y)(y.A,{size:14,className:`transition-colors ${i?"text-ink":"hover:text-ink"}`})}),(0,r.FD)("div",{className:"relative",children:[(0,r.Y)(w.A,{size:14,className:`cursor-pointer transition-colors ${s?"text-ink":"hover:text-ink"}`,onClick:u}),s&&(0,r.Y)("div",{className:"absolute right-0 top-full mt-2 w-48 bg-paper border border-ink/10 rounded shadow-lg z-50 py-1",onMouseLeave:p,children:(0,r.Y)(D.i,{variant:"desktop",sortOption:a,onSortChange:m})})]}),(0,r.Y)(N.A,{size:14,className:"hover:text-ink cursor-pointer ml-1",onClick:A})]})]}),t&&(0,r.Y)("div",{className:"pt-1",children:(0,r.Y)("input",{type:"text",placeholder:"Search workspaces & sessions...",value:n,onChange:e=>o(e.currentTarget.value),autoFocus:!0,className:"w-full bg-ink/5 border border-ink/10 rounded px-2.5 py-1.5 outline-none focus:border-ink/30 text-xs text-ink placeholder-ink/40 transition-colors"})}),i&&(0,r.FD)("div",{className:"flex items-center justify-between bg-amber-500/10 border border-amber-500/20 text-amber-900 rounded px-2.5 py-1.5 text-[10px] font-medium",children:[(0,r.FD)("div",{className:"flex items-center space-x-1.5",children:[(0,r.Y)(y.A,{size:10}),(0,r.Y)("span",{children:"Showing Archived"})]}),(0,r.Y)("button",{className:"hover:text-amber-950",onClick:d,children:(0,r.Y)(Y.A,{size:10})})]})]})}var F=n("vB"),C=n("wU");function S(e){let{onSettings:t,onInfo:n,updateAvailable:i,onUpdateClick:s}=e;return(0,r.FD)("div",{className:"p-3 border-t border-ink/10 flex items-center justify-between text-ink/60 shrink-0",children:[(0,r.FD)("div",{className:"flex space-x-3",children:[(0,r.Y)(F.A,{size:16,className:"hover:text-ink cursor-pointer",onClick:t}),(0,r.Y)(C.A,{size:16,className:"hover:text-ink cursor-pointer",onClick:n})]}),i&&(0,r.Y)("button",{type:"button",onClick:s,className:"px-2 py-0.5 rounded-full border border-ink/20 text-[10px] font-semibold text-ink hover:border-ink/40",children:"update"})]})}var T=n("a"),$=n("X"),z=n("oj"),j=n("NR"),L=n("U"),M=n("Go"),E=n("Nf"),P=n("WO"),I=n("t"),R=n("z"),O=n("b"),J=n("HZ"),_=n("P6");function W(e){let{title:t,isActive:n=!1,isArchived:i=!1,status:s,awaitingInput:a=!1,onClick:l,onArchive:o,onRename:c,expandable:d=!1,isExpanded:u=!1,hasSubagents:p=!1,onToggleExpand:m}=e,h=!!(d&&p&&m),f=h&&!(a||"stream"===s),{isEditing:x,draft:g,setDraft:b,inputRef:v,startRename:k,handleKeyDown:w,handleBlur:N}=(0,_.B)(t,c);return(0,r.FD)("div",{onClick:x?void 0:l,className:`group/item relative flex items-center w-full rounded-lg px-2 py-1.5 cursor-pointer text-xs transition-colors select-none ${n?"bg-ink/10 font-medium text-ink":"text-ink/75 hover:text-ink hover:bg-ink/5"}`,children:[(0,r.FD)("span",{className:"relative w-4 h-4 shrink-0",children:[h&&m&&(0,r.Y)("button",{type:"button",onClick:e=>{e.stopPropagation(),m(e)},title:u?"Collapse subagents":"Expand subagents","aria-expanded":u,className:`peer absolute inset-0 flex items-center justify-center rounded cursor-pointer transition-opacity ${f?"text-ink/60 hover:text-ink":"text-ink/40 hover:text-ink pointer-events-none opacity-0 group-hover/item:pointer-events-auto group-hover/item:opacity-100 focus-visible:opacity-100"}`,children:u?(0,r.Y)(M.A,{size:13}):(0,r.Y)(E.A,{size:13})}),!!(a||s)&&!f&&(0,r.Y)("span",{className:`pointer-events-none absolute inset-0 flex items-center justify-center text-ink/60 transition-opacity ${h?"group-hover/item:opacity-0 peer-focus-visible:opacity-0":""}`,children:a?(0,r.Y)(P.A,{size:12,className:"animate-pulse text-ink/80"}):"stream"===s?(0,r.Y)(I.A,{size:12,className:"animate-spin"}):(0,r.Y)(R.A,{size:12})})]}),(0,r.Y)("span",{className:"w-2 shrink-0"}),x?(0,r.Y)("input",{ref:v,autoFocus:!0,value:g,onChange:e=>b(e.currentTarget.value),onClick:e=>e.stopPropagation(),onKeyDown:w,onBlur:N,className:"flex-1 min-w-0 bg-paper border border-ink/25 rounded px-1 py-0.5 text-xs text-ink outline-none focus:border-ink/50"}):(0,r.Y)("span",{className:"flex-1 min-w-0 truncate leading-snug",children:t.charAt(0).toUpperCase()+t.slice(1)}),!x&&(c||o)&&(0,r.FD)("div",{className:"absolute right-1.5 top-1/2 -translate-y-1/2 flex items-center gap-0.5 opacity-0 group-hover/item:opacity-100 transition-opacity",children:[c&&(0,r.Y)("button",{type:"button",onClick:e=>{e.stopPropagation(),k()},title:"Rename session",className:"p-1 text-ink/40 hover:text-ink bg-paper/90 hover:bg-ink/10 rounded shadow-xs cursor-pointer",children:(0,r.Y)(O.A,{size:12})}),o&&(0,r.Y)("button",{type:"button",onClick:e=>{e.stopPropagation(),o()},title:i?"Unarchive session":"Archive session",className:"p-1 text-ink/40 hover:text-ink bg-paper/90 hover:bg-ink/10 rounded shadow-xs cursor-pointer",children:i?(0,r.Y)(J.A,{size:12}):(0,r.Y)(y.A,{size:12})})]})]})}var U=n("Uo"),K=n("oS"),q=n("B"),B=n("V7"),H=n("T");let G={pending:"started",running:"started",completed:"completed",failed:"failed",aborted:"aborted"};function V(e){let{sessionId:t,isActiveSession:n}=e,[i]=(0,l.o)(),a=i.get("subagent"),[o,c]=(0,s.J0)([]),[d,u]=(0,s.J0)(!1);(0,s.vJ)(()=>{let e=!1,n=String(t);return c([]),u(!0),(0,q.wv)(n).then(t=>{if(e||!t)return;let n=t.map(q.Nh);c(e=>(0,H.j8)(e,n))}).finally(()=>{e||u(!1)}),()=>{e=!0}},[t]),(0,s.vJ)(()=>{if(!n)return;let e=!1,r=String(t),i=Date.now(),s=e=>{let t=e.detail;return t&&t.sessionId===r?t:null},a=e=>{let t=(0,H.bH)(s(e)?.payload);t&&c(e=>(0,H.j8)(e,[t]))},l=e=>{let t=function(e){let t=(0,H.mq)(e);if(!(0,K.u)(e)||!(0,K.u)(e.progress))return t;let n=(0,H.mq)(e.progress);return n?{...n,id:n.id??t?.id,index:n.index??t?.index}:t}(s(e)?.payload);t&&c(e=>e.map(e=>{if(void 0!==t.id){if(e.id!==t.id)return e}else if(void 0===t.index||t.index<0||e.index!==t.index)return e;let n=t.status&&"started"===e.status?G[t.status]??e.status:e.status;return{...e,status:n,progress:{...e.progress,...t},lastUpdate:Date.now()}}))};return window.addEventListener("subagent_lifecycle",a),window.addEventListener("subagent_progress",l),fetch(`/api/agent/${encodeURIComponent(r)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"get_subagents"})}).then(e=>e.ok?e.json():null).then(t=>{if(e||!(0,K.u)(t))return;let n="data"in t?t.data:t;c(e=>(0,H.j8)(e,(0,H.vG)(n),i))}).catch(()=>{}),()=>{e=!0,window.removeEventListener("subagent_lifecycle",a),window.removeEventListener("subagent_progress",l)}},[n,t]);let p=d?"Loading subagents…":0===o.length?"No subagent activity":null;return(0,r.Y)("div",{className:"pl-6 pr-0 space-y-0.5 py-0.5",children:p?(0,r.FD)("div",{className:"px-2 py-1 text-xs italic text-ink/40 flex items-center",children:[(0,r.Y)("span",{className:"w-4 h-4 shrink-0"}),(0,r.Y)("span",{className:"w-2 shrink-0"}),(0,r.Y)("span",{className:"flex-1 min-w-0 truncate",children:p})]}):o.map(e=>{let i=(0,B.us)(e),s=e.task??e.assignment??e.description??i,l=e.id===a;return(0,r.FD)("button",{type:"button",title:s,onClick:()=>window.dispatchEvent(new CustomEvent("omp:view-subagent",{detail:{sessionId:String(t),subagent:e}})),className:`w-full flex items-center text-left text-xs rounded-md px-2 py-1 cursor-pointer transition-colors select-none group/subagent ${l?"bg-ink/10 font-medium text-ink":"text-ink/70 hover:text-ink hover:bg-ink/5"}`,children:[(0,r.Y)("span",{className:"w-4 h-4 flex items-center justify-center shrink-0",children:(0,r.Y)(U.l,{status:e.status,live:n&&"started"===e.status,size:11})}),(0,r.Y)("span",{className:"w-2 shrink-0"}),(0,r.Y)("span",{className:"flex-1 min-w-0 truncate leading-snug",children:i})]},e.id)})})}var Z=n("C4"),Q=n("So");let X="omp_sidebar_expanded_sessions";var ee=n("A"),et=n("A9");function en(e){let{folder:t,activeSessionId:n,onSelectSession:i,onNewSessionForFolder:a,forceExpanded:o=!1,showArchived:c=!1,sessionStatus:d={}}=e,[u,p]=(0,s.J0)(t.isExpanded||!1),[m,h]=(0,s.J0)(!1),{visibleCount:x,showMore:g}=(0,j.y)(),[b]=(0,l.o)(),v=b.get("subagent"),k=b.get("sessionId"),[y,N]=(0,s.J0)(()=>new Set);(0,s.vJ)(()=>{let e,t=Array.isArray(e=(0,Q.BF)(X))?new Set(e.filter(e=>"string"==typeof e)):new Set;t&&t.size>0&&N(t)},[]),(0,s.vJ)(()=>{"boolean"==typeof t.isExpanded&&p(t.isExpanded)},[t.isExpanded]),(0,s.vJ)(()=>{v&&k&&N(e=>{if(e.has(k))return e;let t=new Set(e);return t.add(k),t})},[v,k]);let Y=(0,s.li)(null),{refresh:D}=(0,et.k)(),A=(0,$.L)(),{confirmDelete:F,requestDelete:C,cancelDelete:S,handlePin:M,handleDelete:E,handleArchive:P,handleRename:I}=(0,L.C)(t,D);(0,s.vJ)(()=>{A.data?.success&&window.dispatchEvent(new CustomEvent("omp:workspace-updated"))},[A.data]),(0,z.W)(Y,()=>{h(!1),S()});let R=t.sessions,O=(0,ee.x)(t.icon),J=(R||[]).filter(e=>c?1===e.is_archived:1!==e.is_archived),_=J.slice(0,x),U=J.length>x;return(0,r.FD)("div",{className:"space-y-1",children:[(0,r.FD)("div",{className:"group flex items-center justify-between h-7 text-xs font-semibold text-ink px-2 hover:bg-ink/5 rounded-md transition-colors select-none",children:[(0,r.FD)("div",{className:"flex-1 h-full flex items-center cursor-pointer min-w-0",onClick:()=>{let e=!u;p(e),"number"==typeof t.id&&A.submit({isExpanded:String(e)},{method:"POST",action:`/api/folders/${t.id}/toggle`})},children:[(0,r.Y)("span",{className:"w-4 h-4 flex items-center justify-center shrink-0",children:t.customIconUrl?(0,r.Y)("img",{src:t.customIconUrl,alt:"",className:"w-[15px] h-[15px] rounded-xs object-contain shrink-0",referrerPolicy:"no-referrer"}):(0,r.Y)(O,{size:15,className:"text-ink/75",style:{color:t.accentColor||void 0}})}),(0,r.Y)("span",{className:"w-2 shrink-0"}),t.isPinned&&(0,r.Y)(T.A,{size:11,className:"text-ink/60 shrink-0 mr-1.5"}),(0,r.Y)("span",{className:"truncate text-[13px] font-semibold tracking-tight",children:t.name})]}),(0,r.FD)("div",{className:`items-center space-x-0.5 pl-1 ${m?"flex":"hidden group-hover:flex"}`,children:[(0,r.Y)("button",{type:"button",title:"New Session",className:"w-5 h-5 flex items-center justify-center text-ink/40 hover:text-ink hover:bg-ink/10 rounded cursor-pointer transition-colors",onClick:e=>{e.stopPropagation(),a(t.id)},children:(0,r.Y)(f.A,{size:12})}),(0,r.FD)("div",{className:"relative flex items-center",ref:Y,children:[(0,r.Y)("button",{type:"button",title:"Workspace Options",className:"w-5 h-5 flex items-center justify-center text-ink/40 hover:text-ink hover:bg-ink/10 rounded cursor-pointer transition-colors",onClick:e=>{e.stopPropagation(),h(!m)},children:(0,r.Y)(w.A,{size:12})}),m&&(0,r.Y)("div",{className:"absolute right-0 top-full mt-1 w-44 bg-paper border border-ink/15 rounded-md shadow-lg z-50 py-1 text-xs",children:(0,r.Y)(Z.t,{variant:"desktop",isPinned:t.isPinned,confirmDelete:F,onPin:()=>{M(),h(!1)},onDelete:()=>{E(),h(!1)},onRequestDelete:C,onCancelDelete:S})})]})]})]}),(o||u)&&(0,r.FD)("div",{className:"space-y-0.5",children:[_.map(e=>{let t=String(e.id),s=null!==n?String(n)===t:1===e.is_active,a=s&&k===t&&!!v,l=null!==n&&t===String(n),o=!!e.hasSubagents,c=o&&y.has(t);return(0,r.FD)("div",{className:"space-y-0.5",children:[(0,r.Y)(W,{title:e.title,isActive:s&&!a,isArchived:1===e.is_archived,status:d[t],awaitingInput:!!e.awaitingInput,onClick:()=>i(e.id),onArchive:()=>P(e),onRename:String(e.id).startsWith("new-")?void 0:t=>void I(e,t),expandable:o,hasSubagents:o,isExpanded:c,onToggleExpand:()=>{N(e=>{let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),(0,Q.cz)(X,[...n].slice(-50)),n})}}),o&&c&&(0,r.Y)(V,{sessionId:e.id,isActiveSession:l})]},e.id)}),U&&!o&&(0,r.FD)("button",{type:"button",onClick:g,className:"flex items-center text-xs text-ink/45 hover:text-ink/80 w-full text-left py-1.5 px-2 rounded-lg hover:bg-ink/5 transition-colors cursor-pointer select-none",children:[(0,r.Y)("span",{className:"w-4 h-4 shrink-0"}),(0,r.Y)("span",{className:"w-2 shrink-0"}),(0,r.Y)("span",{className:"truncate leading-snug",children:"Show more sessions"})]}),0===J.length&&(0,r.Y)("div",{className:"px-3 py-2 text-[11px] text-ink/40 italic",children:c?"No archived sessions.":"No sessions."})]})]})}var er=n("jo");function ei(e){let{folders:t,activeSessionId:n,searchQuery:i,showArchived:s,sessionStatus:a,isScrolling:l,onScroll:o,onSelectSession:c,onNewSessionForFolder:d}=e;return(0,r.Y)("div",{onScroll:o,className:`flex-1 scrollbar-overlay-container p-2 space-y-4 ${(0,er.p)(l)}`,children:0===t.length?(0,r.Y)("div",{className:"text-center py-8 text-xs text-ink/40",children:i?"No results found.":"No workspaces available."}):t.map(e=>(0,r.Y)(en,{folder:e,activeSessionId:n,onSelectSession:c,onNewSessionForFolder:d,forceExpanded:!!i,showArchived:s,sessionStatus:a},e.id))})}let es=[3,2];function ea(){return(0,r.Y)("div",{className:"flex-1 p-2 space-y-4","aria-hidden":"true",children:es.map((e,t)=>(0,r.FD)("div",{className:"space-y-1.5",children:[(0,r.FD)("div",{className:"flex items-center gap-2 px-1 py-1.5",children:[(0,r.Y)("span",{className:"w-3.5 h-3.5 rounded-sm animate-pulse bg-ink/10"}),(0,r.Y)("span",{className:"h-3 w-24 rounded animate-pulse bg-ink/10"})]}),Array.from({length:e},(e,t)=>(0,r.FD)("div",{className:"flex items-center gap-2 rounded px-2 py-1.5",children:[(0,r.Y)("span",{className:"w-4 h-4 rounded-full animate-pulse bg-ink/10"}),(0,r.Y)("span",{className:"h-3 rounded animate-pulse bg-ink/10",style:{width:`${58-t%3*12}%`}})]},t))]},t))})}var el=n("wu"),eo=n("wm"),ec=n("oZ"),ed=n("DO"),eu=n("z4");function ep(e){let{className:t="",onClose:n,appSettings:i={}}=e,{folders:a,initializing:o,refresh:c,activeSessionId:d,sessionParam:u,searchQuery:p,setSearchQuery:m,showArchived:f,setShowArchived:g,optionsOpen:b,setOptionsOpen:v,sortOption:k,handleSortChange:y,processedFolders:w,sessionStatus:N,handleSelectSession:Y}=(0,eu.K)(i,{includePendingSessions:!0}),[,D]=(0,l.o)(),[F,C]=(0,s.J0)(!1),[T,$]=(0,s.J0)(!1),[z,j]=(0,s.J0)(!1),[L,M]=(0,s.J0)(!1),E=(0,ed.M)(),{toasts:P,pushToast:I,dismissToast:R}=(0,ec.Y)(),[O,J]=(0,s.J0)(!1),{isScrolling:_,handleScroll:W}=(0,er.K)(),U=e=>{let t=(0,eo.l)(a,u,e);t&&(0,eo.r)(t,i.omp_access_mode)};return(0,r.FD)(r.FK,{children:[(0,r.FD)("aside",{className:`flex flex-col bg-paper h-full ${t}`,children:[(0,r.Y)(x,{onNewSession:()=>{U(),D(e=>{let t=e.get("sessionId"),n=new URLSearchParams(e);if(n.set("sessionId",`new-${Date.now()}`),t){let e=a.find(e=>e.sessions?.some(e=>String(e.id)===String(t)));e&&n.set("folderId",e.id.toString())}else n.delete("folderId");return n},{replace:!0})}}),(0,r.Y)(A,{isSearchVisible:O,searchQuery:p,showArchived:f,optionsOpen:b,sortOption:k,onToggleSearch:()=>J(!O),onSearchChange:m,onToggleArchived:()=>g(!f),onHideArchived:()=>g(!1),onToggleOptions:()=>v(!b),onCloseOptions:()=>v(!1),onSortChange:y,onNewWorkspace:()=>j(!0),onScheduler:()=>M(!0),onRefresh:c,onClose:n}),o?(0,r.Y)(ea,{}):(0,r.Y)(ei,{folders:w,activeSessionId:d,searchQuery:p,showArchived:f,sessionStatus:N,isScrolling:_,onScroll:W,onSelectSession:Y,onNewSessionForFolder:e=>{U(e),D(t=>{let n=new URLSearchParams(t);return n.set("sessionId",`new-${Date.now()}`),n.set("folderId",e.toString()),n},{replace:!0})}}),(0,r.Y)(S,{onSettings:()=>C(!0),onInfo:()=>$(!0),updateAvailable:E.hasUpdate,onUpdateClick:()=>{$(!0),E.check()}})]}),(0,r.Y)(h.bB,{isOpen:F,onClose:()=>C(!1),appSettings:i}),(0,r.Y)(h.VT,{isOpen:T,onClose:()=>$(!1),updates:E,onToast:I}),(0,r.Y)(h.xV,{isOpen:z,onClose:()=>j(!1),onCreate:async e=>{let{name:t,path:n}=e,r=await fetch("/api/folders",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t,path:n})}),i=await r.json().catch(()=>({}));if(!r.ok||!i.success)throw Error(i.error||`HTTP ${r.status}`);window.location.reload()}}),(0,r.Y)(h.Lo,{isOpen:L,onClose:()=>M(!1)}),(0,r.Y)(el.y,{toasts:P,onDismiss:R})]})}var em=n("u"),eh=n("Gb"),ef=n("FL"),ex=n("As"),eg=n("NO"),eb=n("zI"),ev=n("f"),ek=n("b5"),ey=n("Pf"),ew=n("se"),eN=n("tC");let eY=()=>{let{isInstallable:e,isInstalled:t,isIOS:n,install:i}=function(){let[e,t]=(0,s.J0)(null),[n,r]=(0,s.J0)(!1),[i,a]=(0,s.J0)(!1);(0,s.vJ)(()=>{r(window.matchMedia("(display-mode: standalone)").matches||!0===window.navigator.standalone);let e=window.navigator.userAgent.toLowerCase();a(/iphone|ipad|ipod/.test(e));let n=e=>{e.preventDefault(),t(e)},i=()=>{r(!0),t(null)};return window.addEventListener("beforeinstallprompt",n),window.addEventListener("appinstalled",i),()=>{window.removeEventListener("beforeinstallprompt",n),window.removeEventListener("appinstalled",i)}},[]);let l=async()=>{if(!e)return!1;await e.prompt();let{outcome:n}=await e.userChoice;return"accepted"===n&&(r(!0),t(null),!0)};return{isInstallable:!!e,isInstalled:n,isIOS:i,install:l}}(),[a,l]=(0,s.J0)(!1);return t?null:e?(0,r.Y)("button",{onClick:i,className:"p-1.5 rounded hover:bg-ink/10 transition-colors text-ink/60 hover:text-ink",title:"Install OMPChamber",children:(0,r.Y)(eN.A,{size:16})}):n?(0,r.FD)(r.FK,{children:[(0,r.Y)("button",{onClick:()=>l(!0),className:"p-1.5 rounded hover:bg-ink/10 transition-colors text-ink/60 hover:text-ink",title:"Install on iOS",children:(0,r.Y)(eN.A,{size:16})}),a&&(0,r.Y)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-ink/20 p-4",children:(0,r.FD)("div",{className:"w-full max-w-sm rounded bg-paper border border-ink/10 p-6 shadow-xl text-ink",children:[(0,r.Y)("h3",{className:"text-sm font-semibold",children:"Install on iPhone / iPad"}),(0,r.FD)("p",{className:"mt-2 text-xs opacity-80",children:["1. Tap the ",(0,r.Y)("strong",{children:"Share"})," button in Safari toolbar.",(0,r.Y)("br",{}),"2. Scroll down and tap ",(0,r.Y)("strong",{children:"Add to Home Screen"}),"."]}),(0,r.Y)("button",{onClick:()=>l(!1),className:"mt-4 w-full rounded bg-ink text-canvas py-2 text-xs font-semibold hover:bg-ink/90",children:"Close"})]})})]}):null};var eD=n("R2");function eA(e){let{sessionTitle:t,showLeftPanel:n,showEditor:i,showRightPanel:s,streamStatus:a,onSwitchToMobile:l,onToggleEditor:o,onToggleRightPanel:c,onToggleLeftPanel:d}=e;return(0,r.FD)("header",{className:"h-14 flex-shrink-0 border-b border-ink/10 bg-paper flex items-center justify-between pr-4 z-20 titlebar-drag-region select-none",style:{paddingLeft:n?void 0:"max(1rem, env(titlebar-area-x, 0px))",paddingRight:"max(1rem, calc(100vw - env(titlebar-area-width, 100vw)))"},children:[(0,r.FD)("div",{className:"flex items-center space-x-2 px-4 min-w-0",children:[!n&&(0,r.FD)(r.FK,{children:[(0,r.Y)("button",{type:"button",onClick:d,className:"p-1.5 rounded hover:bg-ink/10 transition-colors text-ink/60 hover:text-ink cursor-pointer flex-shrink-0 titlebar-no-drag",title:"Expand Sidebar","aria-label":"Expand Sidebar",children:(0,r.Y)(eb.A,{size:16})}),(0,r.FD)("span",{className:"font-bold text-sm tracking-tight hidden sm:flex items-center flex-shrink-0",children:[(0,r.Y)("span",{className:"text-transparent bg-clip-text bg-gradient-to-r from-orange-600 to-amber-500 font-extrabold text-[15px] tracking-tighter",children:"OMP"}),(0,r.Y)("span",{className:"ml-[1px]",children:"Chamber"})]}),t&&(0,r.Y)("span",{className:"text-ink/30 text-xs select-none flex-shrink-0",children:"/"})]}),t&&(0,r.FD)("div",{className:"flex items-center space-x-2 titlebar-no-drag",children:[(0,r.Y)("span",{className:"font-bold text-sm tracking-tight hidden sm:flex items-center",children:(0,r.Y)("span",{className:"font-semibold text-xs text-ink truncate",children:t.charAt(0).toUpperCase()+t.slice(1)})}),(0,r.Y)(w.A,{size:14,className:"text-ink/40 hover:text-ink cursor-pointer flex-shrink-0"})]})]}),(0,r.Y)("div",{className:"flex items-center space-x-3 titlebar-no-drag",children:(0,r.FD)("div",{className:"flex items-center space-x-1",children:[(0,r.Y)(eD.c,{status:a}),l&&(0,r.Y)("button",{type:"button",onClick:l,className:"p-1.5 rounded hover:bg-ink/10 transition-colors text-ink/60 hover:text-ink cursor-pointer",title:"Switch to Mobile View",children:(0,r.Y)(ev.A,{size:16})}),(0,r.Y)(eY,{}),(0,r.Y)("button",{type:"button",onClick:o,className:`p-1.5 rounded hover:bg-ink/10 transition-colors cursor-pointer ${i?"text-ink":"text-ink/40"}`,title:"Toggle Editor Layout",children:(0,r.Y)(ek.A,{size:16})}),(0,r.Y)("button",{type:"button",onClick:c,className:`p-1.5 rounded hover:bg-ink/10 transition-colors cursor-pointer ${s?"text-ink":"text-ink/40"}`,title:"Toggle Right Panel",children:s?(0,r.Y)(ey.A,{size:16}):(0,r.Y)(ew.A,{size:16})})]})})]})}var eF=n("bQ"),eC=n("nG"),eS=n("oE"),eT=n("Asb"),e$=n("vZ"),ez=n("N"),ej=n("Oj"),eL=n("lW"),eM=n("SJ"),eE=n("so"),eP=n("ET");let eI={context:{title:"Context & Telemetry",icon:(0,r.Y)(eS.A,{size:16})},files:{title:"Files",icon:(0,r.Y)(eT.A,{size:16})},search:{title:"Search",icon:(0,r.Y)(k.A,{size:16})},git:{title:"Source Control",icon:(0,r.Y)(e$.A,{size:16})},terminal:{title:"Terminal (Bun)",icon:(0,r.Y)(ez.A,{size:16})},"user-browser":{title:"Browser (Anda)",icon:(0,r.Y)(ej.A,{size:16})},browser:{title:"Browser Agent",icon:(0,r.Y)(eL.A,{size:16})},usage:{title:"Usage",icon:(0,r.Y)(eM.A,{size:16})}};function eR(e){let{activePanel:t,onChangePanel:n,isPanelOpen:i,hasActiveContext:s,activeProjectPath:a,refreshKey:l}=e,{changes:o}=(0,eE.e)(a??void 0,".",l,s,15e3),c=o.length>0;return(0,r.FD)("nav",{className:"w-11 flex-shrink-0 border-l border-ink/10 bg-paper flex flex-col items-center py-3 space-y-2 z-10",children:[(0,r.Y)("div",{className:"flex flex-col items-center space-y-1 w-full",children:eP.G7.map(e=>{let s=i&&t===e;return(0,r.FD)("button",{className:`relative w-full h-10 flex items-center justify-center transition-colors border-l-2 ${s?"text-ink border-ink bg-ink/5":"text-ink/40 border-transparent hover:text-ink hover:bg-ink/5"}`,onClick:()=>n(e),title:eI[e].title,children:[eI[e].icon,"git"===e&&c&&(0,r.Y)("span",{className:"absolute top-1.5 right-1.5 w-1.5 h-1.5 rounded-full bg-info",title:"Ada perubahan git"})]},e)})}),(0,r.Y)("div",{className:"flex-1"})]})}function eO(){return(0,r.Y)(m,{className:"relative w-[3px] outline-none group flex justify-center cursor-col-resize z-10",children:(0,r.Y)("div",{className:"h-full w-[1px] bg-ink/10 group-hover:bg-ink/40 group-active:bg-ink/60 group-hover:w-[3px] transition-all"})})}let eJ={editor:.6,diff:.6},e_={editor:600,diff:720};function eW(e){let{stored:t,defaultFraction:n,defaultPx:r,available:i,min:s,siblingMin:a,handleCount:l}=e;if(null===i||i<=0)return Math.max(s,Math.round(t?.px??r));let o=Math.max(s,Math.floor(i-400-a-3*l));return Math.min(Math.max(Math.round((t?.fraction??(t?.px!=null?Math.min(1,t.px/i):n))*i),s),o)}function eU(e){if("number"==typeof e)return Number.isFinite(e)&&e>0?{px:Math.round(e)}:void 0;if(!e||"object"!=typeof e)return;let t=Number.isFinite(e.px)&&e.px>0?Math.round(e.px):void 0,n=Number.isFinite(e.fraction)&&e.fraction>0&&e.fraction<=1?e.fraction:void 0;if(void 0!==t||void 0!==n)return{...void 0!==t?{px:t}:{},...void 0!==n?{fraction:n}:{}}}let eK=(0,a.RZ)(()=>Promise.all([n.e("f7"),n.e("yx"),n.e("q8")]).then(n.bind(n,"o3")).then(e=>({default:e.Editor})));function eq(e){let{children:t}=e;return(0,r.Y)(a.tY,{fallback:(0,r.Y)("div",{className:"w-full h-full flex items-center justify-center text-ink/40",children:(0,r.Y)("span",{className:"text-xs font-mono",children:"Loading…"})}),children:t})}function eB(e){let{appSettings:t,showEditor:n,editorPanelRef:i,showRightPanel:a,activeRightPanel:l,rightPanelRef:o,panelWidths:c,editorWidthMode:d,hasActiveContext:m,activeProjectPath:h,openedFiles:f,activeFileId:x,refreshKey:g,onSetActiveFileId:b,onCloseFile:v,onOpenFile:k,onRefreshWorkspace:y,onChangeRightPanel:w,onToggleRightPanel:N,onSessionTitle:Y,onPanelWidths:D}=e,A=(0,s.li)(null),F=function(e){let[t,n]=(0,s.J0)(null);return(0,s.vJ)(()=>{let t=e.current;if(!t||"u"<typeof ResizeObserver)return;let r=new ResizeObserver(()=>{n(t.clientWidth||null)});return r.observe(t),n(t.clientWidth||null),()=>r.disconnect()},[e]),t}(A),C=(0,s.Kr)(()=>({}),[]),S=(0,s.Kr)(()=>eP.G7.map(e=>({view:e,Comp:(0,eC.SU)(C,e)})),[C]),T=+!!n+ +!!a,$=eW({stored:c[d],defaultFraction:eJ[d],defaultPx:e_[d],available:F,min:320,siblingMin:a?eP.lw[l]:0,handleCount:T}),z=eW({stored:c.right?.[l],defaultFraction:eP.Cx[l],defaultPx:eP.qv[l],available:F,min:eP.lw[l],siblingMin:320*!!n,handleCount:T});return(0,r.FD)("div",{className:"flex flex-1 overflow-hidden",children:[(0,r.FD)(u,{orientation:"horizontal",id:"ompchamber-layout",className:"flex-1 min-w-0",groupRef:A,onLayoutChanged:()=>{let e,t,n;D((e={},t=i.current?.getSize()?.inPixels,n=o.current?.getSize()?.inPixels,null!=t&&t>0&&(e[d]={px:Math.round(t),...F?{fraction:t/F}:{}}),null!=n&&n>0&&(e.right={[l]:{px:Math.round(n),...F?{fraction:n/F}:{}}}),e))},children:[(0,r.Y)(p,{id:"center-panel",filler:!0,minSize:400,children:(0,r.Y)(eF.E,{className:"w-full h-full",appSettings:t,onSessionTitle:Y})}),n&&(0,r.Y)(eO,{}),(0,r.Y)(p,{panelRef:i,id:"editor-panel",defaultSize:$,minSize:320,collapsed:!n,children:(0,r.Y)(eq,{children:(0,r.Y)(eK,{className:"w-full h-full",openedFiles:f,activeFileId:x,onSelectFile:b,onCloseFile:v,refreshKey:g,onFileSaved:y})})}),a&&(0,r.Y)(eO,{}),(0,r.Y)(p,{panelRef:o,id:"right-panel",defaultSize:z,minSize:eP.lw[l],collapsed:!a,children:(0,r.Y)(eq,{children:S.map(e=>{let{view:t,Comp:n}=e,i=l===t;return(0,r.Y)("div",{className:i?"w-full h-full":"hidden",children:(0,r.Y)(n,{className:"w-full h-full",enabled:"terminal"===t?m:m&&i,active:i,refreshKey:g,rootPath:h??void 0,onRefresh:y,onOpenFile:k,onClose:N})},t)})})})]}),(0,r.Y)(eR,{activePanel:l,onChangePanel:w,isPanelOpen:a,hasActiveContext:m,activeProjectPath:h,refreshKey:g})]})}var eH=n("FE");function eG(e){let{sessionId:t,onSwitchToMobile:n,appSettings:i={}}=e,{folders:a}=(0,et.k)(),[o,c]=(0,ef.bL)("layout.showRightPanel",i.showRightPanel??!0),[d,m]=(0,ef.bL)("layout.activeRightPanel",i.activeRightPanel??"files"),[h,f]=(0,ef.bL)("layout.showLeftPanel",i.showLeftPanel??!0),{widths:x,commitWidths:g}=function(e,t){let n=(0,s.Kr)(()=>(function(e,t){var n;if(!e||"object"!=typeof e)return{};let r={},i="number"==typeof(n=e.left)&&Number.isFinite(n)&&n>0?Math.round(n):void 0;for(let t of(void 0!==i&&(r.left=i),["editor","diff"])){let n=eU(e[t]);void 0!==n&&(r[t]=n)}let s={};if(e.right&&"object"==typeof e.right)for(let[t,n]of Object.entries(e.right)){if(!(0,eP.ls)(t))continue;let e=eU(n);void 0!==e&&(s[t]=e)}else{let n=eU(e.right);void 0!==n&&(s[t]=n)}return Object.keys(s).length>0&&(r.right=s),r})(e.desktopLayoutSizes,t),[e.desktopLayoutSizes,t]),[r,i]=(0,ef.bL)("layout.panelWidths",n);return{widths:r,commitWidths:(0,s.hb)(e=>{i(t=>(function(e,t){let n={...e,...t};if(t.right){let r={...e.right};for(let[n,i]of Object.entries(t.right))(0,eP.ls)(n)&&i&&(r[n]={...e.right?.[n],...i});n.right=r}for(let r of["editor","diff"])t[r]&&(n[r]={...e[r],...t[r]});return n})(t,e))},[i])}}(i,d),b=(0,s.li)(null),v=(0,s.li)(null),k=(0,s.li)(null),[y,w]=(0,ef.bL)("layout.userToggledEditor",i.userToggledEditor??null),[N]=(0,l.o)(),Y=N.get("folderId"),D=(0,s.Kr)(()=>{let e=(0,eh.t)(a,t||"").folder;return e||(Y?a.find(e=>String(e.id)===String(Y))??null:null)},[a,t,Y]),A=D?.project_path??null,F=!!D,{openedFiles:C,activeFileId:S,setActiveFileId:T,handleOpenFile:$,handleCloseFile:z}=function(e,t,n){let[r,i]=(0,ef.bL)("layout.openedFiles",[]),[a,l]=(0,ef.bL)("layout.activeFileId",null),o=(0,s.li)(void 0),{ready:c}=(0,ex.O)(),d=(0,s.li)(void 0);(0,s.vJ)(()=>{o.current===e||(o.current=e,c&&d.current!==e&&(d.current=e,i([]),l(null)))},[e,t,c,i,l]);let u=(0,s.hb)(t=>{let r={...t,root:t.root??e??void 0};i(e=>{let t=e.find(e=>e.id===r.id||!e.isDiff&&e.path&&r.path&&e.path===r.path);return t?(l(t.id),e):[...e,r]}),l(r.id),n?.()},[e,n,i,l]),p=(0,s.hb)(t=>{let r=t.file.replace(/^\/+/,""),s=r.split("/").pop()||r,a=!!t.staged,o=`diff-${a?"staged":"working"}-${r}`,c={id:o,name:`${s} (Diff)`,path:r,isDiff:!0,diffStatus:t.status||"M",diffStaged:a,repo:t.repo||".",root:t.root??e??void 0};i(e=>{let t=e.find(e=>e.id===o||e.isDiff&&e.path===r&&e.diffStaged===a);return t?(l(t.id),e):[...e,c]}),l(o),n?.()},[e,n,i,l]),m=(0,s.hb)(e=>{i(t=>{let n=t.filter(t=>t.id!==e);return a===e&&l(n.length>0?n[n.length-1].id:null),n})},[a,i,l]);return(0,eg.sY)("omp:open-file",e=>{if(!e.detail||!e.detail.path)return;let t=e.detail.path.replace(/^\/+/,""),n=e.detail.name||t.split("/").pop()||"file",r=0;for(let e=0;e<t.length;e++)r=(r<<5)-r+t.charCodeAt(e)|0;u({id:e.detail.id||Math.abs(r)||Date.now(),name:n,path:t,content:e.detail.content})}),(0,eg.sY)("omp:open-diff",e=>{e.detail&&e.detail.file&&p(e.detail)}),{openedFiles:r,activeFileId:a,setActiveFileId:l,handleOpenFile:u,handleOpenDiff:p,handleCloseFile:m}}(A,t||"",(0,s.hb)(()=>{w(!0)},[w])),j=C.length>0&&(y??!0),L=(0,s.Kr)(()=>C.find(e=>String(e.id)===String(S))?.isDiff?"diff":"editor",[C,S]),[M,E]=(0,s.J0)(!1),[P,I]=(0,s.J0)("appearance"),[R,O]=(0,s.J0)(!1),[J,_]=(0,s.J0)(0),[W,U]=(0,s.J0)(null),K=(0,eH.H)();(0,eg.MN)("keydown",e=>{(e.metaKey||e.ctrlKey)&&","===e.key&&(e.preventDefault(),I("appearance"),O(!1),E(e=>!e))}),(0,eg.sY)("omp:open-settings",e=>{e.detail?.category?I(e.detail.category):I("appearance"),O(!!e.detail?.autoOpenAdd),E(!0)});let q=e=>{f(e)},B=()=>{c(!o)};return(0,r.FD)("div",{className:"flex flex-col h-screen w-screen overflow-hidden bg-canvas text-ink font-sans selection:bg-ink selection:text-canvas",children:[(0,r.Y)("div",{className:"flex flex-1 overflow-hidden",children:(0,r.FD)(u,{orientation:"horizontal",id:"ompchamber-main",onLayoutChanged:()=>{let e=k.current?.getSize()?.inPixels;null!=e&&e>0&&g({left:Math.round(e)})},children:[(0,r.Y)(p,{panelRef:k,id:"left-panel",defaultSize:x.left??280,minSize:264,maxSize:500,collapsed:!h,children:(0,r.Y)(ep,{className:"w-full h-full",onClose:()=>q(!1),appSettings:i})}),h&&(0,r.Y)(eO,{}),(0,r.Y)(p,{id:"main-right-stack",filler:!0,minSize:0,children:(0,r.FD)("div",{className:"flex flex-col h-full",children:[(0,r.Y)(eA,{sessionTitle:W,showLeftPanel:h,showEditor:j,showRightPanel:o,streamStatus:K,onSwitchToMobile:n,onToggleEditor:()=>{w(!j)},onToggleRightPanel:B,onToggleLeftPanel:()=>q(!h)}),(0,r.Y)(eB,{appSettings:i,showEditor:j,editorPanelRef:b,showRightPanel:o,activeRightPanel:d,rightPanelRef:v,panelWidths:x,editorWidthMode:L,hasActiveContext:F,activeProjectPath:A,openedFiles:C,activeFileId:S,refreshKey:J,onSetActiveFileId:T,onCloseFile:z,onOpenFile:$,onRefreshWorkspace:()=>_(e=>e+1),onChangeRightPanel:e=>{let t=o,n=d;d===e&&o?t=!1:(n=e,t=!0),c(t),m(n)},onToggleRightPanel:B,onSessionTitle:U,onPanelWidths:g})]})})]})}),(0,r.Y)(em.b,{isOpen:M,onClose:()=>{E(!1),O(!1)},initialCategory:P,autoOpenAddProvider:R,appSettings:i})]})}var eV=n("SS");function eZ(e){let{sessionId:t,children:n}=e,i=t||"1",[a,l]=(0,s.J0)(!1),o=(0,s.li)(null);(0,s.vJ)(()=>{let e=o.current;if(o.current=i,e!==i){if((0,eV.Y1)(i),e&&e.startsWith("new-")&&!i.startsWith("new-")){(0,eV.vy)(e,i),l(!0);return}if(i.startsWith("new-")){(0,eV.l5)(i),l(!0);return}l(!1),(0,eV.D4)(e).then(()=>(0,eV.L6)(i)).then(()=>{o.current===i&&l(!0)})}},[i]);let c=(0,s.Kr)(()=>({sessionId:i,ready:a}),[i,a]);return(0,r.Y)(ex.b.Provider,{value:c,children:n})}let eQ=(0,a.RZ)(()=>Promise.all([n.e("f7"),n.e("yx"),n.e("g")]).then(n.bind(n,"Wh")).then(e=>({default:e.MobileLayoutWrapper})));var eX=n("eh");let e0=document.getElementById("app"),e1=window.__OMP_BOOTSTRAP__;(0,Q.x9)(e1?.appSettings),(0,eX.iv)(),e0&&(0,i.Qv)((0,r.Y)(function(e){let{initialIsMobile:t=!1,appSettings:n={}}=e,[i]=(0,l.o)(),o=i.get("sessionId")||"1",[c,d]=(0,s.J0)(t),u=(0,s.li)(!1);return((0,s.vJ)(()=>{let e=()=>{let e=window.innerWidth<768,t=window.matchMedia("(pointer: coarse)").matches,n=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Mobile|mobile|CriOS/i.test(navigator.userAgent),r=t&&window.innerHeight<550&&window.innerWidth<1024;return e||n||r};u.current||d(e());let t=()=>{u.current||d(e())};return window.addEventListener("resize",t),window.addEventListener("orientationchange",t),()=>{window.removeEventListener("resize",t),window.removeEventListener("orientationchange",t)}},[]),c)?(0,r.Y)(eZ,{sessionId:o,children:(0,r.Y)(et.O,{children:(0,r.Y)(a.tY,{fallback:null,children:(0,r.Y)(eQ,{onDesktopToggle:()=>{u.current=!0,d(!1)},appSettings:n})})})}):(0,r.Y)(eZ,{sessionId:o,children:(0,r.Y)(et.O,{children:(0,r.Y)(eG,{sessionId:o,onSwitchToMobile:()=>{u.current=!0,d(!0)},appSettings:n})})})},{initialIsMobile:e1?.initialIsMobile,appSettings:e1?.appSettings}),e0)},Fb(e,t,n){let r="omp:browser-include-page";function i(e){"u">typeof window&&window.dispatchEvent(new CustomEvent(r,{detail:e}))}n.d(t,{q:()=>i},{j:r})},ns(e,t,n){var r=n("Sm");let i="agent",s="command",a=new Map,l=new Map;async function o(e){let t=await fetch(e);if(!t.ok)throw Error(`GET ${e} failed: ${t.status}`);let n=await t.json();if(!n||"object"!=typeof n)throw Error(`GET ${e} returned malformed JSON`);return n}async function c(){let e=a.get(i);if(e&&e.expiresAt>Date.now())return e.data;let t=l.get(i);if(t)return t;let n=(async()=>{try{let e=(await o("/api/settings/agents")).agents.map(e=>({id:`agent-${e.name}`,name:e.name,description:e.description,kind:"agent",source:"agent",token:`@${e.name}`}));return a.set(i,{data:e,expiresAt:Date.now()+3e5}),e}finally{l.delete(i)}})();return l.set(i,n),n}async function d(e){let t,n=(t=e??"",`file::${t}`),r=a.get(n);if(r&&r.expiresAt>Date.now())return r.data;let i=l.get(n);if(i)return i;let s=(async()=>{try{let t=e?`?root=${encodeURIComponent(e)}`:"",r=await o(`/api/fs/list${t}`),i=(Array.isArray(r.files)?r.files:[]).map(e=>({id:`file-${e.path}`,name:e.path,description:"",kind:"file",source:"file",token:/\s/.test(e.path)?`@"file:${e.path}"`:`@file:${e.path}`,path:e.path}));return a.set(n,{data:i,expiresAt:Date.now()+3e5}),i}catch{return[]}finally{l.delete(n)}})();return l.set(n,s),s}async function u(){let e=a.get(s);if(e&&e.expiresAt>Date.now())return e.data;let t=l.get(s);if(t)return t;let n=(async()=>{try{let[e,t]=await Promise.all([o("/api/settings/commands"),o("/api/settings/skills")]),n=function(e,t){let n=[],i=new Set;for(let t of[...r.kn,...e]){let e=t.name.toLowerCase();if(i.has(e))continue;i.add(e);let r=t.description??"";n.push({id:`command-${t.name}`,name:t.name,description:t.inputHint?r?`${t.inputHint} - ${r}`:t.inputHint:r,kind:t.name.toLowerCase().startsWith("skill:")?"skill":"command",source:t.name.toLowerCase().startsWith("skill:")?"skill":"command",token:`/${t.name}`,...t.aliases?.length?{aliases:t.aliases}:{},...t.subcommands?.length?{subcommands:t.subcommands}:{},...t.inputHint?{inputHint:t.inputHint}:{}})}for(let e of t){let t=e.name.toLowerCase(),r=`skill:${t}`;i.has(t)||i.has(r)||(i.add(r),n.push({id:`skill-${e.name}`,name:r,description:e.description,kind:"skill",source:"skill",token:`/${r}`}))}return n}(e.commands,t.skills);return a.set(s,{data:n,expiresAt:Date.now()+3e5}),n}finally{l.delete(s)}})();return l.set(s,n),n}function p(e,t){return"mention"===e?Promise.all([c(),d(t??null)]).then(e=>{let[t,n]=e;return[...t,...n]}):u()}async function m(){try{return(await c()).map(e=>e.name)}catch{return[]}}function h(e){if(e){a.delete(e),l.delete(e);return}a.clear(),l.clear()}n.d(t,{O7:()=>m,SA:()=>h,bF:()=>p})},Sm(e,t,n){let r=/[\s([{]/,i=[{id:"chamber-btw",name:"btw",description:"Ask a side question, or browse this session's BTW history",scope:"system",template:"",isBuiltIn:!0,inputHint:"[question]"}];function s(e,t,n,r){for(let n=0;n<t;n+=1)if(""!==(e[n]??"").trim())return!0;return""!==n.slice(0,r).trim()}function a(e,t){let n,i=Math.max(0,Math.min(t,e.length)),a=e.slice(0,i),l=e.split("\n"),o=(a.match(/\n/g)??[]).length,c=a.lastIndexOf("\n")+1,d=a.slice(c),u=(n=d.trimStart()).startsWith("/")?d.length-n.length:null,p=function(e){let t=/(?:^|\s)\/([^\s/]*)$/.exec(e);if(!t||void 0===t.index)return null;let n=t[0].indexOf("/");return t.index+n}(d),m=null!==p&&s(l,o,d,p),h=null!==u&&s(l,o,d,u),f=m?p:h?null:u;if(null!==f){let e=d.slice(f),t=e.indexOf(" ");if(-1===t)return{kind:"command",query:e.slice(1),start:c+f,end:i,phase:"name",replaceFrom:c+f,...m?{midPrompt:!0}:{}};if(!m){let n=c+f+t+1;return{kind:"command",query:a.slice(n),start:c+f,end:i,phase:"args",replaceFrom:n,command:e.slice(1,t)}}}for(let e=d.length-1;e>=0;e--){let t=d[e];if(/\s/.test(t))break;if("@"===t){if(0===e||r.test(d[e-1])){let t=c+e;return{kind:"mention",query:a.slice(t+1),start:t,end:i,phase:"name",replaceFrom:t}}break}}return null}function l(e){return e.insertWithoutSpace?e.token:`${e.token} `}function o(e,t){let n;return!!t&&"command"===e.kind&&"name"===e.phase&&t.name.toLowerCase()===e.query.toLowerCase()&&(n=t.name.toLowerCase(),i.some(e=>e.name.toLowerCase()===n))}function c(e,t,n){return{value:e.slice(0,t.replaceFrom)+n+e.slice(t.end),caret:t.replaceFrom+n.length}}n.d(t,{Ct:()=>l,Rc:()=>c,an:()=>o,eC:()=>a},{kn:i,yG:"/skill:"})},K(e,t,n){var r=n("oS"),i=n("zG");let s={edit:!0,write:!0,ast_edit:!0,bash:!0};function a(e){let t="string"==typeof e.toolName?e.toolName.toLowerCase():"",n=i.YT[t]??t;if(!s[n])return!1;let a=(0,r.u)(e.args)?e.args:{},l=(0,i.oJ)(a.path)??(0,i.oJ)(a.target);return!("write"===n&&"string"==typeof l&&l.startsWith("xd://"))}n.d(t,{Y:()=>a},{s:"omp:files-mutated"})},g0(e,t,n){var r=n("Kn");let i="omp:stream-status",s={transport:(0,r.ul)(),connected:!1};function a(){return s}function l(e){e.transport===s.transport&&e.connected===s.connected||(s=e,"u">typeof window&&window.dispatchEvent(new CustomEvent(i,{detail:e})))}n.d(t,{aK:()=>a,dX:()=>l},{rt:i})},Kn(e,t,n){var r=n("So");function i(e){let t="https:"===window.location.protocol?"wss:":"ws:";return`${t}//${window.location.host}/api/agent/${encodeURIComponent(e)}/ws`}function s(e){return`/api/agent/${encodeURIComponent(e)}/events`}function a(e){let t="https:"===window.location.protocol?"wss:":"ws:";return`${t}//${window.location.host}/api/btw/${encodeURIComponent(e)}/ws`}function l(e){return`/api/btw/${encodeURIComponent(e)}/events`}function o(e){let t=(0,r.BF)("streamTransport",e);return"sse"===t||"websocket"===t?t:"websocket"}n.d(t,{Ec:()=>l,_m:()=>s,oU:()=>a,qq:()=>i,ul:()=>o})},G1(e,t,n){function r(e,t){let n=function(e){let t=e.trim();if(!t)return null;let n="message",r=[];for(let e of t.split("\n"))!e.startsWith(":")&&(e.startsWith("event:")?n=e.replace(/^event:\s*/,"").trim():e.startsWith("data:")&&r.push(e.replace(/^data:\s*/,"")));return 0===r.length?null:{event:n,data:r.join("\n")}}(e);return!!n&&!0===t(n.event,n.data)}async function i(e,t,n){let i=e.body?.getReader();if(!i)return;let s=new TextDecoder("utf-8"),a="";try{for(;;){if(n?.aborted){try{await i.cancel()}catch{}return}let{done:e,value:l}=await i.read();if(e)break;let o=(a+=s.decode(l,{stream:!0})).split("\n\n");for(let e of(a=o.pop()??"",o))if(r(e,t))return}a&&r(a,t)}finally{try{i.releaseLock()}catch{}}}n.d(t,{o:()=>i})},zG(e,t,n){var r=n("oS"),i=n("e");function s(e){if("string"!=typeof e)return;let t=e.trim();return t.length>0?t:void 0}function a(e,t){for(let n of t){let t=e[n],r=s(t);if(r)return r;if(Array.isArray(t)){let e=t.find(e=>void 0!==s(e));if(void 0!==e)return s(e)}}}function l(e){return e.length<=72?e:`${e.slice(0,71)}…`}function o(e){if(e)return/^["'`]/.test(e)?e:`"${e}"`}function c(e,t){switch(e){case"read":case"write":case"edit":return a(t,["path","file","AbsolutePath","TargetFile"])??(0,i.f$)(t);case"ast_edit":return a(t,["paths","path"]);case"ast_grep":{let e=o(a(t,["pat"]));return e?`for ${e}`:void 0}case"bash":return a(t,["command","cmd","CommandLine"]);case"grep":{let e=a(t,["pattern"]),n=a(t,["path","paths"]);if(!e)return n;return n?`for ${o(e)} in ${n}`:`for ${o(e)}`}case"glob":return a(t,["path","pattern"]);case"web_search":{let e=o(a(t,["query"]));return e?`for ${e}`:void 0}case"task":let n,l,c,d;return n=s(t.name),l=(Array.isArray(t.tasks)?t.tasks:[]).find(r.u),c=n??(l?s(l.name):void 0),d=s(t.agent)??(l?s(l.agent):void 0),c&&d?`to ${c} (${d})`:c?`to ${c}`:d?`to ${d}`:void 0;case"hub":return[a(t,["op"]),a(t,["name"])].filter(Boolean).join(" ")||void 0;case"todo":{let e=a(t,["op"]);return e?`\xb7 ${e}`:void 0}case"eval":{let e=a(t,["language"]);return e?`in ${e}`:void 0}case"lsp":return[a(t,["action"]),a(t,["symbol","file"])].filter(Boolean).join(" ")||void 0;case"debug":return a(t,["action","program"]);case"github":return[a(t,["op"]),a(t,["repo","pr","query"])].filter(Boolean).join(" ")||void 0;case"ask":let u=(Array.isArray(t.questions)?t.questions:[]).find(r.u);if(u)return s(u.header)??s(u.question);return;case"checkpoint":return a(t,["goal"]);case"manage_skill":return a(t,["name"]);case"recall":return o(a(t,["query"]));case"reflect":{let e=o(a(t,["query"]));return e?`on ${e}`:void 0}case"security_scan":return a(t,["target_kind","include_paths"]);case"retain":let p;return(p=(Array.isArray(t.items)?t.items:[]).find(r.u))?o(s(p.content)):void 0;default:return a(t,["path","command","query","pattern","name","target","prose"])}}n.d(t,{Up:()=>a,oJ:()=>s,qL:()=>c,xv:()=>l},{K$:{read:"Reading",write:"Writing",edit:"Editing",ast_edit:"Rewriting AST",ast_grep:"Searching AST",bash:"Running",grep:"Searching",glob:"Finding",task:"Delegating",todo:"Updating plan",hub:"Hub",eval:"Running code",lsp:"Running LSP",debug:"Debugging",github:"GitHub",web_search:"Searching the web",ask:"Asking you",checkpoint:"Checkpointing",rewind:"Rewinding",context_notes:"Updating context notes",new_context:"Starting a fresh context",security_scan:"Scanning for vulnerabilities",manage_skill:"Updating skill",learn:"Recording a lesson",retain:"Retaining memory",recall:"Recalling memory",reflect:"Reflecting",think:"Thinking",yield:"Wrapping up",goal:"Tracking goal"},Qq:{lsp:"Running LSP",ast_edit:"Rewriting AST",ast_grep:"Searching AST",resolve:"Applying edit proposal",reject:"Discarding edit proposal",report_issue:"Reporting tool issue",debug:"Debugging",browser:"Driving the browser"},YT:{read_file:"read",view_file:"read",read_file_content:"read",edit_file:"edit",replace_file_content:"edit",multi_edit_file:"edit",write_to_file:"write",create_file:"write",search_fs:"grep",terminal:"bash",run_command:"bash"},n1:{thinking:"Thinking",writing:"Writing response"}})},pm(e,t,n){var r=n("U8");function i(e){return(0,r.Rk)(e)}n.d(t,{F:()=>i})},eh(e,t,n){n.d(t,{iv:()=>w,tn:()=>v,F:()=>D,nv:()=>N,LT:()=>F,Eu:()=>Y,sT:()=>A});var r=n("CU"),i=n("he"),s=n("h3"),a=n("g1");let l={typescript:()=>n.e("zn").then(n.bind(n,"tt")),tsx:()=>n.e("ta").then(n.bind(n,"Xl")),javascript:()=>n.e("jsc").then(n.bind(n,"lK")),jsx:()=>n.e("px").then(n.bind(n,"rz")),json:()=>n.e("zj").then(n.bind(n,"BB")),markdown:()=>n.e("2v").then(n.bind(n,"sN")),css:()=>n.e("n").then(n.bind(n,"d2")),bash:()=>Promise.all([n.e(2),n.e(6)]).then(n.bind(n,"ks")),diff:()=>n.e("0w").then(n.bind(n,"SP")),yaml:()=>n.e("ho").then(n.bind(n,"n1")),html:()=>Promise.all([n.e("jsc"),n.e("n"),n.e("aa")]).then(n.bind(n,"w1")),python:()=>n.e("jd").then(n.bind(n,"hE")),go:()=>n.e("cf").then(n.bind(n,"K1")),rust:()=>n.e("hk").then(n.bind(n,"nb")),sql:()=>n.e("r").then(n.bind(n,"le")),toml:()=>n.e("x0").then(n.bind(n,"DJ")),java:()=>n.e("f8").then(n.bind(n,"lj")),c:()=>n.e("4e").then(n.bind(n,"Gd")),cpp:()=>Promise.all([n.e("4e"),n.e("y6")]).then(n.bind(n,"gB")),csharp:()=>n.e("4k").then(n.bind(n,"Ku")),ruby:()=>Promise.all([n.e("jsc"),n.e("n"),n.e("zn"),n.e("aa"),n.e("4e"),n.e("f8"),n.e("r"),n.e("ta"),n.e("y6"),n.e("px"),n.e(2),n.e("yv"),n.e("ct")]).then(n.bind(n,"eV")),php:()=>Promise.all([n.e("jsc"),n.e("n"),n.e("aa"),n.e("f8"),n.e("r"),n.e(4)]).then(n.bind(n,"eZ")),kotlin:()=>n.e("7l").then(n.bind(n,"hRx")),swift:()=>n.e(0).then(n.bind(n,"ep")),scala:()=>n.e("js").then(n.bind(n,"h3S")),lua:()=>Promise.all([n.e("4e"),n.e("hd")]).then(n.bind(n,"rF")),perl:()=>Promise.all([n.e("jsc"),n.e("n"),n.e("aa"),n.e("f8"),n.e("r"),n.e("i")]).then(n.bind(n,"cr")),dockerfile:()=>n.e("b").then(n.bind(n,"BZ")),ini:()=>n.e("3p").then(n.bind(n,"BD")),properties:()=>n.e("1b").then(n.bind(n,"LU")),zig:()=>n.e("3u").then(n.bind(n,"p9")),elixir:()=>Promise.all([n.e("jsc"),n.e("n"),n.e("aa"),n.e("jll")]).then(n.bind(n,"xu")),dart:()=>n.e("4q").then(n.bind(n,"Cu")),ocaml:()=>n.e("8j").then(n.bind(n,"uA")),haskell:()=>n.e("a").then(n.bind(n,"IX")),nix:()=>n.e("p").then(n.bind(n,"jG")),hcl:()=>n.e("yq").then(n.bind(n,"ka")),graphql:()=>Promise.all([n.e("jsc"),n.e("zn"),n.e("ta"),n.e("px"),n.e("yv")]).then(n.bind(n,"ok")),solidity:()=>n.e("w").then(n.bind(n,"me")),r:()=>n.e(37).then(n.bind(n,"pO")),julia:()=>Promise.all([n.e("jsc"),n.e("4e"),n.e("r"),n.e("y6"),n.e("jd"),n.e("t9")]).then(n.bind(n,"zu")),erlang:()=>Promise.all([n.e("2v"),n.e("y")]).then(n.bind(n,"EY")),clojure:()=>n.e("3d").then(n.bind(n,"lF")),scheme:()=>n.e("az").then(n.bind(n,"wE")),racket:()=>n.e(8).then(n.bind(n,"aB")),protobuf:()=>n.e("1p").then(n.bind(n,"bT")),makefile:()=>n.e("d").then(n.bind(n,"nt")),powershell:()=>n.e("j").then(n.bind(n,"dQ")),json5:()=>n.e("bq").then(n.bind(n,"VH")),less:()=>n.e("c").then(n.bind(n,"i")),scss:()=>Promise.all([n.e("n"),n.e("x")]).then(n.bind(n,"DD")),sass:()=>n.e("zo").then(n.bind(n,"Bc")),stylus:()=>n.e("ky").then(n.bind(n,"uc")),"objective-c":()=>n.e(7).then(n.bind(n,"BG")),groovy:()=>n.e("7e").then(n.bind(n,"tf")),vue:()=>Promise.all([n.e("jsc"),n.e("n"),n.e("zn"),n.e("aa"),n.e("zx")]).then(n.bind(n,"Z")),svelte:()=>Promise.all([n.e("jsc"),n.e("n"),n.e("zn"),n.e("dp")]).then(n.bind(n,"jIY")),astro:()=>Promise.all([n.e("jsc"),n.e("n"),n.e("zn"),n.e("ta"),n.e("o")]).then(n.bind(n,"CuL")),xml:()=>Promise.all([n.e("f8"),n.e("da")]).then(n.bind(n,"rDW"))},o=["typescript","tsx","javascript","jsx","json","bash","python","markdown","yaml","diff"],c=new Map,d=new Set,u=new Set,p={text:!0,plain:!0,plaintext:!0,txt:!0,ansi:!0,none:!0};function m(e){return!0===p[e]||d.has(e)}function h(e,t){if(m(t))return Promise.resolve();let n=c.get(t);if(n)return n;let r=l[t];if(!r)return Promise.resolve();let i=e.loadLanguage(r).then(()=>{for(let e of(d.add(t),u))e()}).catch(()=>{}).finally(()=>{c.delete(t)});return c.set(t,i),i}async function f(e,t){await Promise.all(t.map(t=>h(e,t)))}let x=null,g=!1,b=new Set;function v(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}async function k(){if("u"<typeof window)return null;try{let e=await (0,r.tz)({themes:[s.A,a.A],langs:[],engine:(0,i.l)({forgiving:!0})});x=e,g=!0;let t=[...b];for(let e of(b.clear(),t))try{e()}catch{}return f(e,o),e}catch(e){return console.error("[shiki] highlighter boot failed",e),null}}let y=null;function w(){return y||(y=k()),y}function N(){return g}function Y(e){return g?(e(),()=>{}):(b.add(e),()=>{b.delete(e)})}function D(){return g?x:null}function A(e){return!!x&&(h(x,e),m(e))}let F=function(e){return u.add(e),()=>{u.delete(e)}}},DU(e,t,n){n.d(t,{sQ:()=>s,wY:()=>o,PH:()=>c,O9:()=>d,rw:()=>a,Bl:()=>function e(t){if(null==t)return{isValid:!1};if("object"==typeof t)try{let e=JSON.stringify(t,null,2),n=e.split("\n").length;return{isValid:!0,data:t,pretty:e,linesCount:n}}catch{return{isValid:!1}}if("string"!=typeof t)return{isValid:!1};let n=t.trim();if(!n)return{isValid:!1};let r=n.match(/^```(?:json)?\s*([\s\S]*?)\s*```$/i);r&&(n=r[1].trim());let i=n.match(/^(?:user\s+(?:selected|responded|answered|response)|response|result|output):\s*([\s\S]+)$/i);if(i){let e=i[1].trim();(e.startsWith("{")&&e.endsWith("}")||e.startsWith("[")&&e.endsWith("]"))&&(n=e)}if(n.startsWith('"')&&n.endsWith('"')||n.startsWith("'")&&n.endsWith("'"))try{let t=JSON.parse(n);if("object"==typeof t&&null!==t){let e=JSON.stringify(t,null,2);return{isValid:!0,data:t,pretty:e,linesCount:e.split("\n").length}}if("string"==typeof t){let n=e(t);if(n.isValid)return n}}catch{}if(n.startsWith("{")||n.startsWith("["))try{let e=JSON.parse(n);if(null!==e&&"object"==typeof e){let t=JSON.stringify(e,null,2),n=t.split("\n").length;return{isValid:!0,data:e,pretty:t,linesCount:n}}}catch{}let s=n.indexOf("{"),a=n.lastIndexOf("}");if(-1!==s&&a>s){let e=n.slice(s,a+1);try{let t=JSON.parse(e);if(null!==t&&"object"==typeof t){let e=JSON.stringify(t,null,2);return{isValid:!0,data:t,pretty:e,linesCount:e.split("\n").length}}}catch{}}let l=n.indexOf("["),o=n.lastIndexOf("]");if(-1!==l&&o>l){let e=n.slice(l,o+1);try{let t=JSON.parse(e);if(Array.isArray(t)){let e=JSON.stringify(t,null,2);return{isValid:!0,data:t,pretty:e,linesCount:e.split("\n").length}}}catch{}}return{isValid:!1}}});var r=n("eh");let i={light:"one-light",dark:"one-dark-pro"};function s(e){if(!e)return"javascript";let t=e.split("?")[0].split("#")[0].replace(/:\d+(?:-\d+)?$/,"");switch(t.split(".").pop()?.toLowerCase()){case"ts":return"typescript";case"tsx":return"tsx";case"js":case"mjs":case"cjs":default:return"javascript";case"jsx":return"jsx";case"json":return"json";case"md":case"markdown":return"markdown";case"css":return"css";case"sh":case"bash":case"zsh":case"env":return"bash";case"diff":case"patch":return"diff";case"yaml":case"yml":return"yaml";case"html":return"html";case"svg":case"xml":return"xml";case"py":return"python";case"go":return"go";case"rs":return"rust";case"sql":return"sql";case"toml":return"toml";case"java":return"java";case"c":case"h":return"c";case"cpp":case"cc":case"hpp":return"cpp";case"cs":return"csharp";case"rb":return"ruby";case"php":return"php";case"kt":case"kts":return"kotlin";case"swift":return"swift";case"scala":return"scala";case"lua":return"lua";case"pl":return"perl";case"dockerfile":return"dockerfile";case"ini":case"cfg":case"conf":return"ini";case"properties":return"properties";case"zig":return"zig";case"ex":case"exs":return"elixir";case"dart":return"dart";case"ml":case"mli":return"ocaml";case"hs":return"haskell";case"nix":return"nix";case"tf":case"tfvars":case"hcl":return"hcl";case"graphql":case"gql":return"graphql";case"sol":return"solidity";case"r":return"r";case"jl":return"julia";case"erl":return"erlang";case"clj":case"cljs":case"cljc":case"edn":return"clojure";case"scm":case"ss":return"scheme";case"rkt":return"racket";case"proto":return"protobuf";case"makefile":case"mk":return"makefile";case"ps1":case"psm1":return"powershell";case"json5":return"json5";case"less":return"less";case"scss":return"scss";case"sass":return"sass";case"styl":return"stylus";case"vue":return"vue";case"svelte":return"svelte";case"astro":return"astro";case"mm":case"m":return"objective-c";case"groovy":case"gvy":case"gradle":return"groovy"}}function a(e){if(!e||e.length<5)return!1;let t=e.trim();if(t.startsWith("{")&&t.endsWith("}")||t.startsWith("[")&&t.endsWith("]"))try{return JSON.parse(t),!0}catch{}return[/^(?:import|export)\s+.+from\s+['"][^'"]+['"]/m,/^(?:const|let|var|function|class|interface|type|enum)\s+[A-Za-z0-9_$]+/m,/(?:=>|\bconsole\.(?:log|error|warn)|return\s+|async\s+function)/,/^\s*\d+:\s*(?:import|const|let|function|\/\/|\/\*|<|[A-Za-z])/m,/^\s*\[[A-Za-z0-9_./-]+\.[a-zA-Z0-9]+\]\s*\n\d+:/m].some(e=>e.test(t))}function l(e,t){return(0,r.sT)(t)||e.getLoadedLanguages().includes(t)?t:"javascript"}function o(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"javascript";if(!e)return"";let n=(0,r.F)();if(!n)return(0,r.tn)(e);let s=l(n,t);try{return`<span class="shiki">${n.codeToHtml(e,{lang:s,themes:i,defaultColor:!1,structure:"inline"})}</span>`}catch{return(0,r.tn)(e)}}function c(e){return o(e,"json")}function d(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"javascript",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s=e.split("\n");if(!e)return s;let a=(0,r.F)();if(!a)return s.map(r.tn);let o=l(a,t);try{let{tokens:t}=a.codeToTokens(e,{lang:o,themes:i,defaultColor:!1,tokenizeMaxLineLength:n.maxLineLength??0});if(t.length!==s.length)return s.map(r.tn);return t.map(e=>e.map(e=>{let t=(0,r.tn)(e.content);if(!e.htmlStyle)return t;let n=Object.entries(e.htmlStyle).map(e=>{let[t,n]=e;return`${t}:${n}`}).join(";");return n?`<span style="${n}">${t}</span>`:t}).join(""))}catch{return s.map(r.tn)}}},U8(e,t,n){function r(e){if(null!=e){if("string"==typeof e)return e;if(Number.isFinite(e)&&!(e<=0)){if(e>=1e6){let t=e/1e6;return`${Number.isInteger(t)?t:t.toFixed(1)}M`}if(e>=1e3){let t=e/1e3;return`${Number.isInteger(t)?t:t.toFixed(1)}K`}return String(e)}}}function i(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;return"number"!=typeof e||!Number.isFinite(e)||e<=0?"":`$${e.toFixed(t)}`}function s(e){return"number"!=typeof e||!Number.isFinite(e)||e<0?"":e<1024?`${Math.round(e)} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(2)} MB`}function a(e){return"number"!=typeof e||!Number.isFinite(e)||e<0?"":`$${e.toFixed(2)}`}n.d(t,{$g:()=>a,BD:()=>i,Rk:()=>r,z3:()=>s})},JK(e,t,n){let r={png:"image/png",apng:"image/apng",jpg:"image/jpeg",jpeg:"image/jpeg",jfif:"image/jpeg",gif:"image/gif",webp:"image/webp",avif:"image/avif",bmp:"image/bmp",ico:"image/x-icon",tif:"image/tiff",tiff:"image/tiff"};function i(e){return r[function(e){if(!e)return"";let t=e.split("?")[0].split("#")[0].split(/[/\\]/).pop()??"",n=t.lastIndexOf(".");return n>0?t.slice(n+1).toLowerCase():""}(e)]??null}n.d(t,{CC:()=>i})},LQ(e,t,n){function r(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n="M",r="Modified",i="text-info",s="bg-info/10 text-info border-info/25",a=(e||"").trim().toUpperCase();if(t){let e=a[0]||"M";"A"===e?(n="A",r="Added (Staged)",i="text-success",s="bg-success/10 text-success border-success/25"):"D"===e?(n="D",r="Deleted (Staged)",i="text-error",s="bg-error/10 text-error border-error/25"):"R"===e?(n="R",r="Renamed (Staged)",i="text-meta",s="bg-meta/10 text-meta border-meta/25"):"U"===e||"?"===e?(n="U",r="Untracked",i="text-success",s="bg-success/10 text-success border-success/25"):(n="M",r="Modified (Staged)",i="text-info",s="bg-info/10 text-info border-info/25")}else if("??"===a||"?"===a||"U"===a||"UNTRACKED"===a)n="U",r="Untracked",i="text-success",s="bg-success/10 text-success border-success/25";else{let e=a[1]||a[0]||"M";"A"===e?(n="A",r="Added",i="text-success",s="bg-success/10 text-success border-success/25"):"D"===e?(n="D",r="Deleted",i="text-error",s="bg-error/10 text-error border-error/25"):"R"===e?(n="R",r="Renamed",i="text-meta",s="bg-meta/10 text-meta border-meta/25"):"U"===e||"?"===e?(n="U",r="Untracked",i="text-success",s="bg-success/10 text-success border-success/25"):(n="M",r="Modified",i="text-info",s="bg-info/10 text-info border-info/25")}return{charStatus:n,label:r,colorClass:i,badgeBgClass:s,isStaged:t}}function i(e){let t=new Map,n=new Map;if(!Array.isArray(e))return{fileMap:t,folderMap:n};for(let r of e){if(!r||!r.file)continue;let e=r.file.replace(/^\/+/,"");t.set(e,r);let i=e.split("/");i.pop();let s="";for(let e of i){s=s?`${s}/${e}`:e;let t=n.get(s)||{count:0,hasModified:!1,hasUntracked:!1,hasStaged:!1,hasDeleted:!1,colorClass:"text-info"};t.count+=1,(r.staged||r.status&&" "!==r.status[0]&&"?"!==r.status[0])&&(t.hasStaged=!0),"??"===r.status?t.hasUntracked=!0:r.status?.includes("D")?t.hasDeleted=!0:t.hasModified=!0,t.hasModified||t.hasStaged?t.colorClass="text-info":t.hasUntracked?t.colorClass="text-success":t.hasDeleted&&(t.colorClass="text-error"),n.set(s,t)}}return{fileMap:t,folderMap:n}}n.d(t,{R:()=>r,_:()=>i})},tZ(e,t,n){function r(e){let t=new URLSearchParams({path:e.path});return e.root&&t.set("root",e.root),e.repo&&"."!==e.repo&&t.set("repo",e.repo),`/api/fs/raw?${t.toString()}`}function i(e,t){let n=t.replace(/^(?:\.?[/\\])+/,"").replace(/[/\\]+$/,""),r=(e??"").replace(/[/\\]+$/,"");return r?n?`${r}${r.includes("\\")&&!r.includes("/")?"\\":"/"}${n}`:r:n}n.d(t,{A:()=>i,l:()=>r})},W9(e,t,n){let r=null,i=null;function s(){return i&&i.expiresAt>Date.now()?Promise.resolve(i.data):r||(r=fetch("/api/models").then(e=>e.ok?e.json():Promise.reject(Error(`GET /api/models failed: ${e.status}`))).then(e=>(i={data:e,expiresAt:Date.now()+6e4},e)).finally(()=>{r=null}))}function a(){i=null}function l(){i=null,window.dispatchEvent(new CustomEvent("omp:models-updated"))}function o(e){return window.addEventListener("omp:models-updated",e),()=>window.removeEventListener("omp:models-updated",e)}n.d(t,{$P:()=>l,Sy:()=>o,kn:()=>a,xo:()=>s})},Np(e,t,n){let r="new-";function i(e){return String(e).padStart(2,"0")}function s(e){return!!e?.startsWith(r)}function a(e){return e?.startsWith(r)?Number(e.slice(r.length)):0/0}function l(e){let t=a(e);return function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Date;return Number.isNaN(e.getTime())?"New Session":`New Session - ${e.getFullYear()}-${i(e.getMonth()+1)}-${i(e.getDate())}T${i(e.getHours())}:${i(e.getMinutes())}:${i(e.getSeconds())}`}(Number.isFinite(t)?new Date(t):new Date)}n.d(t,{fN:()=>s,fd:()=>a,g2:()=>l})},e(e,t,n){let r=["input","_input","patch"],i=/#([0-9a-fA-F]{4})$/,s=/^(PUT|CUT)\b/;function a(e){let t=e[0];return e.length>=2&&('"'===t||"'"===t)&&t===e[e.length-1]?e.slice(1,-1):e}function l(e){if(e)for(let t of r){let n=e[t];if("string"!=typeof n)continue;let r=function(e){let t,n=[];for(let r of e.replace(/^\uFEFF/,"").split("\n")){let e=r.endsWith("\r")?r.slice(0,-1):r,l=function(e){let t=e.trimEnd();if(!t.startsWith("["))return;let n=(t.endsWith("]")?t.slice(1,-1):t.slice(1)).trim(),r=i.exec(n),s=a((r?n.slice(0,r.index):n).trim());return s?{path:s,tag:r?.[1]}:void 0}(e);if(l){t={path:l.path,tag:l.tag,removed:!1,ops:[]},n.push(t);continue}if(!t)continue;let o=e.trim();if("REM"===o){t.removed=!0;continue}if(o.startsWith("MV ")){t.moveTo=a(o.slice(3).trim())||void 0;continue}if(s.test(o)){t.ops.push({verb:o.slice(0,3),spec:o.slice(3).trim().replace(/:$/,""),body:[]});continue}let c=t.ops[t.ops.length-1];c&&e.startsWith("+")&&c.body.push(e)}return n}(n);if(r.length>0)return{text:n,sections:r}}}function o(e){return l(e)?.sections[0].path}n.d(t,{I:()=>l,f$:()=>o})},wm(e,t,n){function r(e,t){e&&fetch("/api/agent/prewarm",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,...t?{accessMode:t}:{}})}).catch(()=>{})}function i(e,t,n){let r=void 0!==n?e.find(e=>String(e.id)===String(n)):e.find(e=>e.sessions?.some(e=>String(e.id)===String(t)))??e.find(e=>!!e.project_path);return r?.project_path||r?.name||null}n.d(t,{l:()=>i,r:()=>r})},B(e,t,n){var r=n("oS");function i(e){return(0,r.u)(e)&&"string"==typeof e.id&&e.id.length>0&&"string"==typeof e.agent&&e.agent.length>0&&"string"==typeof e.status&&"number"==typeof e.index}async function s(e){try{let t=await fetch(`/api/sessions/${encodeURIComponent(e)}/subagents`);if(!t.ok)return null;let n=await t.json().catch(()=>null);if(!(0,r.u)(n))return null;let s=(0,r.u)(n.data)?n.data:n;if(!Array.isArray(s.subagents))return null;return s.subagents.filter(i)}catch{return null}}function a(e){let t={...e,source:"history",lastUpdate:0},n={};return void 0!==e.lastIntent&&(n.lastIntent=e.lastIntent),void 0!==e.toolCount&&(n.toolCount=e.toolCount),void 0!==e.requests&&(n.requests=e.requests),void 0!==e.tokens&&(n.tokens=e.tokens),void 0!==e.contextTokens&&(n.contextTokens=e.contextTokens),void 0!==e.contextWindow&&(n.contextWindow=e.contextWindow),void 0!==e.cost&&(n.cost=e.cost),void 0!==e.durationMs&&(n.durationMs=e.durationMs),void 0!==e.resolvedModel&&(n.resolvedModel=e.resolvedModel),Object.keys(n).length>0&&(t.progress=n),t}n.d(t,{Nh:()=>a,wv:()=>s})},V7(e,t,n){let r=/^#{1,6}\s+\S/,i=/^#{1,6}\s+target\s*:?\s*$/i,s=/^complete (the )?assignment\b/i;function a(e){for(let t of e){let e=t.trim();if(e)return e}}function l(e){if(!e)return;let t=e.split("\n"),n=t.findIndex(e=>i.test(e.trim()));if(-1!==n){let e=t.slice(n+1),i=e.findIndex(e=>r.test(e.trim())),s=a(-1===i?e:e.slice(0,i));if(s)return s}return a(t.filter(e=>{let t=e.trim();return!r.test(t)&&!s.test(t)}))}function o(e){let t=e.modelRole??e.progress?.modelRole;return t?`${e.id} (${e.agent}:${t})`:`${e.id} (${e.agent})`}function c(e){let t=l(e.task)??l(e.assignment)??e.description,n=`${e.id} (${e.agent})`;return t?`${n}: ${t}`:n}n.d(t,{Ti:()=>o,us:()=>c})},T(e,t,n){var r=n("oS");function i(e){return"string"==typeof e&&e.length>0?e:void 0}function s(e){return"number"==typeof e&&Number.isFinite(e)?e:void 0}function a(e){return"bundled"===e||"user"===e||"project"===e?e:void 0}function l(e){var t;if(!(0,r.u)(e))return;let n={},l=s(e.index);void 0!==l&&(n.index=l);let o=i(e.id);void 0!==o&&(n.id=o);let c=i(e.agent);void 0!==c&&(n.agent=c);let d=a(e.agentSource);void 0!==d&&(n.agentSource=d);let u="pending"===(t=e.status)||"running"===t||"completed"===t||"failed"===t||"aborted"===t?t:void 0;void 0!==u&&(n.status=u);let p=i(e.task);void 0!==p&&(n.task=p);let m=i(e.assignment);void 0!==m&&(n.assignment=m);let h=i(e.description);void 0!==h&&(n.description=h);let f=i(e.lastIntent);void 0!==f&&(n.lastIntent=f);let x=i(e.currentTool);void 0!==x&&(n.currentTool=x);let g=i(e.currentToolArgs);void 0!==g&&(n.currentToolArgs=g);let b=s(e.currentToolStartMs);void 0!==b&&(n.currentToolStartMs=b),Array.isArray(e.recentTools)&&(n.recentTools=e.recentTools),Array.isArray(e.recentOutput)&&(n.recentOutput=e.recentOutput.filter(e=>"string"==typeof e));let v=s(e.toolCount);void 0!==v&&(n.toolCount=v);let k=s(e.requests);void 0!==k&&(n.requests=k);let y=s(e.tokens);void 0!==y&&(n.tokens=y);let w=s(e.contextTokens);void 0!==w&&(n.contextTokens=w);let N=s(e.contextWindow);void 0!==N&&(n.contextWindow=N);let Y=s(e.cost);void 0!==Y&&(n.cost=Y);let D=s(e.durationMs);void 0!==D&&(n.durationMs=D),("string"==typeof e.modelOverride||Array.isArray(e.modelOverride)&&e.modelOverride.every(e=>"string"==typeof e))&&(n.modelOverride=e.modelOverride);let A=i(e.modelRole);void 0!==A&&(n.modelRole=A);let F=i(e.resolvedModel);if(void 0!==F&&(n.resolvedModel=F),"boolean"==typeof e.resolvedModelIsFallback&&(n.resolvedModelIsFallback=e.resolvedModelIsFallback),(0,r.u)(e.retryState)){let t=s(e.retryState.attempt),r=s(e.retryState.maxAttempts),a=s(e.retryState.delayMs),l=i(e.retryState.errorMessage),o=s(e.retryState.startedAtMs);void 0!==t&&void 0!==r&&void 0!==a&&void 0!==l&&void 0!==o&&(n.retryState={attempt:t,maxAttempts:r,delayMs:a,errorMessage:l,startedAtMs:o})}if((0,r.u)(e.retryFailure)){let t=s(e.retryFailure.attempt),r=i(e.retryFailure.errorMessage);void 0!==t&&void 0!==r&&(n.retryFailure={attempt:t,errorMessage:r})}return void 0!==e.inflightTaskDetails&&(n.inflightTaskDetails=e.inflightTaskDetails),(0,r.u)(e.extractedToolData)&&(n.extractedToolData=e.extractedToolData),Object.keys(n).length>0?n:void 0}function o(e){if(!(0,r.u)(e))return;let t=i(e.id),n=i(e.status);if(!t||!n||"started"!==n&&"completed"!==n&&"failed"!==n&&"aborted"!==n)return;let l={id:t,agent:i(e.agent)??"subagent",status:n,index:s(e.index)??-1,lastUpdate:Date.now(),source:"live"},o=a(e.agentSource);void 0!==o&&(l.agentSource=o);let c=i(e.description);void 0!==c&&(l.description=c);let d=i(e.sessionFile);void 0!==d&&(l.sessionFile=d);let u=i(e.parentToolCallId);return void 0!==u&&(l.parentToolCallId=u),"boolean"==typeof e.detached&&(l.detached=e.detached),l}function c(e){if(!(0,r.u)(e))return[];let t=e.subagents;if(!Array.isArray(t))return[];let n=[];for(let e of t){let t=function(e){let t;if(!(0,r.u)(e))return;let n=i(e.id),o=i(e.agent);if(!n||!o)return;if("started"===e.status||"completed"===e.status||"failed"===e.status||"aborted"===e.status)t=e.status;else{if("pending"!==e.status&&"running"!==e.status)return;t="started"}let c={id:n,agent:o,status:t,index:s(e.index)??-1,source:"live"},d=a(e.agentSource);void 0!==d&&(c.agentSource=d);let u=i(e.description);void 0!==u&&(c.description=u);let p=i(e.task);void 0!==p&&(c.task=p);let m=i(e.assignment);void 0!==m&&(c.assignment=m);let h=i(e.sessionFile);void 0!==h&&(c.sessionFile=h);let f=i(e.parentToolCallId);void 0!==f&&(c.parentToolCallId=f),c.lastUpdate=s(e.lastUpdate)??Date.now();let x=l(e.progress);return void 0!==x&&(c.progress=x),c}(e);t&&n.push(t)}return n}function d(e,t){return(e.batchSeq??Number.MAX_SAFE_INTEGER)-(t.batchSeq??Number.MAX_SAFE_INTEGER)||e.index-t.index||e.id.localeCompare(t.id)}function u(e,t,n){let r=new Map(e.map(e=>[e.id,e]));for(let e of t){let t=r.get(e.id);if(!t){r.set(e.id,e);continue}let i=t.batchSeq??e.batchSeq;if(void 0!==n&&(t.lastUpdate??0)>=n||"history"===e.source&&"history"!==t.source){i!==t.batchSeq&&r.set(e.id,{...t,batchSeq:i});continue}if("history"!==e.source&&"history"===t.source){r.set(e.id,{...e,batchSeq:i});continue}r.set(e.id,{...t,...e,batchSeq:i})}return[...r.values()].sort(d)}n.d(t,{bH:()=>o,j8:()=>u,mq:()=>l,vG:()=>c})},So(e,t,n){let r="omp_chamber_settings",i=null,s={};function a(e){s={...e?.[r]??{}};let t={...e??{}};delete t[r],i={...t,...s}}function l(e){return i||a(e),i??{}}function o(e,t){let n=Array.isArray(e)?e:[e],r=l(t);for(let e of n)if(void 0!==r[e])return r[e]}function c(e,t){return l(t),{...e,...s}}function d(e,t){i={...l(),[e]:t},p({[e]:t})}function u(e){s={...s,...e},i={...l(),...e},p({[r]:s})}function p(e){fetch("/api/settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).catch(()=>{})}n.d(t,{BF:()=>o,cm:()=>c,cz:()=>d,l1:()=>u,x9:()=>a})},oS(e,t,n){function r(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}n.d(t,{u:()=>r})},Gb(e,t,n){function r(e,t){if(!t)return{folder:null,projectPath:null};for(let n of e)if((n.sessions||[]).some(e=>String(e.id)===String(t)))return{folder:n,projectPath:n.project_path??null};return{folder:null,projectPath:null}}function i(e,t,n){let i=r(e,t).folder,s=null!=n?e.find(e=>String(e.id)===String(n))??null:null;return(i??s)?.project_path??null}n.d(t,{M:()=>i,t:()=>r})},A(e,t,n){var r=n("g6"),i=n("AB"),s=n("N"),a=n("h"),l=n("al"),o=n("nv"),c=n("nT"),d=n("w"),u=n("Oj"),p=n("Gh"),m=n("R"),h=n("HJ"),f=n("DK"),x=n("f"),g=n("z9"),b=n("Fx"),v=n("F9"),k=n("bt"),y=n("YO"),w=n("by");let N={default:r.A,code:i.A,terminal:s.A,rocket:a.A,flask:l.A,gamepad:o.A,briefcase:c.A,home:d.A,globe:u.A,leaf:p.A,shield:m.A,palette:h.A,server:f.A,smartphone:x.A,database:g.A,lightbulb:b.A,music:v.A,camera:k.A,book:y.A,heart:w.A};function Y(e){return N[e||"default"]||r.A}n.d(t,{x:()=>Y})},ET(e,t,n){let r=["context","files","search","git","terminal","user-browser","browser","usage"];function i(e){return"string"==typeof e&&r.includes(e)}n.d(t,{ls:()=>i},{Cx:{context:.45,files:.22,search:.22,git:.4,terminal:.6,"user-browser":.45,browser:.45,usage:.48},G7:r,lw:{files:200,search:200,git:260,terminal:320,context:420,"user-browser":320,browser:320,usage:420},qv:{context:536,files:268,search:268,git:268,terminal:640,"user-browser":804,browser:804,usage:536}})},SS(e,t,n){let r=new Map,i=new Map,s=new Set,a=new Map,l=new Map;function o(e){let t=r.get(e);void 0!==t&&(r.delete(e),r.set(e,t)),i.set(e,Date.now())}function c(e){let t=Date.now(),n=e=>{r.delete(e),s.delete(e),a.delete(e),i.delete(e);let t=l.get(e);t&&(clearTimeout(t),l.delete(e))};for(let[r,s]of i)!(t-s<=6e5)&&r!==e&&(a.get(r)||n(r));for(;r.size>10;){let t=!1;for(let i of r.keys())if(i!==e&&!a.get(i)){n(i),t=!0;break}if(!t)break}}function d(e,t){if(e)return o(e),r.get(e)?.[t]}function u(e,t,n){if(!e)return;let i=r.get(e)??{};i[t]=n,r.set(e,i),o(e),a.set(e,!0),p(e),c(e)}function p(e){let t=l.get(e);t&&clearTimeout(t),l.set(e,setTimeout(()=>{l.delete(e),m(e)},600))}async function m(e){if("u"<typeof window||!e||!a.get(e))return;a.set(e,!1);let t=r.get(e)??{};try{await fetch(`/api/sessions/${encodeURIComponent(e)}/state`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({state:t})})}catch(t){console.warn("session-state persist failed:",t),a.set(e,!0)}}function h(e){if(!e||"u"<typeof window)return Promise.resolve();let t=l.get(e);return t&&(clearTimeout(t),l.delete(e)),m(e)}async function f(e){if(e){if("u"<typeof window)return void s.add(e);try{let t=await fetch(`/api/sessions/${encodeURIComponent(e)}/state`);if(t.ok){let n=await t.json(),i=n.state&&"object"==typeof n.state?n.state:{},s=r.get(e)??{},l=!0===a.get(e)?{...i,...s}:i;r.set(e,l),o(e)}}catch(e){console.warn("session-state load failed:",e)}s.add(e),c(e)}}function x(e,t){e&&(r.set(e,{...r.get(e)??{},...t}),o(e),s.add(e),c(e))}function g(e){e&&s.add(e)}function b(e){e&&i.set(e,Date.now())}function v(e){return i.get(e)}function k(e,t){let n=r.get(e);n&&r.set(t,{...n,...r.get(t)??{}}),o(t),s.add(t),a.set(t,!0),p(t),r.delete(e),s.delete(e),a.delete(e),i.delete(e),c(t)}n.d(t,{D4:()=>h,E9:()=>x,L6:()=>f,R7:()=>v,WV:()=>d,Y1:()=>b,l5:()=>g,qI:()=>u,vy:()=>k})},P(e){e.exports={rE:"1.2.1"}}},a={};function l(e){var t=a[e];if(void 0!==t)return t.exports;var n=a[e]={exports:{}};return s[e].call(n.exports,n,n.exports,l),n.exports}l.m=s,l.d=(e,t,n)=>{var r=(t,n)=>{for(var r in t)l.o(t,r)&&!l.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,[n]:t[r]})};r(t,"get"),r(n,"value")},l.f={},l.e=e=>Promise.all(Object.keys(l.f).reduce((t,n)=>(l.f[n](e,t),t),[])),l.u=e=>"static/js/async/"+(121===e?"katex-vendor":e)+"."+({0:"8e59f2eb5b","0k":"5852e6b4fa","0w":"9ed36d5860",1:"f387c12b63",12:"d091f91c99",121:"de6a87c308",13:"8f810a8a6c",19:"6fe909d55a","1b":"23f1141a38","1k":"a411fe5b43","1p":"0d5cddda96",2:"b589f1733b","2v":"96165101de",3:"0cacc08423",37:"b28b2f61cd","3d":"5085fb913f","3j":"357c80ff38","3p":"bcf32a0983","3r":"3a69e98ee0","3u":"1228460e2a","3y":"3186ecdd63",4:"9442eeb472","4e":"678285ca55","4k":"33a0c7eeb4","4q":"aad20dab25",5:"ebaf8b89cc",51:"95bcae98af","5b":"d88304bc13","5j":"d6407c4248","5o":"88316d4460",6:"f034c9b528",66:"86544ad741","6o":"5b1a06a382",7:"e4a9288dd0",73:"308dff4da8","7e":"a1cc9bfd88","7g":"db82aca7ba","7l":"fadbbc0583",8:"5067439d8c","8j":"ea110663fb",a:"bce4542392",aa:"65d3852576",ar:"ad5c8822a8",az:"d656062b0f",b:"b4f6f06515",bi:"09688ba75c",bq:"586bc738d1",c:"797d933882",c0:"0af1e640d3",ca:"8a52cfd447",cf:"d34fff5d67",ct:"b74928f7a3",cx:"9c8268d542",d:"a5fc8fe1b3",da:"f62c70f6c8",dp:"1725d6432c",e:"6443e739a2",f:"ab50467719",f7:"46971e9d6d",f8:"bbf0dbae70",g:"ee41bfed7f",h:"4e790471e4",h1:"d7091cef78",h3:"216e9798ab",hd:"0da931b622",hk:"ba7fb04d41",hn:"b645041e00",ho:"475a5e1ae4",hp:"e9fe2e395a",hs:"e7c59d8090",i:"7c148e8440",id:"573df20f29",j:"ab925882d8",jd:"63886a1f09",jg:"d86ebd4013",jl:"4911fa3383",jll:"11313b455a",js:"67182759ef",jsc:"23b70d6f40",jse:"334588ff5d",jz:"72eb929106",k:"d16cd09ae7",ka:"c1990ecaa3",ku:"29c8a59d0c",ky:"8dab1dade0",l:"12dd34e1be",l9:"949710adaf",ls:"9d9a01026c",m:"2e1ea3db9e",m3:"d2b05f9604",ma:"2c261b04dd",me:"8ace414f80",ms:"98960af4eb",mt:"853be2b5aa",n:"a9f1c51701",na:"a36cd532d6",nk:"fc7e58325e",o:"36353dfb88",oc:"eb22093f05",og:"53f068804c",ot:"84c71b308f",p:"48ecfcd14e",px:"783b6f91f2",q:"b453193538",q5:"88b50ffa95",q8:"7f1b48e9cd",qs:"2a9ddb3c72",r:"51010ad87c",rd:"cb6bf495bb",s:"aad2ecebc6",t:"4dca0e2ba8",t9:"d44f57d518",ta:"973534bbec",tr:"2a0d2b7600",u:"0871ac5b22",ud:"3065bfee31",up:"ea990da0ff",uw:"8890abbabc",v:"7d28d3c241",vp:"9b13bf8610",vt:"20406a5604",w:"08ac210f60",wt:"ad92393a90",x:"563f72ca6b",x0:"475516418f",x1:"fe8af17016",xl:"a3c562a58c",xn:"6360379f71",xnl:"feb0021e50",y:"1a9ed7a5d8",y6:"43c57defe4",yb:"8c1342401d",ybq:"4491f2f2dc",yg:"5a94e1fc8a",yq:"917ddd7ba2",ys:"00687cf82d",yv:"2fa22f009a",yx:"af2936c368",z:"56f61a4374",zi:"5fdb07b86a",zj:"654f37e8ff",zn:"966d6f1cc6",zo:"26213b40c0",zx:"e9f4105e00"})[e]+".js",l.miniCssF=e=>""+e+".css",l.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),e={},l.l=function(t,n,r,i){if(e[t])return void e[t].push(n);if(void 0!==r)for(var s,a,o=document.getElementsByTagName("script"),c=0;c<o.length;c++){var d=o[c];if(d.getAttribute("src")==t||d.getAttribute("data-rspack")=="ompchamber:"+r){s=d;break}}s||(a=!0,(s=document.createElement("script")).timeout=120,l.nc&&s.setAttribute("nonce",l.nc),s.setAttribute("data-rspack","ompchamber:"+r),s.src=t),e[t]=[n];var u=function(n,r){s.onerror=s.onload=null,clearTimeout(p);var i=e[t];if(delete e[t],s.parentNode&&s.parentNode.removeChild(s),i&&i.forEach(function(e){return e(r)}),n)return n(r)},p=setTimeout(u.bind(null,void 0,{type:"timeout",target:s}),12e4);s.onerror=u.bind(null,s.onerror),s.onload=u.bind(null,s.onload),a&&document.head.appendChild(s)},l.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t=[],l.O=(e,n,r,i)=>{if(n){i=i||0;for(var s=t.length;s>0&&t[s-1][2]>i;s--)t[s]=t[s-1];t[s]=[n,r,i];return}for(var a=1/0,s=0;s<t.length;s++){for(var[n,r,i]=t[s],o=!0,c=0;c<n.length;c++)(!1&i||a>=i)&&Object.keys(l.O).every(e=>l.O[e](n[c]))?n.splice(c--,1):(o=!1,i<a&&(a=i));if(o){t.splice(s--,1);var d=r();void 0!==d&&(e=d)}}return e},l.p="/",n={qz:0},l.f.j=function(e,t){var r=l.o(n,e)?n[e]:void 0;if(0!==r)if(r)t.push(r[2]);else{var i=new Promise((t,i)=>r=n[e]=[t,i]);t.push(r[2]=i);var s=l.p+l.u(e),a=Error();l.l(s,function(t){if(l.o(n,e)&&(0!==(r=n[e])&&(n[e]=void 0),r)){var i=t&&("load"===t.type?"missing":t.type),s=t&&t.target&&t.target.src;a.message="Loading chunk "+e+" failed.\n("+i+": "+s+")",a.name="ChunkLoadError",a.type=i,a.request=s,r[1](a)}},"chunk-"+e,e)}},l.O.j=e=>0===n[e],r=(e,t)=>{var r,i,[s,a,o]=t,c=0;if(s.some(e=>0!==n[e])){for(r in a)l.o(a,r)&&(l.m[r]=a[r]);if(o)var d=o(l)}for(e&&e(t);c<s.length;c++)i=s[c],l.o(n,i)&&n[i]&&n[i][0](),n[i]=0;return l.O(d)},(i=self.rspackChunkompchamber=self.rspackChunkompchamber||[]).forEach(r.bind(null,0)),i.push=r.bind(null,i.push.bind(i));var o=l.O(void 0,["a3","9","77"],()=>l("l"));o=l.O(o)})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ompchamber",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "Developer web console and diagnostic chamber for AI Oh-My-Pi — Elysia + Preact on Bun.",
5
5
  "license": "UNLICENSED",
6
6
  "author": "Wijanarko Putra Rajeb <wijanarko.rajeb@gmail.com>",
@@ -19,6 +19,7 @@ export interface BtwComposerProps {
19
19
  running: boolean;
20
20
  modelLabel?: string;
21
21
  provider?: string;
22
+ providerNames?: Record<string, string>;
22
23
  attachments: { id: string; name: string; size: number }[];
23
24
  onFilesSelected: (files: File[]) => void;
24
25
  onRemoveAttachment: (id: string) => void;
@@ -34,6 +35,7 @@ export function BtwComposer({
34
35
  running,
35
36
  modelLabel,
36
37
  provider,
38
+ providerNames,
37
39
  attachments,
38
40
  onFilesSelected,
39
41
  onRemoveAttachment,
@@ -42,7 +44,7 @@ export function BtwComposer({
42
44
  const textareaRef = useRef<HTMLTextAreaElement>(null);
43
45
 
44
46
  const canSend = value.trim().length > 0 || attachments.length > 0;
45
- const providerText = provider ? providerLabel(provider) : '';
47
+ const providerText = provider ? providerLabel(provider, providerNames) : '';
46
48
 
47
49
  // The form replaces the chat composer that had focus, so the caret is put
48
50
  // here — the field the form is for, and the one a restored draft is waiting
@@ -26,14 +26,18 @@ export interface BtwFormProps {
26
26
  /** The chat's own model, shown until the topic reports the one it ran on. */
27
27
  modelName?: string;
28
28
  provider?: string;
29
+ providerNames?: Record<string, string>;
29
30
  }
30
31
 
31
- export function BtwForm({ mode, modelName, provider }: BtwFormProps) {
32
+ export function BtwForm({ mode, modelName, provider, providerNames }: BtwFormProps) {
32
33
  const [attachments, setAttachments] = useState<BtwAttachment[]>([]);
33
34
  const lastTurn = mode.activeTopic?.turns[mode.activeTopic.turns.length - 1];
34
35
  // `busy` is the command in flight (a promote POST, say): promoting again from
35
36
  // the same click burst would be a second request for work already running.
36
- const canPromote = Boolean(mode.activeTopic) && !mode.runningTopicId && !mode.busy && lastTurn?.status === 'complete';
37
+ // An already-promoted topic needs no second button either — its branch
38
+ // session exists, and the server hands that id back on a repeat promote.
39
+ const canPromote =
40
+ Boolean(mode.activeTopic) && !mode.runningTopicId && !mode.busy && !mode.activeTopic?.promotedSessionId && lastTurn?.status === 'complete';
37
41
  const showTurns = (mode.activeTopic?.turns.length ?? 0) > 0 || Boolean(mode.error);
38
42
 
39
43
  return (
@@ -72,6 +76,7 @@ export function BtwForm({ mode, modelName, provider }: BtwFormProps) {
72
76
  running={Boolean(mode.runningTopicId)}
73
77
  modelLabel={mode.activeTopic?.model?.name ?? modelName}
74
78
  provider={mode.activeTopic?.model?.provider ?? provider}
79
+ providerNames={providerNames}
75
80
  attachments={attachments}
76
81
  onFilesSelected={(files) => {
77
82
  void readBtwAttachments(files).then((next) => setAttachments((prev) => [...prev, ...next]));
@@ -118,7 +118,7 @@ export function ComposerDock({
118
118
  isSteering
119
119
  />
120
120
  {btw.open ? (
121
- <BtwForm mode={btw} modelName={modelName} provider={provider} />
121
+ <BtwForm mode={btw} modelName={modelName} provider={provider} providerNames={providerNames} />
122
122
  ) : (
123
123
  <ChatInput
124
124
  value={inputValue}