codexui-android 0.1.100 → 0.1.101

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.
@@ -1,4 +1,4 @@
1
- import{_ as En,o as r,c as l,a as d,d as qs,u as Ks,r as b,w as Y,n as Ct,b as Gs,e as Zs,t as f,f as k,F as g,g as w,h as C,i as Xs,j as Q,I as Js,k as Ys,l as Qs,m as Pn,p as Ze,q as $t,s as Lt,v as ee,x as An,T as ei,y as L,z as ti,A as ni,B as si}from"./index-Cmr8liLe.js";const ii={},oi={xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24","aria-hidden":"true"};function ai(M,be){return r(),l("svg",oi,[...be[0]||(be[0]=[d("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M8 16a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2zm-4 4a2 2 0 0 1-2-2V8m4 8h10"},null,-1)])])}const ri=En(ii,[["render",ai]]),li={key:0,class:"conversation-loading"},ci={key:1,class:"conversation-empty"},ui={key:0,class:"conversation-load-more"},di=["disabled"],hi=["data-role","data-message-type"],fi={key:0,class:"message-row","data-role":"system"},pi={class:"message-stack","data-role":"system"},mi=["onClick"],vi={class:"cmd-group-label"},ki={class:"cmd-status"},gi={class:"cmd-group-inner"},yi=["onClick"],_i={class:"cmd-label"},wi={class:"cmd-status"},bi={class:"cmd-output-inner"},xi=["textContent"],Ci=["onClick"],$i={class:"cmd-label"},Li={class:"cmd-status"},Ti={class:"cmd-output-inner"},Mi=["textContent"],Si=["data-role","data-message-type"],Ii=["data-role"],Pi=["data-role"],Ai={key:0,class:"file-change-summary-block"},Ei=["onClick"],Bi={class:"file-change-summary-label"},Fi={class:"file-change-summary-status"},Ri=["data-tone"],Hi={class:"file-change-panel-inner"},Wi={class:"file-change-list"},Oi=["data-operation"],zi=["title","onClick"],ji={key:0,class:"file-change-arrow"},Di=["title","onClick"],Vi={key:2,class:"file-change-delta"},Ni=["data-tone"],Ui=["data-role","data-message-type"],qi=["data-role"],Ki=["data-role"],Gi=["data-role"],Zi=["onClick"],Xi=["src","alt"],Ji={key:1,class:"message-file-attachments"},Yi=["href","title"],Qi=["data-role"],eo={key:0,class:"worked-separator-wrap","aria-live":"polite"},to=["onClick"],no={class:"worked-separator-text"},so={key:0,class:"worked-details"},io=["onClick"],oo={class:"cmd-label"},ao={class:"cmd-status"},ro={class:"cmd-output-inner"},lo=["textContent"],co=["data-streaming"],uo={class:"plan-card-header"},ho={key:0,class:"plan-card-badge"},fo=["innerHTML"],po={key:1,class:"plan-step-list"},mo=["data-status"],vo=["data-status"],ko=["innerHTML"],go=["innerHTML"],yo={key:3,class:"plan-card-actions"},_o=["onClick"],wo={key:0,class:"message-text"},bo={key:0},xo={key:1,class:"message-bold-text"},Co={key:2,class:"message-italic-text"},$o={key:3,class:"message-strikethrough-text"},Lo=["href","title"],To=["href","title"],Mo={key:6,class:"message-inline-code"},So={key:0},Io={key:1,class:"message-bold-text"},Po={key:2,class:"message-italic-text"},Ao={key:3,class:"message-strikethrough-text"},Eo=["href","title"],Bo=["href","title"],Fo={key:6,class:"message-inline-code"},Ro={key:2,class:"message-blockquote"},Ho={key:0},Wo={key:1,class:"message-bold-text"},Oo={key:2,class:"message-italic-text"},zo={key:3,class:"message-strikethrough-text"},jo=["href","title"],Do=["href","title"],Vo={key:6,class:"message-inline-code"},No={key:3,class:"message-list message-list-unordered"},Uo=["innerHTML"],qo={key:4,class:"message-list message-task-list"},Ko=["data-checked"],Go={class:"message-list-item-text"},Zo={key:0},Xo={key:1,class:"message-bold-text"},Jo={key:2,class:"message-italic-text"},Yo={key:3,class:"message-strikethrough-text"},Qo=["href","title"],ea=["href","title"],ta={key:6,class:"message-inline-code"},na=["start"],sa=["innerHTML"],ia={key:6,class:"message-table-wrap"},oa={class:"message-table"},aa={key:0},ra={key:1,class:"message-bold-text"},la={key:2,class:"message-italic-text"},ca={key:3,class:"message-strikethrough-text"},ua=["href","title"],da=["href","title"],ha={key:6,class:"message-inline-code"},fa={key:0},pa={key:0},ma={key:1,class:"message-bold-text"},va={key:2,class:"message-italic-text"},ka={key:3,class:"message-strikethrough-text"},ga=["href","title"],ya=["href","title"],_a={key:6,class:"message-inline-code"},wa={key:7,class:"message-code-block"},ba={key:0,class:"message-code-language"},xa={class:"message-code-pre"},Ca=["innerHTML"],$a={key:8,class:"message-divider"},La={key:9,class:"message-text"},Ta=["onClick"],Ma=["src","alt","onError"],Sa={key:3,class:"file-change-summary-block file-change-summary-block-inline"},Ia=["onClick"],Pa={class:"file-change-summary-label"},Aa={class:"file-change-summary-status"},Ea=["data-tone"],Ba={class:"file-change-panel-inner"},Fa={class:"file-change-list"},Ra=["data-operation"],Ha=["title","onClick"],Wa={key:0,class:"file-change-arrow"},Oa=["title","onClick"],za={key:2,class:"file-change-delta"},ja=["data-tone"],Da=["data-role"],Va=["onClick"],Na=["onClick"],Ua=["data-copied","aria-label","title","onClick"],qa={class:"message-copy-label"},Ka={key:1,class:"conversation-item conversation-item-overlay"},Ga={class:"message-row"},Za={class:"message-stack"},Xa={class:"live-overlay-inline","aria-live":"polite"},Ja={class:"live-overlay-label"},Ya={key:0,class:"live-overlay-reasoning"},Qa={key:1,class:"live-overlay-error"},er=["src"],tr={key:0,class:"diff-viewer-sidebar"},nr={class:"diff-viewer-sidebar-header"},sr={class:"diff-viewer-sidebar-count"},ir={class:"diff-viewer-sidebar-list"},or=["data-active","onClick"],ar=["data-operation"],rr={class:"diff-viewer-file-label"},lr={key:0,class:"diff-viewer-file-delta"},cr={class:"diff-viewer-main"},ur={class:"diff-viewer-toolbar"},dr={class:"diff-viewer-title-wrap"},hr={class:"diff-viewer-title"},fr={class:"diff-viewer-subtitle"},pr={key:0},mr={class:"diff-viewer-toolbar-actions"},vr={key:0,class:"diff-viewer-empty"},kr={key:1,class:"diff-viewer-panel"},gr={class:"diff-viewer-meta"},yr={class:"diff-viewer-language"},_r={class:"diff-viewer-lines"},wr=["data-kind"],br={class:"diff-viewer-line-number"},xr={class:"diff-viewer-line-number"},Cr={class:"diff-viewer-line-marker"},$r=["innerHTML"],Lr={class:"diff-viewer-mobile-sheet-header"},Tr={class:"diff-viewer-sidebar-count"},Mr={class:"diff-viewer-mobile-sheet-list"},Sr=["data-active","onClick"],Ir=["data-operation"],Pr={class:"diff-viewer-file-label"},Ar={key:0,class:"diff-viewer-file-delta"},Er=16,Br=300,Fr=1200,Rr=300,Hr=250,Tt=50,Wr=30,Or=200,zr=qs({__name:"ThreadConversation",props:{messages:{},pendingRequests:{},liveOverlay:{},isLoading:{type:Boolean},activeThreadId:{},cwd:{},scrollState:{}},emits:["updateScrollState","forkThread","rollback","implementPlan","respondServerRequest"],setup(M,{expose:be,emit:Bn}){var In;const de=b(new Set),W=b(new Set),he=b(new Set),Xe=b(new Set),fe=b(new Set),Je=b(null),xe=b(""),D=b(!1),Mt=b(null),pe=b(!1),St=b(0),It=b(0),Ye=b(""),Qe=b(""),{isMobile:Ce}=Ks();function Fn(e){var i;const n=e.replace(/\r\n/g,`
1
+ import{_ as En,o as r,c as l,a as d,d as qs,u as Ks,r as b,w as Y,n as Ct,b as Gs,e as Zs,t as f,f as k,F as g,g as w,h as C,i as Xs,j as Q,I as Js,k as Ys,l as Qs,m as Pn,p as Ze,q as $t,s as Lt,v as ee,x as An,T as ei,y as L,z as ti,A as ni,B as si}from"./index-DzzwK-KG.js";const ii={},oi={xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24","aria-hidden":"true"};function ai(M,be){return r(),l("svg",oi,[...be[0]||(be[0]=[d("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M8 16a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2zm-4 4a2 2 0 0 1-2-2V8m4 8h10"},null,-1)])])}const ri=En(ii,[["render",ai]]),li={key:0,class:"conversation-loading"},ci={key:1,class:"conversation-empty"},ui={key:0,class:"conversation-load-more"},di=["disabled"],hi=["data-role","data-message-type"],fi={key:0,class:"message-row","data-role":"system"},pi={class:"message-stack","data-role":"system"},mi=["onClick"],vi={class:"cmd-group-label"},ki={class:"cmd-status"},gi={class:"cmd-group-inner"},yi=["onClick"],_i={class:"cmd-label"},wi={class:"cmd-status"},bi={class:"cmd-output-inner"},xi=["textContent"],Ci=["onClick"],$i={class:"cmd-label"},Li={class:"cmd-status"},Ti={class:"cmd-output-inner"},Mi=["textContent"],Si=["data-role","data-message-type"],Ii=["data-role"],Pi=["data-role"],Ai={key:0,class:"file-change-summary-block"},Ei=["onClick"],Bi={class:"file-change-summary-label"},Fi={class:"file-change-summary-status"},Ri=["data-tone"],Hi={class:"file-change-panel-inner"},Wi={class:"file-change-list"},Oi=["data-operation"],zi=["title","onClick"],ji={key:0,class:"file-change-arrow"},Di=["title","onClick"],Vi={key:2,class:"file-change-delta"},Ni=["data-tone"],Ui=["data-role","data-message-type"],qi=["data-role"],Ki=["data-role"],Gi=["data-role"],Zi=["onClick"],Xi=["src","alt"],Ji={key:1,class:"message-file-attachments"},Yi=["href","title"],Qi=["data-role"],eo={key:0,class:"worked-separator-wrap","aria-live":"polite"},to=["onClick"],no={class:"worked-separator-text"},so={key:0,class:"worked-details"},io=["onClick"],oo={class:"cmd-label"},ao={class:"cmd-status"},ro={class:"cmd-output-inner"},lo=["textContent"],co=["data-streaming"],uo={class:"plan-card-header"},ho={key:0,class:"plan-card-badge"},fo=["innerHTML"],po={key:1,class:"plan-step-list"},mo=["data-status"],vo=["data-status"],ko=["innerHTML"],go=["innerHTML"],yo={key:3,class:"plan-card-actions"},_o=["onClick"],wo={key:0,class:"message-text"},bo={key:0},xo={key:1,class:"message-bold-text"},Co={key:2,class:"message-italic-text"},$o={key:3,class:"message-strikethrough-text"},Lo=["href","title"],To=["href","title"],Mo={key:6,class:"message-inline-code"},So={key:0},Io={key:1,class:"message-bold-text"},Po={key:2,class:"message-italic-text"},Ao={key:3,class:"message-strikethrough-text"},Eo=["href","title"],Bo=["href","title"],Fo={key:6,class:"message-inline-code"},Ro={key:2,class:"message-blockquote"},Ho={key:0},Wo={key:1,class:"message-bold-text"},Oo={key:2,class:"message-italic-text"},zo={key:3,class:"message-strikethrough-text"},jo=["href","title"],Do=["href","title"],Vo={key:6,class:"message-inline-code"},No={key:3,class:"message-list message-list-unordered"},Uo=["innerHTML"],qo={key:4,class:"message-list message-task-list"},Ko=["data-checked"],Go={class:"message-list-item-text"},Zo={key:0},Xo={key:1,class:"message-bold-text"},Jo={key:2,class:"message-italic-text"},Yo={key:3,class:"message-strikethrough-text"},Qo=["href","title"],ea=["href","title"],ta={key:6,class:"message-inline-code"},na=["start"],sa=["innerHTML"],ia={key:6,class:"message-table-wrap"},oa={class:"message-table"},aa={key:0},ra={key:1,class:"message-bold-text"},la={key:2,class:"message-italic-text"},ca={key:3,class:"message-strikethrough-text"},ua=["href","title"],da=["href","title"],ha={key:6,class:"message-inline-code"},fa={key:0},pa={key:0},ma={key:1,class:"message-bold-text"},va={key:2,class:"message-italic-text"},ka={key:3,class:"message-strikethrough-text"},ga=["href","title"],ya=["href","title"],_a={key:6,class:"message-inline-code"},wa={key:7,class:"message-code-block"},ba={key:0,class:"message-code-language"},xa={class:"message-code-pre"},Ca=["innerHTML"],$a={key:8,class:"message-divider"},La={key:9,class:"message-text"},Ta=["onClick"],Ma=["src","alt","onError"],Sa={key:3,class:"file-change-summary-block file-change-summary-block-inline"},Ia=["onClick"],Pa={class:"file-change-summary-label"},Aa={class:"file-change-summary-status"},Ea=["data-tone"],Ba={class:"file-change-panel-inner"},Fa={class:"file-change-list"},Ra=["data-operation"],Ha=["title","onClick"],Wa={key:0,class:"file-change-arrow"},Oa=["title","onClick"],za={key:2,class:"file-change-delta"},ja=["data-tone"],Da=["data-role"],Va=["onClick"],Na=["onClick"],Ua=["data-copied","aria-label","title","onClick"],qa={class:"message-copy-label"},Ka={key:1,class:"conversation-item conversation-item-overlay"},Ga={class:"message-row"},Za={class:"message-stack"},Xa={class:"live-overlay-inline","aria-live":"polite"},Ja={class:"live-overlay-label"},Ya={key:0,class:"live-overlay-reasoning"},Qa={key:1,class:"live-overlay-error"},er=["src"],tr={key:0,class:"diff-viewer-sidebar"},nr={class:"diff-viewer-sidebar-header"},sr={class:"diff-viewer-sidebar-count"},ir={class:"diff-viewer-sidebar-list"},or=["data-active","onClick"],ar=["data-operation"],rr={class:"diff-viewer-file-label"},lr={key:0,class:"diff-viewer-file-delta"},cr={class:"diff-viewer-main"},ur={class:"diff-viewer-toolbar"},dr={class:"diff-viewer-title-wrap"},hr={class:"diff-viewer-title"},fr={class:"diff-viewer-subtitle"},pr={key:0},mr={class:"diff-viewer-toolbar-actions"},vr={key:0,class:"diff-viewer-empty"},kr={key:1,class:"diff-viewer-panel"},gr={class:"diff-viewer-meta"},yr={class:"diff-viewer-language"},_r={class:"diff-viewer-lines"},wr=["data-kind"],br={class:"diff-viewer-line-number"},xr={class:"diff-viewer-line-number"},Cr={class:"diff-viewer-line-marker"},$r=["innerHTML"],Lr={class:"diff-viewer-mobile-sheet-header"},Tr={class:"diff-viewer-sidebar-count"},Mr={class:"diff-viewer-mobile-sheet-list"},Sr=["data-active","onClick"],Ir=["data-operation"],Pr={class:"diff-viewer-file-label"},Ar={key:0,class:"diff-viewer-file-delta"},Er=16,Br=300,Fr=1200,Rr=300,Hr=250,Tt=50,Wr=30,Or=200,zr=qs({__name:"ThreadConversation",props:{messages:{},pendingRequests:{},liveOverlay:{},isLoading:{type:Boolean},activeThreadId:{},cwd:{},scrollState:{}},emits:["updateScrollState","forkThread","rollback","implementPlan","respondServerRequest"],setup(M,{expose:be,emit:Bn}){var In;const de=b(new Set),W=b(new Set),he=b(new Set),Xe=b(new Set),fe=b(new Set),Je=b(null),xe=b(""),D=b(!1),Mt=b(null),pe=b(!1),St=b(0),It=b(0),Ye=b(""),Qe=b(""),{isMobile:Ce}=Ks();function Fn(e){var i;const n=e.replace(/\r\n/g,`
2
2
  `).trim();if(!n)return null;const t=[],s=[];for(const a of n.split(`
3
3
  `)){const u=a.trim();if(!u){t.length===0&&s.push("");continue}const o=u.match(/^[-*]\s+\[([ xX~>|-])\]\s+(.+)$/);if(o){const h=(o[1]??" ").toLowerCase();let c="pending";h==="x"&&(c="completed"),(h==="~"||h===">"||h==="-")&&(c="inProgress"),t.push({step:((i=o[2])==null?void 0:i.trim())??"",status:c});continue}s.push(u)}return t.length===0?null:{explanation:s.join(`
4
4
  `).trim(),steps:t.filter(a=>a.step.length>0)}}function et(e){var n;return e.plan&&e.plan.steps.length>0?{explanation:((n=e.plan.explanation)==null?void 0:n.trim())??"",steps:e.plan.steps}:Fn(e.text)}function E(e){return e.messageType==="commandExecution"&&!!e.commandExecution}function tt(e){return e.messageType==="plan"||e.messageType==="plan.live"}function Rn(e){return tt(e)&&e.messageType!=="plan.live"&&e.role==="assistant"&&!!e.turnId}function Hn(e){var t;const n=((t=e.turnId)==null?void 0:t.trim())??"";n&&Pe("implementPlan",{turnId:n})}function nt(e){return e.messageType==="fileChange"&&e.fileChangeStatus==="completed"&&Array.isArray(e.fileChanges)&&e.fileChanges.length>0}function $e(e){return e.role==="assistant"&&!E(e)&&e.messageType!=="worked"&&!(e.messageType??"").endsWith(".live")}const st=L(()=>{var e;for(let n=v.messages.length-1;n>=0;n-=1){const t=v.messages[n];if(t.messageType==="commandExecution"&&((e=t.commandExecution)==null?void 0:e.status)==="inProgress")return t.id}return""}),Pt=L(()=>v.messages.some(e=>e.role==="assistant"&&e.messageType==="agentMessage.live"&&e.text.trim().length>0)),At=L(()=>!!v.liveOverlay||st.value.length>0||Pt.value),it=L(()=>{const e={};for(let n=0;n<v.messages.length;){const t=v.messages[n];if(!E(t)){n+=1;continue}const s=[];for(;n<v.messages.length&&E(v.messages[n]);)s.push(v.messages[n]),n+=1;if(s.length<=1)continue;const i=s[s.length-1];e[i.id]=s.slice(0,-1)}return e}),Wn=L(()=>{const e=new Set;for(const n of Object.values(it.value))for(const t of n)e.add(t.id);return e});function Et(e){var n;return((n=et(e))==null?void 0:n.explanation)??""}function Bt(e){var n;return((n=et(e))==null?void 0:n.steps)??[]}function On(e){switch(e){case"completed":return"✓";case"inProgress":return"•";default:return"○"}}function Ft(e){return!Pt.value&&e.id===st.value}function B(e){return E(e)?de.value.has(e.id)||!W.value.has(e.id)&&Ft(e):!1}function ot(e){return E(e)&&At.value}function at(e){var n;return E(e)&&(At.value||((n=e.commandExecution)==null?void 0:n.status)==="inProgress")}function rt(e){if(!E(e))return;const n=new Set(de.value),t=new Set(W.value),s=Ft(e);n.has(e.id)?(n.delete(e.id),s&&t.add(e.id)):s&&!t.has(e.id)?t.add(e.id):(n.add(e.id),t.delete(e.id)),de.value=n,W.value=t}function Le(e){return it.value[e.id]??[]}function Rt(e){return E(e)?[...Le(e),e]:[]}function zn(e){if(Le(e).length===0)return;const t=new Set(he.value);t.has(e.id)?t.delete(e.id):t.add(e.id),he.value=t}function lt(e){return he.value.has(e.id)}function jn(e){var a,u;const t=Rt(e).length,s=((u=(a=e.commandExecution)==null?void 0:a.command)==null?void 0:u.trim())||"(command)";return`${t===1?"1 command":`${t} commands`} · latest: ${s}`}function Dn(e){return Me(e)}function Vn(e){const n=new Set(Xe.value);n.has(e.id)?n.delete(e.id):n.add(e.id),Xe.value=n}function Ht(e){return Xe.value.has(e.id)}function Wt(e){const n=new Set(fe.value);n.has(e.id)?n.delete(e.id):n.add(e.id),fe.value=n}function te(e){return fe.value.has(e.id)}function T(e){return`${e.path}\0${e.movedToPath??""}`}function Te(e,n){e&&(Je.value=e,xe.value=T(n),D.value=!1)}function Ot(){Je.value=null,xe.value="",D.value=!1}function Nn(){D.value=!D.value}function Un(){D.value=!1}function zt(e){xe.value=T(e),Ce.value&&(D.value=!1)}function Me(e){const n=e.commandExecution;if(!n)return"";const t=ot(e);switch(n.status){case"inProgress":return t?"Running":"⟳ Running";case"completed":return n.exitCode===0?t?"Done":"✓ Completed":`Exit ${n.exitCode??"?"}`;case"failed":return t?"Failed":"✗ Failed";case"declined":return t?"Declined":"⊘ Declined";case"interrupted":return t?"Stopped":"⊘ Interrupted";default:return""}}function Se(e){var t,s;const n=(t=e.commandExecution)==null?void 0:t.status;return n==="inProgress"?"cmd-status-running":n==="completed"&&((s=e.commandExecution)==null?void 0:s.exitCode)===0?"cmd-status-ok":"cmd-status-error"}function Ie(e,n){if(e.size===0)return e;const t=new Set;for(const s of e)n.has(s)&&t.add(s);return t.size===e.size?e:t}function qn(e,n){const t=[];for(let s=n-1;s>=0;s--){const i=e[s];if(i.messageType==="commandExecution")t.unshift(i);else if(i.role==="user"||i.messageType==="worked")break}return t}const v=M,Pe=Bn,V=b(null),jt=b(null),me=b(""),N=b(""),Kn=b(null),O=b(((In=v.scrollState)==null?void 0:In.isAtBottom)!==!1),Dt={js:"javascript",jsx:"jsx",ts:"typescript",tsx:"tsx",py:"python",rb:"ruby",sh:"bash",shell:"bash",zsh:"bash",yml:"yaml",md:"markdown","c++":"cpp","c#":"csharp",ps1:"powershell"};let U=0,A=0,Ae=0,q=null,ve=null;const Vt=new WeakSet,Ee=b(null),ne=b(0),Nt=b(0);let Be=null;const ke=new Map,ge=new Map,se=new Map,ie=new Map;function Fe(e,n,t,s){for(e.has(n)&&e.delete(n),e.set(n,t);e.size>s;){const i=e.keys().next().value;if(i===void 0)break;e.delete(i)}return t}const F=b(0),K=b(!1),Gn=L(()=>v.messages.slice(F.value)),ct=L(()=>F.value>0),Zn=L(()=>!O.value&&(v.messages.length>0||v.pendingRequests.length>0||!!v.liveOverlay));function Xn(){return Ee.value?Promise.resolve():(Be||(Be=ti(()=>import("./common-BeuopZEI.js"),[]).then(e=>{Ee.value=e.default,ie.clear(),se.clear(),ne.value+=1}).finally(()=>{Be=null})),Be)}function Jn(e){if(!e||/[\r\n]/u.test(e)||e.endsWith("/")||e.endsWith("\\")||/^[A-Za-z][A-Za-z0-9+.-]*:\/\//u.test(e))return!1;const n=e.startsWith("/"),t=/^[A-Za-z]:[\\/]/u.test(e),s=e.startsWith("./")||e.startsWith("../")||e.startsWith("~/");return n||t||s?!0:/^[A-Za-z0-9._@() -]+(?:[\\/][A-Za-z0-9._@() -]+)+$/u.test(e)}function Re(e){return e.replace(/\\/gu,"/").split("/").filter(Boolean).pop()||e}function oe(e){return e.replace(/\\/gu,"/")}function Ut(e){if(!e.startsWith("file://"))return e;let n=e.replace(/^file:\/\//u,"");try{n=decodeURIComponent(n)}catch{}return/^\/[A-Za-z]:\//u.test(n)&&(n=n.slice(1)),n}function Yn(e){const n=oe(e),t=n.match(/^\/Users\/([^/]+)/u);if(t)return`/Users/${t[1]}`;const s=n.match(/^\/home\/([^/]+)/u);return s?`/home/${s[1]}`:""}function ae(e){const n=oe(e);if(!n)return n;let t="",s=n;const i=s.match(/^([A-Za-z]:)(\/.*)?$/u);i?(t=`${i[1]}/`,s=(i[2]??"").replace(/^\/+/u,"")):s.startsWith("/")&&(t="/",s=s.slice(1));const a=s.split("/").filter(Boolean),u=[];for(const h of a)if(h!=="."){if(h===".."){u.length>0&&u.pop();continue}u.push(h)}const o=u.join("/");return t?`${t}${o}`.replace(/\/+$/u,"")||t:o||n}function qt(e,n){const t=oe(Ut(e.trim()));if(!t)return"";if(t.startsWith("/")||/^[A-Za-z]:\//u.test(t))return ae(t);if(t.startsWith("~/")){const a=Yn(n);if(a)return ae(`${a}/${t.slice(2)}`)}const i=oe(n.trim());return ae(i?`${i.replace(/\/+$/u,"")}/${t}`:t)}function ye(e){if(!e)return null;let n=e.trim();n=He(n).core.trim();let s=null;const i=n.match(/^(.*)#L(\d+)(?:C\d+)?$/u);if(i)n=i[1],s=Number(i[2]);else{const a=n.match(/^(.*):(\d+)(?::\d+)?$/u);a&&(n=a[1],s=Number(a[2]))}return n=Ut(n),Jn(n)?{path:n,line:s}:null}function He(e){let n=e,t="",s="";const i={"(":")","[":"]","{":"}","<":">",'"':'"',"'":"'","`":"`","“":"”","‘":"’"};for(;n.length>0;){const a=n[0],u=Object.prototype.hasOwnProperty.call(i,a)?i[a]:"";if(!u||!n.endsWith(u))break;t+=a,s+=u,n=n.slice(1,-1)}return{core:n,leading:t,trailing:s}}function ut(e){const n=e.trim();if(!n.startsWith("[")||!n.endsWith(")"))return null;const t=n.indexOf("]");if(t<=1||n[t+1]!=="(")return null;const s=n.slice(1,t).trim(),i=n.slice(t+2,-1).trim();if(s.includes(`
@@ -1,4 +1,4 @@
1
- import{d as fn,r as ct,b as pn,C as gn,e as vn,w as mn,D as vs,n as Sn,E as wn,G as bn,H as yn,o as dt,c as ut,a as Be,F as ms,g as Ss,h as ws,t as St,s as zt,f as Cn,J as kn,y as xn,K as En,_ as Bn}from"./index-Cmr8liLe.js";/**
1
+ import{d as fn,r as ct,b as pn,C as gn,e as vn,w as mn,D as vs,n as Sn,E as wn,G as bn,H as yn,o as dt,c as ut,a as Be,F as ms,g as Ss,h as ws,t as St,s as zt,f as Cn,J as kn,y as xn,K as En,_ as Bn}from"./index-DzzwK-KG.js";/**
2
2
  * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
3
3
  * @license MIT
4
4
  *
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ThreadConversation-CSH0aUWx.js","assets/ThreadConversation-DdzQ_R3z.css","assets/ThreadTerminalPanel-QkJZ7U3Y.js","assets/ThreadTerminalPanel-BfzQNi0v.css","assets/ReviewPane-W_UvYmui.js","assets/ReviewPane-BJuXPOZb.css","assets/DirectoryHub-47WzZs4I.js","assets/DirectoryHub-DkF7hkxl.css"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ThreadConversation-BQnEV6OL.js","assets/ThreadConversation-DdzQ_R3z.css","assets/ThreadTerminalPanel-DuEjX4F5.js","assets/ThreadTerminalPanel-BfzQNi0v.css","assets/ReviewPane-Ce6QI-Sf.js","assets/ReviewPane-BJuXPOZb.css","assets/DirectoryHub-Bm5sZZRJ.js","assets/DirectoryHub-B_wdXTQL.css"])))=>i.map(i=>d[i]);
2
2
  (function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))r(a);new MutationObserver(a=>{for(const o of a)if(o.type==="childList")for(const i of o.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&r(i)}).observe(document,{childList:!0,subtree:!0});function n(a){const o={};return a.integrity&&(o.integrity=a.integrity),a.referrerPolicy&&(o.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?o.credentials="include":a.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(a){if(a.ep)return;a.ep=!0;const o=n(a);fetch(a.href,o)}})();/**
3
3
  * @vue/shared v3.5.33
4
4
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
@@ -53,7 +53,7 @@ ${q}`:i.value=q,ln(()=>{var Q;return(Q=ee.value)==null?void 0:Q.focus()}))}async
53
53
 
54
54
  `)&&St(y,`${tt}
55
55
 
56
- `)}ls(s);const ia=oi(s);ia&&(ea(y,ia),kt(y,{label:"Running command",details:[((ua=ia.commandExecution)==null?void 0:ua.command)??""]}));const Do=bl(s);if(Do){const tt=(l.value[y]??[]).find(hr=>hr.id===Do.itemId);tt!=null&&tt.commandExecution&&ea(y,{...tt,commandExecution:{...tt.commandExecution,aggregatedOutput:`${tt.commandExecution.aggregatedOutput}${Do.delta}`}})}const la=_l(s);la&&ea(y,la);const bs=Tl(s);if(bs&&Ie(y,bs),kl(s)&&(Ot&&n.value&&an(n.value,{scrollTop:0,isAtBottom:!0,scrollRatio:1}),Ht(y)),s.method==="turn/completed"){Ot=!1,Ht(y),l.value[y]&&(l.value=Ct(l.value,y));const tt=zt(s);tt&&(yt(tt,!1),kt(tt,null),wn(tt),ze||(vr(tt),sa(tt)))}}function si(s){if(s.method==="thread/tokenUsage/updated")return;const u=s.method,p=u==="turn/started"||u==="turn/completed"||u==="error",y=u.startsWith("thread/")||u==="turn/completed";if(!p&&!y)return;const A=zt(s);A&&p&&fe.add(A),y&&(Y=!0),!(ge!==null||typeof window>"u")&&(ge=window.setTimeout(()=>{ge=null,fr()},Su))}async function ii(s,u){if(!go){go=!0;try{if(!u)return;const p=[];for(const y of u.order){const A=Bo(y);p.includes(A)||p.push(A)}if(p.length>0){const y=Ri(p,s);Vo(X.value,y)||(X.value=y,Da(X.value))}if(Object.keys(u.labels).length>0){const y={...Ae.value};let A=!1;for(const[$,L]of Object.entries(u.labels)){const G=Bo($);y[G]!==L&&(y[G]=L,A=!0)}A&&(Ae.value=y,Au(y))}}catch{}}}async function Cl(){if(!(Object.keys(K.value).length>0))try{const s=await y0();Object.keys(s.titles).length>0&&(K.value=s.titles)}catch{}}async function ta(){try{return await Fa()}catch{return null}}async function xl(s,u,p){if(K.value[s])return;const y=u.trim();if(!y)return;const A=y.length>300?y.slice(0,300):y;try{const $=await k0(A,p);if(!$||K.value[s])return;K.value={...K.value,[s]:$},Nt(),_u(s,$)}catch{}}function Al(s,u){if(!u||u.order.length===0)return s;const p=new Set(u.order.map(y=>Bo(y)));return s.filter(y=>p.has(y.projectName)?!0:y.threads.some(A=>Ji(A.cwd)))}function ds(s,u){const p=Al(s,u),y=Ri(X.value,p);Vo(X.value,y)||(X.value=y,Da(X.value));const A=Eu(p,X.value);Rr(new Set(kr(A).map(L=>L.id)));const $=Zx(t.value,A,f.value);t.value=Oi(t.value,$),f.value=Qt(f.value,new Set(kr(t.value).map(L=>L.id))),Nt()}function fs(s){const u={};for(const[p,y]of Object.entries(s)){const A=p.trim();!A||y.length===0||(u[A]=y.map($=>({id:$.id,text:$.text,imageUrls:[...$.imageUrls],skills:$.skills.map(L=>({name:L.name,path:L.path})),fileAttachments:$.fileAttachments.map(L=>({label:L.label,path:L.path,fsPath:L.fsPath})),collaborationMode:$.collaborationMode})))}return u}function Tr(){o0(fs(h.value)).catch(()=>{})}async function El(){if(!b){b=!0;try{h.value=await r0()}catch{}}}function hs(s,u){if(s.length===0)return u;if(u.length===0)return s;const p=new Map;for(const A of kr(s))p.set(A.id,A);for(const A of kr(u))p.set(A.id,A);const y=new Map;for(const A of p.values()){const $=y.get(A.projectName);$?$.push(A):y.set(A.projectName,[A])}return Array.from(y.entries()).map(([A,$])=>({projectName:A,threads:$.sort((L,G)=>new Date(G.updatedAtIso).getTime()-new Date(L.updatedAtIso).getTime())})).sort((A,$)=>{var re,he;const L=new Date(((re=A.threads[0])==null?void 0:re.updatedAtIso)??0).getTime();return new Date(((he=$.threads[0])==null?void 0:he.updatedAtIso)??0).getTime()-L})}function na(){return Object.values(f.value).some(s=>s===!0)}function ps(s=mn){if(!(!Be||Ne||na())){if(mn=s,typeof window>"u"){no(s);return}Ye!==null&&window.clearTimeout(Ye),Ye=window.setTimeout(()=>{Ye=null,!(!Be||na())&&no(mn)},wx)}}async function no(s){if(!(Ne||!Be||na())){Ne=!0;try{const u=await lf(Be,Tb());Be=u.nextCursor,vt=u.nextCursor===null,Hn=hs(Hn,u.groups),ds(Hn,s)}catch{}finally{Ne=!1,Be&&!na()&&ps(s)}}}async function ra(){if(Xe){await Xe;return}Xe=(async()=>{var s;ye.value||(De.value=!0);try{const[u,p]=await Promise.all([lf(),ta(),Cl()]);mn=p;const y=u.groups;Hn=ye.value?hs(Hn,y):y,Be=ye.value&&!vt?Be:u.nextCursor,vt=u.nextCursor===null,await ii(y,p),ds(Hn,p),ye.value=!0,vt||ps(p);const A=kr(e.value);vn(A),!A.some(L=>L.id===n.value)&&!n.value&&qt(((s=A[0])==null?void 0:s.id)??"")}finally{De.value=!1}})().finally(()=>{Xe=null}),await Xe}async function Ar(s,u={}){if(!s)return;const p=D.get(s);if(p){await p;return}const y=ee.value[s]===!0,A=u.silent!==!0&&!y;A&&(Je.value=!0);const $=(async()=>{try{const L=bt(s),G=He.value[s]??"",re=Date.now()-(Me.get(s)??0)<Tx;if(y&&(re||(L.length===0||G===L)&&f.value[s]!==!0)){yn(s);return}const ht=we.value[s]!==!0?await gu(s):null,pt=ht??await uf(s);ht&&(xt(s,ht.model),we.value={...we.value,[s]:!0});const{messages:Tt,inProgress:Yt,activeTurnId:ro,turnIndexByTurnId:Ea}=pt;Xr(s,Tt),ml(s,Ea),is(s);const ws=r.value[s]??[],ia=Ux(ws,Tt,{preserveMissing:u.silent===!0});Nn(s,ia);const Do=o.value[s]??[];if(Yt){const la=qx(Do,Tt);bn(s,la)}else Xn(s);cs(s,Tt),ai(s,Tt),ee.value={...ee.value,[s]:!0},Me.set(s,Date.now()),L&&(He.value={...He.value,[s]:L}),yt(s,Yt),ro?me.value={...me.value,[s]:ro}:me.value[s]&&(me.value=Ct(me.value,s)),Yt||dn(s),yn(s)}finally{A&&(Je.value=!1)}})().finally(()=>{D.delete(s)});D.set(s,$),await $}async function li(s,u={}){s&&ee.value[s]!==!0&&await Ar(s,u)}async function ms(){if(F){await F;return}F=(async()=>{var s,u;try{const p=((u=(s=Sr.value)==null?void 0:s.cwd)==null?void 0:u.trim())??"";_e.value=await C0(p?[p]:void 0)}catch{}finally{F=null}})(),await F}async function ui(s={}){await Promise.allSettled([Kn({providerChanged:s.providerChanged,includeProviderModels:s.includeProviderModels}),nn(),Rn(),ms()])}function Il(s={}){const u=()=>{ui(s)};if(typeof window>"u"){u();return}window.setTimeout(u,0)}async function ci(s={}){J.value="";const u=s.includeSelectedThreadMessages!==!1,p=s.awaitAncillaryRefreshes===!0;try{await El(),await ra(),u&&await Ar(n.value),p?await ui({providerChanged:s.providerChanged,includeProviderModels:s.providerChanged===!0||p}):Il({providerChanged:s.providerChanged,includeProviderModels:!1})}catch(y){J.value=y instanceof Error?y.message:"Unknown application error"}}async function Pl(s){qt(s);try{await Ar(s),ms()}catch(u){J.value=u instanceof Error?u.message:"Unknown application error"}}async function Ml(s){try{await Ub(s),await ra(),n.value===s&&await Ar(n.value)}catch(u){J.value=u instanceof Error?u.message:"Unknown application error"}}async function di(s,u){const p=u.trim();if(!(!s||!p))try{await Bb(s,p),K.value={...K.value,[s]:p},Nt(),_u(s,p)}catch(y){J.value=y instanceof Error?y.message:"Unknown application error"}}async function Rl(s){var L,G;const u=s.trim();if(!u)return"";const p=kr(t.value).find(re=>re.id===u),y=((L=p==null?void 0:p.cwd)==null?void 0:L.trim())??"",A=((G=p==null?void 0:p.title)==null?void 0:G.trim())??"Forked chat",$=Gt(u);J.value="";try{const re=await hf(u,y||void 0,$||void 0),he=re.threadId.trim();return he?($n(he,y,A),xt(he,re.model),we.value={...we.value,[he]:!0},qt(he),await ra(),await Ar(he),he):""}catch(re){return J.value=re instanceof Error?re.message:"Unknown application error",""}}async function $l(s,u){var L;const p=s.trim();if(!p||!Number.isInteger(u)||u<0)return"";if(f.value[p]===!0)return J.value="Finish the current turn before forking from a response.","";if(ee.value[p]!==!0)try{await Ar(p)}catch(G){return J.value=G instanceof Error?G.message:"Unknown application error",""}const y=r.value[p]??[];let A=-1;for(const G of y)typeof G.turnIndex=="number"&&Number.isFinite(G.turnIndex)&&(A=Math.max(A,G.turnIndex));if(A>=0&&u>A)return"";const $=kr(t.value).find(G=>G.id===p)??null;try{J.value="";const G=await hf(p),re=G.threadId.trim();if(!re)return"";const he=G.cwd.trim()||((L=$==null?void 0:$.cwd)==null?void 0:L.trim())||"",ze=tA(($==null?void 0:$.title)||($==null?void 0:$.preview)||"Untitled thread");$n(re,he,ze),xt(re,G.model),Nn(re,G.messages),ee.value={...ee.value,[re]:!0},we.value={...we.value,[re]:!0},mt(re),bn(re,[]),Ht(re),l.value[re]&&(l.value=Ct(l.value,re)),rn(re,null),kt(re,null),It(re,null),yt(re,!1);const ht=A-u;if(ht>0){const pt=await vu(re,ht);Nn(re,pt)}return await di(re,ze),qt(re),ra().catch(()=>{}),re}catch(G){return J.value=G instanceof Error?G.message:"Unknown application error",""}}async function fi(s,u,p=[],y=[],A=[]){if(!s||!u.trim()||p.length>0||y.length>0||A.length>0)return!1;const L=(Le.value[s]??[]).filter(he=>he.method==="item/tool/requestUserInput");if(L.length!==1)return!1;const[G]=L,re=_t(G);return re.length!==1?!1:vi({id:G.id,result:{answers:{[re[0]]:{answers:[u.trim()]}}}})}async function hi(s,u=[],p=[],y="steer",A=[],$,L){if(H.value)return;const G=n.value,re=s.trim();if(!G||!re&&u.length===0&&A.length===0||await fi(G,re,u,p,A))return;const he=f.value[G]===!0;if(he&&y==="queue"){const ze=h.value[G]??[],ht=`q-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,pt=[...ze],Tt=typeof $=="number"?Math.max(0,Math.min($,pt.length)):pt.length;pt.splice(Tt,0,{id:ht,text:re,imageUrls:u,skills:p,fileAttachments:A,collaborationMode:L==="plan"?"plan":L==="default"?"default":O.value}),h.value={...h.value,[G]:pt},Tr();return}if(he){Ot=!0,aa(G,re,u,p,A,L).catch(ze=>{const ht=ze instanceof Error?ze.message:"Unknown application error";It(G,ht),J.value=ht});return}J.value="",Ot=!0,rn(G,null),kt(G,{label:"Thinking",details:Sn(Gt(G),Z.value,L==="plan"?"plan":L==="default"?"default":O.value)}),It(G,null),yt(G,!0);try{await aa(G,re,u,p,A,L)}catch(ze){Ot=!1,yt(G,!1),kt(G,null);const ht=ze instanceof Error?ze.message:"Unknown application error";throw It(G,ht),J.value=ht,ze}}async function oa(s,u,p=[],y=[],A=[]){if(H.value)return"";const $=s.trim(),L=u.trim(),G=Gt(xo).trim(),re=As(te.value,xo);if(!$&&p.length===0&&A.length===0)return"";k.value=!0,J.value="";let he="";try{try{const Tt=await ff(L||void 0,G||void 0);he=Tt.threadId,xt(he,Tt.model),lr(he,re)}catch(Tt){if(G&&G!==Fr&&$i(Tt)){await Mn();const Yt=await ff(L||void 0,Fr);he=Yt.threadId,xt(he,Yt.model),lr(he,re)}else throw Tt}if(!he)return"";$n(he,L,$||"[Image]"),on(he),we.value={...we.value,[he]:!0},qt(he),Ot=!0,rn(he,null),kt(he,{label:"Thinking",details:Sn(Gt(he),Z.value,re)}),It(he,null),yt(he,!0);const ze=he,ht=L||null,pt=$;return aa(he,$,p,y,A,re).catch(Tt=>{Ot=!1,yt(he,!1),kt(he,null);const Yt=Tt instanceof Error?Tt.message:"Unknown application error";It(he,Yt),J.value=Yt}).finally(()=>{k.value=!1}),xl(ze,pt,ht),he}catch(ze){Ot=!1,he&&(yt(he,!1),kt(he,null));const ht=ze instanceof Error?ze.message:"Unknown application error";throw he&&It(he,ht),J.value=ht,k.value=!1,ze}}async function aa(s,u,p=[],y=[],A=[],$){const L=Z.value,G=$==="plan"?"plan":$==="default"?"default":O.value,re=u.trim(),he=[...p];if(he.length===0&&pe(re)){const pt=ce(s);pt&&he.push(pt)}const ze=y.map(pt=>({name:pt.name,path:pt.path})),ht=A.map(pt=>({...pt}));tn(s,{text:re,imageUrls:[...he],skills:ze,fileAttachments:ht,effort:L,collaborationMode:G,fallbackRetried:!1});try{if(we.value[s]!==!0){const Yt=await gu(s);xt(s,Yt.model)}const pt=Gt(s);let Tt="";try{Tt=await yu(s,u,he,pt||void 0,L||void 0,y.length>0?y:void 0,A,G)}catch(Yt){if(pt&&pt!==Fr&&$i(Yt))await Mn(s),tn(s,{text:re,imageUrls:[...he],skills:ze,fileAttachments:ht,effort:L,collaborationMode:G,fallbackRetried:!0}),Tt=await yu(s,u,he,Fr,L||void 0,y.length>0?y:void 0,A,G);else throw Yt}Tt&&(me.value={...me.value,[s]:Tt},br(s,Tt)),we.value={...we.value,[s]:!0},fe.add(s),await fr(),Qr(s)}catch(pt){throw pt}}async function sa(s){if(g.value[s]===!0)return;const u=h.value[s];if(!u||u.length===0)return;g.value={...g.value,[s]:!0};const[p,...y]=u;h.value=y.length>0?{...h.value,[s]:y}:Ct(h.value,s),Tr(),k.value=!0,J.value="",Ot=!0,rn(s,null),kt(s,{label:"Thinking",details:Sn(Gt(s),Z.value,p.collaborationMode)}),It(s,null),yt(s,!0);try{gr(p.collaborationMode),await aa(s,p.text,p.imageUrls,p.skills,p.fileAttachments)}catch{yt(s,!1),kt(s,null)}finally{g.value=Ct(g.value,s),k.value=!1}}async function pi(){const s=n.value;if(!s||f.value[s]!==!0||We.value[s]===!0)return;let u=me.value[s];if(!u){const{activeTurnId:p}=await uf(s);u=p,u&&(me.value={...me.value,[s]:u})}if(!u)throw new Error("Could not determine active turn id for interrupt");E.value=!0,J.value="";try{await Gb(s,u),yt(s,!1),kt(s,null),It(s,null),me.value[s]&&(me.value=Ct(me.value,s)),fe.add(s),Y=!0,await fr()}catch(p){const y=p instanceof Error?p.message:"Failed to interrupt active turn";It(s,y),J.value=y}finally{E.value=!1}}async function Nl(s){var G,re;const u=n.value;if(!u||oe.value||!s.trim())return;const p=r.value[u]??[],y=p.find(he=>he.turnId===s),A=typeof(y==null?void 0:y.turnIndex)=="number"?y.turnIndex:-1;if(A<0)return;const $=p.reduce((he,ze)=>typeof ze.turnIndex=="number"&&ze.turnIndex>he?ze.turnIndex:he,-1);if($<0||A>$)return;const L=$-A+1;if(!(L<1)){oe.value=!0,J.value="";try{const he=((re=(G=Sr.value)==null?void 0:G.cwd)==null?void 0:re.trim())??"";he&&await qb(u,s,he);const ze=await vu(u,L);Nn(u,ze),bn(u,[]),Ht(u),l.value[u]&&(l.value=Ct(l.value,u)),rn(u,null),kt(u,null),It(u,null),Y=!0,await fr()}catch(he){J.value=he instanceof Error?he.message:"Failed to rollback thread"}finally{oe.value=!1}}}let Aa=null;async function Ol(s,u){try{const p=await Fa(),y={...p.labels};let A=!1;for(const $ of p.order){if(Bo($)!==s)continue;const L=u.trim();L.length===0?y[$]!==void 0&&(delete y[$],A=!0):y[$]!==L&&(y[$]=L,A=!0)}A&&await wu({order:p.order,labels:y,active:p.active})}catch{}}function Dl(s,u){s.length===0||(Ae.value[s]??"")===u||(Ae.value={...Ae.value,[s]:u},Au(Ae.value),Aa!==null&&clearTimeout(Aa),Aa=setTimeout(()=>{Aa=null,Ol(s,u)},500))}async function Ll(s){var $;if(s.length===0)return;const u=X.value.filter(L=>L!==s);if(Vo(X.value,u)||(X.value=u,Da(X.value)),t.value=t.value.filter(L=>L.projectName!==s),Ae.value[s]!==void 0){const L={...Ae.value};delete L[s],Ae.value=L,Au(L)}Nt();const p=kr(e.value);vn(p),p.some(L=>L.id===n.value)||qt((($=p[0])==null?void 0:$.id)??"");const A=new Set;try{const L=await Fa();for(const G of L.order)Bo(G)===s&&A.add(G);for(const G of L.active)Bo(G)===s&&A.add(G);for(const G of Object.keys(L.labels))Bo(G)===s&&A.add(G)}catch{}if(A.size>0)try{const L=await Fa(),G=L.order.filter(ze=>!A.has(ze)),re=L.active.filter(ze=>!A.has(ze)),he=re.length===0&&G.length>0?[G[0]]:re;await wu({order:G,labels:Jx(L.labels,A),active:he});return}catch{}await gs()}function jl(s,u){if(s.length===0||t.value.length===0)return;const p=t.value.map(re=>re.projectName),y=p.indexOf(s);if(y===-1)return;const A=Math.max(0,Math.min(u,p.length-1)),$=Dx(p,y,A);if($===p)return;const L=Ri($,t.value);X.value=L,Da(X.value);const G=Eu(t.value,X.value);t.value=Oi(t.value,G),Nt(),gs()}function mi(s){const u=s.trim();if(!u)return;const p=[u,...X.value.filter(A=>A!==u)];if(Vo(X.value,p))return;X.value=p,Da(X.value);const y=Eu(t.value,X.value);t.value=Oi(t.value,y),Nt(),gs()}async function gs(){var s,u;try{const p=await Fa(),y=new Map;for(const L of p.order){const G=Bo(L);y.has(G)||y.set(G,L)}for(const L of t.value){const G=((u=(s=L.threads[0])==null?void 0:s.cwd)==null?void 0:u.trim())??"";G&&y.set(L.projectName,G)}const A=[];for(const L of X.value){const G=y.get(L);G&&!A.includes(G)&&A.push(G)}for(const L of p.order)A.includes(L)||A.push(L);const $=p.active.filter(L=>A.includes(L));$.length===0&&A.length>0&&$.push(A[0]),await wu({order:A,labels:p.labels,active:$})}catch{}}async function fr(){if(se.value){typeof window<"u"&&ge===null&&(ge=window.setTimeout(()=>{ge=null,fr()},Su));return}se.value=!0;const s=Y,u=new Set(fe);Y=!1,fe.clear();try{s&&await ra();const p=n.value;if(!p)return;const y=u.has(p),A=f.value[p]===!0,$=bt(p),L=He.value[p]??"";($.length>0&&$!==L||A&&ee.value[p]!==!0||y&&ee.value[p]!==!0||s&&ee.value[p]!==!0)&&await Ar(p,{silent:!0})}catch{}finally{se.value=!1,(Y||fe.size>0)&&typeof window<"u"&&ge===null&&(ge=window.setTimeout(()=>{ge=null,fr()},Su))}}async function Fl(){await gi(),Y=!ye.value,n.value&&ee.value[n.value]!==!0&&fe.add(n.value),await fr()}function Ul(){typeof window>"u"||Re||(gi(),Re=Pb(s=>{if(s.method==="ready"){Zr(),Fl();return}Sl(s),si(s)}))}async function gi(){try{const u=(await Nb()).map(p=>Dr(p)).filter(p=>p!==null);On(u)}catch{}}async function vi(s){try{return await $b(s.id,{result:s.result,error:s.error}),Tn(s.id),!0}catch(u){return J.value=u instanceof Error?u.message:"Failed to reply to server request",!1}}function Bl(){if(Re&&(Re(),Re=null),Y=!1,fe.clear(),pr.clear(),ge!==null&&typeof window<"u"&&(window.clearTimeout(ge),ge=null),Pe!==null&&typeof window<"u"&&(window.clearTimeout(Pe),Pe=null),Ye!==null&&typeof window<"u"&&(window.clearTimeout(Ye),Ye=null),typeof window<"u")for(const s of Ee.values())window.clearTimeout(s);Ee.clear(),Ot=!1,r.value={},a.value={},o.value={},i.value={},l.value={},c.value={},$e.value={},Ue.value={},Ke.value={},Ce.value={},me.value={},We.value={},nt.value={},Ve.value={},h.value={},g.value={},Tr(),ft.value=null,Ze.value={}}const yi=ie(()=>{const s=n.value;return s?h.value[s]??[]:[]});function vs(s){const u=n.value;if(!u)return;const p=h.value[u];if(!p)return;const y=p.filter(A=>A.id!==s);h.value=y.length>0?{...h.value,[u]:y}:Ct(h.value,u),Tr()}function ql(s,u){const p=n.value;if(!p)return;const y=h.value[p];if(!y)return;const A=y.findIndex(re=>re.id===s),$=y.findIndex(re=>re.id===u);if(A<0||$<0||A===$)return;const L=[...y],[G]=L.splice(A,1);L.splice($,0,G),h.value={...h.value,[p]:L},Tr()}function Hl(s){const u=n.value;if(!u)return;const p=h.value[u];if(!p)return;const y=p.find(A=>A.id===s);y&&(vs(s),gr(y.collaborationMode),hi(y.text,y.imageUrls,y.skills,"steer",y.fileAttachments))}function ys(s){qt(s)}return{projectGroups:e,projectDisplayNameById:Ae,selectedThread:Sr,selectedThreadTokenUsage:Vn,selectedThreadScrollState:mr,selectedThreadTerminalOpen:zn,isSelectedThreadInterruptPending:Cr,selectedThreadServerRequests:Ft,selectedLiveOverlay:lt,codexQuota:Pn,selectedThreadId:n,availableCollaborationModes:B,availableModelIds:j,selectedCollaborationMode:O,selectedModelId:V,selectedReasoningEffort:Z,selectedSpeedMode:xe,installedSkills:_e,accountRateLimitSnapshots:be,messages:Jr,isLoadingThreads:De,isLoadingMessages:Je,isSendingMessage:k,isInterruptingTurn:E,isUpdatingSpeedMode:H,isRollingBack:oe,error:J,refreshAll:ci,refreshSkills:ms,selectThread:Pl,loadMessages:Ar,ensureThreadMessagesLoaded:li,setThreadScrollState:an,setThreadTerminalOpen:sn,toggleSelectedThreadTerminal:Qn,archiveThreadById:Ml,renameThreadById:di,forkThreadById:Rl,forkThreadFromTurn:$l,rollbackSelectedThread:Nl,sendMessageToSelectedThread:hi,sendMessageToNewThread:oa,interruptSelectedThreadTurn:pi,selectedThreadQueuedMessages:yi,removeQueuedMessage:vs,reorderQueuedMessage:ql,steerQueuedMessage:Hl,setSelectedCollaborationMode:gr,readModelIdForThread:Gt,setSelectedModelIdForThread:Xt,setSelectedModelId:Ut,setSelectedReasoningEffort:Yr,updateSelectedSpeedMode:Gn,respondToPendingServerRequest:vi,renameProject:Dl,removeProject:Ll,reorderProject:jl,pinProjectToTop:mi,startPolling:Ul,stopPolling:Bl,primeSelectedThread:ys}}const rA={class:"sidebar-root"},oA={class:"sidebar-scrollable"},aA=["aria-pressed","aria-label","title"],sA={key:1,class:"sidebar-search-bar"},iA=["placeholder"],lA=["aria-label"],uA={class:"sidebar-skills-link-icon","aria-hidden":"true"},cA={class:"sidebar-skills-link-copy"},dA={class:"sidebar-skills-link-title"},fA={class:"sidebar-skills-link-subtitle"},hA={class:"sidebar-settings-account-section"},pA={class:"sidebar-settings-account-header"},mA={class:"sidebar-settings-account-header-main"},gA=["aria-expanded","title"],vA={class:"sidebar-settings-account-collapse-icon"},yA={class:"sidebar-settings-account-title"},wA={class:"sidebar-settings-account-count"},bA=["disabled"],_A={key:0,class:"sidebar-settings-account-error"},TA={key:1,class:"sidebar-settings-account-empty"},kA={key:2,class:"sidebar-settings-account-list"},SA=["title","onMouseenter","onMouseleave"],CA={class:"sidebar-settings-account-main"},xA={class:"sidebar-settings-account-email"},AA={class:"sidebar-settings-account-meta"},EA={class:"sidebar-settings-account-quota"},IA={class:"sidebar-settings-account-id"},PA={class:"sidebar-settings-account-actions"},MA=["disabled","onClick"],RA=["disabled","onClick"],$A=["title"],NA={class:"sidebar-settings-label"},OA=["title"],DA={class:"sidebar-settings-label"},LA={class:"sidebar-settings-value"},jA=["title"],FA={class:"sidebar-settings-label"},UA={class:"sidebar-settings-value"},BA=["title"],qA={class:"sidebar-settings-label"},HA=["value"],zA=["value"],VA=["title"],WA={class:"sidebar-settings-label"},GA={class:"sidebar-settings-value"},KA=["title"],JA={class:"sidebar-settings-label"},YA=["title"],QA={class:"sidebar-settings-label"},XA=["title"],ZA={class:"sidebar-settings-label"},eE=["value","disabled"],tE={key:0,class:"sidebar-settings-row sidebar-settings-error"},nE={key:1,class:"sidebar-settings-row sidebar-settings-row--input"},rE={class:"sidebar-settings-provider-info"},oE={class:"sidebar-settings-label"},aE={class:"sidebar-settings-provider-link",href:"https://openrouter.ai/keys",target:"_blank",rel:"noopener noreferrer"},sE={class:"sidebar-settings-key-group"},iE={class:"sidebar-settings-key-masked"},lE=["disabled","title"],uE=["placeholder"],cE=["disabled"],dE={class:"sidebar-settings-row sidebar-settings-row--select",style:{"margin-top":"4px",padding:"0"}},fE={class:"sidebar-settings-label"},hE=["aria-label"],pE=["disabled"],mE=["disabled"],gE={key:2,class:"sidebar-settings-row sidebar-settings-row--input"},vE={class:"sidebar-settings-provider-info"},yE={class:"sidebar-settings-label"},wE={class:"sidebar-settings-provider-link",href:"https://opencode.ai/auth",target:"_blank",rel:"noopener noreferrer"},bE={class:"sidebar-settings-key-group"},_E=["placeholder"],TE=["disabled"],kE={key:3,class:"sidebar-settings-row sidebar-settings-row--input"},SE={class:"sidebar-settings-label"},CE={class:"sidebar-settings-key-group"},xE=["placeholder"],AE={class:"sidebar-settings-label",style:{"margin-top":"4px"}},EE={class:"sidebar-settings-key-group"},IE=["placeholder"],PE=["disabled"],ME={class:"sidebar-settings-row sidebar-settings-row--select",style:{"margin-top":"4px",padding:"0"}},RE={class:"sidebar-settings-label"},$E=["aria-label"],NE=["title"],OE={class:"sidebar-settings-label"},DE={class:"sidebar-settings-label"},LE={class:"sidebar-settings-value"},jE={key:4,class:"sidebar-settings-telegram-panel"},FE={class:"sidebar-settings-field"},UE={class:"sidebar-settings-field-label"},BE={class:"sidebar-settings-field"},qE={class:"sidebar-settings-field-label"},HE={class:"sidebar-settings-field-help"},zE={key:0,class:"sidebar-settings-telegram-error"},VE={class:"sidebar-settings-telegram-actions"},WE=["disabled"],GE=["data-state","title"],KE={class:"sidebar-settings-label"},JE=["data-state"],YE={class:"sidebar-settings-context-meta"},QE={class:"sidebar-settings-rate-limits"},XE=["aria-label"],ZE={class:"sidebar-settings-button-version"},eI={key:0,class:"content-keyboard-spacer","aria-hidden":"true"},tI={key:1,class:"skills-route-header-icon","aria-hidden":"true"},nI=["aria-pressed","title","aria-label"],rI={class:"content-header-terminal-shortcut"},oI={class:"content-body"},aI={key:1,class:"content-grid content-grid-home"},sI={class:"new-thread-empty"},iI={class:"new-thread-hero"},lI=["title"],uI={class:"new-thread-folder-actions"},cI={key:1,class:"new-thread-launch-card","aria-label":"Plugins and Apps announcement"},dI={class:"new-thread-launch-card-copy"},fI={class:"new-thread-launch-card-topline"},hI={class:"new-thread-launch-card-badge","aria-hidden":"true"},pI={class:"new-thread-launch-card-eyebrow"},mI={class:"new-thread-launch-card-title"},gI={class:"new-thread-launch-card-text"},vI={class:"new-thread-launch-card-actions"},yI=["aria-label","onKeydown"],wI={class:"new-thread-open-folder-header"},bI={class:"new-thread-open-folder-title"},_I={class:"new-thread-open-folder-label"},TI={class:"new-thread-open-folder-current"},kI=["placeholder","title","disabled","onKeydown"],SI=["disabled"],CI={class:"new-thread-open-folder-actions"},xI={class:"new-thread-open-folder-toggle"},AI=["aria-pressed","disabled"],EI={key:0,class:"new-thread-open-folder-create"},II={class:"new-thread-open-folder-create-composer"},PI=["placeholder","onKeydown"],MI=["disabled"],RI={key:0,class:"new-thread-open-folder-error"},$I=["placeholder","onKeydown"],NI={key:1,class:"new-thread-open-folder-error-actions"},OI={class:"new-thread-open-folder-error"},DI=["disabled"],LI={key:2,class:"new-thread-open-folder-status"},jI={key:3,class:"new-thread-open-folder-status"},FI={key:4,class:"new-thread-open-folder-list"},UI=["title","disabled","onClick"],BI={class:"new-thread-open-folder-item-name"},qI=["disabled","onClick"],HI={key:2,class:"new-thread-branch-select"},zI={class:"new-thread-branch-select-label"},VI={class:"new-thread-branch-select-help"},WI={class:"new-thread-runtime-help"},GI={class:"worktree-init-status-title"},KI={class:"worktree-init-status-message"},JI={class:"composer-with-queue"},YI={key:2,class:"content-grid"},QI={class:"content-thread"},XI={class:"composer-with-queue"},Uf="codex-web-local.sidebar-collapsed.v1",Bf="codex-web-local.accounts-section-collapsed.v1",qf="codex-web-local.send-with-enter.v1",Hf="codex-web-local.in-progress-send-mode.v1",zf="codex-web-local.dark-mode.v1",Vf="codex-web-local.dictation-click-to-toggle.v1",Wf="codex-web-local.dictation-auto-send.v1",Gf="codex-web-local.dictation-language.v1",Kf="codex-web-local.chat-width.v1",ZI=400,eP=Bn({__name:"App",setup(e){var qc,Hc;const t=xi(()=>Ei(()=>import("./ThreadConversation-CSH0aUWx.js"),__vite__mapDeps([0,1]))),n=xi(()=>Ei(()=>import("./ThreadTerminalPanel-QkJZ7U3Y.js"),__vite__mapDeps([2,3]))),r=xi(()=>Ei(()=>import("./ReviewPane-W_UvYmui.js"),__vite__mapDeps([4,5]))),a=xi(()=>Ei(()=>import("./DirectoryHub-47WzZs4I.js"),__vite__mapDeps([6,7]))),{t:o,uiLanguage:i,uiLanguageOptions:l,setUiLanguage:c}=Qo(),f="ed73",h="0.1.84",g={sendWithEnter:o("When enabled, press Enter to send. When disabled, use Command+Enter to send."),inProgressSendMode:o("If a turn is still running, choose whether a new prompt should steer the current turn or be queued."),appearance:o("Switch between system theme, light mode, and dark mode."),chatWidth:o("Choose how wide the conversation column and composer can grow on desktop screens."),dictationClickToToggle:o("Use click-to-start and click-to-stop dictation instead of hold-to-talk."),dictationAutoSend:o("Automatically send transcribed dictation when recording stops."),dictationLanguage:o("Choose transcription language or keep auto-detect.")},b={standard:{label:"Standard",columnMax:"45rem",cardMax:"76ch"},wide:{label:"Wide",columnMax:"72rem",cardMax:"88ch"},"extra-wide":{label:"Extra wide",columnMax:"96rem",cardMax:"96ch"}},x={en:"english",zh:"chinese",de:"german",es:"spanish",ru:"russian",ko:"korean",fr:"french",ja:"japanese",pt:"portuguese",tr:"turkish",pl:"polish",ca:"catalan",nl:"dutch",ar:"arabic",sv:"swedish",it:"italian",id:"indonesian",hi:"hindi",fi:"finnish",vi:"vietnamese",he:"hebrew",uk:"ukrainian",el:"greek",ms:"malay",cs:"czech",ro:"romanian",da:"danish",hu:"hungarian",ta:"tamil",no:"norwegian",th:"thai",ur:"urdu",hr:"croatian",bg:"bulgarian",lt:"lithuanian",la:"latin",mi:"maori",ml:"malayalam",cy:"welsh",sk:"slovak",te:"telugu",fa:"persian",lv:"latvian",bn:"bengali",sr:"serbian",az:"azerbaijani",sl:"slovenian",kn:"kannada",et:"estonian",mk:"macedonian",br:"breton",eu:"basque",is:"icelandic",hy:"armenian",ne:"nepali",mn:"mongolian",bs:"bosnian",kk:"kazakh",sq:"albanian",sw:"swahili",gl:"galician",mr:"marathi",pa:"punjabi",si:"sinhala",km:"khmer",sn:"shona",yo:"yoruba",so:"somali",af:"afrikaans",oc:"occitan",ka:"georgian",be:"belarusian",tg:"tajik",sd:"sindhi",gu:"gujarati",am:"amharic",yi:"yiddish",lo:"lao",uz:"uzbek",fo:"faroese",ht:"haitian creole",ps:"pashto",tk:"turkmen",nn:"nynorsk",mt:"maltese",sa:"sanskrit",lb:"luxembourgish",my:"myanmar",bo:"tibetan",tl:"tagalog",mg:"malagasy",as:"assamese",tt:"tatar",haw:"hawaiian",ln:"lingala",ha:"hausa",ba:"bashkir",jw:"javanese",su:"sundanese",yue:"cantonese"},{projectGroups:j,projectDisplayNameById:B,selectedThread:te,selectedThreadTokenUsage:z,selectedThreadScrollState:O,selectedThreadTerminalOpen:V,selectedThreadServerRequests:Z,selectedLiveOverlay:xe,codexQuota:Fe,selectedThreadId:ne,availableCollaborationModes:ke,availableModelIds:X,selectedCollaborationMode:Ae,selectedReasoningEffort:He,selectedSpeedMode:ee,installedSkills:we,accountRateLimitSnapshots:$e,messages:Ke,isLoadingThreads:Ue,isLoadingMessages:Ce,isSendingMessage:me,isInterruptingTurn:We,isSelectedThreadInterruptPending:nt,isUpdatingSpeedMode:Ve,refreshAll:Le,refreshSkills:dt,selectThread:ft,ensureThreadMessagesLoaded:Ze,setThreadScrollState:ct,setThreadTerminalOpen:K,toggleSelectedThreadTerminal:_e,archiveThreadById:be,forkThreadById:De,renameThreadById:Je,forkThreadFromTurn:k,sendMessageToSelectedThread:E,sendMessageToNewThread:H,interruptSelectedThreadTurn:oe,selectedThreadQueuedMessages:J,removeQueuedMessage:se,reorderQueuedMessage:ye,steerQueuedMessage:de,setSelectedCollaborationMode:pe,readModelIdForThread:ce,setSelectedModelIdForThread:Re,setSelectedReasoningEffort:ge,updateSelectedSpeedMode:Pe,respondToPendingServerRequest:Ee,renameProject:Xe,removeProject:D,reorderProject:F,pinProjectToTop:U,startPolling:Y,stopPolling:fe,primeSelectedThread:Me,rollbackSelectedThread:Be}=nA(),Ye=Rw(),Ne=Mw(),{isMobile:vt}=Cc(),Hn=I(null),mn=I(null),go=I(null),Ot=I(!1),pr=I(!1),ir=I(!1),Kr=I(!0),Sr=I(null),mr=I(!1),zn=I("");let Cr=!1;const Ft=I(!1),lt=I(""),Pn=I("local"),Vn=I(""),Jr=I([]),Gt=I(!1),Wn=I({order:[],labels:{}}),qt=I({phase:"idle",title:"",message:""}),Xt=I(Pm()),Ut=I(""),xt=I(!1),Kt=I(null),gr=I(null),lr=I(null),Mr=I(null),Mn=I(null);let tn=null,vr=null;const ur=I("New Project (1)"),Yr=I(""),Gn=I(!1),Rn=I(Rm()),Sn=I(!1),Kn=I([]),nn=I(null),xr=I(!1),Cn=I(!1),Qr=I(null),gn=I([]),cr=I(!1),Jn=I(!1),yr=I(""),Nt=I(""),$n=I(""),vn=I(""),yn=I(Gl(qf,!0)),rn=I(vm()),yt=I(gm()),wr=I(ym()),on=I(Gl(Vf,!1)),Yn=I(Gl(Wf,!0)),br=I(Em()),Rr=ie(()=>Im()),Xr=I(!1),wn=I(!1),kt=I(!1),It=I(""),vo=I(!1),Zr=I(null),bt=I(!1),an=I(""),sn=I("codex"),Qn=I(""),Nn=I(""),bn=I("responses"),Xn=I("responses"),_r=I(""),M=I(!1),q=I(""),Q=I(""),Ie=I(""),St=I(!1),Zt=I(!1),Ht=I(""),mt=I(""),Jt=I(!1),dn=I(!1),$r=I(null),No=I(null),Nr=I(""),Zn=I(""),qe=I(""),Se=I([]),Dt=I(""),_n=I(!1),xn=I(!1),Xo=I(!1),zt=I(""),dr=I({configured:!1,active:!1,mappedChats:0,mappedThreads:0,allowedUsers:0,allowAllUsers:!1,lastError:""}),Or=I(null),Dr=I(!1),eo=I(!1),to=I(typeof window<"u"?((qc=window.visualViewport)==null?void 0:qc.height)??window.innerHeight:0),w=I(typeof window<"u"?((Hc=window.visualViewport)==null?void 0:Hc.offsetTop)??0:0),_=I(typeof window<"u"?window.innerHeight:0);let S=null,W=!1,je=0;const _t=ie(()=>{const d=Ye.params.threadId;return typeof d=="string"?d:""}),wt=ie(()=>Ye.name==="home"),Tn=ie(()=>Ye.name==="skills"),On=ie(()=>{var d;return Tn.value?o("Skills"):wt.value?o("Start new thread"):((d=te.value)==null?void 0:d.title)??o("Choose a thread")}),er=typeof window<"u"&&(window.location.hostname||window.location.host)||"codexui",Lr=ie(()=>{var v,P;return(((P=(v=te.value)==null?void 0:v.title)==null?void 0:P.trim())??"")||er}),jr=ie(()=>Ke.value.filter(d=>{const v=Nm(d.messageType,d.role);return v==="worked"?!0:!(v==="turnActivity.live"||v==="turnError.live"||v==="agentReasoning.live")})),Zo=ie(()=>xe.value),Oo=ie(()=>wt.value?"__new-thread__":ne.value),Sa=ie(()=>ce(Oo.value)),ti=ie(()=>{const d=Z.value;return d.length>0?d[d.length-1]:null}),An=ie(()=>{var d,v;return wt.value?lt.value.trim():((v=(d=te.value)==null?void 0:d.cwd)==null?void 0:v.trim())??""}),ml=ie(()=>Kr.value&&(wt.value&&An.value.length>0||Ye.name==="thread"&&ne.value.length>0)),is=ie(()=>wt.value?Ot.value:V.value),Ca=ie(()=>!vt.value||to.value<=0||_.value<=0?!1:_.value-to.value>120),gl=ie(()=>Ca.value||is.value&&ir.value),ni=ie(()=>{var d,v;return((v=(d=te.value)==null?void 0:d.cwd)==null?void 0:v.trim())??lt.value.trim()}),ls=ie(()=>{var d;return!wt.value&&((d=te.value)==null?void 0:d.inProgress)===!0}),vl=ie(()=>!wt.value&&!Tn.value&&ne.value.trim().length>0),us=ie(()=>me.value||We.value||ls.value||Z.value.length>0);function xa(d){return Number.isFinite(d)?new Intl.NumberFormat("en-US",{notation:d>=1e3?"compact":"standard",maximumFractionDigits:d>=1e5?0:1}).format(Math.max(0,Math.trunc(d))):"0"}function yl(d){if(!d)return o("Waiting for Codex thread/tokenUsage/updated events for this thread.");const v=[`${o("Current context usage")}: ${d.currentContextTokens.toLocaleString()} ${o("tokens")}`,`${o("Cumulative thread usage")}: ${d.total.totalTokens.toLocaleString()} ${o("tokens")}`];return typeof d.modelContextWindow=="number"?(v.unshift(`${o("Model context window")}: ${d.modelContextWindow.toLocaleString()} ${o("tokens")}`),v.push(`${o("Remaining context")}: ${(d.remainingContextTokens??0).toLocaleString()} ${o("tokens")}`)):v.push(o("Model context window is unavailable in the latest usage event.")),v.join(`
56
+ `)}ls(s);const ia=oi(s);ia&&(ea(y,ia),kt(y,{label:"Running command",details:[((ua=ia.commandExecution)==null?void 0:ua.command)??""]}));const Do=bl(s);if(Do){const tt=(l.value[y]??[]).find(hr=>hr.id===Do.itemId);tt!=null&&tt.commandExecution&&ea(y,{...tt,commandExecution:{...tt.commandExecution,aggregatedOutput:`${tt.commandExecution.aggregatedOutput}${Do.delta}`}})}const la=_l(s);la&&ea(y,la);const bs=Tl(s);if(bs&&Ie(y,bs),kl(s)&&(Ot&&n.value&&an(n.value,{scrollTop:0,isAtBottom:!0,scrollRatio:1}),Ht(y)),s.method==="turn/completed"){Ot=!1,Ht(y),l.value[y]&&(l.value=Ct(l.value,y));const tt=zt(s);tt&&(yt(tt,!1),kt(tt,null),wn(tt),ze||(vr(tt),sa(tt)))}}function si(s){if(s.method==="thread/tokenUsage/updated")return;const u=s.method,p=u==="turn/started"||u==="turn/completed"||u==="error",y=u.startsWith("thread/")||u==="turn/completed";if(!p&&!y)return;const A=zt(s);A&&p&&fe.add(A),y&&(Y=!0),!(ge!==null||typeof window>"u")&&(ge=window.setTimeout(()=>{ge=null,fr()},Su))}async function ii(s,u){if(!go){go=!0;try{if(!u)return;const p=[];for(const y of u.order){const A=Bo(y);p.includes(A)||p.push(A)}if(p.length>0){const y=Ri(p,s);Vo(X.value,y)||(X.value=y,Da(X.value))}if(Object.keys(u.labels).length>0){const y={...Ae.value};let A=!1;for(const[$,L]of Object.entries(u.labels)){const G=Bo($);y[G]!==L&&(y[G]=L,A=!0)}A&&(Ae.value=y,Au(y))}}catch{}}}async function Cl(){if(!(Object.keys(K.value).length>0))try{const s=await y0();Object.keys(s.titles).length>0&&(K.value=s.titles)}catch{}}async function ta(){try{return await Fa()}catch{return null}}async function xl(s,u,p){if(K.value[s])return;const y=u.trim();if(!y)return;const A=y.length>300?y.slice(0,300):y;try{const $=await k0(A,p);if(!$||K.value[s])return;K.value={...K.value,[s]:$},Nt(),_u(s,$)}catch{}}function Al(s,u){if(!u||u.order.length===0)return s;const p=new Set(u.order.map(y=>Bo(y)));return s.filter(y=>p.has(y.projectName)?!0:y.threads.some(A=>Ji(A.cwd)))}function ds(s,u){const p=Al(s,u),y=Ri(X.value,p);Vo(X.value,y)||(X.value=y,Da(X.value));const A=Eu(p,X.value);Rr(new Set(kr(A).map(L=>L.id)));const $=Zx(t.value,A,f.value);t.value=Oi(t.value,$),f.value=Qt(f.value,new Set(kr(t.value).map(L=>L.id))),Nt()}function fs(s){const u={};for(const[p,y]of Object.entries(s)){const A=p.trim();!A||y.length===0||(u[A]=y.map($=>({id:$.id,text:$.text,imageUrls:[...$.imageUrls],skills:$.skills.map(L=>({name:L.name,path:L.path})),fileAttachments:$.fileAttachments.map(L=>({label:L.label,path:L.path,fsPath:L.fsPath})),collaborationMode:$.collaborationMode})))}return u}function Tr(){o0(fs(h.value)).catch(()=>{})}async function El(){if(!b){b=!0;try{h.value=await r0()}catch{}}}function hs(s,u){if(s.length===0)return u;if(u.length===0)return s;const p=new Map;for(const A of kr(s))p.set(A.id,A);for(const A of kr(u))p.set(A.id,A);const y=new Map;for(const A of p.values()){const $=y.get(A.projectName);$?$.push(A):y.set(A.projectName,[A])}return Array.from(y.entries()).map(([A,$])=>({projectName:A,threads:$.sort((L,G)=>new Date(G.updatedAtIso).getTime()-new Date(L.updatedAtIso).getTime())})).sort((A,$)=>{var re,he;const L=new Date(((re=A.threads[0])==null?void 0:re.updatedAtIso)??0).getTime();return new Date(((he=$.threads[0])==null?void 0:he.updatedAtIso)??0).getTime()-L})}function na(){return Object.values(f.value).some(s=>s===!0)}function ps(s=mn){if(!(!Be||Ne||na())){if(mn=s,typeof window>"u"){no(s);return}Ye!==null&&window.clearTimeout(Ye),Ye=window.setTimeout(()=>{Ye=null,!(!Be||na())&&no(mn)},wx)}}async function no(s){if(!(Ne||!Be||na())){Ne=!0;try{const u=await lf(Be,Tb());Be=u.nextCursor,vt=u.nextCursor===null,Hn=hs(Hn,u.groups),ds(Hn,s)}catch{}finally{Ne=!1,Be&&!na()&&ps(s)}}}async function ra(){if(Xe){await Xe;return}Xe=(async()=>{var s;ye.value||(De.value=!0);try{const[u,p]=await Promise.all([lf(),ta(),Cl()]);mn=p;const y=u.groups;Hn=ye.value?hs(Hn,y):y,Be=ye.value&&!vt?Be:u.nextCursor,vt=u.nextCursor===null,await ii(y,p),ds(Hn,p),ye.value=!0,vt||ps(p);const A=kr(e.value);vn(A),!A.some(L=>L.id===n.value)&&!n.value&&qt(((s=A[0])==null?void 0:s.id)??"")}finally{De.value=!1}})().finally(()=>{Xe=null}),await Xe}async function Ar(s,u={}){if(!s)return;const p=D.get(s);if(p){await p;return}const y=ee.value[s]===!0,A=u.silent!==!0&&!y;A&&(Je.value=!0);const $=(async()=>{try{const L=bt(s),G=He.value[s]??"",re=Date.now()-(Me.get(s)??0)<Tx;if(y&&(re||(L.length===0||G===L)&&f.value[s]!==!0)){yn(s);return}const ht=we.value[s]!==!0?await gu(s):null,pt=ht??await uf(s);ht&&(xt(s,ht.model),we.value={...we.value,[s]:!0});const{messages:Tt,inProgress:Yt,activeTurnId:ro,turnIndexByTurnId:Ea}=pt;Xr(s,Tt),ml(s,Ea),is(s);const ws=r.value[s]??[],ia=Ux(ws,Tt,{preserveMissing:u.silent===!0});Nn(s,ia);const Do=o.value[s]??[];if(Yt){const la=qx(Do,Tt);bn(s,la)}else Xn(s);cs(s,Tt),ai(s,Tt),ee.value={...ee.value,[s]:!0},Me.set(s,Date.now()),L&&(He.value={...He.value,[s]:L}),yt(s,Yt),ro?me.value={...me.value,[s]:ro}:me.value[s]&&(me.value=Ct(me.value,s)),Yt||dn(s),yn(s)}finally{A&&(Je.value=!1)}})().finally(()=>{D.delete(s)});D.set(s,$),await $}async function li(s,u={}){s&&ee.value[s]!==!0&&await Ar(s,u)}async function ms(){if(F){await F;return}F=(async()=>{var s,u;try{const p=((u=(s=Sr.value)==null?void 0:s.cwd)==null?void 0:u.trim())??"";_e.value=await C0(p?[p]:void 0)}catch{}finally{F=null}})(),await F}async function ui(s={}){await Promise.allSettled([Kn({providerChanged:s.providerChanged,includeProviderModels:s.includeProviderModels}),nn(),Rn(),ms()])}function Il(s={}){const u=()=>{ui(s)};if(typeof window>"u"){u();return}window.setTimeout(u,0)}async function ci(s={}){J.value="";const u=s.includeSelectedThreadMessages!==!1,p=s.awaitAncillaryRefreshes===!0;try{await El(),await ra(),u&&await Ar(n.value),p?await ui({providerChanged:s.providerChanged,includeProviderModels:s.providerChanged===!0||p}):Il({providerChanged:s.providerChanged,includeProviderModels:!1})}catch(y){J.value=y instanceof Error?y.message:"Unknown application error"}}async function Pl(s){qt(s);try{await Ar(s),ms()}catch(u){J.value=u instanceof Error?u.message:"Unknown application error"}}async function Ml(s){try{await Ub(s),await ra(),n.value===s&&await Ar(n.value)}catch(u){J.value=u instanceof Error?u.message:"Unknown application error"}}async function di(s,u){const p=u.trim();if(!(!s||!p))try{await Bb(s,p),K.value={...K.value,[s]:p},Nt(),_u(s,p)}catch(y){J.value=y instanceof Error?y.message:"Unknown application error"}}async function Rl(s){var L,G;const u=s.trim();if(!u)return"";const p=kr(t.value).find(re=>re.id===u),y=((L=p==null?void 0:p.cwd)==null?void 0:L.trim())??"",A=((G=p==null?void 0:p.title)==null?void 0:G.trim())??"Forked chat",$=Gt(u);J.value="";try{const re=await hf(u,y||void 0,$||void 0),he=re.threadId.trim();return he?($n(he,y,A),xt(he,re.model),we.value={...we.value,[he]:!0},qt(he),await ra(),await Ar(he),he):""}catch(re){return J.value=re instanceof Error?re.message:"Unknown application error",""}}async function $l(s,u){var L;const p=s.trim();if(!p||!Number.isInteger(u)||u<0)return"";if(f.value[p]===!0)return J.value="Finish the current turn before forking from a response.","";if(ee.value[p]!==!0)try{await Ar(p)}catch(G){return J.value=G instanceof Error?G.message:"Unknown application error",""}const y=r.value[p]??[];let A=-1;for(const G of y)typeof G.turnIndex=="number"&&Number.isFinite(G.turnIndex)&&(A=Math.max(A,G.turnIndex));if(A>=0&&u>A)return"";const $=kr(t.value).find(G=>G.id===p)??null;try{J.value="";const G=await hf(p),re=G.threadId.trim();if(!re)return"";const he=G.cwd.trim()||((L=$==null?void 0:$.cwd)==null?void 0:L.trim())||"",ze=tA(($==null?void 0:$.title)||($==null?void 0:$.preview)||"Untitled thread");$n(re,he,ze),xt(re,G.model),Nn(re,G.messages),ee.value={...ee.value,[re]:!0},we.value={...we.value,[re]:!0},mt(re),bn(re,[]),Ht(re),l.value[re]&&(l.value=Ct(l.value,re)),rn(re,null),kt(re,null),It(re,null),yt(re,!1);const ht=A-u;if(ht>0){const pt=await vu(re,ht);Nn(re,pt)}return await di(re,ze),qt(re),ra().catch(()=>{}),re}catch(G){return J.value=G instanceof Error?G.message:"Unknown application error",""}}async function fi(s,u,p=[],y=[],A=[]){if(!s||!u.trim()||p.length>0||y.length>0||A.length>0)return!1;const L=(Le.value[s]??[]).filter(he=>he.method==="item/tool/requestUserInput");if(L.length!==1)return!1;const[G]=L,re=_t(G);return re.length!==1?!1:vi({id:G.id,result:{answers:{[re[0]]:{answers:[u.trim()]}}}})}async function hi(s,u=[],p=[],y="steer",A=[],$,L){if(H.value)return;const G=n.value,re=s.trim();if(!G||!re&&u.length===0&&A.length===0||await fi(G,re,u,p,A))return;const he=f.value[G]===!0;if(he&&y==="queue"){const ze=h.value[G]??[],ht=`q-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,pt=[...ze],Tt=typeof $=="number"?Math.max(0,Math.min($,pt.length)):pt.length;pt.splice(Tt,0,{id:ht,text:re,imageUrls:u,skills:p,fileAttachments:A,collaborationMode:L==="plan"?"plan":L==="default"?"default":O.value}),h.value={...h.value,[G]:pt},Tr();return}if(he){Ot=!0,aa(G,re,u,p,A,L).catch(ze=>{const ht=ze instanceof Error?ze.message:"Unknown application error";It(G,ht),J.value=ht});return}J.value="",Ot=!0,rn(G,null),kt(G,{label:"Thinking",details:Sn(Gt(G),Z.value,L==="plan"?"plan":L==="default"?"default":O.value)}),It(G,null),yt(G,!0);try{await aa(G,re,u,p,A,L)}catch(ze){Ot=!1,yt(G,!1),kt(G,null);const ht=ze instanceof Error?ze.message:"Unknown application error";throw It(G,ht),J.value=ht,ze}}async function oa(s,u,p=[],y=[],A=[]){if(H.value)return"";const $=s.trim(),L=u.trim(),G=Gt(xo).trim(),re=As(te.value,xo);if(!$&&p.length===0&&A.length===0)return"";k.value=!0,J.value="";let he="";try{try{const Tt=await ff(L||void 0,G||void 0);he=Tt.threadId,xt(he,Tt.model),lr(he,re)}catch(Tt){if(G&&G!==Fr&&$i(Tt)){await Mn();const Yt=await ff(L||void 0,Fr);he=Yt.threadId,xt(he,Yt.model),lr(he,re)}else throw Tt}if(!he)return"";$n(he,L,$||"[Image]"),on(he),we.value={...we.value,[he]:!0},qt(he),Ot=!0,rn(he,null),kt(he,{label:"Thinking",details:Sn(Gt(he),Z.value,re)}),It(he,null),yt(he,!0);const ze=he,ht=L||null,pt=$;return aa(he,$,p,y,A,re).catch(Tt=>{Ot=!1,yt(he,!1),kt(he,null);const Yt=Tt instanceof Error?Tt.message:"Unknown application error";It(he,Yt),J.value=Yt}).finally(()=>{k.value=!1}),xl(ze,pt,ht),he}catch(ze){Ot=!1,he&&(yt(he,!1),kt(he,null));const ht=ze instanceof Error?ze.message:"Unknown application error";throw he&&It(he,ht),J.value=ht,k.value=!1,ze}}async function aa(s,u,p=[],y=[],A=[],$){const L=Z.value,G=$==="plan"?"plan":$==="default"?"default":O.value,re=u.trim(),he=[...p];if(he.length===0&&pe(re)){const pt=ce(s);pt&&he.push(pt)}const ze=y.map(pt=>({name:pt.name,path:pt.path})),ht=A.map(pt=>({...pt}));tn(s,{text:re,imageUrls:[...he],skills:ze,fileAttachments:ht,effort:L,collaborationMode:G,fallbackRetried:!1});try{if(we.value[s]!==!0){const Yt=await gu(s);xt(s,Yt.model)}const pt=Gt(s);let Tt="";try{Tt=await yu(s,u,he,pt||void 0,L||void 0,y.length>0?y:void 0,A,G)}catch(Yt){if(pt&&pt!==Fr&&$i(Yt))await Mn(s),tn(s,{text:re,imageUrls:[...he],skills:ze,fileAttachments:ht,effort:L,collaborationMode:G,fallbackRetried:!0}),Tt=await yu(s,u,he,Fr,L||void 0,y.length>0?y:void 0,A,G);else throw Yt}Tt&&(me.value={...me.value,[s]:Tt},br(s,Tt)),we.value={...we.value,[s]:!0},fe.add(s),await fr(),Qr(s)}catch(pt){throw pt}}async function sa(s){if(g.value[s]===!0)return;const u=h.value[s];if(!u||u.length===0)return;g.value={...g.value,[s]:!0};const[p,...y]=u;h.value=y.length>0?{...h.value,[s]:y}:Ct(h.value,s),Tr(),k.value=!0,J.value="",Ot=!0,rn(s,null),kt(s,{label:"Thinking",details:Sn(Gt(s),Z.value,p.collaborationMode)}),It(s,null),yt(s,!0);try{gr(p.collaborationMode),await aa(s,p.text,p.imageUrls,p.skills,p.fileAttachments)}catch{yt(s,!1),kt(s,null)}finally{g.value=Ct(g.value,s),k.value=!1}}async function pi(){const s=n.value;if(!s||f.value[s]!==!0||We.value[s]===!0)return;let u=me.value[s];if(!u){const{activeTurnId:p}=await uf(s);u=p,u&&(me.value={...me.value,[s]:u})}if(!u)throw new Error("Could not determine active turn id for interrupt");E.value=!0,J.value="";try{await Gb(s,u),yt(s,!1),kt(s,null),It(s,null),me.value[s]&&(me.value=Ct(me.value,s)),fe.add(s),Y=!0,await fr()}catch(p){const y=p instanceof Error?p.message:"Failed to interrupt active turn";It(s,y),J.value=y}finally{E.value=!1}}async function Nl(s){var G,re;const u=n.value;if(!u||oe.value||!s.trim())return;const p=r.value[u]??[],y=p.find(he=>he.turnId===s),A=typeof(y==null?void 0:y.turnIndex)=="number"?y.turnIndex:-1;if(A<0)return;const $=p.reduce((he,ze)=>typeof ze.turnIndex=="number"&&ze.turnIndex>he?ze.turnIndex:he,-1);if($<0||A>$)return;const L=$-A+1;if(!(L<1)){oe.value=!0,J.value="";try{const he=((re=(G=Sr.value)==null?void 0:G.cwd)==null?void 0:re.trim())??"";he&&await qb(u,s,he);const ze=await vu(u,L);Nn(u,ze),bn(u,[]),Ht(u),l.value[u]&&(l.value=Ct(l.value,u)),rn(u,null),kt(u,null),It(u,null),Y=!0,await fr()}catch(he){J.value=he instanceof Error?he.message:"Failed to rollback thread"}finally{oe.value=!1}}}let Aa=null;async function Ol(s,u){try{const p=await Fa(),y={...p.labels};let A=!1;for(const $ of p.order){if(Bo($)!==s)continue;const L=u.trim();L.length===0?y[$]!==void 0&&(delete y[$],A=!0):y[$]!==L&&(y[$]=L,A=!0)}A&&await wu({order:p.order,labels:y,active:p.active})}catch{}}function Dl(s,u){s.length===0||(Ae.value[s]??"")===u||(Ae.value={...Ae.value,[s]:u},Au(Ae.value),Aa!==null&&clearTimeout(Aa),Aa=setTimeout(()=>{Aa=null,Ol(s,u)},500))}async function Ll(s){var $;if(s.length===0)return;const u=X.value.filter(L=>L!==s);if(Vo(X.value,u)||(X.value=u,Da(X.value)),t.value=t.value.filter(L=>L.projectName!==s),Ae.value[s]!==void 0){const L={...Ae.value};delete L[s],Ae.value=L,Au(L)}Nt();const p=kr(e.value);vn(p),p.some(L=>L.id===n.value)||qt((($=p[0])==null?void 0:$.id)??"");const A=new Set;try{const L=await Fa();for(const G of L.order)Bo(G)===s&&A.add(G);for(const G of L.active)Bo(G)===s&&A.add(G);for(const G of Object.keys(L.labels))Bo(G)===s&&A.add(G)}catch{}if(A.size>0)try{const L=await Fa(),G=L.order.filter(ze=>!A.has(ze)),re=L.active.filter(ze=>!A.has(ze)),he=re.length===0&&G.length>0?[G[0]]:re;await wu({order:G,labels:Jx(L.labels,A),active:he});return}catch{}await gs()}function jl(s,u){if(s.length===0||t.value.length===0)return;const p=t.value.map(re=>re.projectName),y=p.indexOf(s);if(y===-1)return;const A=Math.max(0,Math.min(u,p.length-1)),$=Dx(p,y,A);if($===p)return;const L=Ri($,t.value);X.value=L,Da(X.value);const G=Eu(t.value,X.value);t.value=Oi(t.value,G),Nt(),gs()}function mi(s){const u=s.trim();if(!u)return;const p=[u,...X.value.filter(A=>A!==u)];if(Vo(X.value,p))return;X.value=p,Da(X.value);const y=Eu(t.value,X.value);t.value=Oi(t.value,y),Nt(),gs()}async function gs(){var s,u;try{const p=await Fa(),y=new Map;for(const L of p.order){const G=Bo(L);y.has(G)||y.set(G,L)}for(const L of t.value){const G=((u=(s=L.threads[0])==null?void 0:s.cwd)==null?void 0:u.trim())??"";G&&y.set(L.projectName,G)}const A=[];for(const L of X.value){const G=y.get(L);G&&!A.includes(G)&&A.push(G)}for(const L of p.order)A.includes(L)||A.push(L);const $=p.active.filter(L=>A.includes(L));$.length===0&&A.length>0&&$.push(A[0]),await wu({order:A,labels:p.labels,active:$})}catch{}}async function fr(){if(se.value){typeof window<"u"&&ge===null&&(ge=window.setTimeout(()=>{ge=null,fr()},Su));return}se.value=!0;const s=Y,u=new Set(fe);Y=!1,fe.clear();try{s&&await ra();const p=n.value;if(!p)return;const y=u.has(p),A=f.value[p]===!0,$=bt(p),L=He.value[p]??"";($.length>0&&$!==L||A&&ee.value[p]!==!0||y&&ee.value[p]!==!0||s&&ee.value[p]!==!0)&&await Ar(p,{silent:!0})}catch{}finally{se.value=!1,(Y||fe.size>0)&&typeof window<"u"&&ge===null&&(ge=window.setTimeout(()=>{ge=null,fr()},Su))}}async function Fl(){await gi(),Y=!ye.value,n.value&&ee.value[n.value]!==!0&&fe.add(n.value),await fr()}function Ul(){typeof window>"u"||Re||(gi(),Re=Pb(s=>{if(s.method==="ready"){Zr(),Fl();return}Sl(s),si(s)}))}async function gi(){try{const u=(await Nb()).map(p=>Dr(p)).filter(p=>p!==null);On(u)}catch{}}async function vi(s){try{return await $b(s.id,{result:s.result,error:s.error}),Tn(s.id),!0}catch(u){return J.value=u instanceof Error?u.message:"Failed to reply to server request",!1}}function Bl(){if(Re&&(Re(),Re=null),Y=!1,fe.clear(),pr.clear(),ge!==null&&typeof window<"u"&&(window.clearTimeout(ge),ge=null),Pe!==null&&typeof window<"u"&&(window.clearTimeout(Pe),Pe=null),Ye!==null&&typeof window<"u"&&(window.clearTimeout(Ye),Ye=null),typeof window<"u")for(const s of Ee.values())window.clearTimeout(s);Ee.clear(),Ot=!1,r.value={},a.value={},o.value={},i.value={},l.value={},c.value={},$e.value={},Ue.value={},Ke.value={},Ce.value={},me.value={},We.value={},nt.value={},Ve.value={},h.value={},g.value={},Tr(),ft.value=null,Ze.value={}}const yi=ie(()=>{const s=n.value;return s?h.value[s]??[]:[]});function vs(s){const u=n.value;if(!u)return;const p=h.value[u];if(!p)return;const y=p.filter(A=>A.id!==s);h.value=y.length>0?{...h.value,[u]:y}:Ct(h.value,u),Tr()}function ql(s,u){const p=n.value;if(!p)return;const y=h.value[p];if(!y)return;const A=y.findIndex(re=>re.id===s),$=y.findIndex(re=>re.id===u);if(A<0||$<0||A===$)return;const L=[...y],[G]=L.splice(A,1);L.splice($,0,G),h.value={...h.value,[p]:L},Tr()}function Hl(s){const u=n.value;if(!u)return;const p=h.value[u];if(!p)return;const y=p.find(A=>A.id===s);y&&(vs(s),gr(y.collaborationMode),hi(y.text,y.imageUrls,y.skills,"steer",y.fileAttachments))}function ys(s){qt(s)}return{projectGroups:e,projectDisplayNameById:Ae,selectedThread:Sr,selectedThreadTokenUsage:Vn,selectedThreadScrollState:mr,selectedThreadTerminalOpen:zn,isSelectedThreadInterruptPending:Cr,selectedThreadServerRequests:Ft,selectedLiveOverlay:lt,codexQuota:Pn,selectedThreadId:n,availableCollaborationModes:B,availableModelIds:j,selectedCollaborationMode:O,selectedModelId:V,selectedReasoningEffort:Z,selectedSpeedMode:xe,installedSkills:_e,accountRateLimitSnapshots:be,messages:Jr,isLoadingThreads:De,isLoadingMessages:Je,isSendingMessage:k,isInterruptingTurn:E,isUpdatingSpeedMode:H,isRollingBack:oe,error:J,refreshAll:ci,refreshSkills:ms,selectThread:Pl,loadMessages:Ar,ensureThreadMessagesLoaded:li,setThreadScrollState:an,setThreadTerminalOpen:sn,toggleSelectedThreadTerminal:Qn,archiveThreadById:Ml,renameThreadById:di,forkThreadById:Rl,forkThreadFromTurn:$l,rollbackSelectedThread:Nl,sendMessageToSelectedThread:hi,sendMessageToNewThread:oa,interruptSelectedThreadTurn:pi,selectedThreadQueuedMessages:yi,removeQueuedMessage:vs,reorderQueuedMessage:ql,steerQueuedMessage:Hl,setSelectedCollaborationMode:gr,readModelIdForThread:Gt,setSelectedModelIdForThread:Xt,setSelectedModelId:Ut,setSelectedReasoningEffort:Yr,updateSelectedSpeedMode:Gn,respondToPendingServerRequest:vi,renameProject:Dl,removeProject:Ll,reorderProject:jl,pinProjectToTop:mi,startPolling:Ul,stopPolling:Bl,primeSelectedThread:ys}}const rA={class:"sidebar-root"},oA={class:"sidebar-scrollable"},aA=["aria-pressed","aria-label","title"],sA={key:1,class:"sidebar-search-bar"},iA=["placeholder"],lA=["aria-label"],uA={class:"sidebar-skills-link-icon","aria-hidden":"true"},cA={class:"sidebar-skills-link-copy"},dA={class:"sidebar-skills-link-title"},fA={class:"sidebar-skills-link-subtitle"},hA={class:"sidebar-settings-account-section"},pA={class:"sidebar-settings-account-header"},mA={class:"sidebar-settings-account-header-main"},gA=["aria-expanded","title"],vA={class:"sidebar-settings-account-collapse-icon"},yA={class:"sidebar-settings-account-title"},wA={class:"sidebar-settings-account-count"},bA=["disabled"],_A={key:0,class:"sidebar-settings-account-error"},TA={key:1,class:"sidebar-settings-account-empty"},kA={key:2,class:"sidebar-settings-account-list"},SA=["title","onMouseenter","onMouseleave"],CA={class:"sidebar-settings-account-main"},xA={class:"sidebar-settings-account-email"},AA={class:"sidebar-settings-account-meta"},EA={class:"sidebar-settings-account-quota"},IA={class:"sidebar-settings-account-id"},PA={class:"sidebar-settings-account-actions"},MA=["disabled","onClick"],RA=["disabled","onClick"],$A=["title"],NA={class:"sidebar-settings-label"},OA=["title"],DA={class:"sidebar-settings-label"},LA={class:"sidebar-settings-value"},jA=["title"],FA={class:"sidebar-settings-label"},UA={class:"sidebar-settings-value"},BA=["title"],qA={class:"sidebar-settings-label"},HA=["value"],zA=["value"],VA=["title"],WA={class:"sidebar-settings-label"},GA={class:"sidebar-settings-value"},KA=["title"],JA={class:"sidebar-settings-label"},YA=["title"],QA={class:"sidebar-settings-label"},XA=["title"],ZA={class:"sidebar-settings-label"},eE=["value","disabled"],tE={key:0,class:"sidebar-settings-row sidebar-settings-error"},nE={key:1,class:"sidebar-settings-row sidebar-settings-row--input"},rE={class:"sidebar-settings-provider-info"},oE={class:"sidebar-settings-label"},aE={class:"sidebar-settings-provider-link",href:"https://openrouter.ai/keys",target:"_blank",rel:"noopener noreferrer"},sE={class:"sidebar-settings-key-group"},iE={class:"sidebar-settings-key-masked"},lE=["disabled","title"],uE=["placeholder"],cE=["disabled"],dE={class:"sidebar-settings-row sidebar-settings-row--select",style:{"margin-top":"4px",padding:"0"}},fE={class:"sidebar-settings-label"},hE=["aria-label"],pE=["disabled"],mE=["disabled"],gE={key:2,class:"sidebar-settings-row sidebar-settings-row--input"},vE={class:"sidebar-settings-provider-info"},yE={class:"sidebar-settings-label"},wE={class:"sidebar-settings-provider-link",href:"https://opencode.ai/auth",target:"_blank",rel:"noopener noreferrer"},bE={class:"sidebar-settings-key-group"},_E=["placeholder"],TE=["disabled"],kE={key:3,class:"sidebar-settings-row sidebar-settings-row--input"},SE={class:"sidebar-settings-label"},CE={class:"sidebar-settings-key-group"},xE=["placeholder"],AE={class:"sidebar-settings-label",style:{"margin-top":"4px"}},EE={class:"sidebar-settings-key-group"},IE=["placeholder"],PE=["disabled"],ME={class:"sidebar-settings-row sidebar-settings-row--select",style:{"margin-top":"4px",padding:"0"}},RE={class:"sidebar-settings-label"},$E=["aria-label"],NE=["title"],OE={class:"sidebar-settings-label"},DE={class:"sidebar-settings-label"},LE={class:"sidebar-settings-value"},jE={key:4,class:"sidebar-settings-telegram-panel"},FE={class:"sidebar-settings-field"},UE={class:"sidebar-settings-field-label"},BE={class:"sidebar-settings-field"},qE={class:"sidebar-settings-field-label"},HE={class:"sidebar-settings-field-help"},zE={key:0,class:"sidebar-settings-telegram-error"},VE={class:"sidebar-settings-telegram-actions"},WE=["disabled"],GE=["data-state","title"],KE={class:"sidebar-settings-label"},JE=["data-state"],YE={class:"sidebar-settings-context-meta"},QE={class:"sidebar-settings-rate-limits"},XE=["aria-label"],ZE={class:"sidebar-settings-button-version"},eI={key:0,class:"content-keyboard-spacer","aria-hidden":"true"},tI={key:1,class:"skills-route-header-icon","aria-hidden":"true"},nI=["aria-pressed","title","aria-label"],rI={class:"content-header-terminal-shortcut"},oI={class:"content-body"},aI={key:1,class:"content-grid content-grid-home"},sI={class:"new-thread-empty"},iI={class:"new-thread-hero"},lI=["title"],uI={class:"new-thread-folder-actions"},cI={key:1,class:"new-thread-launch-card","aria-label":"Plugins and Apps announcement"},dI={class:"new-thread-launch-card-copy"},fI={class:"new-thread-launch-card-topline"},hI={class:"new-thread-launch-card-badge","aria-hidden":"true"},pI={class:"new-thread-launch-card-eyebrow"},mI={class:"new-thread-launch-card-title"},gI={class:"new-thread-launch-card-text"},vI={class:"new-thread-launch-card-actions"},yI=["aria-label","onKeydown"],wI={class:"new-thread-open-folder-header"},bI={class:"new-thread-open-folder-title"},_I={class:"new-thread-open-folder-label"},TI={class:"new-thread-open-folder-current"},kI=["placeholder","title","disabled","onKeydown"],SI=["disabled"],CI={class:"new-thread-open-folder-actions"},xI={class:"new-thread-open-folder-toggle"},AI=["aria-pressed","disabled"],EI={key:0,class:"new-thread-open-folder-create"},II={class:"new-thread-open-folder-create-composer"},PI=["placeholder","onKeydown"],MI=["disabled"],RI={key:0,class:"new-thread-open-folder-error"},$I=["placeholder","onKeydown"],NI={key:1,class:"new-thread-open-folder-error-actions"},OI={class:"new-thread-open-folder-error"},DI=["disabled"],LI={key:2,class:"new-thread-open-folder-status"},jI={key:3,class:"new-thread-open-folder-status"},FI={key:4,class:"new-thread-open-folder-list"},UI=["title","disabled","onClick"],BI={class:"new-thread-open-folder-item-name"},qI=["disabled","onClick"],HI={key:2,class:"new-thread-branch-select"},zI={class:"new-thread-branch-select-label"},VI={class:"new-thread-branch-select-help"},WI={class:"new-thread-runtime-help"},GI={class:"worktree-init-status-title"},KI={class:"worktree-init-status-message"},JI={class:"composer-with-queue"},YI={key:2,class:"content-grid"},QI={class:"content-thread"},XI={class:"composer-with-queue"},Uf="codex-web-local.sidebar-collapsed.v1",Bf="codex-web-local.accounts-section-collapsed.v1",qf="codex-web-local.send-with-enter.v1",Hf="codex-web-local.in-progress-send-mode.v1",zf="codex-web-local.dark-mode.v1",Vf="codex-web-local.dictation-click-to-toggle.v1",Wf="codex-web-local.dictation-auto-send.v1",Gf="codex-web-local.dictation-language.v1",Kf="codex-web-local.chat-width.v1",ZI=400,eP=Bn({__name:"App",setup(e){var qc,Hc;const t=xi(()=>Ei(()=>import("./ThreadConversation-BQnEV6OL.js"),__vite__mapDeps([0,1]))),n=xi(()=>Ei(()=>import("./ThreadTerminalPanel-DuEjX4F5.js"),__vite__mapDeps([2,3]))),r=xi(()=>Ei(()=>import("./ReviewPane-Ce6QI-Sf.js"),__vite__mapDeps([4,5]))),a=xi(()=>Ei(()=>import("./DirectoryHub-Bm5sZZRJ.js"),__vite__mapDeps([6,7]))),{t:o,uiLanguage:i,uiLanguageOptions:l,setUiLanguage:c}=Qo(),f="ed73",h="0.1.84",g={sendWithEnter:o("When enabled, press Enter to send. When disabled, use Command+Enter to send."),inProgressSendMode:o("If a turn is still running, choose whether a new prompt should steer the current turn or be queued."),appearance:o("Switch between system theme, light mode, and dark mode."),chatWidth:o("Choose how wide the conversation column and composer can grow on desktop screens."),dictationClickToToggle:o("Use click-to-start and click-to-stop dictation instead of hold-to-talk."),dictationAutoSend:o("Automatically send transcribed dictation when recording stops."),dictationLanguage:o("Choose transcription language or keep auto-detect.")},b={standard:{label:"Standard",columnMax:"45rem",cardMax:"76ch"},wide:{label:"Wide",columnMax:"72rem",cardMax:"88ch"},"extra-wide":{label:"Extra wide",columnMax:"96rem",cardMax:"96ch"}},x={en:"english",zh:"chinese",de:"german",es:"spanish",ru:"russian",ko:"korean",fr:"french",ja:"japanese",pt:"portuguese",tr:"turkish",pl:"polish",ca:"catalan",nl:"dutch",ar:"arabic",sv:"swedish",it:"italian",id:"indonesian",hi:"hindi",fi:"finnish",vi:"vietnamese",he:"hebrew",uk:"ukrainian",el:"greek",ms:"malay",cs:"czech",ro:"romanian",da:"danish",hu:"hungarian",ta:"tamil",no:"norwegian",th:"thai",ur:"urdu",hr:"croatian",bg:"bulgarian",lt:"lithuanian",la:"latin",mi:"maori",ml:"malayalam",cy:"welsh",sk:"slovak",te:"telugu",fa:"persian",lv:"latvian",bn:"bengali",sr:"serbian",az:"azerbaijani",sl:"slovenian",kn:"kannada",et:"estonian",mk:"macedonian",br:"breton",eu:"basque",is:"icelandic",hy:"armenian",ne:"nepali",mn:"mongolian",bs:"bosnian",kk:"kazakh",sq:"albanian",sw:"swahili",gl:"galician",mr:"marathi",pa:"punjabi",si:"sinhala",km:"khmer",sn:"shona",yo:"yoruba",so:"somali",af:"afrikaans",oc:"occitan",ka:"georgian",be:"belarusian",tg:"tajik",sd:"sindhi",gu:"gujarati",am:"amharic",yi:"yiddish",lo:"lao",uz:"uzbek",fo:"faroese",ht:"haitian creole",ps:"pashto",tk:"turkmen",nn:"nynorsk",mt:"maltese",sa:"sanskrit",lb:"luxembourgish",my:"myanmar",bo:"tibetan",tl:"tagalog",mg:"malagasy",as:"assamese",tt:"tatar",haw:"hawaiian",ln:"lingala",ha:"hausa",ba:"bashkir",jw:"javanese",su:"sundanese",yue:"cantonese"},{projectGroups:j,projectDisplayNameById:B,selectedThread:te,selectedThreadTokenUsage:z,selectedThreadScrollState:O,selectedThreadTerminalOpen:V,selectedThreadServerRequests:Z,selectedLiveOverlay:xe,codexQuota:Fe,selectedThreadId:ne,availableCollaborationModes:ke,availableModelIds:X,selectedCollaborationMode:Ae,selectedReasoningEffort:He,selectedSpeedMode:ee,installedSkills:we,accountRateLimitSnapshots:$e,messages:Ke,isLoadingThreads:Ue,isLoadingMessages:Ce,isSendingMessage:me,isInterruptingTurn:We,isSelectedThreadInterruptPending:nt,isUpdatingSpeedMode:Ve,refreshAll:Le,refreshSkills:dt,selectThread:ft,ensureThreadMessagesLoaded:Ze,setThreadScrollState:ct,setThreadTerminalOpen:K,toggleSelectedThreadTerminal:_e,archiveThreadById:be,forkThreadById:De,renameThreadById:Je,forkThreadFromTurn:k,sendMessageToSelectedThread:E,sendMessageToNewThread:H,interruptSelectedThreadTurn:oe,selectedThreadQueuedMessages:J,removeQueuedMessage:se,reorderQueuedMessage:ye,steerQueuedMessage:de,setSelectedCollaborationMode:pe,readModelIdForThread:ce,setSelectedModelIdForThread:Re,setSelectedReasoningEffort:ge,updateSelectedSpeedMode:Pe,respondToPendingServerRequest:Ee,renameProject:Xe,removeProject:D,reorderProject:F,pinProjectToTop:U,startPolling:Y,stopPolling:fe,primeSelectedThread:Me,rollbackSelectedThread:Be}=nA(),Ye=Rw(),Ne=Mw(),{isMobile:vt}=Cc(),Hn=I(null),mn=I(null),go=I(null),Ot=I(!1),pr=I(!1),ir=I(!1),Kr=I(!0),Sr=I(null),mr=I(!1),zn=I("");let Cr=!1;const Ft=I(!1),lt=I(""),Pn=I("local"),Vn=I(""),Jr=I([]),Gt=I(!1),Wn=I({order:[],labels:{}}),qt=I({phase:"idle",title:"",message:""}),Xt=I(Pm()),Ut=I(""),xt=I(!1),Kt=I(null),gr=I(null),lr=I(null),Mr=I(null),Mn=I(null);let tn=null,vr=null;const ur=I("New Project (1)"),Yr=I(""),Gn=I(!1),Rn=I(Rm()),Sn=I(!1),Kn=I([]),nn=I(null),xr=I(!1),Cn=I(!1),Qr=I(null),gn=I([]),cr=I(!1),Jn=I(!1),yr=I(""),Nt=I(""),$n=I(""),vn=I(""),yn=I(Gl(qf,!0)),rn=I(vm()),yt=I(gm()),wr=I(ym()),on=I(Gl(Vf,!1)),Yn=I(Gl(Wf,!0)),br=I(Em()),Rr=ie(()=>Im()),Xr=I(!1),wn=I(!1),kt=I(!1),It=I(""),vo=I(!1),Zr=I(null),bt=I(!1),an=I(""),sn=I("codex"),Qn=I(""),Nn=I(""),bn=I("responses"),Xn=I("responses"),_r=I(""),M=I(!1),q=I(""),Q=I(""),Ie=I(""),St=I(!1),Zt=I(!1),Ht=I(""),mt=I(""),Jt=I(!1),dn=I(!1),$r=I(null),No=I(null),Nr=I(""),Zn=I(""),qe=I(""),Se=I([]),Dt=I(""),_n=I(!1),xn=I(!1),Xo=I(!1),zt=I(""),dr=I({configured:!1,active:!1,mappedChats:0,mappedThreads:0,allowedUsers:0,allowAllUsers:!1,lastError:""}),Or=I(null),Dr=I(!1),eo=I(!1),to=I(typeof window<"u"?((qc=window.visualViewport)==null?void 0:qc.height)??window.innerHeight:0),w=I(typeof window<"u"?((Hc=window.visualViewport)==null?void 0:Hc.offsetTop)??0:0),_=I(typeof window<"u"?window.innerHeight:0);let S=null,W=!1,je=0;const _t=ie(()=>{const d=Ye.params.threadId;return typeof d=="string"?d:""}),wt=ie(()=>Ye.name==="home"),Tn=ie(()=>Ye.name==="skills"),On=ie(()=>{var d;return Tn.value?o("Skills"):wt.value?o("Start new thread"):((d=te.value)==null?void 0:d.title)??o("Choose a thread")}),er=typeof window<"u"&&(window.location.hostname||window.location.host)||"codexui",Lr=ie(()=>{var v,P;return(((P=(v=te.value)==null?void 0:v.title)==null?void 0:P.trim())??"")||er}),jr=ie(()=>Ke.value.filter(d=>{const v=Nm(d.messageType,d.role);return v==="worked"?!0:!(v==="turnActivity.live"||v==="turnError.live"||v==="agentReasoning.live")})),Zo=ie(()=>xe.value),Oo=ie(()=>wt.value?"__new-thread__":ne.value),Sa=ie(()=>ce(Oo.value)),ti=ie(()=>{const d=Z.value;return d.length>0?d[d.length-1]:null}),An=ie(()=>{var d,v;return wt.value?lt.value.trim():((v=(d=te.value)==null?void 0:d.cwd)==null?void 0:v.trim())??""}),ml=ie(()=>Kr.value&&(wt.value&&An.value.length>0||Ye.name==="thread"&&ne.value.length>0)),is=ie(()=>wt.value?Ot.value:V.value),Ca=ie(()=>!vt.value||to.value<=0||_.value<=0?!1:_.value-to.value>120),gl=ie(()=>Ca.value||is.value&&ir.value),ni=ie(()=>{var d,v;return((v=(d=te.value)==null?void 0:d.cwd)==null?void 0:v.trim())??lt.value.trim()}),ls=ie(()=>{var d;return!wt.value&&((d=te.value)==null?void 0:d.inProgress)===!0}),vl=ie(()=>!wt.value&&!Tn.value&&ne.value.trim().length>0),us=ie(()=>me.value||We.value||ls.value||Z.value.length>0);function xa(d){return Number.isFinite(d)?new Intl.NumberFormat("en-US",{notation:d>=1e3?"compact":"standard",maximumFractionDigits:d>=1e5?0:1}).format(Math.max(0,Math.trunc(d))):"0"}function yl(d){if(!d)return o("Waiting for Codex thread/tokenUsage/updated events for this thread.");const v=[`${o("Current context usage")}: ${d.currentContextTokens.toLocaleString()} ${o("tokens")}`,`${o("Cumulative thread usage")}: ${d.total.totalTokens.toLocaleString()} ${o("tokens")}`];return typeof d.modelContextWindow=="number"?(v.unshift(`${o("Model context window")}: ${d.modelContextWindow.toLocaleString()} ${o("tokens")}`),v.push(`${o("Remaining context")}: ${(d.remainingContextTokens??0).toLocaleString()} ${o("tokens")}`)):v.push(o("Model context window is unavailable in the latest usage event.")),v.join(`
57
57
  `)}function ri(){Xr.value&&(Xr.value=!1,T0(!0))}function wl(){ri(),Ne.push({name:"skills"})}const oi=ie(()=>{var v;const d=(v=z.value)==null?void 0:v.remainingContextPercent;return d===null||typeof d!="number"?"pending":d<=10?"danger":d<=25?"warning":"ok"}),bl=ie(()=>{const d=z.value;return d?typeof d.remainingContextTokens=="number"?`${xa(d.remainingContextTokens)} ${o("left")}`:`${xa(d.currentContextTokens)} ${o("used")}`:o("Awaiting data")}),_l=ie(()=>{const d=z.value;return d?typeof d.modelContextWindow=="number"?`${xa(d.currentContextTokens)} ${o("used")} / ${xa(d.modelContextWindow)}`:o("Window size unavailable"):o("Updates after the next token usage event")}),Tl=ie(()=>yl(z.value)),ea=ie(()=>{var ae,ve;const d=[],v=new Set;for(const Te of Wn.value.order){const st=Te.trim();!st||v.has(st)||(v.add(st),d.push({value:st,label:Wn.value.labels[st]||ma(st)}))}for(const Te of j.value){const st=((ve=(ae=Te.threads[0])==null?void 0:ae.cwd)==null?void 0:ve.trim())??"";!st||v.has(st)||Ji(st)||(v.add(st),d.push({value:st,label:B.value[Te.projectName]??Te.projectName}))}const P=lt.value.trim();return P&&!v.has(P)&&d.unshift({value:P,label:ma(P)}),d}),cs=ie(()=>{const d=Vn.value.trim(),v=[...Jr.value];return d&&!v.some(P=>P.value===d)&&v.unshift({value:d,label:d}),v}),ai=ie(()=>{const d=Vn.value.trim();if(!d)return"";const v=cs.value.find(P=>P.value===d);return(v==null?void 0:v.label)??d}),kl=ie(()=>nn.value??"__detached_head__"),Sl=ie(()=>{var ae;const d=[{value:"__review__",label:Sn.value?"Review (Open)":"Review"}],v=new Set,P=((ae=nn.value)==null?void 0:ae.trim())??"";P?(d.push({value:P,label:P}),v.add(P)):(d.push({value:"__detached_head__",label:"Detached HEAD"}),v.add("__detached_head__"));for(const ve of Kn.value)!ve.value||v.has(ve.value)||(v.add(ve.value),d.push(ve));return d}),si=ie(()=>Zn.value.trim()),ii=ie(()=>{const d=Ht.value.trim();return!d||d==="."||d===".."?!1:!/[\\/]/u.test(d)}),Cl=ie(()=>ii.value&&si.value.trim().length>0&&!Dt.value),ta=ie(()=>{const d=jt(Nr.value).trim();return d||Zn.value.trim()}),xl=ie(()=>Jt.value?"Creating…":"Create"),Al=ie(()=>{const d=Zn.value.trim(),v=qe.value.trim();return!!(d&&v&&d!==v)}),ds=ie(()=>{const d=[];Al.value&&d.push({key:`parent:${qe.value}`,name:"..",path:qe.value,kind:"parent"});for(const v of Se.value)d.push({key:`directory:${v.path}`,name:v.name,path:v.path,kind:"directory"});return d}),fs=ie(()=>{const d=zt.value.trim().toLowerCase();return d?ds.value.filter(v=>v.kind==="parent"||v.name.toLowerCase().includes(d)):ds.value}),Tr=typeof window<"u"?window.matchMedia("(prefers-color-scheme: dark)"):null,El=ie(()=>o(b[wr.value].label)),hs=ie(()=>typeof navigator<"u"&&/mac|iphone|ipad|ipod/i.test(navigator.platform)?"⌘J":"Ctrl+J"),na=ie(()=>{const d=b[wr.value],v=Math.max(0,_.value-to.value-w.value);return{"--chat-column-max":d.columnMax,"--chat-card-max":d.cardMax,"--visual-viewport-height":to.value>0?`${to.value}px`:"100dvh","--visual-viewport-offset-top":`${Math.max(0,w.value)}px`,"--virtual-keyboard-inset":`${v}px`}}),ps=ie(()=>{if(!dr.value.configured)return o("Not configured");const d=dr.value.active?o("Online"):o("Configured (offline)"),v=dr.value.allowAllUsers?o("allow all users"):`${dr.value.allowedUsers} ${o("allowed user(s)")}`,P=`${dr.value.mappedChats} ${o("chat(s)")}, ${dr.value.mappedThreads} ${o("thread(s)")}, ${v}`,ae=dr.value.lastError?`, ${o("error")}: ${dr.value.lastError}`:"";return`${d}, ${P}${ae}`});Jo(()=>{var d,v;document.addEventListener("pointerdown",ws),window.addEventListener("keydown",he),document.addEventListener("visibilitychange",Do),window.addEventListener("pageshow",la),window.addEventListener("focus",bs),window.addEventListener("resize",no),(d=window.visualViewport)==null||d.addEventListener("resize",no),(v=window.visualViewport)==null||v.addEventListener("scroll",no),no(),_i(),Tr==null||Tr.addEventListener("change",_i),Om(),im(),ms(),Ma(),yo(),li(),Ar(),Jl(),Ea()}),il(()=>{var d,v;document.removeEventListener("pointerdown",ws),window.removeEventListener("keydown",he),document.removeEventListener("visibilitychange",Do),window.removeEventListener("pageshow",la),window.removeEventListener("focus",bs),window.removeEventListener("resize",no),(d=window.visualViewport)==null||d.removeEventListener("resize",no),(v=window.visualViewport)==null||v.removeEventListener("scroll",no),Tr==null||Tr.removeEventListener("change",_i),S!==null&&(window.clearInterval(S),S=null),tn&&(clearTimeout(tn),tn=null),ro(),fe()});function no(){var d,v;typeof window>"u"||(_.value=Math.max(_.value,window.innerHeight),to.value=((d=window.visualViewport)==null?void 0:d.height)??window.innerHeight,w.value=((v=window.visualViewport)==null?void 0:v.offsetTop)??0)}gt(Ut,d=>{const v=d.trim();if(tn&&(clearTimeout(tn),tn=null),!v){Mn.value=null;return}tn=setTimeout(()=>{p0(v,1e3).then(P=>{Ut.value.trim()===v&&(Mn.value=P.threadIds)}).catch(()=>{Ut.value.trim()===v&&(Mn.value=null)})},220)}),gt(Ca,d=>{d||(ir.value=!1)}),gt(gn,()=>{if(typeof window>"u")return;if(!gn.value.some(v=>v.quotaStatus==="loading")){S!==null&&(window.clearInterval(S),S=null);return}S===null&&(S=window.setInterval(()=>{W||(W=!0,fr({silent:!0}).finally(()=>{W=!1}))},1500))},{deep:!0});function ra(){dt()}async function Ar(){try{dr.value=await v0()}catch(d){const v=d instanceof Error?d.message:"Failed to load Telegram status";dr.value={configured:!1,active:!1,mappedChats:0,mappedThreads:0,allowedUsers:0,allowAllUsers:!1,lastError:v}}}async function li(){try{const d=await g0();q.value=d.botToken,Q.value=d.allowedUserIds.map(v=>String(v)).join(`
58
58
  `),Ie.value=""}catch(d){Ie.value=d instanceof Error?d.message:"Failed to load Telegram configuration"}}async function ms(){const d=await _0();Xr.value=d.dismissed!==!0}function ui(d){const v=d.split(/[\n,]/).map(ve=>ve.trim().replace(/^(telegram|tg):/i,"").trim()).filter(Boolean),P=v.includes("*"),ae=Array.from(new Set(v.filter(ve=>/^-?\d+$/.test(ve)).map(ve=>Number.parseInt(ve,10))));return P?["*",...ae]:ae}async function Il(){const d=q.value.trim(),v=ui(Q.value);if(!d){Ie.value=o("Telegram bot token is required.");return}if(v.length===0){Ie.value=o("At least one allowed Telegram user ID or * is required.");return}St.value=!0,Ie.value="";try{await m0(d,v),Q.value=v.map(P=>String(P)).join(`
59
59
  `),await Promise.all([li(),Ar()]),window.alert(o("Telegram bot configured. Only allowlisted Telegram users can use the bridge."))}catch(P){Ie.value=P instanceof Error?P.message:o("Failed to connect Telegram bot"),Ar()}finally{St.value=!1}}function ci(){xt.value=!xt.value,xt.value?ln(()=>{var d;return(d=Kt.value)==null?void 0:d.focus()}):Ut.value=""}function Pl(){var d;Ut.value="",(d=Kt.value)==null||d.focus()}function Ml(d){d.key==="Escape"&&(xt.value=!1,Ut.value="")}function di(d){d&&(Ye.name==="thread"&&_t.value===d||(Ne.push({name:"thread",params:{threadId:d}}),vt.value&&re(!0)))}async function Rl(d){d&&(ne.value!==d&&(await ft(d),await Ne.push({name:"thread",params:{threadId:d}})),await ln(),fm())}function $l(d){return d.length>8?d.slice(-8):d}function fi(d){const v=[d.planType||o("unknown")];return d.authMode&&v.unshift(d.authMode),v.join(" · ")}function hi(d){if(!d)return!1;const v=d.toLowerCase();return v.includes("payment required")||/\b402\b/.test(v)}function oa(d){return d.unavailableReason==="payment_required"||hi(d.quotaError)}function aa(d){return cr.value||Jn.value||yr.value.length>0||d.isActive&&yr.value!==d.accountId&&us.value}function sa(d){return Nt.value===d.accountId}function pi(d){return $n.value===d.accountId||sa(d)}function Nl(d){return oa(d)?o("Unavailable"):d.isActive?o("Active"):Jn.value?o("Switching…"):o("Switch")}function Aa(d){return yr.value===d.accountId?o("Removing…"):sa(d)?o("Click again to remove"):o("Remove")}function Ol(d){$n.value=d}function Dl(d){$n.value===d&&($n.value=""),yr.value!==d&&Nt.value===d&&(Nt.value="")}function Ll(d){const v=d.quotaSnapshot;if(!v)return null;const P=[v==null?void 0:v.primary,v==null?void 0:v.secondary].filter(Te=>Te!==null),ae=P.find(Te=>Te.windowMinutes===10080);if(ae)return ae;const ve=P.filter(Te=>typeof Te.windowMinutes=="number"&&Te.windowMinutes>=10080).sort((Te,st)=>(Te.windowMinutes??0)-(st.windowMinutes??0))[0]??null;return ve||(v.secondary??null)}function jl(d){if(typeof d!="number"||!Number.isFinite(d))return"";const v=new Date(d*1e3);return`${v.getMonth()+1}月${v.getDate()}日`}function mi(d){var Te,st;if(oa(d))return d.quotaError||o("402 Payment Required");const v=d.quotaSnapshot,P=Ll(d),ae=(v==null?void 0:v.primary)??(v==null?void 0:v.secondary)??null,ve=P??ae;if(ve){const Dn=Math.max(0,Math.min(100,100-Math.round(ve.usedPercent))),ao=jl(ve.resetsAt);return ao?`${Dn}% ${o("weekly remaining")} · ${ao}`:`${Dn}% ${o("weekly remaining")}`}return(Te=v==null?void 0:v.credits)!=null&&Te.unlimited?o("Unlimited credits"):(st=v==null?void 0:v.credits)!=null&&st.hasCredits&&v.credits.balance?`${v.credits.balance} ${o("credits")}`:d.quotaStatus==="loading"?o("Loading quota…"):d.quotaStatus==="error"?d.quotaError||o("Quota unavailable"):d.quotaStatus==="ready"||d.quotaStatus==="idle"?o("Quota unavailable"):o("Fetching account details…")}function gs(d){return[d.email||o("Account"),fi(d),oa(d)?o("Unavailable account"):null,mi(d),`${o("Workspace")} ${d.accountId}`].filter(Boolean).join(`
package/dist/index.html CHANGED
@@ -12,7 +12,7 @@
12
12
  <link rel="icon" type="image/png" sizes="192x192" href="/icons/pwa-192x192.png" />
13
13
  <link rel="apple-touch-icon" sizes="180x180" href="/icons/apple-touch-icon.png" />
14
14
  <title>Codex Web</title>
15
- <script type="module" crossorigin src="/assets/index-Cmr8liLe.js"></script>
15
+ <script type="module" crossorigin src="/assets/index-DzzwK-KG.js"></script>
16
16
  <link rel="stylesheet" crossorigin href="/assets/index-B6Gx9sFJ.css">
17
17
  </head>
18
18
  <body class="bg-slate-950">
package/dist-cli/index.js CHANGED
@@ -5613,20 +5613,53 @@ async function startComposioLogin() {
5613
5613
  if (!command) {
5614
5614
  throw new Error("Composio CLI is not installed");
5615
5615
  }
5616
- const invocation = getSpawnInvocation(command, ["login", "-y"]);
5616
+ const invocation = getSpawnInvocation(command, ["login", "--no-browser", "-y"]);
5617
5617
  const proc = spawn4(invocation.command, invocation.args, {
5618
5618
  cwd: process.cwd(),
5619
5619
  env: process.env,
5620
5620
  detached: true,
5621
- stdio: "ignore",
5621
+ stdio: ["ignore", "pipe", "pipe"],
5622
5622
  windowsHide: true
5623
5623
  });
5624
5624
  proc.unref();
5625
+ let stdout = "";
5626
+ let stderr = "";
5627
+ proc.stdout.setEncoding("utf8");
5628
+ proc.stderr.setEncoding("utf8");
5629
+ proc.stderr.on("data", (chunk) => {
5630
+ stderr += chunk;
5631
+ });
5632
+ const loginUrl = await new Promise((resolveLoginUrl, reject) => {
5633
+ const timeout = setTimeout(() => {
5634
+ proc.kill("SIGTERM");
5635
+ reject(new Error(stderr.trim() || stdout.trim() || "Timed out waiting for Composio CLI login URL"));
5636
+ }, 1e4);
5637
+ const finish = (url) => {
5638
+ clearTimeout(timeout);
5639
+ proc.stdout.destroy();
5640
+ proc.stderr.destroy();
5641
+ resolveLoginUrl(url);
5642
+ };
5643
+ proc.once("error", (error) => {
5644
+ clearTimeout(timeout);
5645
+ reject(error);
5646
+ });
5647
+ proc.once("close", (code) => {
5648
+ clearTimeout(timeout);
5649
+ reject(new Error(stderr.trim() || stdout.trim() || `Composio CLI login exited with code ${code ?? 0}`));
5650
+ });
5651
+ proc.stdout.on("data", (chunk) => {
5652
+ stdout += chunk;
5653
+ const url = stdout.match(/https?:\/\/\S+/)?.[0] ?? "";
5654
+ if (url) finish(url);
5655
+ });
5656
+ });
5657
+ const cliKey = loginUrl ? new URL(loginUrl).searchParams.get("cliKey") ?? "" : "";
5625
5658
  return {
5626
5659
  status: "started",
5627
- message: "Composio CLI login started",
5628
- loginUrl: "",
5629
- cliKey: "",
5660
+ message: "Composio CLI login URL created",
5661
+ loginUrl,
5662
+ cliKey,
5630
5663
  expiresAt: ""
5631
5664
  };
5632
5665
  }