@yeaft/webchat-agent 1.0.547 → 1.0.549

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,13 +1,13 @@
1
- var B=(e,t,s)=>()=>{if(s)throw s[0];try{return e&&(t=e(e=0)),t}catch(n){throw s=[n],n}};var ay=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(s){throw t=0,s}};function bd(e,t){let s=nacl.randomBytes(24),n=JSON.stringify(e),r,i=!1;n.length>512?(r=pako.gzip(n),i=!0):r=nacl.util.decodeUTF8(n);let o=nacl.secretbox(r,s,t),a={n:nacl.util.encodeBase64(s),c:nacl.util.encodeBase64(o)};return i&&(a.z=!0),a}function wd(e,t){try{let s=nacl.util.decodeBase64(e.n),n=nacl.util.decodeBase64(e.c),r=nacl.secretbox.open(n,s,t);if(!r)return null;if(e.z){let i=pako.ungzip(r,{to:"string"});return JSON.parse(i)}else return JSON.parse(nacl.util.encodeUTF8(r))}catch{return null}}function kd(e){return e&&typeof e=="object"&&typeof e.n=="string"&&typeof e.c=="string"}function Gt(e){return nacl.util.decodeBase64(e)}var qi=B(()=>{});function bs(){return globalThis.localStorage||null}function Id(){let e=Hi();for(let t of Ra)try{t(e)}catch{}}function ly(){try{bs()?.removeItem(xr),bs()?.removeItem(Tr)}catch{}}function cy(e){return String(e||"").trim()||null}function Sd(e,t){if(!Mr(t))return{};try{let s=JSON.parse(bs()?.getItem(e)||"null");return!s||typeof s!="object"||Array.isArray(s)||s.ownerId!==t.ownerId||!s.records||typeof s.records!="object"||Array.isArray(s.records)?(bs()?.removeItem(e),{}):s.records}catch{try{bs()?.removeItem(e)}catch{}return{}}}function Cd(e,t,s){if(!Mr(s))return!1;try{return bs()?.setItem(e,JSON.stringify({ownerId:s.ownerId,records:t||{}})),!0}catch{return!1}}function Qt(e){let t=cy(e);if(!t)return _a(),null;if(pn!==t){pn=t,Vi+=1;for(let s of[xr,Tr])try{let n=JSON.parse(bs()?.getItem(s)||"null");(!n||n.ownerId!==t)&&bs()?.removeItem(s)}catch{try{bs()?.removeItem(s)}catch{}}Id()}return Hi()}function _a(){pn=null,Vi+=1,ly(),Id()}function Hi(){return pn?{ownerId:pn,epoch:Vi}:null}function Mr(e){return!!e&&!!pn&&e.ownerId===pn&&e.epoch===Vi}function Ad(e){return{drafts:Sd(xr,e),outbox:Sd(Tr,e)}}function Ea(e,t){return Cd(xr,e,t)}function Pr(e,t){return Cd(Tr,e,t)}function xd(e){return typeof e!="function"?()=>{}:(Ra.add(e),()=>Ra.delete(e))}var xr,Tr,pn,Vi,Ra,rI,Da=B(()=>{xr="yeaft-work-center-composer-drafts-v1",Tr="yeaft-work-center-message-outbox-v1",pn=null,Vi=0,Ra=new Set;rI=Object.freeze({drafts:xr,outbox:Tr})});function $a(){try{globalThis.Pinia?.useChatStore?.()?.clearYeaftHistoryMemory?.()}catch{}}function ws(e){let t=String(e||"").trim()||null;Bi!==t&&$a(),Bi=t}function uy(){$a(),Bi=null}var dy,Bi,py,Ge,qt=B(()=>{qi();Da();({defineStore:dy}=Pinia);Bi=null;py=1800*1e3,Ge=dy("auth",{state:()=>({skipAuth:!1,emailVerification:!1,passwordResetEnabled:!1,totpEnabled:!1,registrationEnabled:!1,aadEnabled:!1,aadClientId:null,aadTenantId:null,ssoProviders:{github:!1,google:!1,wechat:!1,alipay:!1},linkedIdentities:[],hasPassword:!1,identitiesLoading:!1,identitiesError:null,initialized:!1,authGeneration:0,isAuthenticated:!1,token:null,sessionKey:null,userId:null,role:null,loginStep:"credentials",tempToken:null,emailHint:null,setupToken:null,totpSecret:null,qrCode:null,error:null,loading:!1,qrPanel:null,_qrPollTimer:null,_sessionRefreshTimer:null,_sessionRefreshVisibilityHandler:null}),actions:{async initialize(){if(this.initialized)return this.isAuthenticated;try{if(await this.checkAuthMode(),this.skipAuth&&this.isAuthenticated)return!0;let e=!1;return typeof window<"u"&&typeof this.consumeSsoRedirect=="function"&&(e=this.consumeSsoRedirect()),!this.isAuthenticated&&!e&&await this.restoreSession(),this.isAuthenticated}finally{this.initialized=!0}},async checkAuthMode(){try{let t=await(await fetch("/api/auth/mode")).json();this.skipAuth=t.skipAuth,this.emailVerification=t.emailVerification,this.passwordResetEnabled=!!t.passwordResetEnabled,this.totpEnabled=t.totpEnabled,this.registrationEnabled=t.registrationEnabled||!1,this.aadEnabled=t.aadEnabled||!1,this.aadClientId=t.aadClientId||null,this.aadTenantId=t.aadTenantId||null,this.ssoProviders=Object.assign({github:!1,google:!1,wechat:!1,alipay:!1},t.ssoProviders||{}),this.skipAuth&&(this.userId="skip-auth",Qt(this.userId),ws(this.userId),this.authGeneration+=1,this.isAuthenticated=!0,this.loginStep="authenticated")}catch{}},async login(e,t){this.loading=!0,this.error=null;try{let n=await(await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:e,password:t})})).json();return n.success?n.needTotpSetup?(this.setupToken=n.setupToken,this.totpSecret=n.totpSecret,this.qrCode=n.qrCode,this.loginStep="totp-setup",!0):n.needTotpCode?(this.tempToken=n.tempToken,this.loginStep="totp",!0):n.needEmailCode?(this.tempToken=n.tempToken,this.emailHint=n.emailHint,this.loginStep="verification",!0):(this.token=n.token,this.sessionKey=n.sessionKey?Gt(n.sessionKey):null,this.role=n.role||"pro",this.userId=n.userId||null,Qt(this.userId),ws(this.userId),this.authGeneration+=1,this.isAuthenticated=!0,this.loginStep="authenticated",localStorage.setItem("authToken",n.token),this.startSessionRefresh(),!0):(this.error=n.error||"Login failed",!1)}catch(s){return this.error=s.message||"Network error",!1}finally{this.loading=!1}},async loginWithMicrosoft(){if(!this.aadEnabled||!this.aadClientId||!this.aadTenantId)return this.error="Microsoft login is not configured",!1;if(typeof msal>"u"||!msal.PublicClientApplication)return this.error="Microsoft authentication library not loaded",!1;this.loading=!0,this.error=null;try{let e={auth:{clientId:this.aadClientId,authority:`https://login.microsoftonline.com/${this.aadTenantId}`,redirectUri:window.location.origin+"/auth/callback"},cache:{cacheLocation:"sessionStorage",storeAuthStateInCookie:!1}},t=new msal.PublicClientApplication(e);await t.initialize();let s=await t.loginPopup({scopes:["openid","profile","email"]});if(!s||!s.idToken)return this.error="Microsoft login failed: no token received",!1;let r=await(await fetch("/api/auth/aad",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({idToken:s.idToken})})).json();return r.success?(this.token=r.token,this.sessionKey=r.sessionKey?Gt(r.sessionKey):null,this.role=r.role||"pro",this.userId=r.userId||null,Qt(this.userId),ws(this.userId),this.authGeneration+=1,this.isAuthenticated=!0,this.loginStep="authenticated",localStorage.setItem("authToken",r.token),this.startSessionRefresh(),!0):(this.error=r.error||"Microsoft login failed",!1)}catch(e){return e.errorCode==="user_cancelled"||e.name==="BrowserAuthError"?(this.error=null,!1):(this.error=e.message||"Microsoft login failed",!1)}finally{this.loading=!1}},async verifyTotpCode(e){this.loading=!0,this.error=null;try{let s=await(await fetch("/api/auth/verify-totp",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tempToken:this.tempToken,totpCode:e})})).json();return s.success?s.needEmailCode?(this.tempToken=s.tempToken,this.emailHint=s.emailHint,this.loginStep="verification",!0):(this.token=s.token,this.sessionKey=s.sessionKey?Gt(s.sessionKey):null,this.role=s.role||"pro",this.userId=s.userId||null,Qt(this.userId),ws(this.userId),this.authGeneration+=1,this.isAuthenticated=!0,this.loginStep="authenticated",this.tempToken=null,localStorage.setItem("authToken",s.token),this.startSessionRefresh(),!0):(this.error=s.error||"TOTP verification failed",!1)}catch(t){return this.error=t.message||"Network error",!1}finally{this.loading=!1}},async completeTotpSetup(e){this.loading=!0,this.error=null;try{let s=await(await fetch("/api/auth/setup-totp",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({setupToken:this.setupToken,totpCode:e})})).json();return s.success?(this.setupToken=null,this.totpSecret=null,this.qrCode=null,s.needEmailCode?(this.tempToken=s.tempToken,this.emailHint=s.emailHint,this.loginStep="verification",!0):(this.token=s.token,this.sessionKey=s.sessionKey?Gt(s.sessionKey):null,this.role=s.role||"pro",this.userId=s.userId||null,Qt(this.userId),ws(this.userId),this.authGeneration+=1,this.isAuthenticated=!0,this.loginStep="authenticated",localStorage.setItem("authToken",s.token),this.startSessionRefresh(),!0)):(this.error=s.error||"TOTP setup failed",!1)}catch(t){return this.error=t.message||"Network error",!1}finally{this.loading=!1}},async verifyCode(e){this.loading=!0,this.error=null;try{let s=await(await fetch("/api/auth/verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tempToken:this.tempToken,code:e})})).json();return s.success?(this.token=s.token,this.sessionKey=s.sessionKey?Gt(s.sessionKey):null,this.role=s.role||"pro",this.userId=s.userId||null,Qt(this.userId),ws(this.userId),this.authGeneration+=1,this.isAuthenticated=!0,this.loginStep="authenticated",this.tempToken=null,this.emailHint=null,localStorage.setItem("authToken",s.token),this.startSessionRefresh(),!0):(this.error=s.error||"Verification failed",!1)}catch(t){return this.error=t.message||"Network error",!1}finally{this.loading=!1}},async register(e,t,s,n){this.loading=!0,this.error=null;try{let i=await(await fetch("/api/auth/register",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:e,password:t,email:s||void 0,invitationCode:n})})).json();return i.success?!0:(this.error=i.error||"Registration failed",!1)}catch(r){return this.error=r.message||"Network error",!1}finally{this.loading=!1}},showRegister(){this.loginStep="register",this.error=null},loginWithSso(e){window.location.href=`/api/auth/sso/${encodeURIComponent(e)}/start`},async loginWithAlipayMobile({intent:e="login"}={}){if(!await this.startSsoQr("alipay",{intent:e}))return!1;let s=this.qrPanel?.authorizeUrl;if(!s)return!1;let n=`alipays://platformapi/startapp?appId=20000067&url=${encodeURIComponent(s)}`;return this.qrPanel={...this.qrPanel,mobileDeepLink:!0},window.location.href=n,!0},async startSsoQr(e,{intent:t="login"}={}){this.cancelSsoQr(),this.error=null;try{let s=new URLSearchParams;if(t==="bind"){if(!this.isAuthenticated)return this.error="You must be logged in to bind an identity",!1;s.set("intent","bind")}let n=s.toString(),r=`/api/auth/sso/${encodeURIComponent(e)}/start-qr${n?"?"+n:""}`,i=await fetch(r),o=await i.json();return!i.ok||!o.success?(this.error=o.error||"Failed to start QR login",!1):(this.qrPanel={provider:e,intent:t,authorizeUrl:o.authorizeUrl,state:o.state,status:"pending",error:null},this._startQrPoll(),!0)}catch(s){return this.error=s.message||"Network error",!1}},_startQrPoll(){this._stopQrPollTimer();let e=async()=>{if(!this.qrPanel)return;let t=this.qrPanel.state;try{let n=await(await fetch(`/api/auth/sso/poll/${encodeURIComponent(t)}`)).json();if(!this.qrPanel||this.qrPanel.state!==t||n.status==="pending")return;if(n.status==="login"){this.token=n.token,this.sessionKey=n.sessionKey?Gt(n.sessionKey):null,this.role=n.role||"pro",this.userId=n.userId||null,Qt(this.userId),ws(this.userId),this.authGeneration+=1,this.isAuthenticated=!0,this.loginStep="authenticated",localStorage.setItem("authToken",n.token),this.startSessionRefresh(),this.cancelSsoQr();return}if(n.status==="bind"){this.qrPanel={...this.qrPanel,status:"bound"},this._stopQrPollTimer();return}this.qrPanel={...this.qrPanel,status:"error",error:n.error||"SSO failed"},this._stopQrPollTimer()}catch{}};this._qrPollTick=e,this._qrPollTimer=setInterval(e,2e3),typeof document<"u"&&!this._qrVisHandler&&(this._qrVisHandler=()=>{typeof document<"u"&&document.visibilityState&&document.visibilityState!=="visible"||!this.qrPanel||!this._qrPollTick||(this._qrPollTick(),this._qrPollTimer&&clearInterval(this._qrPollTimer),this._qrPollTimer=setInterval(this._qrPollTick,2e3))},document.addEventListener("visibilitychange",this._qrVisHandler),typeof window<"u"&&window.addEventListener("pageshow",this._qrVisHandler))},_stopQrPollTimer(){this._qrPollTimer&&(clearInterval(this._qrPollTimer),this._qrPollTimer=null),this._qrVisHandler&&(typeof document<"u"&&document.removeEventListener("visibilitychange",this._qrVisHandler),typeof window<"u"&&window.removeEventListener("pageshow",this._qrVisHandler),this._qrVisHandler=null),this._qrPollTick=null},cancelSsoQr(){this._stopQrPollTimer(),this.qrPanel=null},bindSso(e){if(!this.isAuthenticated){this.error="You must be logged in to bind an identity";return}let t=new URLSearchParams({intent:"bind"});window.location.href=`/api/auth/sso/${encodeURIComponent(e)}/start?${t.toString()}`},consumeSsoRedirect(){let e=window.location.hash||"",t=e.indexOf("?");if(!e.startsWith("#/sso-complete")||t<0)return!1;let s=new URLSearchParams(e.slice(t+1)),n=s.get("token"),r=s.get("sessionKey"),i=s.get("role"),o=s.get("userId");if(!n)return!1;this.token=n,this.sessionKey=r?Gt(r):null,this.role=i||"pro",this.userId=o||null,Qt(this.userId),ws(this.userId),this.authGeneration+=1,this.isAuthenticated=!0,this.loginStep="authenticated",localStorage.setItem("authToken",n),this.startSessionRefresh();try{history.replaceState(null,"",window.location.pathname+window.location.search)}catch{}return!0},async loadIdentities(){if(this.isAuthenticated){this.identitiesLoading=!0,this.identitiesError=null;try{let e=await fetch("/api/auth/identities"),t=await e.json();if(!e.ok||!t.success){this.identitiesError=t.error||"Failed to load identities";return}this.linkedIdentities=t.identities||[],this.hasPassword=!!t.hasPassword}catch(e){this.identitiesError=e.message||"Network error"}finally{this.identitiesLoading=!1}}},async unbindIdentity(e){if(!this.isAuthenticated)return!1;this.identitiesError=null;try{let t=await fetch(`/api/auth/identities/${encodeURIComponent(e)}`,{method:"DELETE"}),s=await t.json();return!t.ok||!s.success?(this.identitiesError=s.error||"Failed to unbind",!1):(this.linkedIdentities=this.linkedIdentities.filter(n=>n.provider!==e),!0)}catch(t){return this.identitiesError=t.message||"Network error",!1}},async refreshSession(){let e=this.token,t=this.authGeneration,s=this.isAuthenticated;try{let n=await fetch("/api/user/profile",{headers:e?{Authorization:`Bearer ${e}`}:{}});if(this.handleAuthResponse(n,e,t,s)||!n.ok)return!1;let r=await n.json().catch(()=>({}));if(t!==this.authGeneration||this.token!==e)return this.isAuthenticated;let i=n.headers?.get?.("X-New-Token"),o=localStorage.getItem("authToken");i&&this.token===e&&(!o||o===e)&&(this.token=i,localStorage.setItem("authToken",i)),r?.role&&(this.role=r.role);let a=this.userId;return this.userId=r?.userId||null,Qt(this.userId),a!==this.userId&&$a(),Bi=this.userId,!0}catch{return!1}},startSessionRefresh(){if(this.stopSessionRefresh(),!this.isAuthenticated||this.skipAuth)return;let e=()=>{typeof document<"u"&&document.visibilityState&&document.visibilityState!=="visible"||this.refreshSession()};this._sessionRefreshTimer=setInterval(e,py),this._sessionRefreshVisibilityHandler=e,typeof document<"u"&&document.addEventListener("visibilitychange",e),typeof window<"u"&&window.addEventListener("pageshow",e)},stopSessionRefresh(){this._sessionRefreshTimer&&(clearInterval(this._sessionRefreshTimer),this._sessionRefreshTimer=null),this._sessionRefreshVisibilityHandler&&(typeof document<"u"&&document.removeEventListener("visibilitychange",this._sessionRefreshVisibilityHandler),typeof window<"u"&&window.removeEventListener("pageshow",this._sessionRefreshVisibilityHandler),this._sessionRefreshVisibilityHandler=null)},async logout(){try{let e={"Content-Type":"application/json"};this.token&&(e.Authorization=`Bearer ${this.token}`),await fetch("/api/auth/logout",{method:"POST",headers:e})}catch{}await this.clearStoredSession()},clearStoredSession(e=null){let t=this.reset();return localStorage.removeItem("authToken"),e&&(this.error=e),t},getActiveToken(){if(this.token)return this.token;let e=localStorage.getItem("authToken");return e&&(this.token=e),this.token},handleAuthResponse(e,t=null,s=this.authGeneration,n=this.isAuthenticated,r=void 0){if(!e||e.status!==401||!n||s!==this.authGeneration)return!1;let i=this.token||localStorage.getItem("authToken")||null;return t!==i?!1:(this.handleAuthFailure(r,t,s),!0)},handleAuthFailure(e="Session expired. Please log in again.",t=null,s=this.authGeneration){if(s!==this.authGeneration)return!1;let n=this.token||localStorage.getItem("authToken")||null;return t!==n||this.clearStoredSession(e),!1},async restoreSession(){let e=localStorage.getItem("authToken"),t=this.authGeneration,s=this.isAuthenticated||!!e;try{let n=await fetch("/api/user/profile",{headers:e?{Authorization:`Bearer ${e}`}:{}});if(this.handleAuthResponse(n,e,t,s))return!1;if(!n.ok)return this.error="Failed to restore session",!1;let r=await n.json();if(t!==this.authGeneration)return this.isAuthenticated;let i=n.headers?.get?.("X-New-Token"),o=this.getActiveToken();if(o!==e)return this.isAuthenticated;let a=i&&(!o||o===e)?i:o||e;return this.token=a,a&&a!==e&&localStorage.setItem("authToken",a),this.role=r?.role||"pro",this.userId=r?.userId||null,Qt(this.userId),ws(this.userId),this.authGeneration+=1,this.isAuthenticated=!0,this.loginStep="authenticated",this.startSessionRefresh(),!0}catch(n){return this.error=n.message||"Failed to restore session",!1}},setSessionKey(e){e&&(this.sessionKey=Gt(e))},backToCredentials(){this.loginStep="credentials",this.tempToken=null,this.emailHint=null,this.setupToken=null,this.totpSecret=null,this.qrCode=null,this.error=null},async requestPasswordReset(e){this.error=null;try{let s=await(await fetch("/api/auth/password-reset/request",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e})})).json();return s.success?s.resetToken||null:(this.error=s.error||"Failed to request password reset",null)}catch(t){return this.error=t.message||"Network error",null}},async verifyPasswordReset(e,t,s){this.error=null;try{let r=await(await fetch("/api/auth/password-reset/verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({resetToken:e,code:t,newPassword:s})})).json();return r.success?!0:(this.error=r.error||"Failed to reset password",!1)}catch(n){return this.error=n.message||"Network error",!1}},async deleteAccount({currentPassword:e,confirm:t}={}){if(!this.isAuthenticated)return{success:!1,error:"Not authenticated"};try{let s=await fetch("/api/user/me",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({currentPassword:e,confirm:t})}),n=await s.json();return!s.ok||!n.success?{success:!1,error:n.error||"Failed to delete account"}:(await this.clearStoredSession(),{success:!0})}catch(s){return{success:!1,error:s.message||"Network error"}}},reset(){_a(),uy(),this.authGeneration+=1,this.stopSessionRefresh(),this.isAuthenticated=!1,this.token=null,this.sessionKey=null,this.userId=null,this.role=null,this.loginStep="credentials",this.tempToken=null,this.emailHint=null,this.setupToken=null,this.totpSecret=null,this.qrCode=null,this.error=null,this.loading=!1}}})});function Oe(e,t){let s=ks?.value||"zh-CN",r=(qn[s]||qn["zh-CN"]||{})[e];if(r===void 0&&s!=="zh-CN"&&(r=(qn["zh-CN"]||{})[e]),r===void 0)return e;if(t)for(let[i,o]of Object.entries(t))r=r.replace(new RegExp(`\\{${i}\\}`,"g"),o);return r}function gy(){return ks?.value||"zh-CN"}function Rr(e){qn[e]&&(ks&&(ks.value=e),localStorage.setItem("locale",e),document.documentElement.setAttribute("lang",e))}function fy(){let e=localStorage.getItem("locale");return e&&qn[e]?e:(navigator.language||navigator.userLanguage||"").startsWith("en")?"en":"zh-CN"}function Td(e,t){return qn=t,ks=Vue.ref(fy()),document.documentElement.setAttribute("lang",ks.value),e.config.globalProperties.$t=Oe,e.config.globalProperties.$locale=ks,e.provide("t",Oe),e.provide("locale",ks),{t:Oe,setLocale:Rr,getLocale:gy,locale:ks}}var ks,qn,ss=B(()=>{ks=null,qn={}});function Vn(e){return e?.capabilityMetadataProvided!==!0?!0:Array.isArray(e.capabilities)&&e.capabilities.includes(La)}var La,Ni=B(()=>{La="yeaft_plugins"});function Wi(e){if(e?.capabilityMetadataProvided!==!0)return!1;let t=Array.isArray(e.capabilities)?e.capabilities:[];return t.includes(La)&&t.includes(hy)}var hy,Fa=B(()=>{Ni();hy="yeaft_managed_skills"});function gn(e){if(e==null||e==="")return"claude-code";if(my.has(e))return e;throw new Error(`Unknown Chat runtime provider: ${e}`)}function Vs(e){if(typeof e!="string"||!e)throw new Error("Chat catalog key requires conversationId");return`chat:${e}`}function Hn(e,t){if(typeof e!="string"||!e||typeof t!="string"||!t)throw new Error("Yeaft catalog key requires agentId and sessionId");return`yeaft:${e}:${t}`}function _r(e,t,s={}){let n=e.sessionCatalog.map(i=>({...i})),r=Array.isArray(e.hiddenSessionCatalog)?e.hiddenSessionCatalog.map(i=>({...i})):null;return e.sessionCatalogMutationRequests[t]={previousCatalog:n,previousHiddenCatalog:r,...s},n}function Md(e,t){let s=t?.requestId?e.sessionCatalogMutationRequests[t.requestId]:null;return s?(delete e.sessionCatalogMutationRequests[t.requestId],t.ok!==!0&&(e.sessionCatalog=s.previousCatalog,Array.isArray(s.previousHiddenCatalog)&&(e.hiddenSessionCatalog=s.previousHiddenCatalog)),!0):!1}function Pd(e,t,s="recent",n=null){let r=Vs(t),i=e.chatHistoryRequests[r]||{},o=Number(i.generation||0)+1,a=`chat_history_${o}_${crypto.randomUUID()}`;return e.chatHistoryRequests[r]={requestId:a,catalogKey:r,generation:o,mode:s,cursor:n,connectionGeneration:Number(e.chatHistoryConnectionGeneration||0),loading:!0,cancelled:!1,error:null},a}function Oa(e,t,s,n){let r=e.chatHistoryRequests[t];return r?.requestId!==s?!1:(e.chatHistoryRequests[t]={...r,loading:!1,cancelled:!0,error:n},!0)}var my,ji=B(()=>{my=new Set(["claude-code","copilot"])});function Bn(e,t,s=""){Er&&(clearTimeout(Er),Er=null),e.sessionLoading=t,e.sessionLoadingText=s,t&&(Er=setTimeout(()=>{e.sessionLoading&&(e.sessionLoading=!1,e.sessionLoadingText=""),Er=null},vy))}function ns(e){Bn(e,!1)}function Rd(e){if(e.currentConversation){e.pendingRecovery=null;return}let t=e.lastUsedSession,s=e.lastUsedAgent;if(t&&t.sessionId&&s){let n=e.agents.find(r=>r.id===s&&r.online);n&&(e.pendingRecovery={agentId:s,agentName:n.name,sessionId:t.sessionId,workDir:t.workDir,provider:gn(t.provider),catalogKey:t.catalogKey||null},e.recoveryDismissed=!1)}}function _d(e){if(!e.pendingRecovery)return;let{agentId:t,sessionId:s,workDir:n,provider:r}=e.pendingRecovery;e.selectAgent(t),setTimeout(()=>{e.resumeConversation(s,n,t,{provider:gn(r)}),e.pendingRecovery=null,e.recoveryDismissed=!1},500)}function Ed(e){e.recoveryDismissed=!0,e.pendingRecovery=null}function Dd(e,t){let s=e.conversations.find(n=>n.id===t);s&&(e.activeConversations=[t],e.currentWorkDir=s.workDir,e.messagesMap[t]?.length>0||(s.claudeSessionId?(e.messagesMap[t]=[],Bn(e,!0,Oe("chat.session.loadingHistory")),e.sendWsMessage({type:"resume_conversation",agentId:s.agentId||e.currentAgent,claudeSessionId:s.claudeSessionId,workDir:s.workDir,conversationId:t})):(e.messagesMap[t]=[],e.requestChatHistory?.(t,{mode:"recent",turns:5}))),e.sendWsMessage({type:"select_conversation",conversationId:t}))}function $d(e){if(e.panels.length>0)return;let t=localStorage.getItem("panels");if(!t)return;let s;try{s=JSON.parse(t)}catch{localStorage.removeItem("panels");return}if(!Array.isArray(s)||s.length<2){localStorage.removeItem("panels");return}let n=new Set(e.conversations.map(i=>i.id)),r=s.filter(i=>i&&typeof i.id=="string").map(i=>({id:i.id,conversationId:i.conversationId&&n.has(i.conversationId)?i.conversationId:null,activeRightPanel:i.activeRightPanel||null}));if(r.length<2){localStorage.removeItem("panels");return}e.panels=r,e.activePanelId=r[0]?.id||null;for(let i of r)i.conversationId&&(e.activeConversations.includes(i.conversationId)||e.activeConversations.push(i.conversationId),e.messagesMap[i.conversationId]||(e.messagesMap[i.conversationId]=[]),e.messagesMap[i.conversationId].length||e.requestChatHistory?.(i.conversationId,{mode:"recent",turns:5}))}function fn(e){if(e.currentAgent){if(localStorage.setItem("lastUsedAgent",e.currentAgent),localStorage.setItem("lastViewedConversation",e.currentConversation||""),e.lastViewedConversation=e.currentConversation,e.currentConversation){let t=e.conversations.find(s=>s.id===e.currentConversation);if(t?.claudeSessionId&&t?.workDir){let s=gn(t.provider),n={sessionId:t.claudeSessionId,workDir:t.workDir,agentId:t.agentId||e.currentAgent,provider:s,catalogKey:Vs(t.id),version:2};localStorage.setItem("lastUsedSession",JSON.stringify(n)),localStorage.setItem("lastViewedSessionRef",JSON.stringify(n)),e.lastUsedSession=n}}e.lastUsedAgent=e.currentAgent,e.panels.length>0?localStorage.setItem("panels",JSON.stringify(e.panels)):localStorage.removeItem("panels")}}function Ld(e){return e.lastUsedSession}function Fd(e){localStorage.removeItem("lastUsedAgent"),localStorage.removeItem("lastUsedSession"),localStorage.removeItem("lastViewedSessionRef"),localStorage.removeItem("lastViewedConversation"),localStorage.removeItem("panels"),localStorage.removeItem("splitPanesSaved"),e.lastUsedAgent=null,e.lastUsedSession=null,e.lastViewedConversation=null}function Od(e,t,s){if(!e.currentAgent){e.historySessionsLoading=!1;return}if(!t){e.historySessions=[],e.historySessionsLoading=!1;return}let n=Date.now().toString();e._historySessionsRequestId=n,e.historySessionsLoading=!0,e.historySessions=[],e.sendWsMessage({type:"list_history_sessions",workDir:t,provider:s||"claude-code",requestId:n})}function qd(e,t){if(!e.currentAgent)return e.foldersLoading=!1,Promise.resolve();e.foldersLoading=!0,e.folders=[];let s=Date.now().toString();return e._foldersRequestId=s,new Promise(n=>{e._foldersResolve&&e._foldersResolve(),e._foldersResolve=n,e.sendWsMessage({type:"list_folders",provider:t||"claude-code",requestId:s}),setTimeout(()=>{e._foldersResolve===n&&(e._foldersResolve(),e._foldersResolve=null,e.foldersLoading=!1)},1e4)})}function Vd(e,t,s){if(!t)return e.foldersLoading=!1,Promise.resolve();e.foldersLoading=!0,e.folders=[];let n=Date.now().toString();return e._foldersRequestId=n,new Promise(r=>{e._foldersResolve&&e._foldersResolve(),e._foldersResolve=r,e.sendWsMessage({type:"list_folders",agentId:t,provider:s||"claude-code",requestId:n}),setTimeout(()=>{e._foldersResolve===r&&(e._foldersResolve(),e._foldersResolve=null,e.foldersLoading=!1)},1e4)})}function Hd(e,t,s){if(!t)return Promise.resolve([]);let n=`models-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;return e._modelsRequestId=n,e.providerModelsLoading=!0,new Promise(r=>{e._modelsResolve&&e._modelsResolve([]),e._modelsTimeout&&clearTimeout(e._modelsTimeout),e._modelsResolve=r,e.sendWsMessage({type:"list_models",agentId:t,provider:s||"claude-code",requestId:n}),e._modelsTimeout=setTimeout(()=>{e._modelsResolve===r&&(e._modelsResolve([]),e._modelsResolve=null,e.providerModelsLoading=!1),e._modelsTimeout=null},1e4)})}function Bd(e,t,s,n){if(!t){e.historySessionsLoading=!1;return}if(!s){e.historySessions=[],e.historySessionsLoading=!1;return}let r=Date.now().toString();e._historySessionsRequestId=r,e.historySessionsLoading=!0,e.historySessions=[],e.sendWsMessage({type:"list_history_sessions",agentId:t,workDir:s,provider:n||"claude-code",requestId:r})}async function Nd(e,t=20){if(Ge().isAuthenticated){e.globalSessionsLoading=!0;try{let n=await fetch(`/api/sessions?limit=${t}`);if(n.ok){let r=await n.json();e.globalSessions=r.sessions||[]}}catch{}finally{e.globalSessionsLoading=!1}}}async function Wd(e,t){if(!Ge().isAuthenticated)return!1;try{if((await fetch(`/api/sessions/${t}`,{method:"DELETE"})).ok)return e.globalSessions=e.globalSessions.filter(r=>r.id!==t),!0}catch{}return!1}function qa(e,t){return t.agentId?e.agents.find(s=>s.id===t.agentId):t.agentName?e.agents.find(s=>s.name===t.agentName):null}function jd(e,t){let s=qa(e,t);return s&&s.online}var vy,Er,hn=B(()=>{qt();ss();ji();vy=3e4,Er=null});function Ud(){typeof window>"u"||typeof window.dispatchEvent!="function"||typeof CustomEvent>"u"||window.dispatchEvent(new CustomEvent("browser-runtime-transport-reset"))}function Kd(e){return e?.code===1008&&String(e.reason||"").toLowerCase().includes("authentication")}function zd(e){let t=Dr;Dr=[];for(let{resolve:s,reject:n,timer:r}of t)clearTimeout(r),e?s():n(new Error("WebSocket reconnect failed"))}function Gd(e,t){if(!e.ws||e.ws.readyState!==WebSocket.OPEN)return!1;if(e.currentView==="yeaft"&&by.has(t.type)){let s=t.conversationId;if(!s||typeof s=="string"&&s.startsWith("yeaft-")||s===e.yeaftConversationId)return!1}try{if(e.serverEncryptionRequired&&e.sessionKey){let s=bd(t,e.sessionKey);e.ws.send(JSON.stringify(s))}else e.ws.send(JSON.stringify(t));return!0}catch{return!1}}function $r(e,t=1e4){return e.ws&&e.ws.readyState===WebSocket.OPEN?Promise.resolve():new Promise((s,n)=>{let r=setTimeout(()=>{Dr=Dr.filter(i=>i.resolve!==s),n(new Error("WebSocket reconnect timeout"))},t);Dr.push({resolve:s,reject:n,timer:r}),(!e.ws||e.ws.readyState!==WebSocket.CONNECTING)&&(e.reconnectAttempts=0,e.connect())})}function Qd(e,t){try{let s=JSON.parse(t);return e.sessionKey&&kd(s)?wd(s,e.sessionKey):s}catch{return null}}function Yd(e,t,s,n){for(let[r,i]of e._sessionCrudPending?.entries?.()||[])Number(i?.connectionGeneration||0)===Number(t||0)&&(i.resolve?.({ok:!1,requestId:r,error:{code:s,message:n}}),e._sessionCrudPending.delete(r))}function Xd(e){let t=Ge(),s=location.protocol==="https:"?"wss:":"ws:";e.reconnectTimer&&(clearTimeout(e.reconnectTimer),e.reconnectTimer=null);let n=t.getActiveToken?.()||t.token||null,r=t.authGeneration;if(e.ws&&e.ws.readyState===WebSocket.CONNECTING&&e._wsAuthToken===n&&e._wsAuthGeneration===r)return;clearTimeout(e._legacyYeaftSessionHydrateTimer),e._legacyYeaftSessionHydrateTimer=null,e._hasHandledAgentList=!1,e._hasHandledYeaftSessionHydrate=!1,e.yeaftSessionInventoryCompleteSupported=null,e.workbenchRouteProtocolSupported=null,e.browserRuntimeProtocolSupported=null,e.browserRuntimeSetupProtocolSupported=null,e.browserRuntimeServerEnabled=!1,Ud(),e.yeaftSessionHydrateRequestId=null,e.yeaftSessionHydrateSlices=[],e.yeaftSessionHydrateError=null,e._yeaftSessionInventorySocketQuarantined=!1,e.pendingAgentSelection=null,e.agentSwitching=!1,e.ws&&(Yd(e,e.chatHistoryConnectionGeneration,"connection_changed","WebSocket connection changed"),e.ws.onopen=null,e.ws.onmessage=null,e.ws.onclose=null,e.ws.close(),e.ws=null),e.connectionState=e.reconnectAttempts>0?"reconnecting":"connecting",e.serverEncryptionRequired=!0,e.chatHistoryRequestIdSupported=null;let i=Number(e.chatHistoryConnectionGeneration||0)+1;e.chatHistoryConnectionGeneration=i;for(let[c,d]of Object.entries(e.projectMutationRequests||{}))d?.resolve?.({ok:!1,requestId:c,error:{code:"connection_changed"}});e.projectMutationRequests={},e.sessionProjects=[];for(let[c,d]of Object.entries(e.chatHistoryRequests||{}))d?.loading&&(e.chatHistoryRequests[c]={...d,loading:!1,cancelled:!0,error:"connection_changed"});let o=Object.values(e.sessionCatalogMutationRequests||{});o.length>0&&(e.sessionCatalog=o[0].previousCatalog,Array.isArray(o[0].previousHiddenCatalog)&&(e.hiddenSessionCatalog=o[0].previousHiddenCatalog),e.sessionCatalogMutationRequests={}),e.sessionCatalogLoaded=!1,e.sessionCatalog=[],e.hiddenSessionCatalog=[],e.activeCatalogKey=null,e._wsAuthToken=n,e._wsAuthGeneration=r;let a=`${s}//${location.host}?type=web`;n&&(a+=`&token=${encodeURIComponent(n)}`);let l=new WebSocket(a);e.ws=l,l.onopen=()=>{if(l===e.ws){e.connectionState="connected",e.reconnectAttempts=0,e.startHeartbeat();try{l.send(JSON.stringify({type:"client_hello",plaintextOk:!0,workbenchRouteProtocol:1,browserRuntimeProtocol:1,browserRuntimeSetupProtocol:1}))}catch{}zd(!0)}},l.onmessage=c=>{if(l!==e.ws)return;let d=e.parseWsMessage(c.data);d&&(d.type,e.handleMessage({...d,_wsAuthToken:n,_wsAuthGeneration:r}))},l.onclose=c=>{if(l!==e.ws){Kd(c)&&t.handleAuthFailure?.(void 0,n,r);return}e.authenticated=!1,clearTimeout(e._legacyYeaftSessionHydrateTimer),e._legacyYeaftSessionHydrateTimer=null,e._hasHandledAgentList=!1,e._hasHandledYeaftSessionHydrate=!1,e.yeaftSessionInventoryCompleteSupported=null,e.workbenchRouteProtocolSupported=null,e.browserRuntimeProtocolSupported=null,e.browserRuntimeSetupProtocolSupported=null,e.browserRuntimeServerEnabled=!1,Ud(),e.yeaftSessionHydrateRequestId=null,e.yeaftSessionHydrateSlices=[],e.yeaftSessionHydrateError=null;for(let u of Object.values(e._workCenterFeaturePending||{}))clearTimeout(u.timer),u.reject(new Error("WebSocket disconnected"));e._workCenterFeaturePending={},Yd(e,i,"agent_offline","WebSocket disconnected"),e.pendingAgentSelection=null,e.agentSwitching=!1;let d=e.connectionState==="updating";if(e.connectionState=d?"updating":"disconnected",e.stopHeartbeat(),ns(e),Kd(c)){t.handleAuthFailure?.(void 0,n,r),e.reconnectAttempts=0,zd(!1);return}if(e._yeaftReconnectCatchUpPending=!0,d){e.reconnectAttempts=0,e.reconnectTimer=setTimeout(()=>{e.connect()},2e3);return}e.scheduleReconnect()},e.ws.onerror=c=>{}}function Zd(e){if(e.reconnectAttempts>=e.maxReconnectAttempts){e.connectionState="disconnected";return}let t=Math.min(1e3*Math.pow(2,e.reconnectAttempts),3e4);e.reconnectAttempts++,e.connectionState="reconnecting",e.reconnectTimer=setTimeout(()=>{e.connect()},t)}function Jd(e){e.reconnectAttempts=0,e.connect()}function eu(e){e.stopHeartbeat(),e._lastPongAt=Date.now(),e.heartbeatTimer=setInterval(()=>{if(e.ws&&e.ws.readyState===WebSocket.OPEN){if(Date.now()-e._lastPongAt>45e3){e.ws.close(4e3,"Heartbeat timeout");return}try{e.sendWsMessage({type:"ping"})}catch{}}},25e3)}function tu(e){e.heartbeatTimer&&(clearInterval(e.heartbeatTimer),e.heartbeatTimer=null)}function su(e){e._visibilityHandlerInstalled||(e._visibilityHandlerInstalled=!0,document.addEventListener("visibilitychange",()=>{if(document.visibilityState==="visible")if(!e.ws||e.ws.readyState!==WebSocket.OPEN)e.reconnectAttempts=0,e.connect();else try{e.sendWsMessage({type:"ping"});let t=e._lastPongAt;setTimeout(()=>{e._lastPongAt===t&&e.ws&&e.ws.close(4001,"Visibility resume timeout")},3e3)}catch{e.reconnectAttempts=0,e.connect()}}))}var Dr,by,Va=B(()=>{qt();qi();hn();Dr=[];by=new Set(["sync_messages","refresh_conversation","select_conversation","cancel_execution","update_conversation_settings","ask_user_answer"])});function Le(e,t){let s=t==null?"__all__":String(t);return e?`${e}${s}`:s}function Lr(e){return typeof e?.entryId=="string"&&e.entryId?`entry:${e.entryId}`:e?.role==="assistant"&&e?.turnId?`live-response:${e.turnId}:${e.speakerVpId||e.vpId||""}`:typeof e?.clientMessageId=="string"&&e.clientMessageId?`client:${e.clientMessageId}`:`message:${e?.messageId||""}`}function Fr(e,t,s){return typeof s!="string"||!s?null:`${Le(e,t)}message:${s}`}function Hs(e,t,s){return typeof s!="string"||!s?null:`${Le(e,t)}client:${s}`}var Nn=B(()=>{});function Ha(e){return typeof e=="string"&&e?e:null}function Wn(e,t){return e?.yeaftSessionHistoryState?.[t]||null}function Xt(e){let t=e?.yeaftActiveSessionFilter||null;if(!t)try{t=(typeof window<"u"&&window.Pinia?.useSessionsStore?.())?.activeSessionId||null}catch{}if(!t)return{agentId:e?.currentAgent||null,sessionId:null,sessionKey:""};let s=(()=>{try{let n=typeof window<"u"&&window.Pinia?.useSessionsStore?.(),r=n?.activeSessionKey?n.sessions?.[n.activeSessionKey]:null;if(r?.id===t&&r.agentId)return r.agentId}catch{}return typeof e?.resolveYeaftSessionAgentId=="function"?e.resolveYeaftSessionAgentId(t):e?.currentAgent||null})();return{agentId:s,sessionId:t,sessionKey:Le(s,t)}}function ru(e,{agentId:t,sessionId:s,mode:n="recent",preserveLoaded:r=!1,latestSeq:i=null}={}){if(!t||!s)return null;let o=Le(t,s),a=Wn(e,o)||{},l=Number(a.generation||0)+1,c=`yeaft_history_${l}_${crypto.randomUUID()}`,d={...a,loaded:!!a.loaded,loading:!0,error:null,requestId:c,generation:l,mode:n,background:n==="prefetch",requestedAt:Date.now(),latestSeq:Number.isFinite(i)?i:a.latestSeq??null};return delete d.completionSeen,r||(d.syncingAfterSeq=null,a.loaded||(d.hasMore=!1,d.oldestSeq=null,d.serverOldestFetchedSeq=null,d.serverHasMore=!1,d.gapQueue=[],d.requestedBeforeSeqs=[],d.count=0)),e.yeaftSessionHistoryState={...e.yeaftSessionHistoryState||{},[o]:d},mn(e),{sessionKey:o,requestId:c,generation:l,state:d}}function Ba(e,t={}){let s=t.sessionId??t.groupId??null;if(!s)return!1;let n=t.agentId||e?.yeaftSessionAgentById?.[s]||null,r=Le(n,s),i=Wn(e,r),o=Ha(t.requestId);if(!i)return o===null;let a=Ha(i.requestId);return o?o===a:a===null}function iu(e,t={},s={},n="chunk"){if(!Ba(e,t))return null;let r=t.sessionId??t.groupId??null,i=t.agentId||e?.yeaftSessionAgentById?.[r]||null,o=Le(i,r),a=Wn(e,o)||{},l=Ha(t.requestId),c=l!==null&&n==="completion",d={...a,...c?{}:s,...c?{completionSeen:!0}:{},error:null};return c?(d.loading=!0,d.requestId=l):(d.loading=!1,d.requestId=null,d.completedAt=Date.now(),delete d.completionSeen),e.yeaftSessionHistoryState={...e.yeaftSessionHistoryState||{},[o]:d},mn(e),d}function Or(e,{agentId:t,sessionId:s,requestId:n,error:r="history_load_failed"}={}){if(!t||!s||!n)return!1;let i=Le(t,s),o=Wn(e,i);return!o||o.requestId!==n||!o.loading?!1:(e.yeaftSessionHistoryState={...e.yeaftSessionHistoryState||{},[i]:{...o,loading:!1,error:r,requestId:null,completedAt:Date.now()}},mn(e),!0)}function mn(e){let{sessionKey:t}=Xt(e),s=t?Wn(e,t):null;return e.yeaftLoadingMoreHistory=!!s?.loading&&s?.mode!=="prefetch",e.yeaftHistoryLoadError=s?.error||null,e.yeaftHasMoreHistory=!!s?.hasMore,e.yeaftOldestLoadedSeq=Number.isFinite(s?.serverOldestFetchedSeq)?s.serverOldestFetchedSeq:Number.isFinite(s?.oldestSeq)?s.oldestSeq:null,s}function Na(e){let{sessionKey:t}=Xt(e);return t?Wn(e,t):null}var nu,Ui=B(()=>{Nn();nu=15e3});function Wa(e){return e?.sessionId??e?.groupId??null}function Ua(e){for(let t of[e?.persistedMessageId,e?.messageId,e?.id]){if(typeof t!="string")continue;let s=t.match(/^(m\d+)/);if(s)return s[1]}return null}function vt(e){return e?.isStreaming||e?.status==="pending"?!1:Number.isFinite(e?.seq)||!!Ua(e)||e?.isHistory===!0&&!e?.clientMessageId}function Ki(e){if(Number.isFinite(e?.seq))return Number(e.seq);let s=Ua(e)?.match(/^m(\d+)$/);if(s)return Number(s[1]);let n=typeof e?.id=="string"?e.id.match(/^(\d+)/):null;return n?Number(n[1]):null}function ky(e){try{return new TextEncoder().encode(JSON.stringify(e)).length}catch{return 0}}function Sy(e){return e?e.isStreaming||e.status==="pending"||e.type==="tool-use"&&(e.askPending||!e.hasResult&&(e.toolName==="AskUser"||e.toolName==="AskUserQuestion"))?!0:e.type!=="user"||!e.clientMessageId?!1:!e.dbMessageId&&!Ua(e):!1}function Iy(e){let t=[],s=null;for(let n of e)(n?.type==="user"||!s)&&(s={rows:[],protected:!1},t.push(s)),s.rows.push(n),Sy(n)&&(s.protected=!0);return t}function au(e,{conversationId:t,agentId:s=null,sessionId:n=null,limits:r=ou}={}){let i=e?.messagesMap?.[t];if(!Array.isArray(i)||i.length===0||!s||!n)return{evictedRows:0,keptRows:0};let o=b=>Wa(b)===n,a=i.filter(o),l=Iy(a);if(l.length===0)return{evictedRows:0,keptRows:0};let c=l.filter(b=>b.protected),d=new Set(c),u=Number.isFinite(r.maxTurnsPerSession)?Math.max(0,Math.floor(r.maxTurnsPerSession)):ja,g=Math.max(0,u-c.length);for(let b=l.length-1;b>=0&&g>0;b-=1){let w=l[b];d.has(w)||(d.add(w),g-=1)}let p=new Set(l.filter(b=>d.has(b)).flatMap(b=>b.rows)),f=a.filter(b=>!p.has(b));if(f.length===0)return{evictedRows:0,keptRows:p.size};let m=i.filter(b=>!o(b)||p.has(b));i.splice(0,i.length,...m);let v=Le(s,n),y=e.yeaftHistoryCacheState?.[v]||null,h=lu(a.filter(b=>p.has(b))),S=JSON.stringify(y?.ranges||[])===JSON.stringify(h.ranges)?Number(y?.rangeEpoch)||0:(Number(y?.rangeEpoch)||0)+1;if(e.yeaftHistoryCacheState={...e.yeaftHistoryCacheState||{},[v]:{...y||{},agentId:s,sessionId:n,conversationId:t,lastAccessed:Date.now(),rangeEpoch:S,...h}},f.some(vt)){let b=h.ranges[0]?.startSeq??null,w=e.yeaftSessionHistoryState?.[v]||{};e.yeaftSessionHistoryState={...e.yeaftSessionHistoryState||{},[v]:{...w,serverOldestFetchedSeq:b,oldestSeq:b,serverHasMore:b!==null,hasMore:b!==null,gapTraversalInitialized:!1,gapQueue:[],requestedBeforeSeqs:[],completedHistoryWorkKeys:[],pendingPageKind:null,pendingPageBeforeSeq:null,pendingGapStopAtSeq:null,pendingCacheEpoch:null,pendingHistoryWorkKey:null,paginationError:null,count:h.rowCount}};let P=Xt(e);P.agentId===s&&P.sessionId===n&&mn(e)}return{evictedRows:f.length,keptRows:p.size}}function Cy(e){let t=[],s=null;for(let n of e)vt(n)&&((n?.type==="user"||!s)&&(s=[],t.push(s)),s.push(n));return t}function Ay(e,t){let s=Number.isFinite(t.maxTurnsPerSession)?Math.max(0,Math.floor(t.maxTurnsPerSession)):ja,n=Cy(e),r=new Set(n.slice(-s).flat());for(let i of n)if(i.some(o=>o?._historyWindowDetached===!0))for(let o of i)r.add(o);return r}function xy(e){let t=Array.from(new Set(e.map(Ki).filter(Number.isFinite))).sort((n,r)=>n-r),s=[];for(let n of t){let r=s.at(-1);r&&n<=r.endSeq+1?r.endSeq=n:s.push({startSeq:n,endSeq:n})}return s}function lu(e){let t=e.filter(vt);return{rowCount:t.length,byteCount:t.reduce((s,n)=>s+ky(n),0),ranges:xy(t)}}function Ty(e,t,s){let n=new Set((t||[]).map(r=>r?.stableKey).filter(Boolean));if(n.size!==0)for(let r of e)r?.stableKey&&n.has(r.stableKey)&&(r._historyCacheTouchedAt=s)}function My(e,{conversationId:t,agentId:s,sessionId:n,incomingRows:r,now:i,limits:o}){let a=e.messagesMap?.[t]||[],l=a.filter(h=>Wa(h)===n);Ty(l,r,i);let c=Ay(l,o),d=l.filter(h=>!vt(h)||c.has(h)),u=new Set(d),g=a.filter(h=>Wa(h)!==n||u.has(h));a.splice(0,a.length,...g);let p=lu(d),f=Le(s,n),m=e.yeaftHistoryCacheState?.[f]||null,y=JSON.stringify(m?.ranges||[])===JSON.stringify(p.ranges)?Number(m?.rangeEpoch)||0:(Number(m?.rangeEpoch)||0)+1;e.yeaftHistoryCacheState={...e.yeaftHistoryCacheState||{},[f]:{agentId:s,sessionId:n,conversationId:t,lastAccessed:i,rangeEpoch:y,...p}}}function cu(e,t,s,n=Date.now()){if(!t||!s)return;let r=Le(t,s),i=e.yeaftHistoryCacheState?.[r];i&&(e.yeaftHistoryCacheState={...e.yeaftHistoryCacheState||{},[r]:{...i,lastAccessed:n}})}function Ka(e,{conversationId:t,agentId:s,sessionId:n,incomingRows:r=[],now:i=Date.now(),limits:o=ou}={}){!e||!t||!s||!n||My(e,{conversationId:t,agentId:s,sessionId:n,incomingRows:r,now:i,limits:o})}var ja,ou,zi=B(()=>{Nn();Ui();ja=500,ou=Object.freeze({maxTurnsPerSession:ja})});function Ss(e){return e?.sessionId??e?.groupId??null}function uu(e){let t=e?.stableKey??e?.uiKey??e?.messageId??e?.dbMessageId??e?.id;return t==null||t===""?null:String(t)}function Py(e,t){if(e?.type!=="assistant"||t?.type!=="assistant"||Ss(e)!==Ss(t)||e.isHistory===!0&&!e.isStreaming||t._hasPersistedTurnId!==!0||!e.turnId||!t.turnId||e.turnId!==t.turnId)return!1;let s=e.speakerVpId||e.vpId||"",n=t.speakerVpId||t.vpId||"";if(s&&n&&s!==n)return!1;let r=e.threadId||"",i=t.threadId||"";if(r&&i&&r!==i)return!1;let o=typeof e.content=="string"?e.content:"",a=typeof t.content=="string"?t.content:"";return!!o&&!!a&&(a.startsWith(o)||o.startsWith(a))}function pu(e,t){let s=e.uiKey||t.uiKey||null;return Object.assign(e,t),s&&(e.uiKey=s),vt(t)&&(e.isStreaming=!1,e.status==="pending"&&(e.status="completed")),e}function Yi(e){let t=vt(e),s=t?Ki(e):null,n=Number(e?.timestamp),r=Number.isFinite(n)&&n>0?n:t?-1/0:1/0;return[r,Number.isFinite(r)?0:Number.isFinite(s)?s:-1]}function Ry(e,t,s){let n=[],r=new Map,i=new Map;for(let l=t;l<s;l+=1){let c=e[l],d=Ss(c),u=vt(c)?Ki(c):null,g=i.get(d);if(!Number.isFinite(u)&&g){g.rows.push(c);continue}let p={sessionId:d,seq:u,rows:[c]};n.push(p),i.set(d,p),Number.isFinite(u)&&(r.has(d)||r.set(d,[]),r.get(d).push(p))}for(let l of r.values())l.sort((c,d)=>c.seq-d.seq);let o=new Map,a=t;for(let l of n){let c=l;if(Number.isFinite(l.seq)){let d=o.get(l.sessionId)||0;c=r.get(l.sessionId)[d],o.set(l.sessionId,d+1)}for(let d of c.rows)e[a++]=d}}function za(e){e.sort((t,s)=>{let n=Yi(t),r=Yi(s);for(let i=0;i<n.length;i+=1)if(n[i]!==r[i])return n[i]-r[i];return 0});for(let t=0;t<e.length;){let s=Yi(e[t])[0],n=t+1;for(;n<e.length&&Yi(e[n])[0]===s;)n+=1;Number.isFinite(s)&&n-t>1&&Ry(e,t,n),t=n}return e}function _y(e,t){return Array.isArray(e.messagesMap?.[t])||(e.messagesMap=e.messagesMap||{},e.messagesMap[t]=[]),e.messagesMap[t]}function Ya(e,t){return e.filter(s=>t===void 0||Ss(s)===t)}function gu(e,t){let s=uu(t);if(s){let n=e.find(r=>uu(r)===s);if(n)return n}if(t?.type==="user"&&t.clientMessageId){let n=e.find(r=>r?.type==="user"&&r.clientMessageId===t.clientMessageId&&Ss(r)===Ss(t));if(n)return n}return t?.type==="assistant"&&e.find(n=>Py(n,t))||null}function rs(e){if(!e||typeof e!="object")return null;let t=du.get(e);return t||(t=new Ga(e),du.set(e,t)),t}var du,Ga,qr=B(()=>{zi();du=new WeakMap;Ga=class{constructor(t){this.store=t}rows(t){return _y(this.store,t)}durableRows(t,s=void 0){return Ya(this.rows(t),s).filter(vt)}overlayRows(t,s=void 0){return Ya(this.rows(t),s).filter(n=>!vt(n))}snapshot(t,s=void 0){return{durableRows:this.durableRows(t,s),overlayRows:this.overlayRows(t,s)}}commitDurable({conversationId:t,sessionId:s=void 0,rows:n=[],mode:r="delta",replaceDurable:i=!1,preserveEmpty:o=!0}={}){if(!t)return{insertedRows:0,preservedEmpty:!1};let a=this.rows(t),l=Array.isArray(n)?n.filter(Boolean):[],c=Ya(a,s).length>0;if(o&&r==="recent"&&l.length===0&&c)return{insertedRows:0,inserted:[],preservedEmpty:!0};if(i){let g=a.filter(p=>Ss(p)!==s||!vt(p));a.splice(0,a.length,...g)}let d=0,u=[];for(let g of l){let p=gu(a,g);p?pu(p,g):(a.push(g),u.push(g),d+=1)}return za(a),{insertedRows:d,inserted:u,preservedEmpty:!1}}upsertOverlay({conversationId:t,row:s}={}){if(!t||!s)return null;let n=this.rows(t),r=gu(n,s);return r?pu(r,s):n.push(s),za(n),r||s}appendOverlayText({conversationId:t,sessionId:s=void 0,turnId:n=null,text:r=""}={}){if(!t||!r)return null;let o=this.rows(t).findLast(a=>a?.type==="assistant"&&!vt(a)&&(s===void 0||Ss(a)===s)&&(!n||a.turnId===n));return o?(o.content?r.startsWith(o.content)?o.content=r:o.content.endsWith(r)||(o.content+=r):o.content=r,o):null}replaceProjection(t,s=[]){let n=this.rows(t);return n.splice(0,n.length,...Array.isArray(s)?s:[]),za(n),n}removeDurable({conversationId:t,sessionId:s}={}){if(!t)return 0;let n=this.rows(t),r=n.filter(o=>Ss(o)!==s||!vt(o)),i=n.length-r.length;return n.splice(0,n.length,...r),i}}});function Vr(e,t){return t?t===e.yeaftConversationId?!0:Object.values(e.yeaftConversationIdsByAgent||{}).includes(t):!1}function jn(e,t,s){s&&(s.type!=="assistant"&&s.type!=="tool-use"||Vr(e,t)&&(!s.vpId&&e._currentYeaftVpId&&(s.vpId=e._currentYeaftVpId),!s.turnId&&e._currentYeaftTurnId&&(s.turnId=e._currentYeaftTurnId),!s.speakerVpId&&s.vpId&&(s.speakerVpId=s.vpId)))}function Dy(e){let t=[e?.timestamp,e?.createdAt,e?.ts,e?.time,e?.created_at];for(let s of t){if(typeof s=="number"&&Number.isFinite(s)&&s>0)return s;if(typeof s=="string"&&s.trim()){let n=Date.parse(s);if(Number.isFinite(n))return n;let r=Number(s);if(Number.isFinite(r)&&r>0)return r}}return Date.now()}function Gi(e){let t=e?.stableKey??e?.messageId??e?.dbMessageId??e?.id;return t==null||t===""?null:String(t)}function Qa(e,t,s){if(!s||typeof s!="object")return null;if(typeof s.uiKey=="string"&&s.uiKey)return s.uiKey;let n=s.entryId||s.stableKey||s.atMessageId||s.messageId||s.dbMessageId||s.id||null;if(n!=null&&n!=="")return s.uiKey=String(n),s.uiKey;let r=`legacy:${t||"conversation"}:`,i=new Set((e?.messagesMap?.[t]||[]).map(a=>a?.uiKey).filter(a=>typeof a=="string"&&a)),o=Number(e?._messageUiKeySequence)||0;do o+=1;while(i.has(`${r}${o}`));return e&&(e._messageUiKeySequence=o),s.uiKey=`${r}${o}`,s.uiKey}function Hr(e,t,s){for(let n of Array.isArray(s)?s:[])Qa(e,t,n);return s}function Xa(e,t){if(!e||!t)return e;let s=e.type==="user"&&typeof e.id=="string"&&e.id===e.clientMessageId;for(let[n,r]of Object.entries(t))if(r!=null){if(n==="isStreaming"){e.isStreaming&&r===!1&&(e.isStreaming=!1);continue}if(!(n==="uiKey"&&e.uiKey)){if(n==="id"||n==="messageId"){if(s&&t.clientMessageId===e.clientMessageId&&t.messageId&&t.messageId!==e.clientMessageId)continue;(e[n]===void 0||e[n]===null||e[n]==="")&&(e[n]=r);continue}if(!(n==="turnId"&&s&&e.turnId===e.clientMessageId)){if(n==="content"&&typeof r=="string"){e.content||(e.content=r);continue}if(n==="responseKind"&&(r==="progress"||r==="result")){e.responseKind=r;continue}if(n==="attachments"&&Array.isArray(r)){(!Array.isArray(e.attachments)||e.attachments.length===0)&&(e.attachments=r);continue}(e[n]===void 0||e[n]===null||e[n]==="")&&(e[n]=r)}}}return e}function fu(e=[],t=[]){let s=[],n=new Map,r=new Map;for(let i of[...e,...t]){if(!i)continue;let o=Gi(i),a=i.type==="user"&&i.clientMessageId?String(i.clientMessageId):null;if(o&&n.has(o)){Xa(n.get(o),i);continue}if(a&&r.has(a)){let l=r.get(a);Xa(l,i),o&&!n.has(o)&&n.set(o,l);continue}s.push(i),o&&n.set(o,i),a&&r.set(a,i)}return s}function hu(e,t,s){return!e||e!==t?!1:!s?.loaded&&!s?.loading}function mu(e,t){return!!t&&!!e?.loaded&&!e?.loading&&Number.isFinite(e?.latestSeq)}function vu({sessionState:e,hasCachedSessionRows:t,force:s=!1}={}){return e?.loading?!1:s?!e?.loaded:e?.loaded?!1:!t}function $y(e,t,s,n){let r=s?.id?String(s.id):null;if(!r)return!1;let o=(e.messagesMap[t]||[]).find(a=>a?.type==="assistant"&&Gi(a)===r);return o?(o.id||(o.id=r),o.messageId||(o.messageId=r),s.ts&&!o.ts&&(o.ts=s.ts),s.timestamp&&!o.timestamp&&(o.timestamp=s.timestamp),s.sessionId&&!o.sessionId&&(o.sessionId=s.sessionId),s.vpId&&!o.vpId&&(o.vpId=s.vpId),s.turnId&&!o.turnId&&(o.turnId=s.turnId),s.threadId&&!o.threadId&&(o.threadId=s.threadId),o.content?typeof o.content=="string"&&(n.startsWith(o.content)?o.content=n:o.content.endsWith(n)||(o.content+=n)):o.content=n,jn(e,t,o),!0):!1}function Qi(e,t,s){if(!t)return;let n={...s};Qa(e,t,n);let r={...n,id:s.dbMessageId||s.id||Date.now().toString()+Math.random().toString(36).substr(2,9),timestamp:Dy(s)};if(Vr(e,t)&&!r.sessionId&&(r.sessionId=e._currentYeaftSessionId||e.yeaftActiveSessionFilter||Ey),Vr(e,t)){let o=e._currentYeaftAgentId||Object.entries(e.yeaftConversationIdsByAgent||{}).find(([,c])=>c===t)?.[0]||e.currentAgent||null,a=typeof r.messageId=="string"&&/^m\d+$/.test(r.messageId)?r.messageId:typeof r.id=="string"&&/^m\d+$/.test(r.id)?r.id:null,l=typeof r.clientMessageId=="string"?r.clientMessageId:null;r.stableKey||(r.stableKey=a?Fr(o,r.sessionId,a):Hs(o,r.sessionId,l)),r.uiKey||(r.uiKey=r.stableKey||null),!r.vpId&&e._currentYeaftVpId&&(r.vpId=e._currentYeaftVpId),!r.turnId&&e._currentYeaftTurnId&&(r.turnId=e._currentYeaftTurnId),jn(e,t,r)}if(e.messagesMap[t]||(e.messagesMap[t]=[]),Qa(e,t,r),Vr(e,t))return rs(e).upsertOverlay({conversationId:t,sessionId:r.sessionId,row:r});let i=Gi(s);if(i){let o=e.messagesMap[t].find(a=>Gi(a)===i);if(o)return Xa(o,r),t===e.yeaftConversationId&&e.messagesMap[t].sort((a,l)=>a.timestamp-l.timestamp),o}return e.messagesMap[t].push(r),t===e.yeaftConversationId&&e.messagesMap[t].sort((o,a)=>o.timestamp-a.timestamp),r}function yu(e,t,s,n={}){if(!t||!s)return;e.messagesMap[t]||(e.messagesMap[t]=[]);let r=e.messagesMap[t];if($y(e,t,n,s))return;if(Vr(e,t)){let l=rs(e).appendOverlayText({conversationId:t,sessionId:n.sessionId||e._currentYeaftSessionId||void 0,turnId:n.turnId||e._currentYeaftTurnId||null,text:s});if(l){jn(e,t,l),n.id&&!l.id&&(l.id=n.id),n.id&&!l.messageId&&(l.messageId=n.id);return}}let i=e._currentYeaftTurnId;if(i){for(let a=r.length-1;a>=0;a--)if(r[a].turnId===i&&r[a].type==="assistant"&&r[a].isStreaming){if(jn(e,t,r[a]),n.id&&!r[a].id&&(r[a].id=n.id),n.id&&!r[a].messageId&&(r[a].messageId=n.id),r[a].content.endsWith(s))return;r[a].content+=s;return}Qi(e,t,{...n.id?{id:n.id,messageId:n.id}:{},...n.ts?{ts:n.ts}:{},...n.timestamp?{timestamp:n.timestamp}:{},...n.sessionId?{sessionId:n.sessionId}:{},...n.vpId?{vpId:n.vpId}:{},...n.turnId?{turnId:n.turnId}:{},...n.threadId?{threadId:n.threadId}:{},type:"assistant",content:s,isStreaming:!0,status:"pending",turnStartAt:n.timestamp||Date.now()});return}let o=r[r.length-1];if(o&&o.type==="assistant"&&o.isStreaming){if(jn(e,t,o),n.id&&!o.id&&(o.id=n.id),n.id&&!o.messageId&&(o.messageId=n.id),o.content.endsWith(s))return;o.content+=s}else Qi(e,t,{...n.id?{id:n.id,messageId:n.id}:{},...n.ts?{ts:n.ts}:{},...n.timestamp?{timestamp:n.timestamp}:{},...n.sessionId?{sessionId:n.sessionId}:{},...n.vpId?{vpId:n.vpId}:{},...n.turnId?{turnId:n.turnId}:{},...n.threadId?{threadId:n.threadId}:{},type:"assistant",content:s,isStreaming:!0,status:"pending",turnStartAt:n.timestamp||Date.now()})}function bu(e,t,{completeLifecycle:s=!0}={}){if(!t)return;let n=e.messagesMap[t];if(!n||n.length===0)return;let r=e._currentYeaftTurnId||null;for(let i=n.length-1;i>=0;i--){let o=n[i];if(r&&o.turnId&&o.turnId!==r){if(o.type==="user")break;continue}if(o.isStreaming&&(o.isStreaming=!1,s&&o.status==="pending"&&(o.status="completed",o.turnEndAt=Date.now())),jn(e,t,o),o.type==="user")break}}function wu(e,t){if(!t||e.processingConversations&&e.processingConversations[t]||e.activeVpTurns&&Object.keys(e.activeVpTurns).length>0)return;let s=e.messagesMap&&e.messagesMap[t];if(!(!s||s.length===0))for(let n of s)n&&n.isStreaming&&(n.isStreaming=!1)}function ku(e,t){let s=e.currentConversation;if(!s)return;e.messagesMap[s]||(e.messagesMap[s]=[]);let n=e.messagesMap[s],r=null;for(let i of t)if(i.type==="user"){let o=i.message?.content;if(o){let a=typeof o=="string"?o:Array.isArray(o)?o.map(l=>l.text||"").join(""):"";a&&(r=a,e.addMessage({type:"user",content:a,isHistory:!0}))}}else if(i.type==="assistant"){let o=i.message?.content;if(o&&Array.isArray(o)){for(let a of o)if(a.type==="text"&&a.text)e.addMessage({type:"assistant",content:a.text,isHistory:!0});else if(a.type==="tool_use")e.addMessage({type:"tool-use",toolName:a.name,toolInput:a.input,isHistory:!0});else if(a.type==="tool_result"){for(let l=n.length-1;l>=0;l--)if(n[l].type==="tool-use"&&!n[l].hasResult){n[l].hasResult=!0,n[l].toolResult=a.content;break}}}}if(r&&s&&!e.conversationTitles[s]){let i=r.trim().substring(0,100);e.conversationTitles[s]=i}}function vn(e){if(!Array.isArray(e))return null;let t=null;for(let s of e)typeof s?.dbMessageId=="number"&&s.dbMessageId>0&&(t===null||s.dbMessageId>t)&&(t=s.dbMessageId);return t}function Ly(e){return{id:e.id,dbMessageId:e.id,timestamp:e.created_at}}function Su(e){if(!e)return null;let t=Ly(e);if(e.message_type==="tool_use"){let n={...t,type:"tool-use",toolName:e.tool_name||"unknown",toolInput:(()=>{try{return JSON.parse(e.tool_input||e.content||"{}")}catch{return{}}})(),hasResult:!0,isHistory:!0,startTime:e.created_at||0};if(e.metadata)try{let r=JSON.parse(e.metadata);r.askRequestId&&(n.askRequestId=r.askRequestId,n.askQuestions=r.askQuestions,n.askAnswered=!!r.askAnswered,n.selectedAnswers=r.selectedAnswers||null,r.askAnswered||(n.isHistory=!1))}catch{}return n}let s=n=>{if(!n)return"";if(typeof n!="string")return String(n);if(n.startsWith("["))try{let r=JSON.parse(n);if(Array.isArray(r))return r.filter(i=>i.type==="text"&&i.text).map(i=>i.text).join("")}catch{}return n};if(e.role==="user"){let n=null;if(e.metadata)try{let r=JSON.parse(e.metadata);r&&typeof r.clientMessageId=="string"&&(n=r.clientMessageId)}catch{}return{...t,type:"user",content:typeof e.content=="string"?e.content:String(e.content||""),...n?{clientMessageId:n}:{}}}else if(e.role==="assistant"){let n=s(e.content),r=(()=>{if(!e.content||typeof e.content!="string"||!e.content.startsWith("["))return[];try{let i=JSON.parse(e.content);return Array.isArray(i)?i.filter(o=>o.type==="tool_use"&&o.name):[]}catch{return[]}})();if(!n&&r.length===0)return null;if(r.length>0){let i=[];n&&i.push({...t,type:"assistant",content:n});for(let o=0;o<r.length;o++){let a=r[o];i.push({id:e.id+"_tool_"+o,dbMessageId:e.id,timestamp:e.created_at,type:"tool-use",toolName:a.name,toolInput:a.input||{},hasResult:!0,isHistory:!0,startTime:e.created_at||0})}return i}return{...t,type:"assistant",content:n}}else if(e.role==="tool"||e.message_type==="tool_result")return{...t,type:"tool_result",tool:e.tool_name||"unknown",content:typeof e.content=="string"?e.content:String(e.content||"")};return null}var Ey,Br=B(()=>{qr();Nn();Ey="grp_default"});function yn(e,t){return e._closedAt?.[t]?Date.now()-e._closedAt[t]<3e4:!1}function Un(e,t){Ve(e,t),e._processingWatchdogs||(e._processingWatchdogs={});let s=()=>{if(!e.processingConversations[t])return;let r=e.conversations.find(o=>o.id===t);e.sendWsMessage({type:"ping_session",conversationId:t,agentId:r?.agentId});let i=setTimeout(()=>{e.processingConversations[t]&&(e.sessionHealth||(e.sessionHealth={}),e.sessionHealth[t]={status:"agent-offline"})},1e4);e._pongTimeouts||(e._pongTimeouts={}),e._pongTimeouts[t]=i},n=setTimeout(()=>{e.processingConversations[t]&&(s(),e._processingWatchdogs[t]=setInterval(()=>{if(!e.processingConversations[t]){Ve(e,t);return}s()},3e4))},45e3);e._processingWatchdogs[t]=n}function Xi(e,t){e._yeaftWatchdogPauseReasons?.[t]?.size||e.processingConversations[t]&&e._processingWatchdogs?.[t]&&(e._pongTimeouts?.[t]&&(clearTimeout(e._pongTimeouts[t]),delete e._pongTimeouts[t]),e.sessionHealth?.[t]&&delete e.sessionHealth[t],e._yeaftWatchdogConvs?.has(t)?zn(e,t):Un(e,t))}function Ve(e,t){e._processingWatchdogs?.[t]&&(clearTimeout(e._processingWatchdogs[t]),clearInterval(e._processingWatchdogs[t]),delete e._processingWatchdogs[t]),e._pongTimeouts?.[t]&&(clearTimeout(e._pongTimeouts[t]),delete e._pongTimeouts[t]),e.sessionHealth?.[t]&&delete e.sessionHealth[t],e._autoRefreshed?.[t]&&delete e._autoRefreshed[t],e._yeaftWatchdogConvs?.delete(t),e._yeaftWatchdogPauseReasons&&delete e._yeaftWatchdogPauseReasons[t]}function Nr(e,t,s="phase"){if(!t||!e.processingConversations[t])return;e._yeaftWatchdogPauseReasons||(e._yeaftWatchdogPauseReasons={});let n=e._yeaftWatchdogPauseReasons[t]||new Set;n.add(s),e._yeaftWatchdogPauseReasons[t]=n,e._processingWatchdogs?.[t]&&(clearTimeout(e._processingWatchdogs[t]),clearInterval(e._processingWatchdogs[t]),delete e._processingWatchdogs[t])}function Kn(e,t,s=null){if(!t)return;let n=e._yeaftWatchdogPauseReasons?.[t];n&&(s?n.delete(s):n.clear(),!n.size&&(delete e._yeaftWatchdogPauseReasons[t],e.processingConversations[t]&&zn(e,t)))}function Iu(e,t){Ve(e,t),e._processingWatchdogs||(e._processingWatchdogs={}),e._processingWatchdogs[t]=setTimeout(()=>{if(e.processingConversations[t]){let s=e.conversations.find(n=>n.id===t);e.sendWsMessage({type:"refresh_conversation",conversationId:t,agentId:s?.agentId}),e._processingWatchdogs[t]=setTimeout(()=>{if(e.processingConversations[t]){delete e.processingConversations[t];let n=e.executionStatusMap[t];n&&(n.currentTool=null),e.finishStreamingForConversation(t)}delete e._processingWatchdogs[t]},1e4)}},9e4)}function zn(e,t){let s=e._yeaftWatchdogPauseReasons?.[t];if(Ve(e,t),e._processingWatchdogs||(e._processingWatchdogs={}),s?.size){e._yeaftWatchdogConvs||(e._yeaftWatchdogConvs=new Set),e._yeaftWatchdogPauseReasons||(e._yeaftWatchdogPauseReasons={}),e._yeaftWatchdogConvs.add(t),e._yeaftWatchdogPauseReasons[t]=new Set(s);return}e._yeaftWatchdogConvs||(e._yeaftWatchdogConvs=new Set),e._yeaftWatchdogConvs.add(t),e._processingWatchdogs[t]=setTimeout(()=>{if(e.processingConversations[t]){delete e.processingConversations[t];let n=e.executionStatusMap[t];n&&(n.currentTool=null),e.finishStreamingForConversation(t)}delete e._processingWatchdogs[t]},15e4)}var Bs=B(()=>{});function Za(e,t){return t&&Array.isArray(e?._yeaftRetiredConversationIdsByAgent?.[t])?e._yeaftRetiredConversationIdsByAgent[t]:[]}function Yn(e,t,s){return!t||!s?!1:Za(e,t).includes(s)}function Ja(e,t){let s=e?._yeaftRetiredConversationTargetsByAgent?.[t];return s&&typeof s=="object"?s:{}}function Cu(e,t,s){if(!t||!s)return null;let n=Ja(e,t),r=s,i=new Set;for(let o=0;o<8;o++){if(i.has(r))return null;i.add(r);let a=n[r];if(!a||a===r)return r===s?null:r;r=a}return null}function Wr(e,t,s,n=null){if(!t||!s)return;let r=Za(e,t).filter(a=>a!==s).concat(s).slice(-8);e._yeaftRetiredConversationIdsByAgent={...e._yeaftRetiredConversationIdsByAgent||{},[t]:r};let i=Ja(e,t),o={};for(let a of r){let l=i[a];l&&(o[a]=l===s&&n?n:l)}n&&n!==s&&(o[s]=n),e._yeaftRetiredConversationTargetsByAgent={...e._yeaftRetiredConversationTargetsByAgent||{},[t]:o}}function el(e,t,s){if(!t||!s||!e?._yeaftRetiredConversationIdsByAgent)return;let n=Za(e,t).filter(i=>i!==s);e._yeaftRetiredConversationIdsByAgent={...e._yeaftRetiredConversationIdsByAgent,[t]:n};let r={...Ja(e,t)};delete r[s],e._yeaftRetiredConversationTargetsByAgent={...e._yeaftRetiredConversationTargetsByAgent||{},[t]:r}}var Zi=B(()=>{});function qy(e,t,s){let n=e.messagesMap?.[t]||[],r=e.messagesMap?.[s]||[];e.messagesMap||(e.messagesMap={}),Hr(e,t,n),Hr(e,s,r);let i=fu(r,n).sort((o,a)=>{let l=Number.isFinite(o?.seq)?o.seq:null,c=Number.isFinite(a?.seq)?a.seq:null;return l!==null&&c!==null&&l!==c?l-c:l!==null&&c===null?-1:l===null&&c!==null?1:(o?.timestamp||0)-(a?.timestamp||0)});rs(e).replaceProjection(s,i)}function Vy(e){if(!e||typeof e!="object")return e;if(typeof structuredClone=="function")try{return structuredClone(e)}catch{}return Array.isArray(e)?e.slice():{...e}}function Ji(e,t){return!!e&&Object.prototype.hasOwnProperty.call(e,t)}function Gn(e,t,s,{removeSource:n}){Ji(e,t)&&(Ji(e,s)||(e[s]=n?e[t]:Vy(e[t])),n&&delete e[t])}function is(e,t,s=null){if(!t)return null;let n=e?._yeaftPendingConversationPromotions?.[t]||null;return!n?.sourceConversationId||!n.targetConversationId||s&&n.targetConversationId!==s?null:n}function eo(e,t,s,n){return!t||!s||!n||s===n?!1:(e._yeaftPendingConversationPromotions={...e._yeaftPendingConversationPromotions||{},[t]:{sourceConversationId:s,targetConversationId:n}},!0)}function jr(e,t,s=null){let n=is(e,t,s);if(!n)return null;let r={...e._yeaftPendingConversationPromotions||{}};return delete r[t],e._yeaftPendingConversationPromotions=r,n}function Ur(e,t,s){let n=is(e,t);return!n||!s||n.targetConversationId===s?null:(os(e,n.targetConversationId,s,{removeSource:!0}),Wr(e,t,n.targetConversationId,s),eo(e,t,n.sourceConversationId,s),n)}function os(e,t,s,{removeSource:n=!0}={}){if(!t||!s||t===s)return!1;qy(e,t,s),e.yeaftHistoryCacheState&&(e.yeaftHistoryCacheState=Object.fromEntries(Object.entries(e.yeaftHistoryCacheState).map(([c,d])=>[c,d?.conversationId===t?{...d,conversationId:s}:d]))),Gn(e.processingConversations,t,s,{removeSource:n}),Gn(e.executionStatusMap,t,s,{removeSource:n}),Gn(e.refreshingSessionMap,t,s,{removeSource:n}),Gn(e._closedAt,t,s,{removeSource:n}),Gn(e._autoRefreshed,t,s,{removeSource:n}),Gn(e.sessionHealth,t,s,{removeSource:n}),e._turnCompletedConvs?.has(t)&&(e._turnCompletedConvs.add(s),n&&e._turnCompletedConvs.delete(t));let r=!!e._yeaftWatchdogConvs?.has(t),i=e._yeaftWatchdogPauseReasons?.[t],o=!!i?.size,a=!!e._processingWatchdogs?.[t];if(o&&(e._yeaftWatchdogPauseReasons||(e._yeaftWatchdogPauseReasons={}),e._yeaftWatchdogPauseReasons[s]=new Set(i)),n&&(a||o)&&Ve(e,t),n&&e._pongTimeouts?.[t]&&(clearTimeout(e._pongTimeouts[t]),delete e._pongTimeouts[t]),n&&(a||r||o)&&!!e.processingConversations?.[s])if(e._processingWatchdogs?.[s])e._yeaftWatchdogConvs?.add(s);else{let c=Ji(e.sessionHealth,s),d=e.sessionHealth?.[s],u=Ji(e._autoRefreshed,s),g=e._autoRefreshed?.[s];zn(e,s),c&&(e.sessionHealth||(e.sessionHealth={}),e.sessionHealth[s]=d),u&&(e._autoRefreshed||(e._autoRefreshed={}),e._autoRefreshed[s]=g)}return n&&e.messagesMap&&delete e.messagesMap[t],!0}var tl=B(()=>{Br();qr();Zi();Bs()});function to(e,t){return!e||!t||e.type!=="user"||t.type!=="user"?!1:e.clientMessageId&&t.clientMessageId?e.clientMessageId===t.clientMessageId:e.clientMessageId||t.clientMessageId?!1:e.content===t.content}var sl=B(()=>{});function nl(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}function Hy(){return Date.now()}function By(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`pt_${crypto.randomUUID()}`:`pt_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,10)}`}function Ny(e,t=160){return typeof e!="string"?e:e.length>t?`${e.slice(0,t)}...[truncated]`:e}function Wy(e){if(!e||typeof e!="object")return e||null;let t={};for(let[s,n]of Object.entries(e))s==="text"||s==="prompt"||s==="content"||s==="data"||(t[s]=typeof n=="string"?Ny(n):n);return t}function bn(){return By()}function kt(e,t={}){!e||!t.traceId||(Array.isArray(e._perfTraceQueue)||(e._perfTraceQueue=[]),e._perfTraceQueue.push({traceId:t.traceId,source:"web",phase:t.phase||"unknown",at:Hy(),monotonicMs:nl(),durationMs:Number.isFinite(t.durationMs)?t.durationMs:null,agentId:t.agentId||null,sessionId:t.sessionId||null,vpId:t.vpId||null,turnId:t.turnId||null,threadId:t.threadId||null,messageType:t.messageType||null,bytes:Number.isFinite(t.bytes)?t.bytes:null,ok:typeof t.ok=="boolean"?t.ok:null,detail:Wy(t.detail)}),e._perfTraceQueue.length>200&&e._perfTraceQueue.splice(0,e._perfTraceQueue.length-200),jy(e))}function jy(e){!e||e._perfTraceFlushTimer||(e._perfTraceFlushTimer=setTimeout(()=>Uy(e),250))}function Uy(e){if(!e||!Array.isArray(e._perfTraceQueue)||e._perfTraceQueue.length===0){e&&(e._perfTraceFlushTimer=null);return}let t=e._perfTraceQueue.splice(0,e._perfTraceQueue.length);e._perfTraceFlushTimer=null,typeof e.sendWsMessage=="function"&&e.sendWsMessage({type:"perf_trace_events",events:t})}function so(e,t={}){if(typeof requestAnimationFrame!="function")return;let s=nl();requestAnimationFrame(()=>{requestAnimationFrame(()=>{kt(e,{...t,phase:t.phase||"render.next_paint",durationMs:nl()-s})})})}var rl=B(()=>{});function as(e){return Number.isFinite(e)?Number(e):null}function Ky(e){return(Array.isArray(e)?e:[]).map(t=>({startSeq:as(t?.startSeq),endSeq:as(t?.endSeq)})).filter(t=>t.startSeq!==null&&t.endSeq!==null&&t.startSeq<=t.endSeq).sort((t,s)=>t.startSeq-s.startSeq)}function Kr(e){return Number.isFinite(e)&&e>=0?Math.floor(e):0}function wn(e){let t=as(e?.beforeSeq);if(t===null)return null;if(e?.kind==="gap"){let s=as(e.stopAtSeq);return s===null?null:`gap:${Kr(e.cacheEpoch)}:${s}:${t}`}return`server:${t}`}function zr(e){let t=new Set((Array.isArray(e?.completedHistoryWorkKeys)?e.completedHistoryWorkKeys:[]).filter(s=>typeof s=="string"&&s));for(let s of Array.isArray(e?.requestedBeforeSeqs)?e.requestedBeforeSeqs:[])Number.isFinite(s)&&t.add(`server:${s}`);return t}function zy(e,t){let s=wn(t);if(!s)return e.completedHistoryWorkKeys||[];let n=zr(e);return n.add(s),Array.from(n).slice(-256)}function Yy(e,t){if(!Number.isFinite(t))return e.requestedBeforeSeqs||[];let s=new Set((Array.isArray(e?.requestedBeforeSeqs)?e.requestedBeforeSeqs:[]).filter(Number.isFinite));return s.add(t),Array.from(s).sort((n,r)=>r-n).slice(-256)}function Gy(e,t={},s=0){let n=Ky(e),r=Kr(s),i=zr(t),o=[];for(let a=1;a<n.length;a+=1){let l=n[a-1],c=n[a];if(l.endSeq+1>=c.startSeq)continue;let d={kind:"gap",beforeSeq:c.startSeq,stopAtSeq:l.endSeq+1,cacheEpoch:r};d.workKey=wn(d),i.has(d.workKey)||o.push(d)}return o.sort((a,l)=>l.beforeSeq-a.beforeSeq)}function Au(e,t,s){let n=Gy(e,t,s),r=as(t.serverOldestFetchedSeq??t.oldestSeq),i=n[0]||null;if(!i||r===null||i.beforeSeq<=r)return[];let o={kind:"gap",beforeSeq:i.beforeSeq,stopAtSeq:r,cacheEpoch:i.cacheEpoch};return o.workKey=wn(o),zr(t).has(o.workKey)?[]:[o]}function xu(e={},t=[],s=0){let n=Kr(s),r=zr(e),i=e.serverHasMore!==!1,o=as(e.serverOldestFetchedSeq??e.oldestSeq),a=e.gapTraversalInitialized===!0,l=Array.isArray(e.gapQueue)?e.gapQueue.slice():[],c=null,d=null;if(i&&o!==null){let u={kind:"server",beforeSeq:o,stopAtSeq:null,cacheEpoch:n};u.workKey=wn(u),r.has(u.workKey)?(i=!1,d="history_cursor_repeated"):c=u}return!c&&!i&&(a||(l=Au(t,e,n),a=!0),c=l[0]||null),c?{request:c,state:{...e,serverHasMore:i,gapTraversalInitialized:a,gapQueue:l,pendingPageKind:c.kind,pendingPageBeforeSeq:c.beforeSeq,pendingGapStopAtSeq:c.stopAtSeq,pendingCacheEpoch:c.cacheEpoch,pendingHistoryWorkKey:c.workKey,hasMore:!0,paginationError:null}}:{request:null,state:{...e,serverHasMore:i,gapTraversalInitialized:a,gapQueue:l,hasMore:!1,paginationError:d}}}function Tu(e={},{mode:t,oldestSeq:s,hasMore:n,ranges:r=[],pageKind:i=null,stopAtSeq:o=null,cacheEpoch:a=0}={}){if(t==="delta")return e;let l=Kr(a),c=as(s),d=as(e.pendingPageBeforeSeq),u=i||e.pendingPageKind||(t==="older"?"server":null),g=as(o??e.pendingGapStopAtSeq),p=Kr(e.pendingCacheEpoch??l),f={kind:u,beforeSeq:d,stopAtSeq:g,cacheEpoch:p},m=as(e.serverOldestFetchedSeq??e.oldestSeq),v=e.serverHasMore!==!1,y=Number(e.noProgressCount)||0,h=null,k=e.requestedBeforeSeqs||[],S=e.completedHistoryWorkKeys||[],b=e.gapTraversalInitialized===!0,w=Array.isArray(e.gapQueue)?e.gapQueue.slice():[];if(t==="recent")m=c,v=!!n,y=0,k=[],S=[],b=!1,w=[];else if(d===null)c!==null&&(m=m===null?c:Math.min(m,c)),v=!!n,y=0;else{k=Yy(e,d),S=zy(e,f);let x=c!==null&&c<d;if(u==="server")x?(m=m===null?c:Math.min(m,c),v=!!n,y=0):(v=!1,y+=1,h="history_cursor_no_progress");else if(u==="gap"){let Y=wn(f);w=w.filter(U=>wn(U)!==Y);let L=g!==null&&c!==null&&c<=g;if(x||L||n===!1){if(y=0,!L&&n!==!1&&c!==null&&g!==null){let U={kind:"gap",beforeSeq:c,stopAtSeq:g,cacheEpoch:p};U.workKey=wn(U),zr({completedHistoryWorkKeys:S}).has(U.workKey)||w.unshift(U)}}else y+=1,h="history_cursor_no_progress"}}t==="older"&&!v&&!b&&(w=Au(r,{...e,serverOldestFetchedSeq:m,completedHistoryWorkKeys:S},l),b=!0);let P={...e,serverOldestFetchedSeq:m,serverHasMore:v,requestedBeforeSeqs:k,completedHistoryWorkKeys:S,gapTraversalInitialized:b,gapQueue:w,noProgressCount:y,oldestSeq:m,paginationError:h};return delete P.pendingPageKind,delete P.pendingPageBeforeSeq,delete P.pendingGapStopAtSeq,delete P.pendingCacheEpoch,delete P.pendingHistoryWorkKey,{...P,hasMore:v||w.length>0}}var il=B(()=>{});function _u(e){return e.filter(t=>!(t.type==="user"&&(!t.content||!t.content.trim())))}function kn(e){let t=typeof e=="string"?e.match(/^m(\d+)$/):null,s=t?Number(t[1]):null;return Number.isFinite(s)?s:null}function Mu(e){let t=[e?.timestamp,e?.createdAt,e?.ts,e?.time,e?.created_at];for(let s of t){if(typeof s=="number"&&Number.isFinite(s)&&s>0)return s;if(typeof s=="string"&&s.trim()){let n=Date.parse(s);if(Number.isFinite(n))return n;let r=Number(s);if(Number.isFinite(r)&&r>0)return r}}return null}function Qy(e){if(!Array.isArray(e))return null;for(let t=e.length-1;t>=0;t-=1){let s=e[t];if(s?.name==="TodoWrite"&&Array.isArray(s?.input?.todos))return s.input.todos}return null}function Xy(e){if(!e||typeof window>"u")return null;try{let t=window.Pinia||null,s=t&&typeof t.useSessionsStore=="function"?t.useSessionsStore():null;if(!s)return null;let n=typeof t.useChatStore=="function"?t.useChatStore():null,r=typeof s.sessionById=="function"?s.sessionById(e,n?.currentAgent||null):s.sessions&&s.sessions[e];return(r&&typeof r.defaultVpId=="string"?r.defaultVpId.trim():"")||null}catch{return null}}function Zy(e,t){return e.speakerVpId||e.vpId||e.vp_id||e.authorVpId||e.authorVP||Xy(t)}function Jy(e){return e?.stableKey||(e&&(e.messageId||e.id)?e.messageId||e.id:null)}function eb(e,t=null){if(!e||e.stableKey)return e;let s=Ns(e),n=e.messageId||e.id||null,r=e.type==="user"&&e.clientMessageId||null;return e.stableKey=r&&n===r?Hs(t,s,r):Fr(t,s,n),Number.isFinite(e.seq)||(e.seq=kn(n)),e.uiKey||(e.uiKey=e.stableKey||null),e}function Ns(e){return e?e.sessionId??e.groupId??null:null}function tb(e){return!e||e.type!=="user"||!e.clientMessageId?!1:(e.messageId||e.id||null)===e.clientMessageId}function sb(e,t,s,n){let r=e.rows(t),i=r.some(c=>c&&(n==null||Ns(c)===n));if(s.length===0&&i)return{insertedRows:0,preservedEmpty:!0};let o=s.reduce((c,d)=>Math.max(c,d?.timestamp||0),0),a=r.filter(c=>c?n!=null&&Ns(c)!==n||vt(c)||c.isStreaming||c.type==="tool-use"&&c.toolName==="AskUserQuestion"&&(c.askAnswered||c.askPending||c.askExpired)||tb(c)?!0:o>0&&(c.timestamp||0)>o:!1);return e.replaceProjection(t,a),{insertedRows:e.commitDurable({conversationId:t,sessionId:n,rows:s,mode:"recent",preserveEmpty:!1}).insertedRows,preservedEmpty:!1}}function nb(e){if(typeof e!="string")return!1;let t=e.trimStart();return t.startsWith("<task-result ")||/^\[system note\] You have called \S+ with the same arguments \d+ times\./.test(t)}function rb(e,t){let s=typeof e.yeaftConversationId=="string"?e.yeaftConversationId:"";return s.startsWith(`yeaft-local-${t}-`)||/^yeaft-local-\d/.test(s)?s:null}function ib(e,t,s,n){let r=t.agentId||s&&e.yeaftSessionAgentById?.[s]||null;if(!r||!n||e.currentView!=="yeaft")return;let i=Xt(e);if(i.sessionId!==(s||null)||i.agentId&&i.agentId!==r)return;let o=e.yeaftConversationId||null;if(Yn(e,r,n)){let d=e.yeaftConversationIdsByAgent?.[r]||null;d&&d!==n&&os(e,n,d,{removeSource:n!==e.yeaftConversationId});return}let a=is(e,r);a&&a.targetConversationId!==n&&Ur(e,r,n);let l=is(e,r,n);if(l&&(os(e,l.sourceConversationId,n,{removeSource:!0}),jr(e,r,n),e.yeaftConversationId=n),o===n||l){e.messagesMap[n]||(e.messagesMap[n]=[]),e.yeaftConversationIdsByAgent={...e.yeaftConversationIdsByAgent||{},[r]:n},e.activeConversations=[n];return}let c=rb(e,r);c&&(os(e,c,n,{removeSource:!0}),e.yeaftConversationIdsByAgent={...e.yeaftConversationIdsByAgent||{},[r]:n},e.yeaftConversationId=n,e.activeConversations=[n])}function Ws(e,t,s=null){let n=e.messagesMap[t]||[];for(let r of n)s&&Object.entries(s).some(([i,o])=>o&&r[i]!==o)||r.type==="tool-use"&&!r.hasResult&&(r.hasResult=!0,r.toolName==="AskUserQuestion"&&!r.askAnswered&&!r.selectedAnswers&&(r.isHistory=!0,r.askExpired=!0,r.askPending=!1,r.pendingAnswers=null,r.askSubmittedAt=null,r.askError=null,r.askRequestId=null))}function Eu(e,t){ns(e);let s=e.agents.find(r=>r.id===t.agentId);e.conversations=e.conversations.filter(r=>r.id!==t.conversationId);let n=t.provider||"claude-code";if(e.conversations.push({id:t.conversationId,agentId:t.agentId,agentName:s?.name||t.agentId,workDir:t.workDir,claudeSessionId:null,createdAt:Date.now(),processing:!1,connecting:n!=="claude-code",type:"chat",provider:n,capabilities:t.capabilities||null,disallowedTools:t.disallowedTools??null}),e.currentAgent=t.agentId,e.currentAgentInfo=s,e.panels.length>1){let r=e._pendingPaneId;if(e._pendingPaneId=null,r){let i=e.panels.find(o=>o.id===r);i&&(i.conversationId=t.conversationId)}else{let i=e.panels.find(o=>!o.conversationId);i&&(i.conversationId=t.conversationId)}e.activeConversations.includes(t.conversationId)||e.activeConversations.push(t.conversationId)}else e.activeConversations=[t.conversationId];e.currentWorkDir=t.workDir,e.messagesMap[t.conversationId]=[],e.sendWsMessage({type:"select_conversation",conversationId:t.conversationId}),e.addMessage({type:"system",content:Oe("store.convCreated",{agent:s?.name||t.agentId,workDir:t.workDir})}),e.saveOpenSessions()}function Du(e,t){ns(e);let s=e.agents.find(n=>n.id===t.agentId);if(e.conversations=e.conversations.filter(n=>n.id!==t.conversationId&&!(n.claudeSessionId&&n.claudeSessionId===t.claudeSessionId&&n.agentId===t.agentId&&(n.provider||"claude-code")===(t.provider||"claude-code"))),e.conversations.push({id:t.conversationId,agentId:t.agentId,agentName:s?.name||t.agentId,workDir:t.workDir,claudeSessionId:t.claudeSessionId,createdAt:Date.now(),processing:!1,connecting:(t.provider||"claude-code")!=="claude-code",type:"chat",provider:t.provider||"claude-code",capabilities:t.capabilities||null,disallowedTools:t.disallowedTools??null}),e.currentAgent=t.agentId,e.currentAgentInfo=s,e.panels.length>1){let n=e._pendingPaneId;if(e._pendingPaneId=null,n){let r=e.panels.find(i=>i.id===n);r&&(r.conversationId=t.conversationId)}else{let r=e.panels.find(i=>!i.conversationId);r&&(r.conversationId=t.conversationId)}e.activeConversations.includes(t.conversationId)||e.activeConversations.push(t.conversationId)}else e.activeConversations=[t.conversationId];if(e.currentWorkDir=t.workDir,e.messagesMap[t.conversationId]=[],e._pendingSessionTitle&&(e.conversationTitles[t.conversationId]=e._pendingSessionTitle,e._pendingSessionTitle=null),e.sendWsMessage({type:"select_conversation",conversationId:t.conversationId}),e.addMessage({type:"system",content:Oe("store.convResumed",{agent:s?.name||t.agentId,sessionId:t.claudeSessionId?t.claudeSessionId.slice(0,8)+"...":""})}),t.dbMessages&&t.dbMessages.length>0){let n=_u(t.dbMessages.map(i=>e.formatDbMessage(i)).flat().filter(Boolean)),r=e.messagesMap[t.conversationId]||[];for(let i of n)r.push(i)}e.hasMoreMessages=!!t.hasMoreMessages,e.chatSessionState[t.conversationId]={lastSeenDbId:vn(e.messagesMap[t.conversationId]),hasMoreOlder:!!t.hasMoreMessages},e.saveOpenSessions()}function ol(e,t){e.conversations=e.conversations.filter(n=>n.id!==t.conversationId),delete e.messagesMap[t.conversationId],delete e.chatSessionState[t.conversationId],delete e.conversationTitles[t.conversationId],delete e.customConversationTitles[t.conversationId],delete e.processingConversations[t.conversationId],e._closedAt&&delete e._closedAt[t.conversationId],Ve(e,t.conversationId),delete e.executionStatusMap[t.conversationId],delete e.subagents[t.conversationId],window.dispatchEvent(new CustomEvent("conversation-deleted",{detail:{conversationId:t.conversationId}}));let s=e.activeConversations.indexOf(t.conversationId);s>=0&&(e.activeConversations.splice(s,1),e.activeConversations.length===0&&e.addMessage({type:"system",content:Oe("chat.session.closed")}));for(let n of e.panels)n.conversationId===t.conversationId&&(n.conversationId=null);e.saveOpenSessions()}function $u(e,t){let s=t.conversationId;if(s){delete e.processingConversations[s],Ve(e,s),e._closedAt||(e._closedAt={}),e._closedAt[s]=Date.now(),e._turnCompletedConvs||(e._turnCompletedConvs=new Set),e._turnCompletedConvs.add(s);let n=e.executionStatusMap[s];n&&(n.currentTool=null),e.finishStreamingForConversation(s),Ws(e,s);let r=e.conversations.find(i=>i.id===s);r&&(t.claudeSessionId&&(r.claudeSessionId=t.claudeSessionId),t.workDir&&(r.workDir=t.workDir)),e.clearStatus?.conversationId===s&&e.clearStatus?.status==="clearing"&&(e.clearStatus={conversationId:s,status:"completed"},setTimeout(()=>{e.clearStatus?.conversationId===s&&e.clearStatus?.status==="completed"&&(e.clearStatus=null)},3e3)),e.saveOpenSessions()}}function Lu(e,t){let s=t.conversationId;if(s){delete e.processingConversations[s],Ve(e,s),e._closedAt||(e._closedAt={}),e._closedAt[s]=Date.now(),e._turnCompletedConvs||(e._turnCompletedConvs=new Set),e._turnCompletedConvs.add(s);let n=e.executionStatusMap[s];n&&(n.currentTool=null),e.finishStreamingForConversation(s),Ws(e,s);let r=e.conversations.find(i=>i.id===s);r&&(t.claudeSessionId&&(r.claudeSessionId=t.claudeSessionId),t.workDir&&(r.workDir=t.workDir)),e.saveOpenSessions()}}function Fu(e,t){if(t.conversationId){if(t.isProcessing&&!yn(e,t.conversationId)&&!e._turnCompletedConvs?.has(t.conversationId))e.processingConversations[t.conversationId]=!0;else if(e.processingConversations[t.conversationId]){delete e.processingConversations[t.conversationId],Ve(e,t.conversationId);let s=e.executionStatusMap[t.conversationId];s&&(s.currentTool=null),e.finishStreamingForConversation(t.conversationId)}}}function Ou(e,t){let s=t.conversationId||e.currentConversation;if(s){delete e.processingConversations[s],Ve(e,s),e._closedAt||(e._closedAt={}),e._closedAt[s]=Date.now(),e._turnCompletedConvs||(e._turnCompletedConvs=new Set),e._turnCompletedConvs.add(s);let n=e.executionStatusMap[s];n&&(n.currentTool=null),e.finishStreamingForConversation(s),Ws(e,s)}}function qu(e,t){if(!!t.requestId){if(e.chatHistoryRequestIdSupported=!0,!e.isCurrentChatHistoryResponse?.(t))return!1}else{let i=`chat:${t.conversationId}`,o=e.chatHistoryRequests?.[i];if(e.chatHistoryRequestIdSupported===!0||!o?.loading)return!1;t={...t,requestId:o.requestId,catalogKey:i,mode:o.mode||t.mode,...o.mode==="delta"?{afterMessageId:o.cursor}:{}}}e.messagesMap[t.conversationId]||(e.messagesMap[t.conversationId]=[]);let n=e.messagesMap[t.conversationId],r=t.mode==="delta"||typeof t.afterMessageId=="number"&&t.afterMessageId>0;if(t.conversationId&&e.activeConversations.includes(t.conversationId)){let i=_u((t.messages||[]).map(a=>e.formatDbMessage(a)).flat().filter(Boolean));if(i.length>0){let a=n.find(l=>l.dbMessageId);if(a&&i[0].dbMessageId&&i[i.length-1].dbMessageId<a.dbMessageId){let l=n.indexOf(a);e.debug,n.splice(l,0,...i)}else{e.debug;for(let l of i)if(!(l.dbMessageId&&n.some(c=>c.dbMessageId===l.dbMessageId))){if(l.dbMessageId&&(l.type==="assistant"||l.type==="user")){let c=null;if(l.type==="user"?c=n.find(d=>!d.dbMessageId&&!d.isStreaming&&to(d,l)):c=n.find(d=>!d.dbMessageId&&!d.isStreaming&&d.type==="assistant"&&d.content===l.content),c){c.dbMessageId=l.dbMessageId,c.id=l.id,l.timestamp&&(c.timestamp=l.timestamp),l.clientMessageId&&!c.clientMessageId&&(c.clientMessageId=l.clientMessageId);continue}}n.push(l)}}}r||(e.hasMoreMessages=t.hasMore??!1),ns(e);let o=e.chatSessionState[t.conversationId]?.hasMoreOlder;e.chatSessionState[t.conversationId]={lastSeenDbId:vn(e.messagesMap[t.conversationId]),hasMoreOlder:r?!!o:!!t.hasMore}}return e.finishChatHistoryRequest?.(t)&&(e.currentConversation===t.conversationId&&(e.loadingMoreMessages=!1),e.setRefreshingSession(t.conversationId,!1)),!0}function Vu(e,t){let s=t.sessionId??null,n=t.agentId||s&&e.yeaftSessionAgentById?.[s]||null,r=t.conversationId||n&&e.yeaftConversationIdsByAgent?.[n]||e.yeaftConversationId;if(!r||!s||!Array.isArray(t.messages))return null;e.messagesMap[r]||(e.messagesMap[r]=[]);let i=new Set(Array.isArray(t.sourceMessageIds)?t.sourceMessageIds:[]),o=new Set,a=new Set;for(let y of e.messagesMap[r]){if(Ns(y)!==s)continue;let h=y?.persistedMessageId||y?.messageId||y?.id||null;h&&o.add(h),h&&(y?._historyWindowPrefetched===!0||y?._historyWindowDetached===!0)&&a.add(h),!(!t.entryId||!i.has(h))&&(y.historyEntryId=t.entryId,Number.isFinite(t.indexGeneration)&&(y.historyIndexGeneration=t.indexGeneration))}let l=t.messages.filter(y=>t.prefetch===!0||!o.has(y?.id)||a.has(y?.id)).map(y=>t.entryId&&i.has(y?.id)?{...y,historyEntryId:t.entryId,...t.prefetch===!0?{_historyWindowPrefetched:!0}:{},...Number.isFinite(t.indexGeneration)?{historyIndexGeneration:t.indexGeneration}:{}}:y),{formatted:c}=Hu(l,s,"window",e.messagesMap[r],n),d=`history-window:${t.requestId||t.anchorMessageId||Date.now()}`;for(let y of c)y._historyWindowKey=d,y._historyWindowDetached=t.prefetch!==!0,y._historyWindowPrefetched=t.prefetch===!0;let u=rs(e),g=u.rows(r),p=new Set(t.messages.map(y=>y?.id).filter(Boolean)),f=[];if(t.prefetch!==!0){for(let h of g){if(Ns(h)!==s)continue;let k=h?.persistedMessageId||h?.messageId||h?.id||null;p.has(k)&&(h._historyWindowPrefetched!==!0&&h._historyWindowDetached!==!0||(h._historyWindowKey=d,h._historyWindowDetached=!0,h._historyWindowPrefetched=!1,f.push(h)))}let y=g.filter(h=>Ns(h)!==s||h._historyWindowDetached!==!0||h._historyWindowKey===d);y.length!==g.length&&u.replaceProjection(r,y)}u.commitDurable({conversationId:r,sessionId:s,rows:c,mode:"window"});let m=c.length>0?c:f,v=Xt(e);return Ka(e,{conversationId:r,agentId:n,sessionId:s,incomingRows:m,activeAgentId:v.agentId,activeSessionId:v.sessionId}),r}function Pu(e){return e?.toolId?[Ns(e)??"",e.vpId||e.speakerVpId||"",e.turnId||"",e.threadId||"main",e.toolId].join("\0"):null}function Ru(e,t,s){return e.toolName="AskUserQuestion",e.toolId=t.toolCallId,e.toolInput={questions:s},e.askQuestions=s,e.askRequestId=null,e.askPending=!1,e.pendingAnswers=null,e.askSubmitGeneration=null,e.askSubmittedAt=null,e.askError=null,e.hasResult=!0,e.isHistory=!0,t.status==="answered"?(e.askAnswered=!0,e.selectedAnswers=t.answers,e.askExpired=!1):(e.askAnswered=!1,e.selectedAnswers=null,e.askExpired=!0),e}function ob(e,t){return(e||[]).find(s=>s?.type==="tool-use"&&(s.toolName==="AskUser"||s.toolName==="AskUserQuestion")&&s.toolId===t.toolCallId&&Ns(s)===t.sessionId&&(s.vpId||s.speakerVpId||"")===(t.vpId||"")&&(s.turnId||"")===(t.turnId||"")&&(s.threadId||"main")===(t.threadId||"main"))||null}function Hu(e,t,s,n,r=null){let i=new Set((n||[]).map(c=>Jy(eb(c,r))).filter(Boolean)),o=new Set,a=[],l=0;for(let c of e){if(!c||c._reflection||c.internal||c.systemOnly||c.systemOnlyMessage||nb(c.content))continue;let d=c.id||c.messageId||null,u=c.clientMessageId||null,g=c.sessionId??c.groupId??t??null,p=Fr(r,g,d),f=u?Hs(r,g,u):p,m=c.historyEntryId?{historyEntryId:c.historyEntryId,...Number.isFinite(c.historyIndexGeneration)?{historyIndexGeneration:c.historyIndexGeneration}:{}}:{};if(!(p&&o.has(p))&&!(p&&s!=="recent"&&i.has(p))){if(p&&o.add(p),c.role==="user"){l+=1;let v=d||c.messageId||c.turnId||null;a.push({...d?{id:d,messageId:d}:{},...p?{stableKey:p}:{},...f?{uiKey:f}:{},...m,seq:Number.isFinite(c.seq)?c.seq:kn(d),type:"user",content:c.content,timestamp:Mu(c),sessionId:g,turnId:c.turnId||v,...u?{clientMessageId:u}:{},...Array.isArray(c.attachments)&&c.attachments.length>0?{attachments:c.attachments}:{},...c.quote?{quote:c.quote}:{},isStreaming:!1,isHistory:!0})}else if(c.role==="assistant"){l+=1;let v=d||c.messageId||c.turnId||null,y=Zy(c,g),h=Mu(c),k=!!c.turnId,S=c.turnId||v,b=typeof c.content=="string"?c.content:c.content||"",w=Array.isArray(c.todos)?c.todos:Qy(c.toolCalls),P=c.executionOrigin==="route_forward"?{executionOrigin:"route_forward"}:{};(typeof b!="string"||b.trim())&&a.push({...d?{id:d,messageId:d}:{},...p?{stableKey:p}:{},...f?{uiKey:f}:{},...m,seq:Number.isFinite(c.seq)?c.seq:kn(d),...c.entryId?{entryId:c.entryId}:{},...Array.isArray(c.sourceMessageIds)?{sourceMessageIds:c.sourceMessageIds}:{},type:"assistant",content:b,timestamp:h,sessionId:g,turnId:S,_hasPersistedTurnId:k,...P,...y?{vpId:y,speakerVpId:y}:{},...c.responseKind==="progress"||c.responseKind==="result"?{responseKind:c.responseKind}:{},...Number.isInteger(c.llmCallCount)&&c.llmCallCount>0?{llmCallCount:c.llmCallCount}:{},...Number.isFinite(c.inputTokens)&&c.inputTokens>=0?{inputTokens:c.inputTokens}:{},...Number.isFinite(c.outputTokens)&&c.outputTokens>=0?{outputTokens:c.outputTokens}:{},...Number.isFinite(c.totalTokens)&&c.totalTokens>=0?{totalTokens:c.totalTokens}:{},...Number.isFinite(c.totalMs)&&c.totalMs>=0?{totalMs:c.totalMs}:{},...typeof c.model=="string"&&c.model?{model:c.model}:{},...typeof c.effort=="string"&&c.effort?{effort:c.effort}:{},...c.incomplete===!0?{incomplete:!0}:{},...typeof c.stopReason=="string"&&c.stopReason?{stopReason:c.stopReason}:{},isStreaming:!1,isHistory:!0}),Array.isArray(w)&&w.length>0&&a.push({...d?{id:`${d}:todos`,messageId:`${d}:todos`}:{},...p?{stableKey:`${p}:todos`}:{},...m,seq:Number.isFinite(c.seq)?c.seq:kn(d),type:"tool-use",toolName:"TodoWrite",toolInput:{todos:w},timestamp:h,startTime:h||0,sessionId:g,turnId:S,...P,...y?{vpId:y,speakerVpId:y}:{},isStreaming:!1,isHistory:!0,hasResult:!0});for(let[x,Y]of(Array.isArray(c.toolCalls)?c.toolCalls:[]).entries()){if(!Y||Y.name==="TodoWrite")continue;let L=Y.id||`index:${x}`,U=encodeURIComponent(String(L));a.push({...d?{id:`${d}:tool:${U}`,messageId:`${d}:tool:${U}`,persistedMessageId:d}:{},...p?{stableKey:`${p}:tool:${U}`}:{},...m,seq:Number.isFinite(c.seq)?c.seq:kn(d),type:"tool-use",toolId:Y.id||null,toolName:Y.name||"unknown",toolInput:Y.input||{},timestamp:h,startTime:h||0,sessionId:g,turnId:S,...c.threadId?{threadId:c.threadId}:{},...P,...y?{vpId:y,speakerVpId:y}:{},isStreaming:!1,isHistory:!0,hasResult:!0})}for(let x of Array.isArray(c.images)?c.images:[])x?.assetId&&a.push({id:`${d||v||S}:image:${x.assetId}`,messageId:`${d||v||S}:image:${x.assetId}`,...p?{stableKey:`${p}:image:${x.assetId}`}:{},...m,seq:Number.isFinite(c.seq)?c.seq:kn(d),type:"chat-image",...x,timestamp:h,sessionId:g,turnId:S,...P,...y?{vpId:y,speakerVpId:y}:{},isStreaming:!1,isHistory:!0});for(let x of Array.isArray(c.askUserResults)?c.askUserResults:[]){if(!x?.toolCallId||x.status!=="answered"&&x.status!=="expired")continue;let Y=[{question:typeof x.question=="string"?x.question:"",options:(Array.isArray(x.options)?x.options:[]).filter(I=>typeof I=="string").map(I=>({label:I,description:""})),multiSelect:!1}],L={toolCallId:x.toolCallId,sessionId:g,vpId:y||"",turnId:S||"",threadId:c.threadId||"main"},U=ob(n,L);if(U){Object.assign(U,m),Ru(U,x,Y);let I=a.findIndex(T=>T?.type==="tool-use"&&T.toolId===x.toolCallId&&(T.sessionId??T.groupId??null)===(U.sessionId??U.groupId??null)&&(T.turnId||"")===(U.turnId||""));I>=0&&a.splice(I,1);continue}let E=Ru({id:`${d||v||S}:ask:${x.toolCallId}`,messageId:`${d||v||S}:ask:${x.toolCallId}`,...p?{stableKey:`${p}:ask:${x.toolCallId}`}:{},...m,seq:Number.isFinite(c.seq)?c.seq:kn(d),type:"tool-use",timestamp:h,sessionId:g,turnId:S,threadId:L.threadId,...P,...y?{vpId:y,speakerVpId:y}:{},isStreaming:!1},x,Y),oe=Pu(E);(!oe||!a.some(I=>Pu(I)===oe))&&a.push(E);let q=a.findIndex(I=>I!==E&&I?.type==="tool-use"&&I.toolId===x.toolCallId&&(I.sessionId??I.groupId??null)===(E.sessionId??E.groupId??null)&&(I.turnId||"")===(E.turnId||""));q>=0&&a.splice(q,1)}}}}return{formatted:a,acceptedHistoryMessages:l}}function Bu(e,t){let s=t.sessionId!=null?t.sessionId:t.groupId,n=t.agentId||s&&e.yeaftSessionAgentById?.[s]||null;if(Yn(e,n,t.conversationId)){let M=e.yeaftConversationIdsByAgent?.[n]||null;if(!M||M===t.conversationId)return;os(e,t.conversationId,M,{removeSource:t.conversationId!==e.yeaftConversationId}),t={...t,conversationId:M}}if(t.requestId&&typeof e.isCurrentYeaftHistoryResponse=="function"&&!e.isCurrentYeaftHistoryResponse(t))return;let r=t.mode==="recent"||t.mode==="delta"?t.mode:"older",i=Array.isArray(t.messages)?t.messages:[],o=t.agentId||s&&e.yeaftSessionAgentById?.[s]||null,a=Le(o,s),l=e.yeaftSessionHistoryState?.[a]||null;typeof t.streamId=="string"&&typeof l?.streamId=="string"&&(t.streamId!==l.streamId||Number.isFinite(t.revision)&&Number.isFinite(l.revision)&&t.revision!==l.revision)&&(r="recent",typeof e.clearYeaftHistoryMemory=="function"&&e.clearYeaftHistoryMemory({agentId:o,sessionId:s,preserveLiveRows:!0,preserveSessionOwner:!0})),t.perfTraceId&&kt(e,{traceId:t.perfTraceId,phase:"history.chunk_received",agentId:t.agentId||null,sessionId:s||null,messageType:t.type,bytes:(()=>{try{return JSON.stringify(t).length}catch{return null}})(),detail:{mode:r,rawCount:i.length}});let d=t.agentId||(s&&e.yeaftSessionAgentById?e.yeaftSessionAgentById[s]:null),u=d&&e.yeaftConversationIdsByAgent?e.yeaftConversationIdsByAgent[d]:null,g=t.conversationId||u||e.yeaftConversationId;if(!g){e.yeaftLoadingMoreHistory=!1;return}ib(e,t,s,g),e.messagesMap[g]||(e.messagesMap[g]=[]);let{formatted:p,acceptedHistoryMessages:f}=Hu(i,s,r,e.messagesMap[g],d);Hr(e,g,p);let m=rs(e),v=0,y=!1;if(r==="recent"){let M=sb(m,g,p,s??null);v=M.insertedRows,y=M.preservedEmpty}else if(p.length>0&&(v=m.commitDurable({conversationId:g,sessionId:s??null,rows:p,mode:r}).insertedRows,r==="older"&&typeof e.expandYeaftMessageWindow=="function")){let $=e.yeaftActiveSessionFilter?s??null:null;e.expandYeaftMessageWindow($,t.turns||10,d)}let h=Xt(e);Ka(e,{conversationId:g,agentId:d,sessionId:s,incomingRows:p,activeAgentId:h.agentId,activeSessionId:h.sessionId});let k=Le(t.agentId||null,s),S=e.yeaftHistoryCacheState?.[k]||null,b=e.yeaftSessionHistoryState?.[k]||{},w=Number.isFinite(b.serverOldestFetchedSeq)?b.serverOldestFetchedSeq:Number.isFinite(b.oldestSeq)?b.oldestSeq:null,P=Number.isFinite(t.nextBeforeSeq)?t.nextBeforeSeq:Number.isFinite(t.oldestSeq)?t.oldestSeq:y?w:null,x=y&&!Number.isFinite(t.nextBeforeSeq)&&!Number.isFinite(t.oldestSeq)?b.serverHasMore??b.hasMore??!1:t.hasMore,Y=r==="delta"?b:Tu(b,{mode:r,oldestSeq:P,hasMore:x,ranges:S?.ranges||[],pageKind:t.pageKind,stopAtSeq:t.gapStopAtSeq,cacheEpoch:S?.rangeEpoch??t.cacheEpoch??0}),L=typeof t.latestSeq=="number"?t.latestSeq:b.latestSeq??null,U={streamId:typeof t.streamId=="string"?t.streamId:b.streamId??null,revision:Number.isFinite(t.revision)?t.revision:b.revision??null},E=r==="delta"?{...b,...U,loaded:!0,loading:!1,latestSeq:L,syncingAfterSeq:null,count:(b.count||0)+v}:{...Y,...U,loaded:!0,loading:!1,count:S?S.rowCount:r==="older"?(b.count||0)+v:y?b.count||0:f,latestSeq:y&&!Number.isFinite(t.latestSeq)?b.latestSeq??null:L,syncingAfterSeq:null};t.requestId&&typeof e.finishYeaftHistoryLoad=="function"?e.finishYeaftHistoryLoad(t,E,"chunk"):e.yeaftSessionHistoryState&&(e.yeaftSessionHistoryState={...e.yeaftSessionHistoryState,[k]:E}),r==="delta"&&t.hasMoreAfter===!0&&Number.isFinite(E.latestSeq)&&E.latestSeq>Number(t.afterSeq??-1)&&typeof e.continueYeaftHistoryDelta=="function"&&queueMicrotask(()=>e.continueYeaftHistoryDelta(s,d,E.latestSeq));let oe=Xt(e),q=oe.sessionId===(s||null),I=!t.agentId||!oe.agentId||t.agentId===oe.agentId,T=q&&I,R=Le(null,oe.sessionId);if(t.perfTraceId&&(kt(e,{traceId:t.perfTraceId,phase:"history.chunk_applied",agentId:t.agentId||null,sessionId:s||null,messageType:t.type,detail:{mode:r,formattedCount:p.length,insertedRows:v,acceptedHistoryMessages:f,preservedEmptyRecent:y}}),so(e,{traceId:t.perfTraceId,phase:"history.next_paint",agentId:t.agentId||null,sessionId:s||null,messageType:t.type,detail:{mode:r,insertedRows:v}})),T)e.yeaftHasMoreHistory=E.hasMore,e.yeaftOldestLoadedSeq=Number.isFinite(E.serverOldestFetchedSeq)?E.serverOldestFetchedSeq:Number.isFinite(E.oldestSeq)?E.oldestSeq:e.yeaftOldestLoadedSeq,e.yeaftLoadingMoreHistory=!1;else if(e.yeaftLoadingMoreHistory){let M=e.yeaftSessionHistoryState?.[oe.sessionKey]||e.yeaftSessionHistoryState?.[R]||null;e.yeaftLoadingMoreHistory=!!M?.loading}}var no=B(()=>{Bs();tl();Zi();hn();sl();Br();ss();rl();Ui();Nn();zi();il();qr()});function Nu(e,t,s=null){if(!s)return!1;if(e.promoteYeaftHistoryOutlineRow?.(t,s))return!0;let n=t?.sessionId??t?.groupId??e._currentYeaftSessionId??null;return n?!!e.invalidateYeaftHistoryOutline?.(n,s):!1}function ab(e){let t=e;if(typeof t=="string"){let s=t.trim();if(s.startsWith("[")&&s.endsWith("]")||s.startsWith("{")&&s.endsWith("}"))try{t=JSON.parse(s)}catch{t=e}}return Array.isArray(t)?t.map(s=>typeof s=="string"?s:!s||typeof s!="object"?"":s.type==="text"&&typeof s.text=="string"||s.type==="input_text"&&typeof s.text=="string"?s.text:"").join("").replace(/\n\n\[Uploaded files\][\s\S]*$/m,"").trim():t&&typeof t=="object"?typeof t.text=="string"?t.text.trim():typeof t.content=="string"?t.content.trim():"":typeof t=="string"?t.replace(/\n\n\[Uploaded files\][\s\S]*$/m,"").trim():""}function al(e,t){return e.executionStatusMap[t]||(e.executionStatusMap[t]={currentTool:null,toolHistory:[],lastActivity:null}),e.executionStatusMap[t]}function Wu(e,t,s,n=null){if(!t)return;let r=al(e,t);if(r.lastActivity=Date.now(),Xi(e,t),s.type==="system"){if(s.subtype==="init"){let i=e.conversations.find(o=>o.id===t);i&&i.connecting&&(i.connecting=!1);return}s.message&&e.addMessageToConversation(t,{type:"system",content:typeof s.message=="string"?s.message:JSON.stringify(s.message,null,2)});return}if(s.type==="assistant"){let i=s.message?.content;if(!i)return;let o=e.messagesMap[t]||[];for(let a of o)a.type==="tool-use"&&!a.hasResult&&(a.hasResult=!0);for(let a of r.toolHistory)a.status==="running"&&(a.status="done");if(r.currentTool=null,typeof i=="string"){e.appendToAssistantMessageForConversation(t,i,{id:s.message?.id||s.message?.messageId||null,ts:s.ts||s.message?.ts||s.message?.time||null,sessionId:e._currentYeaftSessionId||null,vpId:e._currentYeaftVpId||null,turnId:e._currentYeaftTurnId||null,threadId:e._currentYeaftThreadId||null});return}if(!Array.isArray(i))return;if(i.length===0){e.finishStreamingForConversation(t);return}for(let a of i)a.type==="text"?e.appendToAssistantMessageForConversation(t,a.text,{id:s.message?.id||s.message?.messageId||null,ts:s.ts||s.message?.ts||s.message?.time||null,sessionId:e._currentYeaftSessionId||null,vpId:e._currentYeaftVpId||null,turnId:e._currentYeaftTurnId||null,threadId:e._currentYeaftThreadId||null}):a.type==="image_asset"&&a.image?e.addMessageToConversation(t,{type:"chat-image",...a.image,sessionId:e._currentYeaftSessionId||null,vpId:e._currentYeaftVpId||null,speakerVpId:e._currentYeaftVpId||null,turnId:e._currentYeaftTurnId||null,threadId:e._currentYeaftThreadId||null}):a.type==="tool_use"&&(e.finishStreamingForConversation(t,{completeLifecycle:!1}),r.currentTool={name:a.name,input:a.input,startTime:Date.now()},r.toolHistory.unshift({name:a.name,input:a.input,timestamp:Date.now(),status:"running"}),r.toolHistory.length>20&&r.toolHistory.pop(),e.addMessageToConversation(t,{type:"tool-use",toolId:a.id||a.tool_use_id||null,toolName:a.name,toolInput:a.input,startTime:Date.now(),isHistory:a.history===!0||s.history===!0||s.isHistory===!0,sessionId:e._currentYeaftSessionId||null,vpId:e._currentYeaftVpId||null,turnId:e._currentYeaftTurnId||null,threadId:e._currentYeaftThreadId||null}))}else if(s.type==="user"){let i=s.internal===!0||s.message?.internal===!0||s.userAuthored===!1||s.message?.userAuthored===!1,o=s.message?.content,a=ab(o);if(typeof a=="string"&&(a.includes("<local-command-caveat>")||a.includes("<command-name>")))return;if(typeof a=="string"&&a.includes("<local-command-stdout>")){let c=a.match(/<local-command-stdout>([\s\S]*?)<\/local-command-stdout>/);if(c){e.appendToAssistantMessageForConversation(t,c[1].trim()),e.finishStreamingForConversation(t);return}}let l=[];if(s.tool_use_result)l=Array.isArray(s.tool_use_result)?s.tool_use_result:[s.tool_use_result];else if(s.message?.content){let c=s.message.content;l=(Array.isArray(c)?c:[]).filter(u=>u.type==="tool_result")}if(l.length>0){let c=e.messagesMap[t]||[];for(let d of l){if(r.toolHistory.length>0){let f=r.toolHistory.findIndex(m=>m.status==="running");f>=0&&(r.toolHistory[f].status="done")}let u=d.tool_use_id||d.toolUseId||d.tool_call_id||d.toolCallId||null,g=d.content||d,p=!1;if(u){for(let f=c.length-1;f>=0;f--)if(c[f].type==="tool-use"&&c[f].toolId===u){c[f].hasResult=!0,c[f].toolResult=d.is_update&&c[f].toolResult?`${c[f].toolResult}
1
+ var B=(e,t,s)=>()=>{if(s)throw s[0];try{return e&&(t=e(e=0)),t}catch(n){throw s=[n],n}};var ay=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(s){throw t=0,s}};function bd(e,t){let s=nacl.randomBytes(24),n=JSON.stringify(e),r,i=!1;n.length>512?(r=pako.gzip(n),i=!0):r=nacl.util.decodeUTF8(n);let o=nacl.secretbox(r,s,t),a={n:nacl.util.encodeBase64(s),c:nacl.util.encodeBase64(o)};return i&&(a.z=!0),a}function wd(e,t){try{let s=nacl.util.decodeBase64(e.n),n=nacl.util.decodeBase64(e.c),r=nacl.secretbox.open(n,s,t);if(!r)return null;if(e.z){let i=pako.ungzip(r,{to:"string"});return JSON.parse(i)}else return JSON.parse(nacl.util.encodeUTF8(r))}catch{return null}}function kd(e){return e&&typeof e=="object"&&typeof e.n=="string"&&typeof e.c=="string"}function Gt(e){return nacl.util.decodeBase64(e)}var qi=B(()=>{});function bs(){return globalThis.localStorage||null}function Id(){let e=Hi();for(let t of Ra)try{t(e)}catch{}}function ly(){try{bs()?.removeItem(xr),bs()?.removeItem(Tr)}catch{}}function cy(e){return String(e||"").trim()||null}function Sd(e,t){if(!Mr(t))return{};try{let s=JSON.parse(bs()?.getItem(e)||"null");return!s||typeof s!="object"||Array.isArray(s)||s.ownerId!==t.ownerId||!s.records||typeof s.records!="object"||Array.isArray(s.records)?(bs()?.removeItem(e),{}):s.records}catch{try{bs()?.removeItem(e)}catch{}return{}}}function Cd(e,t,s){if(!Mr(s))return!1;try{return bs()?.setItem(e,JSON.stringify({ownerId:s.ownerId,records:t||{}})),!0}catch{return!1}}function Qt(e){let t=cy(e);if(!t)return _a(),null;if(pn!==t){pn=t,Vi+=1;for(let s of[xr,Tr])try{let n=JSON.parse(bs()?.getItem(s)||"null");(!n||n.ownerId!==t)&&bs()?.removeItem(s)}catch{try{bs()?.removeItem(s)}catch{}}Id()}return Hi()}function _a(){pn=null,Vi+=1,ly(),Id()}function Hi(){return pn?{ownerId:pn,epoch:Vi}:null}function Mr(e){return!!e&&!!pn&&e.ownerId===pn&&e.epoch===Vi}function Ad(e){return{drafts:Sd(xr,e),outbox:Sd(Tr,e)}}function Ea(e,t){return Cd(xr,e,t)}function Pr(e,t){return Cd(Tr,e,t)}function xd(e){return typeof e!="function"?()=>{}:(Ra.add(e),()=>Ra.delete(e))}var xr,Tr,pn,Vi,Ra,rI,Da=B(()=>{xr="yeaft-work-center-composer-drafts-v1",Tr="yeaft-work-center-message-outbox-v1",pn=null,Vi=0,Ra=new Set;rI=Object.freeze({drafts:xr,outbox:Tr})});function $a(){try{globalThis.Pinia?.useChatStore?.()?.clearYeaftHistoryMemory?.()}catch{}}function ws(e){let t=String(e||"").trim()||null;Bi!==t&&$a(),Bi=t}function uy(){$a(),Bi=null}var dy,Bi,py,Ge,qt=B(()=>{qi();Da();({defineStore:dy}=Pinia);Bi=null;py=1800*1e3,Ge=dy("auth",{state:()=>({skipAuth:!1,emailVerification:!1,passwordResetEnabled:!1,totpEnabled:!1,registrationEnabled:!1,aadEnabled:!1,aadClientId:null,aadTenantId:null,ssoProviders:{github:!1,google:!1,wechat:!1,alipay:!1},linkedIdentities:[],hasPassword:!1,identitiesLoading:!1,identitiesError:null,initialized:!1,authGeneration:0,isAuthenticated:!1,token:null,sessionKey:null,userId:null,role:null,loginStep:"credentials",tempToken:null,emailHint:null,setupToken:null,totpSecret:null,qrCode:null,error:null,loading:!1,qrPanel:null,_qrPollTimer:null,_sessionRefreshTimer:null,_sessionRefreshVisibilityHandler:null}),actions:{async initialize(){if(this.initialized)return this.isAuthenticated;try{if(await this.checkAuthMode(),this.skipAuth&&this.isAuthenticated)return!0;let e=!1;return typeof window<"u"&&typeof this.consumeSsoRedirect=="function"&&(e=this.consumeSsoRedirect()),!this.isAuthenticated&&!e&&await this.restoreSession(),this.isAuthenticated}finally{this.initialized=!0}},async checkAuthMode(){try{let t=await(await fetch("/api/auth/mode")).json();this.skipAuth=t.skipAuth,this.emailVerification=t.emailVerification,this.passwordResetEnabled=!!t.passwordResetEnabled,this.totpEnabled=t.totpEnabled,this.registrationEnabled=t.registrationEnabled||!1,this.aadEnabled=t.aadEnabled||!1,this.aadClientId=t.aadClientId||null,this.aadTenantId=t.aadTenantId||null,this.ssoProviders=Object.assign({github:!1,google:!1,wechat:!1,alipay:!1},t.ssoProviders||{}),this.skipAuth&&(this.userId="skip-auth",Qt(this.userId),ws(this.userId),this.authGeneration+=1,this.isAuthenticated=!0,this.loginStep="authenticated")}catch{}},async login(e,t){this.loading=!0,this.error=null;try{let n=await(await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:e,password:t})})).json();return n.success?n.needTotpSetup?(this.setupToken=n.setupToken,this.totpSecret=n.totpSecret,this.qrCode=n.qrCode,this.loginStep="totp-setup",!0):n.needTotpCode?(this.tempToken=n.tempToken,this.loginStep="totp",!0):n.needEmailCode?(this.tempToken=n.tempToken,this.emailHint=n.emailHint,this.loginStep="verification",!0):(this.token=n.token,this.sessionKey=n.sessionKey?Gt(n.sessionKey):null,this.role=n.role||"pro",this.userId=n.userId||null,Qt(this.userId),ws(this.userId),this.authGeneration+=1,this.isAuthenticated=!0,this.loginStep="authenticated",localStorage.setItem("authToken",n.token),this.startSessionRefresh(),!0):(this.error=n.error||"Login failed",!1)}catch(s){return this.error=s.message||"Network error",!1}finally{this.loading=!1}},async loginWithMicrosoft(){if(!this.aadEnabled||!this.aadClientId||!this.aadTenantId)return this.error="Microsoft login is not configured",!1;if(typeof msal>"u"||!msal.PublicClientApplication)return this.error="Microsoft authentication library not loaded",!1;this.loading=!0,this.error=null;try{let e={auth:{clientId:this.aadClientId,authority:`https://login.microsoftonline.com/${this.aadTenantId}`,redirectUri:window.location.origin+"/auth/callback"},cache:{cacheLocation:"sessionStorage",storeAuthStateInCookie:!1}},t=new msal.PublicClientApplication(e);await t.initialize();let s=await t.loginPopup({scopes:["openid","profile","email"]});if(!s||!s.idToken)return this.error="Microsoft login failed: no token received",!1;let r=await(await fetch("/api/auth/aad",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({idToken:s.idToken})})).json();return r.success?(this.token=r.token,this.sessionKey=r.sessionKey?Gt(r.sessionKey):null,this.role=r.role||"pro",this.userId=r.userId||null,Qt(this.userId),ws(this.userId),this.authGeneration+=1,this.isAuthenticated=!0,this.loginStep="authenticated",localStorage.setItem("authToken",r.token),this.startSessionRefresh(),!0):(this.error=r.error||"Microsoft login failed",!1)}catch(e){return e.errorCode==="user_cancelled"||e.name==="BrowserAuthError"?(this.error=null,!1):(this.error=e.message||"Microsoft login failed",!1)}finally{this.loading=!1}},async verifyTotpCode(e){this.loading=!0,this.error=null;try{let s=await(await fetch("/api/auth/verify-totp",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tempToken:this.tempToken,totpCode:e})})).json();return s.success?s.needEmailCode?(this.tempToken=s.tempToken,this.emailHint=s.emailHint,this.loginStep="verification",!0):(this.token=s.token,this.sessionKey=s.sessionKey?Gt(s.sessionKey):null,this.role=s.role||"pro",this.userId=s.userId||null,Qt(this.userId),ws(this.userId),this.authGeneration+=1,this.isAuthenticated=!0,this.loginStep="authenticated",this.tempToken=null,localStorage.setItem("authToken",s.token),this.startSessionRefresh(),!0):(this.error=s.error||"TOTP verification failed",!1)}catch(t){return this.error=t.message||"Network error",!1}finally{this.loading=!1}},async completeTotpSetup(e){this.loading=!0,this.error=null;try{let s=await(await fetch("/api/auth/setup-totp",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({setupToken:this.setupToken,totpCode:e})})).json();return s.success?(this.setupToken=null,this.totpSecret=null,this.qrCode=null,s.needEmailCode?(this.tempToken=s.tempToken,this.emailHint=s.emailHint,this.loginStep="verification",!0):(this.token=s.token,this.sessionKey=s.sessionKey?Gt(s.sessionKey):null,this.role=s.role||"pro",this.userId=s.userId||null,Qt(this.userId),ws(this.userId),this.authGeneration+=1,this.isAuthenticated=!0,this.loginStep="authenticated",localStorage.setItem("authToken",s.token),this.startSessionRefresh(),!0)):(this.error=s.error||"TOTP setup failed",!1)}catch(t){return this.error=t.message||"Network error",!1}finally{this.loading=!1}},async verifyCode(e){this.loading=!0,this.error=null;try{let s=await(await fetch("/api/auth/verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tempToken:this.tempToken,code:e})})).json();return s.success?(this.token=s.token,this.sessionKey=s.sessionKey?Gt(s.sessionKey):null,this.role=s.role||"pro",this.userId=s.userId||null,Qt(this.userId),ws(this.userId),this.authGeneration+=1,this.isAuthenticated=!0,this.loginStep="authenticated",this.tempToken=null,this.emailHint=null,localStorage.setItem("authToken",s.token),this.startSessionRefresh(),!0):(this.error=s.error||"Verification failed",!1)}catch(t){return this.error=t.message||"Network error",!1}finally{this.loading=!1}},async register(e,t,s,n){this.loading=!0,this.error=null;try{let i=await(await fetch("/api/auth/register",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:e,password:t,email:s||void 0,invitationCode:n})})).json();return i.success?!0:(this.error=i.error||"Registration failed",!1)}catch(r){return this.error=r.message||"Network error",!1}finally{this.loading=!1}},showRegister(){this.loginStep="register",this.error=null},loginWithSso(e){window.location.href=`/api/auth/sso/${encodeURIComponent(e)}/start`},async loginWithAlipayMobile({intent:e="login"}={}){if(!await this.startSsoQr("alipay",{intent:e}))return!1;let s=this.qrPanel?.authorizeUrl;if(!s)return!1;let n=`alipays://platformapi/startapp?appId=20000067&url=${encodeURIComponent(s)}`;return this.qrPanel={...this.qrPanel,mobileDeepLink:!0},window.location.href=n,!0},async startSsoQr(e,{intent:t="login"}={}){this.cancelSsoQr(),this.error=null;try{let s=new URLSearchParams;if(t==="bind"){if(!this.isAuthenticated)return this.error="You must be logged in to bind an identity",!1;s.set("intent","bind")}let n=s.toString(),r=`/api/auth/sso/${encodeURIComponent(e)}/start-qr${n?"?"+n:""}`,i=await fetch(r),o=await i.json();return!i.ok||!o.success?(this.error=o.error||"Failed to start QR login",!1):(this.qrPanel={provider:e,intent:t,authorizeUrl:o.authorizeUrl,state:o.state,status:"pending",error:null},this._startQrPoll(),!0)}catch(s){return this.error=s.message||"Network error",!1}},_startQrPoll(){this._stopQrPollTimer();let e=async()=>{if(!this.qrPanel)return;let t=this.qrPanel.state;try{let n=await(await fetch(`/api/auth/sso/poll/${encodeURIComponent(t)}`)).json();if(!this.qrPanel||this.qrPanel.state!==t||n.status==="pending")return;if(n.status==="login"){this.token=n.token,this.sessionKey=n.sessionKey?Gt(n.sessionKey):null,this.role=n.role||"pro",this.userId=n.userId||null,Qt(this.userId),ws(this.userId),this.authGeneration+=1,this.isAuthenticated=!0,this.loginStep="authenticated",localStorage.setItem("authToken",n.token),this.startSessionRefresh(),this.cancelSsoQr();return}if(n.status==="bind"){this.qrPanel={...this.qrPanel,status:"bound"},this._stopQrPollTimer();return}this.qrPanel={...this.qrPanel,status:"error",error:n.error||"SSO failed"},this._stopQrPollTimer()}catch{}};this._qrPollTick=e,this._qrPollTimer=setInterval(e,2e3),typeof document<"u"&&!this._qrVisHandler&&(this._qrVisHandler=()=>{typeof document<"u"&&document.visibilityState&&document.visibilityState!=="visible"||!this.qrPanel||!this._qrPollTick||(this._qrPollTick(),this._qrPollTimer&&clearInterval(this._qrPollTimer),this._qrPollTimer=setInterval(this._qrPollTick,2e3))},document.addEventListener("visibilitychange",this._qrVisHandler),typeof window<"u"&&window.addEventListener("pageshow",this._qrVisHandler))},_stopQrPollTimer(){this._qrPollTimer&&(clearInterval(this._qrPollTimer),this._qrPollTimer=null),this._qrVisHandler&&(typeof document<"u"&&document.removeEventListener("visibilitychange",this._qrVisHandler),typeof window<"u"&&window.removeEventListener("pageshow",this._qrVisHandler),this._qrVisHandler=null),this._qrPollTick=null},cancelSsoQr(){this._stopQrPollTimer(),this.qrPanel=null},bindSso(e){if(!this.isAuthenticated){this.error="You must be logged in to bind an identity";return}let t=new URLSearchParams({intent:"bind"});window.location.href=`/api/auth/sso/${encodeURIComponent(e)}/start?${t.toString()}`},consumeSsoRedirect(){let e=window.location.hash||"",t=e.indexOf("?");if(!e.startsWith("#/sso-complete")||t<0)return!1;let s=new URLSearchParams(e.slice(t+1)),n=s.get("token"),r=s.get("sessionKey"),i=s.get("role"),o=s.get("userId");if(!n)return!1;this.token=n,this.sessionKey=r?Gt(r):null,this.role=i||"pro",this.userId=o||null,Qt(this.userId),ws(this.userId),this.authGeneration+=1,this.isAuthenticated=!0,this.loginStep="authenticated",localStorage.setItem("authToken",n),this.startSessionRefresh();try{history.replaceState(null,"",window.location.pathname+window.location.search)}catch{}return!0},async loadIdentities(){if(this.isAuthenticated){this.identitiesLoading=!0,this.identitiesError=null;try{let e=await fetch("/api/auth/identities"),t=await e.json();if(!e.ok||!t.success){this.identitiesError=t.error||"Failed to load identities";return}this.linkedIdentities=t.identities||[],this.hasPassword=!!t.hasPassword}catch(e){this.identitiesError=e.message||"Network error"}finally{this.identitiesLoading=!1}}},async unbindIdentity(e){if(!this.isAuthenticated)return!1;this.identitiesError=null;try{let t=await fetch(`/api/auth/identities/${encodeURIComponent(e)}`,{method:"DELETE"}),s=await t.json();return!t.ok||!s.success?(this.identitiesError=s.error||"Failed to unbind",!1):(this.linkedIdentities=this.linkedIdentities.filter(n=>n.provider!==e),!0)}catch(t){return this.identitiesError=t.message||"Network error",!1}},async refreshSession(){let e=this.token,t=this.authGeneration,s=this.isAuthenticated;try{let n=await fetch("/api/user/profile",{headers:e?{Authorization:`Bearer ${e}`}:{}});if(this.handleAuthResponse(n,e,t,s)||!n.ok)return!1;let r=await n.json().catch(()=>({}));if(t!==this.authGeneration||this.token!==e)return this.isAuthenticated;let i=n.headers?.get?.("X-New-Token"),o=localStorage.getItem("authToken");i&&this.token===e&&(!o||o===e)&&(this.token=i,localStorage.setItem("authToken",i)),r?.role&&(this.role=r.role);let a=this.userId;return this.userId=r?.userId||null,Qt(this.userId),a!==this.userId&&$a(),Bi=this.userId,!0}catch{return!1}},startSessionRefresh(){if(this.stopSessionRefresh(),!this.isAuthenticated||this.skipAuth)return;let e=()=>{typeof document<"u"&&document.visibilityState&&document.visibilityState!=="visible"||this.refreshSession()};this._sessionRefreshTimer=setInterval(e,py),this._sessionRefreshVisibilityHandler=e,typeof document<"u"&&document.addEventListener("visibilitychange",e),typeof window<"u"&&window.addEventListener("pageshow",e)},stopSessionRefresh(){this._sessionRefreshTimer&&(clearInterval(this._sessionRefreshTimer),this._sessionRefreshTimer=null),this._sessionRefreshVisibilityHandler&&(typeof document<"u"&&document.removeEventListener("visibilitychange",this._sessionRefreshVisibilityHandler),typeof window<"u"&&window.removeEventListener("pageshow",this._sessionRefreshVisibilityHandler),this._sessionRefreshVisibilityHandler=null)},async logout(){try{let e={"Content-Type":"application/json"};this.token&&(e.Authorization=`Bearer ${this.token}`),await fetch("/api/auth/logout",{method:"POST",headers:e})}catch{}await this.clearStoredSession()},clearStoredSession(e=null){let t=this.reset();return localStorage.removeItem("authToken"),e&&(this.error=e),t},getActiveToken(){if(this.token)return this.token;let e=localStorage.getItem("authToken");return e&&(this.token=e),this.token},handleAuthResponse(e,t=null,s=this.authGeneration,n=this.isAuthenticated,r=void 0){if(!e||e.status!==401||!n||s!==this.authGeneration)return!1;let i=this.token||localStorage.getItem("authToken")||null;return t!==i?!1:(this.handleAuthFailure(r,t,s),!0)},handleAuthFailure(e="Session expired. Please log in again.",t=null,s=this.authGeneration){if(s!==this.authGeneration)return!1;let n=this.token||localStorage.getItem("authToken")||null;return t!==n||this.clearStoredSession(e),!1},async restoreSession(){let e=localStorage.getItem("authToken"),t=this.authGeneration,s=this.isAuthenticated||!!e;try{let n=await fetch("/api/user/profile",{headers:e?{Authorization:`Bearer ${e}`}:{}});if(this.handleAuthResponse(n,e,t,s))return!1;if(!n.ok)return this.error="Failed to restore session",!1;let r=await n.json();if(t!==this.authGeneration)return this.isAuthenticated;let i=n.headers?.get?.("X-New-Token"),o=this.getActiveToken();if(o!==e)return this.isAuthenticated;let a=i&&(!o||o===e)?i:o||e;return this.token=a,a&&a!==e&&localStorage.setItem("authToken",a),this.role=r?.role||"pro",this.userId=r?.userId||null,Qt(this.userId),ws(this.userId),this.authGeneration+=1,this.isAuthenticated=!0,this.loginStep="authenticated",this.startSessionRefresh(),!0}catch(n){return this.error=n.message||"Failed to restore session",!1}},setSessionKey(e){e&&(this.sessionKey=Gt(e))},backToCredentials(){this.loginStep="credentials",this.tempToken=null,this.emailHint=null,this.setupToken=null,this.totpSecret=null,this.qrCode=null,this.error=null},async requestPasswordReset(e){this.error=null;try{let s=await(await fetch("/api/auth/password-reset/request",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e})})).json();return s.success?s.resetToken||null:(this.error=s.error||"Failed to request password reset",null)}catch(t){return this.error=t.message||"Network error",null}},async verifyPasswordReset(e,t,s){this.error=null;try{let r=await(await fetch("/api/auth/password-reset/verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({resetToken:e,code:t,newPassword:s})})).json();return r.success?!0:(this.error=r.error||"Failed to reset password",!1)}catch(n){return this.error=n.message||"Network error",!1}},async deleteAccount({currentPassword:e,confirm:t}={}){if(!this.isAuthenticated)return{success:!1,error:"Not authenticated"};try{let s=await fetch("/api/user/me",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({currentPassword:e,confirm:t})}),n=await s.json();return!s.ok||!n.success?{success:!1,error:n.error||"Failed to delete account"}:(await this.clearStoredSession(),{success:!0})}catch(s){return{success:!1,error:s.message||"Network error"}}},reset(){_a(),uy(),this.authGeneration+=1,this.stopSessionRefresh(),this.isAuthenticated=!1,this.token=null,this.sessionKey=null,this.userId=null,this.role=null,this.loginStep="credentials",this.tempToken=null,this.emailHint=null,this.setupToken=null,this.totpSecret=null,this.qrCode=null,this.error=null,this.loading=!1}}})});function Oe(e,t){let s=ks?.value||"zh-CN",r=(qn[s]||qn["zh-CN"]||{})[e];if(r===void 0&&s!=="zh-CN"&&(r=(qn["zh-CN"]||{})[e]),r===void 0)return e;if(t)for(let[i,o]of Object.entries(t))r=r.replace(new RegExp(`\\{${i}\\}`,"g"),o);return r}function gy(){return ks?.value||"zh-CN"}function Rr(e){qn[e]&&(ks&&(ks.value=e),localStorage.setItem("locale",e),document.documentElement.setAttribute("lang",e))}function fy(){let e=localStorage.getItem("locale");return e&&qn[e]?e:(navigator.language||navigator.userLanguage||"").startsWith("en")?"en":"zh-CN"}function Td(e,t){return qn=t,ks=Vue.ref(fy()),document.documentElement.setAttribute("lang",ks.value),e.config.globalProperties.$t=Oe,e.config.globalProperties.$locale=ks,e.provide("t",Oe),e.provide("locale",ks),{t:Oe,setLocale:Rr,getLocale:gy,locale:ks}}var ks,qn,ss=B(()=>{ks=null,qn={}});function Vn(e){return e?.capabilityMetadataProvided!==!0?!0:Array.isArray(e.capabilities)&&e.capabilities.includes(La)}var La,Ni=B(()=>{La="yeaft_plugins"});function Wi(e){if(e?.capabilityMetadataProvided!==!0)return!1;let t=Array.isArray(e.capabilities)?e.capabilities:[];return t.includes(La)&&t.includes(hy)}var hy,Fa=B(()=>{Ni();hy="yeaft_managed_skills"});function gn(e){if(e==null||e==="")return"claude-code";if(my.has(e))return e;throw new Error(`Unknown Chat runtime provider: ${e}`)}function Vs(e){if(typeof e!="string"||!e)throw new Error("Chat catalog key requires conversationId");return`chat:${e}`}function Hn(e,t){if(typeof e!="string"||!e||typeof t!="string"||!t)throw new Error("Yeaft catalog key requires agentId and sessionId");return`yeaft:${e}:${t}`}function _r(e,t,s={}){let n=e.sessionCatalog.map(i=>({...i})),r=Array.isArray(e.hiddenSessionCatalog)?e.hiddenSessionCatalog.map(i=>({...i})):null;return e.sessionCatalogMutationRequests[t]={previousCatalog:n,previousHiddenCatalog:r,...s},n}function Md(e,t){let s=t?.requestId?e.sessionCatalogMutationRequests[t.requestId]:null;return s?(delete e.sessionCatalogMutationRequests[t.requestId],t.ok!==!0&&(e.sessionCatalog=s.previousCatalog,Array.isArray(s.previousHiddenCatalog)&&(e.hiddenSessionCatalog=s.previousHiddenCatalog)),!0):!1}function Pd(e,t,s="recent",n=null){let r=Vs(t),i=e.chatHistoryRequests[r]||{},o=Number(i.generation||0)+1,a=`chat_history_${o}_${crypto.randomUUID()}`;return e.chatHistoryRequests[r]={requestId:a,catalogKey:r,generation:o,mode:s,cursor:n,connectionGeneration:Number(e.chatHistoryConnectionGeneration||0),loading:!0,cancelled:!1,error:null},a}function Oa(e,t,s,n){let r=e.chatHistoryRequests[t];return r?.requestId!==s?!1:(e.chatHistoryRequests[t]={...r,loading:!1,cancelled:!0,error:n},!0)}var my,ji=B(()=>{my=new Set(["claude-code","copilot"])});function Bn(e,t,s=""){Er&&(clearTimeout(Er),Er=null),e.sessionLoading=t,e.sessionLoadingText=s,t&&(Er=setTimeout(()=>{e.sessionLoading&&(e.sessionLoading=!1,e.sessionLoadingText=""),Er=null},vy))}function ns(e){Bn(e,!1)}function Rd(e){if(e.currentConversation){e.pendingRecovery=null;return}let t=e.lastUsedSession,s=e.lastUsedAgent;if(t&&t.sessionId&&s){let n=e.agents.find(r=>r.id===s&&r.online);n&&(e.pendingRecovery={agentId:s,agentName:n.name,sessionId:t.sessionId,workDir:t.workDir,provider:gn(t.provider),catalogKey:t.catalogKey||null},e.recoveryDismissed=!1)}}function _d(e){if(!e.pendingRecovery)return;let{agentId:t,sessionId:s,workDir:n,provider:r}=e.pendingRecovery;e.selectAgent(t),setTimeout(()=>{e.resumeConversation(s,n,t,{provider:gn(r)}),e.pendingRecovery=null,e.recoveryDismissed=!1},500)}function Ed(e){e.recoveryDismissed=!0,e.pendingRecovery=null}function Dd(e,t){let s=e.conversations.find(n=>n.id===t);s&&(e.activeConversations=[t],e.currentWorkDir=s.workDir,e.messagesMap[t]?.length>0||(s.claudeSessionId?(e.messagesMap[t]=[],Bn(e,!0,Oe("chat.session.loadingHistory")),e.sendWsMessage({type:"resume_conversation",agentId:s.agentId||e.currentAgent,claudeSessionId:s.claudeSessionId,workDir:s.workDir,conversationId:t})):(e.messagesMap[t]=[],e.requestChatHistory?.(t,{mode:"recent",turns:5}))),e.sendWsMessage({type:"select_conversation",conversationId:t}))}function $d(e){if(e.panels.length>0)return;let t=localStorage.getItem("panels");if(!t)return;let s;try{s=JSON.parse(t)}catch{localStorage.removeItem("panels");return}if(!Array.isArray(s)||s.length<2){localStorage.removeItem("panels");return}let n=new Set(e.conversations.map(i=>i.id)),r=s.filter(i=>i&&typeof i.id=="string").map(i=>({id:i.id,conversationId:i.conversationId&&n.has(i.conversationId)?i.conversationId:null,activeRightPanel:i.activeRightPanel||null}));if(r.length<2){localStorage.removeItem("panels");return}e.panels=r,e.activePanelId=r[0]?.id||null;for(let i of r)i.conversationId&&(e.activeConversations.includes(i.conversationId)||e.activeConversations.push(i.conversationId),e.messagesMap[i.conversationId]||(e.messagesMap[i.conversationId]=[]),e.messagesMap[i.conversationId].length||e.requestChatHistory?.(i.conversationId,{mode:"recent",turns:5}))}function fn(e){if(e.currentAgent){if(localStorage.setItem("lastUsedAgent",e.currentAgent),localStorage.setItem("lastViewedConversation",e.currentConversation||""),e.lastViewedConversation=e.currentConversation,e.currentConversation){let t=e.conversations.find(s=>s.id===e.currentConversation);if(t?.claudeSessionId&&t?.workDir){let s=gn(t.provider),n={sessionId:t.claudeSessionId,workDir:t.workDir,agentId:t.agentId||e.currentAgent,provider:s,catalogKey:Vs(t.id),version:2};localStorage.setItem("lastUsedSession",JSON.stringify(n)),localStorage.setItem("lastViewedSessionRef",JSON.stringify(n)),e.lastUsedSession=n}}e.lastUsedAgent=e.currentAgent,e.panels.length>0?localStorage.setItem("panels",JSON.stringify(e.panels)):localStorage.removeItem("panels")}}function Ld(e){return e.lastUsedSession}function Fd(e){localStorage.removeItem("lastUsedAgent"),localStorage.removeItem("lastUsedSession"),localStorage.removeItem("lastViewedSessionRef"),localStorage.removeItem("lastViewedConversation"),localStorage.removeItem("panels"),localStorage.removeItem("splitPanesSaved"),e.lastUsedAgent=null,e.lastUsedSession=null,e.lastViewedConversation=null}function Od(e,t,s){if(!e.currentAgent){e.historySessionsLoading=!1;return}if(!t){e.historySessions=[],e.historySessionsLoading=!1;return}let n=Date.now().toString();e._historySessionsRequestId=n,e.historySessionsLoading=!0,e.historySessions=[],e.sendWsMessage({type:"list_history_sessions",workDir:t,provider:s||"claude-code",requestId:n})}function qd(e,t){if(!e.currentAgent)return e.foldersLoading=!1,Promise.resolve();e.foldersLoading=!0,e.folders=[];let s=Date.now().toString();return e._foldersRequestId=s,new Promise(n=>{e._foldersResolve&&e._foldersResolve(),e._foldersResolve=n,e.sendWsMessage({type:"list_folders",provider:t||"claude-code",requestId:s}),setTimeout(()=>{e._foldersResolve===n&&(e._foldersResolve(),e._foldersResolve=null,e.foldersLoading=!1)},1e4)})}function Vd(e,t,s){if(!t)return e.foldersLoading=!1,Promise.resolve();e.foldersLoading=!0,e.folders=[];let n=Date.now().toString();return e._foldersRequestId=n,new Promise(r=>{e._foldersResolve&&e._foldersResolve(),e._foldersResolve=r,e.sendWsMessage({type:"list_folders",agentId:t,provider:s||"claude-code",requestId:n}),setTimeout(()=>{e._foldersResolve===r&&(e._foldersResolve(),e._foldersResolve=null,e.foldersLoading=!1)},1e4)})}function Hd(e,t,s){if(!t)return Promise.resolve([]);let n=`models-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;return e._modelsRequestId=n,e.providerModelsLoading=!0,new Promise(r=>{e._modelsResolve&&e._modelsResolve([]),e._modelsTimeout&&clearTimeout(e._modelsTimeout),e._modelsResolve=r,e.sendWsMessage({type:"list_models",agentId:t,provider:s||"claude-code",requestId:n}),e._modelsTimeout=setTimeout(()=>{e._modelsResolve===r&&(e._modelsResolve([]),e._modelsResolve=null,e.providerModelsLoading=!1),e._modelsTimeout=null},1e4)})}function Bd(e,t,s,n){if(!t){e.historySessionsLoading=!1;return}if(!s){e.historySessions=[],e.historySessionsLoading=!1;return}let r=Date.now().toString();e._historySessionsRequestId=r,e.historySessionsLoading=!0,e.historySessions=[],e.sendWsMessage({type:"list_history_sessions",agentId:t,workDir:s,provider:n||"claude-code",requestId:r})}async function Nd(e,t=20){if(Ge().isAuthenticated){e.globalSessionsLoading=!0;try{let n=await fetch(`/api/sessions?limit=${t}`);if(n.ok){let r=await n.json();e.globalSessions=r.sessions||[]}}catch{}finally{e.globalSessionsLoading=!1}}}async function Wd(e,t){if(!Ge().isAuthenticated)return!1;try{if((await fetch(`/api/sessions/${t}`,{method:"DELETE"})).ok)return e.globalSessions=e.globalSessions.filter(r=>r.id!==t),!0}catch{}return!1}function qa(e,t){return t.agentId?e.agents.find(s=>s.id===t.agentId):t.agentName?e.agents.find(s=>s.name===t.agentName):null}function jd(e,t){let s=qa(e,t);return s&&s.online}var vy,Er,hn=B(()=>{qt();ss();ji();vy=3e4,Er=null});function Ud(){typeof window>"u"||typeof window.dispatchEvent!="function"||typeof CustomEvent>"u"||window.dispatchEvent(new CustomEvent("browser-runtime-transport-reset"))}function Kd(e){return e?.code===1008&&String(e.reason||"").toLowerCase().includes("authentication")}function zd(e){let t=Dr;Dr=[];for(let{resolve:s,reject:n,timer:r}of t)clearTimeout(r),e?s():n(new Error("WebSocket reconnect failed"))}function Gd(e,t){if(!e.ws||e.ws.readyState!==WebSocket.OPEN)return!1;if(e.currentView==="yeaft"&&by.has(t.type)){let s=t.conversationId;if(!s||typeof s=="string"&&s.startsWith("yeaft-")||s===e.yeaftConversationId)return!1}try{if(e.serverEncryptionRequired&&e.sessionKey){let s=bd(t,e.sessionKey);e.ws.send(JSON.stringify(s))}else e.ws.send(JSON.stringify(t));return!0}catch{return!1}}function $r(e,t=1e4){return e.ws&&e.ws.readyState===WebSocket.OPEN?Promise.resolve():new Promise((s,n)=>{let r=setTimeout(()=>{Dr=Dr.filter(i=>i.resolve!==s),n(new Error("WebSocket reconnect timeout"))},t);Dr.push({resolve:s,reject:n,timer:r}),(!e.ws||e.ws.readyState!==WebSocket.CONNECTING)&&(e.reconnectAttempts=0,e.connect())})}function Qd(e,t){try{let s=JSON.parse(t);return e.sessionKey&&kd(s)?wd(s,e.sessionKey):s}catch{return null}}function Yd(e,t,s,n){for(let[r,i]of e._sessionCrudPending?.entries?.()||[])Number(i?.connectionGeneration||0)===Number(t||0)&&(i.resolve?.({ok:!1,requestId:r,error:{code:s,message:n}}),e._sessionCrudPending.delete(r))}function Xd(e){let t=Ge(),s=location.protocol==="https:"?"wss:":"ws:";e.reconnectTimer&&(clearTimeout(e.reconnectTimer),e.reconnectTimer=null);let n=t.getActiveToken?.()||t.token||null,r=t.authGeneration;if(e.ws&&e.ws.readyState===WebSocket.CONNECTING&&e._wsAuthToken===n&&e._wsAuthGeneration===r)return;clearTimeout(e._legacyYeaftSessionHydrateTimer),e._legacyYeaftSessionHydrateTimer=null,e._hasHandledAgentList=!1,e._hasHandledYeaftSessionHydrate=!1,e.yeaftSessionInventoryCompleteSupported=null,e.workbenchRouteProtocolSupported=null,e.browserRuntimeProtocolSupported=null,e.browserRuntimeSetupProtocolSupported=null,e.browserRuntimeServerEnabled=!1,Ud(),e.yeaftSessionHydrateRequestId=null,e.yeaftSessionHydrateSlices=[],e.yeaftSessionHydrateError=null,e._yeaftSessionInventorySocketQuarantined=!1,e.pendingAgentSelection=null,e.agentSwitching=!1,e.ws&&(Yd(e,e.chatHistoryConnectionGeneration,"connection_changed","WebSocket connection changed"),e.ws.onopen=null,e.ws.onmessage=null,e.ws.onclose=null,e.ws.close(),e.ws=null),e.connectionState=e.reconnectAttempts>0?"reconnecting":"connecting",e.serverEncryptionRequired=!0,e.chatHistoryRequestIdSupported=null;let i=Number(e.chatHistoryConnectionGeneration||0)+1;e.chatHistoryConnectionGeneration=i;for(let[c,d]of Object.entries(e.projectMutationRequests||{}))d?.resolve?.({ok:!1,requestId:c,error:{code:"connection_changed"}});e.projectMutationRequests={},e.sessionProjects=[];for(let[c,d]of Object.entries(e.chatHistoryRequests||{}))d?.loading&&(e.chatHistoryRequests[c]={...d,loading:!1,cancelled:!0,error:"connection_changed"});let o=Object.values(e.sessionCatalogMutationRequests||{});o.length>0&&(e.sessionCatalog=o[0].previousCatalog,Array.isArray(o[0].previousHiddenCatalog)&&(e.hiddenSessionCatalog=o[0].previousHiddenCatalog),e.sessionCatalogMutationRequests={}),e.sessionCatalogLoaded=!1,e.sessionCatalog=[],e.hiddenSessionCatalog=[],e.activeCatalogKey=null,e._wsAuthToken=n,e._wsAuthGeneration=r;let a=`${s}//${location.host}?type=web`;n&&(a+=`&token=${encodeURIComponent(n)}`);let l=new WebSocket(a);e.ws=l,l.onopen=()=>{if(l===e.ws){e.connectionState="connected",e.reconnectAttempts=0,e.startHeartbeat();try{l.send(JSON.stringify({type:"client_hello",plaintextOk:!0,workbenchRouteProtocol:1,browserRuntimeProtocol:1,browserRuntimeSetupProtocol:1}))}catch{}zd(!0)}},l.onmessage=c=>{if(l!==e.ws)return;let d=e.parseWsMessage(c.data);d&&(d.type,e.handleMessage({...d,_wsAuthToken:n,_wsAuthGeneration:r}))},l.onclose=c=>{if(l!==e.ws){Kd(c)&&t.handleAuthFailure?.(void 0,n,r);return}e.authenticated=!1,clearTimeout(e._legacyYeaftSessionHydrateTimer),e._legacyYeaftSessionHydrateTimer=null,e._hasHandledAgentList=!1,e._hasHandledYeaftSessionHydrate=!1,e.yeaftSessionInventoryCompleteSupported=null,e.workbenchRouteProtocolSupported=null,e.browserRuntimeProtocolSupported=null,e.browserRuntimeSetupProtocolSupported=null,e.browserRuntimeServerEnabled=!1,Ud(),e.yeaftSessionHydrateRequestId=null,e.yeaftSessionHydrateSlices=[],e.yeaftSessionHydrateError=null;for(let u of Object.values(e._workCenterFeaturePending||{}))clearTimeout(u.timer),u.reject(new Error("WebSocket disconnected"));e._workCenterFeaturePending={},Yd(e,i,"agent_offline","WebSocket disconnected"),e.pendingAgentSelection=null,e.agentSwitching=!1;let d=e.connectionState==="updating";if(e.connectionState=d?"updating":"disconnected",e.stopHeartbeat(),ns(e),Kd(c)){t.handleAuthFailure?.(void 0,n,r),e.reconnectAttempts=0,zd(!1);return}if(e._yeaftReconnectCatchUpPending=!0,d){e.reconnectAttempts=0,e.reconnectTimer=setTimeout(()=>{e.connect()},2e3);return}e.scheduleReconnect()},e.ws.onerror=c=>{}}function Zd(e){if(e.reconnectAttempts>=e.maxReconnectAttempts){e.connectionState="disconnected";return}let t=Math.min(1e3*Math.pow(2,e.reconnectAttempts),3e4);e.reconnectAttempts++,e.connectionState="reconnecting",e.reconnectTimer=setTimeout(()=>{e.connect()},t)}function Jd(e){e.reconnectAttempts=0,e.connect()}function eu(e){e.stopHeartbeat(),e._lastPongAt=Date.now(),e.heartbeatTimer=setInterval(()=>{if(e.ws&&e.ws.readyState===WebSocket.OPEN){if(Date.now()-e._lastPongAt>45e3){e.ws.close(4e3,"Heartbeat timeout");return}try{e.sendWsMessage({type:"ping"})}catch{}}},25e3)}function tu(e){e.heartbeatTimer&&(clearInterval(e.heartbeatTimer),e.heartbeatTimer=null)}function su(e){e._visibilityHandlerInstalled||(e._visibilityHandlerInstalled=!0,document.addEventListener("visibilitychange",()=>{if(document.visibilityState==="visible")if(!e.ws||e.ws.readyState!==WebSocket.OPEN)e.reconnectAttempts=0,e.connect();else try{e.sendWsMessage({type:"ping"});let t=e._lastPongAt;setTimeout(()=>{e._lastPongAt===t&&e.ws&&e.ws.close(4001,"Visibility resume timeout")},3e3)}catch{e.reconnectAttempts=0,e.connect()}}))}var Dr,by,Va=B(()=>{qt();qi();hn();Dr=[];by=new Set(["sync_messages","refresh_conversation","select_conversation","cancel_execution","update_conversation_settings","ask_user_answer"])});function Le(e,t){let s=t==null?"__all__":String(t);return e?`${e}${s}`:s}function Lr(e){return typeof e?.entryId=="string"&&e.entryId?`entry:${e.entryId}`:e?.role==="assistant"&&e?.turnId?`live-response:${e.turnId}:${e.speakerVpId||e.vpId||""}`:typeof e?.clientMessageId=="string"&&e.clientMessageId?`client:${e.clientMessageId}`:`message:${e?.messageId||""}`}function Fr(e,t,s){return typeof s!="string"||!s?null:`${Le(e,t)}message:${s}`}function Hs(e,t,s){return typeof s!="string"||!s?null:`${Le(e,t)}client:${s}`}var Nn=B(()=>{});function Ha(e){return typeof e=="string"&&e?e:null}function Wn(e,t){return e?.yeaftSessionHistoryState?.[t]||null}function Xt(e){let t=e?.yeaftActiveSessionFilter||null;if(!t)try{t=(typeof window<"u"&&window.Pinia?.useSessionsStore?.())?.activeSessionId||null}catch{}if(!t)return{agentId:e?.currentAgent||null,sessionId:null,sessionKey:""};let s=(()=>{try{let n=typeof window<"u"&&window.Pinia?.useSessionsStore?.(),r=n?.activeSessionKey?n.sessions?.[n.activeSessionKey]:null;if(r?.id===t&&r.agentId)return r.agentId}catch{}return typeof e?.resolveYeaftSessionAgentId=="function"?e.resolveYeaftSessionAgentId(t):e?.currentAgent||null})();return{agentId:s,sessionId:t,sessionKey:Le(s,t)}}function ru(e,{agentId:t,sessionId:s,mode:n="recent",preserveLoaded:r=!1,latestSeq:i=null}={}){if(!t||!s)return null;let o=Le(t,s),a=Wn(e,o)||{},l=Number(a.generation||0)+1,c=`yeaft_history_${l}_${crypto.randomUUID()}`,d={...a,loaded:!!a.loaded,loading:!0,error:null,requestId:c,generation:l,mode:n,background:n==="prefetch",requestedAt:Date.now(),latestSeq:Number.isFinite(i)?i:a.latestSeq??null};return delete d.completionSeen,r||(d.syncingAfterSeq=null,a.loaded||(d.hasMore=!1,d.oldestSeq=null,d.serverOldestFetchedSeq=null,d.serverHasMore=!1,d.gapQueue=[],d.requestedBeforeSeqs=[],d.count=0)),e.yeaftSessionHistoryState={...e.yeaftSessionHistoryState||{},[o]:d},mn(e),{sessionKey:o,requestId:c,generation:l,state:d}}function Ba(e,t={}){let s=t.sessionId??t.groupId??null;if(!s)return!1;let n=t.agentId||e?.yeaftSessionAgentById?.[s]||null,r=Le(n,s),i=Wn(e,r),o=Ha(t.requestId);if(!i)return o===null;let a=Ha(i.requestId);return o?o===a:a===null}function iu(e,t={},s={},n="chunk"){if(!Ba(e,t))return null;let r=t.sessionId??t.groupId??null,i=t.agentId||e?.yeaftSessionAgentById?.[r]||null,o=Le(i,r),a=Wn(e,o)||{},l=Ha(t.requestId),c=l!==null&&n==="completion",d={...a,...c?{}:s,...c?{completionSeen:!0}:{},error:null};return c?(d.loading=!0,d.requestId=l):(d.loading=!1,d.requestId=null,d.completedAt=Date.now(),delete d.completionSeen),e.yeaftSessionHistoryState={...e.yeaftSessionHistoryState||{},[o]:d},mn(e),d}function Or(e,{agentId:t,sessionId:s,requestId:n,error:r="history_load_failed"}={}){if(!t||!s||!n)return!1;let i=Le(t,s),o=Wn(e,i);return!o||o.requestId!==n||!o.loading?!1:(e.yeaftSessionHistoryState={...e.yeaftSessionHistoryState||{},[i]:{...o,loading:!1,error:r,requestId:null,completedAt:Date.now()}},mn(e),!0)}function mn(e){let{sessionKey:t}=Xt(e),s=t?Wn(e,t):null;return e.yeaftLoadingMoreHistory=!!s?.loading&&s?.mode!=="prefetch",e.yeaftHistoryLoadError=s?.error||null,e.yeaftHasMoreHistory=!!s?.hasMore,e.yeaftOldestLoadedSeq=Number.isFinite(s?.serverOldestFetchedSeq)?s.serverOldestFetchedSeq:Number.isFinite(s?.oldestSeq)?s.oldestSeq:null,s}function Na(e){let{sessionKey:t}=Xt(e);return t?Wn(e,t):null}var nu,Ui=B(()=>{Nn();nu=15e3});function Wa(e){return e?.sessionId??e?.groupId??null}function Ua(e){for(let t of[e?.persistedMessageId,e?.messageId,e?.id]){if(typeof t!="string")continue;let s=t.match(/^(m\d+)/);if(s)return s[1]}return null}function vt(e){return e?.isStreaming||e?.status==="pending"?!1:Number.isFinite(e?.seq)||!!Ua(e)||e?.isHistory===!0&&!e?.clientMessageId}function Ki(e){if(Number.isFinite(e?.seq))return Number(e.seq);let s=Ua(e)?.match(/^m(\d+)$/);if(s)return Number(s[1]);let n=typeof e?.id=="string"?e.id.match(/^(\d+)/):null;return n?Number(n[1]):null}function ky(e){try{return new TextEncoder().encode(JSON.stringify(e)).length}catch{return 0}}function Sy(e){return e?e.isStreaming||e.status==="pending"||e.type==="tool-use"&&(e.askPending||!e.hasResult&&(e.toolName==="AskUser"||e.toolName==="AskUserQuestion"))?!0:e.type!=="user"||!e.clientMessageId?!1:!e.dbMessageId&&!Ua(e):!1}function Iy(e){let t=[],s=null;for(let n of e)(n?.type==="user"||!s)&&(s={rows:[],protected:!1},t.push(s)),s.rows.push(n),Sy(n)&&(s.protected=!0);return t}function au(e,{conversationId:t,agentId:s=null,sessionId:n=null,limits:r=ou}={}){let i=e?.messagesMap?.[t];if(!Array.isArray(i)||i.length===0||!s||!n)return{evictedRows:0,keptRows:0};let o=y=>Wa(y)===n,a=i.filter(o),l=Iy(a);if(l.length===0)return{evictedRows:0,keptRows:0};let c=l.filter(y=>y.protected),d=new Set(c),u=Number.isFinite(r.maxTurnsPerSession)?Math.max(0,Math.floor(r.maxTurnsPerSession)):ja,g=Math.max(0,u-c.length);for(let y=l.length-1;y>=0&&g>0;y-=1){let w=l[y];d.has(w)||(d.add(w),g-=1)}let p=new Set(l.filter(y=>d.has(y)).flatMap(y=>y.rows)),f=a.filter(y=>!p.has(y));if(f.length===0)return{evictedRows:0,keptRows:p.size};let m=i.filter(y=>!o(y)||p.has(y));i.splice(0,i.length,...m);let v=Le(s,n),b=e.yeaftHistoryCacheState?.[v]||null,h=lu(a.filter(y=>p.has(y))),S=JSON.stringify(b?.ranges||[])===JSON.stringify(h.ranges)?Number(b?.rangeEpoch)||0:(Number(b?.rangeEpoch)||0)+1;if(e.yeaftHistoryCacheState={...e.yeaftHistoryCacheState||{},[v]:{...b||{},agentId:s,sessionId:n,conversationId:t,lastAccessed:Date.now(),rangeEpoch:S,...h}},f.some(vt)){let y=h.ranges[0]?.startSeq??null,w=e.yeaftSessionHistoryState?.[v]||{};e.yeaftSessionHistoryState={...e.yeaftSessionHistoryState||{},[v]:{...w,serverOldestFetchedSeq:y,oldestSeq:y,serverHasMore:y!==null,hasMore:y!==null,gapTraversalInitialized:!1,gapQueue:[],requestedBeforeSeqs:[],completedHistoryWorkKeys:[],pendingPageKind:null,pendingPageBeforeSeq:null,pendingGapStopAtSeq:null,pendingCacheEpoch:null,pendingHistoryWorkKey:null,paginationError:null,count:h.rowCount}};let P=Xt(e);P.agentId===s&&P.sessionId===n&&mn(e)}return{evictedRows:f.length,keptRows:p.size}}function Cy(e){let t=[],s=null;for(let n of e)vt(n)&&((n?.type==="user"||!s)&&(s=[],t.push(s)),s.push(n));return t}function Ay(e,t){let s=Number.isFinite(t.maxTurnsPerSession)?Math.max(0,Math.floor(t.maxTurnsPerSession)):ja,n=Cy(e),r=new Set(n.slice(-s).flat());for(let i of n)if(i.some(o=>o?._historyWindowDetached===!0))for(let o of i)r.add(o);return r}function xy(e){let t=Array.from(new Set(e.map(Ki).filter(Number.isFinite))).sort((n,r)=>n-r),s=[];for(let n of t){let r=s.at(-1);r&&n<=r.endSeq+1?r.endSeq=n:s.push({startSeq:n,endSeq:n})}return s}function lu(e){let t=e.filter(vt);return{rowCount:t.length,byteCount:t.reduce((s,n)=>s+ky(n),0),ranges:xy(t)}}function Ty(e,t,s){let n=new Set((t||[]).map(r=>r?.stableKey).filter(Boolean));if(n.size!==0)for(let r of e)r?.stableKey&&n.has(r.stableKey)&&(r._historyCacheTouchedAt=s)}function My(e,{conversationId:t,agentId:s,sessionId:n,incomingRows:r,now:i,limits:o}){let a=e.messagesMap?.[t]||[],l=a.filter(h=>Wa(h)===n);Ty(l,r,i);let c=Ay(l,o),d=l.filter(h=>!vt(h)||c.has(h)),u=new Set(d),g=a.filter(h=>Wa(h)!==n||u.has(h));a.splice(0,a.length,...g);let p=lu(d),f=Le(s,n),m=e.yeaftHistoryCacheState?.[f]||null,b=JSON.stringify(m?.ranges||[])===JSON.stringify(p.ranges)?Number(m?.rangeEpoch)||0:(Number(m?.rangeEpoch)||0)+1;e.yeaftHistoryCacheState={...e.yeaftHistoryCacheState||{},[f]:{agentId:s,sessionId:n,conversationId:t,lastAccessed:i,rangeEpoch:b,...p}}}function cu(e,t,s,n=Date.now()){if(!t||!s)return;let r=Le(t,s),i=e.yeaftHistoryCacheState?.[r];i&&(e.yeaftHistoryCacheState={...e.yeaftHistoryCacheState||{},[r]:{...i,lastAccessed:n}})}function Ka(e,{conversationId:t,agentId:s,sessionId:n,incomingRows:r=[],now:i=Date.now(),limits:o=ou}={}){!e||!t||!s||!n||My(e,{conversationId:t,agentId:s,sessionId:n,incomingRows:r,now:i,limits:o})}var ja,ou,zi=B(()=>{Nn();Ui();ja=500,ou=Object.freeze({maxTurnsPerSession:ja})});function Ss(e){return e?.sessionId??e?.groupId??null}function uu(e){let t=e?.stableKey??e?.uiKey??e?.messageId??e?.dbMessageId??e?.id;return t==null||t===""?null:String(t)}function Py(e,t){if(e?.type!=="assistant"||t?.type!=="assistant"||Ss(e)!==Ss(t)||e.isHistory===!0&&!e.isStreaming||t._hasPersistedTurnId!==!0||!e.turnId||!t.turnId||e.turnId!==t.turnId)return!1;let s=e.speakerVpId||e.vpId||"",n=t.speakerVpId||t.vpId||"";if(s&&n&&s!==n)return!1;let r=e.threadId||"",i=t.threadId||"";if(r&&i&&r!==i)return!1;let o=typeof e.content=="string"?e.content:"",a=typeof t.content=="string"?t.content:"";return!!o&&!!a&&(a.startsWith(o)||o.startsWith(a))}function pu(e,t){let s=e.uiKey||t.uiKey||null;return Object.assign(e,t),s&&(e.uiKey=s),vt(t)&&(e.isStreaming=!1,e.status==="pending"&&(e.status="completed")),e}function Yi(e){let t=vt(e),s=t?Ki(e):null,n=Number(e?.timestamp),r=Number.isFinite(n)&&n>0?n:t?-1/0:1/0;return[r,Number.isFinite(r)?0:Number.isFinite(s)?s:-1]}function Ry(e,t,s){let n=[],r=new Map,i=new Map;for(let l=t;l<s;l+=1){let c=e[l],d=Ss(c),u=vt(c)?Ki(c):null,g=i.get(d);if(!Number.isFinite(u)&&g){g.rows.push(c);continue}let p={sessionId:d,seq:u,rows:[c]};n.push(p),i.set(d,p),Number.isFinite(u)&&(r.has(d)||r.set(d,[]),r.get(d).push(p))}for(let l of r.values())l.sort((c,d)=>c.seq-d.seq);let o=new Map,a=t;for(let l of n){let c=l;if(Number.isFinite(l.seq)){let d=o.get(l.sessionId)||0;c=r.get(l.sessionId)[d],o.set(l.sessionId,d+1)}for(let d of c.rows)e[a++]=d}}function za(e){e.sort((t,s)=>{let n=Yi(t),r=Yi(s);for(let i=0;i<n.length;i+=1)if(n[i]!==r[i])return n[i]-r[i];return 0});for(let t=0;t<e.length;){let s=Yi(e[t])[0],n=t+1;for(;n<e.length&&Yi(e[n])[0]===s;)n+=1;Number.isFinite(s)&&n-t>1&&Ry(e,t,n),t=n}return e}function _y(e,t){return Array.isArray(e.messagesMap?.[t])||(e.messagesMap=e.messagesMap||{},e.messagesMap[t]=[]),e.messagesMap[t]}function Ya(e,t){return e.filter(s=>t===void 0||Ss(s)===t)}function gu(e,t){let s=uu(t);if(s){let n=e.find(r=>uu(r)===s);if(n)return n}if(t?.type==="user"&&t.clientMessageId){let n=e.find(r=>r?.type==="user"&&r.clientMessageId===t.clientMessageId&&Ss(r)===Ss(t));if(n)return n}return t?.type==="assistant"&&e.find(n=>Py(n,t))||null}function rs(e){if(!e||typeof e!="object")return null;let t=du.get(e);return t||(t=new Ga(e),du.set(e,t)),t}var du,Ga,qr=B(()=>{zi();du=new WeakMap;Ga=class{constructor(t){this.store=t}rows(t){return _y(this.store,t)}durableRows(t,s=void 0){return Ya(this.rows(t),s).filter(vt)}overlayRows(t,s=void 0){return Ya(this.rows(t),s).filter(n=>!vt(n))}snapshot(t,s=void 0){return{durableRows:this.durableRows(t,s),overlayRows:this.overlayRows(t,s)}}commitDurable({conversationId:t,sessionId:s=void 0,rows:n=[],mode:r="delta",replaceDurable:i=!1,preserveEmpty:o=!0}={}){if(!t)return{insertedRows:0,preservedEmpty:!1};let a=this.rows(t),l=Array.isArray(n)?n.filter(Boolean):[],c=Ya(a,s).length>0;if(o&&r==="recent"&&l.length===0&&c)return{insertedRows:0,inserted:[],preservedEmpty:!0};if(i){let g=a.filter(p=>Ss(p)!==s||!vt(p));a.splice(0,a.length,...g)}let d=0,u=[];for(let g of l){let p=gu(a,g);p?pu(p,g):(a.push(g),u.push(g),d+=1)}return za(a),{insertedRows:d,inserted:u,preservedEmpty:!1}}upsertOverlay({conversationId:t,row:s}={}){if(!t||!s)return null;let n=this.rows(t),r=gu(n,s);return r?pu(r,s):n.push(s),za(n),r||s}appendOverlayText({conversationId:t,sessionId:s=void 0,turnId:n=null,text:r=""}={}){if(!t||!r)return null;let o=this.rows(t).findLast(a=>a?.type==="assistant"&&!vt(a)&&(s===void 0||Ss(a)===s)&&(!n||a.turnId===n));return o?(o.content?r.startsWith(o.content)?o.content=r:o.content.endsWith(r)||(o.content+=r):o.content=r,o):null}replaceProjection(t,s=[]){let n=this.rows(t);return n.splice(0,n.length,...Array.isArray(s)?s:[]),za(n),n}removeDurable({conversationId:t,sessionId:s}={}){if(!t)return 0;let n=this.rows(t),r=n.filter(o=>Ss(o)!==s||!vt(o)),i=n.length-r.length;return n.splice(0,n.length,...r),i}}});function Vr(e,t){return t?t===e.yeaftConversationId?!0:Object.values(e.yeaftConversationIdsByAgent||{}).includes(t):!1}function jn(e,t,s){s&&(s.type!=="assistant"&&s.type!=="tool-use"||Vr(e,t)&&(!s.vpId&&e._currentYeaftVpId&&(s.vpId=e._currentYeaftVpId),!s.turnId&&e._currentYeaftTurnId&&(s.turnId=e._currentYeaftTurnId),!s.speakerVpId&&s.vpId&&(s.speakerVpId=s.vpId)))}function Dy(e){let t=[e?.timestamp,e?.createdAt,e?.ts,e?.time,e?.created_at];for(let s of t){if(typeof s=="number"&&Number.isFinite(s)&&s>0)return s;if(typeof s=="string"&&s.trim()){let n=Date.parse(s);if(Number.isFinite(n))return n;let r=Number(s);if(Number.isFinite(r)&&r>0)return r}}return Date.now()}function Gi(e){let t=e?.stableKey??e?.messageId??e?.dbMessageId??e?.id;return t==null||t===""?null:String(t)}function Qa(e,t,s){if(!s||typeof s!="object")return null;if(typeof s.uiKey=="string"&&s.uiKey)return s.uiKey;let n=s.entryId||s.stableKey||s.atMessageId||s.messageId||s.dbMessageId||s.id||null;if(n!=null&&n!=="")return s.uiKey=String(n),s.uiKey;let r=`legacy:${t||"conversation"}:`,i=new Set((e?.messagesMap?.[t]||[]).map(a=>a?.uiKey).filter(a=>typeof a=="string"&&a)),o=Number(e?._messageUiKeySequence)||0;do o+=1;while(i.has(`${r}${o}`));return e&&(e._messageUiKeySequence=o),s.uiKey=`${r}${o}`,s.uiKey}function Hr(e,t,s){for(let n of Array.isArray(s)?s:[])Qa(e,t,n);return s}function Xa(e,t){if(!e||!t)return e;let s=e.type==="user"&&typeof e.id=="string"&&e.id===e.clientMessageId;for(let[n,r]of Object.entries(t))if(r!=null){if(n==="isStreaming"){e.isStreaming&&r===!1&&(e.isStreaming=!1);continue}if(!(n==="uiKey"&&e.uiKey)){if(n==="id"||n==="messageId"){if(s&&t.clientMessageId===e.clientMessageId&&t.messageId&&t.messageId!==e.clientMessageId)continue;(e[n]===void 0||e[n]===null||e[n]==="")&&(e[n]=r);continue}if(!(n==="turnId"&&s&&e.turnId===e.clientMessageId)){if(n==="content"&&typeof r=="string"){e.content||(e.content=r);continue}if(n==="responseKind"&&(r==="progress"||r==="result")){e.responseKind=r;continue}if(n==="attachments"&&Array.isArray(r)){(!Array.isArray(e.attachments)||e.attachments.length===0)&&(e.attachments=r);continue}(e[n]===void 0||e[n]===null||e[n]==="")&&(e[n]=r)}}}return e}function fu(e=[],t=[]){let s=[],n=new Map,r=new Map;for(let i of[...e,...t]){if(!i)continue;let o=Gi(i),a=i.type==="user"&&i.clientMessageId?String(i.clientMessageId):null;if(o&&n.has(o)){Xa(n.get(o),i);continue}if(a&&r.has(a)){let l=r.get(a);Xa(l,i),o&&!n.has(o)&&n.set(o,l);continue}s.push(i),o&&n.set(o,i),a&&r.set(a,i)}return s}function hu(e,t,s){return!e||e!==t?!1:!s?.loaded&&!s?.loading}function mu(e,t){return!!t&&!!e?.loaded&&!e?.loading&&Number.isFinite(e?.latestSeq)}function vu({sessionState:e,hasCachedSessionRows:t,force:s=!1}={}){return e?.loading?!1:s?!e?.loaded:e?.loaded?!1:!t}function $y(e,t,s,n){let r=s?.id?String(s.id):null;if(!r)return!1;let o=(e.messagesMap[t]||[]).find(a=>a?.type==="assistant"&&Gi(a)===r);return o?(o.id||(o.id=r),o.messageId||(o.messageId=r),s.ts&&!o.ts&&(o.ts=s.ts),s.timestamp&&!o.timestamp&&(o.timestamp=s.timestamp),s.sessionId&&!o.sessionId&&(o.sessionId=s.sessionId),s.vpId&&!o.vpId&&(o.vpId=s.vpId),s.turnId&&!o.turnId&&(o.turnId=s.turnId),s.threadId&&!o.threadId&&(o.threadId=s.threadId),o.content?typeof o.content=="string"&&(n.startsWith(o.content)?o.content=n:o.content.endsWith(n)||(o.content+=n)):o.content=n,jn(e,t,o),!0):!1}function Qi(e,t,s){if(!t)return;let n={...s};Qa(e,t,n);let r={...n,id:s.dbMessageId||s.id||Date.now().toString()+Math.random().toString(36).substr(2,9),timestamp:Dy(s)};if(Vr(e,t)&&!r.sessionId&&(r.sessionId=e._currentYeaftSessionId||e.yeaftActiveSessionFilter||Ey),Vr(e,t)){let o=e._currentYeaftAgentId||Object.entries(e.yeaftConversationIdsByAgent||{}).find(([,c])=>c===t)?.[0]||e.currentAgent||null,a=typeof r.messageId=="string"&&/^m\d+$/.test(r.messageId)?r.messageId:typeof r.id=="string"&&/^m\d+$/.test(r.id)?r.id:null,l=typeof r.clientMessageId=="string"?r.clientMessageId:null;r.stableKey||(r.stableKey=a?Fr(o,r.sessionId,a):Hs(o,r.sessionId,l)),r.uiKey||(r.uiKey=r.stableKey||null),!r.vpId&&e._currentYeaftVpId&&(r.vpId=e._currentYeaftVpId),!r.turnId&&e._currentYeaftTurnId&&(r.turnId=e._currentYeaftTurnId),jn(e,t,r)}if(e.messagesMap[t]||(e.messagesMap[t]=[]),Qa(e,t,r),Vr(e,t))return rs(e).upsertOverlay({conversationId:t,sessionId:r.sessionId,row:r});let i=Gi(s);if(i){let o=e.messagesMap[t].find(a=>Gi(a)===i);if(o)return Xa(o,r),t===e.yeaftConversationId&&e.messagesMap[t].sort((a,l)=>a.timestamp-l.timestamp),o}return e.messagesMap[t].push(r),t===e.yeaftConversationId&&e.messagesMap[t].sort((o,a)=>o.timestamp-a.timestamp),r}function yu(e,t,s,n={}){if(!t||!s)return;e.messagesMap[t]||(e.messagesMap[t]=[]);let r=e.messagesMap[t];if($y(e,t,n,s))return;if(Vr(e,t)){let l=rs(e).appendOverlayText({conversationId:t,sessionId:n.sessionId||e._currentYeaftSessionId||void 0,turnId:n.turnId||e._currentYeaftTurnId||null,text:s});if(l){jn(e,t,l),n.id&&!l.id&&(l.id=n.id),n.id&&!l.messageId&&(l.messageId=n.id);return}}let i=e._currentYeaftTurnId;if(i){for(let a=r.length-1;a>=0;a--)if(r[a].turnId===i&&r[a].type==="assistant"&&r[a].isStreaming){if(jn(e,t,r[a]),n.id&&!r[a].id&&(r[a].id=n.id),n.id&&!r[a].messageId&&(r[a].messageId=n.id),r[a].content.endsWith(s))return;r[a].content+=s;return}Qi(e,t,{...n.id?{id:n.id,messageId:n.id}:{},...n.ts?{ts:n.ts}:{},...n.timestamp?{timestamp:n.timestamp}:{},...n.sessionId?{sessionId:n.sessionId}:{},...n.vpId?{vpId:n.vpId}:{},...n.turnId?{turnId:n.turnId}:{},...n.threadId?{threadId:n.threadId}:{},type:"assistant",content:s,isStreaming:!0,status:"pending",turnStartAt:n.timestamp||Date.now()});return}let o=r[r.length-1];if(o&&o.type==="assistant"&&o.isStreaming){if(jn(e,t,o),n.id&&!o.id&&(o.id=n.id),n.id&&!o.messageId&&(o.messageId=n.id),o.content.endsWith(s))return;o.content+=s}else Qi(e,t,{...n.id?{id:n.id,messageId:n.id}:{},...n.ts?{ts:n.ts}:{},...n.timestamp?{timestamp:n.timestamp}:{},...n.sessionId?{sessionId:n.sessionId}:{},...n.vpId?{vpId:n.vpId}:{},...n.turnId?{turnId:n.turnId}:{},...n.threadId?{threadId:n.threadId}:{},type:"assistant",content:s,isStreaming:!0,status:"pending",turnStartAt:n.timestamp||Date.now()})}function bu(e,t,{completeLifecycle:s=!0}={}){if(!t)return;let n=e.messagesMap[t];if(!n||n.length===0)return;let r=e._currentYeaftTurnId||null;for(let i=n.length-1;i>=0;i--){let o=n[i];if(r&&o.turnId&&o.turnId!==r){if(o.type==="user")break;continue}if(o.isStreaming&&(o.isStreaming=!1,s&&o.status==="pending"&&(o.status="completed",o.turnEndAt=Date.now())),jn(e,t,o),o.type==="user")break}}function wu(e,t){if(!t||e.processingConversations&&e.processingConversations[t]||e.activeVpTurns&&Object.keys(e.activeVpTurns).length>0)return;let s=e.messagesMap&&e.messagesMap[t];if(!(!s||s.length===0))for(let n of s)n&&n.isStreaming&&(n.isStreaming=!1)}function ku(e,t){let s=e.currentConversation;if(!s)return;e.messagesMap[s]||(e.messagesMap[s]=[]);let n=e.messagesMap[s],r=null;for(let i of t)if(i.type==="user"){let o=i.message?.content;if(o){let a=typeof o=="string"?o:Array.isArray(o)?o.map(l=>l.text||"").join(""):"";a&&(r=a,e.addMessage({type:"user",content:a,isHistory:!0}))}}else if(i.type==="assistant"){let o=i.message?.content;if(o&&Array.isArray(o)){for(let a of o)if(a.type==="text"&&a.text)e.addMessage({type:"assistant",content:a.text,isHistory:!0});else if(a.type==="tool_use")e.addMessage({type:"tool-use",toolName:a.name,toolInput:a.input,isHistory:!0});else if(a.type==="tool_result"){for(let l=n.length-1;l>=0;l--)if(n[l].type==="tool-use"&&!n[l].hasResult){n[l].hasResult=!0,n[l].toolResult=a.content;break}}}}if(r&&s&&!e.conversationTitles[s]){let i=r.trim().substring(0,100);e.conversationTitles[s]=i}}function vn(e){if(!Array.isArray(e))return null;let t=null;for(let s of e)typeof s?.dbMessageId=="number"&&s.dbMessageId>0&&(t===null||s.dbMessageId>t)&&(t=s.dbMessageId);return t}function Ly(e){return{id:e.id,dbMessageId:e.id,timestamp:e.created_at}}function Su(e){if(!e)return null;let t=Ly(e);if(e.message_type==="tool_use"){let n={...t,type:"tool-use",toolName:e.tool_name||"unknown",toolInput:(()=>{try{return JSON.parse(e.tool_input||e.content||"{}")}catch{return{}}})(),hasResult:!0,isHistory:!0,startTime:e.created_at||0};if(e.metadata)try{let r=JSON.parse(e.metadata);r.askRequestId&&(n.askRequestId=r.askRequestId,n.askQuestions=r.askQuestions,n.askAnswered=!!r.askAnswered,n.selectedAnswers=r.selectedAnswers||null,r.askAnswered||(n.isHistory=!1))}catch{}return n}let s=n=>{if(!n)return"";if(typeof n!="string")return String(n);if(n.startsWith("["))try{let r=JSON.parse(n);if(Array.isArray(r))return r.filter(i=>i.type==="text"&&i.text).map(i=>i.text).join("")}catch{}return n};if(e.role==="user"){let n=null;if(e.metadata)try{let r=JSON.parse(e.metadata);r&&typeof r.clientMessageId=="string"&&(n=r.clientMessageId)}catch{}return{...t,type:"user",content:typeof e.content=="string"?e.content:String(e.content||""),...n?{clientMessageId:n}:{}}}else if(e.role==="assistant"){let n=s(e.content),r=(()=>{if(!e.content||typeof e.content!="string"||!e.content.startsWith("["))return[];try{let i=JSON.parse(e.content);return Array.isArray(i)?i.filter(o=>o.type==="tool_use"&&o.name):[]}catch{return[]}})();if(!n&&r.length===0)return null;if(r.length>0){let i=[];n&&i.push({...t,type:"assistant",content:n});for(let o=0;o<r.length;o++){let a=r[o];i.push({id:e.id+"_tool_"+o,dbMessageId:e.id,timestamp:e.created_at,type:"tool-use",toolName:a.name,toolInput:a.input||{},hasResult:!0,isHistory:!0,startTime:e.created_at||0})}return i}return{...t,type:"assistant",content:n}}else if(e.role==="tool"||e.message_type==="tool_result")return{...t,type:"tool_result",tool:e.tool_name||"unknown",content:typeof e.content=="string"?e.content:String(e.content||"")};return null}var Ey,Br=B(()=>{qr();Nn();Ey="grp_default"});function yn(e,t){return e._closedAt?.[t]?Date.now()-e._closedAt[t]<3e4:!1}function Un(e,t){Ve(e,t),e._processingWatchdogs||(e._processingWatchdogs={});let s=()=>{if(!e.processingConversations[t])return;let r=e.conversations.find(o=>o.id===t);e.sendWsMessage({type:"ping_session",conversationId:t,agentId:r?.agentId});let i=setTimeout(()=>{e.processingConversations[t]&&(e.sessionHealth||(e.sessionHealth={}),e.sessionHealth[t]={status:"agent-offline"})},1e4);e._pongTimeouts||(e._pongTimeouts={}),e._pongTimeouts[t]=i},n=setTimeout(()=>{e.processingConversations[t]&&(s(),e._processingWatchdogs[t]=setInterval(()=>{if(!e.processingConversations[t]){Ve(e,t);return}s()},3e4))},45e3);e._processingWatchdogs[t]=n}function Xi(e,t){e._yeaftWatchdogPauseReasons?.[t]?.size||e.processingConversations[t]&&e._processingWatchdogs?.[t]&&(e._pongTimeouts?.[t]&&(clearTimeout(e._pongTimeouts[t]),delete e._pongTimeouts[t]),e.sessionHealth?.[t]&&delete e.sessionHealth[t],e._yeaftWatchdogConvs?.has(t)?zn(e,t):Un(e,t))}function Ve(e,t){e._processingWatchdogs?.[t]&&(clearTimeout(e._processingWatchdogs[t]),clearInterval(e._processingWatchdogs[t]),delete e._processingWatchdogs[t]),e._pongTimeouts?.[t]&&(clearTimeout(e._pongTimeouts[t]),delete e._pongTimeouts[t]),e.sessionHealth?.[t]&&delete e.sessionHealth[t],e._autoRefreshed?.[t]&&delete e._autoRefreshed[t],e._yeaftWatchdogConvs?.delete(t),e._yeaftWatchdogPauseReasons&&delete e._yeaftWatchdogPauseReasons[t]}function Nr(e,t,s="phase"){if(!t||!e.processingConversations[t])return;e._yeaftWatchdogPauseReasons||(e._yeaftWatchdogPauseReasons={});let n=e._yeaftWatchdogPauseReasons[t]||new Set;n.add(s),e._yeaftWatchdogPauseReasons[t]=n,e._processingWatchdogs?.[t]&&(clearTimeout(e._processingWatchdogs[t]),clearInterval(e._processingWatchdogs[t]),delete e._processingWatchdogs[t])}function Kn(e,t,s=null){if(!t)return;let n=e._yeaftWatchdogPauseReasons?.[t];n&&(s?n.delete(s):n.clear(),!n.size&&(delete e._yeaftWatchdogPauseReasons[t],e.processingConversations[t]&&zn(e,t)))}function Iu(e,t){Ve(e,t),e._processingWatchdogs||(e._processingWatchdogs={}),e._processingWatchdogs[t]=setTimeout(()=>{if(e.processingConversations[t]){let s=e.conversations.find(n=>n.id===t);e.sendWsMessage({type:"refresh_conversation",conversationId:t,agentId:s?.agentId}),e._processingWatchdogs[t]=setTimeout(()=>{if(e.processingConversations[t]){delete e.processingConversations[t];let n=e.executionStatusMap[t];n&&(n.currentTool=null),e.finishStreamingForConversation(t)}delete e._processingWatchdogs[t]},1e4)}},9e4)}function zn(e,t){let s=e._yeaftWatchdogPauseReasons?.[t];if(Ve(e,t),e._processingWatchdogs||(e._processingWatchdogs={}),s?.size){e._yeaftWatchdogConvs||(e._yeaftWatchdogConvs=new Set),e._yeaftWatchdogPauseReasons||(e._yeaftWatchdogPauseReasons={}),e._yeaftWatchdogConvs.add(t),e._yeaftWatchdogPauseReasons[t]=new Set(s);return}e._yeaftWatchdogConvs||(e._yeaftWatchdogConvs=new Set),e._yeaftWatchdogConvs.add(t),e._processingWatchdogs[t]=setTimeout(()=>{if(e.processingConversations[t]){delete e.processingConversations[t];let n=e.executionStatusMap[t];n&&(n.currentTool=null),e.finishStreamingForConversation(t)}delete e._processingWatchdogs[t]},15e4)}var Bs=B(()=>{});function Za(e,t){return t&&Array.isArray(e?._yeaftRetiredConversationIdsByAgent?.[t])?e._yeaftRetiredConversationIdsByAgent[t]:[]}function Yn(e,t,s){return!t||!s?!1:Za(e,t).includes(s)}function Ja(e,t){let s=e?._yeaftRetiredConversationTargetsByAgent?.[t];return s&&typeof s=="object"?s:{}}function Cu(e,t,s){if(!t||!s)return null;let n=Ja(e,t),r=s,i=new Set;for(let o=0;o<8;o++){if(i.has(r))return null;i.add(r);let a=n[r];if(!a||a===r)return r===s?null:r;r=a}return null}function Wr(e,t,s,n=null){if(!t||!s)return;let r=Za(e,t).filter(a=>a!==s).concat(s).slice(-8);e._yeaftRetiredConversationIdsByAgent={...e._yeaftRetiredConversationIdsByAgent||{},[t]:r};let i=Ja(e,t),o={};for(let a of r){let l=i[a];l&&(o[a]=l===s&&n?n:l)}n&&n!==s&&(o[s]=n),e._yeaftRetiredConversationTargetsByAgent={...e._yeaftRetiredConversationTargetsByAgent||{},[t]:o}}function el(e,t,s){if(!t||!s||!e?._yeaftRetiredConversationIdsByAgent)return;let n=Za(e,t).filter(i=>i!==s);e._yeaftRetiredConversationIdsByAgent={...e._yeaftRetiredConversationIdsByAgent,[t]:n};let r={...Ja(e,t)};delete r[s],e._yeaftRetiredConversationTargetsByAgent={...e._yeaftRetiredConversationTargetsByAgent||{},[t]:r}}var Zi=B(()=>{});function qy(e,t,s){let n=e.messagesMap?.[t]||[],r=e.messagesMap?.[s]||[];e.messagesMap||(e.messagesMap={}),Hr(e,t,n),Hr(e,s,r);let i=fu(r,n).sort((o,a)=>{let l=Number.isFinite(o?.seq)?o.seq:null,c=Number.isFinite(a?.seq)?a.seq:null;return l!==null&&c!==null&&l!==c?l-c:l!==null&&c===null?-1:l===null&&c!==null?1:(o?.timestamp||0)-(a?.timestamp||0)});rs(e).replaceProjection(s,i)}function Vy(e){if(!e||typeof e!="object")return e;if(typeof structuredClone=="function")try{return structuredClone(e)}catch{}return Array.isArray(e)?e.slice():{...e}}function Ji(e,t){return!!e&&Object.prototype.hasOwnProperty.call(e,t)}function Gn(e,t,s,{removeSource:n}){Ji(e,t)&&(Ji(e,s)||(e[s]=n?e[t]:Vy(e[t])),n&&delete e[t])}function is(e,t,s=null){if(!t)return null;let n=e?._yeaftPendingConversationPromotions?.[t]||null;return!n?.sourceConversationId||!n.targetConversationId||s&&n.targetConversationId!==s?null:n}function eo(e,t,s,n){return!t||!s||!n||s===n?!1:(e._yeaftPendingConversationPromotions={...e._yeaftPendingConversationPromotions||{},[t]:{sourceConversationId:s,targetConversationId:n}},!0)}function jr(e,t,s=null){let n=is(e,t,s);if(!n)return null;let r={...e._yeaftPendingConversationPromotions||{}};return delete r[t],e._yeaftPendingConversationPromotions=r,n}function Ur(e,t,s){let n=is(e,t);return!n||!s||n.targetConversationId===s?null:(os(e,n.targetConversationId,s,{removeSource:!0}),Wr(e,t,n.targetConversationId,s),eo(e,t,n.sourceConversationId,s),n)}function os(e,t,s,{removeSource:n=!0}={}){if(!t||!s||t===s)return!1;qy(e,t,s),e.yeaftHistoryCacheState&&(e.yeaftHistoryCacheState=Object.fromEntries(Object.entries(e.yeaftHistoryCacheState).map(([c,d])=>[c,d?.conversationId===t?{...d,conversationId:s}:d]))),Gn(e.processingConversations,t,s,{removeSource:n}),Gn(e.executionStatusMap,t,s,{removeSource:n}),Gn(e.refreshingSessionMap,t,s,{removeSource:n}),Gn(e._closedAt,t,s,{removeSource:n}),Gn(e._autoRefreshed,t,s,{removeSource:n}),Gn(e.sessionHealth,t,s,{removeSource:n}),e._turnCompletedConvs?.has(t)&&(e._turnCompletedConvs.add(s),n&&e._turnCompletedConvs.delete(t));let r=!!e._yeaftWatchdogConvs?.has(t),i=e._yeaftWatchdogPauseReasons?.[t],o=!!i?.size,a=!!e._processingWatchdogs?.[t];if(o&&(e._yeaftWatchdogPauseReasons||(e._yeaftWatchdogPauseReasons={}),e._yeaftWatchdogPauseReasons[s]=new Set(i)),n&&(a||o)&&Ve(e,t),n&&e._pongTimeouts?.[t]&&(clearTimeout(e._pongTimeouts[t]),delete e._pongTimeouts[t]),n&&(a||r||o)&&!!e.processingConversations?.[s])if(e._processingWatchdogs?.[s])e._yeaftWatchdogConvs?.add(s);else{let c=Ji(e.sessionHealth,s),d=e.sessionHealth?.[s],u=Ji(e._autoRefreshed,s),g=e._autoRefreshed?.[s];zn(e,s),c&&(e.sessionHealth||(e.sessionHealth={}),e.sessionHealth[s]=d),u&&(e._autoRefreshed||(e._autoRefreshed={}),e._autoRefreshed[s]=g)}return n&&e.messagesMap&&delete e.messagesMap[t],!0}var tl=B(()=>{Br();qr();Zi();Bs()});function to(e,t){return!e||!t||e.type!=="user"||t.type!=="user"?!1:e.clientMessageId&&t.clientMessageId?e.clientMessageId===t.clientMessageId:e.clientMessageId||t.clientMessageId?!1:e.content===t.content}var sl=B(()=>{});function nl(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}function Hy(){return Date.now()}function By(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`pt_${crypto.randomUUID()}`:`pt_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,10)}`}function Ny(e,t=160){return typeof e!="string"?e:e.length>t?`${e.slice(0,t)}...[truncated]`:e}function Wy(e){if(!e||typeof e!="object")return e||null;let t={};for(let[s,n]of Object.entries(e))s==="text"||s==="prompt"||s==="content"||s==="data"||(t[s]=typeof n=="string"?Ny(n):n);return t}function bn(){return By()}function kt(e,t={}){!e||!t.traceId||(Array.isArray(e._perfTraceQueue)||(e._perfTraceQueue=[]),e._perfTraceQueue.push({traceId:t.traceId,source:"web",phase:t.phase||"unknown",at:Hy(),monotonicMs:nl(),durationMs:Number.isFinite(t.durationMs)?t.durationMs:null,agentId:t.agentId||null,sessionId:t.sessionId||null,vpId:t.vpId||null,turnId:t.turnId||null,threadId:t.threadId||null,messageType:t.messageType||null,bytes:Number.isFinite(t.bytes)?t.bytes:null,ok:typeof t.ok=="boolean"?t.ok:null,detail:Wy(t.detail)}),e._perfTraceQueue.length>200&&e._perfTraceQueue.splice(0,e._perfTraceQueue.length-200),jy(e))}function jy(e){!e||e._perfTraceFlushTimer||(e._perfTraceFlushTimer=setTimeout(()=>Uy(e),250))}function Uy(e){if(!e||!Array.isArray(e._perfTraceQueue)||e._perfTraceQueue.length===0){e&&(e._perfTraceFlushTimer=null);return}let t=e._perfTraceQueue.splice(0,e._perfTraceQueue.length);e._perfTraceFlushTimer=null,typeof e.sendWsMessage=="function"&&e.sendWsMessage({type:"perf_trace_events",events:t})}function so(e,t={}){if(typeof requestAnimationFrame!="function")return;let s=nl();requestAnimationFrame(()=>{requestAnimationFrame(()=>{kt(e,{...t,phase:t.phase||"render.next_paint",durationMs:nl()-s})})})}var rl=B(()=>{});function as(e){return Number.isFinite(e)?Number(e):null}function Ky(e){return(Array.isArray(e)?e:[]).map(t=>({startSeq:as(t?.startSeq),endSeq:as(t?.endSeq)})).filter(t=>t.startSeq!==null&&t.endSeq!==null&&t.startSeq<=t.endSeq).sort((t,s)=>t.startSeq-s.startSeq)}function Kr(e){return Number.isFinite(e)&&e>=0?Math.floor(e):0}function wn(e){let t=as(e?.beforeSeq);if(t===null)return null;if(e?.kind==="gap"){let s=as(e.stopAtSeq);return s===null?null:`gap:${Kr(e.cacheEpoch)}:${s}:${t}`}return`server:${t}`}function zr(e){let t=new Set((Array.isArray(e?.completedHistoryWorkKeys)?e.completedHistoryWorkKeys:[]).filter(s=>typeof s=="string"&&s));for(let s of Array.isArray(e?.requestedBeforeSeqs)?e.requestedBeforeSeqs:[])Number.isFinite(s)&&t.add(`server:${s}`);return t}function zy(e,t){let s=wn(t);if(!s)return e.completedHistoryWorkKeys||[];let n=zr(e);return n.add(s),Array.from(n).slice(-256)}function Yy(e,t){if(!Number.isFinite(t))return e.requestedBeforeSeqs||[];let s=new Set((Array.isArray(e?.requestedBeforeSeqs)?e.requestedBeforeSeqs:[]).filter(Number.isFinite));return s.add(t),Array.from(s).sort((n,r)=>r-n).slice(-256)}function Gy(e,t={},s=0){let n=Ky(e),r=Kr(s),i=zr(t),o=[];for(let a=1;a<n.length;a+=1){let l=n[a-1],c=n[a];if(l.endSeq+1>=c.startSeq)continue;let d={kind:"gap",beforeSeq:c.startSeq,stopAtSeq:l.endSeq+1,cacheEpoch:r};d.workKey=wn(d),i.has(d.workKey)||o.push(d)}return o.sort((a,l)=>l.beforeSeq-a.beforeSeq)}function Au(e,t,s){let n=Gy(e,t,s),r=as(t.serverOldestFetchedSeq??t.oldestSeq),i=n[0]||null;if(!i||r===null||i.beforeSeq<=r)return[];let o={kind:"gap",beforeSeq:i.beforeSeq,stopAtSeq:r,cacheEpoch:i.cacheEpoch};return o.workKey=wn(o),zr(t).has(o.workKey)?[]:[o]}function xu(e={},t=[],s=0){let n=Kr(s),r=zr(e),i=e.serverHasMore!==!1,o=as(e.serverOldestFetchedSeq??e.oldestSeq),a=e.gapTraversalInitialized===!0,l=Array.isArray(e.gapQueue)?e.gapQueue.slice():[],c=null,d=null;if(i&&o!==null){let u={kind:"server",beforeSeq:o,stopAtSeq:null,cacheEpoch:n};u.workKey=wn(u),r.has(u.workKey)?(i=!1,d="history_cursor_repeated"):c=u}return!c&&!i&&(a||(l=Au(t,e,n),a=!0),c=l[0]||null),c?{request:c,state:{...e,serverHasMore:i,gapTraversalInitialized:a,gapQueue:l,pendingPageKind:c.kind,pendingPageBeforeSeq:c.beforeSeq,pendingGapStopAtSeq:c.stopAtSeq,pendingCacheEpoch:c.cacheEpoch,pendingHistoryWorkKey:c.workKey,hasMore:!0,paginationError:null}}:{request:null,state:{...e,serverHasMore:i,gapTraversalInitialized:a,gapQueue:l,hasMore:!1,paginationError:d}}}function Tu(e={},{mode:t,oldestSeq:s,hasMore:n,ranges:r=[],pageKind:i=null,stopAtSeq:o=null,cacheEpoch:a=0}={}){if(t==="delta")return e;let l=Kr(a),c=as(s),d=as(e.pendingPageBeforeSeq),u=i||e.pendingPageKind||(t==="older"?"server":null),g=as(o??e.pendingGapStopAtSeq),p=Kr(e.pendingCacheEpoch??l),f={kind:u,beforeSeq:d,stopAtSeq:g,cacheEpoch:p},m=as(e.serverOldestFetchedSeq??e.oldestSeq),v=e.serverHasMore!==!1,b=Number(e.noProgressCount)||0,h=null,k=e.requestedBeforeSeqs||[],S=e.completedHistoryWorkKeys||[],y=e.gapTraversalInitialized===!0,w=Array.isArray(e.gapQueue)?e.gapQueue.slice():[];if(t==="recent")m=c,v=!!n,b=0,k=[],S=[],y=!1,w=[];else if(d===null)c!==null&&(m=m===null?c:Math.min(m,c)),v=!!n,b=0;else{k=Yy(e,d),S=zy(e,f);let x=c!==null&&c<d;if(u==="server")x?(m=m===null?c:Math.min(m,c),v=!!n,b=0):(v=!1,b+=1,h="history_cursor_no_progress");else if(u==="gap"){let Y=wn(f);w=w.filter(U=>wn(U)!==Y);let L=g!==null&&c!==null&&c<=g;if(x||L||n===!1){if(b=0,!L&&n!==!1&&c!==null&&g!==null){let U={kind:"gap",beforeSeq:c,stopAtSeq:g,cacheEpoch:p};U.workKey=wn(U),zr({completedHistoryWorkKeys:S}).has(U.workKey)||w.unshift(U)}}else b+=1,h="history_cursor_no_progress"}}t==="older"&&!v&&!y&&(w=Au(r,{...e,serverOldestFetchedSeq:m,completedHistoryWorkKeys:S},l),y=!0);let P={...e,serverOldestFetchedSeq:m,serverHasMore:v,requestedBeforeSeqs:k,completedHistoryWorkKeys:S,gapTraversalInitialized:y,gapQueue:w,noProgressCount:b,oldestSeq:m,paginationError:h};return delete P.pendingPageKind,delete P.pendingPageBeforeSeq,delete P.pendingGapStopAtSeq,delete P.pendingCacheEpoch,delete P.pendingHistoryWorkKey,{...P,hasMore:v||w.length>0}}var il=B(()=>{});function _u(e){return e.filter(t=>!(t.type==="user"&&(!t.content||!t.content.trim())))}function kn(e){let t=typeof e=="string"?e.match(/^m(\d+)$/):null,s=t?Number(t[1]):null;return Number.isFinite(s)?s:null}function Mu(e){let t=[e?.timestamp,e?.createdAt,e?.ts,e?.time,e?.created_at];for(let s of t){if(typeof s=="number"&&Number.isFinite(s)&&s>0)return s;if(typeof s=="string"&&s.trim()){let n=Date.parse(s);if(Number.isFinite(n))return n;let r=Number(s);if(Number.isFinite(r)&&r>0)return r}}return null}function Qy(e){if(!Array.isArray(e))return null;for(let t=e.length-1;t>=0;t-=1){let s=e[t];if(s?.name==="TodoWrite"&&Array.isArray(s?.input?.todos))return s.input.todos}return null}function Xy(e){if(!e||typeof window>"u")return null;try{let t=window.Pinia||null,s=t&&typeof t.useSessionsStore=="function"?t.useSessionsStore():null;if(!s)return null;let n=typeof t.useChatStore=="function"?t.useChatStore():null,r=typeof s.sessionById=="function"?s.sessionById(e,n?.currentAgent||null):s.sessions&&s.sessions[e];return(r&&typeof r.defaultVpId=="string"?r.defaultVpId.trim():"")||null}catch{return null}}function Zy(e,t){return e.speakerVpId||e.vpId||e.vp_id||e.authorVpId||e.authorVP||Xy(t)}function Jy(e){return e?.stableKey||(e&&(e.messageId||e.id)?e.messageId||e.id:null)}function eb(e,t=null){if(!e||e.stableKey)return e;let s=Ns(e),n=e.messageId||e.id||null,r=e.type==="user"&&e.clientMessageId||null;return e.stableKey=r&&n===r?Hs(t,s,r):Fr(t,s,n),Number.isFinite(e.seq)||(e.seq=kn(n)),e.uiKey||(e.uiKey=e.stableKey||null),e}function Ns(e){return e?e.sessionId??e.groupId??null:null}function tb(e){return!e||e.type!=="user"||!e.clientMessageId?!1:(e.messageId||e.id||null)===e.clientMessageId}function sb(e,t,s,n){let r=e.rows(t),i=r.some(c=>c&&(n==null||Ns(c)===n));if(s.length===0&&i)return{insertedRows:0,preservedEmpty:!0};let o=s.reduce((c,d)=>Math.max(c,d?.timestamp||0),0),a=r.filter(c=>c?n!=null&&Ns(c)!==n||vt(c)||c.isStreaming||c.type==="tool-use"&&c.toolName==="AskUserQuestion"&&(c.askAnswered||c.askPending||c.askExpired)||tb(c)?!0:o>0&&(c.timestamp||0)>o:!1);return e.replaceProjection(t,a),{insertedRows:e.commitDurable({conversationId:t,sessionId:n,rows:s,mode:"recent",preserveEmpty:!1}).insertedRows,preservedEmpty:!1}}function nb(e){if(typeof e!="string")return!1;let t=e.trimStart();return t.startsWith("<task-result ")||/^\[system note\] You have called \S+ with the same arguments \d+ times\./.test(t)}function rb(e,t){let s=typeof e.yeaftConversationId=="string"?e.yeaftConversationId:"";return s.startsWith(`yeaft-local-${t}-`)||/^yeaft-local-\d/.test(s)?s:null}function ib(e,t,s,n){let r=t.agentId||s&&e.yeaftSessionAgentById?.[s]||null;if(!r||!n||e.currentView!=="yeaft")return;let i=Xt(e);if(i.sessionId!==(s||null)||i.agentId&&i.agentId!==r)return;let o=e.yeaftConversationId||null;if(Yn(e,r,n)){let d=e.yeaftConversationIdsByAgent?.[r]||null;d&&d!==n&&os(e,n,d,{removeSource:n!==e.yeaftConversationId});return}let a=is(e,r);a&&a.targetConversationId!==n&&Ur(e,r,n);let l=is(e,r,n);if(l&&(os(e,l.sourceConversationId,n,{removeSource:!0}),jr(e,r,n),e.yeaftConversationId=n),o===n||l){e.messagesMap[n]||(e.messagesMap[n]=[]),e.yeaftConversationIdsByAgent={...e.yeaftConversationIdsByAgent||{},[r]:n},e.activeConversations=[n];return}let c=rb(e,r);c&&(os(e,c,n,{removeSource:!0}),e.yeaftConversationIdsByAgent={...e.yeaftConversationIdsByAgent||{},[r]:n},e.yeaftConversationId=n,e.activeConversations=[n])}function Ws(e,t,s=null){let n=e.messagesMap[t]||[];for(let r of n)s&&Object.entries(s).some(([i,o])=>o&&r[i]!==o)||r.type==="tool-use"&&!r.hasResult&&(r.hasResult=!0,r.toolName==="AskUserQuestion"&&!r.askAnswered&&!r.selectedAnswers&&(r.isHistory=!0,r.askExpired=!0,r.askPending=!1,r.pendingAnswers=null,r.askSubmittedAt=null,r.askError=null,r.askRequestId=null))}function Eu(e,t){ns(e);let s=e.agents.find(r=>r.id===t.agentId);e.conversations=e.conversations.filter(r=>r.id!==t.conversationId);let n=t.provider||"claude-code";if(e.conversations.push({id:t.conversationId,agentId:t.agentId,agentName:s?.name||t.agentId,workDir:t.workDir,claudeSessionId:null,createdAt:Date.now(),processing:!1,connecting:n!=="claude-code",type:"chat",provider:n,capabilities:t.capabilities||null,disallowedTools:t.disallowedTools??null}),e.currentAgent=t.agentId,e.currentAgentInfo=s,e.panels.length>1){let r=e._pendingPaneId;if(e._pendingPaneId=null,r){let i=e.panels.find(o=>o.id===r);i&&(i.conversationId=t.conversationId)}else{let i=e.panels.find(o=>!o.conversationId);i&&(i.conversationId=t.conversationId)}e.activeConversations.includes(t.conversationId)||e.activeConversations.push(t.conversationId)}else e.activeConversations=[t.conversationId];e.currentWorkDir=t.workDir,e.messagesMap[t.conversationId]=[],e.sendWsMessage({type:"select_conversation",conversationId:t.conversationId}),e.addMessage({type:"system",content:Oe("store.convCreated",{agent:s?.name||t.agentId,workDir:t.workDir})}),e.saveOpenSessions()}function Du(e,t){ns(e);let s=e.agents.find(n=>n.id===t.agentId);if(e.conversations=e.conversations.filter(n=>n.id!==t.conversationId&&!(n.claudeSessionId&&n.claudeSessionId===t.claudeSessionId&&n.agentId===t.agentId&&(n.provider||"claude-code")===(t.provider||"claude-code"))),e.conversations.push({id:t.conversationId,agentId:t.agentId,agentName:s?.name||t.agentId,workDir:t.workDir,claudeSessionId:t.claudeSessionId,createdAt:Date.now(),processing:!1,connecting:(t.provider||"claude-code")!=="claude-code",type:"chat",provider:t.provider||"claude-code",capabilities:t.capabilities||null,disallowedTools:t.disallowedTools??null}),e.currentAgent=t.agentId,e.currentAgentInfo=s,e.panels.length>1){let n=e._pendingPaneId;if(e._pendingPaneId=null,n){let r=e.panels.find(i=>i.id===n);r&&(r.conversationId=t.conversationId)}else{let r=e.panels.find(i=>!i.conversationId);r&&(r.conversationId=t.conversationId)}e.activeConversations.includes(t.conversationId)||e.activeConversations.push(t.conversationId)}else e.activeConversations=[t.conversationId];if(e.currentWorkDir=t.workDir,e.messagesMap[t.conversationId]=[],e._pendingSessionTitle&&(e.conversationTitles[t.conversationId]=e._pendingSessionTitle,e._pendingSessionTitle=null),e.sendWsMessage({type:"select_conversation",conversationId:t.conversationId}),e.addMessage({type:"system",content:Oe("store.convResumed",{agent:s?.name||t.agentId,sessionId:t.claudeSessionId?t.claudeSessionId.slice(0,8)+"...":""})}),t.dbMessages&&t.dbMessages.length>0){let n=_u(t.dbMessages.map(i=>e.formatDbMessage(i)).flat().filter(Boolean)),r=e.messagesMap[t.conversationId]||[];for(let i of n)r.push(i)}e.hasMoreMessages=!!t.hasMoreMessages,e.chatSessionState[t.conversationId]={lastSeenDbId:vn(e.messagesMap[t.conversationId]),hasMoreOlder:!!t.hasMoreMessages},e.saveOpenSessions()}function ol(e,t){e.conversations=e.conversations.filter(n=>n.id!==t.conversationId),delete e.messagesMap[t.conversationId],delete e.chatSessionState[t.conversationId],delete e.conversationTitles[t.conversationId],delete e.customConversationTitles[t.conversationId],delete e.processingConversations[t.conversationId],e._closedAt&&delete e._closedAt[t.conversationId],Ve(e,t.conversationId),delete e.executionStatusMap[t.conversationId],delete e.subagents[t.conversationId],window.dispatchEvent(new CustomEvent("conversation-deleted",{detail:{conversationId:t.conversationId}}));let s=e.activeConversations.indexOf(t.conversationId);s>=0&&(e.activeConversations.splice(s,1),e.activeConversations.length===0&&e.addMessage({type:"system",content:Oe("chat.session.closed")}));for(let n of e.panels)n.conversationId===t.conversationId&&(n.conversationId=null);e.saveOpenSessions()}function $u(e,t){let s=t.conversationId;if(s){delete e.processingConversations[s],Ve(e,s),e._closedAt||(e._closedAt={}),e._closedAt[s]=Date.now(),e._turnCompletedConvs||(e._turnCompletedConvs=new Set),e._turnCompletedConvs.add(s);let n=e.executionStatusMap[s];n&&(n.currentTool=null),e.finishStreamingForConversation(s),Ws(e,s);let r=e.conversations.find(i=>i.id===s);r&&(t.claudeSessionId&&(r.claudeSessionId=t.claudeSessionId),t.workDir&&(r.workDir=t.workDir)),e.clearStatus?.conversationId===s&&e.clearStatus?.status==="clearing"&&(e.clearStatus={conversationId:s,status:"completed"},setTimeout(()=>{e.clearStatus?.conversationId===s&&e.clearStatus?.status==="completed"&&(e.clearStatus=null)},3e3)),e.saveOpenSessions()}}function Lu(e,t){let s=t.conversationId;if(s){delete e.processingConversations[s],Ve(e,s),e._closedAt||(e._closedAt={}),e._closedAt[s]=Date.now(),e._turnCompletedConvs||(e._turnCompletedConvs=new Set),e._turnCompletedConvs.add(s);let n=e.executionStatusMap[s];n&&(n.currentTool=null),e.finishStreamingForConversation(s),Ws(e,s);let r=e.conversations.find(i=>i.id===s);r&&(t.claudeSessionId&&(r.claudeSessionId=t.claudeSessionId),t.workDir&&(r.workDir=t.workDir)),e.saveOpenSessions()}}function Fu(e,t){if(t.conversationId){if(t.isProcessing&&!yn(e,t.conversationId)&&!e._turnCompletedConvs?.has(t.conversationId))e.processingConversations[t.conversationId]=!0;else if(e.processingConversations[t.conversationId]){delete e.processingConversations[t.conversationId],Ve(e,t.conversationId);let s=e.executionStatusMap[t.conversationId];s&&(s.currentTool=null),e.finishStreamingForConversation(t.conversationId)}}}function Ou(e,t){let s=t.conversationId||e.currentConversation;if(s){delete e.processingConversations[s],Ve(e,s),e._closedAt||(e._closedAt={}),e._closedAt[s]=Date.now(),e._turnCompletedConvs||(e._turnCompletedConvs=new Set),e._turnCompletedConvs.add(s);let n=e.executionStatusMap[s];n&&(n.currentTool=null),e.finishStreamingForConversation(s),Ws(e,s)}}function qu(e,t){if(!!t.requestId){if(e.chatHistoryRequestIdSupported=!0,!e.isCurrentChatHistoryResponse?.(t))return!1}else{let i=`chat:${t.conversationId}`,o=e.chatHistoryRequests?.[i];if(e.chatHistoryRequestIdSupported===!0||!o?.loading)return!1;t={...t,requestId:o.requestId,catalogKey:i,mode:o.mode||t.mode,...o.mode==="delta"?{afterMessageId:o.cursor}:{}}}e.messagesMap[t.conversationId]||(e.messagesMap[t.conversationId]=[]);let n=e.messagesMap[t.conversationId],r=t.mode==="delta"||typeof t.afterMessageId=="number"&&t.afterMessageId>0;if(t.conversationId&&e.activeConversations.includes(t.conversationId)){let i=_u((t.messages||[]).map(a=>e.formatDbMessage(a)).flat().filter(Boolean));if(i.length>0){let a=n.find(l=>l.dbMessageId);if(a&&i[0].dbMessageId&&i[i.length-1].dbMessageId<a.dbMessageId){let l=n.indexOf(a);e.debug,n.splice(l,0,...i)}else{e.debug;for(let l of i)if(!(l.dbMessageId&&n.some(c=>c.dbMessageId===l.dbMessageId))){if(l.dbMessageId&&(l.type==="assistant"||l.type==="user")){let c=null;if(l.type==="user"?c=n.find(d=>!d.dbMessageId&&!d.isStreaming&&to(d,l)):c=n.find(d=>!d.dbMessageId&&!d.isStreaming&&d.type==="assistant"&&d.content===l.content),c){c.dbMessageId=l.dbMessageId,c.id=l.id,l.timestamp&&(c.timestamp=l.timestamp),l.clientMessageId&&!c.clientMessageId&&(c.clientMessageId=l.clientMessageId);continue}}n.push(l)}}}r||(e.hasMoreMessages=t.hasMore??!1),ns(e);let o=e.chatSessionState[t.conversationId]?.hasMoreOlder;e.chatSessionState[t.conversationId]={lastSeenDbId:vn(e.messagesMap[t.conversationId]),hasMoreOlder:r?!!o:!!t.hasMore}}return e.finishChatHistoryRequest?.(t)&&(e.currentConversation===t.conversationId&&(e.loadingMoreMessages=!1),e.setRefreshingSession(t.conversationId,!1)),!0}function Vu(e,t){let s=t.sessionId??null,n=t.agentId||s&&e.yeaftSessionAgentById?.[s]||null,r=t.conversationId||n&&e.yeaftConversationIdsByAgent?.[n]||e.yeaftConversationId;if(!r||!s||!Array.isArray(t.messages))return null;e.messagesMap[r]||(e.messagesMap[r]=[]);let i=new Set(Array.isArray(t.sourceMessageIds)?t.sourceMessageIds:[]),o=new Set,a=new Set;for(let b of e.messagesMap[r]){if(Ns(b)!==s)continue;let h=b?.persistedMessageId||b?.messageId||b?.id||null;h&&o.add(h),h&&(b?._historyWindowPrefetched===!0||b?._historyWindowDetached===!0)&&a.add(h),!(!t.entryId||!i.has(h))&&(b.historyEntryId=t.entryId,Number.isFinite(t.indexGeneration)&&(b.historyIndexGeneration=t.indexGeneration))}let l=t.messages.filter(b=>t.prefetch===!0||!o.has(b?.id)||a.has(b?.id)).map(b=>t.entryId&&i.has(b?.id)?{...b,historyEntryId:t.entryId,...t.prefetch===!0?{_historyWindowPrefetched:!0}:{},...Number.isFinite(t.indexGeneration)?{historyIndexGeneration:t.indexGeneration}:{}}:b),{formatted:c}=Hu(l,s,"window",e.messagesMap[r],n),d=`history-window:${t.requestId||t.anchorMessageId||Date.now()}`;for(let b of c)b._historyWindowKey=d,b._historyWindowDetached=t.prefetch!==!0,b._historyWindowPrefetched=t.prefetch===!0;let u=rs(e),g=u.rows(r),p=new Set(t.messages.map(b=>b?.id).filter(Boolean)),f=[];if(t.prefetch!==!0){for(let h of g){if(Ns(h)!==s)continue;let k=h?.persistedMessageId||h?.messageId||h?.id||null;p.has(k)&&(h._historyWindowPrefetched!==!0&&h._historyWindowDetached!==!0||(h._historyWindowKey=d,h._historyWindowDetached=!0,h._historyWindowPrefetched=!1,f.push(h)))}let b=g.filter(h=>Ns(h)!==s||h._historyWindowDetached!==!0||h._historyWindowKey===d);b.length!==g.length&&u.replaceProjection(r,b)}u.commitDurable({conversationId:r,sessionId:s,rows:c,mode:"window"});let m=c.length>0?c:f,v=Xt(e);return Ka(e,{conversationId:r,agentId:n,sessionId:s,incomingRows:m,activeAgentId:v.agentId,activeSessionId:v.sessionId}),r}function Pu(e){return e?.toolId?[Ns(e)??"",e.vpId||e.speakerVpId||"",e.turnId||"",e.threadId||"main",e.toolId].join("\0"):null}function Ru(e,t,s){return e.toolName="AskUserQuestion",e.toolId=t.toolCallId,e.toolInput={questions:s},e.askQuestions=s,e.askRequestId=null,e.askPending=!1,e.pendingAnswers=null,e.askSubmitGeneration=null,e.askSubmittedAt=null,e.askError=null,e.hasResult=!0,e.isHistory=!0,t.status==="answered"?(e.askAnswered=!0,e.selectedAnswers=t.answers,e.askExpired=!1):(e.askAnswered=!1,e.selectedAnswers=null,e.askExpired=!0),e}function ob(e,t){return(e||[]).find(s=>s?.type==="tool-use"&&(s.toolName==="AskUser"||s.toolName==="AskUserQuestion")&&s.toolId===t.toolCallId&&Ns(s)===t.sessionId&&(s.vpId||s.speakerVpId||"")===(t.vpId||"")&&(s.turnId||"")===(t.turnId||"")&&(s.threadId||"main")===(t.threadId||"main"))||null}function Hu(e,t,s,n,r=null){let i=new Set((n||[]).map(c=>Jy(eb(c,r))).filter(Boolean)),o=new Set,a=[],l=0;for(let c of e){if(!c||c._reflection||c.internal||c.systemOnly||c.systemOnlyMessage||nb(c.content))continue;let d=c.id||c.messageId||null,u=c.clientMessageId||null,g=c.sessionId??c.groupId??t??null,p=Fr(r,g,d),f=u?Hs(r,g,u):p,m=c.historyEntryId?{historyEntryId:c.historyEntryId,...Number.isFinite(c.historyIndexGeneration)?{historyIndexGeneration:c.historyIndexGeneration}:{}}:{};if(!(p&&o.has(p))&&!(p&&s!=="recent"&&i.has(p))){if(p&&o.add(p),c.role==="user"){l+=1;let v=d||c.messageId||c.turnId||null;a.push({...d?{id:d,messageId:d}:{},...p?{stableKey:p}:{},...f?{uiKey:f}:{},...m,seq:Number.isFinite(c.seq)?c.seq:kn(d),type:"user",content:c.content,timestamp:Mu(c),sessionId:g,turnId:c.turnId||v,...u?{clientMessageId:u}:{},...Array.isArray(c.attachments)&&c.attachments.length>0?{attachments:c.attachments}:{},...c.quote?{quote:c.quote}:{},isStreaming:!1,isHistory:!0})}else if(c.role==="assistant"){l+=1;let v=d||c.messageId||c.turnId||null,b=Zy(c,g),h=Mu(c),k=!!c.turnId,S=c.turnId||v,y=typeof c.content=="string"?c.content:c.content||"",w=Array.isArray(c.todos)?c.todos:Qy(c.toolCalls),P=c.executionOrigin==="route_forward"?{executionOrigin:"route_forward"}:{};(typeof y!="string"||y.trim())&&a.push({...d?{id:d,messageId:d}:{},...p?{stableKey:p}:{},...f?{uiKey:f}:{},...m,seq:Number.isFinite(c.seq)?c.seq:kn(d),...c.entryId?{entryId:c.entryId}:{},...Array.isArray(c.sourceMessageIds)?{sourceMessageIds:c.sourceMessageIds}:{},type:"assistant",content:y,timestamp:h,sessionId:g,turnId:S,_hasPersistedTurnId:k,...P,...b?{vpId:b,speakerVpId:b}:{},...c.responseKind==="progress"||c.responseKind==="result"?{responseKind:c.responseKind}:{},...Number.isInteger(c.llmCallCount)&&c.llmCallCount>0?{llmCallCount:c.llmCallCount}:{},...Number.isFinite(c.inputTokens)&&c.inputTokens>=0?{inputTokens:c.inputTokens}:{},...Number.isFinite(c.outputTokens)&&c.outputTokens>=0?{outputTokens:c.outputTokens}:{},...Number.isFinite(c.totalTokens)&&c.totalTokens>=0?{totalTokens:c.totalTokens}:{},...Number.isFinite(c.totalMs)&&c.totalMs>=0?{totalMs:c.totalMs}:{},...typeof c.model=="string"&&c.model?{model:c.model}:{},...typeof c.effort=="string"&&c.effort?{effort:c.effort}:{},...c.incomplete===!0?{incomplete:!0}:{},...typeof c.stopReason=="string"&&c.stopReason?{stopReason:c.stopReason}:{},isStreaming:!1,isHistory:!0}),Array.isArray(w)&&w.length>0&&a.push({...d?{id:`${d}:todos`,messageId:`${d}:todos`}:{},...p?{stableKey:`${p}:todos`}:{},...m,seq:Number.isFinite(c.seq)?c.seq:kn(d),type:"tool-use",toolName:"TodoWrite",toolInput:{todos:w},timestamp:h,startTime:h||0,sessionId:g,turnId:S,...P,...b?{vpId:b,speakerVpId:b}:{},isStreaming:!1,isHistory:!0,hasResult:!0});for(let[x,Y]of(Array.isArray(c.toolCalls)?c.toolCalls:[]).entries()){if(!Y||Y.name==="TodoWrite")continue;let L=Y.id||`index:${x}`,U=encodeURIComponent(String(L));a.push({...d?{id:`${d}:tool:${U}`,messageId:`${d}:tool:${U}`,persistedMessageId:d}:{},...p?{stableKey:`${p}:tool:${U}`}:{},...m,seq:Number.isFinite(c.seq)?c.seq:kn(d),type:"tool-use",toolId:Y.id||null,toolName:Y.name||"unknown",toolInput:Y.input||{},timestamp:h,startTime:h||0,sessionId:g,turnId:S,...c.threadId?{threadId:c.threadId}:{},...P,...b?{vpId:b,speakerVpId:b}:{},isStreaming:!1,isHistory:!0,hasResult:!0})}for(let x of Array.isArray(c.images)?c.images:[])x?.assetId&&a.push({id:`${d||v||S}:image:${x.assetId}`,messageId:`${d||v||S}:image:${x.assetId}`,...p?{stableKey:`${p}:image:${x.assetId}`}:{},...m,seq:Number.isFinite(c.seq)?c.seq:kn(d),type:"chat-image",...x,timestamp:h,sessionId:g,turnId:S,...P,...b?{vpId:b,speakerVpId:b}:{},isStreaming:!1,isHistory:!0});for(let x of Array.isArray(c.askUserResults)?c.askUserResults:[]){if(!x?.toolCallId||x.status!=="answered"&&x.status!=="expired")continue;let Y=[{question:typeof x.question=="string"?x.question:"",options:(Array.isArray(x.options)?x.options:[]).filter(I=>typeof I=="string").map(I=>({label:I,description:""})),multiSelect:!1}],L={toolCallId:x.toolCallId,sessionId:g,vpId:b||"",turnId:S||"",threadId:c.threadId||"main"},U=ob(n,L);if(U){Object.assign(U,m),Ru(U,x,Y);let I=a.findIndex(T=>T?.type==="tool-use"&&T.toolId===x.toolCallId&&(T.sessionId??T.groupId??null)===(U.sessionId??U.groupId??null)&&(T.turnId||"")===(U.turnId||""));I>=0&&a.splice(I,1);continue}let E=Ru({id:`${d||v||S}:ask:${x.toolCallId}`,messageId:`${d||v||S}:ask:${x.toolCallId}`,...p?{stableKey:`${p}:ask:${x.toolCallId}`}:{},...m,seq:Number.isFinite(c.seq)?c.seq:kn(d),type:"tool-use",timestamp:h,sessionId:g,turnId:S,threadId:L.threadId,...P,...b?{vpId:b,speakerVpId:b}:{},isStreaming:!1},x,Y),oe=Pu(E);(!oe||!a.some(I=>Pu(I)===oe))&&a.push(E);let q=a.findIndex(I=>I!==E&&I?.type==="tool-use"&&I.toolId===x.toolCallId&&(I.sessionId??I.groupId??null)===(E.sessionId??E.groupId??null)&&(I.turnId||"")===(E.turnId||""));q>=0&&a.splice(q,1)}}}}return{formatted:a,acceptedHistoryMessages:l}}function Bu(e,t){let s=t.sessionId!=null?t.sessionId:t.groupId,n=t.agentId||s&&e.yeaftSessionAgentById?.[s]||null;if(Yn(e,n,t.conversationId)){let M=e.yeaftConversationIdsByAgent?.[n]||null;if(!M||M===t.conversationId)return;os(e,t.conversationId,M,{removeSource:t.conversationId!==e.yeaftConversationId}),t={...t,conversationId:M}}if(t.requestId&&typeof e.isCurrentYeaftHistoryResponse=="function"&&!e.isCurrentYeaftHistoryResponse(t))return;let r=t.mode==="recent"||t.mode==="delta"?t.mode:"older",i=Array.isArray(t.messages)?t.messages:[],o=t.agentId||s&&e.yeaftSessionAgentById?.[s]||null,a=Le(o,s),l=e.yeaftSessionHistoryState?.[a]||null;typeof t.streamId=="string"&&typeof l?.streamId=="string"&&(t.streamId!==l.streamId||Number.isFinite(t.revision)&&Number.isFinite(l.revision)&&t.revision!==l.revision)&&(r="recent",typeof e.clearYeaftHistoryMemory=="function"&&e.clearYeaftHistoryMemory({agentId:o,sessionId:s,preserveLiveRows:!0,preserveSessionOwner:!0})),t.perfTraceId&&kt(e,{traceId:t.perfTraceId,phase:"history.chunk_received",agentId:t.agentId||null,sessionId:s||null,messageType:t.type,bytes:(()=>{try{return JSON.stringify(t).length}catch{return null}})(),detail:{mode:r,rawCount:i.length}});let d=t.agentId||(s&&e.yeaftSessionAgentById?e.yeaftSessionAgentById[s]:null),u=d&&e.yeaftConversationIdsByAgent?e.yeaftConversationIdsByAgent[d]:null,g=t.conversationId||u||e.yeaftConversationId;if(!g){e.yeaftLoadingMoreHistory=!1;return}ib(e,t,s,g),e.messagesMap[g]||(e.messagesMap[g]=[]);let{formatted:p,acceptedHistoryMessages:f}=Hu(i,s,r,e.messagesMap[g],d);Hr(e,g,p);let m=rs(e),v=0,b=!1;if(r==="recent"){let M=sb(m,g,p,s??null);v=M.insertedRows,b=M.preservedEmpty}else if(p.length>0&&(v=m.commitDurable({conversationId:g,sessionId:s??null,rows:p,mode:r}).insertedRows,r==="older"&&typeof e.expandYeaftMessageWindow=="function")){let $=e.yeaftActiveSessionFilter?s??null:null;e.expandYeaftMessageWindow($,t.turns||10,d)}let h=Xt(e);Ka(e,{conversationId:g,agentId:d,sessionId:s,incomingRows:p,activeAgentId:h.agentId,activeSessionId:h.sessionId});let k=Le(t.agentId||null,s),S=e.yeaftHistoryCacheState?.[k]||null,y=e.yeaftSessionHistoryState?.[k]||{},w=Number.isFinite(y.serverOldestFetchedSeq)?y.serverOldestFetchedSeq:Number.isFinite(y.oldestSeq)?y.oldestSeq:null,P=Number.isFinite(t.nextBeforeSeq)?t.nextBeforeSeq:Number.isFinite(t.oldestSeq)?t.oldestSeq:b?w:null,x=b&&!Number.isFinite(t.nextBeforeSeq)&&!Number.isFinite(t.oldestSeq)?y.serverHasMore??y.hasMore??!1:t.hasMore,Y=r==="delta"?y:Tu(y,{mode:r,oldestSeq:P,hasMore:x,ranges:S?.ranges||[],pageKind:t.pageKind,stopAtSeq:t.gapStopAtSeq,cacheEpoch:S?.rangeEpoch??t.cacheEpoch??0}),L=typeof t.latestSeq=="number"?t.latestSeq:y.latestSeq??null,U={streamId:typeof t.streamId=="string"?t.streamId:y.streamId??null,revision:Number.isFinite(t.revision)?t.revision:y.revision??null},E=r==="delta"?{...y,...U,loaded:!0,loading:!1,latestSeq:L,syncingAfterSeq:null,count:(y.count||0)+v}:{...Y,...U,loaded:!0,loading:!1,count:S?S.rowCount:r==="older"?(y.count||0)+v:b?y.count||0:f,latestSeq:b&&!Number.isFinite(t.latestSeq)?y.latestSeq??null:L,syncingAfterSeq:null};t.requestId&&typeof e.finishYeaftHistoryLoad=="function"?e.finishYeaftHistoryLoad(t,E,"chunk"):e.yeaftSessionHistoryState&&(e.yeaftSessionHistoryState={...e.yeaftSessionHistoryState,[k]:E}),r==="delta"&&t.hasMoreAfter===!0&&Number.isFinite(E.latestSeq)&&E.latestSeq>Number(t.afterSeq??-1)&&typeof e.continueYeaftHistoryDelta=="function"&&queueMicrotask(()=>e.continueYeaftHistoryDelta(s,d,E.latestSeq));let oe=Xt(e),q=oe.sessionId===(s||null),I=!t.agentId||!oe.agentId||t.agentId===oe.agentId,T=q&&I,R=Le(null,oe.sessionId);if(t.perfTraceId&&(kt(e,{traceId:t.perfTraceId,phase:"history.chunk_applied",agentId:t.agentId||null,sessionId:s||null,messageType:t.type,detail:{mode:r,formattedCount:p.length,insertedRows:v,acceptedHistoryMessages:f,preservedEmptyRecent:b}}),so(e,{traceId:t.perfTraceId,phase:"history.next_paint",agentId:t.agentId||null,sessionId:s||null,messageType:t.type,detail:{mode:r,insertedRows:v}})),T)e.yeaftHasMoreHistory=E.hasMore,e.yeaftOldestLoadedSeq=Number.isFinite(E.serverOldestFetchedSeq)?E.serverOldestFetchedSeq:Number.isFinite(E.oldestSeq)?E.oldestSeq:e.yeaftOldestLoadedSeq,e.yeaftLoadingMoreHistory=!1;else if(e.yeaftLoadingMoreHistory){let M=e.yeaftSessionHistoryState?.[oe.sessionKey]||e.yeaftSessionHistoryState?.[R]||null;e.yeaftLoadingMoreHistory=!!M?.loading}}var no=B(()=>{Bs();tl();Zi();hn();sl();Br();ss();rl();Ui();Nn();zi();il();qr()});function Nu(e,t,s=null){if(!s)return!1;if(e.promoteYeaftHistoryOutlineRow?.(t,s))return!0;let n=t?.sessionId??t?.groupId??e._currentYeaftSessionId??null;return n?!!e.invalidateYeaftHistoryOutline?.(n,s):!1}function ab(e){let t=e;if(typeof t=="string"){let s=t.trim();if(s.startsWith("[")&&s.endsWith("]")||s.startsWith("{")&&s.endsWith("}"))try{t=JSON.parse(s)}catch{t=e}}return Array.isArray(t)?t.map(s=>typeof s=="string"?s:!s||typeof s!="object"?"":s.type==="text"&&typeof s.text=="string"||s.type==="input_text"&&typeof s.text=="string"?s.text:"").join("").replace(/\n\n\[Uploaded files\][\s\S]*$/m,"").trim():t&&typeof t=="object"?typeof t.text=="string"?t.text.trim():typeof t.content=="string"?t.content.trim():"":typeof t=="string"?t.replace(/\n\n\[Uploaded files\][\s\S]*$/m,"").trim():""}function al(e,t){return e.executionStatusMap[t]||(e.executionStatusMap[t]={currentTool:null,toolHistory:[],lastActivity:null}),e.executionStatusMap[t]}function Wu(e,t,s,n=null){if(!t)return;let r=al(e,t);if(r.lastActivity=Date.now(),Xi(e,t),s.type==="system"){if(s.subtype==="init"){let i=e.conversations.find(o=>o.id===t);i&&i.connecting&&(i.connecting=!1);return}s.message&&e.addMessageToConversation(t,{type:"system",content:typeof s.message=="string"?s.message:JSON.stringify(s.message,null,2)});return}if(s.type==="assistant"){let i=s.message?.content;if(!i)return;let o=e.messagesMap[t]||[];for(let a of o)a.type==="tool-use"&&!a.hasResult&&(a.hasResult=!0);for(let a of r.toolHistory)a.status==="running"&&(a.status="done");if(r.currentTool=null,typeof i=="string"){e.appendToAssistantMessageForConversation(t,i,{id:s.message?.id||s.message?.messageId||null,ts:s.ts||s.message?.ts||s.message?.time||null,sessionId:e._currentYeaftSessionId||null,vpId:e._currentYeaftVpId||null,turnId:e._currentYeaftTurnId||null,threadId:e._currentYeaftThreadId||null});return}if(!Array.isArray(i))return;if(i.length===0){e.finishStreamingForConversation(t);return}for(let a of i)a.type==="text"?e.appendToAssistantMessageForConversation(t,a.text,{id:s.message?.id||s.message?.messageId||null,ts:s.ts||s.message?.ts||s.message?.time||null,sessionId:e._currentYeaftSessionId||null,vpId:e._currentYeaftVpId||null,turnId:e._currentYeaftTurnId||null,threadId:e._currentYeaftThreadId||null}):a.type==="image_asset"&&a.image?e.addMessageToConversation(t,{type:"chat-image",...a.image,sessionId:e._currentYeaftSessionId||null,vpId:e._currentYeaftVpId||null,speakerVpId:e._currentYeaftVpId||null,turnId:e._currentYeaftTurnId||null,threadId:e._currentYeaftThreadId||null}):a.type==="tool_use"&&(e.finishStreamingForConversation(t,{completeLifecycle:!1}),r.currentTool={name:a.name,input:a.input,startTime:Date.now()},r.toolHistory.unshift({name:a.name,input:a.input,timestamp:Date.now(),status:"running"}),r.toolHistory.length>20&&r.toolHistory.pop(),e.addMessageToConversation(t,{type:"tool-use",toolId:a.id||a.tool_use_id||null,toolName:a.name,toolInput:a.input,startTime:Date.now(),isHistory:a.history===!0||s.history===!0||s.isHistory===!0,sessionId:e._currentYeaftSessionId||null,vpId:e._currentYeaftVpId||null,turnId:e._currentYeaftTurnId||null,threadId:e._currentYeaftThreadId||null}))}else if(s.type==="user"){let i=s.internal===!0||s.message?.internal===!0||s.userAuthored===!1||s.message?.userAuthored===!1,o=s.message?.content,a=ab(o);if(typeof a=="string"&&(a.includes("<local-command-caveat>")||a.includes("<command-name>")))return;if(typeof a=="string"&&a.includes("<local-command-stdout>")){let c=a.match(/<local-command-stdout>([\s\S]*?)<\/local-command-stdout>/);if(c){e.appendToAssistantMessageForConversation(t,c[1].trim()),e.finishStreamingForConversation(t);return}}let l=[];if(s.tool_use_result)l=Array.isArray(s.tool_use_result)?s.tool_use_result:[s.tool_use_result];else if(s.message?.content){let c=s.message.content;l=(Array.isArray(c)?c:[]).filter(u=>u.type==="tool_result")}if(l.length>0){let c=e.messagesMap[t]||[];for(let d of l){if(r.toolHistory.length>0){let f=r.toolHistory.findIndex(m=>m.status==="running");f>=0&&(r.toolHistory[f].status="done")}let u=d.tool_use_id||d.toolUseId||d.tool_call_id||d.toolCallId||null,g=d.content||d,p=!1;if(u){for(let f=c.length-1;f>=0;f--)if(c[f].type==="tool-use"&&c[f].toolId===u){c[f].hasResult=!0,c[f].toolResult=d.is_update&&c[f].toolResult?`${c[f].toolResult}
2
2
 
3
- ${g}`:g,p=!0;break}}if(!p){for(let f=c.length-1;f>=0;f--)if(c[f].type==="tool-use"&&!c[f].hasResult){c[f].hasResult=!0,c[f].toolResult=g;break}}}r.currentTool=null}else if(!i&&(typeof a=="string"&&a.trim()||Array.isArray(s.message?.attachments)&&s.message.attachments.length>0)){let c=s.message?.clientMessageId||s.clientMessageId||null,d={type:"user",content:a,clientMessageId:c},u=e.messagesMap[t]||[];if(u.some(p=>to(p,d))){if(c){for(let p=u.length-1;p>=0;p--)if(u[p].type==="user"&&u[p].clientMessageId===c){s.dbMessageId&&!u[p].dbMessageId&&(u[p].dbMessageId=s.dbMessageId),s.message?.id&&!u[p].messageId&&(u[p].id=s.message.id,u[p].messageId=s.message.id),s.ts&&!u[p].ts&&(u[p].ts=s.ts),Nu(e,u[p],n);break}}}else{let p=e.addMessageToConversation(t,{...s.message?.id?{id:s.message.id,messageId:s.message.id}:{},...s.ts?{ts:s.ts}:{},type:"user",content:a,...s.message?.attachments?{attachments:s.message.attachments}:{},...s.message?.quote?{quote:s.message.quote}:{},...c?{clientMessageId:c}:{}});Nu(e,p,n)}}}else if(s.type==="result"){delete e.processingConversations[t],Ve(e,t);let i=e.conversations.find(d=>d.id===t);i&&i.connecting&&(i.connecting=!1);let o=e._currentYeaftSessionId||null;if(e._currentYeaftTurnId){let d=Object.entries(e.activeVpTurns||{}).find(([,u])=>(u?.turnId===e._currentYeaftTurnId||!u?.turnId&&u===e.activeVpTurns[e._currentYeaftTurnId])&&(!e._currentYeaftAgentId||!u?.agentId||u.agentId===e._currentYeaftAgentId));if(d){let[u,g]=d,{[u]:p,...f}=e.activeVpTurns;!o&&g?.sessionId&&(o=g.sessionId),e.activeVpTurns=f}}if(o&&e._currentYeaftVpId&&e.vpStatuses){let d=e._currentYeaftTurnId||null,u={...e.vpStatuses||{}},g=!1;for(let[p,f]of Object.entries(u))!f||f.vpId!==e._currentYeaftVpId||e._currentYeaftAgentId&&f.agentId&&f.agentId!==e._currentYeaftAgentId||(f.sessionId||f.groupId||null)!==o||d&&f.turnId&&f.turnId!==d||(u[p]={...f,state:"idle",turnId:null,since:Date.now()},g=!0);g&&(e.vpStatuses=u)}o&&typeof e.clearYeaftSessionProcessingIfIdle=="function"&&e.clearYeaftSessionProcessingIfIdle(o,{agentId:e._currentYeaftAgentId||null}),e._closedAt||(e._closedAt={}),e._closedAt[t]=Date.now(),e._turnCompletedConvs||(e._turnCompletedConvs=new Set),e._turnCompletedConvs.add(t),r.currentTool=null,Ws(e,t,e._currentYeaftSessionId?{sessionId:e._currentYeaftSessionId,vpId:e._currentYeaftVpId,turnId:e._currentYeaftTurnId,threadId:e._currentYeaftThreadId}:null);let a=e.messagesMap[t]||[],l=s.result_text||"";if(typeof l=="string"&&l.trim()){let d=!1;for(let u=a.length-1;u>=0;u--){if(a[u].type==="assistant"){d=!0;break}if(a[u].type==="user")break}d||e.appendToAssistantMessageForConversation(t,l.trim())}e.finishStreamingForConversation(t),!(n&&e.promoteCompletedYeaftHistoryOutline?.(t,e._currentYeaftTurnId||null,n))&&o&&n&&e.invalidateYeaftHistoryOutline?.(o,n),e.sweepStaleStreamingForConversation(t),o&&n&&e.pruneConversationMessageRetention?.(t,o,n)}}var ju=B(()=>{Bs();no();sl()});function Sn(e){if(e==null)return e;try{return JSON.parse(JSON.stringify(e))}catch{return e}}function ro(e,t){if(!t)return e??null;if(Object.prototype.hasOwnProperty.call(t,"base"))return Sn(t.base)??null;if(Object.prototype.hasOwnProperty.call(t,"replacement"))return Sn(t.replacement)??null;let s=e&&typeof e=="object"&&!Array.isArray(e)?Sn(e):{};if(t.set&&typeof t.set=="object")for(let[n,r]of Object.entries(t.set))s[n]=Sn(r);if(t.body&&typeof t.body=="object"){let n=s.body&&typeof s.body=="object"&&!Array.isArray(s.body)?{...s.body}:{};for(let[i,o]of Object.entries(t.body))i==="messages"||i==="messagesFrom"||i==="messagesAppend"||i==="messagesKey"||(n[i]=Sn(o));let r=t.body.messagesKey==="messages"||t.body.messagesKey==="input"?t.body.messagesKey:Array.isArray(n.messages)||Object.prototype.hasOwnProperty.call(t.body,"messages")?"messages":"input";if(Array.isArray(t.body.messages))n[r]=Sn(t.body.messages)||[];else if(Array.isArray(t.body.messagesAppend)){let i=Array.isArray(n[r])?n[r]:[],o=Number.isFinite(Number(t.body.messagesFrom))?Number(t.body.messagesFrom):i.length;n[r]=i.slice(0,o).concat(Sn(t.body.messagesAppend)||[])}s.body=n}return s}function Uu(e,t){return!t||!Object.prototype.hasOwnProperty.call(t,"rawRequestDelta")?e??null:ro(e??null,t.rawRequestDelta)}function Yr(e){if(!e)return 0;let t=typeof e=="string"?e:String(e),s=0,n=0;for(let r of t){let i=r.codePointAt(0)||0;i>=19968&&i<=40959||i>=12352&&i<=12447||i>=12448&&i<=12543||i>=44032&&i<=55215?s+=1:n+=1}return Math.ceil(s+n/4)}function cb(e){let t=[],s=[];if(!e)return{messageText:t,toolText:s};let n=e.content;if(typeof n=="string")e.role==="tool"?s.push(n):t.push(n);else if(Array.isArray(n))for(let r of n){if(!r||typeof r!="object")continue;let i=r.type;if(i==="text"&&typeof r.text=="string")t.push(r.text);else if(i==="tool_use"){if(s.push(String(r.name||"")),r.input!==void 0)try{s.push(JSON.stringify(r.input))}catch{}}else if(i==="tool_result"){let o=r.content;if(typeof o=="string")s.push(o);else if(Array.isArray(o)){for(let a of o)if(a)if(typeof a=="string")s.push(a);else if(typeof a=="object"&&typeof a.text=="string")s.push(a.text);else try{s.push(JSON.stringify(a))}catch{}}else if(o!==void 0)try{s.push(JSON.stringify(o))}catch{}}else try{t.push(JSON.stringify(r))}catch{}}if(Array.isArray(e.toolCalls)){for(let r of e.toolCalls)if(r&&(s.push(String(r.name||"")),r.input!==void 0))try{s.push(JSON.stringify(r.input))}catch{}}return{messageText:t,toolText:s}}function Ku(e){let t=0,s=0;if(e&&Array.isArray(e.messages))for(let i of e.messages){let{messageText:o,toolText:a}=cb(i);for(let l of o)t+=Yr(l);for(let l of a)s+=Yr(l)}let n=0,r=0;if(e&&typeof e.response=="string"&&(n+=Yr(e.response)),e&&Array.isArray(e.toolCalls)){for(let i of e.toolCalls)if(i&&(r+=Yr(String(i.name||"")),i.input!==void 0))try{r+=Yr(JSON.stringify(i.input))}catch{}}return{inputMessageTokens:t,inputToolTokens:s,outputMessageTokens:n,outputToolTokens:r,inputTotalEstimated:t+s,outputTotalEstimated:n+r}}function ll(e,t,s){let n=Math.max(0,Math.floor(Number(e)||0)),r=Math.max(0,Number(t)||0),i=Math.max(0,Number(s)||0),o=r+i;if(n===0)return{message:0,tool:0};if(o===0)return{message:n,tool:0};let a=Math.round(r/o*n),l=Math.min(n,Math.max(0,a));return{message:l,tool:n-l}}function zu(e,t){let s=Math.max(0,Math.floor(Number(e)||0)),n=t&&typeof t=="object"?t:{},r=[["systemPrompt",Math.max(0,Number(n.systemPromptTokens)||0)],["historyMessages",Math.max(0,Number(n.historyMessageTokens)||0)],["tools",Math.max(0,Number(n.toolDefinitionTokens)||0)],["currentTurn",Math.max(0,Number(n.currentTurnTokens)||0)]],i=r.reduce((c,[,d])=>c+d,0),o={systemPrompt:0,historyMessages:0,tools:0,currentTurn:0};if(s===0)return o;if(i===0)return o.currentTurn=s,o;let a=r.map(([c,d],u)=>{let g=d/i*s,p=Math.floor(g);return o[c]=p,{key:c,index:u,fraction:g-p}}),l=s-Object.values(o).reduce((c,d)=>c+d,0);a.sort((c,d)=>d.fraction-c.fraction||c.index-d.index);for(let c=0;c<l;c++)o[a[c%a.length].key]+=1;return o}function Yu(e){if(e==null||e==="")return"";let t;if(typeof e=="number")t=e;else if(typeof e=="string"){let o=Date.parse(e);if(Number.isNaN(o)){let a=Number(e);if(!Number.isFinite(a))return"";t=a}else t=o}else return"";if(!Number.isFinite(t))return"";let s=new Date(t),n=String(s.getHours()).padStart(2,"0"),r=String(s.getMinutes()).padStart(2,"0"),i=String(s.getSeconds()).padStart(2,"0");return`${n}:${r}:${i}`}var cl=B(()=>{});function Is(e,t){return!e||!t?"":`${e}${t}`}function Gr(e){let t=typeof e=="string"?e:String(e||"");if(!t)return{agentId:null,sessionId:null};let s=t.indexOf("");if(s<0)return{agentId:null,sessionId:t};let n=t.slice(0,s)||null,r=t.slice(s+1)||null;return{agentId:n,sessionId:r}}function dl(e){return e?`${e}`:""}function ul(e,t){return!e||!t?"":`${e}${t}`}var io=B(()=>{});function db(e,t){if(!e||!!!t?.online)return!1;let n=!e.online,r=e.online&&e.version!=null&&t.version!=null&&e.version!==t.version;return n||r}function Gu(e,t){let s=e.lastViewedConversation||localStorage.getItem("lastViewedConversation");if(!s)return!1;let n=e.conversations.find(i=>i.id===s);if(!n)return!1;let r=t?.agentId||e.currentAgent;return t&&(e.currentAgent=t.agentId,e.currentAgentInfo=t.agentInfo,e.sendWsMessage({type:"select_agent",agentId:t.agentId,silent:!0})),e.activeConversations=[s],e.currentWorkDir=n.workDir,e.messagesMap[s]=[],e.sendWsMessage({type:"select_conversation",conversationId:s}),e.requestChatHistory?.(s,{mode:"recent",turns:5}),e.sendWsMessage({type:"refresh_conversation",conversationId:s}),!0}function Qu(e,t){let s=Array.isArray(e.agents)?e.agents:[],n=Array.isArray(t.agents)?t.agents:[],r=e._hasHandledAgentList===!0,i=new Set(s.filter(d=>d?.id&&d.online).map(d=>d.id)),o=new Set(n.filter(d=>d?.id&&d.online).map(d=>d.id));for(let[d,u]of r?e._sessionCrudPending?.entries?.()||[]:[])!u?.agentId||!i.has(u.agentId)||o.has(u.agentId)||(u.resolve?.({ok:!1,requestId:d,error:{code:"agent_offline",message:"Agent disconnected"}}),e._sessionCrudPending.delete(d));let a=e.currentAgent||null,l=!!(a&&s.some(d=>d&&d.id===a&&d.online));e.agents=n,e._hasHandledAgentList=!0;for(let[d,u]of Object.entries(e.agentOperations||{})){let g=n.find(p=>p.id===d);for(let p of["restart","upgrade"]){let f=u?.[p];if(!f?.pending||!f.acknowledged)continue;if(!g?.online){f.sawOffline||(e.agentOperations={...e.agentOperations,[d]:{...e.agentOperations[d]||{},[p]:{...f,sawOffline:!0}}});continue}let m=p==="upgrade"&&f.oldVersion&&g.version!==f.oldVersion;!f.sawOffline&&!m||e.finishAgentOperation?.(d,p)}}let c=e.currentAgent||null;if(c){let d=e._yeaftAgentSeen&&e._yeaftAgentSeen.id===c?e._yeaftAgentSeen:null,u=n.find(p=>p.id===c)||null;(e.currentView==="yeaft"||e.workCenterOpen&&e.workCenterAgentId===c)&&db(d,u)&&(e._yeaftReconnectCatchUpPending=!0),u?e._yeaftAgentSeen={id:c,online:!!u.online,version:u.version!=null?u.version:null}:d?d.online&&(e._yeaftAgentSeen={id:c,online:!1,version:d.version}):e._yeaftAgentSeen={id:c,online:!1,version:null}}{let d=new Set(n.map(u=>u.id));for(let u of n)e.proxyPorts[u.id]=u.proxyPorts||[],u.yeaftStatus&&typeof e.cacheYeaftAgentStatus=="function"&&e.cacheYeaftAgentStatus(u.id,u.yeaftStatus);for(let u of Object.keys(e.proxyPorts))d.has(u)||delete e.proxyPorts[u]}if(e.currentAgent){let d=n.find(u=>u.id===e.currentAgent);d&&(e.currentAgentInfo=d)}if(e.currentView==="yeaft"&&!e.currentAgent){let d=n.find(u=>u.online);d&&(e.currentAgent=d.id,e.currentAgentInfo=d)}if(e.currentView==="yeaft"&&typeof e.loadOpenedYeaftSessionsForConnectedAgents=="function"){let d=n.filter(u=>u&&u.online&&u.id).map(u=>u.id);e.loadOpenedYeaftSessionsForConnectedAgents(d)}{let d=[],u=new Set;for(let p of n)for(let f of p.conversations||[])u.has(f.id)||(u.add(f.id),d.push({...f,type:f.type,agentId:p.id,agentName:p.name}),f.title&&(f.customTitle&&(e.customConversationTitles[f.id]=f.title),e.conversationTitles[f.id]||(e.conversationTitles[f.id]=f.title)));for(let p of d){p.agentOnline=!0;let f=e.conversations.find(m=>m.id===p.id);if(f)f.claudeSessionId=p.claudeSessionId||f.claudeSessionId,f.processing=p.processing,f.userId=p.userId,f.username=p.username,f.agentId=p.agentId,f.agentName=p.agentName,f.agentOnline=!0,p.type&&(f.type=p.type),p.name!==void 0&&(f.name=p.name);else{let m=e._recentlyDeletedSessions?.[p.id];if(m&&Date.now()-m<15e3)continue;e.conversations.push(p)}p.pinned&&!e.pinnedSessions.includes(p.id)&&e.pinnedSessions.push(p.id)}let g=new Set(n.map(p=>p.id));e.conversations=e.conversations.filter(p=>{if(u.has(p.id)||e.activeConversations.includes(p.id))return!0;if(p.agentId&&g.has(p.agentId)){let f=e._recentlyDeletedSessions?.[p.id];return f&&Date.now()-f<15e3||(delete e.messagesMap[p.id],delete e.processingConversations[p.id],Ve(e,p.id),delete e.executionStatusMap[p.id]),!1}return p.agentId&&!g.has(p.agentId)&&(p.agentOnline=!1),!0});for(let p of d)if(p.processing&&!yn(e,p.id)&&!e._turnCompletedConvs?.has(p.id))e.processingConversations[p.id]=!0;else if(e.processingConversations[p.id]){delete e.processingConversations[p.id],Ve(e,p.id);let f=e.executionStatusMap[p.id];f&&(f.currentTool=null),e.finishStreamingForConversation(p.id)}for(let p of Object.keys(e.processingConversations))if(!u.has(p)){if(p.startsWith("yeaft-"))continue;delete e.processingConversations[p],Ve(e,p);let f=e.executionStatusMap[p];f&&(f.currentTool=null),e.finishStreamingForConversation(p)}}if(localStorage.setItem("pinned-sessions",JSON.stringify(e.pinnedSessions)),e._closedAt){let d=Date.now();for(let u of Object.keys(e._closedAt))d-e._closedAt[u]>3e4&&(delete e._closedAt[u],e._turnCompletedConvs?.delete(u))}if(e.currentAgent){let d=n.find(u=>u.id===e.currentAgent&&u.online);if(d){let u=!!e._yeaftReconnectCatchUpPending,p=u||r&&!l;if(e.currentAgentInfo=d,p&&(e._offlineConversationRestoreKey=null,e.sendWsMessage({type:"select_agent",agentId:e.currentAgent,silent:!0})),p&&e.workCenterOpen&&e.workCenterAgentId===e.currentAgent&&typeof e.listWorkItems=="function"){let f=e._workCenterListFiltersByAgent?.[e.workCenterAgentId]||{};e.listWorkItems(e.workCenterAgentId,f).catch(()=>{})}if(e._yeaftReconnectCatchUpPending=!1,e.currentView==="yeaft"&&typeof e.requestYeaftSessionBootstrap=="function"){let f=u||!e.yeaftSessionReady||!e.yeaftModel||!e.yeaftStatus;(f||u)&&e.requestYeaftSessionBootstrap({forceSessionReady:f,catchUpHistory:u})}if(!p)return;if(e.currentConversation){let f=e.conversations.find(y=>y.id===e.currentConversation);e.sendWsMessage({type:"select_conversation",conversationId:e.currentConversation});let m=e.messagesMap[e.currentConversation]||[],v=vn(m);v!=null?e.requestChatHistory?.(e.currentConversation,{mode:"delta",afterMessageId:v}):e.requestChatHistory?.(e.currentConversation,{mode:"recent",turns:5}),e.sendWsMessage({type:"refresh_conversation",conversationId:e.currentConversation})}else e.recoveryDismissed||Gu(e);return}else{let u=`${e.currentAgent||""}:${e.currentConversation||""}`;e.currentConversation&&(!r||l||e._offlineConversationRestoreKey!==u)&&(e._offlineConversationRestoreKey=u,e.sendWsMessage({type:"select_conversation",conversationId:e.currentConversation}));return}}if(!e.currentConversation&&!e.currentAgent&&!e.recoveryDismissed){let d=e.lastViewedConversation||localStorage.getItem("lastViewedConversation"),u=e.lastUsedAgent;if(d){let g=e.conversations.find(p=>p.id===d);if(g){let p=n.find(f=>f.id===g.agentId&&f.online);if(p){Gu(e,{agentId:g.agentId,agentInfo:p});return}}}u&&(e.agents.find(p=>p.id===u&&p.online)?e.selectAgent(u):e.checkPendingRecovery())}}function Xu(e,t){let s=e.pendingAgentSelection||null;if(s){if(!(typeof t.requestId=="string"&&t.requestId?t.requestId===s.requestId:t.agentId===s.agentId))return!1;if(e.pendingAgentSelection=null,t.ok===!1)return e.agentSwitching=!1,!1}else{if(t.requestId)return!1;if(e.currentAgent&&t.agentId!==e.currentAgent)return!1}e.agentSwitching=!1;let n=e.currentAgent===t.agentId,r={id:t.agentId,name:t.agentName,workDir:t.workDir,capabilities:t.capabilities||["terminal","file_editor","background_tasks"],...t.capabilityMetadataProvided===!0?{capabilityMetadataProvided:!0}:{},version:t.version||null};if(typeof e.activateYeaftAgent=="function"?e.activateYeaftAgent(t.agentId,r):(e.currentAgent=t.agentId,e.currentAgentInfo=r),Array.isArray(t.slashCommands)){let u=[...new Set(t.slashCommands)];e.slashCommandsMap[`agent:${t.agentId}`]=u}t.slashCommandDescriptions&&(e.slashCommandDescriptions={...e.slashCommandDescriptions,...t.slashCommandDescriptions});let i=t.conversations||[],o=new Set,a=i.filter(u=>o.has(u.id)?!1:(o.add(u.id),!0)).map(u=>({...u,agentId:t.agentId,agentName:t.agentName}));if(n&&e.currentConversation){let u=i.find(g=>g.id===e.currentConversation);u&&!a.find(g=>g.id===u.id)&&a.push({...u,agentId:t.agentId,agentName:t.agentName})}let l=new Set(a.map(u=>u.id)),c=e.conversations.filter(u=>!l.has(u.id));e.conversations=[...c,...a];for(let u of i)u.title&&(u.customTitle&&(e.customConversationTitles[u.id]=u.title),e.conversationTitles[u.id]||(e.conversationTitles[u.id]=u.title));let d=new Set(i.map(u=>u.id));for(let u of i)if(u.processing&&!yn(e,u.id)&&!e._turnCompletedConvs?.has(u.id))e.processingConversations[u.id]=!0;else if(e.processingConversations[u.id]){delete e.processingConversations[u.id],Ve(e,u.id);let g=e.executionStatusMap[u.id];g&&(g.currentTool=null),e.finishStreamingForConversation(u.id)}for(let u of Object.keys(e.processingConversations))if(!d.has(u)){if(u.startsWith("yeaft-"))continue;if(!c.some(p=>p.id===u)){delete e.processingConversations[u],Ve(e,u);let p=e.executionStatusMap[u];p&&(p.currentTool=null),e.finishStreamingForConversation(u)}}if(e.currentView!=="yeaft"){if(n&&e.currentConversation){let u=e.conversations.find(g=>g.id===e.currentConversation);e.currentWorkDir=u?.workDir||e.currentWorkDir||t.workDir,ns(e),e.sendWsMessage({type:"select_conversation",conversationId:e.currentConversation})}else{e.activeConversations=[],e.currentWorkDir=t.workDir;let u=e.lastViewedConversation||localStorage.getItem("lastViewedConversation");u&&e.conversations.find(g=>g.id===u)&&(e.autoRestoreConversation(u),e.pendingRecovery=null)}$d(e)}return!0}var Zu=B(()=>{Bs();hn();Br()});function ub(e={}){return{providers:e.providers||[],primaryModel:e.primaryModel||null,fastModel:e.fastModel||null,language:e.language||"en"}}function Qn(e){pl.delete(e)}function mb(e,t){let s=pl.get(e);s||(s=new Map,pl.set(e,s));let n=typeof t?.agentId=="string"?t.agentId:"",r=typeof t?.requestId=="string"?t.requestId:"",i=Number(t?.chunkIndex),o=Number(t?.chunkCount),a=typeof t?.data=="string"?t.data:null,l=e.yeaftDebugPanel?.agentId||null,c=e._yeaftDebugHistoryPending?.payload,d=c?.requestId||e._yeaftDebugHistoryLatestDetailRequestId||e._yeaftDebugHistoryLatestListRequestId;if(!n||!r||l&&n!==l||c&&n!==c.agentId||r!==d||!Number.isSafeInteger(i)||!Number.isSafeInteger(o)||o<=1||i<0||i>=o||a==null||new TextEncoder().encode(a).byteLength>hb)return null;let u=Date.now();for(let[m,v]of s)v.expiresAt<=u&&s.delete(m);let g=`${n}\0${r}`,p=s.get(g);if(!p){if(i!==0)return null;p={nextIndex:0,chunkCount:o,parts:[],bytes:0,expiresAt:u+Ju},s.set(g,p)}let f=new TextEncoder().encode(a).byteLength;if(p.chunkCount!==o||i!==p.nextIndex)return s.delete(g),null;if(p.parts.push(a),p.bytes+=f,p.nextIndex+=1,p.expiresAt=u+Ju,e.refreshYeaftDebugHistoryTimeout?.(r),p.nextIndex!==p.chunkCount)return null;s.delete(g);try{let m=JSON.parse(p.parts.join(""));return m?.type==="yeaft_debug_history"&&m.requestId===r?{...m,agentId:n}:null}catch{return null}}function ep(){return window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore()}function vb(e,t){let s=t.agentId||null,n=Array.isArray(e.yeaftSessionHydrateSlices)?e.yeaftSessionHydrateSlices.filter(r=>r.agentId!==s):[];e.yeaftSessionHydrateSlices=[...n,{agentId:s,sessions:Array.isArray(t.sessions)?t.sessions:[]}]}function yb(e){let t=ep(),s=null;try{s=localStorage.getItem("lastViewedYeaftSession")||null}catch{}let n=Gr(s),r=e.yeaftActiveSessionFilter||t?.activeSessionId||null;if(r){let i=t?.activeSessionKey?t.sessions?.[t.activeSessionKey]:null;return i?.id===r&&i.agentId?{sessionId:r,agentId:i.agentId}:n.sessionId===r&&n.agentId?n:{sessionId:r,agentId:null}}return n}function tp(e){let t=ep(),s=yb(e);typeof t?.beginInventoryCommit=="function"?t.beginInventoryCommit(s.sessionId,s.agentId):typeof t?.resetInventory=="function"&&t.resetInventory();let n=Array.isArray(e.yeaftSessionHydrateSlices)?e.yeaftSessionHydrateSlices:[],r=s.agentId?[...n.filter(i=>i.agentId===s.agentId),...n.filter(i=>i.agentId!==s.agentId)]:n;r.length===0&&t?.applySnapshot?.([],null),r.forEach((i,o)=>{t?.applySnapshot?.(i.sessions||[],i.agentId||null,{deferActivation:o<r.length-1})}),e.yeaftSessionHydrateSlices=[]}function bb(e){let t=e.yeaftSessionHydrateRequestId||null;e.yeaftSessionInventoryCompleteSupported!==!1||!t||(clearTimeout(e._legacyYeaftSessionHydrateTimer),e._legacyYeaftSessionHydrateTimer=setTimeout(()=>{e.yeaftSessionHydrateRequestId===t&&(e._legacyYeaftSessionHydrateTimer=null,tp(e),e._hasHandledYeaftSessionHydrate=!0,e.yeaftSessionHydrateRequestId=null,e.yeaftSessionHydrateError=null,e._yeaftSessionInventorySocketQuarantined=!0)},fb))}function wb(e,t={}){let s=e||{systemPrompt:"",messages:[],rawRequest:null},n={systemPrompt:s.systemPrompt||"",messages:Array.isArray(s.messages)?[...s.messages]:[],rawRequest:s.rawRequest??null};if(t?.base){let r={systemPrompt:t.systemPrompt||"",messages:Array.isArray(t.messages)?t.messages:[],rawRequest:null};return Object.prototype.hasOwnProperty.call(t,"rawRequestDelta")&&(r.rawRequest=ro(null,t.rawRequestDelta)),r}if(typeof t?.systemPrompt=="string"&&(n.systemPrompt=t.systemPrompt),Array.isArray(t?.messages))n.messages=t.messages;else if(Array.isArray(t?.messagesAppend)){let r=Number.isFinite(Number(t.messagesFrom))?Number(t.messagesFrom):n.messages.length;n.messages=n.messages.slice(0,r).concat(t.messagesAppend)}return Object.prototype.hasOwnProperty.call(t||{},"rawRequestDelta")&&(n.rawRequest=ro(n.rawRequest,t.rawRequestDelta)),n}function kb(e=[]){let t=new Map;return e.map(s=>{if(!s||!s.requestDelta)return s;let n=s.turnId||"__unknown__",r=t.get(n)||s.requestBase||null,i=r?.rawRequest??null,o=wb(r,s.requestDelta);return t.set(n,o),{...s,systemPrompt:typeof s.systemPrompt=="string"&&s.systemPrompt?s.systemPrompt:o.systemPrompt,messages:Array.isArray(s.messages)&&s.messages.length>0?s.messages:o.messages,rawRequest:s.rawRequest===void 0?o.rawRequest:s.rawRequest,rawRequestBase:i}})}function sp(e,t){let s=Ge();if(t?.type==="yeaft_debug_history_chunk"){let n=mb(e,t);if(!n)return;t=n}switch(e._lastPongAt=Date.now(),t.type){case"work_center_response":{let n=t.requestId?e.workCenterPending[t.requestId]:null;if(!n)break;clearTimeout(n.timer),delete e.workCenterPending[t.requestId],t.ok?n.resolve(t.data):n.reject(new Error(t.error||"Work Center request failed"));break}case"work_center_event":e.applyWorkCenterEvent(t.agentId,t.event);break;case"client_hello_ack":e.workbenchRouteProtocolSupported=t.workbenchRouteProtocol===1,e.browserRuntimeProtocolSupported=t.browserRuntimeProtocol===1,e.browserRuntimeSetupProtocolSupported=t.browserRuntimeSetupProtocol===1,e.browserRuntimeServerEnabled=t.browserRuntimeEnabled===!0,window.dispatchEvent(new CustomEvent("browser-runtime-message",{detail:t}));break;case"auth_result":if(t.success){if(e.authenticated=!0,t.sessionKey&&(e.sessionKey=Gt(t.sessionKey),s.setSessionKey(t.sessionKey)),t.acceptPlaintext===!0&&(e.serverEncryptionRequired=!1),e.yeaftSessionInventoryCompleteSupported=t.yeaftSessionInventoryComplete===!0,e.workbenchRouteProtocolSupported=!1,e.browserRuntimeProtocolSupported=!1,e.browserRuntimeSetupProtocolSupported=!1,e.browserRuntimeServerEnabled=t.browserRuntimeEnabled===!0,window.dispatchEvent(new CustomEvent("browser-runtime-message",{detail:t})),e.yeaftSessionHydrateSlices=[],e._hasHandledYeaftSessionHydrate=!1,e.yeaftSessionHydrateError=null,t.role&&(s.role=t.role),typeof e.requestYeaftSessionInventory=="function")e.requestYeaftSessionInventory();else{let n=e.conversations.map(r=>r.id).filter(Boolean);e.sendWsMessage({type:"get_agents",conversationIds:n.length>0?n:void 0})}e.checkPendingRecovery()}else e.addMessage({type:"error",content:t.error||Oe("login.error.loginFailed")}),s.handleAuthFailure?.(void 0,t._wsAuthToken,t._wsAuthGeneration);break;case"agent_list":Qu(e,t);break;case"yeaft_session_hydrate":{if(e.yeaftSessionInventoryCompleteSupported===!0&&(!t.requestId||t.requestId!==e.yeaftSessionHydrateRequestId)||e.yeaftSessionInventoryCompleteSupported!==!0&&!e.yeaftSessionHydrateRequestId||t.requestId&&e.yeaftSessionHydrateRequestId&&t.requestId!==e.yeaftSessionHydrateRequestId)break;vb(e,t),e.yeaftSessionInventoryCompleteSupported!==!0&&bb(e);break}case"yeaft_session_hydrate_complete":if(e.yeaftSessionInventoryCompleteSupported===!0&&(!t.requestId||t.requestId!==e.yeaftSessionHydrateRequestId)||e.yeaftSessionHydrateRequestId&&!t.requestId||t.requestId&&e.yeaftSessionHydrateRequestId&&t.requestId!==e.yeaftSessionHydrateRequestId)break;clearTimeout(e._legacyYeaftSessionHydrateTimer),e._legacyYeaftSessionHydrateTimer=null,t.ok!==!1?tp(e):e.yeaftSessionHydrateSlices=[],e.yeaftSessionHydrateRequestId=null,e._hasHandledYeaftSessionHydrate=t.ok!==!1,e.yeaftSessionHydrateError=t.ok===!1?t.error||"session_inventory_failed":null;break;case"session_catalog_snapshot":e.applySessionCatalogSnapshot(t.catalog,t.projectsAuthoritative===!0?t.projects:null,t.hiddenCatalog);break;case"session_ui_metadata_updated":e.finishSessionCatalogMutation?.(t);break;case"session_catalog_reorder_result":e.finishSessionCatalogMutation?.(t);break;case"agent_selected":if(!Xu(e,t))break;e.workCenterOpen&&e.workCenterAgentId&&e.listWorkItems(e.workCenterAgentId).catch(()=>{});break;case"conversation_created":Eu(e,t);break;case"conversation_resumed":Du(e,t);break;case"conversation_selected":if(e.currentConversation===t.conversationId)return;e.activeConversations=[t.conversationId];{let n=e.conversations.find(r=>r.id===t.conversationId);n&&(e.currentWorkDir=n.workDir)}e.messagesMap[t.conversationId]=[],e.saveOpenSessions();break;case"conversation_settings_updated":{let n=e.conversations.find(i=>i.id===t.conversationId);n&&t.disallowedTools!==void 0&&(n.disallowedTools=t.disallowedTools);let r=e.conversationMcpServers[t.conversationId];if(r&&t.disallowedTools){let i=new Set(t.disallowedTools),o=e.conversationMcpServerTools[t.conversationId]||{};for(let a of r){let l=o[a.name];l&&l.length>0?a.enabled=!l.some(c=>i.has(c)):a.enabled=!i.has(`mcp__${a.name}`)}}t.needRestart&&n&&(n.needRestart=!0);break}case"sync_messages_result":qu(e,t);break;case"conversation_deleted":ol(e,t);break;case"conversation_delete_result":t.ok&&ol(e,t);break;case"turn_completed":$u(e,t);break;case"conversation_closed":Lu(e,t);break;case"claude_output":e.handleAssistantOutputFrame(t.conversationId,t.data);break;case"yeaft_output":case"yeaft_session_output":case"session_output":e.handleYeaftOutput(t);break;case"yeaft_asset_ready":{let n=t.conversationId||e.yeaftConversationIdsByAgent?.[t.agentId]||e.yeaftConversationId;if(!n||!t.image)break;e.messagesMap[n]||(e.messagesMap[n]=[]),e.messagesMap[n].some(i=>i?.type==="chat-image"&&i.assetId===t.image.assetId&&i.sessionId===t.sessionId&&i.turnId===t.turnId)||e.addMessageToConversation(n,{type:"chat-image",...t.image,sessionId:t.sessionId||null,vpId:t.vpId||null,speakerVpId:t.vpId||null,turnId:t.turnId||null,threadId:t.threadId||null});break}case"yeaft_history_chunk":Bu(e,t);break;case"yeaft_history_outline":e.handleYeaftHistoryOutline(t);break;case"yeaft_history_search_result":e.handleYeaftHistorySearchResult(t);break;case"yeaft_history_window":{let n=e.pendingYeaftHistoryWindow?.(t);if(!n||(n.pending?.prefetch===!0&&(t.prefetch=!0),e.pendingYeaftHistoryWindow?.(t)?.pending!==n.pending))break;let r=t.error?null:Vu(e,t);e.handleYeaftHistoryWindow(t,r);break}case"yeaft_tool_stats":{e._fetchYeaftToolStatsTimer&&(clearTimeout(e._fetchYeaftToolStatsTimer),e._fetchYeaftToolStatsTimer=null);let n=t?.snapshot,r=n&&typeof n=="object"&&!Array.isArray(n)?n:{};e.yeaftToolStats={snapshot:r,registered:Array.isArray(t?.registered)?t.registered:[],unused:Array.isArray(t?.unused)?t.unused:[],error:typeof t?.error=="string"?t.error:null,notice:typeof t?.notice=="string"?t.notice:null,fetchedAt:Date.now()},e.yeaftToolStatsLoading=!1;break}case"yeaft_debug_history":{let n=e.yeaftDebugPanel?.agentId||null;if(n&&t?.agentId&&t.agentId!==n)break;let r=typeof t?.requestId=="string"?t.requestId:"",i=typeof t?.detailTurnId=="string"&&t.detailTurnId,o=i?e._yeaftDebugHistoryLatestDetailRequestId:e._yeaftDebugHistoryLatestListRequestId;if(o&&r!==o||!o&&r)break;let a=e._yeaftDebugHistoryPending?.payload;if(a&&(a.requestId!==r||a.agentId!==t.agentId||t.sessionId&&a.sessionId!==t.sessionId))break;e._yeaftDebugHistoryPending=null,Qn(e),e._fetchYeaftDebugHistoryTimer&&(clearTimeout(e._fetchYeaftDebugHistoryTimer),e._fetchYeaftDebugHistoryTimer=null),e._yeaftDebugHistoryInFlightKey=null;let l=Array.isArray(t?.turns)?t.turns:[],c=t?.search?gb:pb,d=i?l:l.slice(-c),u=new Set(d.map(x=>x?.turnId).filter(Boolean)),g=kb(Array.isArray(t?.loops)?t.loops:[]),p=i?g:g.filter(x=>!x?.turnId||u.has(x.turnId)),f=Array.isArray(t?.dreamEvents)?t.dreamEvents:[];e.yeaftDebugHistoryHasMore=!!t?.hasMore||!i&&l.length>d.length,!t?.detailTurnId&&Number.isFinite(t?.limit)&&t.limit>0&&(e.yeaftDebugHistoryLimit=Math.min(c,t.limit)),(!e.yeaftDebugTurnsById||typeof e.yeaftDebugTurnsById!="object")&&(e.yeaftDebugTurnsById={}),Array.isArray(e.yeaftDebugLoops)||(e.yeaftDebugLoops=[]),Array.isArray(e.yeaftDebugTurnOrder)||(e.yeaftDebugTurnOrder=[]);let m=i?{...e.yeaftDebugTurnsById}:{};for(let x of d){let Y=x?.turnId;if(!Y)continue;let L=m[Y];if(L){let U=x?.detailsLoaded?{...L,...x}:{...x,...L};U.memoryLoaded==null&&L.memoryLoaded!=null&&(U.memoryLoaded=L.memoryLoaded),U.memoryAdjust==null&&L.memoryAdjust!=null&&(U.memoryAdjust=L.memoryAdjust),m[Y]=U}else m[Y]=x}e.yeaftDebugTurnsById=m;let v=x=>x?.loopInstanceId||`${x?.turnId||""}#${x?.loopNumber||0}`,y=e.yeaftDebugLoops,h=new Map;for(let x of y)x&&h.set(v(x),x);let k=new Set,S=[];for(let x of p){if(!x)continue;let Y=v(x);k.add(Y);let L=h.get(Y);S.push(i?{...L||{},...x}:L||x)}if(i)for(let x of y)!x||k.has(v(x))||S.push(x);e.yeaftDebugLoops=S;let b=new Set,w=[],P=x=>{!x||b.has(x)||(b.add(x),w.push(x))};if(i){for(let x of e.yeaftDebugTurnOrder)P(x);for(let x of d)P(x?.turnId)}else for(let x of d)P(x?.turnId);e.yeaftDebugTurnOrder=i?w:w.slice(-c);for(let x of f){if(!x)continue;let Y=null,L=x.sessionId||x.groupId;typeof x.target=="string"&&x.target.includes("/")?Y=x.target:typeof L=="string"&&L?Y=`group/${L}`:Y="*",typeof e._appendDreamEvent=="function"&&e._appendDreamEvent(Y,x),x.type==="dream_progress"&&typeof e.handleYeaftOutput=="function"&&e.handleYeaftOutput({event:x})}e.yeaftDebugHistoryLoading=!1,e.yeaftDebugHistoryError=typeof t?.error=="string"?t.error:null,e.yeaftDebugHistoryProjection=t?.projection&&typeof t.projection=="object"?t.projection:null,e.yeaftDebugHistoryFetchedAt=Date.now(),e._yeaftDebugDetailDirty&&!e.yeaftDebugHistoryError&&e.scheduleYeaftDebugDetailRefresh?.({agentId:e.yeaftDebugPanel?.agentId,sessionId:e.yeaftDebugPanel?.sessionId},e.yeaftDebugPanel?.turnId),i&&e.yeaftDebugPanel&&e.yeaftDebugPanel.turnId===t.detailTurnId&&(e.yeaftDebugPanel={...e.yeaftDebugPanel,status:e.yeaftDebugHistoryError?"error":"ready",error:e.yeaftDebugHistoryError});break}case"chat_image":t.conversationId&&t.fileId&&e.addMessageToConversation(t.conversationId,{type:"chat-image",fileId:t.fileId,previewToken:t.previewToken,mimeType:t.mimeType});break;case"error":{let n=t.conversationId||e.currentConversation,r=["Permission denied","Agent not found","No conversation selected","Agent is still syncing","No agent available","Agent access denied"].some(c=>t.message?.includes(c));if((t.message?.includes("Agent is still syncing")||t.message?.includes("Agent not found"))&&ns(e),["No conversation selected","Agent is still syncing","No agent available"].some(c=>t.message?.includes(c))&&n&&(delete e.processingConversations[n],Ve(e,n),e.finishStreamingForConversation(n)),r&&n){let c=e.messagesMap[n];if(c&&c.length>0)for(let d=c.length-1;d>=0&&d>=c.length-5;d--){let u=c[d];if(u&&u.type==="error"&&u._sysErrBaseContent!==void 0){if(u._sysErrBaseContent===t.message&&Date.now()-(u._sysErrFirstAt||0)<=3e3){u._sysErrCount=(u._sysErrCount||1)+1,u.content=`${u._sysErrBaseContent} (\xD7${u._sysErrCount})`,u._sysErrRemoveTimer&&(clearTimeout(u._sysErrRemoveTimer),u._sysErrRemoveTimer=setTimeout(()=>{let g=e.messagesMap[n];if(g){let p=g.findIndex(f=>f.id===u.id);p>=0&&g.splice(p,1)}},5e3));return}break}}}let o=Date.now().toString()+Math.random().toString(36).substr(2,9),a={type:"error",content:t.message,transient:r,dbMessageId:r?"err_"+o:void 0};r&&(a._sysErrBaseContent=t.message,a._sysErrCount=1,a._sysErrFirstAt=Date.now()),e.addMessageToConversation(n,a);let l=null;if(r&&n){let c=e.messagesMap[n];c&&c.length>0&&(l=c[c.length-1])}if(r&&n&&l){let c=n,d="err_"+o;l._sysErrRemoveTimer=setTimeout(()=>{let u=e.messagesMap[c];if(u){let g=u.findIndex(p=>p.id===d);g>=0&&u.splice(g,1)}},5e3)}!r&&n&&(delete e.processingConversations[n],Ve(e,n),e.finishStreamingForConversation(n));break}case"history_sessions_list":if(t.requestId&&e._historySessionsRequestId&&t.requestId!==e._historySessionsRequestId)break;e.historySessions=t.sessions||[],e.historySessionsLoading=!1;break;case"folders_list":if(t.requestId&&e._foldersRequestId&&t.requestId!==e._foldersRequestId)break;e.folders=t.folders||[],e.foldersLoading=!1,e._foldersResolve&&(e._foldersResolve(),e._foldersResolve=null);break;case"models_list":if(t.requestId&&e._modelsRequestId&&t.requestId!==e._modelsRequestId)break;e.providerModels=t.models||[],e.providerModelsLoading=!1,e._modelsTimeout&&(clearTimeout(e._modelsTimeout),e._modelsTimeout=null),e._modelsResolve&&(e._modelsResolve(e.providerModels),e._modelsResolve=null);break;case"conversation_refresh":Fu(e,t);break;case"session_pinned":if(t.conversationId){let n=t.agentId?{agentId:t.agentId}:{};if(typeof e.setSessionPinned=="function")e.setSessionPinned(t.conversationId,!!t.pinned,n);else try{let r=window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore();r&&typeof r.applyPinState=="function"&&r.applyPinState(t.conversationId,!!t.pinned,t.agentId||e.yeaftSessionAgentById?.[t.conversationId]||e.currentAgent||null)}catch{}}break;case"execution_cancelled":Ou(e,t);break;case"slash_commands_update":if(Array.isArray(t.slashCommands)){let n=[...new Set(t.slashCommands)];if(t.commandSet==="yeaft"){let r=t.conversationId&&t.conversationId!=="__preload__"?t.conversationId:null,i=t.agentId&&e.yeaftConversationIdsByAgent?.[t.agentId]||null,o=r||i;o&&(e.slashCommandsMap[o]=n);let a=e.yeaftConversationId||null,l=t.agentId?e.currentAgent===t.agentId&&(i===a||r===a):r===a;a&&l&&(e.slashCommandsMap[a]=n)}else t.conversationId&&(e.slashCommandsMap[t.conversationId]=n),t.agentId&&(e.slashCommandsMap[`agent:${t.agentId}`]=n)}t.slashCommandDescriptions&&(e.slashCommandDescriptions={...e.slashCommandDescriptions,...t.slashCommandDescriptions});break;case"compact_status":{let n=t.conversationId;e.compactStatus={conversationId:n,status:t.status,message:t.message},t.status==="completed"?setTimeout(()=>{e.compactStatus?.conversationId===n&&e.compactStatus?.status==="completed"&&(e.compactStatus=null)},3e3):t.status==="compacting"&&setTimeout(()=>{e.compactStatus?.conversationId===n&&e.compactStatus?.status==="compacting"&&(e.compactStatus=null)},3e4)}break;case"pong_session":{let n=t.conversationId;if(!n)break;if(e._pongTimeouts?.[n]&&(clearTimeout(e._pongTimeouts[n]),delete e._pongTimeouts[n]),t.status==="unsupported"){Ve(e,n),Iu(e,n);break}if(t.status==="ok")e.sessionHealth?.[n]&&delete e.sessionHealth[n],!t.isProcessing&&e.processingConversations[n]&&(delete e.processingConversations[n],Ve(e,n),e.finishStreamingForConversation(n));else if(e.sessionHealth||(e.sessionHealth={}),e.sessionHealth[n]={status:t.status},t.status==="session-lost"||t.status==="cli-exited"){if(e._autoRefreshed||(e._autoRefreshed={}),!e._autoRefreshed[n]){e._autoRefreshed[n]=!0;let r=e.conversations.find(i=>i.id===n);e.sendWsMessage({type:"refresh_conversation",conversationId:n,agentId:r?.agentId})}delete e.processingConversations[n],Ve(e,n),e.finishStreamingForConversation(n)}break}case"ask_user_question":if(t.conversationId){let n=()=>{let r=e.messagesMap[t.conversationId]||[];for(let i=r.length-1;i>=0;i--)if(r[i].type==="tool-use"&&r[i].toolName==="AskUserQuestion"&&!r[i].askRequestId)return r[i].askRequestId=t.requestId,r[i].askQuestions=t.questions,!0;return!1};if(!n()){let r=0,i=setInterval(()=>{r++,(n()||r>=10)&&clearInterval(i)},200)}}break;case"dream_enabled_changed":{let n=e.agentDreamState?.[t.agentId]||{},r=!!t.requestId&&n.requestId===t.requestId;if(!n.pending||!r)break;clearTimeout(n.timer);let i=typeof t.enabled=="boolean"?t.enabled:n.authoritative!==!1,o=Array.isArray(e.agents)?e.agents.find(a=>a.id===t.agentId):null;o&&(o.dreamEnabled=i),e.agentDreamState={...e.agentDreamState,[t.agentId]:{...n,pending:!1,timer:null,authoritative:i,error:t.error||null}};break}case"restart_agent_ack":{let n=e.agentOperations?.[t.agentId]?.restart,r=!!t.requestId&&n?.requestId===t.requestId;if(!n?.pending||!r)break;n.pending&&(e.agentOperations={...e.agentOperations,[t.agentId]:{...e.agentOperations[t.agentId]||{},restart:{...n,acknowledged:!0}}}),window.dispatchEvent(new CustomEvent("agent-restart-ack",{detail:{agentId:t.agentId,requestId:t.requestId}}));break}case"upgrade_agent_ack":{let n=e.agentOperations?.[t.agentId]?.upgrade,r=!!t.requestId&&n?.requestId===t.requestId;if(!n?.pending||!r)break;n.pending&&(!t.success||t.alreadyLatest?(n.batchId&&t.alreadyLatest?e.recordAgentUpgradeBatchResult?.(t.agentId,{status:"already_latest",version:t.version||null},n.batchId):n.batchId&&!t.success&&e.recordAgentUpgradeBatchResult?.(t.agentId,{status:"failed",error:t.error||null,reason:t.reason||null,version:t.version||null},n.batchId),e.finishAgentOperation?.(t.agentId,"upgrade",t.error||null)):e.agentOperations={...e.agentOperations,[t.agentId]:{...e.agentOperations[t.agentId]||{},upgrade:{...n,acknowledged:!0}}}),window.dispatchEvent(new CustomEvent("agent-upgrade-ack",{detail:{agentId:t.agentId,requestId:t.requestId,batchId:n.batchId||null,success:t.success,error:t.error,alreadyLatest:t.alreadyLatest,version:t.version,reason:t.reason,currentNode:t.currentNode,requiredNode:t.requiredNode,requiredCapability:t.requiredCapability}}));break}case"browser_runtime_status_result":case"browser_runtime_install_progress":case"browser_runtime_error":case"browser_session_created":case"browser_session_error":case"browser_session_snapshot":case"browser_session_list_result":case"browser_peer_prepared":case"browser_peer_offer":case"browser_peer_ice_candidate":case"browser_peer_state":case"browser_peer_error":window.dispatchEvent(new CustomEvent("browser-runtime-message",{detail:t}));break;case"terminal_created":case"terminal_output":case"terminal_closed":case"terminal_error":case"file_content":case"video_metadata":case"file_references_resolved":case"file_saved":case"directory_listing":case"git_status_result":case"git_diff_result":case"git_op_result":case"file_op_result":case"file_search_result":case"file_tabs_restored":t.type,t.type,window.dispatchEvent(new CustomEvent("workbench-message",{detail:t}));break;case"server_updating":e.connectionState="updating";break;case"context_usage":e.contextUsage={inputTokens:t.inputTokens,maxTokens:t.maxTokens,percentage:t.percentage,conversationId:t.conversationId};break;case"mcp_servers_list":case"mcp_config_updated":t.agentId&&t.servers&&(e.mcpServers[t.agentId]=t.servers);break;case"expert_roles_list":t.roles&&(e.expertRoleDefinitions=t.roles);break;case"llm_models_discovered":t.agentId&&(e.llmModelDiscovery=e.llmModelDiscovery||{},e.llmModelDiscovery[t.agentId]=t);break;case"llm_config":case"llm_config_updated":if(t.agentId){let n=t.agentConfig||ub(t),r=t.effectiveConfig||n;e.llmConfig[t.agentId]={providers:t.providers||r.providers||[],primaryModel:t.primaryModel||r.primaryModel||null,fastModel:t.fastModel||r.fastModel||null,language:t.language||n.language||r.language||"en",needsSetup:t.needsSetup??r.needsSetup??!1,agentConfig:n,effectiveConfig:r,requestId:t.requestId||null,statusRefreshError:t.statusRefreshError||null,error:t.error||null,loaded:!0}}break;case"models_dev_registry":if(e.modelsDevRegistry={registry:t.registry||{},fetchedAt:t.fetchedAt||Date.now(),error:t.error||null,loaded:!0},e._modelsDevPending){let n=e._modelsDevPending;e._modelsDevPending=null,n.timer&&clearTimeout(n.timer);for(let r of n.resolvers)r(e.modelsDevRegistry)}break;case"yeaft_settings":case"yeaft_settings_updated":t.agentId&&(e.yeaftSettings[t.agentId]={maxConcurrentThreads:t.maxConcurrentThreads??6,autoArchiveIdleDays:t.autoArchiveIdleDays??30,error:t.error||null,loaded:!0,at:Date.now()});break;case"yeaft_plugins":case"yeaft_plugins_updated":{let n={plugins:t.plugins&&typeof t.plugins=="object"?t.plugins:{},error:t.error||null,loaded:!0,at:Date.now()};t.agentId&&(e.pluginConfigByAgent={...e.pluginConfigByAgent,[t.agentId]:n});let r=t.requestId?e._pluginPending?.[t.requestId]:null;r&&(clearTimeout(r.timer),delete e._pluginPending[t.requestId],r.resolve(n));break}case"yeaft_managed_skill_result":{let n=t.requestId?e._pluginPending?.[t.requestId]:null,r=n?.kind==="managed-skill"?n:null,i=t.catalog&&typeof t.catalog=="object"?{tools:Array.isArray(t.catalog.tools)?t.catalog.tools:[],skills:Array.isArray(t.catalog.skills)?t.catalog.skills:[],skillSources:Array.isArray(t.catalog.skillSources)?t.catalog.skillSources:[],mcpServers:Array.isArray(t.catalog.mcpServers)?t.catalog.mcpServers:[]}:{tools:[],skills:[],skillSources:[],mcpServers:[]};if(r&&e.managedSkillRequestByKey?.[r.key]===t.requestId){let o=e.pluginCatalogKey?.(r.agentId,r.workDir||"")||"";e.pluginCatalogByKey={...e.pluginCatalogByKey,[o]:{catalog:i,loading:!1,error:t.error||null,loaded:!0,at:Date.now()}}}r&&(clearTimeout(r.timer),delete e._pluginPending[t.requestId],r.resolve({catalog:i,error:t.error||null,result:t.result||null}));break}case"yeaft_plugin_catalog_result":{let n=t.requestId?e._pluginPending?.[t.requestId]:null,r=n?.kind==="catalog"?n:null,i=t.catalog&&typeof t.catalog=="object"?{tools:Array.isArray(t.catalog.tools)?t.catalog.tools:[],skills:Array.isArray(t.catalog.skills)?t.catalog.skills:[],skillSources:Array.isArray(t.catalog.skillSources)?t.catalog.skillSources:[],mcpServers:Array.isArray(t.catalog.mcpServers)?t.catalog.mcpServers:[]}:{tools:[],skills:[],skillSources:[],mcpServers:[]},o=r?.key;o&&e.pluginCatalogRequestByKey?.[o]===t.requestId&&(e.pluginCatalogByKey={...e.pluginCatalogByKey,[o]:{catalog:i,loading:!1,error:t.error||null,loaded:!0,at:Date.now()}}),r&&(clearTimeout(r.timer),delete e._pluginPending[t.requestId],r.resolve({catalog:i,error:t.error||null}));break}case"telemetry_settings":case"telemetry_settings_updated":{let n={enabled:t.enabled!==!1,retentionDays:t.retentionDays??3,flushIntervalMs:t.flushIntervalMs??1e3,maxQueueSize:t.maxQueueSize??5e3,rawExchangeMaxBytes:t.rawExchangeMaxBytes??524288,traceTextMaxBytes:t.traceTextMaxBytes??262144,error:t.error||null,loaded:!0,at:Date.now()},r=t.type==="telemetry_settings_updated"?"update":"load",i=t.requestId?{requestId:t.requestId,pending:e._telemetryPending?.[t.requestId]}:null,o=i?.pending;if(!o||o.agentId!==t.agentId||o.operation!==r)break;clearTimeout(o.timer),delete e._telemetryPending[i.requestId],e.telemetryRequestByAgent?.[o.agentId]===i.requestId&&(e.telemetrySettingsByAgent={...e.telemetrySettingsByAgent,[o.agentId]:n},e.currentAgent===o.agentId&&(e.telemetrySettings=n)),o.resolve(n);break}case"work_center_feature_settings":case"work_center_feature_settings_updated":{let n=t.type==="work_center_feature_settings_updated"?"update":"load",r=t.requestId?e._workCenterFeaturePending?.[t.requestId]:null;if(!r||r.agentId!==t.agentId||r.operation!==n)break;clearTimeout(r.timer),delete e._workCenterFeaturePending[t.requestId];let i={enabled:t.enabled===!0,source:t.source||"config",overridden:t.overridden===!0,error:t.error||null,persisted:t.persisted,effective:t.effective,rolledBack:t.rolledBack===!0,sessionTools:t.sessionTools||null,runtimeError:t.runtimeError||null,unsupported:t.unsupported===!0,loaded:!0};if(e.workCenterFeatureRequestByAgent?.[r.agentId]===t.requestId&&(e.workCenterFeatureSettingsByAgent={...e.workCenterFeatureSettingsByAgent,[r.agentId]:i}),i.error){let o=new Error(i.error);o.settings=i,r.reject(o)}else r.resolve(i);break}case"search_settings":case"search_settings_updated":{let n={backend:t.backend||"tavily",tavilyKeyConfigured:!!t.tavilyKeyConfigured,tavilyKeyMasked:t.tavilyKeyMasked||null,disableHtmlFallback:!!t.disableHtmlFallback,error:t.error||null,loaded:!0,at:Date.now()};e.searchSettings=n;let r=e._searchPending,i=t.type==="search_settings"?"load":"update";r&&r[i]&&(r[i](n),delete r[i]);break}case"tavily_usage":{let n=t.error?{error:t.error}:{plan:t.plan,used:t.used,limit:t.limit,paygoUsed:t.paygoUsed,paygoLimit:t.paygoLimit};e.tavilyUsage=n,e.tavilyUsageLoading=!1;let r=e._searchPending;r&&r.usage&&(r.usage(n),delete r.usage);break}case"yeaft_mcp_list_result":case"yeaft_mcp_add_result":case"yeaft_mcp_remove_result":case"yeaft_mcp_reload_result":case"yeaft_mcp_updated":{if(Array.isArray(t.servers)&&(e.yeaftMcpServers=t.servers),t.runtime&&typeof t.runtime=="object"&&(e.yeaftMcpRuntime={connected:!!t.runtime.connected,toolCount:t.runtime.toolCount||0,perServer:Array.isArray(t.runtime.perServer)?t.runtime.perServer:[]}),e.yeaftMcpLoading=!1,e.yeaftMcpError=t.error||null,t.requestId){let n=e._mcpPending;n&&n[t.requestId]&&(n[t.requestId](t),delete n[t.requestId])}break}case"conversation_mcp_update":t.conversationId&&t.servers&&(e.conversationMcpServers[t.conversationId]=t.servers),t.conversationId&&t.serverTools&&(e.conversationMcpServerTools[t.conversationId]=t.serverTools);break;case"btw_stream":e.appendBtwDelta(t.delta);break;case"btw_done":e.btwLoading=!1,t.btwSessionId&&(e.btwSessionId=t.btwSessionId);break;case"btw_error":{let n=e.btwMessages[e.btwMessages.length-1];n&&n.role==="assistant"&&(n.content="Error: "+t.error),e.btwLoading=!1;break}case"background_task_started":case"background_task_output":break;case"subagent_started":t.conversationId&&t.subagentId&&e.addSubagent(t.conversationId,{id:t.subagentId,slug:t.slug,type:t.subagentType,description:t.description,parentToolUseId:t.parentToolUseId});break;case"subagent_message":t.conversationId&&t.subagentId&&t.message&&e.appendSubagentMessage(t.conversationId,t.subagentId,t.message);break;case"subagent_completed":t.conversationId&&t.subagentId&&e.completeSubagent(t.conversationId,t.subagentId);break}}var pb,gb,fb,hb,Ju,pl,np=B(()=>{qt();qi();ss();Bs();hn();cl();io();Zu();no();pb=1,gb=5,fb=500,hb=512*1024,Ju=3e4,pl=new WeakMap});function ip(){return Object.values(rp).sort((t,s)=>t.order-s.order).map(t=>({teamId:t.id,team:t,roles:Object.values(Zt).filter(s=>s.group===t.id)}))}function op(e){let t=[];for(let s of Object.values(Zt)){t.push({roleId:s.id,roleName:s.name,roleTitle:s.title,actionId:null,actionName:null,searchText:`${s.name} ${s.fullName} ${s.title} ${s.titleEn}`.toLowerCase(),displayText:s.name,group:s.group});for(let n of s.actions)t.push({roleId:s.id,roleName:s.name,roleTitle:s.title,actionId:n.id,actionName:n.name,searchText:`${s.name} ${s.fullName} ${s.title} ${n.name} ${n.nameEn}`.toLowerCase(),displayText:`${s.name}\xB7${n.name}`,group:s.group})}if(e&&e.length>0){for(let s of e)if(t.push({roleId:s.id,roleName:s.name,roleTitle:s.title,actionId:null,actionName:null,searchText:`${s.name} ${s.fullName||""} ${s.title} ${s.titleEn||""}`.toLowerCase(),displayText:s.name,group:"custom"}),s.actions)for(let n of s.actions)t.push({roleId:s.id,roleName:s.name,roleTitle:s.title,actionId:n.id,actionName:n.name,searchText:`${s.name} ${s.fullName||""} ${s.title} ${n.name} ${n.nameEn||""}`.toLowerCase(),displayText:`${s.name}\xB7${n.name}`,group:"custom"})}return t}function In(e,t){let s=Zt[e.role];if(s){if(e.action){let n=s.actions.find(r=>r.id===e.action);return n?`${s.name}\xB7${n.name}`:s.name}return s.name}if(t){let n=t.find(r=>r.id===e.role);if(n){if(e.action){let r=n.actions?.find(i=>i.id===e.action);return r?`${n.name}\xB7${r.name}`:n.name}return n.name}}return e.role}function gl(e,t,s,n="zh-CN"){if(!e||e.length===0||!t||t.length===0)return null;let r=n==="zh-CN";if(!e.some(l=>!Zt[l.role]&&t.some(c=>c.id===l.role)))return null;if(e.length===1){let{role:l,action:c}=e[0],d=t.find(g=>g.id===l);if(!d)return null;let u;if(c&&d.actions){let g=d.actions.find(p=>p.id===c);g?s?(u=(r?g.messageTemplate:g.messageTemplateEn)||"",u+=s):u=(r?g.defaultMessage:g.defaultMessageEn)||"":u=((r?d.messagePrefix:d.messagePrefixEn)||"")+(s||"")}else u=((r?d.messagePrefix:d.messagePrefixEn)||"")+(s||"");return{effectivePrompt:u}}let o=[];for(let{role:l,action:c}of e){let d=t.find(g=>g.id===l),u=Zt[l];if(d)if(c){let g=d.actions?.find(p=>p.id===c);g&&o.push((r?g.messageTemplate:g.messageTemplateEn)||"")}else o.push((r?d.messagePrefix:d.messagePrefixEn)||"");else if(u)return null}return o.length===0?null:{effectivePrompt:o.join(`
3
+ ${g}`:g,p=!0;break}}if(!p){for(let f=c.length-1;f>=0;f--)if(c[f].type==="tool-use"&&!c[f].hasResult){c[f].hasResult=!0,c[f].toolResult=g;break}}}r.currentTool=null}else if(!i&&(typeof a=="string"&&a.trim()||Array.isArray(s.message?.attachments)&&s.message.attachments.length>0)){let c=s.message?.clientMessageId||s.clientMessageId||null,d={type:"user",content:a,clientMessageId:c},u=e.messagesMap[t]||[];if(u.some(p=>to(p,d))){if(c){for(let p=u.length-1;p>=0;p--)if(u[p].type==="user"&&u[p].clientMessageId===c){s.dbMessageId&&!u[p].dbMessageId&&(u[p].dbMessageId=s.dbMessageId),s.message?.id&&!u[p].messageId&&(u[p].id=s.message.id,u[p].messageId=s.message.id),s.ts&&!u[p].ts&&(u[p].ts=s.ts),Nu(e,u[p],n);break}}}else{let p=e.addMessageToConversation(t,{...s.message?.id?{id:s.message.id,messageId:s.message.id}:{},...s.ts?{ts:s.ts}:{},type:"user",content:a,...s.message?.attachments?{attachments:s.message.attachments}:{},...s.message?.quote?{quote:s.message.quote}:{},...c?{clientMessageId:c}:{}});Nu(e,p,n)}}}else if(s.type==="result"){delete e.processingConversations[t],Ve(e,t);let i=e.conversations.find(d=>d.id===t);i&&i.connecting&&(i.connecting=!1);let o=e._currentYeaftSessionId||null;if(e._currentYeaftTurnId){let d=Object.entries(e.activeVpTurns||{}).find(([,u])=>(u?.turnId===e._currentYeaftTurnId||!u?.turnId&&u===e.activeVpTurns[e._currentYeaftTurnId])&&(!e._currentYeaftAgentId||!u?.agentId||u.agentId===e._currentYeaftAgentId));if(d){let[u,g]=d,{[u]:p,...f}=e.activeVpTurns;!o&&g?.sessionId&&(o=g.sessionId),e.activeVpTurns=f}}if(o&&e._currentYeaftVpId&&e.vpStatuses){let d=e._currentYeaftTurnId||null,u={...e.vpStatuses||{}},g=!1;for(let[p,f]of Object.entries(u))!f||f.vpId!==e._currentYeaftVpId||e._currentYeaftAgentId&&f.agentId&&f.agentId!==e._currentYeaftAgentId||(f.sessionId||f.groupId||null)!==o||d&&f.turnId&&f.turnId!==d||(u[p]={...f,state:"idle",turnId:null,since:Date.now()},g=!0);g&&(e.vpStatuses=u)}o&&typeof e.clearYeaftSessionProcessingIfIdle=="function"&&e.clearYeaftSessionProcessingIfIdle(o,{agentId:e._currentYeaftAgentId||null}),e._closedAt||(e._closedAt={}),e._closedAt[t]=Date.now(),e._turnCompletedConvs||(e._turnCompletedConvs=new Set),e._turnCompletedConvs.add(t),r.currentTool=null,Ws(e,t,e._currentYeaftSessionId?{sessionId:e._currentYeaftSessionId,vpId:e._currentYeaftVpId,turnId:e._currentYeaftTurnId,threadId:e._currentYeaftThreadId}:null);let a=e.messagesMap[t]||[],l=s.result_text||"";if(typeof l=="string"&&l.trim()){let d=!1;for(let u=a.length-1;u>=0;u--){if(a[u].type==="assistant"){d=!0;break}if(a[u].type==="user")break}d||e.appendToAssistantMessageForConversation(t,l.trim())}e.finishStreamingForConversation(t),!(n&&e.promoteCompletedYeaftHistoryOutline?.(t,e._currentYeaftTurnId||null,n))&&o&&n&&e.invalidateYeaftHistoryOutline?.(o,n),e.sweepStaleStreamingForConversation(t),o&&n&&e.pruneConversationMessageRetention?.(t,o,n)}}var ju=B(()=>{Bs();no();sl()});function Sn(e){if(e==null)return e;try{return JSON.parse(JSON.stringify(e))}catch{return e}}function ro(e,t){if(!t)return e??null;if(Object.prototype.hasOwnProperty.call(t,"base"))return Sn(t.base)??null;if(Object.prototype.hasOwnProperty.call(t,"replacement"))return Sn(t.replacement)??null;let s=e&&typeof e=="object"&&!Array.isArray(e)?Sn(e):{};if(t.set&&typeof t.set=="object")for(let[n,r]of Object.entries(t.set))s[n]=Sn(r);if(t.body&&typeof t.body=="object"){let n=s.body&&typeof s.body=="object"&&!Array.isArray(s.body)?{...s.body}:{};for(let[i,o]of Object.entries(t.body))i==="messages"||i==="messagesFrom"||i==="messagesAppend"||i==="messagesKey"||(n[i]=Sn(o));let r=t.body.messagesKey==="messages"||t.body.messagesKey==="input"?t.body.messagesKey:Array.isArray(n.messages)||Object.prototype.hasOwnProperty.call(t.body,"messages")?"messages":"input";if(Array.isArray(t.body.messages))n[r]=Sn(t.body.messages)||[];else if(Array.isArray(t.body.messagesAppend)){let i=Array.isArray(n[r])?n[r]:[],o=Number.isFinite(Number(t.body.messagesFrom))?Number(t.body.messagesFrom):i.length;n[r]=i.slice(0,o).concat(Sn(t.body.messagesAppend)||[])}s.body=n}return s}function Uu(e,t){return!t||!Object.prototype.hasOwnProperty.call(t,"rawRequestDelta")?e??null:ro(e??null,t.rawRequestDelta)}function Yr(e){if(!e)return 0;let t=typeof e=="string"?e:String(e),s=0,n=0;for(let r of t){let i=r.codePointAt(0)||0;i>=19968&&i<=40959||i>=12352&&i<=12447||i>=12448&&i<=12543||i>=44032&&i<=55215?s+=1:n+=1}return Math.ceil(s+n/4)}function cb(e){let t=[],s=[];if(!e)return{messageText:t,toolText:s};let n=e.content;if(typeof n=="string")e.role==="tool"?s.push(n):t.push(n);else if(Array.isArray(n))for(let r of n){if(!r||typeof r!="object")continue;let i=r.type;if(i==="text"&&typeof r.text=="string")t.push(r.text);else if(i==="tool_use"){if(s.push(String(r.name||"")),r.input!==void 0)try{s.push(JSON.stringify(r.input))}catch{}}else if(i==="tool_result"){let o=r.content;if(typeof o=="string")s.push(o);else if(Array.isArray(o)){for(let a of o)if(a)if(typeof a=="string")s.push(a);else if(typeof a=="object"&&typeof a.text=="string")s.push(a.text);else try{s.push(JSON.stringify(a))}catch{}}else if(o!==void 0)try{s.push(JSON.stringify(o))}catch{}}else try{t.push(JSON.stringify(r))}catch{}}if(Array.isArray(e.toolCalls)){for(let r of e.toolCalls)if(r&&(s.push(String(r.name||"")),r.input!==void 0))try{s.push(JSON.stringify(r.input))}catch{}}return{messageText:t,toolText:s}}function Ku(e){let t=0,s=0;if(e&&Array.isArray(e.messages))for(let i of e.messages){let{messageText:o,toolText:a}=cb(i);for(let l of o)t+=Yr(l);for(let l of a)s+=Yr(l)}let n=0,r=0;if(e&&typeof e.response=="string"&&(n+=Yr(e.response)),e&&Array.isArray(e.toolCalls)){for(let i of e.toolCalls)if(i&&(r+=Yr(String(i.name||"")),i.input!==void 0))try{r+=Yr(JSON.stringify(i.input))}catch{}}return{inputMessageTokens:t,inputToolTokens:s,outputMessageTokens:n,outputToolTokens:r,inputTotalEstimated:t+s,outputTotalEstimated:n+r}}function ll(e,t,s){let n=Math.max(0,Math.floor(Number(e)||0)),r=Math.max(0,Number(t)||0),i=Math.max(0,Number(s)||0),o=r+i;if(n===0)return{message:0,tool:0};if(o===0)return{message:n,tool:0};let a=Math.round(r/o*n),l=Math.min(n,Math.max(0,a));return{message:l,tool:n-l}}function zu(e,t){let s=Math.max(0,Math.floor(Number(e)||0)),n=t&&typeof t=="object"?t:{},r=[["systemPrompt",Math.max(0,Number(n.systemPromptTokens)||0)],["historyMessages",Math.max(0,Number(n.historyMessageTokens)||0)],["tools",Math.max(0,Number(n.toolDefinitionTokens)||0)],["currentTurn",Math.max(0,Number(n.currentTurnTokens)||0)]],i=r.reduce((c,[,d])=>c+d,0),o={systemPrompt:0,historyMessages:0,tools:0,currentTurn:0};if(s===0)return o;if(i===0)return o.currentTurn=s,o;let a=r.map(([c,d],u)=>{let g=d/i*s,p=Math.floor(g);return o[c]=p,{key:c,index:u,fraction:g-p}}),l=s-Object.values(o).reduce((c,d)=>c+d,0);a.sort((c,d)=>d.fraction-c.fraction||c.index-d.index);for(let c=0;c<l;c++)o[a[c%a.length].key]+=1;return o}function Yu(e){if(e==null||e==="")return"";let t;if(typeof e=="number")t=e;else if(typeof e=="string"){let o=Date.parse(e);if(Number.isNaN(o)){let a=Number(e);if(!Number.isFinite(a))return"";t=a}else t=o}else return"";if(!Number.isFinite(t))return"";let s=new Date(t),n=String(s.getHours()).padStart(2,"0"),r=String(s.getMinutes()).padStart(2,"0"),i=String(s.getSeconds()).padStart(2,"0");return`${n}:${r}:${i}`}var cl=B(()=>{});function Is(e,t){return!e||!t?"":`${e}${t}`}function Gr(e){let t=typeof e=="string"?e:String(e||"");if(!t)return{agentId:null,sessionId:null};let s=t.indexOf("");if(s<0)return{agentId:null,sessionId:t};let n=t.slice(0,s)||null,r=t.slice(s+1)||null;return{agentId:n,sessionId:r}}function dl(e){return e?`${e}`:""}function ul(e,t){return!e||!t?"":`${e}${t}`}var io=B(()=>{});function db(e,t){if(!e||!!!t?.online)return!1;let n=!e.online,r=e.online&&e.version!=null&&t.version!=null&&e.version!==t.version;return n||r}function Gu(e,t){let s=e.lastViewedConversation||localStorage.getItem("lastViewedConversation");if(!s)return!1;let n=e.conversations.find(i=>i.id===s);if(!n)return!1;let r=t?.agentId||e.currentAgent;return t&&(e.currentAgent=t.agentId,e.currentAgentInfo=t.agentInfo,e.sendWsMessage({type:"select_agent",agentId:t.agentId,silent:!0})),e.activeConversations=[s],e.currentWorkDir=n.workDir,e.messagesMap[s]=[],e.sendWsMessage({type:"select_conversation",conversationId:s}),e.requestChatHistory?.(s,{mode:"recent",turns:5}),e.sendWsMessage({type:"refresh_conversation",conversationId:s}),!0}function Qu(e,t){let s=Array.isArray(e.agents)?e.agents:[],n=Array.isArray(t.agents)?t.agents:[],r=e._hasHandledAgentList===!0,i=new Set(s.filter(d=>d?.id&&d.online).map(d=>d.id)),o=new Set(n.filter(d=>d?.id&&d.online).map(d=>d.id));for(let[d,u]of r?e._sessionCrudPending?.entries?.()||[]:[])!u?.agentId||!i.has(u.agentId)||o.has(u.agentId)||(u.resolve?.({ok:!1,requestId:d,error:{code:"agent_offline",message:"Agent disconnected"}}),e._sessionCrudPending.delete(d));let a=e.currentAgent||null,l=!!(a&&s.some(d=>d&&d.id===a&&d.online));e.agents=n,e._hasHandledAgentList=!0;for(let[d,u]of Object.entries(e.agentOperations||{})){let g=n.find(p=>p.id===d);for(let p of["restart","upgrade"]){let f=u?.[p];if(!f?.pending||!f.acknowledged)continue;if(!g?.online){f.sawOffline||(e.agentOperations={...e.agentOperations,[d]:{...e.agentOperations[d]||{},[p]:{...f,sawOffline:!0}}});continue}let m=p==="upgrade"&&f.oldVersion&&g.version!==f.oldVersion;!f.sawOffline&&!m||e.finishAgentOperation?.(d,p)}}let c=e.currentAgent||null;if(c){let d=e._yeaftAgentSeen&&e._yeaftAgentSeen.id===c?e._yeaftAgentSeen:null,u=n.find(p=>p.id===c)||null;(e.currentView==="yeaft"||e.workCenterOpen&&e.workCenterAgentId===c)&&db(d,u)&&(e._yeaftReconnectCatchUpPending=!0),u?e._yeaftAgentSeen={id:c,online:!!u.online,version:u.version!=null?u.version:null}:d?d.online&&(e._yeaftAgentSeen={id:c,online:!1,version:d.version}):e._yeaftAgentSeen={id:c,online:!1,version:null}}{let d=new Set(n.map(u=>u.id));for(let u of n)e.proxyPorts[u.id]=u.proxyPorts||[],u.yeaftStatus&&typeof e.cacheYeaftAgentStatus=="function"&&e.cacheYeaftAgentStatus(u.id,u.yeaftStatus);for(let u of Object.keys(e.proxyPorts))d.has(u)||delete e.proxyPorts[u]}if(e.currentAgent){let d=n.find(u=>u.id===e.currentAgent);d&&(e.currentAgentInfo=d)}if(e.currentView==="yeaft"&&!e.currentAgent){let d=n.find(u=>u.online);d&&(e.currentAgent=d.id,e.currentAgentInfo=d)}if(e.currentView==="yeaft"&&typeof e.loadOpenedYeaftSessionsForConnectedAgents=="function"){let d=n.filter(u=>u&&u.online&&u.id).map(u=>u.id);e.loadOpenedYeaftSessionsForConnectedAgents(d)}{let d=[],u=new Set;for(let p of n)for(let f of p.conversations||[])u.has(f.id)||(u.add(f.id),d.push({...f,type:f.type,agentId:p.id,agentName:p.name}),f.title&&(f.customTitle&&(e.customConversationTitles[f.id]=f.title),e.conversationTitles[f.id]||(e.conversationTitles[f.id]=f.title)));for(let p of d){p.agentOnline=!0;let f=e.conversations.find(m=>m.id===p.id);if(f)f.claudeSessionId=p.claudeSessionId||f.claudeSessionId,f.processing=p.processing,f.userId=p.userId,f.username=p.username,f.agentId=p.agentId,f.agentName=p.agentName,f.agentOnline=!0,p.type&&(f.type=p.type),p.name!==void 0&&(f.name=p.name);else{let m=e._recentlyDeletedSessions?.[p.id];if(m&&Date.now()-m<15e3)continue;e.conversations.push(p)}p.pinned&&!e.pinnedSessions.includes(p.id)&&e.pinnedSessions.push(p.id)}let g=new Set(n.map(p=>p.id));e.conversations=e.conversations.filter(p=>{if(u.has(p.id)||e.activeConversations.includes(p.id))return!0;if(p.agentId&&g.has(p.agentId)){let f=e._recentlyDeletedSessions?.[p.id];return f&&Date.now()-f<15e3||(delete e.messagesMap[p.id],delete e.processingConversations[p.id],Ve(e,p.id),delete e.executionStatusMap[p.id]),!1}return p.agentId&&!g.has(p.agentId)&&(p.agentOnline=!1),!0});for(let p of d)if(p.processing&&!yn(e,p.id)&&!e._turnCompletedConvs?.has(p.id))e.processingConversations[p.id]=!0;else if(e.processingConversations[p.id]){delete e.processingConversations[p.id],Ve(e,p.id);let f=e.executionStatusMap[p.id];f&&(f.currentTool=null),e.finishStreamingForConversation(p.id)}for(let p of Object.keys(e.processingConversations))if(!u.has(p)){if(p.startsWith("yeaft-"))continue;delete e.processingConversations[p],Ve(e,p);let f=e.executionStatusMap[p];f&&(f.currentTool=null),e.finishStreamingForConversation(p)}}if(localStorage.setItem("pinned-sessions",JSON.stringify(e.pinnedSessions)),e._closedAt){let d=Date.now();for(let u of Object.keys(e._closedAt))d-e._closedAt[u]>3e4&&(delete e._closedAt[u],e._turnCompletedConvs?.delete(u))}if(e.currentAgent){let d=n.find(u=>u.id===e.currentAgent&&u.online);if(d){let u=!!e._yeaftReconnectCatchUpPending,p=u||r&&!l;if(e.currentAgentInfo=d,p&&(e._offlineConversationRestoreKey=null,e.sendWsMessage({type:"select_agent",agentId:e.currentAgent,silent:!0})),p&&e.workCenterOpen&&e.workCenterAgentId===e.currentAgent&&typeof e.listWorkItems=="function"){let f=e._workCenterListFiltersByAgent?.[e.workCenterAgentId]||{};e.listWorkItems(e.workCenterAgentId,f).catch(()=>{})}if(e._yeaftReconnectCatchUpPending=!1,e.currentView==="yeaft"&&typeof e.requestYeaftSessionBootstrap=="function"){let f=u||!e.yeaftSessionReady||!e.yeaftModel||!e.yeaftStatus;(f||u)&&e.requestYeaftSessionBootstrap({forceSessionReady:f,catchUpHistory:u})}if(!p)return;if(e.currentConversation){let f=e.conversations.find(b=>b.id===e.currentConversation);e.sendWsMessage({type:"select_conversation",conversationId:e.currentConversation});let m=e.messagesMap[e.currentConversation]||[],v=vn(m);v!=null?e.requestChatHistory?.(e.currentConversation,{mode:"delta",afterMessageId:v}):e.requestChatHistory?.(e.currentConversation,{mode:"recent",turns:5}),e.sendWsMessage({type:"refresh_conversation",conversationId:e.currentConversation})}else e.recoveryDismissed||Gu(e);return}else{let u=`${e.currentAgent||""}:${e.currentConversation||""}`;e.currentConversation&&(!r||l||e._offlineConversationRestoreKey!==u)&&(e._offlineConversationRestoreKey=u,e.sendWsMessage({type:"select_conversation",conversationId:e.currentConversation}));return}}if(!e.currentConversation&&!e.currentAgent&&!e.recoveryDismissed){let d=e.lastViewedConversation||localStorage.getItem("lastViewedConversation"),u=e.lastUsedAgent;if(d){let g=e.conversations.find(p=>p.id===d);if(g){let p=n.find(f=>f.id===g.agentId&&f.online);if(p){Gu(e,{agentId:g.agentId,agentInfo:p});return}}}u&&(e.agents.find(p=>p.id===u&&p.online)?e.selectAgent(u):e.checkPendingRecovery())}}function Xu(e,t){let s=e.pendingAgentSelection||null;if(s){if(!(typeof t.requestId=="string"&&t.requestId?t.requestId===s.requestId:t.agentId===s.agentId))return!1;if(e.pendingAgentSelection=null,t.ok===!1)return e.agentSwitching=!1,!1}else{if(t.requestId)return!1;if(e.currentAgent&&t.agentId!==e.currentAgent)return!1}e.agentSwitching=!1;let n=e.currentAgent===t.agentId,r={id:t.agentId,name:t.agentName,workDir:t.workDir,capabilities:t.capabilities||["terminal","file_editor","background_tasks"],...t.capabilityMetadataProvided===!0?{capabilityMetadataProvided:!0}:{},version:t.version||null};if(typeof e.activateYeaftAgent=="function"?e.activateYeaftAgent(t.agentId,r):(e.currentAgent=t.agentId,e.currentAgentInfo=r),Array.isArray(t.slashCommands)){let u=[...new Set(t.slashCommands)];e.slashCommandsMap[`agent:${t.agentId}`]=u}t.slashCommandDescriptions&&(e.slashCommandDescriptions={...e.slashCommandDescriptions,...t.slashCommandDescriptions});let i=t.conversations||[],o=new Set,a=i.filter(u=>o.has(u.id)?!1:(o.add(u.id),!0)).map(u=>({...u,agentId:t.agentId,agentName:t.agentName}));if(n&&e.currentConversation){let u=i.find(g=>g.id===e.currentConversation);u&&!a.find(g=>g.id===u.id)&&a.push({...u,agentId:t.agentId,agentName:t.agentName})}let l=new Set(a.map(u=>u.id)),c=e.conversations.filter(u=>!l.has(u.id));e.conversations=[...c,...a];for(let u of i)u.title&&(u.customTitle&&(e.customConversationTitles[u.id]=u.title),e.conversationTitles[u.id]||(e.conversationTitles[u.id]=u.title));let d=new Set(i.map(u=>u.id));for(let u of i)if(u.processing&&!yn(e,u.id)&&!e._turnCompletedConvs?.has(u.id))e.processingConversations[u.id]=!0;else if(e.processingConversations[u.id]){delete e.processingConversations[u.id],Ve(e,u.id);let g=e.executionStatusMap[u.id];g&&(g.currentTool=null),e.finishStreamingForConversation(u.id)}for(let u of Object.keys(e.processingConversations))if(!d.has(u)){if(u.startsWith("yeaft-"))continue;if(!c.some(p=>p.id===u)){delete e.processingConversations[u],Ve(e,u);let p=e.executionStatusMap[u];p&&(p.currentTool=null),e.finishStreamingForConversation(u)}}if(e.currentView!=="yeaft"){if(n&&e.currentConversation){let u=e.conversations.find(g=>g.id===e.currentConversation);e.currentWorkDir=u?.workDir||e.currentWorkDir||t.workDir,ns(e),e.sendWsMessage({type:"select_conversation",conversationId:e.currentConversation})}else{e.activeConversations=[],e.currentWorkDir=t.workDir;let u=e.lastViewedConversation||localStorage.getItem("lastViewedConversation");u&&e.conversations.find(g=>g.id===u)&&(e.autoRestoreConversation(u),e.pendingRecovery=null)}$d(e)}return!0}var Zu=B(()=>{Bs();hn();Br()});function ub(e={}){return{providers:e.providers||[],primaryModel:e.primaryModel||null,fastModel:e.fastModel||null,language:e.language||"en"}}function Qn(e){pl.delete(e)}function mb(e,t){let s=pl.get(e);s||(s=new Map,pl.set(e,s));let n=typeof t?.agentId=="string"?t.agentId:"",r=typeof t?.requestId=="string"?t.requestId:"",i=Number(t?.chunkIndex),o=Number(t?.chunkCount),a=typeof t?.data=="string"?t.data:null,l=e.yeaftDebugPanel?.agentId||null,c=e._yeaftDebugHistoryPending?.payload,d=c?.requestId||e._yeaftDebugHistoryLatestDetailRequestId||e._yeaftDebugHistoryLatestListRequestId;if(!n||!r||l&&n!==l||c&&n!==c.agentId||r!==d||!Number.isSafeInteger(i)||!Number.isSafeInteger(o)||o<=1||i<0||i>=o||a==null||new TextEncoder().encode(a).byteLength>hb)return null;let u=Date.now();for(let[m,v]of s)v.expiresAt<=u&&s.delete(m);let g=`${n}\0${r}`,p=s.get(g);if(!p){if(i!==0)return null;p={nextIndex:0,chunkCount:o,parts:[],bytes:0,expiresAt:u+Ju},s.set(g,p)}let f=new TextEncoder().encode(a).byteLength;if(p.chunkCount!==o||i!==p.nextIndex)return s.delete(g),null;if(p.parts.push(a),p.bytes+=f,p.nextIndex+=1,p.expiresAt=u+Ju,e.refreshYeaftDebugHistoryTimeout?.(r),p.nextIndex!==p.chunkCount)return null;s.delete(g);try{let m=JSON.parse(p.parts.join(""));return m?.type==="yeaft_debug_history"&&m.requestId===r?{...m,agentId:n}:null}catch{return null}}function ep(){return window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore()}function vb(e,t){let s=t.agentId||null,n=Array.isArray(e.yeaftSessionHydrateSlices)?e.yeaftSessionHydrateSlices.filter(r=>r.agentId!==s):[];e.yeaftSessionHydrateSlices=[...n,{agentId:s,sessions:Array.isArray(t.sessions)?t.sessions:[]}]}function yb(e){let t=ep(),s=null;try{s=localStorage.getItem("lastViewedYeaftSession")||null}catch{}let n=Gr(s),r=e.yeaftActiveSessionFilter||t?.activeSessionId||null;if(r){let i=t?.activeSessionKey?t.sessions?.[t.activeSessionKey]:null;return i?.id===r&&i.agentId?{sessionId:r,agentId:i.agentId}:n.sessionId===r&&n.agentId?n:{sessionId:r,agentId:null}}return n}function tp(e){let t=ep(),s=yb(e);typeof t?.beginInventoryCommit=="function"?t.beginInventoryCommit(s.sessionId,s.agentId):typeof t?.resetInventory=="function"&&t.resetInventory();let n=Array.isArray(e.yeaftSessionHydrateSlices)?e.yeaftSessionHydrateSlices:[],r=s.agentId?[...n.filter(i=>i.agentId===s.agentId),...n.filter(i=>i.agentId!==s.agentId)]:n;r.length===0&&t?.applySnapshot?.([],null),r.forEach((i,o)=>{t?.applySnapshot?.(i.sessions||[],i.agentId||null,{deferActivation:o<r.length-1})}),e.yeaftSessionHydrateSlices=[]}function bb(e){let t=e.yeaftSessionHydrateRequestId||null;e.yeaftSessionInventoryCompleteSupported!==!1||!t||(clearTimeout(e._legacyYeaftSessionHydrateTimer),e._legacyYeaftSessionHydrateTimer=setTimeout(()=>{e.yeaftSessionHydrateRequestId===t&&(e._legacyYeaftSessionHydrateTimer=null,tp(e),e._hasHandledYeaftSessionHydrate=!0,e.yeaftSessionHydrateRequestId=null,e.yeaftSessionHydrateError=null,e._yeaftSessionInventorySocketQuarantined=!0)},fb))}function wb(e,t={}){let s=e||{systemPrompt:"",messages:[],rawRequest:null},n={systemPrompt:s.systemPrompt||"",messages:Array.isArray(s.messages)?[...s.messages]:[],rawRequest:s.rawRequest??null};if(t?.base){let r={systemPrompt:t.systemPrompt||"",messages:Array.isArray(t.messages)?t.messages:[],rawRequest:null};return Object.prototype.hasOwnProperty.call(t,"rawRequestDelta")&&(r.rawRequest=ro(null,t.rawRequestDelta)),r}if(typeof t?.systemPrompt=="string"&&(n.systemPrompt=t.systemPrompt),Array.isArray(t?.messages))n.messages=t.messages;else if(Array.isArray(t?.messagesAppend)){let r=Number.isFinite(Number(t.messagesFrom))?Number(t.messagesFrom):n.messages.length;n.messages=n.messages.slice(0,r).concat(t.messagesAppend)}return Object.prototype.hasOwnProperty.call(t||{},"rawRequestDelta")&&(n.rawRequest=ro(n.rawRequest,t.rawRequestDelta)),n}function kb(e=[]){let t=new Map;return e.map(s=>{if(!s||!s.requestDelta)return s;let n=s.turnId||"__unknown__",r=t.get(n)||s.requestBase||null,i=r?.rawRequest??null,o=wb(r,s.requestDelta);return t.set(n,o),{...s,systemPrompt:typeof s.systemPrompt=="string"&&s.systemPrompt?s.systemPrompt:o.systemPrompt,messages:Array.isArray(s.messages)&&s.messages.length>0?s.messages:o.messages,rawRequest:s.rawRequest===void 0?o.rawRequest:s.rawRequest,rawRequestBase:i}})}function sp(e,t){let s=Ge();if(t?.type==="yeaft_debug_history_chunk"){let n=mb(e,t);if(!n)return;t=n}switch(e._lastPongAt=Date.now(),t.type){case"work_center_response":{let n=t.requestId?e.workCenterPending[t.requestId]:null;if(!n)break;clearTimeout(n.timer),delete e.workCenterPending[t.requestId],t.ok?n.resolve(t.data):n.reject(new Error(t.error||"Work Center request failed"));break}case"work_center_event":e.applyWorkCenterEvent(t.agentId,t.event);break;case"client_hello_ack":e.workbenchRouteProtocolSupported=t.workbenchRouteProtocol===1,e.browserRuntimeProtocolSupported=t.browserRuntimeProtocol===1,e.browserRuntimeSetupProtocolSupported=t.browserRuntimeSetupProtocol===1,e.browserRuntimeServerEnabled=t.browserRuntimeEnabled===!0,window.dispatchEvent(new CustomEvent("browser-runtime-message",{detail:t}));break;case"auth_result":if(t.success){if(e.authenticated=!0,t.sessionKey&&(e.sessionKey=Gt(t.sessionKey),s.setSessionKey(t.sessionKey)),t.acceptPlaintext===!0&&(e.serverEncryptionRequired=!1),e.yeaftSessionInventoryCompleteSupported=t.yeaftSessionInventoryComplete===!0,e.workbenchRouteProtocolSupported=!1,e.browserRuntimeProtocolSupported=!1,e.browserRuntimeSetupProtocolSupported=!1,e.browserRuntimeServerEnabled=t.browserRuntimeEnabled===!0,window.dispatchEvent(new CustomEvent("browser-runtime-message",{detail:t})),e.yeaftSessionHydrateSlices=[],e._hasHandledYeaftSessionHydrate=!1,e.yeaftSessionHydrateError=null,t.role&&(s.role=t.role),typeof e.requestYeaftSessionInventory=="function")e.requestYeaftSessionInventory();else{let n=e.conversations.map(r=>r.id).filter(Boolean);e.sendWsMessage({type:"get_agents",conversationIds:n.length>0?n:void 0})}e.checkPendingRecovery()}else e.addMessage({type:"error",content:t.error||Oe("login.error.loginFailed")}),s.handleAuthFailure?.(void 0,t._wsAuthToken,t._wsAuthGeneration);break;case"agent_list":Qu(e,t);break;case"yeaft_session_hydrate":{if(e.yeaftSessionInventoryCompleteSupported===!0&&(!t.requestId||t.requestId!==e.yeaftSessionHydrateRequestId)||e.yeaftSessionInventoryCompleteSupported!==!0&&!e.yeaftSessionHydrateRequestId||t.requestId&&e.yeaftSessionHydrateRequestId&&t.requestId!==e.yeaftSessionHydrateRequestId)break;vb(e,t),e.yeaftSessionInventoryCompleteSupported!==!0&&bb(e);break}case"yeaft_session_hydrate_complete":if(e.yeaftSessionInventoryCompleteSupported===!0&&(!t.requestId||t.requestId!==e.yeaftSessionHydrateRequestId)||e.yeaftSessionHydrateRequestId&&!t.requestId||t.requestId&&e.yeaftSessionHydrateRequestId&&t.requestId!==e.yeaftSessionHydrateRequestId)break;clearTimeout(e._legacyYeaftSessionHydrateTimer),e._legacyYeaftSessionHydrateTimer=null,t.ok!==!1?tp(e):e.yeaftSessionHydrateSlices=[],e.yeaftSessionHydrateRequestId=null,e._hasHandledYeaftSessionHydrate=t.ok!==!1,e.yeaftSessionHydrateError=t.ok===!1?t.error||"session_inventory_failed":null;break;case"session_catalog_snapshot":e.applySessionCatalogSnapshot(t.catalog,t.projectsAuthoritative===!0?t.projects:null,t.hiddenCatalog);break;case"session_ui_metadata_updated":e.finishSessionCatalogMutation?.(t);break;case"session_catalog_reorder_result":e.finishSessionCatalogMutation?.(t);break;case"agent_selected":if(!Xu(e,t))break;e.workCenterOpen&&e.workCenterAgentId&&e.listWorkItems(e.workCenterAgentId).catch(()=>{});break;case"conversation_created":Eu(e,t);break;case"conversation_resumed":Du(e,t);break;case"conversation_selected":if(e.currentConversation===t.conversationId)return;e.activeConversations=[t.conversationId];{let n=e.conversations.find(r=>r.id===t.conversationId);n&&(e.currentWorkDir=n.workDir)}e.messagesMap[t.conversationId]=[],e.saveOpenSessions();break;case"conversation_settings_updated":{let n=e.conversations.find(i=>i.id===t.conversationId);n&&t.disallowedTools!==void 0&&(n.disallowedTools=t.disallowedTools);let r=e.conversationMcpServers[t.conversationId];if(r&&t.disallowedTools){let i=new Set(t.disallowedTools),o=e.conversationMcpServerTools[t.conversationId]||{};for(let a of r){let l=o[a.name];l&&l.length>0?a.enabled=!l.some(c=>i.has(c)):a.enabled=!i.has(`mcp__${a.name}`)}}t.needRestart&&n&&(n.needRestart=!0);break}case"sync_messages_result":qu(e,t);break;case"conversation_deleted":ol(e,t);break;case"conversation_delete_result":t.ok&&ol(e,t);break;case"turn_completed":$u(e,t);break;case"conversation_closed":Lu(e,t);break;case"claude_output":e.handleAssistantOutputFrame(t.conversationId,t.data);break;case"yeaft_output":case"yeaft_session_output":case"session_output":e.handleYeaftOutput(t);break;case"yeaft_asset_ready":{let n=t.conversationId||e.yeaftConversationIdsByAgent?.[t.agentId]||e.yeaftConversationId;if(!n||!t.image)break;e.messagesMap[n]||(e.messagesMap[n]=[]),e.messagesMap[n].some(i=>i?.type==="chat-image"&&i.assetId===t.image.assetId&&i.sessionId===t.sessionId&&i.turnId===t.turnId)||e.addMessageToConversation(n,{type:"chat-image",...t.image,sessionId:t.sessionId||null,vpId:t.vpId||null,speakerVpId:t.vpId||null,turnId:t.turnId||null,threadId:t.threadId||null});break}case"yeaft_history_chunk":Bu(e,t);break;case"yeaft_history_outline":e.handleYeaftHistoryOutline(t);break;case"yeaft_history_search_result":e.handleYeaftHistorySearchResult(t);break;case"yeaft_history_window":{let n=e.pendingYeaftHistoryWindow?.(t);if(!n||(n.pending?.prefetch===!0&&(t.prefetch=!0),e.pendingYeaftHistoryWindow?.(t)?.pending!==n.pending))break;let r=t.error?null:Vu(e,t);e.handleYeaftHistoryWindow(t,r);break}case"yeaft_tool_stats":{e._fetchYeaftToolStatsTimer&&(clearTimeout(e._fetchYeaftToolStatsTimer),e._fetchYeaftToolStatsTimer=null);let n=t?.snapshot,r=n&&typeof n=="object"&&!Array.isArray(n)?n:{};e.yeaftToolStats={snapshot:r,registered:Array.isArray(t?.registered)?t.registered:[],unused:Array.isArray(t?.unused)?t.unused:[],error:typeof t?.error=="string"?t.error:null,notice:typeof t?.notice=="string"?t.notice:null,fetchedAt:Date.now()},e.yeaftToolStatsLoading=!1;break}case"yeaft_debug_history":{let n=e.yeaftDebugPanel?.agentId||null;if(n&&t?.agentId&&t.agentId!==n)break;let r=typeof t?.requestId=="string"?t.requestId:"",i=typeof t?.detailTurnId=="string"&&t.detailTurnId,o=i?e._yeaftDebugHistoryLatestDetailRequestId:e._yeaftDebugHistoryLatestListRequestId;if(o&&r!==o||!o&&r)break;let a=e._yeaftDebugHistoryPending?.payload;if(a&&(a.requestId!==r||a.agentId!==t.agentId||t.sessionId&&a.sessionId!==t.sessionId))break;e._yeaftDebugHistoryPending=null,Qn(e),e._fetchYeaftDebugHistoryTimer&&(clearTimeout(e._fetchYeaftDebugHistoryTimer),e._fetchYeaftDebugHistoryTimer=null),e._yeaftDebugHistoryInFlightKey=null;let l=Array.isArray(t?.turns)?t.turns:[],c=t?.search?gb:pb,d=i?l:l.slice(-c),u=new Set(d.map(x=>x?.turnId).filter(Boolean)),g=kb(Array.isArray(t?.loops)?t.loops:[]),p=i?g:g.filter(x=>!x?.turnId||u.has(x.turnId)),f=Array.isArray(t?.dreamEvents)?t.dreamEvents:[];e.yeaftDebugHistoryHasMore=!!t?.hasMore||!i&&l.length>d.length,!t?.detailTurnId&&Number.isFinite(t?.limit)&&t.limit>0&&(e.yeaftDebugHistoryLimit=Math.min(c,t.limit)),(!e.yeaftDebugTurnsById||typeof e.yeaftDebugTurnsById!="object")&&(e.yeaftDebugTurnsById={}),Array.isArray(e.yeaftDebugLoops)||(e.yeaftDebugLoops=[]),Array.isArray(e.yeaftDebugTurnOrder)||(e.yeaftDebugTurnOrder=[]);let m=i?{...e.yeaftDebugTurnsById}:{};for(let x of d){let Y=x?.turnId;if(!Y)continue;let L=m[Y];if(L){let U=x?.detailsLoaded?{...L,...x}:{...x,...L};U.memoryLoaded==null&&L.memoryLoaded!=null&&(U.memoryLoaded=L.memoryLoaded),U.memoryAdjust==null&&L.memoryAdjust!=null&&(U.memoryAdjust=L.memoryAdjust),m[Y]=U}else m[Y]=x}e.yeaftDebugTurnsById=m;let v=x=>x?.loopInstanceId||`${x?.turnId||""}#${x?.loopNumber||0}`,b=e.yeaftDebugLoops,h=new Map;for(let x of b)x&&h.set(v(x),x);let k=new Set,S=[];for(let x of p){if(!x)continue;let Y=v(x);k.add(Y);let L=h.get(Y);S.push(i?{...L||{},...x}:L||x)}if(i)for(let x of b)!x||k.has(v(x))||S.push(x);e.yeaftDebugLoops=S;let y=new Set,w=[],P=x=>{!x||y.has(x)||(y.add(x),w.push(x))};if(i){for(let x of e.yeaftDebugTurnOrder)P(x);for(let x of d)P(x?.turnId)}else for(let x of d)P(x?.turnId);e.yeaftDebugTurnOrder=i?w:w.slice(-c);for(let x of f){if(!x)continue;let Y=null,L=x.sessionId||x.groupId;typeof x.target=="string"&&x.target.includes("/")?Y=x.target:typeof L=="string"&&L?Y=`group/${L}`:Y="*",typeof e._appendDreamEvent=="function"&&e._appendDreamEvent(Y,x),x.type==="dream_progress"&&typeof e.handleYeaftOutput=="function"&&e.handleYeaftOutput({event:x})}e.yeaftDebugHistoryLoading=!1,e.yeaftDebugHistoryError=typeof t?.error=="string"?t.error:null,e.yeaftDebugHistoryProjection=t?.projection&&typeof t.projection=="object"?t.projection:null,e.yeaftDebugHistoryFetchedAt=Date.now(),e._yeaftDebugDetailDirty&&!e.yeaftDebugHistoryError&&e.scheduleYeaftDebugDetailRefresh?.({agentId:e.yeaftDebugPanel?.agentId,sessionId:e.yeaftDebugPanel?.sessionId},e.yeaftDebugPanel?.turnId),i&&e.yeaftDebugPanel&&e.yeaftDebugPanel.turnId===t.detailTurnId&&(e.yeaftDebugPanel={...e.yeaftDebugPanel,status:e.yeaftDebugHistoryError?"error":"ready",error:e.yeaftDebugHistoryError});break}case"chat_image":t.conversationId&&t.fileId&&e.addMessageToConversation(t.conversationId,{type:"chat-image",fileId:t.fileId,previewToken:t.previewToken,mimeType:t.mimeType});break;case"error":{let n=t.conversationId||e.currentConversation,r=["Permission denied","Agent not found","No conversation selected","Agent is still syncing","No agent available","Agent access denied"].some(c=>t.message?.includes(c));if((t.message?.includes("Agent is still syncing")||t.message?.includes("Agent not found"))&&ns(e),["No conversation selected","Agent is still syncing","No agent available"].some(c=>t.message?.includes(c))&&n&&(delete e.processingConversations[n],Ve(e,n),e.finishStreamingForConversation(n)),r&&n){let c=e.messagesMap[n];if(c&&c.length>0)for(let d=c.length-1;d>=0&&d>=c.length-5;d--){let u=c[d];if(u&&u.type==="error"&&u._sysErrBaseContent!==void 0){if(u._sysErrBaseContent===t.message&&Date.now()-(u._sysErrFirstAt||0)<=3e3){u._sysErrCount=(u._sysErrCount||1)+1,u.content=`${u._sysErrBaseContent} (\xD7${u._sysErrCount})`,u._sysErrRemoveTimer&&(clearTimeout(u._sysErrRemoveTimer),u._sysErrRemoveTimer=setTimeout(()=>{let g=e.messagesMap[n];if(g){let p=g.findIndex(f=>f.id===u.id);p>=0&&g.splice(p,1)}},5e3));return}break}}}let o=Date.now().toString()+Math.random().toString(36).substr(2,9),a={type:"error",content:t.message,transient:r,dbMessageId:r?"err_"+o:void 0};r&&(a._sysErrBaseContent=t.message,a._sysErrCount=1,a._sysErrFirstAt=Date.now()),e.addMessageToConversation(n,a);let l=null;if(r&&n){let c=e.messagesMap[n];c&&c.length>0&&(l=c[c.length-1])}if(r&&n&&l){let c=n,d="err_"+o;l._sysErrRemoveTimer=setTimeout(()=>{let u=e.messagesMap[c];if(u){let g=u.findIndex(p=>p.id===d);g>=0&&u.splice(g,1)}},5e3)}!r&&n&&(delete e.processingConversations[n],Ve(e,n),e.finishStreamingForConversation(n));break}case"history_sessions_list":if(t.requestId&&e._historySessionsRequestId&&t.requestId!==e._historySessionsRequestId)break;e.historySessions=t.sessions||[],e.historySessionsLoading=!1;break;case"folders_list":if(t.requestId&&e._foldersRequestId&&t.requestId!==e._foldersRequestId)break;e.folders=t.folders||[],e.foldersLoading=!1,e._foldersResolve&&(e._foldersResolve(),e._foldersResolve=null);break;case"models_list":if(t.requestId&&e._modelsRequestId&&t.requestId!==e._modelsRequestId)break;e.providerModels=t.models||[],e.providerModelsLoading=!1,e._modelsTimeout&&(clearTimeout(e._modelsTimeout),e._modelsTimeout=null),e._modelsResolve&&(e._modelsResolve(e.providerModels),e._modelsResolve=null);break;case"conversation_refresh":Fu(e,t);break;case"session_pinned":if(t.conversationId){let n=t.agentId?{agentId:t.agentId}:{};if(typeof e.setSessionPinned=="function")e.setSessionPinned(t.conversationId,!!t.pinned,n);else try{let r=window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore();r&&typeof r.applyPinState=="function"&&r.applyPinState(t.conversationId,!!t.pinned,t.agentId||e.yeaftSessionAgentById?.[t.conversationId]||e.currentAgent||null)}catch{}}break;case"execution_cancelled":Ou(e,t);break;case"slash_commands_update":if(Array.isArray(t.slashCommands)){let n=[...new Set(t.slashCommands)];if(t.commandSet==="yeaft"){let r=t.conversationId&&t.conversationId!=="__preload__"?t.conversationId:null,i=t.agentId&&e.yeaftConversationIdsByAgent?.[t.agentId]||null,o=r||i;o&&(e.slashCommandsMap[o]=n);let a=e.yeaftConversationId||null,l=t.agentId?e.currentAgent===t.agentId&&(i===a||r===a):r===a;a&&l&&(e.slashCommandsMap[a]=n)}else t.conversationId&&(e.slashCommandsMap[t.conversationId]=n),t.agentId&&(e.slashCommandsMap[`agent:${t.agentId}`]=n)}t.slashCommandDescriptions&&(e.slashCommandDescriptions={...e.slashCommandDescriptions,...t.slashCommandDescriptions});break;case"compact_status":{let n=t.conversationId;e.compactStatus={conversationId:n,status:t.status,message:t.message},t.status==="completed"?setTimeout(()=>{e.compactStatus?.conversationId===n&&e.compactStatus?.status==="completed"&&(e.compactStatus=null)},3e3):t.status==="compacting"&&setTimeout(()=>{e.compactStatus?.conversationId===n&&e.compactStatus?.status==="compacting"&&(e.compactStatus=null)},3e4)}break;case"pong_session":{let n=t.conversationId;if(!n)break;if(e._pongTimeouts?.[n]&&(clearTimeout(e._pongTimeouts[n]),delete e._pongTimeouts[n]),t.status==="unsupported"){Ve(e,n),Iu(e,n);break}if(t.status==="ok")e.sessionHealth?.[n]&&delete e.sessionHealth[n],!t.isProcessing&&e.processingConversations[n]&&(delete e.processingConversations[n],Ve(e,n),e.finishStreamingForConversation(n));else if(e.sessionHealth||(e.sessionHealth={}),e.sessionHealth[n]={status:t.status},t.status==="session-lost"||t.status==="cli-exited"){if(e._autoRefreshed||(e._autoRefreshed={}),!e._autoRefreshed[n]){e._autoRefreshed[n]=!0;let r=e.conversations.find(i=>i.id===n);e.sendWsMessage({type:"refresh_conversation",conversationId:n,agentId:r?.agentId})}delete e.processingConversations[n],Ve(e,n),e.finishStreamingForConversation(n)}break}case"ask_user_question":if(t.conversationId){let n=()=>{let r=e.messagesMap[t.conversationId]||[];for(let i=r.length-1;i>=0;i--)if(r[i].type==="tool-use"&&r[i].toolName==="AskUserQuestion"&&!r[i].askRequestId)return r[i].askRequestId=t.requestId,r[i].askQuestions=t.questions,!0;return!1};if(!n()){let r=0,i=setInterval(()=>{r++,(n()||r>=10)&&clearInterval(i)},200)}}break;case"dream_enabled_changed":{let n=e.agentDreamState?.[t.agentId]||{},r=!!t.requestId&&n.requestId===t.requestId;if(!n.pending||!r)break;clearTimeout(n.timer);let i=typeof t.enabled=="boolean"?t.enabled:n.authoritative!==!1,o=Array.isArray(e.agents)?e.agents.find(a=>a.id===t.agentId):null;o&&(o.dreamEnabled=i),e.agentDreamState={...e.agentDreamState,[t.agentId]:{...n,pending:!1,timer:null,authoritative:i,error:t.error||null}};break}case"restart_agent_ack":{let n=e.agentOperations?.[t.agentId]?.restart,r=!!t.requestId&&n?.requestId===t.requestId;if(!n?.pending||!r)break;n.pending&&(e.agentOperations={...e.agentOperations,[t.agentId]:{...e.agentOperations[t.agentId]||{},restart:{...n,acknowledged:!0}}}),window.dispatchEvent(new CustomEvent("agent-restart-ack",{detail:{agentId:t.agentId,requestId:t.requestId}}));break}case"upgrade_agent_ack":{let n=e.agentOperations?.[t.agentId]?.upgrade,r=!!t.requestId&&n?.requestId===t.requestId;if(!n?.pending||!r)break;n.pending&&(!t.success||t.alreadyLatest?(n.batchId&&t.alreadyLatest?e.recordAgentUpgradeBatchResult?.(t.agentId,{status:"already_latest",version:t.version||null},n.batchId):n.batchId&&!t.success&&e.recordAgentUpgradeBatchResult?.(t.agentId,{status:"failed",error:t.error||null,reason:t.reason||null,version:t.version||null},n.batchId),e.finishAgentOperation?.(t.agentId,"upgrade",t.error||null)):e.agentOperations={...e.agentOperations,[t.agentId]:{...e.agentOperations[t.agentId]||{},upgrade:{...n,acknowledged:!0}}}),window.dispatchEvent(new CustomEvent("agent-upgrade-ack",{detail:{agentId:t.agentId,requestId:t.requestId,batchId:n.batchId||null,success:t.success,error:t.error,alreadyLatest:t.alreadyLatest,version:t.version,reason:t.reason,currentNode:t.currentNode,requiredNode:t.requiredNode,requiredCapability:t.requiredCapability}}));break}case"browser_runtime_status_result":case"browser_runtime_install_progress":case"browser_runtime_error":case"browser_session_created":case"browser_session_error":case"browser_session_snapshot":case"browser_session_list_result":case"browser_peer_prepared":case"browser_peer_offer":case"browser_peer_ice_candidate":case"browser_peer_state":case"browser_peer_error":window.dispatchEvent(new CustomEvent("browser-runtime-message",{detail:t}));break;case"terminal_created":case"terminal_output":case"terminal_closed":case"terminal_error":case"file_content":case"video_metadata":case"file_references_resolved":case"file_saved":case"directory_listing":case"git_status_result":case"git_diff_result":case"git_op_result":case"file_op_result":case"file_search_result":case"file_tabs_restored":t.type,t.type,window.dispatchEvent(new CustomEvent("workbench-message",{detail:t}));break;case"server_updating":e.connectionState="updating";break;case"context_usage":e.contextUsage={inputTokens:t.inputTokens,maxTokens:t.maxTokens,percentage:t.percentage,conversationId:t.conversationId};break;case"mcp_servers_list":case"mcp_config_updated":t.agentId&&t.servers&&(e.mcpServers[t.agentId]=t.servers);break;case"expert_roles_list":t.roles&&(e.expertRoleDefinitions=t.roles);break;case"llm_models_discovered":t.agentId&&(e.llmModelDiscovery=e.llmModelDiscovery||{},e.llmModelDiscovery[t.agentId]=t);break;case"llm_config":case"llm_config_updated":if(t.agentId){let n=t.agentConfig||ub(t),r=t.effectiveConfig||n;e.llmConfig[t.agentId]={providers:t.providers||r.providers||[],primaryModel:t.primaryModel||r.primaryModel||null,fastModel:t.fastModel||r.fastModel||null,language:t.language||n.language||r.language||"en",needsSetup:t.needsSetup??r.needsSetup??!1,agentConfig:n,effectiveConfig:r,requestId:t.requestId||null,statusRefreshError:t.statusRefreshError||null,error:t.error||null,loaded:!0}}break;case"models_dev_registry":if(e.modelsDevRegistry={registry:t.registry||{},fetchedAt:t.fetchedAt||Date.now(),error:t.error||null,loaded:!0},e._modelsDevPending){let n=e._modelsDevPending;e._modelsDevPending=null,n.timer&&clearTimeout(n.timer);for(let r of n.resolvers)r(e.modelsDevRegistry)}break;case"yeaft_settings":case"yeaft_settings_updated":t.agentId&&(e.yeaftSettings[t.agentId]={maxConcurrentThreads:t.maxConcurrentThreads??6,autoArchiveIdleDays:t.autoArchiveIdleDays??30,error:t.error||null,loaded:!0,at:Date.now()});break;case"yeaft_plugins":case"yeaft_plugins_updated":{let n={plugins:t.plugins&&typeof t.plugins=="object"?t.plugins:{},error:t.error||null,loaded:!0,at:Date.now()};t.agentId&&(e.pluginConfigByAgent={...e.pluginConfigByAgent,[t.agentId]:n});let r=t.requestId?e._pluginPending?.[t.requestId]:null;r&&(clearTimeout(r.timer),delete e._pluginPending[t.requestId],r.resolve(n));break}case"yeaft_managed_skill_result":{let n=t.requestId?e._pluginPending?.[t.requestId]:null,r=n?.kind==="managed-skill"?n:null,i=t.catalog&&typeof t.catalog=="object"?{tools:Array.isArray(t.catalog.tools)?t.catalog.tools:[],skills:Array.isArray(t.catalog.skills)?t.catalog.skills:[],skillSources:Array.isArray(t.catalog.skillSources)?t.catalog.skillSources:[],mcpServers:Array.isArray(t.catalog.mcpServers)?t.catalog.mcpServers:[]}:{tools:[],skills:[],skillSources:[],mcpServers:[]};if(r&&e.managedSkillRequestByKey?.[r.key]===t.requestId){let o=e.pluginCatalogKey?.(r.agentId,r.workDir||"")||"";e.pluginCatalogByKey={...e.pluginCatalogByKey,[o]:{catalog:i,loading:!1,error:t.error||null,loaded:!0,at:Date.now()}}}r&&(clearTimeout(r.timer),delete e._pluginPending[t.requestId],r.resolve({catalog:i,error:t.error||null,result:t.result||null}));break}case"yeaft_plugin_catalog_result":{let n=t.requestId?e._pluginPending?.[t.requestId]:null,r=n?.kind==="catalog"?n:null,i=t.catalog&&typeof t.catalog=="object"?{tools:Array.isArray(t.catalog.tools)?t.catalog.tools:[],skills:Array.isArray(t.catalog.skills)?t.catalog.skills:[],skillSources:Array.isArray(t.catalog.skillSources)?t.catalog.skillSources:[],mcpServers:Array.isArray(t.catalog.mcpServers)?t.catalog.mcpServers:[]}:{tools:[],skills:[],skillSources:[],mcpServers:[]},o=r?.key;o&&e.pluginCatalogRequestByKey?.[o]===t.requestId&&(e.pluginCatalogByKey={...e.pluginCatalogByKey,[o]:{catalog:i,loading:!1,error:t.error||null,loaded:!0,at:Date.now()}}),r&&(clearTimeout(r.timer),delete e._pluginPending[t.requestId],r.resolve({catalog:i,error:t.error||null}));break}case"telemetry_settings":case"telemetry_settings_updated":{let n={enabled:t.enabled!==!1,retentionDays:t.retentionDays??3,flushIntervalMs:t.flushIntervalMs??1e3,maxQueueSize:t.maxQueueSize??5e3,rawExchangeMaxBytes:t.rawExchangeMaxBytes??524288,traceTextMaxBytes:t.traceTextMaxBytes??262144,error:t.error||null,loaded:!0,at:Date.now()},r=t.type==="telemetry_settings_updated"?"update":"load",i=t.requestId?{requestId:t.requestId,pending:e._telemetryPending?.[t.requestId]}:null,o=i?.pending;if(!o||o.agentId!==t.agentId||o.operation!==r)break;clearTimeout(o.timer),delete e._telemetryPending[i.requestId],e.telemetryRequestByAgent?.[o.agentId]===i.requestId&&(e.telemetrySettingsByAgent={...e.telemetrySettingsByAgent,[o.agentId]:n},e.currentAgent===o.agentId&&(e.telemetrySettings=n)),o.resolve(n);break}case"work_center_feature_settings":case"work_center_feature_settings_updated":{let n=t.type==="work_center_feature_settings_updated"?"update":"load",r=t.requestId?e._workCenterFeaturePending?.[t.requestId]:null;if(!r||r.agentId!==t.agentId||r.operation!==n)break;clearTimeout(r.timer),delete e._workCenterFeaturePending[t.requestId];let i={enabled:t.enabled===!0,source:t.source||"config",overridden:t.overridden===!0,error:t.error||null,persisted:t.persisted,effective:t.effective,rolledBack:t.rolledBack===!0,sessionTools:t.sessionTools||null,runtimeError:t.runtimeError||null,unsupported:t.unsupported===!0,loaded:!0};if(e.workCenterFeatureRequestByAgent?.[r.agentId]===t.requestId&&(e.workCenterFeatureSettingsByAgent={...e.workCenterFeatureSettingsByAgent,[r.agentId]:i}),i.error){let o=new Error(i.error);o.settings=i,r.reject(o)}else r.resolve(i);break}case"search_settings":case"search_settings_updated":{let n={backend:t.backend||"tavily",tavilyKeyConfigured:!!t.tavilyKeyConfigured,tavilyKeyMasked:t.tavilyKeyMasked||null,disableHtmlFallback:!!t.disableHtmlFallback,error:t.error||null,loaded:!0,at:Date.now()};e.searchSettings=n;let r=e._searchPending,i=t.type==="search_settings"?"load":"update";r&&r[i]&&(r[i](n),delete r[i]);break}case"tavily_usage":{let n=t.error?{error:t.error}:{plan:t.plan,used:t.used,limit:t.limit,paygoUsed:t.paygoUsed,paygoLimit:t.paygoLimit};e.tavilyUsage=n,e.tavilyUsageLoading=!1;let r=e._searchPending;r&&r.usage&&(r.usage(n),delete r.usage);break}case"yeaft_mcp_list_result":case"yeaft_mcp_add_result":case"yeaft_mcp_remove_result":case"yeaft_mcp_reload_result":case"yeaft_mcp_updated":{if(Array.isArray(t.servers)&&(e.yeaftMcpServers=t.servers),t.runtime&&typeof t.runtime=="object"&&(e.yeaftMcpRuntime={connected:!!t.runtime.connected,toolCount:t.runtime.toolCount||0,perServer:Array.isArray(t.runtime.perServer)?t.runtime.perServer:[]}),e.yeaftMcpLoading=!1,e.yeaftMcpError=t.error||null,t.requestId){let n=e._mcpPending;n&&n[t.requestId]&&(n[t.requestId](t),delete n[t.requestId])}break}case"conversation_mcp_update":t.conversationId&&t.servers&&(e.conversationMcpServers[t.conversationId]=t.servers),t.conversationId&&t.serverTools&&(e.conversationMcpServerTools[t.conversationId]=t.serverTools);break;case"btw_stream":e.appendBtwDelta(t.delta);break;case"btw_done":e.btwLoading=!1,t.btwSessionId&&(e.btwSessionId=t.btwSessionId);break;case"btw_error":{let n=e.btwMessages[e.btwMessages.length-1];n&&n.role==="assistant"&&(n.content="Error: "+t.error),e.btwLoading=!1;break}case"background_task_started":case"background_task_output":break;case"subagent_started":t.conversationId&&t.subagentId&&e.addSubagent(t.conversationId,{id:t.subagentId,slug:t.slug,type:t.subagentType,description:t.description,parentToolUseId:t.parentToolUseId});break;case"subagent_message":t.conversationId&&t.subagentId&&t.message&&e.appendSubagentMessage(t.conversationId,t.subagentId,t.message);break;case"subagent_completed":t.conversationId&&t.subagentId&&e.completeSubagent(t.conversationId,t.subagentId);break}}var pb,gb,fb,hb,Ju,pl,np=B(()=>{qt();qi();ss();Bs();hn();cl();io();Zu();no();pb=1,gb=5,fb=500,hb=512*1024,Ju=3e4,pl=new WeakMap});function ip(){return Object.values(rp).sort((t,s)=>t.order-s.order).map(t=>({teamId:t.id,team:t,roles:Object.values(Zt).filter(s=>s.group===t.id)}))}function op(e){let t=[];for(let s of Object.values(Zt)){t.push({roleId:s.id,roleName:s.name,roleTitle:s.title,actionId:null,actionName:null,searchText:`${s.name} ${s.fullName} ${s.title} ${s.titleEn}`.toLowerCase(),displayText:s.name,group:s.group});for(let n of s.actions)t.push({roleId:s.id,roleName:s.name,roleTitle:s.title,actionId:n.id,actionName:n.name,searchText:`${s.name} ${s.fullName} ${s.title} ${n.name} ${n.nameEn}`.toLowerCase(),displayText:`${s.name}\xB7${n.name}`,group:s.group})}if(e&&e.length>0){for(let s of e)if(t.push({roleId:s.id,roleName:s.name,roleTitle:s.title,actionId:null,actionName:null,searchText:`${s.name} ${s.fullName||""} ${s.title} ${s.titleEn||""}`.toLowerCase(),displayText:s.name,group:"custom"}),s.actions)for(let n of s.actions)t.push({roleId:s.id,roleName:s.name,roleTitle:s.title,actionId:n.id,actionName:n.name,searchText:`${s.name} ${s.fullName||""} ${s.title} ${n.name} ${n.nameEn||""}`.toLowerCase(),displayText:`${s.name}\xB7${n.name}`,group:"custom"})}return t}function In(e,t){let s=Zt[e.role];if(s){if(e.action){let n=s.actions.find(r=>r.id===e.action);return n?`${s.name}\xB7${n.name}`:s.name}return s.name}if(t){let n=t.find(r=>r.id===e.role);if(n){if(e.action){let r=n.actions?.find(i=>i.id===e.action);return r?`${n.name}\xB7${r.name}`:n.name}return n.name}}return e.role}function gl(e,t,s,n="zh-CN"){if(!e||e.length===0||!t||t.length===0)return null;let r=n==="zh-CN";if(!e.some(l=>!Zt[l.role]&&t.some(c=>c.id===l.role)))return null;if(e.length===1){let{role:l,action:c}=e[0],d=t.find(g=>g.id===l);if(!d)return null;let u;if(c&&d.actions){let g=d.actions.find(p=>p.id===c);g?s?(u=(r?g.messageTemplate:g.messageTemplateEn)||"",u+=s):u=(r?g.defaultMessage:g.defaultMessageEn)||"":u=((r?d.messagePrefix:d.messagePrefixEn)||"")+(s||"")}else u=((r?d.messagePrefix:d.messagePrefixEn)||"")+(s||"");return{effectivePrompt:u}}let o=[];for(let{role:l,action:c}of e){let d=t.find(g=>g.id===l),u=Zt[l];if(d)if(c){let g=d.actions?.find(p=>p.id===c);g&&o.push((r?g.messageTemplate:g.messageTemplateEn)||"")}else o.push((r?d.messagePrefix:d.messagePrefixEn)||"");else if(u)return null}return o.length===0?null:{effectivePrompt:o.join(`
4
4
  ---
5
5
 
6
- `)+(s||"")}}function lp(e){return Object.values(rp).filter(t=>e||!t.adminOnly).sort((t,s)=>t.order-s.order)}var rp,Zt,ap,Cn,Qr=B(()=>{rp={dev:{id:"dev",name:"\u8F6F\u4EF6\u5F00\u53D1",nameEn:"Software Dev",icon:"\u{1F5A5}\uFE0F",order:0},trading:{id:"trading",name:"\u4EA4\u6613",nameEn:"Trading",icon:"\u{1F4C8}",order:1,adminOnly:!0},writing:{id:"writing",name:"\u5199\u4F5C",nameEn:"Writing",icon:"\u270D\uFE0F",order:2,adminOnly:!0},video:{id:"video",name:"\u89C6\u9891",nameEn:"Video",icon:"\u{1F3AC}",order:3,adminOnly:!0}},Zt={jobs:{id:"jobs",name:"Jobs",fullName:"Steve Jobs",title:"\u4EA7\u54C1\u7ECF\u7406",titleEn:"Product Manager",group:"dev",actions:[{id:"product-analysis",name:"\u4EA7\u54C1\u5206\u6790",nameEn:"Product Analysis"},{id:"design-review",name:"\u8BBE\u8BA1\u5BA1\u67E5",nameEn:"Design Review"},{id:"requirements",name:"\u9700\u6C42\u62C6\u89E3",nameEn:"Requirements"}]},fowler:{id:"fowler",name:"Fowler",fullName:"Martin Fowler",title:"\u8F6F\u4EF6\u67B6\u6784\u5E08",titleEn:"Software Architect",group:"dev",actions:[{id:"architecture",name:"\u67B6\u6784\u5BA1\u67E5",nameEn:"Architecture Review"},{id:"refactoring",name:"\u91CD\u6784\u5206\u6790",nameEn:"Refactoring"},{id:"code-review",name:"\u4EE3\u7801\u5BA1\u67E5",nameEn:"Code Review"}]},torvalds:{id:"torvalds",name:"Torvalds",fullName:"Linus Torvalds",title:"\u7CFB\u7EDF\u5F00\u53D1\u5DE5\u7A0B\u5E08",titleEn:"Systems Engineer",group:"dev",actions:[{id:"system-design",name:"\u7CFB\u7EDF\u8BBE\u8BA1",nameEn:"System Design"},{id:"performance",name:"\u6027\u80FD\u4F18\u5316",nameEn:"Performance"},{id:"code-style",name:"\u4EE3\u7801\u98CE\u683C",nameEn:"Code Style"},{id:"implementation",name:"\u4EE3\u7801\u5B9E\u73B0",nameEn:"Implementation"}]},beck:{id:"beck",name:"Beck",fullName:"Kent Beck",title:"\u6D4B\u8BD5\u5DE5\u7A0B\u5E08",titleEn:"Test Engineer",group:"dev",actions:[{id:"test-strategy",name:"\u6D4B\u8BD5\u7B56\u7565",nameEn:"Test Strategy"},{id:"tdd-guide",name:"TDD \u6307\u5BFC",nameEn:"TDD Guide"},{id:"quality-check",name:"\u8D28\u91CF\u8BC4\u4F30",nameEn:"Quality Check"}]},schneier:{id:"schneier",name:"Schneier",fullName:"Bruce Schneier",title:"\u5B89\u5168\u5DE5\u7A0B\u5E08",titleEn:"Security Engineer",group:"dev",actions:[{id:"security-audit",name:"\u5B89\u5168\u5BA1\u8BA1",nameEn:"Security Audit"},{id:"threat-model",name:"\u5A01\u80C1\u5EFA\u6A21",nameEn:"Threat Model"},{id:"auth-review",name:"\u8BA4\u8BC1\u5BA1\u67E5",nameEn:"Auth Review"}]},rams:{id:"rams",name:"Rams",fullName:"Dieter Rams",title:"UI/UX \u8BBE\u8BA1\u5E08",titleEn:"UI/UX Designer",group:"dev",actions:[{id:"ui-review",name:"\u754C\u9762\u5BA1\u67E5",nameEn:"UI Review"},{id:"interaction",name:"\u4EA4\u4E92\u8BBE\u8BA1",nameEn:"Interaction Design"},{id:"layout",name:"\u5E03\u5C40\u4F18\u5316",nameEn:"Layout Optimization"}]},graham:{id:"graham",name:"Graham",fullName:"Paul Graham",title:"\u6280\u672F\u5199\u4F5C / \u65B9\u6848\u8BC4\u4F30\u5E08",titleEn:"Tech Writer / Evaluator",group:"dev",actions:[{id:"writing",name:"\u6280\u672F\u5199\u4F5C",nameEn:"Tech Writing"},{id:"proposal-review",name:"\u65B9\u6848\u8BC4\u4F30",nameEn:"Proposal Review"},{id:"explain",name:"\u6982\u5FF5\u89E3\u91CA",nameEn:"Explain"}]},hightower:{id:"hightower",name:"Hightower",fullName:"Kelsey Hightower",title:"DevOps / \u8FD0\u7EF4\u5DE5\u7A0B\u5E08",titleEn:"DevOps Engineer",group:"dev",actions:[{id:"deployment",name:"\u90E8\u7F72\u5BA1\u67E5",nameEn:"Deployment Review"},{id:"cicd",name:"CI/CD \u8BC4\u4F30",nameEn:"CI/CD Review"},{id:"infra",name:"\u57FA\u7840\u8BBE\u65BD",nameEn:"Infrastructure"}]},gregg:{id:"gregg",name:"Gregg",fullName:"Brendan Gregg",title:"\u6027\u80FD\u5DE5\u7A0B\u5E08",titleEn:"Performance Engineer",group:"dev",actions:[{id:"perf-analysis",name:"\u6027\u80FD\u5206\u6790",nameEn:"Perf Analysis"},{id:"tuning",name:"\u7CFB\u7EDF\u8C03\u4F18",nameEn:"Tuning"},{id:"benchmark",name:"\u57FA\u51C6\u6D4B\u8BD5",nameEn:"Benchmark"}]},codd:{id:"codd",name:"Codd",fullName:"Edgar Codd",title:"\u6570\u636E\u5E93 / SQL \u4E13\u5BB6",titleEn:"Database / SQL Expert",group:"dev",actions:[{id:"sql-optimization",name:"SQL \u4F18\u5316",nameEn:"SQL Optimization"},{id:"schema-design",name:"Schema \u8BBE\u8BA1",nameEn:"Schema Design"},{id:"data-modeling",name:"\u6570\u636E\u5EFA\u6A21",nameEn:"Data Modeling"}]},knuth:{id:"knuth",name:"Knuth",fullName:"Donald Knuth",title:"\u7B97\u6CD5 / \u6570\u636E\u5904\u7406\u4E13\u5BB6",titleEn:"Algorithm Expert",group:"dev",actions:[{id:"algorithm-design",name:"\u7B97\u6CD5\u8BBE\u8BA1",nameEn:"Algorithm Design"},{id:"data-processing",name:"\u6570\u636E\u5904\u7406",nameEn:"Data Processing"},{id:"optimization",name:"\u4F18\u5316",nameEn:"Optimization"}]},thomas:{id:"thomas",name:"Thomas",fullName:"Dave Thomas",title:"\u6280\u672F\u6587\u6863\u5DE5\u7A0B\u5E08",titleEn:"Tech Doc Engineer",group:"dev",actions:[{id:"api-docs",name:"API \u6587\u6863",nameEn:"API Docs"},{id:"readme",name:"README",nameEn:"README"},{id:"comment-review",name:"\u6CE8\u91CA\u5BA1\u67E5",nameEn:"Comment Review"}]},soros:{id:"soros",name:"Soros",fullName:"George Soros",title:"\u5B8F\u89C2\u7B56\u7565\u5E08",titleEn:"Macro Strategist",group:"trading",actions:[{id:"macro-analysis",name:"\u5B8F\u89C2\u5206\u6790",nameEn:"Macro Analysis"},{id:"risk-assessment",name:"\u98CE\u9669\u8BC4\u4F30",nameEn:"Risk Assessment"},{id:"thesis-review",name:"\u8BBA\u70B9\u5BA1\u67E5",nameEn:"Thesis Review"}]},livermore:{id:"livermore",name:"Livermore",fullName:"Jesse Livermore",title:"\u6280\u672F\u5206\u6790\u5E08",titleEn:"Technical Analyst",group:"trading",actions:[{id:"price-action",name:"\u4EF7\u683C\u884C\u4E3A",nameEn:"Price Action"},{id:"pattern-recognition",name:"\u56FE\u5F62\u8BC6\u522B",nameEn:"Pattern Recognition"},{id:"trade-plan",name:"\u4EA4\u6613\u8BA1\u5212",nameEn:"Trade Plan"}]},dalio:{id:"dalio",name:"Dalio",fullName:"Ray Dalio",title:"\u7814\u7A76\u5458 / \u7ECF\u6D4E\u5206\u6790\u5E08",titleEn:"Research / Economist",group:"trading",actions:[{id:"economic-analysis",name:"\u7ECF\u6D4E\u5206\u6790",nameEn:"Economic Analysis"},{id:"portfolio-review",name:"\u7EC4\u5408\u5BA1\u67E5",nameEn:"Portfolio Review"},{id:"research-report",name:"\u7814\u7A76\u62A5\u544A",nameEn:"Research Report"}]},taleb:{id:"taleb",name:"Taleb",fullName:"Nassim Taleb",title:"\u98CE\u63A7\u5B98",titleEn:"Risk Manager",group:"trading",actions:[{id:"risk-audit",name:"\u98CE\u9669\u5BA1\u8BA1",nameEn:"Risk Audit"},{id:"antifragile",name:"\u53CD\u8106\u5F31\u8BC4\u4F30",nameEn:"Antifragile Assessment"},{id:"stress-test",name:"\u538B\u529B\u6D4B\u8BD5",nameEn:"Stress Test"}]},jones:{id:"jones",name:"Jones",fullName:"Paul Tudor Jones",title:"\u4EA4\u6613\u6267\u884C\u5458",titleEn:"Trade Executor",group:"trading",actions:[{id:"execution",name:"\u6267\u884C\u8BA1\u5212",nameEn:"Execution Plan"},{id:"position-sizing",name:"\u4ED3\u4F4D\u8BA1\u7B97",nameEn:"Position Sizing"},{id:"trade-review",name:"\u4EA4\u6613\u590D\u76D8",nameEn:"Trade Review"}]},simons:{id:"simons",name:"Simons",fullName:"Jim Simons",title:"\u91CF\u5316\u5206\u6790\u5E08",titleEn:"Quant Analyst",group:"trading",actions:[{id:"quant-signal",name:"\u91CF\u5316\u4FE1\u53F7",nameEn:"Quant Signal"},{id:"backtest-review",name:"\u56DE\u6D4B\u5BA1\u67E5",nameEn:"Backtest Review"},{id:"model-design",name:"\u6A21\u578B\u8BBE\u8BA1",nameEn:"Model Design"}]},jinyong:{id:"jinyong",name:"\u91D1\u5EB8",fullName:"\u91D1\u5EB8\uFF08Louis Cha\uFF09",title:"\u6B66\u4FA0\u5927\u5E08",titleEn:"Wuxia Master",group:"writing",actions:[{id:"world-building",name:"\u6B66\u4FA0\u4E16\u754C\u89C2",nameEn:"Wuxia World Building"},{id:"character-design",name:"\u4EBA\u7269\u5851\u9020",nameEn:"Character Design"},{id:"plot-design",name:"\u60C5\u8282\u7F16\u6392",nameEn:"Plot Design"}]},zhouzi:{id:"zhouzi",name:"\u8098\u5B50",fullName:"\u4F1A\u8BF4\u8BDD\u7684\u8098\u5B50",title:"\u7F51\u6587\u5929\u738B",titleEn:"Web Novel King",group:"writing",actions:[{id:"cool-factor",name:"\u723D\u611F\u8BBE\u8BA1",nameEn:"Cool Factor Design"},{id:"pacing",name:"\u8282\u594F\u628A\u63A7",nameEn:"Pacing Control"},{id:"cheat-design",name:"\u91D1\u624B\u6307\u8BBE\u8BA1",nameEn:"Cheat System Design"}]},qiongyao:{id:"qiongyao",name:"\u743C\u7476",fullName:"\u743C\u7476\uFF08Chiung Yao\uFF09",title:"\u8A00\u60C5\u5B97\u5E08",titleEn:"Romance Master",group:"writing",actions:[{id:"emotion-writing",name:"\u60C5\u611F\u63CF\u5199",nameEn:"Emotion Writing"},{id:"dialogue-design",name:"\u5BF9\u8BDD\u8BBE\u8BA1",nameEn:"Dialogue Design"},{id:"romance-arc",name:"\u8650\u604B\u67B6\u6784",nameEn:"Romance Arc"}]},luxun:{id:"luxun",name:"\u9C81\u8FC5",fullName:"\u9C81\u8FC5\uFF08Lu Xun\uFF09",title:"\u6587\u5B66\u5DE8\u5320",titleEn:"Literary Giant",group:"writing",actions:[{id:"satire",name:"\u8BBD\u523A\u5199\u4F5C",nameEn:"Satirical Writing"},{id:"character-sketch",name:"\u4EBA\u7269\u523B\u753B",nameEn:"Character Sketch"},{id:"prose-craft",name:"\u6587\u7B14\u9524\u70BC",nameEn:"Prose Craft"}]},kubrick:{id:"kubrick",name:"Kubrick",fullName:"Stanley Kubrick",title:"\u5BFC\u6F14 / \u89C6\u89C9\u603B\u76D1",titleEn:"Director / Visual Director",group:"video",actions:[{id:"narrative-pacing",name:"\u53D9\u4E8B\u8282\u594F",nameEn:"Narrative Pacing"},{id:"visual-concept",name:"\u89C6\u89C9\u6982\u5FF5",nameEn:"Visual Concept"},{id:"scene-breakdown",name:"\u573A\u666F\u62C6\u89E3",nameEn:"Scene Breakdown"}]},kaufman:{id:"kaufman",name:"Kaufman",fullName:"Charlie Kaufman",title:"\u7F16\u5267",titleEn:"Screenwriter",group:"video",actions:[{id:"script-writing",name:"\u811A\u672C\u5199\u4F5C",nameEn:"Script Writing"},{id:"character-design",name:"\u89D2\u8272\u8BBE\u8BA1",nameEn:"Character Design"},{id:"narrative-structure",name:"\u53D9\u4E8B\u7ED3\u6784",nameEn:"Narrative Structure"}]},spielberg:{id:"spielberg",name:"Spielberg",fullName:"Steven Spielberg",title:"\u5206\u955C / \u89C6\u89C9\u53D9\u4E8B\u5E08",titleEn:"Storyboard / Visual Storyteller",group:"video",actions:[{id:"storyboard",name:"\u5206\u955C\u8BBE\u8BA1",nameEn:"Storyboard"},{id:"shot-design",name:"\u955C\u5934\u65B9\u6848",nameEn:"Shot Design"},{id:"visual-storytelling",name:"\u89C6\u89C9\u53D9\u4E8B",nameEn:"Visual Storytelling"}]},schoonmaker:{id:"schoonmaker",name:"Schoonmaker",fullName:"Thelma Schoonmaker",title:"\u526A\u8F91\u5E08",titleEn:"Editor",group:"video",actions:[{id:"editing-rhythm",name:"\u526A\u8F91\u8282\u594F",nameEn:"Editing Rhythm"},{id:"sequence-design",name:"\u5E8F\u5217\u8BBE\u8BA1",nameEn:"Sequence Design"},{id:"final-cut",name:"\u6700\u7EC8\u5BA1\u7247",nameEn:"Final Cut"}]}};ap="dev",Cn=3});function Ib(e,t){return!t||!e?.yeaftConversationIdsByAgent?[]:Object.entries(e.yeaftConversationIdsByAgent).filter(([,s])=>s===t).map(([s])=>s).filter(Boolean)}function cp(){return`cm_${crypto.randomUUID()}`}function dp(e,t){if(t===e.currentAgent&&!e.pendingAgentSelection)return;let s=`agent_select_${crypto.randomUUID()}`;return e.agentSwitching=!0,e.pendingAgentSelection={agentId:t,requestId:s},e.sendWsMessage({type:"select_agent",agentId:t,requestId:s})===!1?(e.pendingAgentSelection=null,e.agentSwitching=!1,null):s}function up(e,t,s=null,n=null,r={}){let i=s||e.currentAgent;if(!i){e.addMessage({type:"error",content:Oe("chat.agent.selectFirst")});return}Bn(e,!0,Oe("chat.session.creating"));let o={type:"create_conversation",agentId:i,workDir:t||e.currentAgentWorkDir};n!==null&&(o.disallowedTools=n),r&&typeof r.provider=="string"&&(o.provider=r.provider),r&&r.providerOptions&&typeof r.providerOptions=="object"&&(o.providerOptions=r.providerOptions),e.sendWsMessage(o)}function pp(e,t,s,n=null,r=null,i=null){let o=n||e.currentAgent;if(!o){e.addMessage({type:"error",content:Oe("chat.agent.selectFirst")});return}let a=null,l={};r&&typeof r=="object"&&!Array.isArray(r)?l=r:(a=r,i&&typeof i=="object"&&(l=i));let c=gn(l.provider),d=(e.conversations||[]).find(p=>p.type!=="yeaft"&&p.agentId===o&&gn(p.provider)===c&&p.claudeSessionId===t),u=d&&(e.hiddenSessionCatalog||[]).find(p=>p.routeRef?.agentId===o&&p.routeRef?.runtimeProvider===c&&p.routeRef?.sessionId===d.id);if(u&&e.restoreCatalogSession(u)!==!0)return;Bn(e,!0,Oe("chat.session.loadingHistory"));let g={type:"resume_conversation",agentId:o,...d?{conversationId:d.id}:{},claudeSessionId:t,workDir:s||e.currentAgentWorkDir};a!==null&&(g.disallowedTools=a),typeof l.provider=="string"&&(g.provider=l.provider),l.providerOptions&&typeof l.providerOptions=="object"&&(g.providerOptions=l.providerOptions),e.sendWsMessage(g)}function gp(e,t,s,{refresh:n=!1}={}){if(e.panels.length>1){let a=e.activePanelId||e.panels[0]?.id;a&&e.setPanelConversation(a,t,{refresh:n});return}if(t===e.currentConversation){n&&(e.syncChatConversationHistory?.(t),fn(e));return}let r=e.conversations.find(a=>a.id===t&&a.type!=="yeaft");if(r&&r.agentId&&r.agentId!==e.currentAgent){let a=e.agents.find(l=>l.id===r.agentId);a&&(e.currentAgent=r.agentId,e.currentAgentInfo=a,e.sendWsMessage({type:"select_agent",agentId:r.agentId,silent:!0}))}e.sendWsMessage({type:"select_conversation",conversationId:t}),e.panels.length>1?e.activeConversations.includes(t)||e.activeConversations.push(t):e.activeConversations=[t],r&&(e.currentWorkDir=r.workDir);let i=e.messagesMap[t];(!i||i.length===0)&&(e.messagesMap[t]=[],Bn(e,!0,Oe("chat.session.loadingHistory"))),e.syncChatConversationHistory?.(t),e.loadingMoreMessages=!1;let o=e.chatSessionState[t];e.hasMoreMessages=!!o?.hasMoreOlder,fn(e)}function fl(e,t,s){t&&e.sendWsMessage({type:"update_conversation_settings",conversationId:t,...s})}function fp(e,t,s){let n=e.currentConversation;if(!n)return;let r=e.conversationMcpServers[n];if(r){let g=r.find(p=>p.name===t);g&&(g.enabled=s)}let i=e.conversationMcpServers[n]||[],o=e.conversationMcpServerTools[n]||{},a=[];for(let g of i)if(!g.enabled){let p=o[g.name];p&&p.length>0?a.push(...p):a.push(`mcp__${g.name}`)}let u=[...(e.conversations.find(g=>g.id===n)?.disallowedTools||[]).filter(g=>!g.startsWith("mcp__")),...a];fl(e,n,{disallowedTools:u})}function hp(e,t,s){return t?e.sendWsMessage({type:"delete_conversation",requestId:`delete_${crypto.randomUUID()}`,conversationId:t,...s?{agentId:s}:{}}):!1}function mp(e,t,s){e._recentlyDeletedSessions||(e._recentlyDeletedSessions={}),e._recentlyDeletedSessions[t]=Date.now(),e.conversations=e.conversations.filter(i=>i.id!==t);let n=e.activeConversations.indexOf(t);n>=0&&(e.activeConversations.splice(n,1),e.activeConversations.length===0&&(localStorage.removeItem("lastViewedConversation"),e.lastViewedConversation=null));for(let i of e.panels)i.conversationId===t&&(i.conversationId=null);let r=e.pinnedSessions.indexOf(t);r>=0&&(e.pinnedSessions.splice(r,1),localStorage.setItem("pinned-sessions",JSON.stringify(e.pinnedSessions))),e.sendWsMessage({type:"delete_conversation",requestId:`delete_${crypto.randomUUID()}`,conversationId:t,...s?{agentId:s}:{}})}function vp(e,t,s=[],n={}){let r=n.expertSelections&&n.expertSelections.length>0;if(!t.trim()&&s.length===0&&!r||!e.currentAgent||!e.currentConversation)return;let i=cp();if(e.addMessage({type:"user",content:t,clientMessageId:i,attachments:s.length>0?s:void 0,expertSelections:r?n.expertSelections:void 0}),t.trim()){let c=t.trim().substring(0,100);e.conversationTitles[e.currentConversation]=c}else if(r){let c=n.expertSelections[0],d=`@${c.role}${c.action?"\xB7"+c.action:""}`;e.conversationTitles[e.currentConversation]=d}let o=e.conversations.find(c=>c.id===e.currentConversation);o&&(o.lastMessageAt=Date.now()),e.processingConversations[e.currentConversation]||(e.processingConversations[e.currentConversation]=!0,e._closedAt?.[e.currentConversation]&&delete e._closedAt[e.currentConversation],e._turnCompletedConvs?.delete(e.currentConversation),e.getOrCreateExecutionStatus(e.currentConversation),Un(e,e.currentConversation));let a=s.map(c=>c.fileId),l={type:"chat",conversationId:e.currentConversation,prompt:t,fileIds:a,workDir:e.currentWorkDir,clientMessageId:i};if(n.targetRole&&(l.targetRole=n.targetRole),r){l.expertSelections=n.expertSelections;let c=gl(n.expertSelections,e.customExpertRoles,t,e.language||"zh-CN");c&&(l.expertMessage=c.effectivePrompt)}e.sendWsMessage(l)||$r(e).then(()=>{e.sendWsMessage(l)}).catch(()=>{e.addMessage({type:"system",content:Oe("chat.connection.reconnectFailed")}),delete e.processingConversations[e.currentConversation],Ve(e,e.currentConversation)})}function yp(e){if(!e.currentConversation||!e.processingConversations[e.currentConversation])return;let t=e.currentConversation;e.sendWsMessage({type:"cancel_execution",conversationId:t}),delete e.processingConversations[t],Ve(e,t),e._closedAt||(e._closedAt={}),e._closedAt[t]=Date.now();let s=e.executionStatusMap[t];s&&(s.currentTool=null),e.finishStreamingForConversation(t),Ws(e,t),e.addMessage({type:"system",content:Oe("chat.execution.cancelled")})}function bp(e,t,s,n){let r=n||e.currentConversation,o=(e.messagesMap[r]||[]).find(f=>f.type==="tool-use"&&f.toolName==="AskUserQuestion"&&f.askRequestId===t),a=e.currentView==="yeaft"||!!o?.sessionId;if(a&&(!o||o.askAnswered||o.askExpired)||a&&o.askPending&&Date.now()-(o.askSubmittedAt||0)<15e3)return!1;let l=o?.sessionId||e.yeaftActiveSessionFilter||null,c=typeof o?.agentId=="string"&&o.agentId?o.agentId:null,d=a?Ib(e,r):[],u=d.length===1?d[0]:null;if(c&&u&&c!==u)return!1;let g=a&&!c&&!u&&typeof e.agentIdForSession=="function"?e.agentIdForSession(l):null,p=e.sendWsMessage(a?{type:"yeaft_ask_user_answer",agentId:c||u||g||e.yeaftAgentId||e.currentAgent||null,conversationId:r,requestId:t,toolCallId:o?.toolId||null,answers:s,sessionId:l,vpId:o?.vpId||o?.speakerVpId||null,turnId:o?.turnId||null,threadId:o?.threadId||"main"}:{type:"ask_user_answer",conversationId:r,requestId:t,answers:s});o&&!a?(o.askAnswered=!0,o.selectedAnswers=s):o&&p!==!1?(o.askPending=!0,o.pendingAnswers=s,o.askSubmittedAt=Date.now(),o.askError=null):o&&(o.askError="send_failed"),!a&&p!==!1&&r&&!e.processingConversations[r]&&(e.processingConversations[r]=!0,e._closedAt?.[r]&&delete e._closedAt[r],e.getOrCreateExecutionStatus(r))}function wp(e,t){t&&(e.activeConversations.includes(t)||e.activeConversations.length>=3||(e.activeConversations.push(t),e.messagesMap[t]||(e.messagesMap[t]=[],e.requestChatHistory?.(t,{mode:"recent",turns:5})),fn(e)))}function kp(e,t){let s=e.activeConversations.indexOf(t);s<0||(e.activeConversations.splice(s,1),e.activeConversations.length===0&&(localStorage.removeItem("lastViewedConversation"),e.lastViewedConversation=null),fn(e))}function Sp(e,t,s,n=[],r={}){let i=r.expertSelections&&r.expertSelections.length>0;if(!s.trim()&&n.length===0&&!i||!e.currentAgent||!t)return;let o=cp();if(e.addMessageToConversation(t,{type:"user",content:s,clientMessageId:o,attachments:n.length>0?n:void 0,expertSelections:i?r.expertSelections:void 0}),s.trim()){let d=s.trim().substring(0,100);e.conversationTitles[t]=d}else if(i){let d=r.expertSelections[0],u=`@${d.role}${d.action?"\xB7"+d.action:""}`;e.conversationTitles[t]=u}let a=e.conversations.find(d=>d.id===t);a&&(a.lastMessageAt=Date.now()),e.processingConversations[t]||(e.processingConversations[t]=!0,e._closedAt?.[t]&&delete e._closedAt[t],e._turnCompletedConvs?.delete(t),e.getOrCreateExecutionStatus(t),Un(e,t));let l=n.map(d=>d.fileId),c={type:"chat",conversationId:t,prompt:s,fileIds:l,workDir:a?.workDir||e.currentWorkDir,clientMessageId:o};if(r.targetRole&&(c.targetRole=r.targetRole),i){c.expertSelections=r.expertSelections;let d=gl(r.expertSelections,e.customExpertRoles,s,e.language||"zh-CN");d&&(c.expertMessage=d.effectivePrompt)}e.sendWsMessage(c)||$r(e).then(()=>{e.sendWsMessage(c)}).catch(()=>{e.addMessageToConversation(t,{type:"system",content:Oe("chat.connection.reconnectFailed")}),delete e.processingConversations[t],Ve(e,t)})}function Ip(e,t){if(!t||!e.processingConversations[t])return;e.sendWsMessage({type:"cancel_execution",conversationId:t}),delete e.processingConversations[t],Ve(e,t),e._closedAt||(e._closedAt={}),e._closedAt[t]=Date.now();let s=e.executionStatusMap[t];s&&(s.currentTool=null),e.finishStreamingForConversation(t),Ws(e,t),e.addMessageToConversation(t,{type:"system",content:Oe("chat.execution.cancelled")})}function Cp(e){e.ws&&e.ws.readyState===WebSocket.OPEN&&(typeof e.requestYeaftSessionInventory=="function"?e.requestYeaftSessionInventory():e.sendWsMessage({type:"get_agents"}))}function Ap(e){!e.currentAgent||!e.currentConversation||e.sendWsMessage({type:"refresh_conversation",conversationId:e.currentConversation})}function xp(e,t,s,n){t&&e.sendWsMessage({type:"set_dream_enabled",agentId:t,enabled:s!==!1,requestId:n})}var Tp=B(()=>{Bs();hn();Va();no();ss();Qr();ji()});function Ab(e=globalThis.localStorage){try{return e?.getItem(Pp)==="yeaft"?"yeaft":Mp}catch{return Mp}}function hl(e,t=globalThis.localStorage){if(e!=="chat"&&e!=="yeaft")return!1;try{return t?.setItem(Pp,e),!!t}catch{return!1}}function Rp(e=globalThis.localStorage){let t=Ab(e);if(t!=="yeaft")return{currentView:t,_yeaftTransitionActive:!1,_savedActiveConversations:null,_savedChatIdentity:null,_pendingChatRestoreConversationId:null};let s=null;try{s=e?.getItem("lastViewedConversation")||null}catch{}let n=s&&!s.startsWith("yeaft-")?s:null;return{currentView:t,_yeaftTransitionActive:!0,_savedActiveConversations:null,_savedChatIdentity:null,_pendingChatRestoreConversationId:n}}function ml(e){return e._yeaftTransitionActive?!1:(e._savedActiveConversations=[...e.activeConversations],e._savedChatIdentity={agentId:e.currentAgent||null,agentInfo:e.currentAgentInfo?{...e.currentAgentInfo}:null,workDir:e.currentWorkDir||null},e._yeaftTransitionActive=!0,!0)}function _p(e){let t=ml(e);return e.activeConversations=[e.yeaftConversationId],t}function Ep(e){if(!e._yeaftTransitionActive)return null;let t=e._savedChatIdentity||null;return e.activeConversations=e._savedActiveConversations||[],t&&(e.currentAgent=t.agentId,e.currentAgentInfo=t.agentInfo,e.currentWorkDir=t.workDir),e._savedActiveConversations=null,e._savedChatIdentity=null,e._yeaftTransitionActive=!1,t}var Pp,Mp,Dp=B(()=>{Pp="yeaft-preferred-conversation-view",Mp="chat"});function $p(e,t,s){let n={...e||{}},r={...n[t]||{}};return r[s]=(r[s]||0)+1,n[t]=r,n}function Lp(e,t,s){let n={...e||{}},r={...n[t]||{}},i=(r[s]||0)-1;return i<=0?delete r[s]:r[s]=i,Object.keys(r).length===0?delete n[t]:n[t]=r,n}var Fp=B(()=>{});function oo(e){return e.currentView==="yeaft"?e.yeaftConversationId||null:e.activeConversations[0]||null}var Op=B(()=>{});function qp({loops:e,turnsById:t,turnOrder:s,maxLoops:n}){if(!Array.isArray(e)||e.length<=n)return{loops:e,turnsById:t,turnOrder:s};let r=e.length-n,i=e.slice(r),o=new Set;for(let c of i)c&&c.turnId&&o.add(c.turnId);for(let c of s){let d=t[c];d&&d.closedAt==null&&o.add(c)}let a={};for(let c of Object.keys(t))o.has(c)&&(a[c]=t[c]);let l=s.filter(c=>o.has(c));return{loops:i,turnsById:a,turnOrder:l}}var Vp=B(()=>{});function We(e){let t=Number(e);return Number.isFinite(t)?t:null}function Vt(e){let t=We(e);return Number.isInteger(t)&&t>0?t:null}function vl(e){let t=We(e);return Number.isInteger(t)&&t>=0?t:null}function Hp(e){return Mb.has(e)?1:0}function Pb(e,t){if(!e)return t||null;if(!t)return e;let s=We(e.progressRevision),n=We(t.progressRevision);if(s!=null||n!=null){if(s==null)return t;if(n==null)return e;if(s!==n)return n>s?t:e}let r=Hp(e.status),i=Hp(t.status);if(r!==i)return i>r?t:e;let o=We(e.updatedAt)??We(e.createdAt)??0;return(We(t.updatedAt)??We(t.createdAt)??0)>o?t:e}function Xn(e){return Math.max(0,Number(e)||0)}function Bp(e){return typeof e?.id=="string"&&e.id.startsWith("event:")?e.id.slice(6):null}function Rb(e,t){if(/^\d+$/.test(e)&&/^\d+$/.test(t)){let s=BigInt(e),n=BigInt(t);return s<n?-1:s>n?1:0}return e.localeCompare(t)}function _b(e,t){let s=Xn(e?.createdAt)-Xn(t?.createdAt);if(s)return s;let n=Bp(e),r=Bp(t);if(n!=null&&r!=null)return Rb(n,r);let i=e?.role==="user"?0:1,o=t?.role==="user"?0:1;if(i!==o)return i-o;let a=Xn(e?.generation)-Xn(t?.generation);return a||Xn(e?.attempt)-Xn(t?.attempt)||String(e?.id||"").localeCompare(String(t?.id||""))}function Zr(...e){let t=new Map;for(let s of e){let n=Array.isArray(s)?s:[s];for(let r of n)r?.id&&t.set(r.id,Pb(t.get(r.id),r))}return[...t.values()].sort(_b)}function Ht(e){let t=Number(e);return Number.isInteger(t)&&t>0?t:1}function Zn(e,t,s,n){return`${e}:${t}:${s}:${Ht(n)}`}function yl(e,t,s,n){return`${e}:${t}:${s}:${Ht(n)}`}function ao(e,t){let s=Vt(e?.dataRevision),n=Vt(t?.dataRevision);if(s!=null||n!=null)return s==null?-1:n==null?1:Math.sign(s-n);let r=We(e?.revision),i=We(t?.revision);return r!=null&&i!=null?Math.sign(r-i):0}function Jn(e,t){if(!e||!t||e.id!==t.id)return!1;let s=Vt(e.executionControl?.dataRevision)==null&&Vt(t.executionControl?.dataRevision)==null?ao(e.executionControl,t.executionControl):0;if(s<0)return!0;let n=We(e.revision),r=We(t.revision);if(n!=null&&r!=null&&n!==r)return n<r;let i=We(e.coordinatorRevision),o=We(t.coordinatorRevision);if(i!=null&&o!=null&&i!==o)return i<o;if(s>0)return!1;let a=We(e.updatedAt),l=We(t.updatedAt);return a!=null&&l!=null&&a<l}function Eb(e,t){return!e||!t||e.id!==t.id?!1:ao(e.executionControl,t.executionControl)<0||Jn(e,t)}function Xr(e,t,s){let n=ao(t.executionControl,e.executionControl),r=n>0||n===0&&s!==e&&t.executionControl?t.executionControl:e.executionControl,i=r===s.executionControl?s:{...s,executionControl:r};if(i.executionStats&&r?.usage){let o={...i.executionStats};for(let a of["llmRequestCount","inputTokens","outputTokens","cacheReadTokens","cacheWriteTokens","totalTokens"])Number.isFinite(r.usage[a])&&(o[a]=r.usage[a]);Object.keys(o).some(a=>o[a]!==i.executionStats[a])&&(i={...i,executionStats:o})}return i}function Np(e,t){if(Eb(e,t))return!0;if(!e||!t||e.id!==t.id)return!1;let s=We(e.revision),n=We(t.revision);return e.currentActionId!==t.currentActionId&&s!=null&&n!=null&&s<=n}function bl(e,t){let s=Vt(e?.generation),n=Vt(t?.generation);if(s!=null&&n!=null&&s!==n)return n<s;let r=vl(e?.attempt),i=vl(t?.attempt);if(r!=null&&i!=null&&r!==i)return i<r;let o=We(e?.progressRevision),a=We(t?.progressRevision);return o!=null&&a!=null&&a<o}function wl(e,t){if(!e||e.id!==t?.id||Jn(t,e))return null;let s=Array.isArray(e.actions)?e.actions:[],n=Array.isArray(t.actionStats)?t.actionStats:[],r=e.currentActionId||null,i=Object.prototype.hasOwnProperty.call(t,"currentActionId")?t.currentActionId||null:r,o=typeof t.eventActionId=="string"&&n.some(f=>f?.id===t.eventActionId)?t.eventActionId:null,a=o||r!==i&&r||i;if(!a)return null;let l=s.find(f=>f?.id===a)||null,c=n.find(f=>f?.id===a)||(t.currentAction?.id===a?t.currentAction:null);if(l&&c&&bl(l,c))return null;let d=Vt(l?.generation),u=Vt(c?.generation),g=vl(c?.attempt),p={actionId:a,generation:u||d||1,...g==null?{}:{attempt:g}};return o||r!==i||!l||d!=null&&u!=null&&u>d||l?.status==="running"&&c?.status&&c.status!=="running"?p:null}function Wp(e,t){if(!e||e.id!==t?.id||Jn(t,e))return!1;let s=We(t.coordinatorRevision),n=We(e.coordinatorRevision)??0;return s!=null&&s>n?!0:wl(e,t)!=null}function jp(e,t){if(!e||e.id!==t?.id)return e;if(Jn(t,e)||Il(e,t,e.actions,t.actionStats))return Xr(e,t,e);let s={...e},n=!Array.isArray(e.actions)||!Array.isArray(t.actionStats);if(Array.isArray(e.actions)&&Array.isArray(t.actionStats)){let i=new Map(t.actionStats.map(a=>[a?.id,a])),o=!1;n=!0,s.actions=e.actions.map(a=>{let l=i.get(a?.id);if(!l)return a;if(o=!0,bl(a,l))return n=!1,a;if(We(l?.progressRevision)==null){let{response:g,messages:p,...f}=l;return{...a,...f}}let d=Vt(a?.generation),u=Vt(l?.generation);if(d!=null&&u!=null&&u>d){let{messages:g,thread:p,liveMessage:f,response:m,failure:v,messageCursor:y,messageCount:h,failureReason:k,...S}=a;return{...S,...l}}return{...a,...l}}),o||(n=!1)}for(let i of Tb)!n&&Db.has(i)||i!=="executionControl"&&Object.prototype.hasOwnProperty.call(t,i)&&(s[i]=t[i]);let r=n?t:e;return s.executionControl=Xr(e,t,r).executionControl,Xr(e,s,s)}function kl(e,t){if(!Array.isArray(e)||!Array.isArray(t))return!1;let s=new Map(e.map(n=>[n?.id,n]));return t.some(n=>{let r=s.get(n?.id);return r?bl(r,n):!1})}function Sl(e,t){return(Vt(e?.executionControl?.dataRevision)!=null||Vt(t?.executionControl?.dataRevision)!=null||We(e?.executionControl?.revision)===We(t?.executionControl?.revision))&&We(e?.revision)===We(t?.revision)&&We(e?.coordinatorRevision)===We(t?.coordinatorRevision)&&We(e?.updatedAt)===We(t?.updatedAt)}function Il(e,t,s,n){return ao(t.executionControl,e.executionControl)<0&&Sl(e,t)&&!kl(n,s)}function Cl(e,t){if(!e||e.id!==t?.id)return t;let s=Jn(t,e)||Il(e,t,e.actions,t.actions)||Sl(e,t)&&kl(e.actions,t.actions);return Xr(e,t,s?e:t)}function An(e,t){let s=Array.isArray(e)?e:[],n=s.find(i=>i.id===t?.id)||null,r=n&&Jn(t,n)?n:t;return n&&r===t&&(Il(n,t,n.actionStats,t.actionStats)||Sl(n,t)&&kl(n.actionStats,t.actionStats))&&(r=n),r?.id?(n&&(r=Xr(n,t,r)),[r,...s.filter(i=>i.id!==r.id)].sort((i,o)=>Number(o.updatedAt||0)-Number(i.updatedAt||0))):s}var Tb,Mb,Db,Al=B(()=>{Tb=Object.freeze(["revision","planRevision","ledgerRevision","coordinatorRevision","title","goal","workItemType","planningMode","status","lifecycle","attentionState","activeActionIds","attentionActionIds","currentActionId","currentAction","executionStats","executionControl","failureReason","origin","linkedSessionIds","createdAt","updatedAt"]);Mb=new Set(["completed","failed","cancelled","superseded","interrupted"]);Db=new Set(["status","lifecycle","attentionState","activeActionIds","attentionActionIds","currentActionId","currentAction","executionStats","failureReason"])});function xn(e){return typeof e=="string"?e.trim():""}function Up(e){if(typeof e=="number"&&Number.isFinite(e)&&e>0)return e;if(typeof e=="string"&&e.trim()){let t=Date.parse(e);if(Number.isFinite(t))return t}return null}function ls(e){let t=Up(e);if(!t)return"";try{return new Intl.DateTimeFormat(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(new Date(t))}catch{return""}}function $b(e){return Array.isArray(e)?e.slice(0,100).map(t=>({content:xn(t?.content).slice(0,2e3),status:["pending","in_progress","completed"].includes(t?.status)?t.status:"pending",...xn(t?.activeForm)?{activeForm:xn(t.activeForm).slice(0,2e3)}:{}})).filter(t=>t.content):[]}function Tt(e){if(!e||typeof e!="object")return null;let t=xn(e.content).slice(0,1e5),s=$b(e.todos);if(!t&&s.length===0)return null;let n=e.role==="assistant"?"assistant":"user",r=Up(e.timestamp);return{id:xn(e.id).slice(0,256)||null,role:n,author:xn(e.author).slice(0,256)||(n==="assistant"?"Assistant":"User"),content:t,...r?{timestamp:r}:{},...s.length>0?{todos:s}:{}}}function Kp(e,t){return Tt({id:e?.messageId||e?.id||null,role:"user",author:t,content:e?.content||"",timestamp:e?.timestamp||e?.createdAt||e?.ts||e?.time||null})}function zp(e,t){let s=e?.todoMsg?.toolInput?.todos,n=Array.isArray(e?.toolMsgs)?e.toolMsgs.map(i=>xn(i?.toolName)).filter(Boolean):[],r=n.length>0?`Tool actions: ${n.join(", ")}`:"";return Tt({id:e?.atMessageId||e?.messageId||e?.id||e?.turnId||null,role:"assistant",author:t,content:e?.textContent||r,timestamp:e?.timestamp||e?.createdAt||e?.speakerTimestamp||null,todos:s})}var js=B(()=>{});function Yp(e){return typeof e=="string"?e:Array.isArray(e)?e.map(t=>typeof t=="string"?t:t?.type==="text"&&typeof t.text=="string"?t.text:"").join(""):e==null?"":String(e)}function Lb(e,t){if(!e||e.type!=="assistant")return!1;let s=e.sessionId??e.groupId??null,n=e.speakerVpId||e.vpId||null;return!(t.sessionId&&s!==t.sessionId||t.vpId&&n!==t.vpId||t.turnId&&e.turnId!==t.turnId)}function Gp(e,t={}){if(!Array.isArray(e)||!t.turnId)return!1;let s=e.filter(n=>Lb(n,t));if(s.length===0)return!1;for(let n of s)n.responseKind="progress";if(t.reason==="end_turn"){for(let n=s.length-1;n>=0;n-=1)if(Yp(s[n].content).trim()){s[n].responseKind="result";break}}return!0}function lo(e,t){if(!e||!t)return;let s=Yp(t.content);s&&(Array.isArray(e.textSegments)||(e.textSegments=[]),e.textSegments.push({key:t.messageId||t.id||`response-${e.textSegments.length}`,content:s,kind:t.responseKind==="result"?"result":"progress",explicitKind:t.responseKind==="progress"||t.responseKind==="result",isStreaming:t.isStreaming===!0}),e.textContent=e.textSegments.map(n=>n.content).join(`
6
+ `)+(s||"")}}function lp(e){return Object.values(rp).filter(t=>e||!t.adminOnly).sort((t,s)=>t.order-s.order)}var rp,Zt,ap,Cn,Qr=B(()=>{rp={dev:{id:"dev",name:"\u8F6F\u4EF6\u5F00\u53D1",nameEn:"Software Dev",icon:"\u{1F5A5}\uFE0F",order:0},trading:{id:"trading",name:"\u4EA4\u6613",nameEn:"Trading",icon:"\u{1F4C8}",order:1,adminOnly:!0},writing:{id:"writing",name:"\u5199\u4F5C",nameEn:"Writing",icon:"\u270D\uFE0F",order:2,adminOnly:!0},video:{id:"video",name:"\u89C6\u9891",nameEn:"Video",icon:"\u{1F3AC}",order:3,adminOnly:!0}},Zt={jobs:{id:"jobs",name:"Jobs",fullName:"Steve Jobs",title:"\u4EA7\u54C1\u7ECF\u7406",titleEn:"Product Manager",group:"dev",actions:[{id:"product-analysis",name:"\u4EA7\u54C1\u5206\u6790",nameEn:"Product Analysis"},{id:"design-review",name:"\u8BBE\u8BA1\u5BA1\u67E5",nameEn:"Design Review"},{id:"requirements",name:"\u9700\u6C42\u62C6\u89E3",nameEn:"Requirements"}]},fowler:{id:"fowler",name:"Fowler",fullName:"Martin Fowler",title:"\u8F6F\u4EF6\u67B6\u6784\u5E08",titleEn:"Software Architect",group:"dev",actions:[{id:"architecture",name:"\u67B6\u6784\u5BA1\u67E5",nameEn:"Architecture Review"},{id:"refactoring",name:"\u91CD\u6784\u5206\u6790",nameEn:"Refactoring"},{id:"code-review",name:"\u4EE3\u7801\u5BA1\u67E5",nameEn:"Code Review"}]},torvalds:{id:"torvalds",name:"Torvalds",fullName:"Linus Torvalds",title:"\u7CFB\u7EDF\u5F00\u53D1\u5DE5\u7A0B\u5E08",titleEn:"Systems Engineer",group:"dev",actions:[{id:"system-design",name:"\u7CFB\u7EDF\u8BBE\u8BA1",nameEn:"System Design"},{id:"performance",name:"\u6027\u80FD\u4F18\u5316",nameEn:"Performance"},{id:"code-style",name:"\u4EE3\u7801\u98CE\u683C",nameEn:"Code Style"},{id:"implementation",name:"\u4EE3\u7801\u5B9E\u73B0",nameEn:"Implementation"}]},beck:{id:"beck",name:"Beck",fullName:"Kent Beck",title:"\u6D4B\u8BD5\u5DE5\u7A0B\u5E08",titleEn:"Test Engineer",group:"dev",actions:[{id:"test-strategy",name:"\u6D4B\u8BD5\u7B56\u7565",nameEn:"Test Strategy"},{id:"tdd-guide",name:"TDD \u6307\u5BFC",nameEn:"TDD Guide"},{id:"quality-check",name:"\u8D28\u91CF\u8BC4\u4F30",nameEn:"Quality Check"}]},schneier:{id:"schneier",name:"Schneier",fullName:"Bruce Schneier",title:"\u5B89\u5168\u5DE5\u7A0B\u5E08",titleEn:"Security Engineer",group:"dev",actions:[{id:"security-audit",name:"\u5B89\u5168\u5BA1\u8BA1",nameEn:"Security Audit"},{id:"threat-model",name:"\u5A01\u80C1\u5EFA\u6A21",nameEn:"Threat Model"},{id:"auth-review",name:"\u8BA4\u8BC1\u5BA1\u67E5",nameEn:"Auth Review"}]},rams:{id:"rams",name:"Rams",fullName:"Dieter Rams",title:"UI/UX \u8BBE\u8BA1\u5E08",titleEn:"UI/UX Designer",group:"dev",actions:[{id:"ui-review",name:"\u754C\u9762\u5BA1\u67E5",nameEn:"UI Review"},{id:"interaction",name:"\u4EA4\u4E92\u8BBE\u8BA1",nameEn:"Interaction Design"},{id:"layout",name:"\u5E03\u5C40\u4F18\u5316",nameEn:"Layout Optimization"}]},graham:{id:"graham",name:"Graham",fullName:"Paul Graham",title:"\u6280\u672F\u5199\u4F5C / \u65B9\u6848\u8BC4\u4F30\u5E08",titleEn:"Tech Writer / Evaluator",group:"dev",actions:[{id:"writing",name:"\u6280\u672F\u5199\u4F5C",nameEn:"Tech Writing"},{id:"proposal-review",name:"\u65B9\u6848\u8BC4\u4F30",nameEn:"Proposal Review"},{id:"explain",name:"\u6982\u5FF5\u89E3\u91CA",nameEn:"Explain"}]},hightower:{id:"hightower",name:"Hightower",fullName:"Kelsey Hightower",title:"DevOps / \u8FD0\u7EF4\u5DE5\u7A0B\u5E08",titleEn:"DevOps Engineer",group:"dev",actions:[{id:"deployment",name:"\u90E8\u7F72\u5BA1\u67E5",nameEn:"Deployment Review"},{id:"cicd",name:"CI/CD \u8BC4\u4F30",nameEn:"CI/CD Review"},{id:"infra",name:"\u57FA\u7840\u8BBE\u65BD",nameEn:"Infrastructure"}]},gregg:{id:"gregg",name:"Gregg",fullName:"Brendan Gregg",title:"\u6027\u80FD\u5DE5\u7A0B\u5E08",titleEn:"Performance Engineer",group:"dev",actions:[{id:"perf-analysis",name:"\u6027\u80FD\u5206\u6790",nameEn:"Perf Analysis"},{id:"tuning",name:"\u7CFB\u7EDF\u8C03\u4F18",nameEn:"Tuning"},{id:"benchmark",name:"\u57FA\u51C6\u6D4B\u8BD5",nameEn:"Benchmark"}]},codd:{id:"codd",name:"Codd",fullName:"Edgar Codd",title:"\u6570\u636E\u5E93 / SQL \u4E13\u5BB6",titleEn:"Database / SQL Expert",group:"dev",actions:[{id:"sql-optimization",name:"SQL \u4F18\u5316",nameEn:"SQL Optimization"},{id:"schema-design",name:"Schema \u8BBE\u8BA1",nameEn:"Schema Design"},{id:"data-modeling",name:"\u6570\u636E\u5EFA\u6A21",nameEn:"Data Modeling"}]},knuth:{id:"knuth",name:"Knuth",fullName:"Donald Knuth",title:"\u7B97\u6CD5 / \u6570\u636E\u5904\u7406\u4E13\u5BB6",titleEn:"Algorithm Expert",group:"dev",actions:[{id:"algorithm-design",name:"\u7B97\u6CD5\u8BBE\u8BA1",nameEn:"Algorithm Design"},{id:"data-processing",name:"\u6570\u636E\u5904\u7406",nameEn:"Data Processing"},{id:"optimization",name:"\u4F18\u5316",nameEn:"Optimization"}]},thomas:{id:"thomas",name:"Thomas",fullName:"Dave Thomas",title:"\u6280\u672F\u6587\u6863\u5DE5\u7A0B\u5E08",titleEn:"Tech Doc Engineer",group:"dev",actions:[{id:"api-docs",name:"API \u6587\u6863",nameEn:"API Docs"},{id:"readme",name:"README",nameEn:"README"},{id:"comment-review",name:"\u6CE8\u91CA\u5BA1\u67E5",nameEn:"Comment Review"}]},soros:{id:"soros",name:"Soros",fullName:"George Soros",title:"\u5B8F\u89C2\u7B56\u7565\u5E08",titleEn:"Macro Strategist",group:"trading",actions:[{id:"macro-analysis",name:"\u5B8F\u89C2\u5206\u6790",nameEn:"Macro Analysis"},{id:"risk-assessment",name:"\u98CE\u9669\u8BC4\u4F30",nameEn:"Risk Assessment"},{id:"thesis-review",name:"\u8BBA\u70B9\u5BA1\u67E5",nameEn:"Thesis Review"}]},livermore:{id:"livermore",name:"Livermore",fullName:"Jesse Livermore",title:"\u6280\u672F\u5206\u6790\u5E08",titleEn:"Technical Analyst",group:"trading",actions:[{id:"price-action",name:"\u4EF7\u683C\u884C\u4E3A",nameEn:"Price Action"},{id:"pattern-recognition",name:"\u56FE\u5F62\u8BC6\u522B",nameEn:"Pattern Recognition"},{id:"trade-plan",name:"\u4EA4\u6613\u8BA1\u5212",nameEn:"Trade Plan"}]},dalio:{id:"dalio",name:"Dalio",fullName:"Ray Dalio",title:"\u7814\u7A76\u5458 / \u7ECF\u6D4E\u5206\u6790\u5E08",titleEn:"Research / Economist",group:"trading",actions:[{id:"economic-analysis",name:"\u7ECF\u6D4E\u5206\u6790",nameEn:"Economic Analysis"},{id:"portfolio-review",name:"\u7EC4\u5408\u5BA1\u67E5",nameEn:"Portfolio Review"},{id:"research-report",name:"\u7814\u7A76\u62A5\u544A",nameEn:"Research Report"}]},taleb:{id:"taleb",name:"Taleb",fullName:"Nassim Taleb",title:"\u98CE\u63A7\u5B98",titleEn:"Risk Manager",group:"trading",actions:[{id:"risk-audit",name:"\u98CE\u9669\u5BA1\u8BA1",nameEn:"Risk Audit"},{id:"antifragile",name:"\u53CD\u8106\u5F31\u8BC4\u4F30",nameEn:"Antifragile Assessment"},{id:"stress-test",name:"\u538B\u529B\u6D4B\u8BD5",nameEn:"Stress Test"}]},jones:{id:"jones",name:"Jones",fullName:"Paul Tudor Jones",title:"\u4EA4\u6613\u6267\u884C\u5458",titleEn:"Trade Executor",group:"trading",actions:[{id:"execution",name:"\u6267\u884C\u8BA1\u5212",nameEn:"Execution Plan"},{id:"position-sizing",name:"\u4ED3\u4F4D\u8BA1\u7B97",nameEn:"Position Sizing"},{id:"trade-review",name:"\u4EA4\u6613\u590D\u76D8",nameEn:"Trade Review"}]},simons:{id:"simons",name:"Simons",fullName:"Jim Simons",title:"\u91CF\u5316\u5206\u6790\u5E08",titleEn:"Quant Analyst",group:"trading",actions:[{id:"quant-signal",name:"\u91CF\u5316\u4FE1\u53F7",nameEn:"Quant Signal"},{id:"backtest-review",name:"\u56DE\u6D4B\u5BA1\u67E5",nameEn:"Backtest Review"},{id:"model-design",name:"\u6A21\u578B\u8BBE\u8BA1",nameEn:"Model Design"}]},jinyong:{id:"jinyong",name:"\u91D1\u5EB8",fullName:"\u91D1\u5EB8\uFF08Louis Cha\uFF09",title:"\u6B66\u4FA0\u5927\u5E08",titleEn:"Wuxia Master",group:"writing",actions:[{id:"world-building",name:"\u6B66\u4FA0\u4E16\u754C\u89C2",nameEn:"Wuxia World Building"},{id:"character-design",name:"\u4EBA\u7269\u5851\u9020",nameEn:"Character Design"},{id:"plot-design",name:"\u60C5\u8282\u7F16\u6392",nameEn:"Plot Design"}]},zhouzi:{id:"zhouzi",name:"\u8098\u5B50",fullName:"\u4F1A\u8BF4\u8BDD\u7684\u8098\u5B50",title:"\u7F51\u6587\u5929\u738B",titleEn:"Web Novel King",group:"writing",actions:[{id:"cool-factor",name:"\u723D\u611F\u8BBE\u8BA1",nameEn:"Cool Factor Design"},{id:"pacing",name:"\u8282\u594F\u628A\u63A7",nameEn:"Pacing Control"},{id:"cheat-design",name:"\u91D1\u624B\u6307\u8BBE\u8BA1",nameEn:"Cheat System Design"}]},qiongyao:{id:"qiongyao",name:"\u743C\u7476",fullName:"\u743C\u7476\uFF08Chiung Yao\uFF09",title:"\u8A00\u60C5\u5B97\u5E08",titleEn:"Romance Master",group:"writing",actions:[{id:"emotion-writing",name:"\u60C5\u611F\u63CF\u5199",nameEn:"Emotion Writing"},{id:"dialogue-design",name:"\u5BF9\u8BDD\u8BBE\u8BA1",nameEn:"Dialogue Design"},{id:"romance-arc",name:"\u8650\u604B\u67B6\u6784",nameEn:"Romance Arc"}]},luxun:{id:"luxun",name:"\u9C81\u8FC5",fullName:"\u9C81\u8FC5\uFF08Lu Xun\uFF09",title:"\u6587\u5B66\u5DE8\u5320",titleEn:"Literary Giant",group:"writing",actions:[{id:"satire",name:"\u8BBD\u523A\u5199\u4F5C",nameEn:"Satirical Writing"},{id:"character-sketch",name:"\u4EBA\u7269\u523B\u753B",nameEn:"Character Sketch"},{id:"prose-craft",name:"\u6587\u7B14\u9524\u70BC",nameEn:"Prose Craft"}]},kubrick:{id:"kubrick",name:"Kubrick",fullName:"Stanley Kubrick",title:"\u5BFC\u6F14 / \u89C6\u89C9\u603B\u76D1",titleEn:"Director / Visual Director",group:"video",actions:[{id:"narrative-pacing",name:"\u53D9\u4E8B\u8282\u594F",nameEn:"Narrative Pacing"},{id:"visual-concept",name:"\u89C6\u89C9\u6982\u5FF5",nameEn:"Visual Concept"},{id:"scene-breakdown",name:"\u573A\u666F\u62C6\u89E3",nameEn:"Scene Breakdown"}]},kaufman:{id:"kaufman",name:"Kaufman",fullName:"Charlie Kaufman",title:"\u7F16\u5267",titleEn:"Screenwriter",group:"video",actions:[{id:"script-writing",name:"\u811A\u672C\u5199\u4F5C",nameEn:"Script Writing"},{id:"character-design",name:"\u89D2\u8272\u8BBE\u8BA1",nameEn:"Character Design"},{id:"narrative-structure",name:"\u53D9\u4E8B\u7ED3\u6784",nameEn:"Narrative Structure"}]},spielberg:{id:"spielberg",name:"Spielberg",fullName:"Steven Spielberg",title:"\u5206\u955C / \u89C6\u89C9\u53D9\u4E8B\u5E08",titleEn:"Storyboard / Visual Storyteller",group:"video",actions:[{id:"storyboard",name:"\u5206\u955C\u8BBE\u8BA1",nameEn:"Storyboard"},{id:"shot-design",name:"\u955C\u5934\u65B9\u6848",nameEn:"Shot Design"},{id:"visual-storytelling",name:"\u89C6\u89C9\u53D9\u4E8B",nameEn:"Visual Storytelling"}]},schoonmaker:{id:"schoonmaker",name:"Schoonmaker",fullName:"Thelma Schoonmaker",title:"\u526A\u8F91\u5E08",titleEn:"Editor",group:"video",actions:[{id:"editing-rhythm",name:"\u526A\u8F91\u8282\u594F",nameEn:"Editing Rhythm"},{id:"sequence-design",name:"\u5E8F\u5217\u8BBE\u8BA1",nameEn:"Sequence Design"},{id:"final-cut",name:"\u6700\u7EC8\u5BA1\u7247",nameEn:"Final Cut"}]}};ap="dev",Cn=3});function Ib(e,t){return!t||!e?.yeaftConversationIdsByAgent?[]:Object.entries(e.yeaftConversationIdsByAgent).filter(([,s])=>s===t).map(([s])=>s).filter(Boolean)}function cp(){return`cm_${crypto.randomUUID()}`}function dp(e,t){if(t===e.currentAgent&&!e.pendingAgentSelection)return;let s=`agent_select_${crypto.randomUUID()}`;return e.agentSwitching=!0,e.pendingAgentSelection={agentId:t,requestId:s},e.sendWsMessage({type:"select_agent",agentId:t,requestId:s})===!1?(e.pendingAgentSelection=null,e.agentSwitching=!1,null):s}function up(e,t,s=null,n=null,r={}){let i=s||e.currentAgent;if(!i){e.addMessage({type:"error",content:Oe("chat.agent.selectFirst")});return}Bn(e,!0,Oe("chat.session.creating"));let o={type:"create_conversation",agentId:i,workDir:t||e.currentAgentWorkDir};n!==null&&(o.disallowedTools=n),r&&typeof r.provider=="string"&&(o.provider=r.provider),r&&r.providerOptions&&typeof r.providerOptions=="object"&&(o.providerOptions=r.providerOptions),e.sendWsMessage(o)}function pp(e,t,s,n=null,r=null,i=null){let o=n||e.currentAgent;if(!o){e.addMessage({type:"error",content:Oe("chat.agent.selectFirst")});return}let a=null,l={};r&&typeof r=="object"&&!Array.isArray(r)?l=r:(a=r,i&&typeof i=="object"&&(l=i));let c=gn(l.provider),d=(e.conversations||[]).find(p=>p.type!=="yeaft"&&p.agentId===o&&gn(p.provider)===c&&p.claudeSessionId===t),u=d&&(e.hiddenSessionCatalog||[]).find(p=>p.routeRef?.agentId===o&&p.routeRef?.runtimeProvider===c&&p.routeRef?.sessionId===d.id);if(u&&e.restoreCatalogSession(u)!==!0)return;Bn(e,!0,Oe("chat.session.loadingHistory"));let g={type:"resume_conversation",agentId:o,...d?{conversationId:d.id}:{},claudeSessionId:t,workDir:s||e.currentAgentWorkDir};a!==null&&(g.disallowedTools=a),typeof l.provider=="string"&&(g.provider=l.provider),l.providerOptions&&typeof l.providerOptions=="object"&&(g.providerOptions=l.providerOptions),e.sendWsMessage(g)}function gp(e,t,s,{refresh:n=!1}={}){if(e.panels.length>1){let a=e.activePanelId||e.panels[0]?.id;a&&e.setPanelConversation(a,t,{refresh:n});return}if(t===e.currentConversation){n&&(e.syncChatConversationHistory?.(t),fn(e));return}let r=e.conversations.find(a=>a.id===t&&a.type!=="yeaft");if(r&&r.agentId&&r.agentId!==e.currentAgent){let a=e.agents.find(l=>l.id===r.agentId);a&&(e.currentAgent=r.agentId,e.currentAgentInfo=a,e.sendWsMessage({type:"select_agent",agentId:r.agentId,silent:!0}))}e.sendWsMessage({type:"select_conversation",conversationId:t}),e.panels.length>1?e.activeConversations.includes(t)||e.activeConversations.push(t):e.activeConversations=[t],r&&(e.currentWorkDir=r.workDir);let i=e.messagesMap[t];(!i||i.length===0)&&(e.messagesMap[t]=[],Bn(e,!0,Oe("chat.session.loadingHistory"))),e.syncChatConversationHistory?.(t),e.loadingMoreMessages=!1;let o=e.chatSessionState[t];e.hasMoreMessages=!!o?.hasMoreOlder,fn(e)}function fl(e,t,s){t&&e.sendWsMessage({type:"update_conversation_settings",conversationId:t,...s})}function fp(e,t,s){let n=e.currentConversation;if(!n)return;let r=e.conversationMcpServers[n];if(r){let g=r.find(p=>p.name===t);g&&(g.enabled=s)}let i=e.conversationMcpServers[n]||[],o=e.conversationMcpServerTools[n]||{},a=[];for(let g of i)if(!g.enabled){let p=o[g.name];p&&p.length>0?a.push(...p):a.push(`mcp__${g.name}`)}let u=[...(e.conversations.find(g=>g.id===n)?.disallowedTools||[]).filter(g=>!g.startsWith("mcp__")),...a];fl(e,n,{disallowedTools:u})}function hp(e,t,s){return t?e.sendWsMessage({type:"delete_conversation",requestId:`delete_${crypto.randomUUID()}`,conversationId:t,...s?{agentId:s}:{}}):!1}function mp(e,t,s){e._recentlyDeletedSessions||(e._recentlyDeletedSessions={}),e._recentlyDeletedSessions[t]=Date.now(),e.conversations=e.conversations.filter(i=>i.id!==t);let n=e.activeConversations.indexOf(t);n>=0&&(e.activeConversations.splice(n,1),e.activeConversations.length===0&&(localStorage.removeItem("lastViewedConversation"),e.lastViewedConversation=null));for(let i of e.panels)i.conversationId===t&&(i.conversationId=null);let r=e.pinnedSessions.indexOf(t);r>=0&&(e.pinnedSessions.splice(r,1),localStorage.setItem("pinned-sessions",JSON.stringify(e.pinnedSessions))),e.sendWsMessage({type:"delete_conversation",requestId:`delete_${crypto.randomUUID()}`,conversationId:t,...s?{agentId:s}:{}})}function vp(e,t,s=[],n={}){let r=n.expertSelections&&n.expertSelections.length>0;if(!t.trim()&&s.length===0&&!r||!e.currentAgent||!e.currentConversation)return;let i=cp();if(e.addMessage({type:"user",content:t,clientMessageId:i,attachments:s.length>0?s:void 0,expertSelections:r?n.expertSelections:void 0}),t.trim()){let c=t.trim().substring(0,100);e.conversationTitles[e.currentConversation]=c}else if(r){let c=n.expertSelections[0],d=`@${c.role}${c.action?"\xB7"+c.action:""}`;e.conversationTitles[e.currentConversation]=d}let o=e.conversations.find(c=>c.id===e.currentConversation);o&&(o.lastMessageAt=Date.now()),e.processingConversations[e.currentConversation]||(e.processingConversations[e.currentConversation]=!0,e._closedAt?.[e.currentConversation]&&delete e._closedAt[e.currentConversation],e._turnCompletedConvs?.delete(e.currentConversation),e.getOrCreateExecutionStatus(e.currentConversation),Un(e,e.currentConversation));let a=s.map(c=>c.fileId),l={type:"chat",conversationId:e.currentConversation,prompt:t,fileIds:a,workDir:e.currentWorkDir,clientMessageId:i};if(n.targetRole&&(l.targetRole=n.targetRole),r){l.expertSelections=n.expertSelections;let c=gl(n.expertSelections,e.customExpertRoles,t,e.language||"zh-CN");c&&(l.expertMessage=c.effectivePrompt)}e.sendWsMessage(l)||$r(e).then(()=>{e.sendWsMessage(l)}).catch(()=>{e.addMessage({type:"system",content:Oe("chat.connection.reconnectFailed")}),delete e.processingConversations[e.currentConversation],Ve(e,e.currentConversation)})}function yp(e){if(!e.currentConversation||!e.processingConversations[e.currentConversation])return;let t=e.currentConversation;e.sendWsMessage({type:"cancel_execution",conversationId:t}),delete e.processingConversations[t],Ve(e,t),e._closedAt||(e._closedAt={}),e._closedAt[t]=Date.now();let s=e.executionStatusMap[t];s&&(s.currentTool=null),e.finishStreamingForConversation(t),Ws(e,t),e.addMessage({type:"system",content:Oe("chat.execution.cancelled")})}function bp(e,t,s,n){let r=n||e.currentConversation,o=(e.messagesMap[r]||[]).find(f=>f.type==="tool-use"&&f.toolName==="AskUserQuestion"&&f.askRequestId===t),a=e.currentView==="yeaft"||!!o?.sessionId;if(a&&(!o||o.askAnswered||o.askExpired)||a&&o.askPending&&Date.now()-(o.askSubmittedAt||0)<15e3)return!1;let l=o?.sessionId||e.yeaftActiveSessionFilter||null,c=typeof o?.agentId=="string"&&o.agentId?o.agentId:null,d=a?Ib(e,r):[],u=d.length===1?d[0]:null;if(c&&u&&c!==u)return!1;let g=a&&!c&&!u&&typeof e.agentIdForSession=="function"?e.agentIdForSession(l):null,p=e.sendWsMessage(a?{type:"yeaft_ask_user_answer",agentId:c||u||g||e.yeaftAgentId||e.currentAgent||null,conversationId:r,requestId:t,toolCallId:o?.toolId||null,answers:s,sessionId:l,vpId:o?.vpId||o?.speakerVpId||null,turnId:o?.turnId||null,threadId:o?.threadId||"main"}:{type:"ask_user_answer",conversationId:r,requestId:t,answers:s});o&&!a?(o.askAnswered=!0,o.selectedAnswers=s):o&&p!==!1?(o.askPending=!0,o.pendingAnswers=s,o.askSubmittedAt=Date.now(),o.askError=null):o&&(o.askError="send_failed"),!a&&p!==!1&&r&&!e.processingConversations[r]&&(e.processingConversations[r]=!0,e._closedAt?.[r]&&delete e._closedAt[r],e.getOrCreateExecutionStatus(r))}function wp(e,t){t&&(e.activeConversations.includes(t)||e.activeConversations.length>=3||(e.activeConversations.push(t),e.messagesMap[t]||(e.messagesMap[t]=[],e.requestChatHistory?.(t,{mode:"recent",turns:5})),fn(e)))}function kp(e,t){let s=e.activeConversations.indexOf(t);s<0||(e.activeConversations.splice(s,1),e.activeConversations.length===0&&(localStorage.removeItem("lastViewedConversation"),e.lastViewedConversation=null),fn(e))}function Sp(e,t,s,n=[],r={}){let i=r.expertSelections&&r.expertSelections.length>0;if(!s.trim()&&n.length===0&&!i||!e.currentAgent||!t)return;let o=cp();if(e.addMessageToConversation(t,{type:"user",content:s,clientMessageId:o,attachments:n.length>0?n:void 0,expertSelections:i?r.expertSelections:void 0}),s.trim()){let d=s.trim().substring(0,100);e.conversationTitles[t]=d}else if(i){let d=r.expertSelections[0],u=`@${d.role}${d.action?"\xB7"+d.action:""}`;e.conversationTitles[t]=u}let a=e.conversations.find(d=>d.id===t);a&&(a.lastMessageAt=Date.now()),e.processingConversations[t]||(e.processingConversations[t]=!0,e._closedAt?.[t]&&delete e._closedAt[t],e._turnCompletedConvs?.delete(t),e.getOrCreateExecutionStatus(t),Un(e,t));let l=n.map(d=>d.fileId),c={type:"chat",conversationId:t,prompt:s,fileIds:l,workDir:a?.workDir||e.currentWorkDir,clientMessageId:o};if(r.targetRole&&(c.targetRole=r.targetRole),i){c.expertSelections=r.expertSelections;let d=gl(r.expertSelections,e.customExpertRoles,s,e.language||"zh-CN");d&&(c.expertMessage=d.effectivePrompt)}e.sendWsMessage(c)||$r(e).then(()=>{e.sendWsMessage(c)}).catch(()=>{e.addMessageToConversation(t,{type:"system",content:Oe("chat.connection.reconnectFailed")}),delete e.processingConversations[t],Ve(e,t)})}function Ip(e,t){if(!t||!e.processingConversations[t])return;e.sendWsMessage({type:"cancel_execution",conversationId:t}),delete e.processingConversations[t],Ve(e,t),e._closedAt||(e._closedAt={}),e._closedAt[t]=Date.now();let s=e.executionStatusMap[t];s&&(s.currentTool=null),e.finishStreamingForConversation(t),Ws(e,t),e.addMessageToConversation(t,{type:"system",content:Oe("chat.execution.cancelled")})}function Cp(e){e.ws&&e.ws.readyState===WebSocket.OPEN&&(typeof e.requestYeaftSessionInventory=="function"?e.requestYeaftSessionInventory():e.sendWsMessage({type:"get_agents"}))}function Ap(e){!e.currentAgent||!e.currentConversation||e.sendWsMessage({type:"refresh_conversation",conversationId:e.currentConversation})}function xp(e,t,s,n){t&&e.sendWsMessage({type:"set_dream_enabled",agentId:t,enabled:s!==!1,requestId:n})}var Tp=B(()=>{Bs();hn();Va();no();ss();Qr();ji()});function Ab(e=globalThis.localStorage){try{return e?.getItem(Pp)==="yeaft"?"yeaft":Mp}catch{return Mp}}function hl(e,t=globalThis.localStorage){if(e!=="chat"&&e!=="yeaft")return!1;try{return t?.setItem(Pp,e),!!t}catch{return!1}}function Rp(e=globalThis.localStorage){let t=Ab(e);if(t!=="yeaft")return{currentView:t,_yeaftTransitionActive:!1,_savedActiveConversations:null,_savedChatIdentity:null,_pendingChatRestoreConversationId:null};let s=null;try{s=e?.getItem("lastViewedConversation")||null}catch{}let n=s&&!s.startsWith("yeaft-")?s:null;return{currentView:t,_yeaftTransitionActive:!0,_savedActiveConversations:null,_savedChatIdentity:null,_pendingChatRestoreConversationId:n}}function ml(e){return e._yeaftTransitionActive?!1:(e._savedActiveConversations=[...e.activeConversations],e._savedChatIdentity={agentId:e.currentAgent||null,agentInfo:e.currentAgentInfo?{...e.currentAgentInfo}:null,workDir:e.currentWorkDir||null},e._yeaftTransitionActive=!0,!0)}function _p(e){let t=ml(e);return e.activeConversations=[e.yeaftConversationId],t}function Ep(e){if(!e._yeaftTransitionActive)return null;let t=e._savedChatIdentity||null;return e.activeConversations=e._savedActiveConversations||[],t&&(e.currentAgent=t.agentId,e.currentAgentInfo=t.agentInfo,e.currentWorkDir=t.workDir),e._savedActiveConversations=null,e._savedChatIdentity=null,e._yeaftTransitionActive=!1,t}var Pp,Mp,Dp=B(()=>{Pp="yeaft-preferred-conversation-view",Mp="chat"});function $p(e,t,s){let n={...e||{}},r={...n[t]||{}};return r[s]=(r[s]||0)+1,n[t]=r,n}function Lp(e,t,s){let n={...e||{}},r={...n[t]||{}},i=(r[s]||0)-1;return i<=0?delete r[s]:r[s]=i,Object.keys(r).length===0?delete n[t]:n[t]=r,n}var Fp=B(()=>{});function oo(e){return e.currentView==="yeaft"?e.yeaftConversationId||null:e.activeConversations[0]||null}var Op=B(()=>{});function qp({loops:e,turnsById:t,turnOrder:s,maxLoops:n}){if(!Array.isArray(e)||e.length<=n)return{loops:e,turnsById:t,turnOrder:s};let r=e.length-n,i=e.slice(r),o=new Set;for(let c of i)c&&c.turnId&&o.add(c.turnId);for(let c of s){let d=t[c];d&&d.closedAt==null&&o.add(c)}let a={};for(let c of Object.keys(t))o.has(c)&&(a[c]=t[c]);let l=s.filter(c=>o.has(c));return{loops:i,turnsById:a,turnOrder:l}}var Vp=B(()=>{});function We(e){let t=Number(e);return Number.isFinite(t)?t:null}function Vt(e){let t=We(e);return Number.isInteger(t)&&t>0?t:null}function vl(e){let t=We(e);return Number.isInteger(t)&&t>=0?t:null}function Hp(e){return Mb.has(e)?1:0}function Pb(e,t){if(!e)return t||null;if(!t)return e;let s=We(e.progressRevision),n=We(t.progressRevision);if(s!=null||n!=null){if(s==null)return t;if(n==null)return e;if(s!==n)return n>s?t:e}let r=Hp(e.status),i=Hp(t.status);if(r!==i)return i>r?t:e;let o=We(e.updatedAt)??We(e.createdAt)??0;return(We(t.updatedAt)??We(t.createdAt)??0)>o?t:e}function Xn(e){return Math.max(0,Number(e)||0)}function Bp(e){return typeof e?.id=="string"&&e.id.startsWith("event:")?e.id.slice(6):null}function Rb(e,t){if(/^\d+$/.test(e)&&/^\d+$/.test(t)){let s=BigInt(e),n=BigInt(t);return s<n?-1:s>n?1:0}return e.localeCompare(t)}function _b(e,t){let s=Xn(e?.createdAt)-Xn(t?.createdAt);if(s)return s;let n=Bp(e),r=Bp(t);if(n!=null&&r!=null)return Rb(n,r);let i=e?.role==="user"?0:1,o=t?.role==="user"?0:1;if(i!==o)return i-o;let a=Xn(e?.generation)-Xn(t?.generation);return a||Xn(e?.attempt)-Xn(t?.attempt)||String(e?.id||"").localeCompare(String(t?.id||""))}function Zr(...e){let t=new Map;for(let s of e){let n=Array.isArray(s)?s:[s];for(let r of n)r?.id&&t.set(r.id,Pb(t.get(r.id),r))}return[...t.values()].sort(_b)}function Ht(e){let t=Number(e);return Number.isInteger(t)&&t>0?t:1}function Zn(e,t,s,n){return`${e}:${t}:${s}:${Ht(n)}`}function yl(e,t,s,n){return`${e}:${t}:${s}:${Ht(n)}`}function ao(e,t){let s=Vt(e?.dataRevision),n=Vt(t?.dataRevision);if(s!=null||n!=null)return s==null?-1:n==null?1:Math.sign(s-n);let r=We(e?.revision),i=We(t?.revision);return r!=null&&i!=null?Math.sign(r-i):0}function Jn(e,t){if(!e||!t||e.id!==t.id)return!1;let s=Vt(e.executionControl?.dataRevision)==null&&Vt(t.executionControl?.dataRevision)==null?ao(e.executionControl,t.executionControl):0;if(s<0)return!0;let n=We(e.revision),r=We(t.revision);if(n!=null&&r!=null&&n!==r)return n<r;let i=We(e.coordinatorRevision),o=We(t.coordinatorRevision);if(i!=null&&o!=null&&i!==o)return i<o;if(s>0)return!1;let a=We(e.updatedAt),l=We(t.updatedAt);return a!=null&&l!=null&&a<l}function Eb(e,t){return!e||!t||e.id!==t.id?!1:ao(e.executionControl,t.executionControl)<0||Jn(e,t)}function Xr(e,t,s){let n=ao(t.executionControl,e.executionControl),r=n>0||n===0&&s!==e&&t.executionControl?t.executionControl:e.executionControl,i=r===s.executionControl?s:{...s,executionControl:r};if(i.executionStats&&r?.usage){let o={...i.executionStats};for(let a of["llmRequestCount","inputTokens","outputTokens","cacheReadTokens","cacheWriteTokens","totalTokens"])Number.isFinite(r.usage[a])&&(o[a]=r.usage[a]);Object.keys(o).some(a=>o[a]!==i.executionStats[a])&&(i={...i,executionStats:o})}return i}function Np(e,t){if(Eb(e,t))return!0;if(!e||!t||e.id!==t.id)return!1;let s=We(e.revision),n=We(t.revision);return e.currentActionId!==t.currentActionId&&s!=null&&n!=null&&s<=n}function bl(e,t){let s=Vt(e?.generation),n=Vt(t?.generation);if(s!=null&&n!=null&&s!==n)return n<s;let r=vl(e?.attempt),i=vl(t?.attempt);if(r!=null&&i!=null&&r!==i)return i<r;let o=We(e?.progressRevision),a=We(t?.progressRevision);return o!=null&&a!=null&&a<o}function wl(e,t){if(!e||e.id!==t?.id||Jn(t,e))return null;let s=Array.isArray(e.actions)?e.actions:[],n=Array.isArray(t.actionStats)?t.actionStats:[],r=e.currentActionId||null,i=Object.prototype.hasOwnProperty.call(t,"currentActionId")?t.currentActionId||null:r,o=typeof t.eventActionId=="string"&&n.some(f=>f?.id===t.eventActionId)?t.eventActionId:null,a=o||r!==i&&r||i;if(!a)return null;let l=s.find(f=>f?.id===a)||null,c=n.find(f=>f?.id===a)||(t.currentAction?.id===a?t.currentAction:null);if(l&&c&&bl(l,c))return null;let d=Vt(l?.generation),u=Vt(c?.generation),g=vl(c?.attempt),p={actionId:a,generation:u||d||1,...g==null?{}:{attempt:g}};return o||r!==i||!l||d!=null&&u!=null&&u>d||l?.status==="running"&&c?.status&&c.status!=="running"?p:null}function Wp(e,t){if(!e||e.id!==t?.id||Jn(t,e))return!1;let s=We(t.coordinatorRevision),n=We(e.coordinatorRevision)??0;return s!=null&&s>n?!0:wl(e,t)!=null}function jp(e,t){if(!e||e.id!==t?.id)return e;if(Jn(t,e)||Il(e,t,e.actions,t.actionStats))return Xr(e,t,e);let s={...e},n=!Array.isArray(e.actions)||!Array.isArray(t.actionStats);if(Array.isArray(e.actions)&&Array.isArray(t.actionStats)){let i=new Map(t.actionStats.map(a=>[a?.id,a])),o=!1;n=!0,s.actions=e.actions.map(a=>{let l=i.get(a?.id);if(!l)return a;if(o=!0,bl(a,l))return n=!1,a;if(We(l?.progressRevision)==null){let{response:g,messages:p,...f}=l;return{...a,...f}}let d=Vt(a?.generation),u=Vt(l?.generation);if(d!=null&&u!=null&&u>d){let{messages:g,thread:p,liveMessage:f,response:m,failure:v,messageCursor:b,messageCount:h,failureReason:k,...S}=a;return{...S,...l}}return{...a,...l}}),o||(n=!1)}for(let i of Tb)!n&&Db.has(i)||i!=="executionControl"&&Object.prototype.hasOwnProperty.call(t,i)&&(s[i]=t[i]);let r=n?t:e;return s.executionControl=Xr(e,t,r).executionControl,Xr(e,s,s)}function kl(e,t){if(!Array.isArray(e)||!Array.isArray(t))return!1;let s=new Map(e.map(n=>[n?.id,n]));return t.some(n=>{let r=s.get(n?.id);return r?bl(r,n):!1})}function Sl(e,t){return(Vt(e?.executionControl?.dataRevision)!=null||Vt(t?.executionControl?.dataRevision)!=null||We(e?.executionControl?.revision)===We(t?.executionControl?.revision))&&We(e?.revision)===We(t?.revision)&&We(e?.coordinatorRevision)===We(t?.coordinatorRevision)&&We(e?.updatedAt)===We(t?.updatedAt)}function Il(e,t,s,n){return ao(t.executionControl,e.executionControl)<0&&Sl(e,t)&&!kl(n,s)}function Cl(e,t){if(!e||e.id!==t?.id)return t;let s=Jn(t,e)||Il(e,t,e.actions,t.actions)||Sl(e,t)&&kl(e.actions,t.actions);return Xr(e,t,s?e:t)}function An(e,t){let s=Array.isArray(e)?e:[],n=s.find(i=>i.id===t?.id)||null,r=n&&Jn(t,n)?n:t;return n&&r===t&&(Il(n,t,n.actionStats,t.actionStats)||Sl(n,t)&&kl(n.actionStats,t.actionStats))&&(r=n),r?.id?(n&&(r=Xr(n,t,r)),[r,...s.filter(i=>i.id!==r.id)].sort((i,o)=>Number(o.updatedAt||0)-Number(i.updatedAt||0))):s}var Tb,Mb,Db,Al=B(()=>{Tb=Object.freeze(["revision","planRevision","ledgerRevision","coordinatorRevision","title","goal","workItemType","planningMode","status","lifecycle","attentionState","activeActionIds","attentionActionIds","currentActionId","currentAction","executionStats","executionControl","failureReason","origin","linkedSessionIds","createdAt","updatedAt"]);Mb=new Set(["completed","failed","cancelled","superseded","interrupted"]);Db=new Set(["status","lifecycle","attentionState","activeActionIds","attentionActionIds","currentActionId","currentAction","executionStats","failureReason"])});function xn(e){return typeof e=="string"?e.trim():""}function Up(e){if(typeof e=="number"&&Number.isFinite(e)&&e>0)return e;if(typeof e=="string"&&e.trim()){let t=Date.parse(e);if(Number.isFinite(t))return t}return null}function ls(e){let t=Up(e);if(!t)return"";try{return new Intl.DateTimeFormat(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(new Date(t))}catch{return""}}function $b(e){return Array.isArray(e)?e.slice(0,100).map(t=>({content:xn(t?.content).slice(0,2e3),status:["pending","in_progress","completed"].includes(t?.status)?t.status:"pending",...xn(t?.activeForm)?{activeForm:xn(t.activeForm).slice(0,2e3)}:{}})).filter(t=>t.content):[]}function Tt(e){if(!e||typeof e!="object")return null;let t=xn(e.content).slice(0,1e5),s=$b(e.todos);if(!t&&s.length===0)return null;let n=e.role==="assistant"?"assistant":"user",r=Up(e.timestamp);return{id:xn(e.id).slice(0,256)||null,role:n,author:xn(e.author).slice(0,256)||(n==="assistant"?"Assistant":"User"),content:t,...r?{timestamp:r}:{},...s.length>0?{todos:s}:{}}}function Kp(e,t){return Tt({id:e?.messageId||e?.id||null,role:"user",author:t,content:e?.content||"",timestamp:e?.timestamp||e?.createdAt||e?.ts||e?.time||null})}function zp(e,t){let s=e?.todoMsg?.toolInput?.todos,n=Array.isArray(e?.toolMsgs)?e.toolMsgs.map(i=>xn(i?.toolName)).filter(Boolean):[],r=n.length>0?`Tool actions: ${n.join(", ")}`:"";return Tt({id:e?.atMessageId||e?.messageId||e?.id||e?.turnId||null,role:"assistant",author:t,content:e?.textContent||r,timestamp:e?.timestamp||e?.createdAt||e?.speakerTimestamp||null,todos:s})}var js=B(()=>{});function Yp(e){return typeof e=="string"?e:Array.isArray(e)?e.map(t=>typeof t=="string"?t:t?.type==="text"&&typeof t.text=="string"?t.text:"").join(""):e==null?"":String(e)}function Lb(e,t){if(!e||e.type!=="assistant")return!1;let s=e.sessionId??e.groupId??null,n=e.speakerVpId||e.vpId||null;return!(t.sessionId&&s!==t.sessionId||t.vpId&&n!==t.vpId||t.turnId&&e.turnId!==t.turnId)}function Gp(e,t={}){if(!Array.isArray(e)||!t.turnId)return!1;let s=e.filter(n=>Lb(n,t));if(s.length===0)return!1;for(let n of s)n.responseKind="progress";if(t.reason==="end_turn"){for(let n=s.length-1;n>=0;n-=1)if(Yp(s[n].content).trim()){s[n].responseKind="result";break}}return!0}function lo(e,t){if(!e||!t)return;let s=Yp(t.content);s&&(Array.isArray(e.textSegments)||(e.textSegments=[]),e.textSegments.push({key:t.messageId||t.id||`response-${e.textSegments.length}`,content:s,kind:t.responseKind==="result"?"result":"progress",explicitKind:t.responseKind==="progress"||t.responseKind==="result",isStreaming:t.isStreaming===!0}),e.textContent=e.textSegments.map(n=>n.content).join(`
7
7
 
8
- `))}function co(e){let t=Array.isArray(e?.textSegments)?e.textSegments:[];if(t.length===0)return;let s=Array.isArray(e?.messages)?e.messages:[],n=e?.isActive===!0||e?.isStreaming===!0||t.some(l=>l.isStreaming===!0)||s.some(l=>l?.isStreaming===!0||l?.status==="pending"),r=s.some(l=>l?.incomplete===!0||xl.has(l?.status)||xl.has(l?.turnEndReason)||xl.has(l?.stopReason));if(n||r){for(let l of t)l.kind="progress";return}if(t.some(l=>l.kind==="result"))return;let i=s.some(l=>l?.turnEndReason==="end_turn"),o=t.some(l=>l.explicitKind),a=t.length===1&&!o;(i||a||e.isHistory&&!o)&&(t[t.length-1].kind="result")}var xl,uo=B(()=>{xl=new Set(["aborted","errored","error","cancelled","canceled"])});function Cs(e){return typeof e=="string"?e.trim():""}function yt(e){let t=Cs(e?.runtimeProvider),s=Cs(e?.agentId),n=Cs(e?.sessionId);return!t||!s||!n?"":[t,s,n].map(r=>encodeURIComponent(r)).join(":")}function Fb(e){let t=0xcbf29ce484222325n;for(let s of String(e||""))t^=BigInt(s.codePointAt(0)),t=BigInt.asUintN(64,t*0x100000001b3n);return t.toString(16).padStart(16,"0")}function Tn(e,t){let s=Cs(e),n=Cs(t);return!s||!n?"":`${s}@${Fb(n)}`}function Jr(e,t="main"){if(!e)return"";let s=["main","files-folder-picker","git-folder-picker"].includes(t)?t:"main";return s==="main"?`_workbench:${e}`:`_workbench:${e}:${s}`}function cs(e,t){let s=Cs(e?.conversationId);if(!t||!s)return null;if(s===Jr(t))return"main";for(let n of["files-folder-picker","git-folder-picker"])if(s===Jr(t,n))return n;return null}function er(e,t){let s=(n={})=>{let r={runtimeProvider:Cs(t.runtimeProvider),agentId:Cs(t.agentId),sessionId:Cs(t.sessionId)},i="main";n.conversationId==="_folder_picker"?i="files-folder-picker":n.conversationId==="_git_folder_picker"&&(i="git-folder-picker");let o={...n,agentId:r.agentId,workbenchRoute:r,workbenchRouteKey:t.routeKey,workbenchWorkspaceGeneration:t.workspaceGeneration,workbenchScope:i,conversationId:Jr(t.routeKey,i)};return!Object.hasOwn(o,"workDir")&&t.workDir&&(o.workDir=t.workDir),e.sendWsMessage(o)};return new Proxy(e,{get(n,r,i){return r==="currentAgent"?t.agentId||null:r==="currentConversation"?t.conversationId||t.sessionId||null:r==="effectiveWorkDir"?t.workDir||"":r==="activeSessionRoute"?{runtimeProvider:t.runtimeProvider,agentId:t.agentId,sessionId:t.sessionId}:r==="sendWsMessage"?s:Reflect.get(n,r,i)},set(n,r,i,o){return Reflect.set(n,r,i,o)}})}function tr(e,t,s=""){return t?(e?.workbenchRouteKey?e.workbenchRouteKey===t:cs(e,t)!==null)?s?e?.workbenchWorkspaceGeneration===s:!0:!1:!0}var As=B(()=>{});function Tl(e){return e?.type==="user"&&typeof e.content=="string"&&e.content.trim()}function Ml(e){return e?.type==="assistant"||e?.type==="thinking"||e?.type==="tool_use"||e?.type==="tool-use"||e?.type==="tool_result"||e?.type==="tool-result"}function Pl(e,t){if(!e||e.kind!=="assistant")return!0;let s=e.turnId||e.lastTurnId||"",n=t?.turnId||"";if(s&&n&&s!==n)return!0;let r=e.speakerVpId||"",i=t?.speakerVpId||t?.vpId||"";return!!(r&&i&&r!==i)}function Rl(e=[]){let t=[],s=null,n=r=>{s&&(t.push({start:s.start,end:r,kind:s.kind}),s=null)};for(let r=0;r<e.length;r++){let i=e[r];if(i){if(Tl(i)||i.type==="system"||i.type==="error"){n(r),s={start:r,kind:i.type};continue}if(!Ml(i)){s||(s={start:r,kind:"other"});continue}(!s||s.kind==="assistant"&&Pl(s,i))&&(n(r),s={start:r,kind:"assistant",turnId:i.turnId||"",speakerVpId:i.speakerVpId||i.vpId||""}),s.lastTurnId=i.turnId||s.lastTurnId||"",s.speakerVpId=s.speakerVpId||i.speakerVpId||i.vpId||""}}return n(e.length),t}function Qp(e,t){return!e||e._historyWindowPrefetched===!0?!1:t?(e.sessionId??e.groupId)===t:!0}function _l(e=[],t=null,s=ei,n=null){let r=Math.max(1,Number.isFinite(s)?Math.floor(s):ei),i=[],o=[],a=null,l=d=>{a&&(o.push({start:a.start,end:d,kind:a.kind}),a=null)};for(let d of e){if(!Qp(d,t))continue;let u=i.length;if(i.push(d),Tl(d)||d.type==="system"||d.type==="error"){l(u),a={start:u,kind:d.type};continue}if(!Ml(d)){a||(a={start:u,kind:"other"});continue}(!a||a.kind==="assistant"&&Pl(a,d))&&(l(u),a={start:u,kind:"assistant",turnId:d.turnId||"",speakerVpId:d.speakerVpId||d.vpId||""}),a.lastTurnId=d.turnId||a.lastTurnId||"",a.speakerVpId=a.speakerVpId||d.speakerVpId||d.vpId||""}if(l(i.length),o.length<=r)return i;let c=o[o.length-r];return i.slice(c.start)}function Xp(e=[],t=null,s=ei){let n=Math.max(1,s||ei),r=0,i=null,o=()=>i?(i=null,r+=1,r>n):!1;for(let a of e)if(Qp(a,t)){if(Tl(a)||a.type==="system"||a.type==="error"){if(o())return!0;i={kind:a.type};continue}if(!Ml(a)){i||(i={kind:"other"});continue}if(!i||i.kind==="assistant"&&Pl(i,a)){if(o())return!0;i={kind:"assistant",turnId:a.turnId||"",speakerVpId:a.speakerVpId||a.vpId||""}}i.lastTurnId=a.turnId||i.lastTurnId||"",i.speakerVpId=i.speakerVpId||a.speakerVpId||a.vpId||""}return o(),r>n}function Us(){return ei}function ti(){return Ob}var ei,Ob,Zp=B(()=>{ei=Number.POSITIVE_INFINITY,Ob=20});function Vb(e,t){let s=new Set;if(!t)return s;for(let n of e?.sessionCatalog||[])n?.runtimeProvider!=="yeaft"||n?.routeRef?.sessionId!==t||n.routeRef.agentId&&s.add(n.routeRef.agentId);if(s.size===0){let n=ds();for(let r of n?.sessionList||[])r?.id===t&&r?.agentId&&s.add(r.agentId)}return s}function gg(e,t){let s=Vb(e,t);return s.size===1?s.values().next().value:null}function fo(e,t,s){return!!s&&gg(e,t)===s}function Rt(e,t,s){return!e||e.sessionId!==t?!1:s?e.agentId===s:!e.agentId}function Jp(e,t,s=null){if(!t)return!1;let n=s||$e(e,t),r=Is(n,t);if(r&&e.yeaftProcessingSessions?.[r]||e.yeaftProcessingSessions?.[t]&&fo(e,t,n))return!0;for(let i of Object.values(e.activeVpTurns||{}))if(Rt(i,t,n))return!0;for(let i of Object.values(e.vpStatuses||{}))if(Rt(i,t,n)&&ni.has(i?.state))return!0;return!1}function Hb(e,t,s,n=null){let r={...e.yeaftProcessingSessions||{}};if(t){let i=dl(t);if(r=Object.fromEntries(Object.entries(r).filter(([o])=>n?o!==Is(t,n):!o.startsWith(i))),n)fo(e,n,t)&&delete r[n];else for(let o of Object.keys(r))fo(e,o,t)&&delete r[o]}else n?delete r[n]:r={};for(let i of s||[]){let o=i?.sessionId||i?.groupId||null;if(!o||!ni.has(i?.state))continue;let a=Is(t,o)||o;r[a]=!0}return r}function Mn(e,t,s){let n=ul(t,s);return n&&e?.activeVpTurns?.[n]?n:e?.activeVpTurns?.[s]&&(!t||!e.activeVpTurns[s]?.agentId||e.activeVpTurns[s].agentId===t)?s:n||s||""}function eg(e,t){if(!t){e.activeVpTurns={},e.stoppingVpTurnIds={},e.vpStatuses={},e.yeaftProcessingSessions={};return}e.activeVpTurns=Object.fromEntries(Object.entries(e.activeVpTurns||{}).filter(([,n])=>n?.agentId&&n.agentId!==t)),e.stoppingVpTurnIds=Object.fromEntries(Object.entries(e.stoppingVpTurnIds||{}).filter(([n])=>e.activeVpTurns?.[n])),e.vpStatuses=Object.fromEntries(Object.entries(e.vpStatuses||{}).filter(([,n])=>n?.agentId&&n.agentId!==t));let s=dl(t);e.yeaftProcessingSessions=Object.fromEntries(Object.entries(e.yeaftProcessingSessions||{}).filter(([n])=>!n.startsWith(s)))}function xs(e,t){return`${e||""}:${t||""}`}function Gb(e){return e?.kind==="action"&&typeof e.actionId=="string"&&Number.isInteger(Number(e.generation))&&Number(e.generation)>0?{kind:"action",actionId:e.actionId,generation:Number(e.generation)}:{kind:"coordinator"}}function Qb(e){return typeof e=="string"?e:e?.kind==="action"&&typeof e.actionId=="string"?{kind:"action",actionId:e.actionId,generation:Number.isInteger(Number(e.generation))?Number(e.generation):0}:{kind:"coordinator"}}function Xb(e={}){let t=Tt(e.quote);return{agentId:e.agentId||"",workItemId:e.workItemId||"",target:Gb(e.target),text:String(e.text||""),...t?{quote:t}:{},attachments:Array.isArray(e.attachments)?e.attachments.map(s=>({fileId:s?.fileId||"",name:s?.name||"",mimeType:s?.mimeType||"",size:Math.max(0,Number(s?.size)||0)})):[],revision:Number(e.revision)||0,planRevision:Number(e.planRevision)||0,ledgerRevision:Number(e.ledgerRevision)||0,coordinatorRevision:Number(e.coordinatorRevision)||0}}function ng(e,t,s){return{conversationId:s||null,agentId:e?.agentId||t?.agentId||null,requestId:t?.requestId||null,toolCallId:t?.toolCallId||null,sessionId:e?.sessionId||t?.sessionId||null,vpId:e?.vpId||t?.vpId||null,turnId:e?.turnId||t?.turnId||null,threadId:e?.threadId||t?.threadId||null}}function rg(e,t){return{conversationId:t||null,agentId:e?.agentId||null,requestId:e?.askRequestId||null,toolCallId:e?.toolId||null,sessionId:e?.sessionId||e?.groupId||null,vpId:e?.vpId||e?.speakerVpId||null,turnId:e?.turnId||null,threadId:e?.threadId||null}}function Zb(e,t){return ql.every(s=>!t[s]||e[s]===t[s])}function fg(e,t){return ql.every(s=>!e[s]||!t[s]||e[s]===t[s])}function ig(e,t,s){let n=(e||[]).filter(o=>o?.type==="tool-use"&&(o.toolName==="AskUser"||o.toolName==="AskUserQuestion")&&(!t.requestId||!o.askRequestId||o.askRequestId===t.requestId)&&(!t.toolCallId||!o.toolId||o.toolId===t.toolCallId)),r=n.filter(o=>Zb(rg(o,s),t));if(r.length===1)return r[0];let i=n.filter(o=>fg(rg(o,s),t));return i.length===1?i[0]:null}function hg(e){return ql.map(t=>e[t]||"").join("\0")}function Jb(e,t,s){let n=hg(t),r={...e._yeaftAskTerminalEvents||{},[n]:{identity:t,event:s,receivedAt:Date.now()}},i=Object.keys(r);if(i.length>sg){i.sort((o,a)=>r[o].receivedAt-r[a].receivedAt);for(let o of i.slice(0,i.length-sg))delete r[o]}e._yeaftAskTerminalEvents=r}function og(e,t){let s=e._yeaftAskTerminalEvents||{},n=hg(t),r=s[n]?n:null;if(!r){let l=Object.entries(s).filter(([,c])=>fg(c.identity||{},t));l.length===1&&(r=l[0][0])}if(!r)return null;let i=s[r],{[r]:o,...a}=s;return e._yeaftAskTerminalEvents=a,i?.event||null}function ew(e,t,s){return(e.messagesMap?.[t]||[]).some(n=>n?.type==="tool-use"&&n.sessionId===s&&n.hasResult===!1)}function Dl(e,t){if(!(t.type==="ask_user_answer_rejected"&&(e.askAnswered||e.askExpired))){if(t.type==="ask_user_answer_rejected"&&t.reason==="agent_unavailable"){e.askError="agent_unavailable",e.askSubmittedAt=0;return}e.askError=t.type==="ask_user_answer_rejected"?t.reason||"unavailable":null,e.askSubmittedAt=null,t.type==="ask_user_answered"?(e.askAnswered=!0,e.selectedAnswers=t.answers||{},e.askExpired=!1):(e.isHistory=!0,e.askExpired=!0,e.askAnswered=!1,e.selectedAnswers=null),e.askPending=!1,e.pendingAnswers=null,e.askSubmitGeneration=null,e.askRequestId=null}}function tw(e){if(!e||typeof e!="string")return null;let t=e.match(/^(\d+)/);if(!t)return null;let s=Number(t[1]);return Number.isFinite(s)?s:null}function sw(e){if(!e||typeof e!="string")return null;let t=e.match(/^m(\d+)$/);if(!t)return null;let s=Number(t[1]);return Number.isFinite(s)?s:null}function si(e){return Lr(e)}function $l(e,t,s){return`${Is(e,t)}::${s||""}`}function Ll(e){return Object.fromEntries(Object.entries(e||{}).filter(([,t])=>t?.status==="running"))}function ds(){try{return typeof window>"u"?null:window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore()||null}catch{return null}}function ag(e){let t=ds();if(!t?.reorderSessionsGlobally)return;let s=(Array.isArray(e)?e:[]).filter(n=>n?.runtimeProvider==="yeaft").map(n=>`${n.routeRef?.agentId||""}${n.routeRef?.sessionId||""}`).filter(n=>!n.startsWith(""));t.reorderSessionsGlobally(s)}function $e(e,t,s=null){if(s)return s;if(t){let n=ds(),r=n?.activeSessionKey?n.sessions?.[n.activeSessionKey]:null;if(r?.id===t&&r.agentId)return r.agentId;let i=n&&typeof n.sessionById=="function"?n.sessionById(t,e?.currentAgent||null):null;if(i&&i.agentId)return i.agentId;let o=e?.yeaftSessionAgentById?e.yeaftSessionAgentById[t]:null;if(o)return o}return e?.currentAgent||null}function lg(e){let t=Ms(e),s=$e(e,t),n=ds()?.sessionById?.(t,s),r=e.currentAgentInfo?.id===s?e.currentAgentInfo:e.agents?.find(o=>o?.id===s),i=o=>typeof o=="string"?o.trim():"";return i(n?.workDir)||i(r?.workDir)}function nw(e,t){let s=i=>String(i||"").replace(/^v/,"").split(".").slice(0,3).map(o=>Number.parseInt(o,10)),n=s(e),r=s(t);if(n.length<3||r.length<3||[...n,...r].some(i=>!Number.isFinite(i)))return!1;for(let i=0;i<3;i+=1)if(n[i]!==r[i])return n[i]>r[i];return!0}function St(e,t,s){if(!t||!s)return!1;let n=Array.isArray(e?.agents)?e.agents.find(o=>o?.id===t):null,r=e?.currentAgentInfo?.id===t?e.currentAgentInfo:null;return(n?.capabilities||r?.capabilities||[]).includes(s)?!0:s==="session_history_search"&&nw(n?.version||r?.version,"1.0.166")}function Ms(e,{fallbackDefault:t=!1}={}){if(e?.yeaftActiveSessionFilter)return e.yeaftActiveSessionFilter;let s=ds();return s?.activeSessionId?s.activeSessionId:t?"grp_default":null}function go(e){let t=e.yeaftDebugSessionFilter;if(t==="__all__")return null;if(t)return t;let s=Ms(e);return s||(ds()?.sessions?.grp_default?"grp_default":null)}function Fl(e,t="session"){return[e?.vpId||e?.ownerVpId||"vp",e?.threadId||"thread",e?.turnId||t].join(":")}function Ts(e,t,s=null){return s||t&&e?.yeaftConversationIdsByAgent?.[t]||e?.yeaftConversationId||null}function It(e,t=null,s=null){let n=t||e?.yeaftActiveSessionFilter||null,r=s||$e(e,n);return(r&&e?.yeaftConversationIdsByAgent?e.yeaftConversationIdsByAgent[r]:null)||e?.yeaftConversationId||null}function cg(e,t,s){if(e?.currentView!=="yeaft")return!1;let n=e?.yeaftActiveSessionFilter||null;if(n&&t!==n)return!1;let r=$e(e,n);return!r||!s||r===s}var qb,st,po,El,Bb,Nb,Wb,jb,Ub,tg,Kb,ni,zb,Yb,sg,ql,dg,Ol,ug,pg,Pn,ho=B(()=>{qt();Da();ss();Ni();Fa();Va();Br();ju();np();Tp();hn();Bs();qr();Dp();tl();Zi();Fp();Op();Vp();ji();Al();rl();js();uo();As();Nn();Ui();io();Zp();zi();il();({defineStore:qb}=Pinia),st=Object.freeze([]),po=(e,t,s)=>`${e||""}::${t||""}::${s}`;El=5,Bb=100,Nb=512*1024,Wb=15e3,jb=1e4,Ub=450,tg=Object.freeze([150,300,600,1e3]),Kb=new Set(["index_building","stale_result"]),ni=new Set(["typing","thinking","retrying","streaming","tool"]),zb=Object.freeze(["model","availableModels","refreshedAt","catalogRefreshedAt","catalogEpoch","catalogRevision","catalogDigest","refreshStartedAt","refreshReason","refreshError","refreshing"]),Yb=8,sg=64;ql=Object.freeze(["conversationId","agentId","requestId","toolCallId","sessionId","vpId","turnId","threadId"]);dg=1e3,Ol=1,ug=5,pg=200,Pn=qb("chat",{state:()=>({ws:null,authenticated:!1,_hasHandledAgentList:!1,_hasHandledYeaftSessionHydrate:!1,yeaftSessionInventoryCompleteSupported:null,workbenchRouteProtocolSupported:null,browserRuntimeProtocolSupported:null,browserRuntimeSetupProtocolSupported:null,browserRuntimeServerEnabled:!1,yeaftSessionHydrateRequestId:null,yeaftSessionHydrateSlices:[],yeaftSessionHydrateError:null,_yeaftSessionInventorySocketQuarantined:!1,sessionKey:null,serverEncryptionRequired:!0,sessionForkPendingKey:null,sessionForkState:"idle",connectionState:"disconnected",reconnectAttempts:0,maxReconnectAttempts:10,reconnectTimer:null,agents:[],currentAgent:null,currentAgentInfo:null,conversations:[],activeConversations:[],currentWorkDir:null,messagesMap:{},_messageUiKeySequence:0,chatSessionState:{},panels:[],activePanelId:null,_pendingPaneId:null,conversationTitles:{},customConversationTitles:{},processingConversations:{},yeaftProcessingSessions:{},yeaftUnreadSessionKeys:{},theme:localStorage.getItem("theme")||(typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),themeFollowSystem:!localStorage.getItem("theme"),locale:localStorage.getItem("locale")||"zh-CN",executionStatusMap:{},sessionHealth:{},historySessions:[],historySessionsLoading:!1,folders:[],foldersLoading:!1,providerModels:[],providerModelsLoading:!1,contextUsage:null,lastUsedAgent:localStorage.getItem("lastUsedAgent")||null,lastUsedSession:JSON.parse(localStorage.getItem("lastUsedSession")||"null"),lastViewedConversation:localStorage.getItem("lastViewedConversation")||null,pendingRecovery:null,recoveryDismissed:!1,sessionLoading:!1,sessionLoadingText:"",agentSwitching:!1,pendingAgentSelection:null,_pendingSessionTitle:null,workbenchExpanded:!1,workbenchMaximized:!1,workbenchPanelStateByRoute:{},sidebarCollapsed:!1,sessionSidebarOpen:!1,compactStatus:null,clearStatus:null,refreshingSession:!1,refreshingSessionMap:{},proxyPorts:{},hasMoreMessages:!1,loadingMoreMessages:!1,chatHistoryRequests:{},chatHistoryRequestIdSupported:null,chatHistoryConnectionGeneration:0,sessionCatalog:[],hiddenSessionCatalog:[],sessionProjects:[],sessionCatalogLoaded:!1,sessionCatalogMutationRequests:{},projectMutationRequests:{},activeCatalogKey:null,openUnifiedSessionCreate:!1,openUnifiedChatCreate:!1,pendingUnifiedSessionSettings:null,pluginCenterOpen:!1,pluginCenterAgentId:null,pluginConfigByAgent:{},pluginCatalogByKey:{},pluginCatalogRequestByKey:{},managedSkillRequestByKey:{},_pluginPending:{},yeaftHasMoreHistory:!1,yeaftLoadingMoreHistory:!1,yeaftOldestLoadedSeq:null,yeaftHistoryLoadError:null,_yeaftManualHistoryRefresh:null,yeaftSessionHistoryState:{},yeaftMessageWindowState:{},yeaftHistoryCacheState:{},yeaftBootstrapMetaLoadingKey:null,yeaftHistoryPerfTraceBySession:{},_yeaftHistoryPrefetchBySession:{},yeaftHistorySearchState:{requestId:null,agentId:null,sessionId:null,query:"",senderKey:"",loading:!1,results:[],hasMore:!1,nextBeforeSeq:null,nextCursor:null,error:null},yeaftHistoryOutlineBySession:{},_yeaftHistoryOutlineTimeouts:{},_yeaftHistorySearchTimeout:null,_yeaftHistoryWindowPendingByKey:{},_yeaftHistoryResultRefreshByRequestId:{},_yeaftHistoryRevealLeases:{},_yeaftHistoryRevealSequence:0,yeaftHistoryFocusWindowBySession:{},_yeaftReconnectCatchUpPending:!1,_yeaftOpenedSessionsLoadedAgents:{},_yeaftAgentSeen:null,slashCommandsMap:{},slashCommandDescriptions:{},inputDrafts:{},mcpServers:{},expertRoleDefinitions:null,llmConfig:{},llmModelDiscovery:{},llmGithubDevice:null,modelsDevRegistry:{registry:{},fetchedAt:0,error:null,loaded:!1},_modelsDevPending:null,yeaftSettings:{},searchSettings:null,telemetrySettings:null,telemetrySettingsByAgent:{},telemetryRequestByAgent:{},workCenterFeatureSettingsByAgent:{},workCenterFeatureRequestByAgent:{},agentOperations:{},agentUpgradeBatch:null,agentDreamState:{},tavilyUsage:null,tavilyUsageLoading:!1,_perfTraceQueue:[],_perfTraceFlushTimer:null,yeaftPerfTraceByMessageId:{},yeaftPerfTraceByTurnId:{},yeaftMcpServers:[],yeaftMcpRuntime:{connected:!1,toolCount:0,perServer:[]},yeaftMcpLoading:!1,yeaftMcpError:null,btwMode:!1,btwMessages:[],btwLoading:!1,btwSessionId:null,conversationMcpServers:{},conversationMcpServerTools:{},mcpPanelOpen:!1,expertSelections:[],customExpertRoles:[],subagents:{},activeSubagentId:null,activeRightPanel:null,pinnedSessions:JSON.parse(localStorage.getItem("pinned-sessions")||"[]"),...Rp(),workCenterOpen:!1,workCenterUiEnabled:localStorage.getItem("work-center-ui-enabled")!=="false",workCenterAgentId:null,workCenterItemsByAgent:{},workCenterListPageByAgent:{},workCenterListMoreLoadingByAgent:{},_workCenterListGenerationByAgent:{},_workCenterListQueryByAgent:{},_workCenterListFiltersByAgent:{},_workCenterListMoreRequestsByAgent:{},_workCenterListEventGenerationByAgent:{},_workCenterListEventsByAgent:{},_workCenterDeletedIdsByAgent:{},workCenterDetailByAgent:{},workCenterActionMessages:{},workCenterActionMessagesLoading:{},workCenterActionMessagesError:{},workCenterActionRequests:{},workCenterActionRequestDetails:{},workCenterActionRequestsLoading:{},workCenterActionRequestsError:{},workCenterActionRequestDetailsLoading:{},workCenterActionRequestDetailsError:{},workCenterLoadedByAgent:{},workCenterLoadingByAgent:{},workCenterErrorByAgent:{},workCenterWatcherByAgent:{},workCenterSettingsByAgent:{},workCenterRuntimeByAgent:{},workCenterSettingsLoadingByAgent:{},workCenterSettingsErrorByAgent:{},_workCenterSettingsGenerationByAgent:{},_workCenterDetailRequestGenerationByAgent:{},_workCenterDetailEventRefreshByAgent:{},_workCenterActionInputGenerationByAgent:{},_workCenterActionMessageRequests:{},_workCenterActionMessageGenerationByKey:{},_workCenterActionRequestsGeneration:{},_workCenterActionRequestDetailsGeneration:{},workCenterPending:{},workCenterComposerDrafts:{},workCenterMessageOutbox:{},_workCenterBrowserFence:null,_workCenterBrowserUnsubscribe:null,workCenterCreateDraft:null,yeaftConversationId:null,yeaftConversationIdsByAgent:{},_yeaftPendingConversationPromotions:{},_yeaftRetiredConversationIdsByAgent:{},_yeaftRetiredConversationTargetsByAgent:{},yeaftSessionAgentById:{},yeaftModel:null,yeaftModelEffort:null,yeaftSessionReady:!1,yeaftStatus:null,yeaftAvailableModels:[],yeaftStatusByAgent:{},_yeaftRetiredCatalogEpochsByAgent:{},yeaftModelsRefreshing:!1,yeaftModelRefreshError:null,yeaftYeaftDir:null,yeaftActiveTasksBySession:{},yeaftStoppingTasksById:{},yeaftToolStats:null,yeaftToolStatsLoading:!1,yeaftDebugLoops:[],yeaftDebugTurnsById:{},yeaftDebugTurnOrder:[],yeaftDebugHistoryLoading:!1,yeaftDebugHistoryError:null,yeaftDebugHistoryFetchedAt:0,yeaftDebugHistoryProjection:null,yeaftDebugHistoryLimit:Ol,yeaftDebugHistoryHasMore:!1,yeaftDebugPanel:{open:!1,status:"idle",requestId:null,agentId:null,sessionId:null,turnId:null,error:null},yeaftDebugSearch:"",yeaftDebugSessionFilter:null,yeaftDreamLatest:{},yeaftDreamSnapshots:{},yeaftDreamPromptLoads:{},yeaftDreamEvents:{},yeaftReflectionCards:{},yeaftSubAgentCards:{},yeaftSidebarV2Enabled:!0,yeaftActiveSessionFilter:null,_currentYeaftSessionId:null,_currentYeaftVpId:null,_currentYeaftTurnId:null,_currentYeaftThreadId:null,_yeaftAskTerminalEvents:{},activeVpTurns:{},vpStatuses:{},stoppingVpTurnIds:{},yeaftVpTyping:{},_vpCrudPending:null}),getters:{currentConversation:e=>e.activeConversations[0]||null,activeConversationId:e=>oo(e),activeSessionRoute(e){if(e.currentView==="yeaft"){let n=Ms(e);return n?{runtimeProvider:"yeaft",agentId:$e(e,n),sessionId:n}:null}let t=oo(e);if(!t)return null;let s=e.conversations.find(n=>n?.id===t&&n.type!=="yeaft");return s?{runtimeProvider:s.provider==="copilot"?"copilot":"claude-code",agentId:s.agentId||e.currentAgent||null,sessionId:t}:null},messages(e){let t=this.activeConversationId,s=t&&e.messagesMap[t]||st;if(e.currentView==="yeaft"){let n=e.yeaftActiveSessionFilter||null,r=Le($e(e,n),n),i=e.yeaftMessageWindowState[r]?.visibleTurns||Us(),o=e.yeaftHistoryFocusWindowBySession?.[r]?.windowKey||null;return _l(s,e.yeaftActiveSessionFilter||null,i,o)}return s},yeaftAllMessages:e=>{let t=It(e);return t&&e.messagesMap[t]||st},yeaftVisibleMessages(e){let t=It(e),s=t&&e.messagesMap[t]||st,n=e.yeaftActiveSessionFilter||null,r=Le($e(e,n),n),i=e.yeaftMessageWindowState[r]?.visibleTurns||Us(),o=e.yeaftHistoryFocusWindowBySession?.[r]?.windowKey||null;return _l(s,e.yeaftActiveSessionFilter||null,i,o)},hasHiddenYeaftMessages(e){if(e.currentView!=="yeaft")return!1;let t=It(e),s=t&&e.messagesMap[t]||st,n=e.yeaftActiveSessionFilter||null,r=Le($e(e,n),n),i=e.yeaftMessageWindowState[r]?.visibleTurns||Us();return Xp(s,e.yeaftActiveSessionFilter||null,i)},activeYeaftHistoryState(e){return Na(e)},yeaftManualHistoryRefreshLoading(e){let t=e._yeaftManualHistoryRefresh||null;if(!t?.requestId)return!1;let s=Le(t.agentId,t.sessionId),n=Xt(e),r=e.yeaftSessionHistoryState?.[s]||null;return n.sessionKey===s&&r?.loading===!0&&r.requestId===t.requestId},yeaftInitialHistoryLoading(e){let t=Na(e);return e.currentView==="yeaft"&&!!e.yeaftActiveSessionFilter&&!!t?.loading&&!t?.loaded&&this.yeaftVisibleMessages.length===0},vpsTypingInCurrentConv(e){let t=this.activeConversationId;if(!t)return st;let s=(e.yeaftVpTyping||{})[t];if(!s)return st;let n=Object.keys(s).filter(r=>(s[r]||0)>0);return n.length===0?st:n},isVpTypingInCurrentConv(e){return t=>{if(!t)return!1;let s=this.activeConversationId;if(!s)return!1;let n=(e.yeaftVpTyping||{})[s];return n?(n[t]||0)>0:!1}},yeaftDreamLatestForActiveSession(e){let t=go(e);if(!t)return null;let s=`sessions/${t}`;return e.yeaftDreamLatest?.[s]||null},yeaftDreamSnapshotForActiveSession(e){let t=go(e);if(!t)return null;let s=`sessions/${t}`;return e.yeaftDreamSnapshots?.[s]||null},yeaftDreamPromptLoadForActiveSession(e){let t=go(e);if(!t)return null;let s=`sessions/${t}`;return e.yeaftDreamPromptLoads?.[s]||null},yeaftDreamEventsForActiveSession(e){let t=go(e);if(!t)return[];let s=`sessions/${t}`,n=Array.isArray(e.yeaftDreamEvents?.[s])?e.yeaftDreamEvents[s]:[],r=Array.isArray(e.yeaftDreamEvents?.["*"])?e.yeaftDreamEvents["*"]:[];return r.length===0?n:n.length===0?r:[...n,...r].sort((i,o)=>(i.at||0)-(o.at||0))},yeaftDebugTurnsForActiveSession:e=>{let t=e.yeaftDebugTurnOrder||st,s=e.yeaftDebugTurnsById||{},n=e.yeaftDebugLoops||st,r=e.yeaftReflectionCards||{},i=e.yeaftDebugSessionFilter,o;i==="__all__"?o=null:i?o=i:o=null;let a={};for(let d of n)!d||!d.turnId||(a[d.turnId]||(a[d.turnId]=[]),a[d.turnId].push(d));let l={};for(let d of Object.keys(r)){let u=r[d];!u||!u.turnId||(l[u.turnId]||(l[u.turnId]=[]),l[u.turnId].push(u))}let c=[];for(let d=t.length-1;d>=0;d--){let u=t[d],g=s[u];if(!g||o&&g.sessionId&&g.sessionId!==o)continue;let p=a[u]||st,f=l[u]||st,m=p.length,v=0,y=0;for(let S of p){let b=S&&S.usage;b&&Number.isFinite(b.totalTokens)?v+=b.totalTokens:b&&(v+=(b.totalInputTokens||(b.inputTokens||0)+(b.cacheReadTokens||0)+(b.cacheWriteTokens||0))+(b.outputTokens||0)),S&&Number.isFinite(S.latencyMs)&&(y+=S.latencyMs)}let h=!g.closedAt,k={...g,loopCount:h||!g.loopCount?m:g.loopCount,totalTokens:h||!g.totalTokens?v:g.totalTokens,totalMs:h||!g.totalMs?y:g.totalMs,loops:p,reflections:f};c.push(k)}return c},yeaftDebugAvailableSessions:e=>{let t=new Set;for(let s of e.yeaftDebugTurnOrder||st){let n=e.yeaftDebugTurnsById[s];n&&n.sessionId&&t.add(n.sessionId)}return Array.from(t).sort()},yeaftDebugTurnTotal:e=>(e.yeaftDebugTurnOrder||st).length,messagesCache:e=>e.messagesMap,isMultiColumn:e=>e.activeConversations.length>1,isSplitMode:e=>e.panels.length>1,isProcessing:e=>{if(e.currentView==="yeaft"){let t=Ms(e);return t?Jp(e,t,$e(e,t)):!1}return e.currentConversation?!!e.processingConversations[e.currentConversation]:!1},canSend:e=>!(!e.currentAgent||!e.currentConversation),currentAgentName:e=>e.currentAgentInfo?.name||"\u9009\u62E9 Agent",currentAgentWorkDir:e=>e.currentAgentInfo?.workDir||"",effectiveWorkDir:e=>e.currentView==="yeaft"?lg(e):e.currentWorkDir||e.currentAgentInfo?.workDir||"",fileReferenceResolutionContextKey:e=>{let t=e.currentView==="yeaft"?(()=>{let o=Ms(e);return o?{runtimeProvider:"yeaft",agentId:$e(e,o),sessionId:o}:null})():(()=>{let o=oo(e),a=e.conversations.find(l=>l?.id===o&&l.type!=="yeaft");return a?{runtimeProvider:a.provider==="copilot"?"copilot":"claude-code",agentId:a.agentId||e.currentAgent||null,sessionId:o}:null})(),s=t?.agentId||e.currentAgent||null,n=t?.runtimeProvider==="yeaft"?It(e,t.sessionId,s):e.currentConversation,r=St(e,s,"file_reference_resolution");if(!s||!n||!r)return"";let i=e.currentView==="yeaft"?lg(e):e.currentWorkDir||e.currentAgentInfo?.workDir||"";return JSON.stringify([e.connectionState,e.authenticated,e.workbenchRouteProtocolSupported,t?.runtimeProvider||"",s,t?.sessionId||"",n,i,St(e,s,"file_editor"),St(e,s,"workbench_session_routes"),St(e,s,"response_image_preview")])},currentAgentCapabilities:e=>e.currentAgentInfo?.capabilities||["terminal","file_editor","background_tasks"],hasCapability:e=>t=>(e.currentAgentInfo?.capabilities||["terminal","file_editor","background_tasks"]).includes(t),hasAgentCapability:e=>(t,s)=>St(e,t,s),getConversationTitle:e=>t=>e.customConversationTitles[t]||e.conversationTitles[t]||null,executionStatus:e=>e.currentConversation?e.executionStatusMap[e.currentConversation]||{currentTool:null,toolHistory:[],lastActivity:null}:{currentTool:null,toolHistory:[],lastActivity:null},isConversationProcessing:e=>t=>!!e.processingConversations[t],isConversationConnecting:e=>t=>t?!!e.conversations.find(n=>n.id===t)?.connecting:!1,isConversationCompacting:e=>t=>t?e.compactStatus?.conversationId===t&&e.compactStatus?.status==="compacting":!1,isYeaftSessionProcessing:e=>(t,s=null)=>Jp(e,t,s),isSessionHistorySyncing:e=>t=>{let s=t?.sessionId||null;return s?t.runtimeProvider==="yeaft"?!!e.yeaftSessionHistoryState?.[Le(t.agentId||null,s)]?.loading:!!e.chatHistoryRequests?.[Vs(s)]?.loading:!1},isYeaftSessionUnread:e=>(t,s=null)=>{if(!t)return!1;let n=$e(e,t,s);return n?!!e.yeaftUnreadSessionKeys?.[Hn(n,t)]:!1},showRecoveryBanner:e=>e.pendingRecovery&&!e.recoveryDismissed&&!e.currentConversation,currentSubagents:e=>{if(!e.currentConversation)return st;let t=e.subagents[e.currentConversation];return t?Object.values(t):st},hasRunningSubagents:e=>{if(!e.currentConversation)return!1;let t=e.subagents[e.currentConversation];return t?Object.values(t).some(s=>s.status==="running"):!1},runningSubagentCount:e=>{if(!e.currentConversation)return 0;let t=e.subagents[e.currentConversation];return t?Object.values(t).filter(s=>s.status==="running").length:0},activeSubagentMessages:e=>{if(!e.currentConversation||!e.activeSubagentId)return st;let t=e.subagents[e.currentConversation];if(!t)return st;let s=t[e.activeSubagentId];return(Array.isArray(s?.messages)?s.messages:st).filter(r=>r?.type==="text")},selectedTaskInfo:()=>null,currentMcpServers:e=>e.currentConversation&&e.conversationMcpServers[e.currentConversation]||st},actions:{activateChatView({persistPreference:e=!1}={}){let t=this._pendingChatRestoreConversationId;this._pendingChatRestoreConversationId=null;let s=t?this.conversations.find(o=>o.id===t):null,n=s?.agentId?this.agents.find(o=>o.id===s.agentId&&o.online):null;!this._savedChatIdentity&&s&&n&&(this._savedChatIdentity={agentId:n.id,agentInfo:{...n},workDir:s.workDir||n.workDir||null}),this.currentView="chat",e&&hl("chat");let r=this._savedChatIdentity||null,i=this.pendingAgentSelection&&this.pendingAgentSelection.agentId!==r?.agentId;r?.agentId&&(this.currentAgent!==r.agentId||i)&&this.selectAgent(r.agentId),Ep(this),t&&s&&n&&(this.autoRestoreConversation(t),this.sendWsMessage({type:"refresh_conversation",conversationId:t}))},enterWorkCenter(e=null){if(!this.hydrateWorkCenterBrowserState())return!1;let t=this.agents.filter(n=>n?.online&&Array.isArray(n.capabilities)&&n.capabilities.includes("work_center")),s=t.some(n=>n.id===e)?e:t.some(n=>n.id===this.workCenterAgentId)?this.workCenterAgentId:t[0]?.id||null;return this.workCenterAgentId=s,this.workCenterOpen=!0,this.closeSessionSidebar(),s&&this.listWorkItems(s).catch(()=>{}),!0},leaveWorkCenter(){if(!this.workCenterOpen)return;this.workCenterOpen=!1;let e=new URL(window.location.href);for(let t of["workAgentId","workItemId","workContent"])e.searchParams.delete(t);window.history.replaceState({...window.history.state,workCenter:!1,workCenterContent:!1},"",`${e.pathname}${e.search}${e.hash}`)},setWorkCenterUiEnabled(e){this.workCenterUiEnabled=e!==!1;try{localStorage.setItem("work-center-ui-enabled",String(this.workCenterUiEnabled))}catch{}this.workCenterUiEnabled||this.leaveWorkCenter()},openPluginCenter(e=null){let t=this.agents.find(s=>s?.online&&s.id===e)||this.agents.find(s=>s?.online&&s.id===this.currentAgent)||this.agents.find(s=>s?.online)||null;return t?(this.pluginCenterAgentId=t.id,this.pluginCenterOpen=!0,!0):!1},closePluginCenter(){this.pluginCenterOpen=!1},pluginCatalogKey(e,t=""){return`${e||""}${String(t||"").trim()}`},loadPluginConfig(e=this.pluginCenterAgentId||this.currentAgent){if(!e)return Promise.resolve({plugins:{},error:"no agent"});let t=this.agents.find(n=>n?.id===e);if(!Vn(t))return Promise.resolve({plugins:{},error:"The selected Agent does not support Plugins; upgrade and restart the Agent"});let s=`plugins-get-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;return new Promise(n=>{let r=setTimeout(()=>{this._pluginPending?.[s]&&(delete this._pluginPending[s],n({plugins:{},error:"timeout"}))},1e4);this._pluginPending[s]={resolve:n,timer:r,kind:"config",agentId:e},this.sendWsMessage({type:"get_yeaft_plugins",agentId:e,requestId:s})})},savePluginConfig(e,t=this.pluginCenterAgentId||this.currentAgent){if(!t)return Promise.resolve({plugins:{},error:"no agent"});let s=this.agents.find(r=>r?.id===t);if(!Vn(s))return Promise.resolve({plugins:{},error:"The selected Agent does not support Plugins; upgrade and restart the Agent"});let n=`plugins-save-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;return new Promise(r=>{let i=setTimeout(()=>{this._pluginPending?.[n]&&(delete this._pluginPending[n],r({plugins:{},error:"timeout"}))},1e4);this._pluginPending[n]={resolve:r,timer:i,kind:"save",agentId:t},this.sendWsMessage({type:"update_yeaft_plugins",agentId:t,requestId:n,plugins:e})})},activePluginSession(){let e=this.yeaftActiveSessionFilter||ds()?.activeSessionId||null;if(!e)return{sessionId:"",workDir:""};let t=$e(this,e),s=ds()?.sessionById?.(e,t)||null;return{sessionId:e,agentId:s?.agentId||t||"",workDir:typeof s?.workDir=="string"?s.workDir.trim():""}},managedSkillRequestKey(e,t,s){return`${e||""}${t||""}${s||""}`},mutateManagedSkill({action:e,scope:t,skill:s,name:n,sessionId:r=""}={},i=this.pluginCenterAgentId||this.currentAgent){if(!i)return Promise.resolve({catalog:{tools:[],skills:[],skillSources:[],mcpServers:[]},error:"no agent"});let o=this.agents.find(c=>c?.id===i);if(!Wi(o))return Promise.resolve({catalog:{tools:[],skills:[],skillSources:[],mcpServers:[]},error:"The selected Agent does not support Skill management; upgrade and restart the Agent"});let a=`managed-skill-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,l=this.managedSkillRequestKey(i,t,r);return this.managedSkillRequestByKey={...this.managedSkillRequestByKey,[l]:a},new Promise(c=>{let d=setTimeout(()=>{this._pluginPending?.[a]&&(delete this._pluginPending[a],c({catalog:{tools:[],skills:[],skillSources:[],mcpServers:[]},error:"timeout"}))},1e4);this._pluginPending[a]={resolve:c,timer:d,kind:"managed-skill",agentId:i,key:l,workDir:t==="project"&&this.activePluginSession().workDir||""},this.sendWsMessage({type:"yeaft_managed_skill",agentId:i,requestId:a,action:e,scope:t,...r?{sessionId:r}:{},...s?{skill:s}:{},...n?{name:n}:{}})})},loadPluginCatalog(e=this.pluginCenterAgentId||this.currentAgent,t=""){if(!e)return Promise.resolve({catalog:{tools:[],skills:[],mcpServers:[]},error:"no agent"});let s=this.agents.find(i=>i?.id===e);if(!Vn(s))return Promise.resolve({catalog:{tools:[],skills:[],mcpServers:[]},error:"The selected Agent does not support Plugins; upgrade and restart the Agent"});let n=this.pluginCatalogKey(e,t),r=`plugins-catalog-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;return this.pluginCatalogRequestByKey={...this.pluginCatalogRequestByKey,[n]:r},this.pluginCatalogByKey={...this.pluginCatalogByKey,[n]:{...this.pluginCatalogByKey[n]||{},loading:!0,error:null}},new Promise(i=>{let o=setTimeout(()=>{this._pluginPending?.[r]&&(delete this._pluginPending[r],this.pluginCatalogRequestByKey?.[n]===r&&(this.pluginCatalogByKey={...this.pluginCatalogByKey,[n]:{...this.pluginCatalogByKey[n]||{},loading:!1,error:"timeout"}}),i({catalog:{tools:[],skills:[],mcpServers:[]},error:"timeout"}))},1e4);this._pluginPending[r]={resolve:i,timer:o,kind:"catalog",agentId:e,key:n},this.sendWsMessage({type:"yeaft_plugin_catalog",agentId:e,requestId:r,workDir:String(t||"").trim()})})},enterWorkCenterFromSession(e,t=""){if(!e?.id)return;let s=e.agentId||$e(this,e.id),n=String(t||e.title||e.name||"").trim();this.workCenterCreateDraft={sourceAgentId:s,requirement:n,workDir:String(e.workDir||"").trim(),origin:{sessionId:e.id,messageId:null,createdBy:"user"},linkedSessionIds:[e.id]},this.enterWorkCenter(s)},hydrateWorkCenterBrowserState(){this._workCenterBrowserUnsubscribe||(this._workCenterBrowserUnsubscribe=xd(()=>{Mr(this._workCenterBrowserFence)||this.clearWorkCenterBrowserState()}));let e=Hi();if(!e)return this._workCenterBrowserFence=null,this.workCenterComposerDrafts={},this.workCenterMessageOutbox={},!1;if(!Mr(this._workCenterBrowserFence)){let t=Ad(e);this._workCenterBrowserFence=e,this.workCenterComposerDrafts=t.drafts,this.workCenterMessageOutbox=t.outbox}return!0},clearWorkCenterBrowserState(){this._workCenterBrowserFence=null,this.workCenterComposerDrafts={},this.workCenterMessageOutbox={}},workCenterComposerKey(e,t){return xs(e,t)},saveWorkCenterComposerDraft(e,t,s={}){let n=xs(e,t);if(!e||!t)return;let r=Tt(s.quote),i={...this.workCenterComposerDrafts||{},[n]:{text:String(s.text||""),...r?{quote:r}:{},attachments:Array.isArray(s.attachments)?s.attachments:[],target:Qb(s.target),error:String(s.error||"")}};return Ea(i,this._workCenterBrowserFence)?(this.workCenterComposerDrafts=i,!0):!1},loadWorkCenterComposerDraft(e,t){return this.workCenterComposerDrafts?.[xs(e,t)]||null},removeWorkCenterComposerDraft(e,t){let s=xs(e,t),n={...this.workCenterComposerDrafts||{}};return delete n[s],Ea(n,this._workCenterBrowserFence)?(this.workCenterComposerDrafts=n,!0):!1},prepareWorkCenterMessageEnvelope(e={}){let t=Xb(e),s=xs(t.agentId,t.workItemId),n=this.workCenterMessageOutbox?.[s]||null;if(n)return n;let r={...t,clientMessageId:globalThis.crypto?.randomUUID?.()||`${Date.now()}-${Math.random()}`,createdAt:Date.now()},i={...this.workCenterMessageOutbox||{},[s]:r};return Pr(i,this._workCenterBrowserFence)?(this.workCenterMessageOutbox=i,r):null},loadWorkCenterMessageEnvelope(e,t){return this.workCenterMessageOutbox?.[xs(e,t)]||null},replaceWorkCenterMessageEnvelopeAttachments(e,t,s=[]){let n=xs(e,t),r=this.workCenterMessageOutbox?.[n];if(!r)return null;let i={...r,attachments:Array.isArray(s)?s.map(a=>({fileId:a?.fileId||"",name:a?.name||"",mimeType:a?.mimeType||"",size:Math.max(0,Number(a?.size)||0)})):[]},o={...this.workCenterMessageOutbox||{},[n]:i};return Pr(o,this._workCenterBrowserFence)?(this.workCenterMessageOutbox=o,i):null},discardWorkCenterMessageEnvelope(e,t){let s=xs(e,t),n={...this.workCenterMessageOutbox||{}};return delete n[s],Pr(n,this._workCenterBrowserFence)?(this.workCenterMessageOutbox=n,!0):!1},confirmWorkCenterMessageEnvelope(e,t,s){let n=xs(e,t),r=this.workCenterMessageOutbox?.[n];if(!r||r.clientMessageId!==s)return!1;let i={...this.workCenterMessageOutbox||{}};return delete i[n],Pr(i,this._workCenterBrowserFence)?(this.workCenterMessageOutbox=i,this.removeWorkCenterComposerDraft(e,t),!0):!1},workCenterRequest(e,t={},s=null){let n=s||this.workCenterAgentId||this.currentAgent;if(!n)return Promise.reject(new Error("No Agent selected"));let r=`work-center-${Date.now()}-${Math.random().toString(36).slice(2)}`;return new Promise((i,o)=>{let a=setTimeout(()=>{delete this.workCenterPending[r],o(new Error("Work Center request timed out"))},3e4);this.workCenterPending[r]={resolve:i,reject:o,timer:a,agentId:n,op:e,clientMessageId:typeof t.clientMessageId=="string"?t.clientMessageId:null},this.sendWsMessage({type:"work_center_request",agentId:n,requestId:r,op:e,payload:t})})},workItemMatchesBoardQuery(e,t={}){if(!e||t.lane&&e.boardLane!==t.lane||t.vpId&&!(e.executors||[]).some(n=>n?.id===t.vpId)||t.workItemType&&e.workItemType!==t.workItemType||t.updatedFrom&&Number(e.updatedAt)<Number(t.updatedFrom)||t.updatedTo&&Number(e.updatedAt)>Number(t.updatedTo))return!1;let s=String(t.keyword||"").trim().toLowerCase();return!s||String(e.title||"").toLowerCase().includes(s)||String(e.goal||"").toLowerCase().includes(s)},applyWorkItemBoardSummary(e,t,s={}){let n=An(e,t),r=n.find(i=>i?.id===t?.id)||null;return!r||this.workItemMatchesBoardQuery(r,s)?n:n.filter(i=>i.id!==r.id)},async listWorkItems(e=null,t={}){let s=e||this.workCenterAgentId||this.currentAgent;if(!s)return[];let n={lane:["needs_attention","active","closed"].includes(t.lane)?t.lane:null,keyword:String(t.keyword||t.search||"").trim(),vpId:String(t.vpId||"").trim(),workItemType:String(t.workItemType||"").trim(),createdFrom:Number(t.createdFrom)||null,createdTo:Number(t.createdTo)||null,updatedFrom:Number(t.updatedFrom)||null,updatedTo:Number(t.updatedTo)||null,limit:Math.min(Math.max(Number(t.limit)||100,1),200)},r=JSON.stringify(n),i=Number(this._workCenterListGenerationByAgent[s]||0)+1,o=Number(this._workCenterListEventGenerationByAgent[s]||0);this._workCenterListGenerationByAgent={...this._workCenterListGenerationByAgent,[s]:i},this._workCenterListQueryByAgent={...this._workCenterListQueryByAgent,[s]:r},this._workCenterListFiltersByAgent={...this._workCenterListFiltersByAgent,[s]:n},this.workCenterLoadingByAgent={...this.workCenterLoadingByAgent,[s]:!0},this.workCenterErrorByAgent={...this.workCenterErrorByAgent,[s]:null};try{let a=await this.workCenterRequest("list",n,s),l=(Array.isArray(a?.items)?a.items:[]).filter(d=>!this.workItemDeleted(s,d?.id));if(this._workCenterListGenerationByAgent[s]===i&&this._workCenterListQueryByAgent[s]===r&&this.workCenterAgentId===s){let d=this._workCenterListEventsByAgent[s]||{},u=new Map((this.workCenterItemsByAgent[s]||[]).map(p=>[p.id,p])),g=l.flatMap(p=>{let f=d[p.id]?.summary,m=An(f?[f]:[],u.get(p.id)),v=An(m,p)[0];return this.workItemMatchesBoardQuery(v,n)?[v]:[]});for(let p of Object.values(d))Number(p?.generation)<=o||p?.queryKey!==r||(g=this.applyWorkItemBoardSummary(g,p.summary,n));this.workCenterItemsByAgent={...this.workCenterItemsByAgent,[s]:g},this.workCenterListPageByAgent={...this.workCenterListPageByAgent,[s]:{nextCursor:a?.nextCursor||null,queryKey:r}},this.workCenterWatcherByAgent={...this.workCenterWatcherByAgent,[s]:a?.watcher||null},this.workCenterLoadedByAgent={...this.workCenterLoadedByAgent,[s]:!0}}return l}catch(a){throw this._workCenterListGenerationByAgent[s]===i&&this._workCenterListQueryByAgent[s]===r&&(this.workCenterErrorByAgent={...this.workCenterErrorByAgent,[s]:a?.message||String(a)}),a}finally{this._workCenterListGenerationByAgent[s]===i&&this._workCenterListQueryByAgent[s]===r&&(this.workCenterLoadingByAgent={...this.workCenterLoadingByAgent,[s]:!1})}},async loadMoreWorkItems(e=null){let t=e||this.workCenterAgentId||this.currentAgent,s=this.workCenterListPageByAgent[t],n=this._workCenterListFiltersByAgent[t];if(!t||!s?.nextCursor||!n)return[];let r=s.queryKey,i=this._workCenterListGenerationByAgent[t],o=Number(this._workCenterListEventGenerationByAgent[t]||0),a=s.nextCursor,l=`${i}:${r}:${a}`;if(this._workCenterListMoreRequestsByAgent[t]?.key===l)return this._workCenterListMoreRequestsByAgent[t].request;this.workCenterListMoreLoadingByAgent={...this.workCenterListMoreLoadingByAgent,[t]:!0};let c=(async()=>{try{let d=await this.workCenterRequest("list",{...n,cursor:a},t),u=this.workCenterListPageByAgent[t];if(this._workCenterListGenerationByAgent[t]!==i||this._workCenterListQueryByAgent[t]!==r||u?.queryKey!==r||u?.nextCursor!==a||this.workCenterAgentId!==t)return[];let g=[...this.workCenterItemsByAgent[t]||[]],p=this._workCenterListEventsByAgent[t]||{};for(let f of Array.isArray(d?.items)?d.items:[]){if(this.workItemDeleted(t,f?.id))continue;let m=g.findIndex(k=>k.id===f.id),v=p[f.id]?.summary,y=An(v?[v]:[],m<0?null:g[m]),h=An(y,f)[0];m>=0&&g.splice(m,1),this.workItemMatchesBoardQuery(h,n)&&g.splice(m<0?g.length:m,0,h)}for(let f of Object.values(p))Number(f?.generation)<=o||f?.queryKey!==r||(g=this.applyWorkItemBoardSummary(g,f.summary,n));return this.workCenterItemsByAgent={...this.workCenterItemsByAgent,[t]:g},this.workCenterListPageByAgent={...this.workCenterListPageByAgent,[t]:{nextCursor:d?.nextCursor||null,queryKey:r}},d?.items||[]}finally{if(this._workCenterListMoreRequestsByAgent[t]?.key===l){let d={...this._workCenterListMoreRequestsByAgent};delete d[t],this._workCenterListMoreRequestsByAgent=d,this.workCenterListMoreLoadingByAgent={...this.workCenterListMoreLoadingByAgent,[t]:!1}}}})();return this._workCenterListMoreRequestsByAgent={...this._workCenterListMoreRequestsByAgent,[t]:{key:l,request:c}},c},workItemDeleted(e,t){return!!this._workCenterDeletedIdsByAgent[e]?.[t]},removeWorkItemState(e,t){this._workCenterDeletedIdsByAgent={...this._workCenterDeletedIdsByAgent,[e]:{...this._workCenterDeletedIdsByAgent[e]||{},[t]:!0}},this.beginWorkCenterDetailWrite(e),this.workCenterItemsByAgent={...this.workCenterItemsByAgent,[e]:(this.workCenterItemsByAgent[e]||[]).filter(n=>n.id!==t)},this.workCenterDetailByAgent[e]?.id===t&&(this.workCenterDetailByAgent={...this.workCenterDetailByAgent,[e]:null});let s=`${e}:${t}:`;for(let n of["workCenterActionMessages","workCenterActionMessagesLoading","workCenterActionMessagesError","workCenterActionRequests","workCenterActionRequestsLoading","workCenterActionRequestsError","workCenterActionRequestDetails","workCenterActionRequestDetailsLoading","workCenterActionRequestDetailsError","_workCenterActionMessageRequests","_workCenterActionMessageGenerationByKey","_workCenterActionRequestsGeneration","_workCenterActionRequestDetailsGeneration"]){let r={};for(let[i,o]of Object.entries(this[n]||{}))i.startsWith(s)||(r[i]=o);this[n]=r}},beginWorkCenterDetailWrite(e){let t=Number(this._workCenterDetailRequestGenerationByAgent[e]||0)+1;return this._workCenterDetailRequestGenerationByAgent={...this._workCenterDetailRequestGenerationByAgent,[e]:t},t},commitWorkCenterDetail(e,t,s){if(t?.id&&this.workItemDeleted(e,t.id)||s!=null&&Number(this._workCenterDetailRequestGenerationByAgent[e]||0)!==s)return!1;let n=this.workCenterDetailByAgent[e],r=Cl(n,t);return n&&r===n?!1:(this.workCenterDetailByAgent={...this.workCenterDetailByAgent,[e]:r},!0)},async getWorkItem(e,t=null){let s=t||this.workCenterAgentId||this.currentAgent,n=this.beginWorkCenterDetailWrite(s),r=await this.workCenterRequest("get",{id:e},s);return this.commitWorkCenterDetail(s,r,n),this.workCenterDetailByAgent[s]||r},invalidateWorkItemActionMessages(e,t,s,n){if(!e||!t||!s)return null;let r=Ht(n),i=Zn(e,t,s,r);this._workCenterActionMessageGenerationByKey={...this._workCenterActionMessageGenerationByKey,[i]:Number(this._workCenterActionMessageGenerationByKey[i]||0)+1};for(let a of["workCenterActionMessages","workCenterActionMessagesLoading","workCenterActionMessagesError"]){let l={...this[a]};delete l[i],this[a]=l}let o={...this._workCenterActionMessageRequests};for(let a of Object.keys(o))a.startsWith(`${i}:`)&&delete o[a];return this._workCenterActionMessageRequests=o,i},async loadWorkItemActionMessages(e,t,s,n,r=null){let i=r||this.workCenterAgentId||this.currentAgent,o=Ht(s),a=Zn(i,e,t,o),l=Number(this._workCenterActionMessageGenerationByKey[a]||0),c=`${a}:${n==null?"latest":String(n)}`;if(this._workCenterActionMessageRequests[c])return this._workCenterActionMessageRequests[c];this.workCenterActionMessagesLoading={...this.workCenterActionMessagesLoading,[a]:!0},this.workCenterActionMessagesError={...this.workCenterActionMessagesError,[a]:null};let d=(async()=>{try{let u=await this.workCenterRequest("get_action_messages",{id:e,actionId:t,generation:o,cursor:n,limit:20},i);if(this.workItemDeleted(i,e)||Ht(u?.generation)!==o||Number(this._workCenterActionMessageGenerationByKey[a]||0)!==l)return u;let g=this.workCenterActionMessages[a]?.messages||[],p=Zr(g,u?.messages||[]),f=this.workCenterActionMessages[a],m=f?.nextCursor,v=n==null?null:Number(n),y=m==null?null:Number(m),h=!f||v==null||y!=null&&v===y;return this.workCenterActionMessages={...this.workCenterActionMessages,[a]:{generation:o,messages:p,nextCursor:h?u?.nextCursor??null:m,total:Math.max(Number(u?.total)||0,Number(f?.total)||0,p.length)}},u}catch(u){throw Number(this._workCenterActionMessageGenerationByKey[a]||0)===l&&(this.workCenterActionMessagesError={...this.workCenterActionMessagesError,[a]:u?.message||String(u)}),u}finally{if(this._workCenterActionMessageRequests[c]===d){let u={...this._workCenterActionMessageRequests};delete u[c],this._workCenterActionMessageRequests=u;let g=Object.keys(u).some(p=>p.startsWith(`${a}:`));this.workCenterActionMessagesLoading={...this.workCenterActionMessagesLoading,[a]:g}}}})();return this._workCenterActionMessageRequests={...this._workCenterActionMessageRequests,[c]:d},d},async loadWorkItemActionRequests(e,t,s,n=null){let r=n||this.workCenterAgentId||this.currentAgent,i=Ht(s),o=yl(r,e,t,i),a=Number(this._workCenterActionRequestsGeneration[o]||0)+1;this._workCenterActionRequestsGeneration={...this._workCenterActionRequestsGeneration,[o]:a},this.workCenterActionRequestsLoading={...this.workCenterActionRequestsLoading,[o]:!0},this.workCenterActionRequestsError={...this.workCenterActionRequestsError,[o]:null};try{let l=await this.workCenterRequest("get_action_requests",{id:e,actionId:t,generation:i},r),c=!this.workItemDeleted(r,e)&&Ht(l?.generation)===i&&this._workCenterActionRequestsGeneration[o]===a;return c&&(this.workCenterActionRequests={...this.workCenterActionRequests,[o]:l?.requests||[]}),c?l?.requests||[]:this.workCenterActionRequests[o]||[]}catch(l){throw this._workCenterActionRequestsGeneration[o]===a&&(this.workCenterActionRequestsError={...this.workCenterActionRequestsError,[o]:l?.message||String(l)}),l}finally{this._workCenterActionRequestsGeneration[o]===a&&(this.workCenterActionRequestsLoading={...this.workCenterActionRequestsLoading,[o]:!1})}},async loadWorkItemActionRequest(e,t,s,n,r,i=null){let o=i||this.workCenterAgentId||this.currentAgent,a=Ht(s),c=`${yl(o,e,t,a)}:${n}:${r}`,d=Number(this._workCenterActionRequestDetailsGeneration[c]||0)+1;this._workCenterActionRequestDetailsGeneration={...this._workCenterActionRequestDetailsGeneration,[c]:d},this.workCenterActionRequestDetailsLoading={...this.workCenterActionRequestDetailsLoading,[c]:!0},this.workCenterActionRequestDetailsError={...this.workCenterActionRequestDetailsError,[c]:null};try{let u=await this.workCenterRequest("get_action_request",{id:e,actionId:t,generation:a,runId:n,requestId:r},o),g=!this.workItemDeleted(o,e)&&Ht(u?.generation)===a&&this._workCenterActionRequestDetailsGeneration[c]===d;return g&&(this.workCenterActionRequestDetails={...this.workCenterActionRequestDetails,[c]:u?.request||null}),g?u?.request||null:this.workCenterActionRequestDetails[c]||null}catch(u){throw this._workCenterActionRequestDetailsGeneration[c]===d&&(this.workCenterActionRequestDetailsError={...this.workCenterActionRequestDetailsError,[c]:u?.message||String(u)}),u}finally{this._workCenterActionRequestDetailsGeneration[c]===d&&(this.workCenterActionRequestDetailsLoading={...this.workCenterActionRequestDetailsLoading,[c]:!1})}},async loadWorkCenterSettings(e=null){let t=e||this.workCenterAgentId||this.currentAgent;if(!t)throw new Error("No Agent selected");let s=Number(this._workCenterSettingsGenerationByAgent[t]||0)+1;this._workCenterSettingsGenerationByAgent={...this._workCenterSettingsGenerationByAgent,[t]:s},this.workCenterSettingsLoadingByAgent={...this.workCenterSettingsLoadingByAgent,[t]:!0},this.workCenterSettingsErrorByAgent={...this.workCenterSettingsErrorByAgent,[t]:null};try{let n=await this.workCenterRequest("get_settings",{},t);return this._workCenterSettingsGenerationByAgent[t]===s&&(this.workCenterSettingsByAgent={...this.workCenterSettingsByAgent,[t]:n?.settings||null},this.workCenterRuntimeByAgent={...this.workCenterRuntimeByAgent,[t]:n?.runtime||null}),n}catch(n){throw this._workCenterSettingsGenerationByAgent[t]===s&&(this.workCenterSettingsErrorByAgent={...this.workCenterSettingsErrorByAgent,[t]:n?.message||String(n)}),n}finally{this._workCenterSettingsGenerationByAgent[t]===s&&(this.workCenterSettingsLoadingByAgent={...this.workCenterSettingsLoadingByAgent,[t]:!1})}},async refreshWorkCenterRuntime(e=null){let t=e||this.workCenterAgentId||this.currentAgent;if(!t)throw new Error("No Agent selected");let s=Number(this._workCenterSettingsGenerationByAgent[t]||0)+1;this._workCenterSettingsGenerationByAgent={...this._workCenterSettingsGenerationByAgent,[t]:s},this.workCenterSettingsLoadingByAgent={...this.workCenterSettingsLoadingByAgent,[t]:!0},this.workCenterSettingsErrorByAgent={...this.workCenterSettingsErrorByAgent,[t]:null};try{let n=await this.workCenterRequest("refresh_runtime",{},t);return this._workCenterSettingsGenerationByAgent[t]===s&&(this.workCenterSettingsByAgent={...this.workCenterSettingsByAgent,[t]:n?.settings||null},this.workCenterRuntimeByAgent={...this.workCenterRuntimeByAgent,[t]:n?.runtime||null}),n}catch(n){throw this._workCenterSettingsGenerationByAgent[t]===s&&(this.workCenterSettingsErrorByAgent={...this.workCenterSettingsErrorByAgent,[t]:n?.message||String(n)}),n}finally{this._workCenterSettingsGenerationByAgent[t]===s&&(this.workCenterSettingsLoadingByAgent={...this.workCenterSettingsLoadingByAgent,[t]:!1})}},async saveWorkCenterSettings(e,t=null){let s=t||this.workCenterAgentId||this.currentAgent;if(!s)throw new Error("No Agent selected");let n=Number(this._workCenterSettingsGenerationByAgent[s]||0)+1;this._workCenterSettingsGenerationByAgent={...this._workCenterSettingsGenerationByAgent,[s]:n};let r=await this.workCenterRequest("update_settings",{settings:e},s);return this._workCenterSettingsGenerationByAgent[s]===n&&(this.workCenterSettingsByAgent={...this.workCenterSettingsByAgent,[s]:r?.settings||null},this.workCenterRuntimeByAgent={...this.workCenterRuntimeByAgent,[s]:r?.runtime||null},this.workCenterSettingsErrorByAgent={...this.workCenterSettingsErrorByAgent,[s]:null}),r},previewWorkCenterPlan(e={},t=null){let s=t||this.workCenterAgentId||this.currentAgent;return this.workCenterRequest("preview",e,s)},async createWorkItem(e,t=null){let s=t||this.workCenterAgentId||this.currentAgent,n=this.beginWorkCenterDetailWrite(s),r=await this.workCenterRequest("create",e,s);return await this.listWorkItems(s,this._workCenterListFiltersByAgent[s]||{}),this.commitWorkCenterDetail(s,r,n),r},async updateWorkItem(e,t,s=null){let n=s||this.workCenterAgentId||this.currentAgent,r=this.beginWorkCenterDetailWrite(n),i=await this.workCenterRequest("update",{id:e,patch:t},n);return await this.listWorkItems(n,this._workCenterListFiltersByAgent[n]||{}),this.commitWorkCenterDetail(n,i,r),i},async startWorkItem(e,t=null){let s=t||this.workCenterAgentId||this.currentAgent,n=this.beginWorkCenterDetailWrite(s),r=await this.workCenterRequest("start",{id:e},s);return await this.listWorkItems(s,this._workCenterListFiltersByAgent[s]||{}),this.commitWorkCenterDetail(s,r,n),r},async cancelWorkItem(e,t=null){let s=t||this.workCenterAgentId||this.currentAgent,n=this.beginWorkCenterDetailWrite(s),r=await this.workCenterRequest("cancel",{id:e},s);return await this.listWorkItems(s,this._workCenterListFiltersByAgent[s]||{}),this.commitWorkCenterDetail(s,r,n),r},async resumeWorkItem(e,t,s=null,n=void 0){let r=s||this.workCenterAgentId||this.currentAgent,i=this.beginWorkCenterDetailWrite(r),o={id:e,revision:t};n!=null&&(o.executionControlRevision=n);let a=await this.workCenterRequest("resume",o,r);return await this.listWorkItems(r,this._workCenterListFiltersByAgent[r]||{}),this.commitWorkCenterDetail(r,a,i),a},async extendWorkItemBudget(e,t,s,n=null){let r=n||this.workCenterAgentId||this.currentAgent,i=this.beginWorkCenterDetailWrite(r),o=await this.workCenterRequest("extend_budget",{id:e,executionControlRevision:t,additions:s},r);return await this.listWorkItems(r,this._workCenterListFiltersByAgent[r]||{}),this.commitWorkCenterDetail(r,o,i),o},async deleteWorkItem(e,t,s=null){let n=s||this.workCenterAgentId||this.currentAgent,r=await this.workCenterRequest("delete",{id:e,revision:t},n);return this.removeWorkItemState(n,e),r},async postWorkItemMessage(e,t,s,n,r=[],i=null,o={},a=null){if(!this.hydrateWorkCenterBrowserState())throw new Error("Work Center browser owner is unavailable; sign in again and retry");let l=i||this.workCenterAgentId||this.currentAgent,c=this.prepareWorkCenterMessageEnvelope({agentId:l,workItemId:e,target:s,text:t,quote:a,attachments:r,revision:n,planRevision:o.planRevision,ledgerRevision:o.ledgerRevision,coordinatorRevision:o.coordinatorRevision});if(!c)throw new Error("Work Center browser owner changed; reopen Work Center and try again");let d=c.clientMessageId,u=this.workCenterDetailByAgent[l]?.id===e?this.workCenterDetailByAgent[l]:null,g=await this.workCenterRequest("post_work_item_message",{id:c.workItemId,clientMessageId:d,text:c.text,target:c.target,revision:c.revision,planRevision:c.planRevision||Number(u?.planRevision)||0,ledgerRevision:c.ledgerRevision||Number(u?.ledgerRevision)||0,coordinatorRevision:Number.isInteger(Number(c.coordinatorRevision))?Number(c.coordinatorRevision):Number(u?.coordinatorRevision)||0,...c.quote?{quote:c.quote}:{},attachments:c.attachments},l);if(c.target.kind==="coordinator"){if(!g?.accepted)throw new Error("Work Center Coordinator did not accept the message");return this.confirmWorkCenterMessageEnvelope(l,e,d),g}return await this.listWorkItems(l,this._workCenterListFiltersByAgent[l]||{}),this.confirmWorkCenterMessageEnvelope(l,e,d),g},async sendWorkItemMessage(e,t,s,n=[],r=null,i={},o=null){let a=r||this.workCenterAgentId||this.currentAgent,l=this.workCenterDetailByAgent[a]?.id===e?this.workCenterDetailByAgent[a]:null,c=await this.workCenterRequest("work_item_message",{id:e,text:t,revision:s,planRevision:Number.isInteger(Number(i.planRevision))?Number(i.planRevision):Number(l?.planRevision)||0,ledgerRevision:Number.isInteger(Number(i.ledgerRevision))?Number(i.ledgerRevision):Number(l?.ledgerRevision)||0,coordinatorRevision:Number.isInteger(Number(i.coordinatorRevision))?Number(i.coordinatorRevision):Number(l?.coordinatorRevision)||0,...Tt(o)?{quote:Tt(o)}:{},attachments:Array.isArray(n)?n:[]},a);if(!c?.accepted)throw new Error("Work Center Coordinator did not accept the message");return c},async retryWorkItemAction(e,t,s,n,r=null){let i=r||this.workCenterAgentId||this.currentAgent,o=this.beginWorkCenterDetailWrite(i),a=await this.workCenterRequest("retry_action",{id:e,actionId:t,revision:s,generation:n},i);return await this.listWorkItems(i,this._workCenterListFiltersByAgent[i]||{}),this.commitWorkCenterDetail(i,a,o),a},async sendWorkItemActionInput(e,t,s,n,r,i=[],o=null,a=null){let l=o||this.workCenterAgentId||this.currentAgent,c=Number(this._workCenterActionInputGenerationByAgent[l]||0)+1;this._workCenterActionInputGenerationByAgent={...this._workCenterActionInputGenerationByAgent,[l]:c};let d=Tt(a),u=await this.workCenterRequest("action_input",{id:e,text:t,actionId:s,revision:n,generation:r,attachments:i,...d?{quote:d}:{}},l);await this.listWorkItems(l,this._workCenterListFiltersByAgent[l]||{});let g=this.workCenterDetailByAgent[l],p=g?.actions?.find(v=>v?.id===s),f=g?.id===e&&Number(g.revision)===Number(n)&&p&&Number(p.generation)===Number(r),m=Cl(g,u);return this._workCenterActionInputGenerationByAgent[l]===c&&f&&!Np(m,g)?(this.workCenterDetailByAgent={...this.workCenterDetailByAgent,[l]:m},m):g?.id===e?g:u},async guideWorkItemAction(e,t,s,n,r,i=[],o=null){let a=o||this.workCenterAgentId||this.currentAgent,l=this.beginWorkCenterDetailWrite(a),c=await this.workCenterRequest("guide",{id:e,guidance:t,actionId:s,revision:n,generation:r,attachments:i},a);return await this.listWorkItems(a,this._workCenterListFiltersByAgent[a]||{}),this.commitWorkCenterDetail(a,c,l),c},previewWorkItemAttachment(e,t,s=null){let n=s||this.workCenterAgentId||this.currentAgent;return this.workCenterRequest("preview_attachment",{id:e,attachmentId:t},n)},applyWorkCenterEvent(e,t){if(!e||!t?.workItem)return;let s=t.workItem;if(t.clientMessageId){this.confirmWorkCenterMessageEnvelope(e,s.id,t.clientMessageId);let u=Object.entries(this.workCenterPending||{}).find(([,g])=>g?.agentId===e&&g.clientMessageId===t.clientMessageId);if(u){let[g,p]=u;clearTimeout(p.timer),delete this.workCenterPending[g],p.resolve(t.type==="coordinator.turn_started"?{accepted:!0,turnId:null,receipt:!0}:t.workItem)}}let n=this.workCenterItemsByAgent[e]||[];if(t.type==="work_item.deleted"){this.removeWorkItemState(e,s.id);return}if(this.workItemDeleted(e,s.id))return;let r=this._workCenterListFiltersByAgent[e]||{},i=this._workCenterListEventsByAgent[e]?.[s.id]?.summary||null,o=n.some(u=>u?.id===s.id)?n:i?[i]:[],a=An(o,s).find(u=>u?.id===s.id)||s,l=Number(this._workCenterListEventGenerationByAgent[e]||0)+1;this._workCenterListEventGenerationByAgent={...this._workCenterListEventGenerationByAgent,[e]:l},this._workCenterListEventsByAgent={...this._workCenterListEventsByAgent,[e]:{...this._workCenterListEventsByAgent[e]||{},[s.id]:{generation:l,queryKey:this._workCenterListQueryByAgent[e]||null,summary:a}}};let c=this.applyWorkItemBoardSummary(n,a,r);this.workCenterItemsByAgent={...this.workCenterItemsByAgent,[e]:c};let d=this.workCenterDetailByAgent[e];if(d?.id===s.id){let u=t.type==="run.finished"&&t.actionId&&Array.isArray(s.actionStats)&&s.actionStats.some(y=>y?.id===t.actionId)?{...s,eventActionId:t.actionId}:s,g=wl(d,u),p=Number(s.coordinatorRevision),f=Number(d.coordinatorRevision)||0,m=Number.isInteger(p)&&p>f,v=Wp(d,u);this.workCenterDetailByAgent={...this.workCenterDetailByAgent,[e]:jp(d,s)},v&&this.refreshWorkItemDetailAfterActionChange(e,s,m?null:g)}},async refreshWorkItemDetailAfterActionChange(e,t,s=null){let n=s?(Array.isArray(t.actionStats)?t.actionStats:[]).find(m=>m?.id===s.actionId):(Array.isArray(t.actionStats)?t.actionStats:[]).find(m=>m?.id===t.currentActionId)||t.currentAction,r=s?.actionId||t.currentActionId||null,i=Number(s?.generation??n?.generation),o=Number.isInteger(i)&&i>0?i:null,a=Number(t.coordinatorRevision),l=!s&&Number.isInteger(a)&&a>=0?a:null,c=Number(s?.attempt),d=Number.isInteger(c)&&c>=0?c:null,u=l!=null?`${t.id}:coordinator:${l}`:`${t.id}:${r}${o==null?"":`:${o}`}${d==null?"":`:${d}`}`;if(this._workCenterDetailEventRefreshByAgent[e]?.key===u)return;let g=this.beginWorkCenterDetailWrite(e),p={key:u,generation:g};this._workCenterDetailEventRefreshByAgent={...this._workCenterDetailEventRefreshByAgent,[e]:p},s&&this.invalidateWorkItemActionMessages(e,t.id,s.actionId,s.generation);let f=r&&o!=null?this.loadWorkItemActionMessages(t.id,r,o,null,e).catch(()=>null):null;try{let m=await this.workCenterRequest("get",{id:t.id},e),v=this.workCenterDetailByAgent[e],y=v?.actions?.find(P=>P?.id===r),h=m?.actions?.find(P=>P?.id===r),k=o==null||Ht(y?.generation)===o,S=o==null||Ht(h?.generation)>=o,b=l==null||Number(m?.coordinatorRevision)===l,w=l!=null||k&&S&&(t.currentActionId==null?m?.currentActionId==null:v?.currentActionId===t.currentActionId&&m?.currentActionId===t.currentActionId);v?.id===t.id&&b&&w&&this.commitWorkCenterDetail(e,m,g)&&f&&await f}catch{}finally{if(this._workCenterDetailEventRefreshByAgent[e]===p){let m={...this._workCenterDetailEventRefreshByAgent};delete m[e],this._workCenterDetailEventRefreshByAgent=m}}},cacheYeaftAgentStatus(e,t,{allowBootstrapCatalog:s=!1}={}){if(!e||!t)return;let n=this.yeaftStatusByAgent[e]||{},r=Number(n.catalogRevision)||0,i=Number(t.catalogRevision)||0,o=typeof n.catalogEpoch=="string"?n.catalogEpoch:"",a=typeof t.catalogEpoch=="string"?t.catalogEpoch:"",l=Number(n.catalogRefreshedAt)||0,c=Number(t.catalogRefreshedAt)||0,d=Array.isArray(t.availableModels),u=t.type==="yeaft_status"&&d&&(i>0||c>0),g=Array.isArray(this._yeaftRetiredCatalogEpochsByAgent?.[e])?this._yeaftRetiredCatalogEpochsByAgent[e]:[],p=!!a&&g.includes(a),f=!!a&&a===o,m=i>0?f&&i===r:c>0&&c===l,v=i>0?!!a&&(a!==o||i>r):r===0&&c>l,y=i>0?!!t.catalogDigest&&!!n.catalogDigest&&t.catalogDigest===n.catalogDigest:t.catalogDigest===n.catalogDigest,h=u&&!p&&(v||m&&y),S=h||s&&r===0&&l===0&&!u&&d,b={...t};if(!S)for(let P of zb)delete b[P];let w={...n,...b};if(S){if(h&&o&&a&&o!==a){let P=[...g.filter(x=>x!==o),o].slice(-Yb);this._yeaftRetiredCatalogEpochsByAgent={...this._yeaftRetiredCatalogEpochsByAgent||{},[e]:P}}w.availableModels=t.availableModels,w.catalogRefreshedAt=h?c:null,w.catalogEpoch=h&&a||null,w.catalogRevision=h&&i||null,w.catalogDigest=h&&t.catalogDigest||null}this.yeaftStatusByAgent={...this.yeaftStatusByAgent,[e]:w},this.currentAgent===e&&this.applyCachedYeaftStatus(e)},applyCachedYeaftStatus(e=this.currentAgent){let t=e?this.yeaftStatusByAgent[e]:null;return t?(this.yeaftModel=t.model||null,this.yeaftModelEffort=t.modelEffort||null,this.yeaftAvailableModels=Array.isArray(t.availableModels)?t.availableModels:[],this.yeaftModelsRefreshing=!!t.refreshing,this.yeaftModelRefreshError=t.refreshError||null,this.yeaftYeaftDir=t.yeaftDir||null,this.yeaftStatus={skills:t.skills,mcpServers:t.mcpServers,tools:t.tools,multiVp:!!t.multiVp},!0):!1},activateYeaftAgentCatalog(e,t=this.currentAgent){let s=e?this.yeaftStatusByAgent[e]:null;return s&&this.applyCachedYeaftStatus(e),Array.isArray(s?.availableModels)?!0:(this.yeaftModel=null,this.yeaftModelEffort=null,this.yeaftAvailableModels=[],s||(this.yeaftStatus=null),this.yeaftModelsRefreshing=!!e&&!s?.refreshError,this.yeaftModelRefreshError=s?.refreshError||null,t!==e&&(this.yeaftYeaftDir=null),!1)},activateYeaftAgent(e,t=null){if(!e)return!1;let s=this.currentAgent;return this.currentAgent=e,t&&(this.currentAgentInfo=t),this.activateYeaftAgentCatalog(e,s)},resolveYeaftSessionAgentId(e){return $e(this,e)},requestYeaftSessionInventory(){if(this.yeaftSessionInventoryCompleteSupported===!1&&this.yeaftSessionHydrateRequestId)return this.yeaftSessionHydrateRequestId;if(this._yeaftSessionInventorySocketQuarantined)return this.manualReconnect(),null;clearTimeout(this._legacyYeaftSessionHydrateTimer),this._legacyYeaftSessionHydrateTimer=null;let e=`session_inventory_${crypto.randomUUID()}`;this.yeaftSessionHydrateRequestId=e,this.yeaftSessionHydrateSlices=[],this._hasHandledAgentList=!1,this._hasHandledYeaftSessionHydrate=!1,this.yeaftSessionHydrateError=null;let t=this.conversations.map(n=>n.id).filter(Boolean);return this.sendWsMessage({type:"get_agents",requestId:e,conversationIds:t.length>0?t:void 0})?(setTimeout(()=>{this.yeaftSessionHydrateRequestId===e&&(this.yeaftSessionHydrateRequestId=null,this.yeaftSessionHydrateSlices=[],this.yeaftSessionHydrateError="session_inventory_timeout",this.yeaftSessionInventoryCompleteSupported!==!0&&(this._yeaftSessionInventorySocketQuarantined=!0))},Wb),e):(this.yeaftSessionHydrateRequestId=null,this.yeaftSessionHydrateSlices=[],this.yeaftSessionHydrateError="session_inventory_send_failed",null)},beginYeaftHistoryLoad(e){let t=ru(this,e);if(!t)return null;let{agentId:s,sessionId:n}=e||{};return setTimeout(()=>{Or(this,{agentId:s,sessionId:n,requestId:t.requestId,error:"history_load_timeout"})},nu),t},finishYeaftHistoryLoad(e,t={},s="chunk"){return iu(this,e,t,s)},isCurrentYeaftHistoryResponse(e){return Ba(this,e)},syncActiveYeaftHistoryLoad(){return mn(this)},enterYeaft(e=null,{deferBootstrap:t=!1}={}){let s=this.currentAgent;ml(this);let n=Ms(this),r=!e&&n?$e(this,n):null,i=e||r||this.currentAgent||null;if(!i){let a=this.agents.find(l=>l.online);a&&(i=a.id)}if(i&&this.currentAgent!==i){this.selectAgent(i),this.currentAgent=i;let a=this.agents.find(l=>l.id===i);a&&(this.currentAgentInfo=a)}if(!this.applyCachedYeaftStatus(i)&&s&&s!==i&&(this.yeaftAvailableModels=[],this.yeaftStatus=null,this.yeaftModelsRefreshing=!0,this.yeaftModelRefreshError=null),i){let a=this.yeaftConversationIdsByAgent?.[i]||null;a||(a=`yeaft-local-${i}-${Date.now()}`,this.yeaftConversationIdsByAgent={...this.yeaftConversationIdsByAgent||{},[i]:a}),this.yeaftConversationId=a}else this.yeaftConversationId||(this.yeaftConversationId=`yeaft-local-${Date.now()}`);this.messagesMap[this.yeaftConversationId]||(this.messagesMap[this.yeaftConversationId]=[]),_p(this),this.currentView="yeaft",hl("yeaft"),this.hasMoreMessages=!1,this.loadingMoreMessages=!1,this.yeaftHasMoreHistory=!1,this.yeaftLoadingMoreHistory=!1,this.yeaftOldestLoadedSeq=null,this._yeaftReconnectCatchUpPending=!1,this.loadOpenedYeaftSessionsForConnectedAgents(null,{force:!0}),t||this.requestYeaftSessionBootstrap({forceSessionReady:!0,catchUpHistory:!0,forceHistoryReplay:!0})},loadOpenedYeaftSessionsForConnectedAgents(e=null,{force:t=!1}={}){let s=Array.isArray(e)?e.filter(Boolean):Array.isArray(this.agents)?this.agents.filter(i=>i&&i.online&&i.id).map(i=>i.id):[],n=[...new Set(s)];(!this._yeaftOpenedSessionsLoadedAgents||typeof this._yeaftOpenedSessionsLoadedAgents!="object")&&(this._yeaftOpenedSessionsLoadedAgents={});let r=[];for(let i of n)!t&&this._yeaftOpenedSessionsLoadedAgents[i]||(this._yeaftOpenedSessionsLoadedAgents[i]=Date.now(),r.push(i),this.sessionCrudRequest("list",{},{agentId:i}).catch(o=>{delete this._yeaftOpenedSessionsLoadedAgents[i]}));return r},requestYeaftSessionBootstrap({forceSessionReady:e=!1,catchUpHistory:t=!1,forceHistoryReplay:s=!1}={}){if(!this.currentAgent)return;let n=Ms(this),r=n?$e(this,n):this.currentAgent,i=Le(r,n),o=n?this.yeaftSessionHistoryState[i]:null,a=e||!this.yeaftSessionReady||!this.yeaftModel||!this.yeaftStatus,l=Number.isFinite(o?.latestSeq)?o.latestSeq:null,c=!!n&&!!this.yeaftConversationId&&Array.isArray(this.messagesMap?.[this.yeaftConversationId])&&this.messagesMap[this.yeaftConversationId].some(h=>h&&(h.sessionId??h.groupId??null)===n),d=!!n&&vu({sessionState:o,hasCachedSessionRows:c,force:!!s}),u=!!n&&!d&&mu(o,t);if(!a&&!d&&!u)return!1;let g=`${r}:${n||"__none__"}`,p=a&&!d&&!u;if(p&&this.yeaftBootstrapMetaLoadingKey===g)return!1;p&&(this.yeaftBootstrapMetaLoadingKey=g);let f=null;n&&d?f=this.beginYeaftHistoryLoad({agentId:r,sessionId:n,mode:"recent",preserveLoaded:!1}):n&&c&&!o?.loaded?(this.yeaftSessionHistoryState={...this.yeaftSessionHistoryState,[i]:{...o||{},loaded:!0,loading:!1,hasMore:!!o?.hasMore,oldestSeq:Number.isFinite(o?.oldestSeq)?o.oldestSeq:null,count:o?.count||0,latestSeq:l}},this.yeaftLoadingMoreHistory=!1):n&&u&&(f=this.beginYeaftHistoryLoad({agentId:r,sessionId:n,mode:"delta",preserveLoaded:!0,latestSeq:l}));let m={type:"yeaft_load_history",agentId:r,sessionId:n,...f?{requestId:f.requestId}:{}};u?m.afterSeq=l:m.limit=d?El:0;let v=bn();m.perfTraceId=v;let y=u?"delta":d?"recent":"metadata";return n&&(this.yeaftHistoryPerfTraceBySession={...this.yeaftHistoryPerfTraceBySession||{},[i]:v}),kt(this,{traceId:v,phase:"history.request_send",agentId:r,sessionId:n,messageType:m.type,bytes:JSON.stringify(m).length,detail:{mode:y,limit:m.limit??null,afterSeq:m.afterSeq??null,hasCachedSessionRows:c,needSessionReady:a}}),this.sendWsMessage(m),!0},leaveYeaft(){this.activateChatView({persistPreference:!0})},fetchYeaftToolStats(){this.currentAgent&&(this.yeaftToolStatsLoading=!0,this.sendWsMessage({type:"yeaft_fetch_tool_stats",agentId:this.currentAgent}),this._fetchYeaftToolStatsTimer&&clearTimeout(this._fetchYeaftToolStatsTimer),this._fetchYeaftToolStatsTimer=setTimeout(()=>{this.yeaftToolStatsLoading&&(this.yeaftToolStatsLoading=!1,this.yeaftToolStats={...this.yeaftToolStats||{snapshot:{},registered:[],unused:[]},error:null,notice:"Tool stats are unavailable right now. Try again after the agent reconnects.",fetchedAt:Date.now()}),this._fetchYeaftToolStatsTimer=null},1e4))},loadYeaftDebugHistory({groupId:e,limit:t,dreamLimit:s,indexOnly:n=!1,detailTurnId:r=null,search:i=void 0}={}){let o=$e(this,e);if(!o)return;let a=typeof i=="string"?i.trim():(this.yeaftDebugSearch||"").trim(),l=typeof r=="string"&&r,c=a&&!l?ug:Ol,d=Number.isFinite(t)&&t>0?t:this.yeaftDebugHistoryLimit||c,u=Math.max(1,Math.min(c,d)),g=l?"detail":"list",p=`dbg_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,10)}`,f=JSON.stringify({agentId:o,groupId:e||null,limit:u,dreamLimit:Number.isFinite(s)&&s>0?s:5,indexOnly:!!n,detailTurnId:r||null,search:l?"":a});if(this._yeaftDebugHistoryInFlightKey===f)return;this._yeaftDebugHistoryInFlightKey=f,l?this._yeaftDebugHistoryLatestDetailRequestId=p:this._yeaftDebugHistoryLatestListRequestId=p,this.yeaftDebugHistoryLimit=u,this.yeaftDebugHistoryLoading=!0,this.yeaftDebugHistoryError=null,this.yeaftDebugHistoryProjection=null;let m={type:"yeaft_fetch_debug_history",agentId:o,requestId:p,requestKind:g,limit:u,dreamLimit:Number.isFinite(s)&&s>0?s:5};n&&(m.indexOnly=!0),typeof r=="string"&&r?m.detailTurnId=r:a&&(m.search=a),typeof e=="string"&&e&&(m.sessionId=e),this._yeaftDebugHistoryPending={payload:m,attempt:0,startedAt:Date.now()},Qn(this),this.refreshYeaftDebugHistoryTimeout(p),this.sendWsMessage(m)},scheduleYeaftDebugDetailRefresh(e,t){let s=this.yeaftDebugPanel;!s?.open||s.turnId!==t||s.agentId!==e.agentId||s.sessionId&&s.sessionId!==e.sessionId||(this._yeaftDebugDetailDirty=!0,!this._yeaftDebugDetailRefreshTimer&&(this._yeaftDebugDetailRefreshTimer=setTimeout(()=>{this._yeaftDebugDetailRefreshTimer=null,!(!this.yeaftDebugPanel?.open||this.yeaftDebugPanel.requestId!==s.requestId)&&(this.yeaftDebugHistoryLoading||(this._yeaftDebugDetailDirty=!1,this.loadYeaftDebugHistory({groupId:s.sessionId,detailTurnId:s.turnId})))},500)))},refreshYeaftDebugHistoryTimeout(e){let t=this._yeaftDebugHistoryPending;!t||t.payload.requestId!==e||(this._fetchYeaftDebugHistoryTimer&&clearTimeout(this._fetchYeaftDebugHistoryTimer),this._fetchYeaftDebugHistoryTimer=setTimeout(()=>{if(this._yeaftDebugHistoryPending===t){if(this.yeaftDebugHistoryLoading&&t.attempt<1){t.attempt+=1,t.startedAt=Date.now(),t.payload={...t.payload,requestId:`dbg_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,10)}`},t.payload.requestKind==="detail"?this._yeaftDebugHistoryLatestDetailRequestId=t.payload.requestId:this._yeaftDebugHistoryLatestListRequestId=t.payload.requestId,Qn(this),this.refreshYeaftDebugHistoryTimeout(t.payload.requestId),this.sendWsMessage(t.payload);return}this.yeaftDebugHistoryLoading&&(this.yeaftDebugHistoryLoading=!1,this.yeaftDebugHistoryError="debug_history_timeout",this.yeaftDebugPanel?.status==="loading"&&(this.yeaftDebugPanel={...this.yeaftDebugPanel,status:"error",error:this.yeaftDebugHistoryError})),this._yeaftDebugHistoryInFlightKey=null,this._fetchYeaftDebugHistoryTimer=null,this._yeaftDebugHistoryPending=null,this._yeaftDebugHistoryLatestDetailRequestId=null,this._yeaftDebugHistoryLatestListRequestId=null,Qn(this)}},Math.max(0,Math.min(3e4,3e5-(Date.now()-t.startedAt)))))},openYeaftTurnDebug({sessionId:e=null,turnId:t=null}={}){let s=$e(this,e);if(!s)return;this.workbenchExpanded=!1,this.workbenchMaximized=!1,this.rememberWorkbenchPanelState();let n=`dbgpanel_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,10)}`,r=t?"loading":"idle";this.yeaftDebugPanel={open:!0,status:r,requestId:n,agentId:s,sessionId:e||null,turnId:t||null,error:null},t&&this.loadYeaftDebugHistory({groupId:e||void 0,limit:1,dreamLimit:5,detailTurnId:t})},closeYeaftDebugPanel(){this._yeaftDebugDetailRefreshTimer&&clearTimeout(this._yeaftDebugDetailRefreshTimer),this._yeaftDebugDetailRefreshTimer=null,this._yeaftDebugDetailDirty=!1,this._fetchYeaftDebugHistoryTimer&&clearTimeout(this._fetchYeaftDebugHistoryTimer),this._fetchYeaftDebugHistoryTimer=null,this._yeaftDebugHistoryPending=null,this._yeaftDebugHistoryInFlightKey=null,this._yeaftDebugHistoryLatestDetailRequestId=null,this._yeaftDebugHistoryLatestListRequestId=null,this.yeaftDebugHistoryLoading=!1,Qn(this);let t=(this.yeaftDebugPanel||{}).turnId||null;if(this.yeaftDebugPanel={open:!1,status:"idle",requestId:null,agentId:null,sessionId:null,turnId:null,error:null},t&&this.yeaftDebugTurnsById&&this.yeaftDebugTurnsById[t]){let s={...this.yeaftDebugTurnsById};delete s[t],this.yeaftDebugTurnsById=s,this.yeaftDebugTurnOrder=(this.yeaftDebugTurnOrder||[]).filter(n=>n!==t),this.yeaftDebugLoops=(this.yeaftDebugLoops||[]).filter(n=>!n||n.turnId!==t)}},agentIdForSession(e){return $e(this,e)},sendYeaftSessionMessage({groupId:e,text:t,mentions:s,attachments:n,quote:r,quickSend:i}){let o=$e(this,e);if(!e||!o||i&&(o!==this.currentAgent||this.connectionState!=="connected"||!this.agents?.some(v=>v.id===o&&v.online)))return!1;let a=Array.isArray(n)?n.filter(v=>v&&v.fileId):[],l=Tt(r),c=a.length>0;if(!t?.trim()&&!c)return;let d=t?.trim()?t:"(attached files)",u=Date.now(),g=`u_${u.toString(36)}_${Math.random().toString(36).slice(2,10)}`,p=bn();this.yeaftPerfTraceByMessageId={...this.yeaftPerfTraceByMessageId||{},[g]:p},kt(this,{traceId:p,phase:"send.prepare",agentId:o,sessionId:e,turnId:g,messageType:"yeaft_session_send",detail:{mentionCount:Array.isArray(s)?s.length:0,attachmentCount:a.length,quoted:!!l}});let f=It(this,e);if(f){let v={id:g,messageId:g,clientMessageId:g,stableKey:Hs(o,e,g),uiKey:Hs(o,e,g),type:"user",content:d,timestamp:u,sessionId:e,turnId:g,...l?{quote:l}:{}};if(a.length>0&&(v.attachments=a.map(y=>({fileId:y.fileId,name:y.name,preview:y.preview,isImage:!!y.isImage,mimeType:y.mimeType||""}))),rs(this).upsertOverlay({conversationId:f,agentId:o,sessionId:e,row:v}),this.processingConversations[f]=!0,e){let y=Is(o,e);this.yeaftProcessingSessions={...this.yeaftProcessingSessions,...y?{[y]:!0}:{}}}this._turnCompletedConvs?.delete(f),this._closedAt?.[f]&&delete this._closedAt[f],this.getOrCreateExecutionStatus(f),zn(this,f)}let m={type:"yeaft_session_send",agentId:o,id:g,sessionId:e,text:d,mentions:Array.isArray(s)?s:[],perfTraceId:p,...i?{quickSend:{model:i.model,effort:i.effort??null,maxOutputTokens:i.maxOutputTokens??null}}:{},...l?{quote:l}:{}};a.length>0&&(m.attachments=a.map(v=>({fileId:v.fileId,isImage:!!v.isImage}))),kt(this,{traceId:p,phase:"send.websocket_send",agentId:o,sessionId:e,turnId:g,messageType:m.type,bytes:JSON.stringify(m).length}),this.sendWsMessage(m)},cancelYeaftTask({agentId:e=null,sessionId:t,taskId:s}){let n=typeof t=="string"?t.trim():"",r=typeof s=="string"?s.trim():"",i=$e(this,n,e);return!i||!n||!r?!1:(this.yeaftStoppingTasksById={...this.yeaftStoppingTasksById,[$l(i,n,r)]:!0},this.sendWsMessage({type:"yeaft_task_cancel",agentId:i,sessionId:n,taskId:r,clientRequestId:`task_cancel_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}),!0)},continueYeaftHistoryDelta(e,t=null,s=null){let n=e||null,r=$e(this,n,t);if(!r||!n||!Number.isFinite(s))return!1;let i=Le(r,n),o=this.yeaftSessionHistoryState?.[i]||null;if(o?.loading)return!1;let a=this.beginYeaftHistoryLoad({agentId:r,sessionId:n,mode:"delta",preserveLoaded:!0,latestSeq:s});if(!a)return!1;this.yeaftSessionHistoryState={...this.yeaftSessionHistoryState,[i]:{...this.yeaftSessionHistoryState[i],syncingAfterSeq:s}};let l={type:"yeaft_load_history",agentId:r,sessionId:n,requestId:a.requestId,afterSeq:s,maxRows:Bb,maxBytes:Nb,...typeof o?.streamId=="string"?{streamId:o.streamId}:{},...Number.isFinite(o?.revision)?{revision:o.revision}:{}};return this.sendWsMessage(l)?!0:(Or(this,{agentId:r,sessionId:n,requestId:a.requestId,error:"history_load_send_failed"}),!1)},clearYeaftHistoryMemory({agentId:e=null,sessionId:t=null,preserveLiveRows:s=!1,preserveSessionOwner:n=!1}={}){let r=e||null,i=t||null,o=r&&i?Le(r,i):null,a={};for(let[m,v]of Object.entries(this._yeaftHistoryWindowPendingByKey||{})){if(!(!o||v?.agentId===r&&v?.sessionId===i)){a[m]=v;continue}clearTimeout(v?.timeout),v?.resolve?.(!1)}this._yeaftHistoryWindowPendingByKey=a;let l={};for(let[m,v]of Object.entries(this._yeaftHistoryPrefetchBySession||{})){if(o&&m!==o){l[m]=v;continue}v.cancelled=!0,v.idle&&typeof globalThis.cancelIdleCallback=="function"?globalThis.cancelIdleCallback(v.handle):clearTimeout(v.handle)}this._yeaftHistoryPrefetchBySession=l;let c={};for(let[m,v]of Object.entries(this._yeaftHistoryResultRefreshByRequestId||{})){if(!(!o||v?.agentId===r&&v?.sessionId===i)){c[m]=v;continue}clearTimeout(v?.timeout),v?.resolve?.(null)}this._yeaftHistoryResultRefreshByRequestId=c;let d=r&&this.yeaftConversationIdsByAgent?.[r]||null,u=o?new Set([d].filter(Boolean)):new Set(Object.values(this.yeaftConversationIdsByAgent||{}).filter(Boolean));!o&&this.yeaftConversationId&&u.add(this.yeaftConversationId);let g={...this.messagesMap||{}};for(let m of u)Array.isArray(g[m])&&(g[m]=o?g[m].filter(v=>(v?.sessionId??v?.groupId??null)!==i?!0:s&&!vt(v)):[]);this.messagesMap=g;let p=m=>{if(!o)return{};let{[o]:v,...y}=m||{};return y};if(this.yeaftSessionHistoryState=p(this.yeaftSessionHistoryState),this.yeaftHistoryCacheState=p(this.yeaftHistoryCacheState),this.yeaftMessageWindowState=p(this.yeaftMessageWindowState),this.yeaftHistoryFocusWindowBySession=p(this.yeaftHistoryFocusWindowBySession),this.yeaftHistoryOutlineBySession=p(this.yeaftHistoryOutlineBySession),o){let m=this._yeaftHistoryOutlineTimeouts?.[o];m&&clearTimeout(m),this._yeaftHistoryOutlineTimeouts=p(this._yeaftHistoryOutlineTimeouts)}else{for(let m of Object.values(this._yeaftHistoryOutlineTimeouts||{}))m&&clearTimeout(m);this._yeaftHistoryOutlineTimeouts={}}if((!o||this.yeaftHistorySearchState?.agentId===r&&this.yeaftHistorySearchState?.sessionId===i)&&(this._yeaftHistorySearchTimeout&&clearTimeout(this._yeaftHistorySearchTimeout),this._yeaftHistorySearchTimeout=null,this.yeaftHistorySearchState={requestId:null,agentId:null,sessionId:null,query:"",senderKey:"",loading:!1,results:[],hasMore:!1,nextBeforeSeq:null,nextCursor:null,error:null}),this._yeaftHistoryRevealLeases=o?Object.fromEntries(Object.entries(this._yeaftHistoryRevealLeases||{}).filter(([,m])=>m?.sessionKey!==o)):{},o||(this.yeaftHasMoreHistory=!1,this.yeaftLoadingMoreHistory=!1,this.yeaftOldestLoadedSeq=null),!n&&i&&this.yeaftSessionAgentById?.[i]===r){let{[i]:m,...v}=this.yeaftSessionAgentById;this.yeaftSessionAgentById=v}this.syncActiveYeaftHistoryLoad()},getYeaftMessageWindowKey(e=null,t=null){let s=e||this.yeaftActiveSessionFilter||null,n=$e(this,s,t);return Le(n,s)},showLatestYeaftMessageWindow(e=null,t=null){let s=this.getYeaftMessageWindowKey(e,t);if(!s||!this.yeaftHistoryFocusWindowBySession?.[s])return!1;let{[s]:n,...r}=this.yeaftHistoryFocusWindowBySession;return this.yeaftHistoryFocusWindowBySession=r,!0},pruneYeaftMessageWindow(e=null,t=null){if(this.currentView!=="yeaft")return;let s=this.getYeaftMessageWindowKey(e,t);Object.values(this._yeaftHistoryRevealLeases||{}).some(r=>r?.sessionKey===s)||(this.yeaftMessageWindowState={...this.yeaftMessageWindowState,[s]:{visibleTurns:Us()}})},expandYeaftMessageWindow(e=null,t=ti(),s=null){if(this.currentView!=="yeaft")return;let n=this.getYeaftMessageWindowKey(e,s),i=(this.yeaftMessageWindowState[n]?.visibleTurns||Us())+Math.max(1,Number.isFinite(t)?Math.floor(t):ti());this.yeaftMessageWindowState={...this.yeaftMessageWindowState,[n]:{visibleTurns:i}}},isYeaftMessageCached(e,t,s=null,n=null){let r=e||this.yeaftActiveSessionFilter||null,i=s||It(this,r,n);return!i||!t?!1:(this.messagesMap[i]||[]).some(o=>(!r||(o?.sessionId??o?.groupId??null)===r)&&((o?.id||o?.messageId)===t||o?.persistedMessageId===t))},revealYeaftMessage(e,t,s=null,n=null){let r=e||this.yeaftActiveSessionFilter||null,i=$e(this,r,n),o=s||It(this,r,i);if(!o||!t)return!1;let a=(this.messagesMap[o]||[]).filter(v=>v?._historyWindowPrefetched===!0?!1:r?(v?.sessionId??v?.groupId??null)===r:!0),c=a.findIndex(v=>(v?.id||v?.messageId)===t||v?.persistedMessageId===t);if(c<0){let v=(this.messagesMap[o]||[]).find(y=>y?._historyWindowPrefetched===!0&&(y?.sessionId??y?.groupId??null)===r&&((y?.id||y?.messageId)===t||y?.persistedMessageId===t));if(!v)return!1;v._historyWindowPrefetched=!1,a.push(v),a.sort((y,h)=>{let k=Number.isFinite(y?.seq)?y.seq:null,S=Number.isFinite(h?.seq)?h.seq:null;return k!==null&&S!==null&&k!==S?k-S:k!==null&&S===null?-1:k===null&&S!==null?1:(y?.timestamp||0)-(h?.timestamp||0)}),c=a.indexOf(v)}let u=a[c]?._historyWindowKey||null,g=this.getYeaftMessageWindowKey(r,i);if(u){let v=(this.messagesMap[o]||[]).filter(h=>(h?.sessionId??h?.groupId??null)===r&&h?._historyWindowKey===u);return Rl(v).length===0?!1:(this.yeaftHistoryFocusWindowBySession={...this.yeaftHistoryFocusWindowBySession||{},[g]:{windowKey:u,messageId:t,conversationId:o}},this.yeaftMessageWindowState={...this.yeaftMessageWindowState,[g]:{visibleTurns:Us()}},!0)}let p=Rl(a),f=p.findIndex(v=>c>=v.start&&c<v.end);if(f<0)return!1;let m=Math.max(Us(),p.length-f);return this.yeaftMessageWindowState={...this.yeaftMessageWindowState,[g]:{visibleTurns:m}},!0},getYeaftHistoryOutlineState(e=null,t=null){let s=e||this.yeaftActiveSessionFilter||null,n=$e(this,s,t),r=Le(n,s),i=this.yeaftHistoryOutlineBySession[r]||{requestId:null,agentId:n,sessionId:s,loading:!1,results:[],hasMore:!1,nextBeforeSeq:null,nextCursor:null,totalCount:null,loaded:!1,retryAttempt:0,error:null},o=It(this,s,n),a=o?this.messagesMap[o]||[]:[],l=new Map((i.results||[]).map(g=>[si(g),g])),c=0;for(let g of a){if((g?.sessionId??g?.groupId??null)!==s)continue;let p=g.messageId||g.id;if(!p)continue;let f=g.type==="user"&&!!g.clientMessageId&&p===g.clientMessageId,m=g.type==="assistant"&&g.isStreaming===!0;if(!f&&!m)continue;let v=g.type,y=g.turnId||g.threadId||p,h=g.speakerVpId||g.vpId||null,k=si({role:v,messageId:p,clientMessageId:g.clientMessageId,turnId:y,speakerVpId:h}),S=l.get(k),w=(typeof g.content=="string"?g.content:"").replace(/\s+/g," ").trim();l.set(k,{...S,agentId:n,sessionId:s,messageId:Number.isFinite(S?.seq)?S.messageId:p,...g.clientMessageId?{clientMessageId:g.clientMessageId}:{},turnId:y,role:v,speakerVpId:h||S?.speakerVpId||null,timestamp:g.timestamp||g.ts||S?.timestamp||null,snippet:w.length>180?`${w.slice(0,180).trimEnd()}\u2026`:w||S?.snippet||""}),S||(c+=1)}let d=g=>{let p=typeof g=="number"?g:Date.parse(g||"");return Number.isFinite(p)?p:0},u=Array.from(l.values()).sort((g,p)=>Number.isFinite(g.seq)&&Number.isFinite(p.seq)?g.seq-p.seq:d(g.timestamp)-d(p.timestamp));return{...i,results:u,totalCount:Number.isFinite(i.totalCount)?i.totalCount+c:i.totalCount}},promoteYeaftHistoryOutlineRow(e,t=null){let s=e?.sessionId??e?.groupId??null,n=Le(t,s),r=this.yeaftHistoryOutlineBySession[n];if(!s||!t||!r?.loaded||r.loading)return!1;let i=e?.type;if(i!=="user"&&i!=="assistant")return!1;let o=e.dbMessageId||e.messageId||e.id||null,a=sw(o);if(!o||!Number.isFinite(a))return!1;let l=e.turnId||e.threadId||o,c=e.speakerVpId||e.vpId||null,u=(typeof e.content=="string"?e.content:"").replace(/\s+/g," ").trim(),g=si({role:i,messageId:o,clientMessageId:e.clientMessageId,turnId:l,speakerVpId:c}),p=new Map((r.results||[]).map(k=>[si(k),k])),f=p.get(g);p.set(g,{...f,agentId:t,sessionId:s,messageId:o,...e.clientMessageId?{clientMessageId:e.clientMessageId}:{},turnId:l,seq:a,role:i,speakerVpId:c,timestamp:e.timestamp||e.ts||f?.timestamp||null,snippet:u.length>180?`${u.slice(0,180).trimEnd()}\u2026`:u||f?.snippet||""});let m=50,v=Array.from(p.values()).sort((k,S)=>(k.seq||0)-(S.seq||0)),y=v.length>m,h=v.slice(-m);return this.yeaftHistoryOutlineBySession={...this.yeaftHistoryOutlineBySession,[n]:{...r,results:h,hasMore:r.hasMore||y,nextBeforeSeq:y&&Number.isFinite(h[0]?.seq)?h[0].seq:r.nextBeforeSeq,totalCount:Number.isFinite(r.totalCount)&&!f?r.totalCount+1:r.totalCount}},!0},promoteCompletedYeaftHistoryOutline(e,t=null,s=null){let n=this.messagesMap[e]||[],r=null,i=[];for(let o=n.length-1;o>=0;o--){let a=n[o];if(a?.type==="user")break;if(t&&a?.turnId&&a.turnId!==t||a?.type!=="assistant")continue;let l=typeof a.content=="string"?a.content.replace(/\s+/g," ").trim():"";r?!String(r.content||"").trim()&&l&&(r=a):r=a,l&&i.unshift(l)}return r?this.promoteYeaftHistoryOutlineRow({...r,content:i.join(" ")},s):!1},invalidateYeaftHistoryOutline(e,t=null){let s=Le(t,e),n=this.yeaftHistoryOutlineBySession[s];if(!e||!t||!n)return!1;if(n.loading)return this.yeaftHistoryOutlineBySession={...this.yeaftHistoryOutlineBySession,[s]:{...n,refreshPending:!0}},!0;this.yeaftHistoryOutlineBySession={...this.yeaftHistoryOutlineBySession,[s]:{...n,loaded:!1,refreshPending:!1}};let r=$e(this,e);return this.currentView==="yeaft"&&this.yeaftActiveSessionFilter===e&&r===t?this.loadYeaftHistoryOutline({force:!0,targetSessionId:e,targetAgentId:t}):!0},loadYeaftHistoryOutline({append:e=!1,force:t=!1,targetSessionId:s=null,targetAgentId:n=null,retryAttempt:r=0}={}){if(this.currentView!=="yeaft"&&!s)return!1;let i=s||this.yeaftActiveSessionFilter||null,o=n||$e(this,i);if(!i||!o)return!1;let a=Le(o,i),l=this.getYeaftHistoryOutlineState(i,o);if(!e&&l.loaded&&!t)return!0;if(e&&(!l.hasMore||!Number.isFinite(l.nextBeforeSeq))||l.loading)return!1;if(!St(this,o,"session_history_outline"))return this.yeaftHistoryOutlineBySession={...this.yeaftHistoryOutlineBySession,[a]:{...l,error:"unsupported",loading:!1}},!1;let c=`history_outline_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,d={...l,requestId:c,agentId:o,sessionId:i,loading:!0,requestAppend:e,refreshPending:!1,retryAttempt:r,error:null};this.yeaftHistoryOutlineBySession={...this.yeaftHistoryOutlineBySession,[a]:d};let u=this._yeaftHistoryOutlineTimeouts[a];u&&clearTimeout(u);let g=setTimeout(()=>{let m=this.yeaftHistoryOutlineBySession[a];if(m?.requestId!==c)return;let v={...this._yeaftHistoryOutlineTimeouts};delete v[a],this._yeaftHistoryOutlineTimeouts=v;let y=m.refreshPending===!0;this.yeaftHistoryOutlineBySession={...this.yeaftHistoryOutlineBySession,[a]:{...m,requestId:null,loading:!1,requestAppend:!1,loaded:y?!1:m.loaded,refreshPending:!1,error:y?null:"timeout"}},y&&this.loadYeaftHistoryOutline({force:!0,targetSessionId:i,targetAgentId:o})},1e4);this._yeaftHistoryOutlineTimeouts={...this._yeaftHistoryOutlineTimeouts,[a]:g};let p=bn(),f={type:"yeaft_load_history_outline",agentId:o,sessionId:i,requestId:c,perfTraceId:p,limit:50,...e&&l.nextCursor?{cursor:l.nextCursor}:{},...e&&!l.nextCursor&&Number.isFinite(l.nextBeforeSeq)?{beforeSeq:l.nextBeforeSeq}:{}};return kt(this,{traceId:p,phase:"history_outline.request_send",agentId:o,sessionId:i,messageType:f.type,bytes:JSON.stringify(f).length,detail:{append:e,limit:f.limit}}),this.sendWsMessage(f),!0},handleYeaftHistoryOutline(e){if(!e?.agentId||!e?.sessionId)return!1;let t=Le(e.agentId,e.sessionId),s=this.yeaftHistoryOutlineBySession[t];if(!s||e.requestId!==s.requestId)return!1;let n=this._yeaftHistoryOutlineTimeouts[t];n&&clearTimeout(n);let r={...this._yeaftHistoryOutlineTimeouts};delete r[t],this._yeaftHistoryOutlineTimeouts=r;let i=Number.isInteger(s.retryAttempt)?s.retryAttempt:0;if(Kb.has(e.error)&&i<tg.length){let g=tg[i],p=setTimeout(()=>{let f=this.yeaftHistoryOutlineBySession[t];if(f?.requestId!==e.requestId||f.loading!==!0)return;let m={...this._yeaftHistoryOutlineTimeouts};delete m[t],this._yeaftHistoryOutlineTimeouts=m;let v=f.refreshPending===!0;this.yeaftHistoryOutlineBySession={...this.yeaftHistoryOutlineBySession,[t]:{...f,requestId:null,loading:!1,refreshPending:!1}},this.loadYeaftHistoryOutline({append:v?!1:s.requestAppend===!0,force:!0,targetSessionId:e.sessionId,targetAgentId:e.agentId,retryAttempt:i+1})},g);return this._yeaftHistoryOutlineTimeouts={...this._yeaftHistoryOutlineTimeouts,[t]:p},!0}let o=Array.isArray(e.results)?e.results.map(g=>({...g,agentId:e.agentId,sessionId:e.sessionId})):[],a=s.requestAppend?[...s.results||[],...o]:o,l=new Map(a.filter(g=>g?.messageId).map(g=>[si(g),g])),c=Array.from(l.values()).sort((g,p)=>(g.seq||0)-(p.seq||0)),d=s.refreshPending===!0;this.yeaftHistoryOutlineBySession={...this.yeaftHistoryOutlineBySession,[t]:{...s,requestId:null,loading:!1,requestAppend:!1,refreshPending:!1,loaded:d?!1:!e.error,results:c,hasMore:!!e.hasMore,nextBeforeSeq:Number.isFinite(e.nextBeforeSeq)?e.nextBeforeSeq:null,nextCursor:e.nextCursor&&typeof e.nextCursor=="object"?e.nextCursor:null,totalCount:Number.isFinite(e.totalCount)?e.totalCount:s.totalCount,error:d?null:e.error||null}};let u=this._yeaftHistoryResultRefreshByRequestId?.[e.requestId];if(u?.source==="outline"){clearTimeout(u.timeout);let{[e.requestId]:g,...p}=this._yeaftHistoryResultRefreshByRequestId;this._yeaftHistoryResultRefreshByRequestId=p;let f=c.find(m=>u.messageId&&m?.messageId===u.messageId||u.entryId&&m?.entryId===u.entryId);u.resolve(f||null)}return d&&this.loadYeaftHistoryOutline({force:!0,targetSessionId:e.sessionId,targetAgentId:e.agentId}),!0},searchYeaftHistory(e,{append:t=!1,senderKey:s=""}={}){if(this.currentView!=="yeaft")return!1;let n=typeof e=="string"?e.trim():"",r=typeof s=="string"&&(s==="user"||s.startsWith("vp:"))?s.slice(0,103):"",i=this.yeaftActiveSessionFilter||null,o=$e(this,i);if(this._yeaftHistorySearchTimeout&&(clearTimeout(this._yeaftHistorySearchTimeout),this._yeaftHistorySearchTimeout=null),!i||!o||Array.from(n).length<1&&!r)return this.yeaftHistorySearchState={requestId:null,agentId:o,sessionId:i,query:n,senderKey:r,loading:!1,results:[],hasMore:!1,nextBeforeSeq:null,nextCursor:null,error:null},!1;let a=this.yeaftHistorySearchState||{};if(!St(this,o,"session_history_search"))return this.yeaftHistorySearchState={requestId:null,agentId:o,sessionId:i,query:n,senderKey:r,loading:!1,results:[],hasMore:!1,nextBeforeSeq:null,nextCursor:null,error:"unsupported"},!1;let l=`history_search_${Date.now()}_${Math.random().toString(36).slice(2,8)}`;this.yeaftHistorySearchState={requestId:l,agentId:o,sessionId:i,query:n,senderKey:r,loading:!0,results:t&&a.query===n&&a.senderKey===r?a.results:[],hasMore:!1,nextBeforeSeq:t&&a.query===n&&a.senderKey===r?a.nextBeforeSeq:null,nextCursor:t&&a.query===n&&a.senderKey===r&&a.nextCursor||null,error:null},this._yeaftHistorySearchTimeout=setTimeout(()=>{this.yeaftHistorySearchState?.requestId===l&&(this._yeaftHistorySearchTimeout=null,this.yeaftHistorySearchState={...this.yeaftHistorySearchState,loading:!1,error:"timeout"})},1e4);let c=bn(),d={type:"yeaft_search_history",agentId:o,sessionId:i,requestId:l,perfTraceId:c,query:n,senderKey:r,limit:20,...t&&a.query===n&&a.senderKey===r&&a.nextCursor?{cursor:a.nextCursor}:{},...t&&a.query===n&&a.senderKey===r&&!a.nextCursor&&Number.isFinite(a.nextBeforeSeq)?{beforeSeq:a.nextBeforeSeq}:{}};return kt(this,{traceId:c,phase:"history_search.request_send",agentId:o,sessionId:i,messageType:d.type,bytes:JSON.stringify(d).length,detail:{append:t,limit:d.limit,queryLength:Array.from(n).length,senderFilter:!!r}}),this.sendWsMessage(d),!0},handleYeaftHistorySearchResult(e){let t=this.yeaftHistorySearchState||{};if(!e||e.requestId!==t.requestId||e.agentId!==t.agentId||e.sessionId!==t.sessionId||e.query!==t.query||(e.senderKey||"")!==t.senderKey)return!1;this._yeaftHistorySearchTimeout&&(clearTimeout(this._yeaftHistorySearchTimeout),this._yeaftHistorySearchTimeout=null);let s=Array.isArray(e.results)?e.results.map(o=>({...o,agentId:e.agentId,sessionId:e.sessionId})):[],n=new Map((t.results||[]).map(o=>[Lr(o),o]));for(let o of s)(o?.entryId||o?.messageId)&&n.set(Lr(o),o);let r=Array.from(n.values());this.yeaftHistorySearchState={...t,loading:!1,results:r,hasMore:!!e.hasMore,nextBeforeSeq:Number.isFinite(e.nextBeforeSeq)?e.nextBeforeSeq:null,nextCursor:e.nextCursor&&typeof e.nextCursor=="object"?e.nextCursor:null,error:e.error||null};let i=this._yeaftHistoryResultRefreshByRequestId?.[e.requestId];if(i){clearTimeout(i.timeout);let{[e.requestId]:o,...a}=this._yeaftHistoryResultRefreshByRequestId;this._yeaftHistoryResultRefreshByRequestId=a;let l=r.find(c=>i.messageId&&c?.messageId===i.messageId||i.entryId&&c?.entryId===i.entryId);i.resolve(l||null)}return!0},reloadYeaftHistoryResult(e){let t=e?.sessionId||null,s=e?.agentId||null,n=this.yeaftHistorySearchState||{},i=n.agentId===s&&n.sessionId===t&&(Array.from(String(n.query||"").trim()).length>0||!!n.senderKey);if(!t||!s)return Promise.resolve(null);let o=i&&n.query||"",a=i&&n.senderKey||"",l=null,c=!1;if(i)c=this.searchYeaftHistory(o,{senderKey:a}),l=this.yeaftHistorySearchState?.requestId||null;else{let d=Le(s,t),u=this.yeaftHistoryOutlineBySession?.[d]||null;u?.loading===!0&&u.requestAppend!==!0&&u.requestId?(c=!0,l=u.requestId):(c=this.loadYeaftHistoryOutline({force:!0,targetSessionId:t,targetAgentId:s}),l=this.yeaftHistoryOutlineBySession?.[d]?.requestId||null)}return!c||!l?Promise.resolve(null):new Promise(d=>{let u=setTimeout(()=>{if(this._yeaftHistoryResultRefreshByRequestId?.[l]?.resolve!==d)return;let{[l]:p,...f}=this._yeaftHistoryResultRefreshByRequestId;this._yeaftHistoryResultRefreshByRequestId=f,d(null)},1e4);this._yeaftHistoryResultRefreshByRequestId={...this._yeaftHistoryResultRefreshByRequestId||{},[l]:{agentId:s,sessionId:t,query:o,senderKey:a,source:i?"search":"outline",messageId:e?.messageId||null,entryId:e?.entryId||null,resolve:d,timeout:u}}})},loadYeaftHistoryWindow(e,{validateCached:t=!1}={}){let s=e?.sessionId||this.yeaftActiveSessionFilter||null,n=e?.agentId||$e(this,s),r=Lr(e);if(!s||!n||!e?.entryId||!Number.isFinite(e.indexGeneration)||!Number.isFinite(e.entryStartSeq)||!e?.messageId||!Number.isFinite(e.seq))return Promise.resolve(!1);let i=It(this,s,n);if((this.messagesMap[i]||[]).some(m=>(m?.sessionId??m?.groupId??null)===s&&m?.historyEntryId===e.entryId&&m?.historyIndexGeneration===e.indexGeneration)&&!t)return Promise.resolve(!0);let a=Le(n,`${s}:${r}:generation:${e.indexGeneration}`),l=this._yeaftHistoryWindowPendingByKey||{};if(l[a]?.promise)return l[a].promise;let c=`history_window_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,d=null,u=null,g=new Promise(m=>{d=m});Object.defineProperty(g,"error",{get:()=>u});let p=m=>{u=m||null},f=setTimeout(()=>{if(this._yeaftHistoryWindowPendingByKey?.[a]?.requestId!==c)return;let{[a]:v,...y}=this._yeaftHistoryWindowPendingByKey;this._yeaftHistoryWindowPendingByKey=y,d(!1)},1e4);return this._yeaftHistoryWindowPendingByKey={...l,[a]:{requestId:c,agentId:n,sessionId:s,entryId:e.entryId||null,indexGeneration:Number.isFinite(e.indexGeneration)?e.indexGeneration:null,entryStartSeq:Number.isFinite(e.entryStartSeq)?e.entryStartSeq:null,resultId:r,messageId:e.messageId,prefetch:!t,validateCached:!!t,setError:p,resolve:d,timeout:f,promise:g}},this.sendWsMessage({type:"yeaft_load_history_window",agentId:n,sessionId:s,requestId:c,prefetch:!t,...e.entryId?{entryId:e.entryId}:{},...Number.isFinite(e.indexGeneration)?{indexGeneration:e.indexGeneration}:{},...Number.isFinite(e.entryStartSeq)?{entryStartSeq:e.entryStartSeq}:{},anchorMessageId:e.messageId,anchorSeq:e.seq,beforeTurns:5,afterTurns:5,maxRows:200,maxBytes:512*1024}),g},beginYeaftHistoryReveal(e){let t=e?.sessionId||null,s=e?.agentId||null,n=It(this,t,s);if(!t||!s||!n)return null;let r=Le(s,t),i=`${r}${n}`,o=++this._yeaftHistoryRevealSequence,a={key:i,token:o,sessionKey:r,agentId:s,sessionId:t,conversationId:n};return this._yeaftHistoryRevealLeases={...this._yeaftHistoryRevealLeases||{},[i]:a},a},finishYeaftHistoryReveal(e){if(!e?.key||!Number.isFinite(e.token)||this._yeaftHistoryRevealLeases?.[e.key]?.token!==e.token)return!1;let{[e.key]:s,...n}=this._yeaftHistoryRevealLeases;return this._yeaftHistoryRevealLeases=n,!0},async revealYeaftHistoryResult(e,t=null){let s=!t,n=t||this.beginYeaftHistoryReveal(e),r=e?.sessionId||null,i=e?.agentId||null,o=It(this,r,i);if(!n||!r||!i||!o||!e?.messageId)return this.finishYeaftHistoryReveal(n),!1;let a=e,l=this.loadYeaftHistoryWindow(a,{validateCached:!0}),c=await l;if(!c&&l.error==="stale_result"){let u=await this.reloadYeaftHistoryResult(a);u&&(a=u,l=this.loadYeaftHistoryWindow(a,{validateCached:!0}),c=await l)}if(!c)return this.finishYeaftHistoryReveal(n),!1;if(this.currentView!=="yeaft"||this.yeaftActiveSessionFilter!==r||$e(this,r)!==i||It(this,r,i)!==o)return this.finishYeaftHistoryReveal(n),!1;let d=this.revealYeaftMessage(r,a.messageId,o,i);return(!d||s)&&this.finishYeaftHistoryReveal(n),d},pendingYeaftHistoryWindow(e){let s=Object.entries(this._yeaftHistoryWindowPendingByKey||{}).find(([,i])=>i?.requestId===e?.requestId);if(!s)return null;let[n,r]=s;return e.agentId!==r.agentId||e.sessionId!==r.sessionId||e.entryId&&r.entryId&&e.entryId!==r.entryId||Number.isFinite(e.indexGeneration)&&Number.isFinite(r.indexGeneration)&&e.indexGeneration!==r.indexGeneration?null:{pendingKey:n,pending:r}},handleYeaftHistoryWindow(e,t=null){let s=this.pendingYeaftHistoryWindow(e);if(!s)return!1;let{pendingKey:n,pending:r}=s;r.prefetch===!0&&e.prefetch!==!0&&r.validateCached!==!0&&(e.prefetch=!0),clearTimeout(r.timeout);let{[n]:i,...o}=this._yeaftHistoryWindowPendingByKey;this._yeaftHistoryWindowPendingByKey=o;let a=!e.error&&!!t&&this.isYeaftMessageCached(r.sessionId,r.messageId,t,r.agentId);return r.setError?.(e.error||null),r.resolve(!!a),!!a},createYeaftSession({displayName:e,vpIds:t,defaultVpId:s,workDir:n,agentId:r}={}){let i=Array.isArray(t)?t.slice():[],o=s&&i.includes(s)?s:i[0]||null,a=(e||"").trim(),l=(n||"").trim(),c={roster:i,defaultVpId:o};return a&&(c.name=a),l&&(c.workDir=l),this.sessionCrudRequest("create",c,{agentId:r})},handleYeaftOutput(e){if(!e)return;let t=e.agentId||this.yeaftAgentId||this.currentAgent||null,s=e.conversationId||e.event?.conversationId||null,n=Yn(this,t,s);if(e.data&&n){if(e.data.type!=="result")return;let a=Cu(this,t,s);if(!a)return;let l=e.turnId?Mn(this,t,e.turnId):"",c=!!(l&&this.activeVpTurns?.[l])||(this.messagesMap?.[a]||[]).some(d=>d?.turnId===e.turnId&&(d.isStreaming||d.status==="pending"));if(!e.turnId||!c)return;e={...e,conversationId:a}}if(e.perfTraceId&&(kt(this,{traceId:e.perfTraceId,phase:"receive.yeaft_output",agentId:e.agentId||null,sessionId:e.sessionId||null,vpId:e.vpId||null,turnId:e.turnId||null,threadId:e.threadId||null,messageType:e.data?.type||e.event?.type||e.type}),e.turnId&&(this.yeaftPerfTraceByTurnId={...this.yeaftPerfTraceByTurnId||{},[e.turnId]:e.perfTraceId})),e.data){let a=e.agentId||null,l=Ts(this,a,e.conversationId);if(l){let d=Fl(e,e.turnId||"session");for(let u of["retry","retrying","thinking"])Kn(this,l,`${u}:${d}`);e.data?.tool_use_result&&Kn(this,l,`tool:${d}`)}let c=e.turnId?Mn(this,e.agentId||null,e.turnId):"";if(c&&this.activeVpTurns?.[c]?.retryAttempt){let{retryAttempt:d,retryMax:u,retryDelayMs:g,retryReason:p,retryRecoveryMode:f,...m}=this.activeVpTurns[c];this.activeVpTurns={...this.activeVpTurns,[c]:m}}if(l){let d=e.sessionId??e.groupId??null,u=cg(this,d,a),g=a&&this.yeaftConversationIdsByAgent?this.yeaftConversationIdsByAgent[a]:null,p=is(this,a);p&&p.targetConversationId!==l?Ur(this,a,l):!p&&g&&g!==l&&!String(g).startsWith("yeaft-local-")&&(os(this,g,l,{removeSource:g!==this.yeaftConversationId}),Wr(this,a,g,l)),el(this,a,l);let f=is(this,a,l),m=f?.sourceConversationId||g,v=!u&&m===this.yeaftConversationId;if(this.currentView==="yeaft"&&a&&m&&m!==l){let w=!v&&(!!f||String(m).startsWith("yeaft-local-"));os(this,m,l,{removeSource:w}),v?eo(this,a,m,l):w&&jr(this,a,l)}a&&(this.yeaftConversationIdsByAgent={...this.yeaftConversationIdsByAgent||{},[a]:l}),(u||!this.yeaftConversationId)&&(this.yeaftConversationId=l),u&&(this.activeConversations=[l]),this.messagesMap[l]||(this.messagesMap[l]=[]);let y=this._currentYeaftAgentId,h=this._currentYeaftSessionId,k=this._currentYeaftVpId,S=this._currentYeaftTurnId,b=this._currentYeaftThreadId;a&&(this._currentYeaftAgentId=a),d!=null&&(this._currentYeaftSessionId=d),e.vpId&&(this._currentYeaftVpId=e.vpId),e.turnId&&(this._currentYeaftTurnId=e.turnId),e.threadId&&(this._currentYeaftThreadId=e.threadId);try{let w=typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now();if(this.handleAssistantOutputFrame(l,e.data,a),e.perfTraceId){let oe=typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now();kt(this,{traceId:e.perfTraceId,phase:"store.apply_output",agentId:e.agentId||null,sessionId:d||null,vpId:e.vpId||null,turnId:e.turnId||null,threadId:e.threadId||null,messageType:e.data?.type||null,durationMs:oe-w}),so(this,{traceId:e.perfTraceId,agentId:e.agentId||null,sessionId:d||null,vpId:e.vpId||null,turnId:e.turnId||null,threadId:e.threadId||null,messageType:e.data?.type||null})}let P=e.data,x=P?.message?.id||P?.id||null,Y=tw(x),L=Array.isArray(P?.message?.content)?P.message.content:[],U=L.some(oe=>oe?.type==="tool_use"),E=!!P?.tool_use_result||L.some(oe=>oe?.type==="tool_result");if(d){let oe=!E&&!ew(this,l,d)&&(P?.type==="user"||P?.type==="assistant"&&!U)?Y:null,q=Le(e.agentId||null,d),I=this.yeaftSessionHistoryState[q]||{},T=Number.isFinite(I.latestSeq)?I.latestSeq:-1;oe!==null&&oe>T&&(this.yeaftSessionHistoryState={...this.yeaftSessionHistoryState,[q]:{...I,latestSeq:oe}})}}finally{this._currentYeaftAgentId=y,this._currentYeaftSessionId=h,this._currentYeaftVpId=k,this._currentYeaftTurnId=S,this._currentYeaftThreadId=b}}return}let r=e.event;if(!r)return;let i={...r,vpId:r.vpId||e.vpId||null,threadId:r.threadId||e.threadId||null,turnId:r.turnId||e.turnId||null},o=Ts(this,e.agentId||null,e.conversationId);if(o){let a=Fl(i);r.type==="tool_start"?Nr(this,o,`tool:${a}`):r.type==="tool_end"?Kn(this,o,`tool:${a}`):r.type==="llm_retry"?Nr(this,o,`retry:${a}`):r.type==="vp_async_task_wait_start"?Nr(this,o,`async-wait:${a}`):r.type==="vp_async_task_wait_end"&&Kn(this,o,`async-wait:${a}`)}switch(r.type){case"project_mutation_result":r.projectsAuthoritative===!0?this.finishProjectMutation(r):this.finishLegacyProjectMutation(r,e.agentId||null);break;case"ask_user_question":{let a=Ts(this,e.agentId||null,e.conversationId);if(!a||!r.requestId)break;let l=ng(e,r,a),c=()=>{let d=this.messagesMap[a]||[],u=ig(d,l,a);if(u){if(u.askAnswered||u.askExpired)return!0;u.toolName="AskUserQuestion",r.toolCallId&&!u.toolId&&(u.toolId=r.toolCallId),u.agentId=l.agentId||u.agentId||null;for(let m of["sessionId","vpId","turnId","threadId"])l[m]&&(u[m]=l[m]);u.hasResult=!1,u.askRequestId=r.requestId,u.askQuestions=r.questions||[],u.askCreatedAt=r.createdAt||null,u.askExpiresAt=r.expiresAt||null,u.isHistory=!1;let f=og(this,l);return f&&Dl(u,f),this.messagesMap={...this.messagesMap,[a]:d.slice()},!0}if(!r.replay)return!1;let g={id:`ask-card-${r.requestId}`,type:"tool-use",toolName:"AskUserQuestion",toolId:r.toolCallId||null,toolInput:{questions:r.questions||[]},askRequestId:r.requestId,askQuestions:r.questions||[],askCreatedAt:r.createdAt||null,askExpiresAt:r.expiresAt||null,agentId:l.agentId,sessionId:l.sessionId,vpId:l.vpId,speakerVpId:l.vpId,turnId:l.turnId,threadId:l.threadId||"main",hasResult:!1,isHistory:!1,timestamp:r.createdAt||Date.now()},p=og(this,l);return p&&Dl(g,p),d.push(g),this.messagesMap={...this.messagesMap,[a]:d.slice()},!0};if(!c()){let d=0,u=setInterval(()=>{d+=1,(c()||d>=10)&&clearInterval(u)},200)}break}case"ask_user_answered":case"ask_user_answer_rejected":case"ask_user_expired":{let a=Ts(this,e.agentId||null,e.conversationId);if(!a||!r.requestId)break;let l=this.messagesMap[a]||[],c=ng(e,r,a),d=ig(l,c,a);if(!d){Jb(this,c,r);break}Dl(d,r),this.messagesMap={...this.messagesMap,[a]:l.slice()};break}case"session_ready":{let a=r.conversationId,l=e.agentId||this.currentAgent;if(Yn(this,l,a))break;let c=l&&this.yeaftConversationIdsByAgent?this.yeaftConversationIdsByAgent[l]:null,d=this.yeaftConversationId?String(this.yeaftConversationId):"",u=d.startsWith("yeaft-local-")&&(!l||d.startsWith(`yeaft-local-${l}-`)||/^yeaft-local-\d/.test(d))?this.yeaftConversationId:null,g=c||u,p=r.sessionId||e.sessionId||null,f=cg(this,p,l),m=is(this,l);m&&m.targetConversationId!==a?Ur(this,l,a):!m&&c&&c!==a&&!String(c).startsWith("yeaft-local-")&&Wr(this,l,c,a),el(this,l,a);let y=is(this,l,a)?.sourceConversationId||g,h=!f&&y===this.yeaftConversationId;if(y&&y!==a){let P=!h;os(this,y,a,{removeSource:P}),h?eo(this,l,y,a):P&&jr(this,l,a)}else this.messagesMap[a]||(this.messagesMap[a]=[]);l&&(this.yeaftConversationIdsByAgent={...this.yeaftConversationIdsByAgent||{},[l]:a},this.cacheYeaftAgentStatus(l,r,{allowBootstrapCatalog:f})),f&&(this.yeaftModel=r.model,this.yeaftModelEffort=r.modelEffort||null,this.yeaftSessionReady=!0,this.yeaftBootstrapMetaLoadingKey=null,l?this.applyCachedYeaftStatus(l):this.yeaftAvailableModels=r.availableModels||[]);let k=Array.isArray(r.tasks)?r.tasks:[],S={};for(let[P,x]of Object.entries(this.yeaftActiveTasksBySession||{})){let Y=Object.fromEntries(Object.entries(x||{}).filter(([,U])=>U?.id&&U.status==="running"&&U.agentId&&U.agentId!==l)),L=Ll(Y);Object.keys(L).length>0&&(S[P]=L)}for(let P of k){if(!P?.id||!P.sessionId||P.status!=="running")continue;let x=Le(l,P.sessionId);S[x]={...S[x]||{},[P.id]:{...P,agentId:l}}}this.yeaftActiveTasksBySession=S,f&&(r.yeaftDir&&(this.yeaftYeaftDir=r.yeaftDir),this.yeaftStatus={skills:r.skills,mcpServers:r.mcpServers,tools:r.tools,multiVp:!!r.multiVp}),(f||!this.yeaftConversationId)&&(this.yeaftConversationId=a),f&&(this.activeConversations=[a]);let b=e.agentId||this.currentAgent||null,w=b||"__current__";this._yeaftVpSubscribedAgentKey!==w&&(this._yeaftVpSubscribedAgentKey=w,this.sendWsMessage(b?{type:"yeaft_vp_subscribe",agentId:b}:{type:"yeaft_vp_subscribe"}));break}case"yeaft_status":{let a=e.agentId||this.currentAgent;a&&this.cacheYeaftAgentStatus(a,r);break}case"context_usage":break;case"turn_open":{if(!r.turnId)break;let a={turnId:r.turnId,userPrompt:r.userPrompt||"",vpId:r.vpId||e.vpId||null,sessionId:r.sessionId||e.sessionId||null,openedAt:r.at||Date.now(),closedAt:null,totalMs:0,inputTokens:0,outputTokens:0,totalTokens:0,loopCount:0,memoryLoaded:null,memoryLoadedMeta:null,memoryAdjust:null,tools:[],detailsLoaded:!0};this.yeaftDebugTurnsById={...this.yeaftDebugTurnsById,[r.turnId]:a};let l=Mn(this,e.agentId||null,r.turnId),c=this.activeVpTurns?.[l];c&&Number.isFinite(r.at)&&(this.activeVpTurns={...this.activeVpTurns,[l]:{...c,startedAt:r.at}}),this.yeaftDebugTurnOrder.includes(r.turnId)||(this.yeaftDebugTurnOrder=[...this.yeaftDebugTurnOrder,r.turnId]);break}case"turn_close":{if(!r.turnId)break;let a=this.yeaftDebugTurnsById[r.turnId];if(!a)break;this.yeaftDebugTurnsById={...this.yeaftDebugTurnsById,[r.turnId]:{...a,closedAt:Date.now(),...Number.isFinite(r.totalMs)?{totalMs:r.totalMs}:{},...Number.isFinite(r.inputTokens)?{inputTokens:r.inputTokens}:{},...Number.isFinite(r.outputTokens)?{outputTokens:r.outputTokens}:{},...Number.isFinite(r.totalTokens)?{totalTokens:r.totalTokens}:{},loopCount:r.loopCount||a.loopCount||0,...typeof r.model=="string"&&r.model?{model:r.model}:{},...typeof r.effort=="string"&&r.effort?{effort:r.effort}:{}}};break}case"memory_used":{if(!r.turnId)break;let a=this.yeaftDebugTurnsById[r.turnId];if(!a)break;this.yeaftDebugTurnsById={...this.yeaftDebugTurnsById,[r.turnId]:{...a,memoryLoaded:Array.isArray(r.loaded)?r.loaded:[],memoryLoadedMeta:r.meta||null}};break}case"dream_memory_loaded":{let a=Array.isArray(r.resident)?r.resident:[];if(r.turnId){let c=this.yeaftDebugTurnsById[r.turnId];c&&(this.yeaftDebugTurnsById={...this.yeaftDebugTurnsById,[r.turnId]:{...c,dreamMemoryLoaded:a,dreamMemoryLoadedInto:r.loadedInto||"system_prompt.memory"}})}let l={};for(let c of a){let d=c&&typeof c.scope=="string"?c.scope:null,u=d&&/^sessions\/[^/]+$/.test(d)?d:d&&/^group\/[^/]+$/.test(d)?`sessions/${d.slice(6)}`:null;u&&(l[u]={scope:u,sourceScope:d,sessionId:u.slice(9),turnId:r.turnId||null,vpId:r.vpId||null,loadedInto:r.loadedInto||"system_prompt.memory",summary:c.summary||"",truncated:!!c.truncated,receivedAt:Date.now()})}Object.keys(l).length>0&&(this.yeaftDreamPromptLoads={...this.yeaftDreamPromptLoads,...l});break}case"memory_adjust":{if(!r.turnId)break;let a=this.yeaftDebugTurnsById[r.turnId];if(!a)break;this.yeaftDebugTurnsById={...this.yeaftDebugTurnsById,[r.turnId]:{...a,memoryAdjust:{sessionKey:r.sessionKey||null,added:r.added||0,evicted:r.evicted||0,skipped:r.skipped||0,reason:r.reason||""}}};break}case"tool_exec":{if(this.scheduleYeaftDebugDetailRefresh(e,r.turnId),!r.turnId)break;let a=this.yeaftDebugTurnsById[r.turnId];if(!a)break;let l=[...a.tools||[],{loopNumber:r.loopNumber||0,callId:r.callId||null,name:r.name||"?",durationMs:r.durationMs||0,isError:!!r.isError}];this.yeaftDebugTurnsById={...this.yeaftDebugTurnsById,[r.turnId]:{...a,tools:l}};break}case"loop":{if(this.scheduleYeaftDebugDetailRefresh(e,r.turnId),this.yeaftDebugLoops.push({turnId:r.turnId||null,loopNumber:r.loopNumber||0,model:r.model,usage:r.usage||{inputTokens:0,outputTokens:0,totalTokens:0},latencyMs:r.latencyMs,ttfbMs:r.ttfbMs,stopReason:r.stopReason,at:typeof r.at=="number"?r.at:null,sessionId:e.sessionId||null,vpId:e.vpId||r.vpId||null}),this.yeaftDebugLoops.length>dg){let a=qp({loops:this.yeaftDebugLoops,turnsById:this.yeaftDebugTurnsById,turnOrder:this.yeaftDebugTurnOrder,maxLoops:Math.max(dg,this.yeaftDebugHistoryLimit||0)});this.yeaftDebugLoops=a.loops,this.yeaftDebugTurnsById=a.turnsById,this.yeaftDebugTurnOrder=a.turnOrder}break}case"llm_retry":{if(!e.turnId)break;let a=Mn(this,e.agentId||null,e.turnId),l=this.activeVpTurns?.[a];if(!l)break;let c=r.reason==="stream_idle_timeout"?"stream_idle_timeout":"transient_error";this.activeVpTurns={...this.activeVpTurns,[a]:{...l,retryAttempt:r.attempt||0,retryMax:r.maxRetries||0,retryDelayMs:r.delayMs||0,retryReason:c,retryRecoveryMode:r.recoveryMode||"restart"}};break}case"recall":case"fallback":case"thinking_delta":break;case"reflection":{let a=Ts(this,e.agentId||null,e.conversationId)||"unknown",l=Array.isArray(r.loopRange)?r.loopRange:[0,0],c=`${a}:${r.trigger}:${l[0]}-${l[1]}`,d=this.yeaftReflectionCards[c],u=this.messagesMap[a]||[],g=d?d.anchorMsgId:u.length>0&&u[u.length-1].id||null,p=d?d.anchorOrder:u.length;this.yeaftReflectionCards={...this.yeaftReflectionCards,[c]:{key:c,conversationId:a,turnId:r.turnId||d&&d.turnId||null,loopNumber:r.loopNumber||d&&d.loopNumber||null,trigger:r.trigger,status:r.status,loopRange:l,toolCount:r.toolCount||0,content:r.content||"",durationMs:r.durationMs||0,error:r.error||null,sessionId:e.sessionId||null,anchorMsgId:g,anchorOrder:p,updatedAt:Date.now()}};break}case"model_switched":this.yeaftModel=r.model,this.yeaftModelEffort=r.modelEffort||null;break;case"yeaft_task_event":{let a=r.task;if(!a?.id||!a.sessionId)break;let l=e.agentId||$e(this,a.sessionId),c=Le(l,a.sessionId),d={...a,agentId:l},u={...this.yeaftActiveTasksBySession},g={...u[c]||{}};a.status==="running"?g[a.id]=d:delete g[a.id];let p=Ll(g);if(Object.keys(p).length>0?u[c]=p:delete u[c],this.yeaftActiveTasksBySession=u,a.status!=="running"){let{[$l(l,a.sessionId,a.id)]:f,...m}=this.yeaftStoppingTasksById||{};this.yeaftStoppingTasksById=m}break}case"yeaft_task_cancel_result":{let a=r.taskId||r.task?.id||null,l=r.task?.sessionId||r.sessionId||e.sessionId||null,c=e.agentId||$e(this,l);if(a&&l&&r.success===!1){let{[$l(c,l,a)]:u,...g}=this.yeaftStoppingTasksById||{};this.yeaftStoppingTasksById=g}let d=r.task;if(d?.id&&d.sessionId){let u=Le(c,d.sessionId),g={...this.yeaftActiveTasksBySession},p={...g[u]||{}};d.status==="running"?p[d.id]={...d,agentId:c}:delete p[d.id];let f=Ll(p);Object.keys(f).length>0?g[u]=f:delete g[u],this.yeaftActiveTasksBySession=g}break}case"sub_agent_event":{let a=Ts(this,e.agentId||null,e.conversationId)||"unknown",l=r.agentId;if(!l)break;let c=r.payload||{},d=`${a}:${l}`,u=this.yeaftSubAgentCards[d],g=this.messagesMap[a]||[],p=u?u.anchorMsgId:g.length>0&&g[g.length-1].id||null,f=u?u.anchorOrder:g.length,m=u?{...u}:{key:d,conversationId:a,agentId:l,agentName:c.agentName||"sub-agent",status:"running",text:"",toolCallCount:0,turns:0,error:null,expanded:!1,anchorMsgId:p,anchorOrder:f,updatedAt:Date.now(),sessionId:e.sessionId||null};switch(c.agentName&&!m.agentName&&(m.agentName=c.agentName),c.type){case"sub_agent_status":m.status=c.status||m.status,c.error&&(m.error=c.error);break;case"text_delta":break;case"tool_use":case"tool_call":m.toolCallCount=Number(m.toolCallCount||0)+1;break;case"tool_start":break;case"tool_result":case"tool_end":break;case"sub_agent_turn_end":{m.turns+=1;let v=typeof c.content=="string"?c.content.trim():"";v&&(m.text=m.text?`${m.text}
8
+ `))}function co(e){let t=Array.isArray(e?.textSegments)?e.textSegments:[];if(t.length===0)return;let s=Array.isArray(e?.messages)?e.messages:[],n=e?.isActive===!0||e?.isStreaming===!0||t.some(l=>l.isStreaming===!0)||s.some(l=>l?.isStreaming===!0||l?.status==="pending"),r=s.some(l=>l?.incomplete===!0||xl.has(l?.status)||xl.has(l?.turnEndReason)||xl.has(l?.stopReason));if(n||r){for(let l of t)l.kind="progress";return}if(t.some(l=>l.kind==="result"))return;let i=s.some(l=>l?.turnEndReason==="end_turn"),o=t.some(l=>l.explicitKind),a=t.length===1&&!o;(i||a||e.isHistory&&!o)&&(t[t.length-1].kind="result")}var xl,uo=B(()=>{xl=new Set(["aborted","errored","error","cancelled","canceled"])});function Cs(e){return typeof e=="string"?e.trim():""}function yt(e){let t=Cs(e?.runtimeProvider),s=Cs(e?.agentId),n=Cs(e?.sessionId);return!t||!s||!n?"":[t,s,n].map(r=>encodeURIComponent(r)).join(":")}function Fb(e){let t=0xcbf29ce484222325n;for(let s of String(e||""))t^=BigInt(s.codePointAt(0)),t=BigInt.asUintN(64,t*0x100000001b3n);return t.toString(16).padStart(16,"0")}function Tn(e,t){let s=Cs(e),n=Cs(t);return!s||!n?"":`${s}@${Fb(n)}`}function Jr(e,t="main"){if(!e)return"";let s=["main","files-folder-picker","git-folder-picker"].includes(t)?t:"main";return s==="main"?`_workbench:${e}`:`_workbench:${e}:${s}`}function cs(e,t){let s=Cs(e?.conversationId);if(!t||!s)return null;if(s===Jr(t))return"main";for(let n of["files-folder-picker","git-folder-picker"])if(s===Jr(t,n))return n;return null}function er(e,t){let s=(n={})=>{let r={runtimeProvider:Cs(t.runtimeProvider),agentId:Cs(t.agentId),sessionId:Cs(t.sessionId)},i="main";n.conversationId==="_folder_picker"?i="files-folder-picker":n.conversationId==="_git_folder_picker"&&(i="git-folder-picker");let o={...n,agentId:r.agentId,workbenchRoute:r,workbenchRouteKey:t.routeKey,workbenchWorkspaceGeneration:t.workspaceGeneration,workbenchScope:i,conversationId:Jr(t.routeKey,i)};return!Object.hasOwn(o,"workDir")&&t.workDir&&(o.workDir=t.workDir),e.sendWsMessage(o)};return new Proxy(e,{get(n,r,i){return r==="currentAgent"?t.agentId||null:r==="currentConversation"?t.conversationId||t.sessionId||null:r==="effectiveWorkDir"?t.workDir||"":r==="activeSessionRoute"?{runtimeProvider:t.runtimeProvider,agentId:t.agentId,sessionId:t.sessionId}:r==="sendWsMessage"?s:Reflect.get(n,r,i)},set(n,r,i,o){return Reflect.set(n,r,i,o)}})}function tr(e,t,s=""){return t?(e?.workbenchRouteKey?e.workbenchRouteKey===t:cs(e,t)!==null)?s?e?.workbenchWorkspaceGeneration===s:!0:!1:!0}var As=B(()=>{});function Tl(e){return e?.type==="user"&&typeof e.content=="string"&&e.content.trim()}function Ml(e){return e?.type==="assistant"||e?.type==="thinking"||e?.type==="tool_use"||e?.type==="tool-use"||e?.type==="tool_result"||e?.type==="tool-result"}function Pl(e,t){if(!e||e.kind!=="assistant")return!0;let s=e.turnId||e.lastTurnId||"",n=t?.turnId||"";if(s&&n&&s!==n)return!0;let r=e.speakerVpId||"",i=t?.speakerVpId||t?.vpId||"";return!!(r&&i&&r!==i)}function Rl(e=[]){let t=[],s=null,n=r=>{s&&(t.push({start:s.start,end:r,kind:s.kind}),s=null)};for(let r=0;r<e.length;r++){let i=e[r];if(i){if(Tl(i)||i.type==="system"||i.type==="error"){n(r),s={start:r,kind:i.type};continue}if(!Ml(i)){s||(s={start:r,kind:"other"});continue}(!s||s.kind==="assistant"&&Pl(s,i))&&(n(r),s={start:r,kind:"assistant",turnId:i.turnId||"",speakerVpId:i.speakerVpId||i.vpId||""}),s.lastTurnId=i.turnId||s.lastTurnId||"",s.speakerVpId=s.speakerVpId||i.speakerVpId||i.vpId||""}}return n(e.length),t}function Qp(e,t){return!e||e._historyWindowPrefetched===!0?!1:t?(e.sessionId??e.groupId)===t:!0}function _l(e=[],t=null,s=ei,n=null){let r=Math.max(1,Number.isFinite(s)?Math.floor(s):ei),i=[],o=[],a=null,l=d=>{a&&(o.push({start:a.start,end:d,kind:a.kind}),a=null)};for(let d of e){if(!Qp(d,t))continue;let u=i.length;if(i.push(d),Tl(d)||d.type==="system"||d.type==="error"){l(u),a={start:u,kind:d.type};continue}if(!Ml(d)){a||(a={start:u,kind:"other"});continue}(!a||a.kind==="assistant"&&Pl(a,d))&&(l(u),a={start:u,kind:"assistant",turnId:d.turnId||"",speakerVpId:d.speakerVpId||d.vpId||""}),a.lastTurnId=d.turnId||a.lastTurnId||"",a.speakerVpId=a.speakerVpId||d.speakerVpId||d.vpId||""}if(l(i.length),o.length<=r)return i;let c=o[o.length-r];return i.slice(c.start)}function Xp(e=[],t=null,s=ei){let n=Math.max(1,s||ei),r=0,i=null,o=()=>i?(i=null,r+=1,r>n):!1;for(let a of e)if(Qp(a,t)){if(Tl(a)||a.type==="system"||a.type==="error"){if(o())return!0;i={kind:a.type};continue}if(!Ml(a)){i||(i={kind:"other"});continue}if(!i||i.kind==="assistant"&&Pl(i,a)){if(o())return!0;i={kind:"assistant",turnId:a.turnId||"",speakerVpId:a.speakerVpId||a.vpId||""}}i.lastTurnId=a.turnId||i.lastTurnId||"",i.speakerVpId=i.speakerVpId||a.speakerVpId||a.vpId||""}return o(),r>n}function Us(){return ei}function ti(){return Ob}var ei,Ob,Zp=B(()=>{ei=Number.POSITIVE_INFINITY,Ob=20});function Vb(e,t){let s=new Set;if(!t)return s;for(let n of e?.sessionCatalog||[])n?.runtimeProvider!=="yeaft"||n?.routeRef?.sessionId!==t||n.routeRef.agentId&&s.add(n.routeRef.agentId);if(s.size===0){let n=ds();for(let r of n?.sessionList||[])r?.id===t&&r?.agentId&&s.add(r.agentId)}return s}function gg(e,t){let s=Vb(e,t);return s.size===1?s.values().next().value:null}function fo(e,t,s){return!!s&&gg(e,t)===s}function Rt(e,t,s){return!e||e.sessionId!==t?!1:s?e.agentId===s:!e.agentId}function Jp(e,t,s=null){if(!t)return!1;let n=s||$e(e,t),r=Is(n,t);if(r&&e.yeaftProcessingSessions?.[r]||e.yeaftProcessingSessions?.[t]&&fo(e,t,n))return!0;for(let i of Object.values(e.activeVpTurns||{}))if(Rt(i,t,n))return!0;for(let i of Object.values(e.vpStatuses||{}))if(Rt(i,t,n)&&ni.has(i?.state))return!0;return!1}function Hb(e,t,s,n=null){let r={...e.yeaftProcessingSessions||{}};if(t){let i=dl(t);if(r=Object.fromEntries(Object.entries(r).filter(([o])=>n?o!==Is(t,n):!o.startsWith(i))),n)fo(e,n,t)&&delete r[n];else for(let o of Object.keys(r))fo(e,o,t)&&delete r[o]}else n?delete r[n]:r={};for(let i of s||[]){let o=i?.sessionId||i?.groupId||null;if(!o||!ni.has(i?.state))continue;let a=Is(t,o)||o;r[a]=!0}return r}function Mn(e,t,s){let n=ul(t,s);return n&&e?.activeVpTurns?.[n]?n:e?.activeVpTurns?.[s]&&(!t||!e.activeVpTurns[s]?.agentId||e.activeVpTurns[s].agentId===t)?s:n||s||""}function eg(e,t){if(!t){e.activeVpTurns={},e.stoppingVpTurnIds={},e.vpStatuses={},e.yeaftProcessingSessions={};return}e.activeVpTurns=Object.fromEntries(Object.entries(e.activeVpTurns||{}).filter(([,n])=>n?.agentId&&n.agentId!==t)),e.stoppingVpTurnIds=Object.fromEntries(Object.entries(e.stoppingVpTurnIds||{}).filter(([n])=>e.activeVpTurns?.[n])),e.vpStatuses=Object.fromEntries(Object.entries(e.vpStatuses||{}).filter(([,n])=>n?.agentId&&n.agentId!==t));let s=dl(t);e.yeaftProcessingSessions=Object.fromEntries(Object.entries(e.yeaftProcessingSessions||{}).filter(([n])=>!n.startsWith(s)))}function xs(e,t){return`${e||""}:${t||""}`}function Gb(e){return e?.kind==="action"&&typeof e.actionId=="string"&&Number.isInteger(Number(e.generation))&&Number(e.generation)>0?{kind:"action",actionId:e.actionId,generation:Number(e.generation)}:{kind:"coordinator"}}function Qb(e){return typeof e=="string"?e:e?.kind==="action"&&typeof e.actionId=="string"?{kind:"action",actionId:e.actionId,generation:Number.isInteger(Number(e.generation))?Number(e.generation):0}:{kind:"coordinator"}}function Xb(e={}){let t=Tt(e.quote);return{agentId:e.agentId||"",workItemId:e.workItemId||"",target:Gb(e.target),text:String(e.text||""),...t?{quote:t}:{},attachments:Array.isArray(e.attachments)?e.attachments.map(s=>({fileId:s?.fileId||"",name:s?.name||"",mimeType:s?.mimeType||"",size:Math.max(0,Number(s?.size)||0)})):[],revision:Number(e.revision)||0,planRevision:Number(e.planRevision)||0,ledgerRevision:Number(e.ledgerRevision)||0,coordinatorRevision:Number(e.coordinatorRevision)||0}}function ng(e,t,s){return{conversationId:s||null,agentId:e?.agentId||t?.agentId||null,requestId:t?.requestId||null,toolCallId:t?.toolCallId||null,sessionId:e?.sessionId||t?.sessionId||null,vpId:e?.vpId||t?.vpId||null,turnId:e?.turnId||t?.turnId||null,threadId:e?.threadId||t?.threadId||null}}function rg(e,t){return{conversationId:t||null,agentId:e?.agentId||null,requestId:e?.askRequestId||null,toolCallId:e?.toolId||null,sessionId:e?.sessionId||e?.groupId||null,vpId:e?.vpId||e?.speakerVpId||null,turnId:e?.turnId||null,threadId:e?.threadId||null}}function Zb(e,t){return ql.every(s=>!t[s]||e[s]===t[s])}function fg(e,t){return ql.every(s=>!e[s]||!t[s]||e[s]===t[s])}function ig(e,t,s){let n=(e||[]).filter(o=>o?.type==="tool-use"&&(o.toolName==="AskUser"||o.toolName==="AskUserQuestion")&&(!t.requestId||!o.askRequestId||o.askRequestId===t.requestId)&&(!t.toolCallId||!o.toolId||o.toolId===t.toolCallId)),r=n.filter(o=>Zb(rg(o,s),t));if(r.length===1)return r[0];let i=n.filter(o=>fg(rg(o,s),t));return i.length===1?i[0]:null}function hg(e){return ql.map(t=>e[t]||"").join("\0")}function Jb(e,t,s){let n=hg(t),r={...e._yeaftAskTerminalEvents||{},[n]:{identity:t,event:s,receivedAt:Date.now()}},i=Object.keys(r);if(i.length>sg){i.sort((o,a)=>r[o].receivedAt-r[a].receivedAt);for(let o of i.slice(0,i.length-sg))delete r[o]}e._yeaftAskTerminalEvents=r}function og(e,t){let s=e._yeaftAskTerminalEvents||{},n=hg(t),r=s[n]?n:null;if(!r){let l=Object.entries(s).filter(([,c])=>fg(c.identity||{},t));l.length===1&&(r=l[0][0])}if(!r)return null;let i=s[r],{[r]:o,...a}=s;return e._yeaftAskTerminalEvents=a,i?.event||null}function ew(e,t,s){return(e.messagesMap?.[t]||[]).some(n=>n?.type==="tool-use"&&n.sessionId===s&&n.hasResult===!1)}function Dl(e,t){if(!(t.type==="ask_user_answer_rejected"&&(e.askAnswered||e.askExpired))){if(t.type==="ask_user_answer_rejected"&&t.reason==="agent_unavailable"){e.askError="agent_unavailable",e.askSubmittedAt=0;return}e.askError=t.type==="ask_user_answer_rejected"?t.reason||"unavailable":null,e.askSubmittedAt=null,t.type==="ask_user_answered"?(e.askAnswered=!0,e.selectedAnswers=t.answers||{},e.askExpired=!1):(e.isHistory=!0,e.askExpired=!0,e.askAnswered=!1,e.selectedAnswers=null),e.askPending=!1,e.pendingAnswers=null,e.askSubmitGeneration=null,e.askRequestId=null}}function tw(e){if(!e||typeof e!="string")return null;let t=e.match(/^(\d+)/);if(!t)return null;let s=Number(t[1]);return Number.isFinite(s)?s:null}function sw(e){if(!e||typeof e!="string")return null;let t=e.match(/^m(\d+)$/);if(!t)return null;let s=Number(t[1]);return Number.isFinite(s)?s:null}function si(e){return Lr(e)}function $l(e,t,s){return`${Is(e,t)}::${s||""}`}function Ll(e){return Object.fromEntries(Object.entries(e||{}).filter(([,t])=>t?.status==="running"))}function ds(){try{return typeof window>"u"?null:window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore()||null}catch{return null}}function ag(e){let t=ds();if(!t?.reorderSessionsGlobally)return;let s=(Array.isArray(e)?e:[]).filter(n=>n?.runtimeProvider==="yeaft").map(n=>`${n.routeRef?.agentId||""}${n.routeRef?.sessionId||""}`).filter(n=>!n.startsWith(""));t.reorderSessionsGlobally(s)}function $e(e,t,s=null){if(s)return s;if(t){let n=ds(),r=n?.activeSessionKey?n.sessions?.[n.activeSessionKey]:null;if(r?.id===t&&r.agentId)return r.agentId;let i=n&&typeof n.sessionById=="function"?n.sessionById(t,e?.currentAgent||null):null;if(i&&i.agentId)return i.agentId;let o=e?.yeaftSessionAgentById?e.yeaftSessionAgentById[t]:null;if(o)return o}return e?.currentAgent||null}function lg(e){let t=Ms(e),s=$e(e,t),n=ds()?.sessionById?.(t,s),r=e.currentAgentInfo?.id===s?e.currentAgentInfo:e.agents?.find(o=>o?.id===s),i=o=>typeof o=="string"?o.trim():"";return i(n?.workDir)||i(r?.workDir)}function nw(e,t){let s=i=>String(i||"").replace(/^v/,"").split(".").slice(0,3).map(o=>Number.parseInt(o,10)),n=s(e),r=s(t);if(n.length<3||r.length<3||[...n,...r].some(i=>!Number.isFinite(i)))return!1;for(let i=0;i<3;i+=1)if(n[i]!==r[i])return n[i]>r[i];return!0}function St(e,t,s){if(!t||!s)return!1;let n=Array.isArray(e?.agents)?e.agents.find(o=>o?.id===t):null,r=e?.currentAgentInfo?.id===t?e.currentAgentInfo:null;return(n?.capabilities||r?.capabilities||[]).includes(s)?!0:s==="session_history_search"&&nw(n?.version||r?.version,"1.0.166")}function Ms(e,{fallbackDefault:t=!1}={}){if(e?.yeaftActiveSessionFilter)return e.yeaftActiveSessionFilter;let s=ds();return s?.activeSessionId?s.activeSessionId:t?"grp_default":null}function go(e){let t=e.yeaftDebugSessionFilter;if(t==="__all__")return null;if(t)return t;let s=Ms(e);return s||(ds()?.sessions?.grp_default?"grp_default":null)}function Fl(e,t="session"){return[e?.vpId||e?.ownerVpId||"vp",e?.threadId||"thread",e?.turnId||t].join(":")}function Ts(e,t,s=null){return s||t&&e?.yeaftConversationIdsByAgent?.[t]||e?.yeaftConversationId||null}function It(e,t=null,s=null){let n=t||e?.yeaftActiveSessionFilter||null,r=s||$e(e,n);return(r&&e?.yeaftConversationIdsByAgent?e.yeaftConversationIdsByAgent[r]:null)||e?.yeaftConversationId||null}function cg(e,t,s){if(e?.currentView!=="yeaft")return!1;let n=e?.yeaftActiveSessionFilter||null;if(n&&t!==n)return!1;let r=$e(e,n);return!r||!s||r===s}var qb,st,po,El,Bb,Nb,Wb,jb,Ub,tg,Kb,ni,zb,Yb,sg,ql,dg,Ol,ug,pg,Pn,ho=B(()=>{qt();Da();ss();Ni();Fa();Va();Br();ju();np();Tp();hn();Bs();qr();Dp();tl();Zi();Fp();Op();Vp();ji();Al();rl();js();uo();As();Nn();Ui();io();Zp();zi();il();({defineStore:qb}=Pinia),st=Object.freeze([]),po=(e,t,s)=>`${e||""}::${t||""}::${s}`;El=5,Bb=100,Nb=512*1024,Wb=15e3,jb=1e4,Ub=450,tg=Object.freeze([150,300,600,1e3]),Kb=new Set(["index_building","stale_result"]),ni=new Set(["typing","thinking","retrying","streaming","tool"]),zb=Object.freeze(["model","availableModels","refreshedAt","catalogRefreshedAt","catalogEpoch","catalogRevision","catalogDigest","refreshStartedAt","refreshReason","refreshError","refreshing"]),Yb=8,sg=64;ql=Object.freeze(["conversationId","agentId","requestId","toolCallId","sessionId","vpId","turnId","threadId"]);dg=1e3,Ol=1,ug=5,pg=200,Pn=qb("chat",{state:()=>({ws:null,authenticated:!1,_hasHandledAgentList:!1,_hasHandledYeaftSessionHydrate:!1,yeaftSessionInventoryCompleteSupported:null,workbenchRouteProtocolSupported:null,browserRuntimeProtocolSupported:null,browserRuntimeSetupProtocolSupported:null,browserRuntimeServerEnabled:!1,yeaftSessionHydrateRequestId:null,yeaftSessionHydrateSlices:[],yeaftSessionHydrateError:null,_yeaftSessionInventorySocketQuarantined:!1,sessionKey:null,serverEncryptionRequired:!0,sessionForkPendingKey:null,sessionForkState:"idle",connectionState:"disconnected",reconnectAttempts:0,maxReconnectAttempts:10,reconnectTimer:null,agents:[],currentAgent:null,currentAgentInfo:null,conversations:[],activeConversations:[],currentWorkDir:null,messagesMap:{},_messageUiKeySequence:0,chatSessionState:{},panels:[],activePanelId:null,_pendingPaneId:null,conversationTitles:{},customConversationTitles:{},processingConversations:{},yeaftProcessingSessions:{},yeaftUnreadSessionKeys:{},theme:localStorage.getItem("theme")||(typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),themeFollowSystem:!localStorage.getItem("theme"),locale:localStorage.getItem("locale")||"zh-CN",executionStatusMap:{},sessionHealth:{},historySessions:[],historySessionsLoading:!1,folders:[],foldersLoading:!1,providerModels:[],providerModelsLoading:!1,contextUsage:null,lastUsedAgent:localStorage.getItem("lastUsedAgent")||null,lastUsedSession:JSON.parse(localStorage.getItem("lastUsedSession")||"null"),lastViewedConversation:localStorage.getItem("lastViewedConversation")||null,pendingRecovery:null,recoveryDismissed:!1,sessionLoading:!1,sessionLoadingText:"",agentSwitching:!1,pendingAgentSelection:null,_pendingSessionTitle:null,workbenchExpanded:!1,workbenchMaximized:!1,workbenchPanelStateByRoute:{},sidebarCollapsed:!1,sessionSidebarOpen:!1,compactStatus:null,clearStatus:null,refreshingSession:!1,refreshingSessionMap:{},proxyPorts:{},hasMoreMessages:!1,loadingMoreMessages:!1,chatHistoryRequests:{},chatHistoryRequestIdSupported:null,chatHistoryConnectionGeneration:0,sessionCatalog:[],hiddenSessionCatalog:[],sessionProjects:[],sessionCatalogLoaded:!1,sessionCatalogMutationRequests:{},projectMutationRequests:{},activeCatalogKey:null,openUnifiedSessionCreate:!1,openUnifiedChatCreate:!1,pendingUnifiedSessionSettings:null,pluginCenterOpen:!1,pluginCenterAgentId:null,pluginConfigByAgent:{},pluginCatalogByKey:{},pluginCatalogRequestByKey:{},managedSkillRequestByKey:{},_pluginPending:{},yeaftHasMoreHistory:!1,yeaftLoadingMoreHistory:!1,yeaftOldestLoadedSeq:null,yeaftHistoryLoadError:null,_yeaftManualHistoryRefresh:null,yeaftSessionHistoryState:{},yeaftMessageWindowState:{},yeaftHistoryCacheState:{},yeaftBootstrapMetaLoadingKey:null,yeaftHistoryPerfTraceBySession:{},_yeaftHistoryPrefetchBySession:{},yeaftHistorySearchState:{requestId:null,agentId:null,sessionId:null,query:"",senderKey:"",loading:!1,results:[],hasMore:!1,nextBeforeSeq:null,nextCursor:null,error:null},yeaftHistoryOutlineBySession:{},_yeaftHistoryOutlineTimeouts:{},_yeaftHistorySearchTimeout:null,_yeaftHistoryWindowPendingByKey:{},_yeaftHistoryResultRefreshByRequestId:{},_yeaftHistoryRevealLeases:{},_yeaftHistoryRevealSequence:0,yeaftHistoryFocusWindowBySession:{},_yeaftReconnectCatchUpPending:!1,_yeaftOpenedSessionsLoadedAgents:{},_yeaftAgentSeen:null,slashCommandsMap:{},slashCommandDescriptions:{},inputDrafts:{},mcpServers:{},expertRoleDefinitions:null,llmConfig:{},llmModelDiscovery:{},llmGithubDevice:null,modelsDevRegistry:{registry:{},fetchedAt:0,error:null,loaded:!1},_modelsDevPending:null,yeaftSettings:{},searchSettings:null,telemetrySettings:null,telemetrySettingsByAgent:{},telemetryRequestByAgent:{},workCenterFeatureSettingsByAgent:{},workCenterFeatureRequestByAgent:{},agentOperations:{},agentUpgradeBatch:null,agentDreamState:{},tavilyUsage:null,tavilyUsageLoading:!1,_perfTraceQueue:[],_perfTraceFlushTimer:null,yeaftPerfTraceByMessageId:{},yeaftPerfTraceByTurnId:{},yeaftMcpServers:[],yeaftMcpRuntime:{connected:!1,toolCount:0,perServer:[]},yeaftMcpLoading:!1,yeaftMcpError:null,btwMode:!1,btwMessages:[],btwLoading:!1,btwSessionId:null,conversationMcpServers:{},conversationMcpServerTools:{},mcpPanelOpen:!1,expertSelections:[],customExpertRoles:[],subagents:{},activeSubagentId:null,activeRightPanel:null,pinnedSessions:JSON.parse(localStorage.getItem("pinned-sessions")||"[]"),...Rp(),workCenterOpen:!1,workCenterUiEnabled:localStorage.getItem("work-center-ui-enabled")!=="false",workCenterAgentId:null,workCenterItemsByAgent:{},workCenterListPageByAgent:{},workCenterListMoreLoadingByAgent:{},_workCenterListGenerationByAgent:{},_workCenterListQueryByAgent:{},_workCenterListFiltersByAgent:{},_workCenterListMoreRequestsByAgent:{},_workCenterListEventGenerationByAgent:{},_workCenterListEventsByAgent:{},_workCenterDeletedIdsByAgent:{},workCenterDetailByAgent:{},workCenterActionMessages:{},workCenterActionMessagesLoading:{},workCenterActionMessagesError:{},workCenterActionRequests:{},workCenterActionRequestDetails:{},workCenterActionRequestsLoading:{},workCenterActionRequestsError:{},workCenterActionRequestDetailsLoading:{},workCenterActionRequestDetailsError:{},workCenterLoadedByAgent:{},workCenterLoadingByAgent:{},workCenterErrorByAgent:{},workCenterWatcherByAgent:{},workCenterSettingsByAgent:{},workCenterRuntimeByAgent:{},workCenterSettingsLoadingByAgent:{},workCenterSettingsErrorByAgent:{},_workCenterSettingsGenerationByAgent:{},_workCenterDetailRequestGenerationByAgent:{},_workCenterDetailEventRefreshByAgent:{},_workCenterActionInputGenerationByAgent:{},_workCenterActionMessageRequests:{},_workCenterActionMessageGenerationByKey:{},_workCenterActionRequestsGeneration:{},_workCenterActionRequestDetailsGeneration:{},workCenterPending:{},workCenterComposerDrafts:{},workCenterMessageOutbox:{},_workCenterBrowserFence:null,_workCenterBrowserUnsubscribe:null,workCenterCreateDraft:null,yeaftConversationId:null,yeaftConversationIdsByAgent:{},_yeaftPendingConversationPromotions:{},_yeaftRetiredConversationIdsByAgent:{},_yeaftRetiredConversationTargetsByAgent:{},yeaftSessionAgentById:{},yeaftModel:null,yeaftModelEffort:null,yeaftSessionReady:!1,yeaftStatus:null,yeaftAvailableModels:[],yeaftStatusByAgent:{},_yeaftRetiredCatalogEpochsByAgent:{},yeaftModelsRefreshing:!1,yeaftModelRefreshError:null,yeaftYeaftDir:null,yeaftActiveTasksBySession:{},yeaftStoppingTasksById:{},yeaftToolStats:null,yeaftToolStatsLoading:!1,yeaftDebugLoops:[],yeaftDebugTurnsById:{},yeaftDebugTurnOrder:[],yeaftDebugHistoryLoading:!1,yeaftDebugHistoryError:null,yeaftDebugHistoryFetchedAt:0,yeaftDebugHistoryProjection:null,yeaftDebugHistoryLimit:Ol,yeaftDebugHistoryHasMore:!1,yeaftDebugPanel:{open:!1,status:"idle",requestId:null,agentId:null,sessionId:null,turnId:null,error:null},yeaftDebugSearch:"",yeaftDebugSessionFilter:null,yeaftDreamLatest:{},yeaftDreamSnapshots:{},yeaftDreamPromptLoads:{},yeaftDreamEvents:{},yeaftReflectionCards:{},yeaftSubAgentCards:{},yeaftSidebarV2Enabled:!0,yeaftActiveSessionFilter:null,_currentYeaftSessionId:null,_currentYeaftVpId:null,_currentYeaftTurnId:null,_currentYeaftThreadId:null,_yeaftAskTerminalEvents:{},activeVpTurns:{},vpStatuses:{},stoppingVpTurnIds:{},yeaftVpTyping:{},_vpCrudPending:null}),getters:{currentConversation:e=>e.activeConversations[0]||null,activeConversationId:e=>oo(e),activeSessionRoute(e){if(e.currentView==="yeaft"){let n=Ms(e);return n?{runtimeProvider:"yeaft",agentId:$e(e,n),sessionId:n}:null}let t=oo(e);if(!t)return null;let s=e.conversations.find(n=>n?.id===t&&n.type!=="yeaft");return s?{runtimeProvider:s.provider==="copilot"?"copilot":"claude-code",agentId:s.agentId||e.currentAgent||null,sessionId:t}:null},messages(e){let t=this.activeConversationId,s=t&&e.messagesMap[t]||st;if(e.currentView==="yeaft"){let n=e.yeaftActiveSessionFilter||null,r=Le($e(e,n),n),i=e.yeaftMessageWindowState[r]?.visibleTurns||Us(),o=e.yeaftHistoryFocusWindowBySession?.[r]?.windowKey||null;return _l(s,e.yeaftActiveSessionFilter||null,i,o)}return s},yeaftAllMessages:e=>{let t=It(e);return t&&e.messagesMap[t]||st},yeaftVisibleMessages(e){let t=It(e),s=t&&e.messagesMap[t]||st,n=e.yeaftActiveSessionFilter||null,r=Le($e(e,n),n),i=e.yeaftMessageWindowState[r]?.visibleTurns||Us(),o=e.yeaftHistoryFocusWindowBySession?.[r]?.windowKey||null;return _l(s,e.yeaftActiveSessionFilter||null,i,o)},hasHiddenYeaftMessages(e){if(e.currentView!=="yeaft")return!1;let t=It(e),s=t&&e.messagesMap[t]||st,n=e.yeaftActiveSessionFilter||null,r=Le($e(e,n),n),i=e.yeaftMessageWindowState[r]?.visibleTurns||Us();return Xp(s,e.yeaftActiveSessionFilter||null,i)},activeYeaftHistoryState(e){return Na(e)},yeaftManualHistoryRefreshLoading(e){let t=e._yeaftManualHistoryRefresh||null;if(!t?.requestId)return!1;let s=Le(t.agentId,t.sessionId),n=Xt(e),r=e.yeaftSessionHistoryState?.[s]||null;return n.sessionKey===s&&r?.loading===!0&&r.requestId===t.requestId},yeaftInitialHistoryLoading(e){let t=Na(e);return e.currentView==="yeaft"&&!!e.yeaftActiveSessionFilter&&!!t?.loading&&!t?.loaded&&this.yeaftVisibleMessages.length===0},vpsTypingInCurrentConv(e){let t=this.activeConversationId;if(!t)return st;let s=(e.yeaftVpTyping||{})[t];if(!s)return st;let n=Object.keys(s).filter(r=>(s[r]||0)>0);return n.length===0?st:n},isVpTypingInCurrentConv(e){return t=>{if(!t)return!1;let s=this.activeConversationId;if(!s)return!1;let n=(e.yeaftVpTyping||{})[s];return n?(n[t]||0)>0:!1}},yeaftDreamLatestForActiveSession(e){let t=go(e);if(!t)return null;let s=`sessions/${t}`;return e.yeaftDreamLatest?.[s]||null},yeaftDreamSnapshotForActiveSession(e){let t=go(e);if(!t)return null;let s=`sessions/${t}`;return e.yeaftDreamSnapshots?.[s]||null},yeaftDreamPromptLoadForActiveSession(e){let t=go(e);if(!t)return null;let s=`sessions/${t}`;return e.yeaftDreamPromptLoads?.[s]||null},yeaftDreamEventsForActiveSession(e){let t=go(e);if(!t)return[];let s=`sessions/${t}`,n=Array.isArray(e.yeaftDreamEvents?.[s])?e.yeaftDreamEvents[s]:[],r=Array.isArray(e.yeaftDreamEvents?.["*"])?e.yeaftDreamEvents["*"]:[];return r.length===0?n:n.length===0?r:[...n,...r].sort((i,o)=>(i.at||0)-(o.at||0))},yeaftDebugTurnsForActiveSession:e=>{let t=e.yeaftDebugTurnOrder||st,s=e.yeaftDebugTurnsById||{},n=e.yeaftDebugLoops||st,r=e.yeaftReflectionCards||{},i=e.yeaftDebugSessionFilter,o;i==="__all__"?o=null:i?o=i:o=null;let a={};for(let d of n)!d||!d.turnId||(a[d.turnId]||(a[d.turnId]=[]),a[d.turnId].push(d));let l={};for(let d of Object.keys(r)){let u=r[d];!u||!u.turnId||(l[u.turnId]||(l[u.turnId]=[]),l[u.turnId].push(u))}let c=[];for(let d=t.length-1;d>=0;d--){let u=t[d],g=s[u];if(!g||o&&g.sessionId&&g.sessionId!==o)continue;let p=a[u]||st,f=l[u]||st,m=p.length,v=0,b=0;for(let S of p){let y=S&&S.usage;y&&Number.isFinite(y.totalTokens)?v+=y.totalTokens:y&&(v+=(y.totalInputTokens||(y.inputTokens||0)+(y.cacheReadTokens||0)+(y.cacheWriteTokens||0))+(y.outputTokens||0)),S&&Number.isFinite(S.latencyMs)&&(b+=S.latencyMs)}let h=!g.closedAt,k={...g,loopCount:h||!g.loopCount?m:g.loopCount,totalTokens:h||!g.totalTokens?v:g.totalTokens,totalMs:h||!g.totalMs?b:g.totalMs,loops:p,reflections:f};c.push(k)}return c},yeaftDebugAvailableSessions:e=>{let t=new Set;for(let s of e.yeaftDebugTurnOrder||st){let n=e.yeaftDebugTurnsById[s];n&&n.sessionId&&t.add(n.sessionId)}return Array.from(t).sort()},yeaftDebugTurnTotal:e=>(e.yeaftDebugTurnOrder||st).length,messagesCache:e=>e.messagesMap,isMultiColumn:e=>e.activeConversations.length>1,isSplitMode:e=>e.panels.length>1,isProcessing:e=>{if(e.currentView==="yeaft"){let t=Ms(e);return t?Jp(e,t,$e(e,t)):!1}return e.currentConversation?!!e.processingConversations[e.currentConversation]:!1},canSend:e=>!(!e.currentAgent||!e.currentConversation),currentAgentName:e=>e.currentAgentInfo?.name||"\u9009\u62E9 Agent",currentAgentWorkDir:e=>e.currentAgentInfo?.workDir||"",effectiveWorkDir:e=>e.currentView==="yeaft"?lg(e):e.currentWorkDir||e.currentAgentInfo?.workDir||"",fileReferenceResolutionContextKey:e=>{let t=e.currentView==="yeaft"?(()=>{let o=Ms(e);return o?{runtimeProvider:"yeaft",agentId:$e(e,o),sessionId:o}:null})():(()=>{let o=oo(e),a=e.conversations.find(l=>l?.id===o&&l.type!=="yeaft");return a?{runtimeProvider:a.provider==="copilot"?"copilot":"claude-code",agentId:a.agentId||e.currentAgent||null,sessionId:o}:null})(),s=t?.agentId||e.currentAgent||null,n=t?.runtimeProvider==="yeaft"?It(e,t.sessionId,s):e.currentConversation,r=St(e,s,"file_reference_resolution");if(!s||!n||!r)return"";let i=e.currentView==="yeaft"?lg(e):e.currentWorkDir||e.currentAgentInfo?.workDir||"";return JSON.stringify([e.connectionState,e.authenticated,e.workbenchRouteProtocolSupported,t?.runtimeProvider||"",s,t?.sessionId||"",n,i,St(e,s,"file_editor"),St(e,s,"workbench_session_routes"),St(e,s,"response_image_preview")])},currentAgentCapabilities:e=>e.currentAgentInfo?.capabilities||["terminal","file_editor","background_tasks"],hasCapability:e=>t=>(e.currentAgentInfo?.capabilities||["terminal","file_editor","background_tasks"]).includes(t),hasAgentCapability:e=>(t,s)=>St(e,t,s),getConversationTitle:e=>t=>e.customConversationTitles[t]||e.conversationTitles[t]||null,executionStatus:e=>e.currentConversation?e.executionStatusMap[e.currentConversation]||{currentTool:null,toolHistory:[],lastActivity:null}:{currentTool:null,toolHistory:[],lastActivity:null},isConversationProcessing:e=>t=>!!e.processingConversations[t],isConversationConnecting:e=>t=>t?!!e.conversations.find(n=>n.id===t)?.connecting:!1,isConversationCompacting:e=>t=>t?e.compactStatus?.conversationId===t&&e.compactStatus?.status==="compacting":!1,isYeaftSessionProcessing:e=>(t,s=null)=>Jp(e,t,s),isSessionHistorySyncing:e=>t=>{let s=t?.sessionId||null;return s?t.runtimeProvider==="yeaft"?!!e.yeaftSessionHistoryState?.[Le(t.agentId||null,s)]?.loading:!!e.chatHistoryRequests?.[Vs(s)]?.loading:!1},isYeaftSessionUnread:e=>(t,s=null)=>{if(!t)return!1;let n=$e(e,t,s);return n?!!e.yeaftUnreadSessionKeys?.[Hn(n,t)]:!1},showRecoveryBanner:e=>e.pendingRecovery&&!e.recoveryDismissed&&!e.currentConversation,currentSubagents:e=>{if(!e.currentConversation)return st;let t=e.subagents[e.currentConversation];return t?Object.values(t):st},hasRunningSubagents:e=>{if(!e.currentConversation)return!1;let t=e.subagents[e.currentConversation];return t?Object.values(t).some(s=>s.status==="running"):!1},runningSubagentCount:e=>{if(!e.currentConversation)return 0;let t=e.subagents[e.currentConversation];return t?Object.values(t).filter(s=>s.status==="running").length:0},activeSubagentMessages:e=>{if(!e.currentConversation||!e.activeSubagentId)return st;let t=e.subagents[e.currentConversation];if(!t)return st;let s=t[e.activeSubagentId];return(Array.isArray(s?.messages)?s.messages:st).filter(r=>r?.type==="text")},selectedTaskInfo:()=>null,currentMcpServers:e=>e.currentConversation&&e.conversationMcpServers[e.currentConversation]||st},actions:{activateChatView({persistPreference:e=!1}={}){let t=this._pendingChatRestoreConversationId;this._pendingChatRestoreConversationId=null;let s=t?this.conversations.find(o=>o.id===t):null,n=s?.agentId?this.agents.find(o=>o.id===s.agentId&&o.online):null;!this._savedChatIdentity&&s&&n&&(this._savedChatIdentity={agentId:n.id,agentInfo:{...n},workDir:s.workDir||n.workDir||null}),this.currentView="chat",e&&hl("chat");let r=this._savedChatIdentity||null,i=this.pendingAgentSelection&&this.pendingAgentSelection.agentId!==r?.agentId;r?.agentId&&(this.currentAgent!==r.agentId||i)&&this.selectAgent(r.agentId),Ep(this),t&&s&&n&&(this.autoRestoreConversation(t),this.sendWsMessage({type:"refresh_conversation",conversationId:t}))},enterWorkCenter(e=null){if(!this.hydrateWorkCenterBrowserState())return!1;let t=this.agents.filter(n=>n?.online&&Array.isArray(n.capabilities)&&n.capabilities.includes("work_center")),s=t.some(n=>n.id===e)?e:t.some(n=>n.id===this.workCenterAgentId)?this.workCenterAgentId:t[0]?.id||null;return this.workCenterAgentId=s,this.workCenterOpen=!0,this.closeSessionSidebar(),s&&this.listWorkItems(s).catch(()=>{}),!0},leaveWorkCenter(){if(!this.workCenterOpen)return;this.workCenterOpen=!1;let e=new URL(window.location.href);for(let t of["workAgentId","workItemId","workContent"])e.searchParams.delete(t);window.history.replaceState({...window.history.state,workCenter:!1,workCenterContent:!1},"",`${e.pathname}${e.search}${e.hash}`)},setWorkCenterUiEnabled(e){this.workCenterUiEnabled=e!==!1;try{localStorage.setItem("work-center-ui-enabled",String(this.workCenterUiEnabled))}catch{}this.workCenterUiEnabled||this.leaveWorkCenter()},openPluginCenter(e=null){let t=this.agents.find(s=>s?.online&&s.id===e)||this.agents.find(s=>s?.online&&s.id===this.currentAgent)||this.agents.find(s=>s?.online)||null;return t?(this.pluginCenterAgentId=t.id,this.pluginCenterOpen=!0,!0):!1},closePluginCenter(){this.pluginCenterOpen=!1},pluginCatalogKey(e,t=""){return`${e||""}${String(t||"").trim()}`},loadPluginConfig(e=this.pluginCenterAgentId||this.currentAgent){if(!e)return Promise.resolve({plugins:{},error:"no agent"});let t=this.agents.find(n=>n?.id===e);if(!Vn(t))return Promise.resolve({plugins:{},error:"The selected Agent does not support Plugins; upgrade and restart the Agent"});let s=`plugins-get-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;return new Promise(n=>{let r=setTimeout(()=>{this._pluginPending?.[s]&&(delete this._pluginPending[s],n({plugins:{},error:"timeout"}))},1e4);this._pluginPending[s]={resolve:n,timer:r,kind:"config",agentId:e},this.sendWsMessage({type:"get_yeaft_plugins",agentId:e,requestId:s})})},savePluginConfig(e,t=this.pluginCenterAgentId||this.currentAgent){if(!t)return Promise.resolve({plugins:{},error:"no agent"});let s=this.agents.find(r=>r?.id===t);if(!Vn(s))return Promise.resolve({plugins:{},error:"The selected Agent does not support Plugins; upgrade and restart the Agent"});let n=`plugins-save-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;return new Promise(r=>{let i=setTimeout(()=>{this._pluginPending?.[n]&&(delete this._pluginPending[n],r({plugins:{},error:"timeout"}))},1e4);this._pluginPending[n]={resolve:r,timer:i,kind:"save",agentId:t},this.sendWsMessage({type:"update_yeaft_plugins",agentId:t,requestId:n,plugins:e})})},activePluginSession(){let e=this.yeaftActiveSessionFilter||ds()?.activeSessionId||null;if(!e)return{sessionId:"",workDir:""};let t=$e(this,e),s=ds()?.sessionById?.(e,t)||null;return{sessionId:e,agentId:s?.agentId||t||"",workDir:typeof s?.workDir=="string"?s.workDir.trim():""}},managedSkillRequestKey(e,t,s){return`${e||""}${t||""}${s||""}`},mutateManagedSkill({action:e,scope:t,skill:s,name:n,sessionId:r=""}={},i=this.pluginCenterAgentId||this.currentAgent){if(!i)return Promise.resolve({catalog:{tools:[],skills:[],skillSources:[],mcpServers:[]},error:"no agent"});let o=this.agents.find(c=>c?.id===i);if(!Wi(o))return Promise.resolve({catalog:{tools:[],skills:[],skillSources:[],mcpServers:[]},error:"The selected Agent does not support Skill management; upgrade and restart the Agent"});let a=`managed-skill-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,l=this.managedSkillRequestKey(i,t,r);return this.managedSkillRequestByKey={...this.managedSkillRequestByKey,[l]:a},new Promise(c=>{let d=setTimeout(()=>{this._pluginPending?.[a]&&(delete this._pluginPending[a],c({catalog:{tools:[],skills:[],skillSources:[],mcpServers:[]},error:"timeout"}))},1e4);this._pluginPending[a]={resolve:c,timer:d,kind:"managed-skill",agentId:i,key:l,workDir:t==="project"&&this.activePluginSession().workDir||""},this.sendWsMessage({type:"yeaft_managed_skill",agentId:i,requestId:a,action:e,scope:t,...r?{sessionId:r}:{},...s?{skill:s}:{},...n?{name:n}:{}})})},loadPluginCatalog(e=this.pluginCenterAgentId||this.currentAgent,t=""){if(!e)return Promise.resolve({catalog:{tools:[],skills:[],mcpServers:[]},error:"no agent"});let s=this.agents.find(i=>i?.id===e);if(!Vn(s))return Promise.resolve({catalog:{tools:[],skills:[],mcpServers:[]},error:"The selected Agent does not support Plugins; upgrade and restart the Agent"});let n=this.pluginCatalogKey(e,t),r=`plugins-catalog-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;return this.pluginCatalogRequestByKey={...this.pluginCatalogRequestByKey,[n]:r},this.pluginCatalogByKey={...this.pluginCatalogByKey,[n]:{...this.pluginCatalogByKey[n]||{},loading:!0,error:null}},new Promise(i=>{let o=setTimeout(()=>{this._pluginPending?.[r]&&(delete this._pluginPending[r],this.pluginCatalogRequestByKey?.[n]===r&&(this.pluginCatalogByKey={...this.pluginCatalogByKey,[n]:{...this.pluginCatalogByKey[n]||{},loading:!1,error:"timeout"}}),i({catalog:{tools:[],skills:[],mcpServers:[]},error:"timeout"}))},1e4);this._pluginPending[r]={resolve:i,timer:o,kind:"catalog",agentId:e,key:n},this.sendWsMessage({type:"yeaft_plugin_catalog",agentId:e,requestId:r,workDir:String(t||"").trim()})})},enterWorkCenterFromSession(e,t=""){if(!e?.id)return;let s=e.agentId||$e(this,e.id),n=String(t||e.title||e.name||"").trim();this.workCenterCreateDraft={sourceAgentId:s,requirement:n,workDir:String(e.workDir||"").trim(),origin:{sessionId:e.id,messageId:null,createdBy:"user"},linkedSessionIds:[e.id]},this.enterWorkCenter(s)},hydrateWorkCenterBrowserState(){this._workCenterBrowserUnsubscribe||(this._workCenterBrowserUnsubscribe=xd(()=>{Mr(this._workCenterBrowserFence)||this.clearWorkCenterBrowserState()}));let e=Hi();if(!e)return this._workCenterBrowserFence=null,this.workCenterComposerDrafts={},this.workCenterMessageOutbox={},!1;if(!Mr(this._workCenterBrowserFence)){let t=Ad(e);this._workCenterBrowserFence=e,this.workCenterComposerDrafts=t.drafts,this.workCenterMessageOutbox=t.outbox}return!0},clearWorkCenterBrowserState(){this._workCenterBrowserFence=null,this.workCenterComposerDrafts={},this.workCenterMessageOutbox={}},workCenterComposerKey(e,t){return xs(e,t)},saveWorkCenterComposerDraft(e,t,s={}){let n=xs(e,t);if(!e||!t)return;let r=Tt(s.quote),i={...this.workCenterComposerDrafts||{},[n]:{text:String(s.text||""),...r?{quote:r}:{},attachments:Array.isArray(s.attachments)?s.attachments:[],target:Qb(s.target),error:String(s.error||"")}};return Ea(i,this._workCenterBrowserFence)?(this.workCenterComposerDrafts=i,!0):!1},loadWorkCenterComposerDraft(e,t){return this.workCenterComposerDrafts?.[xs(e,t)]||null},removeWorkCenterComposerDraft(e,t){let s=xs(e,t),n={...this.workCenterComposerDrafts||{}};return delete n[s],Ea(n,this._workCenterBrowserFence)?(this.workCenterComposerDrafts=n,!0):!1},prepareWorkCenterMessageEnvelope(e={}){let t=Xb(e),s=xs(t.agentId,t.workItemId),n=this.workCenterMessageOutbox?.[s]||null;if(n)return n;let r={...t,clientMessageId:globalThis.crypto?.randomUUID?.()||`${Date.now()}-${Math.random()}`,createdAt:Date.now()},i={...this.workCenterMessageOutbox||{},[s]:r};return Pr(i,this._workCenterBrowserFence)?(this.workCenterMessageOutbox=i,r):null},loadWorkCenterMessageEnvelope(e,t){return this.workCenterMessageOutbox?.[xs(e,t)]||null},replaceWorkCenterMessageEnvelopeAttachments(e,t,s=[]){let n=xs(e,t),r=this.workCenterMessageOutbox?.[n];if(!r)return null;let i={...r,attachments:Array.isArray(s)?s.map(a=>({fileId:a?.fileId||"",name:a?.name||"",mimeType:a?.mimeType||"",size:Math.max(0,Number(a?.size)||0)})):[]},o={...this.workCenterMessageOutbox||{},[n]:i};return Pr(o,this._workCenterBrowserFence)?(this.workCenterMessageOutbox=o,i):null},discardWorkCenterMessageEnvelope(e,t){let s=xs(e,t),n={...this.workCenterMessageOutbox||{}};return delete n[s],Pr(n,this._workCenterBrowserFence)?(this.workCenterMessageOutbox=n,!0):!1},confirmWorkCenterMessageEnvelope(e,t,s){let n=xs(e,t),r=this.workCenterMessageOutbox?.[n];if(!r||r.clientMessageId!==s)return!1;let i={...this.workCenterMessageOutbox||{}};return delete i[n],Pr(i,this._workCenterBrowserFence)?(this.workCenterMessageOutbox=i,this.removeWorkCenterComposerDraft(e,t),!0):!1},workCenterRequest(e,t={},s=null){let n=s||this.workCenterAgentId||this.currentAgent;if(!n)return Promise.reject(new Error("No Agent selected"));let r=`work-center-${Date.now()}-${Math.random().toString(36).slice(2)}`;return new Promise((i,o)=>{let a=setTimeout(()=>{delete this.workCenterPending[r],o(new Error("Work Center request timed out"))},3e4);this.workCenterPending[r]={resolve:i,reject:o,timer:a,agentId:n,op:e,clientMessageId:typeof t.clientMessageId=="string"?t.clientMessageId:null},this.sendWsMessage({type:"work_center_request",agentId:n,requestId:r,op:e,payload:t})})},workItemMatchesBoardQuery(e,t={}){if(!e||t.lane&&e.boardLane!==t.lane||t.vpId&&!(e.executors||[]).some(n=>n?.id===t.vpId)||t.workItemType&&e.workItemType!==t.workItemType||t.updatedFrom&&Number(e.updatedAt)<Number(t.updatedFrom)||t.updatedTo&&Number(e.updatedAt)>Number(t.updatedTo))return!1;let s=String(t.keyword||"").trim().toLowerCase();return!s||String(e.title||"").toLowerCase().includes(s)||String(e.goal||"").toLowerCase().includes(s)},applyWorkItemBoardSummary(e,t,s={}){let n=An(e,t),r=n.find(i=>i?.id===t?.id)||null;return!r||this.workItemMatchesBoardQuery(r,s)?n:n.filter(i=>i.id!==r.id)},async listWorkItems(e=null,t={}){let s=e||this.workCenterAgentId||this.currentAgent;if(!s)return[];let n={lane:["needs_attention","active","closed"].includes(t.lane)?t.lane:null,keyword:String(t.keyword||t.search||"").trim(),vpId:String(t.vpId||"").trim(),workItemType:String(t.workItemType||"").trim(),createdFrom:Number(t.createdFrom)||null,createdTo:Number(t.createdTo)||null,updatedFrom:Number(t.updatedFrom)||null,updatedTo:Number(t.updatedTo)||null,limit:Math.min(Math.max(Number(t.limit)||100,1),200)},r=JSON.stringify(n),i=Number(this._workCenterListGenerationByAgent[s]||0)+1,o=Number(this._workCenterListEventGenerationByAgent[s]||0);this._workCenterListGenerationByAgent={...this._workCenterListGenerationByAgent,[s]:i},this._workCenterListQueryByAgent={...this._workCenterListQueryByAgent,[s]:r},this._workCenterListFiltersByAgent={...this._workCenterListFiltersByAgent,[s]:n},this.workCenterLoadingByAgent={...this.workCenterLoadingByAgent,[s]:!0},this.workCenterErrorByAgent={...this.workCenterErrorByAgent,[s]:null};try{let a=await this.workCenterRequest("list",n,s),l=(Array.isArray(a?.items)?a.items:[]).filter(d=>!this.workItemDeleted(s,d?.id));if(this._workCenterListGenerationByAgent[s]===i&&this._workCenterListQueryByAgent[s]===r&&this.workCenterAgentId===s){let d=this._workCenterListEventsByAgent[s]||{},u=new Map((this.workCenterItemsByAgent[s]||[]).map(p=>[p.id,p])),g=l.flatMap(p=>{let f=d[p.id]?.summary,m=An(f?[f]:[],u.get(p.id)),v=An(m,p)[0];return this.workItemMatchesBoardQuery(v,n)?[v]:[]});for(let p of Object.values(d))Number(p?.generation)<=o||p?.queryKey!==r||(g=this.applyWorkItemBoardSummary(g,p.summary,n));this.workCenterItemsByAgent={...this.workCenterItemsByAgent,[s]:g},this.workCenterListPageByAgent={...this.workCenterListPageByAgent,[s]:{nextCursor:a?.nextCursor||null,queryKey:r}},this.workCenterWatcherByAgent={...this.workCenterWatcherByAgent,[s]:a?.watcher||null},this.workCenterLoadedByAgent={...this.workCenterLoadedByAgent,[s]:!0}}return l}catch(a){throw this._workCenterListGenerationByAgent[s]===i&&this._workCenterListQueryByAgent[s]===r&&(this.workCenterErrorByAgent={...this.workCenterErrorByAgent,[s]:a?.message||String(a)}),a}finally{this._workCenterListGenerationByAgent[s]===i&&this._workCenterListQueryByAgent[s]===r&&(this.workCenterLoadingByAgent={...this.workCenterLoadingByAgent,[s]:!1})}},async loadMoreWorkItems(e=null){let t=e||this.workCenterAgentId||this.currentAgent,s=this.workCenterListPageByAgent[t],n=this._workCenterListFiltersByAgent[t];if(!t||!s?.nextCursor||!n)return[];let r=s.queryKey,i=this._workCenterListGenerationByAgent[t],o=Number(this._workCenterListEventGenerationByAgent[t]||0),a=s.nextCursor,l=`${i}:${r}:${a}`;if(this._workCenterListMoreRequestsByAgent[t]?.key===l)return this._workCenterListMoreRequestsByAgent[t].request;this.workCenterListMoreLoadingByAgent={...this.workCenterListMoreLoadingByAgent,[t]:!0};let c=(async()=>{try{let d=await this.workCenterRequest("list",{...n,cursor:a},t),u=this.workCenterListPageByAgent[t];if(this._workCenterListGenerationByAgent[t]!==i||this._workCenterListQueryByAgent[t]!==r||u?.queryKey!==r||u?.nextCursor!==a||this.workCenterAgentId!==t)return[];let g=[...this.workCenterItemsByAgent[t]||[]],p=this._workCenterListEventsByAgent[t]||{};for(let f of Array.isArray(d?.items)?d.items:[]){if(this.workItemDeleted(t,f?.id))continue;let m=g.findIndex(k=>k.id===f.id),v=p[f.id]?.summary,b=An(v?[v]:[],m<0?null:g[m]),h=An(b,f)[0];m>=0&&g.splice(m,1),this.workItemMatchesBoardQuery(h,n)&&g.splice(m<0?g.length:m,0,h)}for(let f of Object.values(p))Number(f?.generation)<=o||f?.queryKey!==r||(g=this.applyWorkItemBoardSummary(g,f.summary,n));return this.workCenterItemsByAgent={...this.workCenterItemsByAgent,[t]:g},this.workCenterListPageByAgent={...this.workCenterListPageByAgent,[t]:{nextCursor:d?.nextCursor||null,queryKey:r}},d?.items||[]}finally{if(this._workCenterListMoreRequestsByAgent[t]?.key===l){let d={...this._workCenterListMoreRequestsByAgent};delete d[t],this._workCenterListMoreRequestsByAgent=d,this.workCenterListMoreLoadingByAgent={...this.workCenterListMoreLoadingByAgent,[t]:!1}}}})();return this._workCenterListMoreRequestsByAgent={...this._workCenterListMoreRequestsByAgent,[t]:{key:l,request:c}},c},workItemDeleted(e,t){return!!this._workCenterDeletedIdsByAgent[e]?.[t]},removeWorkItemState(e,t){this._workCenterDeletedIdsByAgent={...this._workCenterDeletedIdsByAgent,[e]:{...this._workCenterDeletedIdsByAgent[e]||{},[t]:!0}},this.beginWorkCenterDetailWrite(e),this.workCenterItemsByAgent={...this.workCenterItemsByAgent,[e]:(this.workCenterItemsByAgent[e]||[]).filter(n=>n.id!==t)},this.workCenterDetailByAgent[e]?.id===t&&(this.workCenterDetailByAgent={...this.workCenterDetailByAgent,[e]:null});let s=`${e}:${t}:`;for(let n of["workCenterActionMessages","workCenterActionMessagesLoading","workCenterActionMessagesError","workCenterActionRequests","workCenterActionRequestsLoading","workCenterActionRequestsError","workCenterActionRequestDetails","workCenterActionRequestDetailsLoading","workCenterActionRequestDetailsError","_workCenterActionMessageRequests","_workCenterActionMessageGenerationByKey","_workCenterActionRequestsGeneration","_workCenterActionRequestDetailsGeneration"]){let r={};for(let[i,o]of Object.entries(this[n]||{}))i.startsWith(s)||(r[i]=o);this[n]=r}},beginWorkCenterDetailWrite(e){let t=Number(this._workCenterDetailRequestGenerationByAgent[e]||0)+1;return this._workCenterDetailRequestGenerationByAgent={...this._workCenterDetailRequestGenerationByAgent,[e]:t},t},commitWorkCenterDetail(e,t,s){if(t?.id&&this.workItemDeleted(e,t.id)||s!=null&&Number(this._workCenterDetailRequestGenerationByAgent[e]||0)!==s)return!1;let n=this.workCenterDetailByAgent[e],r=Cl(n,t);return n&&r===n?!1:(this.workCenterDetailByAgent={...this.workCenterDetailByAgent,[e]:r},!0)},async getWorkItem(e,t=null){let s=t||this.workCenterAgentId||this.currentAgent,n=this.beginWorkCenterDetailWrite(s),r=await this.workCenterRequest("get",{id:e},s);return this.commitWorkCenterDetail(s,r,n),this.workCenterDetailByAgent[s]||r},invalidateWorkItemActionMessages(e,t,s,n){if(!e||!t||!s)return null;let r=Ht(n),i=Zn(e,t,s,r);this._workCenterActionMessageGenerationByKey={...this._workCenterActionMessageGenerationByKey,[i]:Number(this._workCenterActionMessageGenerationByKey[i]||0)+1};for(let a of["workCenterActionMessages","workCenterActionMessagesLoading","workCenterActionMessagesError"]){let l={...this[a]};delete l[i],this[a]=l}let o={...this._workCenterActionMessageRequests};for(let a of Object.keys(o))a.startsWith(`${i}:`)&&delete o[a];return this._workCenterActionMessageRequests=o,i},async loadWorkItemActionMessages(e,t,s,n,r=null){let i=r||this.workCenterAgentId||this.currentAgent,o=Ht(s),a=Zn(i,e,t,o),l=Number(this._workCenterActionMessageGenerationByKey[a]||0),c=`${a}:${n==null?"latest":String(n)}`;if(this._workCenterActionMessageRequests[c])return this._workCenterActionMessageRequests[c];this.workCenterActionMessagesLoading={...this.workCenterActionMessagesLoading,[a]:!0},this.workCenterActionMessagesError={...this.workCenterActionMessagesError,[a]:null};let d=(async()=>{try{let u=await this.workCenterRequest("get_action_messages",{id:e,actionId:t,generation:o,cursor:n,limit:20},i);if(this.workItemDeleted(i,e)||Ht(u?.generation)!==o||Number(this._workCenterActionMessageGenerationByKey[a]||0)!==l)return u;let g=this.workCenterActionMessages[a]?.messages||[],p=Zr(g,u?.messages||[]),f=this.workCenterActionMessages[a],m=f?.nextCursor,v=n==null?null:Number(n),b=m==null?null:Number(m),h=!f||v==null||b!=null&&v===b;return this.workCenterActionMessages={...this.workCenterActionMessages,[a]:{generation:o,messages:p,nextCursor:h?u?.nextCursor??null:m,total:Math.max(Number(u?.total)||0,Number(f?.total)||0,p.length)}},u}catch(u){throw Number(this._workCenterActionMessageGenerationByKey[a]||0)===l&&(this.workCenterActionMessagesError={...this.workCenterActionMessagesError,[a]:u?.message||String(u)}),u}finally{if(this._workCenterActionMessageRequests[c]===d){let u={...this._workCenterActionMessageRequests};delete u[c],this._workCenterActionMessageRequests=u;let g=Object.keys(u).some(p=>p.startsWith(`${a}:`));this.workCenterActionMessagesLoading={...this.workCenterActionMessagesLoading,[a]:g}}}})();return this._workCenterActionMessageRequests={...this._workCenterActionMessageRequests,[c]:d},d},async loadWorkItemActionRequests(e,t,s,n=null){let r=n||this.workCenterAgentId||this.currentAgent,i=Ht(s),o=yl(r,e,t,i),a=Number(this._workCenterActionRequestsGeneration[o]||0)+1;this._workCenterActionRequestsGeneration={...this._workCenterActionRequestsGeneration,[o]:a},this.workCenterActionRequestsLoading={...this.workCenterActionRequestsLoading,[o]:!0},this.workCenterActionRequestsError={...this.workCenterActionRequestsError,[o]:null};try{let l=await this.workCenterRequest("get_action_requests",{id:e,actionId:t,generation:i},r),c=!this.workItemDeleted(r,e)&&Ht(l?.generation)===i&&this._workCenterActionRequestsGeneration[o]===a;return c&&(this.workCenterActionRequests={...this.workCenterActionRequests,[o]:l?.requests||[]}),c?l?.requests||[]:this.workCenterActionRequests[o]||[]}catch(l){throw this._workCenterActionRequestsGeneration[o]===a&&(this.workCenterActionRequestsError={...this.workCenterActionRequestsError,[o]:l?.message||String(l)}),l}finally{this._workCenterActionRequestsGeneration[o]===a&&(this.workCenterActionRequestsLoading={...this.workCenterActionRequestsLoading,[o]:!1})}},async loadWorkItemActionRequest(e,t,s,n,r,i=null){let o=i||this.workCenterAgentId||this.currentAgent,a=Ht(s),c=`${yl(o,e,t,a)}:${n}:${r}`,d=Number(this._workCenterActionRequestDetailsGeneration[c]||0)+1;this._workCenterActionRequestDetailsGeneration={...this._workCenterActionRequestDetailsGeneration,[c]:d},this.workCenterActionRequestDetailsLoading={...this.workCenterActionRequestDetailsLoading,[c]:!0},this.workCenterActionRequestDetailsError={...this.workCenterActionRequestDetailsError,[c]:null};try{let u=await this.workCenterRequest("get_action_request",{id:e,actionId:t,generation:a,runId:n,requestId:r},o),g=!this.workItemDeleted(o,e)&&Ht(u?.generation)===a&&this._workCenterActionRequestDetailsGeneration[c]===d;return g&&(this.workCenterActionRequestDetails={...this.workCenterActionRequestDetails,[c]:u?.request||null}),g?u?.request||null:this.workCenterActionRequestDetails[c]||null}catch(u){throw this._workCenterActionRequestDetailsGeneration[c]===d&&(this.workCenterActionRequestDetailsError={...this.workCenterActionRequestDetailsError,[c]:u?.message||String(u)}),u}finally{this._workCenterActionRequestDetailsGeneration[c]===d&&(this.workCenterActionRequestDetailsLoading={...this.workCenterActionRequestDetailsLoading,[c]:!1})}},async loadWorkCenterSettings(e=null){let t=e||this.workCenterAgentId||this.currentAgent;if(!t)throw new Error("No Agent selected");let s=Number(this._workCenterSettingsGenerationByAgent[t]||0)+1;this._workCenterSettingsGenerationByAgent={...this._workCenterSettingsGenerationByAgent,[t]:s},this.workCenterSettingsLoadingByAgent={...this.workCenterSettingsLoadingByAgent,[t]:!0},this.workCenterSettingsErrorByAgent={...this.workCenterSettingsErrorByAgent,[t]:null};try{let n=await this.workCenterRequest("get_settings",{},t);return this._workCenterSettingsGenerationByAgent[t]===s&&(this.workCenterSettingsByAgent={...this.workCenterSettingsByAgent,[t]:n?.settings||null},this.workCenterRuntimeByAgent={...this.workCenterRuntimeByAgent,[t]:n?.runtime||null}),n}catch(n){throw this._workCenterSettingsGenerationByAgent[t]===s&&(this.workCenterSettingsErrorByAgent={...this.workCenterSettingsErrorByAgent,[t]:n?.message||String(n)}),n}finally{this._workCenterSettingsGenerationByAgent[t]===s&&(this.workCenterSettingsLoadingByAgent={...this.workCenterSettingsLoadingByAgent,[t]:!1})}},async refreshWorkCenterRuntime(e=null){let t=e||this.workCenterAgentId||this.currentAgent;if(!t)throw new Error("No Agent selected");let s=Number(this._workCenterSettingsGenerationByAgent[t]||0)+1;this._workCenterSettingsGenerationByAgent={...this._workCenterSettingsGenerationByAgent,[t]:s},this.workCenterSettingsLoadingByAgent={...this.workCenterSettingsLoadingByAgent,[t]:!0},this.workCenterSettingsErrorByAgent={...this.workCenterSettingsErrorByAgent,[t]:null};try{let n=await this.workCenterRequest("refresh_runtime",{},t);return this._workCenterSettingsGenerationByAgent[t]===s&&(this.workCenterSettingsByAgent={...this.workCenterSettingsByAgent,[t]:n?.settings||null},this.workCenterRuntimeByAgent={...this.workCenterRuntimeByAgent,[t]:n?.runtime||null}),n}catch(n){throw this._workCenterSettingsGenerationByAgent[t]===s&&(this.workCenterSettingsErrorByAgent={...this.workCenterSettingsErrorByAgent,[t]:n?.message||String(n)}),n}finally{this._workCenterSettingsGenerationByAgent[t]===s&&(this.workCenterSettingsLoadingByAgent={...this.workCenterSettingsLoadingByAgent,[t]:!1})}},async saveWorkCenterSettings(e,t=null){let s=t||this.workCenterAgentId||this.currentAgent;if(!s)throw new Error("No Agent selected");let n=Number(this._workCenterSettingsGenerationByAgent[s]||0)+1;this._workCenterSettingsGenerationByAgent={...this._workCenterSettingsGenerationByAgent,[s]:n};let r=await this.workCenterRequest("update_settings",{settings:e},s);return this._workCenterSettingsGenerationByAgent[s]===n&&(this.workCenterSettingsByAgent={...this.workCenterSettingsByAgent,[s]:r?.settings||null},this.workCenterRuntimeByAgent={...this.workCenterRuntimeByAgent,[s]:r?.runtime||null},this.workCenterSettingsErrorByAgent={...this.workCenterSettingsErrorByAgent,[s]:null}),r},previewWorkCenterPlan(e={},t=null){let s=t||this.workCenterAgentId||this.currentAgent;return this.workCenterRequest("preview",e,s)},async createWorkItem(e,t=null){let s=t||this.workCenterAgentId||this.currentAgent,n=this.beginWorkCenterDetailWrite(s),r=await this.workCenterRequest("create",e,s);return await this.listWorkItems(s,this._workCenterListFiltersByAgent[s]||{}),this.commitWorkCenterDetail(s,r,n),r},async updateWorkItem(e,t,s=null){let n=s||this.workCenterAgentId||this.currentAgent,r=this.beginWorkCenterDetailWrite(n),i=await this.workCenterRequest("update",{id:e,patch:t},n);return await this.listWorkItems(n,this._workCenterListFiltersByAgent[n]||{}),this.commitWorkCenterDetail(n,i,r),i},async startWorkItem(e,t=null){let s=t||this.workCenterAgentId||this.currentAgent,n=this.beginWorkCenterDetailWrite(s),r=await this.workCenterRequest("start",{id:e},s);return await this.listWorkItems(s,this._workCenterListFiltersByAgent[s]||{}),this.commitWorkCenterDetail(s,r,n),r},async cancelWorkItem(e,t=null){let s=t||this.workCenterAgentId||this.currentAgent,n=this.beginWorkCenterDetailWrite(s),r=await this.workCenterRequest("cancel",{id:e},s);return await this.listWorkItems(s,this._workCenterListFiltersByAgent[s]||{}),this.commitWorkCenterDetail(s,r,n),r},async resumeWorkItem(e,t,s=null,n=void 0){let r=s||this.workCenterAgentId||this.currentAgent,i=this.beginWorkCenterDetailWrite(r),o={id:e,revision:t};n!=null&&(o.executionControlRevision=n);let a=await this.workCenterRequest("resume",o,r);return await this.listWorkItems(r,this._workCenterListFiltersByAgent[r]||{}),this.commitWorkCenterDetail(r,a,i),a},async extendWorkItemBudget(e,t,s,n=null){let r=n||this.workCenterAgentId||this.currentAgent,i=this.beginWorkCenterDetailWrite(r),o=await this.workCenterRequest("extend_budget",{id:e,executionControlRevision:t,additions:s},r);return await this.listWorkItems(r,this._workCenterListFiltersByAgent[r]||{}),this.commitWorkCenterDetail(r,o,i),o},async deleteWorkItem(e,t,s=null){let n=s||this.workCenterAgentId||this.currentAgent,r=await this.workCenterRequest("delete",{id:e,revision:t},n);return this.removeWorkItemState(n,e),r},async postWorkItemMessage(e,t,s,n,r=[],i=null,o={},a=null){if(!this.hydrateWorkCenterBrowserState())throw new Error("Work Center browser owner is unavailable; sign in again and retry");let l=i||this.workCenterAgentId||this.currentAgent,c=this.prepareWorkCenterMessageEnvelope({agentId:l,workItemId:e,target:s,text:t,quote:a,attachments:r,revision:n,planRevision:o.planRevision,ledgerRevision:o.ledgerRevision,coordinatorRevision:o.coordinatorRevision});if(!c)throw new Error("Work Center browser owner changed; reopen Work Center and try again");let d=c.clientMessageId,u=this.workCenterDetailByAgent[l]?.id===e?this.workCenterDetailByAgent[l]:null,g=await this.workCenterRequest("post_work_item_message",{id:c.workItemId,clientMessageId:d,text:c.text,target:c.target,revision:c.revision,planRevision:c.planRevision||Number(u?.planRevision)||0,ledgerRevision:c.ledgerRevision||Number(u?.ledgerRevision)||0,coordinatorRevision:Number.isInteger(Number(c.coordinatorRevision))?Number(c.coordinatorRevision):Number(u?.coordinatorRevision)||0,...c.quote?{quote:c.quote}:{},attachments:c.attachments},l);if(c.target.kind==="coordinator"){if(!g?.accepted)throw new Error("Work Center Coordinator did not accept the message");return this.confirmWorkCenterMessageEnvelope(l,e,d),g}return await this.listWorkItems(l,this._workCenterListFiltersByAgent[l]||{}),this.confirmWorkCenterMessageEnvelope(l,e,d),g},async sendWorkItemMessage(e,t,s,n=[],r=null,i={},o=null){let a=r||this.workCenterAgentId||this.currentAgent,l=this.workCenterDetailByAgent[a]?.id===e?this.workCenterDetailByAgent[a]:null,c=await this.workCenterRequest("work_item_message",{id:e,text:t,revision:s,planRevision:Number.isInteger(Number(i.planRevision))?Number(i.planRevision):Number(l?.planRevision)||0,ledgerRevision:Number.isInteger(Number(i.ledgerRevision))?Number(i.ledgerRevision):Number(l?.ledgerRevision)||0,coordinatorRevision:Number.isInteger(Number(i.coordinatorRevision))?Number(i.coordinatorRevision):Number(l?.coordinatorRevision)||0,...Tt(o)?{quote:Tt(o)}:{},attachments:Array.isArray(n)?n:[]},a);if(!c?.accepted)throw new Error("Work Center Coordinator did not accept the message");return c},async retryWorkItemAction(e,t,s,n,r=null){let i=r||this.workCenterAgentId||this.currentAgent,o=this.beginWorkCenterDetailWrite(i),a=await this.workCenterRequest("retry_action",{id:e,actionId:t,revision:s,generation:n},i);return await this.listWorkItems(i,this._workCenterListFiltersByAgent[i]||{}),this.commitWorkCenterDetail(i,a,o),a},async sendWorkItemActionInput(e,t,s,n,r,i=[],o=null,a=null){let l=o||this.workCenterAgentId||this.currentAgent,c=Number(this._workCenterActionInputGenerationByAgent[l]||0)+1;this._workCenterActionInputGenerationByAgent={...this._workCenterActionInputGenerationByAgent,[l]:c};let d=Tt(a),u=await this.workCenterRequest("action_input",{id:e,text:t,actionId:s,revision:n,generation:r,attachments:i,...d?{quote:d}:{}},l);await this.listWorkItems(l,this._workCenterListFiltersByAgent[l]||{});let g=this.workCenterDetailByAgent[l],p=g?.actions?.find(v=>v?.id===s),f=g?.id===e&&Number(g.revision)===Number(n)&&p&&Number(p.generation)===Number(r),m=Cl(g,u);return this._workCenterActionInputGenerationByAgent[l]===c&&f&&!Np(m,g)?(this.workCenterDetailByAgent={...this.workCenterDetailByAgent,[l]:m},m):g?.id===e?g:u},async guideWorkItemAction(e,t,s,n,r,i=[],o=null){let a=o||this.workCenterAgentId||this.currentAgent,l=this.beginWorkCenterDetailWrite(a),c=await this.workCenterRequest("guide",{id:e,guidance:t,actionId:s,revision:n,generation:r,attachments:i},a);return await this.listWorkItems(a,this._workCenterListFiltersByAgent[a]||{}),this.commitWorkCenterDetail(a,c,l),c},previewWorkItemAttachment(e,t,s=null){let n=s||this.workCenterAgentId||this.currentAgent;return this.workCenterRequest("preview_attachment",{id:e,attachmentId:t},n)},applyWorkCenterEvent(e,t){if(!e||!t?.workItem)return;let s=t.workItem;if(t.clientMessageId){this.confirmWorkCenterMessageEnvelope(e,s.id,t.clientMessageId);let u=Object.entries(this.workCenterPending||{}).find(([,g])=>g?.agentId===e&&g.clientMessageId===t.clientMessageId);if(u){let[g,p]=u;clearTimeout(p.timer),delete this.workCenterPending[g],p.resolve(t.type==="coordinator.turn_started"?{accepted:!0,turnId:null,receipt:!0}:t.workItem)}}let n=this.workCenterItemsByAgent[e]||[];if(t.type==="work_item.deleted"){this.removeWorkItemState(e,s.id);return}if(this.workItemDeleted(e,s.id))return;let r=this._workCenterListFiltersByAgent[e]||{},i=this._workCenterListEventsByAgent[e]?.[s.id]?.summary||null,o=n.some(u=>u?.id===s.id)?n:i?[i]:[],a=An(o,s).find(u=>u?.id===s.id)||s,l=Number(this._workCenterListEventGenerationByAgent[e]||0)+1;this._workCenterListEventGenerationByAgent={...this._workCenterListEventGenerationByAgent,[e]:l},this._workCenterListEventsByAgent={...this._workCenterListEventsByAgent,[e]:{...this._workCenterListEventsByAgent[e]||{},[s.id]:{generation:l,queryKey:this._workCenterListQueryByAgent[e]||null,summary:a}}};let c=this.applyWorkItemBoardSummary(n,a,r);this.workCenterItemsByAgent={...this.workCenterItemsByAgent,[e]:c};let d=this.workCenterDetailByAgent[e];if(d?.id===s.id){let u=t.type==="run.finished"&&t.actionId&&Array.isArray(s.actionStats)&&s.actionStats.some(b=>b?.id===t.actionId)?{...s,eventActionId:t.actionId}:s,g=wl(d,u),p=Number(s.coordinatorRevision),f=Number(d.coordinatorRevision)||0,m=Number.isInteger(p)&&p>f,v=Wp(d,u);this.workCenterDetailByAgent={...this.workCenterDetailByAgent,[e]:jp(d,s)},v&&this.refreshWorkItemDetailAfterActionChange(e,s,m?null:g)}},async refreshWorkItemDetailAfterActionChange(e,t,s=null){let n=s?(Array.isArray(t.actionStats)?t.actionStats:[]).find(m=>m?.id===s.actionId):(Array.isArray(t.actionStats)?t.actionStats:[]).find(m=>m?.id===t.currentActionId)||t.currentAction,r=s?.actionId||t.currentActionId||null,i=Number(s?.generation??n?.generation),o=Number.isInteger(i)&&i>0?i:null,a=Number(t.coordinatorRevision),l=!s&&Number.isInteger(a)&&a>=0?a:null,c=Number(s?.attempt),d=Number.isInteger(c)&&c>=0?c:null,u=l!=null?`${t.id}:coordinator:${l}`:`${t.id}:${r}${o==null?"":`:${o}`}${d==null?"":`:${d}`}`;if(this._workCenterDetailEventRefreshByAgent[e]?.key===u)return;let g=this.beginWorkCenterDetailWrite(e),p={key:u,generation:g};this._workCenterDetailEventRefreshByAgent={...this._workCenterDetailEventRefreshByAgent,[e]:p},s&&this.invalidateWorkItemActionMessages(e,t.id,s.actionId,s.generation);let f=r&&o!=null?this.loadWorkItemActionMessages(t.id,r,o,null,e).catch(()=>null):null;try{let m=await this.workCenterRequest("get",{id:t.id},e),v=this.workCenterDetailByAgent[e],b=v?.actions?.find(P=>P?.id===r),h=m?.actions?.find(P=>P?.id===r),k=o==null||Ht(b?.generation)===o,S=o==null||Ht(h?.generation)>=o,y=l==null||Number(m?.coordinatorRevision)===l,w=l!=null||k&&S&&(t.currentActionId==null?m?.currentActionId==null:v?.currentActionId===t.currentActionId&&m?.currentActionId===t.currentActionId);v?.id===t.id&&y&&w&&this.commitWorkCenterDetail(e,m,g)&&f&&await f}catch{}finally{if(this._workCenterDetailEventRefreshByAgent[e]===p){let m={...this._workCenterDetailEventRefreshByAgent};delete m[e],this._workCenterDetailEventRefreshByAgent=m}}},cacheYeaftAgentStatus(e,t,{allowBootstrapCatalog:s=!1}={}){if(!e||!t)return;let n=this.yeaftStatusByAgent[e]||{},r=Number(n.catalogRevision)||0,i=Number(t.catalogRevision)||0,o=typeof n.catalogEpoch=="string"?n.catalogEpoch:"",a=typeof t.catalogEpoch=="string"?t.catalogEpoch:"",l=Number(n.catalogRefreshedAt)||0,c=Number(t.catalogRefreshedAt)||0,d=Array.isArray(t.availableModels),u=t.type==="yeaft_status"&&d&&(i>0||c>0),g=Array.isArray(this._yeaftRetiredCatalogEpochsByAgent?.[e])?this._yeaftRetiredCatalogEpochsByAgent[e]:[],p=!!a&&g.includes(a),f=!!a&&a===o,m=i>0?f&&i===r:c>0&&c===l,v=i>0?!!a&&(a!==o||i>r):r===0&&c>l,b=i>0?!!t.catalogDigest&&!!n.catalogDigest&&t.catalogDigest===n.catalogDigest:t.catalogDigest===n.catalogDigest,h=u&&!p&&(v||m&&b),S=h||s&&r===0&&l===0&&!u&&d,y={...t};if(!S)for(let P of zb)delete y[P];let w={...n,...y};if(S){if(h&&o&&a&&o!==a){let P=[...g.filter(x=>x!==o),o].slice(-Yb);this._yeaftRetiredCatalogEpochsByAgent={...this._yeaftRetiredCatalogEpochsByAgent||{},[e]:P}}w.availableModels=t.availableModels,w.catalogRefreshedAt=h?c:null,w.catalogEpoch=h&&a||null,w.catalogRevision=h&&i||null,w.catalogDigest=h&&t.catalogDigest||null}this.yeaftStatusByAgent={...this.yeaftStatusByAgent,[e]:w},this.currentAgent===e&&this.applyCachedYeaftStatus(e)},applyCachedYeaftStatus(e=this.currentAgent){let t=e?this.yeaftStatusByAgent[e]:null;return t?(this.yeaftModel=t.model||null,this.yeaftModelEffort=t.modelEffort||null,this.yeaftAvailableModels=Array.isArray(t.availableModels)?t.availableModels:[],this.yeaftModelsRefreshing=!!t.refreshing,this.yeaftModelRefreshError=t.refreshError||null,this.yeaftYeaftDir=t.yeaftDir||null,this.yeaftStatus={skills:t.skills,mcpServers:t.mcpServers,tools:t.tools,multiVp:!!t.multiVp},!0):!1},activateYeaftAgentCatalog(e,t=this.currentAgent){let s=e?this.yeaftStatusByAgent[e]:null;return s&&this.applyCachedYeaftStatus(e),Array.isArray(s?.availableModels)?!0:(this.yeaftModel=null,this.yeaftModelEffort=null,this.yeaftAvailableModels=[],s||(this.yeaftStatus=null),this.yeaftModelsRefreshing=!!e&&!s?.refreshError,this.yeaftModelRefreshError=s?.refreshError||null,t!==e&&(this.yeaftYeaftDir=null),!1)},activateYeaftAgent(e,t=null){if(!e)return!1;let s=this.currentAgent;return this.currentAgent=e,t&&(this.currentAgentInfo=t),this.activateYeaftAgentCatalog(e,s)},resolveYeaftSessionAgentId(e){return $e(this,e)},requestYeaftSessionInventory(){if(this.yeaftSessionInventoryCompleteSupported===!1&&this.yeaftSessionHydrateRequestId)return this.yeaftSessionHydrateRequestId;if(this._yeaftSessionInventorySocketQuarantined)return this.manualReconnect(),null;clearTimeout(this._legacyYeaftSessionHydrateTimer),this._legacyYeaftSessionHydrateTimer=null;let e=`session_inventory_${crypto.randomUUID()}`;this.yeaftSessionHydrateRequestId=e,this.yeaftSessionHydrateSlices=[],this._hasHandledAgentList=!1,this._hasHandledYeaftSessionHydrate=!1,this.yeaftSessionHydrateError=null;let t=this.conversations.map(n=>n.id).filter(Boolean);return this.sendWsMessage({type:"get_agents",requestId:e,conversationIds:t.length>0?t:void 0})?(setTimeout(()=>{this.yeaftSessionHydrateRequestId===e&&(this.yeaftSessionHydrateRequestId=null,this.yeaftSessionHydrateSlices=[],this.yeaftSessionHydrateError="session_inventory_timeout",this.yeaftSessionInventoryCompleteSupported!==!0&&(this._yeaftSessionInventorySocketQuarantined=!0))},Wb),e):(this.yeaftSessionHydrateRequestId=null,this.yeaftSessionHydrateSlices=[],this.yeaftSessionHydrateError="session_inventory_send_failed",null)},beginYeaftHistoryLoad(e){let t=ru(this,e);if(!t)return null;let{agentId:s,sessionId:n}=e||{};return setTimeout(()=>{Or(this,{agentId:s,sessionId:n,requestId:t.requestId,error:"history_load_timeout"})},nu),t},finishYeaftHistoryLoad(e,t={},s="chunk"){return iu(this,e,t,s)},isCurrentYeaftHistoryResponse(e){return Ba(this,e)},syncActiveYeaftHistoryLoad(){return mn(this)},enterYeaft(e=null,{deferBootstrap:t=!1}={}){let s=this.currentAgent;ml(this);let n=Ms(this),r=!e&&n?$e(this,n):null,i=e||r||this.currentAgent||null;if(!i){let a=this.agents.find(l=>l.online);a&&(i=a.id)}if(i&&this.currentAgent!==i){this.selectAgent(i),this.currentAgent=i;let a=this.agents.find(l=>l.id===i);a&&(this.currentAgentInfo=a)}if(!this.applyCachedYeaftStatus(i)&&s&&s!==i&&(this.yeaftAvailableModels=[],this.yeaftStatus=null,this.yeaftModelsRefreshing=!0,this.yeaftModelRefreshError=null),i){let a=this.yeaftConversationIdsByAgent?.[i]||null;a||(a=`yeaft-local-${i}-${Date.now()}`,this.yeaftConversationIdsByAgent={...this.yeaftConversationIdsByAgent||{},[i]:a}),this.yeaftConversationId=a}else this.yeaftConversationId||(this.yeaftConversationId=`yeaft-local-${Date.now()}`);this.messagesMap[this.yeaftConversationId]||(this.messagesMap[this.yeaftConversationId]=[]),_p(this),this.currentView="yeaft",hl("yeaft"),this.hasMoreMessages=!1,this.loadingMoreMessages=!1,this.yeaftHasMoreHistory=!1,this.yeaftLoadingMoreHistory=!1,this.yeaftOldestLoadedSeq=null,this._yeaftReconnectCatchUpPending=!1,this.loadOpenedYeaftSessionsForConnectedAgents(null,{force:!0}),t||this.requestYeaftSessionBootstrap({forceSessionReady:!0,catchUpHistory:!0,forceHistoryReplay:!0})},loadOpenedYeaftSessionsForConnectedAgents(e=null,{force:t=!1}={}){let s=Array.isArray(e)?e.filter(Boolean):Array.isArray(this.agents)?this.agents.filter(i=>i&&i.online&&i.id).map(i=>i.id):[],n=[...new Set(s)];(!this._yeaftOpenedSessionsLoadedAgents||typeof this._yeaftOpenedSessionsLoadedAgents!="object")&&(this._yeaftOpenedSessionsLoadedAgents={});let r=[];for(let i of n)!t&&this._yeaftOpenedSessionsLoadedAgents[i]||(this._yeaftOpenedSessionsLoadedAgents[i]=Date.now(),r.push(i),this.sessionCrudRequest("list",{},{agentId:i}).catch(o=>{delete this._yeaftOpenedSessionsLoadedAgents[i]}));return r},requestYeaftSessionBootstrap({forceSessionReady:e=!1,catchUpHistory:t=!1,forceHistoryReplay:s=!1}={}){if(!this.currentAgent)return;let n=Ms(this),r=n?$e(this,n):this.currentAgent,i=Le(r,n),o=n?this.yeaftSessionHistoryState[i]:null,a=e||!this.yeaftSessionReady||!this.yeaftModel||!this.yeaftStatus,l=Number.isFinite(o?.latestSeq)?o.latestSeq:null,c=!!n&&!!this.yeaftConversationId&&Array.isArray(this.messagesMap?.[this.yeaftConversationId])&&this.messagesMap[this.yeaftConversationId].some(h=>h&&(h.sessionId??h.groupId??null)===n),d=!!n&&vu({sessionState:o,hasCachedSessionRows:c,force:!!s}),u=!!n&&!d&&mu(o,t);if(!a&&!d&&!u)return!1;let g=`${r}:${n||"__none__"}`,p=a&&!d&&!u;if(p&&this.yeaftBootstrapMetaLoadingKey===g)return!1;p&&(this.yeaftBootstrapMetaLoadingKey=g);let f=null;n&&d?f=this.beginYeaftHistoryLoad({agentId:r,sessionId:n,mode:"recent",preserveLoaded:!1}):n&&c&&!o?.loaded?(this.yeaftSessionHistoryState={...this.yeaftSessionHistoryState,[i]:{...o||{},loaded:!0,loading:!1,hasMore:!!o?.hasMore,oldestSeq:Number.isFinite(o?.oldestSeq)?o.oldestSeq:null,count:o?.count||0,latestSeq:l}},this.yeaftLoadingMoreHistory=!1):n&&u&&(f=this.beginYeaftHistoryLoad({agentId:r,sessionId:n,mode:"delta",preserveLoaded:!0,latestSeq:l}));let m={type:"yeaft_load_history",agentId:r,sessionId:n,...f?{requestId:f.requestId}:{}};u?m.afterSeq=l:m.limit=d?El:0;let v=bn();m.perfTraceId=v;let b=u?"delta":d?"recent":"metadata";return n&&(this.yeaftHistoryPerfTraceBySession={...this.yeaftHistoryPerfTraceBySession||{},[i]:v}),kt(this,{traceId:v,phase:"history.request_send",agentId:r,sessionId:n,messageType:m.type,bytes:JSON.stringify(m).length,detail:{mode:b,limit:m.limit??null,afterSeq:m.afterSeq??null,hasCachedSessionRows:c,needSessionReady:a}}),this.sendWsMessage(m),!0},leaveYeaft(){this.activateChatView({persistPreference:!0})},fetchYeaftToolStats(){this.currentAgent&&(this.yeaftToolStatsLoading=!0,this.sendWsMessage({type:"yeaft_fetch_tool_stats",agentId:this.currentAgent}),this._fetchYeaftToolStatsTimer&&clearTimeout(this._fetchYeaftToolStatsTimer),this._fetchYeaftToolStatsTimer=setTimeout(()=>{this.yeaftToolStatsLoading&&(this.yeaftToolStatsLoading=!1,this.yeaftToolStats={...this.yeaftToolStats||{snapshot:{},registered:[],unused:[]},error:null,notice:"Tool stats are unavailable right now. Try again after the agent reconnects.",fetchedAt:Date.now()}),this._fetchYeaftToolStatsTimer=null},1e4))},loadYeaftDebugHistory({groupId:e,limit:t,dreamLimit:s,indexOnly:n=!1,detailTurnId:r=null,search:i=void 0}={}){let o=$e(this,e);if(!o)return;let a=typeof i=="string"?i.trim():(this.yeaftDebugSearch||"").trim(),l=typeof r=="string"&&r,c=a&&!l?ug:Ol,d=Number.isFinite(t)&&t>0?t:this.yeaftDebugHistoryLimit||c,u=Math.max(1,Math.min(c,d)),g=l?"detail":"list",p=`dbg_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,10)}`,f=JSON.stringify({agentId:o,groupId:e||null,limit:u,dreamLimit:Number.isFinite(s)&&s>0?s:5,indexOnly:!!n,detailTurnId:r||null,search:l?"":a});if(this._yeaftDebugHistoryInFlightKey===f)return;this._yeaftDebugHistoryInFlightKey=f,l?this._yeaftDebugHistoryLatestDetailRequestId=p:this._yeaftDebugHistoryLatestListRequestId=p,this.yeaftDebugHistoryLimit=u,this.yeaftDebugHistoryLoading=!0,this.yeaftDebugHistoryError=null,this.yeaftDebugHistoryProjection=null;let m={type:"yeaft_fetch_debug_history",agentId:o,requestId:p,requestKind:g,limit:u,dreamLimit:Number.isFinite(s)&&s>0?s:5};n&&(m.indexOnly=!0),typeof r=="string"&&r?m.detailTurnId=r:a&&(m.search=a),typeof e=="string"&&e&&(m.sessionId=e),this._yeaftDebugHistoryPending={payload:m,attempt:0,startedAt:Date.now()},Qn(this),this.refreshYeaftDebugHistoryTimeout(p),this.sendWsMessage(m)},scheduleYeaftDebugDetailRefresh(e,t){let s=this.yeaftDebugPanel;!s?.open||s.turnId!==t||s.agentId!==e.agentId||s.sessionId&&s.sessionId!==e.sessionId||(this._yeaftDebugDetailDirty=!0,!this._yeaftDebugDetailRefreshTimer&&(this._yeaftDebugDetailRefreshTimer=setTimeout(()=>{this._yeaftDebugDetailRefreshTimer=null,!(!this.yeaftDebugPanel?.open||this.yeaftDebugPanel.requestId!==s.requestId)&&(this.yeaftDebugHistoryLoading||(this._yeaftDebugDetailDirty=!1,this.loadYeaftDebugHistory({groupId:s.sessionId,detailTurnId:s.turnId})))},500)))},refreshYeaftDebugHistoryTimeout(e){let t=this._yeaftDebugHistoryPending;!t||t.payload.requestId!==e||(this._fetchYeaftDebugHistoryTimer&&clearTimeout(this._fetchYeaftDebugHistoryTimer),this._fetchYeaftDebugHistoryTimer=setTimeout(()=>{if(this._yeaftDebugHistoryPending===t){if(this.yeaftDebugHistoryLoading&&t.attempt<1){t.attempt+=1,t.startedAt=Date.now(),t.payload={...t.payload,requestId:`dbg_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,10)}`},t.payload.requestKind==="detail"?this._yeaftDebugHistoryLatestDetailRequestId=t.payload.requestId:this._yeaftDebugHistoryLatestListRequestId=t.payload.requestId,Qn(this),this.refreshYeaftDebugHistoryTimeout(t.payload.requestId),this.sendWsMessage(t.payload);return}this.yeaftDebugHistoryLoading&&(this.yeaftDebugHistoryLoading=!1,this.yeaftDebugHistoryError="debug_history_timeout",this.yeaftDebugPanel?.status==="loading"&&(this.yeaftDebugPanel={...this.yeaftDebugPanel,status:"error",error:this.yeaftDebugHistoryError})),this._yeaftDebugHistoryInFlightKey=null,this._fetchYeaftDebugHistoryTimer=null,this._yeaftDebugHistoryPending=null,this._yeaftDebugHistoryLatestDetailRequestId=null,this._yeaftDebugHistoryLatestListRequestId=null,Qn(this)}},Math.max(0,Math.min(3e4,3e5-(Date.now()-t.startedAt)))))},openYeaftTurnDebug({sessionId:e=null,turnId:t=null}={}){let s=$e(this,e);if(!s)return;this.workbenchExpanded=!1,this.workbenchMaximized=!1,this.rememberWorkbenchPanelState();let n=`dbgpanel_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,10)}`,r=t?"loading":"idle";this.yeaftDebugPanel={open:!0,status:r,requestId:n,agentId:s,sessionId:e||null,turnId:t||null,error:null},t&&this.loadYeaftDebugHistory({groupId:e||void 0,limit:1,dreamLimit:5,detailTurnId:t})},closeYeaftDebugPanel(){this._yeaftDebugDetailRefreshTimer&&clearTimeout(this._yeaftDebugDetailRefreshTimer),this._yeaftDebugDetailRefreshTimer=null,this._yeaftDebugDetailDirty=!1,this._fetchYeaftDebugHistoryTimer&&clearTimeout(this._fetchYeaftDebugHistoryTimer),this._fetchYeaftDebugHistoryTimer=null,this._yeaftDebugHistoryPending=null,this._yeaftDebugHistoryInFlightKey=null,this._yeaftDebugHistoryLatestDetailRequestId=null,this._yeaftDebugHistoryLatestListRequestId=null,this.yeaftDebugHistoryLoading=!1,Qn(this);let t=(this.yeaftDebugPanel||{}).turnId||null;if(this.yeaftDebugPanel={open:!1,status:"idle",requestId:null,agentId:null,sessionId:null,turnId:null,error:null},t&&this.yeaftDebugTurnsById&&this.yeaftDebugTurnsById[t]){let s={...this.yeaftDebugTurnsById};delete s[t],this.yeaftDebugTurnsById=s,this.yeaftDebugTurnOrder=(this.yeaftDebugTurnOrder||[]).filter(n=>n!==t),this.yeaftDebugLoops=(this.yeaftDebugLoops||[]).filter(n=>!n||n.turnId!==t)}},agentIdForSession(e){return $e(this,e)},sendYeaftSessionMessage({groupId:e,text:t,mentions:s,attachments:n,quote:r,quickSend:i}){let o=$e(this,e);if(!e||!o||i&&(o!==this.currentAgent||this.connectionState!=="connected"||!this.agents?.some(v=>v.id===o&&v.online)))return!1;let a=Array.isArray(n)?n.filter(v=>v&&v.fileId):[],l=Tt(r),c=a.length>0;if(!t?.trim()&&!c)return;let d=t?.trim()?t:"(attached files)",u=Date.now(),g=`u_${u.toString(36)}_${Math.random().toString(36).slice(2,10)}`,p=bn();this.yeaftPerfTraceByMessageId={...this.yeaftPerfTraceByMessageId||{},[g]:p},kt(this,{traceId:p,phase:"send.prepare",agentId:o,sessionId:e,turnId:g,messageType:"yeaft_session_send",detail:{mentionCount:Array.isArray(s)?s.length:0,attachmentCount:a.length,quoted:!!l}});let f=It(this,e);if(f){let v={id:g,messageId:g,clientMessageId:g,stableKey:Hs(o,e,g),uiKey:Hs(o,e,g),type:"user",content:d,timestamp:u,sessionId:e,turnId:g,...l?{quote:l}:{}};if(a.length>0&&(v.attachments=a.map(b=>({fileId:b.fileId,name:b.name,preview:b.preview,isImage:!!b.isImage,mimeType:b.mimeType||""}))),rs(this).upsertOverlay({conversationId:f,agentId:o,sessionId:e,row:v}),this.processingConversations[f]=!0,e){let b=Is(o,e);this.yeaftProcessingSessions={...this.yeaftProcessingSessions,...b?{[b]:!0}:{}}}this._turnCompletedConvs?.delete(f),this._closedAt?.[f]&&delete this._closedAt[f],this.getOrCreateExecutionStatus(f),zn(this,f)}let m={type:"yeaft_session_send",agentId:o,id:g,sessionId:e,text:d,mentions:Array.isArray(s)?s:[],perfTraceId:p,...i?{quickSend:{model:i.model,effort:i.effort??null,maxOutputTokens:i.maxOutputTokens??null}}:{},...l?{quote:l}:{}};a.length>0&&(m.attachments=a.map(v=>({fileId:v.fileId,isImage:!!v.isImage}))),kt(this,{traceId:p,phase:"send.websocket_send",agentId:o,sessionId:e,turnId:g,messageType:m.type,bytes:JSON.stringify(m).length}),this.sendWsMessage(m)},cancelYeaftTask({agentId:e=null,sessionId:t,taskId:s}){let n=typeof t=="string"?t.trim():"",r=typeof s=="string"?s.trim():"",i=$e(this,n,e);return!i||!n||!r?!1:(this.yeaftStoppingTasksById={...this.yeaftStoppingTasksById,[$l(i,n,r)]:!0},this.sendWsMessage({type:"yeaft_task_cancel",agentId:i,sessionId:n,taskId:r,clientRequestId:`task_cancel_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}),!0)},continueYeaftHistoryDelta(e,t=null,s=null){let n=e||null,r=$e(this,n,t);if(!r||!n||!Number.isFinite(s))return!1;let i=Le(r,n),o=this.yeaftSessionHistoryState?.[i]||null;if(o?.loading)return!1;let a=this.beginYeaftHistoryLoad({agentId:r,sessionId:n,mode:"delta",preserveLoaded:!0,latestSeq:s});if(!a)return!1;this.yeaftSessionHistoryState={...this.yeaftSessionHistoryState,[i]:{...this.yeaftSessionHistoryState[i],syncingAfterSeq:s}};let l={type:"yeaft_load_history",agentId:r,sessionId:n,requestId:a.requestId,afterSeq:s,maxRows:Bb,maxBytes:Nb,...typeof o?.streamId=="string"?{streamId:o.streamId}:{},...Number.isFinite(o?.revision)?{revision:o.revision}:{}};return this.sendWsMessage(l)?!0:(Or(this,{agentId:r,sessionId:n,requestId:a.requestId,error:"history_load_send_failed"}),!1)},clearYeaftHistoryMemory({agentId:e=null,sessionId:t=null,preserveLiveRows:s=!1,preserveSessionOwner:n=!1}={}){let r=e||null,i=t||null,o=r&&i?Le(r,i):null,a={};for(let[m,v]of Object.entries(this._yeaftHistoryWindowPendingByKey||{})){if(!(!o||v?.agentId===r&&v?.sessionId===i)){a[m]=v;continue}clearTimeout(v?.timeout),v?.resolve?.(!1)}this._yeaftHistoryWindowPendingByKey=a;let l={};for(let[m,v]of Object.entries(this._yeaftHistoryPrefetchBySession||{})){if(o&&m!==o){l[m]=v;continue}v.cancelled=!0,v.idle&&typeof globalThis.cancelIdleCallback=="function"?globalThis.cancelIdleCallback(v.handle):clearTimeout(v.handle)}this._yeaftHistoryPrefetchBySession=l;let c={};for(let[m,v]of Object.entries(this._yeaftHistoryResultRefreshByRequestId||{})){if(!(!o||v?.agentId===r&&v?.sessionId===i)){c[m]=v;continue}clearTimeout(v?.timeout),v?.resolve?.(null)}this._yeaftHistoryResultRefreshByRequestId=c;let d=r&&this.yeaftConversationIdsByAgent?.[r]||null,u=o?new Set([d].filter(Boolean)):new Set(Object.values(this.yeaftConversationIdsByAgent||{}).filter(Boolean));!o&&this.yeaftConversationId&&u.add(this.yeaftConversationId);let g={...this.messagesMap||{}};for(let m of u)Array.isArray(g[m])&&(g[m]=o?g[m].filter(v=>(v?.sessionId??v?.groupId??null)!==i?!0:s&&!vt(v)):[]);this.messagesMap=g;let p=m=>{if(!o)return{};let{[o]:v,...b}=m||{};return b};if(this.yeaftSessionHistoryState=p(this.yeaftSessionHistoryState),this.yeaftHistoryCacheState=p(this.yeaftHistoryCacheState),this.yeaftMessageWindowState=p(this.yeaftMessageWindowState),this.yeaftHistoryFocusWindowBySession=p(this.yeaftHistoryFocusWindowBySession),this.yeaftHistoryOutlineBySession=p(this.yeaftHistoryOutlineBySession),o){let m=this._yeaftHistoryOutlineTimeouts?.[o];m&&clearTimeout(m),this._yeaftHistoryOutlineTimeouts=p(this._yeaftHistoryOutlineTimeouts)}else{for(let m of Object.values(this._yeaftHistoryOutlineTimeouts||{}))m&&clearTimeout(m);this._yeaftHistoryOutlineTimeouts={}}if((!o||this.yeaftHistorySearchState?.agentId===r&&this.yeaftHistorySearchState?.sessionId===i)&&(this._yeaftHistorySearchTimeout&&clearTimeout(this._yeaftHistorySearchTimeout),this._yeaftHistorySearchTimeout=null,this.yeaftHistorySearchState={requestId:null,agentId:null,sessionId:null,query:"",senderKey:"",loading:!1,results:[],hasMore:!1,nextBeforeSeq:null,nextCursor:null,error:null}),this._yeaftHistoryRevealLeases=o?Object.fromEntries(Object.entries(this._yeaftHistoryRevealLeases||{}).filter(([,m])=>m?.sessionKey!==o)):{},o||(this.yeaftHasMoreHistory=!1,this.yeaftLoadingMoreHistory=!1,this.yeaftOldestLoadedSeq=null),!n&&i&&this.yeaftSessionAgentById?.[i]===r){let{[i]:m,...v}=this.yeaftSessionAgentById;this.yeaftSessionAgentById=v}this.syncActiveYeaftHistoryLoad()},getYeaftMessageWindowKey(e=null,t=null){let s=e||this.yeaftActiveSessionFilter||null,n=$e(this,s,t);return Le(n,s)},showLatestYeaftMessageWindow(e=null,t=null){let s=this.getYeaftMessageWindowKey(e,t);if(!s||!this.yeaftHistoryFocusWindowBySession?.[s])return!1;let{[s]:n,...r}=this.yeaftHistoryFocusWindowBySession;return this.yeaftHistoryFocusWindowBySession=r,!0},pruneYeaftMessageWindow(e=null,t=null){if(this.currentView!=="yeaft")return;let s=this.getYeaftMessageWindowKey(e,t);Object.values(this._yeaftHistoryRevealLeases||{}).some(r=>r?.sessionKey===s)||(this.yeaftMessageWindowState={...this.yeaftMessageWindowState,[s]:{visibleTurns:Us()}})},expandYeaftMessageWindow(e=null,t=ti(),s=null){if(this.currentView!=="yeaft")return;let n=this.getYeaftMessageWindowKey(e,s),i=(this.yeaftMessageWindowState[n]?.visibleTurns||Us())+Math.max(1,Number.isFinite(t)?Math.floor(t):ti());this.yeaftMessageWindowState={...this.yeaftMessageWindowState,[n]:{visibleTurns:i}}},isYeaftMessageCached(e,t,s=null,n=null){let r=e||this.yeaftActiveSessionFilter||null,i=s||It(this,r,n);return!i||!t?!1:(this.messagesMap[i]||[]).some(o=>(!r||(o?.sessionId??o?.groupId??null)===r)&&((o?.id||o?.messageId)===t||o?.persistedMessageId===t))},revealYeaftMessage(e,t,s=null,n=null){let r=e||this.yeaftActiveSessionFilter||null,i=$e(this,r,n),o=s||It(this,r,i);if(!o||!t)return!1;let a=(this.messagesMap[o]||[]).filter(v=>v?._historyWindowPrefetched===!0?!1:r?(v?.sessionId??v?.groupId??null)===r:!0),c=a.findIndex(v=>(v?.id||v?.messageId)===t||v?.persistedMessageId===t);if(c<0){let v=(this.messagesMap[o]||[]).find(b=>b?._historyWindowPrefetched===!0&&(b?.sessionId??b?.groupId??null)===r&&((b?.id||b?.messageId)===t||b?.persistedMessageId===t));if(!v)return!1;v._historyWindowPrefetched=!1,a.push(v),a.sort((b,h)=>{let k=Number.isFinite(b?.seq)?b.seq:null,S=Number.isFinite(h?.seq)?h.seq:null;return k!==null&&S!==null&&k!==S?k-S:k!==null&&S===null?-1:k===null&&S!==null?1:(b?.timestamp||0)-(h?.timestamp||0)}),c=a.indexOf(v)}let u=a[c]?._historyWindowKey||null,g=this.getYeaftMessageWindowKey(r,i);if(u){let v=(this.messagesMap[o]||[]).filter(h=>(h?.sessionId??h?.groupId??null)===r&&h?._historyWindowKey===u);return Rl(v).length===0?!1:(this.yeaftHistoryFocusWindowBySession={...this.yeaftHistoryFocusWindowBySession||{},[g]:{windowKey:u,messageId:t,conversationId:o}},this.yeaftMessageWindowState={...this.yeaftMessageWindowState,[g]:{visibleTurns:Us()}},!0)}let p=Rl(a),f=p.findIndex(v=>c>=v.start&&c<v.end);if(f<0)return!1;let m=Math.max(Us(),p.length-f);return this.yeaftMessageWindowState={...this.yeaftMessageWindowState,[g]:{visibleTurns:m}},!0},getYeaftHistoryOutlineState(e=null,t=null){let s=e||this.yeaftActiveSessionFilter||null,n=$e(this,s,t),r=Le(n,s),i=this.yeaftHistoryOutlineBySession[r]||{requestId:null,agentId:n,sessionId:s,loading:!1,results:[],hasMore:!1,nextBeforeSeq:null,nextCursor:null,totalCount:null,loaded:!1,retryAttempt:0,error:null},o=It(this,s,n),a=o?this.messagesMap[o]||[]:[],l=new Map((i.results||[]).map(g=>[si(g),g])),c=0;for(let g of a){if((g?.sessionId??g?.groupId??null)!==s)continue;let p=g.messageId||g.id;if(!p)continue;let f=g.type==="user"&&!!g.clientMessageId&&p===g.clientMessageId,m=g.type==="assistant"&&g.isStreaming===!0;if(!f&&!m)continue;let v=g.type,b=g.turnId||g.threadId||p,h=g.speakerVpId||g.vpId||null,k=si({role:v,messageId:p,clientMessageId:g.clientMessageId,turnId:b,speakerVpId:h}),S=l.get(k),w=(typeof g.content=="string"?g.content:"").replace(/\s+/g," ").trim();l.set(k,{...S,agentId:n,sessionId:s,messageId:Number.isFinite(S?.seq)?S.messageId:p,...g.clientMessageId?{clientMessageId:g.clientMessageId}:{},turnId:b,role:v,speakerVpId:h||S?.speakerVpId||null,timestamp:g.timestamp||g.ts||S?.timestamp||null,snippet:w.length>180?`${w.slice(0,180).trimEnd()}\u2026`:w||S?.snippet||""}),S||(c+=1)}let d=g=>{let p=typeof g=="number"?g:Date.parse(g||"");return Number.isFinite(p)?p:0},u=Array.from(l.values()).sort((g,p)=>Number.isFinite(g.seq)&&Number.isFinite(p.seq)?g.seq-p.seq:d(g.timestamp)-d(p.timestamp));return{...i,results:u,totalCount:Number.isFinite(i.totalCount)?i.totalCount+c:i.totalCount}},promoteYeaftHistoryOutlineRow(e,t=null){let s=e?.sessionId??e?.groupId??null,n=Le(t,s),r=this.yeaftHistoryOutlineBySession[n];if(!s||!t||!r?.loaded||r.loading)return!1;let i=e?.type;if(i!=="user"&&i!=="assistant")return!1;let o=e.dbMessageId||e.messageId||e.id||null,a=sw(o);if(!o||!Number.isFinite(a))return!1;let l=e.turnId||e.threadId||o,c=e.speakerVpId||e.vpId||null,u=(typeof e.content=="string"?e.content:"").replace(/\s+/g," ").trim(),g=si({role:i,messageId:o,clientMessageId:e.clientMessageId,turnId:l,speakerVpId:c}),p=new Map((r.results||[]).map(k=>[si(k),k])),f=p.get(g);p.set(g,{...f,agentId:t,sessionId:s,messageId:o,...e.clientMessageId?{clientMessageId:e.clientMessageId}:{},turnId:l,seq:a,role:i,speakerVpId:c,timestamp:e.timestamp||e.ts||f?.timestamp||null,snippet:u.length>180?`${u.slice(0,180).trimEnd()}\u2026`:u||f?.snippet||""});let m=50,v=Array.from(p.values()).sort((k,S)=>(k.seq||0)-(S.seq||0)),b=v.length>m,h=v.slice(-m);return this.yeaftHistoryOutlineBySession={...this.yeaftHistoryOutlineBySession,[n]:{...r,results:h,hasMore:r.hasMore||b,nextBeforeSeq:b&&Number.isFinite(h[0]?.seq)?h[0].seq:r.nextBeforeSeq,totalCount:Number.isFinite(r.totalCount)&&!f?r.totalCount+1:r.totalCount}},!0},promoteCompletedYeaftHistoryOutline(e,t=null,s=null){let n=this.messagesMap[e]||[],r=null,i=[];for(let o=n.length-1;o>=0;o--){let a=n[o];if(a?.type==="user")break;if(t&&a?.turnId&&a.turnId!==t||a?.type!=="assistant")continue;let l=typeof a.content=="string"?a.content.replace(/\s+/g," ").trim():"";r?!String(r.content||"").trim()&&l&&(r=a):r=a,l&&i.unshift(l)}return r?this.promoteYeaftHistoryOutlineRow({...r,content:i.join(" ")},s):!1},invalidateYeaftHistoryOutline(e,t=null){let s=Le(t,e),n=this.yeaftHistoryOutlineBySession[s];if(!e||!t||!n)return!1;if(n.loading)return this.yeaftHistoryOutlineBySession={...this.yeaftHistoryOutlineBySession,[s]:{...n,refreshPending:!0}},!0;this.yeaftHistoryOutlineBySession={...this.yeaftHistoryOutlineBySession,[s]:{...n,loaded:!1,refreshPending:!1}};let r=$e(this,e);return this.currentView==="yeaft"&&this.yeaftActiveSessionFilter===e&&r===t?this.loadYeaftHistoryOutline({force:!0,targetSessionId:e,targetAgentId:t}):!0},loadYeaftHistoryOutline({append:e=!1,force:t=!1,targetSessionId:s=null,targetAgentId:n=null,retryAttempt:r=0}={}){if(this.currentView!=="yeaft"&&!s)return!1;let i=s||this.yeaftActiveSessionFilter||null,o=n||$e(this,i);if(!i||!o)return!1;let a=Le(o,i),l=this.getYeaftHistoryOutlineState(i,o);if(!e&&l.loaded&&!t)return!0;if(e&&(!l.hasMore||!Number.isFinite(l.nextBeforeSeq))||l.loading)return!1;if(!St(this,o,"session_history_outline"))return this.yeaftHistoryOutlineBySession={...this.yeaftHistoryOutlineBySession,[a]:{...l,error:"unsupported",loading:!1}},!1;let c=`history_outline_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,d={...l,requestId:c,agentId:o,sessionId:i,loading:!0,requestAppend:e,refreshPending:!1,retryAttempt:r,error:null};this.yeaftHistoryOutlineBySession={...this.yeaftHistoryOutlineBySession,[a]:d};let u=this._yeaftHistoryOutlineTimeouts[a];u&&clearTimeout(u);let g=setTimeout(()=>{let m=this.yeaftHistoryOutlineBySession[a];if(m?.requestId!==c)return;let v={...this._yeaftHistoryOutlineTimeouts};delete v[a],this._yeaftHistoryOutlineTimeouts=v;let b=m.refreshPending===!0;this.yeaftHistoryOutlineBySession={...this.yeaftHistoryOutlineBySession,[a]:{...m,requestId:null,loading:!1,requestAppend:!1,loaded:b?!1:m.loaded,refreshPending:!1,error:b?null:"timeout"}},b&&this.loadYeaftHistoryOutline({force:!0,targetSessionId:i,targetAgentId:o})},1e4);this._yeaftHistoryOutlineTimeouts={...this._yeaftHistoryOutlineTimeouts,[a]:g};let p=bn(),f={type:"yeaft_load_history_outline",agentId:o,sessionId:i,requestId:c,perfTraceId:p,limit:50,...e&&l.nextCursor?{cursor:l.nextCursor}:{},...e&&!l.nextCursor&&Number.isFinite(l.nextBeforeSeq)?{beforeSeq:l.nextBeforeSeq}:{}};return kt(this,{traceId:p,phase:"history_outline.request_send",agentId:o,sessionId:i,messageType:f.type,bytes:JSON.stringify(f).length,detail:{append:e,limit:f.limit}}),this.sendWsMessage(f),!0},handleYeaftHistoryOutline(e){if(!e?.agentId||!e?.sessionId)return!1;let t=Le(e.agentId,e.sessionId),s=this.yeaftHistoryOutlineBySession[t];if(!s||e.requestId!==s.requestId)return!1;let n=this._yeaftHistoryOutlineTimeouts[t];n&&clearTimeout(n);let r={...this._yeaftHistoryOutlineTimeouts};delete r[t],this._yeaftHistoryOutlineTimeouts=r;let i=Number.isInteger(s.retryAttempt)?s.retryAttempt:0;if(Kb.has(e.error)&&i<tg.length){let g=tg[i],p=setTimeout(()=>{let f=this.yeaftHistoryOutlineBySession[t];if(f?.requestId!==e.requestId||f.loading!==!0)return;let m={...this._yeaftHistoryOutlineTimeouts};delete m[t],this._yeaftHistoryOutlineTimeouts=m;let v=f.refreshPending===!0;this.yeaftHistoryOutlineBySession={...this.yeaftHistoryOutlineBySession,[t]:{...f,requestId:null,loading:!1,refreshPending:!1}},this.loadYeaftHistoryOutline({append:v?!1:s.requestAppend===!0,force:!0,targetSessionId:e.sessionId,targetAgentId:e.agentId,retryAttempt:i+1})},g);return this._yeaftHistoryOutlineTimeouts={...this._yeaftHistoryOutlineTimeouts,[t]:p},!0}let o=Array.isArray(e.results)?e.results.map(g=>({...g,agentId:e.agentId,sessionId:e.sessionId})):[],a=s.requestAppend?[...s.results||[],...o]:o,l=new Map(a.filter(g=>g?.messageId).map(g=>[si(g),g])),c=Array.from(l.values()).sort((g,p)=>(g.seq||0)-(p.seq||0)),d=s.refreshPending===!0;this.yeaftHistoryOutlineBySession={...this.yeaftHistoryOutlineBySession,[t]:{...s,requestId:null,loading:!1,requestAppend:!1,refreshPending:!1,loaded:d?!1:!e.error,results:c,hasMore:!!e.hasMore,nextBeforeSeq:Number.isFinite(e.nextBeforeSeq)?e.nextBeforeSeq:null,nextCursor:e.nextCursor&&typeof e.nextCursor=="object"?e.nextCursor:null,totalCount:Number.isFinite(e.totalCount)?e.totalCount:s.totalCount,error:d?null:e.error||null}};let u=this._yeaftHistoryResultRefreshByRequestId?.[e.requestId];if(u?.source==="outline"){clearTimeout(u.timeout);let{[e.requestId]:g,...p}=this._yeaftHistoryResultRefreshByRequestId;this._yeaftHistoryResultRefreshByRequestId=p;let f=c.find(m=>u.messageId&&m?.messageId===u.messageId||u.entryId&&m?.entryId===u.entryId);u.resolve(f||null)}return d&&this.loadYeaftHistoryOutline({force:!0,targetSessionId:e.sessionId,targetAgentId:e.agentId}),!0},searchYeaftHistory(e,{append:t=!1,senderKey:s=""}={}){if(this.currentView!=="yeaft")return!1;let n=typeof e=="string"?e.trim():"",r=typeof s=="string"&&(s==="user"||s.startsWith("vp:"))?s.slice(0,103):"",i=this.yeaftActiveSessionFilter||null,o=$e(this,i);if(this._yeaftHistorySearchTimeout&&(clearTimeout(this._yeaftHistorySearchTimeout),this._yeaftHistorySearchTimeout=null),!i||!o||Array.from(n).length<1&&!r)return this.yeaftHistorySearchState={requestId:null,agentId:o,sessionId:i,query:n,senderKey:r,loading:!1,results:[],hasMore:!1,nextBeforeSeq:null,nextCursor:null,error:null},!1;let a=this.yeaftHistorySearchState||{};if(!St(this,o,"session_history_search"))return this.yeaftHistorySearchState={requestId:null,agentId:o,sessionId:i,query:n,senderKey:r,loading:!1,results:[],hasMore:!1,nextBeforeSeq:null,nextCursor:null,error:"unsupported"},!1;let l=`history_search_${Date.now()}_${Math.random().toString(36).slice(2,8)}`;this.yeaftHistorySearchState={requestId:l,agentId:o,sessionId:i,query:n,senderKey:r,loading:!0,results:t&&a.query===n&&a.senderKey===r?a.results:[],hasMore:!1,nextBeforeSeq:t&&a.query===n&&a.senderKey===r?a.nextBeforeSeq:null,nextCursor:t&&a.query===n&&a.senderKey===r&&a.nextCursor||null,error:null},this._yeaftHistorySearchTimeout=setTimeout(()=>{this.yeaftHistorySearchState?.requestId===l&&(this._yeaftHistorySearchTimeout=null,this.yeaftHistorySearchState={...this.yeaftHistorySearchState,loading:!1,error:"timeout"})},1e4);let c=bn(),d={type:"yeaft_search_history",agentId:o,sessionId:i,requestId:l,perfTraceId:c,query:n,senderKey:r,limit:20,...t&&a.query===n&&a.senderKey===r&&a.nextCursor?{cursor:a.nextCursor}:{},...t&&a.query===n&&a.senderKey===r&&!a.nextCursor&&Number.isFinite(a.nextBeforeSeq)?{beforeSeq:a.nextBeforeSeq}:{}};return kt(this,{traceId:c,phase:"history_search.request_send",agentId:o,sessionId:i,messageType:d.type,bytes:JSON.stringify(d).length,detail:{append:t,limit:d.limit,queryLength:Array.from(n).length,senderFilter:!!r}}),this.sendWsMessage(d),!0},handleYeaftHistorySearchResult(e){let t=this.yeaftHistorySearchState||{};if(!e||e.requestId!==t.requestId||e.agentId!==t.agentId||e.sessionId!==t.sessionId||e.query!==t.query||(e.senderKey||"")!==t.senderKey)return!1;this._yeaftHistorySearchTimeout&&(clearTimeout(this._yeaftHistorySearchTimeout),this._yeaftHistorySearchTimeout=null);let s=Array.isArray(e.results)?e.results.map(o=>({...o,agentId:e.agentId,sessionId:e.sessionId})):[],n=new Map((t.results||[]).map(o=>[Lr(o),o]));for(let o of s)(o?.entryId||o?.messageId)&&n.set(Lr(o),o);let r=Array.from(n.values());this.yeaftHistorySearchState={...t,loading:!1,results:r,hasMore:!!e.hasMore,nextBeforeSeq:Number.isFinite(e.nextBeforeSeq)?e.nextBeforeSeq:null,nextCursor:e.nextCursor&&typeof e.nextCursor=="object"?e.nextCursor:null,error:e.error||null};let i=this._yeaftHistoryResultRefreshByRequestId?.[e.requestId];if(i){clearTimeout(i.timeout);let{[e.requestId]:o,...a}=this._yeaftHistoryResultRefreshByRequestId;this._yeaftHistoryResultRefreshByRequestId=a;let l=r.find(c=>i.messageId&&c?.messageId===i.messageId||i.entryId&&c?.entryId===i.entryId);i.resolve(l||null)}return!0},reloadYeaftHistoryResult(e){let t=e?.sessionId||null,s=e?.agentId||null,n=this.yeaftHistorySearchState||{},i=n.agentId===s&&n.sessionId===t&&(Array.from(String(n.query||"").trim()).length>0||!!n.senderKey);if(!t||!s)return Promise.resolve(null);let o=i&&n.query||"",a=i&&n.senderKey||"",l=null,c=!1;if(i)c=this.searchYeaftHistory(o,{senderKey:a}),l=this.yeaftHistorySearchState?.requestId||null;else{let d=Le(s,t),u=this.yeaftHistoryOutlineBySession?.[d]||null;u?.loading===!0&&u.requestAppend!==!0&&u.requestId?(c=!0,l=u.requestId):(c=this.loadYeaftHistoryOutline({force:!0,targetSessionId:t,targetAgentId:s}),l=this.yeaftHistoryOutlineBySession?.[d]?.requestId||null)}return!c||!l?Promise.resolve(null):new Promise(d=>{let u=setTimeout(()=>{if(this._yeaftHistoryResultRefreshByRequestId?.[l]?.resolve!==d)return;let{[l]:p,...f}=this._yeaftHistoryResultRefreshByRequestId;this._yeaftHistoryResultRefreshByRequestId=f,d(null)},1e4);this._yeaftHistoryResultRefreshByRequestId={...this._yeaftHistoryResultRefreshByRequestId||{},[l]:{agentId:s,sessionId:t,query:o,senderKey:a,source:i?"search":"outline",messageId:e?.messageId||null,entryId:e?.entryId||null,resolve:d,timeout:u}}})},loadYeaftHistoryWindow(e,{validateCached:t=!1}={}){let s=e?.sessionId||this.yeaftActiveSessionFilter||null,n=e?.agentId||$e(this,s),r=Lr(e);if(!s||!n||!e?.entryId||!Number.isFinite(e.indexGeneration)||!Number.isFinite(e.entryStartSeq)||!e?.messageId||!Number.isFinite(e.seq))return Promise.resolve(!1);let i=It(this,s,n);if((this.messagesMap[i]||[]).some(m=>(m?.sessionId??m?.groupId??null)===s&&m?.historyEntryId===e.entryId&&m?.historyIndexGeneration===e.indexGeneration)&&!t)return Promise.resolve(!0);let a=Le(n,`${s}:${r}:generation:${e.indexGeneration}`),l=this._yeaftHistoryWindowPendingByKey||{};if(l[a]?.promise)return l[a].promise;let c=`history_window_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,d=null,u=null,g=new Promise(m=>{d=m});Object.defineProperty(g,"error",{get:()=>u});let p=m=>{u=m||null},f=setTimeout(()=>{if(this._yeaftHistoryWindowPendingByKey?.[a]?.requestId!==c)return;let{[a]:v,...b}=this._yeaftHistoryWindowPendingByKey;this._yeaftHistoryWindowPendingByKey=b,d(!1)},1e4);return this._yeaftHistoryWindowPendingByKey={...l,[a]:{requestId:c,agentId:n,sessionId:s,entryId:e.entryId||null,indexGeneration:Number.isFinite(e.indexGeneration)?e.indexGeneration:null,entryStartSeq:Number.isFinite(e.entryStartSeq)?e.entryStartSeq:null,resultId:r,messageId:e.messageId,prefetch:!t,validateCached:!!t,setError:p,resolve:d,timeout:f,promise:g}},this.sendWsMessage({type:"yeaft_load_history_window",agentId:n,sessionId:s,requestId:c,prefetch:!t,...e.entryId?{entryId:e.entryId}:{},...Number.isFinite(e.indexGeneration)?{indexGeneration:e.indexGeneration}:{},...Number.isFinite(e.entryStartSeq)?{entryStartSeq:e.entryStartSeq}:{},anchorMessageId:e.messageId,anchorSeq:e.seq,beforeTurns:5,afterTurns:5,maxRows:200,maxBytes:512*1024}),g},beginYeaftHistoryReveal(e){let t=e?.sessionId||null,s=e?.agentId||null,n=It(this,t,s);if(!t||!s||!n)return null;let r=Le(s,t),i=`${r}${n}`,o=++this._yeaftHistoryRevealSequence,a={key:i,token:o,sessionKey:r,agentId:s,sessionId:t,conversationId:n};return this._yeaftHistoryRevealLeases={...this._yeaftHistoryRevealLeases||{},[i]:a},a},finishYeaftHistoryReveal(e){if(!e?.key||!Number.isFinite(e.token)||this._yeaftHistoryRevealLeases?.[e.key]?.token!==e.token)return!1;let{[e.key]:s,...n}=this._yeaftHistoryRevealLeases;return this._yeaftHistoryRevealLeases=n,!0},async revealYeaftHistoryResult(e,t=null){let s=!t,n=t||this.beginYeaftHistoryReveal(e),r=e?.sessionId||null,i=e?.agentId||null,o=It(this,r,i);if(!n||!r||!i||!o||!e?.messageId)return this.finishYeaftHistoryReveal(n),!1;let a=e,l=this.loadYeaftHistoryWindow(a,{validateCached:!0}),c=await l;if(!c&&l.error==="stale_result"){let u=await this.reloadYeaftHistoryResult(a);u&&(a=u,l=this.loadYeaftHistoryWindow(a,{validateCached:!0}),c=await l)}if(!c)return this.finishYeaftHistoryReveal(n),!1;if(this.currentView!=="yeaft"||this.yeaftActiveSessionFilter!==r||$e(this,r)!==i||It(this,r,i)!==o)return this.finishYeaftHistoryReveal(n),!1;let d=this.revealYeaftMessage(r,a.messageId,o,i);return(!d||s)&&this.finishYeaftHistoryReveal(n),d},pendingYeaftHistoryWindow(e){let s=Object.entries(this._yeaftHistoryWindowPendingByKey||{}).find(([,i])=>i?.requestId===e?.requestId);if(!s)return null;let[n,r]=s;return e.agentId!==r.agentId||e.sessionId!==r.sessionId||e.entryId&&r.entryId&&e.entryId!==r.entryId||Number.isFinite(e.indexGeneration)&&Number.isFinite(r.indexGeneration)&&e.indexGeneration!==r.indexGeneration?null:{pendingKey:n,pending:r}},handleYeaftHistoryWindow(e,t=null){let s=this.pendingYeaftHistoryWindow(e);if(!s)return!1;let{pendingKey:n,pending:r}=s;r.prefetch===!0&&e.prefetch!==!0&&r.validateCached!==!0&&(e.prefetch=!0),clearTimeout(r.timeout);let{[n]:i,...o}=this._yeaftHistoryWindowPendingByKey;this._yeaftHistoryWindowPendingByKey=o;let a=!e.error&&!!t&&this.isYeaftMessageCached(r.sessionId,r.messageId,t,r.agentId);return r.setError?.(e.error||null),r.resolve(!!a),!!a},createYeaftSession({displayName:e,vpIds:t,defaultVpId:s,workDir:n,agentId:r}={}){let i=Array.isArray(t)?t.slice():[],o=s&&i.includes(s)?s:i[0]||null,a=(e||"").trim(),l=(n||"").trim(),c={roster:i,defaultVpId:o};return a&&(c.name=a),l&&(c.workDir=l),this.sessionCrudRequest("create",c,{agentId:r})},handleYeaftOutput(e){if(!e)return;let t=e.agentId||this.yeaftAgentId||this.currentAgent||null,s=e.conversationId||e.event?.conversationId||null,n=Yn(this,t,s);if(e.data&&n){if(e.data.type!=="result")return;let a=Cu(this,t,s);if(!a)return;let l=e.turnId?Mn(this,t,e.turnId):"",c=!!(l&&this.activeVpTurns?.[l])||(this.messagesMap?.[a]||[]).some(d=>d?.turnId===e.turnId&&(d.isStreaming||d.status==="pending"));if(!e.turnId||!c)return;e={...e,conversationId:a}}if(e.perfTraceId&&(kt(this,{traceId:e.perfTraceId,phase:"receive.yeaft_output",agentId:e.agentId||null,sessionId:e.sessionId||null,vpId:e.vpId||null,turnId:e.turnId||null,threadId:e.threadId||null,messageType:e.data?.type||e.event?.type||e.type}),e.turnId&&(this.yeaftPerfTraceByTurnId={...this.yeaftPerfTraceByTurnId||{},[e.turnId]:e.perfTraceId})),e.data){let a=e.agentId||null,l=Ts(this,a,e.conversationId);if(l){let d=Fl(e,e.turnId||"session");for(let u of["retry","retrying","thinking"])Kn(this,l,`${u}:${d}`);e.data?.tool_use_result&&Kn(this,l,`tool:${d}`)}let c=e.turnId?Mn(this,e.agentId||null,e.turnId):"";if(c&&this.activeVpTurns?.[c]?.retryAttempt){let{retryAttempt:d,retryMax:u,retryDelayMs:g,retryReason:p,retryRecoveryMode:f,...m}=this.activeVpTurns[c];this.activeVpTurns={...this.activeVpTurns,[c]:m}}if(l){let d=e.sessionId??e.groupId??null,u=cg(this,d,a),g=a&&this.yeaftConversationIdsByAgent?this.yeaftConversationIdsByAgent[a]:null,p=is(this,a);p&&p.targetConversationId!==l?Ur(this,a,l):!p&&g&&g!==l&&!String(g).startsWith("yeaft-local-")&&(os(this,g,l,{removeSource:g!==this.yeaftConversationId}),Wr(this,a,g,l)),el(this,a,l);let f=is(this,a,l),m=f?.sourceConversationId||g,v=!u&&m===this.yeaftConversationId;if(this.currentView==="yeaft"&&a&&m&&m!==l){let w=!v&&(!!f||String(m).startsWith("yeaft-local-"));os(this,m,l,{removeSource:w}),v?eo(this,a,m,l):w&&jr(this,a,l)}a&&(this.yeaftConversationIdsByAgent={...this.yeaftConversationIdsByAgent||{},[a]:l}),(u||!this.yeaftConversationId)&&(this.yeaftConversationId=l),u&&(this.activeConversations=[l]),this.messagesMap[l]||(this.messagesMap[l]=[]);let b=this._currentYeaftAgentId,h=this._currentYeaftSessionId,k=this._currentYeaftVpId,S=this._currentYeaftTurnId,y=this._currentYeaftThreadId;a&&(this._currentYeaftAgentId=a),d!=null&&(this._currentYeaftSessionId=d),e.vpId&&(this._currentYeaftVpId=e.vpId),e.turnId&&(this._currentYeaftTurnId=e.turnId),e.threadId&&(this._currentYeaftThreadId=e.threadId);try{let w=typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now();if(this.handleAssistantOutputFrame(l,e.data,a),e.perfTraceId){let oe=typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now();kt(this,{traceId:e.perfTraceId,phase:"store.apply_output",agentId:e.agentId||null,sessionId:d||null,vpId:e.vpId||null,turnId:e.turnId||null,threadId:e.threadId||null,messageType:e.data?.type||null,durationMs:oe-w}),so(this,{traceId:e.perfTraceId,agentId:e.agentId||null,sessionId:d||null,vpId:e.vpId||null,turnId:e.turnId||null,threadId:e.threadId||null,messageType:e.data?.type||null})}let P=e.data,x=P?.message?.id||P?.id||null,Y=tw(x),L=Array.isArray(P?.message?.content)?P.message.content:[],U=L.some(oe=>oe?.type==="tool_use"),E=!!P?.tool_use_result||L.some(oe=>oe?.type==="tool_result");if(d){let oe=!E&&!ew(this,l,d)&&(P?.type==="user"||P?.type==="assistant"&&!U)?Y:null,q=Le(e.agentId||null,d),I=this.yeaftSessionHistoryState[q]||{},T=Number.isFinite(I.latestSeq)?I.latestSeq:-1;oe!==null&&oe>T&&(this.yeaftSessionHistoryState={...this.yeaftSessionHistoryState,[q]:{...I,latestSeq:oe}})}}finally{this._currentYeaftAgentId=b,this._currentYeaftSessionId=h,this._currentYeaftVpId=k,this._currentYeaftTurnId=S,this._currentYeaftThreadId=y}}return}let r=e.event;if(!r)return;let i={...r,vpId:r.vpId||e.vpId||null,threadId:r.threadId||e.threadId||null,turnId:r.turnId||e.turnId||null},o=Ts(this,e.agentId||null,e.conversationId);if(o){let a=Fl(i);r.type==="tool_start"?Nr(this,o,`tool:${a}`):r.type==="tool_end"?Kn(this,o,`tool:${a}`):r.type==="llm_retry"?Nr(this,o,`retry:${a}`):r.type==="vp_async_task_wait_start"?Nr(this,o,`async-wait:${a}`):r.type==="vp_async_task_wait_end"&&Kn(this,o,`async-wait:${a}`)}switch(r.type){case"project_mutation_result":r.projectsAuthoritative===!0?this.finishProjectMutation(r):this.finishLegacyProjectMutation(r,e.agentId||null);break;case"ask_user_question":{let a=Ts(this,e.agentId||null,e.conversationId);if(!a||!r.requestId)break;let l=ng(e,r,a),c=()=>{let d=this.messagesMap[a]||[],u=ig(d,l,a);if(u){if(u.askAnswered||u.askExpired)return!0;u.toolName="AskUserQuestion",r.toolCallId&&!u.toolId&&(u.toolId=r.toolCallId),u.agentId=l.agentId||u.agentId||null;for(let m of["sessionId","vpId","turnId","threadId"])l[m]&&(u[m]=l[m]);u.hasResult=!1,u.askRequestId=r.requestId,u.askQuestions=r.questions||[],u.askCreatedAt=r.createdAt||null,u.askExpiresAt=r.expiresAt||null,u.isHistory=!1;let f=og(this,l);return f&&Dl(u,f),this.messagesMap={...this.messagesMap,[a]:d.slice()},!0}if(!r.replay)return!1;let g={id:`ask-card-${r.requestId}`,type:"tool-use",toolName:"AskUserQuestion",toolId:r.toolCallId||null,toolInput:{questions:r.questions||[]},askRequestId:r.requestId,askQuestions:r.questions||[],askCreatedAt:r.createdAt||null,askExpiresAt:r.expiresAt||null,agentId:l.agentId,sessionId:l.sessionId,vpId:l.vpId,speakerVpId:l.vpId,turnId:l.turnId,threadId:l.threadId||"main",hasResult:!1,isHistory:!1,timestamp:r.createdAt||Date.now()},p=og(this,l);return p&&Dl(g,p),d.push(g),this.messagesMap={...this.messagesMap,[a]:d.slice()},!0};if(!c()){let d=0,u=setInterval(()=>{d+=1,(c()||d>=10)&&clearInterval(u)},200)}break}case"ask_user_answered":case"ask_user_answer_rejected":case"ask_user_expired":{let a=Ts(this,e.agentId||null,e.conversationId);if(!a||!r.requestId)break;let l=this.messagesMap[a]||[],c=ng(e,r,a),d=ig(l,c,a);if(!d){Jb(this,c,r);break}Dl(d,r),this.messagesMap={...this.messagesMap,[a]:l.slice()};break}case"session_ready":{let a=r.conversationId,l=e.agentId||this.currentAgent;if(Yn(this,l,a))break;let c=l&&this.yeaftConversationIdsByAgent?this.yeaftConversationIdsByAgent[l]:null,d=this.yeaftConversationId?String(this.yeaftConversationId):"",u=d.startsWith("yeaft-local-")&&(!l||d.startsWith(`yeaft-local-${l}-`)||/^yeaft-local-\d/.test(d))?this.yeaftConversationId:null,g=c||u,p=r.sessionId||e.sessionId||null,f=cg(this,p,l),m=is(this,l);m&&m.targetConversationId!==a?Ur(this,l,a):!m&&c&&c!==a&&!String(c).startsWith("yeaft-local-")&&Wr(this,l,c,a),el(this,l,a);let b=is(this,l,a)?.sourceConversationId||g,h=!f&&b===this.yeaftConversationId;if(b&&b!==a){let P=!h;os(this,b,a,{removeSource:P}),h?eo(this,l,b,a):P&&jr(this,l,a)}else this.messagesMap[a]||(this.messagesMap[a]=[]);l&&(this.yeaftConversationIdsByAgent={...this.yeaftConversationIdsByAgent||{},[l]:a},this.cacheYeaftAgentStatus(l,r,{allowBootstrapCatalog:f})),f&&(this.yeaftModel=r.model,this.yeaftModelEffort=r.modelEffort||null,this.yeaftSessionReady=!0,this.yeaftBootstrapMetaLoadingKey=null,l?this.applyCachedYeaftStatus(l):this.yeaftAvailableModels=r.availableModels||[]);let k=Array.isArray(r.tasks)?r.tasks:[],S={};for(let[P,x]of Object.entries(this.yeaftActiveTasksBySession||{})){let Y=Object.fromEntries(Object.entries(x||{}).filter(([,U])=>U?.id&&U.status==="running"&&U.agentId&&U.agentId!==l)),L=Ll(Y);Object.keys(L).length>0&&(S[P]=L)}for(let P of k){if(!P?.id||!P.sessionId||P.status!=="running")continue;let x=Le(l,P.sessionId);S[x]={...S[x]||{},[P.id]:{...P,agentId:l}}}this.yeaftActiveTasksBySession=S,f&&(r.yeaftDir&&(this.yeaftYeaftDir=r.yeaftDir),this.yeaftStatus={skills:r.skills,mcpServers:r.mcpServers,tools:r.tools,multiVp:!!r.multiVp}),(f||!this.yeaftConversationId)&&(this.yeaftConversationId=a),f&&(this.activeConversations=[a]);let y=e.agentId||this.currentAgent||null,w=y||"__current__";this._yeaftVpSubscribedAgentKey!==w&&(this._yeaftVpSubscribedAgentKey=w,this.sendWsMessage(y?{type:"yeaft_vp_subscribe",agentId:y}:{type:"yeaft_vp_subscribe"}));break}case"yeaft_status":{let a=e.agentId||this.currentAgent;a&&this.cacheYeaftAgentStatus(a,r);break}case"context_usage":break;case"turn_open":{if(!r.turnId)break;let a={turnId:r.turnId,userPrompt:r.userPrompt||"",vpId:r.vpId||e.vpId||null,sessionId:r.sessionId||e.sessionId||null,openedAt:r.at||Date.now(),closedAt:null,totalMs:0,inputTokens:0,outputTokens:0,totalTokens:0,loopCount:0,memoryLoaded:null,memoryLoadedMeta:null,memoryAdjust:null,tools:[],detailsLoaded:!0};this.yeaftDebugTurnsById={...this.yeaftDebugTurnsById,[r.turnId]:a};let l=Mn(this,e.agentId||null,r.turnId),c=this.activeVpTurns?.[l];c&&Number.isFinite(r.at)&&(this.activeVpTurns={...this.activeVpTurns,[l]:{...c,startedAt:r.at}}),this.yeaftDebugTurnOrder.includes(r.turnId)||(this.yeaftDebugTurnOrder=[...this.yeaftDebugTurnOrder,r.turnId]);break}case"turn_close":{if(!r.turnId)break;let a=this.yeaftDebugTurnsById[r.turnId];if(!a)break;this.yeaftDebugTurnsById={...this.yeaftDebugTurnsById,[r.turnId]:{...a,closedAt:Date.now(),...Number.isFinite(r.totalMs)?{totalMs:r.totalMs}:{},...Number.isFinite(r.inputTokens)?{inputTokens:r.inputTokens}:{},...Number.isFinite(r.outputTokens)?{outputTokens:r.outputTokens}:{},...Number.isFinite(r.totalTokens)?{totalTokens:r.totalTokens}:{},loopCount:r.loopCount||a.loopCount||0,...typeof r.model=="string"&&r.model?{model:r.model}:{},...typeof r.effort=="string"&&r.effort?{effort:r.effort}:{}}};break}case"memory_used":{if(!r.turnId)break;let a=this.yeaftDebugTurnsById[r.turnId];if(!a)break;this.yeaftDebugTurnsById={...this.yeaftDebugTurnsById,[r.turnId]:{...a,memoryLoaded:Array.isArray(r.loaded)?r.loaded:[],memoryLoadedMeta:r.meta||null}};break}case"dream_memory_loaded":{let a=Array.isArray(r.resident)?r.resident:[];if(r.turnId){let c=this.yeaftDebugTurnsById[r.turnId];c&&(this.yeaftDebugTurnsById={...this.yeaftDebugTurnsById,[r.turnId]:{...c,dreamMemoryLoaded:a,dreamMemoryLoadedInto:r.loadedInto||"system_prompt.memory"}})}let l={};for(let c of a){let d=c&&typeof c.scope=="string"?c.scope:null,u=d&&/^sessions\/[^/]+$/.test(d)?d:d&&/^group\/[^/]+$/.test(d)?`sessions/${d.slice(6)}`:null;u&&(l[u]={scope:u,sourceScope:d,sessionId:u.slice(9),turnId:r.turnId||null,vpId:r.vpId||null,loadedInto:r.loadedInto||"system_prompt.memory",summary:c.summary||"",truncated:!!c.truncated,receivedAt:Date.now()})}Object.keys(l).length>0&&(this.yeaftDreamPromptLoads={...this.yeaftDreamPromptLoads,...l});break}case"memory_adjust":{if(!r.turnId)break;let a=this.yeaftDebugTurnsById[r.turnId];if(!a)break;this.yeaftDebugTurnsById={...this.yeaftDebugTurnsById,[r.turnId]:{...a,memoryAdjust:{sessionKey:r.sessionKey||null,added:r.added||0,evicted:r.evicted||0,skipped:r.skipped||0,reason:r.reason||""}}};break}case"tool_exec":{if(this.scheduleYeaftDebugDetailRefresh(e,r.turnId),!r.turnId)break;let a=this.yeaftDebugTurnsById[r.turnId];if(!a)break;let l=[...a.tools||[],{loopNumber:r.loopNumber||0,callId:r.callId||null,name:r.name||"?",durationMs:r.durationMs||0,isError:!!r.isError}];this.yeaftDebugTurnsById={...this.yeaftDebugTurnsById,[r.turnId]:{...a,tools:l}};break}case"loop":{if(this.scheduleYeaftDebugDetailRefresh(e,r.turnId),this.yeaftDebugLoops.push({turnId:r.turnId||null,loopNumber:r.loopNumber||0,model:r.model,usage:r.usage||{inputTokens:0,outputTokens:0,totalTokens:0},latencyMs:r.latencyMs,ttfbMs:r.ttfbMs,stopReason:r.stopReason,at:typeof r.at=="number"?r.at:null,sessionId:e.sessionId||null,vpId:e.vpId||r.vpId||null}),this.yeaftDebugLoops.length>dg){let a=qp({loops:this.yeaftDebugLoops,turnsById:this.yeaftDebugTurnsById,turnOrder:this.yeaftDebugTurnOrder,maxLoops:Math.max(dg,this.yeaftDebugHistoryLimit||0)});this.yeaftDebugLoops=a.loops,this.yeaftDebugTurnsById=a.turnsById,this.yeaftDebugTurnOrder=a.turnOrder}break}case"llm_retry":{if(!e.turnId)break;let a=Mn(this,e.agentId||null,e.turnId),l=this.activeVpTurns?.[a];if(!l)break;let c=r.reason==="stream_idle_timeout"?"stream_idle_timeout":"transient_error";this.activeVpTurns={...this.activeVpTurns,[a]:{...l,retryAttempt:r.attempt||0,retryMax:r.maxRetries||0,retryDelayMs:r.delayMs||0,retryReason:c,retryRecoveryMode:r.recoveryMode||"restart"}};break}case"recall":case"fallback":case"thinking_delta":break;case"reflection":{let a=Ts(this,e.agentId||null,e.conversationId)||"unknown",l=Array.isArray(r.loopRange)?r.loopRange:[0,0],c=`${a}:${r.trigger}:${l[0]}-${l[1]}`,d=this.yeaftReflectionCards[c],u=this.messagesMap[a]||[],g=d?d.anchorMsgId:u.length>0&&u[u.length-1].id||null,p=d?d.anchorOrder:u.length;this.yeaftReflectionCards={...this.yeaftReflectionCards,[c]:{key:c,conversationId:a,turnId:r.turnId||d&&d.turnId||null,loopNumber:r.loopNumber||d&&d.loopNumber||null,trigger:r.trigger,status:r.status,loopRange:l,toolCount:r.toolCount||0,content:r.content||"",durationMs:r.durationMs||0,error:r.error||null,sessionId:e.sessionId||null,anchorMsgId:g,anchorOrder:p,updatedAt:Date.now()}};break}case"model_switched":this.yeaftModel=r.model,this.yeaftModelEffort=r.modelEffort||null;break;case"yeaft_task_event":{let a=r.task;if(!a?.id||!a.sessionId)break;let l=e.agentId||$e(this,a.sessionId),c=Le(l,a.sessionId),d={...a,agentId:l},u={...this.yeaftActiveTasksBySession},g={...u[c]||{}};a.status==="running"?g[a.id]=d:delete g[a.id];let p=Ll(g);if(Object.keys(p).length>0?u[c]=p:delete u[c],this.yeaftActiveTasksBySession=u,a.status!=="running"){let{[$l(l,a.sessionId,a.id)]:f,...m}=this.yeaftStoppingTasksById||{};this.yeaftStoppingTasksById=m}break}case"yeaft_task_cancel_result":{let a=r.taskId||r.task?.id||null,l=r.task?.sessionId||r.sessionId||e.sessionId||null,c=e.agentId||$e(this,l);if(a&&l&&r.success===!1){let{[$l(c,l,a)]:u,...g}=this.yeaftStoppingTasksById||{};this.yeaftStoppingTasksById=g}let d=r.task;if(d?.id&&d.sessionId){let u=Le(c,d.sessionId),g={...this.yeaftActiveTasksBySession},p={...g[u]||{}};d.status==="running"?p[d.id]={...d,agentId:c}:delete p[d.id];let f=Ll(p);Object.keys(f).length>0?g[u]=f:delete g[u],this.yeaftActiveTasksBySession=g}break}case"sub_agent_event":{let a=Ts(this,e.agentId||null,e.conversationId)||"unknown",l=r.agentId;if(!l)break;let c=r.payload||{},d=`${a}:${l}`,u=this.yeaftSubAgentCards[d],g=this.messagesMap[a]||[],p=u?u.anchorMsgId:g.length>0&&g[g.length-1].id||null,f=u?u.anchorOrder:g.length,m=u?{...u}:{key:d,conversationId:a,agentId:l,agentName:c.agentName||"sub-agent",status:"running",text:"",toolCallCount:0,turns:0,error:null,expanded:!1,anchorMsgId:p,anchorOrder:f,updatedAt:Date.now(),sessionId:e.sessionId||null};switch(c.agentName&&!m.agentName&&(m.agentName=c.agentName),c.type){case"sub_agent_status":m.status=c.status||m.status,c.error&&(m.error=c.error);break;case"text_delta":break;case"tool_use":case"tool_call":m.toolCallCount=Number(m.toolCallCount||0)+1;break;case"tool_start":break;case"tool_result":case"tool_end":break;case"sub_agent_turn_end":{m.turns+=1;let v=typeof c.content=="string"?c.content.trim():"";v&&(m.text=m.text?`${m.text}
9
9
 
10
- ${v}`:v),m.status!=="failed"&&m.status!=="closed"&&(m.status=c.status||"idle");break}case"error":c.error&&(m.error=c.error.message||String(c.error));break;default:break}m.updatedAt=Date.now(),this.yeaftSubAgentCards={...this.yeaftSubAgentCards,[d]:m};break}case"history_loaded":{let a={...r,agentId:e.agentId||null,requestId:r.requestId||e.requestId||null};if(a.requestId&&!this.isCurrentYeaftHistoryResponse(a))break;let l=e.agentId||null,c=r.sessionId??null,d=Le(l,c),u=e.perfTraceId||this.yeaftHistoryPerfTraceBySession?.[d];u&&kt(this,{traceId:u,phase:"history.loaded_event",agentId:e.agentId||null,sessionId:r.sessionId||null,messageType:r.type,detail:{mode:r.mode||"recent",count:r.count||0,hasMore:!!r.hasMore}});let g=r.mode==="delta"?"delta":"recent",p=this.yeaftSessionHistoryState[d]||{},f=Number.isFinite(r.latestSeq)?r.latestSeq:Number.isFinite(p.latestSeq)?p.latestSeq:null,m=Number.isFinite(r.nextBeforeSeq)?r.nextBeforeSeq:Number.isFinite(r.oldestSeq)?r.oldestSeq:Number.isFinite(p.serverOldestFetchedSeq)?p.serverOldestFetchedSeq:Number.isFinite(p.oldestSeq)?p.oldestSeq:null,v=g==="delta"?{...p,loaded:!0,loading:!1,latestSeq:f,syncingAfterSeq:null,count:(p.count||0)+(r.count||0)}:{...p,loaded:!0,loading:!1,hasMore:!!r.hasMore,serverHasMore:!!r.hasMore,oldestSeq:m,serverOldestFetchedSeq:m,count:typeof r.count=="number"?r.count:0,latestSeq:f,syncingAfterSeq:null},y=a.requestId?this.finishYeaftHistoryLoad(a,v,"completion"):null;y||(this.yeaftSessionHistoryState={...this.yeaftSessionHistoryState,[d]:v});let h=Le(l?this.currentAgent:null,this.yeaftActiveSessionFilter??null);if(d===h)g==="recent"&&(this.yeaftHasMoreHistory=v.hasMore,this.yeaftOldestLoadedSeq=v.serverOldestFetchedSeq),this.yeaftLoadingMoreHistory=!!y?.loading;else if(this.yeaftLoadingMoreHistory){let k=this.yeaftSessionHistoryState[h]||null;this.yeaftLoadingMoreHistory=!!k?.loading}}break;case"vp_snapshot":{let a=window.Pinia?.useVpStore?.()||window.__useVpStore&&window.__useVpStore();a&&a.applySnapshot(r,e.agentId||null,e.requestId||null);break}case"vp_snapshot_error":{let a=window.Pinia?.useVpStore?.()||window.__useVpStore&&window.__useVpStore();a&&a.failSnapshot(e.agentId||null,e.requestId||null,r.error||r.message||"VP library request failed");break}case"vp_updated":{let a=window.Pinia?.useVpStore?.()||window.__useVpStore&&window.__useVpStore();a&&r.vp&&a.upsert(r.vp,r.reason,e.agentId||null);break}case"vp_removed":{let a=window.Pinia?.useVpStore?.()||window.__useVpStore&&window.__useVpStore();a&&r.vpId&&a.remove(r.vpId,r.reason,e.agentId||null);break}case"vp_crud_result":{let a=this._vpCrudPending&&this._vpCrudPending.get(r.requestId);a&&(this._vpCrudPending.delete(r.requestId),a.resolve({ok:!!r.ok,op:r.op,vpId:r.vpId,vp:r.vp,error:r.error||null}));break}case"group_list_updated":case"session_list_updated":case"yeaft_session_hydrate":{let a=window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore(),l=r.sessions||[];if(r.projectsAuthoritative===!0&&Array.isArray(r.projects)?this.applySessionCatalogSnapshot(this.sessionCatalog,r.projects):Array.isArray(r.projects)&&e.agentId&&this.applyLegacyProjectSnapshot(r.projects,e.agentId),r.type!=="yeaft_session_hydrate"&&this.yeaftSessionHydrateRequestId&&this.yeaftSessionInventoryCompleteSupported===!0){let p=Array.isArray(this.yeaftSessionHydrateSlices)?this.yeaftSessionHydrateSlices.filter(f=>f.agentId!==(e.agentId||null)):[];this.yeaftSessionHydrateSlices=[...p,{agentId:e.agentId||null,sessions:l}];break}let c=a&&a.activeSessionId||null,d=a?.activeSessionKey&&a.sessions?.[a.activeSessionKey]?.agentId||null;a&&(a.applySnapshot(l,e.agentId||null),this._hasHandledYeaftSessionHydrate=!0,this.yeaftSessionHydrateError=null);let u=a&&a.activeSessionId||null,g=a?.activeSessionKey&&a.sessions?.[a.activeSessionKey]?.agentId||null;if(this.currentView==="yeaft"&&u){let p=g||$e(this,u,e.agentId||null),f=Le(p,u),m=this.yeaftSessionHistoryState[f]||null;this.setActiveSessionFilter(u,{agentId:p,force:d!==p||hu(u,c,m)})}break}case"group_roster_changed":case"session_roster_changed":{let a=window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore();a&&a.applyRosterChange(r,e.agentId||null);break}case"group_crud_result":case"session_crud_result":{let a=window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore(),l=this._sessionCrudPending&&this._sessionCrudPending.get(r.requestId);if(r.op==="copy"&&l?.agentId&&l.agentId!==e.agentId)break;r.op==="copy"&&r.projectsAuthoritative===!0&&Array.isArray(r.projects)&&this.applySessionCatalogSnapshot(this.sessionCatalog,r.projects),a&&a.applyCrudResult(r,e.agentId||null,{activate:r.op!=="copy"}),r.ok&&r.op==="delete"&&r.sessionId&&e.agentId&&this.clearYeaftHistoryMemory({agentId:e.agentId,sessionId:r.sessionId}),l&&(()=>{if(this._sessionCrudPending?.get(r.requestId)!==l)return;this._sessionCrudPending.delete(r.requestId);let d=r.session||r.group||null,u=d&&e.agentId&&!d.agentId?{...d,agentId:e.agentId}:d,g=r.sessionId||null,p=r.sessions||null;l.resolve({ok:!!r.ok,op:r.op,session:u,sessionId:g,sessions:p,config:r.config||null,error:r.error||null})})();break}case"vp_turn_start":{if(!r.turnId||!r.vpId)break;let a=ul(e.agentId||null,r.turnId)||r.turnId;if(this.activeVpTurns={...this.activeVpTurns,[a]:{agentId:e.agentId||null,turnId:r.turnId,vpId:r.vpId,sessionId:r.sessionId||null,threadId:r.threadId||null,isStreaming:!0,startedAt:r.ts||Date.now()}},r.sessionId){let l=Is(e.agentId||null,r.sessionId);this.yeaftProcessingSessions={...this.yeaftProcessingSessions,...l?{[l]:!0}:{[r.sessionId]:!0}}}break}case"vp_turn_end":{if(!r.turnId)break;let a=Mn(this,e.agentId||null,r.turnId),l=r.sessionId||this.activeVpTurns?.[a]?.sessionId||null;r.reason==="end_turn"&&l&&this.markYeaftSessionUnread(l,e.agentId||null);let{[a]:c,...d}=this.activeVpTurns;this.activeVpTurns=d;let{[a]:u,...g}=this.stoppingVpTurnIds;this.stoppingVpTurnIds=g;let p=r.sessionId||c?.sessionId||null,f=e.agentId||c?.agentId||null,m=r.vpId||c?.vpId||null;if(!(p&&m?Object.values(this.activeVpTurns||{}).some(b=>b?.vpId===m&&Rt(b,p,f)):!1)&&p&&m){let b={...this.vpStatuses||{}},w=!1;for(let[P,x]of Object.entries(b))x?.vpId===m&&Rt(x,p,f)&&ni.has(x.state)&&(b[P]={...x,state:"idle",turnId:null,since:r.ts||Date.now()},w=!0);w&&(this.vpStatuses=b)}this.clearYeaftSessionProcessingIfIdle(p,{agentId:f});let h={end_turn:"completed",route_forward:"completed",aborted:"aborted",errored:"errored",error:"errored",cancelled:"cancelled",canceled:"cancelled"}[r.reason]||"completed",k=Date.now(),S=Ts(this,e.agentId||null,e.conversationId);if(S&&Array.isArray(this.messagesMap[S])){let b=this.messagesMap[S],w=Gp(b,r);for(let P=0;P<b.length;P++){let x=b[P];if(!x||x.type!=="assistant")continue;let Y=x.sessionId??x.groupId;r.sessionId&&Y&&Y!==r.sessionId||r.vpId&&x.speakerVpId&&x.speakerVpId!==r.vpId||r.turnId&&x.turnId&&x.turnId!==r.turnId||x.status&&x.status!=="pending"||(x.status=h,x.turnEndAt=k,x.turnEndReason=r.reason||null,r.detail&&(x.turnEndDetail=r.detail),Number.isFinite(r.durationMs)&&(x.turnDurationMs=r.durationMs),w=!0)}w&&(this.messagesMap={...this.messagesMap,[S]:b.slice()}),this.pruneConversationMessageRetention(S,p,f)}break}case"yeaft_turn_aborted":{let a=Array.isArray(r.turnIds)?r.turnIds.filter(Boolean):[];r.turnId&&a.push(r.turnId);let l=r.sessionId||null,c=r.vpId||null,d=new Set;for(let f of a){let m=Mn(this,e.agentId||null,f),v=this.activeVpTurns?.[m]||null;(!v||Rt(v,v.sessionId,e.agentId||null))&&d.add(m)}if(c)for(let[f,m]of Object.entries(this.activeVpTurns||{}))!m||m.vpId!==c||Rt(m,l,e.agentId||null)&&d.add(f);if(d.size===0)break;let u=l,g={...this.activeVpTurns||{}},p={...this.stoppingVpTurnIds||{}};for(let f of d){let m=g[f];!u&&m?.sessionId&&(u=m.sessionId),delete g[f],delete p[f]}this.activeVpTurns=g,this.stoppingVpTurnIds=p,this.clearYeaftSessionProcessingIfIdle(u||null,{agentId:e.agentId||null});break}case"yeaft_aborted":{let a=r.sessionId||e.sessionId||null;a?(this.activeVpTurns=Object.fromEntries(Object.entries(this.activeVpTurns||{}).filter(([,l])=>!Rt(l,a,e.agentId||null))),this.stoppingVpTurnIds=Object.fromEntries(Object.entries(this.stoppingVpTurnIds||{}).filter(([l])=>this.activeVpTurns?.[l])),this.vpStatuses=Object.fromEntries(Object.entries(this.vpStatuses||{}).filter(([,l])=>!Rt(l,a,e.agentId||null))),this.clearYeaftSessionProcessingIfIdle(a,{agentId:e.agentId||null,ignoreStatuses:!0})):r.all&&eg(this,e.agentId||null);break}case"vp_typing_start":{if(!r.vpId)break;let a=Ts(this,e.agentId||null,e.conversationId);if(!a)break;this.yeaftVpTyping=$p(this.yeaftVpTyping,a,r.vpId);break}case"vp_typing_end":{if(!r.vpId)break;let a=Ts(this,e.agentId||null,e.conversationId);if(!a)break;this.yeaftVpTyping=Lp(this.yeaftVpTyping,a,r.vpId);break}case"vp_status_changed":{if(!r.vpId||!r.state)break;if(o){let u=Fl(i);if(r.state==="thinking"||r.state==="retrying"||r.state==="tool")Nr(this,o,`${r.state}:${u}`);else if(r.state==="streaming"||r.state==="idle"||r.state==="error")for(let g of["thinking","retrying","tool"])Kn(this,o,`${g}:${u}`)}let a=r.sessionId||null,l=e.agentId||null,c=po(l,a,r.vpId),d={agentId:l,state:r.state,since:r.since||Date.now(),turnId:r.turnId||null,title:r.title||"",sessionId:a,vpId:r.vpId};if(this.vpStatuses={...this.vpStatuses,[c]:d},a&&ni.has(r.state)){let u=Is(l,a);this.yeaftProcessingSessions={...this.yeaftProcessingSessions,...u?{[u]:!0}:{[a]:!0}}}else a&&this.clearYeaftSessionProcessingIfIdle(a,{agentId:l});this.restoreActiveYeaftSessionFromStatuses([d],l);break}case"vp_status_snapshot":{let a=Array.isArray(r.statuses)?r.statuses:[],l=r.sessionId;if(l==null){let c={...this.vpStatuses||{}};if(e.agentId)for(let[d,u]of Object.entries(c))(!u?.agentId||u.agentId===e.agentId)&&delete c[d];else for(let d of Object.keys(c))delete c[d];for(let d of a){if(!d||!d.vpId)continue;let u=d.sessionId||d.groupId||null,g=po(e.agentId||null,u,d.vpId);c[g]={agentId:e.agentId||null,state:d.state,since:d.since||Date.now(),turnId:d.turnId||null,title:d.title||"",sessionId:u,vpId:d.vpId}}this.vpStatuses=c}else{let c={...this.vpStatuses};for(let[d,u]of Object.entries(c))u&&u.sessionId===l&&(!e.agentId||!u.agentId||u.agentId===e.agentId)&&delete c[d];for(let d of a){if(!d||!d.vpId)continue;let u=d.sessionId||d.groupId||null,g=po(e.agentId||null,u,d.vpId);c[g]={agentId:e.agentId||null,state:d.state,since:d.since||Date.now(),turnId:d.turnId||null,title:d.title||"",sessionId:u,vpId:d.vpId}}this.vpStatuses=c}this.yeaftProcessingSessions=Hb(this,e.agentId||null,a,l??null),this.restoreActiveYeaftSessionFromStatuses(a,e.agentId||null);break}case"yeaft_dream_snapshot":{let a=r&&r.snapshot,l=a&&typeof a.scope=="string"?a.scope:null;l&&(this.yeaftDreamSnapshots={...this.yeaftDreamSnapshots,[l]:{...a,receivedAt:Date.now()}});break}case"yeaft_dream_status":{let a=window.Pinia?.useVpStore?.()||window.__useVpStore&&window.__useVpStore();a&&a.applyDreamStatus(r);break}case"yeaft_dream_result":{let a=window.Pinia?.useVpStore?.()||window.__useVpStore&&window.__useVpStore();a&&a.applyDreamResult(r),r?.snapshot?.scope&&(this.yeaftDreamSnapshots={...this.yeaftDreamSnapshots,[r.snapshot.scope]:{...r.snapshot,receivedAt:Date.now()}});{let l=typeof r?.snapshot?.scope=="string"&&r.snapshot.scope?r.snapshot.scope:typeof r?.sessionId=="string"&&r.sessionId?`sessions/${r.sessionId}`:null;if(!l)break;let c=this.yeaftDreamLatest[l]||null;this.yeaftDreamLatest={...this.yeaftDreamLatest,[l]:{scope:l,phase:"result",status:r.skipped?"skipped":r.success?"success":"error",startedAt:c?.startedAt??null,finishedAt:Date.now(),mergedCount:typeof r.entriesCreated=="number"?r.entriesCreated:c?.mergedCount??null,error:r.skipped||r.success?null:r.error||"unknown",manual:typeof r?.manual=="boolean"?r.manual:c?.manual??null,durationMs:typeof r.durationMs=="number"?r.durationMs:c?.durationMs??null,llmCallCount:typeof r.llmCallCount=="number"?r.llmCallCount:c?.llmCallCount??0,inputTokens:typeof r.inputTokens=="number"?r.inputTokens:c?.inputTokens??0,outputTokens:typeof r.outputTokens=="number"?r.outputTokens:c?.outputTokens??0,totalTokens:typeof r.totalTokens=="number"?r.totalTokens:c?.totalTokens??0,metrics:r.metrics||c?.metrics||null,passBreakdown:r.passBreakdown||r.metrics?.passBreakdown||c?.passBreakdown||null,isRunning:!1}},this._appendDreamEvent(l,{type:"dream_progress",phase:"result",sessionId:r.sessionId,status:r.skipped?"skipped":r.success?"success":"error",success:!!r.success,entriesCreated:typeof r.entriesCreated=="number"?r.entriesCreated:null,trigger:r.trigger||null,error:r.skipped||r.success?null:r.error||null,skipped:!!r.skipped,skippedReason:r.skippedReason||null,durationMs:typeof r.durationMs=="number"?r.durationMs:null,llmCallCount:typeof r.llmCallCount=="number"?r.llmCallCount:0,inputTokens:typeof r.inputTokens=="number"?r.inputTokens:0,outputTokens:typeof r.outputTokens=="number"?r.outputTokens:0,totalTokens:typeof r.totalTokens=="number"?r.totalTokens:0,metrics:r.metrics||null,passBreakdown:r.passBreakdown||r.metrics?.passBreakdown||null,ts:Date.now()})}break}case"dream_progress":{let a=r?.phase||"unknown",l=null;typeof r?.target=="string"&&r.target.includes("/")?l=r.target:typeof r?.sessionId=="string"&&r.sessionId?l=`sessions/${r.sessionId}`:l="*";let c=a==="done",d=a==="error"||r?.status==="error",u=!c&&!d,g=p=>{let f=this.yeaftDreamLatest[p]||null;return{scope:p,phase:a,status:d?"error":c?"success":"running",startedAt:f?.startedAt&&u?f.startedAt:r?.ts||f?.startedAt||Date.now(),finishedAt:c||d?r?.ts||Date.now():null,mergedCount:typeof r?.mergedCount=="number"?r.mergedCount:typeof r?.targets=="number"?r.targets:f?.mergedCount??null,error:d?r?.error||"unknown":null,manual:typeof r?.manual=="boolean"?r.manual:f?.manual??!1,durationMs:typeof r?.duration=="number"?r.duration:typeof r?.durationMs=="number"?r.durationMs:f?.durationMs??null,llmCallCount:typeof r?.llmCallCount=="number"?r.llmCallCount:f?.llmCallCount??0,inputTokens:typeof r?.inputTokens=="number"?r.inputTokens:f?.inputTokens??0,outputTokens:typeof r?.outputTokens=="number"?r.outputTokens:f?.outputTokens??0,totalTokens:typeof r?.totalTokens=="number"?r.totalTokens:f?.totalTokens??0,metrics:r?.metrics||f?.metrics||null,passBreakdown:r?.passBreakdown||r?.metrics?.passBreakdown||f?.passBreakdown||null,isRunning:u}};if(l==="*"){let p={...this.yeaftDreamLatest,"*":g("*")};for(let f of Object.keys(this.yeaftDreamLatest))f!=="*"&&(p[f]=g(f));this.yeaftDreamLatest=p}else this.yeaftDreamLatest={...this.yeaftDreamLatest,[l]:g(l)};this._appendDreamEvent(l,r);break}}},_appendDreamEvent(e,t){if(!e||!t)return;let s=Date.now(),n={...t,at:s},r=Array.isArray(this.yeaftDreamEvents?.[e])?this.yeaftDreamEvents[e]:[],i=l=>[l?.type||"",l?.phase||"",(l?.sessionId??l?.groupId)||"",l?.target||"",l?.ts||l?.at||""].join("|"),o=i(n);if(r.some(l=>i(l)===o))return;let a=[...r,n];a.length>pg&&a.splice(0,a.length-pg),this.yeaftDreamEvents={...this.yeaftDreamEvents,[e]:a}},fetchExpertRoleDefinitions(){if(this.expertRoleDefinitions)return;let e=this.currentAgent;e&&this.sendWsMessage({type:"get_expert_roles",agentId:e})},setYeaftSidebarEnabled(e){try{typeof localStorage<"u"&&localStorage.removeItem("yeaft-sidebar-enabled")}catch{}},vpCrudRequest(e,t){(!this._vpCrudPending||typeof this._vpCrudPending.get!="function")&&(this._vpCrudPending=new Map);let s="vpc_"+Date.now().toString(36)+"_"+Math.random().toString(36).slice(2,8),r={create:"yeaft_vp_create",update:"yeaft_vp_update",delete:"yeaft_vp_delete",read:"yeaft_vp_read"}[e];if(!r)return Promise.resolve({ok:!1,op:e,error:{code:"bad_op",message:"unknown op: "+e}});let i={type:r,requestId:s};return e==="create"||e==="update"?i.payload=t||{}:i.vpId=t,new Promise(o=>{let a=setTimeout(()=>{this._vpCrudPending&&this._vpCrudPending.has(s)&&(this._vpCrudPending.delete(s),o({ok:!1,op:e,error:{code:"timeout",message:"vp_crud timeout"}}))},1e4);this._vpCrudPending.set(s,{resolve:l=>{clearTimeout(a),o(l)}}),this.sendWsMessage(i)})},sessionCrudRequest(e,t,s={}){(!this._sessionCrudPending||typeof this._sessionCrudPending.get!="function")&&(this._sessionCrudPending=new Map);let n="grc_"+Date.now().toString(36)+"_"+Math.random().toString(36).slice(2,8),i={list:"yeaft_list_sessions",create:"yeaft_create_session",copy:"yeaft_copy_session",rename:"yeaft_rename_session",update:"yeaft_update_session",update_config:"yeaft_update_session_config",archive:"yeaft_archive_session",delete:"yeaft_delete_session",add_member:"yeaft_session_add_member",remove_member:"yeaft_session_remove_member",set_default_vp:"yeaft_session_set_default_vp",reorder:"reorder_yeaft_sessions",scan_workdir:"yeaft_scan_workdir_sessions",restore:"yeaft_restore_session"}[e];if(!i)return Promise.resolve({ok:!1,op:e,error:{code:"bad_op",message:"unknown op: "+e}});let o={type:i,requestId:n};e==="create"?o.payload=t||{}:t&&typeof t=="object"&&Object.assign(o,t);let a=s&&s.agentId?s.agentId:null;a&&(o.agentId=a);let l=window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore();return l&&l.markPending(n,e),new Promise(c=>{let d=Number.isFinite(s.timeoutMs)?Math.max(1,Number(s.timeoutMs)):e==="copy"?null:jb,u=d==null?null:setTimeout(()=>{this._sessionCrudPending&&this._sessionCrudPending.has(n)&&(this._sessionCrudPending.delete(n),l?.pending&&delete l.pending[n],c({ok:!1,op:e,error:{code:"timeout",message:"session_crud timeout"}}))},d);this._sessionCrudPending.set(n,{op:e,agentId:a||this.currentAgent,connectionGeneration:Number(this.chatHistoryConnectionGeneration||0),resolve:p=>{u&&clearTimeout(u),l?.pending&&delete l.pending[n],c(p)}});let g=this.sendWsMessage(o);e==="copy"&&!g&&(u&&clearTimeout(u),this._sessionCrudPending.delete(n),l?.pending&&delete l.pending[n],c({ok:!1,op:e,error:{code:"agent_offline"}}))})},markYeaftSessionUnread(e,t=null){if(!e)return!1;let s=$e(this,e,t);if(!s)return!1;let n=Hn(s,e);return this.currentView==="yeaft"&&this.yeaftActiveSessionFilter===e&&$e(this,e)===s||this.yeaftUnreadSessionKeys?.[n]?!1:(this.yeaftUnreadSessionKeys={...this.yeaftUnreadSessionKeys,[n]:!0},!0)},markYeaftSessionRead(e,t=null){if(!e)return!1;let s=$e(this,e,t);if(!s)return!1;let n=Hn(s,e);if(!this.yeaftUnreadSessionKeys?.[n])return!1;let{[n]:r,...i}=this.yeaftUnreadSessionKeys;return this.yeaftUnreadSessionKeys=i,!0},restoreActiveYeaftSessionFromStatuses(e=[],t=null){if(this.yeaftActiveSessionFilter)return null;let n=(Array.isArray(e)?e:[]).filter(o=>o&&(o.sessionId||o.groupId)&&!["idle","offline","completed","failed","aborted"].includes(o.state)).sort((o,a)=>(a.updatedAt||a.since||0)-(o.updatedAt||o.since||0)),r=n[0]?.sessionId||n[0]?.groupId||null;if(!r)return null;let i=t||n[0]?.agentId||gg(this,r);if(!i)return null;this.setActiveSessionFilter(r,{agentId:i,force:!0});try{let o=window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore();o&&typeof o.setActive=="function"&&o.setActive(r,i)}catch{}return r},setActiveSessionFilter(e,t={}){let s=this.yeaftActiveSessionFilter||null,n=e||null,r=n?$e(this,n,t.agentId||null):this.currentAgent,i=!!n&&n===s&&!!r&&!!this.currentAgent&&r!==this.currentAgent,o=!!t.force||i;if(this.yeaftActiveSessionFilter=n,r&&n&&this.currentAgent!==r){this.selectAgent(r);let l=this.agents.find(c=>c.id===r);this.activateYeaftAgent(r,l||null)}else r&&n&&this.activateYeaftAgent(r);r&&n&&(this.markYeaftSessionRead(n,r),cu(this,r,n));let a=!o&&n===s;if(r&&n){this.yeaftSessionAgentById={...this.yeaftSessionAgentById||{},[n]:r};let l=this.yeaftConversationIdsByAgent?.[r]||null;l||(l=`yeaft-local-${r}-${Date.now()}`,this.yeaftConversationIdsByAgent={...this.yeaftConversationIdsByAgent||{},[r]:l}),this.yeaftConversationId=l,this.messagesMap[l]||(this.messagesMap[l]=[]),this.currentView==="yeaft"&&(this.activeConversations=[l])}try{let l=window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore();l&&typeof l.setActive=="function"&&l.setActive(n,r||null);let c=l?.activeSessionKey||null;c?localStorage.setItem("lastViewedYeaftSession",c):localStorage.removeItem("lastViewedYeaftSession")}catch{}this.syncActiveYeaftHistoryLoad(),n&&r&&!a&&this.requestYeaftSessionBootstrap({forceSessionReady:!0,forceHistoryReplay:!0})},async switchYeaftModel(e,t=null,s=void 0){if(!e||!this.currentAgent)return;let n=t||null;if(n){let r={model:e};return s!==void 0&&(r.modelEffort=s||null),await this.sessionCrudRequest("update_config",{sessionId:n,config:r},{agentId:$e(this,n)})}return this.sendWsMessage({type:"yeaft_model_switch",model:e,modelEffort:s||null,agentId:this.currentAgent}),null},setYeaftDebugSearch(e){this.yeaftDebugSearch=typeof e=="string"?e:"",this._yeaftDebugSearchTimer&&clearTimeout(this._yeaftDebugSearchTimer),this._yeaftDebugSearchTimer=setTimeout(()=>{this._yeaftDebugSearchTimer=null,this.yeaftDebugLoops=[],this.yeaftDebugTurnsById={},this.yeaftDebugTurnOrder=[],this.loadYeaftDebugHistory({limit:this.yeaftDebugSearch.trim()?ug:Ol,dreamLimit:5,indexOnly:!0,search:this.yeaftDebugSearch})},250)},setYeaftDebugSessionFilter(e){e==null?this.yeaftDebugSessionFilter=null:this.yeaftDebugSessionFilter=String(e)},toggleSubAgentCardExpand(e){let t=this.yeaftSubAgentCards?.[e];t&&(this.yeaftSubAgentCards={...this.yeaftSubAgentCards,[e]:{...t,expanded:!t.expanded}})},requestTelemetrySettings(e,t,s=null){if(!t)return Promise.reject(new Error("no agent"));let n=`telemetry-${Date.now()}-${Math.random().toString(36).slice(2)}`;return this.telemetryRequestByAgent={...this.telemetryRequestByAgent,[t]:n},new Promise((r,i)=>{this._telemetryPending||(this._telemetryPending={});let o=setTimeout(()=>{if(delete this._telemetryPending[n],this.telemetryRequestByAgent?.[t]===n){let a={...this.telemetryRequestByAgent};delete a[t],this.telemetryRequestByAgent=a}i(new Error("Telemetry request timed out"))},15e3);this._telemetryPending[n]={resolve:r,reject:i,timer:o,agentId:t,operation:e,requestId:n},this.sendWsMessage({type:e==="load"?"get_telemetry_settings":"update_telemetry_settings",agentId:t,requestId:n,...e==="update"?{settings:s||{}}:{}})})},loadTelemetrySettings(e=this.currentAgent){return e?this.requestTelemetrySettings("load",e):Promise.resolve({enabled:!0,retentionDays:3,flushIntervalMs:1e3,maxQueueSize:5e3,rawExchangeMaxBytes:524288,traceTextMaxBytes:262144,loaded:!0})},updateTelemetrySettings(e,t=this.currentAgent){return this.requestTelemetrySettings("update",t,e)},requestWorkCenterFeatureSettings(e,t,s=null){if(!t)return Promise.reject(new Error("no agent"));let n=`work-center-feature-${Date.now()}-${Math.random().toString(36).slice(2)}`;return this.workCenterFeatureRequestByAgent={...this.workCenterFeatureRequestByAgent,[t]:n},new Promise((r,i)=>{this._workCenterFeaturePending||(this._workCenterFeaturePending={});let o=setTimeout(()=>{delete this._workCenterFeaturePending[n],i(new Error("Work Center settings request timed out"))},15e3);this._workCenterFeaturePending[n]={resolve:r,reject:i,timer:o,agentId:t,operation:e},this.sendWsMessage({type:e==="load"?"get_work_center_feature_settings":"update_work_center_feature_settings",agentId:t,requestId:n,...e==="update"?{settings:s}:{}})})},loadWorkCenterFeatureSettings(e=this.currentAgent){return this.requestWorkCenterFeatureSettings("load",e)},updateWorkCenterFeatureSettings(e,t=this.currentAgent){return this.requestWorkCenterFeatureSettings("update",t,e)},restartAgent(e){if(!e||this.agentOperations?.[e]?.restart?.pending)return!1;let t=`restart-${Date.now()}-${Math.random().toString(36).slice(2)}`,s=setTimeout(()=>this.finishAgentOperation(e,"restart","timeout"),12e4);return this.agentOperations={...this.agentOperations,[e]:{...this.agentOperations[e]||{},restart:{pending:!0,acknowledged:!1,startedAt:Date.now(),requestId:t,timer:s,error:null}}},this.sendWsMessage({type:"restart_agent",agentId:e,requestId:t}),!0},upgradeAgent(e,t=null){if(!e||this.agentOperations?.[e]?.upgrade?.pending)return!1;let s=this.agents.find(i=>i.id===e),n=`upgrade-${Date.now()}-${Math.random().toString(36).slice(2)}`,r=setTimeout(()=>this.finishAgentOperation(e,"upgrade","timeout"),12e4);return this.agentOperations={...this.agentOperations,[e]:{...this.agentOperations[e]||{},upgrade:{pending:!0,acknowledged:!1,startedAt:Date.now(),requestId:n,oldVersion:s?.version||null,batchId:t,timer:r,error:null}}},this.sendWsMessage({type:"upgrade_agent",agentId:e,requestId:n}),!0},getUpgradableAgents(){return(this.agents||[]).filter(e=>e?.online&&Array.isArray(e.capabilities)&&e.capabilities.includes("remote_upgrade_safe")&&!e.capabilities.includes("container_agent")&&!this.agentOperations?.[e.id]?.restart?.pending&&!this.agentOperations?.[e.id]?.upgrade?.pending)},upgradeAllAgents(){if(this.agentUpgradeBatch?.pending)return null;let e=this.getUpgradableAgents();if(e.length===0)return null;let t={id:`upgrade-batch-${Date.now()}-${Math.random().toString(36).slice(2)}`,pending:!0,startedAt:Date.now(),agentIds:e.map(s=>s.id),skippedCount:Math.max(0,(this.agents||[]).length-e.length),results:{}};this.agentUpgradeBatch=t;for(let s of e)this.upgradeAgent(s.id,t.id)||this.recordAgentUpgradeBatchResult(s.id,{status:"failed",error:"not_started"},t.id);return t.agentIds.length},recordAgentUpgradeBatchResult(e,t={},s=null){let n=this.agentUpgradeBatch;if(!n?.pending||s&&n.id!==s||!n.agentIds.includes(e)||n.results[e])return null;let r={...n,results:{...n.results,[e]:{status:t.status||"failed",error:t.error||null,version:t.version||null,reason:t.reason||null}}},i=r.agentIds.every(o=>r.results[o]);return this.agentUpgradeBatch=i?{...r,pending:!1,completedAt:Date.now()}:r,i&&typeof window<"u"&&window.dispatchEvent(new CustomEvent("agent-upgrade-batch-complete",{detail:this.agentUpgradeBatch})),i?this.agentUpgradeBatch:null},finishAgentOperation(e,t,s=null){let n=this.agentOperations?.[e]?.[t];n&&(clearTimeout(n.timer),this.agentOperations={...this.agentOperations,[e]:{...this.agentOperations[e]||{},[t]:{...n,pending:!1,timer:null,error:s}}},t==="upgrade"&&n.batchId&&this.recordAgentUpgradeBatchResult(e,s?{status:"failed",error:s}:{status:"upgraded"},n.batchId))},loadSearchSettings(){return this.currentAgent?new Promise(e=>{this._searchPending||(this._searchPending={}),this._searchPending.load=e,this.sendWsMessage({type:"get_search_settings",agentId:this.currentAgent})}):(this.searchSettings={backend:"tavily",tavilyKeyConfigured:!1,tavilyKeyMasked:null,disableHtmlFallback:!1,loaded:!0},Promise.resolve(this.searchSettings))},updateSearchSettings(e){return this.currentAgent?new Promise(t=>{this._searchPending||(this._searchPending={}),this._searchPending.update=t,this.sendWsMessage({type:"update_search_settings",agentId:this.currentAgent,settings:e||{}})}):Promise.resolve({error:"no agent"})},loadTavilyUsage(){return this.currentAgent?(this.tavilyUsageLoading=!0,new Promise(e=>{this._searchPending||(this._searchPending={}),this._searchPending.usage=e,this.sendWsMessage({type:"get_tavily_usage",agentId:this.currentAgent})})):Promise.resolve(null)},loadYeaftMcpServers(){if(!this.currentAgent)return this.yeaftMcpServers=[],this.yeaftMcpRuntime={connected:!1,toolCount:0,perServer:[]},Promise.resolve({servers:[],runtime:this.yeaftMcpRuntime});this.yeaftMcpLoading=!0;let e=`mcp-list-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;return new Promise(t=>{this._mcpPending||(this._mcpPending={}),this._mcpPending[e]=t,this.sendWsMessage({type:"yeaft_mcp_list",agentId:this.currentAgent,requestId:e})})},addYeaftMcpServer(e){if(!this.currentAgent)return Promise.resolve({error:"no agent"});this.yeaftMcpLoading=!0;let t=`mcp-add-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;return new Promise(s=>{this._mcpPending||(this._mcpPending={}),this._mcpPending[t]=s,this.sendWsMessage({type:"yeaft_mcp_add",agentId:this.currentAgent,requestId:t,server:e||{}})})},removeYeaftMcpServer(e){if(!this.currentAgent)return Promise.resolve({error:"no agent"});this.yeaftMcpLoading=!0;let t=`mcp-rem-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;return new Promise(s=>{this._mcpPending||(this._mcpPending={}),this._mcpPending[t]=s,this.sendWsMessage({type:"yeaft_mcp_remove",agentId:this.currentAgent,requestId:t,name:e})})},reloadYeaftMcpServer(e){if(!this.currentAgent)return Promise.resolve({error:"no agent"});this.yeaftMcpLoading=!0;let t=`mcp-rel-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;return new Promise(s=>{this._mcpPending||(this._mcpPending={}),this._mcpPending[t]=s,this.sendWsMessage({type:"yeaft_mcp_reload",agentId:this.currentAgent,requestId:t,name:e||null})})},clearYeaftMessages(){let e=this.yeaftConversationId;e&&(Ve(this,e),delete this.messagesMap[e],delete this.processingConversations[e],delete this.executionStatusMap[e],delete this.refreshingSessionMap[e],this._closedAt&&delete this._closedAt[e],this._turnCompletedConvs?.delete(e)),this.yeaftConversationId=this.currentAgent?`yeaft-local-${this.currentAgent}-${Date.now()}`:`yeaft-local-${Date.now()}`,this.currentAgent&&(this.yeaftConversationIdsByAgent={...this.yeaftConversationIdsByAgent||{},[this.currentAgent]:this.yeaftConversationId}),this.messagesMap[this.yeaftConversationId]=[],this.activeConversations=[this.yeaftConversationId],this.yeaftSessionReady=!1,this.yeaftModel=null,this.yeaftAvailableModels=[],this.yeaftStatus=null,this._yeaftAskTerminalEvents={},this.yeaftDebugLoops=[],this.yeaftDebugTurnsById={},this.yeaftDebugTurnOrder=[],this.yeaftDebugHistoryLoading=!1,this.yeaftDebugHistoryError=null,this.yeaftDebugHistoryFetchedAt=0,this.yeaftDebugHistoryProjection=null,this.yeaftDebugSearch="",this.yeaftDebugSessionFilter=null,this.yeaftDebugPanel={open:!1,status:"idle",requestId:null,agentId:null,sessionId:null,turnId:null,error:null},this._yeaftDebugSearchTimer&&(clearTimeout(this._yeaftDebugSearchTimer),this._yeaftDebugSearchTimer=null),this._fetchYeaftDebugHistoryTimer&&(clearTimeout(this._fetchYeaftDebugHistoryTimer),this._fetchYeaftDebugHistoryTimer=null),this._yeaftDebugHistoryInFlightKey=null,this._yeaftDebugHistoryLatestListRequestId=null,this._yeaftDebugHistoryLatestDetailRequestId=null,this.yeaftReflectionCards={},this.yeaftSubAgentCards={},this.yeaftDreamLatest={},this.yeaftDreamEvents={},this.vpStatuses={},this.currentAgent&&this.sendWsMessage({type:"yeaft_reset",agentId:this.currentAgent})},togglePaneRightPanel(e,t=null){if(t&&this.isSplitMode){let s=this.panels.find(n=>n.id===t);if(s){s.activeRightPanel=s.activeRightPanel===e?null:e;return}}this.activeRightPanel=this.activeRightPanel===e?null:e,this.activeRightPanel&&(this.workbenchExpanded=!1,this.workbenchMaximized=!1,this.rememberWorkbenchPanelState())},getPaneRightPanel(e){if(e&&this.isSplitMode){let t=this.panels.find(s=>s.id===e);if(t)return t.activeRightPanel}return this.activeRightPanel},setPaneRightPanel(e,t){if(e&&this.isSplitMode){let s=this.panels.find(n=>n.id===e);if(s){s.activeRightPanel=t;return}}this.activeRightPanel=t},applySessionCatalogSnapshot(e,t=null,s=null){let n=r=>{let i=new Set;return(Array.isArray(r)?r:[]).filter(o=>!o?.catalogKey||i.has(o.catalogKey)?!1:(i.add(o.catalogKey),!0)).map(o=>({...o}))};if(this.sessionCatalog=n(e),Array.isArray(s)&&(this.hiddenSessionCatalog=n(s)),Array.isArray(t)){this.sessionProjects=t.filter(i=>i?.id).map(i=>({...i,members:Array.isArray(i.members)?i.members.filter(o=>o?.agentId&&o?.sessionId):i.agentId?(i.sessionIds||[]).map(o=>({agentId:i.agentId,sessionId:o})):[]}));let r=new Map;for(let i of this.sessionProjects)for(let o of i.members)r.set(`${o.agentId}${o.sessionId}`,i.id);this.sessionCatalog=this.sessionCatalog.map(i=>i.runtimeProvider==="yeaft"?{...i,projectId:r.get(`${i.routeRef?.agentId}${i.routeRef?.sessionId}`)||null}:i)}this.sessionCatalogLoaded=!0},mutateProject(e,t={},s=null){let n=s||t.agentId||this.currentAgent||null;if(e==="move_session"&&!n)return Promise.resolve({ok:!1,error:{code:"missing_agent"}});let r=`project_${crypto.randomUUID()}`;return new Promise(i=>{let o=setTimeout(()=>{delete this.projectMutationRequests[r],i({ok:!1,error:{code:"timeout"}})},1e4);this.projectMutationRequests[r]={connectionGeneration:Number(this.chatHistoryConnectionGeneration||0),catalogOrder:Array.isArray(t.catalogOrder)?t.catalogOrder:null,resolve:l=>{clearTimeout(o),i(l)}},this.sendWsMessage({type:"yeaft_project_mutation",...n?{agentId:n,targetAgentId:n}:{},requestId:r,op:e,...t})||(clearTimeout(o),delete this.projectMutationRequests[r],i({ok:!1,error:{code:"send_failed"}}))})},applyLegacyProjectSnapshot(e,t){if(!t||!Array.isArray(e))return;let s=this.sessionProjects.filter(r=>r.legacyAgentId!==t),n=e.filter(r=>r?.id).map(r=>({...r,id:`${t}${r.id}`,legacyProjectId:r.id,legacyAgentId:t,members:(r.sessionIds||[]).map(i=>({agentId:t,sessionId:i}))}));this.applySessionCatalogSnapshot(this.sessionCatalog,[...s,...n])},finishLegacyProjectMutation(e,t){if(!e?.requestId)return!1;let s=this.projectMutationRequests[e.requestId]||null;return!s||s.connectionGeneration!==Number(this.chatHistoryConnectionGeneration||0)?!1:(delete this.projectMutationRequests[e.requestId],e.ok&&Array.isArray(e.projects)&&t&&this.applyLegacyProjectSnapshot(e.projects,t),s.resolve(e),!0)},finishProjectMutation(e){if(!e?.requestId)return!1;let t=this.projectMutationRequests[e.requestId]||null;if(!t||t.connectionGeneration!==Number(this.chatHistoryConnectionGeneration||0))return!1;if(delete this.projectMutationRequests[e.requestId],e.ok){if(Array.isArray(t.catalogOrder)){let s=new Map(this.sessionCatalog.map(r=>[r.catalogKey,r])),n=t.catalogOrder.map((r,i)=>{let o=s.get(r?.catalogKey);return o?{...o,sortRank:i}:null}).filter(Boolean);n.length===this.sessionCatalog.length&&(this.sessionCatalog=n,ag(n))}Array.isArray(e.projects)&&this.applySessionCatalogSnapshot(this.sessionCatalog,e.projects)}return t.resolve(e),!0},toggleCatalogSessionPin(e){if(!e?.catalogKey||!e?.routeRef||Object.keys(this.sessionCatalogMutationRequests).length>0)return!1;let t=`session_ui_${crypto.randomUUID()}`,s=_r(this,t),n=!e.pinned;return e.pinned=n,this.sendWsMessage({type:"set_session_ui_metadata",requestId:t,catalogKey:e.catalogKey,routeRef:e.routeRef,pinned:n,sortRank:Number.isFinite(e.sortRank)?e.sortRank:null})?!0:(this.sessionCatalog=s,delete this.sessionCatalogMutationRequests[t],!1)},hideCatalogSession(e){if(!e?.catalogKey||!e?.routeRef||Object.keys(this.sessionCatalogMutationRequests).length>0)return!1;let t=`session_hide_${crypto.randomUUID()}`,s=_r(this,t);return this.sessionCatalog=this.sessionCatalog.filter(r=>r.catalogKey!==e.catalogKey),this.hiddenSessionCatalog=[...(this.hiddenSessionCatalog||[]).filter(r=>r.catalogKey!==e.catalogKey),{...e,hidden:!0}],this.sendWsMessage({type:"set_session_ui_metadata",requestId:t,catalogKey:e.catalogKey,routeRef:e.routeRef,hidden:!0,...Number.isFinite(e.sortRank)?{sortRank:e.sortRank}:{}})?!0:(this.sessionCatalog=s,this.hiddenSessionCatalog=Array.isArray(this.sessionCatalogMutationRequests[t]?.previousHiddenCatalog)?this.sessionCatalogMutationRequests[t].previousHiddenCatalog:[],delete this.sessionCatalogMutationRequests[t],!1)},restoreCatalogSession(e){if(!e?.catalogKey||!e?.routeRef||Object.keys(this.sessionCatalogMutationRequests).length>0)return!1;let t=`session_restore_${crypto.randomUUID()}`,s=_r(this,t);return this.hiddenSessionCatalog=(this.hiddenSessionCatalog||[]).filter(r=>r.catalogKey!==e.catalogKey),this.sessionCatalog=this.sessionCatalog.some(r=>r.catalogKey===e.catalogKey)?this.sessionCatalog:[...this.sessionCatalog,{...e,hidden:!1}],this.sendWsMessage({type:"set_session_ui_metadata",requestId:t,catalogKey:e.catalogKey,routeRef:e.routeRef,hidden:!1,...Number.isFinite(e.sortRank)?{sortRank:e.sortRank}:{}})?!0:(this.sessionCatalog=s,this.hiddenSessionCatalog=Array.isArray(this.sessionCatalogMutationRequests[t]?.previousHiddenCatalog)?this.sessionCatalogMutationRequests[t].previousHiddenCatalog:[],delete this.sessionCatalogMutationRequests[t],!1)},renameCatalogSession({row:e,title:t}={}){if(!e?.routeRef||!t)return!1;let{runtimeProvider:s,agentId:n,sessionId:r}=e.routeRef;if(s==="yeaft")this.sessionCrudRequest("rename",{sessionId:r,name:t},{agentId:n});else if(s==="claude-code"||s==="copilot")this.renameChatSession(r,t,n);else return!1;return!0},sessionForkUnavailableReason(e){let t=e?.routeRef;return t?.runtimeProvider!=="yeaft"||!t.agentId||!t.sessionId?"bad_route":this.sessionForkPendingKey?"fork_pending":this.connectionState!=="connected"||!this.agents.some(s=>s.id===t.agentId&&s.online)?"agent_offline":this.isYeaftSessionProcessing(t.sessionId,t.agentId)?"session_running":null},async copyCatalogSession(e){let t=this.sessionForkUnavailableReason(e);if(t)return{ok:!1,op:"copy",error:{code:t}};let s={...e.routeRef};this.sessionForkPendingKey=Hn(s.agentId,s.sessionId),this.sessionForkState="copying";try{let n=await this.sessionCrudRequest("copy",{sessionId:s.sessionId},{agentId:s.agentId});if(!n?.ok||!n.session?.id)return n;this.sessionForkState="success",await new Promise(i=>setTimeout(i,Ub));let r={runtimeProvider:"yeaft",agentId:s.agentId,sessionId:n.session.id};return this.openCatalogSession({catalogKey:Hn(r.agentId,r.sessionId),routeRef:r}),n}catch(n){return{ok:!1,op:"copy",error:{code:"fork_failed",message:n?.message||String(n)}}}finally{this.sessionForkState="idle",this.sessionForkPendingKey=null}},reorderCatalogSessions(e){if(!Array.isArray(e)||e.length===0||Object.keys(this.sessionCatalogMutationRequests).length>0)return!1;let t=`session_order_${crypto.randomUUID()}`,s=_r(this,t);return this.sessionCatalog=e.map((r,i)=>({...r,sortRank:i})),this.sendWsMessage({type:"reorder_session_catalog",requestId:t,sessions:this.sessionCatalog.map((r,i)=>({catalogKey:r.catalogKey,routeRef:r.routeRef,pinned:!!r.pinned,sortRank:i}))})?!0:(this.sessionCatalog=s,delete this.sessionCatalogMutationRequests[t],!1)},finishSessionCatalogMutation(e){if(!Md(this,e))return!1;if(e?.ok===!0&&e?.type==="session_ui_metadata_updated"){let s=n=>{n&&(n.pinned=e.pinned===!0,Object.prototype.hasOwnProperty.call(e,"sortRank")&&(n.sortRank=Number.isFinite(e.sortRank)?e.sortRank:null))};s(this.sessionCatalog.find(n=>n.catalogKey===e.catalogKey)),s(this.hiddenSessionCatalog.find(n=>n.catalogKey===e.catalogKey))}return e?.ok===!0&&e?.type==="session_catalog_reorder_result"&&ag(this.sessionCatalog),!0},openCatalogSession(e){if(!e?.catalogKey||!e.routeRef)return!1;let{runtimeProvider:t,agentId:s,sessionId:n}=e.routeRef;if(this.activeCatalogKey=e.catalogKey,t==="yeaft"){let r=this.isSessionHistorySyncing(e.routeRef);return this.enterYeaft(s,{deferBootstrap:!0}),this.setActiveSessionFilter(n,{agentId:s,force:!1}),r||this.reloadYeaftMessages(),!0}return t!=="claude-code"&&t!=="copilot"?!1:(this.currentView==="yeaft"&&this.leaveYeaft(),this.selectConversation(n,s,{refresh:!0}),!0)},syncChatConversationHistory(e){if(!e)return null;let t=Vs(e);if(this.chatHistoryRequests[t]?.loading)return this.chatHistoryRequests[t].requestId;let s=vn(this.messagesMap[e]);return this.requestChatHistory(e,s===null?{mode:"recent",turns:5}:{mode:"delta",afterMessageId:s})},requestChatHistory(e,{mode:t="recent",turns:s=null,beforeId:n=null,afterMessageId:r=null}={}){if(!e)return null;let i=Vs(e);if(this.chatHistoryRequestIdSupported!==!0&&this.chatHistoryRequests[i]?.loading)return null;let o=n??r??null,a=this.beginChatHistoryRequest(e,t,o);return this.sendWsMessage({type:"sync_messages",conversationId:e,...s!=null?{turns:s}:{},...n!=null?{beforeId:n}:{},...r!=null?{afterMessageId:r}:{},requestId:a})?(setTimeout(()=>{Oa(this,i,a,"history_load_timeout")},1e4),a):(Oa(this,i,a,"send_failed"),null)},beginChatHistoryRequest(e,t="recent",s=null){return Pd(this,e,t,s)},isCurrentChatHistoryResponse(e){if(!e?.conversationId||!e?.requestId||!e?.catalogKey)return!1;let t=Vs(e.conversationId);if(e.catalogKey!==t)return!1;let s=this.chatHistoryRequests[t];return!!s&&s.loading===!0&&s.requestId===e.requestId&&Number(s.connectionGeneration||0)===Number(this.chatHistoryConnectionGeneration||0)},finishChatHistoryRequest(e){if(!this.isCurrentChatHistoryResponse(e))return!1;let t=this.chatHistoryRequests[e.catalogKey];return this.chatHistoryRequests[e.catalogKey]={...t,loading:!1},!0},isRefreshingSession(e){return e?!!this.refreshingSessionMap[e]:this.refreshingSession},setRefreshingSession(e,t){e&&(this.refreshingSessionMap[e]=t),this.refreshingSession=t},enterBtwMode(){this.btwMode=!0,this.btwMessages=[],this.btwLoading=!1,this.btwSessionId=null},sendBtwQuestion(e){this.currentConversation&&(this.btwMessages.push({role:"user",content:e}),this.btwMessages.push({role:"assistant",content:""}),this.btwLoading=!0,this.sendWsMessage({type:"btw_question",conversationId:this.currentConversation,question:e,btwSessionId:this.btwSessionId}))},closeBtw(){this.btwMode=!1,this.btwMessages=[],this.btwLoading=!1,this.btwSessionId=null},appendBtwDelta(e){let t=this.btwMessages[this.btwMessages.length-1];t&&t.role==="assistant"&&(t.content+=e)},addSubagent(e,t){this.subagents[e]||(this.subagents[e]={}),this.subagents[e][t.id]={id:t.id,slug:t.slug||t.id,type:t.type||"Task",description:t.description||"",parentToolUseId:t.parentToolUseId||null,status:"running",startTime:Date.now(),messages:[],toolCallCount:0},e===this.currentConversation&&this.activeRightPanel!=="subagents"&&(this.activeRightPanel="subagents")},appendSubagentMessage(e,t,s){let n=this.subagents[e];if(!n||!n[t])return;let r=n[t];if(s?.type==="tool"){r.toolCallCount=Number(r.toolCallCount||0)+1;return}s?.type==="text"&&r.messages.push(s)},completeSubagent(e,t){let s=this.subagents[e];!s||!s[t]||(s[t].status="completed")},sendWsMessage(e){return Gd(this,e)},parseWsMessage(e){return Qd(this,e)},connect(){Xd(this)},ensureConnected(){return $r(this)},scheduleReconnect(){Zd(this)},manualReconnect(){Jd(this)},startHeartbeat(){eu(this)},stopHeartbeat(){tu(this)},setupVisibilityHandler(){su(this)},handleMessage(e){sp(this,e)},getOrCreateExecutionStatus(e){return al(this,e)},handleAssistantOutputFrame(e,t,s=null){Wu(this,e,t,s)},handleClaudeOutput(e,t){this.handleAssistantOutputFrame(e,t,null)},addMessageToConversation(e,t){return Qi(this,e,t)},pruneConversationMessageRetention(e,t=null,s=null,n=void 0){return au(this,{conversationId:e,sessionId:t,agentId:s,limits:n})},appendToAssistantMessageForConversation(e,t,s){yu(this,e,t,s)},finishStreamingForConversation(e,t){bu(this,e,t)},sweepStaleStreamingForConversation(e){wu(this,e)},appendToAssistantMessage(e){this.appendToAssistantMessageForConversation(this.currentConversation,e)},finishStreaming(){this.finishStreamingForConversation(this.currentConversation)},addMessage(e){this.addMessageToConversation(this.currentConversation,e)},loadHistoryMessages(e){ku(this,e)},formatDbMessage(e){return Su(e)},selectAgent(e){return dp(this,e)},createConversation(e,t=null,s=null,n=void 0){up(this,e,t,s,n)},resumeConversation(e,t,s=null,n=null,r=null){pp(this,e,t,s,n,r)},selectConversation(e,t,s={}){gp(this,e,t,s)},updateConversationSettings(e,t){fl(this,e,t)},toggleConversationMcp(e,t){fp(this,e,t)},deleteConversation(e,t){mp(this,e,t)},closeSession(e,t){hp(this,e,t)},appendColumn(e){wp(this,e)},removeColumn(e){kp(this,e)},sendMessageToConversation(e,t,s=[],n={}){Sp(this,e,t,s,n)},cancelExecutionForConversation(e){Ip(this,e)},addPanel(){if(this.panels.length>=3)return;let e=(t,s)=>({id:t,conversationId:s,activeRightPanel:null});if(this.panels.length===0){let t=localStorage.getItem("splitPanesSaved");if(t){try{let s=JSON.parse(t);if(Array.isArray(s)&&s.length>=2){let n=new Set(this.conversations.map(i=>i.id)),r=s.filter(i=>i&&typeof i.id=="string").map(i=>({...e(i.id,null),conversationId:i.conversationId&&n.has(i.conversationId)?i.conversationId:null}));if(r.length>=2){this.panels=r,this.activePanelId=r[0].id;for(let i of r)i.conversationId&&!this.activeConversations.includes(i.conversationId)&&this.activeConversations.push(i.conversationId),i.conversationId&&!this.messagesMap[i.conversationId]&&(this.messagesMap[i.conversationId]=[],this.requestChatHistory(i.conversationId,{mode:"recent",turns:5}));localStorage.removeItem("splitPanesSaved"),this.saveOpenSessions();return}}}catch{}localStorage.removeItem("splitPanesSaved")}this.panels=[e("panel-0",this.currentConversation),e("panel-1",null)],this.activePanelId="panel-0"}else{let t="panel-"+Date.now();this.panels.push(e(t,null))}this.saveOpenSessions()},removePanel(e){let t=this.panels.findIndex(s=>s.id===e);if(!(t<0)){if(this.panels.splice(t,1),this.panels.length<=1){let s=this.panels[0];s?.conversationId&&(this.activeConversations=[s.conversationId]),this.panels=[],this.activePanelId=null}else this.activePanelId===e&&(this.activePanelId=this.panels[0]?.id||null);this.saveOpenSessions()}},setPanelConversation(e,t,{refresh:s=!1}={}){let n=this.panels.find(i=>i.id===e);if(!n)return;let r=n.conversationId===t;n.conversationId=t,t&&!this.activeConversations.includes(t)&&this.activeConversations.push(t),t&&!this.messagesMap[t]?(this.messagesMap[t]=[],this.syncChatConversationHistory(t)):t&&(s||!r)&&this.syncChatConversationHistory(t),this.saveOpenSessions()},setActivePanel(e){this.activePanelId=e},splitToPanel(e){if(!e)return;let t=(s,n)=>({id:s,conversationId:n,activeRightPanel:null});if(this.panels.length===0)this.panels=[t("panel-0",this.currentConversation),t("panel-"+Date.now(),e)],this.activePanelId=this.panels[1].id;else if(this.panels.length>=3)this.panels[this.panels.length-1].conversationId=e,this.activePanelId=this.panels[this.panels.length-1].id;else{let s="panel-"+Date.now();this.panels.push(t(s,e)),this.activePanelId=s}this.activeConversations.includes(e)||this.activeConversations.push(e),this.messagesMap[e]||(this.messagesMap[e]=[],this.requestChatHistory(e,{mode:"recent",turns:5})),this.saveOpenSessions()},isInAnyPanel(e){return this.panels.some(t=>t.conversationId===e)},setSessionPinned(e,t,s={}){if(!e)return;let n=s&&s.agentId?s.agentId:null,r=n?!!ds()?.sessionById?.(e,n)?.pinned:this.pinnedSessions.includes(e);if(t&&!r)this.pinnedSessions.unshift(e);else if(!t&&r){let i=this.pinnedSessions.indexOf(e);i>=0&&this.pinnedSessions.splice(i,1)}try{localStorage.setItem("pinned-sessions",JSON.stringify(this.pinnedSessions))}catch{}try{let i=window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore(),o=$e(this,e,n);i&&typeof i.applyPinState=="function"&&i.applyPinState(e,!!t,o)}catch{}},togglePin(e,t={}){let s=t&&t.agentId?t.agentId:null,n=s?ds()?.sessionById?.(e,s):null,r=t&&Object.prototype.hasOwnProperty.call(t,"pinned"),o=!(n?!!n.pinned:r?!!t.pinned:this.pinnedSessions.includes(e));this.setSessionPinned(e,o,{agentId:s});let a={type:o?"pin_session":"unpin_session",conversationId:e};t&&t.sessionKind==="yeaft"&&(a.sessionKind="yeaft",t.agentId&&(a.agentId=t.agentId),t.sessionName&&(a.sessionName=t.sessionName),t.workDir&&(a.workDir=t.workDir)),this.sendWsMessage(a)},isSessionPinned(e){return this.pinnedSessions.includes(e)},applyServerPinSnapshot(e,t,s){if(!Array.isArray(this.pinnedSessions))return;let n=new Set(this.pinnedSessions),r=[];for(let i of t)n.has(i)||r.push(i);if(r.length>0&&(this.pinnedSessions=[...r,...this.pinnedSessions]),e){let i=this.pinnedSessions.filter(o=>s(o)?t.has(o):!0);i.length!==this.pinnedSessions.length&&(this.pinnedSessions=i)}try{localStorage.setItem("pinned-sessions",JSON.stringify(this.pinnedSessions))}catch{}},clearYeaftSessionProcessingIfIdle(e,{agentId:t=null,ignoreStatuses:s=!1}={}){if(!e)return;let n=t||$e(this,e);if(Object.values(this.activeVpTurns||{}).some(a=>Rt(a,e,n))||!s&&Object.values(this.vpStatuses||{}).some(l=>Rt(l,e,n)&&ni.has(l?.state)))return;let i=Is(n,e),o={...this.yeaftProcessingSessions||{}};i&&delete o[i],fo(this,e,n)&&delete o[e],this.yeaftProcessingSessions=o},sendMessage(e,t=[],s={}){vp(this,e,t,s)},cancelExecution(){yp(this)},cancelYeaft(){if(!this.currentAgent)return;this.sendWsMessage({type:"yeaft_abort_all",agentId:this.currentAgent});let e=this.yeaftConversationIdsByAgent?.[this.currentAgent]||this.yeaftConversationId;e&&delete this.processingConversations[e],eg(this,this.currentAgent)},cancelYeaftSession(e){let t=$e(this,e);!t||!e||(this.sendWsMessage({type:"yeaft_abort_all",agentId:t,sessionId:e}),this.activeVpTurns=Object.fromEntries(Object.entries(this.activeVpTurns||{}).filter(([,s])=>!Rt(s,e,t))),this.stoppingVpTurnIds=Object.fromEntries(Object.entries(this.stoppingVpTurnIds||{}).filter(([s])=>this.activeVpTurns?.[s])),this.vpStatuses=Object.fromEntries(Object.entries(this.vpStatuses||{}).filter(([,s])=>!Rt(s,e,t))),this.clearYeaftSessionProcessingIfIdle(e,{agentId:t,ignoreStatuses:!0}))},cancelVpTurn(e,{sessionId:t=null,vpId:s=null}={}){let n=$e(this,t);if(!n||!e)return;let r=Mn(this,n,e);this.stoppingVpTurnIds={...this.stoppingVpTurnIds,[r]:Date.now()};let i={type:"yeaft_abort_turn",agentId:n,turnId:e};t&&(i.sessionId=t),s&&(i.vpId=s),this.sendWsMessage(i)},cancelVpTurnForSession(e,t=null){if(!e)return!1;let s=t||this.yeaftActiveSessionFilter||null;if(!s)return!1;let n=$e(this,s);if(!n)return!1;let r=this.activeVpTurns||{},i=null,o=-1/0;for(let[a,l]of Object.entries(r)){if(!l||l.vpId!==e||!Rt(l,s,n))continue;let c=typeof l.startedAt=="number"?l.startedAt:0;c>=o&&(o=c,i=a)}if(!i){let a=this.vpStatuses?.[po(n,s,e)]||null;a?.turnId&&!["idle","offline"].includes(a.state)&&(i=a.turnId)}if(i){let a=r[i]?.turnId||i;return this.cancelVpTurn(a,{sessionId:s,vpId:e}),!0}return this.sendWsMessage({type:"yeaft_abort_turn",agentId:n,sessionId:s,vpId:e}),!0},answerUserQuestion(e,t,s){bp(this,e,t,s)},refreshAgents(){Cp(this)},refreshConversation(){Ap(this)},setDreamEnabled(e,t){if(!e||this.agentDreamState?.[e]?.pending)return!1;let s=this.agents.find(o=>o.id===e),n=t!==!1,r=`dream-${Date.now()}-${Math.random().toString(36).slice(2)}`,i=setTimeout(()=>{let o=this.agentDreamState?.[e];!o?.pending||o.requestId!==r||(this.agentDreamState={...this.agentDreamState,[e]:{...o,pending:!1,timer:null,error:"timeout"}})},15e3);return this.agentDreamState={...this.agentDreamState,[e]:{pending:!0,requestId:r,requested:n,authoritative:s?.dreamEnabled===!0,timer:i,error:null}},xp(this,e,n,r),!0},loadMoreMessages(){if(this.currentView==="yeaft"||this.loadingMoreMessages||!this.hasMoreMessages||!this.currentConversation)return;this.loadingMoreMessages=!0;let e=this._loadMoreGeneration=(this._loadMoreGeneration||0)+1,s=(this.messagesMap[this.currentConversation]||[]).find(i=>i.dbMessageId),n=this.currentConversation,r=s?.dbMessageId??null;this.requestChatHistory(n,{mode:"older",turns:5,beforeId:r}),setTimeout(()=>{this._loadMoreGeneration===e&&this.loadingMoreMessages&&this.currentConversation===n&&(this.loadingMoreMessages=!1)},1e4)},reloadYeaftMessages(){if(this.currentView!=="yeaft")return!1;let e=Ms(this),t=$e(this,e);if(!t)return!1;let s=Le(t,e),n=this.yeaftConversationId,r=this.yeaftSessionHistoryState?.[s];if(r?.loading)return r.requestId?(this._yeaftManualHistoryRefresh={agentId:t,sessionId:e,requestId:r.requestId},r.requestId):!1;let i=this.beginYeaftHistoryLoad({agentId:t,sessionId:e,mode:"recent",preserveLoaded:!1});if(!i)return!1;this._yeaftManualHistoryRefresh={agentId:t,sessionId:e,requestId:i.requestId};let o=bn();this.yeaftHistoryPerfTraceBySession={...this.yeaftHistoryPerfTraceBySession||{},[s]:o};let a={type:"yeaft_load_history",agentId:t,limit:El,sessionId:e,requestId:i.requestId,perfTraceId:o};return kt(this,{traceId:o,phase:"history.request_send",agentId:t,sessionId:e,messageType:a.type,bytes:JSON.stringify(a).length,detail:{mode:"manual-reload",limit:El}}),this.sendWsMessage(a)?!0:(Or(this,{agentId:t,sessionId:e,requestId:i.requestId,error:"history_load_send_failed"}),!1)},loadMoreYeaftHistory(e=ti(),{sessionId:t=null,agentId:s=null,background:n=!1}={}){if(this.currentView!=="yeaft")return!1;let r=t||Ms(this),i=$e(this,r,s);if(!i||!r)return!1;let o=Le(i,r),a=this.yeaftSessionHistoryState?.[o]||{};if(a.loading||!a.hasMore)return!1;let l=Math.min(50,Math.max(1,Number.isFinite(e)?Math.floor(e):ti())),c=this.yeaftHistoryCacheState?.[o]?.ranges||[],d=Number(this.yeaftHistoryCacheState?.[o]?.rangeEpoch)||0,u=xu(a,c,d);if(this.yeaftSessionHistoryState={...this.yeaftSessionHistoryState||{},[o]:u.state},!u.request)return this.syncActiveYeaftHistoryLoad(),!1;let g=this.beginYeaftHistoryLoad({agentId:i,sessionId:r,mode:n?"prefetch":"older",preserveLoaded:!0,latestSeq:this.yeaftSessionHistoryState[o]?.latestSeq??null});if(!g)return!1;let p=bn();this.yeaftHistoryPerfTraceBySession={...this.yeaftHistoryPerfTraceBySession||{},[o]:p};let f={type:"yeaft_load_more_history",agentId:i,sessionId:r,requestId:g.requestId,beforeSeq:u.request.beforeSeq,pageKind:u.request.kind,gapStopAtSeq:u.request.stopAtSeq,cacheEpoch:u.request.cacheEpoch,turns:l,perfTraceId:p};return kt(this,{traceId:p,phase:"history_more.request_send",agentId:i,sessionId:r,messageType:f.type,bytes:JSON.stringify(f).length,detail:{beforeSeq:f.beforeSeq,turns:f.turns,pageKind:u.request.kind,gapStopAtSeq:u.request.stopAtSeq,background:n}}),this.sendWsMessage(f)?!0:(Or(this,{agentId:i,sessionId:r,requestId:g.requestId,error:"history_load_send_failed"}),!1)},checkPendingRecovery(){Rd(this)},performRecovery(){_d(this)},dismissRecovery(){Ed(this)},autoRestoreConversation(e){Dd(this,e)},saveOpenSessions(){fn(this)},getLastSession(){return Ld(this)},clearLastSession(){Fd(this)},listHistorySessions(e){Od(this,e)},listFolders(){return qd(this)},listFoldersForAgent(e,t){return Vd(this,e,t)},listModelsForAgent(e,t){return Hd(this,e,t)},listHistorySessionsForAgent(e,t,s){Bd(this,e,t,s)},async loadGlobalSessions(e=20){return Nd(this,e)},async deleteGlobalSession(e){return Wd(this,e)},findAgentForSession(e){return qa(this,e)},isSessionResumable(e){return jd(this,e)},_isRecentlyClosed(e){return yn(this,e)},_startProcessingWatchdog(e){Un(this,e)},_resetProcessingWatchdog(e){Xi(this,e)},_stopProcessingWatchdog(e){Ve(this,e)},startRefreshTimeout(e){let t=e||this.currentConversation;t&&(this._refreshTimeouts||(this._refreshTimeouts={}),this._refreshTimeouts[t]&&clearTimeout(this._refreshTimeouts[t]),this._refreshTimeouts[t]=setTimeout(()=>{this.setRefreshingSession(t,!1),delete this._refreshTimeouts[t]},1e4))},toggleTheme(){this.theme=this.theme==="dark"?"light":"dark",this.themeFollowSystem=!1,localStorage.setItem("theme",this.theme),document.documentElement.setAttribute("data-theme",this.theme),document.documentElement.classList.toggle("light",this.theme==="light")},initTheme(){if(document.documentElement.setAttribute("data-theme",this.theme),document.documentElement.classList.toggle("light",this.theme==="light"),this.themeFollowSystem&&typeof window<"u"&&window.matchMedia){let e=window.matchMedia("(prefers-color-scheme: dark)"),t=s=>{this.themeFollowSystem&&(this.theme=s.matches?"dark":"light",document.documentElement.setAttribute("data-theme",this.theme),document.documentElement.classList.toggle("light",this.theme==="light"))};e.addEventListener?e.addEventListener("change",t):e.addListener&&e.addListener(t)}},loadModelsDevRegistry({forceRefresh:e=!1}={}){let t=this.modelsDevRegistry.loaded&&!this.modelsDevRegistry.error&&Date.now()-this.modelsDevRegistry.fetchedAt<36e5;if(!e&&t)return Promise.resolve(this.modelsDevRegistry);let s=this.currentAgent;if(!s)return Promise.resolve(this.modelsDevRegistry);if(this._modelsDevPending&&(!e||this._modelsDevPending.force))return new Promise(n=>this._modelsDevPending.resolvers.push(n));if(this._modelsDevPending){let n=this._modelsDevPending;this._modelsDevPending=null,n.timer&&clearTimeout(n.timer);for(let r of n.resolvers)r(this.modelsDevRegistry)}return new Promise(n=>{let r={resolvers:[n],force:e,timer:null};this._modelsDevPending=r;try{this.sendWsMessage({type:"get_models_dev_registry",agentId:s,forceRefresh:e})}catch{this._modelsDevPending===r&&(this._modelsDevPending=null),n(this.modelsDevRegistry);return}r.timer=setTimeout(()=>{if(this._modelsDevPending===r){this._modelsDevPending=null;for(let i of r.resolvers)i(this.modelsDevRegistry)}},2e4)})},changeLocale(e){if(this.locale=e,Rr(e),this.currentAgent)try{this.sendWsMessage({type:"update_llm_config",agentId:this.currentAgent,config:{language:e}})}catch{}},async fetchCustomExpertRoles(){let e=Ge();try{let t={};e.token&&(t.Authorization=`Bearer ${e.token}`);let s=await fetch("/api/expert-roles/custom",{headers:t});if(s.ok){let n=await s.json();this.customExpertRoles=n.roles||[]}}catch{}},async createCustomExpertRole(e){let t=Ge();try{let s={"Content-Type":"application/json"};t.token&&(s.Authorization=`Bearer ${t.token}`);let n=await fetch("/api/expert-roles/custom",{method:"POST",headers:s,body:JSON.stringify(e)});if(n.ok){let r=await n.json();return this.customExpertRoles.push(r.role),r.role}else{let r=await n.json().catch(()=>({}));throw new Error(r.error||"Failed to create custom expert role")}}catch(s){throw s}},async updateCustomExpertRole(e,t){let s=Ge();try{let n={"Content-Type":"application/json"};s.token&&(n.Authorization=`Bearer ${s.token}`);let r=await fetch(`/api/expert-roles/custom/${e}`,{method:"PUT",headers:n,body:JSON.stringify(t)});if(r.ok){let i=await r.json(),o=this.customExpertRoles.findIndex(a=>a.id===e);return o!==-1&&(this.customExpertRoles[o]=i.role),i.role}else{let i=await r.json().catch(()=>({}));throw new Error(i.error||"Failed to update custom expert role")}}catch(n){throw n}},async deleteCustomExpertRole(e){let t=Ge();try{let s={};t.token&&(s.Authorization=`Bearer ${t.token}`);let n=await fetch(`/api/expert-roles/custom/${e}`,{method:"DELETE",headers:s});if(n.ok)return this.customExpertRoles=this.customExpertRoles.filter(r=>r.id!==e),!0;{let r=await n.json().catch(()=>({}));throw new Error(r.error||"Failed to delete custom expert role")}}catch(s){throw s}},rememberWorkbenchPanelState(e=this.activeSessionRoute,t){let s=typeof e=="string"?e:yt(e);if(!s)return!1;let n=this.workbenchPanelStateByRoute[s]||{},r=Number.isFinite(t)&&t>0?Math.round(t):n.width;return this.workbenchPanelStateByRoute={...this.workbenchPanelStateByRoute,[s]:{expanded:!!this.workbenchExpanded,maximized:!!this.workbenchExpanded&&!!this.workbenchMaximized,...Number.isFinite(r)&&r>0?{width:r}:{}}},!0},workbenchPanelWidthForRoute(e=this.activeSessionRoute){let t=typeof e=="string"?e:yt(e),s=t?this.workbenchPanelStateByRoute[t]?.width:null;return Number.isFinite(s)&&s>0?s:null},restoreWorkbenchPanelState(e=this.activeSessionRoute){let t=yt(e),s=t?this.workbenchPanelStateByRoute[t]:null;return this.workbenchExpanded=!!s?.expanded,this.workbenchMaximized=!!s?.expanded&&!!s?.maximized,!!s},openWorkbench(){this.workbenchExpanded=!0,this.activeRightPanel=null,this.closeYeaftDebugPanel(),this.rememberWorkbenchPanelState()},toggleWorkbench(){if(this.workbenchExpanded){this.workbenchExpanded=!1,this.workbenchMaximized=!1,this.rememberWorkbenchPanelState();return}this.openWorkbench()},toggleSidebar(){this.sidebarCollapsed=!this.sidebarCollapsed},toggleSessionSidebar(){this.sessionSidebarOpen=!this.sessionSidebarOpen},closeSessionSidebar(){this.sessionSidebarOpen=!1},toggleWorkbenchMaximized(){this.workbenchMaximized=!this.workbenchMaximized,this.rememberWorkbenchPanelState()},renameChatSession(e,t,s=null){let n=t&&t.trim()?t.trim():"";n?this.customConversationTitles[e]=n:delete this.customConversationTitles[e],this.sendWsMessage({type:"update_conversation_settings",conversationId:e,...s?{agentId:s}:{},title:n})},resolveMessageFileReferences(e){let t=this.activeSessionRoute,s=t?.agentId||this.currentAgent||null,n=t?.runtimeProvider==="yeaft"?It(this,t.sessionId,s):this.currentConversation,i=yt(t)&&s&&n&&this.workbenchRouteProtocolSupported===!0&&St(this,s,"file_reference_resolution")&&St(this,s,"file_editor")&&St(this,s,"workbench_session_routes"),o=[...new Set((Array.isArray(e)?e:[]).filter(u=>typeof u=="string"&&u.trim()).map(u=>u.trim()))].slice(0,32);if(!i||o.length===0)return null;let a=this.effectiveWorkDir||"",l=t?{runtimeProvider:t.runtimeProvider,agentId:t.agentId,sessionId:t.sessionId}:null,c=`file_refs_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`;return this.sendWsMessage({type:"resolve_file_references",requestId:c,references:o,agentId:s,conversationId:n,workDir:a,workbenchRoute:l})?c:null},requestMessageImagePreview(e){let t=this.activeSessionRoute,s=t?.agentId||this.currentAgent||null,n=t?.runtimeProvider==="yeaft"?It(this,t.sessionId,s):this.currentConversation,i=yt(t)&&s&&n&&this.workbenchRouteProtocolSupported===!0&&(s===this.currentAgent?this.hasCapability("file_editor")&&this.hasCapability("workbench_session_routes")&&this.hasCapability("response_image_preview"):St(this,s,"file_editor")&&St(this,s,"workbench_session_routes")&&St(this,s,"response_image_preview")),o=typeof e=="string"?e.trim():"";if(!i||!o)return null;let a=`message_image_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`;return this.sendWsMessage({type:"read_file",requestId:a,filePath:o,responseImagePreview:!0,agentId:s,conversationId:n,workDir:this.effectiveWorkDir||"",workbenchRoute:{runtimeProvider:t.runtimeProvider,agentId:t.agentId,sessionId:t.sessionId}})?a:null},openFileInExplorer(e,{hideTree:t=!1,line:s=null}={}){let n=this.activeSessionRoute,r=n?{runtimeProvider:n.runtimeProvider,agentId:n.agentId,sessionId:n.sessionId}:null,i=yt(r),o=this.effectiveWorkDir||"",a=Tn(i,o),l=r?.agentId||this.currentAgent||null,c=r?.runtimeProvider==="yeaft"?It(this,r.sessionId,l):this.currentConversation,d=this.workbenchRouteProtocolSupported===!0&&St(this,l,"file_editor")&&St(this,l,"workbench_session_routes");if(!l||!c||!d)return!1;let u=typeof e=="string"?e.trim():"";if(!u)return!1;let g=this.workbenchExpanded;this.openWorkbench(),this.workbenchMaximized=!1,this.rememberWorkbenchPanelState();let p=()=>{let f=yt(this.activeSessionRoute),m=this.effectiveWorkDir||"";f!==i||m!==o||Tn(f,m)!==a||window.dispatchEvent(new CustomEvent("open-file-in-explorer",{detail:{filePath:u,agentId:l,conversationId:c,workDir:o,workbenchRoute:r,workbenchRouteKey:i,workspaceGeneration:a,hideTree:!!t,line:Number.isFinite(s)&&s>0?s:null}}))};return g?p():Vue.nextTick(p),!0},logout(){Ge().logout(),this.authenticated=!1,this.sessionKey=null,this.agents=[],this.currentAgent=null,this.currentAgentInfo=null,this.yeaftStatusByAgent={},this._yeaftRetiredCatalogEpochsByAgent={},this.conversations=[],this.activeConversations=[],this.messagesMap={},this.conversationTitles={},this.customConversationTitles={},this.processingConversations={},this.executionStatusMap={},this.workbenchExpanded=!1,this.workbenchMaximized=!1,this.workbenchPanelStateByRoute={},this.subagents={},this.activeSubagentId=null,this.activeRightPanel=null,this.pinnedSessions=[],this.clearWorkCenterBrowserState(),this.ws&&this.ws.close()}}})});function Vl(e,t){!e||typeof e.handleYeaftOutput!="function"||!t||e.handleYeaftOutput({event:t})}function ow(e){let t=String(e||""),s=2166136261;for(let n=0;n<t.length;n++)s^=t.charCodeAt(n),s=Math.imul(s,16777619)>>>0;return s>>>0}function Bl(e){if(!e)return Ks[0];let t=String(e).toLowerCase();return iw[t]||Ks[ow(t)%Ks.length]}function aw(e){return Bl(e).background}function lw(e){return Bl(e).foreground}function Hl(){let e=typeof window<"u"&&window.Pinia&&window.Pinia.useChatStore?window.Pinia.useChatStore():null;return e&&typeof e.locale=="string"?e.locale:typeof localStorage<"u"&&localStorage.getItem("locale")||""}function cw(e,t=""){return e?String(t||"").startsWith("zh")?e.descriptionZh||e.roleZh||e.description||e.role||"":e.description||e.role||e.descriptionZh||e.roleZh||"":""}var rw,Ks,iw,iA,us,sr=B(()=>{({defineStore:rw}=Pinia);Ks=[{key:"rat",label:"Rat",glyph:"R",background:"var(--vp-avatar-rat-bg)",foreground:"var(--vp-avatar-rat-fg)"},{key:"ox",label:"Ox",glyph:"O",background:"var(--vp-avatar-ox-bg)",foreground:"var(--vp-avatar-ox-fg)"},{key:"tiger",label:"Tiger",glyph:"T",background:"var(--vp-avatar-tiger-bg)",foreground:"var(--vp-avatar-tiger-fg)"},{key:"rabbit",label:"Rabbit",glyph:"B",background:"var(--vp-avatar-rabbit-bg)",foreground:"var(--vp-avatar-rabbit-fg)"},{key:"dragon",label:"Dragon",glyph:"D",background:"var(--vp-avatar-dragon-bg)",foreground:"var(--vp-avatar-dragon-fg)"},{key:"snake",label:"Snake",glyph:"S",background:"var(--vp-avatar-snake-bg)",foreground:"var(--vp-avatar-snake-fg)"},{key:"horse",label:"Horse",glyph:"H",background:"var(--vp-avatar-horse-bg)",foreground:"var(--vp-avatar-horse-fg)"},{key:"goat",label:"Goat",glyph:"G",background:"var(--vp-avatar-goat-bg)",foreground:"var(--vp-avatar-goat-fg)"},{key:"monkey",label:"Monkey",glyph:"M",background:"var(--vp-avatar-monkey-bg)",foreground:"var(--vp-avatar-monkey-fg)"},{key:"rooster",label:"Rooster",glyph:"K",background:"var(--vp-avatar-rooster-bg)",foreground:"var(--vp-avatar-rooster-fg)"},{key:"dog",label:"Dog",glyph:"D",background:"var(--vp-avatar-dog-bg)",foreground:"var(--vp-avatar-dog-fg)"},{key:"pig",label:"Pig",glyph:"P",background:"var(--vp-avatar-pig-bg)",foreground:"var(--vp-avatar-pig-fg)"}],iw=Object.freeze({steve:Ks[8],ada:Ks[3],linus:Ks[0],martin:Ks[4]}),iA=Ks.map(e=>e.background);us=rw("vp",{state:()=>({vps:{},vpOrder:[],emptyLibrary:!1,lastSnapshotAt:0,snapshotStatus:"idle",snapshotAgentId:null,snapshotRequestId:null,snapshotError:"",lastVpSnapshotAgentId:null,lastChange:null,dreamStatus:{},groupDreamStatus:{}}),getters:{vpList(e){return e.vpOrder.map(t=>e.vps[t]).filter(Boolean)},vpCount(e){return e.vpOrder.length},vpById:e=>t=>e.vps[t]||null,vpLabel:e=>t=>{let s=e.vps[t];return s?Hl().startsWith("zh")&&s.displayNameZh?s.displayNameZh:s.displayName||s.vpId||t:t},vpDescription:e=>t=>cw(e.vps[t],Hl()),vpInitial:e=>t=>{let s=e.vps[t],n=Hl().startsWith("zh"),r=s&&(s.avatar||n&&s.displayNameZh||s.displayName||s.vpId)||t||"?";return String(r).charAt(0).toUpperCase()||"?"},vpColor:e=>t=>{let s=e.vps[t];return s&&s.color?s.color:aw(t)},vpTextColor:()=>e=>lw(e),vpAvatarMotif:()=>e=>Bl(e),dreamStatusFor:e=>t=>e.dreamStatus[t]||{status:"idle",lastRunAt:null,lastResult:null,lastError:null},groupDreamStatusFor:e=>t=>e.groupDreamStatus[t]||{status:"idle",lastRunAt:null,lastResult:null,lastError:null}},actions:{applySnapshot(e,t=null,s=null){let n=this.snapshotAgentId||null;if(n&&t&&t!==n||s&&this.snapshotRequestId&&s!==this.snapshotRequestId)return!1;let r=e&&Array.isArray(e.vps)?e.vps:[];return this._setActiveSnapshot({vps:r,emptyLibrary:!!(e&&e.emptyLibrary),agentId:t||n||null,requestId:s||this.snapshotRequestId||null,receivedAt:Date.now()}),!0},beginSnapshot(e,t){this.vps={},this.vpOrder=[],this.emptyLibrary=!1,this.lastVpSnapshotAgentId=null,this.snapshotStatus="loading",this.snapshotAgentId=e||null,this.snapshotRequestId=t||null,this.snapshotError=""},failSnapshot(e,t,s=""){return!this.snapshotRequestId||!t||t!==this.snapshotRequestId||e&&this.snapshotAgentId&&e!==this.snapshotAgentId?!1:(this.snapshotStatus="error",this.snapshotAgentId=e||this.snapshotAgentId||null,this.snapshotRequestId=t||this.snapshotRequestId||null,this.snapshotError=String(s||"VP library request failed"),!0)},_setActiveSnapshot({vps:e,emptyLibrary:t,agentId:s,requestId:n,receivedAt:r}){this.vps={},this.vpOrder=[];for(let i of e||[])this._upsertInternal(i);this.emptyLibrary=!!t,this.lastSnapshotAt=r||Date.now(),this.lastVpSnapshotAgentId=s||null,this.snapshotStatus="ready",this.snapshotAgentId=s||null,this.snapshotRequestId=n||null,this.snapshotError=""},upsert(e,t=null,s=null){return s&&this.snapshotAgentId&&s!==this.snapshotAgentId?!1:(this._upsertInternal(e),e&&e.vpId&&(this.lastChange={vpId:e.vpId,kind:"updated",reason:t||null,at:Date.now()}),!0)},remove(e,t=null,s=null){return s&&this.snapshotAgentId&&s!==this.snapshotAgentId||!e?!1:(delete this.vps[e],this.vpOrder=this.vpOrder.filter(n=>n!==e),this.lastChange={vpId:e,kind:"removed",reason:t||"file.removed",at:Date.now()},!0)},_upsertInternal(e){if(!e||!e.vpId)return;let t=!!this.vps[e.vpId];this.vps[e.vpId]={...this.vps[e.vpId]||{},...e},t||this.vpOrder.push(e.vpId),this.emptyLibrary&&(this.emptyLibrary=!1)},triggerDream(e){if(!e)return;this.dreamStatus={...this.dreamStatus,[e]:{...this.dreamStatus[e]||{},status:"running",lastError:null}};let t=window.Pinia&&window.Pinia.useChatStore?window.Pinia.useChatStore():null;t&&typeof t.sendWsMessage=="function"&&t.sendWsMessage({type:"yeaft_dream_trigger",vpId:e})},triggerGroupDream(e,t={}){if(!e)return;this.groupDreamStatus={...this.groupDreamStatus,[e]:{...this.groupDreamStatus[e]||{},status:"running",lastError:null}};let s=window.Pinia&&window.Pinia.useChatStore?window.Pinia.useChatStore():null,n=Date.now();if(Vl(s,{type:"dream_progress",phase:"start",groupId:e,manual:!0,trigger:"manual",source:"header-button",ts:n}),!s||typeof s.sendWsMessage!="function"){Vl(s,{type:"yeaft_dream_result",groupId:e,success:!1,skipped:!0,skippedReason:"chat-store-unavailable",trigger:"manual",error:null});return}let r={type:"yeaft_dream_trigger",sessionId:e},i=t&&t.agentId?t.agentId:typeof s.agentIdForSession=="function"?s.agentIdForSession(e):s.currentAgent;i&&(r.agentId=i),s.sendWsMessage(r)===!1&&Vl(s,{type:"yeaft_dream_result",groupId:e,success:!1,skipped:!0,skippedReason:"websocket-not-open",trigger:"manual",error:null})},applyDreamStatus(e){if(!e)return;let t=e.sessionId;if(t){this.groupDreamStatus={...this.groupDreamStatus,[t]:{...this.groupDreamStatus[t]||{},status:e.status==="running"?"running":e.status||"idle"}};return}if(!e.vpId)return;let s=e.vpId;this.dreamStatus={...this.dreamStatus,[s]:{...this.dreamStatus[s]||{},status:e.status==="running"?"running":e.status||"idle"}}},applyDreamResult(e){if(!e)return;let t=!!e.success,s=!!e.skipped,n={mergedCount:e.mergedCount??null,extractedCount:e.extractedCount??null,entriesCreated:typeof e.entriesCreated=="number"?e.entriesCreated:e.mergedCount??e.extractedCount??0,skipped:s,skippedReason:e.skippedReason||null,sessionsProcessed:typeof e.sessionsProcessed=="number"?e.sessionsProcessed:null,sessionsSkipped:typeof e.sessionsSkipped=="number"?e.sessionsSkipped:null,targetsApplied:typeof e.targetsApplied=="number"?e.targetsApplied:null,durationMs:typeof e.durationMs=="number"?e.durationMs:null,llmCallCount:typeof e.llmCallCount=="number"?e.llmCallCount:0,inputTokens:typeof e.inputTokens=="number"?e.inputTokens:0,outputTokens:typeof e.outputTokens=="number"?e.outputTokens:0,totalTokens:typeof e.totalTokens=="number"?e.totalTokens:0,metrics:e.metrics||null,passBreakdown:e.passBreakdown||e.metrics?.passBreakdown||null,targetErrors:Array.isArray(e.targetErrors)?e.targetErrors:[]},r=t||s?null:e.error||null,i=s?"skipped":t?"success":"error",o=e.sessionId;if(o){this.groupDreamStatus={...this.groupDreamStatus,[o]:{status:i,lastRunAt:Date.now(),lastResult:n,lastError:r}};return}if(!e.vpId)return;let a=e.vpId;this.dreamStatus={...this.dreamStatus,[a]:{status:i,lastRunAt:Date.now(),lastResult:n,lastError:r}}}}})});function Nl(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"&&e){let t=Date.parse(e);if(Number.isFinite(t))return t}return 0}function mo(e){return!e||typeof e!="object"?0:Nl(e.lastMessageAt)||Nl(e.updatedAt)||Nl(e.createdAt)||0}function Wl(e,t){let s=mo(t)-mo(e);return s!==0?s:String(e?.id||"").localeCompare(String(t?.id||""))}function mg(e){return[...Array.isArray(e)?e:[]].sort(Wl)}var vo=B(()=>{});function vg(){try{if(typeof localStorage>"u")return{};let e=JSON.parse(localStorage.getItem(kg)||"{}");return e&&typeof e=="object"?e:{}}catch{return{}}}function dw(e){try{typeof localStorage<"u"&&localStorage.setItem(kg,JSON.stringify(e&&typeof e=="object"?e:{}))}catch{}}function yg(){try{return typeof localStorage>"u"?[]:ri(JSON.parse(localStorage.getItem(Sg)||"[]"))}catch{return[]}}function uw(e){try{typeof localStorage<"u"&&localStorage.setItem(Sg,JSON.stringify(ri(e)))}catch{}}function Ig(e,t){return`${e||""}${t||""}`}function Ps(e){return e&&e.agentId&&e.id?Ig(e.agentId,e.id):""}function ps(e,t){return t?e?Ig(e,t):String(t):""}function pw(e){return typeof e=="string"?e:String(e||"")}function Bt(e,t,s=null){let n=pw(t);if(!n)return"";let r=ps(s,n),i=r?e.sessions[r]:null;if(i&&(s||i.agentId||e.inventoryIdentityMode==="legacy-bare"))return r;if(s){let c=e.sessions[n];return e.inventoryIdentityMode==="legacy-bare"&&c&&!c.agentId?n:""}let o=e.sessions[n];if(o){if(o.agentId||e.inventoryIdentityMode==="legacy-bare")return n;let c=e.activeSessionKey?e.sessions[e.activeSessionKey]:null;return c?.agentId&&c.id===n?e.activeSessionKey:""}if(e.activeSessionKey&&e.sessions[e.activeSessionKey]?.id===n)return e.activeSessionKey;let a=e.sessionOrder.filter(c=>e.sessions[c]?.id===n),l=ii();if(l?.currentAgent){let c=a.find(d=>e.sessions[d]?.agentId===l.currentAgent);if(c)return c}return a[0]||""}function jl(e,t,s=null){return Bt(e,t,s)||""}function Ul(e){if(e.inventoryIdentityMode==="legacy-bare"){let t=e.activeSessionKey?e.sessions[e.activeSessionKey]:null,s=t&&!t.agentId?t:e.activeSessionId?e.sessions[e.activeSessionId]:null;e._retiredBareActiveSessionId=s&&!s.agentId&&s.id||null,e.sessionOrder=e.sessionOrder.filter(n=>e.sessions[n]?.agentId),e._retiredBareActiveSessionId&&(e.activeSessionId=null,e.activeSessionKey=null)}e.inventoryIdentityMode="agent-scoped"}function gw(e){let t=e._preferredExactSessionIdentity||null;if(!t)return!1;e._preferredExactSessionIdentity=null;let s=e.sessions[t.key]||null,n=ii(),r=s?.id===t.sessionId&&s.agentId===t.agentId,i=n?.currentView!=="yeaft"||typeof n.setActiveSessionFilter=="function";if(r&&i){if(e.activeSessionId=t.sessionId,e.activeSessionKey=t.key,n?.currentView==="yeaft")n.setActiveSessionFilter(t.sessionId,{agentId:t.agentId,force:!0});else if(n){n.yeaftActiveSessionFilter=t.sessionId,n.yeaftSessionAgentById={...n.yeaftSessionAgentById||{},[t.sessionId]:t.agentId};try{localStorage.setItem("lastViewedYeaftSession",t.key)}catch{}}return!0}if(e.activeSessionId=null,e.activeSessionKey=null,n?.yeaftActiveSessionFilter===t.sessionId&&(n.yeaftActiveSessionFilter=null),n?.yeaftSessionAgentById?.[t.sessionId]===t.agentId){let o={...n.yeaftSessionAgentById};delete o[t.sessionId],n.yeaftSessionAgentById=o}try{let o=Gr(localStorage.getItem("lastViewedYeaftSession")||"");o.agentId===t.agentId&&o.sessionId===t.sessionId&&localStorage.removeItem("lastViewedYeaftSession")}catch{}return!0}function yo(e){let t=e._retiredBareActiveSessionId||null;if(!t)return!1;let s=ii();if(e.inventoryIdentityMode==="legacy-bare"){let r=e.sessions[t];return e._retiredBareActiveSessionId=null,!r||r.agentId?!1:(e.activeSessionId=t,e.activeSessionKey=t,s?.currentView==="yeaft"&&typeof s.setActiveSessionFilter=="function"?s.setActiveSessionFilter(t,{force:!0}):s&&(s.yeaftActiveSessionFilter=t),!0)}let n=e.sessionOrder.filter(r=>{let i=e.sessions[r];return i?.agentId&&i.id===t});if(n.length===1){let r=n[0],i=e.activeSessionId===t&&e.activeSessionKey===r,o=e.sessions[r]?.agentId||null;return e.activeSessionId=t,e.activeSessionKey=r,i||(s?.currentView==="yeaft"&&typeof s.setActiveSessionFilter=="function"?(s.setActiveSessionFilter(t,{agentId:o,force:!0}),e._retiredBareActiveSessionId=t):s&&(s.yeaftActiveSessionFilter=t)),!0}e.activeSessionId=null,e.activeSessionKey=null,s?.yeaftActiveSessionFilter===t&&(s.yeaftActiveSessionFilter=null);try{let r=localStorage.getItem("lastViewedYeaftSession")||"";Gr(r).sessionId===t&&localStorage.removeItem("lastViewedYeaftSession")}catch{}return!0}function ri(e){let t=[],s=new Set;for(let n of Array.isArray(e)?e:[]){let r=typeof n=="string"?n:String(n||"");!r||s.has(r)||(s.add(r),t.push(r))}return t}function Kl(e,t){let s=ri(e),n=new Set(s),r=ri(t).filter(o=>n.has(o)),i=new Set(r);return[...r,...s.filter(o=>!i.has(o))]}function bo(e,t=!1){return!e||typeof e!="object"?!!t:Object.prototype.hasOwnProperty.call(e,"pinned")?e.pinned===!0:Object.prototype.hasOwnProperty.call(e,"isPinned")?e.isPinned===!0:!!t}function bg(e){return!e||typeof e!="object"?!1:e.running===!0||e.active===!0||e.isActive===!0||e.isRunning===!0}function wg(e){if(!e||typeof e!="object")return 0;let t=e.latestActivityAt||e.lastActivityAt||e.lastMessageAt||e.updatedAt||0;if(typeof t=="number"&&Number.isFinite(t))return t;if(typeof t=="string"&&t){let s=Date.parse(t);return Number.isFinite(s)?s:0}return 0}function ii(){try{if(typeof window<"u"&&window.Pinia&&typeof window.Pinia.useChatStore=="function")return window.Pinia.useChatStore()}catch{}return null}var kg,Sg,fw,Cg,Ag=B(()=>{vo();io();kg="yeaft-session-order-by-agent",Sg="yeaft-session-order-global";({defineStore:fw}=Pinia);Cg=fw("sessions",{state:()=>({sessions:{},sessionOrder:[],activeSessionId:null,activeSessionKey:null,inventoryIdentityMode:"empty",_retiredBareActiveSessionId:null,_preferredExactSessionIdentity:null,lastSnapshotAt:0,lastCrudResult:null,pending:{}}),getters:{sessionList(e){let t=e.sessionOrder.map(d=>e.sessions[d]).filter(Boolean),s=ii(),n=s&&Array.isArray(s.pinnedSessions)?new Set(s.pinnedSessions):new Set;for(let d of t)d&&d.id&&d.pinned&&n.add(d.id);let r=[],i=[];for(let d of t)d.pinned||!d.agentId&&n.has(d.id)?r.push(d):i.push(d);let o=d=>[...d].sort((u,g)=>{let p=Number.isFinite(u?.sortOrder)?u.sortOrder:Number.MAX_SAFE_INTEGER,f=Number.isFinite(g?.sortOrder)?g.sortOrder:Number.MAX_SAFE_INTEGER;return p!==f?p-f:Wl(u,g)}),a=[...o(r),...o(i)],l=yg();if(l.length===0)return a;let c=new Map(l.map((d,u)=>[d,u]));return a.sort((d,u)=>{let g=c.has(Ps(d))?c.get(Ps(d)):Number.MAX_SAFE_INTEGER,p=c.has(Ps(u))?c.get(Ps(u)):Number.MAX_SAFE_INTEGER;return g!==p?g-p:0})},sessionCount(e){return e.sessionOrder.length},sessionById:e=>(t,s=null)=>{let n=Bt(e,t,s);return n&&e.sessions[n]||null},activeSession(e){return e.activeSessionKey&&e.sessions[e.activeSessionKey]||null},hasLoadedSnapshot(e){return e.lastSnapshotAt>0},isEmpty(e){return e.sessionOrder.length===0},activeNeedsInvite(e){let t=e.activeSessionKey?e.sessions[e.activeSessionKey]:null;return t?!t.defaultVpId&&(!Array.isArray(t.roster)||t.roster.length===0):!1}},actions:{applySnapshot(e,t=null,{deferActivation:s=!1}={}){let n=Array.isArray(e)?e:[],r=!1;if(t){Ul(this);let o={...this.sessions},a=new Set;for(let p of n){if(!p||!p.id)continue;let f=ps(t,p.id);a.add(f),o[f]=this._normalize(p,t,bo(this.sessions[f]))}for(let p of this.sessionOrder){let f=this.sessions[p];f&&f.agentId===t&&!a.has(p)&&delete o[p]}let l=this.sessionOrder.filter(p=>o[p]),c=new Set(l),d=[];for(let p of n){if(!p||!p.id)continue;let f=ps(t,p.id);o[f]&&!c.has(f)&&d.push(f)}this.sessions=o;let u=[...l,...d],g=yg();if(g.length>0){let p=new Map(u.map(y=>[Ps(o[y]),y]).filter(([y])=>y)),f=g.map(y=>p.get(y)).filter(Boolean),m=new Set(f);u=[...f,...u.filter(y=>!m.has(y))];let v=new Map(g.map((y,h)=>[y,h]));for(let y of u){let h=Ps(o[y]);h&&v.has(h)&&(o[y]={...o[y],sortOrder:v.get(h)})}}if(t&&g.length===0){let p=vg(),f=ri(p[t]);if(f.length>0){let m=f.map(b=>ps(t,b)),v=new Set(m),y=Kl(u.filter(b=>o[b]?.agentId===t),m),h=this.sessionOrder.some(b=>o[b]?.agentId===t),k=0;h?u=this.sessionOrder.filter(b=>o[b]).map(b=>o[b]?.agentId===t?y[k++]:b).concat(y.slice(k)):u=u.map(b=>o[b]?.agentId===t?y[k++]:b);let S=new Map(m.map((b,w)=>[b,w]));for(let b of y)o[b]&&v.has(b)&&(o[b]={...o[b],sortOrder:S.get(b)})}}this.sessionOrder=u}else{if(this.inventoryIdentityMode==="agent-scoped")return;if(Object.values(this.sessions).some(c=>c&&c.agentId)){this.inventoryIdentityMode="agent-scoped";return}let a={},l=[];for(let c of n){if(!c||!c.id)continue;let d=ps(null,c.id);a[d]=this._normalize(c,null,bo(this.sessions[d])),l.push(d)}this.sessions=a,this.sessionOrder=l,this.inventoryIdentityMode="legacy-bare"}s||(r=gw(this)||yo(this)),this.lastSnapshotAt=Date.now();let i=ii();if(i&&t){let o={...i.yeaftSessionAgentById||{}};for(let a of n)a&&a.id&&!o[a.id]&&(o[a.id]=t);i.yeaftSessionAgentById=o}if(!s&&!r){let o=null;try{o=localStorage.getItem("lastViewedYeaftSession")||null}catch{}let l=(o?this.sessions[o]:null)?o:o?Bt(this,o,t):"",c=l?this.sessions[l]:null,d=c&&(!t||c.agentId===t),u=this.sessionOrder.filter(k=>this.sessions[k]&&(!t||this.sessions[k].agentId===t)&&this.sessions[k].running).sort((k,S)=>wg(this.sessions[S])-wg(this.sessions[k]))[0]||null,g=u?this.sessions[u]?.id:null,p=this.sessionList[0]||null,f=p?.id||null,m=f?Bt(this,f,p?.raw?.agentId||null):"",v=g||(d?c.id:null)||f,y=u||(d?l:"")||m||jl(this,v,t),h=this.activeSessionKey?this.sessions[this.activeSessionKey]?.agentId:null;if(this.activeSessionId&&!Bt(this,this.activeSessionId,h)?(this.activeSessionId=v,this.activeSessionKey=y||null):!this.activeSessionId&&this.sessionOrder.length>0&&!this._retiredBareActiveSessionId?(this.activeSessionId=v,this.activeSessionKey=y||null):this.activeSessionId&&(this.activeSessionKey=jl(this,this.activeSessionId,h)||this.activeSessionKey),i&&!this._retiredBareActiveSessionId){let k=this.activeSessionId||v,S=null;if((i.yeaftActiveSessionFilter&&!Bt(this,i.yeaftActiveSessionFilter)||!i.yeaftActiveSessionFilter&&k)&&(S=k),S){let b=jl(this,S),w=b&&this.sessions[b]?.agentId||null;i.currentView==="yeaft"&&typeof i.setActiveSessionFilter=="function"?i.setActiveSessionFilter(S,{agentId:w,force:!0}):i.yeaftActiveSessionFilter=S,this.activeSessionKey=b||this.activeSessionKey}}}if(i&&typeof i.applyServerPinSnapshot=="function"){let o=new Set;for(let l of n){if(!l||!l.id)continue;let c=ps(t,l.id),d=this.sessions[c];d&&d.pinned&&o.add(l.id)}let a=l=>{let c=Bt(this,l,t),d=c?this.sessions[c]:null;return d?d.agentId===t:!1};i.applyServerPinSnapshot(t,o,a)}},applyRosterChange(e,t=null){if(!e)return;let s=e.sessionId||e.groupId;if(!s)return;let n=t||e.agentId||null;if(n)Ul(this);else if(this.inventoryIdentityMode!=="legacy-bare")return;let r=Bt(this,s,n)||ps(n,s),i=this.sessions[r];if(!i){let o=this._normalize({id:s,name:e.name||s,roster:Array.isArray(e.roster)?e.roster:[],defaultVpId:e.defaultVpId||null},n);this.sessions[r]=o,this.sessionOrder.push(r),yo(this);return}this.sessions[r]={...i,name:e.name||i.name,roster:Array.isArray(e.roster)?e.roster.slice():i.roster,defaultVpId:e.defaultVpId!=null?e.defaultVpId:i.defaultVpId,announcement:typeof e.announcement=="string"?e.announcement:i.announcement},yo(this)},applyCrudResult(e,t=null,{activate:s=!0}={}){if(!e)return;this.lastCrudResult={...e,at:Date.now()},e.requestId&&this.pending[e.requestId]&&delete this.pending[e.requestId];let n=e.session||e.group||null,r=t||e.agentId||n?.agentId||null;e.ok&&e.op==="list"&&Array.isArray(e.sessions)&&this.applySnapshot(e.sessions,r),e.ok&&(e.op==="create"||e.op==="copy"||e.op==="restore")&&n&&n.id&&this.applySnapshotUpsert(n,r)&&s&&this.setActive(n.id,r),e.ok&&(e.op==="rename"||e.op==="update")&&n&&n.id&&this.applySnapshotUpsert(n,r);let i=e.sessionId||e.groupId,o=this.inventoryIdentityMode==="legacy-bare",a=i&&(r||o)?Bt(this,i,r):"";if(e.ok&&(e.op==="archive"||e.op==="delete")&&i&&a&&(delete this.sessions[a],this.sessionOrder=this.sessionOrder.filter(l=>l!==a),(this.activeSessionKey===a||o&&this.activeSessionId===i)&&(this.activeSessionKey=this.sessionOrder[0]||null,this.activeSessionId=this.activeSessionKey&&this.sessions[this.activeSessionKey]?.id||null)),e.ok&&e.op==="update_config"&&i){let l=a?this.sessions[a]:null;l&&(this.sessions[a]={...l,config:e.config&&typeof e.config=="object"?{...e.config}:{}})}},applySnapshotUpsert(e,t=null){if(!e||!e.id)return"";let s=t||e.agentId||null;if(s)Ul(this);else if(this.inventoryIdentityMode!=="legacy-bare")return"";let n=Bt(this,e.id,s)||ps(s,e.id),r=!!this.sessions[n],i=this.sessions[n]||{};return this.sessions[n]={...i,...this._normalize(e,s,bo(i))},r||this.sessionOrder.push(n),yo(this),n},setActive(e,t=null){let s=Bt(this,e,t);e&&s&&this.sessions[s]?(this.activeSessionId=e,this.activeSessionKey=s,this._retiredBareActiveSessionId=null):(this.activeSessionId=null,this.activeSessionKey=null)},reorderSessionsForAgent(e,t){if(!e)return[];let s=this.sessionOrder.filter(l=>this.sessions[l]?.agentId===e),n=Kl(s,t.map(l=>ps(e,l)));if(n.length===0)return[];let r=new Map(n.map((l,c)=>[l,c])),i=0;this.sessionOrder=this.sessionOrder.map(l=>this.sessions[l]?.agentId===e?n[i++]:l);for(let l of n)this.sessions[l]={...this.sessions[l],sortOrder:r.get(l)};let o=vg(),a=n.map(l=>this.sessions[l]?.id).filter(Boolean);return o[e]=a,dw(o),a},reorderSessionsGlobally(e){let t=this.sessionOrder.map(a=>Ps(this.sessions[a])).filter(Boolean),s=Kl(t,e);if(s.length===0)return[];let n=new Map(this.sessionOrder.map(a=>[Ps(this.sessions[a]),a]).filter(([a])=>a)),r=s.map(a=>n.get(a)).filter(Boolean),i=new Set(r);this.sessionOrder=[...r,...this.sessionOrder.filter(a=>!i.has(a))];let o=new Map(s.map((a,l)=>[a,l]));for(let a of this.sessionOrder){let l=Ps(this.sessions[a]);l&&o.has(l)&&(this.sessions[a]={...this.sessions[a],sortOrder:o.get(l)})}return uw(s),s.map(a=>{let l=n.get(a),c=l?this.sessions[l]:null;return c?{agentId:c.agentId,sessionId:c.id}:null}).filter(Boolean)},applyPinState(e,t,s=null){if(!s&&this.inventoryIdentityMode!=="legacy-bare")return;let n=Bt(this,e,s);!e||!n||!this.sessions[n]||(this.sessions[n]={...this.sessions[n],pinned:!!t})},markPending(e,t){e&&(this.pending[e]=t)},clearLastResult(){this.lastCrudResult=null},resetInventory(){this.sessions={},this.sessionOrder=[],this.activeSessionId=null,this.activeSessionKey=null,this.inventoryIdentityMode="empty",this._retiredBareActiveSessionId=null,this._preferredExactSessionIdentity=null,this.lastSnapshotAt=0},beginInventoryCommit(e=null,t=null){if(this.resetInventory(),e&&t){let s=ps(t,e);this.activeSessionId=e,this.activeSessionKey=s,this._preferredExactSessionIdentity={sessionId:e,agentId:t,key:s}}else e&&(this._retiredBareActiveSessionId=e)},_normalize(e,t=null,s=!1){return{id:e.id,name:e.name||e.id,roster:Array.isArray(e.roster)?e.roster.slice():[],defaultVpId:e.defaultVpId||null,announcement:typeof e.announcement=="string"?e.announcement:"",config:e.config&&typeof e.config=="object"?{...e.config}:{},workDir:typeof e.workDir=="string"?e.workDir:"",createdAt:e.createdAt||null,updatedAt:e.updatedAt||null,lastMessageAt:e.lastMessageAt||null,running:bg(e),active:bg(e),runningVpCount:Number.isFinite(Number(e.runningVpCount))?Number(e.runningVpCount):0,latestActivityAt:e.latestActivityAt||e.lastActivityAt||e.lastMessageAt||null,agentId:t||e.agentId||null,pinned:bo(e,s),sortOrder:Number.isFinite(e.sortOrder)?e.sortOrder:null}}}})});function wo(){return globalThis.crypto?.randomUUID?.()||`browser-${Date.now()}-${Math.random().toString(16).slice(2)}`}function Nt(e,t){return`${String(e||"")}\0${String(t||"")}`}function xg(e,t,s,n){return`${Nt(e,t)}\0${String(s||"")}\0${String(n||"")}`}function zl(e,t="Browser Runtime request failed"){return e?.safeError||e?.code||t}function Yl(e){return globalThis.Vue?.markRaw?.(e)||e}var hw,mw,vw,yw,bw,ww,kw,ko,Gl=B(()=>{({defineStore:hw}=Pinia),mw=3e4,vw=60*6e4,yw=2e4,bw=5e3,ww=60*6e4,kw=256;ko=hw("browser",{state:()=>({sessions:{},pending:{},peers:{},cancelledPeers:{},errors:{},errorCodes:{},peerDiagnostics:{},runtimeStatus:{},installProgress:{},protocolSupported:null,connectionEpoch:0,lastError:null,_cancelledPeerCleanupTimer:null,_messageListenerInstalled:!1}),actions:{chatStore(){return window.Pinia?.useChatStore?.()||null},installMessageListener(){if(this._messageListenerInstalled||typeof window>"u")return;this._messageListenerInstalled=!0;let e=this.chatStore();this.protocolSupported=e?.browserRuntimeProtocolSupported??null,window.addEventListener("browser-runtime-message",t=>this.handleMessage(t.detail)),window.addEventListener("browser-runtime-transport-reset",()=>this.handleTransportReset())},send(e){if(!this.chatStore()?.sendWsMessage?.(e))throw new Error("Browser Runtime transport unavailable")},beginRequest(e,t,s=mw){let n=wo();return new Promise((r,i)=>{let o=setTimeout(()=>{delete this.pending[n],i(new Error(`${e} timed out`))},s);this.pending[n]={type:e,resolve:r,reject:i,timer:o,payload:t};try{this.send({type:e,requestId:n,...t})}catch(a){clearTimeout(o),delete this.pending[n],i(a)}})},completeRequest(e,t,s=null){let n=e?this.pending[e]:null;return n?(clearTimeout(n.timer),delete this.pending[e],s?n.reject(s):n.resolve(t),!0):!1},clearCancelledPeers(){clearTimeout(this._cancelledPeerCleanupTimer),this._cancelledPeerCleanupTimer=null,this.cancelledPeers={}},pruneCancelledPeers(e=Date.now()){clearTimeout(this._cancelledPeerCleanupTimer),this._cancelledPeerCleanupTimer=null;for(let[s,n]of Object.entries(this.cancelledPeers))Number(n.expiresAt)<=e&&delete this.cancelledPeers[s];let t=Math.min(...Object.values(this.cancelledPeers).map(s=>Number(s.expiresAt)).filter(Number.isFinite));Number.isFinite(t)&&(this._cancelledPeerCleanupTimer=setTimeout(()=>this.pruneCancelledPeers(),Math.max(1,t-Date.now())))},rememberCancelledPeer(e){let t=Date.now();for(this.pruneCancelledPeers(t);Object.keys(this.cancelledPeers).length>=kw;)delete this.cancelledPeers[Object.keys(this.cancelledPeers)[0]];this.cancelledPeers[xg(e.agentId,e.browserSessionId,e.requestId,e.connectionGeneration)]={agentId:e.agentId,browserSessionId:e.browserSessionId,requestId:e.requestId,connectionGeneration:e.connectionGeneration,expiresAt:t+ww},this.pruneCancelledPeers(t)},takeCancelledPeer(e){let t=xg(e.agentId,e.browserSessionId,e.requestId,e.connectionGeneration),s=this.cancelledPeers[t];return!s||(delete this.cancelledPeers[t],this.pruneCancelledPeers(),Number(s.expiresAt)<=Date.now())?null:s},async getRuntimeStatus(e){let t=await this.beginRequest("browser_runtime_status",{agentId:e});return this.runtimeStatus[e]=t,t},async installRuntime(e,t){let s=await this.beginRequest("browser_runtime_install",{agentId:e,confirmedBuildId:t?.buildId,confirmedDownloadBytes:Number(t?.downloadBytes)||0},vw);return this.runtimeStatus[e]=s,delete this.installProgress[e],s},async enableRuntime(e){let t=await this.beginRequest("browser_runtime_enable",{agentId:e},6e4);return this.runtimeStatus[e]=t,t},async setupRuntime(e,t){return t?.installed?this.enableRuntime(e):this.installRuntime(e,t)},async createSession({agentId:e,sourceRef:t=null,initialUrl:s="about:blank",viewport:n=null,locale:r="en-US"}){let i=await this.beginRequest("browser_session_create",{agentId:e,sourceRef:t,options:{initialUrl:s,viewport:n||{width:1280,height:720,deviceScaleFactor:1},locale:r,capturePreference:"auto"}},45e3);return this.sessions[Nt(e,i.browserSessionId)]=i,i},async listSessions(e){let t=await this.beginRequest("browser_session_list",{agentId:e}),s=new Set((t.sessions||[]).map(n=>Nt(e,n.browserSessionId)));for(let n of Object.keys(this.sessions))n.startsWith(`${e}\0`)&&!s.has(n)&&delete this.sessions[n];for(let n of t.sessions||[])this.sessions[Nt(e,n.browserSessionId)]={...n,agentId:e};return t.sessions||[]},async closeSession(e,t,s){await this.beginRequest("browser_session_close",{agentId:e,browserSessionId:t,expectedRevision:s})},async attach({agentId:e,browserSessionId:t,videoElement:s}){if(!s)throw new Error("Browser video element required");let n=Nt(e,t);delete this.errors[n],delete this.errorCodes[n];let r=Number(this.connectionEpoch||0)+1;this.connectionEpoch=r;let i=wo(),o={localKey:n,agentId:e,browserSessionId:t,requestId:i,peerId:null,connectionGeneration:r,connection:null,videoElement:Yl(s),state:"preparing",remoteState:null,pendingOffer:null,pendingCandidates:[],answerPromise:null,channels:{},controlSeq:0,pointerSeq:0,iceServerCount:null,diagnostics:{connectionState:"new",iceConnectionState:"new",iceGatheringState:"new",candidateErrors:0,lastCandidateError:null},attachTimer:null,disconnectedTimer:null};return this.peers[n]=o,this.peerDiagnostics[n]=o.diagnostics,o.attachTimer=setTimeout(()=>{if(o.attachTimer=null,this.peers[n]!==o||o.connection?.connectionState==="connected")return;let a=o.iceServerCount===0?"browser_ice_servers_missing":o.diagnostics.iceConnectionState==="failed"?"browser_ice_connection_failed":"browser_peer_attach_timeout";this.failPeer(o,new Error(a),a)},yw),this.send({type:"browser_peer_attach",agentId:e,browserSessionId:t,requestId:i,connectionGeneration:r,role:"interactive",clientCapabilities:{codecs:["video/VP8"],maxWidth:1920,maxHeight:1080,maxFps:30}}),o},async preparePeer(e,t){if(this.peers[e.localKey]!==e||e.connectionGeneration!==t.connectionGeneration)return;if(e.connection){if(e.peerId===t.peerId)return;throw new Error("Browser peer identity changed during preparation")}e.peerId=t.peerId;let s=Array.isArray(t.iceServers)?t.iceServers:[];e.iceServerCount=s.length;let n=Yl(new RTCPeerConnection({iceServers:s,iceTransportPolicy:t.iceTransportPolicy==="relay"?"relay":"all"}));e.connection=n,e.diagnostics.iceConnectionState=n.iceConnectionState||"new",e.diagnostics.iceGatheringState=n.iceGatheringState||"new",e.state="prepared",n.ondatachannel=i=>{if(this.peers[e.localKey]!==e)return;let o=i.channel;if(!["browser.control.v1","browser.pointer.v1","browser.state.v1"].includes(o?.label)){o?.close?.();return}e.channels[o.label]=Yl(o),o.onclose=()=>{e.channels[o.label]===o&&delete e.channels[o.label]}},n.ontrack=i=>{this.peers[e.localKey]===e&&(e.videoElement.srcObject=i.streams[0]||new MediaStream([i.track]),e.videoElement.play().catch(()=>{}))},n.onicecandidate=i=>{if(this.peers[e.localKey]===e)try{this.send({type:"browser_peer_ice_candidate",agentId:e.agentId,browserSessionId:e.browserSessionId,peerId:e.peerId,connectionGeneration:e.connectionGeneration,candidate:i.candidate?i.candidate.toJSON():null})}catch{}},n.onicecandidateerror=i=>{this.peers[e.localKey]===e&&(e.diagnostics.candidateErrors+=1,e.diagnostics.lastCandidateError={address:typeof i.address=="string"?i.address:null,port:Number(i.port)||null,url:typeof i.url=="string"?i.url:null,errorCode:Number(i.errorCode)||null,errorText:typeof i.errorText=="string"?i.errorText.slice(0,256):null})},n.oniceconnectionstatechange=()=>{this.peers[e.localKey]===e&&(e.diagnostics.iceConnectionState=n.iceConnectionState||"new")},n.onicegatheringstatechange=()=>{this.peers[e.localKey]===e&&(e.diagnostics.iceGatheringState=n.iceGatheringState||"new")},n.onconnectionstatechange=()=>{if(this.peers[e.localKey]===e){if(e.state=n.connectionState,e.diagnostics.connectionState=n.connectionState||"new",e.diagnostics.iceConnectionState=n.iceConnectionState||"new",e.diagnostics.iceGatheringState=n.iceGatheringState||"new",n.connectionState==="connected"){clearTimeout(e.attachTimer),e.attachTimer=null,clearTimeout(e.disconnectedTimer),e.disconnectedTimer=null;return}if(n.connectionState==="disconnected"){e.disconnectedTimer||(e.disconnectedTimer=setTimeout(()=>{if(e.disconnectedTimer=null,this.peers[e.localKey]!==e||n.connectionState==="connected")return;let i=e.iceServerCount===0?"browser_ice_servers_missing":"browser_ice_connection_failed";this.failPeer(e,new Error(i),i)},bw));return}if(["failed","closed"].includes(n.connectionState)){let i=e.iceServerCount===0?"browser_ice_servers_missing":"browser_ice_connection_failed";this.failPeer(e,new Error(i),i)}}};let r=e.pendingOffer;e.pendingOffer=null,r&&await this.acceptOffer(e,r)},async acceptOffer(e,t){if(!(this.peers[e.localKey]!==e||e.connectionGeneration!==Number(t.connectionGeneration))){if(!e.connection){(!e.peerId||e.peerId===t.peerId)&&(e.pendingOffer||(e.pendingOffer=t));return}if(e.peerId===t.peerId){if(e.answerPromise)return e.answerPromise;e.answerPromise=(async()=>{if(await e.connection.setRemoteDescription(t.description),await e.connection.setLocalDescription(await e.connection.createAnswer()),this.peers[e.localKey]===e){this.send({type:"browser_peer_answer",agentId:e.agentId,browserSessionId:e.browserSessionId,peerId:e.peerId,connectionGeneration:e.connectionGeneration,description:e.connection.localDescription});for(let s of e.pendingCandidates.splice(0))await e.connection.addIceCandidate(s)}})();try{await e.answerPromise}finally{e.answerPromise=null}}}},async acceptCandidate(e,t){if(!(this.peers[e.localKey]!==e||e.connectionGeneration!==Number(t.connectionGeneration)||!t.candidate)){if(!e.connection){(!e.peerId||e.peerId===t.peerId)&&e.pendingCandidates.push(t.candidate);return}e.peerId===t.peerId&&(e.connection.remoteDescription?await e.connection.addIceCandidate(t.candidate):e.pendingCandidates.push(t.candidate))}},interactiveReady(e,t){let s=this.peers[Nt(e,t)];return s?.state==="connected"&&s.channels["browser.control.v1"]?.readyState==="open"&&s.channels["browser.pointer.v1"]?.readyState==="open"},sendControl(e,t,s){let n=this.peers[Nt(e,t)],r=n?.channels["browser.control.v1"];return!n||n.state!=="connected"||r?.readyState!=="open"?!1:(r.send(JSON.stringify({version:1,connectionGeneration:n.connectionGeneration,controlSeq:++n.controlSeq,action:s})),!0)},sendPointer(e,t,s){let n=this.peers[Nt(e,t)],r=n?.channels["browser.pointer.v1"];return!n||n.state!=="connected"||r?.readyState!=="open"?!1:(r.send(JSON.stringify({version:1,connectionGeneration:n.connectionGeneration,pointerSeq:++n.pointerSeq,action:s})),!0)},detach(e,t,{notify:s=!0}={}){let n=Nt(e,t),r=this.peers[n];if(r){if(delete this.peers[n],clearTimeout(r.attachTimer),r.attachTimer=null,clearTimeout(r.disconnectedTimer),r.disconnectedTimer=null,s&&!r.peerId&&this.rememberCancelledPeer(r),s&&r.peerId)try{this.send({type:"browser_peer_detach",requestId:wo(),agentId:e,browserSessionId:t,peerId:r.peerId,connectionGeneration:r.connectionGeneration})}catch{}this.errorCodes[n]||delete this.peerDiagnostics[n];for(let i of Object.values(r.channels||{}))try{i?.close?.()}catch{}r.channels={};try{r.connection?.close()}catch{}r.videoElement&&(r.videoElement.srcObject=null)}},failPeer(e,t,s=null){this.peers[e.localKey]===e&&(this.lastError=t?.message||String(t),this.errors[e.localKey]=this.lastError,s?this.errorCodes[e.localKey]=s:delete this.errorCodes[e.localKey],this.detach(e.agentId,e.browserSessionId,{notify:!0}))},handleTransportReset(){this.protocolSupported=null,this.connectionEpoch+=1;for(let e of Object.values(this.pending))clearTimeout(e.timer),e.reject(new Error("Browser Runtime connection changed"));this.pending={};for(let e of Object.values(this.peers))this.detach(e.agentId,e.browserSessionId,{notify:!1});this.peers={},this.runtimeStatus={},this.installProgress={},this.errors={},this.errorCodes={},this.peerDiagnostics={},this.clearCancelledPeers()},handleMessage(e){if(!e?.type)return;if(e.type==="client_hello_ack"){this.protocolSupported=e.browserRuntimeProtocol===1;return}if(e.type==="auth_result"){this.protocolSupported=!1;return}if(e.type==="browser_runtime_error"){let n=new Error(zl(e));n.code=e.code,this.completeRequest(e.requestId,null,n)||(this.lastError=n.message);return}if(e.type==="browser_runtime_install_progress"){this.installProgress[e.agentId]={downloadedBytes:Number(e.downloadedBytes)||0,totalBytes:Number(e.totalBytes)||0};return}if(e.type==="browser_runtime_status_result"){this.runtimeStatus[e.agentId]=e,this.completeRequest(e.requestId,e),e.state!=="installing"&&delete this.installProgress[e.agentId];return}if(e.type==="browser_session_error"){let n=new Error(zl(e));n.code=e.code,this.completeRequest(e.requestId,null,n)||(this.lastError=n.message);return}if(e.type==="browser_session_created"){this.sessions[Nt(e.agentId,e.browserSessionId)]=e,this.completeRequest(e.requestId,e);return}if(e.type==="browser_session_list_result"){this.completeRequest(e.requestId,e);return}if(e.type==="browser_session_snapshot"){let n=Nt(e.agentId,e.browserSessionId);this.sessions[n]=e,this.completeRequest(e.requestId,e),["closed","failed"].includes(e.state)&&this.detach(e.agentId,e.browserSessionId,{notify:!1});return}let t=Nt(e.agentId,e.browserSessionId),s=this.peers[t];if(!s||s.connectionGeneration!==Number(e.connectionGeneration)){if(e.type==="browser_peer_prepared"||e.type==="browser_peer_error"||e.type==="browser_peer_state"&&["failed","disconnected","closed"].includes(e.state)){let n=this.takeCancelledPeer(e);if(n&&e.type==="browser_peer_prepared")try{this.send({type:"browser_peer_detach",requestId:wo(),agentId:n.agentId,browserSessionId:n.browserSessionId,peerId:e.peerId,connectionGeneration:n.connectionGeneration})}catch{}}return}if(e.type==="browser_peer_error")this.failPeer(s,new Error(zl(e,"Browser peer failed")),e.code||null);else if(e.type==="browser_peer_prepared")this.preparePeer(s,e).catch(n=>this.failPeer(s,n));else if(e.type==="browser_peer_offer")this.acceptOffer(s,e).catch(n=>this.failPeer(s,n));else if(e.type==="browser_peer_ice_candidate")this.acceptCandidate(s,e).catch(n=>this.failPeer(s,n));else if(e.type==="browser_peer_state"&&e.state&&(s.remoteState=e.state,["failed","disconnected","closed"].includes(e.state))){let n=s.iceServerCount===0?"browser_ice_servers_missing":"browser_ice_connection_failed";this.failPeer(s,new Error(n),n)}}}})});function So(){try{if(window.Pinia&&typeof window.Pinia.useAuthStore=="function")return window.Pinia.useAuthStore()}catch{}return null}function Ql(){try{return localStorage.getItem("authToken")||null}catch{return null}}function Pg(){let e=So();if(e)try{return e.getActiveToken?.()||e.token||Ql()}catch{return e.token||Ql()}return Ql()}function Iw(e,t){if(!e)return!1;let s=Pg();if(s&&s!==t)return!1;try{localStorage.setItem("authToken",e)}catch{}let n=So();return n&&(n.token=e),!0}function Cw(e){try{let t=typeof e=="string"?e:e?.url;return!t||typeof window>"u"||!window.location?null:new URL(t,window.location.href)}catch{return null}}function Mg(e){return!e||typeof window>"u"||!window.location?!1:e.origin===window.location.origin&&e.pathname.startsWith("/api/")}function Aw(e){if(!e)return!1;let t=e.pathname;return!!(Sw.has(t)||t.startsWith("/api/auth/sso/poll/")||/^\/api\/auth\/sso\/[^/]+\/start(?:-qr)?$/.test(t))}function xw(e,t){return t?.headers?new Headers(t.headers):e&&typeof e=="object"&&e.headers?new Headers(e.headers):new Headers}function Tw(e){let t=e.get("Authorization");return!t||!t.startsWith("Bearer ")?null:t.slice(7)}function Mw(e,t){return{...e||{},headers:t}}function Pw(e,t,s,n){let r=So();r&&typeof r.handleAuthResponse=="function"?r.handleAuthResponse(e,t,s,n):r&&typeof r.handleAuthFailure=="function"&&n&&r.handleAuthFailure(void 0,t,s)}function Rg(){if(Tg||typeof window>"u"||!window.fetch)return;Tg=!0;let e=window.fetch.bind(window);window.fetch=async function(s,n){let r=Cw(s),i=Mg(r)&&!Aw(r),o=Mg(r)?{...n||{},credentials:"same-origin"}:n,a=null,l=i?So():null,c=l?.authGeneration,d=!!l?.isAuthenticated;if(i){let g=xw(s,n);a=Tw(g),a||(a=Pg(),a&&(g.set("Authorization",`Bearer ${a}`),o=Mw(o,g)))}let u=await e(s,o);try{let g=u.headers&&u.headers.get&&u.headers.get("X-New-Token");g&&Iw(g,a),i&&u.status===401&&Pw(u,a,c,d)}catch{}return u}}var Tg,Sw,_g=B(()=>{Tg=!1,Sw=new Set(["/api/auth/mode","/api/auth/login","/api/auth/aad","/api/auth/verify","/api/auth/verify-totp","/api/auth/setup-totp","/api/auth/register","/api/auth/password-reset/request","/api/auth/password-reset/verify"])});var Eg,Dg,Xl=B(()=>{Eg={"quickSend.title":"Quick send","quickSend.description":"Add up to 5 send buttons for this Agent. Each sends your current message with its model and optional turn overrides.","quickSend.empty":"No quick sends configured. No extra send buttons are shown.","quickSend.offline":"This Agent is offline. Reconnect to load or save quick sends.","quickSend.entry":"Quick send {index}","quickSend.name":"Button name","quickSend.model":"Model","quickSend.chooseModel":"Choose a model","quickSend.noModels":"Configure models in the LLM category first.","quickSend.effort":"Reasoning effort","quickSend.maxOutputTokens":"Maximum output tokens","quickSend.default":"Default","quickSend.outputLimit":"Leave blank to use the model default: {max} tokens (also the maximum).","quickSend.add":"Add quick send","quickSend.remove":"Remove","quickSend.limit":"Maximum 5 quick sends.","quickSend.nameRequired":"Enter a button name (1\u201380 characters).","quickSend.modelRequired":"Choose an available model for each quick send.","quickSend.effortInvalid":"The selected effort is not available for this model.","quickSend.outputInvalid":"Output tokens must be a positive integer no greater than {max}.","quickSend.loadFailed":"Could not load quick sends. Refresh to retry.","quickSend.saveFailed":"Save was not confirmed. Refresh to check the saved configuration before retrying.","quickSend.saved":"Quick sends saved.","quickSend.savedRefreshWarning":"Quick sends saved, but runtime refresh failed: {error}"},Dg={"quickSend.title":"\u5FEB\u6377\u53D1\u9001","quickSend.description":"\u4E3A\u6B64 Agent \u6DFB\u52A0\u6700\u591A 5 \u4E2A\u53D1\u9001\u6309\u94AE\u3002\u4F7F\u7528\u6307\u5B9A\u6A21\u578B\u548C\u53EF\u9009\u7684\u5355\u8F6E\u53C2\u6570\u53D1\u9001\u5F53\u524D\u6D88\u606F\u3002","quickSend.empty":"\u5C1A\u672A\u914D\u7F6E\u5FEB\u6377\u53D1\u9001\uFF0C\u4E0D\u4F1A\u663E\u793A\u989D\u5916\u7684\u53D1\u9001\u6309\u94AE\u3002","quickSend.offline":"\u6B64 Agent \u5DF2\u79BB\u7EBF\u3002\u91CD\u65B0\u8FDE\u63A5\u540E\u53EF\u52A0\u8F7D\u6216\u4FDD\u5B58\u5FEB\u6377\u53D1\u9001\u3002","quickSend.entry":"\u5FEB\u6377\u53D1\u9001 {index}","quickSend.name":"\u6309\u94AE\u540D\u79F0","quickSend.model":"\u6A21\u578B","quickSend.chooseModel":"\u9009\u62E9\u6A21\u578B","quickSend.noModels":"\u8BF7\u5148\u5728\u6A21\u578B\u914D\u7F6E\u5206\u7C7B\u4E2D\u6DFB\u52A0\u6A21\u578B\u3002","quickSend.effort":"\u63A8\u7406\u5F3A\u5EA6","quickSend.maxOutputTokens":"\u6700\u5927\u8F93\u51FA Token \u6570","quickSend.default":"\u9ED8\u8BA4","quickSend.outputLimit":"\u7559\u7A7A\u4F7F\u7528\u6A21\u578B\u9ED8\u8BA4\u503C\uFF1A{max} Token\uFF08\u4E5F\u662F\u53EF\u8BBE\u7F6E\u7684\u4E0A\u9650\uFF09\u3002","quickSend.add":"\u6DFB\u52A0\u5FEB\u6377\u53D1\u9001","quickSend.remove":"\u5220\u9664","quickSend.limit":"\u6700\u591A\u6DFB\u52A0 5 \u4E2A\u5FEB\u6377\u53D1\u9001\u3002","quickSend.nameRequired":"\u8BF7\u8F93\u5165\u6309\u94AE\u540D\u79F0\uFF081\u201380 \u4E2A\u5B57\u7B26\uFF09\u3002","quickSend.modelRequired":"\u8BF7\u4E3A\u6BCF\u4E2A\u5FEB\u6377\u53D1\u9001\u9009\u62E9\u53EF\u7528\u6A21\u578B\u3002","quickSend.effortInvalid":"\u6B64\u6A21\u578B\u4E0D\u652F\u6301\u6240\u9009\u63A8\u7406\u5F3A\u5EA6\u3002","quickSend.outputInvalid":"\u8F93\u51FA Token \u6570\u5FC5\u987B\u4E3A\u4E0D\u8D85\u8FC7 {max} \u7684\u6B63\u6574\u6570\u3002","quickSend.loadFailed":"\u65E0\u6CD5\u52A0\u8F7D\u5FEB\u6377\u53D1\u9001\uFF0C\u8BF7\u5237\u65B0\u91CD\u8BD5\u3002","quickSend.saveFailed":"\u5C1A\u672A\u786E\u8BA4\u4FDD\u5B58\u3002\u8BF7\u5148\u5237\u65B0\u68C0\u67E5\u5DF2\u4FDD\u5B58\u7684\u914D\u7F6E\uFF0C\u518D\u51B3\u5B9A\u662F\u5426\u91CD\u8BD5\u3002","quickSend.saved":"\u5FEB\u6377\u53D1\u9001\u5DF2\u4FDD\u5B58\u3002","quickSend.savedRefreshWarning":"\u5FEB\u6377\u53D1\u9001\u5DF2\u4FDD\u5B58\uFF0C\u4F46\u8FD0\u884C\u65F6\u5237\u65B0\u5931\u8D25\uFF1A{error}"}});var $g,Lg,Zl=B(()=>{$g={"userShortcuts.title":"Keyboard shortcuts","userShortcuts.scope":"These are your user preferences, stored only in this browser for this account. They do not sync across devices.","userShortcuts.quickSendHelp":"Quick-send shortcuts are active automatically when presets are configured in Agent settings. They only work while the message composer is focused; clear an individual binding to disable it.","userShortcuts.help":"Shortcuts use simple Alt + key defaults. Click a binding to replace it, or clear it to disable the action. Escape cancels; Tab moves on. Global actions stay available while the message composer is focused, and never run in dialogs, other text fields, editors or terminals.","userShortcuts.suggestion":"Suggestion: {binding}","userShortcuts.recording":"Press a shortcut\u2026","userShortcuts.unbound":"Not bound","userShortcuts.clear":"Clear","userShortcuts.clearAction":"Clear shortcut for {action}","userShortcuts.reset":"Reset shortcuts","userShortcuts.action.terminal":"Open terminal","userShortcuts.action.files":"Open files","userShortcuts.action.git":"Open Git","userShortcuts.action.newSession":"New session","userShortcuts.action.closeWorkbench":"Close workbench","userShortcuts.action.quickSend1":"Quick send 1","userShortcuts.action.quickSend2":"Quick send 2","userShortcuts.action.quickSend3":"Quick send 3","userShortcuts.action.quickSend4":"Quick send 4","userShortcuts.action.quickSend5":"Quick send 5","userShortcuts.error.invalid":"Use Ctrl, Meta or Alt with a letter or number; Shift is optional.","userShortcuts.error.reserved":"This combination conflicts with a browser or existing app shortcut.","userShortcuts.error.conflict":"This shortcut is already assigned to {action}. Clear it there first.","userShortcuts.error.storage":"Could not save preferences in this browser. Check browser storage permissions.","userShortcuts.error.unauthenticated":"Sign in before saving your shortcuts."},Lg={"userShortcuts.title":"\u952E\u76D8\u5FEB\u6377\u952E","userShortcuts.scope":"\u8FD9\u662F\u4F60\u7684\u7528\u6237\u504F\u597D\uFF0C\u6309\u5F53\u524D\u8D26\u53F7\u4EC5\u4FDD\u5B58\u5728\u6B64\u6D4F\u89C8\u5668\u4E2D\uFF0C\u4E0D\u8DE8\u8BBE\u5907\u540C\u6B65\u3002","userShortcuts.quickSendHelp":"\u5728 Agent \u8BBE\u7F6E\u4E2D\u914D\u7F6E\u5FEB\u6377\u53D1\u9001\u540E\uFF0C\u5FEB\u6377\u952E\u4F1A\u81EA\u52A8\u751F\u6548\uFF1B\u4EC5\u5728\u6D88\u606F\u8F93\u5165\u6846\u83B7\u5F97\u7126\u70B9\u65F6\u89E6\u53D1\u3002\u6E05\u9664\u5355\u9879\u7ED1\u5B9A\u5373\u53EF\u505C\u7528\u5BF9\u5E94\u5FEB\u6377\u952E\u3002","userShortcuts.help":"\u9ED8\u8BA4\u4F7F\u7528\u7B80\u5355\u7684 Alt + \u5355\u952E\u3002\u70B9\u51FB\u7ED1\u5B9A\u6309\u94AE\u53EF\u66FF\u6362\uFF0C\u6E05\u9664\u540E\u53EF\u505C\u7528\u8BE5\u64CD\u4F5C\u3002Escape \u53D6\u6D88\uFF0CTab \u79FB\u81F3\u4E0B\u4E00\u9879\u3002\u6D88\u606F\u8F93\u5165\u6846\u83B7\u5F97\u7126\u70B9\u65F6\u4ECD\u53EF\u4F7F\u7528\u5168\u5C40\u52A8\u4F5C\uFF1B\u5F39\u7A97\u3001\u5176\u4ED6\u8F93\u5165\u6846\u3001\u7F16\u8F91\u5668\u4E0E\u7EC8\u7AEF\u4E2D\u7684\u6309\u952E\u4E0D\u4F1A\u88AB\u62A2\u5360\u3002","userShortcuts.suggestion":"\u63A8\u8350\uFF1A{binding}","userShortcuts.recording":"\u8BF7\u6309\u4E0B\u7EC4\u5408\u952E\u2026","userShortcuts.unbound":"\u672A\u7ED1\u5B9A","userShortcuts.clear":"\u6E05\u9664","userShortcuts.clearAction":"\u6E05\u9664\u201C{action}\u201D\u5FEB\u6377\u952E","userShortcuts.reset":"\u91CD\u7F6E\u5FEB\u6377\u952E","userShortcuts.action.terminal":"\u6253\u5F00\u7EC8\u7AEF","userShortcuts.action.files":"\u6253\u5F00\u6587\u4EF6","userShortcuts.action.git":"\u6253\u5F00 Git","userShortcuts.action.newSession":"\u65B0\u5EFA\u4F1A\u8BDD","userShortcuts.action.closeWorkbench":"\u5173\u95ED\u5DE5\u4F5C\u53F0","userShortcuts.action.quickSend1":"\u5FEB\u6377\u53D1\u9001 1","userShortcuts.action.quickSend2":"\u5FEB\u6377\u53D1\u9001 2","userShortcuts.action.quickSend3":"\u5FEB\u6377\u53D1\u9001 3","userShortcuts.action.quickSend4":"\u5FEB\u6377\u53D1\u9001 4","userShortcuts.action.quickSend5":"\u5FEB\u6377\u53D1\u9001 5","userShortcuts.error.invalid":"\u8BF7\u4F7F\u7528 Ctrl\u3001Meta \u6216 Alt \u642D\u914D\u5B57\u6BCD\u6216\u6570\u5B57\uFF0C\u53EF\u52A0 Shift\u3002","userShortcuts.error.reserved":"\u8BE5\u7EC4\u5408\u4E0E\u6D4F\u89C8\u5668\u6216\u5E94\u7528\u5DF2\u6709\u5FEB\u6377\u952E\u51B2\u7A81\u3002","userShortcuts.error.conflict":"\u8BE5\u7EC4\u5408\u5DF2\u7ED1\u5B9A\u201C{action}\u201D\uFF0C\u8BF7\u5148\u6E05\u9664\u539F\u7ED1\u5B9A\u3002","userShortcuts.error.storage":"\u65E0\u6CD5\u5728\u6B64\u6D4F\u89C8\u5668\u4FDD\u5B58\u504F\u597D\uFF0C\u8BF7\u68C0\u67E5\u6D4F\u89C8\u5668\u5B58\u50A8\u6743\u9650\u3002","userShortcuts.error.unauthenticated":"\u8BF7\u5148\u767B\u5F55\u518D\u4FDD\u5B58\u5FEB\u6377\u952E\u3002"}});var Fg,Og=B(()=>{Xl();Zl();Fg={...Dg,...Lg,"quickSend.composer.label":"\u5FEB\u6377\u53D1\u9001","quickSend.composer.send":"\u5FEB\u6377\u53D1\u9001 {number}\uFF1A{name}","common.loading":"\u52A0\u8F7D\u4E2D...","common.confirm":"\u786E\u5B9A","common.apply":"\u5E94\u7528","common.cancel":"\u53D6\u6D88","common.delete":"\u5220\u9664","common.copy":"\u590D\u5236","common.copied":"\u5DF2\u590D\u5236","common.close":"\u5173\u95ED","common.refresh":"\u5237\u65B0","common.open":"\u6253\u5F00","common.save":"\u4FDD\u5B58","common.saving":"\u4FDD\u5B58\u4E2D...","common.search":"\u641C\u7D22","common.back":"\u8FD4\u56DE","common.noSubdirectories":"\u65E0\u5B50\u76EE\u5F55","common.drives":"\u9A71\u52A8\u5668","common.rootDir":"\u6839\u76EE\u5F55","common.comma":"\uFF0C","common.select":"\u9009\u62E9","common.retry":"\u91CD\u8BD5","mermaid.export":"\u5BFC\u51FA","mermaid.exportMd":"\u5BFC\u51FA MD","mermaid.exportPng":"\u5BFC\u51FA PNG","mermaid.exportJpg":"\u5BFC\u51FA JPG","login.subtitle":"Yeaft Web Code Agent","login.username":"\u7528\u6237\u540D","login.password":"\u5BC6\u7801","login.login":"\u767B\u5F55","login.loggingIn":"\u767B\u5F55\u4E2D...","login.enterUsername":"\u8BF7\u8F93\u5165\u7528\u6237\u540D","login.enterPassword":"\u8BF7\u8F93\u5165\u5BC6\u7801","login.noAccount":"\u6CA1\u6709\u8D26\u53F7\uFF1F","login.registerWithCode":"\u6CE8\u518C\u65B0\u8D26\u53F7","login.or":"\u6216","login.usePassword":"\u4F7F\u7528\u8D26\u53F7\u5BC6\u7801\u767B\u5F55","login.useSso":"\u8FD4\u56DE\u5355\u70B9\u767B\u5F55","login.noProviders":"\u7BA1\u7406\u5458\u5C1A\u672A\u542F\u7528\u4EFB\u4F55\u7B2C\u4E09\u65B9\u767B\u5F55\u3002","login.microsoft":"\u4F7F\u7528 Microsoft \u8D26\u53F7\u767B\u5F55","login.github":"\u4F7F\u7528 GitHub \u8D26\u53F7\u767B\u5F55","login.google":"\u4F7F\u7528 Google \u8D26\u53F7\u767B\u5F55","login.wechat":"\u4F7F\u7528\u5FAE\u4FE1\u626B\u7801\u767B\u5F55","login.alipay":"\u4F7F\u7528\u652F\u4ED8\u5B9D\u8D26\u53F7\u767B\u5F55","login.wechat.mobileUnsupported":"\u5FAE\u4FE1\u767B\u5F55\u6682\u4EC5\u652F\u6301\u7535\u8111\u7AEF\uFF0C\u8BF7\u5728\u7535\u8111\u6D4F\u89C8\u5668\u4E2D\u626B\u7801\u767B\u5F55\u3002","login.alipay.mobileWaiting":"\u6B63\u5728\u7B49\u5F85\u4F60\u5728\u652F\u4ED8\u5B9D\u4E2D\u786E\u8BA4\u2026 \u5B8C\u6210\u540E\u8FD4\u56DE\u672C\u9875\u9762\u5C06\u81EA\u52A8\u767B\u5F55\u3002","login.alipay.relaunch":"\u91CD\u65B0\u6253\u5F00\u652F\u4ED8\u5B9D","login.qr.title":"\u626B\u7801\u767B\u5F55","login.qr.titleAlipay":"\u652F\u4ED8\u5B9D\u626B\u7801\u767B\u5F55","login.qr.titleWechat":"\u5FAE\u4FE1\u626B\u7801\u767B\u5F55","login.qr.hint":"\u8BF7\u4F7F\u7528\u624B\u673A\u626B\u63CF\u4E8C\u7EF4\u7801\u5B8C\u6210\u6388\u6743","login.error.enterUsername":"\u8BF7\u8F93\u5165\u7528\u6237\u540D","login.error.enterPassword":"\u8BF7\u8F93\u5165\u5BC6\u7801","login.error.enter6Digit":"\u8BF7\u8F93\u51656\u4F4D\u9A8C\u8BC1\u7801","login.error.enterInviteCode":"\u8BF7\u8F93\u5165\u9080\u8BF7\u7801","login.error.usernameMinLen":"\u7528\u6237\u540D\u81F3\u5C112\u4E2A\u5B57\u7B26","login.error.passwordMinLen":"\u5BC6\u7801\u81F3\u5C116\u4F4D","login.error.passwordMismatch":"\u4E24\u6B21\u5BC6\u7801\u4E0D\u4E00\u81F4","login.error.enterVerifyCode":"\u8BF7\u8F93\u5165\u9A8C\u8BC1\u7801","login.error.loginFailed":"\u767B\u5F55\u5931\u8D25","login.forgot.link":"\u5FD8\u8BB0\u5BC6\u7801\uFF1F","login.forgot.title":"\u91CD\u7F6E\u5BC6\u7801","login.forgot.emailHint":"\u8F93\u5165\u8D26\u6237\u7ED1\u5B9A\u7684\u90AE\u7BB1\uFF0C\u6211\u4EEC\u5C06\u53D1\u9001 6 \u4F4D\u91CD\u7F6E\u9A8C\u8BC1\u7801\u3002","login.forgot.sendCode":"\u53D1\u9001\u91CD\u7F6E\u9A8C\u8BC1\u7801","login.forgot.sending":"\u53D1\u9001\u4E2D...","login.forgot.codeSent":"\u5982\u679C\u90AE\u7BB1\u5DF2\u6CE8\u518C\uFF0C\u91CD\u7F6E\u9A8C\u8BC1\u7801\u5DF2\u53D1\u9001\u3002\u8BF7\u5728\u4E0B\u65B9\u8F93\u5165\u9A8C\u8BC1\u7801\u4E0E\u65B0\u5BC6\u7801\u3002","login.forgot.resetBtn":"\u91CD\u7F6E\u5BC6\u7801","login.forgot.resetting":"\u91CD\u7F6E\u4E2D...","login.forgot.success":"\u5BC6\u7801\u5DF2\u91CD\u7F6E\uFF0C\u53EF\u4EE5\u4F7F\u7528\u65B0\u5BC6\u7801\u767B\u5F55\u3002","login.forgot.emailInvalid":"\u8BF7\u8F93\u5165\u6709\u6548\u7684\u90AE\u7BB1","login.register.title":"\u65B0\u7528\u6237\u6CE8\u518C","login.register.inviteCode":"\u9080\u8BF7\u7801","login.register.username":"\u7528\u6237\u540D","login.register.password":"\u5BC6\u7801\uFF08\u81F3\u5C116\u4F4D\uFF09","login.register.confirmPassword":"\u786E\u8BA4\u5BC6\u7801","login.register.email":"\u90AE\u7BB1\uFF08\u53EF\u9009\uFF09","login.register.submit":"\u6CE8\u518C","login.register.submitting":"\u6CE8\u518C\u4E2D...","login.register.back":"\u8FD4\u56DE\u767B\u5F55","login.register.success":"\u6CE8\u518C\u6210\u529F\uFF0C\u8BF7\u767B\u5F55","login.register.enterCode":"\u8BF7\u8F93\u5165\u9080\u8BF7\u7801","login.register.usernameMin":"\u7528\u6237\u540D\u81F3\u5C112\u4E2A\u5B57\u7B26","login.register.passwordMin":"\u5BC6\u7801\u81F3\u5C116\u4F4D","login.register.passwordMismatch":"\u4E24\u6B21\u5BC6\u7801\u4E0D\u4E00\u81F4","login.totp.setupTitle":"\u8BBE\u7F6E\u53CC\u56E0\u7D20\u8BA4\u8BC1","login.totp.setupHint":"\u4F7F\u7528 Microsoft Authenticator \u6216 Google Authenticator \u626B\u63CF\u4E0B\u65B9\u4E8C\u7EF4\u7801","login.totp.manualKey":"\u6216\u624B\u52A8\u8F93\u5165\u5BC6\u94A5\uFF1A","login.totp.enterCode":"\u8F93\u51656\u4F4D\u9A8C\u8BC1\u7801","login.totp.complete":"\u5B8C\u6210\u8BBE\u7F6E","login.totp.verifying":"\u9A8C\u8BC1\u4E2D...","login.totp.verify":"\u9A8C\u8BC1","login.totp.prompt":"\u8BF7\u8F93\u5165 Authenticator \u5E94\u7528\u4E2D\u7684\u9A8C\u8BC1\u7801","login.totp.invalidCode":"\u8BF7\u8F93\u51656\u4F4D\u9A8C\u8BC1\u7801","login.email.codeSent":"\u9A8C\u8BC1\u7801\u5DF2\u53D1\u9001\u81F3 {email}","login.email.enterCode":"\u8F93\u5165\u9A8C\u8BC1\u7801","login.email.verify":"\u9A8C\u8BC1","login.email.verifying":"\u9A8C\u8BC1\u4E2D...","login.email.enterCodeError":"\u8BF7\u8F93\u5165\u9A8C\u8BC1\u7801","chat.agent.select":"\u9009\u62E9 Agent","chat.agent.manage":"\u7BA1\u7406 Agent","chat.agent.count":"{count} agents","chat.agent.none":"\u6682\u65E0 Agent","chat.agent.restarting":"\u91CD\u542F\u4E2D","agentSettings.open":"Agent \u8BBE\u7F6E","agentSettings.manage":"\u7BA1\u7406","agentSettings.eyebrow":"\u672C\u5730\u8FD0\u884C\u65F6","agentSettings.title":"Agent \u8BBE\u7F6E","agentSettings.description":"\u6309 Agent \u67E5\u770B\u548C\u914D\u7F6E\u672C\u5730\u8FD0\u884C\u65F6\uFF0C\u4E0D\u518D\u628A\u8FD0\u884C\u63A7\u5236\u6DF7\u5165\u8D26\u6237\u8BBE\u7F6E\u3002","agentSettings.agentList":"Agent","agentSettings.categories":"Agent \u8BBE\u7F6E\u5206\u7C7B","agentSettings.categories.operations":"\u64CD\u4F5C","agentSettings.categories.trace":"Trace","agentSettings.categories.llm":"LLM \u914D\u7F6E","agentSettings.selectedAgent":"\u5F53\u524D Agent","agentSettings.online":"\u5728\u7EBF","agentSettings.offline":"\u79BB\u7EBF","agentSettings.empty":"\u6682\u65E0\u53EF\u7528 Agent\u3002","agentSettings.runtime.title":"\u8FD0\u884C\u65F6","agentSettings.runtime.description":"\u8EAB\u4EFD\u3001\u5DE5\u4F5C\u76EE\u5F55\u548C\u672C\u5730\u540E\u53F0\u5904\u7406\u3002","agentSettings.runtime.version":"\u7248\u672C","agentSettings.runtime.updateAvailable":"\u53EF\u66F4\u65B0\u81F3 v{version}","agentSettings.runtime.updateUnknown":"\u65E0\u6CD5\u83B7\u53D6\u66F4\u65B0\u72B6\u6001","agentSettings.runtime.workDir":"\u5DE5\u4F5C\u76EE\u5F55","agentSettings.workCenter.title":"\u5DE5\u4F5C\u4E2D\u5FC3","agentSettings.workCenter.enabled":"\u5DF2\u542F\u7528","agentSettings.workCenter.disabled":"\u5DF2\u505C\u7528","agentSettings.workCenter.runtimeUnavailable":"\u542F\u52A8\u5931\u8D25","agentSettings.workCenter.runtimeUnavailableMessage":"\u5DE5\u4F5C\u4E2D\u5FC3\u5DF2\u914D\u7F6E\u4E3A\u542F\u7528\uFF0C\u4F46\u8FD0\u884C\u65F6\u672A\u80FD\u542F\u52A8\uFF1B\u8BF7\u67E5\u770B Agent \u65E5\u5FD7\u540E\u91CD\u8BD5\u3002","agentSettings.workCenter.runtimeUnavailableHint":"\u5DF2\u914D\u7F6E\u4E3A\u542F\u7528\uFF0C\u4F46\u5DE5\u4F5C\u4E2D\u5FC3\u8FD0\u884C\u65F6\u5F53\u524D\u4E0D\u53EF\u7528\u3002","agentSettings.workCenter.enabledHint":"\u6B64 Agent \u5DF2\u53EF\u8FD0\u884C\u6301\u4E45\u5DE5\u4F5C\uFF1B\u65B0 Session \u4E5F\u53EF\u521B\u5EFA\u5DE5\u4F5C\u9879\u3002","agentSettings.workCenter.disabledHint":"\u5728\u6B64 Agent \u4E0A\u542F\u7528\u6301\u4E45\u5DE5\u4F5C\u9879\u548C\u540E\u53F0\u6267\u884C\u3002","agentSettings.workCenter.environmentManaged":"\u7531 YEAFT_WORK_CENTER_ENABLED \u7BA1\u7406\uFF0C\u65E0\u6CD5\u5728\u8FD9\u91CC\u4FEE\u6539\u3002","agentSettings.workCenter.upgradeRequired":"\u5347\u7EA7\u6B64 Agent \u540E\u624D\u80FD\u7BA1\u7406\u5DE5\u4F5C\u4E2D\u5FC3\u7684\u542F\u505C\u72B6\u6001\u3002","agentSettings.workCenter.unsupported":"\u9700\u8981\u5347\u7EA7","agentSettings.workCenter.loadFailed":"\u5DE5\u4F5C\u4E2D\u5FC3\u72B6\u6001\u52A0\u8F7D\u5931\u8D25\u3002","agentSettings.workCenter.loadFailedStatus":"\u52A0\u8F7D\u5931\u8D25","agentSettings.workCenter.saveFailed":"\u5DE5\u4F5C\u4E2D\u5FC3\u66F4\u65B0\u5931\u8D25\u3002","agentSettings.telemetry.title":"\u8BCA\u65AD","agentSettings.telemetry.saved":"\u8BCA\u65AD\u8BBE\u7F6E\u5DF2\u4FDD\u5B58\u3002","agentSettings.telemetry.loadFailed":"\u8BCA\u65AD\u8BBE\u7F6E\u52A0\u8F7D\u5931\u8D25\u3002","agentSettings.telemetry.saveFailed":"\u8BCA\u65AD\u8BBE\u7F6E\u4FDD\u5B58\u5931\u8D25\u3002","agentSettings.maintenance.title":"\u7EF4\u62A4","agentSettings.maintenance.description":"\u8FD9\u4E9B\u64CD\u4F5C\u4F1A\u4E2D\u65AD\u5F53\u524D Agent \u4E0A\u6B63\u5728\u8FD0\u884C\u7684\u5DE5\u4F5C\u3002","agentSettings.maintenance.upgradeFailed":"Agent \u5347\u7EA7\u5931\u8D25\u3002","chat.agent.dream":"Dream","chat.agent.dreamHint":"\u542F\u7528\u81EA\u52A8 Dream \u8BB0\u5FC6\u5904\u7406","chat.agent.restart":"\u91CD\u542F","chat.agent.restartConfirm":`\u786E\u5B9A\u8981\u91CD\u542F Agent "{name}" \u5417\uFF1F
10
+ ${v}`:v),m.status!=="failed"&&m.status!=="closed"&&(m.status=c.status||"idle");break}case"error":c.error&&(m.error=c.error.message||String(c.error));break;default:break}m.updatedAt=Date.now(),this.yeaftSubAgentCards={...this.yeaftSubAgentCards,[d]:m};break}case"history_loaded":{let a={...r,agentId:e.agentId||null,requestId:r.requestId||e.requestId||null};if(a.requestId&&!this.isCurrentYeaftHistoryResponse(a))break;let l=e.agentId||null,c=r.sessionId??null,d=Le(l,c),u=e.perfTraceId||this.yeaftHistoryPerfTraceBySession?.[d];u&&kt(this,{traceId:u,phase:"history.loaded_event",agentId:e.agentId||null,sessionId:r.sessionId||null,messageType:r.type,detail:{mode:r.mode||"recent",count:r.count||0,hasMore:!!r.hasMore}});let g=r.mode==="delta"?"delta":"recent",p=this.yeaftSessionHistoryState[d]||{},f=Number.isFinite(r.latestSeq)?r.latestSeq:Number.isFinite(p.latestSeq)?p.latestSeq:null,m=Number.isFinite(r.nextBeforeSeq)?r.nextBeforeSeq:Number.isFinite(r.oldestSeq)?r.oldestSeq:Number.isFinite(p.serverOldestFetchedSeq)?p.serverOldestFetchedSeq:Number.isFinite(p.oldestSeq)?p.oldestSeq:null,v=g==="delta"?{...p,loaded:!0,loading:!1,latestSeq:f,syncingAfterSeq:null,count:(p.count||0)+(r.count||0)}:{...p,loaded:!0,loading:!1,hasMore:!!r.hasMore,serverHasMore:!!r.hasMore,oldestSeq:m,serverOldestFetchedSeq:m,count:typeof r.count=="number"?r.count:0,latestSeq:f,syncingAfterSeq:null},b=a.requestId?this.finishYeaftHistoryLoad(a,v,"completion"):null;b||(this.yeaftSessionHistoryState={...this.yeaftSessionHistoryState,[d]:v});let h=Le(l?this.currentAgent:null,this.yeaftActiveSessionFilter??null);if(d===h)g==="recent"&&(this.yeaftHasMoreHistory=v.hasMore,this.yeaftOldestLoadedSeq=v.serverOldestFetchedSeq),this.yeaftLoadingMoreHistory=!!b?.loading;else if(this.yeaftLoadingMoreHistory){let k=this.yeaftSessionHistoryState[h]||null;this.yeaftLoadingMoreHistory=!!k?.loading}}break;case"vp_snapshot":{let a=window.Pinia?.useVpStore?.()||window.__useVpStore&&window.__useVpStore();a&&a.applySnapshot(r,e.agentId||null,e.requestId||null);break}case"vp_snapshot_error":{let a=window.Pinia?.useVpStore?.()||window.__useVpStore&&window.__useVpStore();a&&a.failSnapshot(e.agentId||null,e.requestId||null,r.error||r.message||"VP library request failed");break}case"vp_updated":{let a=window.Pinia?.useVpStore?.()||window.__useVpStore&&window.__useVpStore();a&&r.vp&&a.upsert(r.vp,r.reason,e.agentId||null);break}case"vp_removed":{let a=window.Pinia?.useVpStore?.()||window.__useVpStore&&window.__useVpStore();a&&r.vpId&&a.remove(r.vpId,r.reason,e.agentId||null);break}case"vp_crud_result":{let a=this._vpCrudPending&&this._vpCrudPending.get(r.requestId);a&&(this._vpCrudPending.delete(r.requestId),a.resolve({ok:!!r.ok,op:r.op,vpId:r.vpId,vp:r.vp,error:r.error||null}));break}case"group_list_updated":case"session_list_updated":case"yeaft_session_hydrate":{let a=window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore(),l=r.sessions||[];if(r.projectsAuthoritative===!0&&Array.isArray(r.projects)?this.applySessionCatalogSnapshot(this.sessionCatalog,r.projects):Array.isArray(r.projects)&&e.agentId&&this.applyLegacyProjectSnapshot(r.projects,e.agentId),r.type!=="yeaft_session_hydrate"&&this.yeaftSessionHydrateRequestId&&this.yeaftSessionInventoryCompleteSupported===!0){let p=Array.isArray(this.yeaftSessionHydrateSlices)?this.yeaftSessionHydrateSlices.filter(f=>f.agentId!==(e.agentId||null)):[];this.yeaftSessionHydrateSlices=[...p,{agentId:e.agentId||null,sessions:l}];break}let c=a&&a.activeSessionId||null,d=a?.activeSessionKey&&a.sessions?.[a.activeSessionKey]?.agentId||null;a&&(a.applySnapshot(l,e.agentId||null),this._hasHandledYeaftSessionHydrate=!0,this.yeaftSessionHydrateError=null);let u=a&&a.activeSessionId||null,g=a?.activeSessionKey&&a.sessions?.[a.activeSessionKey]?.agentId||null;if(this.currentView==="yeaft"&&u){let p=g||$e(this,u,e.agentId||null),f=Le(p,u),m=this.yeaftSessionHistoryState[f]||null;this.setActiveSessionFilter(u,{agentId:p,force:d!==p||hu(u,c,m)})}break}case"group_roster_changed":case"session_roster_changed":{let a=window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore();a&&a.applyRosterChange(r,e.agentId||null);break}case"group_crud_result":case"session_crud_result":{let a=window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore(),l=this._sessionCrudPending&&this._sessionCrudPending.get(r.requestId);if(r.op==="copy"&&l?.agentId&&l.agentId!==e.agentId)break;r.op==="copy"&&r.projectsAuthoritative===!0&&Array.isArray(r.projects)&&this.applySessionCatalogSnapshot(this.sessionCatalog,r.projects),a&&a.applyCrudResult(r,e.agentId||null,{activate:r.op!=="copy"}),r.ok&&r.op==="delete"&&r.sessionId&&e.agentId&&this.clearYeaftHistoryMemory({agentId:e.agentId,sessionId:r.sessionId}),l&&(()=>{if(this._sessionCrudPending?.get(r.requestId)!==l)return;this._sessionCrudPending.delete(r.requestId);let d=r.session||r.group||null,u=d&&e.agentId&&!d.agentId?{...d,agentId:e.agentId}:d,g=r.sessionId||null,p=r.sessions||null;l.resolve({ok:!!r.ok,op:r.op,session:u,sessionId:g,sessions:p,config:r.config||null,error:r.error||null})})();break}case"vp_turn_start":{if(!r.turnId||!r.vpId)break;let a=ul(e.agentId||null,r.turnId)||r.turnId;if(this.activeVpTurns={...this.activeVpTurns,[a]:{agentId:e.agentId||null,turnId:r.turnId,vpId:r.vpId,sessionId:r.sessionId||null,threadId:r.threadId||null,isStreaming:!0,startedAt:r.ts||Date.now()}},r.sessionId){let l=Is(e.agentId||null,r.sessionId);this.yeaftProcessingSessions={...this.yeaftProcessingSessions,...l?{[l]:!0}:{[r.sessionId]:!0}}}break}case"vp_turn_end":{if(!r.turnId)break;let a=Mn(this,e.agentId||null,r.turnId),l=r.sessionId||this.activeVpTurns?.[a]?.sessionId||null;r.reason==="end_turn"&&l&&this.markYeaftSessionUnread(l,e.agentId||null);let{[a]:c,...d}=this.activeVpTurns;this.activeVpTurns=d;let{[a]:u,...g}=this.stoppingVpTurnIds;this.stoppingVpTurnIds=g;let p=r.sessionId||c?.sessionId||null,f=e.agentId||c?.agentId||null,m=r.vpId||c?.vpId||null;if(!(p&&m?Object.values(this.activeVpTurns||{}).some(y=>y?.vpId===m&&Rt(y,p,f)):!1)&&p&&m){let y={...this.vpStatuses||{}},w=!1;for(let[P,x]of Object.entries(y))x?.vpId===m&&Rt(x,p,f)&&ni.has(x.state)&&(y[P]={...x,state:"idle",turnId:null,since:r.ts||Date.now()},w=!0);w&&(this.vpStatuses=y)}this.clearYeaftSessionProcessingIfIdle(p,{agentId:f});let h={end_turn:"completed",route_forward:"completed",aborted:"aborted",errored:"errored",error:"errored",cancelled:"cancelled",canceled:"cancelled"}[r.reason]||"completed",k=Date.now(),S=Ts(this,e.agentId||null,e.conversationId);if(S&&Array.isArray(this.messagesMap[S])){let y=this.messagesMap[S],w=Gp(y,r);for(let P=0;P<y.length;P++){let x=y[P];if(!x||x.type!=="assistant")continue;let Y=x.sessionId??x.groupId;r.sessionId&&Y&&Y!==r.sessionId||r.vpId&&x.speakerVpId&&x.speakerVpId!==r.vpId||r.turnId&&x.turnId&&x.turnId!==r.turnId||x.status&&x.status!=="pending"||(x.status=h,x.turnEndAt=k,x.turnEndReason=r.reason||null,r.detail&&(x.turnEndDetail=r.detail),Number.isFinite(r.durationMs)&&(x.turnDurationMs=r.durationMs),w=!0)}w&&(this.messagesMap={...this.messagesMap,[S]:y.slice()}),this.pruneConversationMessageRetention(S,p,f)}break}case"yeaft_turn_aborted":{let a=Array.isArray(r.turnIds)?r.turnIds.filter(Boolean):[];r.turnId&&a.push(r.turnId);let l=r.sessionId||null,c=r.vpId||null,d=new Set;for(let f of a){let m=Mn(this,e.agentId||null,f),v=this.activeVpTurns?.[m]||null;(!v||Rt(v,v.sessionId,e.agentId||null))&&d.add(m)}if(c)for(let[f,m]of Object.entries(this.activeVpTurns||{}))!m||m.vpId!==c||Rt(m,l,e.agentId||null)&&d.add(f);if(d.size===0)break;let u=l,g={...this.activeVpTurns||{}},p={...this.stoppingVpTurnIds||{}};for(let f of d){let m=g[f];!u&&m?.sessionId&&(u=m.sessionId),delete g[f],delete p[f]}this.activeVpTurns=g,this.stoppingVpTurnIds=p,this.clearYeaftSessionProcessingIfIdle(u||null,{agentId:e.agentId||null});break}case"yeaft_aborted":{let a=r.sessionId||e.sessionId||null;a?(this.activeVpTurns=Object.fromEntries(Object.entries(this.activeVpTurns||{}).filter(([,l])=>!Rt(l,a,e.agentId||null))),this.stoppingVpTurnIds=Object.fromEntries(Object.entries(this.stoppingVpTurnIds||{}).filter(([l])=>this.activeVpTurns?.[l])),this.vpStatuses=Object.fromEntries(Object.entries(this.vpStatuses||{}).filter(([,l])=>!Rt(l,a,e.agentId||null))),this.clearYeaftSessionProcessingIfIdle(a,{agentId:e.agentId||null,ignoreStatuses:!0})):r.all&&eg(this,e.agentId||null);break}case"vp_typing_start":{if(!r.vpId)break;let a=Ts(this,e.agentId||null,e.conversationId);if(!a)break;this.yeaftVpTyping=$p(this.yeaftVpTyping,a,r.vpId);break}case"vp_typing_end":{if(!r.vpId)break;let a=Ts(this,e.agentId||null,e.conversationId);if(!a)break;this.yeaftVpTyping=Lp(this.yeaftVpTyping,a,r.vpId);break}case"vp_status_changed":{if(!r.vpId||!r.state)break;if(o){let u=Fl(i);if(r.state==="thinking"||r.state==="retrying"||r.state==="tool")Nr(this,o,`${r.state}:${u}`);else if(r.state==="streaming"||r.state==="idle"||r.state==="error")for(let g of["thinking","retrying","tool"])Kn(this,o,`${g}:${u}`)}let a=r.sessionId||null,l=e.agentId||null,c=po(l,a,r.vpId),d={agentId:l,state:r.state,since:r.since||Date.now(),turnId:r.turnId||null,title:r.title||"",sessionId:a,vpId:r.vpId};if(this.vpStatuses={...this.vpStatuses,[c]:d},a&&ni.has(r.state)){let u=Is(l,a);this.yeaftProcessingSessions={...this.yeaftProcessingSessions,...u?{[u]:!0}:{[a]:!0}}}else a&&this.clearYeaftSessionProcessingIfIdle(a,{agentId:l});this.restoreActiveYeaftSessionFromStatuses([d],l);break}case"vp_status_snapshot":{let a=Array.isArray(r.statuses)?r.statuses:[],l=r.sessionId;if(l==null){let c={...this.vpStatuses||{}};if(e.agentId)for(let[d,u]of Object.entries(c))(!u?.agentId||u.agentId===e.agentId)&&delete c[d];else for(let d of Object.keys(c))delete c[d];for(let d of a){if(!d||!d.vpId)continue;let u=d.sessionId||d.groupId||null,g=po(e.agentId||null,u,d.vpId);c[g]={agentId:e.agentId||null,state:d.state,since:d.since||Date.now(),turnId:d.turnId||null,title:d.title||"",sessionId:u,vpId:d.vpId}}this.vpStatuses=c}else{let c={...this.vpStatuses};for(let[d,u]of Object.entries(c))u&&u.sessionId===l&&(!e.agentId||!u.agentId||u.agentId===e.agentId)&&delete c[d];for(let d of a){if(!d||!d.vpId)continue;let u=d.sessionId||d.groupId||null,g=po(e.agentId||null,u,d.vpId);c[g]={agentId:e.agentId||null,state:d.state,since:d.since||Date.now(),turnId:d.turnId||null,title:d.title||"",sessionId:u,vpId:d.vpId}}this.vpStatuses=c}this.yeaftProcessingSessions=Hb(this,e.agentId||null,a,l??null),this.restoreActiveYeaftSessionFromStatuses(a,e.agentId||null);break}case"yeaft_dream_snapshot":{let a=r&&r.snapshot,l=a&&typeof a.scope=="string"?a.scope:null;l&&(this.yeaftDreamSnapshots={...this.yeaftDreamSnapshots,[l]:{...a,receivedAt:Date.now()}});break}case"yeaft_dream_status":{let a=window.Pinia?.useVpStore?.()||window.__useVpStore&&window.__useVpStore();a&&a.applyDreamStatus(r);break}case"yeaft_dream_result":{let a=window.Pinia?.useVpStore?.()||window.__useVpStore&&window.__useVpStore();a&&a.applyDreamResult(r),r?.snapshot?.scope&&(this.yeaftDreamSnapshots={...this.yeaftDreamSnapshots,[r.snapshot.scope]:{...r.snapshot,receivedAt:Date.now()}});{let l=typeof r?.snapshot?.scope=="string"&&r.snapshot.scope?r.snapshot.scope:typeof r?.sessionId=="string"&&r.sessionId?`sessions/${r.sessionId}`:null;if(!l)break;let c=this.yeaftDreamLatest[l]||null;this.yeaftDreamLatest={...this.yeaftDreamLatest,[l]:{scope:l,phase:"result",status:r.skipped?"skipped":r.success?"success":"error",startedAt:c?.startedAt??null,finishedAt:Date.now(),mergedCount:typeof r.entriesCreated=="number"?r.entriesCreated:c?.mergedCount??null,error:r.skipped||r.success?null:r.error||"unknown",manual:typeof r?.manual=="boolean"?r.manual:c?.manual??null,durationMs:typeof r.durationMs=="number"?r.durationMs:c?.durationMs??null,llmCallCount:typeof r.llmCallCount=="number"?r.llmCallCount:c?.llmCallCount??0,inputTokens:typeof r.inputTokens=="number"?r.inputTokens:c?.inputTokens??0,outputTokens:typeof r.outputTokens=="number"?r.outputTokens:c?.outputTokens??0,totalTokens:typeof r.totalTokens=="number"?r.totalTokens:c?.totalTokens??0,metrics:r.metrics||c?.metrics||null,passBreakdown:r.passBreakdown||r.metrics?.passBreakdown||c?.passBreakdown||null,isRunning:!1}},this._appendDreamEvent(l,{type:"dream_progress",phase:"result",sessionId:r.sessionId,status:r.skipped?"skipped":r.success?"success":"error",success:!!r.success,entriesCreated:typeof r.entriesCreated=="number"?r.entriesCreated:null,trigger:r.trigger||null,error:r.skipped||r.success?null:r.error||null,skipped:!!r.skipped,skippedReason:r.skippedReason||null,durationMs:typeof r.durationMs=="number"?r.durationMs:null,llmCallCount:typeof r.llmCallCount=="number"?r.llmCallCount:0,inputTokens:typeof r.inputTokens=="number"?r.inputTokens:0,outputTokens:typeof r.outputTokens=="number"?r.outputTokens:0,totalTokens:typeof r.totalTokens=="number"?r.totalTokens:0,metrics:r.metrics||null,passBreakdown:r.passBreakdown||r.metrics?.passBreakdown||null,ts:Date.now()})}break}case"dream_progress":{let a=r?.phase||"unknown",l=null;typeof r?.target=="string"&&r.target.includes("/")?l=r.target:typeof r?.sessionId=="string"&&r.sessionId?l=`sessions/${r.sessionId}`:l="*";let c=a==="done",d=a==="error"||r?.status==="error",u=!c&&!d,g=p=>{let f=this.yeaftDreamLatest[p]||null;return{scope:p,phase:a,status:d?"error":c?"success":"running",startedAt:f?.startedAt&&u?f.startedAt:r?.ts||f?.startedAt||Date.now(),finishedAt:c||d?r?.ts||Date.now():null,mergedCount:typeof r?.mergedCount=="number"?r.mergedCount:typeof r?.targets=="number"?r.targets:f?.mergedCount??null,error:d?r?.error||"unknown":null,manual:typeof r?.manual=="boolean"?r.manual:f?.manual??!1,durationMs:typeof r?.duration=="number"?r.duration:typeof r?.durationMs=="number"?r.durationMs:f?.durationMs??null,llmCallCount:typeof r?.llmCallCount=="number"?r.llmCallCount:f?.llmCallCount??0,inputTokens:typeof r?.inputTokens=="number"?r.inputTokens:f?.inputTokens??0,outputTokens:typeof r?.outputTokens=="number"?r.outputTokens:f?.outputTokens??0,totalTokens:typeof r?.totalTokens=="number"?r.totalTokens:f?.totalTokens??0,metrics:r?.metrics||f?.metrics||null,passBreakdown:r?.passBreakdown||r?.metrics?.passBreakdown||f?.passBreakdown||null,isRunning:u}};if(l==="*"){let p={...this.yeaftDreamLatest,"*":g("*")};for(let f of Object.keys(this.yeaftDreamLatest))f!=="*"&&(p[f]=g(f));this.yeaftDreamLatest=p}else this.yeaftDreamLatest={...this.yeaftDreamLatest,[l]:g(l)};this._appendDreamEvent(l,r);break}}},_appendDreamEvent(e,t){if(!e||!t)return;let s=Date.now(),n={...t,at:s},r=Array.isArray(this.yeaftDreamEvents?.[e])?this.yeaftDreamEvents[e]:[],i=l=>[l?.type||"",l?.phase||"",(l?.sessionId??l?.groupId)||"",l?.target||"",l?.ts||l?.at||""].join("|"),o=i(n);if(r.some(l=>i(l)===o))return;let a=[...r,n];a.length>pg&&a.splice(0,a.length-pg),this.yeaftDreamEvents={...this.yeaftDreamEvents,[e]:a}},fetchExpertRoleDefinitions(){if(this.expertRoleDefinitions)return;let e=this.currentAgent;e&&this.sendWsMessage({type:"get_expert_roles",agentId:e})},setYeaftSidebarEnabled(e){try{typeof localStorage<"u"&&localStorage.removeItem("yeaft-sidebar-enabled")}catch{}},vpCrudRequest(e,t){(!this._vpCrudPending||typeof this._vpCrudPending.get!="function")&&(this._vpCrudPending=new Map);let s="vpc_"+Date.now().toString(36)+"_"+Math.random().toString(36).slice(2,8),r={create:"yeaft_vp_create",update:"yeaft_vp_update",delete:"yeaft_vp_delete",read:"yeaft_vp_read"}[e];if(!r)return Promise.resolve({ok:!1,op:e,error:{code:"bad_op",message:"unknown op: "+e}});let i={type:r,requestId:s};return e==="create"||e==="update"?i.payload=t||{}:i.vpId=t,new Promise(o=>{let a=setTimeout(()=>{this._vpCrudPending&&this._vpCrudPending.has(s)&&(this._vpCrudPending.delete(s),o({ok:!1,op:e,error:{code:"timeout",message:"vp_crud timeout"}}))},1e4);this._vpCrudPending.set(s,{resolve:l=>{clearTimeout(a),o(l)}}),this.sendWsMessage(i)})},sessionCrudRequest(e,t,s={}){(!this._sessionCrudPending||typeof this._sessionCrudPending.get!="function")&&(this._sessionCrudPending=new Map);let n="grc_"+Date.now().toString(36)+"_"+Math.random().toString(36).slice(2,8),i={list:"yeaft_list_sessions",create:"yeaft_create_session",copy:"yeaft_copy_session",rename:"yeaft_rename_session",update:"yeaft_update_session",update_config:"yeaft_update_session_config",archive:"yeaft_archive_session",delete:"yeaft_delete_session",add_member:"yeaft_session_add_member",remove_member:"yeaft_session_remove_member",set_default_vp:"yeaft_session_set_default_vp",reorder:"reorder_yeaft_sessions",scan_workdir:"yeaft_scan_workdir_sessions",restore:"yeaft_restore_session"}[e];if(!i)return Promise.resolve({ok:!1,op:e,error:{code:"bad_op",message:"unknown op: "+e}});let o={type:i,requestId:n};e==="create"?o.payload=t||{}:t&&typeof t=="object"&&Object.assign(o,t);let a=s&&s.agentId?s.agentId:null;a&&(o.agentId=a);let l=window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore();return l&&l.markPending(n,e),new Promise(c=>{let d=Number.isFinite(s.timeoutMs)?Math.max(1,Number(s.timeoutMs)):e==="copy"?null:jb,u=d==null?null:setTimeout(()=>{this._sessionCrudPending&&this._sessionCrudPending.has(n)&&(this._sessionCrudPending.delete(n),l?.pending&&delete l.pending[n],c({ok:!1,op:e,error:{code:"timeout",message:"session_crud timeout"}}))},d);this._sessionCrudPending.set(n,{op:e,agentId:a||this.currentAgent,connectionGeneration:Number(this.chatHistoryConnectionGeneration||0),resolve:p=>{u&&clearTimeout(u),l?.pending&&delete l.pending[n],c(p)}});let g=this.sendWsMessage(o);e==="copy"&&!g&&(u&&clearTimeout(u),this._sessionCrudPending.delete(n),l?.pending&&delete l.pending[n],c({ok:!1,op:e,error:{code:"agent_offline"}}))})},markYeaftSessionUnread(e,t=null){if(!e)return!1;let s=$e(this,e,t);if(!s)return!1;let n=Hn(s,e);return this.currentView==="yeaft"&&this.yeaftActiveSessionFilter===e&&$e(this,e)===s||this.yeaftUnreadSessionKeys?.[n]?!1:(this.yeaftUnreadSessionKeys={...this.yeaftUnreadSessionKeys,[n]:!0},!0)},markYeaftSessionRead(e,t=null){if(!e)return!1;let s=$e(this,e,t);if(!s)return!1;let n=Hn(s,e);if(!this.yeaftUnreadSessionKeys?.[n])return!1;let{[n]:r,...i}=this.yeaftUnreadSessionKeys;return this.yeaftUnreadSessionKeys=i,!0},restoreActiveYeaftSessionFromStatuses(e=[],t=null){if(this.yeaftActiveSessionFilter)return null;let n=(Array.isArray(e)?e:[]).filter(o=>o&&(o.sessionId||o.groupId)&&!["idle","offline","completed","failed","aborted"].includes(o.state)).sort((o,a)=>(a.updatedAt||a.since||0)-(o.updatedAt||o.since||0)),r=n[0]?.sessionId||n[0]?.groupId||null;if(!r)return null;let i=t||n[0]?.agentId||gg(this,r);if(!i)return null;this.setActiveSessionFilter(r,{agentId:i,force:!0});try{let o=window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore();o&&typeof o.setActive=="function"&&o.setActive(r,i)}catch{}return r},setActiveSessionFilter(e,t={}){let s=this.yeaftActiveSessionFilter||null,n=e||null,r=n?$e(this,n,t.agentId||null):this.currentAgent,i=!!n&&n===s&&!!r&&!!this.currentAgent&&r!==this.currentAgent,o=!!t.force||i;if(this.yeaftActiveSessionFilter=n,r&&n&&this.currentAgent!==r){this.selectAgent(r);let l=this.agents.find(c=>c.id===r);this.activateYeaftAgent(r,l||null)}else r&&n&&this.activateYeaftAgent(r);r&&n&&(this.markYeaftSessionRead(n,r),cu(this,r,n));let a=!o&&n===s;if(r&&n){this.yeaftSessionAgentById={...this.yeaftSessionAgentById||{},[n]:r};let l=this.yeaftConversationIdsByAgent?.[r]||null;l||(l=`yeaft-local-${r}-${Date.now()}`,this.yeaftConversationIdsByAgent={...this.yeaftConversationIdsByAgent||{},[r]:l}),this.yeaftConversationId=l,this.messagesMap[l]||(this.messagesMap[l]=[]),this.currentView==="yeaft"&&(this.activeConversations=[l])}try{let l=window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore();l&&typeof l.setActive=="function"&&l.setActive(n,r||null);let c=l?.activeSessionKey||null;c?localStorage.setItem("lastViewedYeaftSession",c):localStorage.removeItem("lastViewedYeaftSession")}catch{}this.syncActiveYeaftHistoryLoad(),n&&r&&!a&&this.requestYeaftSessionBootstrap({forceSessionReady:!0,forceHistoryReplay:!0})},async switchYeaftModel(e,t=null,s=void 0){if(!e||!this.currentAgent)return;let n=t||null;if(n){let r={model:e};return s!==void 0&&(r.modelEffort=s||null),await this.sessionCrudRequest("update_config",{sessionId:n,config:r},{agentId:$e(this,n)})}return this.sendWsMessage({type:"yeaft_model_switch",model:e,modelEffort:s||null,agentId:this.currentAgent}),null},setYeaftDebugSearch(e){this.yeaftDebugSearch=typeof e=="string"?e:"",this._yeaftDebugSearchTimer&&clearTimeout(this._yeaftDebugSearchTimer),this._yeaftDebugSearchTimer=setTimeout(()=>{this._yeaftDebugSearchTimer=null,this.yeaftDebugLoops=[],this.yeaftDebugTurnsById={},this.yeaftDebugTurnOrder=[],this.loadYeaftDebugHistory({limit:this.yeaftDebugSearch.trim()?ug:Ol,dreamLimit:5,indexOnly:!0,search:this.yeaftDebugSearch})},250)},setYeaftDebugSessionFilter(e){e==null?this.yeaftDebugSessionFilter=null:this.yeaftDebugSessionFilter=String(e)},toggleSubAgentCardExpand(e){let t=this.yeaftSubAgentCards?.[e];t&&(this.yeaftSubAgentCards={...this.yeaftSubAgentCards,[e]:{...t,expanded:!t.expanded}})},requestTelemetrySettings(e,t,s=null){if(!t)return Promise.reject(new Error("no agent"));let n=`telemetry-${Date.now()}-${Math.random().toString(36).slice(2)}`;return this.telemetryRequestByAgent={...this.telemetryRequestByAgent,[t]:n},new Promise((r,i)=>{this._telemetryPending||(this._telemetryPending={});let o=setTimeout(()=>{if(delete this._telemetryPending[n],this.telemetryRequestByAgent?.[t]===n){let a={...this.telemetryRequestByAgent};delete a[t],this.telemetryRequestByAgent=a}i(new Error("Telemetry request timed out"))},15e3);this._telemetryPending[n]={resolve:r,reject:i,timer:o,agentId:t,operation:e,requestId:n},this.sendWsMessage({type:e==="load"?"get_telemetry_settings":"update_telemetry_settings",agentId:t,requestId:n,...e==="update"?{settings:s||{}}:{}})})},loadTelemetrySettings(e=this.currentAgent){return e?this.requestTelemetrySettings("load",e):Promise.resolve({enabled:!0,retentionDays:3,flushIntervalMs:1e3,maxQueueSize:5e3,rawExchangeMaxBytes:524288,traceTextMaxBytes:262144,loaded:!0})},updateTelemetrySettings(e,t=this.currentAgent){return this.requestTelemetrySettings("update",t,e)},requestWorkCenterFeatureSettings(e,t,s=null){if(!t)return Promise.reject(new Error("no agent"));let n=`work-center-feature-${Date.now()}-${Math.random().toString(36).slice(2)}`;return this.workCenterFeatureRequestByAgent={...this.workCenterFeatureRequestByAgent,[t]:n},new Promise((r,i)=>{this._workCenterFeaturePending||(this._workCenterFeaturePending={});let o=setTimeout(()=>{delete this._workCenterFeaturePending[n],i(new Error("Work Center settings request timed out"))},15e3);this._workCenterFeaturePending[n]={resolve:r,reject:i,timer:o,agentId:t,operation:e},this.sendWsMessage({type:e==="load"?"get_work_center_feature_settings":"update_work_center_feature_settings",agentId:t,requestId:n,...e==="update"?{settings:s}:{}})})},loadWorkCenterFeatureSettings(e=this.currentAgent){return this.requestWorkCenterFeatureSettings("load",e)},updateWorkCenterFeatureSettings(e,t=this.currentAgent){return this.requestWorkCenterFeatureSettings("update",t,e)},restartAgent(e){if(!e||this.agentOperations?.[e]?.restart?.pending)return!1;let t=`restart-${Date.now()}-${Math.random().toString(36).slice(2)}`,s=setTimeout(()=>this.finishAgentOperation(e,"restart","timeout"),12e4);return this.agentOperations={...this.agentOperations,[e]:{...this.agentOperations[e]||{},restart:{pending:!0,acknowledged:!1,startedAt:Date.now(),requestId:t,timer:s,error:null}}},this.sendWsMessage({type:"restart_agent",agentId:e,requestId:t}),!0},upgradeAgent(e,t=null){if(!e||this.agentOperations?.[e]?.upgrade?.pending)return!1;let s=this.agents.find(i=>i.id===e),n=`upgrade-${Date.now()}-${Math.random().toString(36).slice(2)}`,r=setTimeout(()=>this.finishAgentOperation(e,"upgrade","timeout"),12e4);return this.agentOperations={...this.agentOperations,[e]:{...this.agentOperations[e]||{},upgrade:{pending:!0,acknowledged:!1,startedAt:Date.now(),requestId:n,oldVersion:s?.version||null,batchId:t,timer:r,error:null}}},this.sendWsMessage({type:"upgrade_agent",agentId:e,requestId:n}),!0},getUpgradableAgents(){return(this.agents||[]).filter(e=>e?.online&&Array.isArray(e.capabilities)&&e.capabilities.includes("remote_upgrade_safe")&&!e.capabilities.includes("container_agent")&&!this.agentOperations?.[e.id]?.restart?.pending&&!this.agentOperations?.[e.id]?.upgrade?.pending)},upgradeAllAgents(){if(this.agentUpgradeBatch?.pending)return null;let e=this.getUpgradableAgents();if(e.length===0)return null;let t={id:`upgrade-batch-${Date.now()}-${Math.random().toString(36).slice(2)}`,pending:!0,startedAt:Date.now(),agentIds:e.map(s=>s.id),skippedCount:Math.max(0,(this.agents||[]).length-e.length),results:{}};this.agentUpgradeBatch=t;for(let s of e)this.upgradeAgent(s.id,t.id)||this.recordAgentUpgradeBatchResult(s.id,{status:"failed",error:"not_started"},t.id);return t.agentIds.length},recordAgentUpgradeBatchResult(e,t={},s=null){let n=this.agentUpgradeBatch;if(!n?.pending||s&&n.id!==s||!n.agentIds.includes(e)||n.results[e])return null;let r={...n,results:{...n.results,[e]:{status:t.status||"failed",error:t.error||null,version:t.version||null,reason:t.reason||null}}},i=r.agentIds.every(o=>r.results[o]);return this.agentUpgradeBatch=i?{...r,pending:!1,completedAt:Date.now()}:r,i&&typeof window<"u"&&window.dispatchEvent(new CustomEvent("agent-upgrade-batch-complete",{detail:this.agentUpgradeBatch})),i?this.agentUpgradeBatch:null},finishAgentOperation(e,t,s=null){let n=this.agentOperations?.[e]?.[t];n&&(clearTimeout(n.timer),this.agentOperations={...this.agentOperations,[e]:{...this.agentOperations[e]||{},[t]:{...n,pending:!1,timer:null,error:s}}},t==="upgrade"&&n.batchId&&this.recordAgentUpgradeBatchResult(e,s?{status:"failed",error:s}:{status:"upgraded"},n.batchId))},loadSearchSettings(){return this.currentAgent?new Promise(e=>{this._searchPending||(this._searchPending={}),this._searchPending.load=e,this.sendWsMessage({type:"get_search_settings",agentId:this.currentAgent})}):(this.searchSettings={backend:"tavily",tavilyKeyConfigured:!1,tavilyKeyMasked:null,disableHtmlFallback:!1,loaded:!0},Promise.resolve(this.searchSettings))},updateSearchSettings(e){return this.currentAgent?new Promise(t=>{this._searchPending||(this._searchPending={}),this._searchPending.update=t,this.sendWsMessage({type:"update_search_settings",agentId:this.currentAgent,settings:e||{}})}):Promise.resolve({error:"no agent"})},loadTavilyUsage(){return this.currentAgent?(this.tavilyUsageLoading=!0,new Promise(e=>{this._searchPending||(this._searchPending={}),this._searchPending.usage=e,this.sendWsMessage({type:"get_tavily_usage",agentId:this.currentAgent})})):Promise.resolve(null)},loadYeaftMcpServers(){if(!this.currentAgent)return this.yeaftMcpServers=[],this.yeaftMcpRuntime={connected:!1,toolCount:0,perServer:[]},Promise.resolve({servers:[],runtime:this.yeaftMcpRuntime});this.yeaftMcpLoading=!0;let e=`mcp-list-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;return new Promise(t=>{this._mcpPending||(this._mcpPending={}),this._mcpPending[e]=t,this.sendWsMessage({type:"yeaft_mcp_list",agentId:this.currentAgent,requestId:e})})},addYeaftMcpServer(e){if(!this.currentAgent)return Promise.resolve({error:"no agent"});this.yeaftMcpLoading=!0;let t=`mcp-add-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;return new Promise(s=>{this._mcpPending||(this._mcpPending={}),this._mcpPending[t]=s,this.sendWsMessage({type:"yeaft_mcp_add",agentId:this.currentAgent,requestId:t,server:e||{}})})},removeYeaftMcpServer(e){if(!this.currentAgent)return Promise.resolve({error:"no agent"});this.yeaftMcpLoading=!0;let t=`mcp-rem-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;return new Promise(s=>{this._mcpPending||(this._mcpPending={}),this._mcpPending[t]=s,this.sendWsMessage({type:"yeaft_mcp_remove",agentId:this.currentAgent,requestId:t,name:e})})},reloadYeaftMcpServer(e){if(!this.currentAgent)return Promise.resolve({error:"no agent"});this.yeaftMcpLoading=!0;let t=`mcp-rel-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;return new Promise(s=>{this._mcpPending||(this._mcpPending={}),this._mcpPending[t]=s,this.sendWsMessage({type:"yeaft_mcp_reload",agentId:this.currentAgent,requestId:t,name:e||null})})},clearYeaftMessages(){let e=this.yeaftConversationId;e&&(Ve(this,e),delete this.messagesMap[e],delete this.processingConversations[e],delete this.executionStatusMap[e],delete this.refreshingSessionMap[e],this._closedAt&&delete this._closedAt[e],this._turnCompletedConvs?.delete(e)),this.yeaftConversationId=this.currentAgent?`yeaft-local-${this.currentAgent}-${Date.now()}`:`yeaft-local-${Date.now()}`,this.currentAgent&&(this.yeaftConversationIdsByAgent={...this.yeaftConversationIdsByAgent||{},[this.currentAgent]:this.yeaftConversationId}),this.messagesMap[this.yeaftConversationId]=[],this.activeConversations=[this.yeaftConversationId],this.yeaftSessionReady=!1,this.yeaftModel=null,this.yeaftAvailableModels=[],this.yeaftStatus=null,this._yeaftAskTerminalEvents={},this.yeaftDebugLoops=[],this.yeaftDebugTurnsById={},this.yeaftDebugTurnOrder=[],this.yeaftDebugHistoryLoading=!1,this.yeaftDebugHistoryError=null,this.yeaftDebugHistoryFetchedAt=0,this.yeaftDebugHistoryProjection=null,this.yeaftDebugSearch="",this.yeaftDebugSessionFilter=null,this.yeaftDebugPanel={open:!1,status:"idle",requestId:null,agentId:null,sessionId:null,turnId:null,error:null},this._yeaftDebugSearchTimer&&(clearTimeout(this._yeaftDebugSearchTimer),this._yeaftDebugSearchTimer=null),this._fetchYeaftDebugHistoryTimer&&(clearTimeout(this._fetchYeaftDebugHistoryTimer),this._fetchYeaftDebugHistoryTimer=null),this._yeaftDebugHistoryInFlightKey=null,this._yeaftDebugHistoryLatestListRequestId=null,this._yeaftDebugHistoryLatestDetailRequestId=null,this.yeaftReflectionCards={},this.yeaftSubAgentCards={},this.yeaftDreamLatest={},this.yeaftDreamEvents={},this.vpStatuses={},this.currentAgent&&this.sendWsMessage({type:"yeaft_reset",agentId:this.currentAgent})},togglePaneRightPanel(e,t=null){if(t&&this.isSplitMode){let s=this.panels.find(n=>n.id===t);if(s){s.activeRightPanel=s.activeRightPanel===e?null:e;return}}this.activeRightPanel=this.activeRightPanel===e?null:e,this.activeRightPanel&&(this.workbenchExpanded=!1,this.workbenchMaximized=!1,this.rememberWorkbenchPanelState())},getPaneRightPanel(e){if(e&&this.isSplitMode){let t=this.panels.find(s=>s.id===e);if(t)return t.activeRightPanel}return this.activeRightPanel},setPaneRightPanel(e,t){if(e&&this.isSplitMode){let s=this.panels.find(n=>n.id===e);if(s){s.activeRightPanel=t;return}}this.activeRightPanel=t},applySessionCatalogSnapshot(e,t=null,s=null){let n=r=>{let i=new Set;return(Array.isArray(r)?r:[]).filter(o=>!o?.catalogKey||i.has(o.catalogKey)?!1:(i.add(o.catalogKey),!0)).map(o=>({...o}))};if(this.sessionCatalog=n(e),Array.isArray(s)&&(this.hiddenSessionCatalog=n(s)),Array.isArray(t)){this.sessionProjects=t.filter(i=>i?.id).map(i=>({...i,members:Array.isArray(i.members)?i.members.filter(o=>o?.agentId&&o?.sessionId):i.agentId?(i.sessionIds||[]).map(o=>({agentId:i.agentId,sessionId:o})):[]}));let r=new Map;for(let i of this.sessionProjects)for(let o of i.members)r.set(`${o.agentId}${o.sessionId}`,i.id);this.sessionCatalog=this.sessionCatalog.map(i=>i.runtimeProvider==="yeaft"?{...i,projectId:r.get(`${i.routeRef?.agentId}${i.routeRef?.sessionId}`)||null}:i)}this.sessionCatalogLoaded=!0},mutateProject(e,t={},s=null){let n=s||t.agentId||this.currentAgent||null;if(e==="move_session"&&!n)return Promise.resolve({ok:!1,error:{code:"missing_agent"}});let r=`project_${crypto.randomUUID()}`;return new Promise(i=>{let o=setTimeout(()=>{delete this.projectMutationRequests[r],i({ok:!1,error:{code:"timeout"}})},1e4);this.projectMutationRequests[r]={connectionGeneration:Number(this.chatHistoryConnectionGeneration||0),catalogOrder:Array.isArray(t.catalogOrder)?t.catalogOrder:null,resolve:l=>{clearTimeout(o),i(l)}},this.sendWsMessage({type:"yeaft_project_mutation",...n?{agentId:n,targetAgentId:n}:{},requestId:r,op:e,...t})||(clearTimeout(o),delete this.projectMutationRequests[r],i({ok:!1,error:{code:"send_failed"}}))})},applyLegacyProjectSnapshot(e,t){if(!t||!Array.isArray(e))return;let s=this.sessionProjects.filter(r=>r.legacyAgentId!==t),n=e.filter(r=>r?.id).map(r=>({...r,id:`${t}${r.id}`,legacyProjectId:r.id,legacyAgentId:t,members:(r.sessionIds||[]).map(i=>({agentId:t,sessionId:i}))}));this.applySessionCatalogSnapshot(this.sessionCatalog,[...s,...n])},finishLegacyProjectMutation(e,t){if(!e?.requestId)return!1;let s=this.projectMutationRequests[e.requestId]||null;return!s||s.connectionGeneration!==Number(this.chatHistoryConnectionGeneration||0)?!1:(delete this.projectMutationRequests[e.requestId],e.ok&&Array.isArray(e.projects)&&t&&this.applyLegacyProjectSnapshot(e.projects,t),s.resolve(e),!0)},finishProjectMutation(e){if(!e?.requestId)return!1;let t=this.projectMutationRequests[e.requestId]||null;if(!t||t.connectionGeneration!==Number(this.chatHistoryConnectionGeneration||0))return!1;if(delete this.projectMutationRequests[e.requestId],e.ok){if(Array.isArray(t.catalogOrder)){let s=new Map(this.sessionCatalog.map(r=>[r.catalogKey,r])),n=t.catalogOrder.map((r,i)=>{let o=s.get(r?.catalogKey);return o?{...o,sortRank:i}:null}).filter(Boolean);n.length===this.sessionCatalog.length&&(this.sessionCatalog=n,ag(n))}Array.isArray(e.projects)&&this.applySessionCatalogSnapshot(this.sessionCatalog,e.projects)}return t.resolve(e),!0},toggleCatalogSessionPin(e){if(!e?.catalogKey||!e?.routeRef||Object.keys(this.sessionCatalogMutationRequests).length>0)return!1;let t=`session_ui_${crypto.randomUUID()}`,s=_r(this,t),n=!e.pinned;return e.pinned=n,this.sendWsMessage({type:"set_session_ui_metadata",requestId:t,catalogKey:e.catalogKey,routeRef:e.routeRef,pinned:n,sortRank:Number.isFinite(e.sortRank)?e.sortRank:null})?!0:(this.sessionCatalog=s,delete this.sessionCatalogMutationRequests[t],!1)},hideCatalogSession(e){if(!e?.catalogKey||!e?.routeRef||Object.keys(this.sessionCatalogMutationRequests).length>0)return!1;let t=`session_hide_${crypto.randomUUID()}`,s=_r(this,t);return this.sessionCatalog=this.sessionCatalog.filter(r=>r.catalogKey!==e.catalogKey),this.hiddenSessionCatalog=[...(this.hiddenSessionCatalog||[]).filter(r=>r.catalogKey!==e.catalogKey),{...e,hidden:!0}],this.sendWsMessage({type:"set_session_ui_metadata",requestId:t,catalogKey:e.catalogKey,routeRef:e.routeRef,hidden:!0,...Number.isFinite(e.sortRank)?{sortRank:e.sortRank}:{}})?!0:(this.sessionCatalog=s,this.hiddenSessionCatalog=Array.isArray(this.sessionCatalogMutationRequests[t]?.previousHiddenCatalog)?this.sessionCatalogMutationRequests[t].previousHiddenCatalog:[],delete this.sessionCatalogMutationRequests[t],!1)},restoreCatalogSession(e){if(!e?.catalogKey||!e?.routeRef||Object.keys(this.sessionCatalogMutationRequests).length>0)return!1;let t=`session_restore_${crypto.randomUUID()}`,s=_r(this,t);return this.hiddenSessionCatalog=(this.hiddenSessionCatalog||[]).filter(r=>r.catalogKey!==e.catalogKey),this.sessionCatalog=this.sessionCatalog.some(r=>r.catalogKey===e.catalogKey)?this.sessionCatalog:[...this.sessionCatalog,{...e,hidden:!1}],this.sendWsMessage({type:"set_session_ui_metadata",requestId:t,catalogKey:e.catalogKey,routeRef:e.routeRef,hidden:!1,...Number.isFinite(e.sortRank)?{sortRank:e.sortRank}:{}})?!0:(this.sessionCatalog=s,this.hiddenSessionCatalog=Array.isArray(this.sessionCatalogMutationRequests[t]?.previousHiddenCatalog)?this.sessionCatalogMutationRequests[t].previousHiddenCatalog:[],delete this.sessionCatalogMutationRequests[t],!1)},renameCatalogSession({row:e,title:t}={}){if(!e?.routeRef||!t)return!1;let{runtimeProvider:s,agentId:n,sessionId:r}=e.routeRef;if(s==="yeaft")this.sessionCrudRequest("rename",{sessionId:r,name:t},{agentId:n});else if(s==="claude-code"||s==="copilot")this.renameChatSession(r,t,n);else return!1;return!0},sessionForkUnavailableReason(e){let t=e?.routeRef;return t?.runtimeProvider!=="yeaft"||!t.agentId||!t.sessionId?"bad_route":this.sessionForkPendingKey?"fork_pending":this.connectionState!=="connected"||!this.agents.some(s=>s.id===t.agentId&&s.online)?"agent_offline":this.isYeaftSessionProcessing(t.sessionId,t.agentId)?"session_running":null},async copyCatalogSession(e){let t=this.sessionForkUnavailableReason(e);if(t)return{ok:!1,op:"copy",error:{code:t}};let s={...e.routeRef};this.sessionForkPendingKey=Hn(s.agentId,s.sessionId),this.sessionForkState="copying";try{let n=await this.sessionCrudRequest("copy",{sessionId:s.sessionId},{agentId:s.agentId});if(!n?.ok||!n.session?.id)return n;this.sessionForkState="success",await new Promise(i=>setTimeout(i,Ub));let r={runtimeProvider:"yeaft",agentId:s.agentId,sessionId:n.session.id};return this.openCatalogSession({catalogKey:Hn(r.agentId,r.sessionId),routeRef:r}),n}catch(n){return{ok:!1,op:"copy",error:{code:"fork_failed",message:n?.message||String(n)}}}finally{this.sessionForkState="idle",this.sessionForkPendingKey=null}},reorderCatalogSessions(e){if(!Array.isArray(e)||e.length===0||Object.keys(this.sessionCatalogMutationRequests).length>0)return!1;let t=`session_order_${crypto.randomUUID()}`,s=_r(this,t);return this.sessionCatalog=e.map((r,i)=>({...r,sortRank:i})),this.sendWsMessage({type:"reorder_session_catalog",requestId:t,sessions:this.sessionCatalog.map((r,i)=>({catalogKey:r.catalogKey,routeRef:r.routeRef,pinned:!!r.pinned,sortRank:i}))})?!0:(this.sessionCatalog=s,delete this.sessionCatalogMutationRequests[t],!1)},finishSessionCatalogMutation(e){if(!Md(this,e))return!1;if(e?.ok===!0&&e?.type==="session_ui_metadata_updated"){let s=n=>{n&&(n.pinned=e.pinned===!0,Object.prototype.hasOwnProperty.call(e,"sortRank")&&(n.sortRank=Number.isFinite(e.sortRank)?e.sortRank:null))};s(this.sessionCatalog.find(n=>n.catalogKey===e.catalogKey)),s(this.hiddenSessionCatalog.find(n=>n.catalogKey===e.catalogKey))}return e?.ok===!0&&e?.type==="session_catalog_reorder_result"&&ag(this.sessionCatalog),!0},openCatalogSession(e){if(!e?.catalogKey||!e.routeRef)return!1;let{runtimeProvider:t,agentId:s,sessionId:n}=e.routeRef;if(this.activeCatalogKey=e.catalogKey,t==="yeaft"){let r=this.isSessionHistorySyncing(e.routeRef);return this.enterYeaft(s,{deferBootstrap:!0}),this.setActiveSessionFilter(n,{agentId:s,force:!1}),r||this.reloadYeaftMessages(),!0}return t!=="claude-code"&&t!=="copilot"?!1:(this.currentView==="yeaft"&&this.leaveYeaft(),this.selectConversation(n,s,{refresh:!0}),!0)},syncChatConversationHistory(e){if(!e)return null;let t=Vs(e);if(this.chatHistoryRequests[t]?.loading)return this.chatHistoryRequests[t].requestId;let s=vn(this.messagesMap[e]);return this.requestChatHistory(e,s===null?{mode:"recent",turns:5}:{mode:"delta",afterMessageId:s})},requestChatHistory(e,{mode:t="recent",turns:s=null,beforeId:n=null,afterMessageId:r=null}={}){if(!e)return null;let i=Vs(e);if(this.chatHistoryRequestIdSupported!==!0&&this.chatHistoryRequests[i]?.loading)return null;let o=n??r??null,a=this.beginChatHistoryRequest(e,t,o);return this.sendWsMessage({type:"sync_messages",conversationId:e,...s!=null?{turns:s}:{},...n!=null?{beforeId:n}:{},...r!=null?{afterMessageId:r}:{},requestId:a})?(setTimeout(()=>{Oa(this,i,a,"history_load_timeout")},1e4),a):(Oa(this,i,a,"send_failed"),null)},beginChatHistoryRequest(e,t="recent",s=null){return Pd(this,e,t,s)},isCurrentChatHistoryResponse(e){if(!e?.conversationId||!e?.requestId||!e?.catalogKey)return!1;let t=Vs(e.conversationId);if(e.catalogKey!==t)return!1;let s=this.chatHistoryRequests[t];return!!s&&s.loading===!0&&s.requestId===e.requestId&&Number(s.connectionGeneration||0)===Number(this.chatHistoryConnectionGeneration||0)},finishChatHistoryRequest(e){if(!this.isCurrentChatHistoryResponse(e))return!1;let t=this.chatHistoryRequests[e.catalogKey];return this.chatHistoryRequests[e.catalogKey]={...t,loading:!1},!0},isRefreshingSession(e){return e?!!this.refreshingSessionMap[e]:this.refreshingSession},setRefreshingSession(e,t){e&&(this.refreshingSessionMap[e]=t),this.refreshingSession=t},enterBtwMode(){this.btwMode=!0,this.btwMessages=[],this.btwLoading=!1,this.btwSessionId=null},sendBtwQuestion(e){this.currentConversation&&(this.btwMessages.push({role:"user",content:e}),this.btwMessages.push({role:"assistant",content:""}),this.btwLoading=!0,this.sendWsMessage({type:"btw_question",conversationId:this.currentConversation,question:e,btwSessionId:this.btwSessionId}))},closeBtw(){this.btwMode=!1,this.btwMessages=[],this.btwLoading=!1,this.btwSessionId=null},appendBtwDelta(e){let t=this.btwMessages[this.btwMessages.length-1];t&&t.role==="assistant"&&(t.content+=e)},addSubagent(e,t){this.subagents[e]||(this.subagents[e]={}),this.subagents[e][t.id]={id:t.id,slug:t.slug||t.id,type:t.type||"Task",description:t.description||"",parentToolUseId:t.parentToolUseId||null,status:"running",startTime:Date.now(),messages:[],toolCallCount:0},e===this.currentConversation&&this.activeRightPanel!=="subagents"&&(this.activeRightPanel="subagents")},appendSubagentMessage(e,t,s){let n=this.subagents[e];if(!n||!n[t])return;let r=n[t];if(s?.type==="tool"){r.toolCallCount=Number(r.toolCallCount||0)+1;return}s?.type==="text"&&r.messages.push(s)},completeSubagent(e,t){let s=this.subagents[e];!s||!s[t]||(s[t].status="completed")},sendWsMessage(e){return Gd(this,e)},parseWsMessage(e){return Qd(this,e)},connect(){Xd(this)},ensureConnected(){return $r(this)},scheduleReconnect(){Zd(this)},manualReconnect(){Jd(this)},startHeartbeat(){eu(this)},stopHeartbeat(){tu(this)},setupVisibilityHandler(){su(this)},handleMessage(e){sp(this,e)},getOrCreateExecutionStatus(e){return al(this,e)},handleAssistantOutputFrame(e,t,s=null){Wu(this,e,t,s)},handleClaudeOutput(e,t){this.handleAssistantOutputFrame(e,t,null)},addMessageToConversation(e,t){return Qi(this,e,t)},pruneConversationMessageRetention(e,t=null,s=null,n=void 0){return au(this,{conversationId:e,sessionId:t,agentId:s,limits:n})},appendToAssistantMessageForConversation(e,t,s){yu(this,e,t,s)},finishStreamingForConversation(e,t){bu(this,e,t)},sweepStaleStreamingForConversation(e){wu(this,e)},appendToAssistantMessage(e){this.appendToAssistantMessageForConversation(this.currentConversation,e)},finishStreaming(){this.finishStreamingForConversation(this.currentConversation)},addMessage(e){this.addMessageToConversation(this.currentConversation,e)},loadHistoryMessages(e){ku(this,e)},formatDbMessage(e){return Su(e)},selectAgent(e){return dp(this,e)},createConversation(e,t=null,s=null,n=void 0){up(this,e,t,s,n)},resumeConversation(e,t,s=null,n=null,r=null){pp(this,e,t,s,n,r)},selectConversation(e,t,s={}){gp(this,e,t,s)},updateConversationSettings(e,t){fl(this,e,t)},toggleConversationMcp(e,t){fp(this,e,t)},deleteConversation(e,t){mp(this,e,t)},closeSession(e,t){hp(this,e,t)},appendColumn(e){wp(this,e)},removeColumn(e){kp(this,e)},sendMessageToConversation(e,t,s=[],n={}){Sp(this,e,t,s,n)},cancelExecutionForConversation(e){Ip(this,e)},addPanel(){if(this.panels.length>=3)return;let e=(t,s)=>({id:t,conversationId:s,activeRightPanel:null});if(this.panels.length===0){let t=localStorage.getItem("splitPanesSaved");if(t){try{let s=JSON.parse(t);if(Array.isArray(s)&&s.length>=2){let n=new Set(this.conversations.map(i=>i.id)),r=s.filter(i=>i&&typeof i.id=="string").map(i=>({...e(i.id,null),conversationId:i.conversationId&&n.has(i.conversationId)?i.conversationId:null}));if(r.length>=2){this.panels=r,this.activePanelId=r[0].id;for(let i of r)i.conversationId&&!this.activeConversations.includes(i.conversationId)&&this.activeConversations.push(i.conversationId),i.conversationId&&!this.messagesMap[i.conversationId]&&(this.messagesMap[i.conversationId]=[],this.requestChatHistory(i.conversationId,{mode:"recent",turns:5}));localStorage.removeItem("splitPanesSaved"),this.saveOpenSessions();return}}}catch{}localStorage.removeItem("splitPanesSaved")}this.panels=[e("panel-0",this.currentConversation),e("panel-1",null)],this.activePanelId="panel-0"}else{let t="panel-"+Date.now();this.panels.push(e(t,null))}this.saveOpenSessions()},removePanel(e){let t=this.panels.findIndex(s=>s.id===e);if(!(t<0)){if(this.panels.splice(t,1),this.panels.length<=1){let s=this.panels[0];s?.conversationId&&(this.activeConversations=[s.conversationId]),this.panels=[],this.activePanelId=null}else this.activePanelId===e&&(this.activePanelId=this.panels[0]?.id||null);this.saveOpenSessions()}},setPanelConversation(e,t,{refresh:s=!1}={}){let n=this.panels.find(i=>i.id===e);if(!n)return;let r=n.conversationId===t;n.conversationId=t,t&&!this.activeConversations.includes(t)&&this.activeConversations.push(t),t&&!this.messagesMap[t]?(this.messagesMap[t]=[],this.syncChatConversationHistory(t)):t&&(s||!r)&&this.syncChatConversationHistory(t),this.saveOpenSessions()},setActivePanel(e){this.activePanelId=e},splitToPanel(e){if(!e)return;let t=(s,n)=>({id:s,conversationId:n,activeRightPanel:null});if(this.panels.length===0)this.panels=[t("panel-0",this.currentConversation),t("panel-"+Date.now(),e)],this.activePanelId=this.panels[1].id;else if(this.panels.length>=3)this.panels[this.panels.length-1].conversationId=e,this.activePanelId=this.panels[this.panels.length-1].id;else{let s="panel-"+Date.now();this.panels.push(t(s,e)),this.activePanelId=s}this.activeConversations.includes(e)||this.activeConversations.push(e),this.messagesMap[e]||(this.messagesMap[e]=[],this.requestChatHistory(e,{mode:"recent",turns:5})),this.saveOpenSessions()},isInAnyPanel(e){return this.panels.some(t=>t.conversationId===e)},setSessionPinned(e,t,s={}){if(!e)return;let n=s&&s.agentId?s.agentId:null,r=n?!!ds()?.sessionById?.(e,n)?.pinned:this.pinnedSessions.includes(e);if(t&&!r)this.pinnedSessions.unshift(e);else if(!t&&r){let i=this.pinnedSessions.indexOf(e);i>=0&&this.pinnedSessions.splice(i,1)}try{localStorage.setItem("pinned-sessions",JSON.stringify(this.pinnedSessions))}catch{}try{let i=window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore(),o=$e(this,e,n);i&&typeof i.applyPinState=="function"&&i.applyPinState(e,!!t,o)}catch{}},togglePin(e,t={}){let s=t&&t.agentId?t.agentId:null,n=s?ds()?.sessionById?.(e,s):null,r=t&&Object.prototype.hasOwnProperty.call(t,"pinned"),o=!(n?!!n.pinned:r?!!t.pinned:this.pinnedSessions.includes(e));this.setSessionPinned(e,o,{agentId:s});let a={type:o?"pin_session":"unpin_session",conversationId:e};t&&t.sessionKind==="yeaft"&&(a.sessionKind="yeaft",t.agentId&&(a.agentId=t.agentId),t.sessionName&&(a.sessionName=t.sessionName),t.workDir&&(a.workDir=t.workDir)),this.sendWsMessage(a)},isSessionPinned(e){return this.pinnedSessions.includes(e)},applyServerPinSnapshot(e,t,s){if(!Array.isArray(this.pinnedSessions))return;let n=new Set(this.pinnedSessions),r=[];for(let i of t)n.has(i)||r.push(i);if(r.length>0&&(this.pinnedSessions=[...r,...this.pinnedSessions]),e){let i=this.pinnedSessions.filter(o=>s(o)?t.has(o):!0);i.length!==this.pinnedSessions.length&&(this.pinnedSessions=i)}try{localStorage.setItem("pinned-sessions",JSON.stringify(this.pinnedSessions))}catch{}},clearYeaftSessionProcessingIfIdle(e,{agentId:t=null,ignoreStatuses:s=!1}={}){if(!e)return;let n=t||$e(this,e);if(Object.values(this.activeVpTurns||{}).some(a=>Rt(a,e,n))||!s&&Object.values(this.vpStatuses||{}).some(l=>Rt(l,e,n)&&ni.has(l?.state)))return;let i=Is(n,e),o={...this.yeaftProcessingSessions||{}};i&&delete o[i],fo(this,e,n)&&delete o[e],this.yeaftProcessingSessions=o},sendMessage(e,t=[],s={}){vp(this,e,t,s)},cancelExecution(){yp(this)},cancelYeaft(){if(!this.currentAgent)return;this.sendWsMessage({type:"yeaft_abort_all",agentId:this.currentAgent});let e=this.yeaftConversationIdsByAgent?.[this.currentAgent]||this.yeaftConversationId;e&&delete this.processingConversations[e],eg(this,this.currentAgent)},cancelYeaftSession(e){let t=$e(this,e);!t||!e||(this.sendWsMessage({type:"yeaft_abort_all",agentId:t,sessionId:e}),this.activeVpTurns=Object.fromEntries(Object.entries(this.activeVpTurns||{}).filter(([,s])=>!Rt(s,e,t))),this.stoppingVpTurnIds=Object.fromEntries(Object.entries(this.stoppingVpTurnIds||{}).filter(([s])=>this.activeVpTurns?.[s])),this.vpStatuses=Object.fromEntries(Object.entries(this.vpStatuses||{}).filter(([,s])=>!Rt(s,e,t))),this.clearYeaftSessionProcessingIfIdle(e,{agentId:t,ignoreStatuses:!0}))},cancelVpTurn(e,{sessionId:t=null,vpId:s=null}={}){let n=$e(this,t);if(!n||!e)return;let r=Mn(this,n,e);this.stoppingVpTurnIds={...this.stoppingVpTurnIds,[r]:Date.now()};let i={type:"yeaft_abort_turn",agentId:n,turnId:e};t&&(i.sessionId=t),s&&(i.vpId=s),this.sendWsMessage(i)},cancelVpTurnForSession(e,t=null){if(!e)return!1;let s=t||this.yeaftActiveSessionFilter||null;if(!s)return!1;let n=$e(this,s);if(!n)return!1;let r=this.activeVpTurns||{},i=null,o=-1/0;for(let[a,l]of Object.entries(r)){if(!l||l.vpId!==e||!Rt(l,s,n))continue;let c=typeof l.startedAt=="number"?l.startedAt:0;c>=o&&(o=c,i=a)}if(!i){let a=this.vpStatuses?.[po(n,s,e)]||null;a?.turnId&&!["idle","offline"].includes(a.state)&&(i=a.turnId)}if(i){let a=r[i]?.turnId||i;return this.cancelVpTurn(a,{sessionId:s,vpId:e}),!0}return this.sendWsMessage({type:"yeaft_abort_turn",agentId:n,sessionId:s,vpId:e}),!0},answerUserQuestion(e,t,s){bp(this,e,t,s)},refreshAgents(){Cp(this)},refreshConversation(){Ap(this)},setDreamEnabled(e,t){if(!e||this.agentDreamState?.[e]?.pending)return!1;let s=this.agents.find(o=>o.id===e),n=t!==!1,r=`dream-${Date.now()}-${Math.random().toString(36).slice(2)}`,i=setTimeout(()=>{let o=this.agentDreamState?.[e];!o?.pending||o.requestId!==r||(this.agentDreamState={...this.agentDreamState,[e]:{...o,pending:!1,timer:null,error:"timeout"}})},15e3);return this.agentDreamState={...this.agentDreamState,[e]:{pending:!0,requestId:r,requested:n,authoritative:s?.dreamEnabled===!0,timer:i,error:null}},xp(this,e,n,r),!0},loadMoreMessages(){if(this.currentView==="yeaft"||this.loadingMoreMessages||!this.hasMoreMessages||!this.currentConversation)return;this.loadingMoreMessages=!0;let e=this._loadMoreGeneration=(this._loadMoreGeneration||0)+1,s=(this.messagesMap[this.currentConversation]||[]).find(i=>i.dbMessageId),n=this.currentConversation,r=s?.dbMessageId??null;this.requestChatHistory(n,{mode:"older",turns:5,beforeId:r}),setTimeout(()=>{this._loadMoreGeneration===e&&this.loadingMoreMessages&&this.currentConversation===n&&(this.loadingMoreMessages=!1)},1e4)},reloadYeaftMessages(){if(this.currentView!=="yeaft")return!1;let e=Ms(this),t=$e(this,e);if(!t)return!1;let s=Le(t,e),n=this.yeaftConversationId,r=this.yeaftSessionHistoryState?.[s];if(r?.loading)return r.requestId?(this._yeaftManualHistoryRefresh={agentId:t,sessionId:e,requestId:r.requestId},r.requestId):!1;let i=this.beginYeaftHistoryLoad({agentId:t,sessionId:e,mode:"recent",preserveLoaded:!1});if(!i)return!1;this._yeaftManualHistoryRefresh={agentId:t,sessionId:e,requestId:i.requestId};let o=bn();this.yeaftHistoryPerfTraceBySession={...this.yeaftHistoryPerfTraceBySession||{},[s]:o};let a={type:"yeaft_load_history",agentId:t,limit:El,sessionId:e,requestId:i.requestId,perfTraceId:o};return kt(this,{traceId:o,phase:"history.request_send",agentId:t,sessionId:e,messageType:a.type,bytes:JSON.stringify(a).length,detail:{mode:"manual-reload",limit:El}}),this.sendWsMessage(a)?!0:(Or(this,{agentId:t,sessionId:e,requestId:i.requestId,error:"history_load_send_failed"}),!1)},loadMoreYeaftHistory(e=ti(),{sessionId:t=null,agentId:s=null,background:n=!1}={}){if(this.currentView!=="yeaft")return!1;let r=t||Ms(this),i=$e(this,r,s);if(!i||!r)return!1;let o=Le(i,r),a=this.yeaftSessionHistoryState?.[o]||{};if(a.loading||!a.hasMore)return!1;let l=Math.min(50,Math.max(1,Number.isFinite(e)?Math.floor(e):ti())),c=this.yeaftHistoryCacheState?.[o]?.ranges||[],d=Number(this.yeaftHistoryCacheState?.[o]?.rangeEpoch)||0,u=xu(a,c,d);if(this.yeaftSessionHistoryState={...this.yeaftSessionHistoryState||{},[o]:u.state},!u.request)return this.syncActiveYeaftHistoryLoad(),!1;let g=this.beginYeaftHistoryLoad({agentId:i,sessionId:r,mode:n?"prefetch":"older",preserveLoaded:!0,latestSeq:this.yeaftSessionHistoryState[o]?.latestSeq??null});if(!g)return!1;let p=bn();this.yeaftHistoryPerfTraceBySession={...this.yeaftHistoryPerfTraceBySession||{},[o]:p};let f={type:"yeaft_load_more_history",agentId:i,sessionId:r,requestId:g.requestId,beforeSeq:u.request.beforeSeq,pageKind:u.request.kind,gapStopAtSeq:u.request.stopAtSeq,cacheEpoch:u.request.cacheEpoch,turns:l,perfTraceId:p};return kt(this,{traceId:p,phase:"history_more.request_send",agentId:i,sessionId:r,messageType:f.type,bytes:JSON.stringify(f).length,detail:{beforeSeq:f.beforeSeq,turns:f.turns,pageKind:u.request.kind,gapStopAtSeq:u.request.stopAtSeq,background:n}}),this.sendWsMessage(f)?!0:(Or(this,{agentId:i,sessionId:r,requestId:g.requestId,error:"history_load_send_failed"}),!1)},checkPendingRecovery(){Rd(this)},performRecovery(){_d(this)},dismissRecovery(){Ed(this)},autoRestoreConversation(e){Dd(this,e)},saveOpenSessions(){fn(this)},getLastSession(){return Ld(this)},clearLastSession(){Fd(this)},listHistorySessions(e){Od(this,e)},listFolders(){return qd(this)},listFoldersForAgent(e,t){return Vd(this,e,t)},listModelsForAgent(e,t){return Hd(this,e,t)},listHistorySessionsForAgent(e,t,s){Bd(this,e,t,s)},async loadGlobalSessions(e=20){return Nd(this,e)},async deleteGlobalSession(e){return Wd(this,e)},findAgentForSession(e){return qa(this,e)},isSessionResumable(e){return jd(this,e)},_isRecentlyClosed(e){return yn(this,e)},_startProcessingWatchdog(e){Un(this,e)},_resetProcessingWatchdog(e){Xi(this,e)},_stopProcessingWatchdog(e){Ve(this,e)},startRefreshTimeout(e){let t=e||this.currentConversation;t&&(this._refreshTimeouts||(this._refreshTimeouts={}),this._refreshTimeouts[t]&&clearTimeout(this._refreshTimeouts[t]),this._refreshTimeouts[t]=setTimeout(()=>{this.setRefreshingSession(t,!1),delete this._refreshTimeouts[t]},1e4))},toggleTheme(){this.theme=this.theme==="dark"?"light":"dark",this.themeFollowSystem=!1,localStorage.setItem("theme",this.theme),document.documentElement.setAttribute("data-theme",this.theme),document.documentElement.classList.toggle("light",this.theme==="light")},initTheme(){if(document.documentElement.setAttribute("data-theme",this.theme),document.documentElement.classList.toggle("light",this.theme==="light"),this.themeFollowSystem&&typeof window<"u"&&window.matchMedia){let e=window.matchMedia("(prefers-color-scheme: dark)"),t=s=>{this.themeFollowSystem&&(this.theme=s.matches?"dark":"light",document.documentElement.setAttribute("data-theme",this.theme),document.documentElement.classList.toggle("light",this.theme==="light"))};e.addEventListener?e.addEventListener("change",t):e.addListener&&e.addListener(t)}},loadModelsDevRegistry({forceRefresh:e=!1}={}){let t=this.modelsDevRegistry.loaded&&!this.modelsDevRegistry.error&&Date.now()-this.modelsDevRegistry.fetchedAt<36e5;if(!e&&t)return Promise.resolve(this.modelsDevRegistry);let s=this.currentAgent;if(!s)return Promise.resolve(this.modelsDevRegistry);if(this._modelsDevPending&&(!e||this._modelsDevPending.force))return new Promise(n=>this._modelsDevPending.resolvers.push(n));if(this._modelsDevPending){let n=this._modelsDevPending;this._modelsDevPending=null,n.timer&&clearTimeout(n.timer);for(let r of n.resolvers)r(this.modelsDevRegistry)}return new Promise(n=>{let r={resolvers:[n],force:e,timer:null};this._modelsDevPending=r;try{this.sendWsMessage({type:"get_models_dev_registry",agentId:s,forceRefresh:e})}catch{this._modelsDevPending===r&&(this._modelsDevPending=null),n(this.modelsDevRegistry);return}r.timer=setTimeout(()=>{if(this._modelsDevPending===r){this._modelsDevPending=null;for(let i of r.resolvers)i(this.modelsDevRegistry)}},2e4)})},changeLocale(e){if(this.locale=e,Rr(e),this.currentAgent)try{this.sendWsMessage({type:"update_llm_config",agentId:this.currentAgent,config:{language:e}})}catch{}},async fetchCustomExpertRoles(){let e=Ge();try{let t={};e.token&&(t.Authorization=`Bearer ${e.token}`);let s=await fetch("/api/expert-roles/custom",{headers:t});if(s.ok){let n=await s.json();this.customExpertRoles=n.roles||[]}}catch{}},async createCustomExpertRole(e){let t=Ge();try{let s={"Content-Type":"application/json"};t.token&&(s.Authorization=`Bearer ${t.token}`);let n=await fetch("/api/expert-roles/custom",{method:"POST",headers:s,body:JSON.stringify(e)});if(n.ok){let r=await n.json();return this.customExpertRoles.push(r.role),r.role}else{let r=await n.json().catch(()=>({}));throw new Error(r.error||"Failed to create custom expert role")}}catch(s){throw s}},async updateCustomExpertRole(e,t){let s=Ge();try{let n={"Content-Type":"application/json"};s.token&&(n.Authorization=`Bearer ${s.token}`);let r=await fetch(`/api/expert-roles/custom/${e}`,{method:"PUT",headers:n,body:JSON.stringify(t)});if(r.ok){let i=await r.json(),o=this.customExpertRoles.findIndex(a=>a.id===e);return o!==-1&&(this.customExpertRoles[o]=i.role),i.role}else{let i=await r.json().catch(()=>({}));throw new Error(i.error||"Failed to update custom expert role")}}catch(n){throw n}},async deleteCustomExpertRole(e){let t=Ge();try{let s={};t.token&&(s.Authorization=`Bearer ${t.token}`);let n=await fetch(`/api/expert-roles/custom/${e}`,{method:"DELETE",headers:s});if(n.ok)return this.customExpertRoles=this.customExpertRoles.filter(r=>r.id!==e),!0;{let r=await n.json().catch(()=>({}));throw new Error(r.error||"Failed to delete custom expert role")}}catch(s){throw s}},rememberWorkbenchPanelState(e=this.activeSessionRoute,t){let s=typeof e=="string"?e:yt(e);if(!s)return!1;let n=this.workbenchPanelStateByRoute[s]||{},r=Number.isFinite(t)&&t>0?Math.round(t):n.width;return this.workbenchPanelStateByRoute={...this.workbenchPanelStateByRoute,[s]:{expanded:!!this.workbenchExpanded,maximized:!!this.workbenchExpanded&&!!this.workbenchMaximized,...Number.isFinite(r)&&r>0?{width:r}:{}}},!0},workbenchPanelWidthForRoute(e=this.activeSessionRoute){let t=typeof e=="string"?e:yt(e),s=t?this.workbenchPanelStateByRoute[t]?.width:null;return Number.isFinite(s)&&s>0?s:null},restoreWorkbenchPanelState(e=this.activeSessionRoute){let t=yt(e),s=t?this.workbenchPanelStateByRoute[t]:null;return this.workbenchExpanded=!!s?.expanded,this.workbenchMaximized=!!s?.expanded&&!!s?.maximized,!!s},openWorkbench(){this.workbenchExpanded=!0,this.activeRightPanel=null,this.closeYeaftDebugPanel(),this.rememberWorkbenchPanelState()},toggleWorkbench(){if(this.workbenchExpanded){this.workbenchExpanded=!1,this.workbenchMaximized=!1,this.rememberWorkbenchPanelState();return}this.openWorkbench()},toggleSidebar(){this.sidebarCollapsed=!this.sidebarCollapsed},toggleSessionSidebar(){this.sessionSidebarOpen=!this.sessionSidebarOpen},closeSessionSidebar(){this.sessionSidebarOpen=!1},toggleWorkbenchMaximized(){this.workbenchMaximized=!this.workbenchMaximized,this.rememberWorkbenchPanelState()},renameChatSession(e,t,s=null){let n=t&&t.trim()?t.trim():"";n?this.customConversationTitles[e]=n:delete this.customConversationTitles[e],this.sendWsMessage({type:"update_conversation_settings",conversationId:e,...s?{agentId:s}:{},title:n})},resolveMessageFileReferences(e){let t=this.activeSessionRoute,s=t?.agentId||this.currentAgent||null,n=t?.runtimeProvider==="yeaft"?It(this,t.sessionId,s):this.currentConversation,i=yt(t)&&s&&n&&this.workbenchRouteProtocolSupported===!0&&St(this,s,"file_reference_resolution")&&St(this,s,"file_editor")&&St(this,s,"workbench_session_routes"),o=[...new Set((Array.isArray(e)?e:[]).filter(u=>typeof u=="string"&&u.trim()).map(u=>u.trim()))].slice(0,32);if(!i||o.length===0)return null;let a=this.effectiveWorkDir||"",l=t?{runtimeProvider:t.runtimeProvider,agentId:t.agentId,sessionId:t.sessionId}:null,c=`file_refs_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`;return this.sendWsMessage({type:"resolve_file_references",requestId:c,references:o,agentId:s,conversationId:n,workDir:a,workbenchRoute:l})?c:null},requestMessageImagePreview(e){let t=this.activeSessionRoute,s=t?.agentId||this.currentAgent||null,n=t?.runtimeProvider==="yeaft"?It(this,t.sessionId,s):this.currentConversation,i=yt(t)&&s&&n&&this.workbenchRouteProtocolSupported===!0&&(s===this.currentAgent?this.hasCapability("file_editor")&&this.hasCapability("workbench_session_routes")&&this.hasCapability("response_image_preview"):St(this,s,"file_editor")&&St(this,s,"workbench_session_routes")&&St(this,s,"response_image_preview")),o=typeof e=="string"?e.trim():"";if(!i||!o)return null;let a=`message_image_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`;return this.sendWsMessage({type:"read_file",requestId:a,filePath:o,responseImagePreview:!0,agentId:s,conversationId:n,workDir:this.effectiveWorkDir||"",workbenchRoute:{runtimeProvider:t.runtimeProvider,agentId:t.agentId,sessionId:t.sessionId}})?a:null},openFileInExplorer(e,{hideTree:t=!1,line:s=null}={}){let n=this.activeSessionRoute,r=n?{runtimeProvider:n.runtimeProvider,agentId:n.agentId,sessionId:n.sessionId}:null,i=yt(r),o=this.effectiveWorkDir||"",a=Tn(i,o),l=r?.agentId||this.currentAgent||null,c=r?.runtimeProvider==="yeaft"?It(this,r.sessionId,l):this.currentConversation,d=this.workbenchRouteProtocolSupported===!0&&St(this,l,"file_editor")&&St(this,l,"workbench_session_routes");if(!l||!c||!d)return!1;let u=typeof e=="string"?e.trim():"";if(!u)return!1;let g=this.workbenchExpanded;this.openWorkbench(),this.workbenchMaximized=!1,this.rememberWorkbenchPanelState();let p=()=>{let f=yt(this.activeSessionRoute),m=this.effectiveWorkDir||"";f!==i||m!==o||Tn(f,m)!==a||window.dispatchEvent(new CustomEvent("open-file-in-explorer",{detail:{filePath:u,agentId:l,conversationId:c,workDir:o,workbenchRoute:r,workbenchRouteKey:i,workspaceGeneration:a,hideTree:!!t,line:Number.isFinite(s)&&s>0?s:null}}))};return g?p():Vue.nextTick(p),!0},logout(){Ge().logout(),this.authenticated=!1,this.sessionKey=null,this.agents=[],this.currentAgent=null,this.currentAgentInfo=null,this.yeaftStatusByAgent={},this._yeaftRetiredCatalogEpochsByAgent={},this.conversations=[],this.activeConversations=[],this.messagesMap={},this.conversationTitles={},this.customConversationTitles={},this.processingConversations={},this.executionStatusMap={},this.workbenchExpanded=!1,this.workbenchMaximized=!1,this.workbenchPanelStateByRoute={},this.subagents={},this.activeSubagentId=null,this.activeRightPanel=null,this.pinnedSessions=[],this.clearWorkCenterBrowserState(),this.ws&&this.ws.close()}}})});function Vl(e,t){!e||typeof e.handleYeaftOutput!="function"||!t||e.handleYeaftOutput({event:t})}function ow(e){let t=String(e||""),s=2166136261;for(let n=0;n<t.length;n++)s^=t.charCodeAt(n),s=Math.imul(s,16777619)>>>0;return s>>>0}function Bl(e){if(!e)return Ks[0];let t=String(e).toLowerCase();return iw[t]||Ks[ow(t)%Ks.length]}function aw(e){return Bl(e).background}function lw(e){return Bl(e).foreground}function Hl(){let e=typeof window<"u"&&window.Pinia&&window.Pinia.useChatStore?window.Pinia.useChatStore():null;return e&&typeof e.locale=="string"?e.locale:typeof localStorage<"u"&&localStorage.getItem("locale")||""}function cw(e,t=""){return e?String(t||"").startsWith("zh")?e.descriptionZh||e.roleZh||e.description||e.role||"":e.description||e.role||e.descriptionZh||e.roleZh||"":""}var rw,Ks,iw,iA,us,sr=B(()=>{({defineStore:rw}=Pinia);Ks=[{key:"rat",label:"Rat",glyph:"R",background:"var(--vp-avatar-rat-bg)",foreground:"var(--vp-avatar-rat-fg)"},{key:"ox",label:"Ox",glyph:"O",background:"var(--vp-avatar-ox-bg)",foreground:"var(--vp-avatar-ox-fg)"},{key:"tiger",label:"Tiger",glyph:"T",background:"var(--vp-avatar-tiger-bg)",foreground:"var(--vp-avatar-tiger-fg)"},{key:"rabbit",label:"Rabbit",glyph:"B",background:"var(--vp-avatar-rabbit-bg)",foreground:"var(--vp-avatar-rabbit-fg)"},{key:"dragon",label:"Dragon",glyph:"D",background:"var(--vp-avatar-dragon-bg)",foreground:"var(--vp-avatar-dragon-fg)"},{key:"snake",label:"Snake",glyph:"S",background:"var(--vp-avatar-snake-bg)",foreground:"var(--vp-avatar-snake-fg)"},{key:"horse",label:"Horse",glyph:"H",background:"var(--vp-avatar-horse-bg)",foreground:"var(--vp-avatar-horse-fg)"},{key:"goat",label:"Goat",glyph:"G",background:"var(--vp-avatar-goat-bg)",foreground:"var(--vp-avatar-goat-fg)"},{key:"monkey",label:"Monkey",glyph:"M",background:"var(--vp-avatar-monkey-bg)",foreground:"var(--vp-avatar-monkey-fg)"},{key:"rooster",label:"Rooster",glyph:"K",background:"var(--vp-avatar-rooster-bg)",foreground:"var(--vp-avatar-rooster-fg)"},{key:"dog",label:"Dog",glyph:"D",background:"var(--vp-avatar-dog-bg)",foreground:"var(--vp-avatar-dog-fg)"},{key:"pig",label:"Pig",glyph:"P",background:"var(--vp-avatar-pig-bg)",foreground:"var(--vp-avatar-pig-fg)"}],iw=Object.freeze({steve:Ks[8],ada:Ks[3],linus:Ks[0],martin:Ks[4]}),iA=Ks.map(e=>e.background);us=rw("vp",{state:()=>({vps:{},vpOrder:[],emptyLibrary:!1,lastSnapshotAt:0,snapshotStatus:"idle",snapshotAgentId:null,snapshotRequestId:null,snapshotError:"",lastVpSnapshotAgentId:null,lastChange:null,dreamStatus:{},groupDreamStatus:{}}),getters:{vpList(e){return e.vpOrder.map(t=>e.vps[t]).filter(Boolean)},vpCount(e){return e.vpOrder.length},vpById:e=>t=>e.vps[t]||null,vpLabel:e=>t=>{let s=e.vps[t];return s?Hl().startsWith("zh")&&s.displayNameZh?s.displayNameZh:s.displayName||s.vpId||t:t},vpDescription:e=>t=>cw(e.vps[t],Hl()),vpInitial:e=>t=>{let s=e.vps[t],n=Hl().startsWith("zh"),r=s&&(s.avatar||n&&s.displayNameZh||s.displayName||s.vpId)||t||"?";return String(r).charAt(0).toUpperCase()||"?"},vpColor:e=>t=>{let s=e.vps[t];return s&&s.color?s.color:aw(t)},vpTextColor:()=>e=>lw(e),vpAvatarMotif:()=>e=>Bl(e),dreamStatusFor:e=>t=>e.dreamStatus[t]||{status:"idle",lastRunAt:null,lastResult:null,lastError:null},groupDreamStatusFor:e=>t=>e.groupDreamStatus[t]||{status:"idle",lastRunAt:null,lastResult:null,lastError:null}},actions:{applySnapshot(e,t=null,s=null){let n=this.snapshotAgentId||null;if(n&&t&&t!==n||s&&this.snapshotRequestId&&s!==this.snapshotRequestId)return!1;let r=e&&Array.isArray(e.vps)?e.vps:[];return this._setActiveSnapshot({vps:r,emptyLibrary:!!(e&&e.emptyLibrary),agentId:t||n||null,requestId:s||this.snapshotRequestId||null,receivedAt:Date.now()}),!0},beginSnapshot(e,t){this.vps={},this.vpOrder=[],this.emptyLibrary=!1,this.lastVpSnapshotAgentId=null,this.snapshotStatus="loading",this.snapshotAgentId=e||null,this.snapshotRequestId=t||null,this.snapshotError=""},failSnapshot(e,t,s=""){return!this.snapshotRequestId||!t||t!==this.snapshotRequestId||e&&this.snapshotAgentId&&e!==this.snapshotAgentId?!1:(this.snapshotStatus="error",this.snapshotAgentId=e||this.snapshotAgentId||null,this.snapshotRequestId=t||this.snapshotRequestId||null,this.snapshotError=String(s||"VP library request failed"),!0)},_setActiveSnapshot({vps:e,emptyLibrary:t,agentId:s,requestId:n,receivedAt:r}){this.vps={},this.vpOrder=[];for(let i of e||[])this._upsertInternal(i);this.emptyLibrary=!!t,this.lastSnapshotAt=r||Date.now(),this.lastVpSnapshotAgentId=s||null,this.snapshotStatus="ready",this.snapshotAgentId=s||null,this.snapshotRequestId=n||null,this.snapshotError=""},upsert(e,t=null,s=null){return s&&this.snapshotAgentId&&s!==this.snapshotAgentId?!1:(this._upsertInternal(e),e&&e.vpId&&(this.lastChange={vpId:e.vpId,kind:"updated",reason:t||null,at:Date.now()}),!0)},remove(e,t=null,s=null){return s&&this.snapshotAgentId&&s!==this.snapshotAgentId||!e?!1:(delete this.vps[e],this.vpOrder=this.vpOrder.filter(n=>n!==e),this.lastChange={vpId:e,kind:"removed",reason:t||"file.removed",at:Date.now()},!0)},_upsertInternal(e){if(!e||!e.vpId)return;let t=!!this.vps[e.vpId];this.vps[e.vpId]={...this.vps[e.vpId]||{},...e},t||this.vpOrder.push(e.vpId),this.emptyLibrary&&(this.emptyLibrary=!1)},triggerDream(e){if(!e)return;this.dreamStatus={...this.dreamStatus,[e]:{...this.dreamStatus[e]||{},status:"running",lastError:null}};let t=window.Pinia&&window.Pinia.useChatStore?window.Pinia.useChatStore():null;t&&typeof t.sendWsMessage=="function"&&t.sendWsMessage({type:"yeaft_dream_trigger",vpId:e})},triggerGroupDream(e,t={}){if(!e)return;this.groupDreamStatus={...this.groupDreamStatus,[e]:{...this.groupDreamStatus[e]||{},status:"running",lastError:null}};let s=window.Pinia&&window.Pinia.useChatStore?window.Pinia.useChatStore():null,n=Date.now();if(Vl(s,{type:"dream_progress",phase:"start",groupId:e,manual:!0,trigger:"manual",source:"header-button",ts:n}),!s||typeof s.sendWsMessage!="function"){Vl(s,{type:"yeaft_dream_result",groupId:e,success:!1,skipped:!0,skippedReason:"chat-store-unavailable",trigger:"manual",error:null});return}let r={type:"yeaft_dream_trigger",sessionId:e},i=t&&t.agentId?t.agentId:typeof s.agentIdForSession=="function"?s.agentIdForSession(e):s.currentAgent;i&&(r.agentId=i),s.sendWsMessage(r)===!1&&Vl(s,{type:"yeaft_dream_result",groupId:e,success:!1,skipped:!0,skippedReason:"websocket-not-open",trigger:"manual",error:null})},applyDreamStatus(e){if(!e)return;let t=e.sessionId;if(t){this.groupDreamStatus={...this.groupDreamStatus,[t]:{...this.groupDreamStatus[t]||{},status:e.status==="running"?"running":e.status||"idle"}};return}if(!e.vpId)return;let s=e.vpId;this.dreamStatus={...this.dreamStatus,[s]:{...this.dreamStatus[s]||{},status:e.status==="running"?"running":e.status||"idle"}}},applyDreamResult(e){if(!e)return;let t=!!e.success,s=!!e.skipped,n={mergedCount:e.mergedCount??null,extractedCount:e.extractedCount??null,entriesCreated:typeof e.entriesCreated=="number"?e.entriesCreated:e.mergedCount??e.extractedCount??0,skipped:s,skippedReason:e.skippedReason||null,sessionsProcessed:typeof e.sessionsProcessed=="number"?e.sessionsProcessed:null,sessionsSkipped:typeof e.sessionsSkipped=="number"?e.sessionsSkipped:null,targetsApplied:typeof e.targetsApplied=="number"?e.targetsApplied:null,durationMs:typeof e.durationMs=="number"?e.durationMs:null,llmCallCount:typeof e.llmCallCount=="number"?e.llmCallCount:0,inputTokens:typeof e.inputTokens=="number"?e.inputTokens:0,outputTokens:typeof e.outputTokens=="number"?e.outputTokens:0,totalTokens:typeof e.totalTokens=="number"?e.totalTokens:0,metrics:e.metrics||null,passBreakdown:e.passBreakdown||e.metrics?.passBreakdown||null,targetErrors:Array.isArray(e.targetErrors)?e.targetErrors:[]},r=t||s?null:e.error||null,i=s?"skipped":t?"success":"error",o=e.sessionId;if(o){this.groupDreamStatus={...this.groupDreamStatus,[o]:{status:i,lastRunAt:Date.now(),lastResult:n,lastError:r}};return}if(!e.vpId)return;let a=e.vpId;this.dreamStatus={...this.dreamStatus,[a]:{status:i,lastRunAt:Date.now(),lastResult:n,lastError:r}}}}})});function Nl(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"&&e){let t=Date.parse(e);if(Number.isFinite(t))return t}return 0}function mo(e){return!e||typeof e!="object"?0:Nl(e.lastMessageAt)||Nl(e.updatedAt)||Nl(e.createdAt)||0}function Wl(e,t){let s=mo(t)-mo(e);return s!==0?s:String(e?.id||"").localeCompare(String(t?.id||""))}function mg(e){return[...Array.isArray(e)?e:[]].sort(Wl)}var vo=B(()=>{});function vg(){try{if(typeof localStorage>"u")return{};let e=JSON.parse(localStorage.getItem(kg)||"{}");return e&&typeof e=="object"?e:{}}catch{return{}}}function dw(e){try{typeof localStorage<"u"&&localStorage.setItem(kg,JSON.stringify(e&&typeof e=="object"?e:{}))}catch{}}function yg(){try{return typeof localStorage>"u"?[]:ri(JSON.parse(localStorage.getItem(Sg)||"[]"))}catch{return[]}}function uw(e){try{typeof localStorage<"u"&&localStorage.setItem(Sg,JSON.stringify(ri(e)))}catch{}}function Ig(e,t){return`${e||""}${t||""}`}function Ps(e){return e&&e.agentId&&e.id?Ig(e.agentId,e.id):""}function ps(e,t){return t?e?Ig(e,t):String(t):""}function pw(e){return typeof e=="string"?e:String(e||"")}function Bt(e,t,s=null){let n=pw(t);if(!n)return"";let r=ps(s,n),i=r?e.sessions[r]:null;if(i&&(s||i.agentId||e.inventoryIdentityMode==="legacy-bare"))return r;if(s){let c=e.sessions[n];return e.inventoryIdentityMode==="legacy-bare"&&c&&!c.agentId?n:""}let o=e.sessions[n];if(o){if(o.agentId||e.inventoryIdentityMode==="legacy-bare")return n;let c=e.activeSessionKey?e.sessions[e.activeSessionKey]:null;return c?.agentId&&c.id===n?e.activeSessionKey:""}if(e.activeSessionKey&&e.sessions[e.activeSessionKey]?.id===n)return e.activeSessionKey;let a=e.sessionOrder.filter(c=>e.sessions[c]?.id===n),l=ii();if(l?.currentAgent){let c=a.find(d=>e.sessions[d]?.agentId===l.currentAgent);if(c)return c}return a[0]||""}function jl(e,t,s=null){return Bt(e,t,s)||""}function Ul(e){if(e.inventoryIdentityMode==="legacy-bare"){let t=e.activeSessionKey?e.sessions[e.activeSessionKey]:null,s=t&&!t.agentId?t:e.activeSessionId?e.sessions[e.activeSessionId]:null;e._retiredBareActiveSessionId=s&&!s.agentId&&s.id||null,e.sessionOrder=e.sessionOrder.filter(n=>e.sessions[n]?.agentId),e._retiredBareActiveSessionId&&(e.activeSessionId=null,e.activeSessionKey=null)}e.inventoryIdentityMode="agent-scoped"}function gw(e){let t=e._preferredExactSessionIdentity||null;if(!t)return!1;e._preferredExactSessionIdentity=null;let s=e.sessions[t.key]||null,n=ii(),r=s?.id===t.sessionId&&s.agentId===t.agentId,i=n?.currentView!=="yeaft"||typeof n.setActiveSessionFilter=="function";if(r&&i){if(e.activeSessionId=t.sessionId,e.activeSessionKey=t.key,n?.currentView==="yeaft")n.setActiveSessionFilter(t.sessionId,{agentId:t.agentId,force:!0});else if(n){n.yeaftActiveSessionFilter=t.sessionId,n.yeaftSessionAgentById={...n.yeaftSessionAgentById||{},[t.sessionId]:t.agentId};try{localStorage.setItem("lastViewedYeaftSession",t.key)}catch{}}return!0}if(e.activeSessionId=null,e.activeSessionKey=null,n?.yeaftActiveSessionFilter===t.sessionId&&(n.yeaftActiveSessionFilter=null),n?.yeaftSessionAgentById?.[t.sessionId]===t.agentId){let o={...n.yeaftSessionAgentById};delete o[t.sessionId],n.yeaftSessionAgentById=o}try{let o=Gr(localStorage.getItem("lastViewedYeaftSession")||"");o.agentId===t.agentId&&o.sessionId===t.sessionId&&localStorage.removeItem("lastViewedYeaftSession")}catch{}return!0}function yo(e){let t=e._retiredBareActiveSessionId||null;if(!t)return!1;let s=ii();if(e.inventoryIdentityMode==="legacy-bare"){let r=e.sessions[t];return e._retiredBareActiveSessionId=null,!r||r.agentId?!1:(e.activeSessionId=t,e.activeSessionKey=t,s?.currentView==="yeaft"&&typeof s.setActiveSessionFilter=="function"?s.setActiveSessionFilter(t,{force:!0}):s&&(s.yeaftActiveSessionFilter=t),!0)}let n=e.sessionOrder.filter(r=>{let i=e.sessions[r];return i?.agentId&&i.id===t});if(n.length===1){let r=n[0],i=e.activeSessionId===t&&e.activeSessionKey===r,o=e.sessions[r]?.agentId||null;return e.activeSessionId=t,e.activeSessionKey=r,i||(s?.currentView==="yeaft"&&typeof s.setActiveSessionFilter=="function"?(s.setActiveSessionFilter(t,{agentId:o,force:!0}),e._retiredBareActiveSessionId=t):s&&(s.yeaftActiveSessionFilter=t)),!0}e.activeSessionId=null,e.activeSessionKey=null,s?.yeaftActiveSessionFilter===t&&(s.yeaftActiveSessionFilter=null);try{let r=localStorage.getItem("lastViewedYeaftSession")||"";Gr(r).sessionId===t&&localStorage.removeItem("lastViewedYeaftSession")}catch{}return!0}function ri(e){let t=[],s=new Set;for(let n of Array.isArray(e)?e:[]){let r=typeof n=="string"?n:String(n||"");!r||s.has(r)||(s.add(r),t.push(r))}return t}function Kl(e,t){let s=ri(e),n=new Set(s),r=ri(t).filter(o=>n.has(o)),i=new Set(r);return[...r,...s.filter(o=>!i.has(o))]}function bo(e,t=!1){return!e||typeof e!="object"?!!t:Object.prototype.hasOwnProperty.call(e,"pinned")?e.pinned===!0:Object.prototype.hasOwnProperty.call(e,"isPinned")?e.isPinned===!0:!!t}function bg(e){return!e||typeof e!="object"?!1:e.running===!0||e.active===!0||e.isActive===!0||e.isRunning===!0}function wg(e){if(!e||typeof e!="object")return 0;let t=e.latestActivityAt||e.lastActivityAt||e.lastMessageAt||e.updatedAt||0;if(typeof t=="number"&&Number.isFinite(t))return t;if(typeof t=="string"&&t){let s=Date.parse(t);return Number.isFinite(s)?s:0}return 0}function ii(){try{if(typeof window<"u"&&window.Pinia&&typeof window.Pinia.useChatStore=="function")return window.Pinia.useChatStore()}catch{}return null}var kg,Sg,fw,Cg,Ag=B(()=>{vo();io();kg="yeaft-session-order-by-agent",Sg="yeaft-session-order-global";({defineStore:fw}=Pinia);Cg=fw("sessions",{state:()=>({sessions:{},sessionOrder:[],activeSessionId:null,activeSessionKey:null,inventoryIdentityMode:"empty",_retiredBareActiveSessionId:null,_preferredExactSessionIdentity:null,lastSnapshotAt:0,lastCrudResult:null,pending:{}}),getters:{sessionList(e){let t=e.sessionOrder.map(d=>e.sessions[d]).filter(Boolean),s=ii(),n=s&&Array.isArray(s.pinnedSessions)?new Set(s.pinnedSessions):new Set;for(let d of t)d&&d.id&&d.pinned&&n.add(d.id);let r=[],i=[];for(let d of t)d.pinned||!d.agentId&&n.has(d.id)?r.push(d):i.push(d);let o=d=>[...d].sort((u,g)=>{let p=Number.isFinite(u?.sortOrder)?u.sortOrder:Number.MAX_SAFE_INTEGER,f=Number.isFinite(g?.sortOrder)?g.sortOrder:Number.MAX_SAFE_INTEGER;return p!==f?p-f:Wl(u,g)}),a=[...o(r),...o(i)],l=yg();if(l.length===0)return a;let c=new Map(l.map((d,u)=>[d,u]));return a.sort((d,u)=>{let g=c.has(Ps(d))?c.get(Ps(d)):Number.MAX_SAFE_INTEGER,p=c.has(Ps(u))?c.get(Ps(u)):Number.MAX_SAFE_INTEGER;return g!==p?g-p:0})},sessionCount(e){return e.sessionOrder.length},sessionById:e=>(t,s=null)=>{let n=Bt(e,t,s);return n&&e.sessions[n]||null},activeSession(e){return e.activeSessionKey&&e.sessions[e.activeSessionKey]||null},hasLoadedSnapshot(e){return e.lastSnapshotAt>0},isEmpty(e){return e.sessionOrder.length===0},activeNeedsInvite(e){let t=e.activeSessionKey?e.sessions[e.activeSessionKey]:null;return t?!t.defaultVpId&&(!Array.isArray(t.roster)||t.roster.length===0):!1}},actions:{applySnapshot(e,t=null,{deferActivation:s=!1}={}){let n=Array.isArray(e)?e:[],r=!1;if(t){Ul(this);let o={...this.sessions},a=new Set;for(let p of n){if(!p||!p.id)continue;let f=ps(t,p.id);a.add(f),o[f]=this._normalize(p,t,bo(this.sessions[f]))}for(let p of this.sessionOrder){let f=this.sessions[p];f&&f.agentId===t&&!a.has(p)&&delete o[p]}let l=this.sessionOrder.filter(p=>o[p]),c=new Set(l),d=[];for(let p of n){if(!p||!p.id)continue;let f=ps(t,p.id);o[f]&&!c.has(f)&&d.push(f)}this.sessions=o;let u=[...l,...d],g=yg();if(g.length>0){let p=new Map(u.map(b=>[Ps(o[b]),b]).filter(([b])=>b)),f=g.map(b=>p.get(b)).filter(Boolean),m=new Set(f);u=[...f,...u.filter(b=>!m.has(b))];let v=new Map(g.map((b,h)=>[b,h]));for(let b of u){let h=Ps(o[b]);h&&v.has(h)&&(o[b]={...o[b],sortOrder:v.get(h)})}}if(t&&g.length===0){let p=vg(),f=ri(p[t]);if(f.length>0){let m=f.map(y=>ps(t,y)),v=new Set(m),b=Kl(u.filter(y=>o[y]?.agentId===t),m),h=this.sessionOrder.some(y=>o[y]?.agentId===t),k=0;h?u=this.sessionOrder.filter(y=>o[y]).map(y=>o[y]?.agentId===t?b[k++]:y).concat(b.slice(k)):u=u.map(y=>o[y]?.agentId===t?b[k++]:y);let S=new Map(m.map((y,w)=>[y,w]));for(let y of b)o[y]&&v.has(y)&&(o[y]={...o[y],sortOrder:S.get(y)})}}this.sessionOrder=u}else{if(this.inventoryIdentityMode==="agent-scoped")return;if(Object.values(this.sessions).some(c=>c&&c.agentId)){this.inventoryIdentityMode="agent-scoped";return}let a={},l=[];for(let c of n){if(!c||!c.id)continue;let d=ps(null,c.id);a[d]=this._normalize(c,null,bo(this.sessions[d])),l.push(d)}this.sessions=a,this.sessionOrder=l,this.inventoryIdentityMode="legacy-bare"}s||(r=gw(this)||yo(this)),this.lastSnapshotAt=Date.now();let i=ii();if(i&&t){let o={...i.yeaftSessionAgentById||{}};for(let a of n)a&&a.id&&!o[a.id]&&(o[a.id]=t);i.yeaftSessionAgentById=o}if(!s&&!r){let o=null;try{o=localStorage.getItem("lastViewedYeaftSession")||null}catch{}let l=(o?this.sessions[o]:null)?o:o?Bt(this,o,t):"",c=l?this.sessions[l]:null,d=c&&(!t||c.agentId===t),u=this.sessionOrder.filter(k=>this.sessions[k]&&(!t||this.sessions[k].agentId===t)&&this.sessions[k].running).sort((k,S)=>wg(this.sessions[S])-wg(this.sessions[k]))[0]||null,g=u?this.sessions[u]?.id:null,p=this.sessionList[0]||null,f=p?.id||null,m=f?Bt(this,f,p?.raw?.agentId||null):"",v=g||(d?c.id:null)||f,b=u||(d?l:"")||m||jl(this,v,t),h=this.activeSessionKey?this.sessions[this.activeSessionKey]?.agentId:null;if(this.activeSessionId&&!Bt(this,this.activeSessionId,h)?(this.activeSessionId=v,this.activeSessionKey=b||null):!this.activeSessionId&&this.sessionOrder.length>0&&!this._retiredBareActiveSessionId?(this.activeSessionId=v,this.activeSessionKey=b||null):this.activeSessionId&&(this.activeSessionKey=jl(this,this.activeSessionId,h)||this.activeSessionKey),i&&!this._retiredBareActiveSessionId){let k=this.activeSessionId||v,S=null;if((i.yeaftActiveSessionFilter&&!Bt(this,i.yeaftActiveSessionFilter)||!i.yeaftActiveSessionFilter&&k)&&(S=k),S){let y=jl(this,S),w=y&&this.sessions[y]?.agentId||null;i.currentView==="yeaft"&&typeof i.setActiveSessionFilter=="function"?i.setActiveSessionFilter(S,{agentId:w,force:!0}):i.yeaftActiveSessionFilter=S,this.activeSessionKey=y||this.activeSessionKey}}}if(i&&typeof i.applyServerPinSnapshot=="function"){let o=new Set;for(let l of n){if(!l||!l.id)continue;let c=ps(t,l.id),d=this.sessions[c];d&&d.pinned&&o.add(l.id)}let a=l=>{let c=Bt(this,l,t),d=c?this.sessions[c]:null;return d?d.agentId===t:!1};i.applyServerPinSnapshot(t,o,a)}},applyRosterChange(e,t=null){if(!e)return;let s=e.sessionId||e.groupId;if(!s)return;let n=t||e.agentId||null;if(n)Ul(this);else if(this.inventoryIdentityMode!=="legacy-bare")return;let r=Bt(this,s,n)||ps(n,s),i=this.sessions[r];if(!i){let o=this._normalize({id:s,name:e.name||s,roster:Array.isArray(e.roster)?e.roster:[],defaultVpId:e.defaultVpId||null},n);this.sessions[r]=o,this.sessionOrder.push(r),yo(this);return}this.sessions[r]={...i,name:e.name||i.name,roster:Array.isArray(e.roster)?e.roster.slice():i.roster,defaultVpId:e.defaultVpId!=null?e.defaultVpId:i.defaultVpId,announcement:typeof e.announcement=="string"?e.announcement:i.announcement},yo(this)},applyCrudResult(e,t=null,{activate:s=!0}={}){if(!e)return;this.lastCrudResult={...e,at:Date.now()},e.requestId&&this.pending[e.requestId]&&delete this.pending[e.requestId];let n=e.session||e.group||null,r=t||e.agentId||n?.agentId||null;e.ok&&e.op==="list"&&Array.isArray(e.sessions)&&this.applySnapshot(e.sessions,r),e.ok&&(e.op==="create"||e.op==="copy"||e.op==="restore")&&n&&n.id&&this.applySnapshotUpsert(n,r)&&s&&this.setActive(n.id,r),e.ok&&(e.op==="rename"||e.op==="update")&&n&&n.id&&this.applySnapshotUpsert(n,r);let i=e.sessionId||e.groupId,o=this.inventoryIdentityMode==="legacy-bare",a=i&&(r||o)?Bt(this,i,r):"";if(e.ok&&(e.op==="archive"||e.op==="delete")&&i&&a&&(delete this.sessions[a],this.sessionOrder=this.sessionOrder.filter(l=>l!==a),(this.activeSessionKey===a||o&&this.activeSessionId===i)&&(this.activeSessionKey=this.sessionOrder[0]||null,this.activeSessionId=this.activeSessionKey&&this.sessions[this.activeSessionKey]?.id||null)),e.ok&&e.op==="update_config"&&i){let l=a?this.sessions[a]:null;l&&(this.sessions[a]={...l,config:e.config&&typeof e.config=="object"?{...e.config}:{}})}},applySnapshotUpsert(e,t=null){if(!e||!e.id)return"";let s=t||e.agentId||null;if(s)Ul(this);else if(this.inventoryIdentityMode!=="legacy-bare")return"";let n=Bt(this,e.id,s)||ps(s,e.id),r=!!this.sessions[n],i=this.sessions[n]||{};return this.sessions[n]={...i,...this._normalize(e,s,bo(i))},r||this.sessionOrder.push(n),yo(this),n},setActive(e,t=null){let s=Bt(this,e,t);e&&s&&this.sessions[s]?(this.activeSessionId=e,this.activeSessionKey=s,this._retiredBareActiveSessionId=null):(this.activeSessionId=null,this.activeSessionKey=null)},reorderSessionsForAgent(e,t){if(!e)return[];let s=this.sessionOrder.filter(l=>this.sessions[l]?.agentId===e),n=Kl(s,t.map(l=>ps(e,l)));if(n.length===0)return[];let r=new Map(n.map((l,c)=>[l,c])),i=0;this.sessionOrder=this.sessionOrder.map(l=>this.sessions[l]?.agentId===e?n[i++]:l);for(let l of n)this.sessions[l]={...this.sessions[l],sortOrder:r.get(l)};let o=vg(),a=n.map(l=>this.sessions[l]?.id).filter(Boolean);return o[e]=a,dw(o),a},reorderSessionsGlobally(e){let t=this.sessionOrder.map(a=>Ps(this.sessions[a])).filter(Boolean),s=Kl(t,e);if(s.length===0)return[];let n=new Map(this.sessionOrder.map(a=>[Ps(this.sessions[a]),a]).filter(([a])=>a)),r=s.map(a=>n.get(a)).filter(Boolean),i=new Set(r);this.sessionOrder=[...r,...this.sessionOrder.filter(a=>!i.has(a))];let o=new Map(s.map((a,l)=>[a,l]));for(let a of this.sessionOrder){let l=Ps(this.sessions[a]);l&&o.has(l)&&(this.sessions[a]={...this.sessions[a],sortOrder:o.get(l)})}return uw(s),s.map(a=>{let l=n.get(a),c=l?this.sessions[l]:null;return c?{agentId:c.agentId,sessionId:c.id}:null}).filter(Boolean)},applyPinState(e,t,s=null){if(!s&&this.inventoryIdentityMode!=="legacy-bare")return;let n=Bt(this,e,s);!e||!n||!this.sessions[n]||(this.sessions[n]={...this.sessions[n],pinned:!!t})},markPending(e,t){e&&(this.pending[e]=t)},clearLastResult(){this.lastCrudResult=null},resetInventory(){this.sessions={},this.sessionOrder=[],this.activeSessionId=null,this.activeSessionKey=null,this.inventoryIdentityMode="empty",this._retiredBareActiveSessionId=null,this._preferredExactSessionIdentity=null,this.lastSnapshotAt=0},beginInventoryCommit(e=null,t=null){if(this.resetInventory(),e&&t){let s=ps(t,e);this.activeSessionId=e,this.activeSessionKey=s,this._preferredExactSessionIdentity={sessionId:e,agentId:t,key:s}}else e&&(this._retiredBareActiveSessionId=e)},_normalize(e,t=null,s=!1){return{id:e.id,name:e.name||e.id,roster:Array.isArray(e.roster)?e.roster.slice():[],defaultVpId:e.defaultVpId||null,announcement:typeof e.announcement=="string"?e.announcement:"",config:e.config&&typeof e.config=="object"?{...e.config}:{},workDir:typeof e.workDir=="string"?e.workDir:"",createdAt:e.createdAt||null,updatedAt:e.updatedAt||null,lastMessageAt:e.lastMessageAt||null,running:bg(e),active:bg(e),runningVpCount:Number.isFinite(Number(e.runningVpCount))?Number(e.runningVpCount):0,latestActivityAt:e.latestActivityAt||e.lastActivityAt||e.lastMessageAt||null,agentId:t||e.agentId||null,pinned:bo(e,s),sortOrder:Number.isFinite(e.sortOrder)?e.sortOrder:null}}}})});function wo(){return globalThis.crypto?.randomUUID?.()||`browser-${Date.now()}-${Math.random().toString(16).slice(2)}`}function Nt(e,t){return`${String(e||"")}\0${String(t||"")}`}function xg(e,t,s,n){return`${Nt(e,t)}\0${String(s||"")}\0${String(n||"")}`}function zl(e,t="Browser Runtime request failed"){return e?.safeError||e?.code||t}function Yl(e){return globalThis.Vue?.markRaw?.(e)||e}var hw,mw,vw,yw,bw,ww,kw,ko,Gl=B(()=>{({defineStore:hw}=Pinia),mw=3e4,vw=60*6e4,yw=2e4,bw=5e3,ww=60*6e4,kw=256;ko=hw("browser",{state:()=>({sessions:{},pending:{},peers:{},cancelledPeers:{},errors:{},errorCodes:{},peerDiagnostics:{},runtimeStatus:{},installProgress:{},protocolSupported:null,connectionEpoch:0,lastError:null,_cancelledPeerCleanupTimer:null,_messageListenerInstalled:!1}),actions:{chatStore(){return window.Pinia?.useChatStore?.()||null},installMessageListener(){if(this._messageListenerInstalled||typeof window>"u")return;this._messageListenerInstalled=!0;let e=this.chatStore();this.protocolSupported=e?.browserRuntimeProtocolSupported??null,window.addEventListener("browser-runtime-message",t=>this.handleMessage(t.detail)),window.addEventListener("browser-runtime-transport-reset",()=>this.handleTransportReset())},send(e){if(!this.chatStore()?.sendWsMessage?.(e))throw new Error("Browser Runtime transport unavailable")},beginRequest(e,t,s=mw){let n=wo();return new Promise((r,i)=>{let o=setTimeout(()=>{delete this.pending[n],i(new Error(`${e} timed out`))},s);this.pending[n]={type:e,resolve:r,reject:i,timer:o,payload:t};try{this.send({type:e,requestId:n,...t})}catch(a){clearTimeout(o),delete this.pending[n],i(a)}})},completeRequest(e,t,s=null){let n=e?this.pending[e]:null;return n?(clearTimeout(n.timer),delete this.pending[e],s?n.reject(s):n.resolve(t),!0):!1},clearCancelledPeers(){clearTimeout(this._cancelledPeerCleanupTimer),this._cancelledPeerCleanupTimer=null,this.cancelledPeers={}},pruneCancelledPeers(e=Date.now()){clearTimeout(this._cancelledPeerCleanupTimer),this._cancelledPeerCleanupTimer=null;for(let[s,n]of Object.entries(this.cancelledPeers))Number(n.expiresAt)<=e&&delete this.cancelledPeers[s];let t=Math.min(...Object.values(this.cancelledPeers).map(s=>Number(s.expiresAt)).filter(Number.isFinite));Number.isFinite(t)&&(this._cancelledPeerCleanupTimer=setTimeout(()=>this.pruneCancelledPeers(),Math.max(1,t-Date.now())))},rememberCancelledPeer(e){let t=Date.now();for(this.pruneCancelledPeers(t);Object.keys(this.cancelledPeers).length>=kw;)delete this.cancelledPeers[Object.keys(this.cancelledPeers)[0]];this.cancelledPeers[xg(e.agentId,e.browserSessionId,e.requestId,e.connectionGeneration)]={agentId:e.agentId,browserSessionId:e.browserSessionId,requestId:e.requestId,connectionGeneration:e.connectionGeneration,expiresAt:t+ww},this.pruneCancelledPeers(t)},takeCancelledPeer(e){let t=xg(e.agentId,e.browserSessionId,e.requestId,e.connectionGeneration),s=this.cancelledPeers[t];return!s||(delete this.cancelledPeers[t],this.pruneCancelledPeers(),Number(s.expiresAt)<=Date.now())?null:s},async getRuntimeStatus(e){let t=await this.beginRequest("browser_runtime_status",{agentId:e});return this.runtimeStatus[e]=t,t},async installRuntime(e,t){let s=await this.beginRequest("browser_runtime_install",{agentId:e,confirmedBuildId:t?.buildId,confirmedDownloadBytes:Number(t?.downloadBytes)||0},vw);return this.runtimeStatus[e]=s,delete this.installProgress[e],s},async enableRuntime(e){let t=await this.beginRequest("browser_runtime_enable",{agentId:e},6e4);return this.runtimeStatus[e]=t,t},async setupRuntime(e,t){return t?.installed?this.enableRuntime(e):this.installRuntime(e,t)},async createSession({agentId:e,sourceRef:t=null,initialUrl:s="about:blank",viewport:n=null,locale:r="en-US"}){let i=await this.beginRequest("browser_session_create",{agentId:e,sourceRef:t,options:{initialUrl:s,viewport:n||{width:1280,height:720,deviceScaleFactor:1},locale:r,capturePreference:"auto"}},45e3);return this.sessions[Nt(e,i.browserSessionId)]=i,i},async listSessions(e){let t=await this.beginRequest("browser_session_list",{agentId:e}),s=new Set((t.sessions||[]).map(n=>Nt(e,n.browserSessionId)));for(let n of Object.keys(this.sessions))n.startsWith(`${e}\0`)&&!s.has(n)&&delete this.sessions[n];for(let n of t.sessions||[])this.sessions[Nt(e,n.browserSessionId)]={...n,agentId:e};return t.sessions||[]},async closeSession(e,t,s){await this.beginRequest("browser_session_close",{agentId:e,browserSessionId:t,expectedRevision:s})},async attach({agentId:e,browserSessionId:t,videoElement:s}){if(!s)throw new Error("Browser video element required");let n=Nt(e,t);delete this.errors[n],delete this.errorCodes[n];let r=Number(this.connectionEpoch||0)+1;this.connectionEpoch=r;let i=wo(),o={localKey:n,agentId:e,browserSessionId:t,requestId:i,peerId:null,connectionGeneration:r,connection:null,videoElement:Yl(s),state:"preparing",remoteState:null,pendingOffer:null,pendingCandidates:[],answerPromise:null,channels:{},controlSeq:0,pointerSeq:0,iceServerCount:null,diagnostics:{connectionState:"new",iceConnectionState:"new",iceGatheringState:"new",candidateErrors:0,lastCandidateError:null},attachTimer:null,disconnectedTimer:null};return this.peers[n]=o,this.peerDiagnostics[n]=o.diagnostics,o.attachTimer=setTimeout(()=>{if(o.attachTimer=null,this.peers[n]!==o||o.connection?.connectionState==="connected")return;let a=o.iceServerCount===0?"browser_ice_servers_missing":o.diagnostics.iceConnectionState==="failed"?"browser_ice_connection_failed":"browser_peer_attach_timeout";this.failPeer(o,new Error(a),a)},yw),this.send({type:"browser_peer_attach",agentId:e,browserSessionId:t,requestId:i,connectionGeneration:r,role:"interactive",clientCapabilities:{codecs:["video/VP8"],maxWidth:1920,maxHeight:1080,maxFps:30}}),o},async preparePeer(e,t){if(this.peers[e.localKey]!==e||e.connectionGeneration!==t.connectionGeneration)return;if(e.connection){if(e.peerId===t.peerId)return;throw new Error("Browser peer identity changed during preparation")}e.peerId=t.peerId;let s=Array.isArray(t.iceServers)?t.iceServers:[];e.iceServerCount=s.length;let n=Yl(new RTCPeerConnection({iceServers:s,iceTransportPolicy:t.iceTransportPolicy==="relay"?"relay":"all"}));e.connection=n,e.diagnostics.iceConnectionState=n.iceConnectionState||"new",e.diagnostics.iceGatheringState=n.iceGatheringState||"new",e.state="prepared",n.ondatachannel=i=>{if(this.peers[e.localKey]!==e)return;let o=i.channel;if(!["browser.control.v1","browser.pointer.v1","browser.state.v1"].includes(o?.label)){o?.close?.();return}e.channels[o.label]=Yl(o),o.onclose=()=>{e.channels[o.label]===o&&delete e.channels[o.label]}},n.ontrack=i=>{this.peers[e.localKey]===e&&(e.videoElement.srcObject=i.streams[0]||new MediaStream([i.track]),e.videoElement.play().catch(()=>{}))},n.onicecandidate=i=>{if(this.peers[e.localKey]===e)try{this.send({type:"browser_peer_ice_candidate",agentId:e.agentId,browserSessionId:e.browserSessionId,peerId:e.peerId,connectionGeneration:e.connectionGeneration,candidate:i.candidate?i.candidate.toJSON():null})}catch{}},n.onicecandidateerror=i=>{this.peers[e.localKey]===e&&(e.diagnostics.candidateErrors+=1,e.diagnostics.lastCandidateError={address:typeof i.address=="string"?i.address:null,port:Number(i.port)||null,url:typeof i.url=="string"?i.url:null,errorCode:Number(i.errorCode)||null,errorText:typeof i.errorText=="string"?i.errorText.slice(0,256):null})},n.oniceconnectionstatechange=()=>{this.peers[e.localKey]===e&&(e.diagnostics.iceConnectionState=n.iceConnectionState||"new")},n.onicegatheringstatechange=()=>{this.peers[e.localKey]===e&&(e.diagnostics.iceGatheringState=n.iceGatheringState||"new")},n.onconnectionstatechange=()=>{if(this.peers[e.localKey]===e){if(e.state=n.connectionState,e.diagnostics.connectionState=n.connectionState||"new",e.diagnostics.iceConnectionState=n.iceConnectionState||"new",e.diagnostics.iceGatheringState=n.iceGatheringState||"new",n.connectionState==="connected"){clearTimeout(e.attachTimer),e.attachTimer=null,clearTimeout(e.disconnectedTimer),e.disconnectedTimer=null;return}if(n.connectionState==="disconnected"){e.disconnectedTimer||(e.disconnectedTimer=setTimeout(()=>{if(e.disconnectedTimer=null,this.peers[e.localKey]!==e||n.connectionState==="connected")return;let i=e.iceServerCount===0?"browser_ice_servers_missing":"browser_ice_connection_failed";this.failPeer(e,new Error(i),i)},bw));return}if(["failed","closed"].includes(n.connectionState)){let i=e.iceServerCount===0?"browser_ice_servers_missing":"browser_ice_connection_failed";this.failPeer(e,new Error(i),i)}}};let r=e.pendingOffer;e.pendingOffer=null,r&&await this.acceptOffer(e,r)},async acceptOffer(e,t){if(!(this.peers[e.localKey]!==e||e.connectionGeneration!==Number(t.connectionGeneration))){if(!e.connection){(!e.peerId||e.peerId===t.peerId)&&(e.pendingOffer||(e.pendingOffer=t));return}if(e.peerId===t.peerId){if(e.answerPromise)return e.answerPromise;e.answerPromise=(async()=>{if(await e.connection.setRemoteDescription(t.description),await e.connection.setLocalDescription(await e.connection.createAnswer()),this.peers[e.localKey]===e){this.send({type:"browser_peer_answer",agentId:e.agentId,browserSessionId:e.browserSessionId,peerId:e.peerId,connectionGeneration:e.connectionGeneration,description:e.connection.localDescription});for(let s of e.pendingCandidates.splice(0))await e.connection.addIceCandidate(s)}})();try{await e.answerPromise}finally{e.answerPromise=null}}}},async acceptCandidate(e,t){if(!(this.peers[e.localKey]!==e||e.connectionGeneration!==Number(t.connectionGeneration)||!t.candidate)){if(!e.connection){(!e.peerId||e.peerId===t.peerId)&&e.pendingCandidates.push(t.candidate);return}e.peerId===t.peerId&&(e.connection.remoteDescription?await e.connection.addIceCandidate(t.candidate):e.pendingCandidates.push(t.candidate))}},interactiveReady(e,t){let s=this.peers[Nt(e,t)];return s?.state==="connected"&&s.channels["browser.control.v1"]?.readyState==="open"&&s.channels["browser.pointer.v1"]?.readyState==="open"},sendControl(e,t,s){let n=this.peers[Nt(e,t)],r=n?.channels["browser.control.v1"];return!n||n.state!=="connected"||r?.readyState!=="open"?!1:(r.send(JSON.stringify({version:1,connectionGeneration:n.connectionGeneration,controlSeq:++n.controlSeq,action:s})),!0)},sendPointer(e,t,s){let n=this.peers[Nt(e,t)],r=n?.channels["browser.pointer.v1"];return!n||n.state!=="connected"||r?.readyState!=="open"?!1:(r.send(JSON.stringify({version:1,connectionGeneration:n.connectionGeneration,pointerSeq:++n.pointerSeq,action:s})),!0)},detach(e,t,{notify:s=!0}={}){let n=Nt(e,t),r=this.peers[n];if(r){if(delete this.peers[n],clearTimeout(r.attachTimer),r.attachTimer=null,clearTimeout(r.disconnectedTimer),r.disconnectedTimer=null,s&&!r.peerId&&this.rememberCancelledPeer(r),s&&r.peerId)try{this.send({type:"browser_peer_detach",requestId:wo(),agentId:e,browserSessionId:t,peerId:r.peerId,connectionGeneration:r.connectionGeneration})}catch{}this.errorCodes[n]||delete this.peerDiagnostics[n];for(let i of Object.values(r.channels||{}))try{i?.close?.()}catch{}r.channels={};try{r.connection?.close()}catch{}r.videoElement&&(r.videoElement.srcObject=null)}},failPeer(e,t,s=null){this.peers[e.localKey]===e&&(this.lastError=t?.message||String(t),this.errors[e.localKey]=this.lastError,s?this.errorCodes[e.localKey]=s:delete this.errorCodes[e.localKey],this.detach(e.agentId,e.browserSessionId,{notify:!0}))},handleTransportReset(){this.protocolSupported=null,this.connectionEpoch+=1;for(let e of Object.values(this.pending))clearTimeout(e.timer),e.reject(new Error("Browser Runtime connection changed"));this.pending={};for(let e of Object.values(this.peers))this.detach(e.agentId,e.browserSessionId,{notify:!1});this.peers={},this.runtimeStatus={},this.installProgress={},this.errors={},this.errorCodes={},this.peerDiagnostics={},this.clearCancelledPeers()},handleMessage(e){if(!e?.type)return;if(e.type==="client_hello_ack"){this.protocolSupported=e.browserRuntimeProtocol===1;return}if(e.type==="auth_result"){this.protocolSupported=!1;return}if(e.type==="browser_runtime_error"){let n=new Error(zl(e));n.code=e.code,this.completeRequest(e.requestId,null,n)||(this.lastError=n.message);return}if(e.type==="browser_runtime_install_progress"){this.installProgress[e.agentId]={downloadedBytes:Number(e.downloadedBytes)||0,totalBytes:Number(e.totalBytes)||0};return}if(e.type==="browser_runtime_status_result"){this.runtimeStatus[e.agentId]=e,this.completeRequest(e.requestId,e),e.state!=="installing"&&delete this.installProgress[e.agentId];return}if(e.type==="browser_session_error"){let n=new Error(zl(e));n.code=e.code,this.completeRequest(e.requestId,null,n)||(this.lastError=n.message);return}if(e.type==="browser_session_created"){this.sessions[Nt(e.agentId,e.browserSessionId)]=e,this.completeRequest(e.requestId,e);return}if(e.type==="browser_session_list_result"){this.completeRequest(e.requestId,e);return}if(e.type==="browser_session_snapshot"){let n=Nt(e.agentId,e.browserSessionId);this.sessions[n]=e,this.completeRequest(e.requestId,e),["closed","failed"].includes(e.state)&&this.detach(e.agentId,e.browserSessionId,{notify:!1});return}let t=Nt(e.agentId,e.browserSessionId),s=this.peers[t];if(!s||s.connectionGeneration!==Number(e.connectionGeneration)){if(e.type==="browser_peer_prepared"||e.type==="browser_peer_error"||e.type==="browser_peer_state"&&["failed","disconnected","closed"].includes(e.state)){let n=this.takeCancelledPeer(e);if(n&&e.type==="browser_peer_prepared")try{this.send({type:"browser_peer_detach",requestId:wo(),agentId:n.agentId,browserSessionId:n.browserSessionId,peerId:e.peerId,connectionGeneration:n.connectionGeneration})}catch{}}return}if(e.type==="browser_peer_error")this.failPeer(s,new Error(zl(e,"Browser peer failed")),e.code||null);else if(e.type==="browser_peer_prepared")this.preparePeer(s,e).catch(n=>this.failPeer(s,n));else if(e.type==="browser_peer_offer")this.acceptOffer(s,e).catch(n=>this.failPeer(s,n));else if(e.type==="browser_peer_ice_candidate")this.acceptCandidate(s,e).catch(n=>this.failPeer(s,n));else if(e.type==="browser_peer_state"&&e.state&&(s.remoteState=e.state,["failed","disconnected","closed"].includes(e.state))){let n=s.iceServerCount===0?"browser_ice_servers_missing":"browser_ice_connection_failed";this.failPeer(s,new Error(n),n)}}}})});function So(){try{if(window.Pinia&&typeof window.Pinia.useAuthStore=="function")return window.Pinia.useAuthStore()}catch{}return null}function Ql(){try{return localStorage.getItem("authToken")||null}catch{return null}}function Pg(){let e=So();if(e)try{return e.getActiveToken?.()||e.token||Ql()}catch{return e.token||Ql()}return Ql()}function Iw(e,t){if(!e)return!1;let s=Pg();if(s&&s!==t)return!1;try{localStorage.setItem("authToken",e)}catch{}let n=So();return n&&(n.token=e),!0}function Cw(e){try{let t=typeof e=="string"?e:e?.url;return!t||typeof window>"u"||!window.location?null:new URL(t,window.location.href)}catch{return null}}function Mg(e){return!e||typeof window>"u"||!window.location?!1:e.origin===window.location.origin&&e.pathname.startsWith("/api/")}function Aw(e){if(!e)return!1;let t=e.pathname;return!!(Sw.has(t)||t.startsWith("/api/auth/sso/poll/")||/^\/api\/auth\/sso\/[^/]+\/start(?:-qr)?$/.test(t))}function xw(e,t){return t?.headers?new Headers(t.headers):e&&typeof e=="object"&&e.headers?new Headers(e.headers):new Headers}function Tw(e){let t=e.get("Authorization");return!t||!t.startsWith("Bearer ")?null:t.slice(7)}function Mw(e,t){return{...e||{},headers:t}}function Pw(e,t,s,n){let r=So();r&&typeof r.handleAuthResponse=="function"?r.handleAuthResponse(e,t,s,n):r&&typeof r.handleAuthFailure=="function"&&n&&r.handleAuthFailure(void 0,t,s)}function Rg(){if(Tg||typeof window>"u"||!window.fetch)return;Tg=!0;let e=window.fetch.bind(window);window.fetch=async function(s,n){let r=Cw(s),i=Mg(r)&&!Aw(r),o=Mg(r)?{...n||{},credentials:"same-origin"}:n,a=null,l=i?So():null,c=l?.authGeneration,d=!!l?.isAuthenticated;if(i){let g=xw(s,n);a=Tw(g),a||(a=Pg(),a&&(g.set("Authorization",`Bearer ${a}`),o=Mw(o,g)))}let u=await e(s,o);try{let g=u.headers&&u.headers.get&&u.headers.get("X-New-Token");g&&Iw(g,a),i&&u.status===401&&Pw(u,a,c,d)}catch{}return u}}var Tg,Sw,_g=B(()=>{Tg=!1,Sw=new Set(["/api/auth/mode","/api/auth/login","/api/auth/aad","/api/auth/verify","/api/auth/verify-totp","/api/auth/setup-totp","/api/auth/register","/api/auth/password-reset/request","/api/auth/password-reset/verify"])});var Eg,Dg,Xl=B(()=>{Eg={"quickSend.title":"Quick send","quickSend.description":"Add up to 5 send buttons for this Agent. Each sends your current message with its model and optional turn overrides.","quickSend.empty":"No quick sends configured. No extra send buttons are shown.","quickSend.offline":"This Agent is offline. Reconnect to load or save quick sends.","quickSend.entry":"Quick send {index}","quickSend.name":"Button name","quickSend.model":"Model","quickSend.chooseModel":"Choose a model","quickSend.noModels":"Configure models in the LLM category first.","quickSend.effort":"Reasoning effort","quickSend.maxOutputTokens":"Maximum output tokens","quickSend.default":"Default","quickSend.outputLimit":"Leave blank to use the model default: {max} tokens (also the maximum).","quickSend.add":"Add quick send","quickSend.remove":"Remove","quickSend.limit":"Maximum 5 quick sends.","quickSend.nameRequired":"Enter a button name (1\u201380 characters).","quickSend.modelRequired":"Choose an available model for each quick send.","quickSend.effortInvalid":"The selected effort is not available for this model.","quickSend.outputInvalid":"Output tokens must be a positive integer no greater than {max}.","quickSend.loadFailed":"Could not load quick sends. Refresh to retry.","quickSend.saveFailed":"Save was not confirmed. Refresh to check the saved configuration before retrying.","quickSend.saved":"Quick sends saved.","quickSend.savedRefreshWarning":"Quick sends saved, but runtime refresh failed: {error}"},Dg={"quickSend.title":"\u5FEB\u6377\u53D1\u9001","quickSend.description":"\u4E3A\u6B64 Agent \u6DFB\u52A0\u6700\u591A 5 \u4E2A\u53D1\u9001\u6309\u94AE\u3002\u4F7F\u7528\u6307\u5B9A\u6A21\u578B\u548C\u53EF\u9009\u7684\u5355\u8F6E\u53C2\u6570\u53D1\u9001\u5F53\u524D\u6D88\u606F\u3002","quickSend.empty":"\u5C1A\u672A\u914D\u7F6E\u5FEB\u6377\u53D1\u9001\uFF0C\u4E0D\u4F1A\u663E\u793A\u989D\u5916\u7684\u53D1\u9001\u6309\u94AE\u3002","quickSend.offline":"\u6B64 Agent \u5DF2\u79BB\u7EBF\u3002\u91CD\u65B0\u8FDE\u63A5\u540E\u53EF\u52A0\u8F7D\u6216\u4FDD\u5B58\u5FEB\u6377\u53D1\u9001\u3002","quickSend.entry":"\u5FEB\u6377\u53D1\u9001 {index}","quickSend.name":"\u6309\u94AE\u540D\u79F0","quickSend.model":"\u6A21\u578B","quickSend.chooseModel":"\u9009\u62E9\u6A21\u578B","quickSend.noModels":"\u8BF7\u5148\u5728\u6A21\u578B\u914D\u7F6E\u5206\u7C7B\u4E2D\u6DFB\u52A0\u6A21\u578B\u3002","quickSend.effort":"\u63A8\u7406\u5F3A\u5EA6","quickSend.maxOutputTokens":"\u6700\u5927\u8F93\u51FA Token \u6570","quickSend.default":"\u9ED8\u8BA4","quickSend.outputLimit":"\u7559\u7A7A\u4F7F\u7528\u6A21\u578B\u9ED8\u8BA4\u503C\uFF1A{max} Token\uFF08\u4E5F\u662F\u53EF\u8BBE\u7F6E\u7684\u4E0A\u9650\uFF09\u3002","quickSend.add":"\u6DFB\u52A0\u5FEB\u6377\u53D1\u9001","quickSend.remove":"\u5220\u9664","quickSend.limit":"\u6700\u591A\u6DFB\u52A0 5 \u4E2A\u5FEB\u6377\u53D1\u9001\u3002","quickSend.nameRequired":"\u8BF7\u8F93\u5165\u6309\u94AE\u540D\u79F0\uFF081\u201380 \u4E2A\u5B57\u7B26\uFF09\u3002","quickSend.modelRequired":"\u8BF7\u4E3A\u6BCF\u4E2A\u5FEB\u6377\u53D1\u9001\u9009\u62E9\u53EF\u7528\u6A21\u578B\u3002","quickSend.effortInvalid":"\u6B64\u6A21\u578B\u4E0D\u652F\u6301\u6240\u9009\u63A8\u7406\u5F3A\u5EA6\u3002","quickSend.outputInvalid":"\u8F93\u51FA Token \u6570\u5FC5\u987B\u4E3A\u4E0D\u8D85\u8FC7 {max} \u7684\u6B63\u6574\u6570\u3002","quickSend.loadFailed":"\u65E0\u6CD5\u52A0\u8F7D\u5FEB\u6377\u53D1\u9001\uFF0C\u8BF7\u5237\u65B0\u91CD\u8BD5\u3002","quickSend.saveFailed":"\u5C1A\u672A\u786E\u8BA4\u4FDD\u5B58\u3002\u8BF7\u5148\u5237\u65B0\u68C0\u67E5\u5DF2\u4FDD\u5B58\u7684\u914D\u7F6E\uFF0C\u518D\u51B3\u5B9A\u662F\u5426\u91CD\u8BD5\u3002","quickSend.saved":"\u5FEB\u6377\u53D1\u9001\u5DF2\u4FDD\u5B58\u3002","quickSend.savedRefreshWarning":"\u5FEB\u6377\u53D1\u9001\u5DF2\u4FDD\u5B58\uFF0C\u4F46\u8FD0\u884C\u65F6\u5237\u65B0\u5931\u8D25\uFF1A{error}"}});var $g,Lg,Zl=B(()=>{$g={"userShortcuts.title":"Keyboard shortcuts","userShortcuts.scope":"These are your user preferences, stored only in this browser for this account. They do not sync across devices.","userShortcuts.quickSendHelp":"Quick-send shortcuts are active automatically when presets are configured in Agent settings. They only work while the message composer is focused; clear an individual binding to disable it.","userShortcuts.help":"Shortcuts use simple Alt + key defaults. Click a binding to replace it, or clear it to disable the action. Escape cancels; Tab moves on. Global actions stay available while the message composer is focused, and never run in dialogs, other text fields, editors or terminals.","userShortcuts.suggestion":"Suggestion: {binding}","userShortcuts.recording":"Press a shortcut\u2026","userShortcuts.unbound":"Not bound","userShortcuts.clear":"Clear","userShortcuts.clearAction":"Clear shortcut for {action}","userShortcuts.reset":"Reset shortcuts","userShortcuts.action.terminal":"Open terminal","userShortcuts.action.files":"Open files","userShortcuts.action.git":"Open Git","userShortcuts.action.newSession":"New session","userShortcuts.action.closeWorkbench":"Close workbench","userShortcuts.action.quickSend1":"Quick send 1","userShortcuts.action.quickSend2":"Quick send 2","userShortcuts.action.quickSend3":"Quick send 3","userShortcuts.action.quickSend4":"Quick send 4","userShortcuts.action.quickSend5":"Quick send 5","userShortcuts.error.invalid":"Use Ctrl, Meta or Alt with a letter or number; Shift is optional.","userShortcuts.error.reserved":"This combination conflicts with a browser or existing app shortcut.","userShortcuts.error.conflict":"This shortcut is already assigned to {action}. Clear it there first.","userShortcuts.error.storage":"Could not save preferences in this browser. Check browser storage permissions.","userShortcuts.error.unauthenticated":"Sign in before saving your shortcuts."},Lg={"userShortcuts.title":"\u952E\u76D8\u5FEB\u6377\u952E","userShortcuts.scope":"\u8FD9\u662F\u4F60\u7684\u7528\u6237\u504F\u597D\uFF0C\u6309\u5F53\u524D\u8D26\u53F7\u4EC5\u4FDD\u5B58\u5728\u6B64\u6D4F\u89C8\u5668\u4E2D\uFF0C\u4E0D\u8DE8\u8BBE\u5907\u540C\u6B65\u3002","userShortcuts.quickSendHelp":"\u5728 Agent \u8BBE\u7F6E\u4E2D\u914D\u7F6E\u5FEB\u6377\u53D1\u9001\u540E\uFF0C\u5FEB\u6377\u952E\u4F1A\u81EA\u52A8\u751F\u6548\uFF1B\u4EC5\u5728\u6D88\u606F\u8F93\u5165\u6846\u83B7\u5F97\u7126\u70B9\u65F6\u89E6\u53D1\u3002\u6E05\u9664\u5355\u9879\u7ED1\u5B9A\u5373\u53EF\u505C\u7528\u5BF9\u5E94\u5FEB\u6377\u952E\u3002","userShortcuts.help":"\u9ED8\u8BA4\u4F7F\u7528\u7B80\u5355\u7684 Alt + \u5355\u952E\u3002\u70B9\u51FB\u7ED1\u5B9A\u6309\u94AE\u53EF\u66FF\u6362\uFF0C\u6E05\u9664\u540E\u53EF\u505C\u7528\u8BE5\u64CD\u4F5C\u3002Escape \u53D6\u6D88\uFF0CTab \u79FB\u81F3\u4E0B\u4E00\u9879\u3002\u6D88\u606F\u8F93\u5165\u6846\u83B7\u5F97\u7126\u70B9\u65F6\u4ECD\u53EF\u4F7F\u7528\u5168\u5C40\u52A8\u4F5C\uFF1B\u5F39\u7A97\u3001\u5176\u4ED6\u8F93\u5165\u6846\u3001\u7F16\u8F91\u5668\u4E0E\u7EC8\u7AEF\u4E2D\u7684\u6309\u952E\u4E0D\u4F1A\u88AB\u62A2\u5360\u3002","userShortcuts.suggestion":"\u63A8\u8350\uFF1A{binding}","userShortcuts.recording":"\u8BF7\u6309\u4E0B\u7EC4\u5408\u952E\u2026","userShortcuts.unbound":"\u672A\u7ED1\u5B9A","userShortcuts.clear":"\u6E05\u9664","userShortcuts.clearAction":"\u6E05\u9664\u201C{action}\u201D\u5FEB\u6377\u952E","userShortcuts.reset":"\u91CD\u7F6E\u5FEB\u6377\u952E","userShortcuts.action.terminal":"\u6253\u5F00\u7EC8\u7AEF","userShortcuts.action.files":"\u6253\u5F00\u6587\u4EF6","userShortcuts.action.git":"\u6253\u5F00 Git","userShortcuts.action.newSession":"\u65B0\u5EFA\u4F1A\u8BDD","userShortcuts.action.closeWorkbench":"\u5173\u95ED\u5DE5\u4F5C\u53F0","userShortcuts.action.quickSend1":"\u5FEB\u6377\u53D1\u9001 1","userShortcuts.action.quickSend2":"\u5FEB\u6377\u53D1\u9001 2","userShortcuts.action.quickSend3":"\u5FEB\u6377\u53D1\u9001 3","userShortcuts.action.quickSend4":"\u5FEB\u6377\u53D1\u9001 4","userShortcuts.action.quickSend5":"\u5FEB\u6377\u53D1\u9001 5","userShortcuts.error.invalid":"\u8BF7\u4F7F\u7528 Ctrl\u3001Meta \u6216 Alt \u642D\u914D\u5B57\u6BCD\u6216\u6570\u5B57\uFF0C\u53EF\u52A0 Shift\u3002","userShortcuts.error.reserved":"\u8BE5\u7EC4\u5408\u4E0E\u6D4F\u89C8\u5668\u6216\u5E94\u7528\u5DF2\u6709\u5FEB\u6377\u952E\u51B2\u7A81\u3002","userShortcuts.error.conflict":"\u8BE5\u7EC4\u5408\u5DF2\u7ED1\u5B9A\u201C{action}\u201D\uFF0C\u8BF7\u5148\u6E05\u9664\u539F\u7ED1\u5B9A\u3002","userShortcuts.error.storage":"\u65E0\u6CD5\u5728\u6B64\u6D4F\u89C8\u5668\u4FDD\u5B58\u504F\u597D\uFF0C\u8BF7\u68C0\u67E5\u6D4F\u89C8\u5668\u5B58\u50A8\u6743\u9650\u3002","userShortcuts.error.unauthenticated":"\u8BF7\u5148\u767B\u5F55\u518D\u4FDD\u5B58\u5FEB\u6377\u952E\u3002"}});var Fg,Og=B(()=>{Xl();Zl();Fg={...Dg,...Lg,"quickSend.composer.label":"\u5FEB\u6377\u53D1\u9001","quickSend.composer.send":"\u5FEB\u6377\u53D1\u9001 {number}\uFF1A{name}","common.loading":"\u52A0\u8F7D\u4E2D...","common.confirm":"\u786E\u5B9A","common.apply":"\u5E94\u7528","common.cancel":"\u53D6\u6D88","common.delete":"\u5220\u9664","common.copy":"\u590D\u5236","common.copied":"\u5DF2\u590D\u5236","common.close":"\u5173\u95ED","common.refresh":"\u5237\u65B0","common.open":"\u6253\u5F00","common.save":"\u4FDD\u5B58","common.saving":"\u4FDD\u5B58\u4E2D...","common.search":"\u641C\u7D22","common.back":"\u8FD4\u56DE","common.noSubdirectories":"\u65E0\u5B50\u76EE\u5F55","common.drives":"\u9A71\u52A8\u5668","common.rootDir":"\u6839\u76EE\u5F55","common.comma":"\uFF0C","common.select":"\u9009\u62E9","common.retry":"\u91CD\u8BD5","mermaid.export":"\u5BFC\u51FA","mermaid.exportMd":"\u5BFC\u51FA MD","mermaid.exportPng":"\u5BFC\u51FA PNG","mermaid.exportJpg":"\u5BFC\u51FA JPG","login.subtitle":"Yeaft Web Code Agent","login.username":"\u7528\u6237\u540D","login.password":"\u5BC6\u7801","login.login":"\u767B\u5F55","login.loggingIn":"\u767B\u5F55\u4E2D...","login.enterUsername":"\u8BF7\u8F93\u5165\u7528\u6237\u540D","login.enterPassword":"\u8BF7\u8F93\u5165\u5BC6\u7801","login.noAccount":"\u6CA1\u6709\u8D26\u53F7\uFF1F","login.registerWithCode":"\u6CE8\u518C\u65B0\u8D26\u53F7","login.or":"\u6216","login.usePassword":"\u4F7F\u7528\u8D26\u53F7\u5BC6\u7801\u767B\u5F55","login.useSso":"\u8FD4\u56DE\u5355\u70B9\u767B\u5F55","login.noProviders":"\u7BA1\u7406\u5458\u5C1A\u672A\u542F\u7528\u4EFB\u4F55\u7B2C\u4E09\u65B9\u767B\u5F55\u3002","login.microsoft":"\u4F7F\u7528 Microsoft \u8D26\u53F7\u767B\u5F55","login.github":"\u4F7F\u7528 GitHub \u8D26\u53F7\u767B\u5F55","login.google":"\u4F7F\u7528 Google \u8D26\u53F7\u767B\u5F55","login.wechat":"\u4F7F\u7528\u5FAE\u4FE1\u626B\u7801\u767B\u5F55","login.alipay":"\u4F7F\u7528\u652F\u4ED8\u5B9D\u8D26\u53F7\u767B\u5F55","login.wechat.mobileUnsupported":"\u5FAE\u4FE1\u767B\u5F55\u6682\u4EC5\u652F\u6301\u7535\u8111\u7AEF\uFF0C\u8BF7\u5728\u7535\u8111\u6D4F\u89C8\u5668\u4E2D\u626B\u7801\u767B\u5F55\u3002","login.alipay.mobileWaiting":"\u6B63\u5728\u7B49\u5F85\u4F60\u5728\u652F\u4ED8\u5B9D\u4E2D\u786E\u8BA4\u2026 \u5B8C\u6210\u540E\u8FD4\u56DE\u672C\u9875\u9762\u5C06\u81EA\u52A8\u767B\u5F55\u3002","login.alipay.relaunch":"\u91CD\u65B0\u6253\u5F00\u652F\u4ED8\u5B9D","login.qr.title":"\u626B\u7801\u767B\u5F55","login.qr.titleAlipay":"\u652F\u4ED8\u5B9D\u626B\u7801\u767B\u5F55","login.qr.titleWechat":"\u5FAE\u4FE1\u626B\u7801\u767B\u5F55","login.qr.hint":"\u8BF7\u4F7F\u7528\u624B\u673A\u626B\u63CF\u4E8C\u7EF4\u7801\u5B8C\u6210\u6388\u6743","login.error.enterUsername":"\u8BF7\u8F93\u5165\u7528\u6237\u540D","login.error.enterPassword":"\u8BF7\u8F93\u5165\u5BC6\u7801","login.error.enter6Digit":"\u8BF7\u8F93\u51656\u4F4D\u9A8C\u8BC1\u7801","login.error.enterInviteCode":"\u8BF7\u8F93\u5165\u9080\u8BF7\u7801","login.error.usernameMinLen":"\u7528\u6237\u540D\u81F3\u5C112\u4E2A\u5B57\u7B26","login.error.passwordMinLen":"\u5BC6\u7801\u81F3\u5C116\u4F4D","login.error.passwordMismatch":"\u4E24\u6B21\u5BC6\u7801\u4E0D\u4E00\u81F4","login.error.enterVerifyCode":"\u8BF7\u8F93\u5165\u9A8C\u8BC1\u7801","login.error.loginFailed":"\u767B\u5F55\u5931\u8D25","login.forgot.link":"\u5FD8\u8BB0\u5BC6\u7801\uFF1F","login.forgot.title":"\u91CD\u7F6E\u5BC6\u7801","login.forgot.emailHint":"\u8F93\u5165\u8D26\u6237\u7ED1\u5B9A\u7684\u90AE\u7BB1\uFF0C\u6211\u4EEC\u5C06\u53D1\u9001 6 \u4F4D\u91CD\u7F6E\u9A8C\u8BC1\u7801\u3002","login.forgot.sendCode":"\u53D1\u9001\u91CD\u7F6E\u9A8C\u8BC1\u7801","login.forgot.sending":"\u53D1\u9001\u4E2D...","login.forgot.codeSent":"\u5982\u679C\u90AE\u7BB1\u5DF2\u6CE8\u518C\uFF0C\u91CD\u7F6E\u9A8C\u8BC1\u7801\u5DF2\u53D1\u9001\u3002\u8BF7\u5728\u4E0B\u65B9\u8F93\u5165\u9A8C\u8BC1\u7801\u4E0E\u65B0\u5BC6\u7801\u3002","login.forgot.resetBtn":"\u91CD\u7F6E\u5BC6\u7801","login.forgot.resetting":"\u91CD\u7F6E\u4E2D...","login.forgot.success":"\u5BC6\u7801\u5DF2\u91CD\u7F6E\uFF0C\u53EF\u4EE5\u4F7F\u7528\u65B0\u5BC6\u7801\u767B\u5F55\u3002","login.forgot.emailInvalid":"\u8BF7\u8F93\u5165\u6709\u6548\u7684\u90AE\u7BB1","login.register.title":"\u65B0\u7528\u6237\u6CE8\u518C","login.register.inviteCode":"\u9080\u8BF7\u7801","login.register.username":"\u7528\u6237\u540D","login.register.password":"\u5BC6\u7801\uFF08\u81F3\u5C116\u4F4D\uFF09","login.register.confirmPassword":"\u786E\u8BA4\u5BC6\u7801","login.register.email":"\u90AE\u7BB1\uFF08\u53EF\u9009\uFF09","login.register.submit":"\u6CE8\u518C","login.register.submitting":"\u6CE8\u518C\u4E2D...","login.register.back":"\u8FD4\u56DE\u767B\u5F55","login.register.success":"\u6CE8\u518C\u6210\u529F\uFF0C\u8BF7\u767B\u5F55","login.register.enterCode":"\u8BF7\u8F93\u5165\u9080\u8BF7\u7801","login.register.usernameMin":"\u7528\u6237\u540D\u81F3\u5C112\u4E2A\u5B57\u7B26","login.register.passwordMin":"\u5BC6\u7801\u81F3\u5C116\u4F4D","login.register.passwordMismatch":"\u4E24\u6B21\u5BC6\u7801\u4E0D\u4E00\u81F4","login.totp.setupTitle":"\u8BBE\u7F6E\u53CC\u56E0\u7D20\u8BA4\u8BC1","login.totp.setupHint":"\u4F7F\u7528 Microsoft Authenticator \u6216 Google Authenticator \u626B\u63CF\u4E0B\u65B9\u4E8C\u7EF4\u7801","login.totp.manualKey":"\u6216\u624B\u52A8\u8F93\u5165\u5BC6\u94A5\uFF1A","login.totp.enterCode":"\u8F93\u51656\u4F4D\u9A8C\u8BC1\u7801","login.totp.complete":"\u5B8C\u6210\u8BBE\u7F6E","login.totp.verifying":"\u9A8C\u8BC1\u4E2D...","login.totp.verify":"\u9A8C\u8BC1","login.totp.prompt":"\u8BF7\u8F93\u5165 Authenticator \u5E94\u7528\u4E2D\u7684\u9A8C\u8BC1\u7801","login.totp.invalidCode":"\u8BF7\u8F93\u51656\u4F4D\u9A8C\u8BC1\u7801","login.email.codeSent":"\u9A8C\u8BC1\u7801\u5DF2\u53D1\u9001\u81F3 {email}","login.email.enterCode":"\u8F93\u5165\u9A8C\u8BC1\u7801","login.email.verify":"\u9A8C\u8BC1","login.email.verifying":"\u9A8C\u8BC1\u4E2D...","login.email.enterCodeError":"\u8BF7\u8F93\u5165\u9A8C\u8BC1\u7801","chat.agent.select":"\u9009\u62E9 Agent","chat.agent.manage":"\u7BA1\u7406 Agent","chat.agent.count":"{count} agents","chat.agent.none":"\u6682\u65E0 Agent","chat.agent.restarting":"\u91CD\u542F\u4E2D","agentSettings.open":"Agent \u8BBE\u7F6E","agentSettings.manage":"\u7BA1\u7406","agentSettings.eyebrow":"\u672C\u5730\u8FD0\u884C\u65F6","agentSettings.title":"Agent \u8BBE\u7F6E","agentSettings.description":"\u6309 Agent \u67E5\u770B\u548C\u914D\u7F6E\u672C\u5730\u8FD0\u884C\u65F6\uFF0C\u4E0D\u518D\u628A\u8FD0\u884C\u63A7\u5236\u6DF7\u5165\u8D26\u6237\u8BBE\u7F6E\u3002","agentSettings.agentList":"Agent","agentSettings.categories":"Agent \u8BBE\u7F6E\u5206\u7C7B","agentSettings.categories.operations":"\u64CD\u4F5C","agentSettings.categories.trace":"Trace","agentSettings.categories.llm":"LLM \u914D\u7F6E","agentSettings.selectedAgent":"\u5F53\u524D Agent","agentSettings.online":"\u5728\u7EBF","agentSettings.offline":"\u79BB\u7EBF","agentSettings.empty":"\u6682\u65E0\u53EF\u7528 Agent\u3002","agentSettings.runtime.title":"\u8FD0\u884C\u65F6","agentSettings.runtime.description":"\u8EAB\u4EFD\u3001\u5DE5\u4F5C\u76EE\u5F55\u548C\u672C\u5730\u540E\u53F0\u5904\u7406\u3002","agentSettings.runtime.version":"\u7248\u672C","agentSettings.runtime.updateAvailable":"\u53EF\u66F4\u65B0\u81F3 v{version}","agentSettings.runtime.updateUnknown":"\u65E0\u6CD5\u83B7\u53D6\u66F4\u65B0\u72B6\u6001","agentSettings.runtime.workDir":"\u5DE5\u4F5C\u76EE\u5F55","agentSettings.workCenter.title":"\u5DE5\u4F5C\u4E2D\u5FC3","agentSettings.workCenter.enabled":"\u5DF2\u542F\u7528","agentSettings.workCenter.disabled":"\u5DF2\u505C\u7528","agentSettings.workCenter.runtimeUnavailable":"\u542F\u52A8\u5931\u8D25","agentSettings.workCenter.runtimeUnavailableMessage":"\u5DE5\u4F5C\u4E2D\u5FC3\u5DF2\u914D\u7F6E\u4E3A\u542F\u7528\uFF0C\u4F46\u8FD0\u884C\u65F6\u672A\u80FD\u542F\u52A8\uFF1B\u8BF7\u67E5\u770B Agent \u65E5\u5FD7\u540E\u91CD\u8BD5\u3002","agentSettings.workCenter.runtimeUnavailableHint":"\u5DF2\u914D\u7F6E\u4E3A\u542F\u7528\uFF0C\u4F46\u5DE5\u4F5C\u4E2D\u5FC3\u8FD0\u884C\u65F6\u5F53\u524D\u4E0D\u53EF\u7528\u3002","agentSettings.workCenter.enabledHint":"\u6B64 Agent \u5DF2\u53EF\u8FD0\u884C\u6301\u4E45\u5DE5\u4F5C\uFF1B\u65B0 Session \u4E5F\u53EF\u521B\u5EFA\u5DE5\u4F5C\u9879\u3002","agentSettings.workCenter.disabledHint":"\u5728\u6B64 Agent \u4E0A\u542F\u7528\u6301\u4E45\u5DE5\u4F5C\u9879\u548C\u540E\u53F0\u6267\u884C\u3002","agentSettings.workCenter.environmentManaged":"\u7531 YEAFT_WORK_CENTER_ENABLED \u7BA1\u7406\uFF0C\u65E0\u6CD5\u5728\u8FD9\u91CC\u4FEE\u6539\u3002","agentSettings.workCenter.upgradeRequired":"\u5347\u7EA7\u6B64 Agent \u540E\u624D\u80FD\u7BA1\u7406\u5DE5\u4F5C\u4E2D\u5FC3\u7684\u542F\u505C\u72B6\u6001\u3002","agentSettings.workCenter.unsupported":"\u9700\u8981\u5347\u7EA7","agentSettings.workCenter.loadFailed":"\u5DE5\u4F5C\u4E2D\u5FC3\u72B6\u6001\u52A0\u8F7D\u5931\u8D25\u3002","agentSettings.workCenter.loadFailedStatus":"\u52A0\u8F7D\u5931\u8D25","agentSettings.workCenter.saveFailed":"\u5DE5\u4F5C\u4E2D\u5FC3\u66F4\u65B0\u5931\u8D25\u3002","agentSettings.telemetry.title":"\u8BCA\u65AD","agentSettings.telemetry.saved":"\u8BCA\u65AD\u8BBE\u7F6E\u5DF2\u4FDD\u5B58\u3002","agentSettings.telemetry.loadFailed":"\u8BCA\u65AD\u8BBE\u7F6E\u52A0\u8F7D\u5931\u8D25\u3002","agentSettings.telemetry.saveFailed":"\u8BCA\u65AD\u8BBE\u7F6E\u4FDD\u5B58\u5931\u8D25\u3002","agentSettings.maintenance.title":"\u7EF4\u62A4","agentSettings.maintenance.description":"\u8FD9\u4E9B\u64CD\u4F5C\u4F1A\u4E2D\u65AD\u5F53\u524D Agent \u4E0A\u6B63\u5728\u8FD0\u884C\u7684\u5DE5\u4F5C\u3002","agentSettings.maintenance.upgradeFailed":"Agent \u5347\u7EA7\u5931\u8D25\u3002","chat.agent.dream":"Dream","chat.agent.dreamHint":"\u542F\u7528\u81EA\u52A8 Dream \u8BB0\u5FC6\u5904\u7406","chat.agent.restart":"\u91CD\u542F","chat.agent.restartConfirm":`\u786E\u5B9A\u8981\u91CD\u542F Agent "{name}" \u5417\uFF1F
11
11
  \u6240\u6709\u6D3B\u8DC3\u7684\u4F1A\u8BDD\u5C06\u88AB\u4E2D\u65AD\u3002`,"chat.agent.upgrade":"\u5347\u7EA7","chat.agent.upgrading":"\u5347\u7EA7\u4E2D","chat.agent.upgradeConfirm":`\u5347\u7EA7 Agent "{name}" \u5230\u6700\u65B0\u7248\u672C\uFF1F
12
12
  \u5347\u7EA7\u5B8C\u6210\u540E Agent \u4F1A\u81EA\u52A8\u91CD\u542F\u3002`,"chat.agent.upgradeAll":"\u5168\u90E8\u5347\u7EA7","chat.agent.upgradingAll":"\u5168\u90E8\u5347\u7EA7\u4E2D\u2026","chat.agent.upgradeAllConfirm":`\u786E\u5B9A\u5C06 {count} \u4E2A\u7B26\u5408\u6761\u4EF6\u7684 Agent \u5347\u7EA7\u5230\u6700\u65B0\u7248\u672C\u5417\uFF1F
13
13
  \u5347\u7EA7\u5B8C\u6210\u540E\u5B83\u4EEC\u4F1A\u81EA\u52A8\u91CD\u542F\u3002\u53E6\u6709 {skipped} \u4E2A Agent \u56E0\u5F53\u524D\u4E0D\u53EF\u7528\u6216\u4E0D\u652F\u6301\u5B89\u5168\u8FDC\u7A0B\u5347\u7EA7\u800C\u8DF3\u8FC7\u3002`,"chat.agent.upgradeAllSummary":"Agent \u6279\u91CF\u5347\u7EA7\u5B8C\u6210\uFF1A\u5347\u7EA7\u6210\u529F {upgraded} \u4E2A\uFF0C\u5DF2\u662F\u6700\u65B0 {latest} \u4E2A\uFF0C\u5931\u8D25 {failed} \u4E2A\uFF0C\u8DF3\u8FC7 {skipped} \u4E2A\u3002","chat.agent.alreadyLatest":"Agent \u5DF2\u662F\u6700\u65B0\u7248\u672C (v{version})\uFF0C\u65E0\u9700\u5347\u7EA7\u3002","chat.agent.nodeIncompatible":"Agent \u5347\u7EA7\u4E2D\u6B62\uFF1A\u76EE\u6807\u7248\u672C v{version} \u9700\u8981 Node {required}\uFF0C\u4F46\u5F53\u524D\u673A\u5668\u8FD0\u884C\u7684\u662F Node {current}\u3002\u8BF7\u5148\u5347\u7EA7 Node.js \u518D\u91CD\u8BD5\u3002","chat.agent.manualUpgradeRequired":'Agent v{version} \u6CA1\u6709\u58F0\u660E\u5B89\u5168\u8FDC\u7A0B\u5347\u7EA7\u80FD\u529B\uFF1B\u65E7\u5BA2\u6237\u7AEF\u53C8\u672A\u4E0A\u62A5\u8DB3\u591F\u7684\u5E73\u53F0\u4FE1\u606F\uFF0CServer \u65E0\u6CD5\u6392\u9664 Windows \u5305\u76EE\u5F55\u9501\u5B9A\u6545\u969C\u3002\u4E3A\u907F\u514D\u91CD\u590D\u6267\u884C\u5DF2\u77E5\u4F1A\u5931\u8D25\u7684\u5347\u7EA7\uFF0C\u672C\u6B21\u64CD\u4F5C\u5DF2\u88AB\u963B\u6B62\u3002\u8BF7\u5148\u505C\u6B62\u8BE5\u673A\u5668\u4E0A\u6240\u9009\u7684 Agent/\u670D\u52A1\uFF1A\u82E5\u7531 PM2 \u6216\u5176\u4ED6\u670D\u52A1\u7BA1\u7406\u5668\u8FD0\u884C\uFF0C\u8BF7\u5728\u90A3\u91CC\u505C\u6B62\u8FD9\u4E2A\u7CBE\u786E\u5B9E\u4F8B\uFF1B\u82E5\u5728\u524D\u53F0\u7EC8\u7AEF\u8FD0\u884C\uFF0C\u8BF7\u7EC8\u6B62\u8BE5\u8FDB\u7A0B\u3002\u786E\u8BA4\u8BE5\u8FDB\u7A0B\u5DF2\u7ECF\u9000\u51FA\u540E\uFF0C\u518D\u6267\u884C "npm install -g @yeaft/webchat-agent@latest --registry=https://pkg.yeaft.com/"\uFF1B\u6700\u540E\u4F7F\u7528\u539F\u914D\u7F6E\u542F\u52A8\u540C\u4E00 Agent \u5B9E\u4F8B\u3002\u5B8C\u6210\u8FD9\u6B21\u5F15\u5BFC\u540E\uFF0C\u540E\u7EED\u53EF\u7EE7\u7EED\u5728\u6D4F\u89C8\u5668\u4E2D\u5347\u7EA7\u3002',"chat.agent.containerImageUpgradeRequired":'\u5BB9\u5668 Agent v{version} \u7531 Docker \u955C\u50CF\u7BA1\u7406\uFF0C\u4E0D\u80FD\u5728\u5BB9\u5668\u5185\u4F7F\u7528 npm \u81EA\u5347\u7EA7\u3002\u8BF7\u5728 Docker Host \u4E0A\u6267\u884C "docker pull <configured-agent-image>"\uFF0C\u7136\u540E\u901A\u8FC7\u73B0\u6709 Server/Sandbox \u751F\u547D\u5468\u671F\u6216\u539F\u6765\u7684 "yeaft-agent container install" \u547D\u4EE4\u91CD\u5EFA\u540C\u4E00\u4E2A\u5BB9\u5668\u3002\u4FDD\u7559\u73B0\u6709\u7684 /home/yeaft/.yeaft \u548C /workspace \u6301\u4E45\u5377\uFF0C\u5E76\u590D\u7528 Host \u7AEF\u539F\u6709\u7684 0600 agent-secret \u6587\u4EF6\uFF1B\u4E0D\u8981\u5728\u91CD\u5EFA\u65F6\u5220\u9664\u8FD9\u4E9B\u5377\u3002',"chat.agent.online":"{count} \u4E2A Agent \u5728\u7EBF","chat.agent.selectFirst":"\u8BF7\u5148\u9009\u62E9\u4E00\u4E2A Agent","chat.agent.yeaft":"Yeaft \u5BF9\u8BDD","sidebar.toggle.chat":"\u5207\u6362\u5230 Chat","sidebar.toggle.yeaft":"\u5207\u6362\u5230 Yeaft","sidebar.surface.label":"\u4FA7\u680F\u89C6\u56FE","sidebar.surface.sessions":"\u4F1A\u8BDD","sidebar.provider.label":"\u4F1A\u8BDD Provider","sidebar.provider.claude":"Claude","sidebar.sessions.new":"\u65B0\u5EFA\u4F1A\u8BDD","sidebar.sessions.newChat":"\u65B0\u5EFA\u804A\u5929","sidebar.sessions.emptyProvider":"\u6B64 Provider \u6682\u65E0\u4F1A\u8BDD","sidebar.sessions.menu":"\u4F1A\u8BDD\u83DC\u5355","sidebar.sessions.unread":"\u672A\u8BFB","sidebar.sessions.pinned":"\u5DF2\u7F6E\u9876","sidebar.sessions.processing":"\u6B63\u5728\u56DE\u590D","sidebar.sessions.hidden":"\u5DF2\u9690\u85CF\u7684\u4F1A\u8BDD","sidebar.sessions.remove":"\u4ECE\u4FA7\u680F\u79FB\u9664","sidebar.sessions.agent":"Agent","sidebar.sessions.provider":"Provider","sidebar.projects.title":"\u9879\u76EE","sidebar.projects.menu":"\u9879\u76EE\u83DC\u5355","sidebar.projects.new":"\u65B0\u5EFA\u9879\u76EE","sidebar.projects.newSession":"\u5728{name}\u4E2D\u521B\u5EFA Session","sidebar.projects.assignFailed":"Session \u5DF2\u521B\u5EFA\uFF0C\u4F46\u65E0\u6CD5\u52A0\u5165{name}\u3002\u9519\u8BEF\uFF1A{message}","sidebar.projects.empty":"\u6682\u65E0\u9879\u76EE","sidebar.projects.noSessions":"\u5C06 Yeaft \u804A\u5929\u62D6\u5230\u8FD9\u91CC","sidebar.projects.namePrompt":"\u9879\u76EE\u540D\u79F0","sidebar.projects.renamePrompt":"\u91CD\u547D\u540D\u9879\u76EE","sidebar.projects.rename":"\u91CD\u547D\u540D\u9879\u76EE","sidebar.projects.delete":"\u5220\u9664\u9879\u76EE","sidebar.projects.deleteConfirm":"\u5220\u9664\u9879\u76EE\u201C{name}\u201D\uFF1F\u5176\u4E2D\u804A\u5929\u4F1A\u79FB\u56DE\u6700\u8FD1\u3002","sidebar.projects.remove":"\u79FB\u51FA\u9879\u76EE","sidebar.projects.moveMenu":"\u79FB\u52A8\u5230 Projects","sidebar.projects.moveBack":"\u8FD4\u56DE","sidebar.projects.moveEmpty":"\u6CA1\u6709\u5176\u4ED6 Project","sidebar.projects.moveTo":"\u79FB\u5230 {name}","sidebar.projects.instructions":"Project \u6307\u4EE4","sidebar.projects.instructionsTitle":"{name} \u6307\u4EE4","sidebar.projects.instructionsHint":"\u8FD9\u4E9B\u6307\u4EE4\u4F1A\u52A0\u5165\u6B64 Project \u5185\u6BCF\u4E2A Session \u7684 system prompt\u3002","sidebar.projects.instructionsPlaceholder":"\u8F93\u5165\u5171\u4EAB\u7684\u7F16\u7801\u89C4\u8303\u3001\u7EA6\u675F\u6216\u5DE5\u4F5C\u6D41\u8BF4\u660E\u2026","sidebar.recents.title":"\u6700\u8FD1","sidebar.recents.empty":"\u6682\u65E0\u804A\u5929","yeaft.back":"\u8FD4\u56DE","yeaft.session.people":"\u6210\u5458","yeaft.session.peopleEmpty":"\u6682\u65E0\u6210\u5458","yeaft.session.runningTasks":"\u8FD0\u884C\u4E2D\u7684\u4EFB\u52A1","yeaft.session.tasksEmpty":"\u6682\u65E0\u8FD0\u884C\u4EFB\u52A1","yeaft.session.owner":"\u8D1F\u8D23\u4EBA","yeaft.session.started":"\u5F00\u59CB\u65F6\u95F4","yeaft.breadcrumb.label":"Thread \u8FC7\u6EE4","yeaft.breadcrumb.mainStream":"\u4E3B\u6D41","yeaft.breadcrumb.backHint":"\u8FD4\u56DE\u5168\u6D41 (Esc)","yeaft.featureDetail.ariaLabel":"Task \u8BE6\u60C5","yeaft.featureDetail.replyTo":"\u56DE\u590D\u5230:","yeaft.featureDetail.forkHint":"\u8BE5 task \u6682\u65E0\u6D3B\u8DC3 thread \u2014 \u8BF7 fork \u65B0 thread \u540E\u56DE\u590D\u3002","yeaft.featureDetail.empty":"\u8BE5 task \u6682\u65E0\u6D88\u606F\u3002","yeaft.featureDetail.threadPillHint":"\u6253\u5F00 thread","yeaft.featureDetail.summary.aria":"\u4EFB\u52A1\u6458\u8981\u65F6\u95F4\u7EBF","yeaft.featureDetail.summary.title":"\u6458\u8981\u65F6\u95F4\u7EBF","yeaft.featureDetail.summary.loading":"\u6B63\u5728\u52A0\u8F7D\u6458\u8981\u5386\u53F2\u2026","yeaft.featureDetail.summary.empty":"\u6682\u65E0\u6458\u8981\u3002","yeaft.featureDetail.summary.error":"\u6458\u8981\u52A0\u8F7D\u5931\u8D25\uFF1A{error}","yeaft.featureDetail.summary.showArchived":"\u663E\u793A\u5DF2\u5F52\u6863","yeaft.featureDetail.related.aria":"\u5173\u8054\u4EFB\u52A1","yeaft.featureDetail.related.title":"\u5173\u8054\u4EFB\u52A1","yeaft.featureDetail.related.unlink":"\u53D6\u6D88\u5173\u8054","yeaft.featureDetail.members.aria":"\u4EFB\u52A1\u6210\u5458","yeaft.featureDetail.members.title":"\u6210\u5458","yeaft.featureDetail.members.abort":"\u4E2D\u6B62","yeaft.featureDetail.members.kick":"\u8E22\u51FA","yeaft.model":"\u6A21\u578B","yeaft.placeholder":"\u95EE\u6211\u4EFB\u4F55\u95EE\u9898...","yeaft.inbox":"\u6536\u4EF6\u7BB1","yeaft.inbox.tooltip":"\u4F60\u7684\u9ED8\u8BA4\u5BF9\u8BDD\u7EBF\u7A0B \u2014\u2014 \u4E0E Yeaft \u7684\u4E00\u5BF9\u4E00\u804A\u5929\u3002\u53EF\u4EE5\u4E3A\u5177\u4F53\u8BDD\u9898\u6216\u4EFB\u52A1\u521B\u5EFA\u65B0\u7EBF\u7A0B\u3002","yeaft.sidebar.activeThreads":"\u6D3B\u8DC3","yeaft.sidebar.idleThreads":"\u9759\u9ED8","yeaft.sidebar.archivedThreads":"\u5DF2\u5F52\u6863","yeaft.sidebar.tasks":"\u4EFB\u52A1","yeaft.sidebar.emptyActive":"\u6682\u65E0\u6D3B\u8DC3 thread","yeaft.sidebar.emptyIdle":"\u6682\u65E0\u9759\u9ED8 thread","yeaft.sidebar.emptyArchived":"\u6682\u65E0\u5F52\u6863 thread","yeaft.sidebar.emptyTasks":"\u65E0\u5339\u914D\u4EFB\u52A1","yeaft.sidebar.results":"\u641C\u7D22\u7ED3\u679C","yeaft.sidebar.resultsThreads":"Threads","yeaft.sidebar.kindThread":"thread","yeaft.sidebar.cancel":"\u53D6\u6D88","yeaft.sidebar.mergeInto":"\u5408\u5E76\u5230\u2026","yeaft.sidebar.mergeNoCandidates":"\u6CA1\u6709\u53EF\u5408\u5E76\u7684\u5176\u4ED6\u7EBF\u7A0B","yeaft.sidebar.mergeConfirmTitle":"\u5408\u5E76\u8FD9\u4E2A\u7EBF\u7A0B\uFF1F","yeaft.sidebar.mergeIrreversible":"\u6B64\u64CD\u4F5C\u4E0D\u53EF\u64A4\u9500\uFF0C\u6E90\u7EBF\u7A0B\u5C06\u88AB\u5F52\u6863\uFF0C\u5176\u6D88\u606F\u4F1A\u88AB\u79FB\u52A8\u5230\u76EE\u6807\u7EBF\u7A0B\u3002","yeaft.sidebar.mergeConfirm":"\u5408\u5E76","yeaft.settings.sidebarV2":"\u5B9E\u9A8C\u529F\u80FD\uFF1A\u4FA7\u8FB9\u680F V2","yeaft.settings.sidebarV2Hint":"Thread \u5217\u8868 + \u4EFB\u52A1\u6811\uFF08\u9884\u89C8\uFF09\u3002","yeaft.clearConfirm":"\u6E05\u7A7A\u6240\u6709\u6D88\u606F\uFF1F","yeaft.mode":"\u6A21\u5F0F","yeaft.agent":"\u667A\u80FD\u4F53","yeaft.connecting":"\u8FDE\u63A5\u4E2D...","yeaft.ready":"\u5C31\u7EEA","yeaft.tools":"\u4E2A\u5DE5\u5177","yeaft.skills":"\u4E2A\u6280\u80FD","yeaft.mcp":"\u4E2A MCP","yeaft.showSidebar":"\u663E\u793A\u4FA7\u680F","yeaft.hideSidebar":"\u9690\u85CF\u4FA7\u680F","yeaft.debug":"\u8C03\u8BD5","yeaft.debugClose":"\u5173\u95ED\u8C03\u8BD5\u9762\u677F","yeaft.debugTurns":"\u8F6E","yeaft.debugTabToolStats":"\u5DE5\u5177\u7EDF\u8BA1","yeaft.debugTabDream":"Dream","yeaft.debugTabRequestLog":"\u8BF7\u6C42\u65E5\u5FD7","yeaft.debugHistoryLoad":"\u52A0\u8F7D\u8BF7\u6C42\u5386\u53F2","yeaft.debugHistoryLoading":"\u52A0\u8F7D\u4E2D...","yeaft.debugHistoryLoaded":"\u5DF2\u52A0\u8F7D {count} \u6761","yeaft.debugHistoryUnavailable":"\u8C03\u8BD5\u8F68\u8FF9\u8BF7\u6C42\u8D85\u65F6\u3002Agent \u53EF\u80FD\u79BB\u7EBF\uFF0C\u6216\u54CD\u5E94\u5DF2\u88AB\u4E22\u5F03\uFF0C\u8BF7\u91CD\u8BD5\u3002","yeaft.debugHistoryTruncated":"\u8BE5\u8F68\u8FF9\u8FC7\u5927\uFF0C\u65E0\u6CD5\u5728\u4E00\u6B21\u54CD\u5E94\u4E2D\u5B8C\u6574\u4F20\u8F93\u3002\u6B64\u5904\u663E\u793A\u5927\u5B57\u6BB5\u9884\u89C8\uFF0C\u5B8C\u6574\u8F68\u8FF9\u4ECD\u4FDD\u7559\u5728 Agent\u3002","yeaft.debugSearchPlaceholder":"\u6B63\u5219\u641C\u7D22\u8BF7\u6C42\u65E5\u5FD7","yeaft.debugSearchHint":"\u9ED8\u8BA4\u663E\u793A\u5168\u5C40\u6700\u8FD1 10 \u6761\uFF1B\u641C\u7D22\u4F1A\u8DE8 Session \u5339\u914D\u8BF7\u6C42\u6458\u8981\u3002","yeaft.debugTurnAction":"\u67E5\u770B\u8BE5\u8F6E\u5BF9\u8BDD\u7684\u8C03\u8BD5\u8F68\u8FF9","yeaft.debugTurnContext":"\u8C03\u8BD5\u8F68\u8FF9","yeaft.debugPanelEmpty":"\u60AC\u505C\u5728 AI \u56DE\u590D\u4E0A\uFF0C\u70B9\u51FB\u8C03\u8BD5\u56FE\u6807\u5373\u53EF\u67E5\u770B\u8BE5\u8F6E\u5BF9\u8BDD\u7684\u8C03\u8BD5\u8F68\u8FF9\u3002","yeaft.dreamDebug.title":"Dream \u751F\u547D\u5468\u671F","yeaft.dreamDebug.trigger":"\u89E6\u53D1","yeaft.dreamDebug.status":"\u72B6\u6001","yeaft.dreamDebug.started":"\u5F00\u59CB","yeaft.dreamDebug.finished":"\u7ED3\u675F","yeaft.dreamDebug.time":"\u65F6\u95F4","yeaft.dreamDebug.phase":"\u9636\u6BB5","yeaft.dreamDebug.call":"\u8C03\u7528","yeaft.dreamDebug.location":"\u751F\u6210\u4F4D\u7F6E","yeaft.dreamDebug.result":"\u7ED3\u679C","yeaft.dreamDebug.noLatest":"\u8FD9\u4E2A\u4F1A\u8BDD\u8FD8\u6CA1\u6709\u8BB0\u5F55\u5230 Dream \u68C0\u67E5\u3002","yeaft.dreamDebug.noEvents":"\u8FD9\u4E2A\u4F1A\u8BDD\u8FD8\u6CA1\u6709 Dream \u4E8B\u4EF6\u3002","yeaft.dreamDebug.outputTitle":"\u672C session \u5DF2\u52A0\u8F7D\u7684 Dream \u8F93\u51FA","yeaft.dreamDebug.scope":"Scope","yeaft.dreamDebug.lastDream":"\u4E0A\u6B21 Dream","yeaft.dreamDebug.messagesCovered":"\u5DF2\u8986\u76D6\u6D88\u606F\u6570","yeaft.dreamDebug.noOutput":"\u8FD9\u4E2A session \u8FD8\u6CA1\u6709\u5199\u5165 Dream \u8F93\u51FA\u3002","yeaft.dreamDebug.promptLoadTitle":"\u5DF2\u52A0\u8F7D\u8FDB system prompt \u7684 Dream \u8BB0\u5FC6","yeaft.dreamDebug.loadedInto":"\u52A0\u8F7D\u4F4D\u7F6E","yeaft.dreamDebug.vp":"VP","yeaft.dreamDebug.summaryToPrompt":"summary.md -> system prompt","yeaft.dreamDebug.itemList":"Dream \u8FD0\u884C\u548C Scope","yeaft.dreamDebug.searchPlaceholder":"\u6309\u6807\u9898\u3001ID \u6216\u6458\u8981\u641C\u7D22 Dream Session...","yeaft.dreamDebug.noSearchResults":"\u6CA1\u6709\u5339\u914D\u7684 Dream Session\u3002","yeaft.dreamDebug.noSummary":"\u6682\u65E0\u6458\u8981","yeaft.dreamDebug.segments":"\u6BB5","yeaft.dreamDebug.lastError":"\u6700\u8FD1\u9519\u8BEF","yeaft.dreamDebug.overview":"\u6982\u89C8","yeaft.dreamDebug.sessionId":"Session ID","yeaft.dreamDebug.loadedAt":"\u52A0\u8F7D\u65F6\u95F4","yeaft.dreamDebug.layers":"\u5C42\u7EA7","yeaft.dreamDebug.summaryLayer":"Resident summary","yeaft.dreamDebug.noPromptLoad":"\u8FD9\u4E2A scope \u6682\u65E0 prompt-load \u8BB0\u5F55\u3002","yeaft.dreamDebug.segmentTitle":"Segments","yeaft.dreamDebug.sourceMessages":"\u6765\u6E90\u6D88\u606F","yeaft.dreamDebug.createdAt":"\u521B\u5EFA\u65F6\u95F4","yeaft.dreamDebug.updatedAt":"\u66F4\u65B0\u65F6\u95F4","yeaft.dreamDebug.noSegments":"\u8FD9\u4E2A scope \u6682\u65E0 memory segments\u3002","yeaft.dreamDebug.requestResponse":"Request / Response","yeaft.dreamDebug.noRequestResponse":"\u8FD9\u4E2A scope \u8FD8\u6CA1\u6709\u6301\u4E45\u5316\u7684 Dream request/response \u65E5\u5FD7\u3002","yeaft.dreamDebug.empty":"\u6682\u65E0 Dream debug \u6570\u636E\u3002","yeaft.debugGroupFollowMain":"\u8DDF\u968F\u4E3B\u9762\u677F","yeaft.debugGroupAll":"\u5168\u90E8\u4F1A\u8BDD","yeaft.debugAssistantResponse":"Assistant \u56DE\u590D","yeaft.debugViewAssistantResponse":"\u67E5\u770B\u56DE\u590D","yeaft.debugLatestRequestBody":"\u6700\u8FD1\u53EF\u7528\u8BF7\u6C42\u4F53","yeaft.debugLatestSystemPrompt":"\u6700\u8FD1\u53EF\u7528\u7CFB\u7EDF\u63D0\u793A","yeaft.debugRequestBodyUnavailable":"\u6B64 Turn \u6682\u65E0\u53EF\u7528\u8BF7\u6C42\u4F53\u3002","yeaft.debugSystemPromptUnavailable":"\u6B64 Turn \u6682\u65E0\u53EF\u7528\u7CFB\u7EDF\u63D0\u793A\u3002","yeaft.debugInputSystemShort":"\u7CFB\u7EDF","yeaft.debugInputHistoryShort":"\u5386\u53F2","yeaft.debugInputToolsShort":"\u5DE5\u5177\u5B9A\u4E49","yeaft.debugInputCurrentShort":"\u5F53\u524D","yeaft.debugInputTokenBreakdown":"Provider \u8F93\u5165 {total}\uFF1A\u7CFB\u7EDF\u63D0\u793A {system}\u3001\u5386\u53F2\u6D88\u606F {history}\u3001\u5DE5\u5177\u5B9A\u4E49 {tools}\u3001\u5F53\u524D Turn {current}\uFF08\u4F30\u7B97\u62C6\u5206\uFF09","yeaft.debugToolInput":"\u8F93\u5165","yeaft.debugToolResult":"\u7ED3\u679C","yeaft.debugToolRunning":"\u6267\u884C\u4E2D","yeaft.debugToolRunningNoResult":"\u6267\u884C\u4E2D\uFF0C\u6682\u65E0\u7ED3\u679C","yeaft.debugShowDetails":"\u5C55\u5F00","yeaft.debugHideDetails":"\u6536\u8D77","yeaft.debugTurnStartedAt":"\u56DE\u5408\u5F00\u59CB\u65F6\u95F4","yeaft.debugRequestAt":"\u8BF7\u6C42\u65F6\u95F4","yeaft.debugRequestAtDerived":"\u7531\u56DE\u5408\u5F00\u59CB\u65F6\u95F4\u63A8\u7B97\uFF08\u65E7 loop\uFF09","yeaft.turn":"\u7B2C {n} \u8F6E","yeaft.systemPrompt":"\u7CFB\u7EDF\u63D0\u793A","yeaft.messagesLabel":"\u6D88\u606F","yeaft.response":"\u56DE\u590D","yeaft.toolCalls":"\u5DE5\u5177\u8C03\u7528","yeaft.functionCalls":"\u51FD\u6570\u8C03\u7528","yeaft.request":"\u8BF7\u6C42","yeaft.pending":"(\u7B49\u5F85\u4E2D)","yeaft.inputTokens":"\u8F93\u5165","yeaft.outputTokens":"\u8F93\u51FA","yeaft.duration":"\u8017\u65F6","yeaft.noDebugData":"\u6682\u65E0\u8C03\u8BD5\u6570\u636E","yeaft.showDebug":"\u663E\u793A\u8C03\u8BD5\u9762\u677F","yeaft.hideDebug":"\u9690\u85CF\u8C03\u8BD5\u9762\u677F","yeaft.reloadPage":"\u5237\u65B0\u9875\u9762","yeaft.reloadMessages":"\u91CD\u65B0\u52A0\u8F7D\u6D88\u606F","sidebar.sessions.syncing":"\u6B63\u5728\u540C\u6B65\u6700\u65B0\u6D88\u606F","yeaft.historySearch.label":"\u641C\u7D22 Session \u5386\u53F2\u6D88\u606F","yeaft.historySearch.button":"\u641C\u7D22\u6D88\u606F","yeaft.historySearch.placeholder":"\u641C\u7D22\u5F53\u524D Session \u7684\u6D88\u606F","yeaft.historySearch.searching":"\u6B63\u5728\u641C\u7D22\u2026","yeaft.historySearch.minChars":"\u81F3\u5C11\u8F93\u5165 2 \u4E2A\u5B57\u7B26","yeaft.historySearch.empty":"\u6CA1\u6709\u5339\u914D\u7684\u6D88\u606F","yeaft.historySearch.error":"\u641C\u7D22\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5","yeaft.historySearch.unsupported":"\u8BF7\u5347\u7EA7\u5F53\u524D Agent \u540E\u518D\u641C\u7D22 Session \u5386\u53F2\u6D88\u606F","yeaft.historySearch.more":"\u52A0\u8F7D\u66F4\u591A\u7ED3\u679C","yeaft.historySearch.you":"\u4F60","yeaft.historySearch.assistant":"\u52A9\u624B","yeaft.outline.label":"\u5386\u53F2\u6D88\u606F","yeaft.outline.sender":"\u53D1\u9001\u8005","yeaft.outline.allSenders":"\u5168\u90E8\u53D1\u9001\u8005","yeaft.outline.title":"\u5386\u53F2\u6D88\u606F","yeaft.outline.placeholder":"\u641C\u7D22\u5F53\u524D\u5BF9\u8BDD","yeaft.outline.searching":"\u6B63\u5728\u641C\u7D22\u2026","yeaft.outline.loading":"\u6B63\u5728\u52A0\u8F7D\u2026","yeaft.outline.older":"\u52A0\u8F7D\u66F4\u65E9\u6D88\u606F","yeaft.outline.moreMatches":"\u52A0\u8F7D\u66F4\u591A\u5339\u914D\u9879","yeaft.outline.minChars":"\u81F3\u5C11\u8F93\u5165 2 \u4E2A\u5B57\u7B26","yeaft.outline.empty":"\u6682\u65E0\u6D88\u606F","yeaft.outline.noMatches":"\u6CA1\u6709\u5339\u914D\u7684\u6D88\u606F","yeaft.outline.error":"\u5927\u7EB2\u52A0\u8F7D\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5","yeaft.outline.unsupported":"\u8BF7\u5347\u7EA7\u5F53\u524D Agent \u540E\u518D\u4F7F\u7528\u5BF9\u8BDD\u5927\u7EB2","yeaft.outline.you":"\u4F60","yeaft.outline.assistant":"\u52A9\u624B","yeaft.outline.nonText":"\u975E\u6587\u672C\u56DE\u590D","yeaft.switchModel":"\u5207\u6362\u6A21\u578B","yeaft.modelMenu.title":"\u6A21\u578B\u548C LLM \u8BBE\u7F6E","yeaft.modelMenu.label":"\u6A21\u578B","yeaft.modelMenu.effort":"\u63A8\u7406\u5F3A\u5EA6","yeaft.modelMenu.effort.openaiReasoning":"\u63A8\u7406\u5F3A\u5EA6","yeaft.modelMenu.effort.anthropicBudget":"\u601D\u8003\u9884\u7B97","yeaft.modelMenu.effort.anthropicAdaptive":"\u81EA\u9002\u5E94\u601D\u8003\u5F3A\u5EA6","yeaft.modelMenu.effort.minimal":"\u6700\u5C0F","yeaft.modelMenu.effort.low":"\u4F4E","yeaft.modelMenu.effort.medium":"\u4E2D","yeaft.modelMenu.effort.high":"\u9AD8","yeaft.modelMenu.effort.xhigh":"\u8D85\u9AD8","yeaft.modelMenu.effort.max":"\u6700\u9AD8","yeaft.modelMenu.effort.ultra":"\u6781\u81F4","yeaft.modelMenu.noEffort":"\u5F53\u524D\u6A21\u578B\u6CA1\u6709\u53EF\u517C\u5BB9\u6620\u5C04\u7684\u63A8\u7406\u5F3A\u5EA6\u63A7\u5236\u3002","yeaft.modelMenu.configureHint":"Provider\u3001\u5BC6\u94A5\u3001\u6A21\u578B\u5217\u8868","yeaft.settings.title":"\u8BBE\u7F6E","yeaft.settings.tabs.vp":"VP \u5E93","yeaft.settings.tabs.search":"\u641C\u7D22","search.settings.backendTitle":"\u641C\u7D22\u540E\u7AEF","search.settings.backendDesc":"\u9009\u62E9 WebSearch \u5DE5\u5177\u9ED8\u8BA4\u4F7F\u7528\u7684\u540E\u7AEF\u3002\u4E3B\u540E\u7AEF\u5931\u8D25\u65F6,\u5F15\u64CE\u4F1A\u81EA\u52A8\u964D\u7EA7\u5230 HTML \u6293\u53D6\u3002","search.settings.backend.tavily":"Tavily","search.settings.backend.tavilyHint":"\u6258\u7BA1\u641C\u7D22 API\u3002\u514D\u8D39\u989D\u5EA6 1000 \u6B21/\u6708\u3002\u63A8\u8350\u3002","search.settings.backend.playwright":"Playwright \u670D\u52A1","search.settings.backend.playwrightHint":"\u81EA\u5EFA\u7684\u6D4F\u89C8\u5668\u5F0F\u641C\u7D22/\u6293\u53D6\u670D\u52A1,\u9002\u5408 IP \u4FE1\u8A89\u5DEE\u88AB bot \u68C0\u6D4B\u7684\u73AF\u5883\u3002\u5C1A\u672A\u4E0A\u7EBF\u3002","search.settings.comingSoon":"\u5373\u5C06\u63A8\u51FA","search.settings.tavilyKeyTitle":"Tavily API key","search.settings.tavilyKeyDesc":"\u4FDD\u5B58\u5728 agent \u7684 ~/.yeaft/config.json \u4E2D\u3002\u514D\u8D39\u7533\u8BF7:","search.settings.tavilyKeyUnchanged":"\u4FDD\u6301\u4E0D\u53D8","search.settings.clearKey":"\u6E05\u9664","search.settings.usageTitle":"\u672C\u6708\u7528\u91CF","search.settings.usageRefresh":"\u5237\u65B0","search.settings.usageLoading":"\u52A0\u8F7D\u4E2D\u2026","search.settings.usagePlan":"\u8BA1\u5212","search.settings.usageUsed":"\u5DF2\u7528","search.settings.usagePaygo":"\u6309\u91CF\u4ED8\u8D39","search.settings.usageError":"\u52A0\u8F7D\u7528\u91CF\u5931\u8D25","search.settings.save":"\u4FDD\u5B58","search.settings.saving":"\u4FDD\u5B58\u4E2D\u2026","search.settings.saveSuccess":"\u5DF2\u4FDD\u5B58","search.settings.cancel":"\u91CD\u7F6E","yeaft.settings.yeaftTitle":"\u7EBF\u7A0B\u5E76\u53D1\u4E0E\u5F52\u6863","yeaft.settings.yeaftDesc":"\u8C03\u6574\u53EF\u540C\u65F6\u8FD0\u884C\u7684\u7EBF\u7A0B\u6570\u91CF\uFF0C\u4EE5\u53CA\u95F2\u7F6E\u7EBF\u7A0B\u7684\u81EA\u52A8\u5F52\u6863\u65F6\u957F\u3002","yeaft.settings.maxConcurrentLabel":"\u6700\u5927\u5E76\u53D1\u7EBF\u7A0B\u6570","yeaft.settings.maxConcurrentHint":"\u540C\u65F6\u5728\u7EBF\u7684\u7EBF\u7A0B\u603B\u6570\u4E0A\u9650\uFF08\u542B\u59CB\u7EC8\u5B58\u5728\u7684 main \u4E3B\u7EBF\u7A0B\uFF09\u3002\u8D85\u8FC7\u6B64\u4E0A\u9650\u7684\u65B0\u7EBF\u7A0B\u5C06\u88AB\u62D2\u7EDD\uFF0C\u76F4\u81F3\u5DF2\u6709\u7EBF\u7A0B\u88AB\u5F52\u6863\u6216\u7EC8\u6B62\u3002\u8303\u56F4\uFF1A1-50\u3002","yeaft.settings.archiveIdleDaysLabel":"\u95F2\u7F6E\u591A\u4E45\u540E\u81EA\u52A8\u5F52\u6863\u7EBF\u7A0B\uFF08\u5929\uFF09","yeaft.settings.archiveIdleDaysHint":"\u65E0\u6D3B\u52A8\u8D85\u8FC7\u6B64\u5929\u6570\u7684\u7EBF\u7A0B\u5C06\u88AB\u5F52\u6863\u3002\u8303\u56F4\uFF1A1-3650\u3002","yeaft.settings.yeaftSaveBtn":"\u4FDD\u5B58","yeaft.settings.yeaftSaving":"\u4FDD\u5B58\u4E2D...","yeaft.settings.yeaftSaved":"\u5DF2\u4FDD\u5B58","yeaft.settings.yeaftLoading":"\u52A0\u8F7D\u4E2D...","yeaft.settings.yeaftLoadError":"\u52A0\u8F7D Yeaft \u8BBE\u7F6E\u5931\u8D25","yeaft.settings.yeaftSaveError":"\u4FDD\u5B58 Yeaft \u8BBE\u7F6E\u5931\u8D25","yeaft.settings.rangeErrorConcurrent":"\u5FC5\u987B\u5728 1 \u5230 50 \u4E4B\u95F4","yeaft.settings.rangeErrorArchive":"\u5FC5\u987B\u5728 1 \u5230 3650 \u4E4B\u95F4","chat.session.creating":"\u6B63\u5728\u521B\u5EFA\u4F1A\u8BDD...","chat.session.loadingHistory":"\u6B63\u5728\u52A0\u8F7D\u4F1A\u8BDD\u5386\u53F2...","yeaft.historyLoad.error":"\u4F1A\u8BDD\u5386\u53F2\u6682\u65F6\u65E0\u6CD5\u52A0\u8F7D\uFF0C\u6D88\u606F\u4ECD\u5B89\u5168\u4FDD\u5B58\u5728 Agent \u4E2D\u3002","yeaft.historyLoad.retry":"\u91CD\u65B0\u52A0\u8F7D","yeaft.sessionInventory.error":"\u6682\u65F6\u65E0\u6CD5\u52A0\u8F7D Session\uFF0C\u4F1A\u8BDD\u4ECD\u5B89\u5168\u4FDD\u5B58\u5728 Agent \u4E2D\u3002","yeaft.sessionInventory.retry":"\u91CD\u65B0\u52A0\u8F7D Session","chat.session.closed":"\u4F1A\u8BDD\u5DF2\u5173\u95ED","chat.session.agentOffline":"Agent \u5DF2\u79BB\u7EBF\uFF0C\u8BE5\u4F1A\u8BDD\u5C06\u5728 Agent \u91CD\u65B0\u4E0A\u7EBF\u540E\u6062\u590D\u3002","chat.execution.cancelled":"\u6267\u884C\u5DF2\u53D6\u6D88","chat.sidebar.expand":"\u5C55\u5F00\u83DC\u5355","chat.sidebar.collapse":"\u6536\u8D77\u4FA7\u8FB9\u680F","chat.sidebar.workbench":"\u5DE5\u5177\u9762\u677F","chat.sidebar.newConv":"\u4F1A\u8BDD","chat.sidebar.recentChats":"\u6700\u8FD1\u4F1A\u8BDD","chat.sidebar.resumeConv":"\u6062\u590D\u4F1A\u8BDD","chat.sidebar.lightMode":"\u6D45\u8272\u6A21\u5F0F","chat.sidebar.darkMode":"\u6DF1\u8272\u6A21\u5F0F","chat.sidebar.settings":"\u8BBE\u7F6E","chat.sidebar.emptyHint":"\u70B9\u51FB\u4E0A\u65B9\u6309\u94AE\u521B\u5EFA\u65B0\u4F1A\u8BDD","chat.sidebar.closeConv":"\u5173\u95ED\u4F1A\u8BDD","chat.sidebar.renameConv":"\u91CD\u547D\u540D","chat.sidebar.pin":"\u7F6E\u9876","chat.sidebar.unpin":"\u53D6\u6D88\u7F6E\u9876","chat.connection.connecting":"\u8FDE\u63A5\u4E2D...","chat.connection.reconnecting":"\u91CD\u8FDE\u4E2D ({current}/{max})...","chat.connection.updating":"\u670D\u52A1\u6B63\u5728\u66F4\u65B0\uFF0C\u8BF7\u7A0D\u5019...","chat.connection.disconnected":"\u8FDE\u63A5\u65AD\u5F00","chat.connection.reconnect":"\u91CD\u8FDE","chat.connection.reconnectFailed":"\u8FDE\u63A5\u65AD\u5F00\uFF0C\u8BF7\u70B9\u51FB\u91CD\u8FDE\u6309\u94AE\u91CD\u8BD5\u3002","chat.time.justNow":"\u521A\u521A","chat.time.minutesAgo":"{count}\u5206\u949F\u524D","chat.time.daysAgo":"{count}\u5929\u524D","chat.time.today":"\u4ECA\u5929","chat.time.yesterday":"\u6628\u5929","chat.delete.confirm":"\u786E\u5B9A\u8981\u5173\u95ED\u8FD9\u4E2A\u4F1A\u8BDD\u5417\uFF1F\u8FD9\u5C06\u7EC8\u6B62\u5BF9\u5E94\u7684 Claude \u8FDB\u7A0B\u3002","chat.delete.enterWorkDir":"\u8BF7\u8F93\u5165\u5DE5\u4F5C\u76EE\u5F55\u8DEF\u5F84","modal.newConv.workDir":"\u5DE5\u4F5C\u76EE\u5F55","modal.newConv.inputOrSelect":"\u8F93\u5165\u6216\u9009\u62E9\u5DE5\u4F5C\u76EE\u5F55","modal.newConv.browse":"\u6D4F\u89C8\u76EE\u5F55","modal.newConv.noWorkDirs":"\u6682\u65E0\u5DE5\u4F5C\u76EE\u5F55","modal.newConv.selectAgent":"\u8BF7\u5148\u9009\u62E9\u4E00\u4E2A\u5728\u7EBF\u7684 Agent","modal.newConv.create":"\u521B\u5EFA\u4F1A\u8BDD","modal.newConv.folderLabel":"\u{1F4C1} \u5DE5\u4F5C\u76EE\u5F55","modal.newConv.provider":"\u63D0\u4F9B\u65B9","modal.newConv.model":"\u6A21\u578B","provider.claudeCode":"Claude Code","provider.copilot":"Copilot","modal.resume.workDir":"\u5DE5\u4F5C\u76EE\u5F55","modal.resume.inputOrSelect":"\u8F93\u5165\u6216\u9009\u62E9\u5DE5\u4F5C\u76EE\u5F55","modal.resume.browse":"\u6D4F\u89C8\u76EE\u5F55","modal.resume.tabFolders":"\u5DE5\u4F5C\u76EE\u5F55","modal.resume.tabSessions":"\u5386\u53F2\u4F1A\u8BDD","modal.resume.noWorkDirs":"\u6682\u65E0\u5DE5\u4F5C\u76EE\u5F55","modal.resume.selectWorkDir":"\u8BF7\u5148\u9009\u62E9\u5DE5\u4F5C\u76EE\u5F55","modal.resume.noSessions":"\u8BE5\u76EE\u5F55\u4E0B\u6CA1\u6709\u5386\u53F2\u4F1A\u8BDD","modal.resume.untitled":"\u672A\u547D\u540D\u4F1A\u8BDD","modal.resume.folderLabel":"\u{1F4C1} \u5DE5\u4F5C\u76EE\u5F55","modal.resume.sessionLabel":"\u{1F4AC} \u5386\u53F2\u4F1A\u8BDD","modal.resume.selectAgent":"\u8BF7\u5148\u9009\u62E9\u4E00\u4E2A\u5728\u7EBF\u7684 Agent","modal.folderPicker.title":"\u9009\u62E9\u5DE5\u4F5C\u76EE\u5F55","modal.folderPicker.parentDir":"\u4E0A\u7EA7\u76EE\u5F55","welcome.subtitle":"\u9762\u5411 Session\u3001\u5DE5\u5177\u548C VP \u534F\u4F5C\u7684 Web Code Agent","welcome.agentOnline":"{count} \u4E2A Agent \u5728\u7EBF","welcome.noAgents":"\u6682\u65E0\u5728\u7EBF Agent","welcome.noAgentsHint":"\u8BF7\u5148\u542F\u52A8 Agent \u7A0B\u5E8F\u8FDE\u63A5\u5230\u670D\u52A1\u5668","welcome.noAgent":"\u6682\u65E0\u5728\u7EBF Agent","welcome.noAgentHint":"\u8BF7\u5148\u542F\u52A8 Agent \u7A0B\u5E8F\u8FDE\u63A5\u5230\u670D\u52A1\u5668","welcome.setupAgent":"\u8BBE\u7F6E Agent","welcome.setupTitle":"\u8FDE\u63A5\u4F60\u7684 Agent","welcome.setupDesc":"\u5728\u4F60\u7684\u7535\u8111\u4E0A\u8FD0\u884C\u5B89\u88C5\u547D\u4EE4\uFF0C\u5373\u53EF\u5F00\u59CB\u5BF9\u8BDD\u3002\u4EE3\u7801\u548C\u5DE5\u5177\u59CB\u7EC8\u7559\u5728\u672C\u673A\u3002","welcome.setupSecretLoading":"\u6B63\u5728\u51C6\u5907 Agent secret...","welcome.setupSecretError":"\u65E0\u6CD5\u51C6\u5907 Agent secret\uFF0C\u8BF7\u6253\u5F00\u5B89\u5168\u8BBE\u7F6E\u91CD\u8BD5\u3002","installer.platformLabel":"\u76EE\u6807\u64CD\u4F5C\u7CFB\u7EDF","installer.posix":"Linux / macOS","installer.powershell":"Windows PowerShell","installer.copyCommand":"\u590D\u5236\u5B89\u88C5\u547D\u4EE4","installer.instruction":"\u5C06\u547D\u4EE4\u7C98\u8D34\u5230\u8FD0\u884C Agent \u7684\u7535\u8111\u7EC8\u7AEF\u4E2D\u6267\u884C\u3002","installer.viewCommand":"\u67E5\u770B\u547D\u4EE4","installer.copying":"\u590D\u5236\u4E2D\u2026","installer.copyFailed":"\u590D\u5236\u5931\u8D25","installer.secretLoading":"\u6B63\u5728\u51C6\u5907 Agent secret\u2026","installer.secretError":"\u65E0\u6CD5\u51C6\u5907 Agent secret\u3002","installer.secretRequired":"\u8BF7\u5148\u751F\u6210 Agent secret\uFF0C\u518D\u590D\u5236\u6B64\u547D\u4EE4\u3002","installer.commandUnavailable":"\u751F\u6210 Agent secret \u540E\u624D\u4F1A\u63D0\u4F9B\u547D\u4EE4\u3002","installer.copyError":"\u590D\u5236\u5931\u8D25\uFF0C\u8BF7\u624B\u52A8\u9009\u62E9\u5E76\u590D\u5236\u547D\u4EE4\u3002","installer.copySuccess":"\u547D\u4EE4\u5DF2\u590D\u5236\u3002","installer.openSecurity":"\u6253\u5F00\u5B89\u5168\u8BBE\u7F6E","installer.note":"\u81EA\u52A8\u5B89\u88C5 Node.js \u548C\u79C1\u6709 Agent \u5B9E\u4F8B\u3002\u4EC5\u8FD0\u884C\u53EF\u4FE1\u670D\u52A1\u5668\u7684\u547D\u4EE4\uFF1B\u547D\u4EE4\u542B\u63A5\u5165\u5BC6\u94A5\uFF0C\u8BF7\u52FF\u5206\u4EAB\u3002","welcome.openSecuritySettings":"\u6253\u5F00\u5B89\u5168\u8BBE\u7F6E","welcome.newConv":"\u4F1A\u8BDD","welcome.resumeHistory":"\u6062\u590D\u5386\u53F2","messages.loadingMore":"\u52A0\u8F7D\u66F4\u591A\u6D88\u606F...","messages.loadMore":"\u2191 \u70B9\u51FB\u6216\u5411\u4E0A\u6EDA\u52A8\u52A0\u8F7D\u66F4\u591A","message.loadingMore":"\u52A0\u8F7D\u66F4\u591A\u6D88\u606F...","message.loadMore":"\u2191 \u70B9\u51FB\u6216\u5411\u4E0A\u6EDA\u52A8\u52A0\u8F7D\u66F4\u591A","message.navigation":"\u5BF9\u8BDD\u5BFC\u822A","message.currentTurn":"\u2191 \u672C\u8F6E","message.scrollToLatest":"\u2193 \u6700\u65B0","message.backToCurrentTurn":"\u56DE\u5230\u672C\u8F6E\u95EE\u9898","message.showResponses":"\u5C55\u5F00 {count} \u6761\u56DE\u590D","message.hideResponses":"\u6298\u53E0\u56DE\u590D","message.assistant":"\u52A9\u624B","chat.waiting.disconnected":"\u8FDE\u63A5\u5DF2\u65AD\u5F00","chat.connecting":"\u6B63\u5728\u8FDE\u63A5 provider \u4F1A\u8BDD...","chat.waiting.compacting":"\u6B63\u5728\u538B\u7F29\u4E0A\u4E0B\u6587...","chat.waiting.agentOffline":"Agent \u5DF2\u79BB\u7EBF","chat.waiting.sessionLost":"Session \u5DF2\u4E22\u5931\uFF0C\u5DF2\u5237\u65B0\uFF0C\u7B49\u5F85\u6700\u65B0\u4FE1\u606F...","chat.waiting.cliExited":"Claude \u8FDB\u7A0B\u5DF2\u9000\u51FA\uFF0C\u5DF2\u5237\u65B0\uFF0C\u7B49\u5F85\u6700\u65B0\u4FE1\u606F...","chat.waiting.refresh":"\u5237\u65B0","chat.waiting.thinking":"AI \u6B63\u5728\u601D\u8003\u4E2D\uFF0C\u8BF7\u7A0D\u5019...","btw.hint":"esc \u9000\u51FA","btw.placeholder":"\u95EE\u4E2A\u987A\u4FBF\u7684\u95EE\u9898...","btw.close":"\u9000\u51FA BTW \u6A21\u5F0F","message.copyContent":"\u590D\u5236\u5185\u5BB9","message.copy":"\u590D\u5236\u5185\u5BB9","message.copied":"\u5DF2\u590D\u5236","message.copyCode":"\u590D\u5236\u4EE3\u7801","message.copyAll":"\u590D\u5236\u5168\u90E8","message.screenshot":"\u622A\u56FE","message.screenshotting":"\u6B63\u5728\u622A\u56FE...","message.exportMd":"\u5BFC\u51FA MD","message.askInput":"\u9700\u8981\u4F60\u7684\u8F93\u5165","message.askAnswered":"\u2713 \u5DF2\u56DE\u7B54","message.askCustom":"\u6216\u8F93\u5165\u81EA\u5B9A\u4E49\u56DE\u7B54...","message.askCustomPlaceholder":"\u6216\u8F93\u5165\u81EA\u5B9A\u4E49\u56DE\u7B54...","message.askSubmit":"\u63D0\u4EA4\u56DE\u7B54","message.askWaiting":"\u7B49\u5F85\u95EE\u9898\u52A0\u8F7D...","message.askSubmitting":"\u56DE\u7B54\u5DF2\u53D1\u9001\uFF0C\u7B49\u5F85 Agent \u786E\u8BA4\u2026","message.askUnconfirmed":"\u5C1A\u672A\u6536\u5230\u786E\u8BA4\uFF0C\u8BF7\u68C0\u67E5\u8FDE\u63A5\u540E\u91CD\u53D1\u540C\u4E00\u56DE\u7B54\u3002","message.askRetry":"\u91CD\u53D1\u56DE\u7B54","message.askSendFailed":"\u56DE\u7B54\u672A\u53D1\u9001\uFF0C\u8BF7\u68C0\u67E5\u8FDE\u63A5\u540E\u91CD\u8BD5\u3002","message.askAgentUnavailable":"Agent \u6682\u4E0D\u53EF\u7528\uFF0C\u8BF7\u6062\u590D\u8FDE\u63A5\u540E\u91CD\u53D1\u56DE\u7B54\u3002","message.askIdentityMismatch":"\u6B64\u95EE\u9898\u4E0E\u5F53\u524D\u8BF7\u6C42\u4E0D\u4E00\u81F4\uFF0C\u8BF7\u8BA9\u89D2\u8272\u91CD\u65B0\u63D0\u95EE\u3002","message.askExpired":"\u6B64\u95EE\u9898\u5DF2\u5931\u6548\uFF0C\u8BF7\u8BA9\u89D2\u8272\u91CD\u65B0\u63D0\u95EE","message.openInEditor":"\u5728\u7F16\u8F91\u5668\u4E2D\u6253\u5F00","message.resultDone":"\u5B8C\u6210","message.done":"\u5B8C\u6210","message.resultRead":"\u8BFB\u53D6 {file}","message.readFile":"\u8BFB\u53D6 {name}","message.file":"\u6587\u4EF6","message.attachImages":"{count} \u5F20\u56FE\u7247","message.imageCount":"{count} \u5F20\u56FE\u7247","message.imagePreview":"\u56FE\u7247\u9884\u89C8","message.zoomOut":"\u7F29\u5C0F\u56FE\u7247","message.zoomIn":"\u653E\u5927\u56FE\u7247","message.resetZoom":"\u91CD\u7F6E\u56FE\u7247\u7F29\u653E","message.previousImage":"\u4E0A\u4E00\u5F20\u56FE\u7247","message.nextImage":"\u4E0B\u4E00\u5F20\u56FE\u7247","message.imagePosition":"\u7B2C {current} \u5F20\uFF0C\u5171 {total} \u5F20","message.imageUnavailable":"\u56FE\u7247\u65E0\u6CD5\u52A0\u8F7D","message.attachFiles":"{count} \u4E2A\u6587\u4EF6","message.fileCount":"{count} \u4E2A\u6587\u4EF6","message.quote":"\u5F15\u7528","message.removeQuote":"\u5220\u9664\u5F15\u7528","message.replyingTo":"\u6B63\u5728\u56DE\u590D {author}","message.quotedFrom":"\u5F15\u7528\u81EA {author}","message.editAsNew":"\u7F16\u8F91","message.you":"\u4F60","input.upload":"\u4E0A\u4F20\u6587\u4EF6","input.placeholder":"\u8F93\u5165\u6D88\u606F...","input.send":"\u53D1\u9001","input.stopExecution":"\u505C\u6B62\u6267\u884C","chatInput.upload":"\u4E0A\u4F20\u6587\u4EF6","chatInput.uploading":"\u6B63\u5728\u4E0A\u4F20\u2026","chatInput.uploadFailed":"\u4E0A\u4F20\u5931\u8D25","chatInput.retryUpload":"\u91CD\u8BD5","chatInput.removeAttachment":"\u79FB\u9664\u9644\u4EF6","chatInput.placeholder":"\u8F93\u5165\u6D88\u606F...","chatInput.send":"\u53D1\u9001","chatInput.stop":"\u505C\u6B62\u6267\u884C","tools.thinking":"\u601D\u8003\u4E2D...","tools.read":"\u6B63\u5728\u8BFB\u53D6\u6587\u4EF6","tools.write":"\u6B63\u5728\u5199\u5165\u6587\u4EF6","tools.edit":"\u6B63\u5728\u7F16\u8F91\u6587\u4EF6","tools.bash":"\u6B63\u5728\u6267\u884C\u547D\u4EE4","tools.glob":"\u6B63\u5728\u641C\u7D22\u6587\u4EF6","tools.grep":"\u6B63\u5728\u641C\u7D22\u5185\u5BB9","tools.task":"\u6B63\u5728\u6267\u884C\u4EFB\u52A1","tools.webFetch":"\u6B63\u5728\u83B7\u53D6\u7F51\u9875","tools.webSearch":"\u6B63\u5728\u641C\u7D22\u7F51\u7EDC","tools.todoWrite":"\u6B63\u5728\u66F4\u65B0\u4EFB\u52A1","tools.executing":"\u6B63\u5728\u6267\u884C {name}","status.thinking":"\u601D\u8003\u4E2D...","status.reading":"\u6B63\u5728\u8BFB\u53D6\u6587\u4EF6","status.writing":"\u6B63\u5728\u5199\u5165\u6587\u4EF6","status.editing":"\u6B63\u5728\u7F16\u8F91\u6587\u4EF6","status.executing":"\u6B63\u5728\u6267\u884C\u547D\u4EE4","status.searchingFiles":"\u6B63\u5728\u641C\u7D22\u6587\u4EF6","status.searchingContent":"\u6B63\u5728\u641C\u7D22\u5185\u5BB9","status.executingTask":"\u6B63\u5728\u6267\u884C\u4EFB\u52A1","status.fetching":"\u6B63\u5728\u83B7\u53D6\u7F51\u9875","status.searching":"\u6B63\u5728\u641C\u7D22\u7F51\u7EDC","status.updatingTasks":"\u6B63\u5728\u66F4\u65B0\u4EFB\u52A1","status.executingTool":"\u6B63\u5728\u6267\u884C {name}","header.compacting":"\u6B63\u5728\u538B\u7F29\u4E0A\u4E0B\u6587...","header.compacted":"\u4E0A\u4E0B\u6587\u538B\u7F29\u5B8C\u6210","chatHeader.newConv":"\u4F1A\u8BDD","chatHeader.compacting":"\u6B63\u5728\u538B\u7F29\u4E0A\u4E0B\u6587...","chatHeader.compactDone":"\u4E0A\u4E0B\u6587\u538B\u7F29\u5B8C\u6210","chatHeader.compact":"\u538B\u7F29\u4E0A\u4E0B\u6587","chatHeader.resume":"\u6062\u590D\u4F1A\u8BDD","chatHeader.refresh":"\u5237\u65B0\u6D88\u606F","chatHeader.reloadPage":"\u5237\u65B0\u9875\u9762","chatHeader.clear":"\u6E05\u7A7A\u6D88\u606F","chatHeader.clearing":"\u6B63\u5728\u6E05\u7A7A\u4E0A\u4E0B\u6587...","chatHeader.clearDone":"\u4E0A\u4E0B\u6587\u5DF2\u6E05\u7A7A","chatHeader.confirmClear":"\u786E\u5B9A\u8981\u6E05\u7A7A\u5F53\u524D\u4F1A\u8BDD\u7684\u6240\u6709\u6D88\u606F\u5417\uFF1F","chatHeader.mcpConfig":"MCP \u670D\u52A1\u5668\u914D\u7F6E","chatHeader.mcpNeedRestart":"\u66F4\u6539\u5C06\u5728\u91CD\u542F\u4F1A\u8BDD\u540E\u751F\u6548\u3002","chatHeader.expertPanel":"\u5E2E\u5E2E\u56E2","chatHeader.subAgentPanel":"\u5B50\u4EE3\u7406","settings.close":"\u5173\u95ED\u8BBE\u7F6E","settings.tabs.account":"\u8D26\u53F7","settings.tabs.security":"\u5B89\u5168","settings.tabs.general":"\u901A\u7528","settings.tabs.sandbox":"Sandbox","settings.tabs.invitations":"\u9080\u8BF7","auth.sessionExpired":"\u767B\u5F55\u5DF2\u8FC7\u671F\uFF0C\u8BF7\u91CD\u65B0\u767B\u5F55\u3002","settings.sandbox.description":"\u5728\u672C Server \u7BA1\u7406\u7684 Docker \u5BB9\u5668\u4E2D\u8FD0\u884C\u4E00\u4E2A\u6301\u4E45\u5316 Yeaft Agent\u3002","settings.sandbox.containerAgent":"Docker \u5316 Yeaft Agent","settings.sandbox.serverManaged":"Server \u53EA\u7BA1\u7406\u6B64\u5BB9\u5668\u7684\u542F\u52A8\u3001\u505C\u6B62\u548C\u5220\u9664\uFF1B\u5BB9\u5668\u5185 Agent \u4ECD\u4F7F\u7528\u666E\u901A Yeaft \u8FDE\u63A5\u3002","settings.sandbox.agentName":"Agent \u540D\u79F0","settings.sandbox.sizeLabel":"\u89C4\u683C","settings.sandbox.enable":"\u542F\u7528 Sandbox","settings.sandbox.creating":"\u6B63\u5728\u8BBE\u7F6E\u2026","settings.sandbox.start":"\u542F\u52A8","settings.sandbox.stop":"\u505C\u6B62","settings.sandbox.retry":"\u91CD\u8BD5","settings.sandbox.remove":"\u79FB\u9664","settings.sandbox.removeConfirm":"\u6C38\u4E45\u79FB\u9664\u6B64 Sandbox\uFF0C\u5E76\u5220\u9664 home \u548C workspace \u6570\u636E\uFF1F\u6B64\u64CD\u4F5C\u65E0\u6CD5\u64A4\u9500\u3002","settings.sandbox.size.small":"\u5C0F\u578B","settings.sandbox.size.normal":"\u6807\u51C6","settings.sandbox.state.reserving":"\u6B63\u5728\u8BBE\u7F6E","settings.sandbox.state.provisioning":"\u6B63\u5728\u51C6\u5907 Sandbox","settings.sandbox.state.starting":"\u6B63\u5728\u542F\u52A8","settings.sandbox.state.waiting_for_agent":"\u6B63\u5728\u7B49\u5F85 Agent","settings.sandbox.state.stopping":"\u6B63\u5728\u505C\u6B62","settings.sandbox.state.removing":"\u6B63\u5728\u79FB\u9664","settings.sandbox.state.removed":"\u5DF2\u79FB\u9664","settings.sandbox.state.running":"\u8FD0\u884C\u4E2D","settings.sandbox.state.stopped":"\u5DF2\u505C\u6B62","settings.sandbox.state.failed":"\u5931\u8D25","settings.sandbox.state.remove_failed":"\u79FB\u9664\u5931\u8D25","settings.sandbox.state.recovery_required":"\u9700\u8981\u6062\u590D\u5904\u7406","settings.sandbox.stage.reserving_capacity":"\u6B63\u5728\u9884\u7559\u5BB9\u91CF","settings.sandbox.stage.starting":"\u6B63\u5728\u542F\u52A8 Sandbox","settings.sandbox.stage.stopping":"\u6B63\u5728\u505C\u6B62 Sandbox","settings.sandbox.stage.retrying":"\u6B63\u5728\u91CD\u8BD5\u64CD\u4F5C","settings.sandbox.stage.removing":"\u6B63\u5728\u79FB\u9664 Sandbox","settings.sandbox.stage.complete":"\u5DF2\u5B8C\u6210","settings.sandbox.stage.dispatching":"\u6B63\u5728\u5B89\u5168\u5206\u53D1","settings.sandbox.stage.capacity_rejected":"\u6B63\u5728\u7B49\u5F85\u5BB9\u91CF","settings.sandbox.unavailable.disabled":"\u6B64 Server \u5C1A\u672A\u542F\u7528 Sandbox\u3002\u5347\u7EA7\u672C\u673A Agent \u4E0D\u4F1A\u81EA\u52A8\u542F\u7528\uFF1B\u9700\u8981 Server \u7BA1\u7406\u5458\u5F00\u542F Docker \u7BA1\u7406\u3002","settings.sandbox.unavailable.dockerUnavailable":"Server \u65E0\u6CD5\u4F7F\u7528 Docker\uFF0C\u8BF7\u68C0\u67E5 Sandbox \u7684 Server \u90E8\u7F72\u914D\u7F6E\u3002","settings.sandbox.unavailable.notEntitled":"\u6B64\u8D26\u53F7\u6682\u4E0D\u53EF\u4F7F\u7528 Sandbox\u3002","settings.sandbox.unavailable.capacityUnavailable":"Sandbox \u6682\u65F6\u4E0D\u53EF\u7528\u3002","settings.sandbox.error.SANDBOX_LOAD_FAILED":"\u65E0\u6CD5\u52A0\u8F7D Sandbox \u72B6\u6001\u3002","settings.sandbox.retryLoad":"\u91CD\u8BD5","settings.sandbox.error.SANDBOX_CREATE_FAILED":"\u65E0\u6CD5\u521B\u5EFA Sandbox\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002","settings.sandbox.error.SANDBOX_ACTION_FAILED":"\u65E0\u6CD5\u5B89\u6392 Sandbox \u64CD\u4F5C\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002","settings.sandbox.error.SANDBOX_OPERATION_TIMEOUT":"\u64CD\u4F5C\u5DF2\u8D85\u65F6\uFF0C\u8BF7\u91CD\u8BD5\u6216\u79FB\u9664 Sandbox\u3002","settings.sandbox.error.SANDBOX_RUNTIME_FAILED":"Sandbox \u8FD0\u884C\u65F6\u62A5\u544A\u5931\u8D25\u3002","settings.sandbox.error.SANDBOX_CGROUP_SLICE_UNAVAILABLE":"\u65E0\u6CD5\u5728\u5BBF\u4E3B\u673A\u521D\u59CB\u5316\u5171\u4EAB\u8D44\u6E90 slice\uFF08\u9700\u8981 cgroup v2 \u4E0E root \u6743\u9650\uFF09\u3002\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458\uFF0C\u6216\u79FB\u9664 SANDBOX_CGROUP_PARENT \u4EE5\u5173\u95ED\u8D44\u6E90\u4E0A\u9650\u3002","settings.account.username":"\u7528\u6237\u540D","settings.account.role":"\u89D2\u8272","settings.account.email":"\u90AE\u7BB1","settings.account.emailNotSet":"\u672A\u8BBE\u7F6E","settings.account.profileLoadFailed":"\u8D26\u53F7\u8D44\u6599\u52A0\u8F7D\u5931\u8D25","settings.account.logout":"\u9000\u51FA\u767B\u5F55","settings.account.roleAdmin":"\u7BA1\u7406\u5458","settings.account.rolePro":"Pro","settings.account.linkedAccounts":"\u5DF2\u5173\u8054\u8D26\u6237","settings.account.linkedDesc":"\u5173\u8054\u7B2C\u4E09\u65B9\u767B\u5F55\u540E\uFF0C\u4F7F\u7528\u4EFB\u610F\u4E00\u79CD\u65B9\u5F0F\u90FD\u80FD\u767B\u5F55\u6B64\u8D26\u53F7\u3002","settings.account.bind":"\u7ED1\u5B9A","settings.account.unbind":"\u89E3\u7ED1","settings.account.linked":"\u5DF2\u7ED1\u5B9A","settings.account.providerDisabled":"\u672A\u914D\u7F6E","settings.account.cantUnbindLast":"\u4E0D\u80FD\u89E3\u7ED1\u552F\u4E00\u7684\u767B\u5F55\u65B9\u5F0F","settings.account.unbindFailed":"\u89E3\u7ED1\u5931\u8D25\uFF1A{error}","settings.account.bindFailed":"\u7ED1\u5B9A\u5931\u8D25","settings.account.ssoBoundMsg":"\u5DF2\u6210\u529F\u7ED1\u5B9A {provider}\u3002","settings.account.ssoConflictMsg":"\u8BE5 {provider} \u8D26\u53F7\u5DF2\u88AB\u5176\u4ED6\u7528\u6237\u7ED1\u5B9A\u3002","settings.account.providerMicrosoft":"Microsoft","settings.account.providerGithub":"GitHub","settings.account.providerGoogle":"Google","settings.account.providerWechat":"\u5FAE\u4FE1","settings.account.providerAlipay":"\u652F\u4ED8\u5B9D","settings.security.agentKey":"Agent \u5BC6\u94A5","settings.security.agentKeyDesc":"\u7528\u4E8E Agent \u8FDE\u63A5\u8BA4\u8BC1\u7684\u5171\u4EAB\u5BC6\u94A5","settings.security.agentSetupCommands":"Agent \u63A5\u5165\u547D\u4EE4","settings.security.agentCmdInstall":"\u5B89\u88C5\u5E76\u8FDE\u63A5 Agent","settings.security.agentCmdService":"\u8FD0\u884C Agent server","settings.security.agentCmdContainer":"\u5728 Docker \u4E2D\u8FD0\u884C Agent","settings.security.agentCmdContainerDesc":"\u4E00\u6761\u547D\u4EE4\u5373\u53EF\u3002\u9996\u6B21\u8FD0\u884C\u4F1A\u81EA\u52A8\u521D\u59CB\u5316\u5171\u4EAB CPU/\u5185\u5B58\u9650\u5236\uFF08\u4F1A\u63D0\u793A\u8F93\u5165\u4E00\u6B21 sudo \u5BC6\u7801\uFF09\uFF1B\u4F20 --no-slice \u53EF\u4E0D\u542F\u7528\u8D44\u6E90\u4FDD\u62A4\u3002\u673A\u5668\u4E0A\u9700\u8981\u5DF2\u5B89\u88C5 Docker\u3002","settings.security.agentCmdNeedsSecret":"\u8BF7\u5148\u751F\u6210 Agent \u5BC6\u94A5\uFF0C\u4EE5\u521B\u5EFA\u5305\u542B server \u5730\u5740\u548C\u5BC6\u94A5\u7684\u547D\u4EE4\u3002","settings.security.agentCmdLlm":"Copilot \u624B\u52A8\u515C\u5E95","settings.security.agentCmdLlmDesc":"Agent \u8FDE\u63A5\u540E\uFF0C\u53EF\u5728 Agent \u8BBE\u7F6E\u4E2D\u914D\u7F6E\u53EF\u9009 LLM\u3002\u5B89\u88C5\u5668\u4E5F\u4F1A\u8F93\u51FA\u53EF\u5728\u7EC8\u7AEF\u4F7F\u7528\u7684\u7EDD\u5BF9\u8DEF\u5F84\u7BA1\u7406\u547D\u4EE4\u3002","settings.security.none":"\u65E0","settings.security.show":"\u663E\u793A","settings.security.hide":"\u9690\u85CF","settings.security.generateKey":"\u751F\u6210\u5BC6\u94A5","settings.security.resetKey":"\u91CD\u7F6E\u5BC6\u94A5","settings.security.resetting":"\u91CD\u7F6E\u4E2D...","settings.security.resetWarning":"\u91CD\u7F6E\u540E\u6240\u6709 Agent \u9700\u91CD\u65B0\u914D\u7F6E","settings.security.changePassword":"\u4FEE\u6539\u5BC6\u7801","settings.security.currentPassword":"\u5F53\u524D\u5BC6\u7801","settings.security.newPassword":"\u65B0\u5BC6\u7801\uFF08\u81F3\u5C116\u4F4D\uFF09","settings.security.confirmPassword":"\u786E\u8BA4\u65B0\u5BC6\u7801","settings.security.changeBtn":"\u4FEE\u6539\u5BC6\u7801","settings.security.changing":"\u4FEE\u6539\u4E2D...","settings.security.enterCurrentPwd":"\u8BF7\u8F93\u5165\u5F53\u524D\u5BC6\u7801","settings.security.newPwdMin":"\u65B0\u5BC6\u7801\u81F3\u5C116\u4F4D","settings.security.pwdMismatch":"\u4E24\u6B21\u5BC6\u7801\u4E0D\u4E00\u81F4","settings.security.pwdChanged":"\u5BC6\u7801\u4FEE\u6539\u6210\u529F","settings.security.setPassword":"\u8BBE\u7F6E\u5BC6\u7801","settings.security.setPasswordDesc":"\u4F60\u76EE\u524D\u901A\u8FC7 SSO \u767B\u5F55\uFF0C\u5C1A\u672A\u8BBE\u7F6E\u5BC6\u7801\u3002\u8BBE\u7F6E\u540E\u5373\u53EF\u4F7F\u7528\u7528\u6237\u540D + \u5BC6\u7801\u767B\u5F55\u3002","settings.security.setBtn":"\u8BBE\u7F6E\u5BC6\u7801","settings.security.pwdSet":"\u5BC6\u7801\u8BBE\u7F6E\u6210\u529F","settings.security.deleteAccount":"\u6CE8\u9500\u8D26\u6237","settings.security.deleteAccountDesc":"\u6C38\u4E45\u5220\u9664\u4F60\u7684\u8D26\u6237\u548C\u6240\u6709\u76F8\u5173\u6570\u636E\u3002\u6B64\u64CD\u4F5C\u4E0D\u53EF\u6062\u590D\u3002","settings.security.deleteBtn":"\u6CE8\u9500\u8D26\u6237","settings.security.deleteConfirmBtn":"\u786E\u8BA4\u5220\u9664","settings.security.deleteConfirmPlaceholder":"\u8F93\u5165 DELETE \u4EE5\u786E\u8BA4","settings.security.deleteConfirmRequired":"\u8BF7\u8F93\u5165 DELETE \u4EE5\u786E\u8BA4\u6CE8\u9500\u8D26\u6237","settings.security.deleteFailed":"\u6CE8\u9500\u8D26\u6237\u5931\u8D25","settings.security.deleting":"\u6CE8\u9500\u4E2D...","settings.general.theme":"\u4E3B\u9898","settings.general.lightTheme":"\u6D45\u8272","settings.general.darkTheme":"\u6DF1\u8272","settings.general.language":"\u8BED\u8A00","settings.general.currentValue":"\u5F53\u524D\uFF1A{value}","settings.general.workCenter":"\u5DE5\u4F5C\u4E2D\u5FC3\u5165\u53E3","settings.general.workCenterDesc":"\u5728\u4FA7\u680F\u9876\u680F\u663E\u793A\u5DE5\u4F5C\u4E2D\u5FC3\u5165\u53E3\uFF1B\u652F\u6301\u7684 Agent \u5728\u5DE5\u4F5C\u4E2D\u5FC3\u5185\u9009\u62E9\u3002","settings.general.workCenterOn":"\u5DF2\u5F00\u542F","settings.general.workCenterOff":"\u5DF2\u5173\u95ED","settings.general.telemetry":"\u6027\u80FD\u9065\u6D4B","settings.general.telemetryDesc":"\u5728\u672C\u5730\u6279\u91CF\u8BB0\u5F55\u8017\u65F6\u8BCA\u65AD\uFF1Btrace \u5185\u5BB9\u4E0D\u4F1A\u53D1\u9001\u5230\u670D\u52A1\u5668\u3002","settings.general.telemetryOn":"\u5DF2\u5F00\u542F","settings.general.telemetryOff":"\u5DF2\u5173\u95ED","settings.general.telemetryLoading":"\u52A0\u8F7D\u4E2D\u2026","settings.general.telemetrySaving":"\u4FDD\u5B58\u4E2D\u2026","settings.general.telemetryUnavailable":"\u72B6\u6001\u4E0D\u53EF\u7528","settings.general.telemetryLoadFailed":"\u65E0\u6CD5\u52A0\u8F7D\u5DF2\u4FDD\u5B58\u7684\u9065\u6D4B\u8BBE\u7F6E\uFF0C\u8BF7\u91CD\u65B0\u6253\u5F00\u8BBE\u7F6E\u540E\u91CD\u8BD5\u3002","settings.general.telemetrySaveFailed":"\u65E0\u6CD5\u786E\u8BA4\u9065\u6D4B\u8BBE\u7F6E\u53D8\u66F4\uFF0C\u5DF2\u6062\u590D\u663E\u793A\u4E4B\u524D\u7684\u8BBE\u7F6E\uFF1B\u8BF7\u91CD\u65B0\u6253\u5F00\u8BBE\u7F6E\u6838\u5BF9\u3002","settings.general.telemetryRawLimit":"Provider \u539F\u59CB\u8BF7\u6C42/\u54CD\u5E94\u4E0A\u9650\uFF08\u5B57\u8282\uFF09","settings.general.telemetryTraceTextLimit":"Debug Prompt \u4E0E\u6D88\u606F\u4E0A\u9650\uFF08\u5B57\u8282\uFF09","settings.invite.create":"\u521B\u5EFA\u9080\u8BF7\u7801","settings.invite.normalUser":"\u666E\u901A\u7528\u6237","settings.invite.proUser":"Pro \u7528\u6237","settings.invite.createBtn":"\u521B\u5EFA\u9080\u8BF7\u7801","settings.invite.creating":"\u521B\u5EFA\u4E2D...","settings.invite.list":"\u9080\u8BF7\u7801\u5217\u8868","settings.invite.used":"\u5DF2\u4F7F\u7528","settings.invite.expired":"\u5DF2\u8FC7\u671F","settings.invite.available":"\u53EF\u7528","settings.invite.usedBy":"\u4F7F\u7528\u8005: {user}","settings.invite.expiredAt":"\u8FC7\u671F\u4E8E: {time}","settings.invite.expiresAt":"\u6709\u6548\u81F3: {time}","settings.invite.noInvites":"\u6682\u65E0\u9080\u8BF7\u7801","settings.msg.copiedClipboard":"\u5DF2\u590D\u5236\u5230\u526A\u8D34\u677F","settings.msg.copyFailed":"\u590D\u5236\u5931\u8D25","settings.msg.keyReset":"\u5BC6\u94A5\u5DF2\u91CD\u7F6E","settings.msg.resetFailed":"\u91CD\u7F6E\u5931\u8D25","settings.msg.changeFailed":"\u4FEE\u6539\u5931\u8D25","settings.msg.inviteCreated":"\u9080\u8BF7\u7801\u5DF2\u521B\u5EFA","settings.msg.createFailed":"\u521B\u5EFA\u5931\u8D25","settings.msg.inviteCopied":"\u9080\u8BF7\u7801\u5DF2\u590D\u5236","settings.msg.inviteDeleted":"\u9080\u8BF7\u7801\u5DF2\u5220\u9664","settings.msg.deleteFailed":"\u5220\u9664\u5931\u8D25","settings.tabs.llm":"LLM","settings.tabs.yeaft":"Yeaft","settings.yeaft.tabs.vp":"VP \u5E93","settings.yeaft.tabs.search":"\u641C\u7D22","settings.yeaft.tabs.mcp":"MCP","settings.mcp.title":"MCP \u670D\u52A1\u5668","settings.mcp.description":"\u901A\u8FC7 Model Context Protocol \u7ED9 Yeaft \u63A5\u5165\u66F4\u591A\u5DE5\u5177\u3002\u914D\u7F6E\u5199\u5165 agent \u4E0A\u7684 ~/.yeaft/config.json\uFF0C\u5DE5\u5177\u4F1A\u4EE5 mcp__<server>__<tool> \u7684\u5F62\u5F0F\u51FA\u73B0\u5728 LLM \u5DE5\u5177\u5217\u8868\u91CC\u3002","settings.mcp.reloadAll":"\u5168\u90E8\u91CD\u8FDE","settings.mcp.reloadOne":"\u91CD\u65B0\u8FDE\u63A5\u6B64\u670D\u52A1\u5668","settings.mcp.loading":"\u5904\u7406\u4E2D\u2026","settings.mcp.connected":"\u5DF2\u8FDE\u63A5","settings.mcp.disconnected":"\u672A\u8FDE\u63A5","settings.mcp.tools":"\u4E2A\u5DE5\u5177","settings.mcp.remove":"\u79FB\u9664","settings.mcp.empty":"\u8FD8\u6CA1\u6709\u914D\u7F6E MCP \u670D\u52A1\u5668\uFF0C\u53EF\u4EE5\u5728\u4E0B\u65B9\u6DFB\u52A0\u4E00\u4E2A\u3002","settings.mcp.addServer":"\u6DFB\u52A0\u670D\u52A1\u5668","settings.mcp.addServerDesc":"\u5927\u90E8\u5206 MCP \u670D\u52A1\u5668\u662F\u672C\u5730\u547D\u4EE4 \u2014 Yeaft \u4F1A\u901A\u8FC7 stdio \u542F\u52A8\u5B83\u5E76\u81EA\u52A8\u53D1\u73B0\u53EF\u7528\u5DE5\u5177\u3002","settings.mcp.serverName":"\u540D\u79F0","settings.mcp.command":"\u547D\u4EE4","settings.mcp.args":"\u53C2\u6570","settings.mcp.argsPlaceholder":"\u4F8B\u5982\uFF1A-y @modelcontextprotocol/server-filesystem /tmp","settings.mcp.env":"\u73AF\u5883\u53D8\u91CF","settings.mcp.envPlaceholder":"\u6BCF\u884C\u4E00\u4E2A KEY=value\uFF0C# \u5F00\u5934\u7684\u884C\u4F1A\u88AB\u5FFD\u7565\u3002","settings.mcp.saving":"\u4FDD\u5B58\u4E2D\u2026","settings.mcp.add":"\u6DFB\u52A0","settings.mcp.cancel":"\u6E05\u7A7A","settings.mcp.connectFailed":"\u5DF2\u4FDD\u5B58\u4F46\u8FDE\u63A5\u5931\u8D25","settings.mcp.addSuccess":"\u670D\u52A1\u5668\u5DF2\u6DFB\u52A0","settings.mcp.removeSuccess":"\u670D\u52A1\u5668\u5DF2\u79FB\u9664","settings.mcp.reloadSuccess":"\u5DF2\u8BF7\u6C42\u91CD\u8FDE","settings.mcp.confirmRemove":'\u79FB\u9664 MCP \u670D\u52A1\u5668 "{name}"\uFF1F\u4E0B\u4E00\u4E2A LLM turn \u8D77\u5B83\u7684\u5DE5\u5177\u5C06\u4E0D\u518D\u53EF\u89C1\u3002',"settings.mcp.errors.nameRequired":"\u8BF7\u586B\u5199\u540D\u79F0","settings.mcp.errors.nameFormat":"\u540D\u79F0\u53EA\u80FD\u5305\u542B\u5C0F\u5199\u5B57\u6BCD\u3001\u6570\u5B57\u3001\u77ED\u6A2A\u7EBF\u548C\u4E0B\u5212\u7EBF","settings.mcp.errors.commandRequired":"\u8BF7\u586B\u5199\u547D\u4EE4","settings.mcp.errors.argsParse":"\u53C2\u6570\u89E3\u6790\u5931\u8D25","settings.mcp.errors.envParse":"\u73AF\u5883\u53D8\u91CF\u89E3\u6790\u5931\u8D25","yeaft.session.title":"\u4F1A\u8BDD","yeaft.session.new":"+ \u65B0\u5EFA\u4F1A\u8BDD","yeaft.session.create.title":"\u65B0\u5EFA\u4F1A\u8BDD","yeaft.session.create.subtitle":"\u9009\u62E9\u8FD0\u884C\u4F4D\u7F6E\u548C\u5904\u7406\u4F1A\u8BDD\u7684 Provider\u3002","yeaft.session.create.close":"\u5173\u95ED","yeaft.session.create.nameLabel":"\u540D\u79F0","yeaft.session.create.namePlaceholder":"\u4F1A\u8BDD\u540D\u79F0\uFF08\u53EF\u9009\uFF09","yeaft.session.create.workDirLabel":"\u5DE5\u4F5C\u76EE\u5F55","yeaft.session.create.agentLabel":"Agent","yeaft.session.create.vpPicker":"\u9009\u62E9 VP","yeaft.session.create.vpNone":"\u672A\u9009\u62E9 VP","yeaft.session.create.vpCount":"\u5DF2\u9009 {n} \u4E2A VP","yeaft.session.create.untitled":"\u672A\u547D\u540D\u4F1A\u8BDD","yeaft.session.create.rosterEmpty":"\u6682\u65E0\u53EF\u7528 VP \u2014 \u8BF7\u5148\u5230\u89D2\u8272\u5E93\u521B\u5EFA\u3002","yeaft.session.create.rosterLoading":"VP \u52A0\u8F7D\u4E2D\u2026","yeaft.session.create.rosterError":"\u65E0\u6CD5\u4ECE\u5F53\u524D Agent \u52A0\u8F7D VP\u3002","yeaft.session.create.rosterRetry":"\u91CD\u8BD5","yeaft.vp.domain.general":"\u901A\u7528\u4E0E\u534F\u4F5C","yeaft.vp.domain.productDesign":"\u4EA7\u54C1\u4E0E\u4F53\u9A8C\u8BBE\u8BA1","yeaft.vp.domain.softwareSystems":"\u8F6F\u4EF6\u4E0E\u7CFB\u7EDF","yeaft.vp.domain.securityReliability":"\u5B89\u5168\u4E0E\u53EF\u9760\u6027","yeaft.vp.domain.scienceAnalysis":"\u79D1\u5B66\u4E0E\u5206\u6790","yeaft.vp.domain.philosophyPsychology":"\u54F2\u5B66\u4E0E\u5FC3\u7406","yeaft.vp.domain.strategyHistory":"\u6218\u7565\u4E0E\u5386\u53F2","yeaft.vp.domain.businessManagement":"\u5546\u4E1A\u4E0E\u7BA1\u7406","yeaft.vp.domain.artsCulture":"\u827A\u672F\u4E0E\u6587\u5316","yeaft.vp.domain.other":"\u5176\u4ED6\u9886\u57DF","yeaft.vp.domain.custom":"\u81EA\u5B9A\u4E49 VP","yeaft.session.create.defaultVpHint":"\u5F53\u6CA1\u6709 @ \u63D0\u53CA\u65F6\u9ED8\u8BA4\u56DE\u7B54\u7684 VP\u3002","yeaft.session.create.folderLabel":"\u{1F4C1} \u5DE5\u4F5C\u76EE\u5F55","yeaft.session.create.sessionLabel":"\u{1F4AC} \u6B64\u76EE\u5F55\u4E0B\u7684 session","yeaft.session.create.noWorkDirs":"\u8FD8\u6CA1\u6709\u4EFB\u4F55\u4F1A\u8BDD \u2014 \u5728\u4E0A\u65B9\u9009\u62E9\u6216\u8F93\u5165\u5DE5\u4F5C\u76EE\u5F55\u5F00\u59CB\u3002","yeaft.session.create.back":"\u8FD4\u56DE","yeaft.session.create.creating":"\u521B\u5EFA\u4E2D\u2026","yeaft.session.create.submit":"\u521B\u5EFA","yeaft.plugins.title":"\u63D2\u4EF6","yeaft.plugins.subtitle":"\u9009\u62E9\u6B64 Agent \u5411\u4F1A\u8BDD\u63D0\u4F9B\u54EA\u4E9B\u5DE5\u5177\u3001\u6280\u80FD\u548C MCP \u670D\u52A1\u5668\u3002","yeaft.plugins.agentLabel":"Agent","yeaft.plugins.overviewLabel":"\u63D2\u4EF6\u53EF\u7528\u6027\u6982\u89C8","yeaft.plugins.noAgent":"\u672A\u9009\u62E9 Agent","yeaft.plugins.allAvailable":"\u5DF2\u542F\u7528\u5168\u90E8\u53EF\u7528\u80FD\u529B\u3002","yeaft.plugins.selectedSummary":"\u5DF2\u542F\u7528 {count} \u9879\u80FD\u529B\u3002","yeaft.plugins.enabledLabel":"\u5DF2\u542F\u7528","yeaft.plugins.useAll":"\u4F7F\u7528\u5168\u90E8\u53EF\u7528\u9879","yeaft.plugins.loading":"\u6B63\u5728\u52A0\u8F7D\u63D2\u4EF6\u2026","yeaft.plugins.empty":"\u6B64 Agent \u6CA1\u6709\u53EF\u914D\u7F6E\u7684\u63D2\u4EF6\u3002","yeaft.plugins.loadError":"\u52A0\u8F7D\u63D2\u4EF6\u5931\u8D25\uFF1A{error}","yeaft.plugins.upgradeRequired":"\u6B64 Agent \u4E0D\u652F\u6301\u63D2\u4EF6\u3002\u8BF7\u5347\u7EA7\u5E76\u91CD\u542F\u8BE5 Agent\u3002","yeaft.plugins.retry":"\u91CD\u8BD5","yeaft.plugins.searchPlaceholder":"\u641C\u7D22\u5DE5\u5177\u3001\u6280\u80FD\u548C MCP \u670D\u52A1\u5668","yeaft.plugins.resultCount":"{count} \u4E2A\u7ED3\u679C","yeaft.plugins.categoryLabel":"\u63D2\u4EF6\u5206\u7C7B","yeaft.plugins.all":"\u5168\u90E8","yeaft.plugins.noMatchesTitle":"\u6CA1\u6709\u5339\u914D\u7684\u63D2\u4EF6","yeaft.plugins.noMatchesBody":"\u8BF7\u5C1D\u8BD5\u5176\u4ED6\u641C\u7D22\u8BCD\u6216\u5206\u7C7B\u3002","yeaft.plugins.toolDescription":"Agent \u5185\u7F6E\u80FD\u529B","yeaft.plugins.skillDescription":"\u53EF\u590D\u7528\u7684 Agent \u5DE5\u4F5C\u6D41","yeaft.plugins.mcpDescription":"\u53EF\u63D0\u4F9B {count} \u4E2A\u5DE5\u5177","yeaft.plugins.unsavedChanges":"\u6709\u672A\u4FDD\u5B58\u7684\u4FEE\u6539","yeaft.plugins.tools":"\u5DE5\u5177","yeaft.plugins.skills":"\u6280\u80FD","yeaft.plugins.mcpServers":"MCP \u670D\u52A1\u5668","yeaft.plugins.toolsCount":"\u4E2A\u5DE5\u5177","yeaft.plugins.manageSkills":"\u7BA1\u7406\u6280\u80FD","yeaft.plugins.manageSkillsDescription":"\u4E3A\u6B64 Agent \u6216\u5F53\u524D\u9879\u76EE\u521B\u5EFA\u53EF\u590D\u7528\u6280\u80FD\u3002\u9879\u76EE\u7EA7\u6280\u80FD\u4F1A\u8986\u76D6\u540C\u540D\u7528\u6237\u7EA7\u6280\u80FD\u3002","yeaft.plugins.createSkill":"\u521B\u5EFA\u6280\u80FD","yeaft.plugins.removeSkill":"\u79FB\u9664","yeaft.plugins.confirmRemoveSkill":"\u79FB\u9664\u6280\u80FD\u201C{name}\u201D\uFF1F\u8FD9\u53EA\u4F1A\u5220\u9664\u8BE5\u5C42\u7EA7\u4E2D\u7684\u539F\u751F\u6280\u80FD\u3002","yeaft.plugins.skillManagementUpgradeRequired":"\u6B64 Agent \u5FC5\u987B\u5347\u7EA7\u540E\u624D\u80FD\u521B\u5EFA\u6216\u79FB\u9664\u6280\u80FD\u3002","yeaft.plugins.skillManagementVersionUnknown":"\u6B64 Agent \u5C1A\u672A\u4E0A\u62A5\u6280\u80FD\u7BA1\u7406\u652F\u6301\u3002\u8BF7\u5347\u7EA7\u5E76\u91CD\u542F\u540E\u518D\u521B\u5EFA\u6216\u79FB\u9664\u6280\u80FD\u3002","yeaft.plugins.skillScope":"\u5C42\u7EA7","yeaft.plugins.userScope":"\u7528\u6237\u7EA7","yeaft.plugins.projectScope":"\u9879\u76EE\u7EA7","yeaft.plugins.userScopeDescription":"\u5BF9\u8BE5 Agent \u8FD0\u884C\u7684\u6240\u6709\u9879\u76EE\u53EF\u7528\u3002","yeaft.plugins.projectScopeDescription":"\u53EA\u5BF9\u5F53\u524D\u9879\u76EE\u53EF\u7528\uFF0C\u5E76\u8986\u76D6\u540C\u540D\u7528\u6237\u7EA7\u6280\u80FD\u3002","yeaft.plugins.projectScopeUnavailable":"\u8BF7\u9009\u62E9\u5E26\u9879\u76EE\u76EE\u5F55\u7684 Session\uFF0C\u624D\u80FD\u7BA1\u7406\u9879\u76EE\u7EA7\u6280\u80FD\u3002","yeaft.plugins.skillName":"\u540D\u79F0","yeaft.plugins.skillDescriptionLabel":"\u8BF4\u660E","yeaft.plugins.skillTrigger":"\u89E6\u53D1\u8BCD\uFF08\u53EF\u9009\uFF09","yeaft.plugins.skillInstructions":"\u6307\u4EE4","yeaft.plugins.resetSkillForm":"\u91CD\u7F6E","yeaft.plugins.skillTier.bundled":"\u5185\u7F6E \xB7 \u53EA\u8BFB","yeaft.plugins.skillTier.user":"\u7528\u6237\u7EA7","yeaft.plugins.skillTier.project":"\u9879\u76EE\u7EA7","yeaft.plugins.skillTier.project-claude":"Claude \u9879\u76EE \xB7 \u53EA\u8BFB","yeaft.plugins.skillTier.project-codex":"Codex \u9879\u76EE \xB7 \u53EA\u8BFB","yeaft.onboarding.ariaLabel":"Yeaft \u4E0A\u624B\u8BF4\u660E","yeaft.onboarding.topbarTitle":"\u5F00\u59CB\u4F7F\u7528 Yeaft","yeaft.onboarding.eyebrow":"Yeaft \u4E0A\u624B\u6307\u5357","yeaft.onboarding.title":"\u5148\u8FDE\u63A5 Agent\uFF0C\u518D\u5F00\u59CB\u4F1A\u8BDD","yeaft.onboarding.subtitle":"\u5728\u8D1F\u8D23\u6267\u884C\u5DE5\u5177\u7684\u673A\u5668\u4E0A\u76F4\u63A5\u8FD0\u884C\u4E0B\u9762\u7684\u547D\u4EE4\u3002agent secret \u5982\u679C\u4E0D\u5B58\u5728\uFF0C\u4F1A\u81EA\u52A8\u4E3A\u5F53\u524D\u8D26\u53F7\u751F\u6210\u3002","yeaft.onboarding.createSession":"\u521B\u5EFA\u6216\u6062\u590D Session","yeaft.onboarding.secretLoading":"\u6B63\u5728\u751F\u6210 agent secret\u2026","yeaft.onboarding.secretError":"\u52A0\u8F7D agent secret \u5931\u8D25\u3002","yeaft.onboarding.secretPending":"<\u6B63\u5728\u52A0\u8F7D-agent-secret>","yeaft.onboarding.installTitle":"\u5B89\u88C5\u5E76\u8FDE\u63A5 Agent","yeaft.onboarding.installDesc":"\u5728\u76EE\u6807\u673A\u5668\u8FD0\u884C\u4E00\u6761\u547D\u4EE4\uFF0C\u5B89\u88C5\u6240\u9700\u73AF\u5883\u3001\u521B\u5EFA\u79C1\u6709\u5B9E\u4F8B\u5E76\u8FDE\u63A5\u5F53\u524D server\u3002","yeaft.onboarding.connectTitle":"\u8FDE\u63A5\u8FD9\u4E2A Agent","yeaft.onboarding.connectDesc":"\u5B89\u88C5\u5668\u4F1A\u4F7F\u7528\u5F53\u524D server URL \u548C\u81EA\u52A8\u751F\u6210\u7684 secret\u3002","yeaft.restore.modal.empty":"\u6B64\u76EE\u5F55\u4E0B\u6CA1\u6709 yeaft session","yeaft.restore.modal.scanError":"\u626B\u63CF\u5931\u8D25: {message}","yeaft.restore.modal.restoreError":"\u6062\u590D\u5931\u8D25: {message}","settings.llm.noAgent":"\u8BF7\u5148\u9009\u62E9\u4E00\u4E2A Agent \u4EE5\u7BA1\u7406 LLM \u914D\u7F6E\u3002","settings.llm.agentOffline":"Agent \u5F53\u524D\u79BB\u7EBF\uFF0C\u65E0\u6CD5\u52A0\u8F7D LLM \u914D\u7F6E\u3002\u8BF7\u7B49\u5F85 Agent \u4E0A\u7EBF\u540E\u91CD\u8BD5\u3002","settings.llm.loading":"\u6B63\u5728\u52A0\u8F7D\u914D\u7F6E...","settings.llm.loadError":"\u52A0\u8F7D\u914D\u7F6E\u5931\u8D25","settings.llm.configureAgent":"\u914D\u7F6E\u5F53\u524D Agent \u7684 LLM","settings.llm.configureMenu":"\u8BBE\u7F6E LLM","settings.llm.simpleCopilotTitle":"\u63A8\u8350\uFF1AGitHub Copilot","settings.llm.useGitHubCopilot":"\u4F7F\u7528 GitHub Copilot","settings.llm.refreshingModels":"\u6B63\u5728\u5237\u65B0\u6A21\u578B...","settings.llm.managedCopilotTitle":"\u6258\u7BA1\u7684 GitHub Copilot","settings.llm.managedCopilotDesc":"Base URL\u3001\u8BA4\u8BC1\u3001\u6A21\u578B\u76EE\u5F55\u548C\u6BCF\u4E2A\u6A21\u578B\u7684 API \u534F\u8BAE\u90FD\u81EA\u52A8\u7BA1\u7406\u3002Claude \u6A21\u578B\u8D70 Anthropic Messages\uFF1BGPT/o \u6A21\u578B\u8D70 OpenAI Responses\u3002","settings.llm.providersTitle":"\u670D\u52A1\u5546","settings.llm.testFailed":"\u8FDE\u63A5\u6D4B\u8BD5\u5931\u8D25","settings.llm.saveSuccess":"LLM \u8BBE\u7F6E\u5DF2\u4FDD\u5B58","settings.llm.saveFailed":"\u4FDD\u5B58 LLM \u8BBE\u7F6E\u5931\u8D25","settings.llm.presets.title":"\u5FEB\u901F\u914D\u7F6E","settings.llm.providersDesc":"\u9009\u62E9\u4E00\u4E2A\u670D\u52A1\u5546\uFF0C\u4FDD\u5B58\u540E\u5373\u53EF\u5728 Session \u4E2D\u4F7F\u7528\u3002","settings.llm.agentProviders":"\u5F53\u524D agent providers","settings.llm.agentBadge":"\u5F53\u524D agent","settings.llm.addProvider":"\u6DFB\u52A0\u670D\u52A1\u5546","settings.llm.addFromPreset":"\u4ECE\u76EE\u5F55\u6DFB\u52A0","settings.llm.preset.title":"\u670D\u52A1\u5546\u76EE\u5F55\uFF08models.dev\uFF09","settings.llm.preset.refresh":"\u5237\u65B0\u76EE\u5F55","settings.llm.preset.loading":"\u52A0\u8F7D\u76EE\u5F55\u2026","settings.llm.preset.empty":"\u76EE\u5F55\u4E3A\u7A7A\u3002","settings.llm.preset.pickProvider":"\u5728\u5DE6\u4FA7\u9009\u62E9\u4E00\u4E2A\u670D\u52A1\u5546\u4EE5\u67E5\u770B\u6A21\u578B\u3002","settings.llm.preset.filterProviders":"\u8FC7\u6EE4\u670D\u52A1\u5546\u2026","settings.llm.preset.filterModels":"\u8FC7\u6EE4\u6A21\u578B\u2026","settings.llm.preset.selectAll":"\u5168\u9009","settings.llm.preset.selectNone":"\u6E05\u7A7A","settings.llm.preset.cancel":"\u53D6\u6D88","settings.llm.preset.add":"\u6DFB\u52A0\u5230\u670D\u52A1\u5546\u5217\u8868","settings.llm.preset.fetchedAt":"\u76EE\u5F55\u5DF2\u66F4\u65B0 {minutes} \u5206\u949F","settings.llm.addModel":"\u6DFB\u52A0\u6A21\u578B","settings.llm.removeModel":"\u79FB\u9664\u6A21\u578B","settings.llm.providerName":"\u540D\u79F0","settings.llm.providerNamePlaceholder":"\u4F8B\u5982 my-proxy","settings.llm.baseUrl":"Base URL","settings.llm.baseUrlPlaceholder":"\u4F8B\u5982 http://localhost:6628/v1","settings.llm.apiKey":"API Key","settings.llm.apiKeyPlaceholder":"\u8F93\u5165 API Key","settings.llm.protocol":"\u534F\u8BAE","settings.llm.protocolOpenAI":"OpenAI \u517C\u5BB9","settings.llm.protocolOpenAIResponses":"OpenAI Responses (GPT-5)","settings.llm.protocolAnthropic":"Anthropic \u539F\u751F","settings.llm.protocolHint.anthropic":"Claude \u539F\u751F Messages API\u3002","settings.llm.protocolHint.openai":"Chat Completions /v1/chat/completions \u2014 GPT-4 \u53CA\u5927\u591A\u6570\u517C\u5BB9\u4EE3\u7406\u3002","settings.llm.protocolHint.openaiResponses":"Responses API /v1/responses \u2014 GPT-5 \u7CFB\u5217\u5FC5\u987B\u3002","settings.llm.modelCtxPlaceholder":"\u4E0A\u4E0B\u6587","settings.llm.modelMaxPlaceholder":"\u8F93\u51FA","settings.llm.models":"\u5019\u9009\u6A21\u578B ID","settings.llm.modelsPlaceholder":"\u6A21\u578B ID\uFF0C\u9017\u53F7\u6216\u6362\u884C\u5206\u9694\uFF0C\u4F8B\u5982 claude-sonnet-4-20250514, gpt-5","settings.llm.modelsHint":"\u9017\u53F7\u6216\u6362\u884C\u5206\u9694\u3002","settings.llm.removeProvider":"\u79FB\u9664","settings.llm.modelSelectionTitle":"\u6A21\u578B\u9009\u62E9","settings.llm.modelSelectionDesc":"\u9009\u62E9\u9ED8\u8BA4\u6A21\u578B\u3002","settings.llm.primaryModel":"\u4E3B\u6A21\u578B","settings.llm.primaryModelDesc":"\u7528\u4E8E\u7528\u6237\u5BF9\u8BDD","settings.llm.fastModel":"\u5FEB\u901F\u6A21\u578B","settings.llm.fastModelDesc":"\u7528\u4E8E\u5185\u90E8\u4EFB\u52A1\uFF08\u8BB0\u5FC6\u3001\u603B\u7ED3\uFF09","settings.llm.noModels":"\u6682\u65E0\u53EF\u7528\u6A21\u578B\u3002\u8BF7\u5148\u6DFB\u52A0\u670D\u52A1\u5546\u3002","settings.llm.selectModel":"\u9009\u62E9\u6A21\u578B...","settings.llm.debugTitle":"\u8C03\u8BD5\u8F68\u8FF9","settings.llm.debugDesc":"\u6309 Agent \u5F00\u542F\u9010\u8F6E\u8C03\u8BD5\u8F68\u8FF9\u6536\u96C6\uFF08\u7CFB\u7EDF\u63D0\u793A\u8BCD\u3001LLM \u8C03\u7528\u3001\u5DE5\u5177\u8F7D\u8377\uFF09\u3002","settings.llm.enableDebug":"\u542F\u7528\u8C03\u8BD5\u8F68\u8FF9","settings.llm.save":"\u4FDD\u5B58\u66F4\u6539","settings.llm.saving":"\u4FDD\u5B58\u4E2D...","settings.llm.saved":"\u914D\u7F6E\u5DF2\u4FDD\u5B58","settings.llm.savedRefreshWarning":"\u914D\u7F6E\u5DF2\u4FDD\u5B58\uFF0C\u4F46\u5B9E\u65F6\u6A21\u578B\u76EE\u5F55\u5237\u65B0\u5931\u8D25\uFF1A{error}","settings.llm.unsavedChanges":"\u6709\u672A\u4FDD\u5B58\u7684\u66F4\u6539","settings.llm.confirmRemoveProvider":"\u786E\u5B9A\u79FB\u9664\u6B64\u670D\u52A1\u5546\uFF1F","settings.llm.setupTitle":"\u8FDE\u63A5\u6A21\u578B","settings.llm.setupDesc":"\u63A8\u8350\u4F7F\u7528 GitHub Copilot\uFF1B\u4E5F\u53EF\u4EE5\u6DFB\u52A0\u81EA\u5DF1\u7684 API \u670D\u52A1\u5546\u3002","settings.llm.providerSectionHint":"\u53EA\u4FDD\u7559\u8FDE\u63A5\u6A21\u578B\u5FC5\u9700\u7684\u4FE1\u606F\u3002","settings.tabs.dashboard":"\u4EEA\u8868\u677F","settings.dashboard.totalUsers":"\u603B\u7528\u6237\u6570","settings.dashboard.onlineUsers":"\u5728\u7EBF\u7528\u6237","settings.dashboard.activeUsers":"\u6D3B\u8DC3\u7528\u6237","settings.dashboard.onlineAgents":"\u5728\u7EBFAgent","settings.dashboard.totalSessions":"\u603B\u4F1A\u8BDD\u6570","settings.dashboard.todayActive":"\u4ECA\u65E5\u6D3B\u8DC3","settings.dashboard.todayMessages":"\u4ECA\u65E5\u6D88\u606F","settings.dashboard.todayUserTurns":"\u4ECA\u65E5\u7528\u6237 Turn","settings.dashboard.totalTokens":"\u603B Token","settings.dashboard.tokenAccuracy":"\u6765\u81EA\u6A21\u578B\u670D\u52A1\u5546\u8FD4\u56DE\u7684\u5B9E\u9645\u7528\u91CF\uFF1B\u4ECE\u542F\u7528\u6309\u7528\u6237 Token \u7EDF\u8BA1\u7684\u7248\u672C\u5F00\u59CB\u7D2F\u8BA1\uFF0C\u4E14\u4E0D\u5305\u542B\u5FC3\u8DF3\u3002","settings.dashboard.agentTurns":"Agent Turn","settings.dashboard.agentSessions":"Agent Session","settings.dashboard.turns":"Turn","settings.dashboard.tokens":"Token","settings.dashboard.inputTokens":"\u8F93\u5165","settings.dashboard.outputTokens":"\u8F93\u51FA","settings.dashboard.cacheTokens":"\u7F13\u5B58","settings.dashboard.today":"\u4ECA\u5929","settings.dashboard.thisWeek":"\u672C\u5468","settings.dashboard.thisMonth":"\u672C\u6708","settings.dashboard.all":"\u5168\u90E8","settings.dashboard.general":"\u5E38\u89C4","settings.dashboard.detailed":"\u8BE6\u7EC6\u4FE1\u606F","settings.dashboard.users":"\u7528\u6237","settings.dashboard.agents":"Agent","settings.dashboard.time":"\u65F6\u95F4","settings.dashboard.active":"\u6D3B\u8DC3","settings.dashboard.inactive":"\u672A\u6D3B\u8DC3","settings.dashboard.activeOnly":"\u4EC5\u6D3B\u8DC3","settings.dashboard.inactiveOnly":"\u4EC5\u672A\u6D3B\u8DC3","settings.dashboard.userUsage":"\u7528\u6237\u7528\u91CF","settings.dashboard.refresh":"\u5237\u65B0","settings.dashboard.name":"\u540D\u79F0","settings.dashboard.messages":"\u6D88\u606F\u6570","settings.dashboard.userTurns":"\u7528\u6237 Turn \u6570","settings.dashboard.sessions":"\u4F1A\u8BDD\u6570","settings.dashboard.requests":"\u8BF7\u6C42\u6570","settings.dashboard.traffic":"\u6D41\u91CF","settings.dashboard.lastTurnCompleted":"\u6700\u540E Turn \u7ED3\u675F\u65F6\u95F4","settings.dashboard.status":"\u72B6\u6001","settings.dashboard.latency":"\u5EF6\u8FDF","settings.dashboard.version":"\u7248\u672C","settings.dashboard.owner":"\u6240\u6709\u8005","settings.dashboard.role":"\u89D2\u8272","settings.dashboard.agent":"Agent","settings.dashboard.online":"\u5728\u7EBF","settings.dashboard.offline":"\u79BB\u7EBF","settings.dashboard.noAgents":"\u6682\u65E0\u6CE8\u518C Agent","settings.dashboard.noUserData":"\u6682\u65E0\u7528\u6237\u6570\u636E","settings.dashboard.noOnlineUsers":"\u6682\u65E0\u5728\u7EBF\u7528\u6237","settings.dashboard.loading":"\u52A0\u8F7D\u4E2D...","settings.dashboard.error":"\u6570\u636E\u52A0\u8F7D\u5931\u8D25","settings.dashboard.ago":"{time}\u524D","settings.dashboard.loadMore":"\u52A0\u8F7D\u66F4\u591A\uFF08\u5269\u4F59 {remaining} \u6761\uFF09","workbench.title":"Workbench","workbench.openItems":"\u5DF2\u6253\u5F00\u7684 Workbench \u9879\u76EE","workbench.addItem":"\u6DFB\u52A0 Workbench \u9879\u76EE","workbench.addItemHint":"\u4F7F\u7528 + \u6253\u5F00\u6587\u4EF6\u3001\u7EC8\u7AEF\u3001Git \u6216\u6D4F\u89C8\u5668\u3002","workbench.closeItem":"\u5173\u95ED {name}","workbench.chooseCapability":"\u9009\u62E9\u80FD\u529B","workbench.chooseCapabilityHint":"\u9009\u62E9\u4E00\u4E2A\u5DE5\u5177\u5F00\u59CB\u4F7F\u7528\uFF1B\u5DF2\u6253\u5F00\u7684\u5DE5\u5177\u4F1A\u4FDD\u7559\u5728\u6807\u7B7E\u9875\u4E2D\u3002","workbench.terminal":"\u7EC8\u7AEF","workbench.terminalDescription":"\u5728\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55\u8FD0\u884C\u547D\u4EE4\u5E76\u7BA1\u7406\u7EC8\u7AEF\u5206\u5C4F\u3002","workbench.git":"Git","workbench.gitDescription":"\u67E5\u770B\u4ED3\u5E93\u72B6\u6001\u3001\u4EE3\u7801\u5DEE\u5F02\u548C\u53D8\u66F4\u6587\u4EF6\u3002","workbench.files":"\u6587\u4EF6","workbench.filesDescription":"\u6D4F\u89C8\u3001\u9884\u89C8\u548C\u7F16\u8F91\u6240\u9009 Agent \u4E0A\u7684\u6587\u4EF6\u3002","workbench.browser":"\u6D4F\u89C8\u5668","workbench.browserDescription":"\u901A\u8FC7\u5B9E\u65F6 WebRTC \u753B\u9762\u67E5\u770B Agent \u672C\u5730\u6D4F\u89C8\u5668\u3002","workbench.available":"\u53EF\u7528","workbench.enableRequired":"\u9700\u8981\u542F\u7528","workbench.unavailable":"\u5F53\u524D Agent \u4E0D\u53EF\u7528","workbench.capabilityUnavailable":"\u6240\u9009 Agent \u672A\u63D0\u4F9B\u6B64\u80FD\u529B\u3002","workbench.browserUnavailable":"\u6D4F\u89C8\u5668\u5DF2\u88AB\u7BA1\u7406\u5458\u5173\u95ED\uFF0C\u6216\u5F53\u524D Agent \u4E0D\u652F\u6301\u3002\u8BF7\u5347\u7EA7 Agent\uFF0C\u6216\u8BA9\u7BA1\u7406\u5458\u5F00\u542F\u6D4F\u89C8\u5668\u8DEF\u7531\u3002","workbench.browserReadyHint":"\u8F93\u5165\u5730\u5740\u4EE5\u542F\u52A8\u9694\u79BB\u7684 Agent \u672C\u5730\u6D4F\u89C8\u5668\u3002\u70B9\u51FB\u5B9E\u65F6\u753B\u9762\u540E\u53EF\u4F7F\u7528\u9F20\u6807\u548C\u952E\u76D8\u4EA4\u4E92\u3002","workbench.browserStart":"\u542F\u52A8\u6D4F\u89C8\u5668","workbench.browserAddressLabel":"\u6D4F\u89C8\u5668\u5730\u5740","workbench.browserAddressPlaceholder":"example.com","workbench.browserAddressInvalid":"\u8BF7\u8F93\u5165\u6709\u6548\u7684 HTTP \u6216 HTTPS \u5730\u5740\u3002","workbench.browserInteractionUnavailable":"\u6D4F\u89C8\u5668\u8F93\u5165\u94FE\u8DEF\u5C1A\u672A\u8FDE\u63A5\uFF0C\u8BF7\u7B49\u5F85 WebRTC \u8FDE\u63A5\u540E\u91CD\u8BD5\u3002","workbench.browserGo":"\u524D\u5F80","workbench.browserStarting":"\u6B63\u5728\u542F\u52A8 Agent \u672C\u5730\u6D4F\u89C8\u5668\u2026","workbench.browserConnecting":"\u6B63\u5728\u8FDE\u63A5\u5B9E\u65F6 WebRTC \u753B\u9762\u2026","workbench.browserIceServersMissing":"\u6D4F\u89C8\u5668\u753B\u9762\u65E0\u6CD5\u8FDE\u63A5\u5F53\u524D Agent\uFF0C\u4E14 Server \u672A\u914D\u7F6E STUN \u6216 TURN \u670D\u52A1\u3002\u8BF7\u8BA9\u7BA1\u7406\u5458\u914D\u7F6E Browser ICE/TURN \u540E\u91CD\u8BD5\u3002","workbench.browserIceConnectionFailed":"\u6D4F\u89C8\u5668 WebRTC \u8FDE\u63A5\u5931\u8D25\u3002\u8BF7\u68C0\u67E5\u5DF2\u914D\u7F6E\u7684 TURN \u670D\u52A1\u662F\u5426\u80FD\u88AB Web \u6D4F\u89C8\u5668\u548C Agent \u540C\u65F6\u8BBF\u95EE\uFF0C\u7136\u540E\u91CD\u8BD5\u3002","workbench.browserPeerAttachTimeout":"\u8FDE\u63A5\u6D4F\u89C8\u5668 WebRTC \u753B\u9762\u8D85\u65F6\u3002\u8BF7\u68C0\u67E5 Browser ICE/TURN \u8FDE\u901A\u6027\uFF0C\u7136\u540E\u91CD\u8BD5\u3002","workbench.browserEnd":"\u7ED3\u675F\u6D4F\u89C8\u5668","workbench.browserVideoLabel":"Agent \u6D4F\u89C8\u5668\u5B9E\u65F6\u753B\u9762","workbench.browserInputLabel":"\u6D4F\u89C8\u5668\u952E\u76D8\u8F93\u5165","workbench.browserStatusConnecting":"\u8FDE\u63A5\u4E2D","workbench.browserProtocolUnavailable":"\u5F53\u524D Server \u8FDE\u63A5\u4E0D\u652F\u6301 Browser Runtime \u534F\u8BAE\u3002","workbench.browserChecking":"\u6B63\u5728\u68C0\u67E5\u6240\u9009 Agent \u7684 Browser Runtime\u2026","workbench.browserPlatformUnsupported":"\u6240\u9009 Agent \u65E0\u6CD5\u8FD0\u884C\u5F53\u524D Browser Runtime \u6570\u636E\u94FE\u8DEF\u3002","workbench.browserSetupTitle":"\u542F\u7528\u6D4F\u89C8\u5668","workbench.browserOptionalInstall":"\u6D4F\u89C8\u5668\u9700\u8981\u5728\u5F53\u524D Agent \u5B89\u88C5\u56FA\u5B9A\u7248\u672C Chrome for Testing\u3002\u542F\u7528\u540E\u5C06\u4E0B\u8F7D\u7EA6 {size}\uFF0C\u6821\u9A8C\u5E76\u5B89\u88C5\u7248\u672C {build}\uFF0C\u7136\u540E\u68C0\u67E5\u5A92\u4F53\u94FE\u8DEF\u3002","workbench.browserInstallDiskNote":"\u70B9\u51FB\u201C\u542F\u7528\u6D4F\u89C8\u5668\u201D\u524D\u4E0D\u4F1A\u4E0B\u8F7D\u4EFB\u4F55\u5185\u5BB9\uFF1B\u6D4F\u89C8\u5668\u6587\u4EF6\u53EA\u5B58\u653E\u5728\u5F53\u524D Agent instance \u7684\u6570\u636E\u76EE\u5F55\u3002","workbench.browserInstallAction":"\u542F\u7528\u6D4F\u89C8\u5668\uFF08{size}\uFF09","workbench.browserInstalling":"\u6B63\u5728\u542F\u7528\u6D4F\u89C8\u5668\uFF1A\u4E0B\u8F7D\u5E76\u6821\u9A8C Chrome for Testing {build}\u2026","workbench.browserInstallKeepOpen":"\u53EF\u4EE5\u79BB\u5F00\u6B64\u9762\u677F\u3002\u518D\u6B21\u6253\u5F00\u6D4F\u89C8\u5668\u4F1A\u6062\u590D\u663E\u793A\u5F53\u524D\u5B89\u88C5\u72B6\u6001\uFF0C\u4E0D\u4F1A\u91CD\u590D\u4E0B\u8F7D\u3002","workbench.browserInstallProgressLabel":"\u6D4F\u89C8\u5668\u4E0B\u8F7D\u8FDB\u5EA6","workbench.browserInstallProgress":"\u5DF2\u4E0B\u8F7D {downloaded} / {total}","workbench.browserInstalledEnable":"\u6D4F\u89C8\u5668\u6587\u4EF6\u5DF2\u7ECF\u5B89\u88C5\u3002\u542F\u7528\u6D4F\u89C8\u5668\u5E76\u68C0\u67E5\u5A92\u4F53\u94FE\u8DEF\u5373\u53EF\u4F7F\u7528\u3002","workbench.browserEnableAction":"\u542F\u7528\u6D4F\u89C8\u5668","workbench.browserEnabling":"\u6B63\u5728\u5B8C\u6210\u8BBE\u7F6E\u5E76\u68C0\u67E5\u5A92\u4F53\u94FE\u8DEF\u2026","workbench.browserStatusInstalling":"\u5B89\u88C5\u4E2D","workbench.browserStatusProbing":"\u63A2\u6D4B\u4E2D","workbench.backToCapabilities":"\u8FD4\u56DE\u80FD\u529B\u5217\u8868","workbench.closeCapability":"\u5173\u95ED\u5F53\u524D\u80FD\u529B","workbench.maximize":"\u6700\u5927\u5316\u9762\u677F","workbench.restore":"\u8FD8\u539F\u9762\u677F","workbench.collapse":"\u6536\u8D77\u9762\u677F","theme.switchToLight":"\u5207\u6362\u5230\u6D45\u8272\u4E3B\u9898","theme.switchToDark":"\u5207\u6362\u5230\u6DF1\u8272\u4E3B\u9898","theme.toLight":"\u5207\u6362\u5230\u6D45\u8272\u4E3B\u9898","theme.toDark":"\u5207\u6362\u5230\u6DF1\u8272\u4E3B\u9898","terminal.splitH":"\u6C34\u5E73\u5206\u5C4F\uFF08\u5DE6\u53F3\uFF09","terminal.splitV":"\u5782\u76F4\u5206\u5C4F\uFF08\u4E0A\u4E0B\uFF09","terminal.close":"\u5173\u95ED\u5F53\u524D\u7EC8\u7AEF","terminal.autoCreate":"\u6253\u5F00\u7EC8\u7AEF\u80FD\u529B\u65F6\u5C06\u81EA\u52A8\u521B\u5EFA\u7EC8\u7AEF","terminal.xtermError":"xterm.js \u672A\u52A0\u8F7D\uFF0C\u8BF7\u5237\u65B0\u9875\u9762","terminal.xtermNotLoaded":"xterm.js \u672A\u52A0\u8F7D\uFF0C\u8BF7\u5237\u65B0\u9875\u9762","terminal.mountError":"\u7EC8\u7AEF\u5BB9\u5668\u6302\u8F7D\u5931\u8D25","terminal.mountFailed":"\u7EC8\u7AEF\u5BB9\u5668\u6302\u8F7D\u5931\u8D25","terminal.createError":"\u7EC8\u7AEF\u521B\u5EFA\u5931\u8D25","terminal.createFailed":"\u7EC8\u7AEF\u521B\u5EFA\u5931\u8D25","terminal.error":"\u7EC8\u7AEF\u9519\u8BEF","git.selectFolder":"\u9009\u62E9\u6587\u4EF6\u5939","git.repoPath":"\u8F93\u5165 Git \u4ED3\u5E93\u8DEF\u5F84...","git.repoPathPlaceholder":"\u8F93\u5165 Git \u4ED3\u5E93\u8DEF\u5F84...","git.workDir":"Git \u5DE5\u4F5C\u76EE\u5F55","git.loadStatus":"\u52A0\u8F7D Git \u72B6\u6001","git.loading":"\u52A0\u8F7D Git \u72B6\u6001...","git.loadingStatus":"\u52A0\u8F7D Git \u72B6\u6001...","git.clean":"\u5DE5\u4F5C\u533A\u5E72\u51C0\uFF0C\u65E0\u53D8\u66F4","git.cleanWorkDir":"\u5DE5\u4F5C\u533A\u5E72\u51C0\uFF0C\u65E0\u53D8\u66F4","git.selectAgent":"\u9009\u62E9 Agent \u540E\u52A0\u8F7D Git \u72B6\u6001","git.selectAgentFirst":"\u9009\u62E9 Agent \u540E\u52A0\u8F7D Git \u72B6\u6001","git.diffOnly":"\u53EA\u770B\u5DEE\u5F02","git.fullFile":"\u770B\u5168\u6587","git.zoomIn":"\u653E\u5927\u5B57\u4F53","git.zoomOut":"\u7F29\u5C0F\u5B57\u4F53","git.loadingDiff":"\u52A0\u8F7D Diff...","git.clickToView":"\u70B9\u51FB\u6587\u4EF6\u67E5\u770B\u5DEE\u5F02","git.clickFileToView":"\u70B9\u51FB\u6587\u4EF6\u67E5\u770B\u5DEE\u5F02","git.selectRepo":"\u9009\u62E9 Git \u4ED3\u5E93","git.noDiff":"(\u65E0\u5DEE\u5F02)","git.binaryFile":"(\u4E8C\u8FDB\u5236\u6587\u4EF6)","files.notLoaded":"\u672A\u52A0\u8F7D","files.newFile":"\u65B0\u5EFA\u6587\u4EF6","files.newFolder":"\u65B0\u5EFA\u6587\u4EF6\u5939","files.openFolder":"\u6253\u5F00\u6587\u4EF6\u5939","files.showTree":"\u663E\u793A\u6587\u4EF6\u5939","files.hideTree":"\u9690\u85CF\u6587\u4EF6\u5939","files.deleteSelected":"\u5220\u9664\u9009\u4E2D","files.moveSelected":"\u79FB\u52A8\u9009\u4E2D","files.enterPath":"\u8F93\u5165\u8DEF\u5F84...","files.searchFiles":"\u641C\u7D22\u6587\u4EF6... (Ctrl+P)","files.noMatch":"\u65E0\u5339\u914D\u7ED3\u679C","files.searching":"\u641C\u7D22\u4E2D...","files.loadingTree":"\u52A0\u8F7D\u4E2D...","files.emptyDir":"\u7A7A\u76EE\u5F55","files.loadingFile":"\u52A0\u8F7D\u6587\u4EF6...","files.readSendFailed":"\u6587\u4EF6\u8BF7\u6C42\u672A\u53D1\u9001\u3002\u8BF7\u68C0\u67E5\u8FDE\u63A5\uFF0C\u7136\u540E\u518D\u6B21\u70B9\u51FB\u6587\u4EF6\u91CD\u8BD5\u3002","files.readInterrupted":"\u6587\u4EF6\u8BFB\u53D6\u5DF2\u4E2D\u65AD\u3002\u8BF7\u91CD\u65B0\u8FDE\u63A5\uFF0C\u7136\u540E\u518D\u6B21\u70B9\u51FB\u6587\u4EF6\u91CD\u8BD5\u3002","files.searchPlaceholder":"\u641C\u7D22...","files.replacePlaceholder":"\u66FF\u6362...","files.replace":"\u66FF\u6362","files.replaceAll":"\u5168\u90E8","files.replaceCurrent":"\u66FF\u6362\u5F53\u524D","files.replaceAllTitle":"\u5168\u90E8\u66FF\u6362","files.clickToView":"\u70B9\u51FB\u6587\u4EF6\u67E5\u770B\u5185\u5BB9","files.selectFolder":"\u9009\u62E9\u6587\u4EF6\u5939","files.enterFolderName":"\u8F93\u5165\u6587\u4EF6\u5939\u540D...","files.enterFileName":"\u8F93\u5165\u6587\u4EF6\u540D...","files.moveTarget":"\u8F93\u5165\u76EE\u6807\u76EE\u5F55\u8DEF\u5F84...","files.moveItems":"\u5C06 {count} \u4E2A\u9879\u76EE\u79FB\u52A8\u5230\u6307\u5B9A\u76EE\u5F55","files.workDir":"\u5DE5\u4F5C\u76EE\u5F55: {dir}","files.enterDirPath":"\u8F93\u5165\u76EE\u5F55\u8DEF\u5F84...","files.unsavedConfirm":'"{name}" \u6709\u672A\u4FDD\u5B58\u7684\u4FEE\u6539\uFF0C\u786E\u5B9A\u5173\u95ED\uFF1F',"files.unsavedBatchConfirm":"{count} \u4E2A\u6587\u4EF6\u6709\u672A\u4FDD\u5B58\u7684\u4FEE\u6539\uFF0C\u786E\u5B9A\u5173\u95ED\uFF1F","files.showOpenTabs":"\u663E\u793A\u5DF2\u6253\u5F00\u7684\u6587\u4EF6","files.closeTab":"\u5173\u95ED {name}","files.closeTabAction":"\u5173\u95ED","files.closeOtherTabs":"\u5173\u95ED\u5176\u4ED6","files.closeTabsToLeft":"\u5173\u95ED\u5DE6\u4FA7","files.closeTabsToRight":"\u5173\u95ED\u53F3\u4FA7","files.closeAllTabs":"\u5168\u90E8\u5173\u95ED","files.deleteConfirm":'\u786E\u5B9A\u8981\u5220\u9664 "{name}" \u5417\uFF1F',"files.deleteDirHint":"\uFF08\u5C06\u5220\u9664\u6587\u4EF6\u5939\u53CA\u5176\u6240\u6709\u5185\u5BB9\uFF09","files.deleteSelectedConfirm":"\u786E\u5B9A\u8981\u5220\u9664\u9009\u4E2D\u7684 {count} \u4E2A\u9879\u76EE\u5417\uFF1F\u6B64\u64CD\u4F5C\u4E0D\u53EF\u64A4\u9500\u3002","files.findPrev":"\u4E0A\u4E00\u4E2A (Shift+Enter)","files.findNext":"\u4E0B\u4E00\u4E2A (Enter)","files.caseSensitive":"\u533A\u5206\u5927\u5C0F\u5199","files.regex":"\u6B63\u5219\u8868\u8FBE\u5F0F","files.unsaved":"\u672A\u4FDD\u5B58","files.clearSelection":"\u6E05\u9664\u9009\u62E9","files.rename":"\u91CD\u547D\u540D","files.copyHere":"\u590D\u5236","files.moveTo":"\u79FB\u52A8\u5230...","files.download":"\u4E0B\u8F7D","files.enterNewName":"\u8F93\u5165\u65B0\u540D\u79F0...","files.loadingPreview":"\u52A0\u8F7D\u9884\u89C8\u4E2D...","files.previewTooLarge":"\u8BE5\u6587\u4EF6\u5927\u5C0F\u4E3A {size} MB\uFF0C\u8D85\u8FC7 {limit} MB \u7684\u9884\u89C8\u4E0E\u4E0B\u8F7D\u4E0A\u9650\u3002","files.previewLoadFailed":"\u56FE\u7247\u9884\u89C8\u52A0\u8F7D\u5931\u8D25\u3002","files.videoPreviewLoadFailed":"\u89C6\u9891\u65E0\u6CD5\u64AD\u653E\uFF0C\u5F53\u524D\u6D4F\u89C8\u5668\u53EF\u80FD\u4E0D\u652F\u6301\u8BE5\u89C6\u9891\u7F16\u7801\u3002","files.videoStreamUnavailable":"\u5F53\u524D Agent \u6216 Session \u4E0D\u652F\u6301\u89C6\u9891\u6D41\u5F0F\u64AD\u653E\u3002","files.preview":"\u9884\u89C8","files.edit":"\u7F16\u8F91","files.pptxNotSupported":"PPTX \u672C\u5730\u9884\u89C8\u6682\u4E0D\u652F\u6301\uFF0C\u8BF7\u5728\u8BBE\u7F6E\u4E2D\u5207\u6362\u4E3A Office Online \u6A21\u5F0F\u3002","files.officePreviewMode":"Office \u9884\u89C8\u6A21\u5F0F","files.officeOnline":"Office Online","files.localRender":"\u672C\u5730\u6E32\u67D3","proxy.port":"\u7AEF\u53E3","proxy.label":"\u6807\u7B7E","proxy.add":"\u6DFB\u52A0\u7AEF\u53E3\u6620\u5C04","proxy.addPort":"\u6DFB\u52A0\u7AEF\u53E3\u6620\u5C04","proxy.enable":"\u70B9\u51FB\u542F\u7528","proxy.clickEnable":"\u70B9\u51FB\u542F\u7528","proxy.disable":"\u70B9\u51FB\u7981\u7528","proxy.clickDisable":"\u70B9\u51FB\u7981\u7528","proxy.openNewTab":"\u5728\u65B0\u6807\u7B7E\u9875\u6253\u5F00","proxy.openInBrowser":"\u5728\u65B0\u6807\u7B7E\u9875\u6253\u5F00","proxy.noMappings":"\u6682\u65E0\u7AEF\u53E3\u6620\u5C04","proxy.noPorts":"\u6682\u65E0\u7AEF\u53E3\u6620\u5C04","proxy.hint":"\u6DFB\u52A0\u7AEF\u53E3\u540E\uFF0C\u53EF\u901A\u8FC7\u4EE3\u7406 URL \u8BBF\u95EE agent \u673A\u5668\u4E0A\u7684\u672C\u5730\u670D\u52A1","proxy.noPortsHint":"\u6DFB\u52A0\u7AEF\u53E3\u540E\uFF0C\u53EF\u901A\u8FC7\u4EE3\u7406 URL \u8BBF\u95EE agent \u673A\u5668\u4E0A\u7684\u672C\u5730\u670D\u52A1","proxy.selectAgent":"\u8BF7\u5148\u9009\u62E9\u4E00\u4E2A Agent","store.selectAgent":"\u8BF7\u5148\u9009\u62E9\u4E00\u4E2A Agent","store.creatingConv":"\u6B63\u5728\u521B\u5EFA\u4F1A\u8BDD...","store.loadingHistory":"\u6B63\u5728\u52A0\u8F7D\u4F1A\u8BDD\u5386\u53F2...","store.executionCancelled":"\u6267\u884C\u5DF2\u53D6\u6D88","store.loginFailed":"\u767B\u5F55\u5931\u8D25","store.convClosed":"\u4F1A\u8BDD\u5DF2\u5173\u95ED","store.convCreated":"\u65B0\u4F1A\u8BDD\u5DF2\u521B\u5EFA [{agent}]\uFF0C\u5DE5\u4F5C\u76EE\u5F55: {workDir}","store.convResumed":"\u5DF2\u6062\u590D\u4F1A\u8BDD [{agent}]: {sessionId}","roleplay.creating":"\u6B63\u5728\u521B\u5EFA \u89D2\u8272\u626E\u6F14 \u4F1A\u8BDD...","roleplay.working":"\u5DE5\u4F5C\u4E2D","roleplay.selectTeam":"\u9009\u62E9\u56E2\u961F\u6A21\u677F","roleplay.teamDev":"\u8F6F\u4EF6\u5F00\u53D1","roleplay.teamCustom":"\u81EA\u5B9A\u4E49","roleplay.editRoles":"\u7F16\u8F91\u89D2\u8272","roleplay.roleName":"\u89D2\u8272\u6807\u8BC6","roleplay.roleDisplayName":"\u663E\u793A\u540D\u79F0","roleplay.roleIcon":"\u56FE\u6807","roleplay.roleDesc":"\u89D2\u8272\u63CF\u8FF0","roleplay.rolePrompt":"\u89D2\u8272 Prompt","roleplay.removeRole":"\u79FB\u9664\u89D2\u8272","roleplay.addRole":"\u6DFB\u52A0\u89D2\u8272","roleplay.start":"\u542F\u52A8 \u89D2\u8272\u626E\u6F14","roleplay.sidebarTitle":"\u89D2\u8272\u626E\u6F14","roleplay.configTitle":"\u89D2\u8272\u626E\u6F14","roleplay.newSession":"\u65B0\u5EFA \u89D2\u8272\u626E\u6F14","roleplay.emptyHint":"\u53D1\u9001\u6D88\u606F\u5F00\u59CB\u591A\u89D2\u8272\u534F\u4F5C","roleplay.askingYou":"\u6B63\u5728\u63D0\u95EE","roleplay.language":"\u8BED\u8A00","roleplay.rolePreview":"\u89D2\u8272\u914D\u7F6E","roleplay.noAgents":"\u6CA1\u6709\u5728\u7EBF\u7684 Agent","roleplay.inputPlaceholder":"\u8F93\u5165\u6D88\u606F\u2026 \u4F7F\u7528 @ \u63D0\u53CA\u89D2\u8272","roleplay.existingSessions":"\u5DF2\u6709\u56E2\u961F","roleplay.restore":"\u6062\u590D","roleplay.restoring":"\u6B63\u5728\u6062\u590D \u89D2\u8272\u626E\u6F14 \u4F1A\u8BDD...","roleplay.createNew":"\u521B\u5EFA\u65B0\u56E2\u961F","expertPanel.title":"\u5E2E\u5E2E\u56E2","expertPanel.search":"\u641C\u7D22\u89D2\u8272\u6216 Action...","expertPanel.noResults":"\u6CA1\u6709\u5339\u914D\u7ED3\u679C","expertPanel.clearAll":"\u6E05\u7A7A","expertPanel.persona":"\u89D2\u8272\u4EBA\u8BBE","expertPanel.template":"\u6709\u8F93\u5165\u65F6 \xB7 \u6D88\u606F\u524D\u7F00","expertPanel.templateHint":"\u7528\u6237\u5199\u4E86\u6587\u5B57\u65F6\uFF1A\u6B64\u524D\u7F00 + \u7528\u6237\u6587\u5B57 = \u6700\u7EC8\u53D1\u9001\u5185\u5BB9","expertPanel.defaultMsg":"\u65E0\u8F93\u5165\u65F6 \xB7 \u5B8C\u6574 Prompt","expertPanel.defaultMsgHint":"\u7528\u6237\u4E0D\u5199\u6587\u5B57\u76F4\u63A5\u53D1\u9001\u65F6\uFF0C\u4F7F\u7528\u6B64\u5B8C\u6574 prompt","expertPanel.loading":"\u6B63\u5728\u52A0\u8F7D\u89D2\u8272\u5B9A\u4E49...","expertPanel.viewPrompt":"\u67E5\u770B\u63D0\u793A\u8BCD","expertPanel.customRoles":"\u81EA\u5B9A\u4E49\u89D2\u8272","expertPanel.addRole":"\u6DFB\u52A0\u89D2\u8272","expertPanel.editRole":"\u7F16\u8F91\u89D2\u8272","expertPanel.deleteRole":"\u5220\u9664\u89D2\u8272","expertPanel.noCustomRoles":"\u6682\u65E0\u81EA\u5B9A\u4E49\u89D2\u8272","expertPanel.createFirst":"\u521B\u5EFA\u7B2C\u4E00\u4E2A\u81EA\u5B9A\u4E49\u89D2\u8272","expertPanel.noActions":"\u6682\u65E0 Action","expertPanel.deleteConfirm":'\u786E\u5B9A\u8981\u5220\u9664\u89D2\u8272 "{name}" \u5417\uFF1F\u6B64\u64CD\u4F5C\u4E0D\u53EF\u64A4\u9500\u3002',"expertPanel.deleteConfirmBtn":"\u5220\u9664","expertEditor.createTitle":"\u521B\u5EFA\u81EA\u5B9A\u4E49\u89D2\u8272","expertEditor.editTitle":"\u7F16\u8F91\u81EA\u5B9A\u4E49\u89D2\u8272","expertEditor.basicInfo":"\u57FA\u672C\u4FE1\u606F","expertEditor.roleName":"\u89D2\u8272\u540D\u79F0","expertEditor.roleNamePlaceholder":"\u5982\uFF1A\u6570\u636E\u5206\u6790\u5E08","expertEditor.roleTitle":"\u804C\u79F0","expertEditor.roleTitlePlaceholder":"\u5982\uFF1A\u9AD8\u7EA7\u6570\u636E\u5206\u6790\u5E08","expertEditor.fullName":"\u5168\u540D","expertEditor.fullNamePlaceholder":"\u53EF\u9009","expertEditor.titleEn":"\u82F1\u6587\u804C\u79F0","expertEditor.titleEnPlaceholder":"\u53EF\u9009","expertEditor.rolePrompt":"\u89D2\u8272 Prompt","expertEditor.messagePrefix":"\u6D88\u606F\u524D\u7F00\uFF08\u4E2D\u6587\uFF09","expertEditor.messagePrefixPlaceholder":"\u5982\uFF1A\u4F5C\u4E3A\u4E00\u540D\u8D44\u6DF1\u6570\u636E\u5206\u6790\u5E08\uFF0C","expertEditor.messagePrefixEn":"\u6D88\u606F\u524D\u7F00\uFF08\u82F1\u6587\uFF09","expertEditor.messagePrefixEnPlaceholder":"As a senior data analyst, ","expertEditor.actions":"Actions","expertEditor.addAction":"\u6DFB\u52A0 Action","expertEditor.removeAction":"\u79FB\u9664","expertEditor.actionName":"Action \u540D\u79F0","expertEditor.actionNamePlaceholder":"\u5982\uFF1A\u6570\u636E\u5206\u6790","expertEditor.actionNameEn":"\u82F1\u6587\u540D\u79F0","expertEditor.actionNameEnPlaceholder":"\u53EF\u9009","expertEditor.messageTemplate":"\u6709\u8F93\u5165\u65F6 \xB7 \u6D88\u606F\u524D\u7F00\uFF08\u4E2D\u6587\uFF09","expertEditor.messageTemplatePlaceholder":"\u7528\u6237\u5199\u4E86\u6587\u5B57\u65F6\uFF0C\u62FC\u5728\u7528\u6237\u6587\u5B57\u524D\u9762\u53D1\u9001","expertEditor.messageTemplateEn":"\u6709\u8F93\u5165\u65F6 \xB7 \u6D88\u606F\u524D\u7F00\uFF08\u82F1\u6587\uFF09","expertEditor.messageTemplateEnPlaceholder":"Prepended to user text when user types something","expertEditor.defaultMessage":"\u65E0\u8F93\u5165\u65F6 \xB7 \u5B8C\u6574 Prompt\uFF08\u4E2D\u6587\uFF09","expertEditor.defaultMessagePlaceholder":"\u7528\u6237\u4E0D\u5199\u6587\u5B57\u76F4\u63A5\u53D1\u9001\u65F6\uFF0C\u4F7F\u7528\u6B64\u5B8C\u6574\u5185\u5BB9","expertEditor.defaultMessageEn":"\u65E0\u8F93\u5165\u65F6 \xB7 \u5B8C\u6574 Prompt\uFF08\u82F1\u6587\uFF09","expertEditor.defaultMessageEnPlaceholder":"Used as-is when user sends without typing","expertEditor.cancel":"\u53D6\u6D88","expertEditor.save":"\u4FDD\u5B58","expertEditor.saving":"\u4FDD\u5B58\u4E2D...","subAgentPanel.title":"\u5B50\u4EE3\u7406","subAgentPanel.back":"\u8FD4\u56DE\u5217\u8868","subAgentPanel.running":"\u8FD0\u884C\u4E2D","subAgentPanel.completed":"\u5DF2\u5B8C\u6210","subAgentPanel.waitingMessages":"\u7B49\u5F85\u6D88\u606F...","subAgentPanel.toolCount":"{count} \u4E2A\u5DE5\u5177","subAgentPanel.toolSummary":"\u5DF2\u5B8C\u6210 {count} \u6B21\u5DE5\u5177\u8C03\u7528","subAgentPanel.empty":"\u6682\u65E0\u5B50\u4EE3\u7406","subAgentPanel.emptyHint":"\u5F53 Claude \u59D4\u6D3E\u4EFB\u52A1\u65F6\uFF0C\u5B50\u4EE3\u7406\u4F1A\u5728\u8FD9\u91CC\u663E\u793A","splitScreen.split":"\u5206\u5C4F","splitScreen.closePane":"\u5173\u95ED\u6B64\u9762\u677F","splitScreen.newChat":"\u65B0\u5EFA Chat","splitScreen.noSessions":"\u6682\u65E0\u4F1A\u8BDD","splitScreen.splitToPanel":"\u5728\u65B0\u9762\u677F\u4E2D\u6253\u5F00","splitScreen.selectFromSidebar":"\u4ECE\u5DE6\u4FA7\u9009\u62E9\u5BF9\u8BDD","yeaft.vp.library":"\u89D2\u8272\u5E93","yeaft.vp.createFirst":"+ \u521B\u5EFA\u4F60\u7684\u7B2C\u4E00\u4E2A\u89D2\u8272","yeaft.vp.empty.aria":"\u5C1A\u65E0\u89D2\u8272","yeaft.vp.avatar.aria":"{name} \u5934\u50CF","yeaft.vp.speaker.stateCauseAria":"\u72B6\u6001\u53D8\u66F4\uFF1A{cause}","yeaft.vp.status.thinking":"\u6B63\u5728\u601D\u8003\u2026","yeaft.vp.status.tool":"\u6B63\u5728\u4F7F\u7528 {name}","yeaft.vp.status.done":"\u5B8C\u6210 \xB7 {count} \u4E2A\u5DE5\u5177","yeaft.vp.status.aborted":"\u5DF2\u4E2D\u6B62","yeaft.vp.crud.title":"\u89D2\u8272\u5E93","yeaft.vp.crud.close":"\u5173\u95ED","yeaft.vp.crud.addNew":"+ \u65B0\u5EFA\u89D2\u8272","yeaft.vp.crud.empty":"\u8FD8\u6CA1\u6709\u89D2\u8272\u3002\u521B\u5EFA\u7B2C\u4E00\u4E2A\u89D2\u8272\u5F00\u59CB\u534F\u4F5C\u5427\u3002","yeaft.vp.crud.edit":"\u7F16\u8F91","yeaft.vp.crud.delete":"\u5220\u9664","yeaft.vp.crud.deleteConfirm":'\u5220\u9664 "{name}"\uFF1F\u4F1A\u4E00\u5E76\u5220\u9664\u78C1\u76D8\u4E0A\u7684 role.md \u6587\u4EF6\u3002',"yeaft.vp.crud.form.create":"\u521B\u5EFA\u89D2\u8272","yeaft.vp.crud.form.update":"\u7F16\u8F91\u89D2\u8272","yeaft.vp.crud.form.vpId":"\u89D2\u8272 ID","yeaft.vp.crud.form.vpId.tooltip":"\u53EA\u80FD\u7528\u5B57\u6BCD\u3001\u6570\u5B57\u3001- \u548C _\uFF0C\u4E0D\u80FD\u4EE5 _ \u5F00\u5934\uFF0C\u4E0D\u80FD\u662F\u7EAF\u6570\u5B57\uFF0C\u4E0D\u80FD\u7528\u4FDD\u7559\u540D\uFF1Aall / user / system / everyone\u3002","yeaft.vp.crud.form.displayName":"\u663E\u793A\u540D\uFF08\u82F1\u6587\uFF09","yeaft.vp.crud.form.displayNameZh":"\u663E\u793A\u540D\uFF08\u4E2D\u6587\uFF09","yeaft.vp.crud.form.description":"\u80FD\u529B\u63CF\u8FF0\uFF08\u82F1\u6587\uFF09","yeaft.vp.crud.form.descriptionZh":"\u80FD\u529B\u63CF\u8FF0\uFF08\u4E2D\u6587\uFF09","yeaft.vp.crud.form.descriptionPlaceholder":"\u4F8B\u5982\uFF1AAPI design, migration planning, and compatibility reviews","yeaft.vp.crud.form.descriptionZhPlaceholder":"\u4F8B\u5982\uFF1AAPI \u8BBE\u8BA1\u3001\u8FC1\u79FB\u89C4\u5212\u4E0E\u517C\u5BB9\u6027\u8BC4\u5BA1","yeaft.vp.crud.form.role":"\u804C\u4F4D","yeaft.vp.crud.form.rolePlaceholder":"\u4F8B\u5982\uFF1A\u4EA7\u54C1\u7ECF\u7406","yeaft.vp.crud.form.traits":"\u7279\u8D28\u6807\u7B7E","yeaft.vp.crud.form.traitsHint":"\u7528\u82F1\u6587\u9017\u53F7\u5206\u9694\u7684\u77ED\u6807\u7B7E\uFF08\u4F8B\u5982\uFF1A\u597D\u5947, \u52A1\u5B9E\uFF09\u3002","yeaft.vp.crud.form.modelHint":"\u6A21\u578B\u504F\u597D","yeaft.vp.crud.form.modelHint.none":"\u2014 \u9ED8\u8BA4 \u2014","yeaft.vp.crud.form.modelHint.primary":"\u4E3B\u6A21\u578B","yeaft.vp.crud.form.modelHint.fast":"\u5FEB\u6A21\u578B","yeaft.vp.crud.form.persona":"\u4EBA\u8BBE\uFF08Markdown\uFF09","yeaft.vp.crud.form.personaPlaceholder":"\u63CF\u8FF0\u8FD9\u4E2A\u89D2\u8272\u5982\u4F55\u601D\u8003\u3001\u8868\u8FBE\u3001\u505A\u51B3\u7B56\u2026\u2026","yeaft.vp.crud.form.submit":"\u4FDD\u5B58","yeaft.vp.crud.form.cancel":"\u53D6\u6D88","yeaft.vp.crud.form.ok":"\u683C\u5F0F\u6B63\u786E","yeaft.vp.crud.form.idLocked":"\u521B\u5EFA\u540E\u89D2\u8272 ID \u4E0D\u53EF\u4FEE\u6539\u3002","yeaft.vp.crud.saving":"\u4FDD\u5B58\u4E2D\u2026\u2026","yeaft.vp.crud.saveFailed":"\u4FDD\u5B58\u5931\u8D25\uFF1A{error}","yeaft.vp.crud.deleteFailed":"\u5220\u9664\u5931\u8D25\uFF1A{error}","yeaft.vp.crud.viewPrompt":"\u67E5\u770B prompt","yeaft.vp.crud.view.title":"VP \u63D0\u793A\u8BCD","yeaft.vp.crud.view.personaEmpty":"\uFF08\u672A\u5B9A\u4E49 persona \u6B63\u6587\uFF0C\u53EA\u6709\u57FA\u7840\u5143\u6570\u636E\uFF09","yeaft.vp.crud.view.back":"\u8FD4\u56DE","yeaft.vp.crud.view.editFromHere":"\u7F16\u8F91\u8BE5 VP","yeaft.vp.crud.view.removed":"\u8BE5 VP \u5DF2\u5728\u522B\u5904\u88AB\u5220\u9664\uFF0C\u8FD4\u56DE\u5217\u8868\u3002","yeaft.vp.crud.stockBadge":"\u9884\u88C5","yeaft.vp.crud.stockReadOnly":"\u9884\u88C5 VP \u968F agent \u51FA\u5382\uFF0C\u4E0D\u80FD\u7F16\u8F91\u6216\u5220\u9664\u3002","yeaft.vp.idError.empty_or_non_string":"\u89D2\u8272 ID \u4E0D\u80FD\u4E3A\u7A7A\u3002","yeaft.vp.idError.too_long":"\u89D2\u8272 ID \u592A\u957F\uFF08\u6700\u591A 40 \u5B57\u7B26\uFF09\u3002","yeaft.vp.idError.illegal_character":'\u53EA\u80FD\u4F7F\u7528\u5B57\u6BCD\u3001\u6570\u5B57\u3001"-" \u548C "_"\u3002',"yeaft.vp.idError.underscore_prefix_reserved":'\u89D2\u8272 ID \u4E0D\u80FD\u4EE5 "_" \u5F00\u5934\uFF08\u9884\u7559\u7ED9\u7CFB\u7EDF\u89D2\u8272\uFF09\u3002',"yeaft.vp.idError.pure_digits":"\u89D2\u8272 ID \u4E0D\u80FD\u662F\u7EAF\u6570\u5B57\u3002","yeaft.vp.idError.reserved":"\u89D2\u8272 ID \u4E0D\u80FD\u7528\u4FDD\u7559\u540D\uFF08all / user / system / everyone\uFF09\u3002","yeaft.vp.idError.duplicate":"\u5DF2\u7ECF\u5B58\u5728\u540C ID \u7684\u89D2\u8272\u3002","yeaft.vp.idError.not_found":"\u8BE5 VP \u4E0D\u5B58\u5728\uFF0C\u53EF\u80FD\u5DF2\u88AB\u5220\u9664\u3002","yeaft.vp.idError.stock_readonly":"\u9884\u88C5 VP \u4E0D\u80FD\u7F16\u8F91\u6216\u5220\u9664\u3002","yeaft.vp.idError.unknown":"\u53D1\u751F\u672A\u77E5\u9519\u8BEF\uFF0C\u8BF7\u91CD\u8BD5\u3002","yeaft.vp.reason.personaEdit":"\u4EBA\u8BBE\u5DF2\u66F4\u65B0","yeaft.vp.reason.traitsEdit":"\u7279\u5F81\u5DF2\u66F4\u65B0","yeaft.vp.reason.manualReload":"\u5DF2\u91CD\u65B0\u8F7D\u5165","yeaft.vp.reason.fileRemoved":"\u5DF2\u79FB\u9664","yeaft.vp.reason.toast.updated":"{name}\uFF1A{reason}","yeaft.vp.reason.toast.removed":"{name} \u5DF2\u88AB\u79FB\u9664","yeaft.message.timeAria":"\u53D1\u9001\u4E8E {time}","yeaft.message.llmCall":"{count} \u6B21 LLM \u8C03\u7528","yeaft.message.llmCalls":"{count} \u6B21 LLM \u8C03\u7528","yeaft.message.tokenUsage":"\u603B\u8BA1 {total} \xB7 \u8F93\u5165 {input} \xB7 \u8F93\u51FA {output}","yeaft.user.youLabel":"\u6211","yeaft.session.sidebarTitle":"\u4F1A\u8BDD","yeaft.session.sidebarAria":"\u4F1A\u8BDD\u5217\u8868","yeaft.session.newButton":"+ \u65B0\u5EFA\u4F1A\u8BDD","yeaft.session.newButtonAria":"\u521B\u5EFA\u65B0\u4F1A\u8BDD","yeaft.session.empty":"\u6682\u65E0\u4F1A\u8BDD\u3002","yeaft.session.membersCount":"{count} \u4F4D\u6210\u5458","yeaft.session.oneMember":"1 \u4F4D\u6210\u5458","yeaft.session.noMembers":"\u7A7A\u4F1A\u8BDD \u2014 \u8BF7\u9080\u8BF7 VP","yeaft.session.defaultBadge":"\u9ED8\u8BA4","yeaft.session.defaultName":"\u9ED8\u8BA4\u4F1A\u8BDD","yeaft.session.moreActions":"\u66F4\u591A\u64CD\u4F5C","yeaft.session.archive":"\u5F52\u6863","yeaft.session.archiveConfirm":"\u5F52\u6863\u300C{name}\u300D\uFF1F\u7A0D\u540E\u53EF\u4ECE\u78C1\u76D8\u6062\u590D\u3002","yeaft.session.archivingEllipsis":"\u5F52\u6863\u4E2D\u2026","yeaft.session.delete":"\u5220\u9664","yeaft.session.deleteConfirm":"\u5220\u9664\u300C{name}\u300D\uFF1F\u5C06\u6C38\u4E45\u5220\u9664\u8BE5\u4F1A\u8BDD\u53CA\u5176\u6240\u6709\u6570\u636E\uFF0C\u6B64\u64CD\u4F5C\u4E0D\u53EF\u64A4\u9500\u3002","yeaft.session.deletingEllipsis":"\u5220\u9664\u4E2D\u2026","yeaft.session.rename":"\u91CD\u547D\u540D","yeaft.session.copy":"\u590D\u5236\u4F1A\u8BDD","yeaft.session.copying":"\u6B63\u5728\u590D\u5236\u4F1A\u8BDD\u2026","yeaft.session.copyComplete":"\u4F1A\u8BDD\u590D\u5236\u5B8C\u6210","yeaft.session.copyFailed":"\u65E0\u6CD5\u590D\u5236\u4F1A\u8BDD\uFF1A{message}","yeaft.session.openSettings":"\u8BBE\u7F6E","yeaft.session.removeFromList":"\u79FB\u9664","yeaft.session.manageMembers":"\u7BA1\u7406\u6210\u5458","yeaft.session.memberCount.one":"1 \u4F4D\u6210\u5458","yeaft.session.memberCount.other":"{count} \u4F4D\u6210\u5458","yeaft.session.renamePrompt":"\u4E3A\u300C{name}\u300D\u8F93\u5165\u65B0\u540D\u79F0\uFF1A","yeaft.session.renamingEllipsis":"\u91CD\u547D\u540D\u4E2D\u2026","yeaft.session.editModal.renameTitle":"\u91CD\u547D\u540D\u4F1A\u8BDD","yeaft.session.editModal.renameBody":"\u4E3A\u300C{name}\u300D\u9009\u62E9\u4E00\u4E2A\u65B0\u540D\u79F0\u3002","yeaft.session.editModal.renameSubmit":"\u4FDD\u5B58","yeaft.session.editModal.archiveTitle":"\u5F52\u6863\u4F1A\u8BDD","yeaft.session.editModal.archiveBody":"\u5F52\u6863\u300C{name}\u300D\uFF1F\u7A0D\u540E\u53EF\u4ECE\u78C1\u76D8\u6062\u590D\u3002","yeaft.session.editModal.archiveSubmit":"\u5F52\u6863","yeaft.session.editModal.deleteTitle":"\u5220\u9664\u4F1A\u8BDD","yeaft.session.editModal.deleteBody":"\u5220\u9664\u300C{name}\u300D\uFF1F\u5C06\u6C38\u4E45\u5220\u9664\u8BE5\u4F1A\u8BDD\u53CA\u5176\u6240\u6709\u6570\u636E\uFF0C\u6B64\u64CD\u4F5C\u4E0D\u53EF\u64A4\u9500\u3002","yeaft.session.editModal.deleteSubmit":"\u5220\u9664","yeaft.session.editModal.newNameLabel":"\u65B0\u540D\u79F0","yeaft.session.editModal.cancel":"\u53D6\u6D88","yeaft.session.editModal.close":"\u5173\u95ED","yeaft.session.error.invalid_name":"\u4F1A\u8BDD\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A\u3002","yeaft.session.error.duplicate":"\u8BE5\u4F1A\u8BDD id \u5DF2\u5B58\u5728\u3002","yeaft.session.error.not_found":"\u672A\u627E\u5230\u8BE5\u4F1A\u8BDD\u3002","yeaft.session.error.agent_offline":"\u8BF7\u8FDE\u63A5 Agent \u540E\u518D\u590D\u5236\u4F1A\u8BDD\u3002","yeaft.session.error.fork_pending":"\u6B63\u5728\u590D\u5236\u4F1A\u8BDD\uFF0C\u8BF7\u7A0D\u5019\u3002","yeaft.session.error.project_inheritance_failed":"\u526F\u672C\u5DF2\u521B\u5EFA\uFF0C\u4F46\u4FDD\u5B58 Project \u5F52\u5C5E\u5931\u8D25\u3002\u8BF7\u5728\u4FA7\u680F\u5C06\u65B0\u4F1A\u8BDD\u79FB\u5165\u539F Project\uFF0C\u4E0D\u8981\u91CD\u590D\u590D\u5236\u3002","yeaft.session.error.session_running":"\u8BF7\u7B49\u5F85\u8BE5\u4F1A\u8BDD\u7684\u5F53\u524D\u56DE\u590D\u5B8C\u6210\u540E\u518D\u590D\u5236\u3002","yeaft.session.error.default_not_in_roster":"\u9ED8\u8BA4 VP \u5FC5\u987B\u5728\u6210\u5458\u5217\u8868\u4E2D\u3002","yeaft.session.error.no_default_vp":"\u8BE5\u4F1A\u8BDD\u6CA1\u6709\u6210\u5458\uFF0C\u8BF7\u4ECE\u89D2\u8272\u5E93\u6DFB\u52A0 VP \u4EE5\u5F00\u59CB\u5BF9\u8BDD\u3002","yeaft.session.error.reserved":"\u6240\u9009 id \u4E2D\u5305\u542B\u4FDD\u7559\u540D\uFF08all / user / system / everyone\uFF09\u3002","yeaft.session.error.unknown":"\u4F1A\u8BDD\u64CD\u4F5C\u5931\u8D25\uFF1A{message}","yeaft.session.error.timeout":"\u4F1A\u8BDD\u64CD\u4F5C\u8D85\u65F6\uFF0C\u8BF7\u91CD\u8BD5\u3002","yeaft.session.invite.title":"\u9080\u8BF7 VP","yeaft.session.invite.body":"\u300C{name}\u300D\u5F53\u524D\u4E3A\u7A7A\uFF0C\u8BF7\u4ECE\u89D2\u8272\u5E93\u6DFB\u52A0\u4E00\u4F4D VP \u4EE5\u5F00\u59CB\u5BF9\u8BDD\u3002","yeaft.session.invite.openLibrary":"\u6253\u5F00\u89D2\u8272\u5E93","yeaft.session.invite.dismiss":"\u6682\u4E0D","yeaft.session.empty.title":"\u7A7A\u4F1A\u8BDD","yeaft.session.empty.hint":"\u300C{name}\u300D\u8FD8\u6CA1\u6709\u6210\u5458\u3002\u6DFB\u52A0\u4E00\u4F4D VP \u5373\u53EF\u5F00\u59CB\u5BF9\u8BDD\u3002","yeaft.session.empty.cta":"\u7BA1\u7406\u6210\u5458","yeaft.session.members.title":"\u7BA1\u7406\u300C{name}\u300D\u7684\u6210\u5458","yeaft.session.members.aria":"\u6210\u5458\u7BA1\u7406","yeaft.session.members.close":"\u5173\u95ED","yeaft.session.members.done":"\u5B8C\u6210","yeaft.session.members.empty":"\u6682\u65E0\u53EF\u7528 VP \u2014 \u8BF7\u5148\u5230\u89D2\u8272\u5E93\u521B\u5EFA\u3002","yeaft.session.members.loading":"VP \u52A0\u8F7D\u4E2D\u2026","yeaft.session.members.defaultHint":"\u9ED8\u8BA4 VP\uFF08@\u63D0\u53CA\u7F3A\u7701\u65F6\u7531\u8BE5 VP \u5E94\u7B54\uFF09","yeaft.session.members.memberCount":"\u5DF2\u9009 {count} \u4F4D","yeaft.session.members.actionFailed":"\u64CD\u4F5C\u5931\u8D25\uFF1A{error}","yeaft.session.members.openLibrary":"\u6253\u5F00 VP \u5E93","yeaft.session.members.openLibraryHint":"\u5728 VP \u5E93\u53EF\u521B\u5EFA\u65B0 VP \u6216\u67E5\u770B VP \u7684 prompt\u3002","yeaft.session.announcement.label":"\u4F1A\u8BDD\u516C\u544A","yeaft.session.announcement.hintEmpty":"\u6682\u65E0\u516C\u544A \u2014 \u70B9\u51FB \u270F\uFE0F \u6DFB\u52A0\u3002","yeaft.session.announcement.emptyBody":"\u672A\u8BBE\u7F6E\u4F1A\u8BDD\u516C\u544A\u3002\u53EF\u4EE5\u5728\u8FD9\u91CC\u5199\u4E00\u6BB5\u7B80\u4ECB\uFF0C\u4F1A\u8BDD\u5185\u6240\u6709 VP \u5728\u6536\u5230\u6D88\u606F\u65F6\u90FD\u4F1A\u5728 system prompt \u9876\u90E8\u770B\u5230 \u2014 \u9002\u5408\u5199\u5171\u540C\u80CC\u666F\u3001\u89C4\u5219\u3001\u6216 CLAUDE.md \u5F0F\u7684\u6307\u5F15\u3002","yeaft.session.announcement.placeholder":"\u4E3A\u8FD9\u4E2A\u4F1A\u8BDD\u91CC\u7684\u6240\u6709 VP \u5199\u4E00\u6BB5\u5171\u4EAB\u7684\u7B80\u4ECB\u2026","yeaft.session.announcement.edit":"\u7F16\u8F91\u516C\u544A","yeaft.session.announcement.editTitle":"\u7F16\u8F91\u4F1A\u8BDD\u516C\u544A","yeaft.session.announcement.saving":"\u4FDD\u5B58\u4E2D\u2026","yeaft.session.announcement.saveFailed":"\u4FDD\u5B58\u5931\u8D25\uFF1A{error}","yeaft.session.announcement.openSettings":"\u6253\u5F00\u4F1A\u8BDD\u8BBE\u7F6E","yeaft.session.settings.title":"{name} \u2014 \u4F1A\u8BDD\u8BBE\u7F6E","yeaft.session.settings.short":"\u4F1A\u8BDD","yeaft.session.settings.close":"\u5173\u95ED","yeaft.session.settings.nav.session":"\u4F1A\u8BDD","yeaft.session.settings.nav.members":"\u6210\u5458","yeaft.session.settings.nav.memory":"\u4F1A\u8BDD\u8BB0\u5FC6","yeaft.session.settings.announcement.heading":"\u4F1A\u8BDD\u516C\u544A","yeaft.session.settings.announcement.help":"\u6CE8\u5165\u5230\u4F1A\u8BDD\u5185\u6BCF\u4E2A VP \u7684 system prompt \u9876\u90E8 \u2014 \u7C7B\u4F3C\u56E2\u961F\u5171\u4EAB\u7684 CLAUDE.md\u3002","yeaft.session.settings.members.heading":"\u6210\u5458","yeaft.session.settings.rename.heading":"\u91CD\u547D\u540D\u4F1A\u8BDD","yeaft.session.settings.rename.label":"\u65B0\u540D\u79F0","yeaft.session.settings.rename.save":"\u4FDD\u5B58\u540D\u79F0","yeaft.session.settings.rename.saving":"\u4FDD\u5B58\u4E2D\u2026","yeaft.session.settings.workDir.heading":"\u5DE5\u4F5C\u76EE\u5F55","yeaft.session.settings.workDir.help":"\u4E0B\u4E2A\u56DE\u5408\u5C06\u4ECE\u6B64\u76EE\u5F55\u52A0\u8F7D\u9879\u76EE\u6587\u4EF6\u548C\u9879\u76EE\u6307\u4EE4\u3002\u4F1A\u8BDD\u5386\u53F2\u4ECD\u4FDD\u5B58\u5728 Agent \u6570\u636E\u76EE\u5F55\u4E2D\u3002","yeaft.session.settings.workDir.label":"\u8DEF\u5F84","yeaft.session.settings.workDir.placeholder":"/path/to/project","yeaft.session.settings.workDir.save":"\u4FDD\u5B58\u76EE\u5F55","yeaft.session.settings.workDir.saving":"\u4FDD\u5B58\u4E2D\u2026","yeaft.session.settings.workDir.saveFailed":"\u65E0\u6CD5\u4FDD\u5B58\u5DE5\u4F5C\u76EE\u5F55\uFF1A{error}","yeaft.session.settings.memory.heading":"\u4F1A\u8BDD\u8BB0\u5FC6","yeaft.session.settings.memory.help":"\u7ACB\u5373\u8FD0\u884C dream \u6574\u7406\uFF1A\u8BFB\u53D6\u4E0A\u6B21\u4EE5\u6765\u7684\u65B0\u6D88\u606F\uFF0C\u63D0\u53D6\u8981\u70B9\u5E76\u5408\u5E76\u8FDB\u4F1A\u8BDD\u7684 summary\uFF0C\u8BA9 Resident \u5C42\u80FD\u53CD\u6620\u6700\u65B0\u7684\u5BF9\u8BDD\u3002","yeaft.session.settings.memory.runNow":"\u7ACB\u5373\u8FD0\u884C dream","yeaft.session.settings.memory.running":"\u8FD0\u884C\u4E2D\u2026","yeaft.session.settings.memory.lastSuccess":"\u4E0A\u6B21\u6210\u529F\uFF1A{time} \u2014 \u66F4\u65B0\u4E86 {count} \u4E2A\u76EE\u6807\u3002","yeaft.session.settings.memory.lastError":"\u4E0A\u6B21\u8FD0\u884C\u5931\u8D25\uFF1A{error}","yeaft.session.settings.danger.heading":"\u5220\u9664\u4F1A\u8BDD","yeaft.session.settings.danger.deleteHelp":"\u8FD9\u4F1A\u6C38\u4E45\u5220\u9664\u8BE5\u4F1A\u8BDD\uFF0C\u79FB\u9664\u78C1\u76D8\u4E0A\u7684 session.json \u548C\u5168\u90E8\u6D88\u606F\u5386\u53F2\uFF0C\u4E0D\u53EF\u6062\u590D\u3002","yeaft.session.settings.danger.deleteBtn":"\u5220\u9664\u4F1A\u8BDD","yeaft.vp.mention.placeholder":"\u6309 id \u6216\u540D\u79F0\u641C\u7D22\u89D2\u8272\u2026","yeaft.vp.mention.noMatch":"\u6CA1\u6709\u5339\u914D\u7684\u89D2\u8272","yeaft.vp.mention.count":"\u5DF2 @{count} \u4EBA","yeaft.feature.reject.missing_group_id":"\u53D1\u9001\u5931\u8D25\uFF1A\u672A\u6307\u5B9A\u4F1A\u8BDD\u3002","yeaft.feature.reject.missing_feature_id":"\u53D1\u9001\u5931\u8D25\uFF1A\u4EFB\u52A1\u4E0A\u4E0B\u6587\u4E22\u5931\u3002","yeaft.feature.reject.missing_vp_id":"\u53D1\u9001\u5931\u8D25\uFF1A\u672A\u8BBE\u7F6E\u53D1\u8A00\u8005\u3002","yeaft.feature.reject.invalid_vp_id":"\u53D1\u9001\u5931\u8D25\uFF1A\u53D1\u8A00\u8005 id \u975E\u6CD5\u3002","yeaft.feature.reject.empty_text":"\u53D1\u9001\u5931\u8D25\uFF1A\u5185\u5BB9\u4E3A\u7A7A\u3002","yeaft.feature.reject.text_too_long":"\u53D1\u9001\u5931\u8D25\uFF1A\u5185\u5BB9\u8FC7\u957F\uFF08\u4E0A\u9650 16 KiB\uFF09\u3002","yeaft.feature.reject.unknown":"\u53D1\u9001\u5931\u8D25\u3002","yeaft.feature.pill.label":"\u4EFB\u52A1","yeaft.feature.messageTime.aria":"\u53D1\u9001\u4E8E {time}","yeaft.vp.turnBlock.elapsedTitle":"\u672C\u8F6E turn \u5F00\u59CB\u81F3\u4ECA\u7684\u65F6\u95F4","yeaft.vp.turnBlock.retryingRequest":"\u54CD\u5E94\u505C\u6EDE\uFF0C\u6B63\u5728\u53D1\u8D77\u5168\u65B0\u8BF7\u6C42\uFF08{attempt}/{max}\uFF09","yeaft.vp.turnBlock.retryingContinue":"\u54CD\u5E94\u505C\u6EDE\uFF0C\u6B63\u5728\u7528\u5168\u65B0\u8BF7\u6C42\u7EED\u5199\uFF08{attempt}/{max}\uFF09","yeaft.sessionStatus.aria":"Session \u72B6\u6001","yeaft.sessionStatus.title":"Session \u72B6\u6001","yeaft.sessionStatus.announcement":"\u516C\u544A","yeaft.sessionStatus.announcementEmpty":"\u6682\u65E0\u516C\u544A","yeaft.sessionStatus.announcementAdd":"\u6DFB\u52A0\u516C\u544A","yeaft.sessionStatus.announcementEdit":"\u7F16\u8F91\u516C\u544A","yeaft.sessionStatus.vps":"VP","yeaft.sessionStatus.backgroundTasks":"\u540E\u53F0\u4EFB\u52A1","yeaft.sessionStatus.noLogPreview":"\u6682\u65E0\u65E5\u5FD7\u8F93\u51FA\u3002","yeaft.sessionStatus.task.subAgentStarted":"{name} \u5DF2\u542F\u52A8","yeaft.sessionStatus.task.subAgentStartedWithMission":"{name} \u5DF2\u542F\u52A8\uFF1A{mission}","yeaft.sessionStatus.task.subAgentStatus":"{name} \u72B6\u6001\uFF1A{status}","yeaft.sessionStatus.task.subAgentStatusUpdated":"{name} \u72B6\u6001\u5DF2\u66F4\u65B0","yeaft.sessionStatus.task.subAgentResult":"{name} \u7ED3\u679C\uFF1A{text}","yeaft.sessionStatus.task.subAgentProducedResult":"{name} \u5DF2\u4EA7\u751F\u7ED3\u679C","yeaft.sessionStatus.task.subAgentUsedTool":"{name} \u8C03\u7528\u4E86 {tool}","yeaft.sessionStatus.task.subAgentFinishedTool":"{name} \u5B8C\u6210\u4E86 {tool}","yeaft.sessionStatus.task.subAgentUsage":"{name} \u4F7F\u7528\u4E86 {tokens} tokens","yeaft.sessionStatus.task.subAgentEvent":"{name}\uFF1A{text}","yeaft.sessionStatus.task.subAgentUserPrompt":"\u4F60\uFF1A{text}","yeaft.sessionStatus.task.subAgentToolSummary":"\u5DF2\u5B8C\u6210 {count} \u6B21\u5DE5\u5177\u8C03\u7528","yeaft.sessionStatus.task.subAgentError":"{name} \u9519\u8BEF\uFF1A{error}","yeaft.sessionStatus.task.subAgentHitError":"{name} \u9047\u5230\u9519\u8BEF","yeaft.sessionStatus.task.subAgentNoReadableEvents":"\u6682\u65E0\u53EF\u8BFB\u7684 sub-agent \u6D3B\u52A8\u3002","yeaft.sessionStatus.task.promptPlaceholder":"\u7ED9\u8FD9\u4E2A sub-agent \u8FFD\u52A0\u60F3\u6CD5\u2026","yeaft.sessionStatus.task.promptSend":"\u53D1\u9001","yeaft.sessionStatus.task.promptSending":"\u53D1\u9001\u4E2D\u2026","yeaft.sessionStatus.task.promptFailed":"\u53D1\u9001\u5931\u8D25\u3002","yeaft.sessionStatus.task.title":"\u4EFB\u52A1","yeaft.sessionStatus.task.command":"\u547D\u4EE4","yeaft.sessionStatus.task.stop":"\u505C\u6B62\u4EFB\u52A1","yeaft.sessionStatus.task.stopping":"\u505C\u6B62\u4E2D\u2026","yeaft.sessionStatus.task.kind.subAgent":"sub-agent","yeaft.sessionStatus.task.kind.shell":"shell","yeaft.sessionStatus.show":"\u663E\u793A Session \u72B6\u6001","yeaft.sessionStatus.hide":"\u9690\u85CF Session \u72B6\u6001","yeaft.sessionStatus.close":"\u5173\u95ED Session \u72B6\u6001","yeaft.vpTimeline.empty":"\u672C Session \u8FD8\u6CA1\u6709 VP\u3002","yeaft.vpTimeline.resizeTitle":"\u62D6\u52A8\u8C03\u6574\u5BBD\u5EA6","yeaft.vpTimeline.status.idle":"\u7A7A\u95F2","yeaft.vpTimeline.status.typing":"\u8F93\u5165\u4E2D\u2026","yeaft.vpTimeline.status.thinking":"\u601D\u8003\u4E2D\u2026","yeaft.vpTimeline.status.retrying":"\u6B63\u5728\u91CD\u8BD5\u8BF7\u6C42\u2026","yeaft.vpTimeline.status.streaming":"\u751F\u6210\u4E2D","yeaft.vpTimeline.status.tool":"\u8C03\u7528\u5DE5\u5177\u4E2D\u2026","yeaft.vpTimeline.status.error":"\u51FA\u9519","yeaft.vpTimeline.status.offline":"\u79BB\u7EBF","yeaft.vpTimeline.abort":"\u4E2D\u6B62","yeaft.vpTimeline.edit":"\u7F16\u8F91 VP","yeaft.vpTimeline.mention":"\u70B9\u51FB @ \u8BE5 VP","yeaft.vpTimeline.expand":"\u5C55\u5F00\u4EFB\u52A1\u8BE6\u60C5","yeaft.toolStats.title":"\u5DE5\u5177\u4F7F\u7528\u7EDF\u8BA1","yeaft.toolStats.refresh":"\u5237\u65B0","yeaft.toolStats.close":"\u5173\u95ED","yeaft.toolStats.tabAll":"\u5168\u90E8\u5DE5\u5177","yeaft.toolStats.tabUnused":"\u672A\u4F7F\u7528","yeaft.toolStats.loading":"\u52A0\u8F7D\u4E2D\u2026","yeaft.toolStats.notLoaded":"\u6682\u65E0\u6570\u636E \u2014 \u70B9\u51FB\u5237\u65B0\u3002","yeaft.toolStats.empty":"\uFF08\u6682\u65E0\u5DE5\u5177\u8C03\u7528\u8BB0\u5F55\uFF09","yeaft.toolStats.noneUnused":"\uFF08\u6BCF\u4E2A\u5DF2\u6CE8\u518C\u5DE5\u5177\u90FD\u81F3\u5C11\u88AB\u8C03\u7528\u8FC7\u4E00\u6B21\uFF09","yeaft.toolStats.fetchedAt":"\u83B7\u53D6\u65F6\u95F4","yeaft.toolStats.col.name":"\u5DE5\u5177","yeaft.toolStats.col.calls":"\u8C03\u7528","yeaft.toolStats.col.errors":"\u9519\u8BEF","yeaft.toolStats.col.errRate":"\u9519\u8BEF\u7387","yeaft.toolStats.col.p50":"p50","yeaft.toolStats.col.p95":"p95","yeaft.toolStats.col.avg":"\u5E73\u5747","yeaft.toolStats.col.last":"\u6700\u8FD1","yeaft.toolStats.buttonLabel":"\u5DE5\u5177\u7EDF\u8BA1","workCenter.title":"\u5DE5\u4F5C\u4E2D\u5FC3","workCenter.subtitle":"\u7531\u5F53\u524D Agent \u6301\u7EED\u63A8\u8FDB\u7684\u6301\u4E45\u5DE5\u4F5C","workCenter.agent":"Agent","workCenter.selectAgent":"\u9009\u62E9 Agent","workCenter.noOnlineAgents":"\u6CA1\u6709\u5728\u7EBF Agent","workCenter.noAvailableAgents":"\u6CA1\u6709\u517C\u5BB9\u5DE5\u4F5C\u4E2D\u5FC3\u7684\u5728\u7EBF Agent","workCenter.checkingAgents":"\u6B63\u5728\u68C0\u67E5\u5DE5\u4F5C\u4E2D\u5FC3\u53EF\u7528\u72B6\u6001\u2026","workCenter.agentStatusLoadFailed":"\u65E0\u6CD5\u68C0\u67E5\u5DE5\u4F5C\u4E2D\u5FC3\u72B6\u6001\uFF0C\u8BF7\u91CD\u8BD5\u3002","workCenter.retryAgentStatus":"\u91CD\u8BD5\u72B6\u6001\u68C0\u67E5","workCenter.unavailableAgents":"\u5DE5\u4F5C\u4E2D\u5FC3\u5DF2\u914D\u7F6E\u4E3A\u542F\u7528\uFF0C\u4F46\u8FD0\u884C\u65F6\u5F53\u524D\u4E0D\u53EF\u7528\uFF1B\u8BF7\u68C0\u67E5\u6B64 Agent \u7684\u8BBE\u7F6E\u548C\u65E5\u5FD7\u3002","workCenter.disabledAgents":"\u5728\u7EBF Agent \u5C1A\u672A\u542F\u7528\u5DE5\u4F5C\u4E2D\u5FC3\u3002","workCenter.disabledAgentsMany":"{count} \u4E2A\u5728\u7EBF Agent \u5C1A\u672A\u542F\u7528\u5DE5\u4F5C\u4E2D\u5FC3\u3002","workCenter.openAgentSettings":"\u6253\u5F00 Agent \u8BBE\u7F6E","workCenter.openAgentSettingsUpgrade":"\u6253\u5F00 Agent \u8BBE\u7F6E\u5E76\u5347\u7EA7","workCenter.upgradeAgents":"\u5728\u7EBF Agent \u6682\u4E0D\u652F\u6301\u5DE5\u4F5C\u4E2D\u5FC3\u8BBE\u7F6E\u3002","workCenter.new":"\u65B0\u5EFA","workCenter.newWorkItem":"\u65B0\u5EFA\u5DE5\u4F5C\u9879","workCenter.workItem":"\u5DE5\u4F5C\u9879","workCenter.createFirst":"\u521B\u5EFA\u7B2C\u4E00\u4E2A\u5DE5\u4F5C\u9879","workCenter.backToChat":"\u8FD4\u56DE\u5BF9\u8BDD","workCenter.refresh":"\u5237\u65B0","workCenter.search":"\u641C\u7D22\u5DE5\u4F5C\u9879","workCenter.filter":"\u7B5B\u9009","workCenter.filterAttention":"\u9700\u8981\u5904\u7406","workCenter.filterActive":"\u6267\u884C\u4E2D","workCenter.filterAll":"\u5168\u90E8","workCenter.filterDone":"\u5DF2\u5B8C\u6210","workCenter.attentionItems":"\u9700\u8981\u5904\u7406","workCenter.board.active":"\u8FDB\u884C\u4E2D","workCenter.board.needsAttention":"\u9700\u8981\u5904\u7406","workCenter.board.closed":"\u5DF2\u5173\u95ED","workCenter.board.emptyLane":"\u6682\u65E0\u5DE5\u4F5C\u9879","workCenter.board.lanes":"\u5DE5\u4F5C\u9879\u5206\u680F","workCenter.filterVp":"\u6309 VP \u7B5B\u9009","workCenter.filterType":"\u6309\u7C7B\u578B\u7B5B\u9009","workCenter.filterUpdated":"\u6309\u66F4\u65B0\u65F6\u95F4\u7B5B\u9009","workCenter.allVps":"\u5168\u90E8 VP","workCenter.allTypes":"\u5168\u90E8\u7C7B\u578B","workCenter.anyTime":"\u4E0D\u9650\u65F6\u95F4","workCenter.lastDay":"\u6700\u8FD1 24 \u5C0F\u65F6","workCenter.lastWeek":"\u6700\u8FD1 7 \u5929","workCenter.deleteWorkItem":"\u5220\u9664 Work Item","workCenter.deleteConfirm":"\u6C38\u4E45\u5220\u9664\u8FD9\u4E2A Work Item\u3001\u6267\u884C\u5386\u53F2\u548C\u9644\u4EF6\uFF1F","workCenter.deleteRequiresStop":"\u8BF7\u5148\u505C\u6B62\u8FD9\u4E2A Work Item \u518D\u5220\u9664","workCenter.lastMonth":"\u6700\u8FD1 30 \u5929","workCenter.assignment.planned":"\u8BA1\u5212\u5206\u914D","workCenter.created":"\u521B\u5EFA\u4E8E","workCenter.files":"\u4E2A\u6587\u4EF6","workCenter.loadMore":"\u52A0\u8F7D\u66F4\u591A","workCenter.activeItems":"\u6267\u884C\u4E2D\u7684\u5DE5\u4F5C","workCenter.allItems":"\u5168\u90E8\u5DE5\u4F5C\u9879","workCenter.completedItems":"\u5DF2\u5B8C\u6210","workCenter.watcherActive":"Watcher \u8FD0\u884C\u4E2D","workCenter.loading":"\u6B63\u5728\u52A0\u8F7D\u5DE5\u4F5C\u9879\u2026","workCenter.noTimestamp":"\u65E0\u65F6\u95F4\u6233","workCenter.updated":"\u66F4\u65B0\u65F6\u95F4","workCenter.emptyTitle":"\u8FD8\u6CA1\u6709\u5DE5\u4F5C\u9879","workCenter.emptyBody":"\u5F53\u5DE5\u4F5C\u9700\u8981\u8DE8\u8D8A\u4E00\u6B21\u5BF9\u8BDD\u3001\u7B49\u5F85\u6216\u89D2\u8272\u63A5\u529B\u65F6\uFF0C\u628A\u5B83\u521B\u5EFA\u4E3A\u6301\u4E45\u5DE5\u4F5C\u9879\u3002","workCenter.noAttentionTitle":"\u5F53\u524D\u6CA1\u6709\u9700\u8981\u5904\u7406\u7684\u5DE5\u4F5C\u9879","workCenter.noAttentionBody":"\u7B49\u5F85\u4F60\u56DE\u7B54\u6216\u9700\u8981\u6062\u590D\u7684\u5DE5\u4F5C\u9879\u4F1A\u663E\u793A\u5728\u8FD9\u91CC\u3002","workCenter.noActiveTitle":"\u5F53\u524D\u6CA1\u6709\u6267\u884C\u4E2D\u7684\u5DE5\u4F5C\u9879","workCenter.noActiveBody":"\u8349\u7A3F\u3001\u5C31\u7EEA\u548C\u6267\u884C\u4E2D\u7684\u5DE5\u4F5C\u9879\u4F1A\u663E\u793A\u5728\u8FD9\u91CC\u3002","workCenter.noCompletedTitle":"\u8FD8\u6CA1\u6709\u5DF2\u5B8C\u6210\u7684\u5DE5\u4F5C\u9879","workCenter.noCompletedBody":"\u5B8C\u6210\u540E\u7684\u5DE5\u4F5C\u9879\u4F1A\u663E\u793A\u5728\u8FD9\u91CC\u3002","workCenter.noMatchesTitle":"\u6CA1\u6709\u5339\u914D\u7684\u5DE5\u4F5C\u9879","workCenter.noMatchesBody":"\u5C1D\u8BD5\u8C03\u6574\u641C\u7D22\u5185\u5BB9\u6216\u7B5B\u9009\u6761\u4EF6\u3002","workCenter.selectTitle":"\u5DE5\u4F5C\u9879\u8BE6\u60C5","workCenter.detailLoading":"\u6B63\u5728\u52A0\u8F7D\u5B8C\u6574\u8BE6\u60C5\u2026","workCenter.detailLoadFailed":"\u65E0\u6CD5\u52A0\u8F7D\u5B8C\u6574\u8BE6\u60C5","workCenter.start":"\u5F00\u59CB","workCenter.retry":"\u91CD\u8BD5","workCenter.cancel":"\u53D6\u6D88","workCenter.closeWorkItem":"\u5173\u95ED\u8BE6\u60C5","workCenter.cancelWorkItem":"\u505C\u6B62\u5DE5\u4F5C\u9879","workCenter.cancelWorkItemHint":"\u505C\u6B62\u8FD9\u4E2A\u5DE5\u4F5C\u9879\u53CA\u6240\u6709\u5C1A\u672A\u5B8C\u6210\u7684 Actions\u3002","workCenter.cancelConfirm":"\u505C\u6B62\u8FD9\u4E2A\u5DE5\u4F5C\u9879\u53CA\u5176\u5C1A\u672A\u5B8C\u6210\u7684 Actions\uFF1F","workCenter.stopWorkItem":"\u505C\u6B62\u5DE5\u4F5C\u9879","workCenter.resumeWorkItem":"\u6062\u590D\u5DE5\u4F5C\u9879","workCenter.resource.title":"\u8D44\u6E90\u9884\u7B97","workCenter.resource.requests":"\u8BF7\u6C42","workCenter.resource.chargedTokens":"Token \u9884\u7B97\u5360\u7528","workCenter.resource.details":"\u6D88\u8017\u660E\u7EC6\u4E0E\u9650\u989D","workCenter.resource.total":"\u603B\u8BA1 \xB7 \u5168\u751F\u547D\u5468\u671F","workCenter.resource.coordinator":"\u534F\u8C03\u5668","workCenter.resource.actions":"Actions","workCenter.resource.usage":"{requests} \u6B21\u8BF7\u6C42 \xB7 \u5360\u7528 {charged} token","workCenter.resource.tokens":"\u5DF2\u62A5\u544A {reported} \xB7 \u9884\u7559 / \u672A\u77E5\u5360\u7528 {reserved} token","workCenter.resource.unknown":"\u7528\u91CF\u672A\u77E5\uFF1A{unknown} \u6B21\u8BF7\u6C42 \xB7 \u5728\u9014\uFF1A{inflight}","workCenter.resource.accounting":"\u9884\u7B97\u5360\u7528\u5DF2\u542B\u9884\u7559\uFF0C\u8BF7\u52FF\u91CD\u590D\u76F8\u52A0\u3002\u5DF2\u62A5\u544A token \u662F\u5DF2\u77E5\u7528\u91CF\uFF0C\u4E0D\u4EE3\u8868\u5B8C\u6574\u8D26\u5355\u3002\u51C6\u5165\u57FA\u4E8E\u4F30\u7B97\uFF0C\u4E0D\u662F\u786C\u6027\u8D39\u7528\u4E0A\u9650\u3002","workCenter.resource.maxRequests":"\u7D2F\u8BA1\u8BF7\u6C42\u4E0A\u9650","workCenter.resource.maxTokens":"\u7D2F\u8BA1 token \u4E0A\u9650","workCenter.resource.maxRunRequests":"\u6BCF\u4E2A Run \u8BF7\u6C42\u4E0A\u9650","workCenter.resource.maxActionAttempts":"\u6BCF\u4E2A Action \u5C1D\u8BD5\u4E0A\u9650","workCenter.resource.maxCoordinatorFailures":"\u534F\u8C03\u5668\u5931\u8D25\u4E0A\u9650","workCenter.resource.attemptLimit":"Action \u5C1D\u8BD5\u8DE8\u4EE3\u7D2F\u8BA1\uFF0C\u540C\u65F6\u53D7\u5404 Action \u539F\u59CB\u4E0A\u9650\u4E0E\u663E\u5F0F\u8FFD\u52A0\u989D\u5EA6\u7EA6\u675F\u3002\u5DF2\u7528 / \u6709\u6548\u4E0A\u9650\uFF1A","workCenter.resource.attemptExtension":"\u8FFD\u52A0 Action \u5C1D\u8BD5\u989D\u5EA6\u4F1A\u6388\u6743\u6B64\u5DE5\u4F5C\u9879\u7684\u6240\u6709\u5F53\u524D\u53CA\u672A\u6765 Action \u589E\u52A0\u5C1D\u8BD5\u6B21\u6570\u3002","workCenter.resource.stopped":"\u6267\u884C\u5DF2\u88AB\u8D44\u6E90\u63A7\u5236\u505C\u6B62\u3002","workCenter.resource.stop.work_item_requests_exhausted":"\u5DF2\u505C\u6B62\uFF1A\u7D2F\u8BA1\u8BF7\u6C42\u9884\u7B97\u8017\u5C3D\u3002","workCenter.resource.stop.work_item_tokens_exhausted":"\u5DF2\u505C\u6B62\uFF1Atoken \u9884\u7B97\u4E0D\u8DB3\u4EE5\u51C6\u5165\u4E0B\u4E00\u6B21\u8BF7\u6C42\u3002","workCenter.resource.stop.run_requests_exhausted":"\u5DF2\u505C\u6B62\uFF1ARun \u8BF7\u6C42\u6570\u8FBE\u5230\u4E0A\u9650\u3002\u6062\u590D\u5C06\u542F\u52A8\u65B0\u7684 Run\u3002","workCenter.resource.stop.action_attempts_exhausted":"\u5DF2\u505C\u6B62\uFF1AAction \u5C1D\u8BD5\u6B21\u6570\u8FBE\u5230\u4E0A\u9650\u3002","workCenter.resource.stop.coordinator_failures_exhausted":"\u5DF2\u505C\u6B62\uFF1A\u534F\u8C03\u5668\u5931\u8D25\u6B21\u6570\u8FBE\u5230\u4E0A\u9650\u3002","workCenter.resource.offline":"Agent \u5DF2\u65AD\u5F00\u3002\u8BF7\u91CD\u65B0\u8FDE\u63A5\u5E76\u5237\u65B0\u540E\u518D\u4FEE\u6539\u8D44\u6E90\u9884\u7B97\u3002","workCenter.resource.stale":"\u8D44\u6E90\u72B6\u6001\u5DF2\u53D8\u5316\u6216\u5C1A\u672A\u786E\u8BA4\u3002\u8BF7\u5237\u65B0\u540E\u91CD\u65B0\u786E\u8BA4\uFF1B\u4E0D\u4F1A\u81EA\u52A8\u91CD\u8BD5\u4EFB\u4F55\u4FEE\u6539\u3002","workCenter.resource.refresh":"\u5237\u65B0\u8D44\u6E90\u72B6\u6001","workCenter.resource.reconfirm":"\u5DF2\u52A0\u8F7D\u6700\u65B0\u72B6\u6001\u3002\u8BF7\u68C0\u67E5\u9650\u989D\uFF0C\u9700\u8981\u65F6\u91CD\u65B0\u786E\u8BA4\u64CD\u4F5C\u3002","workCenter.resource.extend":"\u8FFD\u52A0\u9884\u7B97","workCenter.resource.confirmExtend":"\u786E\u8BA4\u8FFD\u52A0\u9884\u7B97","workCenter.resource.extendHelp":"\u8F93\u5165\u8981\u8FFD\u52A0\u7684\u6B63\u6574\u6570\u989D\u5EA6\uFF0C\u800C\u975E\u65B0\u7684\u603B\u4E0A\u9650\uFF1B\u4E0D\u4FEE\u6539\u7684\u5B57\u6BB5\u7559\u7A7A\u3002\u8FFD\u52A0\u4E0D\u4F1A\u6062\u590D\u6267\u884C\u6216\u6E05\u96F6\u7528\u91CF\u3002","workCenter.resource.current":"\u5F53\u524D\uFF1A{count}","workCenter.resource.invalid":"\u53EA\u80FD\u586B\u5199\u6B63\u5B89\u5168\u6574\u6570\uFF0C\u8FFD\u52A0\u540E\u7684\u4E0A\u9650\u4E5F\u5FC5\u987B\u662F\u5B89\u5168\u6574\u6570\u3002","workCenter.resource.extended":"\u9884\u7B97\u5DF2\u8FFD\u52A0\u3002\u672A\u6062\u590D\u6267\u884C\uFF1B\u51C6\u5907\u597D\u540E\u8BF7\u660E\u786E\u70B9\u51FB\u6062\u590D\u3002","workCenter.resource.resumed":"\u6062\u590D\u8BF7\u6C42\u5DF2\u63A5\u53D7\u3002","workCenter.resource.pending":"\u6B63\u5728\u66F4\u65B0\u8D44\u6E90\u72B6\u6001\u2026","workCenter.resource.close":"\u5173\u95ED\u9884\u7B97\u8868\u5355","workCenter.breadcrumbs":"Work Center \u5BFC\u822A","workCenter.actionNumber":"Action {number}","workCenter.actionBreadcrumb":"Action {number}\uFF1A{description}","workCenter.untitledAction":"\u672A\u547D\u540D Action","workCenter.workItems":"\u5DE5\u4F5C\u9879","workCenter.description":"\u9700\u6C42\u63CF\u8FF0","workCenter.goal":"\u76EE\u6807","workCenter.acceptanceCriteria":"\u9A8C\u6536\u6761\u4EF6","workCenter.goalProgress":"\u76EE\u6807\u8FDB\u5EA6","workCenter.criteriaProgress":"{completed} / {total} \u9879\u9A8C\u6536\u6761\u4EF6\u5DF2\u9A8C\u8BC1","workCenter.criteriaRemaining":"\u5269\u4F59 {count} \u9879","workCenter.criteriaOmitted":"\u6B64\u6709\u754C\u89C6\u56FE\u7701\u7565\u4E86 {count} \u9879\u6761\u4EF6\uFF0C\u603B\u6570\u4ECD\u5305\u542B\u8FD9\u4E9B\u6761\u4EF6\u3002","workCenter.criteriaVerified":"\u6240\u6709\u9A8C\u6536\u6761\u4EF6\u5DF2\u9A8C\u8BC1","workCenter.criteriaPending":"\u5C1A\u672A\u5B9A\u4E49\u9A8C\u6536\u6761\u4EF6","workCenter.goalStatus.passed":"\u5DF2\u9A8C\u8BC1","workCenter.goalStatus.failed":"\u672A\u901A\u8FC7","workCenter.goalStatus.unmet":"\u5F85\u9A8C\u8BC1","workCenter.goalBlockers":"\u963B\u585E\u539F\u56E0","workCenter.evidenceRuns":"\u8BC1\u636E Run","workCenter.deliveredResponse":"\u4EA4\u4ED8\u56DE\u590D","workCenter.responseEvidence":"\u56DE\u590D\u6765\u6E90\u4E0E\u8BC1\u636E","workCenter.noCriteria":"\u672A\u63D0\u4F9B\u9A8C\u6536\u6761\u4EF6","workCenter.failureReason":"\u5931\u8D25\u539F\u56E0","workCenter.workflow":"\u4EFB\u52A1\u6D41","workCenter.triageSummary":"Triage \u6458\u8981","workCenter.actionFlow":"Action \u6D41\u7A0B","workCenter.viewActions":"\u67E5\u770B Actions","workCenter.actionsPanel":"Actions","workCenter.closeActions":"\u5173\u95ED Actions","workCenter.actionCount":"{count} \u4E2A Action","workCenter.noActionSummary":"\u6682\u65E0\u6458\u8981","workCenter.actionProgress":"{completed} / {total} \u4E2A Action","workCenter.currentAction":"\u5F53\u524D Action","workCenter.expandActions":"\u5C55\u5F00 Action","workCenter.collapseActions":"\u6536\u8D77","workCenter.actionObjective":"\u8FD9\u6B21\u8981\u505A\u4EC0\u4E48","workCenter.actionApproach":"\u51C6\u5907\u600E\u4E48\u505A","workCenter.actionExpectedOutcome":"\u671F\u5F85\u7684\u7ED3\u679C","workCenter.dependencies":"\u6765\u6E90 Action","workCenter.actionResult":"\u6700\u65B0\u7ED3\u679C","workCenter.currentProgress":"\u5F53\u524D\u8FDB\u5EA6","workCenter.actionMessages":"\u6D88\u606F","workCenter.loops":"\u4E2A Loop","workCenter.tools":"\u6B21\u5DE5\u5177\u8C03\u7528","workCenter.noActionMessages":"\u8FD8\u6CA1\u6709\u6D88\u606F\u3002","workCenter.actionDetails":"Action \u8BE6\u60C5","workCenter.selectAction":"\u9009\u62E9\u4E00\u4E2A Action","workCenter.backToWorkItems":"\u5DE5\u4F5C\u9879","workCenter.backToActions":"\u8FD4\u56DE Actions","workCenter.you":"\u4F60","workCenter.noRequestDetails":"\u8FD9\u4E2A Action \u6682\u65F6\u6CA1\u6709\u53EF\u7528\u7684\u6267\u884C\u8BB0\u5F55\u3002","workCenter.loadingRequests":"\u6B63\u5728\u52A0\u8F7D\u6267\u884C\u8BB0\u5F55\u2026","workCenter.loadingRequestDetail":"\u6B63\u5728\u52A0\u8F7D\u5DE5\u5177\u8BC1\u636E\u2026","workCenter.requestDetailUnavailable":"\u5DE5\u5177\u8BC1\u636E\u6682\u4E0D\u53EF\u7528\uFF0C\u8BF7\u91CD\u8BD5\u3002","workCenter.noRequestLoops":"\u8FD9\u6B21\u6267\u884C\u6CA1\u6709\u4FDD\u7559\u4E0B\u53EF\u5C55\u793A\u7684 Loop\u3002","workCenter.requestDetailTruncated":"\u6267\u884C\u5185\u5BB9\u8F83\u5927\uFF1A{summarized} \u4E2A Loop \u663E\u793A\u6458\u8981\uFF0C\u53E6\u6709 {omitted} \u4E2A\u8F83\u65E9 Loop \u672A\u663E\u793A\u3002","workCenter.loopDetailTruncated":"\u8FD9\u4E2A Loop \u5185\u5BB9\u8F83\u5927\uFF0C\u5F53\u524D\u663E\u793A\u4FDD\u7559\u4E0B\u6765\u7684\u5DE5\u5177\u8BC1\u636E\u3002","workCenter.loadEarlierMessages":"\u52A0\u8F7D\u66F4\u65E9\u6D88\u606F","workCenter.loadingEarlierMessages":"\u6B63\u5728\u52A0\u8F7D\u66F4\u65E9\u6D88\u606F\u2026","workCenter.unknownModel":"\u672A\u77E5\u6A21\u578B","workCenter.loop":"Loop","workCenter.actionBrief":"\u4EFB\u52A1\u8BF4\u660E","workCenter.executionSummary":"\u6267\u884C\u6458\u8981","workCenter.toolParameters":"\u8C03\u7528\u53C2\u6570","workCenter.toolResult":"\u6267\u884C\u7ED3\u679C","workCenter.noToolCalls":"\u8FD9\u4E2A Loop \u6CA1\u6709\u5DE5\u5177\u8C03\u7528\u3002","workCenter.actionInputPlaceholder":"\u8865\u5145\u4E0A\u4E0B\u6587\u3001\u56DE\u7B54\u95EE\u9898\u6216\u8C03\u6574\u8FD9\u4E2A Action","workCenter.actionInputResumeHint":"\u4F60\u7684\u8F93\u5165\u4F1A\u5E26\u7740\u65B0\u589E\u4E0A\u4E0B\u6587\u7EE7\u7EED\u8FD9\u4E2A Action\u3002","workCenter.waitingQuestionTitle":"\u9700\u8981\u4F60\u7684\u56DE\u7B54","workCenter.actionInputRetryHint":"\u8865\u5145\u4FEE\u6B63\u8BF4\u660E\u6216\u6587\u4EF6\u540E\uFF0C\u4F7F\u7528\u65B0\u4E0A\u4E0B\u6587\u91CD\u65B0\u6267\u884C\u8FD9\u4E2A Action\u3002","workCenter.actionInputContinueHint":"\u8FD9\u91CC\u53EA\u76F4\u63A5\u5E72\u9884\u5F53\u524D Action\u3002","workCenter.actionFailedTitle":"\u8FD9\u4E2A Action \u4E3A\u4EC0\u4E48\u5931\u8D25","workCenter.actionClosedTitle":"\u8FD9\u4E2A Action \u4E3A\u4EC0\u4E48\u88AB\u5173\u95ED","workCenter.failedAt":"\u5931\u8D25\u65F6\u95F4","workCenter.closedAt":"\u5173\u95ED\u65F6\u95F4","workCenter.actionFailureRecovery":"\u5728\u5DE5\u4F5C\u9879\u8F93\u5165\u6846\u4E2D\u9009\u62E9\u6B64 Action\uFF0C\u518D\u53D1\u9001\u4FEE\u6B63\u8BF4\u660E\u3002","workCenter.sendInput":"\u53D1\u9001\u7ED9 Action","workCenter.sendingInput":"\u6B63\u5728\u53D1\u9001\u2026","workCenter.retryAction":"\u91CD\u8BD5 Action","workCenter.sendAndRetryAction":"\u53D1\u9001\u5E76\u91CD\u8BD5 Action","workCenter.coordinatorDecision.guide_actions":"\u5DF2\u66F4\u65B0 Action \u6307\u4EE4","workCenter.coordinatorDecision.replan":"\u5DF2\u66F4\u65B0\u76EE\u6807\u6216\u8BA1\u5212","workCenter.coordinatorDecision.request_human":"\u9700\u8981\u4EBA\u5DE5\u8865\u5145\u4FE1\u606F","workCenter.conversation":"\u5BF9\u8BDD","workCenter.contentPane":"\u5185\u5BB9","workCenter.workItemPanes":"\u5DE5\u4F5C\u9879\u9762\u677F","workCenter.coordinator":"\u534F\u8C03\u8005","workCenter.coordinatorTargetHint":"\u5DE5\u4F5C\u9879\u89C4\u5212\u4E0E\u534F\u8C03","workCenter.composerTarget":"\u6D88\u606F\u76EE\u6807","workCenter.targetUnavailable":"\u6240\u9009 Action \u5DF2\u4E0D\u53EF\u7528","workCenter.targetUnavailableHelp":"\u53D1\u9001\u524D\u8BF7\u9009\u62E9\u5176\u4ED6\u76EE\u6807\uFF1B\u7CFB\u7EDF\u6CA1\u6709\u91CD\u5B9A\u5411\u8FD9\u4EFD\u8349\u7A3F\u3002","workCenter.sendToCoordinatorInstead":"\u6539\u53D1\u7ED9 Coordinator","workCenter.sendToTarget":"\u53D1\u9001\u7ED9 {target}","workCenter.answerWithTarget":"\u5728\u5BF9\u8BDD\u8F93\u5165\u6846\u4E2D\u9009\u62E9\u76F8\u5173\u76EE\u6807\uFF0C\u7136\u540E\u56DE\u590D\u3002","workCenter.conversationThinking":"\u5904\u7406\u4E2D\u2026","workCenter.conversationReadOnly":"\u8FD9\u4E2A\u5DE5\u4F5C\u9879\u5DF2\u5173\u95ED\uFF0C\u5BF9\u8BDD\u8BB0\u5F55\u4ECD\u53EF\u67E5\u770B\u3002","workCenter.conversationPlaceholder":"\u7EE7\u7EED\u8BA8\u8BBA\u8FD9\u4E2A\u5DE5\u4F5C\u9879","workCenter.sendMessage":"\u53D1\u9001\u6D88\u606F","workCenter.messageSpeakerRole":"{name} \xB7 {role}","workCenter.originalRequest":"\u539F\u59CB\u9700\u6C42","workCenter.actionMessageScopeTitle":"\u7ED9\u8FD9\u4E2A Action \u53D1\u6D88\u606F","workCenter.actionMessageScope":"\u6D88\u606F\u53EA\u53D1\u9001\u7ED9\u5F53\u524D Action\u3002","workCenter.actionConversation":"\u5BF9\u8BDD","workCenter.actionConversationWith":"Action \u6267\u884C\u8005","workCenter.actionViews":"Action \u89C6\u56FE","workCenter.actionExecutor":"\u6267\u884C\u8005","workCenter.actionExecutorPending":"\u7B49\u5F85\u5206\u914D\u6267\u884C\u8005","workCenter.actionInformation":"Action \u4FE1\u606F","workCenter.messageExecutor":"\u7ED9 {name} \u53D1\u6D88\u606F","workCenter.actionChatPlaceholder":"\u5728\u5BF9\u8BDD\u8F93\u5165\u6846\u4E2D\u7ED9 {name} \u53D1\u6D88\u606F","workCenter.statusLabel":"\u72B6\u6001","workCenter.llmRequestsLabel":"LLM \u8BF7\u6C42","workCenter.loopsLabel":"Loops","workCenter.toolsLabel":"\u5DE5\u5177","workCenter.tokensLabel":"Tokens","workCenter.workItemMessagePlaceholder":"\u8865\u5145\u6574\u4E2A Work Item \u7684\u65B9\u5411\u6216\u7EA6\u675F","workCenter.sendWorkItemMessage":"\u53D1\u9001\u7ED9 Work Item","workCenter.fromSession":"\u4ECE\u5F53\u524D Session \u521B\u5EFA\u5DE5\u4F5C\u9879","workCenter.llmRequestCount":"{count} \u6B21 LLM \u8BF7\u6C42","workCenter.loopCount":"{count} \u6B21 Loop","workCenter.toolCount":"{count} \u4E2A\u5DE5\u5177","workCenter.tokenCount":"{count} tokens","workCenter.tokenBreakdown":"\u8F93\u5165 {input} / \u8F93\u51FA {output} / \u7F13\u5B58 {cache}","workCenter.guidance":"\u7ED9\u5F53\u524D Action \u8865\u5145\u63D0\u793A","workCenter.guidanceHint":"\u8865\u5145\u7EA6\u675F\uFF0C\u6216\u8C03\u6574\u5F53\u524D Action \u7684\u6267\u884C\u65B9\u5411","workCenter.guidanceRestartHint":"\u53D1\u9001\u540E\u4F1A\u4F7F\u7528\u65B0\u63D0\u793A\u91CD\u542F\u5F53\u524D Action\u3002","workCenter.sendGuidance":"\u53D1\u9001\u63D0\u793A","workCenter.reuseMemory":"\u4F7F\u7528\u76F8\u5173 Agent memory \u548C\u6B64\u9879\u76EE\u7684\u5DF2\u5B8C\u6210\u5DE5\u4F5C","workCenter.reuseMemoryHelp":"\u5305\u62EC\u53D7 scope \u7EA6\u675F\u7684 Agent memory\uFF0C\u4EE5\u53CA canonical \u9879\u76EE\u76EE\u5F55\u76F8\u540C\u7684\u5DF2\u5B8C\u6210 Work Item \u7ED3\u6784\u5316\u6458\u8981\u548C\u8BC1\u636E\uFF1B\u4E0D\u4F1A\u590D\u7528\u539F\u59CB\u5DE5\u5177\u8F93\u51FA\u3002","workCenter.resumeAnswer":"\u56DE\u7B54\u7B49\u5F85\u4E2D\u7684\u95EE\u9898","workCenter.resumeAnswerHint":"\u63D0\u4F9B\u7EE7\u7EED\u6267\u884C\u6240\u9700\u7684\u4FE1\u606F","workCenter.answerInActionDetail":"\u5728\u5BF9\u8BDD\u8F93\u5165\u6846\u4E2D\u5C06\u76EE\u6807\u8BBE\u4E3A\u5F53\u524D Action\uFF0C\u7136\u540E\u56DE\u590D\u3002","workCenter.selectPrompt":"\u9009\u62E9\u4E00\u4E2A\u5DE5\u4F5C\u9879\uFF0C\u67E5\u770B\u5B83\u7684\u6D41\u7A0B\u3002","workCenter.createHint":"\u63CF\u8FF0\u4F60\u9700\u8981\u4EC0\u4E48\uFF0CCoordinator \u4F1A\u6301\u7EED\u521B\u5EFA\u5F53\u524D\u5FC5\u8981\u7684 Actions\uFF0C\u76F4\u5230\u9A8C\u6536\u6761\u4EF6\u5F97\u5230\u9A8C\u8BC1\u3002","workCenter.requirement":"\u9700\u6C42","workCenter.requirementHint":"\u7528\u81EA\u7136\u8BED\u8A00\u63CF\u8FF0\u95EE\u9898\u3001\u671F\u671B\u7ED3\u679C\u548C\u5FC5\u8981\u7EA6\u675F","workCenter.requirementHelp":"Coordinator \u4F1A\u5B8C\u5584\u76EE\u6807\u4E0E\u9A8C\u6536\u6761\u4EF6\uFF0C\u5E76\u968F\u7740\u8BC1\u636E\u4EA7\u751F\u52A8\u6001\u521B\u5EFA Actions\u3002","workCenter.titleField":"\u6807\u9898","workCenter.titleHint":"\u7B80\u77ED\u3001\u660E\u786E\u5730\u63CF\u8FF0\u9884\u671F\u7ED3\u679C","workCenter.goalHint":"\u8BF4\u660E Agent \u5FC5\u987B\u4EA4\u4ED8\u7684\u6700\u7EC8\u7ED3\u679C","workCenter.criteriaHint":"\u6BCF\u884C\u4E00\u6761\u9A8C\u6536\u6761\u4EF6","workCenter.attachments":"\u9644\u4EF6","workCenter.outputs":"\u4EA7\u51FA","workCenter.deliveryTarget":"\u4EA4\u4ED8\u76EE\u6807","workCenter.deliveryTargetAsk":"\u4EA4\u4ED8\u524D\u8BE2\u95EE\u6211","workCenter.deliveryTargetResponse":"\u56DE\u590D","workCenter.deliveryTargetFiles":"\u5DE5\u4F5C\u76EE\u5F55\u4E2D\u7684\u6587\u4EF6","workCenter.deliveryTargetPr":"\u521B\u5EFA\u62C9\u53D6\u8BF7\u6C42","workCenter.deliveryTargetMerge":"\u5408\u5E76\u5DF2\u6279\u51C6\u7684\u62C9\u53D6\u8BF7\u6C42","workCenter.deliveryTargetHelp":"\u201C\u56DE\u590D\u201D\u4EA4\u4ED8\u6709\u8BC1\u636E\u652F\u6301\u7684\u7B54\u590D\uFF0C\u4E0D\u8981\u6C42\u4EE3\u7801\u4EA7\u7269\u3002\u4EE3\u7801\u7C7B\u4EA4\u4ED8\u4ECD\u987B\u9075\u5B88\u8BC4\u5BA1\u4E0E\u5408\u5E76\u7B56\u7565\u3002","workCenter.attachmentsHelp":"\u56FE\u7247\u3001PDF \u548C\u6587\u672C\u6587\u4EF6\u4F1A\u6301\u7EED\u7ED1\u5B9A\u5230\u6B64 Work Item\uFF0C\u5E76\u63D0\u4F9B\u7ED9\u6BCF\u4E2A Action\u3002","workCenter.attachmentsUnsupported":"\u6240\u9009 Agent \u4E0D\u652F\u6301 Work Item \u9644\u4EF6\u3002","workCenter.addAttachments":"\u6DFB\u52A0\u6587\u4EF6","workCenter.attachmentsUploading":"\u4E0A\u4F20\u4E2D\u2026","workCenter.attachmentsUploadFailed":"\u9644\u4EF6\u4E0A\u4F20\u5931\u8D25","workCenter.pendingEnvelopeLocked":"\u6709\u4E00\u6761\u672A\u786E\u8BA4\u8BF7\u6C42\u5DF2\u9501\u5B9A\u5230\u539F\u59CB\u8EAB\u4EFD\u3002","workCenter.replacePendingAttachments":"\u66FF\u6362\u9644\u4EF6","workCenter.discardPendingEnvelope":"\u653E\u5F03\u5F85\u786E\u8BA4\u8BF7\u6C42","workCenter.pendingEnvelopeChanged":"\u5F85\u786E\u8BA4\u8BF7\u6C42\u5DF2\u53D8\u5316\uFF0C\u8BF7\u91CD\u65B0\u6253\u5F00\u8BE5\u5DE5\u4F5C\u9879\u540E\u518D\u8BD5\u3002","workCenter.removeAttachment":"\u4ECE\u8349\u7A3F\u4E2D\u79FB\u9664","workCenter.previewAttachment":"\u6253\u5F00\u9644\u4EF6","workCenter.openAttachmentNamed":"\u6253\u5F00\u9644\u4EF6 {name}","workCenter.openingAttachment":"\u6B63\u5728\u6253\u5F00\u9644\u4EF6\u2026","workCenter.attachmentPreviewFailed":"\u65E0\u6CD5\u6253\u5F00\u9644\u4EF6\uFF0C\u8BF7\u91CD\u8BD5\u3002","workCenter.attachmentOpenBlocked":"\u6D4F\u89C8\u5668\u963B\u6B62\u4E86\u9644\u4EF6\u7A97\u53E3\uFF0C\u8BF7\u5141\u8BB8\u5F39\u51FA\u7A97\u53E3\u540E\u91CD\u8BD5\u3002","workCenter.execution":"\u6267\u884C\u65B9\u5F0F","workCenter.executionHint":"\u9009\u62E9\u5DE5\u4F5C\u9879\u5728\u54EA\u91CC\u6267\u884C\uFF0C\u4EE5\u53CA\u521B\u5EFA\u540E\u662F\u5426\u7ACB\u5373\u5F00\u59CB\u3002","workCenter.workDir":"\u5DE5\u4F5C\u76EE\u5F55","workCenter.workDirHint":"\u9009\u62E9\u4E00\u4E2A\u5DF2\u5B58\u5728\u7684\u9879\u76EE\u76EE\u5F55","workCenter.chooseFolder":"\u9009\u62E9\u6587\u4EF6\u5939","workCenter.workDirPickerHelp":"\u4ECE\u5F53\u524D Agent \u7684\u771F\u5B9E\u76EE\u5F55\u4E2D\u9009\u62E9\u5DF2\u5B58\u5728\u7684\u6587\u4EF6\u5939\u3002","workCenter.folderPickerHint":"\u9009\u62E9\u8FD9\u4E2A\u5DE5\u4F5C\u9879\u53EF\u4EE5\u8BFB\u53D6\u548C\u4FEE\u6539\u7684\u9879\u76EE\u76EE\u5F55\u3002","workCenter.folderPickerSelectionHint":"\u53CC\u51FB\u8FDB\u5165\u76EE\u5F55\uFF0C\u6216\u9009\u4E2D\u76EE\u5F55\u540E\u786E\u8BA4\u3002","workCenter.startImmediately":"\u7ACB\u5373\u5F00\u59CB","workCenter.startImmediatelyHint":"\u5173\u95ED\u540E\u5C06\u521B\u5EFA\u4E3A\u8349\u7A3F\uFF0C\u786E\u8BA4\u65E0\u8BEF\u540E\u518D\u5F00\u59CB\u3002","workCenter.creating":"\u521B\u5EFA\u4E2D\u2026","workCenter.create":"\u521B\u5EFA","workCenter.status.draft":"\u8349\u7A3F","workCenter.status.ready":"\u5F85\u6267\u884C","workCenter.status.running":"\u6267\u884C\u4E2D","workCenter.status.waiting":"\u7B49\u5F85\u4E2D","workCenter.status.needs_attention":"\u9700\u8981\u5904\u7406","workCenter.status.done":"\u5DF2\u5B8C\u6210","workCenter.status.cancelled":"\u5DF2\u53D6\u6D88","workCenter.status.completed":"\u5DF2\u5B8C\u6210","workCenter.status.failed":"\u5931\u8D25","workCenter.status.closed":"\u5DF2\u5173\u95ED","workCenter.status.superseded":"\u5DF2\u66FF\u4EE3","workCenter.action.triage":"\u5206\u6790","workCenter.action.implement":"\u5B9E\u73B0","workCenter.action.review":"\u8BC4\u5BA1","workCenter.action.integrate":"\u96C6\u6210","workCenter.action.deliver":"\u4EA4\u4ED8","workCenter.action.test":"\u6D4B\u8BD5","workCenter.action.research":"\u7814\u7A76","workCenter.action.design":"\u8BBE\u8BA1","workCenter.action.diagnose":"\u8BCA\u65AD","workCenter.action.migrate":"\u8FC1\u79FB","workCenter.action.document":"\u6587\u6863","workCenter.action.operate":"\u8FD0\u7EF4","workCenter.action.write":"\u5199\u4F5C","workCenter.action.create_vp":"\u521B\u5EFA VP","workCenter.action.custom":"\u81EA\u5B9A\u4E49","workCenter.assignment.auto":"\u4F7F\u7528\u4EFB\u52A1\u6D41\u7B56\u7565","workCenter.model.inherit":"\u4F7F\u7528\u4EFB\u52A1\u6D41\u6A21\u578B","workCenter.model.defaultProvider":"\u9ED8\u8BA4 Provider","workCenter.planPreview":"\u6267\u884C\u8BA1\u5212","workCenter.planPreviewHelp":"\u6839\u636E\u5F53\u524D Agent \u7684 VP \u6C60\u548C\u6A21\u578B\u8BBE\u7F6E\u5B9E\u65F6\u89E3\u6790\u3002","workCenter.settings.title":"\u5DE5\u4F5C\u4E2D\u5FC3\u8BBE\u7F6E","workCenter.settings.subtitle":"\u914D\u7F6E Coordinator\uFF0C\u4EE5\u53CA AI \u52A8\u6001\u89C4\u5212\u4F7F\u7528\u7684 Action \u63D0\u793A\u8BCD\u3001\u6A21\u578B\u548C effort\u3002","workCenter.settings.workflow":"\u4EFB\u52A1\u6D41","workCenter.settings.workflowHelp":"Coordinator \u4F1A\u9488\u5BF9\u4EFB\u52A1\u52A8\u6001\u9009\u62E9 Action \u548C\u6267\u884C\u8005\u3002","workCenter.settings.aiWorkflowHelp":"Coordinator \u53EA\u521B\u5EFA\u5F53\u524D\u5FC5\u8981\u7684\u4EFB\u52A1\u4E13\u5C5E Action\u3002\u5185\u7F6E Action \u7B56\u7565\u662F\u53EF\u590D\u7528\u6A21\u677F\uFF1B\u9700\u8981\u65F6 Coordinator \u53EF\u4EE5\u521B\u5EFA\u7CBE\u786E\u7684\u9886\u57DF\u7C7B\u578B\u3002","workCenter.settings.globalInstructions":"Agent \u5168\u5C40\u6307\u4EE4","workCenter.settings.globalInstructionsHint":"\u4F8B\u5982\uFF1A\u9075\u5FAA\u4ED3\u5E93\u53D1\u5E03\u6D41\u7A0B\u3001\u5FC5\u987B\u72EC\u7ACB\u8BC4\u5BA1\uFF0C\u672A\u7ECF\u660E\u786E\u6279\u51C6\u4E0D\u5F97\u521B\u5EFA\u90E8\u7F72 tag\u3002","workCenter.settings.globalInstructionsHelp":"\u4FDD\u5B58\u5728 Agent \u7EA7\uFF0C\u5E76\u51BB\u7ED3\u8FDB\u6BCF\u4E2A\u65B0 Work Item\uFF1B\u5BF9 triage \u548C\u6240\u6709\u751F\u6210\u7684 Action \u751F\u6548\uFF0C\u4F18\u5148\u7EA7\u4F4E\u4E8E Work Item \u5951\u7EA6\u53CA\u7CFB\u7EDF/\u5DE5\u5177\u5B89\u5168\u89C4\u5219\u3002\u5DF2\u6709 Work Item \u4FDD\u7559\u539F\u5FEB\u7167\u3002","workCenter.settings.actionPolicies":"\u5185\u7F6E Action \u7B56\u7565","workCenter.settings.actionPoliciesHelp":"\u8FD9\u4E9B\u662F\u53EF\u590D\u7528\u7684\u6267\u884C\u57FA\u7EBF\uFF0C\u4E0D\u662F\u56FA\u5B9A\u5DE5\u4F5C\u6D41\u3002\u672A\u77E5\u7684\u9886\u57DF Action \u7C7B\u578B\u4F1A\u4F7F\u7528\u201C\u81EA\u5B9A\u4E49\u201D\u7B56\u7565\uFF0C\u5E76\u4FDD\u7559 triage \u751F\u6210\u7684\u7C7B\u578B\u548C\u4EFB\u52A1\u76EE\u6807\u3002","workCenter.settings.dynamicInstructionHelp":"AI \u4F1A\u52A0\u5165 Work Item \u5951\u7EA6\u3001\u5168\u5C40\u6307\u4EE4\u3001\u524D\u5E8F Action \u4E0A\u4E0B\u6587\u3001memory \u548C\u4EFB\u52A1\u4E13\u5C5E\u76EE\u6807\uFF1B\u8FD9\u91CC\u5B9A\u4E49\u8BE5 Action \u7C7B\u578B\u7684\u53EF\u590D\u7528\u884C\u4E3A\u3002","workCenter.settings.models":"\u6A21\u578B","workCenter.settings.modelsHelp":"Provider \u548C\u51ED\u8BC1\u4ECD\u7531 Agent LLM \u8BBE\u7F6E\u7BA1\u7406\uFF1B\u5DE5\u4F5C\u4E2D\u5FC3\u53EA\u9009\u62E9\u53EF\u7528\u6A21\u578B\u3002","workCenter.settings.dynamicModelsHelp":"Coordinator \u4E0E\u5B9E\u9645\u6267\u884C Action \u7684\u6A21\u578B\u53EF\u4EE5\u5206\u522B\u914D\u7F6E\u3002","workCenter.settings.coordinatorModel":"Coordinator","workCenter.settings.coordinatorModelHelp":"\u7528\u4E8E Work Item \u5BF9\u8BDD\u3001\u4FEE\u6539\u76EE\u6807\u548C\u91CD\u65B0\u89C4\u5212\uFF1B\u4E0D\u4F1A\u6267\u884C\u9879\u76EE\u5DE5\u5177\u3002","workCenter.settings.allActions":"\u6240\u6709 Action \u7684\u515C\u5E95\u7B56\u7565","workCenter.settings.maxConcurrentActions":"\u6700\u5927\u5E76\u53D1 Action \u6570","workCenter.settings.maxConcurrentActionsHelp":"\u9ED8\u8BA4 3\u3002\u975E Git\u3001\u810F\u5DE5\u4F5C\u533A\u3001\u5171\u4EAB\u526F\u4F5C\u7528\u548C\u96C6\u6210 Action \u4ECD\u4F1A\u4E32\u884C\u6267\u884C\u3002","workCenter.workItemType":"\u7C7B\u578B","workCenter.typeAuto":"Auto \u2014 \u7531 LLM \u63A8\u65AD","workCenter.typeHelp":"\u53EF\u9009\u62E9\u4EFB\u52A1\u7C7B\u522B\uFF0C\u4E5F\u53EF\u8BA9 AI \u81EA\u52A8\u63A8\u65AD\uFF1B\u5177\u4F53 Actions \u59CB\u7EC8\u7531 AI \u89C4\u5212\u3002","workCenter.planning":"\u89C4\u5212\u4E2D","workCenter.aiPlan":"Coordinator \u9A71\u52A8\u6267\u884C","workCenter.aiPlanHelp":"Coordinator \u4F1A\u4F9D\u636E\u5F53\u524D\u8BC1\u636E\u9009\u62E9\u4E0B\u4E00\u6279 Action \u548C\u6267\u884C\u8005\uFF0C\u4E0D\u518D\u9884\u5148\u751F\u6210\u5DE5\u4F5C\u6D41\u56FE\uFF1B\u6A21\u578B\u4E0E effort \u7531 Work Center \u8BBE\u7F6E\u63A7\u5236\u3002","workCenter.settings.manageProviders":"\u7BA1\u7406 Agent \u6A21\u578B","workCenter.settings.assignment":"VP \u9009\u62E9","workCenter.settings.assignment.auto":"\u4ECE\u5168\u90E8 VP \u81EA\u52A8\u9009\u62E9","workCenter.settings.assignment.pool":"\u5019\u9009\u6C60","workCenter.settings.assignment.fixed":"\u56FA\u5B9A VP","workCenter.settings.capability":"\u6240\u9700\u80FD\u529B","workCenter.settings.vp":"Virtual Person","workCenter.settings.poolMembers":"\u5019\u9009 VP","workCenter.settings.modelPolicy":"\u6A21\u578B\u7B56\u7565","workCenter.settings.model.inherit":"\u7EE7\u627F VP \u504F\u597D","workCenter.settings.model.primary":"Agent \u4E3B\u6A21\u578B","workCenter.settings.model.fast":"Agent \u5FEB\u6A21\u578B","workCenter.settings.model.specific":"\u6307\u5B9A\u6A21\u578B","workCenter.settings.model":"\u6A21\u578B","workCenter.settings.effort":"\u63A8\u7406\u5F3A\u5EA6","workCenter.settings.effortDefault":"\u6A21\u578B\u9ED8\u8BA4\u503C","workCenter.settings.effortHelp":"\u8986\u76D6\u6240\u9009\u6A21\u578B\u7684\u9ED8\u8BA4\u63A8\u7406\u5F3A\u5EA6\uFF0C\u5E76\u7528\u4E8E\u6240\u6709 Work Center Action\u3002","workCenter.settings.effortChooseModelHelp":"\u9009\u62E9 Agent \u4E3B\u6A21\u578B\u3001\u5FEB\u6A21\u578B\u6216\u6307\u5B9A\u6A21\u578B\u540E\u53EF\u914D\u7F6E\u63A8\u7406\u5F3A\u5EA6\uFF1B\u7EE7\u627F VP \u504F\u597D\u65F6\u4F7F\u7528\u5404 VP \u6A21\u578B\u7684\u9ED8\u8BA4\u503C\u3002","workCenter.settings.effortUnsupportedHelp":"\u6240\u9009\u6A21\u578B\u4E0D\u63D0\u4F9B\u53EF\u914D\u7F6E\u7684\u63A8\u7406\u5F3A\u5EA6\uFF0C\u56E0\u6B64\u4F7F\u7528\u6A21\u578B\u9ED8\u8BA4\u503C\u3002","workCenter.settings.saving":"\u4FDD\u5B58\u4E2D\u2026","workCenter.settings.reload":"\u91CD\u65B0\u52A0\u8F7D\u8BBE\u7F6E","workCenter.settings.conflict":"\u8BBE\u7F6E\u5DF2\u5728\u5176\u4ED6\u4F4D\u7F6E\u66F4\u65B0\uFF0C\u8BF7\u91CD\u65B0\u52A0\u8F7D\u540E\u518D\u4FDD\u5B58\u3002","workCenter.settings.upgradeRequired":"\u5F53\u524D Agent \u7248\u672C\u65E0\u6CD5\u4FDD\u5B58\u5DE5\u4F5C\u4E2D\u5FC3\u8BBE\u7F6E\u3002\u8FD9\u91CC\u4EE5\u53EA\u8BFB\u65B9\u5F0F\u663E\u793A\u5F53\u524D\u503C\uFF1B\u5347\u7EA7 Agent \u540E\u5373\u53EF\u7F16\u8F91\u5E76\u4FDD\u5B58\u3002","workCenter.settings.saveNotConfirmed":"Agent \u672A\u786E\u8BA4\u672C\u6B21\u63D0\u4EA4\u7684\u63D0\u793A\u8BCD\u548C\u6A21\u578B\u7B56\u7565\u3002\u8BBE\u7F6E\u7A97\u53E3\u4E0D\u4F1A\u5173\u95ED\uFF1B\u8BF7\u91CD\u65B0\u52A0\u8F7D\u6216\u5347\u7EA7 Agent \u540E\u518D\u8BD5\u3002","workCenter.settings.addWorkflow":"\u590D\u5236\u4EFB\u52A1\u6D41","workCenter.settings.removeWorkflow":"\u5220\u9664","workCenter.settings.newWorkflow":"\u4EFB\u52A1\u6D41 {index}","workCenter.settings.workflowName":"\u4EFB\u52A1\u6D41\u540D\u79F0","workCenter.settings.newStage":"\u65B0\u9636\u6BB5","workCenter.settings.addStage":"\u6DFB\u52A0\u9636\u6BB5","workCenter.settings.removeStage":"\u5220\u9664\u9636\u6BB5","workCenter.settings.moveUp":"\u4E0A\u79FB\u9636\u6BB5","workCenter.settings.moveDown":"\u4E0B\u79FB\u9636\u6BB5","workCenter.settings.stageType":"\u9636\u6BB5\u7C7B\u578B","workCenter.settings.reviewReturnStage":"\u8981\u6C42\u4FEE\u6539\u65F6\u9000\u56DE\u9636\u6BB5","workCenter.settings.instruction":"\u9636\u6BB5 Prompt","workCenter.settings.instructionHint":"\u5B9A\u4E49\u8FD9\u4E2A\u9636\u6BB5\u5177\u4F53\u8981\u505A\u4EC0\u4E48\u3002","workCenter.settings.instructionHelp":"\u8FD0\u884C\u65F6\u4F1A\u81EA\u52A8\u52A0\u5165 Work Item \u7684\u76EE\u6807\u3001\u9A8C\u6536\u6807\u51C6\u548C\u53EF\u590D\u7528\u4E0A\u4E0B\u6587\u3002","workCenter.settings.instructionReset":"\u6062\u590D\u9ED8\u8BA4\u503C"}});var qg,Vg=B(()=>{Xl();Zl();qg={...Eg,...$g,"quickSend.composer.label":"Quick send","quickSend.composer.send":"Quick send {number}: {name}","common.loading":"Loading...","common.confirm":"OK","common.apply":"Apply","common.cancel":"Cancel","common.delete":"Delete","common.copy":"Copy","common.copied":"Copied","common.close":"Close","common.refresh":"Refresh","common.open":"Open","common.save":"Save","common.saving":"Saving...","common.search":"Search","common.back":"Back","common.noSubdirectories":"No subdirectories","common.drives":"Drives","common.rootDir":"Root","common.comma":", ","common.select":"Select","common.retry":"Retry","mermaid.export":"Export","mermaid.exportMd":"Export MD","mermaid.exportPng":"Export PNG","mermaid.exportJpg":"Export JPG","login.subtitle":"Yeaft Web Code Agent","login.username":"Username","login.password":"Password","login.login":"Login","login.loggingIn":"Logging in...","login.enterUsername":"Please enter your username","login.enterPassword":"Please enter your password","login.noAccount":"Don't have an account?","login.registerWithCode":"Register","login.or":"or","login.usePassword":"Sign in with username & password","login.useSso":"Back to single sign-on","login.noProviders":"No third-party sign-in providers are enabled.","login.microsoft":"Sign in with Microsoft","login.github":"Sign in with GitHub","login.google":"Sign in with Google","login.wechat":"Sign in with WeChat","login.alipay":"Sign in with Alipay","login.wechat.mobileUnsupported":"Sign in with WeChat is only available on PC. Please scan the QR code from a desktop browser.","login.alipay.mobileWaiting":"Waiting for you to confirm in the Alipay app\u2026 Once you finish, return to this page and you will be signed in automatically.","login.alipay.relaunch":"Open Alipay again","login.qr.title":"Scan to sign in","login.qr.titleAlipay":"Sign in with Alipay","login.qr.titleWechat":"Sign in with WeChat","login.qr.hint":"Scan the QR code with your phone to authorize.","login.error.enterUsername":"Please enter your username","login.error.enterPassword":"Please enter your password","login.error.enter6Digit":"Please enter a 6-digit code","login.error.enterInviteCode":"Please enter the invite code","login.error.usernameMinLen":"Username must be at least 2 characters","login.error.passwordMinLen":"Password must be at least 6 characters","login.error.passwordMismatch":"Passwords do not match","login.error.enterVerifyCode":"Please enter the verification code","login.error.loginFailed":"Login failed","login.forgot.link":"Forgot password?","login.forgot.title":"Reset your password","login.forgot.emailHint":"Enter the email address on your account. We will send a 6-digit reset code.","login.forgot.sendCode":"Send Reset Code","login.forgot.sending":"Sending...","login.forgot.codeSent":"If the email is on file, a 6-digit reset code has been sent. Enter it below along with your new password.","login.forgot.resetBtn":"Reset Password","login.forgot.resetting":"Resetting...","login.forgot.success":"Password reset. You can now sign in with your new password.","login.forgot.emailInvalid":"Please enter a valid email","login.register.title":"New User Registration","login.register.inviteCode":"Invite Code","login.register.username":"Username","login.register.password":"Password (min 6 characters)","login.register.confirmPassword":"Confirm Password","login.register.email":"Email (optional)","login.register.submit":"Register","login.register.submitting":"Registering...","login.register.back":"Back to Login","login.register.success":"Registration successful, please login","login.register.enterCode":"Please enter the invite code","login.register.usernameMin":"Username must be at least 2 characters","login.register.passwordMin":"Password must be at least 6 characters","login.register.passwordMismatch":"Passwords do not match","login.totp.setupTitle":"Set Up Two-Factor Authentication","login.totp.setupHint":"Scan the QR code below with Microsoft Authenticator or Google Authenticator","login.totp.manualKey":"Or enter the key manually:","login.totp.enterCode":"Enter 6-digit code","login.totp.complete":"Complete Setup","login.totp.verifying":"Verifying...","login.totp.verify":"Verify","login.totp.prompt":"Enter the code from your Authenticator app","login.totp.invalidCode":"Please enter a 6-digit code","login.email.codeSent":"Verification code sent to {email}","login.email.enterCode":"Enter verification code","login.email.verify":"Verify","login.email.verifying":"Verifying...","login.email.enterCodeError":"Please enter the verification code","chat.agent.select":"Select Agent","chat.agent.manage":"Manage Agents","chat.agent.count":"{count} agents","chat.agent.none":"No Agents","chat.agent.restarting":"Restarting","agentSettings.open":"Agent settings","agentSettings.manage":"Manage","agentSettings.eyebrow":"Local runtime","agentSettings.title":"Agent settings","agentSettings.description":"Inspect and configure each connected Agent without mixing runtime controls into account settings.","agentSettings.agentList":"Agent","agentSettings.categories":"Agent setting categories","agentSettings.categories.operations":"Operations","agentSettings.categories.trace":"Trace","agentSettings.categories.llm":"LLM configuration","agentSettings.selectedAgent":"Selected Agent","agentSettings.online":"Online","agentSettings.offline":"Offline","agentSettings.empty":"No Agents are available.","agentSettings.runtime.title":"Runtime","agentSettings.runtime.description":"Identity, workspace, and local background processing.","agentSettings.runtime.version":"Version","agentSettings.runtime.updateAvailable":"Update available: v{version}","agentSettings.runtime.updateUnknown":"Update status unavailable","agentSettings.runtime.workDir":"Working directory","agentSettings.workCenter.title":"Work Center","agentSettings.workCenter.enabled":"Enabled","agentSettings.workCenter.disabled":"Disabled","agentSettings.workCenter.runtimeUnavailable":"Startup failed","agentSettings.workCenter.runtimeUnavailableMessage":"Work Center is configured on, but its runtime did not start. Review the Agent logs and try again.","agentSettings.workCenter.runtimeUnavailableHint":"Configured on, but the Work Center runtime is currently unavailable.","agentSettings.workCenter.enabledHint":"Persistent work is available on this Agent. New Sessions can also create Work Items.","agentSettings.workCenter.disabledHint":"Enable persistent Work Items and background execution on this Agent.","agentSettings.workCenter.environmentManaged":"Managed by YEAFT_WORK_CENTER_ENABLED and cannot be changed here.","agentSettings.workCenter.upgradeRequired":"Upgrade this Agent to manage Work Center availability.","agentSettings.workCenter.unsupported":"Upgrade required","agentSettings.workCenter.loadFailed":"Failed to load Work Center status.","agentSettings.workCenter.loadFailedStatus":"Load failed","agentSettings.workCenter.saveFailed":"Failed to update Work Center.","agentSettings.telemetry.title":"Diagnostics","agentSettings.telemetry.saved":"Diagnostics settings saved.","agentSettings.telemetry.loadFailed":"Failed to load diagnostics settings.","agentSettings.telemetry.saveFailed":"Failed to save diagnostics settings.","agentSettings.maintenance.title":"Maintenance","agentSettings.maintenance.description":"These operations interrupt work running on the selected Agent.","agentSettings.maintenance.upgradeFailed":"Agent upgrade failed.","chat.agent.dream":"Dream","chat.agent.dreamHint":"Enable automatic Dream memory processing","chat.agent.restart":"Restart","chat.agent.restartConfirm":`Are you sure you want to restart Agent "{name}"?
@@ -305,7 +305,7 @@ They will restart after upgrading. {skipped} other Agent(s) will be skipped beca
305
305
  </template>
306
306
  </div>
307
307
  </div>
308
- `,setup(){let e=Ge(),t=Vue.inject("t"),s=Vue.inject("locale"),n=Vue.ref(""),r=Vue.ref(""),i=Vue.ref(""),o=Vue.ref(""),a=Vue.ref(""),l=Vue.ref(null),c=Vue.ref(null),d=Vue.ref(null),u=Vue.ref(null),g=Vue.ref(null),p=Vue.ref(null),f=Vue.ref(""),m=Vue.ref(localStorage.getItem("loginMode")==="credentials"?"credentials":"oauth");Vue.watch(m,ue=>localStorage.setItem("loginMode",ue));let v=Vue.ref(""),y=Vue.ref(""),h=Vue.ref(""),k=Vue.ref(""),S=Vue.ref(""),b=Vue.ref(!1),w=Vue.ref(""),P=Vue.ref(""),x=Vue.ref(""),Y=Vue.ref(""),L=Vue.ref(""),U=Vue.ref(""),E=Vue.ref(!1),oe=Vue.ref(!1),q=()=>{a.value="",e.error=null,w.value="email",P.value="",Y.value="",L.value="",U.value="",x.value="",oe.value=!1},I=()=>{w.value="",x.value="",oe.value=!1},T=async()=>{if(a.value="",!P.value||!/.+@.+\..+/.test(P.value)){a.value=t("login.forgot.emailInvalid");return}E.value=!0;try{let ue=await e.requestPasswordReset(P.value.trim());if(!ue)return;x.value=ue,w.value="verify"}finally{E.value=!1}},R=async()=>{if(a.value="",!Y.value){a.value=t("login.error.enterVerifyCode");return}if(!L.value||L.value.length<6){a.value=t("login.error.passwordMinLen");return}if(L.value!==U.value){a.value=t("login.error.passwordMismatch");return}E.value=!0;try{await e.verifyPasswordReset(x.value,Y.value,L.value)&&(oe.value=!0,setTimeout(()=>{I(),m.value="credentials"},1500))}finally{E.value=!1}},M={alipay:'<svg viewBox="0 0 32 32" width="22" height="22" aria-hidden="true"><rect width="32" height="32" rx="6" fill="#1677FF"/><path fill="#fff" d="M25 18.6c-1.5-.5-3-1-4.6-1.7.4-.8.8-1.6 1.1-2.5h-2.9v-1h3.4v-.5h-3.4v-1.6h-1.4c-.3 0-.3.3-.3.3v1.3h-3.6v.5h3.6v1H11v.5h5.7c-.2.6-.4 1.2-.7 1.7-1.7-.5-3.4-.8-4.7-.8-2.2 0-3.7 1-3.8 2.5-.1 1.4.9 3 3.4 3 1.8 0 3.4-.9 4.7-2.5 2.2 1 4.2 2 6.6 2.9.3-.4.5-.8.7-1.2.2-.4.1-.9-.1-1.3zM11 19.7c-1.8 0-2.3-1.3-2.1-2 .1-.4.6-.9 1.4-1.1.4-.1 1.4-.1 2.4.2.9.2 1.8.5 2.7.8-.7 1.4-2.1 2.1-4.4 2.1z"/></svg>',microsoft:'<svg viewBox="0 0 21 21" width="20" height="20" aria-hidden="true"><rect x="1" y="1" width="9" height="9" fill="#f25022"/><rect x="1" y="11" width="9" height="9" fill="#00a4ef"/><rect x="11" y="1" width="9" height="9" fill="#7fba00"/><rect x="11" y="11" width="9" height="9" fill="#ffb900"/></svg>',github:'<svg viewBox="0 0 24 24" width="20" height="20" aria-hidden="true"><path fill="currentColor" d="M12 .3a12 12 0 0 0-3.8 23.4c.6.1.8-.3.8-.6v-2c-3.3.7-4-1.6-4-1.6-.5-1.4-1.3-1.7-1.3-1.7-1.1-.7.1-.7.1-.7 1.2.1 1.8 1.2 1.8 1.2 1.1 1.8 2.8 1.3 3.4 1 .1-.8.4-1.3.8-1.6-2.7-.3-5.5-1.3-5.5-6 0-1.3.5-2.3 1.2-3.2-.1-.3-.5-1.5.1-3.2 0 0 1-.3 3.3 1.2A11.5 11.5 0 0 1 12 5.8c1 0 2 .1 3 .4 2.3-1.5 3.3-1.2 3.3-1.2.6 1.7.2 2.9.1 3.2.7.9 1.2 1.9 1.2 3.2 0 4.6-2.8 5.7-5.5 6 .4.4.8 1.1.8 2.2v3.3c0 .3.2.7.8.6A12 12 0 0 0 12 .3"/></svg>',google:'<svg viewBox="0 0 24 24" width="20" height="20" aria-hidden="true"><path fill="#4285F4" d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"/><path fill="#34A853" d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84A11 11 0 0 0 12 23z"/><path fill="#FBBC05" d="M5.84 14.1A6.6 6.6 0 0 1 5.5 12c0-.73.13-1.44.34-2.1V7.07H2.18A11 11 0 0 0 1 12c0 1.77.42 3.45 1.18 4.93l3.66-2.83z"/><path fill="#EA4335" d="M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1A11 11 0 0 0 2.18 7.07l3.66 2.83C6.71 7.31 9.14 5.38 12 5.38z"/></svg>',wechat:'<svg viewBox="0 0 24 24" width="20" height="20" aria-hidden="true"><path fill="#07C160" d="M9.5 4C5.36 4 2 6.91 2 10.5c0 2.07 1.13 3.91 2.86 5.09L4 18l2.7-1.41c.85.22 1.76.34 2.7.34h.51c-.13-.42-.21-.86-.21-1.32 0-3 2.91-5.43 6.5-5.43.32 0 .64.02.95.06C16.63 7.32 13.4 4 9.5 4zM7 8.5a1 1 0 110 2 1 1 0 010-2zm5 0a1 1 0 110 2 1 1 0 010-2zm4.21 3.66c-3.04 0-5.5 1.92-5.5 4.29 0 1.39.91 2.65 2.34 3.46l-.46 1.5 1.93-.95c.55.13 1.13.2 1.69.2 3.04 0 5.5-1.92 5.5-4.21 0-2.37-2.46-4.29-5.5-4.29zm-1.71 2.21a.75.75 0 110 1.5.75.75 0 010-1.5zm3.42 0a.75.75 0 110 1.5.75.75 0 010-1.5z"/></svg>'},$=Vue.computed(()=>["alipay","microsoft","github","google","wechat"].filter(re=>re==="microsoft"?e.aadEnabled:!!e.ssoProviders[re]).map(re=>({key:re,label:t(`login.${re}`),icon:M[re]}))),j=()=>{c.value&&c.value.focus()},z=()=>{m.value="credentials",Vue.nextTick(()=>{l.value&&l.value.focus()})},Q=()=>{let ue=e.qrPanel;if(!ue||!ue.authorizeUrl)return;let re=`alipays://platformapi/startapp?appId=20000067&url=${encodeURIComponent(ue.authorizeUrl)}`;window.location.href=re},ae=ue=>{if(a.value="",ue==="microsoft"){e.loginWithMicrosoft();return}if(ue==="alipay"){Co()?e.loginWithSso(ue):nr()?e.loginWithAlipayMobile():e.startSsoQr(ue).then(re=>{re&&N()});return}if(ue==="wechat"){if(nr()||Io()){a.value=t("login.wechat.mobileUnsupported");return}e.startSsoQr(ue).then(re=>{re&&N()});return}e.loginWithSso(ue)},ke=async()=>{if(!n.value){a.value=t("login.error.enterUsername");return}if(!r.value){a.value=t("login.error.enterPassword");return}a.value="",await e.login(n.value,r.value),Vue.nextTick(()=>{(e.loginStep==="totp"||e.loginStep==="totp-setup")&&u.value?u.value.focus():e.loginStep==="verification"&&d.value&&d.value.focus()})},N=()=>{if(e.qrPanel&&typeof qrcode=="function")try{let ue=qrcode(0,"M");ue.addData(e.qrPanel.authorizeUrl,"Byte"),ue.make(),f.value=ue.createDataURL(6,4)}catch{}},G=Vue.computed(()=>{let ue=e.qrPanel?.provider;return t(ue==="alipay"?"login.qr.titleAlipay":ue==="wechat"?"login.qr.titleWechat":"login.qr.title")});Vue.watch(()=>e.qrPanel?.authorizeUrl,ue=>{ue?N():f.value=""});let de=async()=>{if(!o.value||o.value.length!==6){a.value=t("login.error.enter6Digit");return}a.value="",await e.verifyTotpCode(o.value)&&e.loginStep==="verification"&&(o.value="",Vue.nextTick(()=>{d.value&&d.value.focus()}))},we=async()=>{if(!o.value||o.value.length!==6){a.value=t("login.error.enter6Digit");return}a.value="",await e.completeTotpSetup(o.value)&&e.loginStep==="verification"&&(o.value="",Vue.nextTick(()=>{d.value&&d.value.focus()}))},se=async()=>{if(a.value="",b.value=!1,!y.value||y.value.length<2){a.value=t("login.error.usernameMinLen");return}if(!h.value||h.value.length<6){a.value=t("login.error.passwordMinLen");return}if(h.value!==k.value){a.value=t("login.error.passwordMismatch");return}await e.register(y.value,h.value,S.value||void 0,v.value)&&(b.value=!0,n.value=y.value,v.value="",y.value="",h.value="",k.value="",S.value="",setTimeout(()=>e.backToCredentials(),1500))},ve=async()=>{if(!i.value){a.value=t("login.error.enterVerifyCode");return}a.value="",await e.verifyCode(i.value)};return Vue.onMounted(async()=>{await e.checkAuthMode(),$.value.length===0&&m.value==="oauth"&&(m.value="credentials"),e.loginStep==="credentials"&&m.value==="credentials"&&l.value&&l.value.focus()}),Vue.watch(()=>e.loginStep,ue=>{Vue.nextTick(()=>{ue==="credentials"&&m.value==="credentials"&&l.value?l.value.focus():(ue==="totp"||ue==="totp-setup")&&u.value?u.value.focus():ue==="verification"&&d.value?d.value.focus():ue==="register"&&g.value&&g.value.focus()})}),{authStore:e,currentLocale:s,toggleLang:()=>{Rr(s.value==="zh-CN"?"en":"zh-CN")},loginMode:m,switchToCredentials:z,enabledProviders:$,handleProviderClick:ae,relaunchAlipayMobile:Q,qrCanvas:p,qrDataUrl:f,qrPanelTitle:G,username:n,password:r,verificationCode:i,totpCode:o,localError:a,usernameInput:l,passwordInput:c,codeInput:d,totpInput:u,regCodeInput:g,regInvitationCode:v,regUsername:y,regPassword:h,regPasswordConfirm:k,regEmail:S,registerSuccess:b,focusPassword:j,login:ke,verify:ve,verifyTotp:de,setupTotp:we,doRegister:se,forgotStep:w,forgotEmail:P,forgotResetToken:x,forgotCode:Y,forgotNewPassword:L,forgotConfirm:U,forgotLoading:E,forgotSuccess:oe,enterForgotMode:q,exitForgotMode:I,submitForgotEmail:T,submitForgotReset:R}}}});function nc(){return tc||(tc=Vue.reactive({open:!1,id:0,type:"alert",title:"",message:"",value:"",confirmLabel:"",cancelLabel:"",destructive:!1})),tc}function Ng(){_t||sc.length===0||(_t=sc.shift(),Object.assign(nc(),{open:!0,id:_t.id,type:_t.type,title:_t.options.title||"",message:_t.options.message||"",value:_t.options.defaultValue||"",confirmLabel:_t.options.confirmLabel||"",cancelLabel:_t.options.cancelLabel||"",destructive:_t.options.destructive===!0}))}function rc(e,t,s={}){return new Promise(n=>{sc.push({id:++Rw,type:e,options:{...s,message:String(t||"")},resolve:n}),Ng()})}function ht(e,t){return rc("alert",e,t)}function Be(e,t){return rc("confirm",e,t)}function ic(e,t="",s={}){return rc("prompt",e,{...s,defaultValue:t})}function Ao(e,t=""){if(!_t)return;let s=_t;_t=null,nc().open=!1,s.type==="alert"?s.resolve(void 0):s.type==="confirm"?s.resolve(e===!0):s.resolve(e?t:null),Vue.nextTick(Ng)}function Wg(){return nc()}var sc,_t,Rw,tc,Ct=B(()=>{sc=[],_t=null,Rw=0,tc=null});var xo,oc=B(()=>{Ct();xo={name:"ChatHeader",emits:["toggle-sidebar","close-pane"],props:{conversationId:{type:String,default:null},paneId:{type:String,default:null},showClosePane:{type:Boolean,default:!1},canUseWorkbench:{type:Boolean,default:!1}},template:`
308
+ `,setup(){let e=Ge(),t=Vue.inject("t"),s=Vue.inject("locale"),n=Vue.ref(""),r=Vue.ref(""),i=Vue.ref(""),o=Vue.ref(""),a=Vue.ref(""),l=Vue.ref(null),c=Vue.ref(null),d=Vue.ref(null),u=Vue.ref(null),g=Vue.ref(null),p=Vue.ref(null),f=Vue.ref(""),m=Vue.ref(localStorage.getItem("loginMode")==="credentials"?"credentials":"oauth");Vue.watch(m,ue=>localStorage.setItem("loginMode",ue));let v=Vue.ref(""),b=Vue.ref(""),h=Vue.ref(""),k=Vue.ref(""),S=Vue.ref(""),y=Vue.ref(!1),w=Vue.ref(""),P=Vue.ref(""),x=Vue.ref(""),Y=Vue.ref(""),L=Vue.ref(""),U=Vue.ref(""),E=Vue.ref(!1),oe=Vue.ref(!1),q=()=>{a.value="",e.error=null,w.value="email",P.value="",Y.value="",L.value="",U.value="",x.value="",oe.value=!1},I=()=>{w.value="",x.value="",oe.value=!1},T=async()=>{if(a.value="",!P.value||!/.+@.+\..+/.test(P.value)){a.value=t("login.forgot.emailInvalid");return}E.value=!0;try{let ue=await e.requestPasswordReset(P.value.trim());if(!ue)return;x.value=ue,w.value="verify"}finally{E.value=!1}},R=async()=>{if(a.value="",!Y.value){a.value=t("login.error.enterVerifyCode");return}if(!L.value||L.value.length<6){a.value=t("login.error.passwordMinLen");return}if(L.value!==U.value){a.value=t("login.error.passwordMismatch");return}E.value=!0;try{await e.verifyPasswordReset(x.value,Y.value,L.value)&&(oe.value=!0,setTimeout(()=>{I(),m.value="credentials"},1500))}finally{E.value=!1}},M={alipay:'<svg viewBox="0 0 32 32" width="22" height="22" aria-hidden="true"><rect width="32" height="32" rx="6" fill="#1677FF"/><path fill="#fff" d="M25 18.6c-1.5-.5-3-1-4.6-1.7.4-.8.8-1.6 1.1-2.5h-2.9v-1h3.4v-.5h-3.4v-1.6h-1.4c-.3 0-.3.3-.3.3v1.3h-3.6v.5h3.6v1H11v.5h5.7c-.2.6-.4 1.2-.7 1.7-1.7-.5-3.4-.8-4.7-.8-2.2 0-3.7 1-3.8 2.5-.1 1.4.9 3 3.4 3 1.8 0 3.4-.9 4.7-2.5 2.2 1 4.2 2 6.6 2.9.3-.4.5-.8.7-1.2.2-.4.1-.9-.1-1.3zM11 19.7c-1.8 0-2.3-1.3-2.1-2 .1-.4.6-.9 1.4-1.1.4-.1 1.4-.1 2.4.2.9.2 1.8.5 2.7.8-.7 1.4-2.1 2.1-4.4 2.1z"/></svg>',microsoft:'<svg viewBox="0 0 21 21" width="20" height="20" aria-hidden="true"><rect x="1" y="1" width="9" height="9" fill="#f25022"/><rect x="1" y="11" width="9" height="9" fill="#00a4ef"/><rect x="11" y="1" width="9" height="9" fill="#7fba00"/><rect x="11" y="11" width="9" height="9" fill="#ffb900"/></svg>',github:'<svg viewBox="0 0 24 24" width="20" height="20" aria-hidden="true"><path fill="currentColor" d="M12 .3a12 12 0 0 0-3.8 23.4c.6.1.8-.3.8-.6v-2c-3.3.7-4-1.6-4-1.6-.5-1.4-1.3-1.7-1.3-1.7-1.1-.7.1-.7.1-.7 1.2.1 1.8 1.2 1.8 1.2 1.1 1.8 2.8 1.3 3.4 1 .1-.8.4-1.3.8-1.6-2.7-.3-5.5-1.3-5.5-6 0-1.3.5-2.3 1.2-3.2-.1-.3-.5-1.5.1-3.2 0 0 1-.3 3.3 1.2A11.5 11.5 0 0 1 12 5.8c1 0 2 .1 3 .4 2.3-1.5 3.3-1.2 3.3-1.2.6 1.7.2 2.9.1 3.2.7.9 1.2 1.9 1.2 3.2 0 4.6-2.8 5.7-5.5 6 .4.4.8 1.1.8 2.2v3.3c0 .3.2.7.8.6A12 12 0 0 0 12 .3"/></svg>',google:'<svg viewBox="0 0 24 24" width="20" height="20" aria-hidden="true"><path fill="#4285F4" d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"/><path fill="#34A853" d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84A11 11 0 0 0 12 23z"/><path fill="#FBBC05" d="M5.84 14.1A6.6 6.6 0 0 1 5.5 12c0-.73.13-1.44.34-2.1V7.07H2.18A11 11 0 0 0 1 12c0 1.77.42 3.45 1.18 4.93l3.66-2.83z"/><path fill="#EA4335" d="M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1A11 11 0 0 0 2.18 7.07l3.66 2.83C6.71 7.31 9.14 5.38 12 5.38z"/></svg>',wechat:'<svg viewBox="0 0 24 24" width="20" height="20" aria-hidden="true"><path fill="#07C160" d="M9.5 4C5.36 4 2 6.91 2 10.5c0 2.07 1.13 3.91 2.86 5.09L4 18l2.7-1.41c.85.22 1.76.34 2.7.34h.51c-.13-.42-.21-.86-.21-1.32 0-3 2.91-5.43 6.5-5.43.32 0 .64.02.95.06C16.63 7.32 13.4 4 9.5 4zM7 8.5a1 1 0 110 2 1 1 0 010-2zm5 0a1 1 0 110 2 1 1 0 010-2zm4.21 3.66c-3.04 0-5.5 1.92-5.5 4.29 0 1.39.91 2.65 2.34 3.46l-.46 1.5 1.93-.95c.55.13 1.13.2 1.69.2 3.04 0 5.5-1.92 5.5-4.21 0-2.37-2.46-4.29-5.5-4.29zm-1.71 2.21a.75.75 0 110 1.5.75.75 0 010-1.5zm3.42 0a.75.75 0 110 1.5.75.75 0 010-1.5z"/></svg>'},$=Vue.computed(()=>["alipay","microsoft","github","google","wechat"].filter(re=>re==="microsoft"?e.aadEnabled:!!e.ssoProviders[re]).map(re=>({key:re,label:t(`login.${re}`),icon:M[re]}))),j=()=>{c.value&&c.value.focus()},z=()=>{m.value="credentials",Vue.nextTick(()=>{l.value&&l.value.focus()})},Q=()=>{let ue=e.qrPanel;if(!ue||!ue.authorizeUrl)return;let re=`alipays://platformapi/startapp?appId=20000067&url=${encodeURIComponent(ue.authorizeUrl)}`;window.location.href=re},ae=ue=>{if(a.value="",ue==="microsoft"){e.loginWithMicrosoft();return}if(ue==="alipay"){Co()?e.loginWithSso(ue):nr()?e.loginWithAlipayMobile():e.startSsoQr(ue).then(re=>{re&&N()});return}if(ue==="wechat"){if(nr()||Io()){a.value=t("login.wechat.mobileUnsupported");return}e.startSsoQr(ue).then(re=>{re&&N()});return}e.loginWithSso(ue)},ke=async()=>{if(!n.value){a.value=t("login.error.enterUsername");return}if(!r.value){a.value=t("login.error.enterPassword");return}a.value="",await e.login(n.value,r.value),Vue.nextTick(()=>{(e.loginStep==="totp"||e.loginStep==="totp-setup")&&u.value?u.value.focus():e.loginStep==="verification"&&d.value&&d.value.focus()})},N=()=>{if(e.qrPanel&&typeof qrcode=="function")try{let ue=qrcode(0,"M");ue.addData(e.qrPanel.authorizeUrl,"Byte"),ue.make(),f.value=ue.createDataURL(6,4)}catch{}},G=Vue.computed(()=>{let ue=e.qrPanel?.provider;return t(ue==="alipay"?"login.qr.titleAlipay":ue==="wechat"?"login.qr.titleWechat":"login.qr.title")});Vue.watch(()=>e.qrPanel?.authorizeUrl,ue=>{ue?N():f.value=""});let de=async()=>{if(!o.value||o.value.length!==6){a.value=t("login.error.enter6Digit");return}a.value="",await e.verifyTotpCode(o.value)&&e.loginStep==="verification"&&(o.value="",Vue.nextTick(()=>{d.value&&d.value.focus()}))},we=async()=>{if(!o.value||o.value.length!==6){a.value=t("login.error.enter6Digit");return}a.value="",await e.completeTotpSetup(o.value)&&e.loginStep==="verification"&&(o.value="",Vue.nextTick(()=>{d.value&&d.value.focus()}))},se=async()=>{if(a.value="",y.value=!1,!b.value||b.value.length<2){a.value=t("login.error.usernameMinLen");return}if(!h.value||h.value.length<6){a.value=t("login.error.passwordMinLen");return}if(h.value!==k.value){a.value=t("login.error.passwordMismatch");return}await e.register(b.value,h.value,S.value||void 0,v.value)&&(y.value=!0,n.value=b.value,v.value="",b.value="",h.value="",k.value="",S.value="",setTimeout(()=>e.backToCredentials(),1500))},ve=async()=>{if(!i.value){a.value=t("login.error.enterVerifyCode");return}a.value="",await e.verifyCode(i.value)};return Vue.onMounted(async()=>{await e.checkAuthMode(),$.value.length===0&&m.value==="oauth"&&(m.value="credentials"),e.loginStep==="credentials"&&m.value==="credentials"&&l.value&&l.value.focus()}),Vue.watch(()=>e.loginStep,ue=>{Vue.nextTick(()=>{ue==="credentials"&&m.value==="credentials"&&l.value?l.value.focus():(ue==="totp"||ue==="totp-setup")&&u.value?u.value.focus():ue==="verification"&&d.value?d.value.focus():ue==="register"&&g.value&&g.value.focus()})}),{authStore:e,currentLocale:s,toggleLang:()=>{Rr(s.value==="zh-CN"?"en":"zh-CN")},loginMode:m,switchToCredentials:z,enabledProviders:$,handleProviderClick:ae,relaunchAlipayMobile:Q,qrCanvas:p,qrDataUrl:f,qrPanelTitle:G,username:n,password:r,verificationCode:i,totpCode:o,localError:a,usernameInput:l,passwordInput:c,codeInput:d,totpInput:u,regCodeInput:g,regInvitationCode:v,regUsername:b,regPassword:h,regPasswordConfirm:k,regEmail:S,registerSuccess:y,focusPassword:j,login:ke,verify:ve,verifyTotp:de,setupTotp:we,doRegister:se,forgotStep:w,forgotEmail:P,forgotResetToken:x,forgotCode:Y,forgotNewPassword:L,forgotConfirm:U,forgotLoading:E,forgotSuccess:oe,enterForgotMode:q,exitForgotMode:I,submitForgotEmail:T,submitForgotReset:R}}}});function nc(){return tc||(tc=Vue.reactive({open:!1,id:0,type:"alert",title:"",message:"",value:"",confirmLabel:"",cancelLabel:"",destructive:!1})),tc}function Ng(){_t||sc.length===0||(_t=sc.shift(),Object.assign(nc(),{open:!0,id:_t.id,type:_t.type,title:_t.options.title||"",message:_t.options.message||"",value:_t.options.defaultValue||"",confirmLabel:_t.options.confirmLabel||"",cancelLabel:_t.options.cancelLabel||"",destructive:_t.options.destructive===!0}))}function rc(e,t,s={}){return new Promise(n=>{sc.push({id:++Rw,type:e,options:{...s,message:String(t||"")},resolve:n}),Ng()})}function ht(e,t){return rc("alert",e,t)}function Be(e,t){return rc("confirm",e,t)}function ic(e,t="",s={}){return rc("prompt",e,{...s,defaultValue:t})}function Ao(e,t=""){if(!_t)return;let s=_t;_t=null,nc().open=!1,s.type==="alert"?s.resolve(void 0):s.type==="confirm"?s.resolve(e===!0):s.resolve(e?t:null),Vue.nextTick(Ng)}function Wg(){return nc()}var sc,_t,Rw,tc,Ct=B(()=>{sc=[],_t=null,Rw=0,tc=null});var xo,oc=B(()=>{Ct();xo={name:"ChatHeader",emits:["toggle-sidebar","close-pane"],props:{conversationId:{type:String,default:null},paneId:{type:String,default:null},showClosePane:{type:Boolean,default:!1},canUseWorkbench:{type:Boolean,default:!1}},template:`
309
309
  <header class="chat-header">
310
310
  <!-- Mobile sidebar toggle \u2014 hidden on desktop and in split mode -->
311
311
  <button class="header-sidebar-toggle" v-if="!store.isSplitMode"
@@ -410,7 +410,7 @@ They will restart after upgrading. {skipped} other Agent(s) will be skipped beca
410
410
  </button>
411
411
  </div>
412
412
  </header>
413
- `,setup(e){let t=Pinia.useChatStore(),s=Vue.inject("t"),n=Vue.computed(()=>e.conversationId||t.currentConversation),r=Vue.computed(()=>n.value&&t.conversations.find(N=>N.id===n.value)||null),i=Vue.computed(()=>r.value?.capabilities||null),o=Vue.computed(()=>n.value?(r.value?.provider||"claude-code")==="claude-code":!0),a=(N,G=!0)=>{let de=i.value;return de?!!de[N]:o.value?G:!1},l=Vue.computed(()=>a("compact")),c=Vue.computed(()=>a("clear")),d=Vue.computed(()=>a("expert")),u=Vue.computed(()=>a("mcp")),g=Vue.computed(()=>{if(!n.value)return"Yeaft";let N=t.getConversationTitle(n.value);if(N)return N;let de=t.conversations.find(we=>we.id===n.value)?.workDir||t.currentWorkDir;if(de){let we=de.split(/[/\\]/);return we[we.length-1]||we[we.length-2]||de}return s("chatHeader.newConv")}),p=Vue.computed(()=>{if(!n.value)return"";let G=t.conversations.find(we=>we.id===n.value)?.agentId;return G&&t.agents.find(we=>we.id===G)?.name||""}),f=Vue.computed(()=>t.clearStatus?.conversationId===n.value?!0:t.compactStatus?t.compactStatus.conversationId===n.value:!1),m=Vue.computed(()=>t.clearStatus?.conversationId===n.value?t.clearStatus.status==="clearing"?"compacting":"completed":t.compactStatus?t.compactStatus.status==="compacting"?"compacting":"completed":""),v=Vue.computed(()=>t.clearStatus?.conversationId===n.value?t.clearStatus.status==="clearing":t.compactStatus?.status==="compacting"),y=Vue.computed(()=>t.clearStatus?.conversationId===n.value?t.clearStatus.status==="clearing"?s("chatHeader.clearing"):s("chatHeader.clearDone"):t.compactStatus?t.compactStatus.status==="compacting"?t.compactStatus.message||s("chatHeader.compacting"):t.compactStatus.message||s("chatHeader.compactDone"):""),h=Vue.computed(()=>n.value&&(t.conversations.find(G=>G.id===n.value)?.workDir||t.currentWorkDir)||""),k=Vue.computed(()=>!t.contextUsage||t.contextUsage.conversationId!==n.value?null:t.contextUsage),S=Vue.computed(()=>{let N=k.value?.percentage||0;return N>=80?"context-danger":N>=50?"context-warn":"context-ok"}),b=Vue.computed(()=>{if(!k.value)return"";let N=(k.value.inputTokens/1e3).toFixed(0),G=(k.value.maxTokens/1e3).toFixed(0);return`Context: ${N}k / ${G}k`}),w=Vue.computed(()=>t.isRefreshingSession(n.value)),P=Vue.computed(()=>t.compactStatus?.status==="compacting"&&t.compactStatus?.conversationId===n.value),x=Vue.computed(()=>t.clearStatus?.status==="clearing"&&t.clearStatus?.conversationId===n.value),Y=Vue.computed(()=>n.value?!t.isRefreshingSession(n.value):!1),L=()=>{if(t.isRefreshingSession(n.value)||!n.value)return;t.setRefreshingSession(n.value,!0),t.startRefreshTimeout(n.value),t.requestChatHistory(n.value,{mode:"recent",turns:5})||t.setRefreshingSession(n.value,!1)},U=()=>{P.value||t.sendMessage("/compact")},E=()=>{window.location.reload()},oe=async()=>{x.value||await Be(s("chatHeader.confirmClear"),{destructive:!0})&&(t.clearStatus={conversationId:n.value,status:"clearing"},t.sendMessage("/clear"))},q=Vue.computed(()=>t.getPaneRightPanel(e.paneId)),I=Vue.ref(null),T=Vue.computed(()=>{if(!t.mcpPanelOpen||!I.value)return null;let N=I.value.getBoundingClientRect();return{top:`${N.bottom+6}px`,right:`${window.innerWidth-N.right}px`}}),R=Vue.computed(()=>t.currentMcpServers.filter(N=>N.enabled).length),M=Vue.computed(()=>!!t.conversations.find(G=>G.id===n.value)?.needRestart),$=()=>{t.mcpPanelOpen=!t.mcpPanelOpen},j=()=>{t.togglePaneRightPanel("experts",e.paneId)},z=()=>{t.togglePaneRightPanel("subagents",e.paneId)},Q=Vue.computed(()=>t.runningSubagentCount),ae=(N,G)=>{t.toggleConversationMcp(N,G)},ke=N=>{t.mcpPanelOpen&&!N.target.closest(".mcp-dropdown")&&!N.target.closest(".mcp-config-wrapper")&&(t.mcpPanelOpen=!1)};return Vue.onMounted(()=>{document.addEventListener("click",ke)}),Vue.onUnmounted(()=>{document.removeEventListener("click",ke)}),{store:t,effectiveConvId:n,effectiveRightPanel:q,isClaudeCode:o,canCompact:l,canClear:c,canExpert:d,canMcp:u,headerTitle:g,showStatusBanner:f,statusBannerClass:m,statusBannerSpinner:v,statusBannerMessage:y,contextUsage:k,contextColorClass:S,contextLabel:b,isRefreshing:w,isCompacting:P,isClearing:x,canRefresh:Y,refreshSession:L,reloadPage:E,compactContext:U,clearMessages:oe,mcpBtnRef:I,mcpDropdownStyle:T,mcpEnabledCount:R,currentConvNeedRestart:M,toggleMcpPanel:$,toggleMcpServer:ae,toggleExpertPanel:j,toggleSubAgentPanel:z,runningSubagentCount:Q}}}});function To(e=globalThis.location){let t=e?.protocol==="https:"?"wss:":"ws:",s=e?.host||"localhost";return`${t}//${s}`}function _w(e=globalThis.location){let t=e?.origin;if(t&&t!=="null")return t.replace(/\/$/,"");let s=e?.protocol==="https:"?"https:":"http:",n=e?.host||"localhost";return`${s}//${n}`}function ac(e){return`'${String(e).replace(/'/g,`'"'"'`)}'`}function lc(e){return`'${String(e).replace(/'/g,"''")}'`}function jg({platform:e="posix",agentSecret:t="",serverWsUrl:s,locationLike:n=globalThis.location}={}){if(!t)return"";let r=s||To(n),i=_w(n);if(e==="powershell")return`& { param($Server, $Secret) $tls = [Net.ServicePointManager]::SecurityProtocol; try { [Net.ServicePointManager]::SecurityProtocol = $tls -bor [Net.SecurityProtocolType]::Tls12; & ([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing ${lc(`${i}/installers/install.ps1`)} -MaximumRedirection 0 -ErrorAction Stop).Content)) -Server $Server -Secret $Secret } finally { [Net.ServicePointManager]::SecurityProtocol = $tls } } -Server ${lc(r)} -Secret ${lc(t)}`;let o=ac(`${i}/installers/install.sh`);return`(tmp=$(mktemp) && trap 'rm -f "$tmp"' EXIT && curl -fSL ${i.startsWith("https:")?"--proto '=https' --proto-redir '=https' --tlsv1.2":"--proto '=http,https' --proto-redir '=http,https'"} ${o} -o "$tmp" && sh "$tmp" --server ${ac(r)} --secret ${ac(t)})`}function cc(e=null){let t=e&&(e.username||e.displayName)||"agent",s=2166136261;for(let i=0;i<t.length;i++)s^=t.charCodeAt(i),s=s+((s<<1)+(s<<4)+(s<<7)+(s<<8)+(s<<24))>>>0;let n=s.toString(16).padStart(8,"0").slice(0,6);return`${String(t).replace(/[^A-Za-z0-9_-]/g,"-").replace(/^-+|-+$/g,"")||"agent"}-${n}`}function Ug({profile:e=null,agentSecret:t="",serverWsUrl:s=To()}={}){if(!t)return"";let n=cc(e);return`yeaft-agent container install --server ${s} --secret ${t} --name ${n}`}var dc=B(()=>{});var Ew,rr,Mo=B(()=>{dc();Ew=2e3,rr={props:{agentSecret:{type:String,default:""},loading:{type:Boolean,default:!1},error:{type:String,default:""},showSettingsLink:{type:Boolean,default:!0}},emits:["open-settings"],data(){return{platform:"posix",copyState:"idle",copyTimer:null}},computed:{command(){return this.agentSecret?jg({platform:this.platform,agentSecret:this.agentSecret,locationLike:globalThis.location}):""},copyLabel(){return this.copyState==="copying"?this.$t("installer.copying"):this.copyState==="copied"?this.$t("common.copied"):this.copyState==="error"?this.$t("installer.copyFailed"):this.$t("installer.copyCommand")},statusText(){return this.loading?this.$t("installer.secretLoading"):this.error?this.$t("installer.secretError"):this.agentSecret?this.copyState==="error"?this.$t("installer.copyError"):this.copyState==="copied"?this.$t("installer.copySuccess"):"":this.$t("installer.secretRequired")}},beforeUnmount(){this.copyTimer&&clearTimeout(this.copyTimer)},methods:{selectPlatform(e){this.platform=e,this.copyState="idle"},async copyCommand(){if(!(!this.command||this.loading||this.copyState==="copying")){this.copyState="copying";try{await navigator.clipboard.writeText(this.command),this.copyState="copied"}catch{this.copyState="error",this.$refs.commandDetails&&(this.$refs.commandDetails.open=!0)}this.copyTimer&&clearTimeout(this.copyTimer),this.copyTimer=setTimeout(()=>{this.copyState="idle"},Ew)}}},template:`
413
+ `,setup(e){let t=Pinia.useChatStore(),s=Vue.inject("t"),n=Vue.computed(()=>e.conversationId||t.currentConversation),r=Vue.computed(()=>n.value&&t.conversations.find(N=>N.id===n.value)||null),i=Vue.computed(()=>r.value?.capabilities||null),o=Vue.computed(()=>n.value?(r.value?.provider||"claude-code")==="claude-code":!0),a=(N,G=!0)=>{let de=i.value;return de?!!de[N]:o.value?G:!1},l=Vue.computed(()=>a("compact")),c=Vue.computed(()=>a("clear")),d=Vue.computed(()=>a("expert")),u=Vue.computed(()=>a("mcp")),g=Vue.computed(()=>{if(!n.value)return"Yeaft";let N=t.getConversationTitle(n.value);if(N)return N;let de=t.conversations.find(we=>we.id===n.value)?.workDir||t.currentWorkDir;if(de){let we=de.split(/[/\\]/);return we[we.length-1]||we[we.length-2]||de}return s("chatHeader.newConv")}),p=Vue.computed(()=>{if(!n.value)return"";let G=t.conversations.find(we=>we.id===n.value)?.agentId;return G&&t.agents.find(we=>we.id===G)?.name||""}),f=Vue.computed(()=>t.clearStatus?.conversationId===n.value?!0:t.compactStatus?t.compactStatus.conversationId===n.value:!1),m=Vue.computed(()=>t.clearStatus?.conversationId===n.value?t.clearStatus.status==="clearing"?"compacting":"completed":t.compactStatus?t.compactStatus.status==="compacting"?"compacting":"completed":""),v=Vue.computed(()=>t.clearStatus?.conversationId===n.value?t.clearStatus.status==="clearing":t.compactStatus?.status==="compacting"),b=Vue.computed(()=>t.clearStatus?.conversationId===n.value?t.clearStatus.status==="clearing"?s("chatHeader.clearing"):s("chatHeader.clearDone"):t.compactStatus?t.compactStatus.status==="compacting"?t.compactStatus.message||s("chatHeader.compacting"):t.compactStatus.message||s("chatHeader.compactDone"):""),h=Vue.computed(()=>n.value&&(t.conversations.find(G=>G.id===n.value)?.workDir||t.currentWorkDir)||""),k=Vue.computed(()=>!t.contextUsage||t.contextUsage.conversationId!==n.value?null:t.contextUsage),S=Vue.computed(()=>{let N=k.value?.percentage||0;return N>=80?"context-danger":N>=50?"context-warn":"context-ok"}),y=Vue.computed(()=>{if(!k.value)return"";let N=(k.value.inputTokens/1e3).toFixed(0),G=(k.value.maxTokens/1e3).toFixed(0);return`Context: ${N}k / ${G}k`}),w=Vue.computed(()=>t.isRefreshingSession(n.value)),P=Vue.computed(()=>t.compactStatus?.status==="compacting"&&t.compactStatus?.conversationId===n.value),x=Vue.computed(()=>t.clearStatus?.status==="clearing"&&t.clearStatus?.conversationId===n.value),Y=Vue.computed(()=>n.value?!t.isRefreshingSession(n.value):!1),L=()=>{if(t.isRefreshingSession(n.value)||!n.value)return;t.setRefreshingSession(n.value,!0),t.startRefreshTimeout(n.value),t.requestChatHistory(n.value,{mode:"recent",turns:5})||t.setRefreshingSession(n.value,!1)},U=()=>{P.value||t.sendMessage("/compact")},E=()=>{window.location.reload()},oe=async()=>{x.value||await Be(s("chatHeader.confirmClear"),{destructive:!0})&&(t.clearStatus={conversationId:n.value,status:"clearing"},t.sendMessage("/clear"))},q=Vue.computed(()=>t.getPaneRightPanel(e.paneId)),I=Vue.ref(null),T=Vue.computed(()=>{if(!t.mcpPanelOpen||!I.value)return null;let N=I.value.getBoundingClientRect();return{top:`${N.bottom+6}px`,right:`${window.innerWidth-N.right}px`}}),R=Vue.computed(()=>t.currentMcpServers.filter(N=>N.enabled).length),M=Vue.computed(()=>!!t.conversations.find(G=>G.id===n.value)?.needRestart),$=()=>{t.mcpPanelOpen=!t.mcpPanelOpen},j=()=>{t.togglePaneRightPanel("experts",e.paneId)},z=()=>{t.togglePaneRightPanel("subagents",e.paneId)},Q=Vue.computed(()=>t.runningSubagentCount),ae=(N,G)=>{t.toggleConversationMcp(N,G)},ke=N=>{t.mcpPanelOpen&&!N.target.closest(".mcp-dropdown")&&!N.target.closest(".mcp-config-wrapper")&&(t.mcpPanelOpen=!1)};return Vue.onMounted(()=>{document.addEventListener("click",ke)}),Vue.onUnmounted(()=>{document.removeEventListener("click",ke)}),{store:t,effectiveConvId:n,effectiveRightPanel:q,isClaudeCode:o,canCompact:l,canClear:c,canExpert:d,canMcp:u,headerTitle:g,showStatusBanner:f,statusBannerClass:m,statusBannerSpinner:v,statusBannerMessage:b,contextUsage:k,contextColorClass:S,contextLabel:y,isRefreshing:w,isCompacting:P,isClearing:x,canRefresh:Y,refreshSession:L,reloadPage:E,compactContext:U,clearMessages:oe,mcpBtnRef:I,mcpDropdownStyle:T,mcpEnabledCount:R,currentConvNeedRestart:M,toggleMcpPanel:$,toggleMcpServer:ae,toggleExpertPanel:j,toggleSubAgentPanel:z,runningSubagentCount:Q}}}});function To(e=globalThis.location){let t=e?.protocol==="https:"?"wss:":"ws:",s=e?.host||"localhost";return`${t}//${s}`}function _w(e=globalThis.location){let t=e?.origin;if(t&&t!=="null")return t.replace(/\/$/,"");let s=e?.protocol==="https:"?"https:":"http:",n=e?.host||"localhost";return`${s}//${n}`}function ac(e){return`'${String(e).replace(/'/g,`'"'"'`)}'`}function lc(e){return`'${String(e).replace(/'/g,"''")}'`}function jg({platform:e="posix",agentSecret:t="",serverWsUrl:s,locationLike:n=globalThis.location}={}){if(!t)return"";let r=s||To(n),i=_w(n);if(e==="powershell")return`& { param($Server, $Secret) $tls = [Net.ServicePointManager]::SecurityProtocol; try { [Net.ServicePointManager]::SecurityProtocol = $tls -bor [Net.SecurityProtocolType]::Tls12; & ([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing ${lc(`${i}/installers/install.ps1`)} -MaximumRedirection 0 -ErrorAction Stop).Content)) -Server $Server -Secret $Secret } finally { [Net.ServicePointManager]::SecurityProtocol = $tls } } -Server ${lc(r)} -Secret ${lc(t)}`;let o=ac(`${i}/installers/install.sh`);return`(tmp=$(mktemp) && trap 'rm -f "$tmp"' EXIT && curl -fSL ${i.startsWith("https:")?"--proto '=https' --proto-redir '=https' --tlsv1.2":"--proto '=http,https' --proto-redir '=http,https'"} ${o} -o "$tmp" && sh "$tmp" --server ${ac(r)} --secret ${ac(t)})`}function cc(e=null){let t=e&&(e.username||e.displayName)||"agent",s=2166136261;for(let i=0;i<t.length;i++)s^=t.charCodeAt(i),s=s+((s<<1)+(s<<4)+(s<<7)+(s<<8)+(s<<24))>>>0;let n=s.toString(16).padStart(8,"0").slice(0,6);return`${String(t).replace(/[^A-Za-z0-9_-]/g,"-").replace(/^-+|-+$/g,"")||"agent"}-${n}`}function Ug({profile:e=null,agentSecret:t="",serverWsUrl:s=To()}={}){if(!t)return"";let n=cc(e);return`yeaft-agent container install --server ${s} --secret ${t} --name ${n}`}var dc=B(()=>{});var Ew,rr,Mo=B(()=>{dc();Ew=2e3,rr={props:{agentSecret:{type:String,default:""},loading:{type:Boolean,default:!1},error:{type:String,default:""},showSettingsLink:{type:Boolean,default:!0}},emits:["open-settings"],data(){return{platform:"posix",copyState:"idle",copyTimer:null}},computed:{command(){return this.agentSecret?jg({platform:this.platform,agentSecret:this.agentSecret,locationLike:globalThis.location}):""},copyLabel(){return this.copyState==="copying"?this.$t("installer.copying"):this.copyState==="copied"?this.$t("common.copied"):this.copyState==="error"?this.$t("installer.copyFailed"):this.$t("installer.copyCommand")},statusText(){return this.loading?this.$t("installer.secretLoading"):this.error?this.$t("installer.secretError"):this.agentSecret?this.copyState==="error"?this.$t("installer.copyError"):this.copyState==="copied"?this.$t("installer.copySuccess"):"":this.$t("installer.secretRequired")}},beforeUnmount(){this.copyTimer&&clearTimeout(this.copyTimer)},methods:{selectPlatform(e){this.platform=e,this.copyState="idle"},async copyCommand(){if(!(!this.command||this.loading||this.copyState==="copying")){this.copyState="copying";try{await navigator.clipboard.writeText(this.command),this.copyState="copied"}catch{this.copyState="error",this.$refs.commandDetails&&(this.$refs.commandDetails.open=!0)}this.copyTimer&&clearTimeout(this.copyTimer),this.copyTimer=setTimeout(()=>{this.copyState="idle"},Ew)}}},template:`
414
414
  <div class="agent-installer">
415
415
  <div class="agent-installer-toolbar">
416
416
  <div class="agent-installer-tabs" role="group" :aria-label="$t('installer.platformLabel')">
@@ -452,7 +452,7 @@ They will restart after upgrading. {skipped} other Agent(s) will be skipped beca
452
452
  </p>
453
453
  <p class="agent-installer-note">{{ $t('installer.note') }}</p>
454
454
  </div>
455
- `}});function Dw(e,t){return typeof e=="string"?e?{src:e,alt:t}:null:!e||typeof e!="object"||!e.src?null:{src:e.src,alt:e.alt||t}}function Rs(e,{alt:t="Preview",closeLabel:s="Close",previousLabel:n="Previous image",nextLabel:r="Next image",positionLabel:i=(g,p)=>`${g} / ${p}`,zoomOutLabel:o="Zoom out",zoomInLabel:a="Zoom in",resetZoomLabel:l="Reset zoom",gallery:c=null,initialIndex:d=null,trigger:u=null}={}){if(!e)return null;let g=(Array.isArray(c)?c:[e]).map(G=>Dw(G,t)).filter(Boolean);g.length===0&&g.push({src:e,alt:t});let p=Number.isInteger(d)&&d>=0&&d<g.length?d:g.findIndex(G=>G.src===e);p<0&&(p=0);let f=document.createElement("div");f.className="image-preview-overlay",f.setAttribute("role","dialog"),f.setAttribute("aria-modal","true"),f.setAttribute("aria-label",t);let m=document.createElement("img");m.className="image-preview-img",m.draggable=!1;let v=(G,de,we)=>{let se=document.createElement("button");return se.type="button",se.className=G,se.setAttribute("aria-label",de),se.setAttribute("title",de),se.textContent=we,se},y=v("image-preview-close",s,"\xD7"),h=document.createElement("div");h.className="image-preview-zoom-controls";let k=v("image-preview-zoom-button",o,"\u2212"),S=v("image-preview-zoom-reset",l,"100%"),b=v("image-preview-zoom-button",a,"+");h.append(k,S,b);let w=1,P=0,x=0,Y=null,L=()=>{if(w<=1){P=0,x=0;return}let G=Math.max(0,(m.offsetWidth*w-f.clientWidth)/2),de=Math.max(0,(m.offsetHeight*w-f.clientHeight)/2);P=Math.max(-G,Math.min(G,P)),x=Math.max(-de,Math.min(de,x))},U=()=>{L(),m.style.transform=`translate(${P}px, ${x}px) scale(${w})`,m.classList.toggle("is-zoomed",w>1),S.textContent=`${Math.round(w*100)}%`,k.disabled=w<=Kg,b.disabled=w>=zg},E=(G,de=null)=>{let we=w;if(w=Math.max(Kg,Math.min(zg,G)),w<=1)P=0,x=0;else if(de&&Number.isFinite(de.clientX)&&Number.isFinite(de.clientY)&&we>0&&w!==we){let se=f.getBoundingClientRect(),ve=de.clientX-(se.left+se.width/2),Ie=de.clientY-(se.top+se.height/2),ue=w/we;P=ve-(ve-P)*ue,x=Ie-(Ie-x)*ue}U()},oe=()=>{w=1,P=0,x=0,U()},q=null,I=null,T=null;g.length>1&&(q=document.createElement("button"),q.type="button",q.className="image-preview-navigation image-preview-previous",q.setAttribute("aria-label",n),q.setAttribute("title",n),q.innerHTML='<svg viewBox="0 0 24 24" aria-hidden="true"><path fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" d="m15 18-6-6 6-6"/></svg>',I=document.createElement("button"),I.type="button",I.className="image-preview-navigation image-preview-next",I.setAttribute("aria-label",r),I.setAttribute("title",r),I.innerHTML='<svg viewBox="0 0 24 24" aria-hidden="true"><path fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" d="m9 18 6-6-6-6"/></svg>',T=document.createElement("div"),T.className="image-preview-position",T.setAttribute("aria-live","polite"));let R=()=>{let G=g[p];m.src=G.src,m.alt=G.alt,f.setAttribute("aria-label",G.alt),T&&(T.textContent=typeof i=="function"?i(p+1,g.length):`${p+1} / ${g.length}`),oe()},M=G=>{p=(p+G+g.length)%g.length,R()};R(),f.append(m),q&&I&&T&&f.append(q,I,T),f.append(y,h),document.body.appendChild(f),f.offsetHeight,f.classList.add("visible"),y.focus();let $=!1,j=null,z=()=>{j&&clearTimeout(j),j=null,f.isConnected&&f.remove()},Q=()=>{$||($=!0,f.classList.remove("visible"),f.addEventListener("transitionend",z,{once:!0}),j=setTimeout(z,250),document.removeEventListener("keydown",ke),window.removeEventListener("resize",U),u?.isConnected&&typeof u.focus=="function"&&u.focus())},ae=()=>[q,I,k,S,b,y].filter(G=>G&&!G.disabled),ke=G=>{if(G.key==="Escape"){G.preventDefault(),Q();return}if(G.key==="+"||G.key==="="){G.preventDefault(),E(w+oi);return}if(G.key==="-"||G.key==="_"){G.preventDefault(),E(w-oi);return}if(G.key==="0"){G.preventDefault(),oe();return}if(g.length>1&&(G.key==="ArrowLeft"||G.key==="ArrowRight")){G.preventDefault(),M(G.key==="ArrowLeft"?-1:1);return}if(G.key==="Tab"){G.preventDefault();let de=ae(),we=de.indexOf(document.activeElement),se=G.shiftKey?-1:1,ve=we<0?0:(we+se+de.length)%de.length;de[ve]?.focus()}};y.addEventListener("click",Q),k.addEventListener("click",()=>E(w-oi)),S.addEventListener("click",oe),b.addEventListener("click",()=>E(w+oi)),q?.addEventListener("click",()=>M(-1)),I?.addEventListener("click",()=>M(1)),m.addEventListener("load",U),m.addEventListener("wheel",G=>{G.preventDefault();let de=G.deltaY<0?1:-1;E(w+de*oi,G)},{passive:!1}),m.addEventListener("pointerdown",G=>{w<=1||G.button!==0||(G.preventDefault(),Y={pointerId:G.pointerId,x:G.clientX,y:G.clientY,panX:P,panY:x},m.classList.add("is-dragging"),m.setPointerCapture?.(G.pointerId))}),m.addEventListener("pointermove",G=>{!Y||Y.pointerId!==G.pointerId||(P=Y.panX+G.clientX-Y.x,x=Y.panY+G.clientY-Y.y,U())});let N=G=>{!Y||Y.pointerId!==G.pointerId||(m.releasePointerCapture?.(G.pointerId),Y=null,m.classList.remove("is-dragging"))};return m.addEventListener("pointerup",N),m.addEventListener("pointercancel",N),f.addEventListener("click",G=>{G.target===f&&Q()}),document.addEventListener("keydown",ke),window.addEventListener("resize",U),f}var Kg,zg,oi,ai=B(()=>{Kg=.5,zg=4,oi=.25});function Fw(e){let t=[];for(let s of e)s==="\b"?t.pop():t.push(s);return t.join("")}function Ow(e){let t=e.split("\r"),s=t[t.length-1]||"";return Fw(s)}function Zg(e){return e.replace(/\r\n/g,`
455
+ `}});function Dw(e,t){return typeof e=="string"?e?{src:e,alt:t}:null:!e||typeof e!="object"||!e.src?null:{src:e.src,alt:e.alt||t}}function Rs(e,{alt:t="Preview",closeLabel:s="Close",previousLabel:n="Previous image",nextLabel:r="Next image",positionLabel:i=(g,p)=>`${g} / ${p}`,zoomOutLabel:o="Zoom out",zoomInLabel:a="Zoom in",resetZoomLabel:l="Reset zoom",gallery:c=null,initialIndex:d=null,trigger:u=null}={}){if(!e)return null;let g=(Array.isArray(c)?c:[e]).map(G=>Dw(G,t)).filter(Boolean);g.length===0&&g.push({src:e,alt:t});let p=Number.isInteger(d)&&d>=0&&d<g.length?d:g.findIndex(G=>G.src===e);p<0&&(p=0);let f=document.createElement("div");f.className="image-preview-overlay",f.setAttribute("role","dialog"),f.setAttribute("aria-modal","true"),f.setAttribute("aria-label",t);let m=document.createElement("img");m.className="image-preview-img",m.draggable=!1;let v=(G,de,we)=>{let se=document.createElement("button");return se.type="button",se.className=G,se.setAttribute("aria-label",de),se.setAttribute("title",de),se.textContent=we,se},b=v("image-preview-close",s,"\xD7"),h=document.createElement("div");h.className="image-preview-zoom-controls";let k=v("image-preview-zoom-button",o,"\u2212"),S=v("image-preview-zoom-reset",l,"100%"),y=v("image-preview-zoom-button",a,"+");h.append(k,S,y);let w=1,P=0,x=0,Y=null,L=()=>{if(w<=1){P=0,x=0;return}let G=Math.max(0,(m.offsetWidth*w-f.clientWidth)/2),de=Math.max(0,(m.offsetHeight*w-f.clientHeight)/2);P=Math.max(-G,Math.min(G,P)),x=Math.max(-de,Math.min(de,x))},U=()=>{L(),m.style.transform=`translate(${P}px, ${x}px) scale(${w})`,m.classList.toggle("is-zoomed",w>1),S.textContent=`${Math.round(w*100)}%`,k.disabled=w<=Kg,y.disabled=w>=zg},E=(G,de=null)=>{let we=w;if(w=Math.max(Kg,Math.min(zg,G)),w<=1)P=0,x=0;else if(de&&Number.isFinite(de.clientX)&&Number.isFinite(de.clientY)&&we>0&&w!==we){let se=f.getBoundingClientRect(),ve=de.clientX-(se.left+se.width/2),Ie=de.clientY-(se.top+se.height/2),ue=w/we;P=ve-(ve-P)*ue,x=Ie-(Ie-x)*ue}U()},oe=()=>{w=1,P=0,x=0,U()},q=null,I=null,T=null;g.length>1&&(q=document.createElement("button"),q.type="button",q.className="image-preview-navigation image-preview-previous",q.setAttribute("aria-label",n),q.setAttribute("title",n),q.innerHTML='<svg viewBox="0 0 24 24" aria-hidden="true"><path fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" d="m15 18-6-6 6-6"/></svg>',I=document.createElement("button"),I.type="button",I.className="image-preview-navigation image-preview-next",I.setAttribute("aria-label",r),I.setAttribute("title",r),I.innerHTML='<svg viewBox="0 0 24 24" aria-hidden="true"><path fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" d="m9 18 6-6-6-6"/></svg>',T=document.createElement("div"),T.className="image-preview-position",T.setAttribute("aria-live","polite"));let R=()=>{let G=g[p];m.src=G.src,m.alt=G.alt,f.setAttribute("aria-label",G.alt),T&&(T.textContent=typeof i=="function"?i(p+1,g.length):`${p+1} / ${g.length}`),oe()},M=G=>{p=(p+G+g.length)%g.length,R()};R(),f.append(m),q&&I&&T&&f.append(q,I,T),f.append(b,h),document.body.appendChild(f),f.offsetHeight,f.classList.add("visible"),b.focus();let $=!1,j=null,z=()=>{j&&clearTimeout(j),j=null,f.isConnected&&f.remove()},Q=()=>{$||($=!0,f.classList.remove("visible"),f.addEventListener("transitionend",z,{once:!0}),j=setTimeout(z,250),document.removeEventListener("keydown",ke),window.removeEventListener("resize",U),u?.isConnected&&typeof u.focus=="function"&&u.focus())},ae=()=>[q,I,k,S,y,b].filter(G=>G&&!G.disabled),ke=G=>{if(G.key==="Escape"){G.preventDefault(),Q();return}if(G.key==="+"||G.key==="="){G.preventDefault(),E(w+oi);return}if(G.key==="-"||G.key==="_"){G.preventDefault(),E(w-oi);return}if(G.key==="0"){G.preventDefault(),oe();return}if(g.length>1&&(G.key==="ArrowLeft"||G.key==="ArrowRight")){G.preventDefault(),M(G.key==="ArrowLeft"?-1:1);return}if(G.key==="Tab"){G.preventDefault();let de=ae(),we=de.indexOf(document.activeElement),se=G.shiftKey?-1:1,ve=we<0?0:(we+se+de.length)%de.length;de[ve]?.focus()}};b.addEventListener("click",Q),k.addEventListener("click",()=>E(w-oi)),S.addEventListener("click",oe),y.addEventListener("click",()=>E(w+oi)),q?.addEventListener("click",()=>M(-1)),I?.addEventListener("click",()=>M(1)),m.addEventListener("load",U),m.addEventListener("wheel",G=>{G.preventDefault();let de=G.deltaY<0?1:-1;E(w+de*oi,G)},{passive:!1}),m.addEventListener("pointerdown",G=>{w<=1||G.button!==0||(G.preventDefault(),Y={pointerId:G.pointerId,x:G.clientX,y:G.clientY,panX:P,panY:x},m.classList.add("is-dragging"),m.setPointerCapture?.(G.pointerId))}),m.addEventListener("pointermove",G=>{!Y||Y.pointerId!==G.pointerId||(P=Y.panX+G.clientX-Y.x,x=Y.panY+G.clientY-Y.y,U())});let N=G=>{!Y||Y.pointerId!==G.pointerId||(m.releasePointerCapture?.(G.pointerId),Y=null,m.classList.remove("is-dragging"))};return m.addEventListener("pointerup",N),m.addEventListener("pointercancel",N),f.addEventListener("click",G=>{G.target===f&&Q()}),document.addEventListener("keydown",ke),window.addEventListener("resize",U),f}var Kg,zg,oi,ai=B(()=>{Kg=.5,zg=4,oi=.25});function Fw(e){let t=[];for(let s of e)s==="\b"?t.pop():t.push(s);return t.join("")}function Ow(e){let t=e.split("\r"),s=t[t.length-1]||"";return Fw(s)}function Zg(e){return e.replace(/\r\n/g,`
456
456
  `).split(`
457
457
  `).map(t=>Ow(t)).join(`
458
458
  `)}function Jg(e){return e.replace($w,"").replace(Lw,"")}function qw(e){return e?e.split(";").filter(t=>t!=="").map(t=>Number(t)).filter(Number.isFinite):[0]}function Yg(e,t){let s=t==="bg"&&e>=30&&e<=37||t==="bg"&&e>=90&&e<=97?e+10:e;return t==="bg"?fc.get(s):gc.get(s)}function Gg(e,t,s){let n=hc[0],r=1/0;for(let i of hc){let o=(i.r-e)**2+(i.g-t)**2+(i.b-s)**2;o<r&&(n=i,r=o)}return n.code}function Vw(e){if(e<0||e>255)return null;if(e<16){let s=hc[e];return{r:s.r,g:s.g,b:s.b}}if(e>=232){let s=8+(e-232)*10;return{r:s,g:s,b:s}}let t=e-16;return{r:pc[Math.floor(t/36)],g:pc[Math.floor(t%36/6)],b:pc[t%6]}}function Qg(e,t,s,n){let r=s[n+1];if(r===5){let i=s[n+2];if(Number.isFinite(i)){let o=Vw(i);o&&(e[t]=Yg(Gg(o.r,o.g,o.b),t)||"")}return n+3}if(r===2){let i=s[n+2],o=s[n+3],a=s[n+4];return Number.isFinite(i)&&Number.isFinite(o)&&Number.isFinite(a)&&(e[t]=Yg(Gg(i,o,a),t)||""),n+5}return n+2}function Hw(e,t){let s={...e},n=t.length?t:[0];for(let r=0;r<n.length;){let i=n[r];if(i===0)s.fg="",s.bg="",s.bold=!1,s.dim=!1,s.italic=!1,s.underline=!1;else if(i===1)s.bold=!0,s.dim=!1;else if(i===2)s.dim=!0,s.bold=!1;else if(i===3)s.italic=!0;else if(i===4)s.underline=!0;else if(i===22)s.bold=!1,s.dim=!1;else if(i===23)s.italic=!1;else if(i===24)s.underline=!1;else if(i===39)s.fg="";else if(i===49)s.bg="";else if(gc.has(i))s.fg=gc.get(i);else if(fc.has(i))s.bg=fc.get(i);else if(i===38){r=Qg(s,"fg",n,r);continue}else if(i===48){r=Qg(s,"bg",n,r);continue}r+=1}return s}function Bw(e){return[e.fg,e.bg,e.bold&&"terminal-bold",e.dim&&"terminal-dim",e.italic&&"terminal-italic",e.underline&&"terminal-underline"].filter(Boolean).join(" ")}function Xg(e,t,s){let n=Jg(t);if(!n)return;let r=Bw(s),i=e[e.length-1];i&&i.className===r?i.text+=n:e.push({text:n,className:r})}function _s(e){if(e==null)return"";let t=typeof e=="string"?e:String(e);return t?Jg(Zg(t)):""}function ef(e){if(e==null)return[];let t=typeof e=="string"?e:String(e);if(!t)return[];let s=Zg(t),n=[],r={fg:"",bg:"",bold:!1,dim:!1,italic:!1,underline:!1},i=0;uc.lastIndex=0;for(let o=uc.exec(s);o;o=uc.exec(s))Xg(n,s.slice(i,o.index),r),r=Hw(r,qw(o[1])),i=o.index+o[0].length;return Xg(n,s.slice(i),r),n}var $w,uc,Lw,gc,fc,hc,pc,li=B(()=>{$w=/[\u001b\u009b](?:[\[\]()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><~]|\][^\u0007]*(?:\u0007|\u001b\\)|[PX^_][\s\S]*?\u001b\\)/g,uc=/(?:\u001b\[|\u009b)([0-9;]*)m/g,Lw=/[\u0000-\u0008\u000b\u000c\u000e-\u001a\u001c-\u001f\u007f-\u009f]/g,gc=new Map([[30,"terminal-fg-black"],[31,"terminal-fg-red"],[32,"terminal-fg-green"],[33,"terminal-fg-yellow"],[34,"terminal-fg-blue"],[35,"terminal-fg-magenta"],[36,"terminal-fg-cyan"],[37,"terminal-fg-white"],[90,"terminal-fg-bright-black"],[91,"terminal-fg-bright-red"],[92,"terminal-fg-bright-green"],[93,"terminal-fg-bright-yellow"],[94,"terminal-fg-bright-blue"],[95,"terminal-fg-bright-magenta"],[96,"terminal-fg-bright-cyan"],[97,"terminal-fg-bright-white"]]),fc=new Map([[40,"terminal-bg-black"],[41,"terminal-bg-red"],[42,"terminal-bg-green"],[43,"terminal-bg-yellow"],[44,"terminal-bg-blue"],[45,"terminal-bg-magenta"],[46,"terminal-bg-cyan"],[47,"terminal-bg-white"],[100,"terminal-bg-bright-black"],[101,"terminal-bg-bright-red"],[102,"terminal-bg-bright-green"],[103,"terminal-bg-bright-yellow"],[104,"terminal-bg-bright-blue"],[105,"terminal-bg-bright-magenta"],[106,"terminal-bg-bright-cyan"],[107,"terminal-bg-bright-white"]]),hc=[{code:30,r:0,g:0,b:0},{code:31,r:170,g:0,b:0},{code:32,r:0,g:170,b:0},{code:33,r:170,g:85,b:0},{code:34,r:0,g:0,b:170},{code:35,r:170,g:0,b:170},{code:36,r:0,g:170,b:170},{code:37,r:170,g:170,b:170},{code:90,r:85,g:85,b:85},{code:91,r:255,g:85,b:85},{code:92,r:85,g:255,b:85},{code:93,r:255,g:255,b:85},{code:94,r:85,g:85,b:255},{code:95,r:255,g:85,b:255},{code:96,r:85,g:255,b:255},{code:97,r:255,g:255,b:255}],pc=[0,95,135,175,215,255]});var ir,Po=B(()=>{ai();Qr();li();js();ir={name:"MessageItem",props:{message:{type:Object,required:!0},sessionActions:{type:Boolean,default:!1},externalAttachmentOpen:{type:Boolean,default:!1}},emits:["quote","edit-as-new","open-attachment"],template:`
@@ -550,14 +550,15 @@ They will restart after upgrading. {skipped} other Agent(s) will be skipped beca
550
550
  {{ displayContent }}
551
551
  </template>
552
552
  </div>
553
- `,setup(e,{emit:t}){let s=Pinia.useChatStore(),n=Vue.ref(!1),r=Vue.inject("t"),i=Vue.computed(()=>["message",e.message.type]),o=()=>{let h=e.message;return typeof h.timestamp=="number"&&h.timestamp>0?h.timestamp:typeof h.createdAt=="number"&&h.createdAt>0?h.createdAt:null},a=Vue.computed(()=>ls(o())),l=Vue.computed(()=>{let h=o();if(!h)return"";try{return new Date(h).toLocaleString()}catch{return""}}),c=Vue.computed(()=>_s(e.message.content||"")),d=Vue.computed(()=>Kp(e.message,r("message.you"))),u=()=>{n.value=!n.value},g=Vue.computed(()=>(Array.isArray(e.message?.attachments)?e.message.attachments:[]).filter(h=>h?.isImage&&h?.preview).map(h=>({attachment:h,src:h.preview,alt:h.name||r("message.imagePreview")})));return{messageClass:i,messageTime:a,messageTimeFull:l,displayContent:c,userQuote:d,showAttachments:n,toggleAttachments:u,previewAttachment:(h,k)=>{if(e.externalAttachmentOpen){t("open-attachment",{attachment:h,trigger:k});return}let S=g.value,b=S.findIndex(w=>w.attachment===h);b<0||Rs(S[b].src,{alt:S[b].alt,closeLabel:r("common.close"),previousLabel:r("message.previousImage"),nextLabel:r("message.nextImage"),positionLabel:(w,P)=>r("message.imagePosition",{current:w,total:P}),gallery:S.map(({src:w,alt:P})=>({src:w,alt:P})),initialIndex:b,trigger:k})},t:r,formatExpertLabel:h=>In(h,s.customExpertRoles),getAttachmentsText:h=>{if(!h||h.length===0)return"";let k=h.filter(w=>w.isImage).length,S=h.length-k,b=[];return k>0&&b.push(r("message.imageCount",{count:k})),S>0&&b.push(r("message.fileCount",{count:S})),b.join(r("common.comma"))},todoStatusSymbol:h=>h==="completed"?"\u2713":h==="in_progress"?"\u2192":"\u25CB",getFileIcon:h=>h?h.startsWith("image/")?"\u{1F5BC}\uFE0F":h.startsWith("video/")?"\u{1F3AC}":h.startsWith("audio/")?"\u{1F3B5}":h.includes("pdf")?"\u{1F4D5}":h.includes("word")||h.includes("document")?"\u{1F4DD}":h.includes("sheet")||h.includes("excel")?"\u{1F4CA}":h.includes("presentation")||h.includes("powerpoint")?"\u{1F4FD}\uFE0F":h.includes("zip")||h.includes("compressed")||h.includes("archive")?"\u{1F4E6}":h.includes("text")||h.includes("json")||h.includes("xml")?"\u{1F4C3}":"\u{1F4C4}":"\u{1F4C4}"}}}});function mc(e){let t=e&&typeof e.to=="string"&&e.to.trim()?e.to.trim():"?",s=t==="all"?"@all":`@${t}`,n=typeof e?.text=="string"?e.text.trim():"",r=typeof e?.reason=="string"?e.reason.trim():"";return{to:t,target:s,text:n,reason:r}}function tf(e,t=s=>s){let s=mc(e);return s.text?`Route ${s.target}: ${t(s.text,70)}`:`Route ${s.target}`}var vc=B(()=>{});var Ro,yc=B(()=>{li();Ro={name:"TerminalOutput",props:{content:{default:""}},template:`
553
+ `,setup(e,{emit:t}){let s=Pinia.useChatStore(),n=Vue.ref(!1),r=Vue.inject("t"),i=Vue.computed(()=>["message",e.message.type]),o=()=>{let h=e.message;return typeof h.timestamp=="number"&&h.timestamp>0?h.timestamp:typeof h.createdAt=="number"&&h.createdAt>0?h.createdAt:null},a=Vue.computed(()=>ls(o())),l=Vue.computed(()=>{let h=o();if(!h)return"";try{return new Date(h).toLocaleString()}catch{return""}}),c=Vue.computed(()=>_s(e.message.content||"")),d=Vue.computed(()=>Kp(e.message,r("message.you"))),u=()=>{n.value=!n.value},g=Vue.computed(()=>(Array.isArray(e.message?.attachments)?e.message.attachments:[]).filter(h=>h?.isImage&&h?.preview).map(h=>({attachment:h,src:h.preview,alt:h.name||r("message.imagePreview")})));return{messageClass:i,messageTime:a,messageTimeFull:l,displayContent:c,userQuote:d,showAttachments:n,toggleAttachments:u,previewAttachment:(h,k)=>{if(e.externalAttachmentOpen){t("open-attachment",{attachment:h,trigger:k});return}let S=g.value,y=S.findIndex(w=>w.attachment===h);y<0||Rs(S[y].src,{alt:S[y].alt,closeLabel:r("common.close"),previousLabel:r("message.previousImage"),nextLabel:r("message.nextImage"),positionLabel:(w,P)=>r("message.imagePosition",{current:w,total:P}),gallery:S.map(({src:w,alt:P})=>({src:w,alt:P})),initialIndex:y,trigger:k})},t:r,formatExpertLabel:h=>In(h,s.customExpertRoles),getAttachmentsText:h=>{if(!h||h.length===0)return"";let k=h.filter(w=>w.isImage).length,S=h.length-k,y=[];return k>0&&y.push(r("message.imageCount",{count:k})),S>0&&y.push(r("message.fileCount",{count:S})),y.join(r("common.comma"))},todoStatusSymbol:h=>h==="completed"?"\u2713":h==="in_progress"?"\u2192":"\u25CB",getFileIcon:h=>h?h.startsWith("image/")?"\u{1F5BC}\uFE0F":h.startsWith("video/")?"\u{1F3AC}":h.startsWith("audio/")?"\u{1F3B5}":h.includes("pdf")?"\u{1F4D5}":h.includes("word")||h.includes("document")?"\u{1F4DD}":h.includes("sheet")||h.includes("excel")?"\u{1F4CA}":h.includes("presentation")||h.includes("powerpoint")?"\u{1F4FD}\uFE0F":h.includes("zip")||h.includes("compressed")||h.includes("archive")?"\u{1F4E6}":h.includes("text")||h.includes("json")||h.includes("xml")?"\u{1F4C3}":"\u{1F4C4}":"\u{1F4C4}"}}}});function mc(e){let t=e&&typeof e.to=="string"&&e.to.trim()?e.to.trim():"?",s=t==="all"?"@all":`@${t}`,n=typeof e?.text=="string"?e.text.trim():"",r=typeof e?.reason=="string"?e.reason.trim():"";return{to:t,target:s,text:n,reason:r}}function tf(e,t=s=>s){let s=mc(e);return s.text?`Route ${s.target}: ${t(s.text,70)}`:`Route ${s.target}`}var vc=B(()=>{});var Ro,yc=B(()=>{li();Ro={name:"TerminalOutput",props:{content:{default:""}},template:`
554
554
  <pre class="terminal-output"><code><template v-for="(token, index) in tokens" :key="index"><span v-if="token.className" :class="token.className">{{ token.text }}</span><template v-else>{{ token.text }}</template></template></code></pre>
555
- `,setup(e){return{tokens:Vue.computed(()=>ef(e.content))}}}});var _o,bc=B(()=>{vc();li();yc();_o={name:"ToolLine",components:{TerminalOutput:Ro},props:{toolName:{type:String,required:!0},toolInput:{type:Object,default:null},toolResult:{default:null},hasResult:{type:Boolean,default:!1},compact:{type:Boolean,default:!1},startTime:{type:Number,default:0},expanded:{type:Boolean,default:null}},emits:["update:expanded"],template:`
555
+ `,setup(e){return{tokens:Vue.computed(()=>ef(e.content))}}}});var _o,bc=B(()=>{vc();li();yc();_o={name:"ToolLine",components:{TerminalOutput:Ro},props:{toolName:{type:String,required:!0},toolInput:{type:Object,default:null},toolResult:{default:null},hasResult:{type:Boolean,default:!1},isError:{type:Boolean,default:!1},compact:{type:Boolean,default:!1},startTime:{type:Number,default:0},expanded:{type:Boolean,default:null}},emits:["update:expanded"],template:`
556
556
  <div>
557
- <div class="tool-line" :class="{ expandable: hasExpandableContent, expanded: isExpanded, completed: hasResult, running: !hasResult }" @click="toggle">
557
+ <div class="tool-line" :class="{ expandable: hasExpandableContent, expanded: isExpanded, completed: hasResult && !isError, error: isError, running: !hasResult && !isError }" @click="toggle">
558
558
  <span class="tool-line-icon">{{ getToolIcon(toolName) }}</span>
559
559
  <span class="tool-line-text">{{ getToolOneLine(toolName, toolInput) }}</span>
560
- <span class="tool-line-status completed" v-if="hasResult">\u2713</span>
560
+ <span class="tool-line-status error" v-if="isError">\u2715</span>
561
+ <span class="tool-line-status completed" v-else-if="hasResult">\u2713</span>
561
562
  <span class="tool-line-status running" v-else><span class="tool-dots"><span></span><span></span><span></span></span></span>
562
563
  <span class="tool-line-time" v-if="formattedTime">{{ formattedTime }}</span>
563
564
  <span class="tool-line-toggle" v-if="hasExpandableContent" @click.stop="toggle">
@@ -587,11 +588,11 @@ They will restart after upgrading. {skipped} other Agent(s) will be skipped beca
587
588
  </div>
588
589
  </div>
589
590
  </div>
590
- `,setup(e,{emit:t}){let s=Vue.ref(e.toolName==="Edit"),n=Vue.computed(()=>e.expanded===null?s.value:!!e.expanded),r=b=>{s.value=!!b,t("update:expanded",!!b)},i=Vue.computed(()=>{if(!e.startTime)return"";let b=new Date(e.startTime),w=b.getHours().toString().padStart(2,"0"),P=b.getMinutes().toString().padStart(2,"0"),x=b.getSeconds().toString().padStart(2,"0");return`${w}:${P}:${x}`}),o=Vue.computed(()=>e.toolName==="Edit"),a=Vue.computed(()=>{let b=e.toolInput;return b&&b.old_string!==void 0&&b.new_string!==void 0}),l=Vue.computed(()=>{let b=e.toolInput;return b?e.toolName==="Edit"?a.value:e.toolName==="Bash"?!!(b.command?.length>60||e.hasResult):e.toolName==="Read"?!!b.file_path:e.toolName==="Write"?!!b.content:Object.keys(b).length>0:!1}),c=b=>{if(!b)return"";if(typeof b=="string")return b;if(Array.isArray(b))return b.map(w=>typeof w=="string"?w:w?.type==="text"?w.text:"").filter(Boolean).join(`
591
- `);if(b?.type==="text"&&b?.text)return b.text;if(b?.content){if(typeof b.content=="string")return b.content;if(Array.isArray(b.content))return b.content.map(w=>typeof w=="string"?w:w?.type==="text"?w.text:"").filter(Boolean).join(`
592
- `)}return""},d=Vue.computed(()=>e.toolName!=="Bash"?"":c(e.toolResult)),u=Vue.computed(()=>e.toolName!=="__SubagentResult"?"":_s(e.toolInput?.result||e.toolInput?.summary||S(e.toolInput))),g=Vue.computed(()=>e.toolName!=="__CompactSummary"?"":_s(e.toolInput?.summary||S(e.toolInput))),p=()=>{l.value&&r(!n.value)},f=(b,w=80)=>{if(!b||b.length<=w)return b||"";let P=Math.ceil(w*.6),x=w-P-3;return b.slice(0,P)+"..."+b.slice(-x)},m=b=>({Read:"\u{1F4D6}",Edit:"\u270F\uFE0F",Write:"\u{1F4DD}",Bash:"\u26A1",Glob:"\u{1F50D}",Grep:"\u{1F50E}",Task:"\u{1F4CB}",WebFetch:"\u{1F310}",WebSearch:"\u{1F50D}",TodoWrite:"\u2705",RouteForward:"@",__SubagentResult:"\u{1F916}",__CompactSummary:"\u{1F4DA}"})[b]||"\u2699\uFE0F",v=b=>_s(b).replace(/\s+/g," ").trim(),y=(b,w)=>{if(!w)return b;if(b==="Read"&&w.file_path){let P=`Read ${w.file_path}`;if(w.offset||w.limit){let x=(w.offset||0)+1,Y=w.limit?x+w.limit-1:"\u221E";P+=`:${x}-${Y}`}return P}if(b==="Edit"&&w.file_path)return`Edit ${w.file_path}`;if(b==="Write"&&w.file_path)return`Write ${w.file_path}`;if(b==="Bash"&&w.command){let P=w.command;return f(P,80)}if(b==="Glob"&&w.pattern)return`Glob ${w.pattern}`+(w.path?` in ${w.path}`:"");if(b==="Grep"&&w.pattern){let P=`Grep "${w.pattern}"`;return w.path&&(P+=` in ${w.path}`),w.glob&&(P+=` (${w.glob})`),P}if(b==="Task"){let P=w.subagent_type||"agent",x=w.description||f(w.prompt||"",40);return`Task [${P}]: ${x}`}if(b==="WebFetch"&&w.url)try{let P=new URL(w.url);return`Fetch ${P.hostname}${P.pathname.length>20?f(P.pathname,20):P.pathname}`}catch{return`Fetch ${w.url.slice(0,50)}`}if(b==="WebSearch"&&w.query)return`Search "${w.query}"`;if(b==="TodoWrite"&&w.todos)return`Todo: ${w.todos.filter(x=>x.status==="completed").length}/${w.todos.length} done`;if(b==="RouteForward")return tf(w,f);if(b==="__SubagentResult"){let P=v(w.summary||w.status||"completed");return`Sub-agent: ${f(P,80)}`}return b==="__CompactSummary"?`Context summarized (${_s(w.summary||"").length} chars)`:b},h=b=>{let w=document.createElement("div");return w.textContent=b,w.innerHTML},k=b=>{if(!b||b.old_string===void 0||b.new_string===void 0)return"";let w='<div class="diff-compact">';return b.old_string.split(`
593
- `).forEach(P=>{w+=`<div class="diff-line del">- ${h(P)}</div>`}),b.new_string.split(`
594
- `).forEach(P=>{w+=`<div class="diff-line add">+ ${h(P)}</div>`}),w+="</div>",w},S=b=>{try{return JSON.stringify(b,null,2)}catch{return String(b)}};return{isExpanded:n,isEditTool:o,hasDiff:a,hasExpandableContent:l,bashOutput:d,syntheticResultOutput:u,compactSummaryOutput:g,formattedTime:i,toggle:p,getToolIcon:m,getToolOneLine:y,renderDiff:k,formatInput:S}}}});var sf,nf=B(()=>{sf={name:"AskCard",props:{askMsg:{type:Object,required:!0},compact:{type:Boolean,default:!1}},emits:["submit"],template:`
591
+ `,setup(e,{emit:t}){let s=Vue.ref(e.toolName==="Edit"),n=Vue.computed(()=>e.expanded===null?s.value:!!e.expanded),r=y=>{s.value=!!y,t("update:expanded",!!y)},i=Vue.computed(()=>{if(!e.startTime)return"";let y=new Date(e.startTime),w=y.getHours().toString().padStart(2,"0"),P=y.getMinutes().toString().padStart(2,"0"),x=y.getSeconds().toString().padStart(2,"0");return`${w}:${P}:${x}`}),o=Vue.computed(()=>e.toolName==="Edit"),a=Vue.computed(()=>{let y=e.toolInput;return y&&y.old_string!==void 0&&y.new_string!==void 0}),l=Vue.computed(()=>{let y=e.toolInput;return y?e.toolName==="Edit"?a.value:e.toolName==="Bash"?!!(y.command?.length>60||e.hasResult):e.toolName==="Read"?!!y.file_path:e.toolName==="Write"?!!y.content:Object.keys(y).length>0:!1}),c=y=>{if(!y)return"";if(typeof y=="string")return y;if(Array.isArray(y))return y.map(w=>typeof w=="string"?w:w?.type==="text"?w.text:"").filter(Boolean).join(`
592
+ `);if(y?.type==="text"&&y?.text)return y.text;if(y?.content){if(typeof y.content=="string")return y.content;if(Array.isArray(y.content))return y.content.map(w=>typeof w=="string"?w:w?.type==="text"?w.text:"").filter(Boolean).join(`
593
+ `)}return""},d=Vue.computed(()=>e.toolName!=="Bash"?"":c(e.toolResult)),u=Vue.computed(()=>e.toolName!=="__SubagentResult"?"":_s(e.toolInput?.result||e.toolInput?.summary||S(e.toolInput))),g=Vue.computed(()=>e.toolName!=="__CompactSummary"?"":_s(e.toolInput?.summary||S(e.toolInput))),p=()=>{l.value&&r(!n.value)},f=(y,w=80)=>{if(!y||y.length<=w)return y||"";let P=Math.ceil(w*.6),x=w-P-3;return y.slice(0,P)+"..."+y.slice(-x)},m=y=>({Read:"\u{1F4D6}",Edit:"\u270F\uFE0F",Write:"\u{1F4DD}",Bash:"\u26A1",Glob:"\u{1F50D}",Grep:"\u{1F50E}",Task:"\u{1F4CB}",WebFetch:"\u{1F310}",WebSearch:"\u{1F50D}",TodoWrite:"\u2705",RouteForward:"@",__SubagentResult:"\u{1F916}",__CompactSummary:"\u{1F4DA}"})[y]||"\u2699\uFE0F",v=y=>_s(y).replace(/\s+/g," ").trim(),b=(y,w)=>{if(!w)return y;if(w.displayResource)return`${y} ${w.displayResource}`;if(y==="Read"&&w.file_path){let P=`Read ${w.file_path}`;if(w.offset||w.limit){let x=(w.offset||0)+1,Y=w.limit?x+w.limit-1:"\u221E";P+=`:${x}-${Y}`}return P}if(y==="Edit"&&w.file_path)return`Edit ${w.file_path}`;if(y==="Write"&&w.file_path)return`Write ${w.file_path}`;if(y==="Bash"&&w.command){let P=w.command;return f(P,80)}if(y==="Glob"&&w.pattern)return`Glob ${w.pattern}`+(w.path?` in ${w.path}`:"");if(y==="Grep"&&w.pattern){let P=`Grep "${w.pattern}"`;return w.path&&(P+=` in ${w.path}`),w.glob&&(P+=` (${w.glob})`),P}if(y==="Task"){let P=w.subagent_type||"agent",x=w.description||f(w.prompt||"",40);return`Task [${P}]: ${x}`}if(y==="WebFetch"&&w.url)try{let P=new URL(w.url);return`Fetch ${P.hostname}${P.pathname.length>20?f(P.pathname,20):P.pathname}`}catch{return`Fetch ${w.url.slice(0,50)}`}if(y==="WebSearch"&&w.query)return`Search "${w.query}"`;if(y==="TodoWrite"&&w.todos)return`Todo: ${w.todos.filter(x=>x.status==="completed").length}/${w.todos.length} done`;if(y==="RouteForward")return tf(w,f);if(y==="__SubagentResult"){let P=v(w.summary||w.status||"completed");return`Sub-agent: ${f(P,80)}`}return y==="__CompactSummary"?`Context summarized (${_s(w.summary||"").length} chars)`:y},h=y=>{let w=document.createElement("div");return w.textContent=y,w.innerHTML},k=y=>{if(!y||y.old_string===void 0||y.new_string===void 0)return"";let w='<div class="diff-compact">';return y.old_string.split(`
594
+ `).forEach(P=>{w+=`<div class="diff-line del">- ${h(P)}</div>`}),y.new_string.split(`
595
+ `).forEach(P=>{w+=`<div class="diff-line add">+ ${h(P)}</div>`}),w+="</div>",w},S=y=>{try{return JSON.stringify(y,null,2)}catch{return String(y)}};return{isExpanded:n,isEditTool:o,hasDiff:a,hasExpandableContent:l,bashOutput:d,syntheticResultOutput:u,compactSummaryOutput:g,formattedTime:i,toggle:p,getToolIcon:m,getToolOneLine:b,renderDiff:k,formatInput:S}}}});var sf,nf=B(()=>{sf={name:"AskCard",props:{askMsg:{type:Object,required:!0},compact:{type:Boolean,default:!1}},emits:["submit"],template:`
595
596
  <div class="ask-card-wrapper">
596
597
  <!-- Only an Agent acknowledgement or durable history confirms success. -->
597
598
  <div v-if="isAnswered" class="ask-summary">
@@ -685,7 +686,7 @@ They will restart after upgrading. {skipped} other Agent(s) will be skipped beca
685
686
  </div>
686
687
  </div>
687
688
  </div>
688
- `,setup(e,{emit:t}){let s=Vue.reactive({}),n=Vue.reactive({}),r=Vue.ref(Date.now()),i=null;Vue.watch(()=>[e.askMsg.askPending,e.askMsg.askSubmittedAt],()=>{if(i&&clearTimeout(i),i=null,r.value=Date.now(),e.askMsg.askPending){let h=Math.max(0,(e.askMsg.askSubmittedAt||0)+15e3-r.value);h&&(i=setTimeout(()=>{r.value=Date.now()},h))}},{immediate:!0}),Vue.onBeforeUnmount(()=>{i&&clearTimeout(i)});let o=Vue.computed(()=>!!e.askMsg.askPending&&r.value>=(e.askMsg.askSubmittedAt||0)+15e3),a=Vue.computed(()=>({send_failed:"message.askSendFailed",agent_unavailable:"message.askAgentUnavailable",identity_mismatch:"message.askIdentityMismatch",unavailable:"message.askExpired"})[e.askMsg.askError]||null),l=()=>{o.value&&e.askMsg.askRequestId&&e.askMsg.pendingAnswers&&t("submit",e.askMsg.askRequestId,e.askMsg.pendingAnswers)},c=Vue.computed(()=>{let h=e.askMsg;return h&&(!!h.askAnswered||!!h.selectedAnswers)}),d=Vue.computed(()=>{let h=e.askMsg;return h?!!h.askExpired||!h.askRequestId&&!h.askAnswered&&!h.selectedAnswers&&!!h.isHistory:!1}),u=Vue.computed(()=>{let h=e.askMsg;return h?.askQuestions||h?.toolInput?.questions||[]}),g=(h,k)=>{let S=s[h];return Array.isArray(S)?S.includes(k):S===k},p=(h,k)=>{if(!c.value)if(n[h.question]="",h.multiSelect){let S=s[h.question]||[],b=Array.isArray(S)?[...S]:[],w=b.indexOf(k.label);w>=0?b.splice(w,1):b.push(k.label),s[h.question]=b}else s[h.question]=k.label},f=(h,k)=>{n[h]=k,k&&delete s[h]},m=Vue.computed(()=>{let h=u.value;return!h||h.length===0?!1:h.some(k=>{let S=s[k.question];return n[k.question]?!0:Array.isArray(S)?S.length>0:!!S})}),v=()=>{if(c.value||e.askMsg.askPending||!m.value)return;let h=u.value,k={};for(let b of h){let w=n[b.question];if(w)k[b.question]=w;else{let P=s[b.question];Array.isArray(P)&&P.length>0?k[b.question]=P.join(", "):P&&(k[b.question]=P)}}let S=e.askMsg.askRequestId;S&&t("submit",S,k)},y=Vue.computed(()=>{let h=e.askMsg?.selectedAnswers||e.askMsg?.pendingAnswers;return h?Object.values(h).filter(S=>S&&S!=="-").join(", "):""});return{isAnswered:c,isExpired:d,canRetry:o,retryAnswers:l,errorKey:a,questions:u,isOptionSelected:g,selectOption:p,setCustomAnswer:f,customAnswers:n,hasAnySelection:m,submitAnswers:v,summaryText:y}}}});var rf,of=B(()=>{sr();rf={name:"VpBadge",props:{vpId:{type:String,required:!0},size:{type:Number,default:20},showSubtitle:{type:Boolean,default:!1},status:{type:String,default:null},typing:{type:Boolean,default:!1},compact:{type:Boolean,default:!1}},template:`
689
+ `,setup(e,{emit:t}){let s=Vue.reactive({}),n=Vue.reactive({}),r=Vue.ref(Date.now()),i=null;Vue.watch(()=>[e.askMsg.askPending,e.askMsg.askSubmittedAt],()=>{if(i&&clearTimeout(i),i=null,r.value=Date.now(),e.askMsg.askPending){let h=Math.max(0,(e.askMsg.askSubmittedAt||0)+15e3-r.value);h&&(i=setTimeout(()=>{r.value=Date.now()},h))}},{immediate:!0}),Vue.onBeforeUnmount(()=>{i&&clearTimeout(i)});let o=Vue.computed(()=>!!e.askMsg.askPending&&r.value>=(e.askMsg.askSubmittedAt||0)+15e3),a=Vue.computed(()=>({send_failed:"message.askSendFailed",agent_unavailable:"message.askAgentUnavailable",identity_mismatch:"message.askIdentityMismatch",unavailable:"message.askExpired"})[e.askMsg.askError]||null),l=()=>{o.value&&e.askMsg.askRequestId&&e.askMsg.pendingAnswers&&t("submit",e.askMsg.askRequestId,e.askMsg.pendingAnswers)},c=Vue.computed(()=>{let h=e.askMsg;return h&&(!!h.askAnswered||!!h.selectedAnswers)}),d=Vue.computed(()=>{let h=e.askMsg;return h?!!h.askExpired||!h.askRequestId&&!h.askAnswered&&!h.selectedAnswers&&!!h.isHistory:!1}),u=Vue.computed(()=>{let h=e.askMsg;return h?.askQuestions||h?.toolInput?.questions||[]}),g=(h,k)=>{let S=s[h];return Array.isArray(S)?S.includes(k):S===k},p=(h,k)=>{if(!c.value)if(n[h.question]="",h.multiSelect){let S=s[h.question]||[],y=Array.isArray(S)?[...S]:[],w=y.indexOf(k.label);w>=0?y.splice(w,1):y.push(k.label),s[h.question]=y}else s[h.question]=k.label},f=(h,k)=>{n[h]=k,k&&delete s[h]},m=Vue.computed(()=>{let h=u.value;return!h||h.length===0?!1:h.some(k=>{let S=s[k.question];return n[k.question]?!0:Array.isArray(S)?S.length>0:!!S})}),v=()=>{if(c.value||e.askMsg.askPending||!m.value)return;let h=u.value,k={};for(let y of h){let w=n[y.question];if(w)k[y.question]=w;else{let P=s[y.question];Array.isArray(P)&&P.length>0?k[y.question]=P.join(", "):P&&(k[y.question]=P)}}let S=e.askMsg.askRequestId;S&&t("submit",S,k)},b=Vue.computed(()=>{let h=e.askMsg?.selectedAnswers||e.askMsg?.pendingAnswers;return h?Object.values(h).filter(S=>S&&S!=="-").join(", "):""});return{isAnswered:c,isExpired:d,canRetry:o,retryAnswers:l,errorKey:a,questions:u,isOptionSelected:g,selectOption:p,setCustomAnswer:f,customAnswers:n,hasAnySelection:m,submitAnswers:v,summaryText:b}}}});var rf,of=B(()=>{sr();rf={name:"VpBadge",props:{vpId:{type:String,required:!0},size:{type:Number,default:20},showSubtitle:{type:Boolean,default:!1},status:{type:String,default:null},typing:{type:Boolean,default:!1},compact:{type:Boolean,default:!1}},template:`
689
690
  <span class="vp-badge" :class="{ compact }">
690
691
  <span class="vp-badge-text">
691
692
  <span class="vp-badge-name" :style="nameStyle">{{ displayName }}</span>
@@ -727,7 +728,7 @@ They will restart after upgrading. {skipped} other Agent(s) will be skipped beca
727
728
  `:""}`}catch{return t?`<div class="math-fallback">${s}</div>
728
729
  `:s}}function uf(){return[{name:"blockMath",level:"block",start(e){return e.match(/(?:^|\n) {0,3}(?:\$\$|\\\[)/)?.index},tokenizer(e){let t=/^( {0,3})(\$\$|\\\[)/.exec(e);if(!t)return;let s=t[2]==="$$"?"$$":"\\]",n=cf(e,s,t[0].length);return n<0||!/^[ \t]*(?:\n|$)/.test(e.slice(n+s.length))?void 0:{type:"blockMath",raw:e.slice(0,n+s.length),formula:e.slice(t[0].length,n).trim(),display:!0}},renderer(e){return df(e,!0)}},{name:"inlineMath",level:"inline",start(e){let t=e.search(/\$|\\[([]/);return t===-1?void 0:t},tokenizer(e){if(this.lexer.state.inRawBlock)return;let t=/^(\$\$|\$|\\\(|\\\[)/.exec(e)?.[0];if(!t)return;let s=t==="\\("?"\\)":t==="\\["?"\\]":t,n=cf(e,s,t.length);if(n<0)return t!=="$"?{type:"inlineMath",raw:e.split(`
729
730
  `)[0]}:void 0;let r=e.slice(t.length,n);if(!r.includes(`
730
- `)&&!(t==="$"&&(!r||r.includes("`")||/^\s|\s$/.test(r)||/\d/.test(e[n+1]||"")||e[n+1]==="$")))return{type:"inlineMath",raw:e.slice(0,n+s.length),formula:r,display:t==="$$"||t==="\\["}},renderer(e){return df(e)}}]}var pf=B(()=>{});function kc(e,t){return`${String(e||"mermaid-diagram").replace(/[^a-z0-9_-]+/gi,"-").replace(/^-+|-+$/g,"")||"mermaid-diagram"}.${t}`}function Uw(e){if(typeof document>"u")return String(e||"").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&").replace(/&quot;/g,'"').replace(/&#39;/g,"'");let t=document.createElement("textarea");return t.innerHTML=String(e||""),t.value}function Kw(e,t){return e!=="mermaid"?"":` data-mermaid-source="${encodeURIComponent(Uw(t))}"`}function zw(e){let t=e?.dataset?.mermaidSource;if(!t)return"";try{return decodeURIComponent(t)}catch{return""}}function mf(e,t){let s=document.createElement("a");s.href=e,s.download=t,document.body.appendChild(s),s.click(),s.remove()}function vf(e,t){let s=URL.createObjectURL(e);mf(s,t),setTimeout(()=>URL.revokeObjectURL(s),0)}function Yw(e){let t=o=>{let a=Number.parseFloat(String(o||"").replace("px",""));return Number.isFinite(a)&&a>0?a:null},s=t(e.getAttribute("width")),n=t(e.getAttribute("height"));if(s&&n)return{width:s,height:n};let r=e.getAttribute("viewBox");if(r){let o=r.trim().split(/\s+/).map(Number.parseFloat);if(o.length===4&&o.every(a=>Number.isFinite(a))&&o[2]>0&&o[3]>0)return{width:o[2],height:o[3]}}let i=e.getBoundingClientRect?.();return i?.width&&i?.height?{width:i.width,height:i.height}:{width:1200,height:800}}function yf(e,t){return typeof getComputedStyle>"u"||typeof document>"u"?t:getComputedStyle(document.documentElement).getPropertyValue(e).trim()||t}function Gw(e,t,s){e.setAttribute("xmlns","http://www.w3.org/2000/svg"),e.setAttribute("width",String(t)),e.setAttribute("height",String(s)),e.getAttribute("viewBox")||e.setAttribute("viewBox",`0 0 ${t} ${s}`)}async function Qw(e,t,s,n){if(!window.htmlToImage)return!1;let r=kc("mermaid-diagram",t==="jpg"?"jpg":"png"),i={backgroundColor:yf("--bg-main","white"),height:n,pixelRatio:Math.max(1,Math.min(3,window.devicePixelRatio||1)),style:{margin:"0"},width:s},o=t==="jpg"?await window.htmlToImage.toJpeg(e,{...i,quality:.92}):await window.htmlToImage.toPng(e,i);return mf(o,r),!0}async function hf(e,t){let s=e.querySelector("svg");if(!s)throw new Error("No Mermaid SVG found");let{width:n,height:r}=Yw(s);try{if(await Qw(s,t,n,r))return}catch{}let i=s.cloneNode(!0);Gw(i,n,r);let o=new XMLSerializer().serializeToString(i),a=new Blob([o],{type:"image/svg+xml;charset=utf-8"}),l=URL.createObjectURL(a);try{let c=new Image,d=new Promise((v,y)=>{c.onload=v,c.onerror=()=>y(new Error("Failed to load Mermaid SVG for export"))});c.src=l,await d;let u=Math.max(1,Math.min(3,window.devicePixelRatio||1)),g=document.createElement("canvas");g.width=Math.ceil(n*u),g.height=Math.ceil(r*u);let p=g.getContext("2d");if(!p)throw new Error("Canvas is not available");p.scale(u,u),t==="jpg"&&(p.fillStyle=yf("--bg-main","white"),p.fillRect(0,0,n,r)),p.drawImage(c,0,0,n,r);let f=t==="jpg"?"image/jpeg":"image/png",m=await new Promise((v,y)=>{g.toBlob(h=>h?v(h):y(new Error("Failed to export Mermaid image")),f,.92)});vf(m,kc("mermaid-diagram",t==="jpg"?"jpg":"png"))}finally{URL.revokeObjectURL(l)}}function Xw(e){let t=`\`\`\`mermaid
731
+ `)&&!(t==="$"&&(!r||r.includes("`")||/^\s|\s$/.test(r)||/\d/.test(e[n+1]||"")||e[n+1]==="$")))return{type:"inlineMath",raw:e.slice(0,n+s.length),formula:r,display:t==="$$"||t==="\\["}},renderer(e){return df(e)}}]}var pf=B(()=>{});function kc(e,t){return`${String(e||"mermaid-diagram").replace(/[^a-z0-9_-]+/gi,"-").replace(/^-+|-+$/g,"")||"mermaid-diagram"}.${t}`}function Uw(e){if(typeof document>"u")return String(e||"").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&").replace(/&quot;/g,'"').replace(/&#39;/g,"'");let t=document.createElement("textarea");return t.innerHTML=String(e||""),t.value}function Kw(e,t){return e!=="mermaid"?"":` data-mermaid-source="${encodeURIComponent(Uw(t))}"`}function zw(e){let t=e?.dataset?.mermaidSource;if(!t)return"";try{return decodeURIComponent(t)}catch{return""}}function mf(e,t){let s=document.createElement("a");s.href=e,s.download=t,document.body.appendChild(s),s.click(),s.remove()}function vf(e,t){let s=URL.createObjectURL(e);mf(s,t),setTimeout(()=>URL.revokeObjectURL(s),0)}function Yw(e){let t=o=>{let a=Number.parseFloat(String(o||"").replace("px",""));return Number.isFinite(a)&&a>0?a:null},s=t(e.getAttribute("width")),n=t(e.getAttribute("height"));if(s&&n)return{width:s,height:n};let r=e.getAttribute("viewBox");if(r){let o=r.trim().split(/\s+/).map(Number.parseFloat);if(o.length===4&&o.every(a=>Number.isFinite(a))&&o[2]>0&&o[3]>0)return{width:o[2],height:o[3]}}let i=e.getBoundingClientRect?.();return i?.width&&i?.height?{width:i.width,height:i.height}:{width:1200,height:800}}function yf(e,t){return typeof getComputedStyle>"u"||typeof document>"u"?t:getComputedStyle(document.documentElement).getPropertyValue(e).trim()||t}function Gw(e,t,s){e.setAttribute("xmlns","http://www.w3.org/2000/svg"),e.setAttribute("width",String(t)),e.setAttribute("height",String(s)),e.getAttribute("viewBox")||e.setAttribute("viewBox",`0 0 ${t} ${s}`)}async function Qw(e,t,s,n){if(!window.htmlToImage)return!1;let r=kc("mermaid-diagram",t==="jpg"?"jpg":"png"),i={backgroundColor:yf("--bg-main","white"),height:n,pixelRatio:Math.max(1,Math.min(3,window.devicePixelRatio||1)),style:{margin:"0"},width:s},o=t==="jpg"?await window.htmlToImage.toJpeg(e,{...i,quality:.92}):await window.htmlToImage.toPng(e,i);return mf(o,r),!0}async function hf(e,t){let s=e.querySelector("svg");if(!s)throw new Error("No Mermaid SVG found");let{width:n,height:r}=Yw(s);try{if(await Qw(s,t,n,r))return}catch{}let i=s.cloneNode(!0);Gw(i,n,r);let o=new XMLSerializer().serializeToString(i),a=new Blob([o],{type:"image/svg+xml;charset=utf-8"}),l=URL.createObjectURL(a);try{let c=new Image,d=new Promise((v,b)=>{c.onload=v,c.onerror=()=>b(new Error("Failed to load Mermaid SVG for export"))});c.src=l,await d;let u=Math.max(1,Math.min(3,window.devicePixelRatio||1)),g=document.createElement("canvas");g.width=Math.ceil(n*u),g.height=Math.ceil(r*u);let p=g.getContext("2d");if(!p)throw new Error("Canvas is not available");p.scale(u,u),t==="jpg"&&(p.fillStyle=yf("--bg-main","white"),p.fillRect(0,0,n,r)),p.drawImage(c,0,0,n,r);let f=t==="jpg"?"image/jpeg":"image/png",m=await new Promise((v,b)=>{g.toBlob(h=>h?v(h):b(new Error("Failed to export Mermaid image")),f,.92)});vf(m,kc("mermaid-diagram",t==="jpg"?"jpg":"png"))}finally{URL.revokeObjectURL(l)}}function Xw(e){let t=`\`\`\`mermaid
731
732
  ${String(e||"").trim()}
732
733
  \`\`\`
733
734
  `;vf(new Blob([t],{type:"text/markdown;charset=utf-8"}),kc("mermaid-diagram","md"))}function Zw(e,t){let s=document.createElement("div");s.className="mermaid-export-controls",s.setAttribute("aria-label",Oe("mermaid.export"));let n=[{label:Oe("mermaid.exportMd"),action:()=>Xw(t)},{label:Oe("mermaid.exportPng"),action:()=>hf(e,"png")},{label:Oe("mermaid.exportJpg"),action:()=>hf(e,"jpg")}];for(let r of n){let i=document.createElement("button");i.type="button",i.className="mermaid-export-btn",i.textContent=r.label,i.title=r.label,i.addEventListener("click",async o=>{o.preventDefault(),o.stopPropagation();try{await r.action()}catch{}}),s.appendChild(i)}return s}function Sc(){gf||typeof marked>"u"||(marked.setOptions({highlight:(e,t)=>{if(typeof hljs<"u"&&t&&hljs.getLanguage(t))try{return hljs.highlight(e,{language:t}).value}catch{}return e},breaks:!0,gfm:!0}),marked.use?.({extensions:uf()}),gf=!0)}function Jw(e){return e.replace(/<pre><code([^>]*)>([\s\S]*?)<\/code><\/pre>/g,(t,s,n)=>{let r=s.match(/class="language-(\w+)"/),i=r?r[1]:"",o=Kw(i,n);return`<div class="code-block-wrapper">
@@ -829,6 +830,7 @@ ${String(e||"").trim()}
829
830
  :tool-input="tool.toolInput"
830
831
  :tool-result="tool.toolResult"
831
832
  :has-result="!!tool.hasResult"
833
+ :is-error="!!tool.isError"
832
834
  :start-time="tool.startTime"
833
835
  :expanded="toolExpandedValue(tool, i, 'history')"
834
836
  @update:expanded="value => updateToolExpanded(tool, i, 'history', value)"
@@ -848,6 +850,7 @@ ${String(e||"").trim()}
848
850
  :tool-input="latestTool.toolInput"
849
851
  :tool-result="latestTool.toolResult"
850
852
  :has-result="!!latestTool.hasResult"
853
+ :is-error="!!latestTool.isError"
851
854
  :start-time="latestTool.startTime"
852
855
  :expanded="toolExpandedValue(latestTool, latestToolIndex, 'latest')"
853
856
  @update:expanded="value => updateToolExpanded(latestTool, latestToolIndex, 'latest', value)"
@@ -947,7 +950,7 @@ ${String(e||"").trim()}
947
950
  <!-- H2.f.6: Fork-from-here button removed (single-conversation model). -->
948
951
  </div>
949
952
  </div>
950
- `,setup(e,{emit:t}){let s=Pinia.useChatStore(),n=Vue.ref(!1),r=Vue.ref(!1),i=Vue.ref(!1),o=Vue.computed(()=>e.actionsExpanded===null?i.value:!!e.actionsExpanded),a=W=>{i.value=!!W,t("update-actions-expanded",!!W)},l=Vue.ref(!1),c=Vue.ref(null),d=Vue.reactive(new Set),u=Vue.reactive(new Map),g=Vue.reactive(new Map),p=new Map,f=new Map,m=new Set,v=new Set,y=new Set,h=new Map,k=new Map,S="",b=null,w=null,P=Vue.inject("t"),x=(W,ie)=>{s.answerUserQuestion(W,ie,e.conversationId||void 0)},Y=Vue.computed(()=>(Array.isArray(e.turn?.toolMsgs)?e.turn.toolMsgs:[]).filter(ie=>ie?.toolName==="RouteForward").map((ie,me)=>({...mc(ie.toolInput||{}),key:ie.toolId||`${ie.startTime||0}:${me}`}))),L=Vue.computed(()=>(Array.isArray(e.turn?.toolMsgs)?e.turn.toolMsgs:[]).filter(ie=>ie?.toolName!=="RouteForward")),U=Vue.computed(()=>L.value.length>0),E=Vue.computed(()=>{let W=L.value;return W[W.length-1]}),oe=Vue.computed(()=>L.value.slice(0,-1)),q=Vue.computed(()=>Math.max(0,L.value.length-1)),I=Vue.computed(()=>{let W=e.turn?.todoMsg?.toolInput?.todos;return Array.isArray(W)?W.map(ie=>af(e.turn,ie)):[]}),T=()=>{a(!o.value)},R=(W,ie,me)=>{let he=e.toolStatePrefix||e.turn.id||e.turn.turnId||"assistant-turn",Ee=W?.toolName||"tool",Ue=W?.startTime||ie;return`${he}:tool:${me}:${ie}:${Ee}:${Ue}`},M=(W,ie,me)=>{let he=R(W,ie,me);return e.toolExpandStates&&Object.prototype.hasOwnProperty.call(e.toolExpandStates,he)?!!e.toolExpandStates[he]:null},$=(W,ie,me,he)=>{t("update-tool-expanded",{key:R(W,ie,me),value:!!he})};Sc();let j=W=>{let ie=W;return typeof ie!="string"&&(Array.isArray(ie)?ie=ie.map(me=>typeof me=="string"?me:me&&me.type==="text"&&me.text||"").join(""):ie=String(ie)),_s(ie||"")},z=W=>{let ie=j(W);if(!ie)return"";try{if(typeof marked<"u"){let me=marked.parse(ie);return Af(te(re(me)),u,g,s.effectiveWorkDir||"")}}catch{}return V(ie)},Q=W=>{let ie=W.target?.closest?.("img");if(ie&&W.currentTarget?.contains?.(ie)){let Ue=ie.getAttribute("src");Ue&&(W.preventDefault(),W.stopPropagation(),Rs(Ue,{alt:ie.getAttribute("alt")||P("message.imagePreview"),closeLabel:P("common.close"),zoomOutLabel:P("message.zoomOut"),zoomInLabel:P("message.zoomIn"),resetZoomLabel:P("message.resetZoom"),trigger:ie}));return}let me=W.target?.closest?.("a[href]");if(!me||!W.currentTarget?.contains?.(me))return;let he=Es(me.getAttribute("href"),{htmlEncoded:!1}),Ee=me.dataset?.resolvedFilePath;!he||!Ee||(W.preventDefault(),W.stopPropagation(),s.openFileInExplorer(Ee,{hideTree:!0,line:he.line}))},ae=Vue.computed(()=>Array.isArray(e.turn?.textSegments)&&e.turn.textSegments.length>0?e.turn.textSegments:e.turn?.textContent?[{key:"legacy-result",content:e.turn.textContent,kind:"result",isStreaming:e.turn.isStreaming===!0}]:[]),ke=Vue.computed(()=>ae.value.filter(W=>W.kind!=="result")),N=Vue.computed(()=>ae.value.filter(W=>W.kind==="result")),G=Vue.computed(()=>[...ae.value.map(W=>typeof W?.content=="string"?W.content:W?.content==null?"":JSON.stringify(W.content)),...Array.isArray(e.turn?.imageMsgs)?e.turn.imageMsgs.map(W=>W?.src||W?.fileId||""):[]].join("\0")),de=new Set,we=()=>{clearTimeout(b),clearTimeout(w),b=null,w=null,f.clear(),m.clear(),v.clear(),y.clear(),h.clear(),k.clear(),u.clear(),g.clear(),p.clear(),S=s.fileReferenceResolutionContextKey||""},se=()=>{clearTimeout(b),b=null;let W=new Set;de.clear();for(let me of ae.value)if(!(!me?.content||typeof marked>"u"))try{let he=marked.parse(j(me.content)),Ee=s.effectiveWorkDir||"";for(let Ue of Cf(he,Ee))W.add(Ue);for(let Ue of Ic(he,Ee))de.add(Ue)}catch{}for(let me of Array.isArray(e.turn?.imageMsgs)?e.turn.imageMsgs:[]){let he=ui(me?.src,s.effectiveWorkDir||"");he&&(W.add(he.path),de.add(he.path))}let ie=[...W].filter(me=>m.has(me)?!1:v.has(me)?!0:v.size>=128?!1:(v.add(me),!0));for(let me=0;me<ie.length;me+=32){let he=ie.slice(me,me+32);he.forEach(Ue=>m.add(Ue));let Ee=s.resolveMessageFileReferences?.(he);if(!Ee){ve(he);continue}f.set(Ee,{contextKey:S,paths:new Set(he)})}},ve=W=>{for(let ie of W)!u.has(ie)&&(h.get(ie)||0)<2&&y.add(ie);!y.size||w!==null||(w=setTimeout(()=>{w=null;for(let ie of y)m.delete(ie),h.set(ie,(h.get(ie)||0)+1);y.clear(),se()},1500))},Ie=()=>{let W=new Set([...f.values()].flatMap(me=>[...me.paths])),ie=!1;for(let me of m){let he=k.get(me)||0;!u.has(me)&&!W.has(me)&&!y.has(me)&&he<2&&(m.delete(me),k.set(me,he+1),ie=!0)}ie&&se()},ue=W=>{let ie=W.detail;if(ie?.type==="file_content"){let he=p.get(ie.requestId);if(!he||(p.delete(ie.requestId),he.contextKey!==(s.fileReferenceResolutionContextKey||"")))return;!ie.error&&ie.binary&&ie.previewUrl&&g.set(he.requestedPath,ie.previewUrl);return}if(ie?.type!=="file_references_resolved")return;let me=f.get(ie.requestId);if(me&&(f.delete(ie.requestId),(s.fileReferenceResolutionContextKey||"")===me.contextKey)){if(ie.error){ve(me.paths);return}for(let he of ie.references||[])if(!(!me.paths.has(he?.requestedPath)||!he?.resolvedPath)&&(u.set(he.requestedPath,he.resolvedPath),de.has(he.requestedPath))){let Ee=s.requestMessageImagePreview?.(he.resolvedPath);Ee&&p.set(Ee,{requestedPath:he.requestedPath,contextKey:S})}}};Vue.onMounted(()=>{window.addEventListener("workbench-message",ue),we(),se()}),Vue.onBeforeUnmount(()=>{window.removeEventListener("workbench-message",ue),we()}),Vue.watch([()=>e.turn?.isStreaming,G,()=>s.fileReferenceResolutionContextKey],([W,ie,me],[he,Ee,Ue])=>{me!==Ue||!W?(we(),se()):(ie!==Ee||W!==he)&&b===null&&(b=setTimeout(se,500))},{flush:"post"}),Vue.watch(()=>s.isProcessing,(W,ie)=>{ie===!0&&W===!1&&!e.turn?.isStreaming&&Ie()},{flush:"post"});let re=W=>W.replace(/<pre><code([^>]*)>([\s\S]*?)<\/code><\/pre>/g,(ie,me,he)=>{let Ee=me.match(/class="language-(\w+)"/);return`<div class="code-block-wrapper">
953
+ `,setup(e,{emit:t}){let s=Pinia.useChatStore(),n=Vue.ref(!1),r=Vue.ref(!1),i=Vue.ref(!1),o=Vue.computed(()=>e.actionsExpanded===null?i.value:!!e.actionsExpanded),a=W=>{i.value=!!W,t("update-actions-expanded",!!W)},l=Vue.ref(!1),c=Vue.ref(null),d=Vue.reactive(new Set),u=Vue.reactive(new Map),g=Vue.reactive(new Map),p=new Map,f=new Map,m=new Set,v=new Set,b=new Set,h=new Map,k=new Map,S="",y=null,w=null,P=Vue.inject("t"),x=(W,ie)=>{s.answerUserQuestion(W,ie,e.conversationId||void 0)},Y=Vue.computed(()=>(Array.isArray(e.turn?.toolMsgs)?e.turn.toolMsgs:[]).filter(ie=>ie?.toolName==="RouteForward").map((ie,me)=>({...mc(ie.toolInput||{}),key:ie.toolId||`${ie.startTime||0}:${me}`}))),L=Vue.computed(()=>(Array.isArray(e.turn?.toolMsgs)?e.turn.toolMsgs:[]).filter(ie=>ie?.toolName!=="RouteForward")),U=Vue.computed(()=>L.value.length>0),E=Vue.computed(()=>{let W=L.value;return W[W.length-1]}),oe=Vue.computed(()=>L.value.slice(0,-1)),q=Vue.computed(()=>Math.max(0,L.value.length-1)),I=Vue.computed(()=>{let W=e.turn?.todoMsg?.toolInput?.todos;return Array.isArray(W)?W.map(ie=>af(e.turn,ie)):[]}),T=()=>{a(!o.value)},R=(W,ie,me)=>{let he=e.toolStatePrefix||e.turn.id||e.turn.turnId||"assistant-turn",Ee=W?.toolName||"tool",Ue=W?.startTime||ie;return`${he}:tool:${me}:${ie}:${Ee}:${Ue}`},M=(W,ie,me)=>{let he=R(W,ie,me);return e.toolExpandStates&&Object.prototype.hasOwnProperty.call(e.toolExpandStates,he)?!!e.toolExpandStates[he]:null},$=(W,ie,me,he)=>{t("update-tool-expanded",{key:R(W,ie,me),value:!!he})};Sc();let j=W=>{let ie=W;return typeof ie!="string"&&(Array.isArray(ie)?ie=ie.map(me=>typeof me=="string"?me:me&&me.type==="text"&&me.text||"").join(""):ie=String(ie)),_s(ie||"")},z=W=>{let ie=j(W);if(!ie)return"";try{if(typeof marked<"u"){let me=marked.parse(ie);return Af(te(re(me)),u,g,s.effectiveWorkDir||"")}}catch{}return V(ie)},Q=W=>{let ie=W.target?.closest?.("img");if(ie&&W.currentTarget?.contains?.(ie)){let Ue=ie.getAttribute("src");Ue&&(W.preventDefault(),W.stopPropagation(),Rs(Ue,{alt:ie.getAttribute("alt")||P("message.imagePreview"),closeLabel:P("common.close"),zoomOutLabel:P("message.zoomOut"),zoomInLabel:P("message.zoomIn"),resetZoomLabel:P("message.resetZoom"),trigger:ie}));return}let me=W.target?.closest?.("a[href]");if(!me||!W.currentTarget?.contains?.(me))return;let he=Es(me.getAttribute("href"),{htmlEncoded:!1}),Ee=me.dataset?.resolvedFilePath;!he||!Ee||(W.preventDefault(),W.stopPropagation(),s.openFileInExplorer(Ee,{hideTree:!0,line:he.line}))},ae=Vue.computed(()=>Array.isArray(e.turn?.textSegments)&&e.turn.textSegments.length>0?e.turn.textSegments:e.turn?.textContent?[{key:"legacy-result",content:e.turn.textContent,kind:"result",isStreaming:e.turn.isStreaming===!0}]:[]),ke=Vue.computed(()=>ae.value.filter(W=>W.kind!=="result")),N=Vue.computed(()=>ae.value.filter(W=>W.kind==="result")),G=Vue.computed(()=>[...ae.value.map(W=>typeof W?.content=="string"?W.content:W?.content==null?"":JSON.stringify(W.content)),...Array.isArray(e.turn?.imageMsgs)?e.turn.imageMsgs.map(W=>W?.src||W?.fileId||""):[]].join("\0")),de=new Set,we=()=>{clearTimeout(y),clearTimeout(w),y=null,w=null,f.clear(),m.clear(),v.clear(),b.clear(),h.clear(),k.clear(),u.clear(),g.clear(),p.clear(),S=s.fileReferenceResolutionContextKey||""},se=()=>{clearTimeout(y),y=null;let W=new Set;de.clear();for(let me of ae.value)if(!(!me?.content||typeof marked>"u"))try{let he=marked.parse(j(me.content)),Ee=s.effectiveWorkDir||"";for(let Ue of Cf(he,Ee))W.add(Ue);for(let Ue of Ic(he,Ee))de.add(Ue)}catch{}for(let me of Array.isArray(e.turn?.imageMsgs)?e.turn.imageMsgs:[]){let he=ui(me?.src,s.effectiveWorkDir||"");he&&(W.add(he.path),de.add(he.path))}let ie=[...W].filter(me=>m.has(me)?!1:v.has(me)?!0:v.size>=128?!1:(v.add(me),!0));for(let me=0;me<ie.length;me+=32){let he=ie.slice(me,me+32);he.forEach(Ue=>m.add(Ue));let Ee=s.resolveMessageFileReferences?.(he);if(!Ee){ve(he);continue}f.set(Ee,{contextKey:S,paths:new Set(he)})}},ve=W=>{for(let ie of W)!u.has(ie)&&(h.get(ie)||0)<2&&b.add(ie);!b.size||w!==null||(w=setTimeout(()=>{w=null;for(let ie of b)m.delete(ie),h.set(ie,(h.get(ie)||0)+1);b.clear(),se()},1500))},Ie=()=>{let W=new Set([...f.values()].flatMap(me=>[...me.paths])),ie=!1;for(let me of m){let he=k.get(me)||0;!u.has(me)&&!W.has(me)&&!b.has(me)&&he<2&&(m.delete(me),k.set(me,he+1),ie=!0)}ie&&se()},ue=W=>{let ie=W.detail;if(ie?.type==="file_content"){let he=p.get(ie.requestId);if(!he||(p.delete(ie.requestId),he.contextKey!==(s.fileReferenceResolutionContextKey||"")))return;!ie.error&&ie.binary&&ie.previewUrl&&g.set(he.requestedPath,ie.previewUrl);return}if(ie?.type!=="file_references_resolved")return;let me=f.get(ie.requestId);if(me&&(f.delete(ie.requestId),(s.fileReferenceResolutionContextKey||"")===me.contextKey)){if(ie.error){ve(me.paths);return}for(let he of ie.references||[])if(!(!me.paths.has(he?.requestedPath)||!he?.resolvedPath)&&(u.set(he.requestedPath,he.resolvedPath),de.has(he.requestedPath))){let Ee=s.requestMessageImagePreview?.(he.resolvedPath);Ee&&p.set(Ee,{requestedPath:he.requestedPath,contextKey:S})}}};Vue.onMounted(()=>{window.addEventListener("workbench-message",ue),we(),se()}),Vue.onBeforeUnmount(()=>{window.removeEventListener("workbench-message",ue),we()}),Vue.watch([()=>e.turn?.isStreaming,G,()=>s.fileReferenceResolutionContextKey],([W,ie,me],[he,Ee,Ue])=>{me!==Ue||!W?(we(),se()):(ie!==Ee||W!==he)&&y===null&&(y=setTimeout(se,500))},{flush:"post"}),Vue.watch(()=>s.isProcessing,(W,ie)=>{ie===!0&&W===!1&&!e.turn?.isStreaming&&Ie()},{flush:"post"});let re=W=>W.replace(/<pre><code([^>]*)>([\s\S]*?)<\/code><\/pre>/g,(ie,me,he)=>{let Ee=me.match(/class="language-(\w+)"/);return`<div class="code-block-wrapper">
951
954
  <div class="code-block-header">
952
955
  <span class="code-lang">${Ee?Ee[1]:""}</span>
953
956
  <button class="code-copy-btn" onclick="window.copyCodeBlock(this)" title="Copy">
@@ -1035,7 +1038,7 @@ ${String(e||"").trim()}
1035
1038
  <slot></slot>
1036
1039
  </div>
1037
1040
  </div>
1038
- `,setup(e){let t=Pn(),s=us(),n=Vue.getCurrentInstance(),r=n&&n.appContext.config.globalProperties.$t||(v=>v),i=Vue.computed(()=>{if(e.displayNameOverride)return e.displayNameOverride;let v=e.turn&&e.turn.speakerVpId;return v?s.vpLabel(v)||v:""}),o=Vue.computed(()=>{let v=e.turn&&e.turn.speakerVpId;return!v||typeof s.vpTextColor!="function"?{}:{color:s.vpTextColor(v)}}),a=()=>{let v=e.turn&&e.turn.turnId;if(v)try{typeof t.cancelVpTurn=="function"&&t.cancelVpTurn(v)}catch{}},l=Vue.computed(()=>{let v=e.turn&&e.turn.speakerVpId;return v?t.isVpTypingInCurrentConv(v):!1}),c=Vue.computed(()=>!!(e.canStop&&e.turn&&e.turn.isStreaming&&e.turn.turnId)),d=Vue.computed(()=>!!(e.turn&&e.turn.turnId&&!e.turn.isStreaming)),u=Vue.computed(()=>{let v="yeaft.debugTurnAction",y=r(v);return y===v?"View debug trace for this turn":y}),g=Vue.computed(()=>ls(e.turn.speakerTimestamp)),p=Vue.computed(()=>{let v=e.turn.speakerTimestamp;if(!v)return"";let y=new Date(v);return Number.isNaN(y.getTime())?"":y.toLocaleString()}),f=Vue.computed(()=>{if(!e.turn)return"";if(Number.isFinite(e.turn.totalMs)&&!e.turn.isActive)return Cc(e.turn.totalMs);let v=Number.isFinite(e.turn.startedAt)&&e.turn.startedAt>0?e.turn.startedAt:e.turn.speakerTimestamp;return!v||!e.nowMs||!e.turn.isActive?"":Cc(e.nowMs-v)}),m=Vue.computed(()=>{let v=e.turn&&e.turn.turnId,y=v?Object.values(t.activeVpTurns||{}).find(b=>b?.turnId===v&&(!t.currentAgent||!b?.agentId||b.agentId===t.currentAgent))||t.activeVpTurns?.[v]:null;if(!y?.retryAttempt||!y?.retryMax)return"";let h=y.retryRecoveryMode==="continue"?"yeaft.vp.turnBlock.retryingContinue":"yeaft.vp.turnBlock.retryingRequest",k=y.retryRecoveryMode==="continue"?`Response stalled; continuing with a fresh request (${y.retryAttempt}/${y.retryMax})`:`Response stalled; retrying with a fresh request (${y.retryAttempt}/${y.retryMax})`,S=r(h,{attempt:y.retryAttempt,max:y.retryMax});return S===h?k:S});return{onStopTurn:a,isTyping:l,showStop:c,hasDebugEntry:d,debugActionTitle:u,displayName:i,speakerNameStyle:o,startedTimeText:g,startedTimeFullText:p,elapsedText:f,retryText:m}}}});function mk(e){let t=[];if(typeof e!="string"||!e.trim())return t;let s=e.split(`
1041
+ `,setup(e){let t=Pn(),s=us(),n=Vue.getCurrentInstance(),r=n&&n.appContext.config.globalProperties.$t||(v=>v),i=Vue.computed(()=>{if(e.displayNameOverride)return e.displayNameOverride;let v=e.turn&&e.turn.speakerVpId;return v?s.vpLabel(v)||v:""}),o=Vue.computed(()=>{let v=e.turn&&e.turn.speakerVpId;return!v||typeof s.vpTextColor!="function"?{}:{color:s.vpTextColor(v)}}),a=()=>{let v=e.turn&&e.turn.turnId;if(v)try{typeof t.cancelVpTurn=="function"&&t.cancelVpTurn(v)}catch{}},l=Vue.computed(()=>{let v=e.turn&&e.turn.speakerVpId;return v?t.isVpTypingInCurrentConv(v):!1}),c=Vue.computed(()=>!!(e.canStop&&e.turn&&e.turn.isStreaming&&e.turn.turnId)),d=Vue.computed(()=>!!(e.turn&&e.turn.turnId&&!e.turn.isStreaming)),u=Vue.computed(()=>{let v="yeaft.debugTurnAction",b=r(v);return b===v?"View debug trace for this turn":b}),g=Vue.computed(()=>ls(e.turn.speakerTimestamp)),p=Vue.computed(()=>{let v=e.turn.speakerTimestamp;if(!v)return"";let b=new Date(v);return Number.isNaN(b.getTime())?"":b.toLocaleString()}),f=Vue.computed(()=>{if(!e.turn)return"";if(Number.isFinite(e.turn.totalMs)&&!e.turn.isActive)return Cc(e.turn.totalMs);let v=Number.isFinite(e.turn.startedAt)&&e.turn.startedAt>0?e.turn.startedAt:e.turn.speakerTimestamp;return!v||!e.nowMs||!e.turn.isActive?"":Cc(e.nowMs-v)}),m=Vue.computed(()=>{let v=e.turn&&e.turn.turnId,b=v?Object.values(t.activeVpTurns||{}).find(y=>y?.turnId===v&&(!t.currentAgent||!y?.agentId||y.agentId===t.currentAgent))||t.activeVpTurns?.[v]:null;if(!b?.retryAttempt||!b?.retryMax)return"";let h=b.retryRecoveryMode==="continue"?"yeaft.vp.turnBlock.retryingContinue":"yeaft.vp.turnBlock.retryingRequest",k=b.retryRecoveryMode==="continue"?`Response stalled; continuing with a fresh request (${b.retryAttempt}/${b.retryMax})`:`Response stalled; retrying with a fresh request (${b.retryAttempt}/${b.retryMax})`,S=r(h,{attempt:b.retryAttempt,max:b.retryMax});return S===h?k:S});return{onStopTurn:a,isTyping:l,showStop:c,hasDebugEntry:d,debugActionTitle:u,displayName:i,speakerNameStyle:o,startedTimeText:g,startedTimeFullText:p,elapsedText:f,retryText:m}}}});function mk(e){let t=[];if(typeof e!="string"||!e.trim())return t;let s=e.split(`
1039
1042
  `),n=null;for(let r of s){let i=/^##\s+(.+?)\s*$/.exec(r);i?(n&&t.push(n),n={title:i[1],body:""}):n&&(n.body+=(n.body?`
1040
1043
  `:"")+r)}n&&t.push(n);for(let r of t)r.body=r.body.trim();return t}var Mf,Pf=B(()=>{Mf={name:"ReflectionCard",props:{card:{type:Object,required:!0}},data(){return{expanded:{"What was attempted":!1,"Key findings":!1,"Direction check":!0,"Suggested next direction":!1,"Tool execution log":!1}}},computed:{isPending(){return this.card&&this.card.status==="pending"},isError(){return this.card&&this.card.status==="error"},triggerLabel(){return this.card.trigger==="t1"?"In-turn reflection":"End-of-turn reflection"},sections(){let e=this.card&&this.card.content||"";return mk(e)}},methods:{toggle(e){this.expanded={...this.expanded,[e]:!this.expanded[e]}}},template:`
1041
1044
  <div class="reflection-card" :class="{ 'is-pending': isPending, 'is-error': isError }">
@@ -1110,7 +1113,7 @@ ${String(e||"").trim()}
1110
1113
  />
1111
1114
  </div>
1112
1115
  </div>
1113
- `}});function pi(e,t,s){return Math.min(Math.max(e,t),s)}function Fo(e){return e?typeof e=="string"?e.length:Array.isArray(e)?e.reduce((t,s)=>t+Fo(s),0):typeof e=="object"?Object.values(e).reduce((t,s)=>t+Fo(s),0):String(e).length:0}function Ef(e){if(!e)return 260;let t=Fo(e.content||e.text||e.message||""),s=Array.isArray(e.attachments)?e.attachments.length:0;return pi(110+Math.ceil(t/90)*18+s*120,120,1400)}function vk(e){if(!e)return 260;let t=Fo(e.text||e.content||""),s=Array.isArray(e.toolMsgs)?e.toolMsgs.length:0,n=Array.isArray(e.images)?e.images.length:0,r=Array.isArray(e.askRequests)?e.askRequests.length:0;return pi(160+Math.ceil(t/95)*18+s*56+n*140+r*96,160,1400)}function zs(e){if(!e)return 260;if(e.type==="message-block"){let t=Array.isArray(e.items)?e.items:[];return t.length?t.reduce((s,n)=>s+zs(n),0)+Math.max(0,t.length-1)*18:260}return e.type==="assistant-turn"?vk(e):e.message?Ef(e.message):Ef(e)}function Ys(e,t=0){return String(e?.id||e?.messageId||e?.turnId||`virtual_${t}`)}function yk(e,t,s,n){let r=Ys(e,t),i=s instanceof Map?s.get(r):s?.[r];if(Number.isFinite(i)&&i>0)return i;let o=n?n(e,t):zs(e);return Number.isFinite(o)&&o>0?o:260}function gi(e,t={},s={}){let n=Array.isArray(e)?e:[],r=Math.max(0,Number(s.itemGap??18)),i=s.estimateHeight||zs,o=[0],a=[];for(let l=0;l<n.length;l+=1){let c=yk(n[l],l,t,i);a.push(c),o.push(o[l]+c+(l<n.length-1?r:0))}return{offsets:o,heights:a,totalHeight:o[o.length-1]||0,itemGap:r}}function Df(e,t){let s=0,n=Math.max(0,e.length-2),r=0;for(;s<=n;){let i=Math.floor((s+n)/2);e[i+1]<=t?(r=i+1,s=i+1):n=i-1}return r}function bk(e,t,s){let n=Df(e,t);for(;n<s&&e[n]<t;)n+=1;return pi(n,0,s)}function Ac(e,t,s={}){let n=Array.isArray(e)?e:[],r=n.length;if(!r)return{start:0,end:0,visibleStart:0,visibleEnd:0,topSpacerHeight:0,bottomSpacerHeight:0,totalHeight:0,items:[]};let i=Math.max(0,Number(s.scrollTop||0)),o=Math.max(1,Number(s.viewportHeight||720)),a=Math.max(0,Number(s.overscan??1)),l=Array.isArray(t?.offsets)?t.offsets:[0],c=Number.isFinite(t?.totalHeight)?t.totalHeight:0,d=i+o,u=pi(Df(l,i),0,r-1),g=pi(bk(l,d,r),u+1,r),p=Math.max(0,u-a),f=Math.min(r,g+a);return{start:p,end:f,visibleStart:u,visibleEnd:g,topSpacerHeight:l[p]||0,bottomSpacerHeight:Math.max(0,c-(l[f]||c)),totalHeight:c,items:n.slice(p,f).map((m,v)=>{let y=p+v;return{item:m,index:y,key:Ys(m,y),top:l[y]||0}})}}function $f(e,t,s={},n={}){let r=Array.isArray(e)?e:[],i=Math.max(0,Math.min(r.length-1,Number.isFinite(t)?Math.floor(t):0));if(r.length===0)return 0;let{offsets:o,heights:a,totalHeight:l}=gi(r,s,n),c=Math.max(1,Number(n.viewportHeight||720)),d=n.align==="start"||n.align==="end"?n.align:"center",u=o[i]||0,g=a[i]||260;return d==="start"?Math.max(0,Math.min(u,l-c)):d==="end"?Math.max(0,Math.min(u+g-c,l-c)):Math.max(0,Math.min(u-(c-g)/2,l-c))}function fi({scrollTop:e=0,scrollHeight:t=0,clientHeight:s=0,threshold:n=80}={}){return Math.max(0,Number(t)-Number(e)-Number(s))<=Math.max(0,Number(n))}function Lf(e=0,{viewports:t=2,minPx:s=600}={}){let n=Math.max(0,Number(e)||0),r=Math.max(0,Number(t)||0);return Math.max(0,Number(s)||0,n*r)}function Ff({following:e=!0,atBottom:t=!1,userScroll:s=!1}={}){return(s||!!e)&&!!t}function Of({following:e=!0,atBottom:t=!1,userScroll:s=!1}={}){return s?!1:!!e&&!!t}function Sk(e){return wk.has(String(e||""))}function qf(e,t){if(!e||!t||e.button!==0)return!1;let s=t.getBoundingClientRect?.(),n=Math.max(0,Number(t.offsetWidth||0)-Number(t.clientWidth||0));return!s||n<=0?!1:Number(e.clientX)>=Number(s.right)-n&&Number(e.clientX)<=Number(s.right)&&Number(e.clientY)>=Number(s.top)&&Number(e.clientY)<=Number(s.bottom)}function Vf(e,t,s=globalThis.document){if(!e||e.defaultPrevented||!t||!Sk(e.key))return!1;let n=e.target;return!n||n.closest?.(kk)?!1:n===t||n===s?.body||n===s?.documentElement}var wk,kk,Gs,xc=B(()=>{wk=new Set(["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "]),kk='input, textarea, select, button, a, [contenteditable], [role="button"], [role="link"]';Gs=Object.freeze({itemHeight:260,viewportHeight:720,overscan:1,itemGap:18,bottomThreshold:80,resumeBottomThreshold:2,historyPrefetchViewports:2,historyPrefetchMinPx:600})});var hi,Hf,Bf=B(()=>{xc();hi=2,Hf={name:"VirtualTranscript",props:{items:{type:Array,default:()=>[]},overscan:{type:Number,default:Gs.overscan},itemGap:{type:Number,default:Gs.itemGap},estimateHeight:{type:Function,default:zs},initialAlign:{type:String,default:"start"}},emits:["scroll-state"],template:`
1116
+ `}});function pi(e,t,s){return Math.min(Math.max(e,t),s)}function Fo(e){return e?typeof e=="string"?e.length:Array.isArray(e)?e.reduce((t,s)=>t+Fo(s),0):typeof e=="object"?Object.values(e).reduce((t,s)=>t+Fo(s),0):String(e).length:0}function Ef(e){if(!e)return 260;let t=Fo(e.content||e.text||e.message||""),s=Array.isArray(e.attachments)?e.attachments.length:0;return pi(110+Math.ceil(t/90)*18+s*120,120,1400)}function vk(e){if(!e)return 260;let t=Fo(e.text||e.content||""),s=Array.isArray(e.toolMsgs)?e.toolMsgs.length:0,n=Array.isArray(e.images)?e.images.length:0,r=Array.isArray(e.askRequests)?e.askRequests.length:0;return pi(160+Math.ceil(t/95)*18+s*56+n*140+r*96,160,1400)}function zs(e){if(!e)return 260;if(e.type==="message-block"){let t=Array.isArray(e.items)?e.items:[];return t.length?t.reduce((s,n)=>s+zs(n),0)+Math.max(0,t.length-1)*18:260}return e.type==="assistant-turn"?vk(e):e.message?Ef(e.message):Ef(e)}function Ys(e,t=0){return String(e?.id||e?.messageId||e?.turnId||`virtual_${t}`)}function yk(e,t,s,n){let r=Ys(e,t),i=s instanceof Map?s.get(r):s?.[r];if(Number.isFinite(i)&&i>0)return i;let o=n?n(e,t):zs(e);return Number.isFinite(o)&&o>0?o:260}function gi(e,t={},s={}){let n=Array.isArray(e)?e:[],r=Math.max(0,Number(s.itemGap??18)),i=s.estimateHeight||zs,o=[0],a=[];for(let l=0;l<n.length;l+=1){let c=yk(n[l],l,t,i);a.push(c),o.push(o[l]+c+(l<n.length-1?r:0))}return{offsets:o,heights:a,totalHeight:o[o.length-1]||0,itemGap:r}}function Df(e,t){let s=0,n=Math.max(0,e.length-2),r=0;for(;s<=n;){let i=Math.floor((s+n)/2);e[i+1]<=t?(r=i+1,s=i+1):n=i-1}return r}function bk(e,t,s){let n=Df(e,t);for(;n<s&&e[n]<t;)n+=1;return pi(n,0,s)}function Ac(e,t,s={}){let n=Array.isArray(e)?e:[],r=n.length;if(!r)return{start:0,end:0,visibleStart:0,visibleEnd:0,topSpacerHeight:0,bottomSpacerHeight:0,totalHeight:0,items:[]};let i=Math.max(0,Number(s.scrollTop||0)),o=Math.max(1,Number(s.viewportHeight||720)),a=Math.max(0,Number(s.overscan??1)),l=Array.isArray(t?.offsets)?t.offsets:[0],c=Number.isFinite(t?.totalHeight)?t.totalHeight:0,d=i+o,u=pi(Df(l,i),0,r-1),g=pi(bk(l,d,r),u+1,r),p=Math.max(0,u-a),f=Math.min(r,g+a);return{start:p,end:f,visibleStart:u,visibleEnd:g,topSpacerHeight:l[p]||0,bottomSpacerHeight:Math.max(0,c-(l[f]||c)),totalHeight:c,items:n.slice(p,f).map((m,v)=>{let b=p+v;return{item:m,index:b,key:Ys(m,b),top:l[b]||0}})}}function $f(e,t,s={},n={}){let r=Array.isArray(e)?e:[],i=Math.max(0,Math.min(r.length-1,Number.isFinite(t)?Math.floor(t):0));if(r.length===0)return 0;let{offsets:o,heights:a,totalHeight:l}=gi(r,s,n),c=Math.max(1,Number(n.viewportHeight||720)),d=n.align==="start"||n.align==="end"?n.align:"center",u=o[i]||0,g=a[i]||260;return d==="start"?Math.max(0,Math.min(u,l-c)):d==="end"?Math.max(0,Math.min(u+g-c,l-c)):Math.max(0,Math.min(u-(c-g)/2,l-c))}function fi({scrollTop:e=0,scrollHeight:t=0,clientHeight:s=0,threshold:n=80}={}){return Math.max(0,Number(t)-Number(e)-Number(s))<=Math.max(0,Number(n))}function Lf(e=0,{viewports:t=2,minPx:s=600}={}){let n=Math.max(0,Number(e)||0),r=Math.max(0,Number(t)||0);return Math.max(0,Number(s)||0,n*r)}function Ff({following:e=!0,atBottom:t=!1,userScroll:s=!1}={}){return(s||!!e)&&!!t}function Of({following:e=!0,atBottom:t=!1,userScroll:s=!1}={}){return s?!1:!!e&&!!t}function Sk(e){return wk.has(String(e||""))}function qf(e,t){if(!e||!t||e.button!==0)return!1;let s=t.getBoundingClientRect?.(),n=Math.max(0,Number(t.offsetWidth||0)-Number(t.clientWidth||0));return!s||n<=0?!1:Number(e.clientX)>=Number(s.right)-n&&Number(e.clientX)<=Number(s.right)&&Number(e.clientY)>=Number(s.top)&&Number(e.clientY)<=Number(s.bottom)}function Vf(e,t,s=globalThis.document){if(!e||e.defaultPrevented||!t||!Sk(e.key))return!1;let n=e.target;return!n||n.closest?.(kk)?!1:n===t||n===s?.body||n===s?.documentElement}var wk,kk,Gs,xc=B(()=>{wk=new Set(["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "]),kk='input, textarea, select, button, a, [contenteditable], [role="button"], [role="link"]';Gs=Object.freeze({itemHeight:260,viewportHeight:720,overscan:1,itemGap:18,bottomThreshold:80,resumeBottomThreshold:2,historyPrefetchViewports:2,historyPrefetchMinPx:600})});var hi,Hf,Bf=B(()=>{xc();hi=2,Hf={name:"VirtualTranscript",props:{items:{type:Array,default:()=>[]},overscan:{type:Number,default:Gs.overscan},itemGap:{type:Number,default:Gs.itemGap},estimateHeight:{type:Function,default:zs},initialAlign:{type:String,default:"start"}},emits:["scroll-state"],template:`
1114
1117
  <div class="virtual-transcript" ref="rootRef">
1115
1118
  <div
1116
1119
  v-if="topSpacerHeight > 0"
@@ -1137,8 +1140,8 @@ ${String(e||"").trim()}
1137
1140
  aria-hidden="true"
1138
1141
  ></div>
1139
1142
  </div>
1140
- `,setup(e,{emit:t,expose:s}){let n=Vue.ref(null),r=Vue.ref(null),i=e.initialAlign==="end",o=Vue.ref(i?Number.MAX_SAFE_INTEGER:0),a=Vue.ref(Gs.viewportHeight),l=Vue.reactive({}),c=new Map,d=new Map,u=new Map,g=null,p=null,f=null,m=null,v=0,y=!1,h=0,k=!0,S=null,b="start",w=null,P=[],x=0,Y=Vue.computed(()=>gi(e.items,l,{itemGap:e.itemGap,estimateHeight:e.estimateHeight})),L=Vue.computed(()=>Ac(e.items,Y.value,{scrollTop:o.value,viewportHeight:a.value,overscan:e.overscan})),U=Vue.computed(()=>L.value.items),E=Vue.computed(()=>L.value.topSpacerHeight),oe=Vue.computed(()=>L.value.bottomSpacerHeight);function q(V){V&&t("scroll-state",{scrollTop:V.scrollTop||0,scrollHeight:V.scrollHeight||0,clientHeight:V.clientHeight||0})}function I(){let V=r.value;V&&(a.value=Math.max(1,V.clientHeight||Gs.viewportHeight),i&&e.items.length===0||(o.value=Math.max(0,V.scrollTop||0)),q(V))}function T(){let V=r.value;return!i||e.initialAlign!=="end"||e.items.length===0||!V?!1:(ae(),V.scrollTop=V.scrollHeight,i=!1,I(),!0)}function R(){T()||I()}function M(V,ce){let X=V.findIndex((Z,fe)=>Ys(Z,fe)===ce);return X<0?null:gi(V,l,{itemGap:e.itemGap,estimateHeight:e.estimateHeight}).offsets[X]||0}function $(V,ce,X){let F=r.value;if(!F||k||V.length===0||ce.length===0)return;let Z=gi(V,l,{itemGap:e.itemGap,estimateHeight:e.estimateHeight}),fe=Ac(V,Z,{scrollTop:F.scrollTop||0,viewportHeight:F.clientHeight||a.value,overscan:0}),Re=Math.min(V.length-1,fe.visibleStart),J=Ys(V[Re],Re),D=Z.offsets[Re]||0;Vue.nextTick(()=>{if(X!==x)return;let ye=M(ce,J);Number.isFinite(ye)&&(F.scrollTop+=ye-D,I())})}function j(){p||(p=requestAnimationFrame(()=>{p=null,I()}))}function z(V){return V?fi({scrollTop:V.scrollTop,scrollHeight:V.scrollHeight,clientHeight:V.clientHeight,threshold:Gs.bottomThreshold}):!0}function Q({delta:V=0,toBottom:ce=!1}={},X=h){if(X!==h||(Math.abs(V)>=hi&&(v+=V),ce&&(y=!0),m))return;let F=X;m=requestAnimationFrame(()=>{if(m=null,F!==h)return;let Z=r.value;if(!Z){v=0,y=!1;return}y?Z.scrollTop=Z.scrollHeight:Math.abs(v)>=hi&&(Z.scrollTop+=v),v=0,y=!1,I()})}function ae(){S=null,w=null}function ke({preserveTarget:V=!1}={}){h+=1,y=!1,v=0,V||ae(),m&&cancelAnimationFrame(m),m=null}function N(V,ce,X){!V||!X||(u.set(V,{index:ce,el:X}),!f&&(f=requestAnimationFrame(()=>{f=null;let F=Array.from(u.entries());u.clear(),G(F)})))}function G(V){let ce=[];for(let[Me,ze]of V){let Ye=ze?.el;if(!Ye)continue;let rt=Math.ceil(Ye.getBoundingClientRect?.().height||Ye.offsetHeight||0);if(!Number.isFinite(rt)||rt<=0)continue;let ut=l[Me];if(ut===rt)continue;let at=c.get(Me);ce.push({key:Me,nextHeight:rt,previousHeight:ut,itemIndex:Number.isFinite(at)?at:ze.index})}if(!ce.length)return;let X=r.value,F=k&&z(X),Z=ce.some(Me=>!Number.isFinite(Me.previousHeight)),fe=L.value.visibleStart,Re=!!S&&ce.some(Me=>Me.key===S),J=0,D=k&&e.initialAlign==="end"&&Z;for(let Me of ce){let{key:ze,nextHeight:Ye,previousHeight:rt,itemIndex:ut}=Me;if(l[ze]=Ye,!X||!Number.isFinite(rt))continue;let at=Ye-rt;Math.abs(at)<hi||(Number.isFinite(ut)&&ut<fe?J+=at:F&&(D=!0))}if(Re){ke({preserveTarget:!0}),we(S,b);return}if(Math.abs(J)>=hi||D){let Me={delta:J,toBottom:D},ze=h;D?Vue.nextTick(()=>Q(Me,ze)):Q(Me,ze)}}function de(V,ce="start"){let X=r.value,F=w||d.get(String(V));if(!X||!F)return!1;let Z=X.getBoundingClientRect?.(),fe=F.getBoundingClientRect?.();if(!Z||!fe)return!1;let Re=Number(Z.top),J=Number(X.clientHeight||a.value),D=Number(fe.height||0),ye=ce==="center"&&D<=J?Re+(J-D)/2:ce==="end"&&D<=J?Number(Z.bottom)-D:Re,Me=Number(fe.top)-ye;return Math.abs(Me)>=hi&&(X.scrollTop+=Me),I(),!0}function we(V,ce="start",X){let F=String(V);S=F,b=ce,X!==void 0&&(w=X);let Z=()=>{S===F&&de(F,b)};Vue.nextTick(Z)}function se(V){let ce=!!V;ce&&ae(),k!==ce&&(k=ce,k||ke())}function ve(V,ce,X){c.set(V,ce),X&&(d.set(V,X),g&&g.observe(X),Vue.nextTick(()=>N(V,ce,X)))}function Ie(V,ce,X){if(!V)return;let F=d.get(V);if(F&&F!==X&&g&&g.unobserve(F),!X){d.delete(V);return}ve(V,ce,X)}async function ue(V,{align:ce="center"}={}){let X=Number.isFinite(V)?Math.floor(V):-1,F=r.value;if(!F||X<0||X>=e.items.length)return!1;ke({preserveTarget:!0});let Z=Ys(e.items[X],X);return S=Z,b=ce,w=null,F.scrollTop=$f(e.items,X,l,{itemGap:e.itemGap,estimateHeight:e.estimateHeight,viewportHeight:F.clientHeight||a.value,align:ce}),I(),await Vue.nextTick(),d.get(Z)?(we(Z,ce),!0):!1}function re(V,ce={}){let X=c.get(String(V));return Number.isFinite(X)?ue(X,ce):Promise.resolve(!1)}function te(V,ce,{align:X="start"}={}){let F=String(V||"");return!F||!ce?!1:(S=F,b=X,w=ce,de(F,X),!0)}return s({scrollToKey:re,scrollToIndex:ue,anchorTarget:te,clearTargetAnchor:ae,cancelPendingBottomFollow:ke,setBottomFollowEnabled:se}),Vue.watch(()=>e.items.map((V,ce)=>Ys(V,ce)).join(`
1141
- `),()=>{let V=e.items.slice(),ce=P;P=V,x+=1;let X=x;c.clear(),e.items.forEach((F,Z)=>c.set(Ys(F,Z),Z)),S&&!c.has(S)&&ae(),ce.length>0&&$(ce,V,X),Vue.nextTick(()=>{X===x&&R()})},{immediate:!0}),Vue.onMounted(()=>{if(r.value=n.value?.closest?.(".chat-container")||n.value?.parentElement||null,R(),r.value?.addEventListener("scroll",j,{passive:!0}),window.addEventListener("resize",j),typeof ResizeObserver<"u"){g=new ResizeObserver(V=>{for(let ce of V){let X=ce.target?.dataset?.virtualId,F=Number(ce.target?.dataset?.virtualIndex);X&&N(X,F,ce.target)}});for(let[V,ce]of d.entries()){let X=c.get(V)??Number(ce.dataset?.virtualIndex||0);ve(V,X,ce)}}}),Vue.onBeforeUnmount(()=>{r.value?.removeEventListener("scroll",j),window.removeEventListener("resize",j),g&&g.disconnect(),p&&cancelAnimationFrame(p),f&&cancelAnimationFrame(f),m&&cancelAnimationFrame(m),u.clear(),v=0,y=!1}),{rootRef:n,visibleEntries:U,topSpacerHeight:E,bottomSpacerHeight:oe,setItemRef:Ie}}}});function Oo(e,t=0){let s=Math.max(0,e)%19e3,n=0,r=1,i="speed-normal";return s<2500?n=s/2500*.16:s<5e3?(n=.16+(s-2500)/2500*.29,i="speed-fast"):s<7500?(n=.45+(s-5e3)/2500*.55,i="speed-turbo"):s<1e4?(n=1-(s-7500)/2500,r=-1,i="speed-crazy"):s<14e3?(n=0,i="speed-tired"):s<16e3?(n=0,i="speed-petted"):(n=0,i="speed-napping"),{phase:i,transform:`translate3d(${Math.max(0,t)*n}px, 0, 0) scaleX(${r})`}}function qo(e,t,s){if(!(!e||!t||!s)){e.style.transform=s.transform;for(let n of Ik)t.classList.toggle(n,n===s.phase)}}function Vo({onFrame:e,requestFrame:t=requestAnimationFrame,cancelFrame:s=cancelAnimationFrame}){let n=!1,r=null,i=()=>{r=null,n&&(e?.(),n&&(r=t(i)))};return{start(){return n?!1:(n=!0,r=t(i),!0)},stop(){return n?(n=!1,r!==null&&s(r),r=null,!0):!1},isRunning(){return n}}}var Ik,Tc=B(()=>{Ik=["speed-napping","speed-normal","speed-fast","speed-turbo","speed-crazy","speed-tired","speed-petted"]});function dr(e){return typeof e=="string"&&e.trim()?e.trim():""}function Wf(e){return dr(e?.speakerVpId)||dr(e?.vpId)}function Nf(e){let t=Wf(e),s=dr(e?.turnId);return!t||!s?"":[t,s].join("\0")}function jf(e){if(!Array.isArray(e)||e.length<2)return e||[];let t=[],s=[],n=()=>{if(s.length===0)return;let r=new Map;for(let i of s){let o=Nf(i);r.has(o)||r.set(o,[]),r.get(o).push(i)}for(let i of r.values())t.push(...i);s=[]};for(let r of e){if(Ck.has(r?.type)&&Nf(r)){s.push(r);continue}n(),t.push(r)}return n(),t}function Uf(e,t){if(!e||!t)return!1;let s=dr(e.speakerVpId),n=Wf(t);if(s&&n&&s!==n)return!0;let r=dr(e.turnId),i=dr(t.turnId);return e.isHistory&&t.isHistory?e.messages?.length>0&&t.executionOrigin==="route_forward"&&r&&i&&r!==i:!!(r&&i&&r!==i)}var Ck,Kf=B(()=>{Ck=new Set(["assistant","chat-image","tool-result","tool-use","tool_result"])});function mi(e){return e?e.type!=="user"&&e.type!=="system"&&e.type!=="error":!1}function Ho(e){let t=Array.isArray(e?.items)?e.items:[];return e?.responseCollapsed?t.filter(s=>!mi(s)):t}function Ak(e){return(Array.isArray(e?.items)?e.items:[]).filter(mi)}function zf(e){let t=Ak(e);return t.length?t[0]:null}function xk(e){let t=e?.textContent??e?.text??e?.content??e?.message?.content??"";return typeof t=="string"?t:Array.isArray(t)?t.map(s=>typeof s=="string"?s:s&&s.type==="text"&&s.text||"").join(""):t==null?"":String(t)}function Yf(e){if(!e?.responseCollapsed)return[];let t=zf(e);return xk(t).replace(/```[\s\S]*?```/g," ").replace(/`([^`]+)`/g,"$1").replace(/!\[[^\]]*\]\([^)]*\)/g," ").replace(/\[[^\]]*\]\(([^)]*)\)/g,"").replace(/[#>*_~\-]+/g," ").split(/\r?\n/).map(n=>n.trim()).filter(Boolean).slice(0,2)}function Gf(e,t){if(!e?.responseCollapsed||typeof t!="function")return null;let s=Ho(e),n=zf(e)?74:0,r=s.length+(n?1:0);if(!s.length)return n;let i=s.reduce((a,l)=>a+t(l),0),o=Math.max(0,r-1)*18;return i+o+n}var Qf=B(()=>{});function Ds(e,t){typeof t!="string"||!/^m\d+$/.test(t)||e.includes(t)||e.push(t)}function Tk(e){if(!e)return[];let t=[];for(let s of Array.isArray(e.messages)?e.messages:[]){Ds(t,s?.id),Ds(t,s?.messageId),Ds(t,s?.persistedMessageId);for(let n of Array.isArray(s?.sourceMessageIds)?s.sourceMessageIds:[])Ds(t,n)}return Ds(t,e.message?.id),Ds(t,e.messageId),Ds(t,e.atMessageId),e.type!=="assistant-turn"&&Ds(t,e.id),t}function Mk(e){let t=[],s=n=>{typeof n=="string"&&n&&!t.includes(n)&&t.push(n)};s(e?.entryId),s(e?.message?.entryId);for(let n of Array.isArray(e?.messages)?e.messages:[])s(n?.entryId);return t}function Zf(e,t=[]){return e?.closest?.(Xf)?!1:!t.some(s=>s?.matches?.(Xf))}async function Jf({result:e,revealWindow:t,nextTick:s,revealMessage:n,isMobile:r,closeOutline:i}){if(!e||!await t?.(e))return!1;await s?.();let a=await n?.(e);return a&&r&&i?.(),!!a}function Pk(e,t){let s=typeof t?.entryId=="string"?t.entryId:null,n=[];for(let r of[...Array.isArray(t?.sourceMessageIds)?t.sourceMessageIds:[],t?.messageId,typeof t=="string"?t:null])Ds(n,r);if(!s&&n.length===0)return null;for(let r of Array.isArray(e)?e:[]){if(!r)continue;let i=Array.isArray(r.items)?r.items:[r];for(let o of i){let a=s&&Mk(o).includes(s),l=n.some(u=>Tk(o).includes(u));if(!a&&!l)continue;let c=o?.id,d=r?.id;return!c||!d?null:{blockId:d,rowId:c,collapseKey:r.responseCollapseKey||null,requiresExpansion:!!(r.responseCollapsed&&o.type==="assistant-turn")}}}return null}async function eh({blocks:e,target:t,messageId:s,collapseStates:n,scrollToBlock:r,findRow:i,anchorRow:o,flashRow:a,nextTick:l,align:c="start"}){let d=Pk(e,t||s);if(!d||typeof r!="function"||typeof i!="function")return!1;if(d.requiresExpansion){if(!d.collapseKey||!n)return!1;n[d.collapseKey]=!1,await l?.()}if(!await r(d.blockId,{align:c}))return!1;await l?.();let g=i(d.rowId);return g?(typeof o=="function"?o(d.blockId,d.rowId,g,{align:c}):g.scrollIntoView?.({block:c,inline:"nearest"}),a?.(d.rowId),!0):!1}var Xf,Mc=B(()=>{Xf=[".yeaft-conversation-outline",".yeaft-conversation-outline-sender-menu",".yeaft-search-btn"].join(", ")});function th({responses:e,viewportTop:t,viewportHeight:s,thresholdViewports:n=2,readingLineRatio:r=.35}){let i=Math.max(0,Number(s)||0);if(!i)return"";let o=Number(t)||0,a=o+i,l=o+i*r,c=i*n,d=(Array.isArray(e)?e:[]).map((g,p)=>{let f=Number(g?.top)||0,m=Number(g?.bottom)||0,v=Math.max(Number(g?.height)||0,m-f);return{originMessageId:String(g?.originMessageId||""),top:f,bottom:m,height:v,visibleHeight:Math.max(0,Math.min(m,a)-Math.max(f,o)),index:p}}).filter(g=>g.originMessageId&&g.height>=c&&g.top<o&&g.bottom>=l&&g.visibleHeight>0);if(!d.length)return"";let u=d.find(g=>g.top<=l&&g.bottom>=l);return u?u.originMessageId:(d.sort((g,p)=>p.visibleHeight-g.visibleHeight||Math.abs((g.top+g.bottom)/2-l)-Math.abs((p.top+p.bottom)/2-l)||g.index-p.index),d[0].originMessageId)}var sh=B(()=>{});var Bo,Pc=B(()=>{qt();Mo();Po();Do();$o();wc();Pf();_f();Lo();Bf();Tc();Kf();xc();Qf();Mc();js();uo();sh();Bo={name:"MessageList",components:{AgentInstaller:rr,MessageItem:ir,AssistantTurn:ar,VpTurnBlock:lr,VpSpeakerHeader:Eo,ReflectionCard:Mf,SubAgentCard:Rf,UserTurnBlock:cr,VirtualTranscript:Hf},template:`
1143
+ `,setup(e,{emit:t,expose:s}){let n=Vue.ref(null),r=Vue.ref(null),i=e.initialAlign==="end",o=Vue.ref(i?Number.MAX_SAFE_INTEGER:0),a=Vue.ref(Gs.viewportHeight),l=Vue.reactive({}),c=new Map,d=new Map,u=new Map,g=null,p=null,f=null,m=null,v=0,b=!1,h=0,k=!0,S=null,y="start",w=null,P=[],x=0,Y=Vue.computed(()=>gi(e.items,l,{itemGap:e.itemGap,estimateHeight:e.estimateHeight})),L=Vue.computed(()=>Ac(e.items,Y.value,{scrollTop:o.value,viewportHeight:a.value,overscan:e.overscan})),U=Vue.computed(()=>L.value.items),E=Vue.computed(()=>L.value.topSpacerHeight),oe=Vue.computed(()=>L.value.bottomSpacerHeight);function q(V){V&&t("scroll-state",{scrollTop:V.scrollTop||0,scrollHeight:V.scrollHeight||0,clientHeight:V.clientHeight||0})}function I(){let V=r.value;V&&(a.value=Math.max(1,V.clientHeight||Gs.viewportHeight),i&&e.items.length===0||(o.value=Math.max(0,V.scrollTop||0)),q(V))}function T(){let V=r.value;return!i||e.initialAlign!=="end"||e.items.length===0||!V?!1:(ae(),V.scrollTop=V.scrollHeight,i=!1,I(),!0)}function R(){T()||I()}function M(V,ce){let X=V.findIndex((Z,fe)=>Ys(Z,fe)===ce);return X<0?null:gi(V,l,{itemGap:e.itemGap,estimateHeight:e.estimateHeight}).offsets[X]||0}function $(V,ce,X){let F=r.value;if(!F||k||V.length===0||ce.length===0)return;let Z=gi(V,l,{itemGap:e.itemGap,estimateHeight:e.estimateHeight}),fe=Ac(V,Z,{scrollTop:F.scrollTop||0,viewportHeight:F.clientHeight||a.value,overscan:0}),Re=Math.min(V.length-1,fe.visibleStart),J=Ys(V[Re],Re),D=Z.offsets[Re]||0;Vue.nextTick(()=>{if(X!==x)return;let ye=M(ce,J);Number.isFinite(ye)&&(F.scrollTop+=ye-D,I())})}function j(){p||(p=requestAnimationFrame(()=>{p=null,I()}))}function z(V){return V?fi({scrollTop:V.scrollTop,scrollHeight:V.scrollHeight,clientHeight:V.clientHeight,threshold:Gs.bottomThreshold}):!0}function Q({delta:V=0,toBottom:ce=!1}={},X=h){if(X!==h||(Math.abs(V)>=hi&&(v+=V),ce&&(b=!0),m))return;let F=X;m=requestAnimationFrame(()=>{if(m=null,F!==h)return;let Z=r.value;if(!Z){v=0,b=!1;return}b?Z.scrollTop=Z.scrollHeight:Math.abs(v)>=hi&&(Z.scrollTop+=v),v=0,b=!1,I()})}function ae(){S=null,w=null}function ke({preserveTarget:V=!1}={}){h+=1,b=!1,v=0,V||ae(),m&&cancelAnimationFrame(m),m=null}function N(V,ce,X){!V||!X||(u.set(V,{index:ce,el:X}),!f&&(f=requestAnimationFrame(()=>{f=null;let F=Array.from(u.entries());u.clear(),G(F)})))}function G(V){let ce=[];for(let[Me,ze]of V){let Ye=ze?.el;if(!Ye)continue;let rt=Math.ceil(Ye.getBoundingClientRect?.().height||Ye.offsetHeight||0);if(!Number.isFinite(rt)||rt<=0)continue;let ut=l[Me];if(ut===rt)continue;let at=c.get(Me);ce.push({key:Me,nextHeight:rt,previousHeight:ut,itemIndex:Number.isFinite(at)?at:ze.index})}if(!ce.length)return;let X=r.value,F=k&&z(X),Z=ce.some(Me=>!Number.isFinite(Me.previousHeight)),fe=L.value.visibleStart,Re=!!S&&ce.some(Me=>Me.key===S),J=0,D=k&&e.initialAlign==="end"&&Z;for(let Me of ce){let{key:ze,nextHeight:Ye,previousHeight:rt,itemIndex:ut}=Me;if(l[ze]=Ye,!X||!Number.isFinite(rt))continue;let at=Ye-rt;Math.abs(at)<hi||(Number.isFinite(ut)&&ut<fe?J+=at:F&&(D=!0))}if(Re){ke({preserveTarget:!0}),we(S,y);return}if(Math.abs(J)>=hi||D){let Me={delta:J,toBottom:D},ze=h;D?Vue.nextTick(()=>Q(Me,ze)):Q(Me,ze)}}function de(V,ce="start"){let X=r.value,F=w||d.get(String(V));if(!X||!F)return!1;let Z=X.getBoundingClientRect?.(),fe=F.getBoundingClientRect?.();if(!Z||!fe)return!1;let Re=Number(Z.top),J=Number(X.clientHeight||a.value),D=Number(fe.height||0),ye=ce==="center"&&D<=J?Re+(J-D)/2:ce==="end"&&D<=J?Number(Z.bottom)-D:Re,Me=Number(fe.top)-ye;return Math.abs(Me)>=hi&&(X.scrollTop+=Me),I(),!0}function we(V,ce="start",X){let F=String(V);S=F,y=ce,X!==void 0&&(w=X);let Z=()=>{S===F&&de(F,y)};Vue.nextTick(Z)}function se(V){let ce=!!V;ce&&ae(),k!==ce&&(k=ce,k||ke())}function ve(V,ce,X){c.set(V,ce),X&&(d.set(V,X),g&&g.observe(X),Vue.nextTick(()=>N(V,ce,X)))}function Ie(V,ce,X){if(!V)return;let F=d.get(V);if(F&&F!==X&&g&&g.unobserve(F),!X){d.delete(V);return}ve(V,ce,X)}async function ue(V,{align:ce="center"}={}){let X=Number.isFinite(V)?Math.floor(V):-1,F=r.value;if(!F||X<0||X>=e.items.length)return!1;ke({preserveTarget:!0});let Z=Ys(e.items[X],X);return S=Z,y=ce,w=null,F.scrollTop=$f(e.items,X,l,{itemGap:e.itemGap,estimateHeight:e.estimateHeight,viewportHeight:F.clientHeight||a.value,align:ce}),I(),await Vue.nextTick(),d.get(Z)?(we(Z,ce),!0):!1}function re(V,ce={}){let X=c.get(String(V));return Number.isFinite(X)?ue(X,ce):Promise.resolve(!1)}function te(V,ce,{align:X="start"}={}){let F=String(V||"");return!F||!ce?!1:(S=F,y=X,w=ce,de(F,X),!0)}return s({scrollToKey:re,scrollToIndex:ue,anchorTarget:te,clearTargetAnchor:ae,cancelPendingBottomFollow:ke,setBottomFollowEnabled:se}),Vue.watch(()=>e.items.map((V,ce)=>Ys(V,ce)).join(`
1144
+ `),()=>{let V=e.items.slice(),ce=P;P=V,x+=1;let X=x;c.clear(),e.items.forEach((F,Z)=>c.set(Ys(F,Z),Z)),S&&!c.has(S)&&ae(),ce.length>0&&$(ce,V,X),Vue.nextTick(()=>{X===x&&R()})},{immediate:!0}),Vue.onMounted(()=>{if(r.value=n.value?.closest?.(".chat-container")||n.value?.parentElement||null,R(),r.value?.addEventListener("scroll",j,{passive:!0}),window.addEventListener("resize",j),typeof ResizeObserver<"u"){g=new ResizeObserver(V=>{for(let ce of V){let X=ce.target?.dataset?.virtualId,F=Number(ce.target?.dataset?.virtualIndex);X&&N(X,F,ce.target)}});for(let[V,ce]of d.entries()){let X=c.get(V)??Number(ce.dataset?.virtualIndex||0);ve(V,X,ce)}}}),Vue.onBeforeUnmount(()=>{r.value?.removeEventListener("scroll",j),window.removeEventListener("resize",j),g&&g.disconnect(),p&&cancelAnimationFrame(p),f&&cancelAnimationFrame(f),m&&cancelAnimationFrame(m),u.clear(),v=0,b=!1}),{rootRef:n,visibleEntries:U,topSpacerHeight:E,bottomSpacerHeight:oe,setItemRef:Ie}}}});function Oo(e,t=0){let s=Math.max(0,e)%19e3,n=0,r=1,i="speed-normal";return s<2500?n=s/2500*.16:s<5e3?(n=.16+(s-2500)/2500*.29,i="speed-fast"):s<7500?(n=.45+(s-5e3)/2500*.55,i="speed-turbo"):s<1e4?(n=1-(s-7500)/2500,r=-1,i="speed-crazy"):s<14e3?(n=0,i="speed-tired"):s<16e3?(n=0,i="speed-petted"):(n=0,i="speed-napping"),{phase:i,transform:`translate3d(${Math.max(0,t)*n}px, 0, 0) scaleX(${r})`}}function qo(e,t,s){if(!(!e||!t||!s)){e.style.transform=s.transform;for(let n of Ik)t.classList.toggle(n,n===s.phase)}}function Vo({onFrame:e,requestFrame:t=requestAnimationFrame,cancelFrame:s=cancelAnimationFrame}){let n=!1,r=null,i=()=>{r=null,n&&(e?.(),n&&(r=t(i)))};return{start(){return n?!1:(n=!0,r=t(i),!0)},stop(){return n?(n=!1,r!==null&&s(r),r=null,!0):!1},isRunning(){return n}}}var Ik,Tc=B(()=>{Ik=["speed-napping","speed-normal","speed-fast","speed-turbo","speed-crazy","speed-tired","speed-petted"]});function dr(e){return typeof e=="string"&&e.trim()?e.trim():""}function Wf(e){return dr(e?.speakerVpId)||dr(e?.vpId)}function Nf(e){let t=Wf(e),s=dr(e?.turnId);return!t||!s?"":[t,s].join("\0")}function jf(e){if(!Array.isArray(e)||e.length<2)return e||[];let t=[],s=[],n=()=>{if(s.length===0)return;let r=new Map;for(let i of s){let o=Nf(i);r.has(o)||r.set(o,[]),r.get(o).push(i)}for(let i of r.values())t.push(...i);s=[]};for(let r of e){if(Ck.has(r?.type)&&Nf(r)){s.push(r);continue}n(),t.push(r)}return n(),t}function Uf(e,t){if(!e||!t)return!1;let s=dr(e.speakerVpId),n=Wf(t);if(s&&n&&s!==n)return!0;let r=dr(e.turnId),i=dr(t.turnId);return e.isHistory&&t.isHistory?e.messages?.length>0&&t.executionOrigin==="route_forward"&&r&&i&&r!==i:!!(r&&i&&r!==i)}var Ck,Kf=B(()=>{Ck=new Set(["assistant","chat-image","tool-result","tool-use","tool_result"])});function mi(e){return e?e.type!=="user"&&e.type!=="system"&&e.type!=="error":!1}function Ho(e){let t=Array.isArray(e?.items)?e.items:[];return e?.responseCollapsed?t.filter(s=>!mi(s)):t}function Ak(e){return(Array.isArray(e?.items)?e.items:[]).filter(mi)}function zf(e){let t=Ak(e);return t.length?t[0]:null}function xk(e){let t=e?.textContent??e?.text??e?.content??e?.message?.content??"";return typeof t=="string"?t:Array.isArray(t)?t.map(s=>typeof s=="string"?s:s&&s.type==="text"&&s.text||"").join(""):t==null?"":String(t)}function Yf(e){if(!e?.responseCollapsed)return[];let t=zf(e);return xk(t).replace(/```[\s\S]*?```/g," ").replace(/`([^`]+)`/g,"$1").replace(/!\[[^\]]*\]\([^)]*\)/g," ").replace(/\[[^\]]*\]\(([^)]*)\)/g,"").replace(/[#>*_~\-]+/g," ").split(/\r?\n/).map(n=>n.trim()).filter(Boolean).slice(0,2)}function Gf(e,t){if(!e?.responseCollapsed||typeof t!="function")return null;let s=Ho(e),n=zf(e)?74:0,r=s.length+(n?1:0);if(!s.length)return n;let i=s.reduce((a,l)=>a+t(l),0),o=Math.max(0,r-1)*18;return i+o+n}var Qf=B(()=>{});function Ds(e,t){typeof t!="string"||!/^m\d+$/.test(t)||e.includes(t)||e.push(t)}function Tk(e){if(!e)return[];let t=[];for(let s of Array.isArray(e.messages)?e.messages:[]){Ds(t,s?.id),Ds(t,s?.messageId),Ds(t,s?.persistedMessageId);for(let n of Array.isArray(s?.sourceMessageIds)?s.sourceMessageIds:[])Ds(t,n)}return Ds(t,e.message?.id),Ds(t,e.messageId),Ds(t,e.atMessageId),e.type!=="assistant-turn"&&Ds(t,e.id),t}function Mk(e){let t=[],s=n=>{typeof n=="string"&&n&&!t.includes(n)&&t.push(n)};s(e?.entryId),s(e?.message?.entryId);for(let n of Array.isArray(e?.messages)?e.messages:[])s(n?.entryId);return t}function Zf(e,t=[]){return e?.closest?.(Xf)?!1:!t.some(s=>s?.matches?.(Xf))}async function Jf({result:e,revealWindow:t,nextTick:s,revealMessage:n,isMobile:r,closeOutline:i}){if(!e||!await t?.(e))return!1;await s?.();let a=await n?.(e);return a&&r&&i?.(),!!a}function Pk(e,t){let s=typeof t?.entryId=="string"?t.entryId:null,n=[];for(let r of[...Array.isArray(t?.sourceMessageIds)?t.sourceMessageIds:[],t?.messageId,typeof t=="string"?t:null])Ds(n,r);if(!s&&n.length===0)return null;for(let r of Array.isArray(e)?e:[]){if(!r)continue;let i=Array.isArray(r.items)?r.items:[r];for(let o of i){let a=s&&Mk(o).includes(s),l=n.some(u=>Tk(o).includes(u));if(!a&&!l)continue;let c=o?.id,d=r?.id;return!c||!d?null:{blockId:d,rowId:c,collapseKey:r.responseCollapseKey||null,requiresExpansion:!!(r.responseCollapsed&&o.type==="assistant-turn")}}}return null}async function eh({blocks:e,target:t,messageId:s,collapseStates:n,scrollToBlock:r,findRow:i,anchorRow:o,flashRow:a,nextTick:l,align:c="start"}){let d=Pk(e,t||s);if(!d||typeof r!="function"||typeof i!="function")return!1;if(d.requiresExpansion){if(!d.collapseKey||!n)return!1;n[d.collapseKey]=!1,await l?.()}if(!await r(d.blockId,{align:c}))return!1;await l?.();let g=i(d.rowId);return g?(typeof o=="function"?o(d.blockId,d.rowId,g,{align:c}):g.scrollIntoView?.({block:c,inline:"nearest"}),a?.(d.rowId),!0):!1}var Xf,Mc=B(()=>{Xf=[".yeaft-conversation-outline",".yeaft-conversation-outline-sender-menu",".yeaft-search-btn"].join(", ")});function th({responses:e,viewportTop:t,viewportHeight:s,thresholdViewports:n=2,readingLineRatio:r=.35}){let i=Math.max(0,Number(s)||0);if(!i)return"";let o=Number(t)||0,a=o+i,l=o+i*r,c=i*n,d=(Array.isArray(e)?e:[]).map((g,p)=>{let f=Number(g?.top)||0,m=Number(g?.bottom)||0,v=Math.max(Number(g?.height)||0,m-f);return{originMessageId:String(g?.originMessageId||""),top:f,bottom:m,height:v,visibleHeight:Math.max(0,Math.min(m,a)-Math.max(f,o)),index:p}}).filter(g=>g.originMessageId&&g.height>=c&&g.top<o&&g.bottom>=l&&g.visibleHeight>0);if(!d.length)return"";let u=d.find(g=>g.top<=l&&g.bottom>=l);return u?u.originMessageId:(d.sort((g,p)=>p.visibleHeight-g.visibleHeight||Math.abs((g.top+g.bottom)/2-l)-Math.abs((p.top+p.bottom)/2-l)||g.index-p.index),d[0].originMessageId)}var sh=B(()=>{});var Bo,Pc=B(()=>{qt();Mo();Po();Do();$o();wc();Pf();_f();Lo();Bf();Tc();Kf();xc();Qf();Mc();js();uo();sh();Bo={name:"MessageList",components:{AgentInstaller:rr,MessageItem:ir,AssistantTurn:ar,VpTurnBlock:lr,VpSpeakerHeader:Eo,ReflectionCard:Mf,SubAgentCard:Rf,UserTurnBlock:cr,VirtualTranscript:Hf},template:`
1142
1145
  <main class="chat-container" ref="containerRef">
1143
1146
  <!-- Session Loading Overlay - only covers message area -->
1144
1147
  <div class="session-loading-overlay" v-if="showSessionLoadingOverlay">
@@ -1738,7 +1741,7 @@ ${String(e||"").trim()}
1738
1741
  </button>
1739
1742
  </nav>
1740
1743
  </main>
1741
- `,emits:["new-conversation","resume-conversation","open-settings","quote-message","edit-message-as-new"],setup(e,{expose:t}){let s=Pinia.useChatStore(),n=Ge(),r=typeof window<"u"&&window.Pinia?.useVpStore?window.Pinia.useVpStore():null,i=Vue.inject("t",null),o=Vue.ref(null),a=Vue.ref(null),l=Vue.reactive({}),c=Vue.reactive({}),d=Vue.reactive({}),u=C=>String(C?.id||C?.turnId||C?.messageId||C?.atMessageId||C?.message?.id||"turn_unknown"),g=C=>{let H=u(C);return Object.prototype.hasOwnProperty.call(l,H)?!!l[H]:!1},p=(C,H)=>{l[u(C)]=!!H},f=C=>{let H=C&&(C.turnId||C.id);!H||typeof s.openYeaftTurnDebug!="function"||s.openYeaftTurnDebug({sessionId:L.value||null,turnId:H})},m=({key:C,value:H}={})=>{C&&(c[C]=!!H)},v=C=>{let H=Gf(C,zs);return Number.isFinite(H)?H:zs(C)},y=C=>Ho(C),h=C=>{let H=Array.isArray(C?.collapsedResponsePreview)?C.collapsedResponsePreview:Yf(C);return Array.isArray(H)?H:H?[String(H)]:[]},k=C=>{let H=Array.isArray(C?.items)?C.items.find(Ae=>mi(Ae)):null,K=H?.speakerVpId||H?.vpId||H?.message?.speakerVpId||H?.message?.vpId||C?.vpId||"",Ce=K&&r&&typeof r.vpLabel=="function"?r.vpLabel(K)||K:K||(typeof i=="function"?i("message.assistant"):"Assistant"),De=K&&r&&typeof r.vpTextColor=="function"?{color:r.vpTextColor(K)}:{},xe=H?.speakerTimestamp||H?.timestamp||H?.createdAt||H?.message?.timestamp||H?.message?.createdAt||0,ft="",Ne="";if(xe)try{let Ae=new Date(xe);Number.isNaN(Ae.getTime())||(ft=ls(xe),Ne=Ae.toLocaleString())}catch{}return{name:Ce,style:De,timeText:ft,fullTimeText:Ne}},S=C=>{let H=Array.isArray(C?.items)?C.items:[];for(let K=H.length-1;K>=0;K-=1)if(mi(H[K]))return H[K];return null},b=(C,H)=>!C?.responseCollapsible||!H?!1:S(C)===H,w=C=>!!(C?.responseCollapsible&&!Ho(C).some(H=>b(C,H))),P=C=>{let H=C?.responseCollapseKey;H&&(d[H]=!C.responseCollapsed)},x=C=>{let H=Number(C?.responseCount||0),K=C?.responseCollapsed?"message.showResponses":"message.hideResponses",Ce=(typeof i=="function"?i(K):"")||(C?.responseCollapsed?"Show {count} response(s)":"Hide response(s)");return String(Ce).replace("{count}",String(H))},Y=(()=>{try{return window.Pinia?.useSessionsStore?.()||null}catch{return null}}),L=Vue.computed(()=>{if(s.currentView!=="yeaft")return null;let C=Y();if(!C)return null;let H=s.yeaftActiveSessionFilter||null;return H&&typeof C.sessionById=="function"&&C.sessionById(H,s.currentAgent||null)?H:C.activeSessionId&&typeof C.sessionById=="function"&&C.sessionById(C.activeSessionId,s.currentAgent||null)?C.activeSessionId:null}),U=Vue.computed(()=>{let C=s.currentView||"",H=s.currentAgent||"";if(C==="yeaft"){let K=s.yeaftActiveSessionFilter||L.value||"__all__";return[C,H,K].join("")}return[C,H,s.activeConversationId||""].join("")}),E=Vue.computed(()=>L.value!==null),oe=Vue.computed(()=>s.agents.filter(C=>C.online)),q=Vue.ref(null),I=Vue.ref(!1),T=Vue.ref(""),R=null,M=0,$=n.token||"",j=()=>{q.value=null,T.value="",R=null,M+=1},z=()=>{let C={"Content-Type":"application/json"};return n.token&&(C.Authorization=`Bearer ${n.token}`),C},Q=async()=>{if(oe.value.length>0||s.currentConversation)return;if(q.value||R)return R;I.value=!0,T.value="";let C=++M;return R=(async()=>{let H=n.token||"",K=z(),Ce=await fetch("/api/user/agent-secret",{headers:K});if(C!==M||H!==(n.token||""))return;if(!Ce.ok){let ft="";try{ft=(await Ce.json())?.error||""}catch{}throw new Error(ft||"Failed to load Agent secret")}let De=await Ce.json();if(C!==M||H!==(n.token||""))return;let xe=De?.agentSecret||De?.agent_secret||null;q.value=xe&&String(xe).trim()?String(xe):null})().catch(H=>{C===M&&(T.value=H?.message||"Failed to load Agent secret")}).finally(()=>{C===M&&(I.value=!1,R=null)}),R},ae=new WeakMap,ke=0,N=(C,H)=>{let K=C?.message&&typeof C.message=="object"?C.message:Array.isArray(C?.messages)&&C.messages[0]&&typeof C.messages[0]=="object"?C.messages[0]:H&&typeof H=="object"?H:C&&typeof C=="object"?C:null;if(!K)return`legacy_render_${++ke}`;let Ce=ae.get(K);return Ce||(Ce=`legacy_render_${++ke}`,ae.set(K,Ce)),Ce},G=C=>{let H=C?.message||C||null;return C?.entryId||C?.uiKey||C?.stableKey||H?.entryId||H?.uiKey||H?.stableKey||C?.atMessageId||C?.messageId||H?.messageId||C?.id||H?.id||N(C,H)},de=C=>encodeURIComponent(String(C||"legacy")),we=C=>{let H=C?.message||null,K=G(C),Ce=C?.id||C?.atMessageId||H?.id||H?.messageId||K,De=C?.speakerVpId||C?.vpId||H?.speakerVpId||H?.vpId||"";return{id:`message_${de(K)}`,uiKey:K,vpId:De,messageId:Ce}},se=Vue.computed(()=>{let C=s.currentView==="yeaft"?jf(s.messages):s.messages,H=[],K=null,Ce=()=>{if(K){let Ne=K.turnId&&Object.values(s.activeVpTurns||{}).find(ot=>((ot?.turnId||null)===K.turnId||!ot?.turnId&&s.activeVpTurns?.[K.turnId]===ot)&&(!s.currentAgent||!ot?.agentId||ot.agentId===s.currentAgent))||null;K.isActive=!!Ne,Number.isFinite(Ne?.startedAt)&&(K.startedAt=Ne.startedAt),co(K);let Ae=K.messages.reduce((ot,dn)=>Number.isInteger(dn?.llmCallCount)&&dn.llmCallCount>ot?dn.llmCallCount:ot,0),Ot=K.turnId?s.yeaftDebugTurnsById?.[K.turnId]:null;K.llmCallCount=Math.max(Ae,Ot?.loopCount||0);let Yt=[...K.messages].reverse().find(ot=>ot?.type==="assistant"&&(ot.model||ot.effort||Number.isFinite(ot.inputTokens)||Number.isFinite(ot.outputTokens)||Number.isFinite(ot.totalTokens)||Number.isFinite(ot.totalMs)||Number.isFinite(ot.turnDurationMs)));K.model=Ot?.model||Yt?.model||null,K.effort=Ot?.effort||Yt?.effort||null;for(let ot of["inputTokens","outputTokens","totalTokens"]){let dn=Ot?.[ot],Pa=Yt?.[ot];Number.isFinite(dn)?K[ot]=dn:Number.isFinite(Pa)&&(K[ot]=Pa)}Number.isFinite(Ot?.totalMs)?K.totalMs=Ot.totalMs:Number.isFinite(Yt?.totalMs)?K.totalMs=Yt.totalMs:Number.isFinite(Yt?.turnDurationMs)&&(K.totalMs=Yt.turnDurationMs);let cn=!!(K.textContent||K.todoMsg||K.askMsg||K.imageMsgs.length>0),Ma=K.toolMsgs.length>0;(cn||Ma)&&(K.showSpeakerHeader=!!K.speakerVpId,H.push(K)),K=null}},De=Ne=>{if(K){if(!K.speakerVpId){let Ae=Ne.speakerVpId||Ne.vpId;Ae&&(K.speakerVpId=Ae,K.speakerTimestamp=typeof Ne.timestamp=="number"&&Ne.timestamp>0?Ne.timestamp:typeof Ne.createdAt=="number"?Ne.createdAt:0,typeof Ne.lastStateChangeCause=="string"&&!K.speakerStateCause&&(K.speakerStateCause=Ne.lastStateChangeCause))}!K.turnId&&Ne.turnId&&(K.turnId=Ne.turnId)}},xe=(Ne=null)=>{let Ae=G(Ne);K={type:"assistant-turn",id:`response_${de(Ae)}`,uiKey:Ae,...Ne?.entryId?{entryId:Ne.entryId}:{},textContent:"",textSegments:[],isStreaming:!1,isActive:!1,isHistory:!1,todoMsg:null,toolMsgs:[],imageMsgs:[],askMsg:null,messages:[],atMessageId:null,speakerVpId:null,speakerTimestamp:0,speakerStateCause:"",showSpeakerHeader:!1,startedAt:0,totalMs:null,inputTokens:null,outputTokens:null,totalTokens:null,turnId:null}},ft=Ne=>{Uf(K,Ne)&&Ce()};for(let Ne=0;Ne<C.length;Ne++){let Ae=C[Ne];if(Ae.type==="user"){if(!Ae.content||!Ae.content.trim())continue;Ce(),H.push({type:"user",id:G(Ae),message:Ae});continue}if(Ae.type==="system"||Ae.type==="error"){Ce(),H.push({type:Ae.type,id:G(Ae),message:Ae});continue}if(!(Ae.type==="tool-result"||Ae.type==="tool_result")){if(Ae.type==="assistant"){ft(Ae),K||xe(Ae),lo(K,Ae),Ae.isStreaming&&(K.isStreaming=!0),Ae.isHistory&&(K.isHistory=!0),Ae.id&&/^m\d+$/.test(Ae.id)&&(K.atMessageId=Ae.id),De(Ae),K.messages.push(Ae);continue}if(Ae.type==="tool-use"){ft(Ae),K||xe(Ae),De(Ae);let Ot=C[Ne+1],Yt=Ot&&(Ot.type==="tool-result"||Ot.type==="tool_result"),cn={...Ae,hasResult:Yt||Ae.hasResult||!1,toolResult:Ae.toolResult||null};Ae.isHistory&&(K.isHistory=!0),Ae.toolName==="TodoWrite"?K.todoMsg=cn:Ae.toolName==="AskUserQuestion"?K.askMsg=cn:K.toolMsgs.push(cn),K.messages.push(Ae);continue}if(Ae.type==="chat-image"){ft(Ae),K||xe(Ae),De(Ae),Ae.isHistory&&(K.isHistory=!0),K.imageMsgs.push(Ae),K.messages.push(Ae);continue}Ce(),H.push({type:Ae.type||"unknown",id:G(Ae),message:Ae})}}return Ce(),H}),ve=Vue.computed(()=>{let C=[],H=null,K=()=>{H&&C.push(H),H=null};return se.value.forEach(Ce=>{if(!Ce||Ce.type==="system"||Ce.type==="error"){K(),C.push(Ce);return}let De=we(Ce);if(Ce.type==="user"||!H){K(),H={type:"message-block",id:`block_${de(De.uiKey)}`,uiKey:De.uiKey,vpId:De.vpId,messageId:De.messageId,originMessageId:Ce.type==="user"?Ce.id:"",items:[Ce]};return}H.items.push(Ce),!H.vpId&&De.vpId&&(H.vpId=De.vpId)}),K(),C}),Ie=Vue.computed(()=>{let C=s.yeaftReflectionCards||{},H=s.yeaftConversationId,K={__orphans:[]},Ce=Object.values(C).filter(xe=>xe&&xe.conversationId===H).sort((xe,ft)=>(xe.anchorOrder||0)-(ft.anchorOrder||0)||(xe.updatedAt||0)-(ft.updatedAt||0)),De=new Set;for(let xe of s.messages||[])xe&&xe.id&&De.add(xe.id);for(let xe of Ce)xe.anchorMsgId&&De.has(xe.anchorMsgId)?(K[xe.anchorMsgId]||(K[xe.anchorMsgId]=[]),K[xe.anchorMsgId].push(xe)):K.__orphans.push(xe);return K}),ue=C=>C?C.type==="assistant-turn"?C.atMessageId||null:C.message&&C.message.id||null:null,re=C=>{let H=ue(C);return H?(Ie.value||{})[H]||[]:[]},te=Vue.computed(()=>(Ie.value||{}).__orphans||[]),V=Vue.computed(()=>{let C=s.yeaftSubAgentCards||{},H=s.yeaftConversationId,K={__orphans:[]},Ce=Object.values(C).filter(xe=>xe&&xe.conversationId===H).sort((xe,ft)=>(xe.anchorOrder||0)-(ft.anchorOrder||0)||(xe.updatedAt||0)-(ft.updatedAt||0)),De=new Set;for(let xe of s.messages||[])xe&&xe.id&&De.add(xe.id);for(let xe of Ce)xe.anchorMsgId&&De.has(xe.anchorMsgId)?(K[xe.anchorMsgId]||(K[xe.anchorMsgId]=[]),K[xe.anchorMsgId].push(xe)):K.__orphans.push(xe);return K}),ce=C=>{let H=ue(C);return H?(V.value||{})[H]||[]:[]},X=Vue.computed(()=>(V.value||{}).__orphans||[]),F=Vue.ref(!0),Z=Vue.ref(""),fe=Vue.ref(!1),Re=Gs.bottomThreshold,J=!0,D=Vue.computed(()=>s.messages.some(C=>C.isStreaming)),ye=Vue.computed(()=>{let C=s.currentAgent||null,H=s.yeaftActiveSessionFilter||s.activeYeaftSessionId||null;return Object.values(s.activeVpTurns||{}).some(K=>(!C||!K?.agentId||K.agentId===C)&&(!H||!K?.sessionId||K.sessionId===H))}),Me=Vue.computed(()=>!s.activeConversationId||ve.value.length>0?!1:s.currentView==="yeaft"?!!s.yeaftInitialHistoryLoading:!!s.sessionLoading),ze=Vue.computed(()=>s.currentView==="yeaft"&&!!s.yeaftLoadingMoreHistory&&s.activeYeaftHistoryState?.mode==="older"),Ye=Vue.computed(()=>s.currentView==="yeaft"?"":s.sessionLoadingText||""),rt=Vue.computed(()=>!!s.sessionLoading&&!Me.value),ut=Vue.computed(()=>s.isProcessing&&!D.value),at=Vue.ref(Date.now()),W=null,ie=()=>{W||(W=setInterval(()=>{at.value=Date.now()},1e3))},me=()=>{W&&(clearInterval(W),W=null)};Vue.watch(ye,C=>{C?(at.value=Date.now(),ie()):me()},{immediate:!0}),Vue.onBeforeUnmount(()=>me());let he=Vue.ref(0),Ee=Vue.ref(Date.now()),Ue=Vue.ref(null),Mt=Vue.ref(null),Qe=null,mt=Vue.ref("cat"),Et=new URLSearchParams(window.location.search).get("preview"),et=Vue.ref(5),lt=Vue.ref(95),_=Vue.ref("bark-both"),ee=Vue.ref(1),Se=Vue.ref(-1),_e=null;function Fe(){if(!he.value)return;let C=Ue.value,H=Mt.value;if(C&&H){let K=C.parentElement,Ce=Math.max(0,(K?.clientWidth||0)-80);qo(C,H,Oo(Date.now()-he.value,Ce))}}let Xe=Vo({onFrame:Fe});function pt(){if(!he.value||mt.value!=="dog")return;Ee.value=Date.now();let C=(Ee.value-he.value)%18e3;if(C<2e3)et.value=5,lt.value=95,_.value="bark-both",ee.value=1,Se.value=-1;else if(C<5e3){let H=(C-2e3)/3e3;et.value=5+H*25,lt.value=95,_.value="left-approach",ee.value=1,Se.value=-1}else if(C<8e3){let H=(C-5e3)/3e3;et.value=30,lt.value=95-H*25,_.value="right-approach",ee.value=1,Se.value=-1}else if(C<1e4){let H=(C-8e3)/2e3;et.value=30+H*13,lt.value=70-H*13,_.value="both-approach",ee.value=1,Se.value=-1}else if(C<11e3)et.value=43,lt.value=57,_.value="snap",ee.value=1,Se.value=-1;else if(C<12500)et.value=43,lt.value=57,_.value="stunned",ee.value=1,Se.value=-1;else if(C<15e3){let H=(C-12500)/2500;et.value=43-H*38,lt.value=57+H*38,_.value="retreat",ee.value=-1,Se.value=1}else C<17e3?(et.value=5,lt.value=95,_.value="rehang",ee.value=-1,Se.value=1):(et.value=5,lt.value=95,_.value="reset",ee.value=1,Se.value=-1);_e=requestAnimationFrame(pt)}let gt=Vue.computed(()=>{let C=et.value*1.2;return ee.value<0?`translate(${C+13.5}, 0) scale(-1, 1)`:`translate(${C-13.5}, 0)`}),Dt=Vue.computed(()=>{let C=lt.value*1.2;return Se.value>0?`translate(${C-10.5}, 2)`:`translate(${C+10.5}, 2) scale(-1, 1)`}),$t=Vue.computed(()=>{let C=_.value;return C==="bark-both"||C==="left-approach"||C==="right-approach"||C==="both-approach"||C==="reset"}),Lt=Vue.computed(()=>{let C=et.value*1.2,H=10;if($t.value){let De=Math.max(0,(C-3)*.12);return`M3,18 Q${(3+C)/2},${18+De} ${C},${H}`}if(_.value==="rehang")return`M${C},${H} Q${C-3},20 3,18`;let K=ee.value<0?1:-1,Ce=C+K*8;return`M${C},${H} Q${C},18 ${Ce},22`}),tn=Vue.computed(()=>{let C=lt.value*1.2,H=10;if($t.value){let De=Math.max(0,(118-C)*.12);return`M118,18 Q${(118+C)/2},${18+De} ${C},${H}`}if(_.value==="rehang")return`M${C},${H} Q${C+3},20 118,18`;let K=Se.value>0?-1:1,Ce=C+K*8;return`M${C},${H} Q${C},18 ${Ce},22`}),Dn=Vue.computed(()=>_.value==="snap"?.2:.4),Sr=Vue.computed(()=>_.value==="snap"?.2:.4),Jt=Vue.computed(()=>et.value*1.2),sn=Vue.computed(()=>lt.value*1.2),nn=Et==="cat"||Et==="dog"||Et==="animation",$n=600,rn=Vue.ref(!1),Ze=null,Ut=Vue.computed(()=>nn?!0:rn.value);Vue.watch(ut,C=>{if(C)Ze&&(clearTimeout(Ze),Ze=null),rn.value=!0,he.value=Date.now(),Ee.value=Date.now(),Qe||(Qe=setInterval(()=>{Ee.value=Date.now()},1e3)),mt.value="cat",et.value=5,lt.value=95,_.value="bark-both",ee.value=1,Se.value=-1,mt.value==="cat"?Xe.start():_e=requestAnimationFrame(pt);else{let H=he.value?Date.now()-he.value:$n,K=Math.max(0,$n-H),Ce=()=>{Ze=null,rn.value=!1,he.value=0,Qe&&(clearInterval(Qe),Qe=null),Xe.stop(),_e&&(cancelAnimationFrame(_e),_e=null)};K===0?Ce():(Ze&&clearTimeout(Ze),Ze=setTimeout(Ce,K))}},{immediate:!0}),nn&&(he.value=Date.now(),Ee.value=Date.now(),Et==="dog"?mt.value="dog":mt.value="cat",mt.value==="cat"?Xe.start():(et.value=5,lt.value=95,_.value="bark-both",ee.value=1,Se.value=-1,_e=requestAnimationFrame(pt)));let Fs=Vue.computed(()=>{if(!s.isProcessing)return null;if(s.connectionState!=="connected")return"disconnected";let C=s.currentConversation;if(s.compactStatus?.conversationId===C&&s.compactStatus?.status==="compacting")return"compacting";let H=s.sessionHealth?.[C];return H?H.status:he.value&&Ee.value-he.value>8e3?"thinking":null});function O(){let C=s.currentConversation;if(!C)return;let H=s.conversations.find(K=>K.id===C);s.sendWsMessage({type:"refresh_conversation",conversationId:C,agentId:H?.agentId})}let ne=null,be=null,Pe=new Set,qe=C=>{if(!be)return;let H=new Set(C);for(let K of Pe)H.has(K)||(be.unobserve(K),Pe.delete(K));for(let K of H)Pe.has(K)||(be.observe(K),Pe.add(K))},it=()=>{ne=null;let C=o.value;if(!C){Z.value="";return}let H=C.getBoundingClientRect?.(),K=Array.from(C.querySelectorAll?.("[data-response-origin-id]")||[]);qe(K),Z.value=th({viewportTop:H?.top||0,viewportHeight:C.clientHeight||H?.height||0,responses:K.map(Ce=>{let De=Ce.getBoundingClientRect();return{originMessageId:Ce.dataset?.responseOriginId||"",top:De.top,bottom:De.bottom,height:De.height}})})},Je=()=>{ne==null&&(ne=requestAnimationFrame(it))},Pt=()=>{if(!o.value)return!0;let{scrollTop:C,scrollHeight:H,clientHeight:K}=o.value;return fi({scrollTop:C,scrollHeight:H,clientHeight:K,threshold:Re})},At=(C,H=0,{allowContinuation:K=!1}={})=>{if(C>Lf(H)){J=!0;return}K&&(J=!0),!(!J||!Ti())&&(J=!1,Mi())},bt=C=>{if(!C)return"";let K=(Array.isArray(C.items)?C.items:[])[0]||null;return[C.type||"",C.messageId||"",C.turnId||"",C.vpId||"",K?.id||"",K?.turnId||"",K?.messageId||""].join(":")},xt=()=>{let C=ve.value||[];return{blockCount:C.length,firstBlockIdentity:bt(C[0])}},Kt=(C,H)=>!C||!H?!1:H.blockCount>C.blockCount||H.firstBlockIdentity!==C.firstBlockIdentity,Ft=C=>{Vue.nextTick(()=>{if(!o.value)return;let H=xt();Kt(C,H)&&At(o.value.scrollTop||0,o.value.clientHeight||0,{allowContinuation:!0})})},He=()=>{fe.value=!1,F.value=!0,a.value?.setBottomFollowEnabled?.(!0)},ct=()=>{fe.value=!0,F.value=!1,a.value?.setBottomFollowEnabled?.(!1),a.value?.cancelPendingBottomFollow?.()},Ir=({scrollTop:C,scrollHeight:H,clientHeight:K})=>{let Ce=fi({scrollTop:C||0,scrollHeight:H||0,clientHeight:K||0,threshold:Re});F.value=Ff({following:!fe.value,atBottom:Ce}),fe.value=!F.value,a.value?.setBottomFollowEnabled?.(F.value),vs||(an=Number(C||0)),At(C||0,K||0),Je()},Ca=(C,H)=>{let K=xt(),Ce=!1,De=null,xe=()=>{Ce||(Ce=!0,De&&De(),Ft(K))};H&&(De=Vue.watch(H,ft=>{ft||xe()})),C(),Vue.nextTick(()=>{(!H||!H())&&xe()})},es=()=>{if(s.hasHiddenYeaftMessages){s.expandYeaftMessageWindow();return}s.loadMoreYeaftHistory()},Ti=()=>s.currentView==="yeaft"?s.hasHiddenYeaftMessages||s.yeaftHasMoreHistory&&!s.yeaftLoadingMoreHistory&&s.yeaftOldestLoadedSeq!=null:!!s.currentConversation&&s.hasMoreMessages&&!s.loadingMoreMessages,Mi=()=>{if(!Ti())return;let C=s.currentView==="yeaft";Ca(C?es:()=>s.loadMoreMessages(),C?()=>s.yeaftLoadingMoreHistory:()=>s.loadingMoreMessages)},vs=!1,on=!1,zt=null,an=0,Pi=250,Cr=()=>{vs=!1,zt&&(clearTimeout(zt),zt=null)},ln=()=>{on||(zt&&clearTimeout(zt),zt=setTimeout(Cr,Pi))},Ln=()=>{ct(),vs=!0,a.value?.clearTargetAnchor?.(),an=Number(o.value?.scrollTop||0),ln()},Ri=C=>{qf(C,o.value)&&(ct(),on=!0,vs=!0,a.value?.clearTargetAnchor?.(),an=Number(o.value?.scrollTop||0),zt&&(clearTimeout(zt),zt=null))},Fn=()=>{on=!1,ln()},_i=C=>{Vf(C,o.value)&&(ct(),vs=!0,a.value?.clearTargetAnchor?.(),ln())},Os=()=>{let C=Number(o.value?.scrollTop||0),H=!fe.value;an=C;let K=Pt();F.value=Of({following:H,atBottom:K,userScroll:vs}),fe.value=!F.value,a.value?.setBottomFollowEnabled?.(F.value),vs&&ln(),o.value&&At(o.value.scrollTop||0,o.value.clientHeight||0),Je()},ts=()=>{o.value&&(o.value.scrollTop=o.value.scrollHeight,He())},Aa=()=>{a.value?.clearTargetAnchor?.(),s.currentView==="yeaft"&&s.showLatestYeaftMessageWindow?.(L.value||s.yeaftActiveSessionFilter||null,s.currentAgent||null),Cr(),He(),Vue.nextTick(ts)},Ei=()=>{!fe.value&&F.value&&Vue.nextTick(ts)},Di=C=>{if(!C)return"";if(Array.isArray(C.items))return C.items.map(Di).join(",");let H=C.message||{};return[C.type||"",C.id||"",C.atMessageId||"",C.turnId||"",C.messageId||"",C.speakerVpId||"",H.id||"",H.content?String(H.content).length:0,C.textContent?String(C.textContent).length:0,C.isStreaming||H.isStreaming?"streaming":"done"].join(":")},xa=Vue.computed(()=>{let C=ve.value||[];return[s.activeConversationId||"",L.value||"",Di(C[C.length-1])].join("|")});Vue.watch(()=>[s.currentConversation,oe.value.length,n.token],()=>{let C=n.token||"";C!==$&&($=C,j()),Q()},{immediate:!0}),Vue.watch(xa,()=>{Ei(),Vue.nextTick(Je)}),Vue.watch(Ut,C=>{C&&Ei()}),Vue.watch(U,()=>{for(let C of Object.keys(l))delete l[C];for(let C of Object.keys(c))delete c[C];for(let C of Object.keys(d))delete d[C];He(),Vue.nextTick(ts)});let Ar=Vue.ref(null),On=0,$i=C=>{let H=++On;Ar.value=C,setTimeout(()=>{H===On&&(Ar.value=null)},1800)},Ta=async C=>{if(!C)return!1;let H=ve.value.find(xe=>xe?.originMessageId===C);if(!H?.id||(Z.value="",ct(),!await a.value?.scrollToKey?.(H.id,{align:"start"})))return!1;await Vue.nextTick();let Ce=o.value?.querySelectorAll?.("[data-msg-id]")||[],De=Array.from(Ce).find(xe=>xe?.dataset?.msgId===C)||null;return De?(a.value?.anchorTarget?.(H.id,De,{align:"start"}),$i(C),!0):!1};return t({revealMessage:async C=>C?(ct(),await eh({blocks:ve.value,target:C,collapseStates:d,nextTick:Vue.nextTick,scrollToBlock:(K,Ce)=>(ct(),a.value?.scrollToKey?.(K,Ce)),findRow:K=>{let Ce=o.value?.querySelectorAll?.("[data-msg-id]")||[];return Array.from(Ce).find(De=>De?.dataset?.msgId===K)||null},anchorRow:(K,Ce,De,xe)=>a.value?.anchorTarget?.(K,De,xe),flashRow:$i})):!1}),Vue.onMounted(()=>{typeof ResizeObserver<"u"&&(be=new ResizeObserver(Je)),ts(),Vue.nextTick(Je),o.value&&(o.value.addEventListener("wheel",Ln,{passive:!0}),o.value.addEventListener("touchmove",Ln,{passive:!0}),o.value.addEventListener("pointerdown",Ri,{passive:!0}),o.value.addEventListener("scroll",Os)),window.addEventListener("pointerup",Fn,{passive:!0}),window.addEventListener("pointercancel",Fn,{passive:!0}),window.addEventListener("keydown",_i)}),Vue.onUnmounted(()=>{o.value&&(o.value.removeEventListener("wheel",Ln),o.value.removeEventListener("touchmove",Ln),o.value.removeEventListener("pointerdown",Ri),o.value.removeEventListener("scroll",Os)),window.removeEventListener("pointerup",Fn),window.removeEventListener("pointercancel",Fn),window.removeEventListener("keydown",_i),ne!=null&&cancelAnimationFrame(ne),ne=null,be?.disconnect(),be=null,Pe.clear(),Cr(),Qe&&(clearInterval(Qe),Qe=null),Ze&&(clearTimeout(Ze),Ze=null),Xe.stop(),_e&&(cancelAnimationFrame(_e),_e=null)}),{store:s,containerRef:o,virtualTranscriptRef:a,flashMsgId:Ar,jumpToOrigin:Ta,hasStreamingMessage:D,nowMs:at,showTypingDots:ut,showInitialMessagesLoading:Me,showYeaftOlderHistoryLoading:ze,showSessionLoadingOverlay:rt,initialMessagesLoadingText:Ye,previewShowTypingDots:Ut,isPreviewMode:nn,waitingStatus:Fs,animationType:mt,catWalkRef:Ue,catSpriteRef:Mt,dogPhase:_,spikeTransform:gt,teddyTransform:Dt,leashPathL:Lt,leashPathR:tn,leashOpacityL:Dn,leashOpacityR:Sr,questionLX:Jt,questionRX:sn,refreshSession:O,onlineAgents:oe,welcomeAgentSecret:q,welcomeSetupLoading:I,welcomeSetupError:T,turnGroups:se,messageBlocks:ve,virtualTranscriptIdentity:U,estimateMessageBlockHeight:v,visibleItemsForBlock:y,collapsedResponsePreviewLines:h,collapsedResponsePreviewSpeaker:k,responseToggleBelongsToItem:b,showBlockResponseToggle:w,toggleMessageTurnResponse:P,responseCollapseLabel:x,turnUiKey:u,assistantTurnActionsExpandedFor:g,setAssistantTurnActionsExpanded:p,onOpenTurnDebug:f,toolExpandStates:c,setToolExpanded:m,cardsForRow:re,orphanCards:te,subAgentCardsForRow:ce,orphanSubAgentCards:X,useImStyleForUser:E,onClickLoadMore:Mi,onVirtualTranscriptScrollState:Ir,isAtBottom:F,activeLongResponseOriginId:Z,scrollToLatest:Aa}}}});function jo(...e){let t=[];for(let s of e)if(Array.isArray(s))for(let n of s)typeof n!="string"||!n||t.includes(n)||t.push(n);return t}function oh(e,t,s){let n=t?e?.slashCommandsMap?.[t]:null;return e?.currentView==="yeaft"?jo(n):jo(n,s?e?.slashCommandsMap?.[`agent:${s}`]:null,e?.slashCommandsMap?.__preload__)}function _k(e,t={},s=new Set){if(Rk.has(e)||Object.prototype.hasOwnProperty.call(Wo,e))return"builtin";let n=e.startsWith("/")?e.slice(1):e;return n.startsWith("skill:")||n.startsWith("yeaft-skills:")||s.has(n)&&Object.prototype.hasOwnProperty.call(t||{},n)?"skill":"project"}function ah(e,t={}){if(No[e])return No[e];if(Wo[e])return Wo[e];let s=e.startsWith("/")?e.slice(1):e;return t[s]?t[s]:Ek(s)}function Ek(e){return(e.includes(":")?e.split(":").pop():e).replace(/-/g," ").replace(/^\w/,s=>s.toUpperCase())}function lh(e,t={},s=[]){if(e.length===0)return[];let n=new Set(s.filter(o=>typeof o=="string").map(o=>o.startsWith("/")?o.slice(1):o)),r={};e.forEach((o,a)=>{let l=_k(o.cmd,o.descriptions||o.dynamicDescriptions||t,n);r[l]||(r[l]=[]),r[l].push({...o,flatIndex:a})});let i=Object.keys(r).sort((o,a)=>(nh[o]??99)-(nh[a]??99));return i.map((o,a)=>({label:Dk[o]||o,items:r[o],isLast:a===i.length-1}))}var No,Rk,rh,Wo,ih,Dk,nh,ch=B(()=>{No={"/compact":"Compact context","/context":"Show context usage","/cost":"Show token costs","/init":"Reinitialize session","/doctor":"Check health status","/memory":"View/edit memory","/model":"View/switch model","/review":"Code review","/mcp":"MCP server status","/skills":"List available skills","/btw":"Side question (no history)","/insights":"Session insights","/pr-comments":"PR comment review","/release-notes":"Generate release notes","/security-review":"Security review"},Rk=new Set(Object.keys(No)),rh=Object.keys(No),Wo={"/low":"Use low reasoning effort for this turn","/medium":"Use medium reasoning effort for this turn","/high":"Use high reasoning effort for this turn","/xhigh":"Use extra-high reasoning effort for this turn","/max":"Use maximum reasoning effort for this turn","/ultra":"Use ultra reasoning effort for this turn"},ih=Object.keys(Wo);Dk={skill:"Skills",builtin:"Built-in",project:"Commands"},nh={skill:0,project:1,builtin:2}});function Ok(e){return!(!e||typeof e!="string"||e.length<1||e.length>40||e.startsWith("_")||Lk.test(e)||$k.has(e.toLowerCase()))}function Uo(e){if(!e||typeof e!="string")return{text:e||"",mentions:[]};let t=new Set;dh.lastIndex=0;let s;for(;(s=dh.exec(e))!==null;){let n=s[2];if(Ok(n)&&!t.has(n)&&(t.add(n),t.size>=Fk))break}return{text:e,mentions:Array.from(t)}}var $k,dh,Lk,Fk,Rc=B(()=>{$k=new Set(["all","user","system","everyone"]),dh=/(^|[\s\p{P}])@([A-Za-z0-9_-]{1,40})(?=$|[\s\p{P}])/gu,Lk=/^[0-9]+$/,Fk=32});function uh(e){let t=typeof e?.vpId=="string"?e.vpId:"";return _c.has(t)?_c.get(t):e?.isStock===!0?"other":"custom"}function Rn(e){let t=new Map(Ko.map(s=>[s.id,[]]));for(let s of Array.isArray(e)?e:[])!s||typeof s.vpId!="string"||!s.vpId||t.get(uh(s)).push(s);return Ko.map(s=>({id:s.id,labelKey:s.labelKey,vps:t.get(s.id)})).filter(s=>s.vps.length>0)}function vi(e){return Rn(e).flatMap(t=>t.vps)}function ph(e){let t=new Map(Ko.map(r=>[r.id,r])),s=new Map,n=[];for(let r of Array.isArray(e)?e:[]){if(!r||typeof r.vpId!="string"||!r.vpId)continue;let i=uh(r),o=n[n.length-1];if(o&&o.id===i){o.vps.push(r);continue}let a=(s.get(i)||0)+1;s.set(i,a),n.push({id:i,key:`${i}-${a}`,labelKey:t.get(i).labelKey,vps:[r]})}return n}var qk,Ko,_c,yi=B(()=>{qk=[{id:"general",labelKey:"yeaft.vp.domain.general",vpIds:["omni"]},{id:"productDesign",labelKey:"yeaft.vp.domain.productDesign",vpIds:["steve","dieter","norman"]},{id:"softwareSystems",labelKey:"yeaft.vp.domain.softwareSystems",vpIds:["linus","martin","anders","ada","grace","ken","alan"]},{id:"securityReliability",labelKey:"yeaft.vp.domain.securityReliability",vpIds:["alice","margaret"]},{id:"scienceAnalysis",labelKey:"yeaft.vp.domain.scienceAnalysis",vpIds:["shannon","einstein"]},{id:"philosophyPsychology",labelKey:"yeaft.vp.domain.philosophyPsychology",vpIds:["kongzi","socrates","nietzsche","kahneman","jung"]},{id:"strategyHistory",labelKey:"yeaft.vp.domain.strategyHistory",vpIds:["sunzi","clausewitz","simaqian","harari"]},{id:"businessManagement",labelKey:"yeaft.vp.domain.businessManagement",vpIds:["buffett","munger","dalio","bezos","drucker"]},{id:"artsCulture",labelKey:"yeaft.vp.domain.artsCulture",vpIds:["luxun","sudongpo","borges","kubrick","miyazaki"]},{id:"other",labelKey:"yeaft.vp.domain.other",vpIds:[]},{id:"custom",labelKey:"yeaft.vp.domain.custom",vpIds:[]}],Ko=Object.freeze(qk.map(e=>Object.freeze({id:e.id,labelKey:e.labelKey,vpIds:Object.freeze([...e.vpIds])}))),_c=new Map;for(let e of Ko)for(let t of e.vpIds)_c.set(t,e.id)});function Ec(e,t){let s=Array.isArray(e)?e:[],n=typeof t=="string"?t.toLowerCase():"";if(!n){let c=s.filter(d=>d&&d.vpId&&d.vpId!=="user");return vi(c).slice(0,gh)}let r=[],i=[],o=[],a=new Set,l=(c,d)=>{a.has(c.vpId)||(a.add(c.vpId),d.push(c))};for(let c of s){if(!c||!c.vpId||c.vpId==="user")continue;if(String(c.vpId).toLowerCase().startsWith(n)){l(c,r);continue}let u=Array.isArray(c.aliases)?c.aliases:[],g=!1;for(let k of u){let S=String(k||"").toLowerCase();if(S&&S.startsWith(n)){g=!0;break}}if(g){l(c,i);continue}let p=String(c.displayName||"").toLowerCase(),f=String(c.displayNameZh||""),m=[c.description,c.descriptionZh,c.role,c.roleZh].map(k=>String(k||"").toLowerCase()),v=typeof t=="string"?t:"",y=p.includes(n)||v&&f.includes(v),h=n&&m.some(k=>k.includes(n));(y||h)&&l(c,o)}return[...vi(r),...vi(i),...vi(o)].slice(0,gh)}function Dc(e="chat-input"){return`${e}-vp-mention-listbox`}function $c(e,t){let s=String(t||"").replace(/[^A-Za-z0-9_.:-]/g,"-");return`${e}-vp-mention-option-${s}`}function Vk(e){let t=0;return ph(e).map(s=>({...s,items:s.vps.map(n=>({vp:n,flatIndex:t++}))}))}function fh(e,t){let s=Array.isArray(e)?e:[];if(!t)return s;let n=Array.isArray(t.roster)?t.roster:[];if(n.length===0)return[];let r=new Set(n);return s.filter(i=>i&&i.vpId&&r.has(i.vpId))}function hh(e,t){if(typeof e!="string"||!t)return e;let s=e.lastIndexOf("@");if(s<0)return e;let n=s+1;for(;n<e.length&&!/[\s]/.test(e[n]);)n++;return e.slice(0,s)+"@"+t+" "+e.slice(n)}var gh,mh,vh=B(()=>{yi();gh=12;mh={name:"VpMentionAutocomplete",emits:["select","hover-index"],props:{vps:{type:Array,default:()=>[]},query:{type:String,default:""},selectedIndex:{type:Number,default:0},inputId:{type:String,required:!0}},template:`
1744
+ `,emits:["new-conversation","resume-conversation","open-settings","quote-message","edit-message-as-new"],setup(e,{expose:t}){let s=Pinia.useChatStore(),n=Ge(),r=typeof window<"u"&&window.Pinia?.useVpStore?window.Pinia.useVpStore():null,i=Vue.inject("t",null),o=Vue.ref(null),a=Vue.ref(null),l=Vue.reactive({}),c=Vue.reactive({}),d=Vue.reactive({}),u=C=>String(C?.id||C?.turnId||C?.messageId||C?.atMessageId||C?.message?.id||"turn_unknown"),g=C=>{let H=u(C);return Object.prototype.hasOwnProperty.call(l,H)?!!l[H]:!1},p=(C,H)=>{l[u(C)]=!!H},f=C=>{let H=C&&(C.turnId||C.id);!H||typeof s.openYeaftTurnDebug!="function"||s.openYeaftTurnDebug({sessionId:L.value||null,turnId:H})},m=({key:C,value:H}={})=>{C&&(c[C]=!!H)},v=C=>{let H=Gf(C,zs);return Number.isFinite(H)?H:zs(C)},b=C=>Ho(C),h=C=>{let H=Array.isArray(C?.collapsedResponsePreview)?C.collapsedResponsePreview:Yf(C);return Array.isArray(H)?H:H?[String(H)]:[]},k=C=>{let H=Array.isArray(C?.items)?C.items.find(Ae=>mi(Ae)):null,K=H?.speakerVpId||H?.vpId||H?.message?.speakerVpId||H?.message?.vpId||C?.vpId||"",Ce=K&&r&&typeof r.vpLabel=="function"?r.vpLabel(K)||K:K||(typeof i=="function"?i("message.assistant"):"Assistant"),De=K&&r&&typeof r.vpTextColor=="function"?{color:r.vpTextColor(K)}:{},xe=H?.speakerTimestamp||H?.timestamp||H?.createdAt||H?.message?.timestamp||H?.message?.createdAt||0,ft="",Ne="";if(xe)try{let Ae=new Date(xe);Number.isNaN(Ae.getTime())||(ft=ls(xe),Ne=Ae.toLocaleString())}catch{}return{name:Ce,style:De,timeText:ft,fullTimeText:Ne}},S=C=>{let H=Array.isArray(C?.items)?C.items:[];for(let K=H.length-1;K>=0;K-=1)if(mi(H[K]))return H[K];return null},y=(C,H)=>!C?.responseCollapsible||!H?!1:S(C)===H,w=C=>!!(C?.responseCollapsible&&!Ho(C).some(H=>y(C,H))),P=C=>{let H=C?.responseCollapseKey;H&&(d[H]=!C.responseCollapsed)},x=C=>{let H=Number(C?.responseCount||0),K=C?.responseCollapsed?"message.showResponses":"message.hideResponses",Ce=(typeof i=="function"?i(K):"")||(C?.responseCollapsed?"Show {count} response(s)":"Hide response(s)");return String(Ce).replace("{count}",String(H))},Y=(()=>{try{return window.Pinia?.useSessionsStore?.()||null}catch{return null}}),L=Vue.computed(()=>{if(s.currentView!=="yeaft")return null;let C=Y();if(!C)return null;let H=s.yeaftActiveSessionFilter||null;return H&&typeof C.sessionById=="function"&&C.sessionById(H,s.currentAgent||null)?H:C.activeSessionId&&typeof C.sessionById=="function"&&C.sessionById(C.activeSessionId,s.currentAgent||null)?C.activeSessionId:null}),U=Vue.computed(()=>{let C=s.currentView||"",H=s.currentAgent||"";if(C==="yeaft"){let K=s.yeaftActiveSessionFilter||L.value||"__all__";return[C,H,K].join("")}return[C,H,s.activeConversationId||""].join("")}),E=Vue.computed(()=>L.value!==null),oe=Vue.computed(()=>s.agents.filter(C=>C.online)),q=Vue.ref(null),I=Vue.ref(!1),T=Vue.ref(""),R=null,M=0,$=n.token||"",j=()=>{q.value=null,T.value="",R=null,M+=1},z=()=>{let C={"Content-Type":"application/json"};return n.token&&(C.Authorization=`Bearer ${n.token}`),C},Q=async()=>{if(oe.value.length>0||s.currentConversation)return;if(q.value||R)return R;I.value=!0,T.value="";let C=++M;return R=(async()=>{let H=n.token||"",K=z(),Ce=await fetch("/api/user/agent-secret",{headers:K});if(C!==M||H!==(n.token||""))return;if(!Ce.ok){let ft="";try{ft=(await Ce.json())?.error||""}catch{}throw new Error(ft||"Failed to load Agent secret")}let De=await Ce.json();if(C!==M||H!==(n.token||""))return;let xe=De?.agentSecret||De?.agent_secret||null;q.value=xe&&String(xe).trim()?String(xe):null})().catch(H=>{C===M&&(T.value=H?.message||"Failed to load Agent secret")}).finally(()=>{C===M&&(I.value=!1,R=null)}),R},ae=new WeakMap,ke=0,N=(C,H)=>{let K=C?.message&&typeof C.message=="object"?C.message:Array.isArray(C?.messages)&&C.messages[0]&&typeof C.messages[0]=="object"?C.messages[0]:H&&typeof H=="object"?H:C&&typeof C=="object"?C:null;if(!K)return`legacy_render_${++ke}`;let Ce=ae.get(K);return Ce||(Ce=`legacy_render_${++ke}`,ae.set(K,Ce)),Ce},G=C=>{let H=C?.message||C||null;return C?.entryId||C?.uiKey||C?.stableKey||H?.entryId||H?.uiKey||H?.stableKey||C?.atMessageId||C?.messageId||H?.messageId||C?.id||H?.id||N(C,H)},de=C=>encodeURIComponent(String(C||"legacy")),we=C=>{let H=C?.message||null,K=G(C),Ce=C?.id||C?.atMessageId||H?.id||H?.messageId||K,De=C?.speakerVpId||C?.vpId||H?.speakerVpId||H?.vpId||"";return{id:`message_${de(K)}`,uiKey:K,vpId:De,messageId:Ce}},se=Vue.computed(()=>{let C=s.currentView==="yeaft"?jf(s.messages):s.messages,H=[],K=null,Ce=()=>{if(K){let Ne=K.turnId&&Object.values(s.activeVpTurns||{}).find(ot=>((ot?.turnId||null)===K.turnId||!ot?.turnId&&s.activeVpTurns?.[K.turnId]===ot)&&(!s.currentAgent||!ot?.agentId||ot.agentId===s.currentAgent))||null;K.isActive=!!Ne,Number.isFinite(Ne?.startedAt)&&(K.startedAt=Ne.startedAt),co(K);let Ae=K.messages.reduce((ot,dn)=>Number.isInteger(dn?.llmCallCount)&&dn.llmCallCount>ot?dn.llmCallCount:ot,0),Ot=K.turnId?s.yeaftDebugTurnsById?.[K.turnId]:null;K.llmCallCount=Math.max(Ae,Ot?.loopCount||0);let Yt=[...K.messages].reverse().find(ot=>ot?.type==="assistant"&&(ot.model||ot.effort||Number.isFinite(ot.inputTokens)||Number.isFinite(ot.outputTokens)||Number.isFinite(ot.totalTokens)||Number.isFinite(ot.totalMs)||Number.isFinite(ot.turnDurationMs)));K.model=Ot?.model||Yt?.model||null,K.effort=Ot?.effort||Yt?.effort||null;for(let ot of["inputTokens","outputTokens","totalTokens"]){let dn=Ot?.[ot],Pa=Yt?.[ot];Number.isFinite(dn)?K[ot]=dn:Number.isFinite(Pa)&&(K[ot]=Pa)}Number.isFinite(Ot?.totalMs)?K.totalMs=Ot.totalMs:Number.isFinite(Yt?.totalMs)?K.totalMs=Yt.totalMs:Number.isFinite(Yt?.turnDurationMs)&&(K.totalMs=Yt.turnDurationMs);let cn=!!(K.textContent||K.todoMsg||K.askMsg||K.imageMsgs.length>0),Ma=K.toolMsgs.length>0;(cn||Ma)&&(K.showSpeakerHeader=!!K.speakerVpId,H.push(K)),K=null}},De=Ne=>{if(K){if(!K.speakerVpId){let Ae=Ne.speakerVpId||Ne.vpId;Ae&&(K.speakerVpId=Ae,K.speakerTimestamp=typeof Ne.timestamp=="number"&&Ne.timestamp>0?Ne.timestamp:typeof Ne.createdAt=="number"?Ne.createdAt:0,typeof Ne.lastStateChangeCause=="string"&&!K.speakerStateCause&&(K.speakerStateCause=Ne.lastStateChangeCause))}!K.turnId&&Ne.turnId&&(K.turnId=Ne.turnId)}},xe=(Ne=null)=>{let Ae=G(Ne);K={type:"assistant-turn",id:`response_${de(Ae)}`,uiKey:Ae,...Ne?.entryId?{entryId:Ne.entryId}:{},textContent:"",textSegments:[],isStreaming:!1,isActive:!1,isHistory:!1,todoMsg:null,toolMsgs:[],imageMsgs:[],askMsg:null,messages:[],atMessageId:null,speakerVpId:null,speakerTimestamp:0,speakerStateCause:"",showSpeakerHeader:!1,startedAt:0,totalMs:null,inputTokens:null,outputTokens:null,totalTokens:null,turnId:null}},ft=Ne=>{Uf(K,Ne)&&Ce()};for(let Ne=0;Ne<C.length;Ne++){let Ae=C[Ne];if(Ae.type==="user"){if(!Ae.content||!Ae.content.trim())continue;Ce(),H.push({type:"user",id:G(Ae),message:Ae});continue}if(Ae.type==="system"||Ae.type==="error"){Ce(),H.push({type:Ae.type,id:G(Ae),message:Ae});continue}if(!(Ae.type==="tool-result"||Ae.type==="tool_result")){if(Ae.type==="assistant"){ft(Ae),K||xe(Ae),lo(K,Ae),Ae.isStreaming&&(K.isStreaming=!0),Ae.isHistory&&(K.isHistory=!0),Ae.id&&/^m\d+$/.test(Ae.id)&&(K.atMessageId=Ae.id),De(Ae),K.messages.push(Ae);continue}if(Ae.type==="tool-use"){ft(Ae),K||xe(Ae),De(Ae);let Ot=C[Ne+1],Yt=Ot&&(Ot.type==="tool-result"||Ot.type==="tool_result"),cn={...Ae,hasResult:Yt||Ae.hasResult||!1,toolResult:Ae.toolResult||null};Ae.isHistory&&(K.isHistory=!0),Ae.toolName==="TodoWrite"?K.todoMsg=cn:Ae.toolName==="AskUserQuestion"?K.askMsg=cn:K.toolMsgs.push(cn),K.messages.push(Ae);continue}if(Ae.type==="chat-image"){ft(Ae),K||xe(Ae),De(Ae),Ae.isHistory&&(K.isHistory=!0),K.imageMsgs.push(Ae),K.messages.push(Ae);continue}Ce(),H.push({type:Ae.type||"unknown",id:G(Ae),message:Ae})}}return Ce(),H}),ve=Vue.computed(()=>{let C=[],H=null,K=()=>{H&&C.push(H),H=null};return se.value.forEach(Ce=>{if(!Ce||Ce.type==="system"||Ce.type==="error"){K(),C.push(Ce);return}let De=we(Ce);if(Ce.type==="user"||!H){K(),H={type:"message-block",id:`block_${de(De.uiKey)}`,uiKey:De.uiKey,vpId:De.vpId,messageId:De.messageId,originMessageId:Ce.type==="user"?Ce.id:"",items:[Ce]};return}H.items.push(Ce),!H.vpId&&De.vpId&&(H.vpId=De.vpId)}),K(),C}),Ie=Vue.computed(()=>{let C=s.yeaftReflectionCards||{},H=s.yeaftConversationId,K={__orphans:[]},Ce=Object.values(C).filter(xe=>xe&&xe.conversationId===H).sort((xe,ft)=>(xe.anchorOrder||0)-(ft.anchorOrder||0)||(xe.updatedAt||0)-(ft.updatedAt||0)),De=new Set;for(let xe of s.messages||[])xe&&xe.id&&De.add(xe.id);for(let xe of Ce)xe.anchorMsgId&&De.has(xe.anchorMsgId)?(K[xe.anchorMsgId]||(K[xe.anchorMsgId]=[]),K[xe.anchorMsgId].push(xe)):K.__orphans.push(xe);return K}),ue=C=>C?C.type==="assistant-turn"?C.atMessageId||null:C.message&&C.message.id||null:null,re=C=>{let H=ue(C);return H?(Ie.value||{})[H]||[]:[]},te=Vue.computed(()=>(Ie.value||{}).__orphans||[]),V=Vue.computed(()=>{let C=s.yeaftSubAgentCards||{},H=s.yeaftConversationId,K={__orphans:[]},Ce=Object.values(C).filter(xe=>xe&&xe.conversationId===H).sort((xe,ft)=>(xe.anchorOrder||0)-(ft.anchorOrder||0)||(xe.updatedAt||0)-(ft.updatedAt||0)),De=new Set;for(let xe of s.messages||[])xe&&xe.id&&De.add(xe.id);for(let xe of Ce)xe.anchorMsgId&&De.has(xe.anchorMsgId)?(K[xe.anchorMsgId]||(K[xe.anchorMsgId]=[]),K[xe.anchorMsgId].push(xe)):K.__orphans.push(xe);return K}),ce=C=>{let H=ue(C);return H?(V.value||{})[H]||[]:[]},X=Vue.computed(()=>(V.value||{}).__orphans||[]),F=Vue.ref(!0),Z=Vue.ref(""),fe=Vue.ref(!1),Re=Gs.bottomThreshold,J=!0,D=Vue.computed(()=>s.messages.some(C=>C.isStreaming)),ye=Vue.computed(()=>{let C=s.currentAgent||null,H=s.yeaftActiveSessionFilter||s.activeYeaftSessionId||null;return Object.values(s.activeVpTurns||{}).some(K=>(!C||!K?.agentId||K.agentId===C)&&(!H||!K?.sessionId||K.sessionId===H))}),Me=Vue.computed(()=>!s.activeConversationId||ve.value.length>0?!1:s.currentView==="yeaft"?!!s.yeaftInitialHistoryLoading:!!s.sessionLoading),ze=Vue.computed(()=>s.currentView==="yeaft"&&!!s.yeaftLoadingMoreHistory&&s.activeYeaftHistoryState?.mode==="older"),Ye=Vue.computed(()=>s.currentView==="yeaft"?"":s.sessionLoadingText||""),rt=Vue.computed(()=>!!s.sessionLoading&&!Me.value),ut=Vue.computed(()=>s.isProcessing&&!D.value),at=Vue.ref(Date.now()),W=null,ie=()=>{W||(W=setInterval(()=>{at.value=Date.now()},1e3))},me=()=>{W&&(clearInterval(W),W=null)};Vue.watch(ye,C=>{C?(at.value=Date.now(),ie()):me()},{immediate:!0}),Vue.onBeforeUnmount(()=>me());let he=Vue.ref(0),Ee=Vue.ref(Date.now()),Ue=Vue.ref(null),Mt=Vue.ref(null),Qe=null,mt=Vue.ref("cat"),Et=new URLSearchParams(window.location.search).get("preview"),et=Vue.ref(5),lt=Vue.ref(95),_=Vue.ref("bark-both"),ee=Vue.ref(1),Se=Vue.ref(-1),_e=null;function Fe(){if(!he.value)return;let C=Ue.value,H=Mt.value;if(C&&H){let K=C.parentElement,Ce=Math.max(0,(K?.clientWidth||0)-80);qo(C,H,Oo(Date.now()-he.value,Ce))}}let Xe=Vo({onFrame:Fe});function pt(){if(!he.value||mt.value!=="dog")return;Ee.value=Date.now();let C=(Ee.value-he.value)%18e3;if(C<2e3)et.value=5,lt.value=95,_.value="bark-both",ee.value=1,Se.value=-1;else if(C<5e3){let H=(C-2e3)/3e3;et.value=5+H*25,lt.value=95,_.value="left-approach",ee.value=1,Se.value=-1}else if(C<8e3){let H=(C-5e3)/3e3;et.value=30,lt.value=95-H*25,_.value="right-approach",ee.value=1,Se.value=-1}else if(C<1e4){let H=(C-8e3)/2e3;et.value=30+H*13,lt.value=70-H*13,_.value="both-approach",ee.value=1,Se.value=-1}else if(C<11e3)et.value=43,lt.value=57,_.value="snap",ee.value=1,Se.value=-1;else if(C<12500)et.value=43,lt.value=57,_.value="stunned",ee.value=1,Se.value=-1;else if(C<15e3){let H=(C-12500)/2500;et.value=43-H*38,lt.value=57+H*38,_.value="retreat",ee.value=-1,Se.value=1}else C<17e3?(et.value=5,lt.value=95,_.value="rehang",ee.value=-1,Se.value=1):(et.value=5,lt.value=95,_.value="reset",ee.value=1,Se.value=-1);_e=requestAnimationFrame(pt)}let gt=Vue.computed(()=>{let C=et.value*1.2;return ee.value<0?`translate(${C+13.5}, 0) scale(-1, 1)`:`translate(${C-13.5}, 0)`}),Dt=Vue.computed(()=>{let C=lt.value*1.2;return Se.value>0?`translate(${C-10.5}, 2)`:`translate(${C+10.5}, 2) scale(-1, 1)`}),$t=Vue.computed(()=>{let C=_.value;return C==="bark-both"||C==="left-approach"||C==="right-approach"||C==="both-approach"||C==="reset"}),Lt=Vue.computed(()=>{let C=et.value*1.2,H=10;if($t.value){let De=Math.max(0,(C-3)*.12);return`M3,18 Q${(3+C)/2},${18+De} ${C},${H}`}if(_.value==="rehang")return`M${C},${H} Q${C-3},20 3,18`;let K=ee.value<0?1:-1,Ce=C+K*8;return`M${C},${H} Q${C},18 ${Ce},22`}),tn=Vue.computed(()=>{let C=lt.value*1.2,H=10;if($t.value){let De=Math.max(0,(118-C)*.12);return`M118,18 Q${(118+C)/2},${18+De} ${C},${H}`}if(_.value==="rehang")return`M${C},${H} Q${C+3},20 118,18`;let K=Se.value>0?-1:1,Ce=C+K*8;return`M${C},${H} Q${C},18 ${Ce},22`}),Dn=Vue.computed(()=>_.value==="snap"?.2:.4),Sr=Vue.computed(()=>_.value==="snap"?.2:.4),Jt=Vue.computed(()=>et.value*1.2),sn=Vue.computed(()=>lt.value*1.2),nn=Et==="cat"||Et==="dog"||Et==="animation",$n=600,rn=Vue.ref(!1),Ze=null,Ut=Vue.computed(()=>nn?!0:rn.value);Vue.watch(ut,C=>{if(C)Ze&&(clearTimeout(Ze),Ze=null),rn.value=!0,he.value=Date.now(),Ee.value=Date.now(),Qe||(Qe=setInterval(()=>{Ee.value=Date.now()},1e3)),mt.value="cat",et.value=5,lt.value=95,_.value="bark-both",ee.value=1,Se.value=-1,mt.value==="cat"?Xe.start():_e=requestAnimationFrame(pt);else{let H=he.value?Date.now()-he.value:$n,K=Math.max(0,$n-H),Ce=()=>{Ze=null,rn.value=!1,he.value=0,Qe&&(clearInterval(Qe),Qe=null),Xe.stop(),_e&&(cancelAnimationFrame(_e),_e=null)};K===0?Ce():(Ze&&clearTimeout(Ze),Ze=setTimeout(Ce,K))}},{immediate:!0}),nn&&(he.value=Date.now(),Ee.value=Date.now(),Et==="dog"?mt.value="dog":mt.value="cat",mt.value==="cat"?Xe.start():(et.value=5,lt.value=95,_.value="bark-both",ee.value=1,Se.value=-1,_e=requestAnimationFrame(pt)));let Fs=Vue.computed(()=>{if(!s.isProcessing)return null;if(s.connectionState!=="connected")return"disconnected";let C=s.currentConversation;if(s.compactStatus?.conversationId===C&&s.compactStatus?.status==="compacting")return"compacting";let H=s.sessionHealth?.[C];return H?H.status:he.value&&Ee.value-he.value>8e3?"thinking":null});function O(){let C=s.currentConversation;if(!C)return;let H=s.conversations.find(K=>K.id===C);s.sendWsMessage({type:"refresh_conversation",conversationId:C,agentId:H?.agentId})}let ne=null,be=null,Pe=new Set,qe=C=>{if(!be)return;let H=new Set(C);for(let K of Pe)H.has(K)||(be.unobserve(K),Pe.delete(K));for(let K of H)Pe.has(K)||(be.observe(K),Pe.add(K))},it=()=>{ne=null;let C=o.value;if(!C){Z.value="";return}let H=C.getBoundingClientRect?.(),K=Array.from(C.querySelectorAll?.("[data-response-origin-id]")||[]);qe(K),Z.value=th({viewportTop:H?.top||0,viewportHeight:C.clientHeight||H?.height||0,responses:K.map(Ce=>{let De=Ce.getBoundingClientRect();return{originMessageId:Ce.dataset?.responseOriginId||"",top:De.top,bottom:De.bottom,height:De.height}})})},Je=()=>{ne==null&&(ne=requestAnimationFrame(it))},Pt=()=>{if(!o.value)return!0;let{scrollTop:C,scrollHeight:H,clientHeight:K}=o.value;return fi({scrollTop:C,scrollHeight:H,clientHeight:K,threshold:Re})},At=(C,H=0,{allowContinuation:K=!1}={})=>{if(C>Lf(H)){J=!0;return}K&&(J=!0),!(!J||!Ti())&&(J=!1,Mi())},bt=C=>{if(!C)return"";let K=(Array.isArray(C.items)?C.items:[])[0]||null;return[C.type||"",C.messageId||"",C.turnId||"",C.vpId||"",K?.id||"",K?.turnId||"",K?.messageId||""].join(":")},xt=()=>{let C=ve.value||[];return{blockCount:C.length,firstBlockIdentity:bt(C[0])}},Kt=(C,H)=>!C||!H?!1:H.blockCount>C.blockCount||H.firstBlockIdentity!==C.firstBlockIdentity,Ft=C=>{Vue.nextTick(()=>{if(!o.value)return;let H=xt();Kt(C,H)&&At(o.value.scrollTop||0,o.value.clientHeight||0,{allowContinuation:!0})})},He=()=>{fe.value=!1,F.value=!0,a.value?.setBottomFollowEnabled?.(!0)},ct=()=>{fe.value=!0,F.value=!1,a.value?.setBottomFollowEnabled?.(!1),a.value?.cancelPendingBottomFollow?.()},Ir=({scrollTop:C,scrollHeight:H,clientHeight:K})=>{let Ce=fi({scrollTop:C||0,scrollHeight:H||0,clientHeight:K||0,threshold:Re});F.value=Ff({following:!fe.value,atBottom:Ce}),fe.value=!F.value,a.value?.setBottomFollowEnabled?.(F.value),vs||(an=Number(C||0)),At(C||0,K||0),Je()},Ca=(C,H)=>{let K=xt(),Ce=!1,De=null,xe=()=>{Ce||(Ce=!0,De&&De(),Ft(K))};H&&(De=Vue.watch(H,ft=>{ft||xe()})),C(),Vue.nextTick(()=>{(!H||!H())&&xe()})},es=()=>{if(s.hasHiddenYeaftMessages){s.expandYeaftMessageWindow();return}s.loadMoreYeaftHistory()},Ti=()=>s.currentView==="yeaft"?s.hasHiddenYeaftMessages||s.yeaftHasMoreHistory&&!s.yeaftLoadingMoreHistory&&s.yeaftOldestLoadedSeq!=null:!!s.currentConversation&&s.hasMoreMessages&&!s.loadingMoreMessages,Mi=()=>{if(!Ti())return;let C=s.currentView==="yeaft";Ca(C?es:()=>s.loadMoreMessages(),C?()=>s.yeaftLoadingMoreHistory:()=>s.loadingMoreMessages)},vs=!1,on=!1,zt=null,an=0,Pi=250,Cr=()=>{vs=!1,zt&&(clearTimeout(zt),zt=null)},ln=()=>{on||(zt&&clearTimeout(zt),zt=setTimeout(Cr,Pi))},Ln=()=>{ct(),vs=!0,a.value?.clearTargetAnchor?.(),an=Number(o.value?.scrollTop||0),ln()},Ri=C=>{qf(C,o.value)&&(ct(),on=!0,vs=!0,a.value?.clearTargetAnchor?.(),an=Number(o.value?.scrollTop||0),zt&&(clearTimeout(zt),zt=null))},Fn=()=>{on=!1,ln()},_i=C=>{Vf(C,o.value)&&(ct(),vs=!0,a.value?.clearTargetAnchor?.(),ln())},Os=()=>{let C=Number(o.value?.scrollTop||0),H=!fe.value;an=C;let K=Pt();F.value=Of({following:H,atBottom:K,userScroll:vs}),fe.value=!F.value,a.value?.setBottomFollowEnabled?.(F.value),vs&&ln(),o.value&&At(o.value.scrollTop||0,o.value.clientHeight||0),Je()},ts=()=>{o.value&&(o.value.scrollTop=o.value.scrollHeight,He())},Aa=()=>{a.value?.clearTargetAnchor?.(),s.currentView==="yeaft"&&s.showLatestYeaftMessageWindow?.(L.value||s.yeaftActiveSessionFilter||null,s.currentAgent||null),Cr(),He(),Vue.nextTick(ts)},Ei=()=>{!fe.value&&F.value&&Vue.nextTick(ts)},Di=C=>{if(!C)return"";if(Array.isArray(C.items))return C.items.map(Di).join(",");let H=C.message||{};return[C.type||"",C.id||"",C.atMessageId||"",C.turnId||"",C.messageId||"",C.speakerVpId||"",H.id||"",H.content?String(H.content).length:0,C.textContent?String(C.textContent).length:0,C.isStreaming||H.isStreaming?"streaming":"done"].join(":")},xa=Vue.computed(()=>{let C=ve.value||[];return[s.activeConversationId||"",L.value||"",Di(C[C.length-1])].join("|")});Vue.watch(()=>[s.currentConversation,oe.value.length,n.token],()=>{let C=n.token||"";C!==$&&($=C,j()),Q()},{immediate:!0}),Vue.watch(xa,()=>{Ei(),Vue.nextTick(Je)}),Vue.watch(Ut,C=>{C&&Ei()}),Vue.watch(U,()=>{for(let C of Object.keys(l))delete l[C];for(let C of Object.keys(c))delete c[C];for(let C of Object.keys(d))delete d[C];He(),Vue.nextTick(ts)});let Ar=Vue.ref(null),On=0,$i=C=>{let H=++On;Ar.value=C,setTimeout(()=>{H===On&&(Ar.value=null)},1800)},Ta=async C=>{if(!C)return!1;let H=ve.value.find(xe=>xe?.originMessageId===C);if(!H?.id||(Z.value="",ct(),!await a.value?.scrollToKey?.(H.id,{align:"start"})))return!1;await Vue.nextTick();let Ce=o.value?.querySelectorAll?.("[data-msg-id]")||[],De=Array.from(Ce).find(xe=>xe?.dataset?.msgId===C)||null;return De?(a.value?.anchorTarget?.(H.id,De,{align:"start"}),$i(C),!0):!1};return t({revealMessage:async C=>C?(ct(),await eh({blocks:ve.value,target:C,collapseStates:d,nextTick:Vue.nextTick,scrollToBlock:(K,Ce)=>(ct(),a.value?.scrollToKey?.(K,Ce)),findRow:K=>{let Ce=o.value?.querySelectorAll?.("[data-msg-id]")||[];return Array.from(Ce).find(De=>De?.dataset?.msgId===K)||null},anchorRow:(K,Ce,De,xe)=>a.value?.anchorTarget?.(K,De,xe),flashRow:$i})):!1}),Vue.onMounted(()=>{typeof ResizeObserver<"u"&&(be=new ResizeObserver(Je)),ts(),Vue.nextTick(Je),o.value&&(o.value.addEventListener("wheel",Ln,{passive:!0}),o.value.addEventListener("touchmove",Ln,{passive:!0}),o.value.addEventListener("pointerdown",Ri,{passive:!0}),o.value.addEventListener("scroll",Os)),window.addEventListener("pointerup",Fn,{passive:!0}),window.addEventListener("pointercancel",Fn,{passive:!0}),window.addEventListener("keydown",_i)}),Vue.onUnmounted(()=>{o.value&&(o.value.removeEventListener("wheel",Ln),o.value.removeEventListener("touchmove",Ln),o.value.removeEventListener("pointerdown",Ri),o.value.removeEventListener("scroll",Os)),window.removeEventListener("pointerup",Fn),window.removeEventListener("pointercancel",Fn),window.removeEventListener("keydown",_i),ne!=null&&cancelAnimationFrame(ne),ne=null,be?.disconnect(),be=null,Pe.clear(),Cr(),Qe&&(clearInterval(Qe),Qe=null),Ze&&(clearTimeout(Ze),Ze=null),Xe.stop(),_e&&(cancelAnimationFrame(_e),_e=null)}),{store:s,containerRef:o,virtualTranscriptRef:a,flashMsgId:Ar,jumpToOrigin:Ta,hasStreamingMessage:D,nowMs:at,showTypingDots:ut,showInitialMessagesLoading:Me,showYeaftOlderHistoryLoading:ze,showSessionLoadingOverlay:rt,initialMessagesLoadingText:Ye,previewShowTypingDots:Ut,isPreviewMode:nn,waitingStatus:Fs,animationType:mt,catWalkRef:Ue,catSpriteRef:Mt,dogPhase:_,spikeTransform:gt,teddyTransform:Dt,leashPathL:Lt,leashPathR:tn,leashOpacityL:Dn,leashOpacityR:Sr,questionLX:Jt,questionRX:sn,refreshSession:O,onlineAgents:oe,welcomeAgentSecret:q,welcomeSetupLoading:I,welcomeSetupError:T,turnGroups:se,messageBlocks:ve,virtualTranscriptIdentity:U,estimateMessageBlockHeight:v,visibleItemsForBlock:b,collapsedResponsePreviewLines:h,collapsedResponsePreviewSpeaker:k,responseToggleBelongsToItem:y,showBlockResponseToggle:w,toggleMessageTurnResponse:P,responseCollapseLabel:x,turnUiKey:u,assistantTurnActionsExpandedFor:g,setAssistantTurnActionsExpanded:p,onOpenTurnDebug:f,toolExpandStates:c,setToolExpanded:m,cardsForRow:re,orphanCards:te,subAgentCardsForRow:ce,orphanSubAgentCards:X,useImStyleForUser:E,onClickLoadMore:Mi,onVirtualTranscriptScrollState:Ir,isAtBottom:F,activeLongResponseOriginId:Z,scrollToLatest:Aa}}}});function jo(...e){let t=[];for(let s of e)if(Array.isArray(s))for(let n of s)typeof n!="string"||!n||t.includes(n)||t.push(n);return t}function oh(e,t,s){let n=t?e?.slashCommandsMap?.[t]:null;return e?.currentView==="yeaft"?jo(n):jo(n,s?e?.slashCommandsMap?.[`agent:${s}`]:null,e?.slashCommandsMap?.__preload__)}function _k(e,t={},s=new Set){if(Rk.has(e)||Object.prototype.hasOwnProperty.call(Wo,e))return"builtin";let n=e.startsWith("/")?e.slice(1):e;return n.startsWith("skill:")||n.startsWith("yeaft-skills:")||s.has(n)&&Object.prototype.hasOwnProperty.call(t||{},n)?"skill":"project"}function ah(e,t={}){if(No[e])return No[e];if(Wo[e])return Wo[e];let s=e.startsWith("/")?e.slice(1):e;return t[s]?t[s]:Ek(s)}function Ek(e){return(e.includes(":")?e.split(":").pop():e).replace(/-/g," ").replace(/^\w/,s=>s.toUpperCase())}function lh(e,t={},s=[]){if(e.length===0)return[];let n=new Set(s.filter(o=>typeof o=="string").map(o=>o.startsWith("/")?o.slice(1):o)),r={};e.forEach((o,a)=>{let l=_k(o.cmd,o.descriptions||o.dynamicDescriptions||t,n);r[l]||(r[l]=[]),r[l].push({...o,flatIndex:a})});let i=Object.keys(r).sort((o,a)=>(nh[o]??99)-(nh[a]??99));return i.map((o,a)=>({label:Dk[o]||o,items:r[o],isLast:a===i.length-1}))}var No,Rk,rh,Wo,ih,Dk,nh,ch=B(()=>{No={"/compact":"Compact context","/context":"Show context usage","/cost":"Show token costs","/init":"Reinitialize session","/doctor":"Check health status","/memory":"View/edit memory","/model":"View/switch model","/review":"Code review","/mcp":"MCP server status","/skills":"List available skills","/btw":"Side question (no history)","/insights":"Session insights","/pr-comments":"PR comment review","/release-notes":"Generate release notes","/security-review":"Security review"},Rk=new Set(Object.keys(No)),rh=Object.keys(No),Wo={"/low":"Use low reasoning effort for this turn","/medium":"Use medium reasoning effort for this turn","/high":"Use high reasoning effort for this turn","/xhigh":"Use extra-high reasoning effort for this turn","/max":"Use maximum reasoning effort for this turn","/ultra":"Use ultra reasoning effort for this turn"},ih=Object.keys(Wo);Dk={skill:"Skills",builtin:"Built-in",project:"Commands"},nh={skill:0,project:1,builtin:2}});function Ok(e){return!(!e||typeof e!="string"||e.length<1||e.length>40||e.startsWith("_")||Lk.test(e)||$k.has(e.toLowerCase()))}function Uo(e){if(!e||typeof e!="string")return{text:e||"",mentions:[]};let t=new Set;dh.lastIndex=0;let s;for(;(s=dh.exec(e))!==null;){let n=s[2];if(Ok(n)&&!t.has(n)&&(t.add(n),t.size>=Fk))break}return{text:e,mentions:Array.from(t)}}var $k,dh,Lk,Fk,Rc=B(()=>{$k=new Set(["all","user","system","everyone"]),dh=/(^|[\s\p{P}])@([A-Za-z0-9_-]{1,40})(?=$|[\s\p{P}])/gu,Lk=/^[0-9]+$/,Fk=32});function uh(e){let t=typeof e?.vpId=="string"?e.vpId:"";return _c.has(t)?_c.get(t):e?.isStock===!0?"other":"custom"}function Rn(e){let t=new Map(Ko.map(s=>[s.id,[]]));for(let s of Array.isArray(e)?e:[])!s||typeof s.vpId!="string"||!s.vpId||t.get(uh(s)).push(s);return Ko.map(s=>({id:s.id,labelKey:s.labelKey,vps:t.get(s.id)})).filter(s=>s.vps.length>0)}function vi(e){return Rn(e).flatMap(t=>t.vps)}function ph(e){let t=new Map(Ko.map(r=>[r.id,r])),s=new Map,n=[];for(let r of Array.isArray(e)?e:[]){if(!r||typeof r.vpId!="string"||!r.vpId)continue;let i=uh(r),o=n[n.length-1];if(o&&o.id===i){o.vps.push(r);continue}let a=(s.get(i)||0)+1;s.set(i,a),n.push({id:i,key:`${i}-${a}`,labelKey:t.get(i).labelKey,vps:[r]})}return n}var qk,Ko,_c,yi=B(()=>{qk=[{id:"general",labelKey:"yeaft.vp.domain.general",vpIds:["omni"]},{id:"productDesign",labelKey:"yeaft.vp.domain.productDesign",vpIds:["steve","dieter","norman"]},{id:"softwareSystems",labelKey:"yeaft.vp.domain.softwareSystems",vpIds:["linus","martin","anders","ada","grace","ken","alan"]},{id:"securityReliability",labelKey:"yeaft.vp.domain.securityReliability",vpIds:["alice","margaret"]},{id:"scienceAnalysis",labelKey:"yeaft.vp.domain.scienceAnalysis",vpIds:["shannon","einstein"]},{id:"philosophyPsychology",labelKey:"yeaft.vp.domain.philosophyPsychology",vpIds:["kongzi","socrates","nietzsche","kahneman","jung"]},{id:"strategyHistory",labelKey:"yeaft.vp.domain.strategyHistory",vpIds:["sunzi","clausewitz","simaqian","harari"]},{id:"businessManagement",labelKey:"yeaft.vp.domain.businessManagement",vpIds:["buffett","munger","dalio","bezos","drucker"]},{id:"artsCulture",labelKey:"yeaft.vp.domain.artsCulture",vpIds:["luxun","sudongpo","borges","kubrick","miyazaki"]},{id:"other",labelKey:"yeaft.vp.domain.other",vpIds:[]},{id:"custom",labelKey:"yeaft.vp.domain.custom",vpIds:[]}],Ko=Object.freeze(qk.map(e=>Object.freeze({id:e.id,labelKey:e.labelKey,vpIds:Object.freeze([...e.vpIds])}))),_c=new Map;for(let e of Ko)for(let t of e.vpIds)_c.set(t,e.id)});function Ec(e,t){let s=Array.isArray(e)?e:[],n=typeof t=="string"?t.toLowerCase():"";if(!n){let c=s.filter(d=>d&&d.vpId&&d.vpId!=="user");return vi(c).slice(0,gh)}let r=[],i=[],o=[],a=new Set,l=(c,d)=>{a.has(c.vpId)||(a.add(c.vpId),d.push(c))};for(let c of s){if(!c||!c.vpId||c.vpId==="user")continue;if(String(c.vpId).toLowerCase().startsWith(n)){l(c,r);continue}let u=Array.isArray(c.aliases)?c.aliases:[],g=!1;for(let k of u){let S=String(k||"").toLowerCase();if(S&&S.startsWith(n)){g=!0;break}}if(g){l(c,i);continue}let p=String(c.displayName||"").toLowerCase(),f=String(c.displayNameZh||""),m=[c.description,c.descriptionZh,c.role,c.roleZh].map(k=>String(k||"").toLowerCase()),v=typeof t=="string"?t:"",b=p.includes(n)||v&&f.includes(v),h=n&&m.some(k=>k.includes(n));(b||h)&&l(c,o)}return[...vi(r),...vi(i),...vi(o)].slice(0,gh)}function Dc(e="chat-input"){return`${e}-vp-mention-listbox`}function $c(e,t){let s=String(t||"").replace(/[^A-Za-z0-9_.:-]/g,"-");return`${e}-vp-mention-option-${s}`}function Vk(e){let t=0;return ph(e).map(s=>({...s,items:s.vps.map(n=>({vp:n,flatIndex:t++}))}))}function fh(e,t){let s=Array.isArray(e)?e:[];if(!t)return s;let n=Array.isArray(t.roster)?t.roster:[];if(n.length===0)return[];let r=new Set(n);return s.filter(i=>i&&i.vpId&&r.has(i.vpId))}function hh(e,t){if(typeof e!="string"||!t)return e;let s=e.lastIndexOf("@");if(s<0)return e;let n=s+1;for(;n<e.length&&!/[\s]/.test(e[n]);)n++;return e.slice(0,s)+"@"+t+" "+e.slice(n)}var gh,mh,vh=B(()=>{yi();gh=12;mh={name:"VpMentionAutocomplete",emits:["select","hover-index"],props:{vps:{type:Array,default:()=>[]},query:{type:String,default:""},selectedIndex:{type:Number,default:0},inputId:{type:String,required:!0}},template:`
1742
1745
  <div
1743
1746
  class="slash-autocomplete vp-mention-autocomplete"
1744
1747
  v-if="filteredList.length > 0"
@@ -1775,7 +1778,7 @@ ${String(e||"").trim()}
1775
1778
  </div>
1776
1779
  </div>
1777
1780
  </div>
1778
- `,setup(e){let t=Vue.computed(()=>Ec(e.vps,e.query)),s=Vue.computed(()=>Vk(t.value)),n=Vue.computed(()=>Dc(e.inputId)),r=u=>$c(e.inputId,u),i=u=>`${n.value}-domain-${u}`,o=typeof window<"u"&&window.Pinia&&window.Pinia.useChatStore?window.Pinia.useChatStore():null,a=typeof window<"u"&&window.Pinia&&window.Pinia.useVpStore?window.Pinia.useVpStore():null;function l(u){return u?(o&&typeof o.locale=="string"?o.locale:typeof localStorage<"u"&&localStorage.getItem("locale")||"").startsWith("zh")&&u.displayNameZh?u.displayNameZh:u.displayName||u.vpId||"":""}function c(u){return u?a&&typeof a.vpDescription=="function"?a.vpDescription(u.vpId):(o&&typeof o.locale=="string"?o.locale:"").startsWith("zh")?u.descriptionZh||u.roleZh||u.description||u.role||"":u.description||u.role||u.descriptionZh||u.roleZh||"":""}function d(u){return a&&typeof a.vpTextColor=="function"?a.vpTextColor(u):"var(--text-primary)"}return{filteredList:t,domainSections:s,listboxId:n,optionId:r,domainLabelId:i,displayNameFor:l,descriptionFor:c,vpTextColorFor:d}}}});var zo,Lc=B(()=>{zo={name:"MessageComposer",props:{modelValue:{type:String,default:""},placeholder:{type:String,default:""},disabled:{type:Boolean,default:!1},canSend:{type:Boolean,default:!1},sending:{type:Boolean,default:!1},showStop:{type:Boolean,default:!1},rows:{type:Number,default:2},inputId:{type:String,default:""},sendLabel:{type:String,default:""},stopLabel:{type:String,default:""},ariaAutocomplete:{type:String,default:null},ariaHaspopup:{type:String,default:null},ariaControls:{type:String,default:null},ariaActivedescendant:{type:String,default:null}},emits:["update:modelValue","input","keydown","paste","focus","blur","send","stop"],setup(e,{emit:t}){let s=Vue.ref(null),n=Vue.ref(null),r=Vue.ref(!1),i=120,o=null,a=null,l=null,c=()=>{let m=n.value;if(!m)return;m.style.height="auto";let v=Math.min(m.scrollHeight,i);m.style.height=`${v}px`,r.value=m.scrollHeight>i},d=()=>{if(a===null){if(typeof requestAnimationFrame!="function"){c();return}a=requestAnimationFrame(()=>{a=null,c()})}},u=()=>{let m=n.value;m&&(m.style.height="auto",r.value=!1)},g=m=>{t("update:modelValue",m.target.value),t("input",m),c()},p=()=>Vue.nextTick(()=>n.value?.focus()),f=()=>n.value;return Vue.watch(()=>e.modelValue,m=>{Vue.nextTick(()=>{m?c():u()})}),Vue.onMounted(()=>{c();let m=s.value;!m||typeof ResizeObserver>"u"||(l=m.getBoundingClientRect().width,o=new ResizeObserver(v=>{let y=v[0]?.contentRect?.width??m.getBoundingClientRect().width;y!==l&&(l=y,d())}),o.observe(m))}),Vue.onUnmounted(()=>{o?.disconnect(),o=null,a!==null&&typeof cancelAnimationFrame=="function"&&cancelAnimationFrame(a),a=null}),{textareaWrapperRef:s,textareaRef:n,textareaScrollable:r,autoResize:c,resetTextareaSize:u,focusInput:p,getTextarea:f,onInput:g,emit:t}},template:`
1781
+ `,setup(e){let t=Vue.computed(()=>Ec(e.vps,e.query)),s=Vue.computed(()=>Vk(t.value)),n=Vue.computed(()=>Dc(e.inputId)),r=u=>$c(e.inputId,u),i=u=>`${n.value}-domain-${u}`,o=typeof window<"u"&&window.Pinia&&window.Pinia.useChatStore?window.Pinia.useChatStore():null,a=typeof window<"u"&&window.Pinia&&window.Pinia.useVpStore?window.Pinia.useVpStore():null;function l(u){return u?(o&&typeof o.locale=="string"?o.locale:typeof localStorage<"u"&&localStorage.getItem("locale")||"").startsWith("zh")&&u.displayNameZh?u.displayNameZh:u.displayName||u.vpId||"":""}function c(u){return u?a&&typeof a.vpDescription=="function"?a.vpDescription(u.vpId):(o&&typeof o.locale=="string"?o.locale:"").startsWith("zh")?u.descriptionZh||u.roleZh||u.description||u.role||"":u.description||u.role||u.descriptionZh||u.roleZh||"":""}function d(u){return a&&typeof a.vpTextColor=="function"?a.vpTextColor(u):"var(--text-primary)"}return{filteredList:t,domainSections:s,listboxId:n,optionId:r,domainLabelId:i,displayNameFor:l,descriptionFor:c,vpTextColorFor:d}}}});var zo,Lc=B(()=>{zo={name:"MessageComposer",props:{modelValue:{type:String,default:""},placeholder:{type:String,default:""},disabled:{type:Boolean,default:!1},canSend:{type:Boolean,default:!1},sending:{type:Boolean,default:!1},showStop:{type:Boolean,default:!1},rows:{type:Number,default:2},inputId:{type:String,default:""},sendLabel:{type:String,default:""},stopLabel:{type:String,default:""},ariaAutocomplete:{type:String,default:null},ariaHaspopup:{type:String,default:null},ariaControls:{type:String,default:null},ariaActivedescendant:{type:String,default:null}},emits:["update:modelValue","input","keydown","paste","focus","blur","send","stop"],setup(e,{emit:t}){let s=Vue.ref(null),n=Vue.ref(null),r=Vue.ref(!1),i=120,o=null,a=null,l=null,c=()=>{let m=n.value;if(!m)return;m.style.height="auto";let v=Math.min(m.scrollHeight,i);m.style.height=`${v}px`,r.value=m.scrollHeight>i},d=()=>{if(a===null){if(typeof requestAnimationFrame!="function"){c();return}a=requestAnimationFrame(()=>{a=null,c()})}},u=()=>{let m=n.value;m&&(m.style.height="auto",r.value=!1)},g=m=>{t("update:modelValue",m.target.value),t("input",m),c()},p=()=>Vue.nextTick(()=>n.value?.focus()),f=()=>n.value;return Vue.watch(()=>e.modelValue,m=>{Vue.nextTick(()=>{m?c():u()})}),Vue.onMounted(()=>{c();let m=s.value;!m||typeof ResizeObserver>"u"||(l=m.getBoundingClientRect().width,o=new ResizeObserver(v=>{let b=v[0]?.contentRect?.width??m.getBoundingClientRect().width;b!==l&&(l=b,d())}),o.observe(m))}),Vue.onUnmounted(()=>{o?.disconnect(),o=null,a!==null&&typeof cancelAnimationFrame=="function"&&cancelAnimationFrame(a),a=null}),{textareaWrapperRef:s,textareaRef:n,textareaScrollable:r,autoResize:c,resetTextareaSize:u,focusInput:p,getTextarea:f,onInput:g,emit:t}},template:`
1779
1782
  <div class="input-wrapper chat-composer" data-message-composer>
1780
1783
  <div ref="textareaWrapperRef" class="textarea-wrapper">
1781
1784
  <slot name="overlays"></slot>
@@ -1999,8 +2002,8 @@ ${String(e||"").trim()}
1999
2002
  </template>
2000
2003
  </MessageComposer>
2001
2004
  </footer>
2002
- `,setup(e,{emit:t}){let s=Pinia.useChatStore(),n=Pinia.useAuthStore(),r=Pinia.useVpStore(),i=Pinia.useSessionsStore?Pinia.useSessionsStore():null,o=Vue.ref(""),a=Vue.ref(!1),l=Vue.ref(null),c=Vue.computed(()=>l.value?.getTextarea?.()||null),u=`chat-input-${Vue.getCurrentInstance()?.uid??0}`,g=Vue.ref(null),p=Vue.ref([]),f=Vue.computed(()=>p.value.some(_=>_.uploading)),m=Vue.ref(null),v=Vue.ref(null),y=Vue.ref(null),h=Vue.computed(()=>!!e.sendFn),k=Vue.computed(()=>!s.btwMode),S=Vue.computed(()=>e.placeholderKey||"chatInput.placeholder"),b=Vue.computed(()=>e.showStop||!h.value&&s.isProcessing),w=Vue.computed({get:()=>s.expertSelections||[],set:_=>{s.expertSelections=_}}),P=Vue.ref(!1),x=Vue.ref(0),Y=Vue.computed(()=>op(s.customExpertRoles)),L=Vue.computed(()=>{let _=o.value,ee=_.lastIndexOf("@");if(ee===-1||!P.value)return[];let Se=_.slice(ee+1).toLowerCase();return Y.value.filter(_e=>Se?_e.searchText.includes(Se):!0).filter(_e=>!w.value.some(Fe=>Fe.role===_e.roleId)).slice(0,12)}),U=_=>{if(w.value.length>=Cn)return;let ee={role:_.roleId,action:_.actionId};s.expertSelections=[...w.value,ee];let Se=o.value,_e=Se.lastIndexOf("@");_e!==-1&&(o.value=Se.slice(0,_e).trimEnd()),P.value=!1,Vue.nextTick(()=>c.value?.focus())},E=_=>{let ee=[...w.value];ee.splice(_,1),s.expertSelections=ee},oe=_=>In(_,s.customExpertRoles),q=_=>_==="completed"?"\u2713":_==="in_progress"?"\u2192":"\u25CB",I=Vue.ref(!1),T=Vue.ref(0),R=()=>s.currentView==="yeaft"&&!!s.currentAgent,M=Vue.computed(()=>{let _=o.value,ee=_.lastIndexOf("@");return ee<0||!I.value?"":_.slice(ee+1)}),$=Vue.computed(()=>{if(!i)return r.vpList||[];let _=s.yeaftActiveSessionFilter||i.activeSessionId||null,ee=typeof i.sessionById=="function"?i.sessionById(_,s.currentAgent||null):i.sessions?.[_];return fh(r.vpList,ee)}),j=Vue.computed(()=>Ec($.value,M.value)),z=Vue.computed(()=>!s.btwMode&&I.value&&!P.value&&j.value.length>0),Q=Dc(u),ae=Vue.computed(()=>{if(!z.value)return null;let _=j.value[T.value];return _?$c(u,_.vpId):null}),ke=_=>{!_||!_.vpId||(o.value=hh(o.value,_.vpId),I.value=!1,T.value=0,Vue.nextTick(()=>c.value?.focus()))},N=Vue.computed(()=>e.draftKey||e.conversationId||s.currentConversation||null);N.value&&s.inputDrafts[N.value]&&(o.value=s.inputDrafts[N.value]),Vue.watch(o,_=>{let ee=N.value;ee&&(_?s.inputDrafts[ee]=_:delete s.inputDrafts[ee])}),Vue.watch(j,_=>{if(_.length===0){T.value=0;return}T.value>=_.length&&(T.value=_.length-1)}),Vue.watch(N,(_,ee)=>{ee&&o.value&&(s.inputDrafts[ee]=o.value),o.value=_&&s.inputDrafts[_]||""});let G=_=>{if(!_||typeof _!="string")return;let ee=o.value||"",Se=ee.length>0&&!/\s$/.test(ee),_e=ee+(Se?" ":"")+"@"+_+" ";o.value=_e,Vue.nextTick(()=>{let Fe=c.value;Fe&&(Fe.focus(),Fe.setSelectionRange(_e.length,_e.length),D())})},de=Vue.ref(!1),we=Vue.ref(0),se=Vue.computed(()=>{let _=e.conversationId||s.activeConversationId||s.currentConversation,ee=s.currentAgent,Se=oh(s,_,ee),_e=s.currentView==="yeaft"?ih:rh;return jo(_e,Se).map(Xe=>Xe.startsWith("/")?Xe:"/"+Xe)}),ve=Vue.computed(()=>{let _=o.value.trim();if(!_.startsWith("/"))return[];let ee=_.toLowerCase();return se.value.filter(Se=>Se.toLowerCase().startsWith(ee)&&Se.toLowerCase()!==ee).map(Se=>({cmd:Se,desc:ah(Se,s.slashCommandDescriptions)}))}),Ie=Vue.computed(()=>lh(ve.value,s.slashCommandDescriptions,se.value)),ue=Vue.computed(()=>ve.value.map(_=>_.cmd)),re=Vue.computed(()=>e.conversationId||s.activeConversationId||s.currentConversation||null),te=Vue.computed(()=>s.compactStatus?.status==="compacting"&&s.compactStatus?.conversationId===re.value),V=_=>typeof _?.fileId=="string"&&_.fileId.trim().length>0,ce=Vue.computed(()=>{if(e.disabled||te.value)return!1;let _=!!o.value.trim(),ee=p.value.length>0;if(h.value){let pt=!f.value&&p.value.every(V);return(_||ee)&&pt}let Se=w.value.length>0,_e=w.value.some(pt=>pt.action),Fe=_||ee||Se&&(_||_e),Xe=!f.value&&p.value.every(V);return Fe&&s.currentAgent&&s.currentConversation&&Xe}),{preferences:X}=pr(),F=Vue.computed(()=>{if(!e.quickSendEnabled||s.btwMode)return[];let _=s.llmConfig?.[s.currentAgent];if(!_?.loaded||_.error)return[];let ee=_.agentConfig?.quickSends||_.effectiveConfig?.quickSends||[];return Array.isArray(ee)?ee.slice(0,5):[]}),Z=Vue.computed(()=>ce.value&&s.connectionState==="connected"&&s.agents?.some(_=>_.id===s.currentAgent&&_.online));Vue.watch(()=>[e.quickSendEnabled,s.currentAgent,s.connectionState,s.agents?.find(_=>_.id===s.currentAgent)?.online],([_,ee,Se,_e])=>{_&&ee&&Se==="connected"&&_e&&s.sendWsMessage({type:"get_llm_config",agentId:ee})},{immediate:!0});let fe=_=>{!Z.value||!F.value.includes(_)||Qe({model:_.model,effort:_.effort??null,maxOutputTokens:_.maxOutputTokens??null})},Re=()=>{if(typeof window>"u")return!1;try{return typeof window.matchMedia=="function"?window.matchMedia("(max-width: 768px)").matches:Number(window.innerWidth)<=768}catch{return!1}},J=()=>{if(!Re())return;c.value?.blur();let _=globalThis.document?.activeElement;_?.closest?.("[data-message-composer]")&&_.blur?.(),a.value=!1},D=()=>l.value?.autoResize?.(),ye=()=>l.value?.resetTextareaSize?.(),Me=()=>{D();let _=o.value.trim();_.startsWith("/")&&!_.includes(" ")?(de.value=!0,we.value=0,P.value=!1):de.value=!1;let ee=o.value,Se=ee.lastIndexOf("@");if(Se!==-1&&!de.value){let _e=Se>0?ee[Se-1]:" ";_e===" "||_e===`
2003
- `||Se===0?R()?(I.value=!0,T.value=0,P.value=!1):(P.value=!0,x.value=0,I.value=!1):(P.value=!1,I.value=!1)}else Se===-1&&(P.value=!1,I.value=!1)},ze=_=>{o.value=_+" ",de.value=!1,Vue.nextTick(()=>{c.value?.focus()})},Ye=()=>{a.value=!1,setTimeout(()=>{de.value=!1,P.value=!1,I.value=!1},150)},rt=async _=>{let ee=Array.from(_.target.files||[]);ee.length>0&&await Ee(ee),_.target.value="",Vue.nextTick(()=>{c.value?.focus()})},ut=async _=>{let ee=_.clipboardData?.items;if(!ee)return;let Se=[];for(let _e of ee)if(_e.kind==="file"){let Fe=_e.getAsFile();Fe&&Se.push(Fe)}Se.length>0&&(_.preventDefault(),await Ee(Se))},at=_=>{let ee=String(_||"").toLowerCase();return ee==="image/png"?".png":ee==="image/jpeg"?".jpg":ee==="image/gif"?".gif":ee==="image/webp"?".webp":ee==="image/svg+xml"?".svg":ee==="text/plain"?".txt":ee==="application/json"?".json":""},W=(_,ee)=>{let Se=typeof _?.name=="string"?_.name.trim():"";return Se||`${String(_?.type||"").startsWith("image/")?"pasted-image":"pasted-file"}-${Date.now()}-${ee+1}${at(_?.type)}`},ie=1,me=_=>{let ee=Number(_);return!Number.isFinite(ee)||ee<=0?"":ee<1024?`${ee} B`:ee<1024*1024?`${Math.round(ee/1024)} KB`:`${(ee/(1024*1024)).toFixed(ee<10*1024*1024?1:0)} MB`},he=async _=>{for(let ee of _)ee.uploading=!0,ee.uploadError=!1;try{let ee=new FormData;for(let gt of _)ee.append("files",gt.file,gt.uploadName);let Se={},_e=n.getActiveToken?.()||n.token||null;_e&&(Se.Authorization=`Bearer ${_e}`);let Fe=await fetch("/api/upload",{method:"POST",headers:Se,body:ee});if(!Fe.ok)throw new Error("Upload failed");let Xe=await Fe.json(),pt=Array.isArray(Xe.files)?Xe.files:[];for(let[gt,Dt]of _.entries()){let $t=pt[gt],Lt=typeof $t?.fileId=="string"?$t.fileId.trim():"";if(!Lt)throw new Error("Upload response is incomplete");Dt.fileId=Lt,Dt.uploading=!1,delete Dt.uploadName}}catch{for(let Se of _)Se.fileId||(Se.uploading=!1,Se.uploadError=!0)}finally{Vue.nextTick(()=>c.value?.focus())}},Ee=async _=>{let ee=[];for(let[Se,_e]of _.entries()){let Fe=W(_e,Se),Xe=Vue.reactive({localId:`attachment-${ie++}`,file:_e,name:Fe,size:_e.size,uploadName:Fe,preview:null,uploading:!1,uploadError:!1,fileId:null});_e.type.startsWith("image/")&&(Xe.preview=URL.createObjectURL(_e)),p.value.push(Xe),ee.push(Xe)}await he(ee)},Ue=async _=>{!_||_.uploading||_.fileId||(_.uploadName=_.name,await he([_]))},Mt=_=>{let ee=p.value[_];ee.preview&&URL.revokeObjectURL(ee.preview),p.value.splice(_,1),Vue.nextTick(()=>{c.value?.focus()})},Qe=(_=null)=>{if(!ce.value)return;(!_||typeof _.model!="string")&&(_=null),de.value=!1,P.value=!1,I.value=!1;let ee=o.value.trim();if(e.sendFn){let Fe=p.value.filter(V).map(gt=>({fileId:gt.fileId,name:gt.name,preview:gt.preview,isImage:gt.file?.type?.startsWith("image/")||!1,mimeType:gt.file?.type||""})),Xe=Fe.length>0?Fe:void 0;if((_?e.sendFn(ee,Xe,e.quote,_):e.quote?e.sendFn(ee,Xe,e.quote):e.sendFn(ee,Xe))===!1)return;p.value=[],e.quote&&t("quote-consumed"),o.value="",N.value&&delete s.inputDrafts[N.value],ye(),J();return}if(ee==="/btw"||ee.startsWith("/btw ")){let Fe=ee.substring(4).trim();s.enterBtwMode(),Fe&&s.sendBtwQuestion(Fe),o.value="",N.value&&delete s.inputDrafts[N.value],ye(),J();return}if(s.btwMode){s.sendBtwQuestion(ee),o.value="",N.value&&delete s.inputDrafts[N.value],ye(),J();return}let Se=p.value.filter(V).map(Fe=>({fileId:Fe.fileId,name:Fe.name,preview:Fe.preview,isImage:Fe.file?.type?.startsWith("image/")||!1,mimeType:Fe.file?.type||""}));if(s.currentView==="yeaft"&&(ee||Se.length>0)){let Fe=Uo(ee).mentions,Xe=s.yeaftActiveSessionFilter||i?.activeSessionId||"grp_default";s.sendYeaftSessionMessage({groupId:Xe,text:ee,mentions:Fe,attachments:Se}),p.value=[],o.value="",N.value&&delete s.inputDrafts[N.value],ye(),J();return}let _e=[...w.value];s.sendMessage(o.value.trim(),Se,{expertSelections:_e}),p.value=[],o.value="",s.expertSelections=[],N.value&&delete s.inputDrafts[N.value],ye(),J()},mt=_=>{if(!(_.isComposing||_.keyCode===229)){if(!_.defaultPrevented&&e.quickSendEnabled){let ee=[1,2,3,4,5].find(_e=>Qo(_,X.value.bindings[`quickSend${_e}`])),Se=ee?F.value[ee-1]:null;if(!_.repeat&&Se&&Z.value){_.preventDefault(),_.stopPropagation(),fe(Se);return}}if(_.key==="Escape"&&s.btwMode){_.preventDefault(),s.closeBtw();return}if(I.value){let ee=j.value;if(ee.length>0){if(_.key==="ArrowDown"){_.preventDefault(),T.value=(T.value+1)%ee.length;return}if(_.key==="ArrowUp"){_.preventDefault(),T.value=(T.value-1+ee.length)%ee.length;return}if(_.key==="Tab"||_.key==="Enter"&&!_.shiftKey){_.preventDefault(),ke(ee[T.value]);return}}if(_.key==="Escape"){_.preventDefault(),I.value=!1;return}}if(P.value&&L.value.length>0){if(_.key==="ArrowDown"){_.preventDefault(),x.value=(x.value+1)%L.value.length;return}if(_.key==="ArrowUp"){_.preventDefault(),x.value=(x.value-1+L.value.length)%L.value.length;return}if(_.key==="Tab"||_.key==="Enter"&&!_.shiftKey){_.preventDefault(),U(L.value[x.value]);return}if(_.key==="Escape"){_.preventDefault(),P.value=!1;return}}if(de.value&&ue.value.length>0){if(_.key==="ArrowDown"){_.preventDefault(),we.value=(we.value+1)%ue.value.length;return}if(_.key==="ArrowUp"){_.preventDefault(),we.value=(we.value-1+ue.value.length)%ue.value.length;return}if(_.key==="Tab"||_.key==="Enter"&&!_.shiftKey){_.preventDefault(),ze(ue.value[we.value]);return}if(_.key==="Escape"){_.preventDefault(),de.value=!1;return}}_.key==="Enter"&&!_.shiftKey&&(_.preventDefault(),Qe())}},Et=()=>{e.cancelFn?e.cancelFn():s.cancelExecution()},et=_=>{o.value=typeof _=="string"?_:"",Vue.nextTick(()=>{D(),c.value?.focus();let ee=o.value.length;c.value?.setSelectionRange(ee,ee)})},lt=()=>Vue.nextTick(()=>c.value?.focus());return{store:s,inputText:o,inputFocused:a,inputRef:c,messageComposerRef:l,inputAreaRef:m,fileInput:g,attachments:p,uploading:f,canSend:ce,quickSends:F,canQuickSend:Z,shortcutPreferences:X,sendQuick:fe,isCompacting:te,isStopVisible:b,effectivePlaceholderKey:S,attachmentsAllowed:k,showAutocomplete:de,selectedIndex:we,filteredCommands:ue,flatItems:ve,groupedCommands:Ie,autocompleteRef:v,sendFn:Vue.toRef(e,"sendFn"),expertSelections:w,showExpertAutocomplete:P,expertSelectedIndex:x,expertAutocompleteFiltered:L,expertAutocompleteRef:y,selectExpertItem:U,removeExpertSelection:E,getExpertLabel:oe,todoStatusSymbol:q,autoResize:D,handleInput:Me,selectCommand:ze,onBlur:Ye,handleFileSelect:rt,handlePaste:ut,formatFileSize:me,retryAttachment:Ue,removeAttachment:Mt,send:Qe,handleKeydown:mt,cancelExecution:Et,vpStore:r,inputElementId:u,showVpAutocomplete:I,vpMentionPopupOpen:z,vpMentionPopupId:Q,vpMentionActiveOptionId:ae,vpSelectedIndex:T,vpMentionQuery:M,mentionVpCandidates:$,selectVpMention:ke,appendMention:G,replaceDraft:et,focusInput:lt}}}});function Bc(e){return new Promise((t,s)=>{if(document.querySelector(`script[src="${e}"]`))return t();let n=document.createElement("script");n.src=e,n.onload=t,n.onerror=s,document.head.appendChild(n)})}function wh(e){return e+":"+Math.random().toString(36).slice(2,8)}function ki(e){return e?e.type==="pane"?[e.terminalId]:[...ki(e.first),...ki(e.second)]:[]}function Jo(e){return e?e.type==="pane"?e.terminalId:Jo(e.first):null}function Zo(e,t,s){return e&&(e.type==="pane"?e.terminalId===t?s:e:{...e,first:Zo(e.first,t,s),second:Zo(e.second,t,s)})}function Qs(e,t){if(!e)return null;if(e.type==="pane")return e.terminalId===t?null:e;if(e.first?.type==="pane"&&e.first.terminalId===t)return e.second;if(e.second?.type==="pane"&&e.second.terminalId===t)return e.first;let s=Qs(e.first,t),n=Qs(e.second,t);return s?n?{...e,first:s,second:n}:s:n}var kh=B(()=>{});var Sh,Ih=B(()=>{Sh={name:"PaneTree",props:{node:Object,terminals:Object,activePane:String,onActivate:Function,onClosePane:Function,setMountRef:Function},template:`
2005
+ `,setup(e,{emit:t}){let s=Pinia.useChatStore(),n=Pinia.useAuthStore(),r=Pinia.useVpStore(),i=Pinia.useSessionsStore?Pinia.useSessionsStore():null,o=Vue.ref(""),a=Vue.ref(!1),l=Vue.ref(null),c=Vue.computed(()=>l.value?.getTextarea?.()||null),u=`chat-input-${Vue.getCurrentInstance()?.uid??0}`,g=Vue.ref(null),p=Vue.ref([]),f=Vue.computed(()=>p.value.some(_=>_.uploading)),m=Vue.ref(null),v=Vue.ref(null),b=Vue.ref(null),h=Vue.computed(()=>!!e.sendFn),k=Vue.computed(()=>!s.btwMode),S=Vue.computed(()=>e.placeholderKey||"chatInput.placeholder"),y=Vue.computed(()=>e.showStop||!h.value&&s.isProcessing),w=Vue.computed({get:()=>s.expertSelections||[],set:_=>{s.expertSelections=_}}),P=Vue.ref(!1),x=Vue.ref(0),Y=Vue.computed(()=>op(s.customExpertRoles)),L=Vue.computed(()=>{let _=o.value,ee=_.lastIndexOf("@");if(ee===-1||!P.value)return[];let Se=_.slice(ee+1).toLowerCase();return Y.value.filter(_e=>Se?_e.searchText.includes(Se):!0).filter(_e=>!w.value.some(Fe=>Fe.role===_e.roleId)).slice(0,12)}),U=_=>{if(w.value.length>=Cn)return;let ee={role:_.roleId,action:_.actionId};s.expertSelections=[...w.value,ee];let Se=o.value,_e=Se.lastIndexOf("@");_e!==-1&&(o.value=Se.slice(0,_e).trimEnd()),P.value=!1,Vue.nextTick(()=>c.value?.focus())},E=_=>{let ee=[...w.value];ee.splice(_,1),s.expertSelections=ee},oe=_=>In(_,s.customExpertRoles),q=_=>_==="completed"?"\u2713":_==="in_progress"?"\u2192":"\u25CB",I=Vue.ref(!1),T=Vue.ref(0),R=()=>s.currentView==="yeaft"&&!!s.currentAgent,M=Vue.computed(()=>{let _=o.value,ee=_.lastIndexOf("@");return ee<0||!I.value?"":_.slice(ee+1)}),$=Vue.computed(()=>{if(!i)return r.vpList||[];let _=s.yeaftActiveSessionFilter||i.activeSessionId||null,ee=typeof i.sessionById=="function"?i.sessionById(_,s.currentAgent||null):i.sessions?.[_];return fh(r.vpList,ee)}),j=Vue.computed(()=>Ec($.value,M.value)),z=Vue.computed(()=>!s.btwMode&&I.value&&!P.value&&j.value.length>0),Q=Dc(u),ae=Vue.computed(()=>{if(!z.value)return null;let _=j.value[T.value];return _?$c(u,_.vpId):null}),ke=_=>{!_||!_.vpId||(o.value=hh(o.value,_.vpId),I.value=!1,T.value=0,Vue.nextTick(()=>c.value?.focus()))},N=Vue.computed(()=>e.draftKey||e.conversationId||s.currentConversation||null);N.value&&s.inputDrafts[N.value]&&(o.value=s.inputDrafts[N.value]),Vue.watch(o,_=>{let ee=N.value;ee&&(_?s.inputDrafts[ee]=_:delete s.inputDrafts[ee])}),Vue.watch(j,_=>{if(_.length===0){T.value=0;return}T.value>=_.length&&(T.value=_.length-1)}),Vue.watch(N,(_,ee)=>{ee&&o.value&&(s.inputDrafts[ee]=o.value),o.value=_&&s.inputDrafts[_]||""});let G=_=>{if(!_||typeof _!="string")return;let ee=o.value||"",Se=ee.length>0&&!/\s$/.test(ee),_e=ee+(Se?" ":"")+"@"+_+" ";o.value=_e,Vue.nextTick(()=>{let Fe=c.value;Fe&&(Fe.focus(),Fe.setSelectionRange(_e.length,_e.length),D())})},de=Vue.ref(!1),we=Vue.ref(0),se=Vue.computed(()=>{let _=e.conversationId||s.activeConversationId||s.currentConversation,ee=s.currentAgent,Se=oh(s,_,ee),_e=s.currentView==="yeaft"?ih:rh;return jo(_e,Se).map(Xe=>Xe.startsWith("/")?Xe:"/"+Xe)}),ve=Vue.computed(()=>{let _=o.value.trim();if(!_.startsWith("/"))return[];let ee=_.toLowerCase();return se.value.filter(Se=>Se.toLowerCase().startsWith(ee)&&Se.toLowerCase()!==ee).map(Se=>({cmd:Se,desc:ah(Se,s.slashCommandDescriptions)}))}),Ie=Vue.computed(()=>lh(ve.value,s.slashCommandDescriptions,se.value)),ue=Vue.computed(()=>ve.value.map(_=>_.cmd)),re=Vue.computed(()=>e.conversationId||s.activeConversationId||s.currentConversation||null),te=Vue.computed(()=>s.compactStatus?.status==="compacting"&&s.compactStatus?.conversationId===re.value),V=_=>typeof _?.fileId=="string"&&_.fileId.trim().length>0,ce=Vue.computed(()=>{if(e.disabled||te.value)return!1;let _=!!o.value.trim(),ee=p.value.length>0;if(h.value){let pt=!f.value&&p.value.every(V);return(_||ee)&&pt}let Se=w.value.length>0,_e=w.value.some(pt=>pt.action),Fe=_||ee||Se&&(_||_e),Xe=!f.value&&p.value.every(V);return Fe&&s.currentAgent&&s.currentConversation&&Xe}),{preferences:X}=pr(),F=Vue.computed(()=>{if(!e.quickSendEnabled||s.btwMode)return[];let _=s.llmConfig?.[s.currentAgent];if(!_?.loaded||_.error)return[];let ee=_.agentConfig?.quickSends||_.effectiveConfig?.quickSends||[];return Array.isArray(ee)?ee.slice(0,5):[]}),Z=Vue.computed(()=>ce.value&&s.connectionState==="connected"&&s.agents?.some(_=>_.id===s.currentAgent&&_.online));Vue.watch(()=>[e.quickSendEnabled,s.currentAgent,s.connectionState,s.agents?.find(_=>_.id===s.currentAgent)?.online],([_,ee,Se,_e])=>{_&&ee&&Se==="connected"&&_e&&s.sendWsMessage({type:"get_llm_config",agentId:ee})},{immediate:!0});let fe=_=>{!Z.value||!F.value.includes(_)||Qe({model:_.model,effort:_.effort??null,maxOutputTokens:_.maxOutputTokens??null})},Re=()=>{if(typeof window>"u")return!1;try{return typeof window.matchMedia=="function"?window.matchMedia("(max-width: 768px)").matches:Number(window.innerWidth)<=768}catch{return!1}},J=()=>{if(!Re())return;c.value?.blur();let _=globalThis.document?.activeElement;_?.closest?.("[data-message-composer]")&&_.blur?.(),a.value=!1},D=()=>l.value?.autoResize?.(),ye=()=>l.value?.resetTextareaSize?.(),Me=()=>{D();let _=o.value.trim();_.startsWith("/")&&!_.includes(" ")?(de.value=!0,we.value=0,P.value=!1):de.value=!1;let ee=o.value,Se=ee.lastIndexOf("@");if(Se!==-1&&!de.value){let _e=Se>0?ee[Se-1]:" ";_e===" "||_e===`
2006
+ `||Se===0?R()?(I.value=!0,T.value=0,P.value=!1):(P.value=!0,x.value=0,I.value=!1):(P.value=!1,I.value=!1)}else Se===-1&&(P.value=!1,I.value=!1)},ze=_=>{o.value=_+" ",de.value=!1,Vue.nextTick(()=>{c.value?.focus()})},Ye=()=>{a.value=!1,setTimeout(()=>{de.value=!1,P.value=!1,I.value=!1},150)},rt=async _=>{let ee=Array.from(_.target.files||[]);ee.length>0&&await Ee(ee),_.target.value="",Vue.nextTick(()=>{c.value?.focus()})},ut=async _=>{let ee=_.clipboardData?.items;if(!ee)return;let Se=[];for(let _e of ee)if(_e.kind==="file"){let Fe=_e.getAsFile();Fe&&Se.push(Fe)}Se.length>0&&(_.preventDefault(),await Ee(Se))},at=_=>{let ee=String(_||"").toLowerCase();return ee==="image/png"?".png":ee==="image/jpeg"?".jpg":ee==="image/gif"?".gif":ee==="image/webp"?".webp":ee==="image/svg+xml"?".svg":ee==="text/plain"?".txt":ee==="application/json"?".json":""},W=(_,ee)=>{let Se=typeof _?.name=="string"?_.name.trim():"";return Se||`${String(_?.type||"").startsWith("image/")?"pasted-image":"pasted-file"}-${Date.now()}-${ee+1}${at(_?.type)}`},ie=1,me=_=>{let ee=Number(_);return!Number.isFinite(ee)||ee<=0?"":ee<1024?`${ee} B`:ee<1024*1024?`${Math.round(ee/1024)} KB`:`${(ee/(1024*1024)).toFixed(ee<10*1024*1024?1:0)} MB`},he=async _=>{for(let ee of _)ee.uploading=!0,ee.uploadError=!1;try{let ee=new FormData;for(let gt of _)ee.append("files",gt.file,gt.uploadName);let Se={},_e=n.getActiveToken?.()||n.token||null;_e&&(Se.Authorization=`Bearer ${_e}`);let Fe=await fetch("/api/upload",{method:"POST",headers:Se,body:ee});if(!Fe.ok)throw new Error("Upload failed");let Xe=await Fe.json(),pt=Array.isArray(Xe.files)?Xe.files:[];for(let[gt,Dt]of _.entries()){let $t=pt[gt],Lt=typeof $t?.fileId=="string"?$t.fileId.trim():"";if(!Lt)throw new Error("Upload response is incomplete");Dt.fileId=Lt,Dt.uploading=!1,delete Dt.uploadName}}catch{for(let Se of _)Se.fileId||(Se.uploading=!1,Se.uploadError=!0)}finally{Vue.nextTick(()=>c.value?.focus())}},Ee=async _=>{let ee=[];for(let[Se,_e]of _.entries()){let Fe=W(_e,Se),Xe=Vue.reactive({localId:`attachment-${ie++}`,file:_e,name:Fe,size:_e.size,uploadName:Fe,preview:null,uploading:!1,uploadError:!1,fileId:null});_e.type.startsWith("image/")&&(Xe.preview=URL.createObjectURL(_e)),p.value.push(Xe),ee.push(Xe)}await he(ee)},Ue=async _=>{!_||_.uploading||_.fileId||(_.uploadName=_.name,await he([_]))},Mt=_=>{let ee=p.value[_];ee.preview&&URL.revokeObjectURL(ee.preview),p.value.splice(_,1),Vue.nextTick(()=>{c.value?.focus()})},Qe=(_=null)=>{if(!ce.value)return;(!_||typeof _.model!="string")&&(_=null),de.value=!1,P.value=!1,I.value=!1;let ee=o.value.trim();if(e.sendFn){let Fe=p.value.filter(V).map(gt=>({fileId:gt.fileId,name:gt.name,preview:gt.preview,isImage:gt.file?.type?.startsWith("image/")||!1,mimeType:gt.file?.type||""})),Xe=Fe.length>0?Fe:void 0;if((_?e.sendFn(ee,Xe,e.quote,_):e.quote?e.sendFn(ee,Xe,e.quote):e.sendFn(ee,Xe))===!1)return;p.value=[],e.quote&&t("quote-consumed"),o.value="",N.value&&delete s.inputDrafts[N.value],ye(),J();return}if(ee==="/btw"||ee.startsWith("/btw ")){let Fe=ee.substring(4).trim();s.enterBtwMode(),Fe&&s.sendBtwQuestion(Fe),o.value="",N.value&&delete s.inputDrafts[N.value],ye(),J();return}if(s.btwMode){s.sendBtwQuestion(ee),o.value="",N.value&&delete s.inputDrafts[N.value],ye(),J();return}let Se=p.value.filter(V).map(Fe=>({fileId:Fe.fileId,name:Fe.name,preview:Fe.preview,isImage:Fe.file?.type?.startsWith("image/")||!1,mimeType:Fe.file?.type||""}));if(s.currentView==="yeaft"&&(ee||Se.length>0)){let Fe=Uo(ee).mentions,Xe=s.yeaftActiveSessionFilter||i?.activeSessionId||"grp_default";s.sendYeaftSessionMessage({groupId:Xe,text:ee,mentions:Fe,attachments:Se}),p.value=[],o.value="",N.value&&delete s.inputDrafts[N.value],ye(),J();return}let _e=[...w.value];s.sendMessage(o.value.trim(),Se,{expertSelections:_e}),p.value=[],o.value="",s.expertSelections=[],N.value&&delete s.inputDrafts[N.value],ye(),J()},mt=_=>{if(!(_.isComposing||_.keyCode===229)){if(!_.defaultPrevented&&e.quickSendEnabled){let ee=[1,2,3,4,5].find(_e=>Qo(_,X.value.bindings[`quickSend${_e}`])),Se=ee?F.value[ee-1]:null;if(!_.repeat&&Se&&Z.value){_.preventDefault(),_.stopPropagation(),fe(Se);return}}if(_.key==="Escape"&&s.btwMode){_.preventDefault(),s.closeBtw();return}if(I.value){let ee=j.value;if(ee.length>0){if(_.key==="ArrowDown"){_.preventDefault(),T.value=(T.value+1)%ee.length;return}if(_.key==="ArrowUp"){_.preventDefault(),T.value=(T.value-1+ee.length)%ee.length;return}if(_.key==="Tab"||_.key==="Enter"&&!_.shiftKey){_.preventDefault(),ke(ee[T.value]);return}}if(_.key==="Escape"){_.preventDefault(),I.value=!1;return}}if(P.value&&L.value.length>0){if(_.key==="ArrowDown"){_.preventDefault(),x.value=(x.value+1)%L.value.length;return}if(_.key==="ArrowUp"){_.preventDefault(),x.value=(x.value-1+L.value.length)%L.value.length;return}if(_.key==="Tab"||_.key==="Enter"&&!_.shiftKey){_.preventDefault(),U(L.value[x.value]);return}if(_.key==="Escape"){_.preventDefault(),P.value=!1;return}}if(de.value&&ue.value.length>0){if(_.key==="ArrowDown"){_.preventDefault(),we.value=(we.value+1)%ue.value.length;return}if(_.key==="ArrowUp"){_.preventDefault(),we.value=(we.value-1+ue.value.length)%ue.value.length;return}if(_.key==="Tab"||_.key==="Enter"&&!_.shiftKey){_.preventDefault(),ze(ue.value[we.value]);return}if(_.key==="Escape"){_.preventDefault(),de.value=!1;return}}_.key==="Enter"&&!_.shiftKey&&(_.preventDefault(),Qe())}},Et=()=>{e.cancelFn?e.cancelFn():s.cancelExecution()},et=_=>{o.value=typeof _=="string"?_:"",Vue.nextTick(()=>{D(),c.value?.focus();let ee=o.value.length;c.value?.setSelectionRange(ee,ee)})},lt=()=>Vue.nextTick(()=>c.value?.focus());return{store:s,inputText:o,inputFocused:a,inputRef:c,messageComposerRef:l,inputAreaRef:m,fileInput:g,attachments:p,uploading:f,canSend:ce,quickSends:F,canQuickSend:Z,shortcutPreferences:X,sendQuick:fe,isCompacting:te,isStopVisible:y,effectivePlaceholderKey:S,attachmentsAllowed:k,showAutocomplete:de,selectedIndex:we,filteredCommands:ue,flatItems:ve,groupedCommands:Ie,autocompleteRef:v,sendFn:Vue.toRef(e,"sendFn"),expertSelections:w,showExpertAutocomplete:P,expertSelectedIndex:x,expertAutocompleteFiltered:L,expertAutocompleteRef:b,selectExpertItem:U,removeExpertSelection:E,getExpertLabel:oe,todoStatusSymbol:q,autoResize:D,handleInput:Me,selectCommand:ze,onBlur:Ye,handleFileSelect:rt,handlePaste:ut,formatFileSize:me,retryAttachment:Ue,removeAttachment:Mt,send:Qe,handleKeydown:mt,cancelExecution:Et,vpStore:r,inputElementId:u,showVpAutocomplete:I,vpMentionPopupOpen:z,vpMentionPopupId:Q,vpMentionActiveOptionId:ae,vpSelectedIndex:T,vpMentionQuery:M,mentionVpCandidates:$,selectVpMention:ke,appendMention:G,replaceDraft:et,focusInput:lt}}}});function Bc(e){return new Promise((t,s)=>{if(document.querySelector(`script[src="${e}"]`))return t();let n=document.createElement("script");n.src=e,n.onload=t,n.onerror=s,document.head.appendChild(n)})}function wh(e){return e+":"+Math.random().toString(36).slice(2,8)}function ki(e){return e?e.type==="pane"?[e.terminalId]:[...ki(e.first),...ki(e.second)]:[]}function Jo(e){return e?e.type==="pane"?e.terminalId:Jo(e.first):null}function Zo(e,t,s){return e&&(e.type==="pane"?e.terminalId===t?s:e:{...e,first:Zo(e.first,t,s),second:Zo(e.second,t,s)})}function Qs(e,t){if(!e)return null;if(e.type==="pane")return e.terminalId===t?null:e;if(e.first?.type==="pane"&&e.first.terminalId===t)return e.second;if(e.second?.type==="pane"&&e.second.terminalId===t)return e.first;let s=Qs(e.first,t),n=Qs(e.second,t);return s?n?{...e,first:s,second:n}:s:n}var kh=B(()=>{});var Sh,Ih=B(()=>{Sh={name:"PaneTree",props:{node:Object,terminals:Object,activePane:String,onActivate:Function,onClosePane:Function,setMountRef:Function},template:`
2004
2007
  <div v-if="node.type === 'pane'"
2005
2008
  class="terminal-pane"
2006
2009
  :class="{ active: node.terminalId === activePane }"
@@ -2039,7 +2042,7 @@ ${String(e||"").trim()}
2039
2042
  />
2040
2043
  </div>
2041
2044
  </div>
2042
- `,setup(e){let t=Vue.computed(()=>e.node.type!=="split"?{}:{flexBasis:(e.node.ratio*100).toFixed(2)+"%",flexGrow:0,flexShrink:0}),s=Vue.computed(()=>e.node.type!=="split"?{}:{flexBasis:((1-e.node.ratio)*100).toFixed(2)+"%",flexGrow:0,flexShrink:0});return{firstStyle:t,secondStyle:s,startDrag:(r,i)=>{let o=r.target.closest(".terminal-split");if(!o)return;let a=r.type==="touchstart",l=i.direction==="horizontal",c=l?a?r.touches[0].clientX:r.clientX:a?r.touches[0].clientY:r.clientY,d=o.getBoundingClientRect(),u=l?d.width:d.height,g=i.ratio;document.body.style.cursor=l?"col-resize":"row-resize",document.body.style.userSelect="none";let p=m=>{let y=(l?a?m.touches[0].clientX:m.clientX:a?m.touches[0].clientY:m.clientY)-c,h=Math.max(.1,Math.min(.9,g+y/u));i.ratio=h},f=()=>{document.body.style.cursor="",document.body.style.userSelect="",document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",f),document.removeEventListener("touchmove",p),document.removeEventListener("touchend",f),window.dispatchEvent(new CustomEvent("terminal-fit-all"))};document.addEventListener(a?"touchmove":"mousemove",p),document.addEventListener(a?"touchend":"mouseup",f)}}}}});var Ch,Ah=B(()=>{kh();As();Ih();Ch={name:"TerminalTab",components:{PaneTree:Sh},props:{routeKey:{type:String,required:!0},runtimeProvider:{type:String,required:!0},agentId:{type:String,required:!0},sessionId:{type:String,required:!0},conversationId:{type:String,required:!0},workDir:{type:String,default:""},workspaceGeneration:{type:String,required:!0}},template:`
2045
+ `,setup(e){let t=Vue.computed(()=>e.node.type!=="split"?{}:{flexBasis:(e.node.ratio*100).toFixed(2)+"%",flexGrow:0,flexShrink:0}),s=Vue.computed(()=>e.node.type!=="split"?{}:{flexBasis:((1-e.node.ratio)*100).toFixed(2)+"%",flexGrow:0,flexShrink:0});return{firstStyle:t,secondStyle:s,startDrag:(r,i)=>{let o=r.target.closest(".terminal-split");if(!o)return;let a=r.type==="touchstart",l=i.direction==="horizontal",c=l?a?r.touches[0].clientX:r.clientX:a?r.touches[0].clientY:r.clientY,d=o.getBoundingClientRect(),u=l?d.width:d.height,g=i.ratio;document.body.style.cursor=l?"col-resize":"row-resize",document.body.style.userSelect="none";let p=m=>{let b=(l?a?m.touches[0].clientX:m.clientX:a?m.touches[0].clientY:m.clientY)-c,h=Math.max(.1,Math.min(.9,g+b/u));i.ratio=h},f=()=>{document.body.style.cursor="",document.body.style.userSelect="",document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",f),document.removeEventListener("touchmove",p),document.removeEventListener("touchend",f),window.dispatchEvent(new CustomEvent("terminal-fit-all"))};document.addEventListener(a?"touchmove":"mousemove",p),document.addEventListener(a?"touchend":"mouseup",f)}}}}});var Ch,Ah=B(()=>{kh();As();Ih();Ch={name:"TerminalTab",components:{PaneTree:Sh},props:{routeKey:{type:String,required:!0},runtimeProvider:{type:String,required:!0},agentId:{type:String,required:!0},sessionId:{type:String,required:!0},conversationId:{type:String,required:!0},workDir:{type:String,default:""},workspaceGeneration:{type:String,required:!0}},template:`
2043
2046
  <div ref="terminalRoot" class="terminal-tab">
2044
2047
  <div class="terminal-toolbar">
2045
2048
  <button class="wb-btn" @click="splitPane('horizontal')" :disabled="!hasActivePane" :title="$t('terminal.splitH')" :aria-label="$t('terminal.splitH')">
@@ -2070,9 +2073,9 @@ ${String(e||"").trim()}
2070
2073
  <div class="placeholder-text">{{ $t('terminal.autoCreate') }}</div>
2071
2074
  </div>
2072
2075
  </div>
2073
- `,setup(e){let t=er(Pinia.useChatStore(),e),s=Vue.inject("t"),n=Vue.reactive({}),r=Vue.reactive({}),i=Vue.reactive({}),o=Vue.ref(""),a=Vue.ref(null),l={},c=!1,d=null,u=Vue.computed(()=>{let R=t.currentConversation;return R&&r[R]||null}),g=Vue.computed(()=>{let R=t.currentConversation;return R&&i[R]||""}),p=Vue.computed(()=>!!g.value),f=(R,M)=>{if(M){let $=l[R];if(l[R]=M,$&&$!==M){let j=n[R];j?.terminal?.element&&(M.innerHTML="",M.appendChild(j.terminal.element),Vue.nextTick(()=>{try{j.fitAddon?.fit()}catch{}}))}}},m=R=>{let M=t.currentConversation;M&&(i[M]=R)};async function v(){if(c)return!0;let R=typeof Terminal<"u"?Terminal.Terminal||Terminal:null,M=typeof FitAddon<"u"?FitAddon.FitAddon||FitAddon:null;if(!R||!M)try{await Bc("vendor/xterm.min.js"),await Bc("vendor/xterm-addon-fit.min.js"),R=typeof Terminal<"u"?Terminal.Terminal||Terminal:null,M=typeof FitAddon<"u"?FitAddon.FitAddon||FitAddon:null}catch{}return!R||!M?(o.value=s("terminal.xtermNotLoaded"),!1):(c=!0,!0)}function y(){let R=document.documentElement.getAttribute("data-theme")==="dark",$=getComputedStyle(document.documentElement).getPropertyValue("--bg-main").trim()||(R?"#212121":"#ffffff");return R?{background:$,foreground:"#d4d4d4",cursor:"#a0a0a0",selectionBackground:"rgba(255,255,255,0.12)",black:"#3a3a3a",red:"#f48771",green:"#89d185",yellow:"#e5c07b",blue:"#6cb6ff",magenta:"#d670d6",cyan:"#56d4dd",white:"#cccccc",brightBlack:"#555555",brightRed:"#f48771",brightGreen:"#89d185",brightYellow:"#e5c07b",brightBlue:"#6cb6ff",brightMagenta:"#d670d6",brightCyan:"#56d4dd",brightWhite:"#e8e8e8"}:{background:$,foreground:"#383a42",cursor:"#526fff",selectionBackground:"rgba(0,0,0,0.07)",black:"#383a42",red:"#e45649",green:"#50a14f",yellow:"#c18401",blue:"#4078f2",magenta:"#a626a4",cyan:"#0184bc",white:"#a0a1a7",brightBlack:"#4f525e",brightRed:"#e45649",brightGreen:"#50a14f",brightYellow:"#c18401",brightBlue:"#4078f2",brightMagenta:"#a626a4",brightCyan:"#0184bc",brightWhite:"#fafafa"}}async function h(R){if(!R||!t.currentAgent||!await v())return null;let M=wh(R),$=Terminal.Terminal||Terminal,j=FitAddon.FitAddon||FitAddon,z=new $({cursorBlink:!0,fontSize:13,fontFamily:"'SF Mono', 'Fira Code', 'Consolas', monospace, 'Symbols Nerd Font Mono', 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji'",theme:y(),allowProposedApi:!0}),Q=new j;return z.loadAddon(Q),z.attachCustomKeyEventHandler(ae=>!((ae.ctrlKey||ae.metaKey)&&ae.key==="v"||(ae.ctrlKey||ae.metaKey)&&ae.key==="c"&&z.hasSelection())),n[M]={created:!0,connected:!1,terminal:z,fitAddon:Q},z.onData(ae=>{t.sendWsMessage({type:"terminal_input",agentId:t.currentAgent,conversationId:R,terminalId:M,data:ae,_clientId:t.clientId})}),M}async function k(R,M){let $=n[M];if(!$)return!1;let j=null;for(let z=0;z<10&&(await Vue.nextTick(),j=l[M],!(j||z>=2&&(await new Promise(Q=>setTimeout(Q,50)),j=l[M],j)));z++);return j?($.terminal.open(j),$.fitAddon.fit(),t.sendWsMessage({type:"terminal_create",agentId:t.currentAgent,conversationId:R,terminalId:M,workDir:e.workDir,cols:$.terminal.cols,rows:$.terminal.rows,_clientId:t.clientId}),!0):(o.value=s("terminal.mountFailed"),$.terminal.dispose(),delete n[M],!1)}let S=!1;async function b(){let R=t.currentConversation;if(!R||!t.currentAgent||r[R]||S)return;S=!0,o.value="";let M=await h(R);if(!M){S=!1;return}r[R]=Vue.reactive({type:"pane",terminalId:M}),i[R]=M,await k(R,M)||(delete r[R],delete i[R]),S=!1}async function w(R){let M=t.currentConversation;if(!M||!i[M])return;let $=i[M],j=await h(M);if(!j)return;let z=Vue.reactive({type:"split",direction:R,ratio:.5,first:{type:"pane",terminalId:$},second:{type:"pane",terminalId:j}}),Q=Zo(r[M],$,z);if(r[M]=Vue.reactive(Q),i[M]=j,!await k(M,j)){let ke=Qs(r[M],j);ke&&(r[M]=Vue.reactive(ke)),i[M]=$;return}await Vue.nextTick(),Y(M)}function P(R){let M=t.currentConversation;if(!M)return;let $=n[R];$&&(t.sendWsMessage({type:"terminal_close",agentId:t.currentAgent,conversationId:M,terminalId:R,_clientId:t.clientId}),$.terminal?.dispose(),delete n[R],delete l[R]);let j=Qs(r[M],R);j?(r[M]=Vue.reactive(j),i[M]===R&&(i[M]=Jo(r[M])||""),Vue.nextTick(()=>Y(M))):(delete r[M],delete i[M],Vue.nextTick(()=>b()))}function x(){let R=t.currentConversation;!R||!i[R]||P(i[R])}function Y(R){if(R||(R=t.currentConversation),!R||!r[R])return;let M=ki(r[R]);for(let $ of M){let j=n[$];if(j?.fitAddon&&j.connected)try{j.fitAddon.fit(),t.sendWsMessage({type:"terminal_resize",agentId:t.currentAgent,conversationId:R,terminalId:$,cols:j.terminal.cols,rows:j.terminal.rows,_clientId:t.clientId})}catch{}}}function L(R){let M=R.detail;if(!(!M||!tr(M,e.routeKey,e.workspaceGeneration))&&!(e.routeKey&&cs(M,e.routeKey)!=="main"))switch(M.type){case"terminal_created":{let $=M.terminalId||M.conversationId,j=n[$];if(j)if(M.success)j.connected=!0,o.value="";else{o.value=M.error||s("terminal.createFailed"),j.terminal?.dispose(),delete n[$];let z=M.conversationId;if(z&&r[z]){let Q=Qs(r[z],$);Q?r[z]=Vue.reactive(Q):(delete r[z],delete i[z])}}break}case"terminal_output":{let $=M.terminalId||M.conversationId,j=n[$];j?.terminal&&j.terminal.write(M.data);break}case"terminal_closed":{let $=M.terminalId||M.conversationId,j=n[$];if(j){j.terminal?.dispose(),delete n[$],delete l[$];let z=M.conversationId;if(z&&r[z]){let Q=Qs(r[z],$);Q?(r[z]=Vue.reactive(Q),i[z]===$&&(i[z]=Jo(r[z])||"")):(delete r[z],delete i[z])}}break}case"terminal_error":{o.value=M.message||s("terminal.error");let $=M.terminalId;if($&&n[$]&&!n[$].connected){n[$].terminal?.dispose(),delete n[$];let j=M.conversationId;if(j&&r[j]){let z=Qs(r[j],$);z?r[j]=Vue.reactive(z):(delete r[j],delete i[j])}}break}}}let U=null;function E(){clearTimeout(U),U=setTimeout(()=>Y(),100)}function oe(){Y()}function q(R){let{conversationId:M}=R.detail;if(M&&r[M]){let $=ki(r[M]);for(let j of $){let z=n[j];z&&(t.sendWsMessage({type:"terminal_close",terminalId:j,_clientId:t.clientId}),z.terminal?.dispose(),delete n[j],delete l[j])}delete r[M],delete i[M]}}let I=Vue.ref(!0);Vue.onMounted(()=>{window.addEventListener("workbench-message",L),window.addEventListener("resize",E),window.addEventListener("workbench-panel-resize",E),window.addEventListener("terminal-fit-all",oe),window.addEventListener("conversation-deleted",q),typeof ResizeObserver<"u"&&a.value&&(d=new ResizeObserver(E),d.observe(a.value))}),Vue.onActivated(()=>{I.value=!0,Vue.nextTick(()=>{b(),Y()})}),Vue.onDeactivated(()=>{I.value=!1}),Vue.onUnmounted(()=>{window.removeEventListener("workbench-message",L),window.removeEventListener("resize",E),window.removeEventListener("workbench-panel-resize",E),window.removeEventListener("terminal-fit-all",oe),window.removeEventListener("conversation-deleted",q),d?.disconnect(),d=null,clearTimeout(U);for(let R of Object.keys(n))t.sendWsMessage({type:"terminal_close",terminalId:R,_clientId:t.clientId}),n[R]?.terminal?.dispose()}),Vue.watch(()=>[t.currentConversation,t.workbenchExpanded],()=>{Vue.nextTick(()=>{if(!t.currentConversation||!t.workbenchExpanded||!I.value)return;let M=document.querySelector(".terminal-tab");M&&M.offsetParent!==null&&b()})},{immediate:!0}),Vue.watch(()=>t.connectionState,(R,M)=>{if(R==="connected"&&M&&M!=="connected"){for(let $ of Object.keys(n))n[$]?.terminal?.dispose(),delete n[$],delete l[$];for(let $ of Object.keys(r))delete r[$],delete i[$];Vue.nextTick(()=>b())}}),Vue.watch(()=>t.currentConversation,()=>{Vue.nextTick(()=>Y())});let T=null;return Vue.onMounted(()=>{let R=()=>{let $=document.querySelector(".terminal-tab");I.value&&$&&$.offsetParent!==null&&(b(),Y())};T=new MutationObserver(()=>{setTimeout(R,50)});let M=document.querySelector(".workbench-tab-content");M&&T.observe(M,{attributes:!0,subtree:!0,attributeFilter:["style"]})}),Vue.onUnmounted(()=>{T&&T.disconnect()}),{store:t,terminalRoot:a,terminals:n,currentTree:u,currentActivePane:g,hasActivePane:p,terminalError:o,setMountRef:f,activatePane:m,splitPane:w,closeActivePane:x,closePane:P}}}});function ea(e){if(!e)return Si(ge.default);let t=e.toLowerCase();if(Nc[t])return Nc[t]();let s=t.lastIndexOf(".");if(s>=0){let n=t.slice(s+1);if(xh[n])return xh[n]();let r=t;for(let[i,o]of Object.entries(Nc))if(r===i||r.endsWith("/"+i))return o()}return Si(ge.default)}function ta(e=!1){return Wk(ge.folder,e)}var ge,Si,Wk,le,xh,Nc,Wc=B(()=>{ge={js:"#F1C40F",ts:"#3178C6",jsx:"#61DAFB",tsx:"#3178C6",py:"#3776AB",rb:"#CC342D",go:"#00ADD8",rs:"#DEA584",java:"#E76F00",cs:"#68217A",cpp:"#00599C",c:"#A8B9CC",html:"#E44D26",css:"#1572B6",scss:"#CF649A",less:"#1D365D",json:"#F1C40F",yaml:"#CB171E",xml:"#E44D26",md:"#519ABA",txt:"#8E8E8E",log:"#8E8E8E",sh:"#4EAA25",ps1:"#012456",sql:"#E38C00",svg:"#FFB13B",img:"#26A69A",video:"#7E57C2",git:"#F05032",docker:"#2496ED",config:"#6D8086",lock:"#8E8E8E",env:"#ECD53F",vue:"#41B883",react:"#61DAFB",angular:"#DD0031",svelte:"#FF3E00",php:"#777BB4",swift:"#FA7343",kt:"#7F52FF",lua:"#000080",r:"#276DC3",dart:"#00B4AB",liquid:"#67B6E4",folder:"#90A4AE",folderOpen:"#90A4AE",default:"#8E8E8E"},Si=e=>`<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><path d="M14 2H6C4.9 2 4 2.9 4 4v16c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V8l-6-6z" fill="${e}" opacity="0.85"/><path d="M14 2v6h6" fill="${e}" opacity="0.5"/></svg>`,Wk=(e,t)=>t?`<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><path d="M20 6h-8l-2-2H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm0 12H4V8h16v10z" fill="${e}" opacity="0.9"/></svg>`:`<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><path d="M10 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z" fill="${e}" opacity="0.9"/></svg>`,le=(e,t)=>`<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><path d="M14 2H6C4.9 2 4 2.9 4 4v16c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V8l-6-6z" fill="${e}" opacity="0.2"/><path d="M14 2v6h6" fill="${e}" opacity="0.15"/><path d="M14 2H6C4.9 2 4 2.9 4 4v16c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V8l-6-6z" stroke="${e}" stroke-width="1.2" fill="none"/><text x="12" y="17" text-anchor="middle" font-size="7" font-weight="700" font-family="system-ui,sans-serif" fill="${e}">${t}</text></svg>`,xh={js:()=>le(ge.js,"JS"),mjs:()=>le(ge.js,"JS"),cjs:()=>le(ge.js,"JS"),ts:()=>le(ge.ts,"TS"),mts:()=>le(ge.ts,"TS"),jsx:()=>le(ge.jsx,"JSX"),tsx:()=>le(ge.tsx,"TSX"),html:()=>le(ge.html,"</>"),htm:()=>le(ge.html,"</>"),css:()=>le(ge.css,"CSS"),scss:()=>le(ge.scss,"SC"),sass:()=>le(ge.scss,"SA"),less:()=>le(ge.less,"LS"),vue:()=>le(ge.vue,"V"),svelte:()=>le(ge.svelte,"SV"),json:()=>le(ge.json,"{ }"),yaml:()=>le(ge.yaml,"YML"),yml:()=>le(ge.yaml,"YML"),toml:()=>le(ge.config,"TML"),xml:()=>le(ge.xml,"</>"),csv:()=>le(ge.config,"CSV"),md:()=>le(ge.md,"MD"),markdown:()=>le(ge.md,"MD"),txt:()=>Si(ge.txt),log:()=>Si(ge.log),pdf:()=>le("#E53935","PDF"),py:()=>le(ge.py,"PY"),rb:()=>le(ge.rb,"RB"),go:()=>le(ge.go,"GO"),rs:()=>le(ge.rs,"RS"),java:()=>le(ge.java,"JA"),cs:()=>le(ge.cs,"C#"),cpp:()=>le(ge.cpp,"C+"),cc:()=>le(ge.cpp,"C+"),c:()=>le(ge.c,"C"),h:()=>le(ge.c,"H"),hpp:()=>le(ge.cpp,"H+"),swift:()=>le(ge.swift,"SW"),kt:()=>le(ge.kt,"KT"),php:()=>le(ge.php,"PHP"),lua:()=>le(ge.lua,"LUA"),r:()=>le(ge.r,"R"),dart:()=>le(ge.dart,"DA"),sh:()=>le(ge.sh,">_"),bash:()=>le(ge.sh,">_"),zsh:()=>le(ge.sh,">_"),fish:()=>le(ge.sh,">_"),ps1:()=>le(ge.ps1,"PS"),bat:()=>le(ge.ps1,"BAT"),cmd:()=>le(ge.ps1,"CMD"),sql:()=>le(ge.sql,"SQL"),db:()=>le(ge.sql,"DB"),sqlite:()=>le(ge.sql,"DB"),svg:()=>le(ge.svg,"SVG"),png:()=>le(ge.img,"PNG"),jpg:()=>le(ge.img,"JPG"),jpeg:()=>le(ge.img,"JPG"),gif:()=>le(ge.img,"GIF"),ico:()=>le(ge.img,"ICO"),webp:()=>le(ge.img,"WP"),mp4:()=>le(ge.video,"MP4"),m4v:()=>le(ge.video,"M4V"),webm:()=>le(ge.video,"WEB"),ogv:()=>le(ge.video,"OGV"),ogg:()=>le(ge.video,"OGG"),mov:()=>le(ge.video,"MOV"),lock:()=>Si(ge.lock),env:()=>le(ge.env,"ENV"),ini:()=>le(ge.config,"INI"),cfg:()=>le(ge.config,"CFG"),conf:()=>le(ge.config,"CNF"),liquid:()=>le(ge.liquid,"LQ"),ejs:()=>le(ge.html,"EJS"),hbs:()=>le(ge.html,"HBS"),pug:()=>le(ge.html,"PUG"),wasm:()=>le("#654FF0","WA"),proto:()=>le(ge.config,"PB"),graphql:()=>le("#E535AB","GQL"),gql:()=>le("#E535AB","GQL")},Nc={dockerfile:()=>le(ge.docker,"DK"),"docker-compose.yml":()=>le(ge.docker,"DC"),"docker-compose.yaml":()=>le(ge.docker,"DC"),".gitignore":()=>le(ge.git,"GI"),".gitattributes":()=>le(ge.git,"GA"),".gitmodules":()=>le(ge.git,"GM"),".env":()=>le(ge.env,"ENV"),".env.local":()=>le(ge.env,"ENV"),".env.development":()=>le(ge.env,"ENV"),".env.production":()=>le(ge.env,"ENV"),"package.json":()=>le("#CB3837","NPM"),"package-lock.json":()=>le("#CB3837","NPM"),"tsconfig.json":()=>le(ge.ts,"TSC"),eslintrc:()=>le("#4B32C3","ESL"),".eslintrc.js":()=>le("#4B32C3","ESL"),".eslintrc.json":()=>le("#4B32C3","ESL"),".prettierrc":()=>le("#F7B93E","PR"),makefile:()=>le(ge.config,"MK"),"cmakelists.txt":()=>le("#064F8C","CM"),"readme.md":()=>le(ge.md,"RM"),license:()=>le("#F5C518","LIC"),"license.md":()=>le("#F5C518","LIC"),"cargo.toml":()=>le(ge.rs,"CG"),"go.mod":()=>le(ge.go,"MOD"),"go.sum":()=>le(ge.go,"SUM"),gemfile:()=>le(ge.rb,"GEM"),rakefile:()=>le(ge.rb,"RK"),"requirements.txt":()=>le(ge.py,"REQ"),pipfile:()=>le(ge.py,"PIP"),csproj:()=>le(ge.cs,"CSP"),".sln":()=>le(ge.cs,"SLN"),slnx:()=>le(ge.cs,"SLN")}});function _n(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function jk(e,t){if(!e||!t)return _n(e);let s=[],n=(a,l)=>{if(!a)return;let c=new RegExp(a.source,a.flags),d;for(;(d=c.exec(e))!==null;){let u=d[1]!==void 0?d[1]:d[0],g=d.index+(d[1]!==void 0?d[0].indexOf(d[1]):0);if(s.push({start:g,end:g+u.length,cls:l}),!c.global)break}},r=t.commentType||"slash";if((r==="slash"||r==="both")&&(n(fr.comment1,Ke.comment),n(fr.commentBlock,Ke.comment)),(r==="hash"||r==="both")&&n(fr.commentHash,Ke.comment),r==="html"&&n(t.commentHtml,Ke.comment),t.commentLine&&n(t.commentLine,Ke.comment),t.commentBlock&&n(t.commentBlock,Ke.comment),n(fr.string,Ke.string),n(fr.number,Ke.number),t.keywords&&n(t.keywords,Ke.keyword),t.builtins&&n(t.builtins,Ke.builtin),t.operators&&n(t.operators,Ke.operator),t.decorators&&n(t.decorators,Ke.decorator),t.macros&&n(t.macros,Ke.macro),t.preprocessor&&n(t.preprocessor,Ke.preprocessor),t.attributes&&n(t.attributes,Ke.attribute),t.tags&&n(t.tags,Ke.tag),t.properties&&n(t.properties,Ke.property),t.variables&&n(t.variables,Ke.variable),t.headings&&n(t.headings,Ke.heading),t.bold&&n(t.bold,Ke.bold),t.links&&n(t.links,Ke.link),t.keys&&n(t.keys,Ke.key),t.sections&&n(t.sections,Ke.section),t.selectors&&n(t.selectors,Ke.keyword),t.values&&n(t.values,Ke.number),t.code&&n(t.code,Ke.string),t.italic&&n(t.italic,Ke.builtin),t.attrs&&n(t.attrs,Ke.attribute),s.length===0)return _n(e);s.sort((a,l)=>a.start-l.start||l.end-l.start-(a.end-a.start));let i="",o=0;for(let a of s)a.start<o||(a.start>o&&(i+=_n(e.slice(o,a.start))),i+=`<span class="${a.cls}">${_n(e.slice(a.start,a.end))}</span>`,o=a.end);return o<e.length&&(i+=_n(e.slice(o))),i}function Uk(e){if(!e)return null;let t=e.split(".").pop()?.toLowerCase();if(!t)return null;let s=Th[t];return typeof s=="string"&&(s=Th[s]),s||null}function Mh(e,t){if(!e)return _n(e||"");let s=Uk(t);return s?jk(e,s):_n(e)}var fr,Th,Ke,Ph=B(()=>{fr={string:/("(?:[^"\\]|\\.)*")|('(?:[^'\\]|\\.)*')|(`(?:[^`\\]|\\.)*`)/g,number:/\b(\d+\.?\d*(?:[eE][+-]?\d+)?|0x[\da-fA-F]+|0b[01]+|0o[0-7]+)\b/g,comment1:/(\/\/.*$)/gm,commentHash:/(#.*$)/gm,commentBlock:/(\/\*.*?\*\/)/g},Th={js:{keywords:/\b(const|let|var|function|class|extends|return|if|else|for|while|do|switch|case|break|continue|new|this|super|import|export|from|default|async|await|yield|try|catch|finally|throw|typeof|instanceof|in|of|delete|void|null|undefined|true|false|NaN|Infinity)\b/g,builtins:/\b(console|window|document|Math|JSON|Array|Object|String|Number|Boolean|Promise|Map|Set|WeakMap|WeakSet|Symbol|Proxy|Reflect|RegExp|Error|Date|parseInt|parseFloat|setTimeout|setInterval|clearTimeout|clearInterval|fetch|require|module|exports|process)\b/g,operators:/(=>|\.\.\.|\?\.|&&|\|\||===|!==|==|!=|>=|<=|>>>=|>>>|>>=|<<=|\+\+|--|[+\-*/%&|^~!<>]=?|\?|:)/g},ts:"js",jsx:"js",tsx:"js",mjs:"js",cjs:"js",vue:"js",py:{keywords:/\b(def|class|return|if|elif|else|for|while|break|continue|pass|import|from|as|with|try|except|finally|raise|yield|lambda|and|or|not|is|in|True|False|None|global|nonlocal|del|assert|async|await)\b/g,builtins:/\b(print|len|range|int|float|str|bool|list|dict|set|tuple|type|isinstance|super|property|staticmethod|classmethod|enumerate|zip|map|filter|sorted|reversed|open|input|hasattr|getattr|setattr|id|hex|oct|bin|abs|max|min|sum|all|any|iter|next)\b/g,decorators:/(@\w+)/g,commentType:"hash"},rb:{keywords:/\b(def|class|module|end|return|if|elsif|else|unless|for|while|until|do|break|next|case|when|begin|rescue|ensure|raise|yield|require|include|extend|attr_accessor|attr_reader|attr_writer|self|super|nil|true|false|and|or|not|then|puts|print)\b/g,commentType:"hash"},go:{keywords:/\b(func|package|import|var|const|type|struct|interface|map|chan|go|select|switch|case|default|if|else|for|range|break|continue|return|defer|fallthrough|nil|true|false|iota)\b/g,builtins:/\b(fmt|make|len|cap|append|copy|delete|close|panic|recover|new|error|string|int|int8|int16|int32|int64|uint|uint8|uint16|uint32|uint64|float32|float64|bool|byte|rune|complex64|complex128)\b/g},rs:{keywords:/\b(fn|let|mut|const|pub|mod|use|struct|enum|impl|trait|where|for|loop|while|if|else|match|return|break|continue|move|ref|self|Self|super|crate|as|in|unsafe|async|await|dyn|true|false|Some|None|Ok|Err)\b/g,builtins:/\b(String|Vec|Box|Rc|Arc|Option|Result|HashMap|HashSet|println|eprintln|format|panic|todo|unimplemented|assert|assert_eq|assert_ne|dbg|cfg|derive|macro_rules)\b/g,macros:/(\w+!)/g},java:{keywords:/\b(class|interface|extends|implements|public|private|protected|static|final|abstract|synchronized|volatile|transient|native|new|return|if|else|for|while|do|switch|case|default|break|continue|try|catch|finally|throw|throws|import|package|this|super|void|null|true|false|instanceof)\b/g,builtins:/\b(System|String|Integer|Long|Double|Float|Boolean|List|ArrayList|Map|HashMap|Set|HashSet|Optional|Stream|Object|Exception|RuntimeException|Thread|Runnable|Override|Deprecated)\b/g},cs:{keywords:/\b(class|struct|interface|enum|record|delegate|event|namespace|using|public|private|protected|internal|static|readonly|const|sealed|abstract|virtual|override|new|return|if|else|for|foreach|while|do|switch|case|default|break|continue|try|catch|finally|throw|async|await|yield|var|dynamic|is|as|in|out|ref|params|this|base|null|true|false|void|get|set|init|required|partial|where|select|from|orderby|group|join|let|into)\b/g,builtins:/\b(Console|String|Int32|Int64|Double|Boolean|List|Dictionary|HashSet|Task|IEnumerable|ILogger|IOptions|IFeatures|Exception|Guid|DateTime|TimeSpan|CancellationToken|Action|Func|Span|Memory|ReadOnlySpan)\b/g,attributes:/(\[[\w]+(?:\(.*?\))?\])/g},cpp:{keywords:/\b(class|struct|enum|union|namespace|using|template|typename|public|private|protected|static|const|constexpr|volatile|virtual|override|final|explicit|inline|extern|auto|decltype|new|delete|return|if|else|for|while|do|switch|case|default|break|continue|try|catch|throw|sizeof|alignof|typeid|static_cast|dynamic_cast|reinterpret_cast|const_cast|nullptr|true|false|void|this|operator|friend|noexcept|co_await|co_yield|co_return|concept|requires)\b/g,builtins:/\b(std|string|vector|map|unordered_map|set|array|pair|tuple|shared_ptr|unique_ptr|weak_ptr|optional|variant|any|cout|cin|endl|printf|scanf|malloc|free|sizeof|size_t|int8_t|int16_t|int32_t|int64_t|uint8_t|uint16_t|uint32_t|uint64_t)\b/g,preprocessor:/(#\s*(?:include|define|undef|if|ifdef|ifndef|else|elif|endif|pragma|error|warning).*$)/gm},c:"cpp",h:"cpp",hpp:"cpp",html:{tags:/(<\/?[\w-]+|>|\/>)/g,attrs:/\b([\w-]+)(?==)/g,commentType:"html",commentHtml:/(<!--[\s\S]*?-->)/g},xml:"html",svg:"html",css:{selectors:/([\w.#\[\]:,>+~*-]+)\s*\{/g,properties:/\b([\w-]+)(?=\s*:)/g,values:/:\s*([^;{}]+)/g,commentType:"block"},scss:"css",less:"css",json:{keys:/("[\w.-]+")\s*:/g,commentType:"none"},yaml:{keys:/([\w.-]+)\s*:/g,commentType:"hash"},yml:"yaml",md:{headings:/^(#{1,6}\s.*)$/gm,bold:/(\*\*[^*]+\*\*|__[^_]+__)/g,italic:/(\*[^*]+\*|_[^_]+_)/g,code:/(`[^`]+`)/g,links:/(\[[^\]]+\]\([^)]+\))/g,commentType:"none"},sh:{keywords:/\b(if|then|else|elif|fi|for|while|do|done|case|esac|function|return|exit|echo|export|local|readonly|unset|set|shift|eval|exec|trap|source|alias|cd|pwd|ls|mkdir|rm|cp|mv|cat|grep|sed|awk|find|xargs|sort|uniq|wc|head|tail|tee|cut|tr|test)\b/g,variables:/(\$\{?\w+\}?|\$\(|\$\{)/g,commentType:"hash"},bash:"sh",zsh:"sh",sql:{keywords:/\b(SELECT|FROM|WHERE|AND|OR|NOT|IN|LIKE|BETWEEN|JOIN|LEFT|RIGHT|INNER|OUTER|FULL|ON|AS|GROUP|BY|ORDER|HAVING|LIMIT|OFFSET|INSERT|INTO|VALUES|UPDATE|SET|DELETE|CREATE|ALTER|DROP|TABLE|INDEX|VIEW|TRIGGER|FUNCTION|PROCEDURE|BEGIN|END|IF|ELSE|THEN|CASE|WHEN|DECLARE|EXEC|UNION|ALL|DISTINCT|TOP|EXISTS|NULL|IS|ASC|DESC|PRIMARY|KEY|FOREIGN|REFERENCES|CONSTRAINT|DEFAULT|CHECK|UNIQUE|CASCADE|TRUNCATE|COMMIT|ROLLBACK|GRANT|REVOKE)\b/gi,commentType:"both"},lua:{keywords:/\b(and|break|do|else|elseif|end|false|for|function|goto|if|in|local|nil|not|or|repeat|return|then|true|until|while)\b/g,builtins:/\b(print|type|tostring|tonumber|pairs|ipairs|next|select|unpack|error|pcall|xpcall|assert|require|table|string|math|io|os|coroutine|setmetatable|getmetatable|rawget|rawset)\b/g,commentLine:/(--(?!\[).*$)/gm,commentBlock:/(--\[\[[\s\S]*?\]\])/g},php:{keywords:/\b(function|class|interface|trait|extends|implements|public|private|protected|static|final|abstract|const|var|new|return|if|else|elseif|for|foreach|while|do|switch|case|default|break|continue|try|catch|finally|throw|use|namespace|require|include|require_once|include_once|echo|print|die|exit|null|true|false|array|list|match|fn|yield|from)\b/g,variables:/(\$\w+)/g},swift:{keywords:/\b(func|class|struct|enum|protocol|extension|let|var|guard|if|else|for|while|repeat|switch|case|default|break|continue|return|throw|try|catch|defer|import|typealias|associatedtype|init|deinit|subscript|operator|precedencegroup|self|Self|super|nil|true|false|is|as|in|inout|throws|rethrows|where|some|any|weak|unowned|lazy|mutating|nonmutating|override|final|required|convenience|optional|dynamic|async|await|actor|nonisolated|isolated|sending|consuming|borrowing)\b/g},kt:{keywords:/\b(fun|class|object|interface|val|var|if|else|when|for|while|do|return|break|continue|throw|try|catch|finally|import|package|as|is|in|out|by|init|constructor|companion|data|sealed|enum|abstract|open|override|private|protected|internal|public|inline|reified|suspend|coroutine|null|true|false|this|super|it|typealias|annotation|lateinit|lazy|get|set)\b/g},dart:{keywords:/\b(class|extends|implements|with|mixin|abstract|sealed|base|interface|final|const|var|late|required|dynamic|void|static|return|if|else|for|while|do|switch|case|default|break|continue|try|catch|finally|throw|rethrow|assert|new|this|super|null|true|false|is|as|in|async|await|yield|import|export|library|part|show|hide|deferred|typedef|enum|extension|on)\b/g},r:{keywords:/\b(if|else|for|while|repeat|function|return|break|next|in|TRUE|FALSE|NULL|NA|Inf|NaN|library|require|source|print|cat|paste|paste0|sprintf|stop|warning|message)\b/g,commentType:"hash"},toml:{keys:/([\w.-]+)\s*=/g,sections:/(\[[\w.]+\])/g,commentType:"hash"},proto:{keywords:/\b(syntax|package|import|option|message|enum|service|rpc|returns|repeated|optional|required|map|oneof|reserved|extensions|extend|group|default|packed|deprecated|java_package|java_outer_classname|optimize_for|cc_enable_arenas|objc_class_prefix|csharp_namespace|swift_prefix|php_class_prefix|php_namespace|ruby_package|string|int32|int64|uint32|uint64|sint32|sint64|fixed32|fixed64|sfixed32|sfixed64|float|double|bool|bytes)\b/g}},Ke={keyword:"hl-kw",builtin:"hl-bi",string:"hl-st",number:"hl-nm",comment:"hl-cm",operator:"hl-op",decorator:"hl-dc",macro:"hl-mc",preprocessor:"hl-pp",attribute:"hl-at",tag:"hl-tg",property:"hl-pr",variable:"hl-vr",heading:"hl-hd",bold:"hl-bd",link:"hl-lk",key:"hl-ky",section:"hl-sc"}});function Rh(e,t,s){let n=[],r=0,i=0;if(t!=null){let p=t.split(`
2076
+ `,setup(e){let t=er(Pinia.useChatStore(),e),s=Vue.inject("t"),n=Vue.reactive({}),r=Vue.reactive({}),i=Vue.reactive({}),o=Vue.ref(""),a=Vue.ref(null),l={},c=!1,d=null,u=Vue.computed(()=>{let R=t.currentConversation;return R&&r[R]||null}),g=Vue.computed(()=>{let R=t.currentConversation;return R&&i[R]||""}),p=Vue.computed(()=>!!g.value),f=(R,M)=>{if(M){let $=l[R];if(l[R]=M,$&&$!==M){let j=n[R];j?.terminal?.element&&(M.innerHTML="",M.appendChild(j.terminal.element),Vue.nextTick(()=>{try{j.fitAddon?.fit()}catch{}}))}}},m=R=>{let M=t.currentConversation;M&&(i[M]=R)};async function v(){if(c)return!0;let R=typeof Terminal<"u"?Terminal.Terminal||Terminal:null,M=typeof FitAddon<"u"?FitAddon.FitAddon||FitAddon:null;if(!R||!M)try{await Bc("vendor/xterm.min.js"),await Bc("vendor/xterm-addon-fit.min.js"),R=typeof Terminal<"u"?Terminal.Terminal||Terminal:null,M=typeof FitAddon<"u"?FitAddon.FitAddon||FitAddon:null}catch{}return!R||!M?(o.value=s("terminal.xtermNotLoaded"),!1):(c=!0,!0)}function b(){let R=document.documentElement.getAttribute("data-theme")==="dark",$=getComputedStyle(document.documentElement).getPropertyValue("--bg-main").trim()||(R?"#212121":"#ffffff");return R?{background:$,foreground:"#d4d4d4",cursor:"#a0a0a0",selectionBackground:"rgba(255,255,255,0.12)",black:"#3a3a3a",red:"#f48771",green:"#89d185",yellow:"#e5c07b",blue:"#6cb6ff",magenta:"#d670d6",cyan:"#56d4dd",white:"#cccccc",brightBlack:"#555555",brightRed:"#f48771",brightGreen:"#89d185",brightYellow:"#e5c07b",brightBlue:"#6cb6ff",brightMagenta:"#d670d6",brightCyan:"#56d4dd",brightWhite:"#e8e8e8"}:{background:$,foreground:"#383a42",cursor:"#526fff",selectionBackground:"rgba(0,0,0,0.07)",black:"#383a42",red:"#e45649",green:"#50a14f",yellow:"#c18401",blue:"#4078f2",magenta:"#a626a4",cyan:"#0184bc",white:"#a0a1a7",brightBlack:"#4f525e",brightRed:"#e45649",brightGreen:"#50a14f",brightYellow:"#c18401",brightBlue:"#4078f2",brightMagenta:"#a626a4",brightCyan:"#0184bc",brightWhite:"#fafafa"}}async function h(R){if(!R||!t.currentAgent||!await v())return null;let M=wh(R),$=Terminal.Terminal||Terminal,j=FitAddon.FitAddon||FitAddon,z=new $({cursorBlink:!0,fontSize:13,fontFamily:"'SF Mono', 'Fira Code', 'Consolas', monospace, 'Symbols Nerd Font Mono', 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji'",theme:b(),allowProposedApi:!0}),Q=new j;return z.loadAddon(Q),z.attachCustomKeyEventHandler(ae=>!((ae.ctrlKey||ae.metaKey)&&ae.key==="v"||(ae.ctrlKey||ae.metaKey)&&ae.key==="c"&&z.hasSelection())),n[M]={created:!0,connected:!1,terminal:z,fitAddon:Q},z.onData(ae=>{t.sendWsMessage({type:"terminal_input",agentId:t.currentAgent,conversationId:R,terminalId:M,data:ae,_clientId:t.clientId})}),M}async function k(R,M){let $=n[M];if(!$)return!1;let j=null;for(let z=0;z<10&&(await Vue.nextTick(),j=l[M],!(j||z>=2&&(await new Promise(Q=>setTimeout(Q,50)),j=l[M],j)));z++);return j?($.terminal.open(j),$.fitAddon.fit(),t.sendWsMessage({type:"terminal_create",agentId:t.currentAgent,conversationId:R,terminalId:M,workDir:e.workDir,cols:$.terminal.cols,rows:$.terminal.rows,_clientId:t.clientId}),!0):(o.value=s("terminal.mountFailed"),$.terminal.dispose(),delete n[M],!1)}let S=!1;async function y(){let R=t.currentConversation;if(!R||!t.currentAgent||r[R]||S)return;S=!0,o.value="";let M=await h(R);if(!M){S=!1;return}r[R]=Vue.reactive({type:"pane",terminalId:M}),i[R]=M,await k(R,M)||(delete r[R],delete i[R]),S=!1}async function w(R){let M=t.currentConversation;if(!M||!i[M])return;let $=i[M],j=await h(M);if(!j)return;let z=Vue.reactive({type:"split",direction:R,ratio:.5,first:{type:"pane",terminalId:$},second:{type:"pane",terminalId:j}}),Q=Zo(r[M],$,z);if(r[M]=Vue.reactive(Q),i[M]=j,!await k(M,j)){let ke=Qs(r[M],j);ke&&(r[M]=Vue.reactive(ke)),i[M]=$;return}await Vue.nextTick(),Y(M)}function P(R){let M=t.currentConversation;if(!M)return;let $=n[R];$&&(t.sendWsMessage({type:"terminal_close",agentId:t.currentAgent,conversationId:M,terminalId:R,_clientId:t.clientId}),$.terminal?.dispose(),delete n[R],delete l[R]);let j=Qs(r[M],R);j?(r[M]=Vue.reactive(j),i[M]===R&&(i[M]=Jo(r[M])||""),Vue.nextTick(()=>Y(M))):(delete r[M],delete i[M],Vue.nextTick(()=>y()))}function x(){let R=t.currentConversation;!R||!i[R]||P(i[R])}function Y(R){if(R||(R=t.currentConversation),!R||!r[R])return;let M=ki(r[R]);for(let $ of M){let j=n[$];if(j?.fitAddon&&j.connected)try{j.fitAddon.fit(),t.sendWsMessage({type:"terminal_resize",agentId:t.currentAgent,conversationId:R,terminalId:$,cols:j.terminal.cols,rows:j.terminal.rows,_clientId:t.clientId})}catch{}}}function L(R){let M=R.detail;if(!(!M||!tr(M,e.routeKey,e.workspaceGeneration))&&!(e.routeKey&&cs(M,e.routeKey)!=="main"))switch(M.type){case"terminal_created":{let $=M.terminalId||M.conversationId,j=n[$];if(j)if(M.success)j.connected=!0,o.value="";else{o.value=M.error||s("terminal.createFailed"),j.terminal?.dispose(),delete n[$];let z=M.conversationId;if(z&&r[z]){let Q=Qs(r[z],$);Q?r[z]=Vue.reactive(Q):(delete r[z],delete i[z])}}break}case"terminal_output":{let $=M.terminalId||M.conversationId,j=n[$];j?.terminal&&j.terminal.write(M.data);break}case"terminal_closed":{let $=M.terminalId||M.conversationId,j=n[$];if(j){j.terminal?.dispose(),delete n[$],delete l[$];let z=M.conversationId;if(z&&r[z]){let Q=Qs(r[z],$);Q?(r[z]=Vue.reactive(Q),i[z]===$&&(i[z]=Jo(r[z])||"")):(delete r[z],delete i[z])}}break}case"terminal_error":{o.value=M.message||s("terminal.error");let $=M.terminalId;if($&&n[$]&&!n[$].connected){n[$].terminal?.dispose(),delete n[$];let j=M.conversationId;if(j&&r[j]){let z=Qs(r[j],$);z?r[j]=Vue.reactive(z):(delete r[j],delete i[j])}}break}}}let U=null;function E(){clearTimeout(U),U=setTimeout(()=>Y(),100)}function oe(){Y()}function q(R){let{conversationId:M}=R.detail;if(M&&r[M]){let $=ki(r[M]);for(let j of $){let z=n[j];z&&(t.sendWsMessage({type:"terminal_close",terminalId:j,_clientId:t.clientId}),z.terminal?.dispose(),delete n[j],delete l[j])}delete r[M],delete i[M]}}let I=Vue.ref(!0);Vue.onMounted(()=>{window.addEventListener("workbench-message",L),window.addEventListener("resize",E),window.addEventListener("workbench-panel-resize",E),window.addEventListener("terminal-fit-all",oe),window.addEventListener("conversation-deleted",q),typeof ResizeObserver<"u"&&a.value&&(d=new ResizeObserver(E),d.observe(a.value))}),Vue.onActivated(()=>{I.value=!0,Vue.nextTick(()=>{y(),Y()})}),Vue.onDeactivated(()=>{I.value=!1}),Vue.onUnmounted(()=>{window.removeEventListener("workbench-message",L),window.removeEventListener("resize",E),window.removeEventListener("workbench-panel-resize",E),window.removeEventListener("terminal-fit-all",oe),window.removeEventListener("conversation-deleted",q),d?.disconnect(),d=null,clearTimeout(U);for(let R of Object.keys(n))t.sendWsMessage({type:"terminal_close",terminalId:R,_clientId:t.clientId}),n[R]?.terminal?.dispose()}),Vue.watch(()=>[t.currentConversation,t.workbenchExpanded],()=>{Vue.nextTick(()=>{if(!t.currentConversation||!t.workbenchExpanded||!I.value)return;let M=document.querySelector(".terminal-tab");M&&M.offsetParent!==null&&y()})},{immediate:!0}),Vue.watch(()=>t.connectionState,(R,M)=>{if(R==="connected"&&M&&M!=="connected"){for(let $ of Object.keys(n))n[$]?.terminal?.dispose(),delete n[$],delete l[$];for(let $ of Object.keys(r))delete r[$],delete i[$];Vue.nextTick(()=>y())}}),Vue.watch(()=>t.currentConversation,()=>{Vue.nextTick(()=>Y())});let T=null;return Vue.onMounted(()=>{let R=()=>{let $=document.querySelector(".terminal-tab");I.value&&$&&$.offsetParent!==null&&(y(),Y())};T=new MutationObserver(()=>{setTimeout(R,50)});let M=document.querySelector(".workbench-tab-content");M&&T.observe(M,{attributes:!0,subtree:!0,attributeFilter:["style"]})}),Vue.onUnmounted(()=>{T&&T.disconnect()}),{store:t,terminalRoot:a,terminals:n,currentTree:u,currentActivePane:g,hasActivePane:p,terminalError:o,setMountRef:f,activatePane:m,splitPane:w,closeActivePane:x,closePane:P}}}});function ea(e){if(!e)return Si(ge.default);let t=e.toLowerCase();if(Nc[t])return Nc[t]();let s=t.lastIndexOf(".");if(s>=0){let n=t.slice(s+1);if(xh[n])return xh[n]();let r=t;for(let[i,o]of Object.entries(Nc))if(r===i||r.endsWith("/"+i))return o()}return Si(ge.default)}function ta(e=!1){return Wk(ge.folder,e)}var ge,Si,Wk,le,xh,Nc,Wc=B(()=>{ge={js:"#F1C40F",ts:"#3178C6",jsx:"#61DAFB",tsx:"#3178C6",py:"#3776AB",rb:"#CC342D",go:"#00ADD8",rs:"#DEA584",java:"#E76F00",cs:"#68217A",cpp:"#00599C",c:"#A8B9CC",html:"#E44D26",css:"#1572B6",scss:"#CF649A",less:"#1D365D",json:"#F1C40F",yaml:"#CB171E",xml:"#E44D26",md:"#519ABA",txt:"#8E8E8E",log:"#8E8E8E",sh:"#4EAA25",ps1:"#012456",sql:"#E38C00",svg:"#FFB13B",img:"#26A69A",video:"#7E57C2",git:"#F05032",docker:"#2496ED",config:"#6D8086",lock:"#8E8E8E",env:"#ECD53F",vue:"#41B883",react:"#61DAFB",angular:"#DD0031",svelte:"#FF3E00",php:"#777BB4",swift:"#FA7343",kt:"#7F52FF",lua:"#000080",r:"#276DC3",dart:"#00B4AB",liquid:"#67B6E4",folder:"#90A4AE",folderOpen:"#90A4AE",default:"#8E8E8E"},Si=e=>`<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><path d="M14 2H6C4.9 2 4 2.9 4 4v16c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V8l-6-6z" fill="${e}" opacity="0.85"/><path d="M14 2v6h6" fill="${e}" opacity="0.5"/></svg>`,Wk=(e,t)=>t?`<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><path d="M20 6h-8l-2-2H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm0 12H4V8h16v10z" fill="${e}" opacity="0.9"/></svg>`:`<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><path d="M10 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z" fill="${e}" opacity="0.9"/></svg>`,le=(e,t)=>`<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><path d="M14 2H6C4.9 2 4 2.9 4 4v16c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V8l-6-6z" fill="${e}" opacity="0.2"/><path d="M14 2v6h6" fill="${e}" opacity="0.15"/><path d="M14 2H6C4.9 2 4 2.9 4 4v16c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V8l-6-6z" stroke="${e}" stroke-width="1.2" fill="none"/><text x="12" y="17" text-anchor="middle" font-size="7" font-weight="700" font-family="system-ui,sans-serif" fill="${e}">${t}</text></svg>`,xh={js:()=>le(ge.js,"JS"),mjs:()=>le(ge.js,"JS"),cjs:()=>le(ge.js,"JS"),ts:()=>le(ge.ts,"TS"),mts:()=>le(ge.ts,"TS"),jsx:()=>le(ge.jsx,"JSX"),tsx:()=>le(ge.tsx,"TSX"),html:()=>le(ge.html,"</>"),htm:()=>le(ge.html,"</>"),css:()=>le(ge.css,"CSS"),scss:()=>le(ge.scss,"SC"),sass:()=>le(ge.scss,"SA"),less:()=>le(ge.less,"LS"),vue:()=>le(ge.vue,"V"),svelte:()=>le(ge.svelte,"SV"),json:()=>le(ge.json,"{ }"),yaml:()=>le(ge.yaml,"YML"),yml:()=>le(ge.yaml,"YML"),toml:()=>le(ge.config,"TML"),xml:()=>le(ge.xml,"</>"),csv:()=>le(ge.config,"CSV"),md:()=>le(ge.md,"MD"),markdown:()=>le(ge.md,"MD"),txt:()=>Si(ge.txt),log:()=>Si(ge.log),pdf:()=>le("#E53935","PDF"),py:()=>le(ge.py,"PY"),rb:()=>le(ge.rb,"RB"),go:()=>le(ge.go,"GO"),rs:()=>le(ge.rs,"RS"),java:()=>le(ge.java,"JA"),cs:()=>le(ge.cs,"C#"),cpp:()=>le(ge.cpp,"C+"),cc:()=>le(ge.cpp,"C+"),c:()=>le(ge.c,"C"),h:()=>le(ge.c,"H"),hpp:()=>le(ge.cpp,"H+"),swift:()=>le(ge.swift,"SW"),kt:()=>le(ge.kt,"KT"),php:()=>le(ge.php,"PHP"),lua:()=>le(ge.lua,"LUA"),r:()=>le(ge.r,"R"),dart:()=>le(ge.dart,"DA"),sh:()=>le(ge.sh,">_"),bash:()=>le(ge.sh,">_"),zsh:()=>le(ge.sh,">_"),fish:()=>le(ge.sh,">_"),ps1:()=>le(ge.ps1,"PS"),bat:()=>le(ge.ps1,"BAT"),cmd:()=>le(ge.ps1,"CMD"),sql:()=>le(ge.sql,"SQL"),db:()=>le(ge.sql,"DB"),sqlite:()=>le(ge.sql,"DB"),svg:()=>le(ge.svg,"SVG"),png:()=>le(ge.img,"PNG"),jpg:()=>le(ge.img,"JPG"),jpeg:()=>le(ge.img,"JPG"),gif:()=>le(ge.img,"GIF"),ico:()=>le(ge.img,"ICO"),webp:()=>le(ge.img,"WP"),mp4:()=>le(ge.video,"MP4"),m4v:()=>le(ge.video,"M4V"),webm:()=>le(ge.video,"WEB"),ogv:()=>le(ge.video,"OGV"),ogg:()=>le(ge.video,"OGG"),mov:()=>le(ge.video,"MOV"),lock:()=>Si(ge.lock),env:()=>le(ge.env,"ENV"),ini:()=>le(ge.config,"INI"),cfg:()=>le(ge.config,"CFG"),conf:()=>le(ge.config,"CNF"),liquid:()=>le(ge.liquid,"LQ"),ejs:()=>le(ge.html,"EJS"),hbs:()=>le(ge.html,"HBS"),pug:()=>le(ge.html,"PUG"),wasm:()=>le("#654FF0","WA"),proto:()=>le(ge.config,"PB"),graphql:()=>le("#E535AB","GQL"),gql:()=>le("#E535AB","GQL")},Nc={dockerfile:()=>le(ge.docker,"DK"),"docker-compose.yml":()=>le(ge.docker,"DC"),"docker-compose.yaml":()=>le(ge.docker,"DC"),".gitignore":()=>le(ge.git,"GI"),".gitattributes":()=>le(ge.git,"GA"),".gitmodules":()=>le(ge.git,"GM"),".env":()=>le(ge.env,"ENV"),".env.local":()=>le(ge.env,"ENV"),".env.development":()=>le(ge.env,"ENV"),".env.production":()=>le(ge.env,"ENV"),"package.json":()=>le("#CB3837","NPM"),"package-lock.json":()=>le("#CB3837","NPM"),"tsconfig.json":()=>le(ge.ts,"TSC"),eslintrc:()=>le("#4B32C3","ESL"),".eslintrc.js":()=>le("#4B32C3","ESL"),".eslintrc.json":()=>le("#4B32C3","ESL"),".prettierrc":()=>le("#F7B93E","PR"),makefile:()=>le(ge.config,"MK"),"cmakelists.txt":()=>le("#064F8C","CM"),"readme.md":()=>le(ge.md,"RM"),license:()=>le("#F5C518","LIC"),"license.md":()=>le("#F5C518","LIC"),"cargo.toml":()=>le(ge.rs,"CG"),"go.mod":()=>le(ge.go,"MOD"),"go.sum":()=>le(ge.go,"SUM"),gemfile:()=>le(ge.rb,"GEM"),rakefile:()=>le(ge.rb,"RK"),"requirements.txt":()=>le(ge.py,"REQ"),pipfile:()=>le(ge.py,"PIP"),csproj:()=>le(ge.cs,"CSP"),".sln":()=>le(ge.cs,"SLN"),slnx:()=>le(ge.cs,"SLN")}});function _n(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function jk(e,t){if(!e||!t)return _n(e);let s=[],n=(a,l)=>{if(!a)return;let c=new RegExp(a.source,a.flags),d;for(;(d=c.exec(e))!==null;){let u=d[1]!==void 0?d[1]:d[0],g=d.index+(d[1]!==void 0?d[0].indexOf(d[1]):0);if(s.push({start:g,end:g+u.length,cls:l}),!c.global)break}},r=t.commentType||"slash";if((r==="slash"||r==="both")&&(n(fr.comment1,Ke.comment),n(fr.commentBlock,Ke.comment)),(r==="hash"||r==="both")&&n(fr.commentHash,Ke.comment),r==="html"&&n(t.commentHtml,Ke.comment),t.commentLine&&n(t.commentLine,Ke.comment),t.commentBlock&&n(t.commentBlock,Ke.comment),n(fr.string,Ke.string),n(fr.number,Ke.number),t.keywords&&n(t.keywords,Ke.keyword),t.builtins&&n(t.builtins,Ke.builtin),t.operators&&n(t.operators,Ke.operator),t.decorators&&n(t.decorators,Ke.decorator),t.macros&&n(t.macros,Ke.macro),t.preprocessor&&n(t.preprocessor,Ke.preprocessor),t.attributes&&n(t.attributes,Ke.attribute),t.tags&&n(t.tags,Ke.tag),t.properties&&n(t.properties,Ke.property),t.variables&&n(t.variables,Ke.variable),t.headings&&n(t.headings,Ke.heading),t.bold&&n(t.bold,Ke.bold),t.links&&n(t.links,Ke.link),t.keys&&n(t.keys,Ke.key),t.sections&&n(t.sections,Ke.section),t.selectors&&n(t.selectors,Ke.keyword),t.values&&n(t.values,Ke.number),t.code&&n(t.code,Ke.string),t.italic&&n(t.italic,Ke.builtin),t.attrs&&n(t.attrs,Ke.attribute),s.length===0)return _n(e);s.sort((a,l)=>a.start-l.start||l.end-l.start-(a.end-a.start));let i="",o=0;for(let a of s)a.start<o||(a.start>o&&(i+=_n(e.slice(o,a.start))),i+=`<span class="${a.cls}">${_n(e.slice(a.start,a.end))}</span>`,o=a.end);return o<e.length&&(i+=_n(e.slice(o))),i}function Uk(e){if(!e)return null;let t=e.split(".").pop()?.toLowerCase();if(!t)return null;let s=Th[t];return typeof s=="string"&&(s=Th[s]),s||null}function Mh(e,t){if(!e)return _n(e||"");let s=Uk(t);return s?jk(e,s):_n(e)}var fr,Th,Ke,Ph=B(()=>{fr={string:/("(?:[^"\\]|\\.)*")|('(?:[^'\\]|\\.)*')|(`(?:[^`\\]|\\.)*`)/g,number:/\b(\d+\.?\d*(?:[eE][+-]?\d+)?|0x[\da-fA-F]+|0b[01]+|0o[0-7]+)\b/g,comment1:/(\/\/.*$)/gm,commentHash:/(#.*$)/gm,commentBlock:/(\/\*.*?\*\/)/g},Th={js:{keywords:/\b(const|let|var|function|class|extends|return|if|else|for|while|do|switch|case|break|continue|new|this|super|import|export|from|default|async|await|yield|try|catch|finally|throw|typeof|instanceof|in|of|delete|void|null|undefined|true|false|NaN|Infinity)\b/g,builtins:/\b(console|window|document|Math|JSON|Array|Object|String|Number|Boolean|Promise|Map|Set|WeakMap|WeakSet|Symbol|Proxy|Reflect|RegExp|Error|Date|parseInt|parseFloat|setTimeout|setInterval|clearTimeout|clearInterval|fetch|require|module|exports|process)\b/g,operators:/(=>|\.\.\.|\?\.|&&|\|\||===|!==|==|!=|>=|<=|>>>=|>>>|>>=|<<=|\+\+|--|[+\-*/%&|^~!<>]=?|\?|:)/g},ts:"js",jsx:"js",tsx:"js",mjs:"js",cjs:"js",vue:"js",py:{keywords:/\b(def|class|return|if|elif|else|for|while|break|continue|pass|import|from|as|with|try|except|finally|raise|yield|lambda|and|or|not|is|in|True|False|None|global|nonlocal|del|assert|async|await)\b/g,builtins:/\b(print|len|range|int|float|str|bool|list|dict|set|tuple|type|isinstance|super|property|staticmethod|classmethod|enumerate|zip|map|filter|sorted|reversed|open|input|hasattr|getattr|setattr|id|hex|oct|bin|abs|max|min|sum|all|any|iter|next)\b/g,decorators:/(@\w+)/g,commentType:"hash"},rb:{keywords:/\b(def|class|module|end|return|if|elsif|else|unless|for|while|until|do|break|next|case|when|begin|rescue|ensure|raise|yield|require|include|extend|attr_accessor|attr_reader|attr_writer|self|super|nil|true|false|and|or|not|then|puts|print)\b/g,commentType:"hash"},go:{keywords:/\b(func|package|import|var|const|type|struct|interface|map|chan|go|select|switch|case|default|if|else|for|range|break|continue|return|defer|fallthrough|nil|true|false|iota)\b/g,builtins:/\b(fmt|make|len|cap|append|copy|delete|close|panic|recover|new|error|string|int|int8|int16|int32|int64|uint|uint8|uint16|uint32|uint64|float32|float64|bool|byte|rune|complex64|complex128)\b/g},rs:{keywords:/\b(fn|let|mut|const|pub|mod|use|struct|enum|impl|trait|where|for|loop|while|if|else|match|return|break|continue|move|ref|self|Self|super|crate|as|in|unsafe|async|await|dyn|true|false|Some|None|Ok|Err)\b/g,builtins:/\b(String|Vec|Box|Rc|Arc|Option|Result|HashMap|HashSet|println|eprintln|format|panic|todo|unimplemented|assert|assert_eq|assert_ne|dbg|cfg|derive|macro_rules)\b/g,macros:/(\w+!)/g},java:{keywords:/\b(class|interface|extends|implements|public|private|protected|static|final|abstract|synchronized|volatile|transient|native|new|return|if|else|for|while|do|switch|case|default|break|continue|try|catch|finally|throw|throws|import|package|this|super|void|null|true|false|instanceof)\b/g,builtins:/\b(System|String|Integer|Long|Double|Float|Boolean|List|ArrayList|Map|HashMap|Set|HashSet|Optional|Stream|Object|Exception|RuntimeException|Thread|Runnable|Override|Deprecated)\b/g},cs:{keywords:/\b(class|struct|interface|enum|record|delegate|event|namespace|using|public|private|protected|internal|static|readonly|const|sealed|abstract|virtual|override|new|return|if|else|for|foreach|while|do|switch|case|default|break|continue|try|catch|finally|throw|async|await|yield|var|dynamic|is|as|in|out|ref|params|this|base|null|true|false|void|get|set|init|required|partial|where|select|from|orderby|group|join|let|into)\b/g,builtins:/\b(Console|String|Int32|Int64|Double|Boolean|List|Dictionary|HashSet|Task|IEnumerable|ILogger|IOptions|IFeatures|Exception|Guid|DateTime|TimeSpan|CancellationToken|Action|Func|Span|Memory|ReadOnlySpan)\b/g,attributes:/(\[[\w]+(?:\(.*?\))?\])/g},cpp:{keywords:/\b(class|struct|enum|union|namespace|using|template|typename|public|private|protected|static|const|constexpr|volatile|virtual|override|final|explicit|inline|extern|auto|decltype|new|delete|return|if|else|for|while|do|switch|case|default|break|continue|try|catch|throw|sizeof|alignof|typeid|static_cast|dynamic_cast|reinterpret_cast|const_cast|nullptr|true|false|void|this|operator|friend|noexcept|co_await|co_yield|co_return|concept|requires)\b/g,builtins:/\b(std|string|vector|map|unordered_map|set|array|pair|tuple|shared_ptr|unique_ptr|weak_ptr|optional|variant|any|cout|cin|endl|printf|scanf|malloc|free|sizeof|size_t|int8_t|int16_t|int32_t|int64_t|uint8_t|uint16_t|uint32_t|uint64_t)\b/g,preprocessor:/(#\s*(?:include|define|undef|if|ifdef|ifndef|else|elif|endif|pragma|error|warning).*$)/gm},c:"cpp",h:"cpp",hpp:"cpp",html:{tags:/(<\/?[\w-]+|>|\/>)/g,attrs:/\b([\w-]+)(?==)/g,commentType:"html",commentHtml:/(<!--[\s\S]*?-->)/g},xml:"html",svg:"html",css:{selectors:/([\w.#\[\]:,>+~*-]+)\s*\{/g,properties:/\b([\w-]+)(?=\s*:)/g,values:/:\s*([^;{}]+)/g,commentType:"block"},scss:"css",less:"css",json:{keys:/("[\w.-]+")\s*:/g,commentType:"none"},yaml:{keys:/([\w.-]+)\s*:/g,commentType:"hash"},yml:"yaml",md:{headings:/^(#{1,6}\s.*)$/gm,bold:/(\*\*[^*]+\*\*|__[^_]+__)/g,italic:/(\*[^*]+\*|_[^_]+_)/g,code:/(`[^`]+`)/g,links:/(\[[^\]]+\]\([^)]+\))/g,commentType:"none"},sh:{keywords:/\b(if|then|else|elif|fi|for|while|do|done|case|esac|function|return|exit|echo|export|local|readonly|unset|set|shift|eval|exec|trap|source|alias|cd|pwd|ls|mkdir|rm|cp|mv|cat|grep|sed|awk|find|xargs|sort|uniq|wc|head|tail|tee|cut|tr|test)\b/g,variables:/(\$\{?\w+\}?|\$\(|\$\{)/g,commentType:"hash"},bash:"sh",zsh:"sh",sql:{keywords:/\b(SELECT|FROM|WHERE|AND|OR|NOT|IN|LIKE|BETWEEN|JOIN|LEFT|RIGHT|INNER|OUTER|FULL|ON|AS|GROUP|BY|ORDER|HAVING|LIMIT|OFFSET|INSERT|INTO|VALUES|UPDATE|SET|DELETE|CREATE|ALTER|DROP|TABLE|INDEX|VIEW|TRIGGER|FUNCTION|PROCEDURE|BEGIN|END|IF|ELSE|THEN|CASE|WHEN|DECLARE|EXEC|UNION|ALL|DISTINCT|TOP|EXISTS|NULL|IS|ASC|DESC|PRIMARY|KEY|FOREIGN|REFERENCES|CONSTRAINT|DEFAULT|CHECK|UNIQUE|CASCADE|TRUNCATE|COMMIT|ROLLBACK|GRANT|REVOKE)\b/gi,commentType:"both"},lua:{keywords:/\b(and|break|do|else|elseif|end|false|for|function|goto|if|in|local|nil|not|or|repeat|return|then|true|until|while)\b/g,builtins:/\b(print|type|tostring|tonumber|pairs|ipairs|next|select|unpack|error|pcall|xpcall|assert|require|table|string|math|io|os|coroutine|setmetatable|getmetatable|rawget|rawset)\b/g,commentLine:/(--(?!\[).*$)/gm,commentBlock:/(--\[\[[\s\S]*?\]\])/g},php:{keywords:/\b(function|class|interface|trait|extends|implements|public|private|protected|static|final|abstract|const|var|new|return|if|else|elseif|for|foreach|while|do|switch|case|default|break|continue|try|catch|finally|throw|use|namespace|require|include|require_once|include_once|echo|print|die|exit|null|true|false|array|list|match|fn|yield|from)\b/g,variables:/(\$\w+)/g},swift:{keywords:/\b(func|class|struct|enum|protocol|extension|let|var|guard|if|else|for|while|repeat|switch|case|default|break|continue|return|throw|try|catch|defer|import|typealias|associatedtype|init|deinit|subscript|operator|precedencegroup|self|Self|super|nil|true|false|is|as|in|inout|throws|rethrows|where|some|any|weak|unowned|lazy|mutating|nonmutating|override|final|required|convenience|optional|dynamic|async|await|actor|nonisolated|isolated|sending|consuming|borrowing)\b/g},kt:{keywords:/\b(fun|class|object|interface|val|var|if|else|when|for|while|do|return|break|continue|throw|try|catch|finally|import|package|as|is|in|out|by|init|constructor|companion|data|sealed|enum|abstract|open|override|private|protected|internal|public|inline|reified|suspend|coroutine|null|true|false|this|super|it|typealias|annotation|lateinit|lazy|get|set)\b/g},dart:{keywords:/\b(class|extends|implements|with|mixin|abstract|sealed|base|interface|final|const|var|late|required|dynamic|void|static|return|if|else|for|while|do|switch|case|default|break|continue|try|catch|finally|throw|rethrow|assert|new|this|super|null|true|false|is|as|in|async|await|yield|import|export|library|part|show|hide|deferred|typedef|enum|extension|on)\b/g},r:{keywords:/\b(if|else|for|while|repeat|function|return|break|next|in|TRUE|FALSE|NULL|NA|Inf|NaN|library|require|source|print|cat|paste|paste0|sprintf|stop|warning|message)\b/g,commentType:"hash"},toml:{keys:/([\w.-]+)\s*=/g,sections:/(\[[\w.]+\])/g,commentType:"hash"},proto:{keywords:/\b(syntax|package|import|option|message|enum|service|rpc|returns|repeated|optional|required|map|oneof|reserved|extensions|extend|group|default|packed|deprecated|java_package|java_outer_classname|optimize_for|cc_enable_arenas|objc_class_prefix|csharp_namespace|swift_prefix|php_class_prefix|php_namespace|ruby_package|string|int32|int64|uint32|uint64|sint32|sint64|fixed32|fixed64|sfixed32|sfixed64|float|double|bool|bytes)\b/g}},Ke={keyword:"hl-kw",builtin:"hl-bi",string:"hl-st",number:"hl-nm",comment:"hl-cm",operator:"hl-op",decorator:"hl-dc",macro:"hl-mc",preprocessor:"hl-pp",attribute:"hl-at",tag:"hl-tg",property:"hl-pr",variable:"hl-vr",heading:"hl-hd",bold:"hl-bd",link:"hl-lk",key:"hl-ky",section:"hl-sc"}});function Rh(e,t,s){let n=[],r=0,i=0;if(t!=null){let p=t.split(`
2074
2077
  `);for(let f=0;f<p.length;f++)n.push({type:"addition",oldNum:"",oldText:"",newNum:f+1,newText:p[f]}),r++;return{lines:n,stats:{additions:r,deletions:0},content:t}}if(!e||e.trim()==="")return{lines:[{type:"context",oldNum:"",oldText:s("git.noDiff"),newNum:"",newText:s("git.noDiff")}],stats:{additions:0,deletions:0},content:""};if(e.includes("Binary files")&&e.includes("differ"))return{lines:[{type:"context",oldNum:"",oldText:s("git.binaryFile"),newNum:"",newText:s("git.binaryFile")}],stats:{additions:0,deletions:0},content:e};let o=e.split(`
2075
- `),a=0,l=0,c=!1,d=[],u=[],g=()=>{let p=Math.max(d.length,u.length);for(let f=0;f<p;f++){let m=d[f],v=u[f];m&&v?n.push({type:"modification",oldNum:m.num,oldText:m.text,newNum:v.num,newText:v.text}):m?n.push({type:"deletion",oldNum:m.num,oldText:m.text,newNum:"",newText:""}):v&&n.push({type:"addition",oldNum:"",oldText:"",newNum:v.num,newText:v.text})}d=[],u=[]};for(let p of o){if(p.startsWith("diff --git")||p.startsWith("index ")||p.startsWith("---")||p.startsWith("+++")||p.startsWith("\\"))continue;let f=p.match(/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/);if(f){g(),a=parseInt(f[1]),l=parseInt(f[2]),c=!0,n.push({type:"hunk",oldNum:"\xB7\xB7\xB7",oldText:p,newNum:"\xB7\xB7\xB7",newText:p});continue}if(c)if(p.startsWith("-"))u.length>0&&d.length===0&&g(),d.push({num:a++,text:p.substring(1)}),i++;else if(p.startsWith("+"))u.push({num:l++,text:p.substring(1)}),r++;else{g();let m=p.startsWith(" ")?p.substring(1):p;n.push({type:"context",oldNum:a++,oldText:m,newNum:l++,newText:m})}}return g(),{lines:n,stats:{additions:r,deletions:i},content:e}}var _h=B(()=>{});function Eh(e,t){let{effectiveGitWorkDir:s,gitOperating:n,gitOpFeedback:r,commitMessage:i}=t,o=null,a=null,l=(S,b)=>{o&&clearTimeout(o),r.value={ok:S,message:b},o=setTimeout(()=>{r.value=null},4e3)},c=(S,b)=>{e.currentAgent&&(S.value=!0,b.value="",e.sendWsMessage({type:"git_status",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,workDir:s.value,_clientId:e.clientId}))},d=(S,b={})=>{e.currentAgent&&(n.value=!0,a&&clearTimeout(a),a=setTimeout(()=>{n.value&&(n.value=!1,l(!1,"Operation timed out"))},15e3),e.sendWsMessage({type:S,conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,workDir:s.value,_clientId:e.clientId,...b}))};return{showFeedback:l,loadGitStatus:c,gitOp:d,stageFile:S=>d("git_add",{filePath:S}),unstageFile:S=>d("git_reset",{filePath:S}),discardFile:async S=>{await Be("Discard changes to "+S+"?",{destructive:!0})&&d("git_restore",{filePath:S})},stageAll:()=>d("git_add",{addAll:!0}),unstageAll:()=>d("git_reset",{resetAll:!0}),commitChanges:()=>{let S=i.value.trim();S&&d("git_commit",{commitMessage:S})},pushChanges:()=>d("git_push"),handleGitOpResult:(S,b)=>{n.value=!1,a&&(clearTimeout(a),a=null),S.success?(l(!0,S.message||S.operation+" succeeded"),S.operation==="commit"&&(i.value=""),b()):l(!1,S.error||S.operation+" failed")},cleanup:()=>{o&&clearTimeout(o),a&&clearTimeout(a)}}}var Dh=B(()=>{Ct()});function $h(e,t){let s=Vue.ref(!1),n=Vue.ref(""),r=Vue.ref([]),i=Vue.ref(!1),o=Vue.ref(""),a=f=>{i.value=!0,o.value="",e.sendWsMessage({type:"list_directory",conversationId:"_git_folder_picker",agentId:e.currentAgent,dirPath:f,workDir:t.value,_clientId:e.clientId})};return{folderPickerOpen:s,folderPickerPath:n,folderPickerEntries:r,folderPickerLoading:i,folderPickerSelected:o,openFolderPicker:()=>{s.value=!0,o.value="",i.value=!0;let f=t.value||"";n.value=f,r.value=[],e.sendWsMessage({type:"list_directory",conversationId:"_git_folder_picker",agentId:e.currentAgent,dirPath:f,workDir:t.value,_clientId:e.clientId})},folderPickerNavigateUp:()=>{if(!n.value)return;let f=n.value.includes("\\"),m=f?"\\":"/",v=n.value.replace(/[/\\]$/,"").split(/[/\\]/);if(v.pop(),v.length===0)n.value="",a("");else if(f&&v.length===1&&/^[A-Za-z]:$/.test(v[0]))n.value=v[0]+"\\",a(v[0]+"\\");else{let y=v.join(m);n.value=y,a(y)}},folderPickerSelectItem:f=>{o.value=f.name},folderPickerEnter:f=>{let m=n.value.includes("\\")||/^[A-Z]:/.test(f.name)?"\\":"/",v;n.value?v=n.value.replace(/[/\\]$/,"")+m+f.name:v=f.name+(f.name.endsWith("\\")?"":"\\"),n.value=v,a(v)},confirmFolderPicker:(f,m)=>{let v=n.value;if(v){if(o.value){let y=v.includes("\\")?"\\":"/";v=v.replace(/[/\\]$/,"")+y+o.value}f.value=v,s.value=!1,m()}},handleDirectoryListing:f=>f.conversationId!=="_git_folder_picker"?!1:(i.value=!1,r.value=(f.entries||[]).filter(m=>m.type==="directory").sort((m,v)=>m.name.localeCompare(v.name)),f.dirPath!=null&&(n.value=f.dirPath),!0)}}var Lh=B(()=>{});var Fh,Oh=B(()=>{Wc();Ph();_h();Dh();Lh();As();Fh={name:"GitStatusTab",props:{routeKey:{type:String,required:!0},runtimeProvider:{type:String,required:!0},agentId:{type:String,required:!0},sessionId:{type:String,required:!0},conversationId:{type:String,required:!0},workDir:{type:String,default:""},workspaceGeneration:{type:String,required:!0}},template:`
2078
+ `),a=0,l=0,c=!1,d=[],u=[],g=()=>{let p=Math.max(d.length,u.length);for(let f=0;f<p;f++){let m=d[f],v=u[f];m&&v?n.push({type:"modification",oldNum:m.num,oldText:m.text,newNum:v.num,newText:v.text}):m?n.push({type:"deletion",oldNum:m.num,oldText:m.text,newNum:"",newText:""}):v&&n.push({type:"addition",oldNum:"",oldText:"",newNum:v.num,newText:v.text})}d=[],u=[]};for(let p of o){if(p.startsWith("diff --git")||p.startsWith("index ")||p.startsWith("---")||p.startsWith("+++")||p.startsWith("\\"))continue;let f=p.match(/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/);if(f){g(),a=parseInt(f[1]),l=parseInt(f[2]),c=!0,n.push({type:"hunk",oldNum:"\xB7\xB7\xB7",oldText:p,newNum:"\xB7\xB7\xB7",newText:p});continue}if(c)if(p.startsWith("-"))u.length>0&&d.length===0&&g(),d.push({num:a++,text:p.substring(1)}),i++;else if(p.startsWith("+"))u.push({num:l++,text:p.substring(1)}),r++;else{g();let m=p.startsWith(" ")?p.substring(1):p;n.push({type:"context",oldNum:a++,oldText:m,newNum:l++,newText:m})}}return g(),{lines:n,stats:{additions:r,deletions:i},content:e}}var _h=B(()=>{});function Eh(e,t){let{effectiveGitWorkDir:s,gitOperating:n,gitOpFeedback:r,commitMessage:i}=t,o=null,a=null,l=(S,y)=>{o&&clearTimeout(o),r.value={ok:S,message:y},o=setTimeout(()=>{r.value=null},4e3)},c=(S,y)=>{e.currentAgent&&(S.value=!0,y.value="",e.sendWsMessage({type:"git_status",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,workDir:s.value,_clientId:e.clientId}))},d=(S,y={})=>{e.currentAgent&&(n.value=!0,a&&clearTimeout(a),a=setTimeout(()=>{n.value&&(n.value=!1,l(!1,"Operation timed out"))},15e3),e.sendWsMessage({type:S,conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,workDir:s.value,_clientId:e.clientId,...y}))};return{showFeedback:l,loadGitStatus:c,gitOp:d,stageFile:S=>d("git_add",{filePath:S}),unstageFile:S=>d("git_reset",{filePath:S}),discardFile:async S=>{await Be("Discard changes to "+S+"?",{destructive:!0})&&d("git_restore",{filePath:S})},stageAll:()=>d("git_add",{addAll:!0}),unstageAll:()=>d("git_reset",{resetAll:!0}),commitChanges:()=>{let S=i.value.trim();S&&d("git_commit",{commitMessage:S})},pushChanges:()=>d("git_push"),handleGitOpResult:(S,y)=>{n.value=!1,a&&(clearTimeout(a),a=null),S.success?(l(!0,S.message||S.operation+" succeeded"),S.operation==="commit"&&(i.value=""),y()):l(!1,S.error||S.operation+" failed")},cleanup:()=>{o&&clearTimeout(o),a&&clearTimeout(a)}}}var Dh=B(()=>{Ct()});function $h(e,t){let s=Vue.ref(!1),n=Vue.ref(""),r=Vue.ref([]),i=Vue.ref(!1),o=Vue.ref(""),a=f=>{i.value=!0,o.value="",e.sendWsMessage({type:"list_directory",conversationId:"_git_folder_picker",agentId:e.currentAgent,dirPath:f,workDir:t.value,_clientId:e.clientId})};return{folderPickerOpen:s,folderPickerPath:n,folderPickerEntries:r,folderPickerLoading:i,folderPickerSelected:o,openFolderPicker:()=>{s.value=!0,o.value="",i.value=!0;let f=t.value||"";n.value=f,r.value=[],e.sendWsMessage({type:"list_directory",conversationId:"_git_folder_picker",agentId:e.currentAgent,dirPath:f,workDir:t.value,_clientId:e.clientId})},folderPickerNavigateUp:()=>{if(!n.value)return;let f=n.value.includes("\\"),m=f?"\\":"/",v=n.value.replace(/[/\\]$/,"").split(/[/\\]/);if(v.pop(),v.length===0)n.value="",a("");else if(f&&v.length===1&&/^[A-Za-z]:$/.test(v[0]))n.value=v[0]+"\\",a(v[0]+"\\");else{let b=v.join(m);n.value=b,a(b)}},folderPickerSelectItem:f=>{o.value=f.name},folderPickerEnter:f=>{let m=n.value.includes("\\")||/^[A-Z]:/.test(f.name)?"\\":"/",v;n.value?v=n.value.replace(/[/\\]$/,"")+m+f.name:v=f.name+(f.name.endsWith("\\")?"":"\\"),n.value=v,a(v)},confirmFolderPicker:(f,m)=>{let v=n.value;if(v){if(o.value){let b=v.includes("\\")?"\\":"/";v=v.replace(/[/\\]$/,"")+b+o.value}f.value=v,s.value=!1,m()}},handleDirectoryListing:f=>f.conversationId!=="_git_folder_picker"?!1:(i.value=!1,r.value=(f.entries||[]).filter(m=>m.type==="directory").sort((m,v)=>m.name.localeCompare(v.name)),f.dirPath!=null&&(n.value=f.dirPath),!0)}}var Lh=B(()=>{});var Fh,Oh=B(()=>{Wc();Ph();_h();Dh();Lh();As();Fh={name:"GitStatusTab",props:{routeKey:{type:String,required:!0},runtimeProvider:{type:String,required:!0},agentId:{type:String,required:!0},sessionId:{type:String,required:!0},conversationId:{type:String,required:!0},workDir:{type:String,default:""},workspaceGeneration:{type:String,required:!0}},template:`
2076
2079
  <div class="git-status-tab git-three-col">
2077
2080
  <!-- \u5DE6\u680F: \u6587\u4EF6\u5217\u8868 -->
2078
2081
  <div class="git-col-files">
@@ -2316,7 +2319,7 @@ ${String(e||"").trim()}
2316
2319
  </div>
2317
2320
  </div>
2318
2321
  </div>
2319
- `,setup(e){let t=er(Pinia.useChatStore(),e),s=Vue.inject("t"),n=te=>te.split(/[/\\]/).pop()||te,r=te=>{let V=te.split(/[/\\]/);return V.pop(),V.join("/")},i=te=>ea(n(te)),o=Vue.ref(null),a=Vue.reactive({staged:!1,modified:!1,untracked:!1}),l=te=>{a[te]=!a[te]},c=Vue.ref(!1),d=Vue.ref(""),u=Vue.ref(null),g=Vue.ref([]),p=Vue.computed(()=>t.effectiveWorkDir||""),f=Vue.ref(""),m=Vue.computed(()=>f.value.trim()||p.value),v=Vue.ref(null),y=Vue.ref(!1),h=Vue.ref(!1),k=Vue.ref(""),S=Vue.ref(null),b=Vue.ref([]),w=Vue.ref(null),P=Vue.ref(!0),x=Vue.ref(!1),Y=Vue.ref(""),L=Vue.ref(null),U=Vue.ref(0),E=Vue.ref(0),oe=te=>te==null||te===""?"":Mh(te,v.value||""),q=Vue.ref(parseInt(localStorage.getItem("gitDiffFontSize"))||12),I=te=>{q.value=Math.max(8,Math.min(24,te)),localStorage.setItem("gitDiffFontSize",q.value.toString())},T=()=>I(q.value+1),R=()=>I(q.value-1),M=te=>{te.deltaY<0?T():te.deltaY>0&&R()},$=Vue.computed(()=>{let te=b.value;if(!te||te.length===0)return[];let V=te.length,ce=[],X=0;for(;X<V;){let F=te[X];if(F.type==="addition"||F.type==="deletion"||F.type==="modification"){let Z=F.type==="modification"?"modification":F.type,fe=X;for(;X<V&&(te[X].type===Z||te[X].type==="modification"&&Z!=="modification");)X++;let Re=X-fe;ce.push({type:Z,top:fe/V*100,height:Math.max(Re/V*100,.5)})}else X++}return ce}),j=te=>{let V=o.value;if(!V)return;let ce=te.currentTarget.getBoundingClientRect(),X=(te.clientY-ce.top)/ce.height;V.scrollTop=X*(V.scrollHeight-V.clientHeight)},z=Vue.computed(()=>g.value.filter(te=>te.indexStatus!==" "&&te.indexStatus!=="?")),Q=Vue.computed(()=>g.value.filter(te=>te.workTreeStatus==="M"||te.workTreeStatus==="D")),ae=Vue.computed(()=>g.value.filter(te=>te.indexStatus==="?"&&te.workTreeStatus==="?")),ke=Eh(t,{effectiveGitWorkDir:m,gitOperating:x,gitOpFeedback:L,commitMessage:Y}),N=()=>ke.loadGitStatus(c,d),G=()=>{N()},de=$h(t,m),we=te=>ta(te),se=()=>de.confirmFolderPicker(f,N),ve=(te,V)=>{v.value=te.path,y.value=V,h.value=!0,k.value="",S.value=null,b.value=[],w.value=null;let ce=te.indexStatus==="?"&&te.workTreeStatus==="?";t.sendWsMessage({type:"git_diff",conversationId:t.currentConversation||"_explorer",agentId:t.currentAgent,workDir:m.value,filePath:te.path,staged:V,untracked:ce,fullFile:P.value,_clientId:t.clientId})},Ie=()=>{if(P.value=!P.value,v.value){let te=g.value.find(V=>V.path===v.value);te&&ve(te,y.value)}},ue=te=>{let V=te.detail;if(!(!V||!tr(V,e.routeKey,e.workspaceGeneration)))switch(V.type){case"directory_listing":{cs(V,e.routeKey)==="git-folder-picker"&&de.handleDirectoryListing({...V,conversationId:"_git_folder_picker"});break}case"git_status_result":{if(e.routeKey&&cs(V,e.routeKey)!=="main")return;if(c.value=!1,V.error){d.value=V.error,u.value=null,g.value=[];return}if(d.value="",u.value=V.branch||"HEAD",g.value=V.files||[],U.value=V.ahead||0,E.value=V.behind||0,v.value){let ce=g.value.find(X=>X.path===v.value);if(ce){let X=ce.indexStatus!==" "&&ce.indexStatus!=="?";y.value=X}else v.value=null,S.value=null,b.value=[],w.value=null}break}case"git_diff_result":{if(e.routeKey&&cs(V,e.routeKey)!=="main")return;if(h.value=!1,V.error){k.value=V.error;return}k.value="";let ce=Rh(V.diff,V.newFileContent,s);w.value=ce.stats,b.value=ce.lines,S.value=ce.content;break}case"git_op_result":{if(e.routeKey&&cs(V,e.routeKey)!=="main")return;ke.handleGitOpResult(V,N);break}}};Vue.watch(()=>t.currentAgent,()=>{u.value=null,g.value=[],d.value="",v.value=null,S.value=null,t.currentAgent&&Vue.nextTick(()=>N())}),Vue.watch(()=>t.currentConversation,()=>{t.currentAgent&&(v.value=null,S.value=null,b.value=[],w.value=null,Vue.nextTick(()=>N()))});let re=()=>N();return Vue.onMounted(()=>{window.addEventListener("workbench-message",ue),t.currentAgent&&N()}),Vue.onUnmounted(()=>{window.removeEventListener("workbench-message",ue),ke.cleanup()}),{store:t,getFileName:n,getDirName:r,getFileIconHtml:i,hlLine:oe,collapsedGroups:a,toggleGroup:l,gitLoading:c,gitError:d,gitBranch:u,gitFiles:g,gitWorkDir:f,defaultWorkDir:p,changeGitWorkDir:G,stagedFiles:z,modifiedFiles:Q,untrackedFiles:ae,selectedGitFile:v,selectedStaged:y,diffLoading:h,diffError:k,diffContent:S,diffLines:b,diffStats:w,diffFullFile:P,toggleDiffMode:Ie,scrollMarkers:$,diffScrollContainer:o,onMarkerClick:j,fontSize:q,zoomIn:T,zoomOut:R,onWheel:M,gitOperating:x,commitMessage:Y,gitOpFeedback:L,gitAhead:U,gitBehind:E,stageFile:ke.stageFile,unstageFile:ke.unstageFile,discardFile:ke.discardFile,stageAll:ke.stageAll,unstageAll:ke.unstageAll,commitChanges:ke.commitChanges,pushChanges:ke.pushChanges,selectGitFile:ve,refresh:re,folderPickerOpen:de.folderPickerOpen,folderPickerPath:de.folderPickerPath,folderPickerEntries:de.folderPickerEntries,folderPickerLoading:de.folderPickerLoading,folderPickerSelected:de.folderPickerSelected,getFolderIcon:we,openFolderPicker:de.openFolderPicker,folderPickerNavigateUp:de.folderPickerNavigateUp,folderPickerSelectItem:de.folderPickerSelectItem,folderPickerEnter:de.folderPickerEnter,confirmFolderPicker:se}}}});function qh(e){let t=Vue.ref(!1),s=Vue.ref(!1),n=Vue.ref(""),r=Vue.ref(""),i=Vue.ref(!1),o=Vue.ref(!1),a=Vue.ref(0),l=Vue.ref(-1),c=Vue.ref(null),d=Vue.ref(null),u=[],g=[],p=()=>{let L=e.value?.cmInstance;if(!L)return;let E=L.getWrapperElement().querySelector(".cm-find-scrollbar-annotations");E&&E.remove()},f=()=>{let L=e.value?.cmInstance;if(!L||g.length===0)return;p();let U=L.getWrapperElement();if(!U.querySelector(".CodeMirror-vscrollbar"))return;let oe=L.lineCount();if(oe===0)return;let q=document.createElement("div");q.className="cm-find-scrollbar-annotations";for(let I of g){let T=I.from.line/oe*100,R=document.createElement("div");R.className="cm-find-scrollbar-tick",R.style.top=T+"%",q.appendChild(R)}U.appendChild(q)},m=()=>{for(let L of u)try{L.clear()}catch{}u=[],g=[],a.value=0,l.value=-1,p()},v=L=>{let U=e.value?.cmInstance;if(!U||!g[L])return;for(let oe=0;oe<u.length;oe++){if(!u[oe])continue;let q=u[oe].find();q&&(u[oe].clear(),u[oe]=U.markText(q.from,q.to,{className:"cm-find-highlight"}))}let E=g[L];if(u[L]){let oe=u[L].find();oe&&(u[L].clear(),u[L]=U.markText(oe.from,oe.to,{className:"cm-find-highlight cm-find-current"}))}setTimeout(()=>{U.scrollIntoView({from:E.from,to:E.to},100)},0)},y=()=>{m();let L=e.value?.cmInstance;if(!L||!n.value)return;let U=n.value;if(U.length<3)return;let E=L.getValue(),oe=i.value,q=o.value,I=[];try{if(q){let T=oe?"g":"gi",R=new RegExp(U,T),M;for(;(M=R.exec(E))!==null;){if(M[0].length===0){R.lastIndex++;continue}let $=L.posFromIndex(M.index),j=L.posFromIndex(M.index+M[0].length);if(I.push({from:$,to:j}),I.length>1e4)break}}else{let T=oe?U:U.toLowerCase(),R=oe?E:E.toLowerCase(),M=0;for(;(M=R.indexOf(T,M))!==-1;){let $=L.posFromIndex(M),j=L.posFromIndex(M+U.length);if(I.push({from:$,to:j}),M+=U.length,I.length>1e4)break}}}catch{return}g=I,a.value=I.length;for(let T of I)u.push(L.markText(T.from,T.to,{className:"cm-find-highlight"}));if(I.length>0){let T=L.getCursor(),R=0;for(let M=0;M<I.length;M++){if(CodeMirror.cmpPos(I[M].from,T)>=0){R=M;break}M===I.length-1&&(R=0)}l.value=R,v(R)}f()};return{findBarVisible:t,replaceBarVisible:s,findQuery:n,replaceQuery:r,findCaseSensitive:i,findUseRegex:o,findMatchCount:a,findMatchIndex:l,findInputRef:c,replaceInputRef:d,clearFindMarkers:m,performFind:y,onFindInput:()=>{y()},findNext:()=>{if(g.length===0)return;let L=(l.value+1)%g.length;l.value=L,v(L)},findPrev:()=>{if(g.length===0)return;let L=(l.value-1+g.length)%g.length;l.value=L,v(L)},openFindBar:(L=!1)=>{t.value=!0,s.value=L;let U=e.value?.cmInstance;if(U){let E=U.getSelection();E&&(n.value=E)}Vue.nextTick(()=>{c.value?.focus(),c.value?.select(),n.value&&y()})},closeFindBar:()=>{m(),t.value=!1,s.value=!1;let L=e.value?.cmInstance;L&&L.focus()},toggleReplaceBar:()=>{s.value=!s.value,s.value&&Vue.nextTick(()=>d.value?.focus())},replaceOne:()=>{let L=e.value?.cmInstance;if(!L||g.length===0||l.value<0)return;let U=g[l.value];L.replaceRange(r.value,U.from,U.to),y()},replaceAll:()=>{let L=e.value?.cmInstance;!L||g.length===0||(L.operation(()=>{for(let U=g.length-1;U>=0;U--)L.replaceRange(r.value,g[U].from,g[U].to)}),y())}}}var Vh=B(()=>{});function Xs(e){let t=e.lastIndexOf(".");if(t<0)return"text";let s=e.substring(t).toLowerCase();return Kk.has(s)?"office":zk.has(s)?"pdf":Yk.has(s)?"image":Gk.has(s)?"video":"text"}function $s(e){let t=e.lastIndexOf(".");return t<0?!1:Qk.has(e.substring(t).toLowerCase())}function Xk(e){let t=e.split(".").pop()?.toLowerCase();return{js:"javascript",mjs:"javascript",jsx:"javascript",ts:{name:"javascript",typescript:!0},tsx:{name:"javascript",typescript:!0},json:{name:"javascript",json:!0},py:"python",html:"htmlmixed",htm:"htmlmixed",vue:"htmlmixed",xml:"xml",svg:"xml",css:"css",scss:"css",less:"css",sh:"shell",bash:"shell",zsh:"shell",c:"text/x-csrc",h:"text/x-csrc",cpp:"text/x-c++src",hpp:"text/x-c++src",cs:"text/x-csharp",java:"text/x-java",md:"markdown",markdown:"markdown"}[t]||"text/plain"}function Hh(e,{activeFile:t,editorContainer:s,fontSize:n,clearFindMarkers:r,openFindBar:i,saveFile:o}){let a=Vue.ref(""),l=Vue.reactive({}),c=()=>{},d=()=>{},u=({openQuickOpen:h,openGoToLine:k})=>{c=h,d=k},g=(h,k=0)=>{if(!s.value){k<20&&setTimeout(()=>g(h,k+1),100);return}if(!h)return;if(s.value.innerHTML="",typeof CodeMirror>"u"){let w=document.createElement("textarea");w.value=h.content||"",w.style.cssText="width:100%;height:100%;border:none;outline:none;resize:none;padding:12px;font-family:monospace;font-size:12px;background:var(--bg-main);color:var(--text-main);white-space:pre;tab-size:4;",w.spellcheck=!1,w.addEventListener("input",()=>{h.content=w.value,h.isDirty=w.value!==h.originalContent}),w.addEventListener("keydown",P=>{(P.ctrlKey||P.metaKey)&&P.key==="s"&&(P.preventDefault(),o())}),s.value.appendChild(w),a.value="";return}let b=document.documentElement.getAttribute("data-theme")==="dark"?"material-darker":"default";try{let w=CodeMirror(s.value,{value:h.content||"",mode:Xk(h.name),theme:b,lineNumbers:!0,tabSize:4,indentWithTabs:!1,lineWrapping:!1,readOnly:!1,extraKeys:{"Ctrl-S":()=>o(),"Cmd-S":()=>o(),"Ctrl-P":()=>c(),"Cmd-P":()=>c(),"Ctrl-G":()=>d(),"Cmd-G":()=>d(),"Ctrl-F":()=>i(!1),"Cmd-F":()=>i(!1),"Ctrl-R":()=>i(!0),"Cmd-R":()=>i(!0),"Ctrl-H":()=>i(!0),"Cmd-H":()=>i(!0)}});w.on("change",()=>{let x=w.getValue();h.content=x,h.isDirty=x!==h.originalContent}),h.cmInstance=w,w.getWrapperElement().style.fontSize=n.value+"px";let P=e.currentConversation;P&&l[P]?.[h.path]&&w.setHistory(l[P][h.path]),Vue.nextTick(()=>{w.refresh(),setTimeout(()=>w.refresh(),200)}),a.value=""}catch(w){a.value=`Editor error: ${w.message}`}};return{debugStatus:a,undoHistoryMap:l,createEditor:g,destroyEditor:()=>{r();let h=t.value;h?.cmInstance&&(h.cmInstance.toTextArea&&h.cmInstance.toTextArea(),h.cmInstance=null),s.value&&(s.value.innerHTML="")},setKeyBindings:u,saveCurrentUndoHistory:()=>{let h=e.currentConversation;if(!h)return;let k=t.value;k?.cmInstance&&(l[h]||(l[h]={}),l[h][k.path]=k.cmInstance.getHistory())},saveAllUndoHistory:h=>{if(!h)return;let k=t.value;k?.cmInstance&&(l[h]||(l[h]={}),l[h][k.path]=k.cmInstance.getHistory())},cleanupUndoHistory:(h,k)=>{h&&l[h]&&delete l[h][k]},deleteConversationHistory:h=>{delete l[h]}}}var Kk,zk,Yk,Gk,Qk,hr=B(()=>{Kk=new Set([".docx",".xlsx",".xls",".pptx",".ppt"]),zk=new Set([".pdf"]),Yk=new Set([".png",".jpg",".jpeg",".gif",".webp",".bmp",".ico"]),Gk=new Set([".mp4",".m4v",".webm",".ogv",".ogg",".mov"]),Qk=new Set([".md",".markdown",".mdx"])});function Bh(e,t){let{getEffectiveWorkDir:s,treePath:n}=t,r=Vue.reactive(new Set),i=Vue.ref(-1),o=Vue.ref(!1),a=Vue.ref(null),l=null,c=null,d=Vue.ref(!1),u=Vue.ref(""),g=Vue.ref("file"),p=Vue.ref(null),f=Vue.ref(!1),m=Vue.ref(""),v=Vue.ref(null),y=Vue.reactive({visible:!1,x:0,y:0,entry:null}),h=Vue.ref(!1),k=Vue.ref(""),S=Vue.ref(null),b=new Map,w=Vue.reactive({dragging:null,dropTarget:null}),P=Vue.ref(!1),x=(F,Z)=>{l&&clearTimeout(l),a.value={ok:F,message:Z},l=setTimeout(()=>{a.value=null},4e3)},Y=()=>{o.value=!0,c&&clearTimeout(c),c=setTimeout(()=>{o.value&&(o.value=!1,x(!1,"Operation timed out"))},15e3)},L=F=>{r.has(F)?r.delete(F):r.add(F)},U=()=>{r.clear(),i.value=-1},E=F=>{g.value=F,u.value="",d.value=!0,Vue.nextTick(()=>p.value?.focus())},oe=()=>{let F=u.value.trim();if(!F)return;d.value=!1;let Z=n.value||s();if(!Z)return;let fe=Z.includes("\\")?"\\":"/",Re=Z.replace(/[/\\]$/,"")+fe+F;Y(),e.sendWsMessage({type:"create_file",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,filePath:Re,isDirectory:g.value==="directory",workDir:s(),_clientId:e.clientId})},q=async(F,Z)=>{let fe=F.path.split("/").pop();await Be(Z("files.deleteConfirm",{name:fe})+(F.type==="directory"?Z("files.deleteDirHint"):""),{destructive:!0})&&(Y(),e.sendWsMessage({type:"delete_files",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,paths:[F.path],workDir:s(),_clientId:e.clientId}))},I=async F=>{let Z=r.size;Z!==0&&await Be(F("files.deleteSelectedConfirm",{count:Z}),{destructive:!0})&&(Y(),e.sendWsMessage({type:"delete_files",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,paths:[...r],workDir:s(),_clientId:e.clientId}))},T=()=>{m.value=n.value||s()||"",f.value=!0,Vue.nextTick(()=>v.value?.focus())},R=()=>{let F=m.value.trim();!F||r.size===0||(f.value=!1,Y(),e.sendWsMessage({type:"move_files",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,paths:[...r],destination:F,workDir:s(),_clientId:e.clientId}))},M=(F,Z)=>{let J=F.clientX,D=F.clientY;J+180>window.innerWidth&&(J=window.innerWidth-180),D+240>window.innerHeight&&(D=window.innerHeight-240),y.entry=Z,y.x=J,y.y=D,y.visible=!0},$=()=>{y.visible=!1},j=()=>{let F=y.entry;$(),F&&(k.value=F.name,h.value=!0,Vue.nextTick(()=>{let Z=S.value;if(Z)if(Z.focus(),F.type==="file"){let fe=F.name.lastIndexOf(".");fe>0?Z.setSelectionRange(0,fe):Z.select()}else Z.select()}))},z=()=>{let F=y.entry,Z=k.value.trim();if(!Z||!F||Z===F.name){h.value=!1;return}h.value=!1;let fe=F.path.replace(/\/$/,"").split("/");fe.pop();let Re=fe.join("/")||"/";Y(),e.sendWsMessage({type:"move_files",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,paths:[F.path],destination:Re,newName:Z,workDir:s(),_clientId:e.clientId})},Q=()=>{let F=y.entry;if($(),!F)return;let Z=F.path.replace(/\/$/,"").split("/");Z.pop();let fe=Z.join("/")||"/";Y(),e.sendWsMessage({type:"copy_files",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,paths:[F.path],destination:fe,workDir:s(),_clientId:e.clientId})},ae=()=>{let F=y.entry;$(),F&&(r.clear(),r.add(F.path),T())},ke=F=>{let Z=y.entry;$(),Z&&q(Z,F)},N=F=>{if(!F?.path)return;let Z=`file-download-${Date.now()}-${Math.random().toString(36).slice(2)}`;b.set(Z,F.path),e.sendWsMessage({type:Xs(F.path)==="video"?"video_metadata":"read_file",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,requestId:Z,download:!0,filePath:F.path,workDir:s(),_clientId:e.clientId})};return{selectedPaths:r,lastClickedIndex:i,fileOperating:o,fileOpFeedback:a,newFileDialogVisible:d,newFileName:u,newFileType:g,newFileInput:p,moveDialogVisible:f,moveDestination:m,moveDestInput:v,contextMenu:y,renameDialogVisible:h,renameNewName:k,renameInput:S,dragState:w,externalDropActive:P,showFileOpFeedback:x,toggleSelection:L,clearSelection:U,showNewFileDialog:E,confirmNewFile:oe,deleteSingleFile:q,deleteSelected:I,openMoveDialog:T,confirmMove:R,showContextMenu:M,hideContextMenu:$,ctxRename:j,confirmRename:z,ctxCopy:Q,ctxMoveTo:ae,ctxDelete:ke,ctxDownload:()=>{let F=y.entry;$(),!(!F||F.type!=="file")&&N(F)},downloadFile:N,onDragStart:(F,Z)=>{w.dragging=Z,F.dataTransfer.setData("text/plain",Z.path),F.dataTransfer.effectAllowed="move"},onDragOver:(F,Z)=>{if(!w.dragging&&F.dataTransfer.types.includes("Files")){Z.type==="directory"&&(F.dataTransfer.dropEffect="copy",w.dropTarget=Z.path);return}!w.dragging||Z.type!=="directory"||Z.path!==w.dragging.path&&(Z.path.startsWith(w.dragging.path+"/")||(F.dataTransfer.dropEffect="move",w.dropTarget=Z.path))},onDragLeave:F=>{let Z=F.relatedTarget;Z&&F.currentTarget.contains(Z)||(w.dropTarget=null)},onDrop:(F,Z,fe)=>{if(w.dropTarget=null,!w.dragging&&F.dataTransfer.files.length>0&&Z.type==="directory"){fe(F.dataTransfer.files,Z.path);return}if(!w.dragging||Z.type!=="directory"){w.dragging=null;return}if(Z.path===w.dragging.path){w.dragging=null;return}Y(),e.sendWsMessage({type:"move_files",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,paths:[w.dragging.path],destination:Z.path,workDir:s(),_clientId:e.clientId}),w.dragging=null},onTreeDragOver:F=>{w.dragging||F.dataTransfer.types.includes("Files")&&(F.dataTransfer.dropEffect="copy",P.value=!0)},onTreeDragLeave:F=>{let Z=F.relatedTarget;Z&&F.currentTarget.contains(Z)||(P.value=!1)},onTreeDrop:(F,Z,fe)=>{if(P.value=!1,!w.dragging&&F.dataTransfer.files.length>0){let Re=n.value||Z||s();fe(F.dataTransfer.files,Re)}},handleExternalFileDrop:async(F,Z)=>{if(!Z)return;let fe=[],Re=[];for(let J of F)Re.push(new Promise(D=>{let ye=new FileReader;ye.onload=()=>{let Me=btoa(new Uint8Array(ye.result).reduce((ze,Ye)=>ze+String.fromCharCode(Ye),""));fe.push({name:J.name,data:Me}),D()},ye.onerror=()=>D(),ye.readAsArrayBuffer(J)}));await Promise.all(Re),fe.length!==0&&(o.value=!0,c&&clearTimeout(c),c=setTimeout(()=>{o.value&&(o.value=!1,x(!1,"Upload timed out"))},3e4),e.sendWsMessage({type:"upload_to_dir",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,files:fe,dirPath:Z,workDir:s(),_clientId:e.clientId}))},handleFileOpResult:(F,Z,fe)=>{o.value=!1,c&&(clearTimeout(c),c=null),x(F.success,F.success?F.message:F.error||"Operation failed"),F.success&&(fe&&Z(fe),(F.operation==="delete"||F.operation==="move")&&(r.clear(),i.value=-1))},takePendingDownload:F=>{if(!F||!b.has(F))return null;let Z=b.get(F);return b.delete(F),Z},cleanup:()=>{l&&clearTimeout(l),c&&clearTimeout(c),b.clear()}}}var Nh=B(()=>{Ct();hr()});function Wh(e,{getEffectiveWorkDir:t,normalizePath:s,selectedPaths:n,lastClickedIndex:r,openFileInTab:i,clearSelection:o}){let a=Vue.ref(""),l=Vue.ref(""),c=Vue.reactive({}),d=new Map,u=0,g=I=>{let T=`files-tree-${++u}`;return d.set(I,T),T},p=Vue.ref(!1),f=Vue.ref(null),m=Vue.computed(()=>{if(!l.value)return"EXPLORER";let I=l.value.replace(/[\\/]+$/,"").split(/[\\/]/);return(I[I.length-1]||l.value).toUpperCase()}),v=()=>{p.value=!0,Vue.nextTick(()=>f.value?.focus())},y=()=>{p.value=!1,b()},h=()=>{p.value=!1},k=Vue.computed(()=>{let I=[],T=(R,M)=>{let $=c[R];if(!(!$||!$.entries))for(let j of $.entries)I.push({...j,depth:M}),j.type==="directory"&&c[j.path]?.expanded&&T(j.path,M+1)};return l.value&&c[l.value]?.expanded&&T(l.value,0),I}),S=I=>{let T=s(I);c[T]?c[T].loading=!0:c[T]={entries:[],expanded:!0,loaded:!1,loading:!0},e.sendWsMessage({type:"list_directory",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,requestId:g(T),dirPath:I,workDir:t(),_clientId:e.clientId})},b=()=>{let I=a.value.trim();if(!I)return;let T=s(I);l.value=T,Object.keys(c).forEach(R=>delete c[R]),d.clear(),c[T]={entries:[],expanded:!0,loaded:!1,loading:!0},e.sendWsMessage({type:"list_directory",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,requestId:g(T),dirPath:I,workDir:t(),_clientId:e.clientId})},w=I=>{let T=s(I),R=c[T];R?R.loaded?R.expanded=!R.expanded:(R.expanded=!0,S(I)):(c[T]={entries:[],expanded:!0,loaded:!1,loading:!1},S(I))},P=(I,T)=>{let R=k.value,M=R.findIndex($=>$.path===I.path);if(T&&(T.shiftKey||T.ctrlKey||T.metaKey)){if(T.shiftKey&&r.value>=0&&M>=0){let $=Math.min(r.value,M),j=Math.max(r.value,M);!T.ctrlKey&&!T.metaKey&&n.clear();for(let z=$;z<=j;z++)n.add(R[z].path)}else n.has(I.path)?n.delete(I.path):n.add(I.path);r.value=M;return}n.size>0&&(n.clear(),r.value=-1),I.type==="directory"?w(I.path):i(I.path,I.name),r.value=M},x=I=>{let T=`${I.replace(/\/$/,"")}/`;for(let R of Object.keys(c))(R===I||R.startsWith(T))&&delete c[R];for(let R of d.keys())(R===I||R.startsWith(T))&&d.delete(R);for(let R of Object.values(c))R?.entries&&(R.entries=R.entries.filter(M=>M.path!==I))},Y=I=>typeof I=="string"&&/(?:ENOENT|not\s+(?:exist|found)|no such file)/i.test(I),L=I=>I===l.value?!0:Object.values(c).some(T=>T?.entries?.some(R=>R.type==="directory"&&R.path===I)),U=I=>{let T=s(I.dirPath),R=d.get(T);if(R&&I.requestId!==R||!R&&I.requestId)return;if(R&&d.delete(T),!L(T)){x(T);return}if(I.error){if(Y(I.error))if(T===l.value){for(let Q of c[T]?.entries||[])Q.type==="directory"&&x(Q.path);c[T]&&(c[T].entries=[],c[T].loaded=!0,c[T].loading=!1)}else x(T);else c[T]&&(c[T].loading=!1);return}let M=(I.entries||[]).sort((Q,ae)=>Q.type===ae.type?Q.name.localeCompare(ae.name):Q.type==="directory"?-1:1),$=T.replace(/\/$/,""),j=M.map(Q=>({...Q,path:$+"/"+Q.name})),z=new Set(j.filter(Q=>Q.type==="directory").map(Q=>Q.path));for(let Q of c[T]?.entries||[])Q.type==="directory"&&!z.has(Q.path)&&x(Q.path);c[T]?(c[T].entries=j,c[T].loaded=!0,c[T].loading=!1):c[T]={entries:j,expanded:!0,loaded:!0,loading:!1},T===l.value&&(a.value=I.dirPath)},E=()=>{Object.keys(c).forEach(I=>delete c[I]),d.clear()};return{treePath:a,treeRootPath:l,treeNodes:c,flattenedTree:k,editingTreePath:p,treePathInputRef:f,rootFolderName:m,startTreePathEdit:v,confirmTreePath:y,cancelTreePathEdit:h,loadTreeDirectory:S,loadRootDirectory:b,toggleDirectory:w,onTreeItemClick:P,handleDirectoryListing:U,clearTreeNodes:E,initFileBrowser:()=>{let I=t();if(I){let T=s(I);a.value=I,l.value=T,E(),S(I)}},refresh:()=>{if(!l.value)return;let I=Object.entries(c).filter(([,T])=>T?.expanded).map(([T])=>T);I.includes(l.value)||I.unshift(l.value);for(let T of I)S(T)}}}var jh=B(()=>{});function Uh(e,{editorContainer:t,createEditor:s,t:n}){let r=Vue.ref(!0),i=Vue.ref(null),o=Vue.ref(null),a=Vue.computed(()=>{let v=e.value;return!!(v&&$s(v.name))}),l=Vue.computed(()=>{let v=e.value;if(!v||!$s(v.name)||v.content==null)return"";try{if(typeof marked<"u")return marked.parse(v.content)}catch{}return"<pre>"+(v.content||"")+"</pre>"});function c(){Wt(i.value)}async function d(){await Wt(i.value)}function u(){r.value=!1,Vue.nextTick(()=>{let v=e.value;v&&t.value&&s(v)})}let g=0,p=new WeakMap,f=(v,y)=>v===y||typeof Vue.toRaw=="function"&&Vue.toRaw(v)===Vue.toRaw(y);return{mdPreviewMode:r,mdPreviewRef:i,officePreviewContainer:o,isActiveMarkdown:a,mdRenderedHtml:l,initMermaid:c,renderMermaidBlocks:d,switchToMdEdit:u,renderOfficeLocal:async v=>{let y=o.value;if(!y||!v._arrayBuffer)return!1;let h=++g;p.set(v,h),v.previewLoading=!0;let k=y.ownerDocument||globalThis.document,S=k?.createElement?k.createElement("div"):{innerHTML:""},b=("."+v.name.split(".").pop()).toLowerCase(),w=null,P=()=>p.get(v)===h,x=()=>h===g&&P()&&f(e.value,v)&&o.value===y;try{if(b===".docx"&&window.docx)await window.docx.renderAsync(v._arrayBuffer,S,null,{className:"docx-preview-content",inWrapper:!0,ignoreWidth:!1,ignoreHeight:!0});else if(b===".xlsx"||b===".xls"){w=XLSX.read(v._arrayBuffer,{type:"array"});let Y=w.SheetNames[0],L=XLSX.utils.sheet_to_html(w.Sheets[Y],{editable:!1});S.innerHTML='<div class="xlsx-sheet-tabs">'+w.SheetNames.map((U,E)=>`<button class="xlsx-sheet-tab${E===0?" active":""}" data-idx="${E}">${U}</button>`).join("")+'</div><div class="xlsx-table-wrap">'+L+"</div>"}else(b===".pptx"||b===".ppt")&&(S.innerHTML='<div class="preview-unsupported">'+(n?n("files.pptxNotSupported"):"PowerPoint preview not supported")+"</div>");return x()?(typeof y.replaceChildren=="function"&&S.childNodes?y.replaceChildren(...S.childNodes):y.innerHTML=S.innerHTML,w&&y.querySelectorAll(".xlsx-sheet-tab").forEach(Y=>{Y.addEventListener("click",()=>{let L=parseInt(Y.dataset.idx),U=w.SheetNames[L],E=XLSX.utils.sheet_to_html(w.Sheets[U],{editable:!1});y.querySelector(".xlsx-table-wrap").innerHTML=E,y.querySelectorAll(".xlsx-sheet-tab").forEach(oe=>oe.classList.remove("active")),Y.classList.add("active")})}),!0):!1}catch(Y){return P()&&(v.previewError=Y.message),!1}finally{P()&&(v.previewLoading=!1)}}}}var Kh=B(()=>{di();hr()});function zh(e,{getEffectiveWorkDir:t,treePath:s,openFileInTab:n,normalizePath:r,treeRootPath:i,treeNodes:o,loadTreeDirectory:a}){let l=Vue.ref(""),c=Vue.ref([]),d=Vue.ref(!1),u=null,g=Vue.ref(!1),p=Vue.ref(""),f=Vue.ref([]),m=Vue.ref(0),v=Vue.ref(!1),y=Vue.ref(null),h=null,k=Vue.ref(!1),S=Vue.ref(""),b=Vue.ref(null),w=z=>{!e.currentAgent||!z.trim()||e.sendWsMessage({type:"file_search",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,query:z.trim(),dirPath:s.value||t()||"",_clientId:e.clientId})},P=()=>{if(u&&clearTimeout(u),!l.value.trim()){c.value=[],d.value=!1;return}d.value=!0,u=setTimeout(()=>{w(l.value)},300)},x=()=>{l.value="",c.value=[],d.value=!1},Y=z=>{if(z.type==="directory"){let Q=r(z.fullPath);i.value=Q,s.value=z.fullPath,Object.keys(o).forEach(ae=>delete o[ae]),a(z.fullPath),x()}else n(z.fullPath,z.name),x()},L=()=>{g.value=!0,p.value="",f.value=[],m.value=0,v.value=!1,Vue.nextTick(()=>y.value?.focus())},U=()=>{g.value=!1,p.value="",f.value=[]},E=()=>{if(h&&clearTimeout(h),!p.value.trim()){f.value=[],v.value=!1;return}v.value=!0,m.value=0,h=setTimeout(()=>{w(p.value)},200)},oe=()=>{f.value.length>0&&(m.value=(m.value+1)%f.value.length)},q=()=>{f.value.length>0&&(m.value=(m.value-1+f.value.length)%f.value.length)},I=z=>{z.type!=="directory"&&n(z.fullPath,z.name),U()},T=()=>{let z=f.value[m.value];z&&I(z)},R=()=>{k.value=!0,S.value="",Vue.nextTick(()=>b.value?.focus())},M=()=>{k.value=!1,S.value=""};return{searchQuery:l,searchResults:c,searchLoading:d,onSearchInput:P,clearSearch:x,onSearchResultClick:Y,quickOpenVisible:g,quickOpenQuery:p,quickOpenResults:f,quickOpenSelectedIndex:m,quickOpenLoading:v,quickOpenInput:y,openQuickOpen:L,closeQuickOpen:U,onQuickOpenInput:E,quickOpenSelectNext:oe,quickOpenSelectPrev:q,quickOpenConfirm:T,quickOpenOpenFile:I,goToLineVisible:k,goToLineValue:S,goToLineInput:b,openGoToLine:R,closeGoToLine:M,goToLineConfirm:z=>{let Q=parseInt(S.value);if(isNaN(Q)||Q<1)return;let ae=z.value;if(ae?.cmInstance){let ke=ae.cmInstance,N=Math.min(Q-1,ke.lineCount()-1);ke.setCursor({line:N,ch:0}),ke.scrollIntoView({line:N,ch:0},100),ke.focus()}M()},handleFileSearchResult:z=>{let Q=z.results||[];g.value?z.query&&z.query.trim()===p.value.trim()&&(f.value=Q,v.value=!1,m.value=0):z.query&&z.query.trim()===l.value.trim()&&(c.value=Q,d.value=!1)}}}var Yh=B(()=>{});function Gh(e,{getEffectiveWorkDir:t,treePath:s,treeRootPath:n,treeNodes:r,normalizePath:i,loadTreeDirectory:o}){let a=Vue.ref(!1),l=Vue.ref(""),c=Vue.ref([]),d=Vue.ref(!1),u=Vue.ref(""),g=()=>{a.value=!0,u.value="",d.value=!0;let k=s.value||t()||"";l.value=k,c.value=[],e.sendWsMessage({type:"list_directory",conversationId:"_folder_picker",agentId:e.currentAgent,dirPath:k,workDir:t(),_clientId:e.clientId})},p=k=>{d.value=!0,u.value="",e.sendWsMessage({type:"list_directory",conversationId:"_folder_picker",agentId:e.currentAgent,dirPath:k,workDir:t(),_clientId:e.clientId})};return{folderPickerOpen:a,folderPickerPath:l,folderPickerEntries:c,folderPickerLoading:d,folderPickerSelected:u,openFolderPicker:g,folderPickerNavigateUp:()=>{if(!l.value)return;let k=l.value.includes("\\"),S=k?"\\":"/",b=l.value.replace(/[/\\]$/,"").split(/[/\\]/);if(b.pop(),b.length===0)l.value="",p("");else if(k&&b.length===1&&/^[A-Za-z]:$/.test(b[0]))l.value=b[0]+"\\",p(b[0]+"\\");else{let w=b.join(S);l.value=w,p(w)}},folderPickerSelectItem:k=>{u.value=k.name},folderPickerEnter:k=>{let S;if(!l.value)S=k.name+(k.name.endsWith("\\")?"":"\\");else{let b=l.value.includes("\\")||/^[A-Z]:/.test(k.name)?"\\":"/";S=l.value.replace(/[/\\]$/,"")+b+k.name}l.value=S,p(S)},confirmFolderPicker:()=>{let k=l.value;if(!k)return;if(u.value){let b=k.includes("\\")?"\\":"/";k=k.replace(/[/\\]$/,"")+b+u.value}s.value=k,a.value=!1;let S=i(k);n.value=S,Object.keys(r).forEach(b=>delete r[b]),r[S]={entries:[],expanded:!0,loaded:!1,loading:!0},e.sendWsMessage({type:"list_directory",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,dirPath:k,workDir:t(),_clientId:e.clientId})},handleFolderPickerListing:k=>{d.value=!1,c.value=(k.entries||[]).filter(S=>S.type==="directory").sort((S,b)=>S.name.localeCompare(b.name)),k.dirPath!=null&&(l.value=k.dirPath)}}}var Qh=B(()=>{});function sa(e,t,s,{requestId:n=jc(),t:r=i=>i}={}){t.requestId=n,t.loading=!0,t.loadError=null,t.previewError=null,t.previewLoading=t.fileType!=="text",e.sendWsMessage({type:t.fileType==="video"?"video_metadata":"read_file",conversationId:t.conversationId,agentId:t.agentId,requestId:n,filePath:s,workDir:t.workDir,_clientId:e.clientId})===!1&&(t.loading=!1,t.previewLoading=!1,t.loadError=r("files.readSendFailed"),t.previewError=t.loadError)}function Xh(e,{normalizePath:t,getEffectiveWorkDir:s,editorContainer:n,createEditor:r,destroyEditor:i,clearFindMarkers:o,saveCurrentUndoHistory:a,saveAllUndoHistory:l,cleanupUndoHistory:c,deleteConversationHistory:d,mdPreviewMode:u,renderOfficeLocal:g,performFind:p,findBarVisible:f,findQuery:m,t:v}){let y=Vue.reactive({}),h=Vue.ref([]),k=Vue.ref(-1),S=Vue.ref(!1),b=Vue.ref(0),w=()=>{b.value+=1},P=0,x=null,Y=()=>{let se=`file-tabs-${Date.now()}-${++P}`;return x={requestId:se,tabRevision:b.value},se},L=se=>{let ve=x;return!ve||se!==ve.requestId?!1:(x=null,b.value===ve.tabRevision)},U=Vue.computed(()=>k.value>=0&&k.value<h.value.length?h.value[k.value]:null),E=Vue.computed(()=>!!U.value?.loading),oe=null,q=()=>{oe&&clearTimeout(oe),oe=setTimeout(()=>{e.sendWsMessage({type:"update_file_tabs",openFiles:h.value.map(se=>({path:se.path})),activeIndex:k.value})},500)},I=se=>{se&&(l(se),h.value.length>0?y[se]={files:h.value.map(ve=>({path:ve.path,name:ve.name,content:ve.content,originalContent:ve.originalContent,isDirty:ve.isDirty,fileType:ve.fileType,agentId:ve.agentId,conversationId:ve.conversationId,workDir:ve.workDir})),activeIndex:k.value}:delete y[se],q())},T=se=>{if(i(),!se||!y[se]){h.value.length>0&&w(),h.value=[],k.value=-1;return}let ve=y[se];h.value=ve.files.map(Ie=>({...Ie,isDirty:Ie.isDirty||!1,originalContent:Ie.originalContent||Ie.content,cmInstance:null,fileType:Ie.fileType||Xs(Ie.name||""),blobUrl:null,previewUrl:null,previewLoading:!1,localPreviewReady:!1,previewError:null,loading:!1,loadError:null})),w(),k.value=ve.activeIndex,Vue.nextTick(()=>{let Ie=U.value;Ie&&(!Ie.fileType||Ie.fileType==="text")&&n.value&&r(Ie)})},R=()=>{for(let se of h.value)se.loading&&(se.requestId=jc(),se.loading=!1,se.previewLoading=!1,se.loadError=v("files.readInterrupted"),se.previewError=se.loadError)},M=se=>!se.loading&&!se.isDirty&&(se.loadError||(!se.fileType||se.fileType==="text")&&se.content==null)&&(!se.fileType||se.fileType==="text"?se.content==null:!se.blobUrl&&!se.previewUrl&&!se.localPreviewReady);function $(se,ve,Ie={}){let ue=t(se),re=Ie.agentId||e.currentAgent||null,te=Ie.conversationId||e.currentConversation||"_explorer",V=Ie.workDir||s(),ce=h.value.findIndex(Re=>Re.path===ue&&(!Re.agentId||Re.agentId===re)&&(!Re.conversationId||Re.conversationId===te));if(ce>=0){k.value!==ce&&(o(),a(),k.value=ce,Vue.nextTick(()=>{let J=h.value[ce];J&&J.content!=null&&(!J.fileType||J.fileType==="text")&&r(J)}));let Re=h.value[ce];M(Re)&&sa(e,Re,se,{t:v}),I(e.currentConversation);return}a();let X=ve||ue.split(/[/\\]/).pop(),F=Xs(X);h.value.push({path:ue,name:X,agentId:re,conversationId:te,workDir:V,content:null,originalContent:null,isDirty:!1,cmInstance:null,fileType:F,blobUrl:null,previewUrl:null,previewLoading:F!=="text",localPreviewReady:!1,previewError:null,loading:!0,loadError:null}),w(),k.value=h.value.length-1,F==="text"&&i(),I(e.currentConversation);let Z=Ie.requestId||jc(),fe=h.value[k.value];fe&&sa(e,fe,se,{requestId:Z,t:v})}let j=se=>{se!==k.value&&(o(),a(),k.value=se,I(e.currentConversation),Vue.nextTick(()=>{let ve=h.value[se];ve&&(!ve.fileType||ve.fileType==="text"?$s(ve.name)?u.value=!0:ve.content!=null&&n.value&&(r(ve),f.value&&m.value&&Vue.nextTick(()=>p())):ve.fileType==="office"&&ve.localPreviewReady&&Vue.nextTick(()=>g(ve)))}))},z=async(se,{canCommit:ve=()=>!0}={})=>{let Ie=[...new Set(se)].filter(X=>Number.isInteger(X)&&X>=0&&X<h.value.length).sort((X,F)=>X-F);if(Ie.length===0)return!1;let ue=Ie.map(X=>h.value[X]),re=b.value,te=ue.filter(X=>X?.isDirty);if(te.length>0){let X=te.length===1?v("files.unsavedConfirm",{name:te[0].name}):v("files.unsavedBatchConfirm",{count:te.length});if(!await Be(X,{destructive:!0}))return!1}if(b.value!==re||!ve()||ue.some(X=>!h.value.includes(X)))return!1;let V=U.value,ce=V;if(ue.includes(V)){let X=h.value.indexOf(V);ce=h.value.slice(X+1).find(F=>!ue.includes(F))||h.value.slice(0,X).reverse().find(F=>!ue.includes(F))||null}for(let X of ue)c(X.conversationId||e.currentConversation,X.path),X.blobUrl?.startsWith?.("blob:")&&URL.revokeObjectURL(X.blobUrl);for(let X of ue){let F=h.value.indexOf(X);F>=0&&h.value.splice(F,1)}return w(),h.value.length===0?(k.value=-1,i()):k.value=Math.max(0,h.value.indexOf(ce)),I(e.currentConversation),V!==U.value&&U.value&&Vue.nextTick(()=>{let X=U.value;X&&(!X.fileType||X.fileType==="text")&&X.content!=null&&n.value&&r(X)}),!0},Q=(se,ve)=>z([se],ve),ae=(se,ve)=>z(h.value.map((Ie,ue)=>ue).filter(Ie=>Ie<se),ve),ke=(se,ve)=>z(h.value.map((Ie,ue)=>ue).filter(Ie=>Ie>se),ve),N=(se,ve)=>z(h.value.map((Ie,ue)=>ue).filter(Ie=>Ie!==se),ve),G=se=>z(h.value.map((ve,Ie)=>Ie),se);function de(){let se=U.value;if(!se||!se.isDirty||se.pendingSaveRequestId)return;S.value=!0;let ve=`file-save-${Date.now()}-${Math.random().toString(36).slice(2)}`;se.pendingSaveRequestId=ve,se.pendingSaveContent=se.content,e.sendWsMessage({type:"write_file",conversationId:se.conversationId||e.currentConversation||"_explorer",agentId:se.agentId||e.currentAgent,requestId:ve,filePath:se.path,content:se.content,workDir:se.workDir||s(),_clientId:e.clientId})}return{fileTabsMap:y,openFiles:h,activeFileIndex:k,activeFile:U,fileLoading:E,fileSaving:S,tabRevision:b,bumpTabRevision:w,beginTabsRestoreRequest:Y,acceptTabsRestoreRequest:L,saveTabsState:I,restoreTabsState:T,openFileInTab:$,interruptFileReads:R,switchToTab:j,closeFileTab:Q,closeFileTabs:z,closeTabsToLeft:ae,closeTabsToRight:ke,closeOtherTabs:N,closeAllTabs:G,saveFile:de,handleConversationDeleted:se=>{let{conversationId:ve}=se.detail;ve&&(delete y[ve],d(ve))}}}var jc,Uc=B(()=>{Ct();hr();jc=()=>`file-${Date.now()}-${Math.random().toString(36).slice(2)}`});function Zh({store:e,normalizePath:t,getEffectiveWorkDir:s,openFiles:n,activeFileIndex:r,activeFile:i,fileSaving:o,saveTabsState:a,createEditor:l,openFileInTab:c,bumpTabRevision:d=()=>{},acceptTabsRestoreRequest:u=()=>!1,tree:g,setTreeVisible:p,fp:f,qo:m,ops:v,mdPreviewMode:y,renderOfficeLocal:h,editorContainer:k,t:S=P=>P,routeKey:b="",workspaceGeneration:w=""}){let P=new Map,x=(U,E)=>{if(!U||!Number.isFinite(E)||E<=0)return;let oe=Math.max(0,Math.floor(E)-1),q=()=>{let I=U.cmInstance;return I?(I.setCursor({line:oe,ch:0}),I.scrollIntoView({line:oe,ch:0},80),I.focus(),!0):!1};Vue.nextTick(()=>{q()||setTimeout(q,180)})};return{handleWorkbenchMessage:U=>{let E=U.detail;if(!E||!tr(E,b,w))return;let oe=cs(E,b);switch(E.type){case"video_metadata":{let q=t(E.requestedFilePath||E.filePath),I=v.takePendingDownload(E.requestId);if(I){if(E.error||!E.videoStream||!E.previewUrl){v.showFileOpFeedback?.(!1,E.error||S("files.videoStreamUnavailable"));return}let R=t(I).split("/").pop()||"video",M=document.createElement("a"),$=new URL(E.previewUrl,`${location.protocol}//${location.host}`);$.searchParams.set("download","1"),M.href=$.href,M.download=R,document.body.appendChild(M),M.click(),document.body.removeChild(M);return}let T=n.value.find(R=>(E.requestId&&R.requestId?E.requestId===R.requestId:R.path===q)&&(!R.agentId||!E.agentId||R.agentId===E.agentId)&&(!R.conversationId||!E.conversationId||R.conversationId===E.conversationId));if(!T)return;if(T.loading=!1,E.error){T.loadError=E.error,T.previewLoading=!1,T.previewError=E.error;return}if(!E.videoStream||!E.previewUrl){T.loadError=S("files.videoStreamUnavailable"),T.previewLoading=!1,T.previewError=T.loadError;return}T.fileType="video",T.blobUrl=new URL(E.previewUrl,`${location.protocol}//${location.host}`).href,T.previewLoading=!0,T.previewError=null,a(e.currentConversation);break}case"directory_listing":{if(oe==="files-folder-picker"){f.handleFolderPickerListing(E);return}if(b&&oe!=="main")return;g.handleDirectoryListing(E);break}case"file_content":{let q=t(E.requestedFilePath||E.filePath),I=v.takePendingDownload(E.requestId);if(I){if(E.error){v.showFileOpFeedback?.(!1,E.error);return}try{let M=t(I).split("/").pop()||"download";if(E.binary){let $=`${location.protocol}//${location.host}/api/preview/${E.fileId}?token=${E.previewToken}&download=1`,j=document.createElement("a");j.href=$,j.download=M,document.body.appendChild(j),j.click(),document.body.removeChild(j)}else{let $=new Blob([E.content||""],{type:"application/octet-stream"}),j=URL.createObjectURL($),z=document.createElement("a");z.href=j,z.download=M,document.body.appendChild(z),z.click(),document.body.removeChild(z),URL.revokeObjectURL(j)}}catch{}return}let T=n.value.find(M=>(E.requestId&&M.requestId?E.requestId===M.requestId:M.path===q)&&(!M.agentId||!E.agentId||M.agentId===E.agentId)&&(!M.conversationId||!E.conversationId||M.conversationId===E.conversationId));if(!T)return;if(T.loading=!1,E.error){let M=E.errorCode==="FILE_PREVIEW_TOO_LARGE"?S("files.previewTooLarge",{size:((E.errorDetails?.sizeBytes||0)/1024/1024).toFixed(1),limit:((E.errorDetails?.limitBytes||20971520)/1024/1024).toFixed(0)}):E.error;T.loadError=M,T.previewLoading=!1,T.previewError=M;return}let R=n.value.indexOf(T);if(R>=0){let M=T;if(M.loadError=null,E.binary){let $=`${location.protocol}//${location.host}`,j=E.previewUrl?new URL(E.previewUrl,$).href:`${$}/api/preview/${E.fileId}?token=${E.previewToken}`,z=M.fileType||Xs(M.name);M.fileType=z,z==="pdf"||z==="image"?(M.blobUrl=j,M.previewError=null,M.previewLoading=z==="image"):z==="office"?(localStorage.getItem("officePreviewMode")||"local")==="online"?(M.previewUrl="https://view.officeapps.live.com/op/embed.aspx?src="+encodeURIComponent(j),M.previewLoading=!1):fetch(j).then(ae=>{if(!ae.ok)throw new Error(`Preview request failed (${ae.status})`);return ae.arrayBuffer()}).then(ae=>{M._arrayBuffer=ae,M.localPreviewReady=!0,R===r.value?Vue.nextTick(()=>{R===r.value?h(M):M.previewLoading=!1}):M.previewLoading=!1}).catch(ae=>{M.previewError=ae.message,M.previewLoading=!1}):M.previewLoading=!1,a(e.currentConversation);return}if(M.content=E.content||"",M.originalContent=E.content||"",M.isDirty=!1,a(e.currentConversation),R===r.value){$s(M.name)&&y.value||Vue.nextTick(()=>{setTimeout(()=>l(M),100)});let $=T.path,j=P.get($);P.delete($),x(M,j)}}break}case"file_saved":{let q=t(E.requestedFilePath||E.filePath),I=n.value.find(R=>R.path===q&&(!R.agentId||!E.agentId||R.agentId===E.agentId)&&(!R.conversationId||!E.conversationId||R.conversationId===E.conversationId));if(!I?.pendingSaveRequestId||E.requestId&&E.requestId!==I.pendingSaveRequestId)return;o.value=!1;let T=I.pendingSaveContent;if(delete I.pendingSaveRequestId,delete I.pendingSaveContent,E.error)return;I.originalContent=T??I.content,I.isDirty=I.content!==I.originalContent,a(I.conversationId||e.currentConversation);break}case"file_search_result":{m.handleFileSearchResult(E);break}case"file_op_result":{v.handleFileOpResult(E,g.loadTreeDirectory,g.treeRootPath.value);break}case"file_tabs_restored":{if(!u(E.restoreRequestId))return;if(E.openFiles?.length>0&&n.value.length===0){let q=E.activeIndex||0,I=E.openFiles.length;d();for(let T of E.openFiles){let R=t(T.path),M=R.split("/").pop(),$=Xs(M),j=e.currentAgent||null,z=e.currentConversation||"_explorer",Q=s();n.value.push({path:R,name:M,agentId:j,conversationId:z,workDir:Q,content:null,originalContent:null,isDirty:!1,cmInstance:null,fileType:$,blobUrl:null,previewUrl:null,previewLoading:$!=="text",localPreviewReady:!1,previewError:null,loading:!0,loadError:null}),sa(e,n.value.at(-1),T.path,{t:S})}r.value=q>=0&&q<I?q:0}break}}},handleOpenFile:U=>{let{filePath:E,agentId:oe=e.currentAgent,conversationId:q=e.currentConversation,workDir:I=s(),workbenchRouteKey:T=b,workspaceGeneration:R=w,hideTree:M=!1,line:$=null}=U.detail||{},j=t(E);!j||!oe||!q||b&&T!==b||w&&R!==w||(M&&typeof p=="function"&&p(!1),Number.isFinite($)&&$>0&&P.set(j,$),c(j,j.split("/").pop(),{agentId:oe,conversationId:q,workDir:I}),x(i.value,$))}}}var Jh=B(()=>{hr();Uc();As()});function na(e,t,s=""){let n=t?.currentTarget?.src||t?.target?.src;if(!e?.blobUrl||!n)return!1;let r=e.blobUrl;try{r=new URL(e.blobUrl,`${location.protocol}//${location.host}`).href}catch{}return n!==r?!1:(e.previewLoading=!1,e.previewError=s||null,!0)}function Zk({liveStore:e,props:t,tabs:s,isDisposed:n}){let r=d=>d.detail?.routeKey===t.routeKey&&d.detail?.workspaceGeneration===t.workspaceGeneration,i=(d,u)=>{let g=yt(e.activeSessionRoute),p=Tn(g,e.effectiveWorkDir);return!n()&&t.routeKey===d&&t.workspaceGeneration===u&&g===d&&p===u};return{isCurrentEvent:r,handleSelectFileItem:d=>{if(!r(d))return;let u=s.openFiles.value.findIndex(g=>g.path===d.detail.path);u>=0&&s.switchToTab(u)},handleCloseFileItem:async d=>{if(!r(d))return;let u=d.detail.routeKey,g=d.detail.workspaceGeneration,p=s.tabRevision.value,f=s.openFiles.value.find(y=>y.path===d.detail.path);if(!f)return;let m=()=>i(u,g)&&s.tabRevision.value===p&&s.openFiles.value.includes(f),v=s.openFiles.value.indexOf(f);v>=0&&await s.closeFileTab(v,{canCommit:m})},handleCloseFileItems:async d=>{if(!r(d)||typeof d.detail.resolve!="function")return;let u=d.detail.routeKey,g=d.detail.workspaceGeneration,p=s.tabRevision.value,f=new Set(Array.isArray(d.detail.paths)?d.detail.paths:[]),m=s.openFiles.value.filter(k=>f.has(k.path)),v=()=>i(u,g)&&s.tabRevision.value===p&&m.every(k=>s.openFiles.value.includes(k)),y=m.map(k=>s.openFiles.value.indexOf(k)).filter(k=>k>=0),h=y.length===0?v():await s.closeFileTabs(y,{canCommit:v});d.detail.resolve(h&&v())},handleCloseFilesCapability:async d=>{if(!r(d)||typeof d.detail.resolve!="function")return;let u=d.detail.routeKey,g=d.detail.workspaceGeneration,p=s.tabRevision.value,f=()=>i(u,g)&&s.tabRevision.value===p,m=s.openFiles.value.length===0?f():await s.closeAllTabs({canCommit:f});d.detail.resolve(m&&f()&&s.openFiles.value.length===0)}}}var em,tm=B(()=>{Wc();Vh();Nh();jh();hr();Kh();Yh();Qh();Uc();Jh();ai();As();em={name:"FilesTab",props:{treeInitiallyVisible:{type:Boolean,default:!0},routeKey:{type:String,required:!0},runtimeProvider:{type:String,required:!0},agentId:{type:String,required:!0},sessionId:{type:String,required:!0},conversationId:{type:String,required:!0},workDir:{type:String,default:""},workspaceGeneration:{type:String,required:!0}},template:`
2322
+ `,setup(e){let t=er(Pinia.useChatStore(),e),s=Vue.inject("t"),n=te=>te.split(/[/\\]/).pop()||te,r=te=>{let V=te.split(/[/\\]/);return V.pop(),V.join("/")},i=te=>ea(n(te)),o=Vue.ref(null),a=Vue.reactive({staged:!1,modified:!1,untracked:!1}),l=te=>{a[te]=!a[te]},c=Vue.ref(!1),d=Vue.ref(""),u=Vue.ref(null),g=Vue.ref([]),p=Vue.computed(()=>t.effectiveWorkDir||""),f=Vue.ref(""),m=Vue.computed(()=>f.value.trim()||p.value),v=Vue.ref(null),b=Vue.ref(!1),h=Vue.ref(!1),k=Vue.ref(""),S=Vue.ref(null),y=Vue.ref([]),w=Vue.ref(null),P=Vue.ref(!0),x=Vue.ref(!1),Y=Vue.ref(""),L=Vue.ref(null),U=Vue.ref(0),E=Vue.ref(0),oe=te=>te==null||te===""?"":Mh(te,v.value||""),q=Vue.ref(parseInt(localStorage.getItem("gitDiffFontSize"))||12),I=te=>{q.value=Math.max(8,Math.min(24,te)),localStorage.setItem("gitDiffFontSize",q.value.toString())},T=()=>I(q.value+1),R=()=>I(q.value-1),M=te=>{te.deltaY<0?T():te.deltaY>0&&R()},$=Vue.computed(()=>{let te=y.value;if(!te||te.length===0)return[];let V=te.length,ce=[],X=0;for(;X<V;){let F=te[X];if(F.type==="addition"||F.type==="deletion"||F.type==="modification"){let Z=F.type==="modification"?"modification":F.type,fe=X;for(;X<V&&(te[X].type===Z||te[X].type==="modification"&&Z!=="modification");)X++;let Re=X-fe;ce.push({type:Z,top:fe/V*100,height:Math.max(Re/V*100,.5)})}else X++}return ce}),j=te=>{let V=o.value;if(!V)return;let ce=te.currentTarget.getBoundingClientRect(),X=(te.clientY-ce.top)/ce.height;V.scrollTop=X*(V.scrollHeight-V.clientHeight)},z=Vue.computed(()=>g.value.filter(te=>te.indexStatus!==" "&&te.indexStatus!=="?")),Q=Vue.computed(()=>g.value.filter(te=>te.workTreeStatus==="M"||te.workTreeStatus==="D")),ae=Vue.computed(()=>g.value.filter(te=>te.indexStatus==="?"&&te.workTreeStatus==="?")),ke=Eh(t,{effectiveGitWorkDir:m,gitOperating:x,gitOpFeedback:L,commitMessage:Y}),N=()=>ke.loadGitStatus(c,d),G=()=>{N()},de=$h(t,m),we=te=>ta(te),se=()=>de.confirmFolderPicker(f,N),ve=(te,V)=>{v.value=te.path,b.value=V,h.value=!0,k.value="",S.value=null,y.value=[],w.value=null;let ce=te.indexStatus==="?"&&te.workTreeStatus==="?";t.sendWsMessage({type:"git_diff",conversationId:t.currentConversation||"_explorer",agentId:t.currentAgent,workDir:m.value,filePath:te.path,staged:V,untracked:ce,fullFile:P.value,_clientId:t.clientId})},Ie=()=>{if(P.value=!P.value,v.value){let te=g.value.find(V=>V.path===v.value);te&&ve(te,b.value)}},ue=te=>{let V=te.detail;if(!(!V||!tr(V,e.routeKey,e.workspaceGeneration)))switch(V.type){case"directory_listing":{cs(V,e.routeKey)==="git-folder-picker"&&de.handleDirectoryListing({...V,conversationId:"_git_folder_picker"});break}case"git_status_result":{if(e.routeKey&&cs(V,e.routeKey)!=="main")return;if(c.value=!1,V.error){d.value=V.error,u.value=null,g.value=[];return}if(d.value="",u.value=V.branch||"HEAD",g.value=V.files||[],U.value=V.ahead||0,E.value=V.behind||0,v.value){let ce=g.value.find(X=>X.path===v.value);if(ce){let X=ce.indexStatus!==" "&&ce.indexStatus!=="?";b.value=X}else v.value=null,S.value=null,y.value=[],w.value=null}break}case"git_diff_result":{if(e.routeKey&&cs(V,e.routeKey)!=="main")return;if(h.value=!1,V.error){k.value=V.error;return}k.value="";let ce=Rh(V.diff,V.newFileContent,s);w.value=ce.stats,y.value=ce.lines,S.value=ce.content;break}case"git_op_result":{if(e.routeKey&&cs(V,e.routeKey)!=="main")return;ke.handleGitOpResult(V,N);break}}};Vue.watch(()=>t.currentAgent,()=>{u.value=null,g.value=[],d.value="",v.value=null,S.value=null,t.currentAgent&&Vue.nextTick(()=>N())}),Vue.watch(()=>t.currentConversation,()=>{t.currentAgent&&(v.value=null,S.value=null,y.value=[],w.value=null,Vue.nextTick(()=>N()))});let re=()=>N();return Vue.onMounted(()=>{window.addEventListener("workbench-message",ue),t.currentAgent&&N()}),Vue.onUnmounted(()=>{window.removeEventListener("workbench-message",ue),ke.cleanup()}),{store:t,getFileName:n,getDirName:r,getFileIconHtml:i,hlLine:oe,collapsedGroups:a,toggleGroup:l,gitLoading:c,gitError:d,gitBranch:u,gitFiles:g,gitWorkDir:f,defaultWorkDir:p,changeGitWorkDir:G,stagedFiles:z,modifiedFiles:Q,untrackedFiles:ae,selectedGitFile:v,selectedStaged:b,diffLoading:h,diffError:k,diffContent:S,diffLines:y,diffStats:w,diffFullFile:P,toggleDiffMode:Ie,scrollMarkers:$,diffScrollContainer:o,onMarkerClick:j,fontSize:q,zoomIn:T,zoomOut:R,onWheel:M,gitOperating:x,commitMessage:Y,gitOpFeedback:L,gitAhead:U,gitBehind:E,stageFile:ke.stageFile,unstageFile:ke.unstageFile,discardFile:ke.discardFile,stageAll:ke.stageAll,unstageAll:ke.unstageAll,commitChanges:ke.commitChanges,pushChanges:ke.pushChanges,selectGitFile:ve,refresh:re,folderPickerOpen:de.folderPickerOpen,folderPickerPath:de.folderPickerPath,folderPickerEntries:de.folderPickerEntries,folderPickerLoading:de.folderPickerLoading,folderPickerSelected:de.folderPickerSelected,getFolderIcon:we,openFolderPicker:de.openFolderPicker,folderPickerNavigateUp:de.folderPickerNavigateUp,folderPickerSelectItem:de.folderPickerSelectItem,folderPickerEnter:de.folderPickerEnter,confirmFolderPicker:se}}}});function qh(e){let t=Vue.ref(!1),s=Vue.ref(!1),n=Vue.ref(""),r=Vue.ref(""),i=Vue.ref(!1),o=Vue.ref(!1),a=Vue.ref(0),l=Vue.ref(-1),c=Vue.ref(null),d=Vue.ref(null),u=[],g=[],p=()=>{let L=e.value?.cmInstance;if(!L)return;let E=L.getWrapperElement().querySelector(".cm-find-scrollbar-annotations");E&&E.remove()},f=()=>{let L=e.value?.cmInstance;if(!L||g.length===0)return;p();let U=L.getWrapperElement();if(!U.querySelector(".CodeMirror-vscrollbar"))return;let oe=L.lineCount();if(oe===0)return;let q=document.createElement("div");q.className="cm-find-scrollbar-annotations";for(let I of g){let T=I.from.line/oe*100,R=document.createElement("div");R.className="cm-find-scrollbar-tick",R.style.top=T+"%",q.appendChild(R)}U.appendChild(q)},m=()=>{for(let L of u)try{L.clear()}catch{}u=[],g=[],a.value=0,l.value=-1,p()},v=L=>{let U=e.value?.cmInstance;if(!U||!g[L])return;for(let oe=0;oe<u.length;oe++){if(!u[oe])continue;let q=u[oe].find();q&&(u[oe].clear(),u[oe]=U.markText(q.from,q.to,{className:"cm-find-highlight"}))}let E=g[L];if(u[L]){let oe=u[L].find();oe&&(u[L].clear(),u[L]=U.markText(oe.from,oe.to,{className:"cm-find-highlight cm-find-current"}))}setTimeout(()=>{U.scrollIntoView({from:E.from,to:E.to},100)},0)},b=()=>{m();let L=e.value?.cmInstance;if(!L||!n.value)return;let U=n.value;if(U.length<3)return;let E=L.getValue(),oe=i.value,q=o.value,I=[];try{if(q){let T=oe?"g":"gi",R=new RegExp(U,T),M;for(;(M=R.exec(E))!==null;){if(M[0].length===0){R.lastIndex++;continue}let $=L.posFromIndex(M.index),j=L.posFromIndex(M.index+M[0].length);if(I.push({from:$,to:j}),I.length>1e4)break}}else{let T=oe?U:U.toLowerCase(),R=oe?E:E.toLowerCase(),M=0;for(;(M=R.indexOf(T,M))!==-1;){let $=L.posFromIndex(M),j=L.posFromIndex(M+U.length);if(I.push({from:$,to:j}),M+=U.length,I.length>1e4)break}}}catch{return}g=I,a.value=I.length;for(let T of I)u.push(L.markText(T.from,T.to,{className:"cm-find-highlight"}));if(I.length>0){let T=L.getCursor(),R=0;for(let M=0;M<I.length;M++){if(CodeMirror.cmpPos(I[M].from,T)>=0){R=M;break}M===I.length-1&&(R=0)}l.value=R,v(R)}f()};return{findBarVisible:t,replaceBarVisible:s,findQuery:n,replaceQuery:r,findCaseSensitive:i,findUseRegex:o,findMatchCount:a,findMatchIndex:l,findInputRef:c,replaceInputRef:d,clearFindMarkers:m,performFind:b,onFindInput:()=>{b()},findNext:()=>{if(g.length===0)return;let L=(l.value+1)%g.length;l.value=L,v(L)},findPrev:()=>{if(g.length===0)return;let L=(l.value-1+g.length)%g.length;l.value=L,v(L)},openFindBar:(L=!1)=>{t.value=!0,s.value=L;let U=e.value?.cmInstance;if(U){let E=U.getSelection();E&&(n.value=E)}Vue.nextTick(()=>{c.value?.focus(),c.value?.select(),n.value&&b()})},closeFindBar:()=>{m(),t.value=!1,s.value=!1;let L=e.value?.cmInstance;L&&L.focus()},toggleReplaceBar:()=>{s.value=!s.value,s.value&&Vue.nextTick(()=>d.value?.focus())},replaceOne:()=>{let L=e.value?.cmInstance;if(!L||g.length===0||l.value<0)return;let U=g[l.value];L.replaceRange(r.value,U.from,U.to),b()},replaceAll:()=>{let L=e.value?.cmInstance;!L||g.length===0||(L.operation(()=>{for(let U=g.length-1;U>=0;U--)L.replaceRange(r.value,g[U].from,g[U].to)}),b())}}}var Vh=B(()=>{});function Xs(e){let t=e.lastIndexOf(".");if(t<0)return"text";let s=e.substring(t).toLowerCase();return Kk.has(s)?"office":zk.has(s)?"pdf":Yk.has(s)?"image":Gk.has(s)?"video":"text"}function $s(e){let t=e.lastIndexOf(".");return t<0?!1:Qk.has(e.substring(t).toLowerCase())}function Xk(e){let t=e.split(".").pop()?.toLowerCase();return{js:"javascript",mjs:"javascript",jsx:"javascript",ts:{name:"javascript",typescript:!0},tsx:{name:"javascript",typescript:!0},json:{name:"javascript",json:!0},py:"python",html:"htmlmixed",htm:"htmlmixed",vue:"htmlmixed",xml:"xml",svg:"xml",css:"css",scss:"css",less:"css",sh:"shell",bash:"shell",zsh:"shell",c:"text/x-csrc",h:"text/x-csrc",cpp:"text/x-c++src",hpp:"text/x-c++src",cs:"text/x-csharp",java:"text/x-java",md:"markdown",markdown:"markdown"}[t]||"text/plain"}function Hh(e,{activeFile:t,editorContainer:s,fontSize:n,clearFindMarkers:r,openFindBar:i,saveFile:o}){let a=Vue.ref(""),l=Vue.reactive({}),c=()=>{},d=()=>{},u=({openQuickOpen:h,openGoToLine:k})=>{c=h,d=k},g=(h,k=0)=>{if(!s.value){k<20&&setTimeout(()=>g(h,k+1),100);return}if(!h)return;if(s.value.innerHTML="",typeof CodeMirror>"u"){let w=document.createElement("textarea");w.value=h.content||"",w.style.cssText="width:100%;height:100%;border:none;outline:none;resize:none;padding:12px;font-family:monospace;font-size:12px;background:var(--bg-main);color:var(--text-main);white-space:pre;tab-size:4;",w.spellcheck=!1,w.addEventListener("input",()=>{h.content=w.value,h.isDirty=w.value!==h.originalContent}),w.addEventListener("keydown",P=>{(P.ctrlKey||P.metaKey)&&P.key==="s"&&(P.preventDefault(),o())}),s.value.appendChild(w),a.value="";return}let y=document.documentElement.getAttribute("data-theme")==="dark"?"material-darker":"default";try{let w=CodeMirror(s.value,{value:h.content||"",mode:Xk(h.name),theme:y,lineNumbers:!0,tabSize:4,indentWithTabs:!1,lineWrapping:!1,readOnly:!1,extraKeys:{"Ctrl-S":()=>o(),"Cmd-S":()=>o(),"Ctrl-P":()=>c(),"Cmd-P":()=>c(),"Ctrl-G":()=>d(),"Cmd-G":()=>d(),"Ctrl-F":()=>i(!1),"Cmd-F":()=>i(!1),"Ctrl-R":()=>i(!0),"Cmd-R":()=>i(!0),"Ctrl-H":()=>i(!0),"Cmd-H":()=>i(!0)}});w.on("change",()=>{let x=w.getValue();h.content=x,h.isDirty=x!==h.originalContent}),h.cmInstance=w,w.getWrapperElement().style.fontSize=n.value+"px";let P=e.currentConversation;P&&l[P]?.[h.path]&&w.setHistory(l[P][h.path]),Vue.nextTick(()=>{w.refresh(),setTimeout(()=>w.refresh(),200)}),a.value=""}catch(w){a.value=`Editor error: ${w.message}`}};return{debugStatus:a,undoHistoryMap:l,createEditor:g,destroyEditor:()=>{r();let h=t.value;h?.cmInstance&&(h.cmInstance.toTextArea&&h.cmInstance.toTextArea(),h.cmInstance=null),s.value&&(s.value.innerHTML="")},setKeyBindings:u,saveCurrentUndoHistory:()=>{let h=e.currentConversation;if(!h)return;let k=t.value;k?.cmInstance&&(l[h]||(l[h]={}),l[h][k.path]=k.cmInstance.getHistory())},saveAllUndoHistory:h=>{if(!h)return;let k=t.value;k?.cmInstance&&(l[h]||(l[h]={}),l[h][k.path]=k.cmInstance.getHistory())},cleanupUndoHistory:(h,k)=>{h&&l[h]&&delete l[h][k]},deleteConversationHistory:h=>{delete l[h]}}}var Kk,zk,Yk,Gk,Qk,hr=B(()=>{Kk=new Set([".docx",".xlsx",".xls",".pptx",".ppt"]),zk=new Set([".pdf"]),Yk=new Set([".png",".jpg",".jpeg",".gif",".webp",".bmp",".ico"]),Gk=new Set([".mp4",".m4v",".webm",".ogv",".ogg",".mov"]),Qk=new Set([".md",".markdown",".mdx"])});function Bh(e,t){let{getEffectiveWorkDir:s,treePath:n}=t,r=Vue.reactive(new Set),i=Vue.ref(-1),o=Vue.ref(!1),a=Vue.ref(null),l=null,c=null,d=Vue.ref(!1),u=Vue.ref(""),g=Vue.ref("file"),p=Vue.ref(null),f=Vue.ref(!1),m=Vue.ref(""),v=Vue.ref(null),b=Vue.reactive({visible:!1,x:0,y:0,entry:null}),h=Vue.ref(!1),k=Vue.ref(""),S=Vue.ref(null),y=new Map,w=Vue.reactive({dragging:null,dropTarget:null}),P=Vue.ref(!1),x=(F,Z)=>{l&&clearTimeout(l),a.value={ok:F,message:Z},l=setTimeout(()=>{a.value=null},4e3)},Y=()=>{o.value=!0,c&&clearTimeout(c),c=setTimeout(()=>{o.value&&(o.value=!1,x(!1,"Operation timed out"))},15e3)},L=F=>{r.has(F)?r.delete(F):r.add(F)},U=()=>{r.clear(),i.value=-1},E=F=>{g.value=F,u.value="",d.value=!0,Vue.nextTick(()=>p.value?.focus())},oe=()=>{let F=u.value.trim();if(!F)return;d.value=!1;let Z=n.value||s();if(!Z)return;let fe=Z.includes("\\")?"\\":"/",Re=Z.replace(/[/\\]$/,"")+fe+F;Y(),e.sendWsMessage({type:"create_file",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,filePath:Re,isDirectory:g.value==="directory",workDir:s(),_clientId:e.clientId})},q=async(F,Z)=>{let fe=F.path.split("/").pop();await Be(Z("files.deleteConfirm",{name:fe})+(F.type==="directory"?Z("files.deleteDirHint"):""),{destructive:!0})&&(Y(),e.sendWsMessage({type:"delete_files",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,paths:[F.path],workDir:s(),_clientId:e.clientId}))},I=async F=>{let Z=r.size;Z!==0&&await Be(F("files.deleteSelectedConfirm",{count:Z}),{destructive:!0})&&(Y(),e.sendWsMessage({type:"delete_files",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,paths:[...r],workDir:s(),_clientId:e.clientId}))},T=()=>{m.value=n.value||s()||"",f.value=!0,Vue.nextTick(()=>v.value?.focus())},R=()=>{let F=m.value.trim();!F||r.size===0||(f.value=!1,Y(),e.sendWsMessage({type:"move_files",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,paths:[...r],destination:F,workDir:s(),_clientId:e.clientId}))},M=(F,Z)=>{let J=F.clientX,D=F.clientY;J+180>window.innerWidth&&(J=window.innerWidth-180),D+240>window.innerHeight&&(D=window.innerHeight-240),b.entry=Z,b.x=J,b.y=D,b.visible=!0},$=()=>{b.visible=!1},j=()=>{let F=b.entry;$(),F&&(k.value=F.name,h.value=!0,Vue.nextTick(()=>{let Z=S.value;if(Z)if(Z.focus(),F.type==="file"){let fe=F.name.lastIndexOf(".");fe>0?Z.setSelectionRange(0,fe):Z.select()}else Z.select()}))},z=()=>{let F=b.entry,Z=k.value.trim();if(!Z||!F||Z===F.name){h.value=!1;return}h.value=!1;let fe=F.path.replace(/\/$/,"").split("/");fe.pop();let Re=fe.join("/")||"/";Y(),e.sendWsMessage({type:"move_files",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,paths:[F.path],destination:Re,newName:Z,workDir:s(),_clientId:e.clientId})},Q=()=>{let F=b.entry;if($(),!F)return;let Z=F.path.replace(/\/$/,"").split("/");Z.pop();let fe=Z.join("/")||"/";Y(),e.sendWsMessage({type:"copy_files",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,paths:[F.path],destination:fe,workDir:s(),_clientId:e.clientId})},ae=()=>{let F=b.entry;$(),F&&(r.clear(),r.add(F.path),T())},ke=F=>{let Z=b.entry;$(),Z&&q(Z,F)},N=F=>{if(!F?.path)return;let Z=`file-download-${Date.now()}-${Math.random().toString(36).slice(2)}`;y.set(Z,F.path),e.sendWsMessage({type:Xs(F.path)==="video"?"video_metadata":"read_file",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,requestId:Z,download:!0,filePath:F.path,workDir:s(),_clientId:e.clientId})};return{selectedPaths:r,lastClickedIndex:i,fileOperating:o,fileOpFeedback:a,newFileDialogVisible:d,newFileName:u,newFileType:g,newFileInput:p,moveDialogVisible:f,moveDestination:m,moveDestInput:v,contextMenu:b,renameDialogVisible:h,renameNewName:k,renameInput:S,dragState:w,externalDropActive:P,showFileOpFeedback:x,toggleSelection:L,clearSelection:U,showNewFileDialog:E,confirmNewFile:oe,deleteSingleFile:q,deleteSelected:I,openMoveDialog:T,confirmMove:R,showContextMenu:M,hideContextMenu:$,ctxRename:j,confirmRename:z,ctxCopy:Q,ctxMoveTo:ae,ctxDelete:ke,ctxDownload:()=>{let F=b.entry;$(),!(!F||F.type!=="file")&&N(F)},downloadFile:N,onDragStart:(F,Z)=>{w.dragging=Z,F.dataTransfer.setData("text/plain",Z.path),F.dataTransfer.effectAllowed="move"},onDragOver:(F,Z)=>{if(!w.dragging&&F.dataTransfer.types.includes("Files")){Z.type==="directory"&&(F.dataTransfer.dropEffect="copy",w.dropTarget=Z.path);return}!w.dragging||Z.type!=="directory"||Z.path!==w.dragging.path&&(Z.path.startsWith(w.dragging.path+"/")||(F.dataTransfer.dropEffect="move",w.dropTarget=Z.path))},onDragLeave:F=>{let Z=F.relatedTarget;Z&&F.currentTarget.contains(Z)||(w.dropTarget=null)},onDrop:(F,Z,fe)=>{if(w.dropTarget=null,!w.dragging&&F.dataTransfer.files.length>0&&Z.type==="directory"){fe(F.dataTransfer.files,Z.path);return}if(!w.dragging||Z.type!=="directory"){w.dragging=null;return}if(Z.path===w.dragging.path){w.dragging=null;return}Y(),e.sendWsMessage({type:"move_files",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,paths:[w.dragging.path],destination:Z.path,workDir:s(),_clientId:e.clientId}),w.dragging=null},onTreeDragOver:F=>{w.dragging||F.dataTransfer.types.includes("Files")&&(F.dataTransfer.dropEffect="copy",P.value=!0)},onTreeDragLeave:F=>{let Z=F.relatedTarget;Z&&F.currentTarget.contains(Z)||(P.value=!1)},onTreeDrop:(F,Z,fe)=>{if(P.value=!1,!w.dragging&&F.dataTransfer.files.length>0){let Re=n.value||Z||s();fe(F.dataTransfer.files,Re)}},handleExternalFileDrop:async(F,Z)=>{if(!Z)return;let fe=[],Re=[];for(let J of F)Re.push(new Promise(D=>{let ye=new FileReader;ye.onload=()=>{let Me=btoa(new Uint8Array(ye.result).reduce((ze,Ye)=>ze+String.fromCharCode(Ye),""));fe.push({name:J.name,data:Me}),D()},ye.onerror=()=>D(),ye.readAsArrayBuffer(J)}));await Promise.all(Re),fe.length!==0&&(o.value=!0,c&&clearTimeout(c),c=setTimeout(()=>{o.value&&(o.value=!1,x(!1,"Upload timed out"))},3e4),e.sendWsMessage({type:"upload_to_dir",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,files:fe,dirPath:Z,workDir:s(),_clientId:e.clientId}))},handleFileOpResult:(F,Z,fe)=>{o.value=!1,c&&(clearTimeout(c),c=null),x(F.success,F.success?F.message:F.error||"Operation failed"),F.success&&(fe&&Z(fe),(F.operation==="delete"||F.operation==="move")&&(r.clear(),i.value=-1))},takePendingDownload:F=>{if(!F||!y.has(F))return null;let Z=y.get(F);return y.delete(F),Z},cleanup:()=>{l&&clearTimeout(l),c&&clearTimeout(c),y.clear()}}}var Nh=B(()=>{Ct();hr()});function Wh(e,{getEffectiveWorkDir:t,normalizePath:s,selectedPaths:n,lastClickedIndex:r,openFileInTab:i,clearSelection:o}){let a=Vue.ref(""),l=Vue.ref(""),c=Vue.reactive({}),d=new Map,u=0,g=I=>{let T=`files-tree-${++u}`;return d.set(I,T),T},p=Vue.ref(!1),f=Vue.ref(null),m=Vue.computed(()=>{if(!l.value)return"EXPLORER";let I=l.value.replace(/[\\/]+$/,"").split(/[\\/]/);return(I[I.length-1]||l.value).toUpperCase()}),v=()=>{p.value=!0,Vue.nextTick(()=>f.value?.focus())},b=()=>{p.value=!1,y()},h=()=>{p.value=!1},k=Vue.computed(()=>{let I=[],T=(R,M)=>{let $=c[R];if(!(!$||!$.entries))for(let j of $.entries)I.push({...j,depth:M}),j.type==="directory"&&c[j.path]?.expanded&&T(j.path,M+1)};return l.value&&c[l.value]?.expanded&&T(l.value,0),I}),S=I=>{let T=s(I);c[T]?c[T].loading=!0:c[T]={entries:[],expanded:!0,loaded:!1,loading:!0},e.sendWsMessage({type:"list_directory",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,requestId:g(T),dirPath:I,workDir:t(),_clientId:e.clientId})},y=()=>{let I=a.value.trim();if(!I)return;let T=s(I);l.value=T,Object.keys(c).forEach(R=>delete c[R]),d.clear(),c[T]={entries:[],expanded:!0,loaded:!1,loading:!0},e.sendWsMessage({type:"list_directory",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,requestId:g(T),dirPath:I,workDir:t(),_clientId:e.clientId})},w=I=>{let T=s(I),R=c[T];R?R.loaded?R.expanded=!R.expanded:(R.expanded=!0,S(I)):(c[T]={entries:[],expanded:!0,loaded:!1,loading:!1},S(I))},P=(I,T)=>{let R=k.value,M=R.findIndex($=>$.path===I.path);if(T&&(T.shiftKey||T.ctrlKey||T.metaKey)){if(T.shiftKey&&r.value>=0&&M>=0){let $=Math.min(r.value,M),j=Math.max(r.value,M);!T.ctrlKey&&!T.metaKey&&n.clear();for(let z=$;z<=j;z++)n.add(R[z].path)}else n.has(I.path)?n.delete(I.path):n.add(I.path);r.value=M;return}n.size>0&&(n.clear(),r.value=-1),I.type==="directory"?w(I.path):i(I.path,I.name),r.value=M},x=I=>{let T=`${I.replace(/\/$/,"")}/`;for(let R of Object.keys(c))(R===I||R.startsWith(T))&&delete c[R];for(let R of d.keys())(R===I||R.startsWith(T))&&d.delete(R);for(let R of Object.values(c))R?.entries&&(R.entries=R.entries.filter(M=>M.path!==I))},Y=I=>typeof I=="string"&&/(?:ENOENT|not\s+(?:exist|found)|no such file)/i.test(I),L=I=>I===l.value?!0:Object.values(c).some(T=>T?.entries?.some(R=>R.type==="directory"&&R.path===I)),U=I=>{let T=s(I.dirPath),R=d.get(T);if(R&&I.requestId!==R||!R&&I.requestId)return;if(R&&d.delete(T),!L(T)){x(T);return}if(I.error){if(Y(I.error))if(T===l.value){for(let Q of c[T]?.entries||[])Q.type==="directory"&&x(Q.path);c[T]&&(c[T].entries=[],c[T].loaded=!0,c[T].loading=!1)}else x(T);else c[T]&&(c[T].loading=!1);return}let M=(I.entries||[]).sort((Q,ae)=>Q.type===ae.type?Q.name.localeCompare(ae.name):Q.type==="directory"?-1:1),$=T.replace(/\/$/,""),j=M.map(Q=>({...Q,path:$+"/"+Q.name})),z=new Set(j.filter(Q=>Q.type==="directory").map(Q=>Q.path));for(let Q of c[T]?.entries||[])Q.type==="directory"&&!z.has(Q.path)&&x(Q.path);c[T]?(c[T].entries=j,c[T].loaded=!0,c[T].loading=!1):c[T]={entries:j,expanded:!0,loaded:!0,loading:!1},T===l.value&&(a.value=I.dirPath)},E=()=>{Object.keys(c).forEach(I=>delete c[I]),d.clear()};return{treePath:a,treeRootPath:l,treeNodes:c,flattenedTree:k,editingTreePath:p,treePathInputRef:f,rootFolderName:m,startTreePathEdit:v,confirmTreePath:b,cancelTreePathEdit:h,loadTreeDirectory:S,loadRootDirectory:y,toggleDirectory:w,onTreeItemClick:P,handleDirectoryListing:U,clearTreeNodes:E,initFileBrowser:()=>{let I=t();if(I){let T=s(I);a.value=I,l.value=T,E(),S(I)}},refresh:()=>{if(!l.value)return;let I=Object.entries(c).filter(([,T])=>T?.expanded).map(([T])=>T);I.includes(l.value)||I.unshift(l.value);for(let T of I)S(T)}}}var jh=B(()=>{});function Uh(e,{editorContainer:t,createEditor:s,t:n}){let r=Vue.ref(!0),i=Vue.ref(null),o=Vue.ref(null),a=Vue.computed(()=>{let v=e.value;return!!(v&&$s(v.name))}),l=Vue.computed(()=>{let v=e.value;if(!v||!$s(v.name)||v.content==null)return"";try{if(typeof marked<"u")return marked.parse(v.content)}catch{}return"<pre>"+(v.content||"")+"</pre>"});function c(){Wt(i.value)}async function d(){await Wt(i.value)}function u(){r.value=!1,Vue.nextTick(()=>{let v=e.value;v&&t.value&&s(v)})}let g=0,p=new WeakMap,f=(v,b)=>v===b||typeof Vue.toRaw=="function"&&Vue.toRaw(v)===Vue.toRaw(b);return{mdPreviewMode:r,mdPreviewRef:i,officePreviewContainer:o,isActiveMarkdown:a,mdRenderedHtml:l,initMermaid:c,renderMermaidBlocks:d,switchToMdEdit:u,renderOfficeLocal:async v=>{let b=o.value;if(!b||!v._arrayBuffer)return!1;let h=++g;p.set(v,h),v.previewLoading=!0;let k=b.ownerDocument||globalThis.document,S=k?.createElement?k.createElement("div"):{innerHTML:""},y=("."+v.name.split(".").pop()).toLowerCase(),w=null,P=()=>p.get(v)===h,x=()=>h===g&&P()&&f(e.value,v)&&o.value===b;try{if(y===".docx"&&window.docx)await window.docx.renderAsync(v._arrayBuffer,S,null,{className:"docx-preview-content",inWrapper:!0,ignoreWidth:!1,ignoreHeight:!0});else if(y===".xlsx"||y===".xls"){w=XLSX.read(v._arrayBuffer,{type:"array"});let Y=w.SheetNames[0],L=XLSX.utils.sheet_to_html(w.Sheets[Y],{editable:!1});S.innerHTML='<div class="xlsx-sheet-tabs">'+w.SheetNames.map((U,E)=>`<button class="xlsx-sheet-tab${E===0?" active":""}" data-idx="${E}">${U}</button>`).join("")+'</div><div class="xlsx-table-wrap">'+L+"</div>"}else(y===".pptx"||y===".ppt")&&(S.innerHTML='<div class="preview-unsupported">'+(n?n("files.pptxNotSupported"):"PowerPoint preview not supported")+"</div>");return x()?(typeof b.replaceChildren=="function"&&S.childNodes?b.replaceChildren(...S.childNodes):b.innerHTML=S.innerHTML,w&&b.querySelectorAll(".xlsx-sheet-tab").forEach(Y=>{Y.addEventListener("click",()=>{let L=parseInt(Y.dataset.idx),U=w.SheetNames[L],E=XLSX.utils.sheet_to_html(w.Sheets[U],{editable:!1});b.querySelector(".xlsx-table-wrap").innerHTML=E,b.querySelectorAll(".xlsx-sheet-tab").forEach(oe=>oe.classList.remove("active")),Y.classList.add("active")})}),!0):!1}catch(Y){return P()&&(v.previewError=Y.message),!1}finally{P()&&(v.previewLoading=!1)}}}}var Kh=B(()=>{di();hr()});function zh(e,{getEffectiveWorkDir:t,treePath:s,openFileInTab:n,normalizePath:r,treeRootPath:i,treeNodes:o,loadTreeDirectory:a}){let l=Vue.ref(""),c=Vue.ref([]),d=Vue.ref(!1),u=null,g=Vue.ref(!1),p=Vue.ref(""),f=Vue.ref([]),m=Vue.ref(0),v=Vue.ref(!1),b=Vue.ref(null),h=null,k=Vue.ref(!1),S=Vue.ref(""),y=Vue.ref(null),w=z=>{!e.currentAgent||!z.trim()||e.sendWsMessage({type:"file_search",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,query:z.trim(),dirPath:s.value||t()||"",_clientId:e.clientId})},P=()=>{if(u&&clearTimeout(u),!l.value.trim()){c.value=[],d.value=!1;return}d.value=!0,u=setTimeout(()=>{w(l.value)},300)},x=()=>{l.value="",c.value=[],d.value=!1},Y=z=>{if(z.type==="directory"){let Q=r(z.fullPath);i.value=Q,s.value=z.fullPath,Object.keys(o).forEach(ae=>delete o[ae]),a(z.fullPath),x()}else n(z.fullPath,z.name),x()},L=()=>{g.value=!0,p.value="",f.value=[],m.value=0,v.value=!1,Vue.nextTick(()=>b.value?.focus())},U=()=>{g.value=!1,p.value="",f.value=[]},E=()=>{if(h&&clearTimeout(h),!p.value.trim()){f.value=[],v.value=!1;return}v.value=!0,m.value=0,h=setTimeout(()=>{w(p.value)},200)},oe=()=>{f.value.length>0&&(m.value=(m.value+1)%f.value.length)},q=()=>{f.value.length>0&&(m.value=(m.value-1+f.value.length)%f.value.length)},I=z=>{z.type!=="directory"&&n(z.fullPath,z.name),U()},T=()=>{let z=f.value[m.value];z&&I(z)},R=()=>{k.value=!0,S.value="",Vue.nextTick(()=>y.value?.focus())},M=()=>{k.value=!1,S.value=""};return{searchQuery:l,searchResults:c,searchLoading:d,onSearchInput:P,clearSearch:x,onSearchResultClick:Y,quickOpenVisible:g,quickOpenQuery:p,quickOpenResults:f,quickOpenSelectedIndex:m,quickOpenLoading:v,quickOpenInput:b,openQuickOpen:L,closeQuickOpen:U,onQuickOpenInput:E,quickOpenSelectNext:oe,quickOpenSelectPrev:q,quickOpenConfirm:T,quickOpenOpenFile:I,goToLineVisible:k,goToLineValue:S,goToLineInput:y,openGoToLine:R,closeGoToLine:M,goToLineConfirm:z=>{let Q=parseInt(S.value);if(isNaN(Q)||Q<1)return;let ae=z.value;if(ae?.cmInstance){let ke=ae.cmInstance,N=Math.min(Q-1,ke.lineCount()-1);ke.setCursor({line:N,ch:0}),ke.scrollIntoView({line:N,ch:0},100),ke.focus()}M()},handleFileSearchResult:z=>{let Q=z.results||[];g.value?z.query&&z.query.trim()===p.value.trim()&&(f.value=Q,v.value=!1,m.value=0):z.query&&z.query.trim()===l.value.trim()&&(c.value=Q,d.value=!1)}}}var Yh=B(()=>{});function Gh(e,{getEffectiveWorkDir:t,treePath:s,treeRootPath:n,treeNodes:r,normalizePath:i,loadTreeDirectory:o}){let a=Vue.ref(!1),l=Vue.ref(""),c=Vue.ref([]),d=Vue.ref(!1),u=Vue.ref(""),g=()=>{a.value=!0,u.value="",d.value=!0;let k=s.value||t()||"";l.value=k,c.value=[],e.sendWsMessage({type:"list_directory",conversationId:"_folder_picker",agentId:e.currentAgent,dirPath:k,workDir:t(),_clientId:e.clientId})},p=k=>{d.value=!0,u.value="",e.sendWsMessage({type:"list_directory",conversationId:"_folder_picker",agentId:e.currentAgent,dirPath:k,workDir:t(),_clientId:e.clientId})};return{folderPickerOpen:a,folderPickerPath:l,folderPickerEntries:c,folderPickerLoading:d,folderPickerSelected:u,openFolderPicker:g,folderPickerNavigateUp:()=>{if(!l.value)return;let k=l.value.includes("\\"),S=k?"\\":"/",y=l.value.replace(/[/\\]$/,"").split(/[/\\]/);if(y.pop(),y.length===0)l.value="",p("");else if(k&&y.length===1&&/^[A-Za-z]:$/.test(y[0]))l.value=y[0]+"\\",p(y[0]+"\\");else{let w=y.join(S);l.value=w,p(w)}},folderPickerSelectItem:k=>{u.value=k.name},folderPickerEnter:k=>{let S;if(!l.value)S=k.name+(k.name.endsWith("\\")?"":"\\");else{let y=l.value.includes("\\")||/^[A-Z]:/.test(k.name)?"\\":"/";S=l.value.replace(/[/\\]$/,"")+y+k.name}l.value=S,p(S)},confirmFolderPicker:()=>{let k=l.value;if(!k)return;if(u.value){let y=k.includes("\\")?"\\":"/";k=k.replace(/[/\\]$/,"")+y+u.value}s.value=k,a.value=!1;let S=i(k);n.value=S,Object.keys(r).forEach(y=>delete r[y]),r[S]={entries:[],expanded:!0,loaded:!1,loading:!0},e.sendWsMessage({type:"list_directory",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,dirPath:k,workDir:t(),_clientId:e.clientId})},handleFolderPickerListing:k=>{d.value=!1,c.value=(k.entries||[]).filter(S=>S.type==="directory").sort((S,y)=>S.name.localeCompare(y.name)),k.dirPath!=null&&(l.value=k.dirPath)}}}var Qh=B(()=>{});function sa(e,t,s,{requestId:n=jc(),t:r=i=>i}={}){t.requestId=n,t.loading=!0,t.loadError=null,t.previewError=null,t.previewLoading=t.fileType!=="text",e.sendWsMessage({type:t.fileType==="video"?"video_metadata":"read_file",conversationId:t.conversationId,agentId:t.agentId,requestId:n,filePath:s,workDir:t.workDir,_clientId:e.clientId})===!1&&(t.loading=!1,t.previewLoading=!1,t.loadError=r("files.readSendFailed"),t.previewError=t.loadError)}function Xh(e,{normalizePath:t,getEffectiveWorkDir:s,editorContainer:n,createEditor:r,destroyEditor:i,clearFindMarkers:o,saveCurrentUndoHistory:a,saveAllUndoHistory:l,cleanupUndoHistory:c,deleteConversationHistory:d,mdPreviewMode:u,renderOfficeLocal:g,performFind:p,findBarVisible:f,findQuery:m,t:v}){let b=Vue.reactive({}),h=Vue.ref([]),k=Vue.ref(-1),S=Vue.ref(!1),y=Vue.ref(0),w=()=>{y.value+=1},P=0,x=null,Y=()=>{let se=`file-tabs-${Date.now()}-${++P}`;return x={requestId:se,tabRevision:y.value},se},L=se=>{let ve=x;return!ve||se!==ve.requestId?!1:(x=null,y.value===ve.tabRevision)},U=Vue.computed(()=>k.value>=0&&k.value<h.value.length?h.value[k.value]:null),E=Vue.computed(()=>!!U.value?.loading),oe=null,q=()=>{oe&&clearTimeout(oe),oe=setTimeout(()=>{e.sendWsMessage({type:"update_file_tabs",openFiles:h.value.map(se=>({path:se.path})),activeIndex:k.value})},500)},I=se=>{se&&(l(se),h.value.length>0?b[se]={files:h.value.map(ve=>({path:ve.path,name:ve.name,content:ve.content,originalContent:ve.originalContent,isDirty:ve.isDirty,fileType:ve.fileType,agentId:ve.agentId,conversationId:ve.conversationId,workDir:ve.workDir})),activeIndex:k.value}:delete b[se],q())},T=se=>{if(i(),!se||!b[se]){h.value.length>0&&w(),h.value=[],k.value=-1;return}let ve=b[se];h.value=ve.files.map(Ie=>({...Ie,isDirty:Ie.isDirty||!1,originalContent:Ie.originalContent||Ie.content,cmInstance:null,fileType:Ie.fileType||Xs(Ie.name||""),blobUrl:null,previewUrl:null,previewLoading:!1,localPreviewReady:!1,previewError:null,loading:!1,loadError:null})),w(),k.value=ve.activeIndex,Vue.nextTick(()=>{let Ie=U.value;Ie&&(!Ie.fileType||Ie.fileType==="text")&&n.value&&r(Ie)})},R=()=>{for(let se of h.value)se.loading&&(se.requestId=jc(),se.loading=!1,se.previewLoading=!1,se.loadError=v("files.readInterrupted"),se.previewError=se.loadError)},M=se=>!se.loading&&!se.isDirty&&(se.loadError||(!se.fileType||se.fileType==="text")&&se.content==null)&&(!se.fileType||se.fileType==="text"?se.content==null:!se.blobUrl&&!se.previewUrl&&!se.localPreviewReady);function $(se,ve,Ie={}){let ue=t(se),re=Ie.agentId||e.currentAgent||null,te=Ie.conversationId||e.currentConversation||"_explorer",V=Ie.workDir||s(),ce=h.value.findIndex(Re=>Re.path===ue&&(!Re.agentId||Re.agentId===re)&&(!Re.conversationId||Re.conversationId===te));if(ce>=0){k.value!==ce&&(o(),a(),k.value=ce,Vue.nextTick(()=>{let J=h.value[ce];J&&J.content!=null&&(!J.fileType||J.fileType==="text")&&r(J)}));let Re=h.value[ce];M(Re)&&sa(e,Re,se,{t:v}),I(e.currentConversation);return}a();let X=ve||ue.split(/[/\\]/).pop(),F=Xs(X);h.value.push({path:ue,name:X,agentId:re,conversationId:te,workDir:V,content:null,originalContent:null,isDirty:!1,cmInstance:null,fileType:F,blobUrl:null,previewUrl:null,previewLoading:F!=="text",localPreviewReady:!1,previewError:null,loading:!0,loadError:null}),w(),k.value=h.value.length-1,F==="text"&&i(),I(e.currentConversation);let Z=Ie.requestId||jc(),fe=h.value[k.value];fe&&sa(e,fe,se,{requestId:Z,t:v})}let j=se=>{se!==k.value&&(o(),a(),k.value=se,I(e.currentConversation),Vue.nextTick(()=>{let ve=h.value[se];ve&&(!ve.fileType||ve.fileType==="text"?$s(ve.name)?u.value=!0:ve.content!=null&&n.value&&(r(ve),f.value&&m.value&&Vue.nextTick(()=>p())):ve.fileType==="office"&&ve.localPreviewReady&&Vue.nextTick(()=>g(ve)))}))},z=async(se,{canCommit:ve=()=>!0}={})=>{let Ie=[...new Set(se)].filter(X=>Number.isInteger(X)&&X>=0&&X<h.value.length).sort((X,F)=>X-F);if(Ie.length===0)return!1;let ue=Ie.map(X=>h.value[X]),re=y.value,te=ue.filter(X=>X?.isDirty);if(te.length>0){let X=te.length===1?v("files.unsavedConfirm",{name:te[0].name}):v("files.unsavedBatchConfirm",{count:te.length});if(!await Be(X,{destructive:!0}))return!1}if(y.value!==re||!ve()||ue.some(X=>!h.value.includes(X)))return!1;let V=U.value,ce=V;if(ue.includes(V)){let X=h.value.indexOf(V);ce=h.value.slice(X+1).find(F=>!ue.includes(F))||h.value.slice(0,X).reverse().find(F=>!ue.includes(F))||null}for(let X of ue)c(X.conversationId||e.currentConversation,X.path),X.blobUrl?.startsWith?.("blob:")&&URL.revokeObjectURL(X.blobUrl);for(let X of ue){let F=h.value.indexOf(X);F>=0&&h.value.splice(F,1)}return w(),h.value.length===0?(k.value=-1,i()):k.value=Math.max(0,h.value.indexOf(ce)),I(e.currentConversation),V!==U.value&&U.value&&Vue.nextTick(()=>{let X=U.value;X&&(!X.fileType||X.fileType==="text")&&X.content!=null&&n.value&&r(X)}),!0},Q=(se,ve)=>z([se],ve),ae=(se,ve)=>z(h.value.map((Ie,ue)=>ue).filter(Ie=>Ie<se),ve),ke=(se,ve)=>z(h.value.map((Ie,ue)=>ue).filter(Ie=>Ie>se),ve),N=(se,ve)=>z(h.value.map((Ie,ue)=>ue).filter(Ie=>Ie!==se),ve),G=se=>z(h.value.map((ve,Ie)=>Ie),se);function de(){let se=U.value;if(!se||!se.isDirty||se.pendingSaveRequestId)return;S.value=!0;let ve=`file-save-${Date.now()}-${Math.random().toString(36).slice(2)}`;se.pendingSaveRequestId=ve,se.pendingSaveContent=se.content,e.sendWsMessage({type:"write_file",conversationId:se.conversationId||e.currentConversation||"_explorer",agentId:se.agentId||e.currentAgent,requestId:ve,filePath:se.path,content:se.content,workDir:se.workDir||s(),_clientId:e.clientId})}return{fileTabsMap:b,openFiles:h,activeFileIndex:k,activeFile:U,fileLoading:E,fileSaving:S,tabRevision:y,bumpTabRevision:w,beginTabsRestoreRequest:Y,acceptTabsRestoreRequest:L,saveTabsState:I,restoreTabsState:T,openFileInTab:$,interruptFileReads:R,switchToTab:j,closeFileTab:Q,closeFileTabs:z,closeTabsToLeft:ae,closeTabsToRight:ke,closeOtherTabs:N,closeAllTabs:G,saveFile:de,handleConversationDeleted:se=>{let{conversationId:ve}=se.detail;ve&&(delete b[ve],d(ve))}}}var jc,Uc=B(()=>{Ct();hr();jc=()=>`file-${Date.now()}-${Math.random().toString(36).slice(2)}`});function Zh({store:e,normalizePath:t,getEffectiveWorkDir:s,openFiles:n,activeFileIndex:r,activeFile:i,fileSaving:o,saveTabsState:a,createEditor:l,openFileInTab:c,bumpTabRevision:d=()=>{},acceptTabsRestoreRequest:u=()=>!1,tree:g,setTreeVisible:p,fp:f,qo:m,ops:v,mdPreviewMode:b,renderOfficeLocal:h,editorContainer:k,t:S=P=>P,routeKey:y="",workspaceGeneration:w=""}){let P=new Map,x=(U,E)=>{if(!U||!Number.isFinite(E)||E<=0)return;let oe=Math.max(0,Math.floor(E)-1),q=()=>{let I=U.cmInstance;return I?(I.setCursor({line:oe,ch:0}),I.scrollIntoView({line:oe,ch:0},80),I.focus(),!0):!1};Vue.nextTick(()=>{q()||setTimeout(q,180)})};return{handleWorkbenchMessage:U=>{let E=U.detail;if(!E||!tr(E,y,w))return;let oe=cs(E,y);switch(E.type){case"video_metadata":{let q=t(E.requestedFilePath||E.filePath),I=v.takePendingDownload(E.requestId);if(I){if(E.error||!E.videoStream||!E.previewUrl){v.showFileOpFeedback?.(!1,E.error||S("files.videoStreamUnavailable"));return}let R=t(I).split("/").pop()||"video",M=document.createElement("a"),$=new URL(E.previewUrl,`${location.protocol}//${location.host}`);$.searchParams.set("download","1"),M.href=$.href,M.download=R,document.body.appendChild(M),M.click(),document.body.removeChild(M);return}let T=n.value.find(R=>(E.requestId&&R.requestId?E.requestId===R.requestId:R.path===q)&&(!R.agentId||!E.agentId||R.agentId===E.agentId)&&(!R.conversationId||!E.conversationId||R.conversationId===E.conversationId));if(!T)return;if(T.loading=!1,E.error){T.loadError=E.error,T.previewLoading=!1,T.previewError=E.error;return}if(!E.videoStream||!E.previewUrl){T.loadError=S("files.videoStreamUnavailable"),T.previewLoading=!1,T.previewError=T.loadError;return}T.fileType="video",T.blobUrl=new URL(E.previewUrl,`${location.protocol}//${location.host}`).href,T.previewLoading=!0,T.previewError=null,a(e.currentConversation);break}case"directory_listing":{if(oe==="files-folder-picker"){f.handleFolderPickerListing(E);return}if(y&&oe!=="main")return;g.handleDirectoryListing(E);break}case"file_content":{let q=t(E.requestedFilePath||E.filePath),I=v.takePendingDownload(E.requestId);if(I){if(E.error){v.showFileOpFeedback?.(!1,E.error);return}try{let M=t(I).split("/").pop()||"download";if(E.binary){let $=`${location.protocol}//${location.host}/api/preview/${E.fileId}?token=${E.previewToken}&download=1`,j=document.createElement("a");j.href=$,j.download=M,document.body.appendChild(j),j.click(),document.body.removeChild(j)}else{let $=new Blob([E.content||""],{type:"application/octet-stream"}),j=URL.createObjectURL($),z=document.createElement("a");z.href=j,z.download=M,document.body.appendChild(z),z.click(),document.body.removeChild(z),URL.revokeObjectURL(j)}}catch{}return}let T=n.value.find(M=>(E.requestId&&M.requestId?E.requestId===M.requestId:M.path===q)&&(!M.agentId||!E.agentId||M.agentId===E.agentId)&&(!M.conversationId||!E.conversationId||M.conversationId===E.conversationId));if(!T)return;if(T.loading=!1,E.error){let M=E.errorCode==="FILE_PREVIEW_TOO_LARGE"?S("files.previewTooLarge",{size:((E.errorDetails?.sizeBytes||0)/1024/1024).toFixed(1),limit:((E.errorDetails?.limitBytes||20971520)/1024/1024).toFixed(0)}):E.error;T.loadError=M,T.previewLoading=!1,T.previewError=M;return}let R=n.value.indexOf(T);if(R>=0){let M=T;if(M.loadError=null,E.binary){let $=`${location.protocol}//${location.host}`,j=E.previewUrl?new URL(E.previewUrl,$).href:`${$}/api/preview/${E.fileId}?token=${E.previewToken}`,z=M.fileType||Xs(M.name);M.fileType=z,z==="pdf"||z==="image"?(M.blobUrl=j,M.previewError=null,M.previewLoading=z==="image"):z==="office"?(localStorage.getItem("officePreviewMode")||"local")==="online"?(M.previewUrl="https://view.officeapps.live.com/op/embed.aspx?src="+encodeURIComponent(j),M.previewLoading=!1):fetch(j).then(ae=>{if(!ae.ok)throw new Error(`Preview request failed (${ae.status})`);return ae.arrayBuffer()}).then(ae=>{M._arrayBuffer=ae,M.localPreviewReady=!0,R===r.value?Vue.nextTick(()=>{R===r.value?h(M):M.previewLoading=!1}):M.previewLoading=!1}).catch(ae=>{M.previewError=ae.message,M.previewLoading=!1}):M.previewLoading=!1,a(e.currentConversation);return}if(M.content=E.content||"",M.originalContent=E.content||"",M.isDirty=!1,a(e.currentConversation),R===r.value){$s(M.name)&&b.value||Vue.nextTick(()=>{setTimeout(()=>l(M),100)});let $=T.path,j=P.get($);P.delete($),x(M,j)}}break}case"file_saved":{let q=t(E.requestedFilePath||E.filePath),I=n.value.find(R=>R.path===q&&(!R.agentId||!E.agentId||R.agentId===E.agentId)&&(!R.conversationId||!E.conversationId||R.conversationId===E.conversationId));if(!I?.pendingSaveRequestId||E.requestId&&E.requestId!==I.pendingSaveRequestId)return;o.value=!1;let T=I.pendingSaveContent;if(delete I.pendingSaveRequestId,delete I.pendingSaveContent,E.error)return;I.originalContent=T??I.content,I.isDirty=I.content!==I.originalContent,a(I.conversationId||e.currentConversation);break}case"file_search_result":{m.handleFileSearchResult(E);break}case"file_op_result":{v.handleFileOpResult(E,g.loadTreeDirectory,g.treeRootPath.value);break}case"file_tabs_restored":{if(!u(E.restoreRequestId))return;if(E.openFiles?.length>0&&n.value.length===0){let q=E.activeIndex||0,I=E.openFiles.length;d();for(let T of E.openFiles){let R=t(T.path),M=R.split("/").pop(),$=Xs(M),j=e.currentAgent||null,z=e.currentConversation||"_explorer",Q=s();n.value.push({path:R,name:M,agentId:j,conversationId:z,workDir:Q,content:null,originalContent:null,isDirty:!1,cmInstance:null,fileType:$,blobUrl:null,previewUrl:null,previewLoading:$!=="text",localPreviewReady:!1,previewError:null,loading:!0,loadError:null}),sa(e,n.value.at(-1),T.path,{t:S})}r.value=q>=0&&q<I?q:0}break}}},handleOpenFile:U=>{let{filePath:E,agentId:oe=e.currentAgent,conversationId:q=e.currentConversation,workDir:I=s(),workbenchRouteKey:T=y,workspaceGeneration:R=w,hideTree:M=!1,line:$=null}=U.detail||{},j=t(E);!j||!oe||!q||y&&T!==y||w&&R!==w||(M&&typeof p=="function"&&p(!1),Number.isFinite($)&&$>0&&P.set(j,$),c(j,j.split("/").pop(),{agentId:oe,conversationId:q,workDir:I}),x(i.value,$))}}}var Jh=B(()=>{hr();Uc();As()});function na(e,t,s=""){let n=t?.currentTarget?.src||t?.target?.src;if(!e?.blobUrl||!n)return!1;let r=e.blobUrl;try{r=new URL(e.blobUrl,`${location.protocol}//${location.host}`).href}catch{}return n!==r?!1:(e.previewLoading=!1,e.previewError=s||null,!0)}function Zk({liveStore:e,props:t,tabs:s,isDisposed:n}){let r=d=>d.detail?.routeKey===t.routeKey&&d.detail?.workspaceGeneration===t.workspaceGeneration,i=(d,u)=>{let g=yt(e.activeSessionRoute),p=Tn(g,e.effectiveWorkDir);return!n()&&t.routeKey===d&&t.workspaceGeneration===u&&g===d&&p===u};return{isCurrentEvent:r,handleSelectFileItem:d=>{if(!r(d))return;let u=s.openFiles.value.findIndex(g=>g.path===d.detail.path);u>=0&&s.switchToTab(u)},handleCloseFileItem:async d=>{if(!r(d))return;let u=d.detail.routeKey,g=d.detail.workspaceGeneration,p=s.tabRevision.value,f=s.openFiles.value.find(b=>b.path===d.detail.path);if(!f)return;let m=()=>i(u,g)&&s.tabRevision.value===p&&s.openFiles.value.includes(f),v=s.openFiles.value.indexOf(f);v>=0&&await s.closeFileTab(v,{canCommit:m})},handleCloseFileItems:async d=>{if(!r(d)||typeof d.detail.resolve!="function")return;let u=d.detail.routeKey,g=d.detail.workspaceGeneration,p=s.tabRevision.value,f=new Set(Array.isArray(d.detail.paths)?d.detail.paths:[]),m=s.openFiles.value.filter(k=>f.has(k.path)),v=()=>i(u,g)&&s.tabRevision.value===p&&m.every(k=>s.openFiles.value.includes(k)),b=m.map(k=>s.openFiles.value.indexOf(k)).filter(k=>k>=0),h=b.length===0?v():await s.closeFileTabs(b,{canCommit:v});d.detail.resolve(h&&v())},handleCloseFilesCapability:async d=>{if(!r(d)||typeof d.detail.resolve!="function")return;let u=d.detail.routeKey,g=d.detail.workspaceGeneration,p=s.tabRevision.value,f=()=>i(u,g)&&s.tabRevision.value===p,m=s.openFiles.value.length===0?f():await s.closeAllTabs({canCommit:f});d.detail.resolve(m&&f()&&s.openFiles.value.length===0)}}}var em,tm=B(()=>{Wc();Vh();Nh();jh();hr();Kh();Yh();Qh();Uc();Jh();ai();As();em={name:"FilesTab",props:{treeInitiallyVisible:{type:Boolean,default:!0},routeKey:{type:String,required:!0},runtimeProvider:{type:String,required:!0},agentId:{type:String,required:!0},sessionId:{type:String,required:!0},conversationId:{type:String,required:!0},workDir:{type:String,default:""},workspaceGeneration:{type:String,required:!0}},template:`
2320
2323
  <div class="files-tab file-two-col" :class="{ 'mobile-editor-view': isMobile && mobileView === 'editor', 'tree-collapsed': !treeVisible }" ref="rootEl">
2321
2324
  <div class="file-tree-collapsed-rail" v-if="!treeVisible">
2322
2325
  <button
@@ -2808,7 +2811,7 @@ ${String(e||"").trim()}
2808
2811
  </template>
2809
2812
  </div>
2810
2813
  </div>
2811
- `,setup(e){let t=Pinia.useChatStore(),s=er(t,e),n=Vue.inject("t"),r=Vue.ref(!0),i=!1,o=Vue.ref(e.treeInitiallyVisible),a=()=>s.effectiveWorkDir||"",l=D=>D?D.replace(/\\/g,"/"):"",c=D=>ea(D),d=D=>ta(D),u=D=>D==null?"":D<1024?D+" B":D<1024*1024?(D/1024).toFixed(1)+" KB":(D/(1024*1024)).toFixed(1)+" MB",g=(D,ye)=>na(D,ye),p=(D,ye)=>na(D,ye,n("files.previewLoadFailed")),f=(D,ye)=>na(D,ye),m=(D,ye)=>na(D,ye,n("files.videoPreviewLoadFailed")),v=D=>{let ye=I.activeFile.value;ye?.blobUrl&&Rs(ye.blobUrl,{alt:ye.name||n("message.imagePreview"),closeLabel:n("common.close"),zoomOutLabel:n("message.zoomOut"),zoomInLabel:n("message.zoomIn"),resetZoomLabel:n("message.resetZoom"),trigger:D})},y=Vue.ref(null),h=Vue.ref(null),k=Vue.ref(window.innerWidth<=768),S=Vue.ref("tree"),b=()=>{S.value="tree"},w=Vue.ref(parseInt(localStorage.getItem("filesFontSize"))||15),P=D=>{w.value=Math.max(8,Math.min(24,D)),localStorage.setItem("filesFontSize",w.value.toString());let ye=I.activeFile.value;ye?.cmInstance&&(ye.cmInstance.getWrapperElement().style.fontSize=w.value+"px",ye.cmInstance.refresh())},x=()=>P(w.value+1),Y=()=>P(w.value-1),L=Vue.computed(()=>{let D=I?.activeFile.value;return!!D&&(!D.fileType||D.fileType==="text")}),U=D=>{L.value&&(D.preventDefault(),D.deltaY<0?x():Y())},E=Vue.ref(parseInt(localStorage.getItem("filePanelWidth"))||220),oe=Vue.ref(!1),q=D=>{D.preventDefault();let ye=D.type==="touchstart";oe.value=!0;let Me=ye?D.touches[0].clientX:D.clientX,ze=E.value;document.body.style.cursor="col-resize",document.body.style.userSelect="none";let Ye=D.target.closest(".file-two-col"),rt=Ye?Ye.offsetWidth*.5:400,ut=W=>{let ie=ye?W.touches[0].clientX:W.clientX;E.value=Math.max(120,Math.min(rt,ze-(ie-Me)))},at=()=>{oe.value=!1,document.body.style.cursor="",document.body.style.userSelect="",localStorage.setItem("filePanelWidth",E.value.toString()),document.removeEventListener("mousemove",ut),document.removeEventListener("mouseup",at),document.removeEventListener("touchmove",ut),document.removeEventListener("touchend",at)};document.addEventListener(ye?"touchmove":"mousemove",ut),document.addEventListener(ye?"touchend":"mouseup",at)},I,T,R=Vue.computed(()=>I?I.activeFile.value:null),M=Vue.computed(()=>T?T.treePath.value:""),$=qh(R),j=Hh(s,{activeFile:R,editorContainer:h,fontSize:w,clearFindMarkers:$.clearFindMarkers,openFindBar:$.openFindBar,saveFile:()=>I.saveFile()}),z=Uh(R,{editorContainer:h,createEditor:j.createEditor,t:n}),Q=Bh(s,{getEffectiveWorkDir:a,treePath:M});I=Xh(s,{normalizePath:l,getEffectiveWorkDir:a,editorContainer:h,createEditor:j.createEditor,destroyEditor:j.destroyEditor,clearFindMarkers:$.clearFindMarkers,saveCurrentUndoHistory:j.saveCurrentUndoHistory,saveAllUndoHistory:j.saveAllUndoHistory,cleanupUndoHistory:j.cleanupUndoHistory,deleteConversationHistory:j.deleteConversationHistory,mdPreviewMode:z.mdPreviewMode,renderOfficeLocal:z.renderOfficeLocal,performFind:$.performFind,findBarVisible:$.findBarVisible,findQuery:$.findQuery,t:n}),T=Wh(s,{getEffectiveWorkDir:a,normalizePath:l,selectedPaths:Q.selectedPaths,lastClickedIndex:Q.lastClickedIndex,openFileInTab:(...D)=>I.openFileInTab(...D),clearSelection:Q.clearSelection});let ae=zh(s,{getEffectiveWorkDir:a,treePath:T.treePath,openFileInTab:(...D)=>I.openFileInTab(...D),normalizePath:l,treeRootPath:T.treeRootPath,treeNodes:T.treeNodes,loadTreeDirectory:T.loadTreeDirectory});j.setKeyBindings({openQuickOpen:ae.openQuickOpen,openGoToLine:ae.openGoToLine});let ke=Gh(s,{getEffectiveWorkDir:a,treePath:T.treePath,treeRootPath:T.treeRootPath,treeNodes:T.treeNodes,normalizePath:l,loadTreeDirectory:T.loadTreeDirectory}),N=Zh({store:s,normalizePath:l,getEffectiveWorkDir:a,openFiles:I.openFiles,activeFileIndex:I.activeFileIndex,setTreeVisible:D=>{o.value=!!D},activeFile:I.activeFile,fileSaving:I.fileSaving,saveTabsState:I.saveTabsState,createEditor:j.createEditor,openFileInTab:I.openFileInTab,bumpTabRevision:I.bumpTabRevision,acceptTabsRestoreRequest:I.acceptTabsRestoreRequest,tree:T,fp:ke,qo:ae,ops:Q,mdPreviewMode:z.mdPreviewMode,renderOfficeLocal:z.renderOfficeLocal,editorContainer:h,t:n,routeKey:e.routeKey,workspaceGeneration:e.workspaceGeneration}),G=D=>Q.deleteSingleFile(D,n),de=()=>Q.deleteSelected(n),we=()=>Q.ctxDelete(n),se=(D,ye)=>Q.onDrop(D,ye,Q.handleExternalFileDrop),ve=D=>Q.onTreeDrop(D,T.treeRootPath.value,Q.handleExternalFileDrop),Ie=()=>ae.goToLineConfirm(I.activeFile),ue=()=>{let D=I.activeFile.value;D&&Q.downloadFile({path:D.path,type:"file"})};Vue.watch(()=>s.currentAgent,()=>{I.saveTabsState(s.currentConversation),j.destroyEditor(),T.clearTreeNodes(),I.openFiles.value.length>0&&I.bumpTabRevision(),I.openFiles.value=[],I.activeFileIndex.value=-1,s.currentAgent&&Vue.nextTick(()=>T.initFileBrowser())});let re=s.currentConversation;Vue.watch(()=>s.currentConversation,D=>{I.saveTabsState(re),re=D,I.restoreTabsState(D);let ye=a(),Me=l(ye);ye&&Me!==T.treeRootPath.value&&(T.treePath.value=ye,T.treeRootPath.value=Me,T.clearTreeNodes(),T.loadTreeDirectory(ye))}),Vue.watch(()=>t.connectionState,(D,ye)=>{ye==="connected"&&D!=="connected"&&I.interruptFileReads()},{flush:"sync"}),Vue.watch(()=>s.theme,D=>{let ye=I.activeFile.value;ye?.cmInstance&&ye.cmInstance.setOption("theme",D==="dark"?"material-darker":"default")}),Vue.watch(()=>a(),D=>{if(D&&!T.treeRootPath.value){let ye=l(D);T.treePath.value=D,T.treeRootPath.value=ye,T.clearTreeNodes(),T.loadTreeDirectory(D)}}),Vue.watch(()=>I.activeFile.value?.content,(D,ye)=>{let Me=I.activeFile.value;if(Me&&D!=null&&ye==null&&!Me.cmInstance&&(!Me.fileType||Me.fileType==="text")){if($s(Me.name)&&z.mdPreviewMode.value)return;Vue.nextTick(()=>{setTimeout(()=>{Me.cmInstance||j.createEditor(Me)},150)})}}),Vue.watch([z.mdRenderedHtml,z.mdPreviewMode],([D,ye])=>{D&&ye&&Vue.nextTick(()=>{setTimeout(()=>z.renderMermaidBlocks(),50)})});let te=D=>{!r.value||!(y.value&&y.value.offsetParent!==null)&&!ae.quickOpenVisible.value&&!ae.goToLineVisible.value&&!$.findBarVisible.value||((D.ctrlKey||D.metaKey)&&D.key==="p"?(D.preventDefault(),ae.quickOpenVisible.value?ae.closeQuickOpen():ae.openQuickOpen()):(D.ctrlKey||D.metaKey)&&D.key==="g"?(D.preventDefault(),ae.goToLineVisible.value?ae.closeGoToLine():ae.openGoToLine()):(D.ctrlKey||D.metaKey)&&D.key==="f"?I.activeFile.value&&(D.preventDefault(),$.openFindBar(!1)):(D.ctrlKey||D.metaKey)&&(D.key==="r"||D.key==="h")?I.activeFile.value&&(D.preventDefault(),$.openFindBar(!0)):D.key==="Escape"&&($.findBarVisible.value&&$.closeFindBar(),Q.selectedPaths.size>0&&Q.clearSelection(),ae.quickOpenVisible.value&&ae.closeQuickOpen(),ae.goToLineVisible.value&&ae.closeGoToLine()))},V=()=>{Q.hideContextMenu()},ce=()=>{k.value=window.innerWidth<=768};Vue.watch(()=>I.activeFileIndex.value,(D,ye)=>{k.value&&D>=0&&D!==ye&&(S.value="editor")}),Vue.watch(()=>I.openFiles.value.length,D=>{k.value&&D===0&&(S.value="tree")});let X=Vue.computed(()=>{let D=I.activeFile.value?.path||"",ye=Math.max(D.lastIndexOf("/"),D.lastIndexOf("\\"));return ye>0?D.slice(0,ye):a()}),F=()=>{window.dispatchEvent(new CustomEvent("workbench-file-items-changed",{detail:{routeKey:e.routeKey,workspaceGeneration:e.workspaceGeneration,files:I.openFiles.value.map(D=>({path:D.path,name:D.name,isDirty:!!D.isDirty})),activePath:I.activeFile.value?.path||""}}))},{handleSelectFileItem:Z,handleCloseFileItem:fe,handleCloseFileItems:Re,handleCloseFilesCapability:J}=Zk({liveStore:t,props:e,tabs:I,isDisposed:()=>i});return Vue.watch([I.openFiles,I.activeFileIndex],F,{deep:!0,flush:"post"}),Vue.onMounted(()=>{window.addEventListener("workbench-message",N.handleWorkbenchMessage),window.addEventListener("workbench-open-file-in-active-view",N.handleOpenFile),window.addEventListener("workbench-select-file-item",Z),window.addEventListener("workbench-close-file-item",fe),window.addEventListener("workbench-close-file-items",Re),window.addEventListener("workbench-close-files-capability",J),window.addEventListener("conversation-deleted",I.handleConversationDeleted),window.addEventListener("keydown",te),document.addEventListener("click",V),window.addEventListener("resize",ce),z.initMermaid(),s.currentAgent&&(T.initFileBrowser(),s.sendWsMessage({type:"restore_file_tabs",restoreRequestId:I.beginTabsRestoreRequest()}))}),Vue.onActivated(()=>{r.value=!0,F()}),Vue.onDeactivated(()=>{r.value=!1,ae.closeQuickOpen(),ae.closeGoToLine(),$.closeFindBar(),Q.hideContextMenu()}),Vue.onUnmounted(()=>{i=!0,I.saveTabsState(s.currentConversation),window.removeEventListener("workbench-message",N.handleWorkbenchMessage),window.removeEventListener("workbench-open-file-in-active-view",N.handleOpenFile),window.removeEventListener("workbench-select-file-item",Z),window.removeEventListener("workbench-close-file-item",fe),window.removeEventListener("workbench-close-file-items",Re),window.removeEventListener("workbench-close-files-capability",J),window.removeEventListener("conversation-deleted",I.handleConversationDeleted),window.removeEventListener("keydown",te),document.removeEventListener("click",V),window.removeEventListener("resize",ce),j.destroyEditor(),Q.cleanup()}),{store:s,debugStatus:j.debugStatus,rootEl:y,treeVisible:o,isMobile:k,mobileView:S,mobileGoBack:b,fontSize:w,zoomIn:x,zoomOut:Y,isTextZoomAvailable:L,onWheel:U,openActiveImagePreview:v,treePath:T.treePath,treeRootPath:T.treeRootPath,treeNodes:T.treeNodes,flattenedTree:T.flattenedTree,editingTreePath:T.editingTreePath,treePathInputRef:T.treePathInputRef,rootFolderName:T.rootFolderName,startTreePathEdit:T.startTreePathEdit,confirmTreePath:T.confirmTreePath,cancelTreePathEdit:T.cancelTreePathEdit,treePanelWidth:E,isTreeResizing:oe,startTreeResize:q,openFiles:I.openFiles,activeFileIndex:I.activeFileIndex,activeFile:I.activeFile,activeFileFolder:X,fileLoading:I.fileLoading,fileSaving:I.fileSaving,editorContainer:h,officePreviewContainer:z.officePreviewContainer,mdPreviewRef:z.mdPreviewRef,isActiveMarkdown:z.isActiveMarkdown,mdPreviewMode:z.mdPreviewMode,mdRenderedHtml:z.mdRenderedHtml,switchToMdEdit:z.switchToMdEdit,folderPickerOpen:ke.folderPickerOpen,folderPickerPath:ke.folderPickerPath,folderPickerEntries:ke.folderPickerEntries,folderPickerLoading:ke.folderPickerLoading,folderPickerSelected:ke.folderPickerSelected,searchQuery:ae.searchQuery,searchResults:ae.searchResults,searchLoading:ae.searchLoading,onSearchInput:ae.onSearchInput,clearSearch:ae.clearSearch,onSearchResultClick:ae.onSearchResultClick,quickOpenVisible:ae.quickOpenVisible,quickOpenQuery:ae.quickOpenQuery,quickOpenResults:ae.quickOpenResults,quickOpenSelectedIndex:ae.quickOpenSelectedIndex,quickOpenLoading:ae.quickOpenLoading,quickOpenInput:ae.quickOpenInput,openQuickOpen:ae.openQuickOpen,closeQuickOpen:ae.closeQuickOpen,onQuickOpenInput:ae.onQuickOpenInput,quickOpenSelectNext:ae.quickOpenSelectNext,quickOpenSelectPrev:ae.quickOpenSelectPrev,quickOpenConfirm:ae.quickOpenConfirm,quickOpenOpenFile:ae.quickOpenOpenFile,goToLineVisible:ae.goToLineVisible,goToLineValue:ae.goToLineValue,goToLineInput:ae.goToLineInput,openGoToLine:ae.openGoToLine,closeGoToLine:ae.closeGoToLine,goToLineConfirm:Ie,findBarVisible:$.findBarVisible,replaceBarVisible:$.replaceBarVisible,findQuery:$.findQuery,replaceQuery:$.replaceQuery,findCaseSensitive:$.findCaseSensitive,findUseRegex:$.findUseRegex,findMatchCount:$.findMatchCount,findMatchIndex:$.findMatchIndex,findInputRef:$.findInputRef,replaceInputRef:$.replaceInputRef,onFindInput:$.onFindInput,findNext:$.findNext,findPrev:$.findPrev,openFindBar:$.openFindBar,closeFindBar:$.closeFindBar,toggleReplaceBar:$.toggleReplaceBar,replaceOne:$.replaceOne,replaceAll:$.replaceAll,selectedPaths:Q.selectedPaths,fileOperating:Q.fileOperating,fileOpFeedback:Q.fileOpFeedback,newFileDialogVisible:Q.newFileDialogVisible,newFileName:Q.newFileName,newFileType:Q.newFileType,newFileInput:Q.newFileInput,moveDialogVisible:Q.moveDialogVisible,moveDestination:Q.moveDestination,moveDestInput:Q.moveDestInput,toggleSelection:Q.toggleSelection,clearSelection:Q.clearSelection,showNewFileDialog:Q.showNewFileDialog,confirmNewFile:Q.confirmNewFile,deleteSingleFile:G,deleteSelected:de,openMoveDialog:Q.openMoveDialog,confirmMove:Q.confirmMove,contextMenu:Q.contextMenu,showContextMenu:Q.showContextMenu,hideContextMenu:Q.hideContextMenu,ctxRename:Q.ctxRename,ctxCopy:Q.ctxCopy,ctxMoveTo:Q.ctxMoveTo,ctxDelete:we,ctxDownload:Q.ctxDownload,downloadActiveFile:ue,renameDialogVisible:Q.renameDialogVisible,renameNewName:Q.renameNewName,renameInput:Q.renameInput,confirmRename:Q.confirmRename,dragState:Q.dragState,externalDropActive:Q.externalDropActive,onDragStart:Q.onDragStart,onDragOver:Q.onDragOver,onDragLeave:Q.onDragLeave,onDrop:se,onTreeDragOver:Q.onTreeDragOver,onTreeDragLeave:Q.onTreeDragLeave,onTreeDrop:ve,loadRootDirectory:T.loadRootDirectory,onTreeItemClick:T.onTreeItemClick,openFileInTab:I.openFileInTab,switchToTab:I.switchToTab,closeFileTab:I.closeFileTab,saveFile:I.saveFile,openFolderPicker:ke.openFolderPicker,folderPickerNavigateUp:ke.folderPickerNavigateUp,folderPickerSelectItem:ke.folderPickerSelectItem,folderPickerEnter:ke.folderPickerEnter,confirmFolderPicker:ke.confirmFolderPicker,getFileIcon:()=>"",getFileIconHtml:c,getFolderIcon:d,formatSize:u,onImagePreviewLoad:g,onImagePreviewError:p,onVideoPreviewLoad:f,onVideoPreviewError:m,refresh:T.refresh,placeholderPath:Vue.computed(()=>{let D=a();return D?n("files.workDir",{dir:D}):n("files.enterDirPath")})}}}});var Jk,sm,nm=B(()=>{Ah();Oh();tm();Jk=Object.freeze({terminal:"TerminalTab",git:"GitStatusTab",files:"FilesTab"}),sm={name:"WorkbenchCapabilityHost",components:{TerminalTab:Ch,GitStatusTab:Fh,FilesTab:em},props:{activeCapability:{type:String,default:null},retainedCapabilities:{type:Array,default:()=>[]},routeProps:{type:Object,required:!0}},template:`
2814
+ `,setup(e){let t=Pinia.useChatStore(),s=er(t,e),n=Vue.inject("t"),r=Vue.ref(!0),i=!1,o=Vue.ref(e.treeInitiallyVisible),a=()=>s.effectiveWorkDir||"",l=D=>D?D.replace(/\\/g,"/"):"",c=D=>ea(D),d=D=>ta(D),u=D=>D==null?"":D<1024?D+" B":D<1024*1024?(D/1024).toFixed(1)+" KB":(D/(1024*1024)).toFixed(1)+" MB",g=(D,ye)=>na(D,ye),p=(D,ye)=>na(D,ye,n("files.previewLoadFailed")),f=(D,ye)=>na(D,ye),m=(D,ye)=>na(D,ye,n("files.videoPreviewLoadFailed")),v=D=>{let ye=I.activeFile.value;ye?.blobUrl&&Rs(ye.blobUrl,{alt:ye.name||n("message.imagePreview"),closeLabel:n("common.close"),zoomOutLabel:n("message.zoomOut"),zoomInLabel:n("message.zoomIn"),resetZoomLabel:n("message.resetZoom"),trigger:D})},b=Vue.ref(null),h=Vue.ref(null),k=Vue.ref(window.innerWidth<=768),S=Vue.ref("tree"),y=()=>{S.value="tree"},w=Vue.ref(parseInt(localStorage.getItem("filesFontSize"))||15),P=D=>{w.value=Math.max(8,Math.min(24,D)),localStorage.setItem("filesFontSize",w.value.toString());let ye=I.activeFile.value;ye?.cmInstance&&(ye.cmInstance.getWrapperElement().style.fontSize=w.value+"px",ye.cmInstance.refresh())},x=()=>P(w.value+1),Y=()=>P(w.value-1),L=Vue.computed(()=>{let D=I?.activeFile.value;return!!D&&(!D.fileType||D.fileType==="text")}),U=D=>{L.value&&(D.preventDefault(),D.deltaY<0?x():Y())},E=Vue.ref(parseInt(localStorage.getItem("filePanelWidth"))||220),oe=Vue.ref(!1),q=D=>{D.preventDefault();let ye=D.type==="touchstart";oe.value=!0;let Me=ye?D.touches[0].clientX:D.clientX,ze=E.value;document.body.style.cursor="col-resize",document.body.style.userSelect="none";let Ye=D.target.closest(".file-two-col"),rt=Ye?Ye.offsetWidth*.5:400,ut=W=>{let ie=ye?W.touches[0].clientX:W.clientX;E.value=Math.max(120,Math.min(rt,ze-(ie-Me)))},at=()=>{oe.value=!1,document.body.style.cursor="",document.body.style.userSelect="",localStorage.setItem("filePanelWidth",E.value.toString()),document.removeEventListener("mousemove",ut),document.removeEventListener("mouseup",at),document.removeEventListener("touchmove",ut),document.removeEventListener("touchend",at)};document.addEventListener(ye?"touchmove":"mousemove",ut),document.addEventListener(ye?"touchend":"mouseup",at)},I,T,R=Vue.computed(()=>I?I.activeFile.value:null),M=Vue.computed(()=>T?T.treePath.value:""),$=qh(R),j=Hh(s,{activeFile:R,editorContainer:h,fontSize:w,clearFindMarkers:$.clearFindMarkers,openFindBar:$.openFindBar,saveFile:()=>I.saveFile()}),z=Uh(R,{editorContainer:h,createEditor:j.createEditor,t:n}),Q=Bh(s,{getEffectiveWorkDir:a,treePath:M});I=Xh(s,{normalizePath:l,getEffectiveWorkDir:a,editorContainer:h,createEditor:j.createEditor,destroyEditor:j.destroyEditor,clearFindMarkers:$.clearFindMarkers,saveCurrentUndoHistory:j.saveCurrentUndoHistory,saveAllUndoHistory:j.saveAllUndoHistory,cleanupUndoHistory:j.cleanupUndoHistory,deleteConversationHistory:j.deleteConversationHistory,mdPreviewMode:z.mdPreviewMode,renderOfficeLocal:z.renderOfficeLocal,performFind:$.performFind,findBarVisible:$.findBarVisible,findQuery:$.findQuery,t:n}),T=Wh(s,{getEffectiveWorkDir:a,normalizePath:l,selectedPaths:Q.selectedPaths,lastClickedIndex:Q.lastClickedIndex,openFileInTab:(...D)=>I.openFileInTab(...D),clearSelection:Q.clearSelection});let ae=zh(s,{getEffectiveWorkDir:a,treePath:T.treePath,openFileInTab:(...D)=>I.openFileInTab(...D),normalizePath:l,treeRootPath:T.treeRootPath,treeNodes:T.treeNodes,loadTreeDirectory:T.loadTreeDirectory});j.setKeyBindings({openQuickOpen:ae.openQuickOpen,openGoToLine:ae.openGoToLine});let ke=Gh(s,{getEffectiveWorkDir:a,treePath:T.treePath,treeRootPath:T.treeRootPath,treeNodes:T.treeNodes,normalizePath:l,loadTreeDirectory:T.loadTreeDirectory}),N=Zh({store:s,normalizePath:l,getEffectiveWorkDir:a,openFiles:I.openFiles,activeFileIndex:I.activeFileIndex,setTreeVisible:D=>{o.value=!!D},activeFile:I.activeFile,fileSaving:I.fileSaving,saveTabsState:I.saveTabsState,createEditor:j.createEditor,openFileInTab:I.openFileInTab,bumpTabRevision:I.bumpTabRevision,acceptTabsRestoreRequest:I.acceptTabsRestoreRequest,tree:T,fp:ke,qo:ae,ops:Q,mdPreviewMode:z.mdPreviewMode,renderOfficeLocal:z.renderOfficeLocal,editorContainer:h,t:n,routeKey:e.routeKey,workspaceGeneration:e.workspaceGeneration}),G=D=>Q.deleteSingleFile(D,n),de=()=>Q.deleteSelected(n),we=()=>Q.ctxDelete(n),se=(D,ye)=>Q.onDrop(D,ye,Q.handleExternalFileDrop),ve=D=>Q.onTreeDrop(D,T.treeRootPath.value,Q.handleExternalFileDrop),Ie=()=>ae.goToLineConfirm(I.activeFile),ue=()=>{let D=I.activeFile.value;D&&Q.downloadFile({path:D.path,type:"file"})};Vue.watch(()=>s.currentAgent,()=>{I.saveTabsState(s.currentConversation),j.destroyEditor(),T.clearTreeNodes(),I.openFiles.value.length>0&&I.bumpTabRevision(),I.openFiles.value=[],I.activeFileIndex.value=-1,s.currentAgent&&Vue.nextTick(()=>T.initFileBrowser())});let re=s.currentConversation;Vue.watch(()=>s.currentConversation,D=>{I.saveTabsState(re),re=D,I.restoreTabsState(D);let ye=a(),Me=l(ye);ye&&Me!==T.treeRootPath.value&&(T.treePath.value=ye,T.treeRootPath.value=Me,T.clearTreeNodes(),T.loadTreeDirectory(ye))}),Vue.watch(()=>t.connectionState,(D,ye)=>{ye==="connected"&&D!=="connected"&&I.interruptFileReads()},{flush:"sync"}),Vue.watch(()=>s.theme,D=>{let ye=I.activeFile.value;ye?.cmInstance&&ye.cmInstance.setOption("theme",D==="dark"?"material-darker":"default")}),Vue.watch(()=>a(),D=>{if(D&&!T.treeRootPath.value){let ye=l(D);T.treePath.value=D,T.treeRootPath.value=ye,T.clearTreeNodes(),T.loadTreeDirectory(D)}}),Vue.watch(()=>I.activeFile.value?.content,(D,ye)=>{let Me=I.activeFile.value;if(Me&&D!=null&&ye==null&&!Me.cmInstance&&(!Me.fileType||Me.fileType==="text")){if($s(Me.name)&&z.mdPreviewMode.value)return;Vue.nextTick(()=>{setTimeout(()=>{Me.cmInstance||j.createEditor(Me)},150)})}}),Vue.watch([z.mdRenderedHtml,z.mdPreviewMode],([D,ye])=>{D&&ye&&Vue.nextTick(()=>{setTimeout(()=>z.renderMermaidBlocks(),50)})});let te=D=>{!r.value||!(b.value&&b.value.offsetParent!==null)&&!ae.quickOpenVisible.value&&!ae.goToLineVisible.value&&!$.findBarVisible.value||((D.ctrlKey||D.metaKey)&&D.key==="p"?(D.preventDefault(),ae.quickOpenVisible.value?ae.closeQuickOpen():ae.openQuickOpen()):(D.ctrlKey||D.metaKey)&&D.key==="g"?(D.preventDefault(),ae.goToLineVisible.value?ae.closeGoToLine():ae.openGoToLine()):(D.ctrlKey||D.metaKey)&&D.key==="f"?I.activeFile.value&&(D.preventDefault(),$.openFindBar(!1)):(D.ctrlKey||D.metaKey)&&(D.key==="r"||D.key==="h")?I.activeFile.value&&(D.preventDefault(),$.openFindBar(!0)):D.key==="Escape"&&($.findBarVisible.value&&$.closeFindBar(),Q.selectedPaths.size>0&&Q.clearSelection(),ae.quickOpenVisible.value&&ae.closeQuickOpen(),ae.goToLineVisible.value&&ae.closeGoToLine()))},V=()=>{Q.hideContextMenu()},ce=()=>{k.value=window.innerWidth<=768};Vue.watch(()=>I.activeFileIndex.value,(D,ye)=>{k.value&&D>=0&&D!==ye&&(S.value="editor")}),Vue.watch(()=>I.openFiles.value.length,D=>{k.value&&D===0&&(S.value="tree")});let X=Vue.computed(()=>{let D=I.activeFile.value?.path||"",ye=Math.max(D.lastIndexOf("/"),D.lastIndexOf("\\"));return ye>0?D.slice(0,ye):a()}),F=()=>{window.dispatchEvent(new CustomEvent("workbench-file-items-changed",{detail:{routeKey:e.routeKey,workspaceGeneration:e.workspaceGeneration,files:I.openFiles.value.map(D=>({path:D.path,name:D.name,isDirty:!!D.isDirty})),activePath:I.activeFile.value?.path||""}}))},{handleSelectFileItem:Z,handleCloseFileItem:fe,handleCloseFileItems:Re,handleCloseFilesCapability:J}=Zk({liveStore:t,props:e,tabs:I,isDisposed:()=>i});return Vue.watch([I.openFiles,I.activeFileIndex],F,{deep:!0,flush:"post"}),Vue.onMounted(()=>{window.addEventListener("workbench-message",N.handleWorkbenchMessage),window.addEventListener("workbench-open-file-in-active-view",N.handleOpenFile),window.addEventListener("workbench-select-file-item",Z),window.addEventListener("workbench-close-file-item",fe),window.addEventListener("workbench-close-file-items",Re),window.addEventListener("workbench-close-files-capability",J),window.addEventListener("conversation-deleted",I.handleConversationDeleted),window.addEventListener("keydown",te),document.addEventListener("click",V),window.addEventListener("resize",ce),z.initMermaid(),s.currentAgent&&(T.initFileBrowser(),s.sendWsMessage({type:"restore_file_tabs",restoreRequestId:I.beginTabsRestoreRequest()}))}),Vue.onActivated(()=>{r.value=!0,F()}),Vue.onDeactivated(()=>{r.value=!1,ae.closeQuickOpen(),ae.closeGoToLine(),$.closeFindBar(),Q.hideContextMenu()}),Vue.onUnmounted(()=>{i=!0,I.saveTabsState(s.currentConversation),window.removeEventListener("workbench-message",N.handleWorkbenchMessage),window.removeEventListener("workbench-open-file-in-active-view",N.handleOpenFile),window.removeEventListener("workbench-select-file-item",Z),window.removeEventListener("workbench-close-file-item",fe),window.removeEventListener("workbench-close-file-items",Re),window.removeEventListener("workbench-close-files-capability",J),window.removeEventListener("conversation-deleted",I.handleConversationDeleted),window.removeEventListener("keydown",te),document.removeEventListener("click",V),window.removeEventListener("resize",ce),j.destroyEditor(),Q.cleanup()}),{store:s,debugStatus:j.debugStatus,rootEl:b,treeVisible:o,isMobile:k,mobileView:S,mobileGoBack:y,fontSize:w,zoomIn:x,zoomOut:Y,isTextZoomAvailable:L,onWheel:U,openActiveImagePreview:v,treePath:T.treePath,treeRootPath:T.treeRootPath,treeNodes:T.treeNodes,flattenedTree:T.flattenedTree,editingTreePath:T.editingTreePath,treePathInputRef:T.treePathInputRef,rootFolderName:T.rootFolderName,startTreePathEdit:T.startTreePathEdit,confirmTreePath:T.confirmTreePath,cancelTreePathEdit:T.cancelTreePathEdit,treePanelWidth:E,isTreeResizing:oe,startTreeResize:q,openFiles:I.openFiles,activeFileIndex:I.activeFileIndex,activeFile:I.activeFile,activeFileFolder:X,fileLoading:I.fileLoading,fileSaving:I.fileSaving,editorContainer:h,officePreviewContainer:z.officePreviewContainer,mdPreviewRef:z.mdPreviewRef,isActiveMarkdown:z.isActiveMarkdown,mdPreviewMode:z.mdPreviewMode,mdRenderedHtml:z.mdRenderedHtml,switchToMdEdit:z.switchToMdEdit,folderPickerOpen:ke.folderPickerOpen,folderPickerPath:ke.folderPickerPath,folderPickerEntries:ke.folderPickerEntries,folderPickerLoading:ke.folderPickerLoading,folderPickerSelected:ke.folderPickerSelected,searchQuery:ae.searchQuery,searchResults:ae.searchResults,searchLoading:ae.searchLoading,onSearchInput:ae.onSearchInput,clearSearch:ae.clearSearch,onSearchResultClick:ae.onSearchResultClick,quickOpenVisible:ae.quickOpenVisible,quickOpenQuery:ae.quickOpenQuery,quickOpenResults:ae.quickOpenResults,quickOpenSelectedIndex:ae.quickOpenSelectedIndex,quickOpenLoading:ae.quickOpenLoading,quickOpenInput:ae.quickOpenInput,openQuickOpen:ae.openQuickOpen,closeQuickOpen:ae.closeQuickOpen,onQuickOpenInput:ae.onQuickOpenInput,quickOpenSelectNext:ae.quickOpenSelectNext,quickOpenSelectPrev:ae.quickOpenSelectPrev,quickOpenConfirm:ae.quickOpenConfirm,quickOpenOpenFile:ae.quickOpenOpenFile,goToLineVisible:ae.goToLineVisible,goToLineValue:ae.goToLineValue,goToLineInput:ae.goToLineInput,openGoToLine:ae.openGoToLine,closeGoToLine:ae.closeGoToLine,goToLineConfirm:Ie,findBarVisible:$.findBarVisible,replaceBarVisible:$.replaceBarVisible,findQuery:$.findQuery,replaceQuery:$.replaceQuery,findCaseSensitive:$.findCaseSensitive,findUseRegex:$.findUseRegex,findMatchCount:$.findMatchCount,findMatchIndex:$.findMatchIndex,findInputRef:$.findInputRef,replaceInputRef:$.replaceInputRef,onFindInput:$.onFindInput,findNext:$.findNext,findPrev:$.findPrev,openFindBar:$.openFindBar,closeFindBar:$.closeFindBar,toggleReplaceBar:$.toggleReplaceBar,replaceOne:$.replaceOne,replaceAll:$.replaceAll,selectedPaths:Q.selectedPaths,fileOperating:Q.fileOperating,fileOpFeedback:Q.fileOpFeedback,newFileDialogVisible:Q.newFileDialogVisible,newFileName:Q.newFileName,newFileType:Q.newFileType,newFileInput:Q.newFileInput,moveDialogVisible:Q.moveDialogVisible,moveDestination:Q.moveDestination,moveDestInput:Q.moveDestInput,toggleSelection:Q.toggleSelection,clearSelection:Q.clearSelection,showNewFileDialog:Q.showNewFileDialog,confirmNewFile:Q.confirmNewFile,deleteSingleFile:G,deleteSelected:de,openMoveDialog:Q.openMoveDialog,confirmMove:Q.confirmMove,contextMenu:Q.contextMenu,showContextMenu:Q.showContextMenu,hideContextMenu:Q.hideContextMenu,ctxRename:Q.ctxRename,ctxCopy:Q.ctxCopy,ctxMoveTo:Q.ctxMoveTo,ctxDelete:we,ctxDownload:Q.ctxDownload,downloadActiveFile:ue,renameDialogVisible:Q.renameDialogVisible,renameNewName:Q.renameNewName,renameInput:Q.renameInput,confirmRename:Q.confirmRename,dragState:Q.dragState,externalDropActive:Q.externalDropActive,onDragStart:Q.onDragStart,onDragOver:Q.onDragOver,onDragLeave:Q.onDragLeave,onDrop:se,onTreeDragOver:Q.onTreeDragOver,onTreeDragLeave:Q.onTreeDragLeave,onTreeDrop:ve,loadRootDirectory:T.loadRootDirectory,onTreeItemClick:T.onTreeItemClick,openFileInTab:I.openFileInTab,switchToTab:I.switchToTab,closeFileTab:I.closeFileTab,saveFile:I.saveFile,openFolderPicker:ke.openFolderPicker,folderPickerNavigateUp:ke.folderPickerNavigateUp,folderPickerSelectItem:ke.folderPickerSelectItem,folderPickerEnter:ke.folderPickerEnter,confirmFolderPicker:ke.confirmFolderPicker,getFileIcon:()=>"",getFileIconHtml:c,getFolderIcon:d,formatSize:u,onImagePreviewLoad:g,onImagePreviewError:p,onVideoPreviewLoad:f,onVideoPreviewError:m,refresh:T.refresh,placeholderPath:Vue.computed(()=>{let D=a();return D?n("files.workDir",{dir:D}):n("files.enterDirPath")})}}}});var Jk,sm,nm=B(()=>{Ah();Oh();tm();Jk=Object.freeze({terminal:"TerminalTab",git:"GitStatusTab",files:"FilesTab"}),sm={name:"WorkbenchCapabilityHost",components:{TerminalTab:Ch,GitStatusTab:Fh,FilesTab:em},props:{activeCapability:{type:String,default:null},retainedCapabilities:{type:Array,default:()=>[]},routeProps:{type:Object,required:!0}},template:`
2812
2815
  <div class="workbench-capability-host" :class="activeCapability ? 'capability-' + activeCapability : ''">
2813
2816
  <component
2814
2817
  v-for="capability in mountedCapabilities"
@@ -2994,7 +2997,7 @@ ${String(e||"").trim()}
2994
2997
  </div>
2995
2998
  </div>
2996
2999
  </section>
2997
- `,setup(e){let t=ko(),s=Vue.ref(null),n=Vue.ref(null),r=Vue.ref(!1),i=Vue.ref(!1),o=Vue.ref(!1),a=Vue.ref(!1),l=Vue.ref(!1),c=Vue.ref(!1),d=Vue.ref(""),u=Vue.ref(""),g=Vue.ref(""),p=Vue.ref(null),f=null,m=!1,v=sS(J=>t.sendControl(e.agentId,p.value,J)),y=nS(v);t.installMessageListener();let h=Vue.computed(()=>t.runtimeStatus[e.agentId]||(e.runtimeReady?{supported:!0,installed:!0,enabled:!0,ready:!0,state:"ready"}:null)),k=Vue.computed(()=>t.installProgress[e.agentId]||null),S=Vue.computed(()=>i.value||h.value?.state==="installing"),b=Vue.computed(()=>S.value||o.value||h.value?.state==="probing"),w=Vue.computed(()=>Kc(h.value?.downloadBytes)),P=Vue.computed(()=>{let J=Number(k.value?.downloadedBytes??h.value?.downloadedBytes)||0,D=Number(k.value?.totalBytes??h.value?.totalBytes??h.value?.downloadBytes)||0;return D<=0?0:Math.min(100,Math.max(0,Math.round(J*100/D)))}),x=Vue.computed(()=>{let J=Number(k.value?.downloadedBytes??h.value?.downloadedBytes)||0,D=Number(k.value?.totalBytes??h.value?.totalBytes??h.value?.downloadBytes)||0;return Oe("workbench.browserInstallProgress",{downloaded:Kc(J),total:Kc(D)})}),Y=Vue.computed(()=>`${e.agentId||""}\0${p.value||""}`),L=Vue.computed(()=>p.value&&t.sessions[Y.value]||null),U=Vue.computed(()=>p.value&&t.peers[Y.value]||null),E=Vue.computed(()=>U.value?.state==="connected"),oe=Vue.computed(()=>{let J=t.errorCodes[Y.value];return J==="browser_ice_servers_missing"?Oe("workbench.browserIceServersMissing"):J==="browser_ice_connection_failed"?Oe("workbench.browserIceConnectionFailed"):J==="browser_peer_attach_timeout"?Oe("workbench.browserPeerAttachTimeout"):t.errors[Y.value]||""}),q=Vue.computed(()=>{let J=t.peerDiagnostics[Y.value];if(!J||E.value||!L.value)return"";let D=J.iceConnectionState||J.connectionState||"new",ye=Number(J.candidateErrors)||0;return ye>0?`${D} \xB7 ICE ${ye}`:D}),I=Vue.computed(()=>g.value||oe.value),T=Vue.computed(()=>E.value?"connected":I.value||u.value||h.value?.safeError?"failed":"connecting"),R=Vue.computed(()=>L.value?.activeUrl||""),M=Vue.computed(()=>S.value?Oe("workbench.browserStatusInstalling"):o.value||h.value?.state==="probing"?Oe("workbench.browserStatusProbing"):I.value?I.value:E.value?p.value?"WebRTC":"":L.value?Oe("workbench.browserStatusConnecting"):""),$=()=>e.runtimeProvider==="yeaft"&&e.sessionId?{kind:"yeaft-session",sessionId:e.sessionId}:e.sessionId?{kind:"chat-conversation",conversationId:e.sessionId}:null,j=()=>{clearTimeout(f),f=null},z=()=>{j(),!(m||i.value||!["installing","probing"].includes(h.value?.state))&&(f=setTimeout(()=>{X({startWhenReady:!0})},2e3))},Q=async()=>{!p.value||!s.value||(t.detach(e.agentId,p.value,{notify:!0}),await t.attach({agentId:e.agentId,browserSessionId:p.value,videoElement:s.value}))},ae=async(J=null)=>{if(!(a.value||!e.agentId||h.value?.ready!==!0)){a.value=!0,g.value="";try{let D=$(),Me=(await t.listSessions(e.agentId)).find(ze=>ze.state==="ready"&&rS(ze,D))||null;if(Me||(Me=await t.createSession({agentId:e.agentId,sourceRef:D,initialUrl:J||"about:blank",locale:document.documentElement.lang||"en-US",viewport:{width:1280,height:720,deviceScaleFactor:1}})),p.value=Me.browserSessionId,d.value=J||(Me.activeUrl==="about:blank"?"":Me.activeUrl),a.value=!1,await Vue.nextTick(),await Q(),J&&Me.activeUrl!==J){let ze=Date.now()+1e4;for(;!t.interactiveReady(e.agentId,Me.browserSessionId);){if(Date.now()>=ze)throw new Error(Oe("workbench.browserInteractionUnavailable"));await new Promise(Ye=>setTimeout(Ye,50))}t.sendControl(e.agentId,Me.browserSessionId,{type:"navigate",url:J})}}catch(D){g.value=D?.message||String(D)}finally{a.value=!1}}},ke=async()=>{let J=eS(d.value);if(!J){g.value=Oe("workbench.browserAddressInvalid");return}if(g.value="",!L.value){await ae(J);return}c.value=!0;try{if(!t.sendControl(e.agentId,p.value,{type:"navigate",url:J}))throw new Error(Oe("workbench.browserInteractionUnavailable"));d.value=J}catch(D){g.value=D?.message||String(D)}finally{c.value=!1}},N=J=>tS(J,s.value,L.value?.viewport),G=J=>{let D=N(J);D&&t.sendPointer(e.agentId,p.value,{type:"pointerMove",...D})},de=J=>["left","middle","right"][J]||"left",we=J=>{let D=N(J);D&&(n.value?.focus?.({preventScroll:!0}),s.value?.setPointerCapture?.(J.pointerId),v.pointerDown(de(J.button),D))},se=J=>{v.pointerUp(de(J.button),N(J))},ve=J=>t.sendControl(e.agentId,p.value,{type:"wheel",deltaX:J.deltaX,deltaY:J.deltaY}),Ie=J=>{v.keyDown(J)&&J.preventDefault()},ue=J=>{v.keyUp(J.key)&&J.preventDefault()},re=y.compositionstart,te=y.compositionend,V=y.input,ce=()=>v.reset(),X=async({startWhenReady:J=!1,preserveError:D=!1}={})=>{if(!(r.value||!e.agentId||t.protocolSupported!==!0)){r.value=!0,D||(u.value="");try{let ye=await t.getRuntimeStatus(e.agentId);if(m)return;["installing","probing"].includes(ye.state)?z():j(),J&&ye.ready===!0&&L.value&&await Q()}catch(ye){(!D||!u.value)&&(u.value=ye?.message||String(ye))}finally{r.value=!1}}},F=async()=>{let J=h.value;if(b.value||!J)return;!J.installed?i.value=!0:o.value=!0,u.value="",j();try{await t.setupRuntime(e.agentId,J)}catch(ye){u.value=ye?.message||String(ye),await X({preserveError:!0})}finally{i.value=!1,o.value=!1,z()}},Z=async()=>{if(!L.value||l.value)return;l.value=!0,g.value="";let J=p.value;try{t.detach(e.agentId,J,{notify:!1}),await t.closeSession(e.agentId,J,L.value.revision),p.value=null}catch(D){g.value=D?.message||String(D)}finally{l.value=!1}},fe=()=>ce(),Re=()=>{document.visibilityState==="hidden"&&ce()};return Vue.onMounted(()=>{window.addEventListener("blur",fe),document.addEventListener("visibilitychange",Re),t.protocolSupported===!0&&X()}),Vue.watch(()=>t.protocolSupported,(J,D)=>{J===!0&&D!==!0&&X(),J===!1&&(u.value=Oe("workbench.browserProtocolUnavailable"))}),Vue.watch(()=>e.runtimeReady,(J,D)=>{!J||D===!0||m||(delete t.runtimeStatus[e.agentId],X())}),Vue.watch(()=>h.value?.state,J=>{["installing","probing"].includes(J)?z():j()}),Vue.watch(R,J=>{J&&J!=="about:blank"&&document.activeElement?.closest?.(".browser-location")==null&&(d.value=J)}),Vue.onUnmounted(()=>{m=!0,j(),window.removeEventListener("blur",fe),document.removeEventListener("visibilitychange",Re),ce(),p.value&&t.detach(e.agentId,p.value,{notify:!0})}),{video:s,inputSink:n,runtimeLoading:r,installing:i,enabling:o,viewerLoading:a,closing:l,navigating:c,address:d,setupError:u,displayError:I,peerDiagnosticText:q,runtimeStatus:h,runtimeInstalling:S,setupInProgress:b,downloadSize:w,progressPercent:P,progressText:x,snapshot:L,connected:E,connectionClass:T,displayUrl:R,statusText:M,refreshRuntime:X,setupRuntime:F,attach:Q,startViewer:ae,navigate:ke,onPointerMove:G,onPointerDown:we,onPointerUp:se,onWheel:ve,onKeyDown:Ie,onKeyUp:ue,onCompositionStart:re,onCompositionEnd:te,onTextInput:V,releaseInput:ce,closeBrowser:Z}}}});var ra,zc=B(()=>{nm();im();As();ra={name:"WorkbenchPanel",components:{WorkbenchCapabilityHost:sm,BrowserPanel:rm},template:`
3000
+ `,setup(e){let t=ko(),s=Vue.ref(null),n=Vue.ref(null),r=Vue.ref(!1),i=Vue.ref(!1),o=Vue.ref(!1),a=Vue.ref(!1),l=Vue.ref(!1),c=Vue.ref(!1),d=Vue.ref(""),u=Vue.ref(""),g=Vue.ref(""),p=Vue.ref(null),f=null,m=!1,v=sS(J=>t.sendControl(e.agentId,p.value,J)),b=nS(v);t.installMessageListener();let h=Vue.computed(()=>t.runtimeStatus[e.agentId]||(e.runtimeReady?{supported:!0,installed:!0,enabled:!0,ready:!0,state:"ready"}:null)),k=Vue.computed(()=>t.installProgress[e.agentId]||null),S=Vue.computed(()=>i.value||h.value?.state==="installing"),y=Vue.computed(()=>S.value||o.value||h.value?.state==="probing"),w=Vue.computed(()=>Kc(h.value?.downloadBytes)),P=Vue.computed(()=>{let J=Number(k.value?.downloadedBytes??h.value?.downloadedBytes)||0,D=Number(k.value?.totalBytes??h.value?.totalBytes??h.value?.downloadBytes)||0;return D<=0?0:Math.min(100,Math.max(0,Math.round(J*100/D)))}),x=Vue.computed(()=>{let J=Number(k.value?.downloadedBytes??h.value?.downloadedBytes)||0,D=Number(k.value?.totalBytes??h.value?.totalBytes??h.value?.downloadBytes)||0;return Oe("workbench.browserInstallProgress",{downloaded:Kc(J),total:Kc(D)})}),Y=Vue.computed(()=>`${e.agentId||""}\0${p.value||""}`),L=Vue.computed(()=>p.value&&t.sessions[Y.value]||null),U=Vue.computed(()=>p.value&&t.peers[Y.value]||null),E=Vue.computed(()=>U.value?.state==="connected"),oe=Vue.computed(()=>{let J=t.errorCodes[Y.value];return J==="browser_ice_servers_missing"?Oe("workbench.browserIceServersMissing"):J==="browser_ice_connection_failed"?Oe("workbench.browserIceConnectionFailed"):J==="browser_peer_attach_timeout"?Oe("workbench.browserPeerAttachTimeout"):t.errors[Y.value]||""}),q=Vue.computed(()=>{let J=t.peerDiagnostics[Y.value];if(!J||E.value||!L.value)return"";let D=J.iceConnectionState||J.connectionState||"new",ye=Number(J.candidateErrors)||0;return ye>0?`${D} \xB7 ICE ${ye}`:D}),I=Vue.computed(()=>g.value||oe.value),T=Vue.computed(()=>E.value?"connected":I.value||u.value||h.value?.safeError?"failed":"connecting"),R=Vue.computed(()=>L.value?.activeUrl||""),M=Vue.computed(()=>S.value?Oe("workbench.browserStatusInstalling"):o.value||h.value?.state==="probing"?Oe("workbench.browserStatusProbing"):I.value?I.value:E.value?p.value?"WebRTC":"":L.value?Oe("workbench.browserStatusConnecting"):""),$=()=>e.runtimeProvider==="yeaft"&&e.sessionId?{kind:"yeaft-session",sessionId:e.sessionId}:e.sessionId?{kind:"chat-conversation",conversationId:e.sessionId}:null,j=()=>{clearTimeout(f),f=null},z=()=>{j(),!(m||i.value||!["installing","probing"].includes(h.value?.state))&&(f=setTimeout(()=>{X({startWhenReady:!0})},2e3))},Q=async()=>{!p.value||!s.value||(t.detach(e.agentId,p.value,{notify:!0}),await t.attach({agentId:e.agentId,browserSessionId:p.value,videoElement:s.value}))},ae=async(J=null)=>{if(!(a.value||!e.agentId||h.value?.ready!==!0)){a.value=!0,g.value="";try{let D=$(),Me=(await t.listSessions(e.agentId)).find(ze=>ze.state==="ready"&&rS(ze,D))||null;if(Me||(Me=await t.createSession({agentId:e.agentId,sourceRef:D,initialUrl:J||"about:blank",locale:document.documentElement.lang||"en-US",viewport:{width:1280,height:720,deviceScaleFactor:1}})),p.value=Me.browserSessionId,d.value=J||(Me.activeUrl==="about:blank"?"":Me.activeUrl),a.value=!1,await Vue.nextTick(),await Q(),J&&Me.activeUrl!==J){let ze=Date.now()+1e4;for(;!t.interactiveReady(e.agentId,Me.browserSessionId);){if(Date.now()>=ze)throw new Error(Oe("workbench.browserInteractionUnavailable"));await new Promise(Ye=>setTimeout(Ye,50))}t.sendControl(e.agentId,Me.browserSessionId,{type:"navigate",url:J})}}catch(D){g.value=D?.message||String(D)}finally{a.value=!1}}},ke=async()=>{let J=eS(d.value);if(!J){g.value=Oe("workbench.browserAddressInvalid");return}if(g.value="",!L.value){await ae(J);return}c.value=!0;try{if(!t.sendControl(e.agentId,p.value,{type:"navigate",url:J}))throw new Error(Oe("workbench.browserInteractionUnavailable"));d.value=J}catch(D){g.value=D?.message||String(D)}finally{c.value=!1}},N=J=>tS(J,s.value,L.value?.viewport),G=J=>{let D=N(J);D&&t.sendPointer(e.agentId,p.value,{type:"pointerMove",...D})},de=J=>["left","middle","right"][J]||"left",we=J=>{let D=N(J);D&&(n.value?.focus?.({preventScroll:!0}),s.value?.setPointerCapture?.(J.pointerId),v.pointerDown(de(J.button),D))},se=J=>{v.pointerUp(de(J.button),N(J))},ve=J=>t.sendControl(e.agentId,p.value,{type:"wheel",deltaX:J.deltaX,deltaY:J.deltaY}),Ie=J=>{v.keyDown(J)&&J.preventDefault()},ue=J=>{v.keyUp(J.key)&&J.preventDefault()},re=b.compositionstart,te=b.compositionend,V=b.input,ce=()=>v.reset(),X=async({startWhenReady:J=!1,preserveError:D=!1}={})=>{if(!(r.value||!e.agentId||t.protocolSupported!==!0)){r.value=!0,D||(u.value="");try{let ye=await t.getRuntimeStatus(e.agentId);if(m)return;["installing","probing"].includes(ye.state)?z():j(),J&&ye.ready===!0&&L.value&&await Q()}catch(ye){(!D||!u.value)&&(u.value=ye?.message||String(ye))}finally{r.value=!1}}},F=async()=>{let J=h.value;if(y.value||!J)return;!J.installed?i.value=!0:o.value=!0,u.value="",j();try{await t.setupRuntime(e.agentId,J)}catch(ye){u.value=ye?.message||String(ye),await X({preserveError:!0})}finally{i.value=!1,o.value=!1,z()}},Z=async()=>{if(!L.value||l.value)return;l.value=!0,g.value="";let J=p.value;try{t.detach(e.agentId,J,{notify:!1}),await t.closeSession(e.agentId,J,L.value.revision),p.value=null}catch(D){g.value=D?.message||String(D)}finally{l.value=!1}},fe=()=>ce(),Re=()=>{document.visibilityState==="hidden"&&ce()};return Vue.onMounted(()=>{window.addEventListener("blur",fe),document.addEventListener("visibilitychange",Re),t.protocolSupported===!0&&X()}),Vue.watch(()=>t.protocolSupported,(J,D)=>{J===!0&&D!==!0&&X(),J===!1&&(u.value=Oe("workbench.browserProtocolUnavailable"))}),Vue.watch(()=>e.runtimeReady,(J,D)=>{!J||D===!0||m||(delete t.runtimeStatus[e.agentId],X())}),Vue.watch(()=>h.value?.state,J=>{["installing","probing"].includes(J)?z():j()}),Vue.watch(R,J=>{J&&J!=="about:blank"&&document.activeElement?.closest?.(".browser-location")==null&&(d.value=J)}),Vue.onUnmounted(()=>{m=!0,j(),window.removeEventListener("blur",fe),document.removeEventListener("visibilitychange",Re),ce(),p.value&&t.detach(e.agentId,p.value,{notify:!0})}),{video:s,inputSink:n,runtimeLoading:r,installing:i,enabling:o,viewerLoading:a,closing:l,navigating:c,address:d,setupError:u,displayError:I,peerDiagnosticText:q,runtimeStatus:h,runtimeInstalling:S,setupInProgress:y,downloadSize:w,progressPercent:P,progressText:x,snapshot:L,connected:E,connectionClass:T,displayUrl:R,statusText:M,refreshRuntime:X,setupRuntime:F,attach:Q,startViewer:ae,navigate:ke,onPointerMove:G,onPointerDown:we,onPointerUp:se,onWheel:ve,onKeyDown:Ie,onKeyUp:ue,onCompositionStart:re,onCompositionEnd:te,onTextInput:V,releaseInput:ce,closeBrowser:Z}}}});var ra,zc=B(()=>{nm();im();As();ra={name:"WorkbenchPanel",components:{WorkbenchCapabilityHost:sm,BrowserPanel:rm},template:`
2998
3001
  <div ref="panelRoot" class="workbench-panel" :class="{ expanded: store.workbenchExpanded, maximized: store.workbenchMaximized }" :style="panelStyle">
2999
3002
  <div class="workbench-content" v-show="store.workbenchExpanded">
3000
3003
  <header class="workbench-header">
@@ -3210,7 +3213,7 @@ ${String(e||"").trim()}
3210
3213
 
3211
3214
  <div class="resize-handle" @mousedown="startResize" @touchstart.prevent="startResize" v-if="store.workbenchExpanded"></div>
3212
3215
  </div>
3213
- `,setup(){let e=Pinia.useChatStore(),t=Vue.ref(null),s=Vue.ref(null),n=Vue.ref(null),r=Vue.ref(null),i=Vue.ref(!1),o=Vue.ref(null),a=Vue.ref(null),l=Vue.ref(null),c=Vue.ref(null),d=Vue.ref(null),u=Vue.reactive({visible:!1,x:0,y:0}),g=Vue.reactive({visible:!1,x:0,y:0,itemId:"",index:-1}),p=Vue.ref([]),f=new Map,m=!1,v=Vue.getCurrentInstance(),y=(O,ne)=>v?.proxy?.$t?.(O,ne)||O,h=Vue.computed(()=>e.activeSessionRoute||null),k=Vue.computed(()=>yt(h.value)),S=Vue.computed(()=>e.effectiveWorkDir||""),b=Vue.computed(()=>Tn(k.value,S.value)),w=Vue.computed(()=>`${k.value}\0${b.value}`),P=Vue.computed(()=>({routeKey:k.value,runtimeProvider:h.value?.runtimeProvider||"",agentId:h.value?.agentId||"",sessionId:h.value?.sessionId||"",conversationId:Jr(k.value),workDir:S.value,workspaceGeneration:b.value})),x=Vue.computed(()=>e.workbenchRouteProtocolSupported===!0&&e.hasAgentCapability(h.value?.agentId,"workbench_session_routes")),Y=Vue.computed(()=>x.value&&e.hasAgentCapability(h.value?.agentId,"terminal")),L=Vue.computed(()=>x.value&&e.hasAgentCapability(h.value?.agentId,"file_editor")),U=Vue.computed(()=>e.browserRuntimeServerEnabled===!0&&e.browserRuntimeProtocolSupported===!0&&e.browserRuntimeSetupProtocolSupported===!0&&e.hasCapability("browser_runtime_setup")),E=Vue.computed(()=>e.browserRuntimeServerEnabled===!0&&e.browserRuntimeProtocolSupported===!0&&e.hasCapability("browser_runtime")&&e.hasCapability("browser_webrtc")&&(e.hasCapability("browser_capture_tab")||e.hasCapability("browser_capture_cdp"))),oe=Vue.computed(()=>E.value||U.value),q=(O,ne,be,Pe,qe=Pe)=>({id:O,titleKey:ne,descriptionKey:be,available:Pe,ready:qe,statusKey:Pe?qe?"workbench.available":"workbench.enableRequired":"workbench.unavailable"}),I=Vue.computed(()=>[q("terminal","workbench.terminal","workbench.terminalDescription",Y.value),q("git","workbench.git","workbench.gitDescription",L.value),q("files","workbench.files","workbench.filesDescription",L.value),q("browser","workbench.browser","workbench.browserDescription",oe.value,E.value)]),T=Vue.ref(null),R=Vue.reactive(new Set),M=Vue.reactive([]),$=Vue.ref([]),j=Vue.ref(""),z=new Map,Q=Vue.computed(()=>I.value.find(O=>O.id===T.value)||null),ae=Vue.computed(()=>Q.value?.titleKey||"workbench.title"),ke=Vue.computed(()=>Q.value?.available===!1),N=Vue.computed(()=>Q.value?.available&&["terminal","git","files"].includes(T.value)&&we(T.value)?T.value:null),G=Vue.computed(()=>({openCapabilities:M.filter(O=>I.value.find(be=>be.id===O)?.available&&["terminal","git","files"].includes(O)),routeProps:{...P.value}})),de=O=>`${w.value}\0${O}`,we=O=>R.has(de(O)),se=O=>{M.includes(O)||M.push(O)},ve=O=>{let ne=I.value.find(be=>be.id===O);return ne?y(ne.titleKey):O},Ie=O=>`file:${O}`,ue=Vue.computed(()=>{let O=[];for(let ne of M){if(ne==="files"){for(let be of $.value)O.push({id:Ie(be.path),capabilityId:"files",path:be.path,label:be.name,title:be.path,dirty:be.isDirty});$.value.length===0&&O.push({id:"files",capabilityId:"files",label:ve("files")});continue}O.push({id:ne,capabilityId:ne,label:ve(ne)})}return O}),re=Vue.computed(()=>T.value==="files"&&j.value?Ie(j.value):T.value),te=Vue.computed(()=>new Set(p.value)),V=Vue.computed(()=>ue.value.filter(O=>O.id===re.value||!te.value.has(O.id))),ce=Vue.computed(()=>ue.value.filter(O=>O.id!==re.value&&te.value.has(O.id))),X=()=>{w.value&&z.set(w.value,{activeCapability:T.value,openCapabilities:[...M]})},F=()=>{let O=z.get(w.value);M.splice(0,M.length,...O?.openCapabilities||[]);let ne=O?.activeCapability||M[0]||null;if(!ne||!I.value.some(be=>be.id===ne)){T.value=null;return}R.add(de(ne)),T.value=ne},Z=()=>[...a.value?.querySelectorAll(".workbench-add-menu-item")||[]],fe=(O=0)=>Vue.nextTick(()=>{let ne=Z();ne[Math.max(0,Math.min(O,ne.length-1))]?.focus()}),Re=async()=>{await Vue.nextTick();let O=o.value?.getBoundingClientRect(),ne=a.value;if(!O||!ne)return;let be=8,Pe=Math.min(ne.getBoundingClientRect().width,window.innerWidth-be*2),qe=Math.max(be,Math.min(O.left,window.innerWidth-Pe-be));ne.style.left=`${qe}px`,ne.style.top=`${O.bottom+4}px`},J=(O=0)=>{i.value=!0,Re(),fe(O)},D=(O=!1)=>{i.value=!1,O&&Vue.nextTick(()=>o.value?.focus())},ye=()=>{i.value?D():J()},Me=O=>{O.key==="ArrowDown"?(O.preventDefault(),J(0)):O.key==="ArrowUp"?(O.preventDefault(),J(I.value.length-1)):O.key==="Escape"&&i.value&&(O.preventDefault(),D(!0))},ze=O=>{let ne=Z(),be=ne.indexOf(document.activeElement),Pe=be;if(O.key==="ArrowDown")Pe=(be+1)%ne.length;else if(O.key==="ArrowUp")Pe=(be-1+ne.length)%ne.length;else if(O.key==="Home")Pe=0;else if(O.key==="End")Pe=ne.length-1;else if(O.key==="Escape"){O.preventDefault(),D(!0);return}else if(O.key==="Tab"){D();return}else return;O.preventDefault(),ne[Pe]?.focus()},Ye=O=>!I.value.some(ne=>ne.id===O)||["terminal","git","files"].includes(O)&&!k.value?!1:(se(O),R.add(de(O)),T.value=O,D(),X(),!0),rt=O=>{let ne=O.detail;!ne||ne.routeKey!==k.value||!["terminal","files","git"].includes(ne.capabilityId)||!I.value.some(be=>be.id===ne.capabilityId&&be.available)||Ye(ne.capabilityId)&&(e.openWorkbench(),ne.accepted=!0)},ut=({routeKey:O,workspaceGeneration:ne})=>new Promise(be=>{window.dispatchEvent(new CustomEvent("workbench-close-files-capability",{detail:{routeKey:O,workspaceGeneration:ne,resolve:be}}))}),at=O=>{let ne=M.indexOf(O);return ne<0?!1:(T.value===O&&(T.value=M[ne+1]||M[ne-1]||null),M.splice(ne,1),R.delete(de(O)),O==="files"&&($.value=[],j.value=""),X(),!0)},W=async O=>{let ne=O||T.value,be=w.value;return!M.includes(ne)||ne==="files"&&L.value&&we(ne)&&(!await ut({routeKey:k.value,workspaceGeneration:b.value})||w.value!==be)?!1:at(ne)},ie=O=>{Ye(O.capabilityId),O.path&&window.dispatchEvent(new CustomEvent("workbench-select-file-item",{detail:{routeKey:k.value,workspaceGeneration:b.value,path:O.path}}))},me=O=>{if(O.path){window.dispatchEvent(new CustomEvent("workbench-close-file-item",{detail:{routeKey:k.value,workspaceGeneration:b.value,path:O.path}}));return}W(O.capabilityId)},he=(O,ne)=>{let Pe=O?.offsetWidth||220,qe=O?.offsetHeight||200;return{x:Math.max(8,Math.min(ne.left,window.innerWidth-Pe-8)),y:Math.max(8,Math.min(ne.bottom+4,window.innerHeight-qe-8))}},Ee=()=>{u.visible=!1,g.visible=!1},Ue=()=>[...c.value?.querySelectorAll(".ctx-menu-item:not(:disabled)")||[]],Mt=(O=0)=>Vue.nextTick(()=>{let ne=Ue();if(!ne.length)return;let be=Math.max(0,Math.min(O,ne.length-1));ne[be]?.focus()}),Qe=async(O=0)=>{g.visible=!1,u.visible=!0,await Vue.nextTick();let ne=l.value?.getBoundingClientRect();ne&&Object.assign(u,he(c.value,ne)),Mt(O)},mt=(O=!1)=>{u.visible=!1,O&&Vue.nextTick(()=>l.value?.focus())},Et=()=>{u.visible?mt():Qe()},et=O=>{O.key==="ArrowDown"?(O.preventDefault(),Qe(0)):O.key==="ArrowUp"?(O.preventDefault(),Qe(ce.value.length-1)):O.key==="Escape"&&u.visible&&(O.preventDefault(),mt(!0))},lt=O=>{let ne=Ue(),be=ne.indexOf(document.activeElement),Pe=be;if(O.key==="ArrowDown")Pe=(be+1)%ne.length;else if(O.key==="ArrowUp")Pe=(be-1+ne.length)%ne.length;else if(O.key==="Home")Pe=0;else if(O.key==="End")Pe=ne.length-1;else if(O.key==="Escape"){O.preventDefault(),mt(!0);return}else if(O.key==="Tab"){O.preventDefault();let qe=O.shiftKey?l.value:t.value?.querySelector(".workbench-maximize-btn:not(:disabled)");mt(),Vue.nextTick(()=>qe?.focus());return}else return;O.preventDefault(),ne[Pe]?.focus()},_=O=>{ie(O),Ee()},ee=async(O,ne)=>{D(),u.visible=!1;let be=ue.value.findIndex(it=>it.id===ne.id);Object.assign(g,{visible:!0,x:O.clientX,y:O.clientY,itemId:ne.id,index:be}),await Vue.nextTick();let Pe=d.value?.offsetWidth||180,qe=d.value?.offsetHeight||220;g.x=Math.max(8,Math.min(O.clientX,window.innerWidth-Pe-8)),g.y=Math.max(8,Math.min(O.clientY,window.innerHeight-qe-8))},Se=O=>new Promise(ne=>{window.dispatchEvent(new CustomEvent("workbench-close-file-items",{detail:{routeKey:k.value,workspaceGeneration:b.value,paths:O,resolve:ne}}))}),_e=async O=>{let ne=[...ue.value],be=ne.findIndex(Je=>Je.id===g.itemId);if(be<0){Ee();return}let Pe=[];O==="current"?Pe=[ne[be]]:O==="others"?Pe=ne.filter((Je,Pt)=>Pt!==be):O==="left"?Pe=ne.slice(0,be):O==="right"?Pe=ne.slice(be+1):O==="all"&&(Pe=ne),Ee();let qe=Pe.filter(Je=>Je.path).map(Je=>Je.path),it=qe.length>0&&qe.length===$.value.length&&$.value.every(Je=>qe.includes(Je.path));if(!(qe.length&&!await Se(qe))){it&&at("files");for(let Je of Pe.filter(Pt=>!Pt.path))if(!await W(Je.capabilityId))break}},Fe=O=>Vue.nextTick(()=>{[...n.value?.querySelectorAll(".workbench-item-tab")||[]].find(be=>be.dataset.workbenchItemId===O)?.querySelector(".workbench-item-select")?.focus()}),Xe=(O,ne)=>{let be=ue.value,Pe=be.findIndex(Je=>Je.id===ne.id),qe=Pe;if(O.key==="ArrowLeft")qe=Math.max(0,Pe-1);else if(O.key==="ArrowRight")qe=Math.min(be.length-1,Pe+1);else if(O.key==="Home")qe=0;else if(O.key==="End")qe=be.length-1;else return;O.preventDefault();let it=be[qe];it&&(ie(it),Fe(it.id))},pt=Vue.ref(0),gt=Vue.ref(!1),Dt=Vue.ref(!1),$t=null,Lt=null,tn=()=>{Lt?.cleanup()};Vue.watch(w,(O,ne)=>{if(O===ne)return;tn(),ne&&(z.set(ne,{activeCapability:T.value,openCapabilities:[...M]}),e.rememberWorkbenchPanelState(ne.split("\0",1)[0],Dt.value?pt.value:void 0)),e.restoreWorkbenchPanelState(h.value);let be=e.workbenchPanelWidthForRoute(h.value);Dt.value=be!==null,pt.value=be||0,$.value=[],j.value="",F()},{flush:"sync",immediate:!0});let Dn=()=>Math.round(t.value?.getBoundingClientRect?.().width||0),Sr=()=>{let O=Math.floor(s.value?.clientWidth||s.value?.getBoundingClientRect?.().width||0);if(O<=0)return;let ne=new Set(ue.value.map(He=>He.id));for(let He of f.keys())ne.has(He)||f.delete(He);for(let He of n.value?.querySelectorAll(".workbench-item-tab")||[]){let ct=Math.ceil(He.getBoundingClientRect?.().width||He.offsetWidth||0);He.dataset.workbenchItemId&&ct>0&&f.set(He.dataset.workbenchItemId,ct)}let be=Math.ceil(r.value?.getBoundingClientRect?.().width||r.value?.offsetWidth||32),Pe=He=>f.get(He.id)||96,qe=Math.ceil(l.value?.getBoundingClientRect?.().width||l.value?.offsetWidth||32)+6,it=O+(l.value?qe:0);if(ue.value.reduce((He,ct)=>He+Pe(ct),0)+be<=it){p.value=[],u.visible=!1;return}let Pt=Math.max(0,it-be-qe),At=re.value,bt=new Set,xt=Pt,Kt=ue.value.find(He=>He.id===At);Kt&&(bt.add(Kt.id),xt-=Pe(Kt));for(let He of ue.value){if(bt.has(He.id))continue;let ct=Pe(He);ct<=xt&&(bt.add(He.id),xt-=ct)}let Ft=ue.value.filter(He=>!bt.has(He.id)).map(He=>He.id);Ft.length===p.value.length&&Ft.every((He,ct)=>He===p.value[ct])||(p.value=Ft,Ft.length===0&&(u.visible=!1),Vue.nextTick(Jt))},Jt=()=>{m||(m=!0,Vue.nextTick(()=>{m=!1,Sr()}))},sn=()=>{window.dispatchEvent(new CustomEvent("workbench-panel-resize",{detail:{width:Dn()}}))},nn=()=>{p.value=p.value.filter(O=>O!==re.value),Jt()},$n=Vue.computed(()=>{if(!e.workbenchExpanded)return{};if(e.workbenchMaximized)return{};if(window.innerWidth<=768)return{};if(!Dt.value)return gt.value?{transition:"none"}:{};let O={width:pt.value+"px"};return gt.value&&(O.transition="none"),O}),rn=O=>{O.preventDefault(),tn();let ne=O.type==="touchstart",be=ne?O.touches[0].clientX:O.clientX,Pe=w.value,qe={...h.value};gt.value=!0;let it=Dn()||pt.value;pt.value=it,Dt.value=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none";let Je=null,Pt=()=>{document.removeEventListener("mousemove",bt),document.removeEventListener("mouseup",xt),document.removeEventListener("touchmove",bt),document.removeEventListener("touchend",xt),document.removeEventListener("touchcancel",xt),Lt===Je&&(Lt=null,gt.value=!1,document.body.style.cursor="",document.body.style.userSelect="")},At=()=>Lt===Je&&w.value===Pe,bt=Kt=>{if(!At())return;let Ft=ne?Kt.touches[0]?.clientX:Kt.clientX;if(!Number.isFinite(Ft))return;let He=be-Ft,ct=Math.max(900,window.innerWidth-100);pt.value=Math.max(280,Math.min(ct,it+He)),sn()},xt=()=>{if(!At()){Pt();return}e.rememberWorkbenchPanelState(qe,pt.value),sn(),Pt()};Je={cleanup:Pt},Lt=Je,document.addEventListener(ne?"touchmove":"mousemove",bt),document.addEventListener(ne?"touchend":"mouseup",xt),ne&&document.addEventListener("touchcancel",xt)},Ze=O=>{if(!L.value||!k.value)return;let ne={...O.detail||{}},be=ne.workbenchRouteKey||(ne.workbenchRoute?yt(ne.workbenchRoute):""),Pe=ne.workspaceGeneration||"";if(!be||!Pe||be!==k.value||Pe!==b.value)return;let qe=w.value,it={...P.value};Ye("files")&&Vue.nextTick(()=>{w.value===qe&&window.dispatchEvent(new CustomEvent("workbench-open-file-in-active-view",{detail:{...ne,agentId:it.agentId,conversationId:it.conversationId,workDir:it.workDir,workbenchRouteKey:it.routeKey,workspaceGeneration:it.workspaceGeneration}}))})},Ut=O=>{O.detail?.routeKey!==k.value||O.detail?.workspaceGeneration!==b.value||($.value=Array.isArray(O.detail.files)?O.detail.files:[],j.value=O.detail.activePath||"",$.value.length>0&&se("files"))},Fs=O=>{i.value&&!r.value?.contains(O.target)&&!a.value?.contains(O.target)&&D(),u.visible&&!l.value?.contains(O.target)&&!c.value?.contains(O.target)&&(u.visible=!1),g.visible&&!d.value?.contains(O.target)&&(g.visible=!1)};return Vue.onMounted(()=>{window.addEventListener("open-file-in-explorer",Ze),window.addEventListener("workbench-open-capability",rt),window.addEventListener("workbench-file-items-changed",Ut),document.addEventListener("click",Fs),typeof ResizeObserver<"u"&&t.value&&($t=new ResizeObserver(()=>{Jt(),sn()}),$t.observe(t.value)),window.addEventListener("resize",Jt),Jt()}),Vue.watch([re,ue],()=>Vue.nextTick(nn),{flush:"post"}),Vue.onUnmounted(()=>{tn(),window.removeEventListener("open-file-in-explorer",Ze),window.removeEventListener("workbench-open-capability",rt),window.removeEventListener("workbench-file-items-changed",Ut),document.removeEventListener("click",Fs),window.removeEventListener("resize",Jt),$t?.disconnect(),$t=null}),{store:e,panelRoot:t,tabRail:s,tabList:n,launcherRoot:r,launcherTrigger:o,launcherMenu:a,launcherOpen:i,openItemsTrigger:l,openItemsMenuElement:c,openItemsMenu:u,tabContextMenuElement:d,tabContextMenu:g,activeCapability:T,activeCapabilityTitleKey:ae,activeCapabilityUnavailable:ke,activeToolCapability:N,routeHostState:G,openCapabilities:M,activeWorkbenchItemId:re,workbenchItems:ue,visibleWorkbenchItems:V,hiddenWorkbenchItems:ce,capabilityCards:I,routeProps:P,activeRouteKey:k,workbenchContextKey:w,openCapability:Ye,closeCapability:W,toggleLauncher:ye,handleLauncherButtonKeydown:Me,handleLauncherMenuKeydown:ze,closeWorkbenchItem:me,selectWorkbenchItem:ie,selectItemFromMenu:_,toggleOpenItemsMenu:Et,handleOpenItemsButtonKeydown:et,handleOpenItemsMenuKeydown:lt,showTabContextMenu:ee,runTabContextAction:_e,handleWorkbenchTabKeydown:Xe,isCapabilityActivated:we,hasTerminal:Y,hasExplorer:L,canOpenBrowser:oe,hasBrowser:E,panelStyle:$n,startResize:rn}}}});function gs(e){let t=e?.currentTarget;t&&Ii.set(t,{startedOnOverlay:e.target===t,endedOnOverlay:!1})}function fs(e){let t=e?.currentTarget,s=t&&Ii.get(t);s&&(s.endedOnOverlay=e.target===t)}function hs(e){let t=e?.currentTarget;t&&Ii.delete(t)}function Ls(e){let t=e?.currentTarget;if(!t)return!1;let s=Ii.get(t),n=e.target===t&&s?.startedOnOverlay===!0&&s.endedOnOverlay===!0;return Ii.delete(t),n}var Ii,mr=B(()=>{Ii=new WeakMap});var Zs,om,am=B(()=>{qt();Zs=20,om={name:"DashboardTab",template:`
3216
+ `,setup(){let e=Pinia.useChatStore(),t=Vue.ref(null),s=Vue.ref(null),n=Vue.ref(null),r=Vue.ref(null),i=Vue.ref(!1),o=Vue.ref(null),a=Vue.ref(null),l=Vue.ref(null),c=Vue.ref(null),d=Vue.ref(null),u=Vue.reactive({visible:!1,x:0,y:0}),g=Vue.reactive({visible:!1,x:0,y:0,itemId:"",index:-1}),p=Vue.ref([]),f=new Map,m=!1,v=Vue.getCurrentInstance(),b=(O,ne)=>v?.proxy?.$t?.(O,ne)||O,h=Vue.computed(()=>e.activeSessionRoute||null),k=Vue.computed(()=>yt(h.value)),S=Vue.computed(()=>e.effectiveWorkDir||""),y=Vue.computed(()=>Tn(k.value,S.value)),w=Vue.computed(()=>`${k.value}\0${y.value}`),P=Vue.computed(()=>({routeKey:k.value,runtimeProvider:h.value?.runtimeProvider||"",agentId:h.value?.agentId||"",sessionId:h.value?.sessionId||"",conversationId:Jr(k.value),workDir:S.value,workspaceGeneration:y.value})),x=Vue.computed(()=>e.workbenchRouteProtocolSupported===!0&&e.hasAgentCapability(h.value?.agentId,"workbench_session_routes")),Y=Vue.computed(()=>x.value&&e.hasAgentCapability(h.value?.agentId,"terminal")),L=Vue.computed(()=>x.value&&e.hasAgentCapability(h.value?.agentId,"file_editor")),U=Vue.computed(()=>e.browserRuntimeServerEnabled===!0&&e.browserRuntimeProtocolSupported===!0&&e.browserRuntimeSetupProtocolSupported===!0&&e.hasCapability("browser_runtime_setup")),E=Vue.computed(()=>e.browserRuntimeServerEnabled===!0&&e.browserRuntimeProtocolSupported===!0&&e.hasCapability("browser_runtime")&&e.hasCapability("browser_webrtc")&&(e.hasCapability("browser_capture_tab")||e.hasCapability("browser_capture_cdp"))),oe=Vue.computed(()=>E.value||U.value),q=(O,ne,be,Pe,qe=Pe)=>({id:O,titleKey:ne,descriptionKey:be,available:Pe,ready:qe,statusKey:Pe?qe?"workbench.available":"workbench.enableRequired":"workbench.unavailable"}),I=Vue.computed(()=>[q("terminal","workbench.terminal","workbench.terminalDescription",Y.value),q("git","workbench.git","workbench.gitDescription",L.value),q("files","workbench.files","workbench.filesDescription",L.value),q("browser","workbench.browser","workbench.browserDescription",oe.value,E.value)]),T=Vue.ref(null),R=Vue.reactive(new Set),M=Vue.reactive([]),$=Vue.ref([]),j=Vue.ref(""),z=new Map,Q=Vue.computed(()=>I.value.find(O=>O.id===T.value)||null),ae=Vue.computed(()=>Q.value?.titleKey||"workbench.title"),ke=Vue.computed(()=>Q.value?.available===!1),N=Vue.computed(()=>Q.value?.available&&["terminal","git","files"].includes(T.value)&&we(T.value)?T.value:null),G=Vue.computed(()=>({openCapabilities:M.filter(O=>I.value.find(be=>be.id===O)?.available&&["terminal","git","files"].includes(O)),routeProps:{...P.value}})),de=O=>`${w.value}\0${O}`,we=O=>R.has(de(O)),se=O=>{M.includes(O)||M.push(O)},ve=O=>{let ne=I.value.find(be=>be.id===O);return ne?b(ne.titleKey):O},Ie=O=>`file:${O}`,ue=Vue.computed(()=>{let O=[];for(let ne of M){if(ne==="files"){for(let be of $.value)O.push({id:Ie(be.path),capabilityId:"files",path:be.path,label:be.name,title:be.path,dirty:be.isDirty});$.value.length===0&&O.push({id:"files",capabilityId:"files",label:ve("files")});continue}O.push({id:ne,capabilityId:ne,label:ve(ne)})}return O}),re=Vue.computed(()=>T.value==="files"&&j.value?Ie(j.value):T.value),te=Vue.computed(()=>new Set(p.value)),V=Vue.computed(()=>ue.value.filter(O=>O.id===re.value||!te.value.has(O.id))),ce=Vue.computed(()=>ue.value.filter(O=>O.id!==re.value&&te.value.has(O.id))),X=()=>{w.value&&z.set(w.value,{activeCapability:T.value,openCapabilities:[...M]})},F=()=>{let O=z.get(w.value);M.splice(0,M.length,...O?.openCapabilities||[]);let ne=O?.activeCapability||M[0]||null;if(!ne||!I.value.some(be=>be.id===ne)){T.value=null;return}R.add(de(ne)),T.value=ne},Z=()=>[...a.value?.querySelectorAll(".workbench-add-menu-item")||[]],fe=(O=0)=>Vue.nextTick(()=>{let ne=Z();ne[Math.max(0,Math.min(O,ne.length-1))]?.focus()}),Re=async()=>{await Vue.nextTick();let O=o.value?.getBoundingClientRect(),ne=a.value;if(!O||!ne)return;let be=8,Pe=Math.min(ne.getBoundingClientRect().width,window.innerWidth-be*2),qe=Math.max(be,Math.min(O.left,window.innerWidth-Pe-be));ne.style.left=`${qe}px`,ne.style.top=`${O.bottom+4}px`},J=(O=0)=>{i.value=!0,Re(),fe(O)},D=(O=!1)=>{i.value=!1,O&&Vue.nextTick(()=>o.value?.focus())},ye=()=>{i.value?D():J()},Me=O=>{O.key==="ArrowDown"?(O.preventDefault(),J(0)):O.key==="ArrowUp"?(O.preventDefault(),J(I.value.length-1)):O.key==="Escape"&&i.value&&(O.preventDefault(),D(!0))},ze=O=>{let ne=Z(),be=ne.indexOf(document.activeElement),Pe=be;if(O.key==="ArrowDown")Pe=(be+1)%ne.length;else if(O.key==="ArrowUp")Pe=(be-1+ne.length)%ne.length;else if(O.key==="Home")Pe=0;else if(O.key==="End")Pe=ne.length-1;else if(O.key==="Escape"){O.preventDefault(),D(!0);return}else if(O.key==="Tab"){D();return}else return;O.preventDefault(),ne[Pe]?.focus()},Ye=O=>!I.value.some(ne=>ne.id===O)||["terminal","git","files"].includes(O)&&!k.value?!1:(se(O),R.add(de(O)),T.value=O,D(),X(),!0),rt=O=>{let ne=O.detail;!ne||ne.routeKey!==k.value||!["terminal","files","git"].includes(ne.capabilityId)||!I.value.some(be=>be.id===ne.capabilityId&&be.available)||Ye(ne.capabilityId)&&(e.openWorkbench(),ne.accepted=!0)},ut=({routeKey:O,workspaceGeneration:ne})=>new Promise(be=>{window.dispatchEvent(new CustomEvent("workbench-close-files-capability",{detail:{routeKey:O,workspaceGeneration:ne,resolve:be}}))}),at=O=>{let ne=M.indexOf(O);return ne<0?!1:(T.value===O&&(T.value=M[ne+1]||M[ne-1]||null),M.splice(ne,1),R.delete(de(O)),O==="files"&&($.value=[],j.value=""),X(),!0)},W=async O=>{let ne=O||T.value,be=w.value;return!M.includes(ne)||ne==="files"&&L.value&&we(ne)&&(!await ut({routeKey:k.value,workspaceGeneration:y.value})||w.value!==be)?!1:at(ne)},ie=O=>{Ye(O.capabilityId),O.path&&window.dispatchEvent(new CustomEvent("workbench-select-file-item",{detail:{routeKey:k.value,workspaceGeneration:y.value,path:O.path}}))},me=O=>{if(O.path){window.dispatchEvent(new CustomEvent("workbench-close-file-item",{detail:{routeKey:k.value,workspaceGeneration:y.value,path:O.path}}));return}W(O.capabilityId)},he=(O,ne)=>{let Pe=O?.offsetWidth||220,qe=O?.offsetHeight||200;return{x:Math.max(8,Math.min(ne.left,window.innerWidth-Pe-8)),y:Math.max(8,Math.min(ne.bottom+4,window.innerHeight-qe-8))}},Ee=()=>{u.visible=!1,g.visible=!1},Ue=()=>[...c.value?.querySelectorAll(".ctx-menu-item:not(:disabled)")||[]],Mt=(O=0)=>Vue.nextTick(()=>{let ne=Ue();if(!ne.length)return;let be=Math.max(0,Math.min(O,ne.length-1));ne[be]?.focus()}),Qe=async(O=0)=>{g.visible=!1,u.visible=!0,await Vue.nextTick();let ne=l.value?.getBoundingClientRect();ne&&Object.assign(u,he(c.value,ne)),Mt(O)},mt=(O=!1)=>{u.visible=!1,O&&Vue.nextTick(()=>l.value?.focus())},Et=()=>{u.visible?mt():Qe()},et=O=>{O.key==="ArrowDown"?(O.preventDefault(),Qe(0)):O.key==="ArrowUp"?(O.preventDefault(),Qe(ce.value.length-1)):O.key==="Escape"&&u.visible&&(O.preventDefault(),mt(!0))},lt=O=>{let ne=Ue(),be=ne.indexOf(document.activeElement),Pe=be;if(O.key==="ArrowDown")Pe=(be+1)%ne.length;else if(O.key==="ArrowUp")Pe=(be-1+ne.length)%ne.length;else if(O.key==="Home")Pe=0;else if(O.key==="End")Pe=ne.length-1;else if(O.key==="Escape"){O.preventDefault(),mt(!0);return}else if(O.key==="Tab"){O.preventDefault();let qe=O.shiftKey?l.value:t.value?.querySelector(".workbench-maximize-btn:not(:disabled)");mt(),Vue.nextTick(()=>qe?.focus());return}else return;O.preventDefault(),ne[Pe]?.focus()},_=O=>{ie(O),Ee()},ee=async(O,ne)=>{D(),u.visible=!1;let be=ue.value.findIndex(it=>it.id===ne.id);Object.assign(g,{visible:!0,x:O.clientX,y:O.clientY,itemId:ne.id,index:be}),await Vue.nextTick();let Pe=d.value?.offsetWidth||180,qe=d.value?.offsetHeight||220;g.x=Math.max(8,Math.min(O.clientX,window.innerWidth-Pe-8)),g.y=Math.max(8,Math.min(O.clientY,window.innerHeight-qe-8))},Se=O=>new Promise(ne=>{window.dispatchEvent(new CustomEvent("workbench-close-file-items",{detail:{routeKey:k.value,workspaceGeneration:y.value,paths:O,resolve:ne}}))}),_e=async O=>{let ne=[...ue.value],be=ne.findIndex(Je=>Je.id===g.itemId);if(be<0){Ee();return}let Pe=[];O==="current"?Pe=[ne[be]]:O==="others"?Pe=ne.filter((Je,Pt)=>Pt!==be):O==="left"?Pe=ne.slice(0,be):O==="right"?Pe=ne.slice(be+1):O==="all"&&(Pe=ne),Ee();let qe=Pe.filter(Je=>Je.path).map(Je=>Je.path),it=qe.length>0&&qe.length===$.value.length&&$.value.every(Je=>qe.includes(Je.path));if(!(qe.length&&!await Se(qe))){it&&at("files");for(let Je of Pe.filter(Pt=>!Pt.path))if(!await W(Je.capabilityId))break}},Fe=O=>Vue.nextTick(()=>{[...n.value?.querySelectorAll(".workbench-item-tab")||[]].find(be=>be.dataset.workbenchItemId===O)?.querySelector(".workbench-item-select")?.focus()}),Xe=(O,ne)=>{let be=ue.value,Pe=be.findIndex(Je=>Je.id===ne.id),qe=Pe;if(O.key==="ArrowLeft")qe=Math.max(0,Pe-1);else if(O.key==="ArrowRight")qe=Math.min(be.length-1,Pe+1);else if(O.key==="Home")qe=0;else if(O.key==="End")qe=be.length-1;else return;O.preventDefault();let it=be[qe];it&&(ie(it),Fe(it.id))},pt=Vue.ref(0),gt=Vue.ref(!1),Dt=Vue.ref(!1),$t=null,Lt=null,tn=()=>{Lt?.cleanup()};Vue.watch(w,(O,ne)=>{if(O===ne)return;tn(),ne&&(z.set(ne,{activeCapability:T.value,openCapabilities:[...M]}),e.rememberWorkbenchPanelState(ne.split("\0",1)[0],Dt.value?pt.value:void 0)),e.restoreWorkbenchPanelState(h.value);let be=e.workbenchPanelWidthForRoute(h.value);Dt.value=be!==null,pt.value=be||0,$.value=[],j.value="",F()},{flush:"sync",immediate:!0});let Dn=()=>Math.round(t.value?.getBoundingClientRect?.().width||0),Sr=()=>{let O=Math.floor(s.value?.clientWidth||s.value?.getBoundingClientRect?.().width||0);if(O<=0)return;let ne=new Set(ue.value.map(He=>He.id));for(let He of f.keys())ne.has(He)||f.delete(He);for(let He of n.value?.querySelectorAll(".workbench-item-tab")||[]){let ct=Math.ceil(He.getBoundingClientRect?.().width||He.offsetWidth||0);He.dataset.workbenchItemId&&ct>0&&f.set(He.dataset.workbenchItemId,ct)}let be=Math.ceil(r.value?.getBoundingClientRect?.().width||r.value?.offsetWidth||32),Pe=He=>f.get(He.id)||96,qe=Math.ceil(l.value?.getBoundingClientRect?.().width||l.value?.offsetWidth||32)+6,it=O+(l.value?qe:0);if(ue.value.reduce((He,ct)=>He+Pe(ct),0)+be<=it){p.value=[],u.visible=!1;return}let Pt=Math.max(0,it-be-qe),At=re.value,bt=new Set,xt=Pt,Kt=ue.value.find(He=>He.id===At);Kt&&(bt.add(Kt.id),xt-=Pe(Kt));for(let He of ue.value){if(bt.has(He.id))continue;let ct=Pe(He);ct<=xt&&(bt.add(He.id),xt-=ct)}let Ft=ue.value.filter(He=>!bt.has(He.id)).map(He=>He.id);Ft.length===p.value.length&&Ft.every((He,ct)=>He===p.value[ct])||(p.value=Ft,Ft.length===0&&(u.visible=!1),Vue.nextTick(Jt))},Jt=()=>{m||(m=!0,Vue.nextTick(()=>{m=!1,Sr()}))},sn=()=>{window.dispatchEvent(new CustomEvent("workbench-panel-resize",{detail:{width:Dn()}}))},nn=()=>{p.value=p.value.filter(O=>O!==re.value),Jt()},$n=Vue.computed(()=>{if(!e.workbenchExpanded)return{};if(e.workbenchMaximized)return{};if(window.innerWidth<=768)return{};if(!Dt.value)return gt.value?{transition:"none"}:{};let O={width:pt.value+"px"};return gt.value&&(O.transition="none"),O}),rn=O=>{O.preventDefault(),tn();let ne=O.type==="touchstart",be=ne?O.touches[0].clientX:O.clientX,Pe=w.value,qe={...h.value};gt.value=!0;let it=Dn()||pt.value;pt.value=it,Dt.value=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none";let Je=null,Pt=()=>{document.removeEventListener("mousemove",bt),document.removeEventListener("mouseup",xt),document.removeEventListener("touchmove",bt),document.removeEventListener("touchend",xt),document.removeEventListener("touchcancel",xt),Lt===Je&&(Lt=null,gt.value=!1,document.body.style.cursor="",document.body.style.userSelect="")},At=()=>Lt===Je&&w.value===Pe,bt=Kt=>{if(!At())return;let Ft=ne?Kt.touches[0]?.clientX:Kt.clientX;if(!Number.isFinite(Ft))return;let He=be-Ft,ct=Math.max(900,window.innerWidth-100);pt.value=Math.max(280,Math.min(ct,it+He)),sn()},xt=()=>{if(!At()){Pt();return}e.rememberWorkbenchPanelState(qe,pt.value),sn(),Pt()};Je={cleanup:Pt},Lt=Je,document.addEventListener(ne?"touchmove":"mousemove",bt),document.addEventListener(ne?"touchend":"mouseup",xt),ne&&document.addEventListener("touchcancel",xt)},Ze=O=>{if(!L.value||!k.value)return;let ne={...O.detail||{}},be=ne.workbenchRouteKey||(ne.workbenchRoute?yt(ne.workbenchRoute):""),Pe=ne.workspaceGeneration||"";if(!be||!Pe||be!==k.value||Pe!==y.value)return;let qe=w.value,it={...P.value};Ye("files")&&Vue.nextTick(()=>{w.value===qe&&window.dispatchEvent(new CustomEvent("workbench-open-file-in-active-view",{detail:{...ne,agentId:it.agentId,conversationId:it.conversationId,workDir:it.workDir,workbenchRouteKey:it.routeKey,workspaceGeneration:it.workspaceGeneration}}))})},Ut=O=>{O.detail?.routeKey!==k.value||O.detail?.workspaceGeneration!==y.value||($.value=Array.isArray(O.detail.files)?O.detail.files:[],j.value=O.detail.activePath||"",$.value.length>0&&se("files"))},Fs=O=>{i.value&&!r.value?.contains(O.target)&&!a.value?.contains(O.target)&&D(),u.visible&&!l.value?.contains(O.target)&&!c.value?.contains(O.target)&&(u.visible=!1),g.visible&&!d.value?.contains(O.target)&&(g.visible=!1)};return Vue.onMounted(()=>{window.addEventListener("open-file-in-explorer",Ze),window.addEventListener("workbench-open-capability",rt),window.addEventListener("workbench-file-items-changed",Ut),document.addEventListener("click",Fs),typeof ResizeObserver<"u"&&t.value&&($t=new ResizeObserver(()=>{Jt(),sn()}),$t.observe(t.value)),window.addEventListener("resize",Jt),Jt()}),Vue.watch([re,ue],()=>Vue.nextTick(nn),{flush:"post"}),Vue.onUnmounted(()=>{tn(),window.removeEventListener("open-file-in-explorer",Ze),window.removeEventListener("workbench-open-capability",rt),window.removeEventListener("workbench-file-items-changed",Ut),document.removeEventListener("click",Fs),window.removeEventListener("resize",Jt),$t?.disconnect(),$t=null}),{store:e,panelRoot:t,tabRail:s,tabList:n,launcherRoot:r,launcherTrigger:o,launcherMenu:a,launcherOpen:i,openItemsTrigger:l,openItemsMenuElement:c,openItemsMenu:u,tabContextMenuElement:d,tabContextMenu:g,activeCapability:T,activeCapabilityTitleKey:ae,activeCapabilityUnavailable:ke,activeToolCapability:N,routeHostState:G,openCapabilities:M,activeWorkbenchItemId:re,workbenchItems:ue,visibleWorkbenchItems:V,hiddenWorkbenchItems:ce,capabilityCards:I,routeProps:P,activeRouteKey:k,workbenchContextKey:w,openCapability:Ye,closeCapability:W,toggleLauncher:ye,handleLauncherButtonKeydown:Me,handleLauncherMenuKeydown:ze,closeWorkbenchItem:me,selectWorkbenchItem:ie,selectItemFromMenu:_,toggleOpenItemsMenu:Et,handleOpenItemsButtonKeydown:et,handleOpenItemsMenuKeydown:lt,showTabContextMenu:ee,runTabContextAction:_e,handleWorkbenchTabKeydown:Xe,isCapabilityActivated:we,hasTerminal:Y,hasExplorer:L,canOpenBrowser:oe,hasBrowser:E,panelStyle:$n,startResize:rn}}}});function gs(e){let t=e?.currentTarget;t&&Ii.set(t,{startedOnOverlay:e.target===t,endedOnOverlay:!1})}function fs(e){let t=e?.currentTarget,s=t&&Ii.get(t);s&&(s.endedOnOverlay=e.target===t)}function hs(e){let t=e?.currentTarget;t&&Ii.delete(t)}function Ls(e){let t=e?.currentTarget;if(!t)return!1;let s=Ii.get(t),n=e.target===t&&s?.startedOnOverlay===!0&&s.endedOnOverlay===!0;return Ii.delete(t),n}var Ii,mr=B(()=>{Ii=new WeakMap});var Zs,om,am=B(()=>{qt();Zs=20,om={name:"DashboardTab",template:`
3214
3217
  <div class="db-container">
3215
3218
  <div v-if="loading && !loaded" class="db-loading">{{ $t('settings.dashboard.loading') }}</div>
3216
3219
  <div v-else-if="error" class="db-empty">{{ $t('settings.dashboard.error') }}</div>
@@ -3829,7 +3832,7 @@ ${String(e||"").trim()}
3829
3832
  </button>
3830
3833
  </div>
3831
3834
  </div>
3832
- `,setup(e,{emit:t}){let s=Pinia.useChatStore(),n=Vue.getCurrentInstance(),r=b=>n?.proxy?.$t?.(b)??b,i=Vue.computed(()=>s.searchSettings),o=Vue.computed(()=>s.tavilyUsage),a=Vue.computed(()=>s.tavilyUsageLoading),l=Vue.reactive({backend:"tavily",key:""}),c=Vue.ref(!1),d=Vue.ref(!1);function u(){let b=i.value;l.backend=b?.backend||"tavily",l.key="",c.value=!1}Vue.watch(i,u,{immediate:!0});let g=Vue.computed(()=>c.value?l.key:""),p=Vue.computed(()=>{let b=i.value;return b?!!((b.backend||"tavily")!==l.backend||c.value):c.value});function f(b){c.value=!0,l.key=b.target.value}function m(){!c.value&&i.value?.tavilyKeyConfigured&&(c.value=!0,l.key="")}function v(){c.value=!0,l.key=""}function y(){u()}async function h(){if(!(d.value||!p.value)){d.value=!0;try{let b={backend:l.backend};c.value&&(b.tavilyApiKey=l.key.trim());let w=await s.updateSearchSettings(b);w?.error?t("message",w.error,!0):(t("message",r("search.settings.saveSuccess"),!1),c.value&&await s.loadTavilyUsage())}catch(b){t("message",b.message||String(b),!0)}finally{d.value=!1}}}async function k(){await s.loadTavilyUsage()}function S(b,w){return w?Math.min(100,Math.round(b/w*100)):0}return Vue.onMounted(async()=>{await s.loadSearchSettings(),s.searchSettings?.tavilyKeyConfigured&&s.loadTavilyUsage()}),{settings:i,usage:o,usageLoading:a,form:l,keyDirty:c,keyDisplay:g,saving:d,dirty:p,onKeyInput:f,onKeyFocus:m,clearKey:v,reset:y,save:h,refreshUsage:k,pct:S}}}});var hm,mm=B(()=>{Ct();hm={name:"McpTab",emits:["message"],template:`
3835
+ `,setup(e,{emit:t}){let s=Pinia.useChatStore(),n=Vue.getCurrentInstance(),r=y=>n?.proxy?.$t?.(y)??y,i=Vue.computed(()=>s.searchSettings),o=Vue.computed(()=>s.tavilyUsage),a=Vue.computed(()=>s.tavilyUsageLoading),l=Vue.reactive({backend:"tavily",key:""}),c=Vue.ref(!1),d=Vue.ref(!1);function u(){let y=i.value;l.backend=y?.backend||"tavily",l.key="",c.value=!1}Vue.watch(i,u,{immediate:!0});let g=Vue.computed(()=>c.value?l.key:""),p=Vue.computed(()=>{let y=i.value;return y?!!((y.backend||"tavily")!==l.backend||c.value):c.value});function f(y){c.value=!0,l.key=y.target.value}function m(){!c.value&&i.value?.tavilyKeyConfigured&&(c.value=!0,l.key="")}function v(){c.value=!0,l.key=""}function b(){u()}async function h(){if(!(d.value||!p.value)){d.value=!0;try{let y={backend:l.backend};c.value&&(y.tavilyApiKey=l.key.trim());let w=await s.updateSearchSettings(y);w?.error?t("message",w.error,!0):(t("message",r("search.settings.saveSuccess"),!1),c.value&&await s.loadTavilyUsage())}catch(y){t("message",y.message||String(y),!0)}finally{d.value=!1}}}async function k(){await s.loadTavilyUsage()}function S(y,w){return w?Math.min(100,Math.round(y/w*100)):0}return Vue.onMounted(async()=>{await s.loadSearchSettings(),s.searchSettings?.tavilyKeyConfigured&&s.loadTavilyUsage()}),{settings:i,usage:o,usageLoading:a,form:l,keyDirty:c,keyDisplay:g,saving:d,dirty:p,onKeyInput:f,onKeyFocus:m,clearKey:v,reset:b,save:h,refreshUsage:k,pct:S}}}});var hm,mm=B(()=>{Ct();hm={name:"McpTab",emits:["message"],template:`
3833
3836
  <div class="mcp-settings-tab">
3834
3837
  <div class="settings-section">
3835
3838
  <h3 class="settings-section-title">
@@ -3932,7 +3935,7 @@ ${String(e||"").trim()}
3932
3935
  </div>
3933
3936
  </div>
3934
3937
  </div>
3935
- `,setup(e,{emit:t}){let s=Pinia.useChatStore(),n=Vue.getCurrentInstance(),r=k=>n?.proxy?.$t?.(k)??k,i=Vue.computed(()=>s.yeaftMcpServers||[]),o=Vue.computed(()=>s.yeaftMcpRuntime||{connected:!1,toolCount:0,perServer:[]}),a=Vue.computed(()=>!!s.yeaftMcpLoading),l=Vue.computed(()=>{let k=new Map((o.value.perServer||[]).map(S=>[S.name,S]));return i.value.map(S=>{let b=k.get(S.name);return{...S,ready:!!(b&&b.ready),toolCount:b?b.toolCount:0}})}),c=Vue.reactive({name:"",command:"",argsRaw:"",envRaw:""}),d=Vue.ref("");function u(){c.name="",c.command="",c.argsRaw="",c.envRaw="",d.value=""}function g(k){if(!k)return[];let S=[],b=/"([^"]*)"|'([^']*)'|(\S+)/g,w;for(;(w=b.exec(k))!==null;)S.push(w[1]??w[2]??w[3]);return S}function p(k){if(!k)return{};let S={},b=k.split(/\r?\n/);for(let w of b){let P=w.trim();if(!P||P.startsWith("#"))continue;let x=P.indexOf("=");if(x<0)continue;let Y=P.slice(0,x).trim(),L=P.slice(x+1);Y&&(S[Y]=L)}return S}function f(){d.value="";let k=(c.name||"").trim(),S=(c.command||"").trim();if(!k)return d.value=r("settings.mcp.errors.nameRequired"),null;if(!/^[a-z0-9_-]+$/.test(k))return d.value=r("settings.mcp.errors.nameFormat"),null;if(!S)return d.value=r("settings.mcp.errors.commandRequired"),null;let b=[],w={};try{b=g(c.argsRaw)}catch{return d.value=r("settings.mcp.errors.argsParse"),null}try{w=p(c.envRaw)}catch{return d.value=r("settings.mcp.errors.envParse"),null}return{name:k,command:S,args:b,env:w}}async function m(){let k=f();if(!k)return;let S=await s.addYeaftMcpServer(k);if(S?.error){t("message",S.error,!0);return}S?.connectError?t("message",r("settings.mcp.connectFailed")+": "+S.connectError,!0):t("message",r("settings.mcp.addSuccess"),!1),u()}async function v(k){if(!k||!await Be(r("settings.mcp.confirmRemove").replace("{name}",k),{destructive:!0}))return;let S=await s.removeYeaftMcpServer(k);S?.error?t("message",S.error,!0):t("message",r("settings.mcp.removeSuccess"),!1)}async function y(k){let S=await s.reloadYeaftMcpServer(k);S?.error?t("message",S.error,!0):t("message",r("settings.mcp.reloadSuccess"),!1)}async function h(){let k=await s.reloadYeaftMcpServer(null);k?.error?t("message",k.error,!0):t("message",r("settings.mcp.reloadSuccess"),!1)}return Vue.onMounted(()=>{s.loadYeaftMcpServers()}),{servers:i,runtime:o,loading:a,serversWithStatus:l,form:c,formError:d,resetForm:u,addServer:m,removeOne:v,reloadOne:y,reloadAll:h}}}});var vm,ym=B(()=>{wi();vm={name:"UserShortcutsSettings",setup(){let{preferences:e,ownerId:t,save:s,reset:n}=pr(),r=Vue.ref(""),i=Vue.ref(null),o={terminal:"Alt+T",files:"Alt+O",git:"Alt+G",newSession:"Alt+N",closeWorkbench:"Alt+W",quickSend1:"Alt+1",quickSend2:"Alt+2",quickSend3:"Alt+3",quickSend4:"Alt+4",quickSend5:"Alt+5"};Vue.watch(t,()=>{r.value="",i.value=null},{flush:"sync"});function a(d,u=""){let g=s(d);return i.value=g.ok?null:{...g,action:u},g.ok}function l(d,u){if(r.value!==u)return;if(d.key==="Tab"){r.value="";return}if(d.preventDefault(),d.stopPropagation(),d.key==="Escape"){r.value="";return}if(!Go(d)||["Control","Meta","Alt","Shift"].includes(d.key))return;let g=Hc(d),p=g?bi(g,e.value.bindings,u):{valid:!1,error:"invalid"};if(!p.valid){i.value={...p,action:u};return}a({bindings:{[u]:g}},u)&&(r.value="")}function c(){r.value="";let d=n();i.value=d.ok?null:d}return{preferences:e,ownerId:t,recording:r,error:i,actions:ur,suggestions:o,persist:a,record:l,resetAll:c}},template:`
3938
+ `,setup(e,{emit:t}){let s=Pinia.useChatStore(),n=Vue.getCurrentInstance(),r=k=>n?.proxy?.$t?.(k)??k,i=Vue.computed(()=>s.yeaftMcpServers||[]),o=Vue.computed(()=>s.yeaftMcpRuntime||{connected:!1,toolCount:0,perServer:[]}),a=Vue.computed(()=>!!s.yeaftMcpLoading),l=Vue.computed(()=>{let k=new Map((o.value.perServer||[]).map(S=>[S.name,S]));return i.value.map(S=>{let y=k.get(S.name);return{...S,ready:!!(y&&y.ready),toolCount:y?y.toolCount:0}})}),c=Vue.reactive({name:"",command:"",argsRaw:"",envRaw:""}),d=Vue.ref("");function u(){c.name="",c.command="",c.argsRaw="",c.envRaw="",d.value=""}function g(k){if(!k)return[];let S=[],y=/"([^"]*)"|'([^']*)'|(\S+)/g,w;for(;(w=y.exec(k))!==null;)S.push(w[1]??w[2]??w[3]);return S}function p(k){if(!k)return{};let S={},y=k.split(/\r?\n/);for(let w of y){let P=w.trim();if(!P||P.startsWith("#"))continue;let x=P.indexOf("=");if(x<0)continue;let Y=P.slice(0,x).trim(),L=P.slice(x+1);Y&&(S[Y]=L)}return S}function f(){d.value="";let k=(c.name||"").trim(),S=(c.command||"").trim();if(!k)return d.value=r("settings.mcp.errors.nameRequired"),null;if(!/^[a-z0-9_-]+$/.test(k))return d.value=r("settings.mcp.errors.nameFormat"),null;if(!S)return d.value=r("settings.mcp.errors.commandRequired"),null;let y=[],w={};try{y=g(c.argsRaw)}catch{return d.value=r("settings.mcp.errors.argsParse"),null}try{w=p(c.envRaw)}catch{return d.value=r("settings.mcp.errors.envParse"),null}return{name:k,command:S,args:y,env:w}}async function m(){let k=f();if(!k)return;let S=await s.addYeaftMcpServer(k);if(S?.error){t("message",S.error,!0);return}S?.connectError?t("message",r("settings.mcp.connectFailed")+": "+S.connectError,!0):t("message",r("settings.mcp.addSuccess"),!1),u()}async function v(k){if(!k||!await Be(r("settings.mcp.confirmRemove").replace("{name}",k),{destructive:!0}))return;let S=await s.removeYeaftMcpServer(k);S?.error?t("message",S.error,!0):t("message",r("settings.mcp.removeSuccess"),!1)}async function b(k){let S=await s.reloadYeaftMcpServer(k);S?.error?t("message",S.error,!0):t("message",r("settings.mcp.reloadSuccess"),!1)}async function h(){let k=await s.reloadYeaftMcpServer(null);k?.error?t("message",k.error,!0):t("message",r("settings.mcp.reloadSuccess"),!1)}return Vue.onMounted(()=>{s.loadYeaftMcpServers()}),{servers:i,runtime:o,loading:a,serversWithStatus:l,form:c,formError:d,resetForm:u,addServer:m,removeOne:v,reloadOne:b,reloadAll:h}}}});var vm,ym=B(()=>{wi();vm={name:"UserShortcutsSettings",setup(){let{preferences:e,ownerId:t,save:s,reset:n}=pr(),r=Vue.ref(""),i=Vue.ref(null),o={terminal:"Alt+T",files:"Alt+O",git:"Alt+G",newSession:"Alt+N",closeWorkbench:"Alt+W",quickSend1:"Alt+1",quickSend2:"Alt+2",quickSend3:"Alt+3",quickSend4:"Alt+4",quickSend5:"Alt+5"};Vue.watch(t,()=>{r.value="",i.value=null},{flush:"sync"});function a(d,u=""){let g=s(d);return i.value=g.ok?null:{...g,action:u},g.ok}function l(d,u){if(r.value!==u)return;if(d.key==="Tab"){r.value="";return}if(d.preventDefault(),d.stopPropagation(),d.key==="Escape"){r.value="";return}if(!Go(d)||["Control","Meta","Alt","Shift"].includes(d.key))return;let g=Hc(d),p=g?bi(g,e.value.bindings,u):{valid:!1,error:"invalid"};if(!p.valid){i.value={...p,action:u};return}a({bindings:{[u]:g}},u)&&(r.value="")}function c(){r.value="";let d=n();i.value=d.ok?null:d}return{preferences:e,ownerId:t,recording:r,error:i,actions:ur,suggestions:o,persist:a,record:l,resetAll:c}},template:`
3936
3939
  <section class="user-shortcuts-settings" aria-labelledby="user-shortcuts-title">
3937
3940
  <h3 id="user-shortcuts-title">{{ $t('userShortcuts.title') }}</h3>
3938
3941
  <p class="sp-desc">{{ $t('userShortcuts.scope') }}</p>
@@ -4756,7 +4759,7 @@ ${String(e||"").trim()}
4756
4759
  </div>
4757
4760
  </div>
4758
4761
  </div>
4759
- `,directives:{"click-outside":{mounted(e,t){e._clickOutside=s=>{e.contains(s.target)||t.value()},document.addEventListener("click",e._clickOutside)},unmounted(e){document.removeEventListener("click",e._clickOutside)}}},data(){return{loading:!1,loadError:null,localProviders:[],providerModelsText:[],localPrimaryModel:null,localFastModel:null,localDebug:!1,isDirty:!1,saving:!1,openDropdown:null,showApiKey:{},showPresetPicker:!1,discoveringModels:!1,modelDiscoveryWarning:null,modelDiscoveryError:null,saveRefreshWarning:null}},computed:{chatStore(){return Pinia.useChatStore()},effectiveAgentId(){return this.agentId||this.chatStore.currentAgent},agentOnline(){let e=this.effectiveAgentId;if(!e)return!1;if(this.context==="yeaft")return!0;let t=this.chatStore.agents.find(s=>s.id===e);return t?t.online:!1},currentConfig(){let e=this.effectiveAgentId;return e&&this.chatStore.llmConfig[e]||null},editableProviders(){return this.localProviders},allModelRefs(){let e=this.localProviders,t=[];for(let s of e){if(!s.name)continue;let n=this.parseModelsFromProvider(s);for(let r of n)t.push(`${s.name}/${r}`)}return t}},watch:{effectiveAgentId:{handler(e,t){e!==t&&(this.cancelPendingDiscovery(),this.cancelPendingSave(),this._loadTimeout&&(clearTimeout(this._loadTimeout),this._loadTimeout=null),this.loading=!1,this.loadError=null,this.localProviders=[],this.providerModelsText=[],this.localPrimaryModel=null,this.localFastModel=null,this.localDebug=!1,this.isDirty=!1,this.modelDiscoveryWarning=null,this.modelDiscoveryError=null,this.saveRefreshWarning=null),e&&this.requestConfig()},immediate:!0},agentOnline(e){e&&!this.currentConfig&&this.effectiveAgentId&&this.requestConfig()},currentConfig:{handler(e){e&&e.loaded&&this.loadFromConfig(e)},deep:!0}},methods:{async copyText(e){try{await navigator.clipboard.writeText(e),this.$emit("message",this.$t("settings.msg.copiedClipboard"),!1)}catch{this.$emit("message",this.$t("settings.msg.copyFailed"),!0)}},async useGitHubCopilotPreset(){let e=this.effectiveAgentId;if(!e||!this.agentOnline)return;this.cancelPendingDiscovery(),this.discoveringModels=!0,this.modelDiscoveryWarning=null,this.modelDiscoveryError=null;let t=`llm-discovery-${Date.now()}-${Math.random().toString(36).slice(2)}`;this._pendingDiscovery={agentId:e,requestId:t},this.chatStore.sendWsMessage({type:"discover_llm_models",agentId:e,requestId:t,providerType:"github-copilot"});let s=await this.waitForModelDiscovery(e,t);if(!(this._pendingDiscovery?.agentId!==e||this._pendingDiscovery?.requestId!==t||this.effectiveAgentId!==e)){if(this._pendingDiscovery=null,this.discoveringModels=!1,s.error){this.modelDiscoveryError=s.error;return}this.applyDiscoveredProvider(s),this.modelDiscoveryWarning=s.warning||null}},waitForModelDiscovery(e,t){return new Promise(s=>{let n=Date.now(),r=i=>{this._discoveryTimer&&clearInterval(this._discoveryTimer),this._discoveryTimer=null,this._resolvePendingDiscovery=null,s(i)};this._resolvePendingDiscovery=r,this._discoveryTimer=setInterval(()=>{let i=this.chatStore.llmModelDiscovery?.[e];if(i?.requestId===t){r(i);return}Date.now()-n>1e4&&r({error:"Timed out while refreshing provider models."})},100)})},cancelPendingDiscovery(){let e=this._resolvePendingDiscovery;this._discoveryTimer&&clearInterval(this._discoveryTimer),this._discoveryTimer=null,this._resolvePendingDiscovery=null,this._pendingDiscovery=null,this.discoveringModels=!1,e&&e({cancelled:!0})},cancelPendingSave(){this._saveTimeout&&(clearTimeout(this._saveTimeout),this._saveTimeout=null),this._saveUnwatch&&(this._saveUnwatch(),this._saveUnwatch=null),this._pendingSave=null,this.saving=!1},applyDiscoveredProvider(e){let t={name:e.provider?.name||"github-copilot",credentialProvider:e.provider?.credentialProvider||"github-copilot",managed:e.provider?.managed||"github-copilot",models:Array.isArray(e.providerModels)&&e.providerModels.length?e.providerModels:e.models||[]},s=[...this.localProviders],n=s.findIndex(o=>o?.name===t.name);n>=0?s[n]=t:s.push(t),this.localProviders=s,this.refreshProviderModelsText();let r=new Set(this.parseModelsFromProvider(t).map(o=>`${t.name}/${o}`)),i=r.values().next().value||null;i&&!r.has(this.localPrimaryModel)&&(this.localPrimaryModel=i),i&&this.localFastModel?.startsWith(`${t.name}/`)&&!r.has(this.localFastModel)&&(this.localFastModel=i),this.markDirty()},requestConfig(){let e=this.effectiveAgentId;if(e){if(!this.agentOnline){this.loading=!1,this.loadError=null;return}this.loading=!0,this.loadError=null,this.chatStore.sendWsMessage({type:"get_llm_config",agentId:e}),this._loadTimeout=setTimeout(()=>{this.loading&&(this.loading=!1,this.loadError="Timeout")},5e3)}},loadFromConfig(e){if(this._loadTimeout&&(clearTimeout(this._loadTimeout),this._loadTimeout=null),this.loading=!1,e.error){this.loadError=e.error;return}this.loadError=null,this.localProviders=(e.agentConfig?.providers||e.providers||[]).map(t=>this.cloneProvider(t)),this.refreshProviderModelsText(),this.localPrimaryModel=e.agentConfig?.primaryModel||e.primaryModel||null,this.localFastModel=e.agentConfig?.fastModel||e.fastModel||null,this.localDebug=e.agentConfig?.debug===!0,this.isDirty=!1,this.showApiKey={}},cloneProvider(e){return{type:e.type||"api-key",scope:"agent",name:e.originalName||e.name||"",baseUrl:e.baseUrl||"",apiKey:e.apiKey||"",githubToken:e.githubToken||"",protocol:e.protocol||"openai-responses",credentialProvider:e.credentialProvider||null,models:Array.isArray(e.models)?e.models.map(t=>t&&typeof t=="object"?{...t}:t):[]}},refreshProviderModelsText(){this.providerModelsText=this.editableProviders.map(e=>(e.models||[]).map(t=>this._modelId(t)).join(", "))},parseModelsFromProvider(e){return this.isManagedProvider(e)&&(!Array.isArray(e.models)||e.models.length===0)?this.fallbackCopilotModels():Array.isArray(e.models)?e.models.map(t=>this._modelId(t)).filter(t=>t):[]},_modelId(e){return typeof e=="string"?e:e&&typeof e=="object"&&typeof e.id=="string"?e.id:""},isManagedProvider(e){return e?.managed==="github-copilot"||e?.credentialProvider==="github-copilot"||e?.name==="github-copilot"},fallbackCopilotModels(){return["gpt-5.5","gpt-5.4","gpt-5.4-mini","gpt-5-mini","gpt-5.3-codex","gpt-5.2-codex","gpt-4.1","gpt-4o","gpt-4o-mini","claude-opus-4.8","claude-opus-4.7","claude-opus-4.6","claude-sonnet-4.6","claude-sonnet-4.5","claude-haiku-4.5","gemini-2.5-pro"]},addProvider(){this.editableProviders.push({name:"",baseUrl:"",apiKey:"",protocol:"openai",credentialProvider:null,models:[]}),this.providerModelsText.push(""),this.markDirty()},onPresetPick(e){if(this.showPresetPicker=!1,!e||!e.name)return;let t=new Set(this.editableProviders.map(i=>(i.name||"").trim())),s=e.name,n=2;for(;t.has(s);)s=`${e.name}-${n++}`;let r=Array.isArray(e.models)?e.models.filter(Boolean):[];this.editableProviders.push({name:s,baseUrl:e.baseUrl||"",apiKey:"",protocol:e.protocol||"openai",credentialProvider:null,models:r}),this.providerModelsText.push(r.join(", ")),this.markDirty()},removeProvider(e){this.editableProviders.splice(e,1),this.providerModelsText.splice(e,1);let t={};for(let s=0;s<this.editableProviders.length;s++)s<e?t[s]=this.showApiKey[s]:t[s]=this.showApiKey[s+1];this.showApiKey=t,this.markDirty()},onModelsTextChange(e,t){let s=t.target.value;this.providerModelsText[e]=s;let n=Array.isArray(this.editableProviders[e].models)?this.editableProviders[e].models:[],r=new Map;for(let i of n){let o=this._modelId(i);o&&r.set(o,i)}this.editableProviders[e].models=s.split(/[\n,]+/).map(i=>i.trim()).filter(i=>i).map(i=>r.has(i)?r.get(i):i),this.markDirty()},setProtocol(e,t){let s=this.editableProviders[e].protocol;if(this.editableProviders[e].protocol=t,this.markDirty(),(this.editableProviders[e].models||[]).filter(r=>r).length===0&&t!==s){let r=this._getModelPresets(t);r.length>0&&(this.editableProviders[e].models=[...r],this.providerModelsText[e]=r.join(", "))}},protocolLabel(e){return e==="anthropic"?this.$t("settings.llm.protocolAnthropic"):e==="openai-responses"?this.$t("settings.llm.protocolOpenAIResponses"):this.$t("settings.llm.protocolOpenAI")},protocolHint(e){return e==="anthropic"?this.$t("settings.llm.protocolHint.anthropic"):e==="openai-responses"?this.$t("settings.llm.protocolHint.openaiResponses"):this.$t("settings.llm.protocolHint.openai")},_getModelPresets(e){return Gc[e]||Gc.openai},toggleApiKeyVisibility(e){this.showApiKey={...this.showApiKey,[e]:!this.showApiKey[e]}},toggleDropdown(e){this.openDropdown=this.openDropdown===e?null:e},closeDropdown(e){this.openDropdown===e&&(this.openDropdown=null)},markDirty(){this.isDirty=!0},saveConfig(){let e=this.effectiveAgentId;if(!e||this.saving)return;this.saving=!0,this.saveRefreshWarning=null;let s={providers:this.editableProviders.filter(r=>r.name&&(this.isManagedProvider(r)||r.baseUrl)).map(r=>{if(this.isManagedProvider(r))return{name:r.name.trim()||"github-copilot",credentialProvider:"github-copilot",managed:r.managed||"github-copilot",models:(r.models||[]).filter(o=>this._modelId(o))};let i={type:r.type||"api-key",name:r.name.trim(),baseUrl:r.baseUrl.trim(),apiKey:r.apiKey||"",githubToken:r.githubToken||"",models:(r.models||[]).filter(o=>this._modelId(o))};return r.protocol&&r.protocol!=="openai"&&(i.protocol=r.protocol),r.credentialProvider&&(i.credentialProvider=r.credentialProvider,i.apiKey=""),i}),primaryModel:this.localPrimaryModel||null,debug:this.localDebug===!0};this.context!=="yeaft"&&(s.fastModel=this.localFastModel||null);let n=`llm-save-${Date.now()}-${Math.random().toString(36).slice(2)}`;this.cancelPendingSave(),this.saving=!0,this._pendingSave={agentId:e,requestId:n},this.chatStore.sendWsMessage({type:"update_llm_config",agentId:e,requestId:n,config:s}),this._saveTimeout=setTimeout(()=>{this._pendingSave?.agentId!==e||this._pendingSave?.requestId!==n||(this.cancelPendingSave(),this.$emit("message",this.$t("settings.llm.saveFailed"),!0))},1e4),this._saveUnwatch=this.$watch("currentConfig",r=>{if(!(!r?.loaded||r.requestId!==n||this.effectiveAgentId!==e||this._pendingSave?.agentId!==e||this._pendingSave?.requestId!==n)){if(this.cancelPendingSave(),r.error){this.$emit("message",r.error,!0);return}this.isDirty=!1,this.saveRefreshWarning=r.statusRefreshError?this.$t("settings.llm.savedRefreshWarning",{error:r.statusRefreshError}):null,this.$emit("message",this.saveRefreshWarning||this.$t("settings.llm.saved"),!!r.statusRefreshError),this.$emit("saved",{warning:this.saveRefreshWarning})}},{deep:!0})}},beforeUnmount(){this._loadTimeout&&clearTimeout(this._loadTimeout),this.cancelPendingDiscovery(),this.cancelPendingSave()}}});var uS,ms,yr=B(()=>{uS=0,ms={name:"ModernSelect",props:{modelValue:{type:[String,Number],default:null},options:{type:Array,default:()=>[]},placeholder:{type:String,default:""},searchable:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},emptyText:{type:String,default:"\u2014"},ariaLabel:{type:String,default:""},menuMinWidth:{type:Number,default:0},menuClass:{type:String,default:""}},emits:["update:modelValue","change"],setup(e,{emit:t}){let s=Vue.ref(!1),n=Vue.ref(""),r=Vue.ref(null),i=Vue.ref(null),o=Vue.ref(null),a=Vue.ref(null),l=Vue.ref(-1),c=`modern-select-${++uS}`,d=`${c}-menu`,u=Vue.ref({}),g=Vue.computed(()=>e.options.find(x=>x.value===e.modelValue)||null),p=Vue.computed(()=>{if(!e.searchable||!n.value.trim())return e.options;let x=n.value.trim().toLowerCase();return e.options.filter(Y=>String(Y.label||"").toLowerCase().includes(x)||String(Y.sublabel||"").toLowerCase().includes(x)||String(Y.value||"").toLowerCase().includes(x))}),f=x=>`${c}-option-${x}`,m=Vue.computed(()=>s.value&&l.value>=0&&l.value<p.value.length?f(l.value):void 0);function v(){let x=r.value,Y=i.value,L=o.value;if(!x||!Y||!L)return;let U=6,E=8,oe=x.getBoundingClientRect(),q=document.documentElement.clientWidth||window.innerWidth,I=document.documentElement.clientHeight||window.innerHeight,T=Math.min(Math.max(oe.width,e.menuMinWidth),Math.max(0,q-E*2)),R=e.searchable?58:12,M=Math.min(L.scrollHeight+R,304),$=Math.max(0,I-oe.bottom-U-E),j=Math.max(0,oe.top-U-E),z=$<M&&j>$,Q=Math.max(48,Math.min(M,z?j:$)),ae=oe.right-T,ke=Math.min(Math.max(E,ae),Math.max(E,q-E-T));u.value={top:`${z?oe.top-U-Q:oe.bottom+U}px`,left:`${ke}px`,width:`${T}px`,maxHeight:`${Q}px`,"--modern-select-list-max-height":`${Math.max(36,Q-(e.searchable?58:12))}px`}}function y(){e.disabled||(s.value=!s.value,s.value&&(n.value="",l.value=p.value.findIndex(x=>x.value===e.modelValue),Vue.nextTick(()=>{v(),e.searchable&&a.value?.focus&&a.value.focus();let x=i.value?.querySelector(".modern-select-option.is-active");x?.scrollIntoView&&x.scrollIntoView({block:"nearest"})})))}function h(){s.value=!1}function k(x){!x||x.disabled||(t("update:modelValue",x.value),t("change",x.value),h())}function S(x){if(!p.value.length)return;let Y=l.value;for(let L=0;L<p.value.length;L+=1)if(Y=(Y+x+p.value.length)%p.value.length,!p.value[Y]?.disabled){l.value=Y;return}}function b(x){if(!s.value){(x.key==="Enter"||x.key===" "||x.key==="ArrowDown")&&(x.preventDefault(),y());return}if(x.key==="Escape"){x.preventDefault(),x.stopPropagation(),h();return}if(x.key==="ArrowDown")x.preventDefault(),S(1);else if(x.key==="ArrowUp")x.preventDefault(),S(-1);else if(x.key==="Enter"){x.preventDefault();let Y=p.value[l.value];Y&&k(Y)}}function w(x){s.value&&(r.value?.contains(x.target)||i.value?.contains(x.target)||h())}let P=()=>{s.value&&v()};return Vue.onMounted(()=>{document.addEventListener("mousedown",w),window.addEventListener("resize",P),window.addEventListener("scroll",P,!0)}),Vue.onBeforeUnmount(()=>{document.removeEventListener("mousedown",w),window.removeEventListener("resize",P),window.removeEventListener("scroll",P,!0)}),Vue.watch(()=>e.modelValue,()=>{}),{open:s,search:n,triggerEl:r,menuEl:i,searchEl:a,activeIdx:l,selected:g,filtered:p,menuId:d,menuStyle:u,listEl:o,optionId:f,activeOptionId:m,toggle:y,close:h,pick:k,onKey:b}},template:`
4762
+ `,directives:{"click-outside":{mounted(e,t){e._clickOutside=s=>{e.contains(s.target)||t.value()},document.addEventListener("click",e._clickOutside)},unmounted(e){document.removeEventListener("click",e._clickOutside)}}},data(){return{loading:!1,loadError:null,localProviders:[],providerModelsText:[],localPrimaryModel:null,localFastModel:null,localDebug:!1,isDirty:!1,saving:!1,openDropdown:null,showApiKey:{},showPresetPicker:!1,discoveringModels:!1,modelDiscoveryWarning:null,modelDiscoveryError:null,saveRefreshWarning:null}},computed:{chatStore(){return Pinia.useChatStore()},effectiveAgentId(){return this.agentId||this.chatStore.currentAgent},agentOnline(){let e=this.effectiveAgentId;if(!e)return!1;if(this.context==="yeaft")return!0;let t=this.chatStore.agents.find(s=>s.id===e);return t?t.online:!1},currentConfig(){let e=this.effectiveAgentId;return e&&this.chatStore.llmConfig[e]||null},editableProviders(){return this.localProviders},allModelRefs(){let e=this.localProviders,t=[];for(let s of e){if(!s.name)continue;let n=this.parseModelsFromProvider(s);for(let r of n)t.push(`${s.name}/${r}`)}return t}},watch:{effectiveAgentId:{handler(e,t){e!==t&&(this.cancelPendingDiscovery(),this.cancelPendingSave(),this._loadTimeout&&(clearTimeout(this._loadTimeout),this._loadTimeout=null),this.loading=!1,this.loadError=null,this.localProviders=[],this.providerModelsText=[],this.localPrimaryModel=null,this.localFastModel=null,this.localDebug=!1,this.isDirty=!1,this.modelDiscoveryWarning=null,this.modelDiscoveryError=null,this.saveRefreshWarning=null),e&&this.requestConfig()},immediate:!0},agentOnline(e){e&&!this.currentConfig&&this.effectiveAgentId&&this.requestConfig()},currentConfig:{handler(e){e&&e.loaded&&this.loadFromConfig(e)},deep:!0}},methods:{async copyText(e){try{await navigator.clipboard.writeText(e),this.$emit("message",this.$t("settings.msg.copiedClipboard"),!1)}catch{this.$emit("message",this.$t("settings.msg.copyFailed"),!0)}},async useGitHubCopilotPreset(){let e=this.effectiveAgentId;if(!e||!this.agentOnline)return;this.cancelPendingDiscovery(),this.discoveringModels=!0,this.modelDiscoveryWarning=null,this.modelDiscoveryError=null;let t=`llm-discovery-${Date.now()}-${Math.random().toString(36).slice(2)}`;this._pendingDiscovery={agentId:e,requestId:t},this.chatStore.sendWsMessage({type:"discover_llm_models",agentId:e,requestId:t,providerType:"github-copilot"});let s=await this.waitForModelDiscovery(e,t);if(!(this._pendingDiscovery?.agentId!==e||this._pendingDiscovery?.requestId!==t||this.effectiveAgentId!==e)){if(this._pendingDiscovery=null,this.discoveringModels=!1,s.error){this.modelDiscoveryError=s.error;return}this.applyDiscoveredProvider(s),this.modelDiscoveryWarning=s.warning||null}},waitForModelDiscovery(e,t){return new Promise(s=>{let n=Date.now(),r=i=>{this._discoveryTimer&&clearInterval(this._discoveryTimer),this._discoveryTimer=null,this._resolvePendingDiscovery=null,s(i)};this._resolvePendingDiscovery=r,this._discoveryTimer=setInterval(()=>{let i=this.chatStore.llmModelDiscovery?.[e];if(i?.requestId===t){r(i);return}Date.now()-n>1e4&&r({error:"Timed out while refreshing provider models."})},100)})},cancelPendingDiscovery(){let e=this._resolvePendingDiscovery;this._discoveryTimer&&clearInterval(this._discoveryTimer),this._discoveryTimer=null,this._resolvePendingDiscovery=null,this._pendingDiscovery=null,this.discoveringModels=!1,e&&e({cancelled:!0})},cancelPendingSave(){this._saveTimeout&&(clearTimeout(this._saveTimeout),this._saveTimeout=null),this._saveUnwatch&&(this._saveUnwatch(),this._saveUnwatch=null),this._pendingSave=null,this.saving=!1},applyDiscoveredProvider(e){let t={name:e.provider?.name||"github-copilot",credentialProvider:e.provider?.credentialProvider||"github-copilot",managed:e.provider?.managed||"github-copilot",models:Array.isArray(e.providerModels)&&e.providerModels.length?e.providerModels:e.models||[]},s=[...this.localProviders],n=s.findIndex(o=>o?.name===t.name);n>=0?s[n]=t:s.push(t),this.localProviders=s,this.refreshProviderModelsText();let r=new Set(this.parseModelsFromProvider(t).map(o=>`${t.name}/${o}`)),i=r.values().next().value||null;i&&!r.has(this.localPrimaryModel)&&(this.localPrimaryModel=i),i&&this.localFastModel?.startsWith(`${t.name}/`)&&!r.has(this.localFastModel)&&(this.localFastModel=i),this.markDirty()},requestConfig(){let e=this.effectiveAgentId;if(e){if(!this.agentOnline){this.loading=!1,this.loadError=null;return}this.loading=!0,this.loadError=null,this.chatStore.sendWsMessage({type:"get_llm_config",agentId:e}),this._loadTimeout=setTimeout(()=>{this.loading&&(this.loading=!1,this.loadError="Timeout")},5e3)}},loadFromConfig(e){if(this._loadTimeout&&(clearTimeout(this._loadTimeout),this._loadTimeout=null),this.loading=!1,e.error){this.loadError=e.error;return}this.loadError=null,this.localProviders=(e.agentConfig?.providers||e.providers||[]).map(t=>this.cloneProvider(t)),this.refreshProviderModelsText(),this.localPrimaryModel=e.agentConfig?.primaryModel||e.primaryModel||null,this.localFastModel=e.agentConfig?.fastModel||e.fastModel||null,this.localDebug=e.agentConfig?.debug===!0,this.isDirty=!1,this.showApiKey={}},cloneProvider(e){return{type:e.type||"api-key",scope:"agent",name:e.originalName||e.name||"",baseUrl:e.baseUrl||"",apiKey:e.apiKey||"",githubToken:e.githubToken||"",protocol:e.protocol||"openai-responses",credentialProvider:e.credentialProvider||null,models:Array.isArray(e.models)?e.models.map(t=>t&&typeof t=="object"?{...t}:t):[]}},refreshProviderModelsText(){this.providerModelsText=this.editableProviders.map(e=>(e.models||[]).map(t=>this._modelId(t)).join(", "))},parseModelsFromProvider(e){return this.isManagedProvider(e)&&(!Array.isArray(e.models)||e.models.length===0)?this.fallbackCopilotModels():Array.isArray(e.models)?e.models.map(t=>this._modelId(t)).filter(t=>t):[]},_modelId(e){return typeof e=="string"?e:e&&typeof e=="object"&&typeof e.id=="string"?e.id:""},isManagedProvider(e){return e?.managed==="github-copilot"||e?.credentialProvider==="github-copilot"||e?.name==="github-copilot"},fallbackCopilotModels(){return["gpt-5.5","gpt-5.4","gpt-5.4-mini","gpt-5-mini","gpt-5.3-codex","gpt-5.2-codex","gpt-4.1","gpt-4o","gpt-4o-mini","claude-opus-4.8","claude-opus-4.7","claude-opus-4.6","claude-sonnet-4.6","claude-sonnet-4.5","claude-haiku-4.5","gemini-2.5-pro"]},addProvider(){this.editableProviders.push({name:"",baseUrl:"",apiKey:"",protocol:"openai",credentialProvider:null,models:[]}),this.providerModelsText.push(""),this.markDirty()},onPresetPick(e){if(this.showPresetPicker=!1,!e||!e.name)return;let t=new Set(this.editableProviders.map(i=>(i.name||"").trim())),s=e.name,n=2;for(;t.has(s);)s=`${e.name}-${n++}`;let r=Array.isArray(e.models)?e.models.filter(Boolean):[];this.editableProviders.push({name:s,baseUrl:e.baseUrl||"",apiKey:"",protocol:e.protocol||"openai",credentialProvider:null,models:r}),this.providerModelsText.push(r.join(", ")),this.markDirty()},removeProvider(e){this.editableProviders.splice(e,1),this.providerModelsText.splice(e,1);let t={};for(let s=0;s<this.editableProviders.length;s++)s<e?t[s]=this.showApiKey[s]:t[s]=this.showApiKey[s+1];this.showApiKey=t,this.markDirty()},onModelsTextChange(e,t){let s=t.target.value;this.providerModelsText[e]=s;let n=Array.isArray(this.editableProviders[e].models)?this.editableProviders[e].models:[],r=new Map;for(let i of n){let o=this._modelId(i);o&&r.set(o,i)}this.editableProviders[e].models=s.split(/[\n,]+/).map(i=>i.trim()).filter(i=>i).map(i=>r.has(i)?r.get(i):i),this.markDirty()},setProtocol(e,t){let s=this.editableProviders[e].protocol;if(this.editableProviders[e].protocol=t,this.markDirty(),(this.editableProviders[e].models||[]).filter(r=>r).length===0&&t!==s){let r=this._getModelPresets(t);r.length>0&&(this.editableProviders[e].models=[...r],this.providerModelsText[e]=r.join(", "))}},protocolLabel(e){return e==="anthropic"?this.$t("settings.llm.protocolAnthropic"):e==="openai-responses"?this.$t("settings.llm.protocolOpenAIResponses"):this.$t("settings.llm.protocolOpenAI")},protocolHint(e){return e==="anthropic"?this.$t("settings.llm.protocolHint.anthropic"):e==="openai-responses"?this.$t("settings.llm.protocolHint.openaiResponses"):this.$t("settings.llm.protocolHint.openai")},_getModelPresets(e){return Gc[e]||Gc.openai},toggleApiKeyVisibility(e){this.showApiKey={...this.showApiKey,[e]:!this.showApiKey[e]}},toggleDropdown(e){this.openDropdown=this.openDropdown===e?null:e},closeDropdown(e){this.openDropdown===e&&(this.openDropdown=null)},markDirty(){this.isDirty=!0},saveConfig(){let e=this.effectiveAgentId;if(!e||this.saving)return;this.saving=!0,this.saveRefreshWarning=null;let s={providers:this.editableProviders.filter(r=>r.name&&(this.isManagedProvider(r)||r.baseUrl)).map(r=>{if(this.isManagedProvider(r))return{name:r.name.trim()||"github-copilot",credentialProvider:"github-copilot",managed:r.managed||"github-copilot",models:(r.models||[]).filter(o=>this._modelId(o))};let i={type:r.type||"api-key",name:r.name.trim(),baseUrl:r.baseUrl.trim(),apiKey:r.apiKey||"",githubToken:r.githubToken||"",models:(r.models||[]).filter(o=>this._modelId(o))};return r.protocol&&r.protocol!=="openai"&&(i.protocol=r.protocol),r.credentialProvider&&(i.credentialProvider=r.credentialProvider,i.apiKey=""),i}),primaryModel:this.localPrimaryModel||null,debug:this.localDebug===!0};this.context!=="yeaft"&&(s.fastModel=this.localFastModel||null);let n=`llm-save-${Date.now()}-${Math.random().toString(36).slice(2)}`;this.cancelPendingSave(),this.saving=!0,this._pendingSave={agentId:e,requestId:n},this.chatStore.sendWsMessage({type:"update_llm_config",agentId:e,requestId:n,config:s}),this._saveTimeout=setTimeout(()=>{this._pendingSave?.agentId!==e||this._pendingSave?.requestId!==n||(this.cancelPendingSave(),this.$emit("message",this.$t("settings.llm.saveFailed"),!0))},1e4),this._saveUnwatch=this.$watch("currentConfig",r=>{if(!(!r?.loaded||r.requestId!==n||this.effectiveAgentId!==e||this._pendingSave?.agentId!==e||this._pendingSave?.requestId!==n)){if(this.cancelPendingSave(),r.error){this.$emit("message",r.error,!0);return}this.isDirty=!1,this.saveRefreshWarning=r.statusRefreshError?this.$t("settings.llm.savedRefreshWarning",{error:r.statusRefreshError}):null,this.$emit("message",this.saveRefreshWarning||this.$t("settings.llm.saved"),!!r.statusRefreshError),this.$emit("saved",{warning:this.saveRefreshWarning})}},{deep:!0})}},beforeUnmount(){this._loadTimeout&&clearTimeout(this._loadTimeout),this.cancelPendingDiscovery(),this.cancelPendingSave()}}});var uS,ms,yr=B(()=>{uS=0,ms={name:"ModernSelect",props:{modelValue:{type:[String,Number],default:null},options:{type:Array,default:()=>[]},placeholder:{type:String,default:""},searchable:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},emptyText:{type:String,default:"\u2014"},ariaLabel:{type:String,default:""},menuMinWidth:{type:Number,default:0},menuClass:{type:String,default:""}},emits:["update:modelValue","change"],setup(e,{emit:t}){let s=Vue.ref(!1),n=Vue.ref(""),r=Vue.ref(null),i=Vue.ref(null),o=Vue.ref(null),a=Vue.ref(null),l=Vue.ref(-1),c=`modern-select-${++uS}`,d=`${c}-menu`,u=Vue.ref({}),g=Vue.computed(()=>e.options.find(x=>x.value===e.modelValue)||null),p=Vue.computed(()=>{if(!e.searchable||!n.value.trim())return e.options;let x=n.value.trim().toLowerCase();return e.options.filter(Y=>String(Y.label||"").toLowerCase().includes(x)||String(Y.sublabel||"").toLowerCase().includes(x)||String(Y.value||"").toLowerCase().includes(x))}),f=x=>`${c}-option-${x}`,m=Vue.computed(()=>s.value&&l.value>=0&&l.value<p.value.length?f(l.value):void 0);function v(){let x=r.value,Y=i.value,L=o.value;if(!x||!Y||!L)return;let U=6,E=8,oe=x.getBoundingClientRect(),q=document.documentElement.clientWidth||window.innerWidth,I=document.documentElement.clientHeight||window.innerHeight,T=Math.min(Math.max(oe.width,e.menuMinWidth),Math.max(0,q-E*2)),R=e.searchable?58:12,M=Math.min(L.scrollHeight+R,304),$=Math.max(0,I-oe.bottom-U-E),j=Math.max(0,oe.top-U-E),z=$<M&&j>$,Q=Math.max(48,Math.min(M,z?j:$)),ae=oe.right-T,ke=Math.min(Math.max(E,ae),Math.max(E,q-E-T));u.value={top:`${z?oe.top-U-Q:oe.bottom+U}px`,left:`${ke}px`,width:`${T}px`,maxHeight:`${Q}px`,"--modern-select-list-max-height":`${Math.max(36,Q-(e.searchable?58:12))}px`}}function b(){e.disabled||(s.value=!s.value,s.value&&(n.value="",l.value=p.value.findIndex(x=>x.value===e.modelValue),Vue.nextTick(()=>{v(),e.searchable&&a.value?.focus&&a.value.focus();let x=i.value?.querySelector(".modern-select-option.is-active");x?.scrollIntoView&&x.scrollIntoView({block:"nearest"})})))}function h(){s.value=!1}function k(x){!x||x.disabled||(t("update:modelValue",x.value),t("change",x.value),h())}function S(x){if(!p.value.length)return;let Y=l.value;for(let L=0;L<p.value.length;L+=1)if(Y=(Y+x+p.value.length)%p.value.length,!p.value[Y]?.disabled){l.value=Y;return}}function y(x){if(!s.value){(x.key==="Enter"||x.key===" "||x.key==="ArrowDown")&&(x.preventDefault(),b());return}if(x.key==="Escape"){x.preventDefault(),x.stopPropagation(),h();return}if(x.key==="ArrowDown")x.preventDefault(),S(1);else if(x.key==="ArrowUp")x.preventDefault(),S(-1);else if(x.key==="Enter"){x.preventDefault();let Y=p.value[l.value];Y&&k(Y)}}function w(x){s.value&&(r.value?.contains(x.target)||i.value?.contains(x.target)||h())}let P=()=>{s.value&&v()};return Vue.onMounted(()=>{document.addEventListener("mousedown",w),window.addEventListener("resize",P),window.addEventListener("scroll",P,!0)}),Vue.onBeforeUnmount(()=>{document.removeEventListener("mousedown",w),window.removeEventListener("resize",P),window.removeEventListener("scroll",P,!0)}),Vue.watch(()=>e.modelValue,()=>{}),{open:s,search:n,triggerEl:r,menuEl:i,searchEl:a,activeIdx:l,selected:g,filtered:p,menuId:d,menuStyle:u,listEl:o,optionId:f,activeOptionId:m,toggle:b,close:h,pick:k,onKey:y}},template:`
4760
4763
  <div class="modern-select" :class="{ 'is-open': open, 'is-disabled': disabled }">
4761
4764
  <button
4762
4765
  type="button"
@@ -5349,7 +5352,7 @@ ${String(e||"").trim()}
5349
5352
  </div>
5350
5353
  </div>
5351
5354
  </div>
5352
- `,props:{visible:{type:Boolean,default:!1},modelValue:{type:Array,default:()=>[]}},emits:["close","update:modelValue"],setup(e,{emit:t}){let s=Pinia.useChatStore(),n=Pinia.useAuthStore(),r=Vue.ref(null),i=Vue.computed(()=>n.role==="admin"),o=Vue.computed(()=>(s.locale||"zh-CN")==="zh-CN"),a=Vue.ref(null),l=Vue.ref(!1),c=Vue.ref(null),d=Vue.ref(null),u={id:"custom",name:o.value?"\u81EA\u5B9A\u4E49":"Custom",nameEn:"Custom",icon:"\u2728",order:99},g=Vue.computed(()=>{if(!a.value)return null;let N=Zt[a.value];return N||s.customExpertRoles.find(G=>G.id===a.value)||null}),p=Vue.computed(()=>{let N=g.value;return N?`${N.title}\xB7${N.name}`:""}),f=Vue.computed(()=>!a.value||!s.expertRoleDefinitions?null:s.expertRoleDefinitions[a.value]||null),m=Vue.computed(()=>!a.value||Zt[a.value]?null:s.customExpertRoles.find(N=>N.id===a.value)||null),v=Vue.ref(new Set([ap])),y=Vue.computed(()=>e.modelValue),h=Vue.computed(()=>lp(i.value)),k=Vue.computed(()=>{let N=[...h.value];return N.push({id:"custom",name:o.value?"\u81EA\u5B9A\u4E49":"Custom",icon:"\u2728",order:99}),N}),S=Vue.computed(()=>v.value.has("custom")),b=Vue.computed(()=>new Set(h.value.map(N=>N.id))),w=Vue.computed(()=>ip().filter(N=>b.value.has(N.teamId)&&v.value.has(N.teamId)));Vue.watch(()=>e.visible,N=>{N&&(s.fetchExpertRoleDefinitions(),s.fetchCustomExpertRoles())});let P=N=>{a.value=N,Zt[N]&&s.fetchExpertRoleDefinitions()},x=N=>{c.value=N,l.value=!0},Y=()=>{s.fetchCustomExpertRoles()},L=N=>{d.value=N},U=async()=>{if(d.value){try{let N=d.value.id,G=y.value.filter(de=>de.role!==N);G.length!==y.value.length&&t("update:modelValue",G),await s.deleteCustomExpertRole(N)}catch{}d.value=null}},E=N=>{if(!(v.value.size===1&&v.value.has(N)))if(v.value=new Set([N]),N==="custom"){let G=new Set(s.customExpertRoles.map(we=>we.id)),de=y.value.filter(we=>G.has(we.role));de.length!==y.value.length&&t("update:modelValue",de)}else{let G=y.value.filter(de=>{let we=Zt[de.role];return we&&we.group===N});G.length!==y.value.length&&t("update:modelValue",G)}},oe=(N,G)=>y.value.some(de=>de.role===N&&de.action===(G||null)),q=N=>y.value.some(G=>G.role===N&&!G.action),I=N=>y.value.some(G=>G.role===N),T=N=>y.value.length>=Cn&&!I(N),R=(N,G)=>oe(N,G)?!1:!!(I(N)||y.value.length>=Cn),M=N=>{if(q(N.id)){t("update:modelValue",y.value.filter(G=>!(G.role===N.id&&!G.action)));return}if(I(N.id)){t("update:modelValue",[...y.value.filter(G=>G.role!==N.id),{role:N.id,action:null}]);return}y.value.length>=Cn||t("update:modelValue",[...y.value,{role:N.id,action:null}])},$=(N,G)=>{if(oe(N.id,G.id)){t("update:modelValue",y.value.filter(de=>!(de.role===N.id&&de.action===G.id)));return}if(I(N.id)){t("update:modelValue",[...y.value.filter(de=>de.role!==N.id),{role:N.id,action:G.id}]);return}y.value.length>=Cn||t("update:modelValue",[...y.value,{role:N.id,action:G.id}])};return{store:s,roleListRef:r,enabledTeams:v,selections:y,availableTeams:h,allTeamTabs:k,filteredGroups:w,isZh:o,isCustomTabActive:S,viewingRoleId:a,viewingRoleMeta:g,viewingRoleTitle:p,viewingRoleDef:f,viewingCustomRole:m,viewRole:P,editorOpen:l,editingRole:c,openEditor:x,onEditorSaved:Y,deletingRole:d,confirmDeleteRole:L,executeDelete:U,toggleTeam:E,isSelected:oe,isRoleOnlySelected:q,hasRoleSelection:I,isRoleDisabled:T,isDisabled:R,toggleRoleOnly:M,toggleAction:$,toggleCustomRoleOnly:N=>{M(N)},toggleCustomAction:(N,G)=>{$(N,G)},getSelectionLabelFull:N=>{if(Zt[N.role])return In(N);let de=s.customExpertRoles.find(we=>we.id===N.role);if(!de)return N.role;if(N.action){let we=de.actions?.find(se=>se.id===N.action);return we?`${de.name}\xB7${we.name}`:de.name}return de.name},removeSelection:N=>{let G=[...y.value];G.splice(N,1),t("update:modelValue",G)},clearAll:()=>{t("update:modelValue",[])},getSelectionLabel:In}}}});var da,ed=B(()=>{di();da={name:"SubAgentPanel",props:{visible:{type:Boolean,default:!1}},emits:["close"],template:`
5355
+ `,props:{visible:{type:Boolean,default:!1},modelValue:{type:Array,default:()=>[]}},emits:["close","update:modelValue"],setup(e,{emit:t}){let s=Pinia.useChatStore(),n=Pinia.useAuthStore(),r=Vue.ref(null),i=Vue.computed(()=>n.role==="admin"),o=Vue.computed(()=>(s.locale||"zh-CN")==="zh-CN"),a=Vue.ref(null),l=Vue.ref(!1),c=Vue.ref(null),d=Vue.ref(null),u={id:"custom",name:o.value?"\u81EA\u5B9A\u4E49":"Custom",nameEn:"Custom",icon:"\u2728",order:99},g=Vue.computed(()=>{if(!a.value)return null;let N=Zt[a.value];return N||s.customExpertRoles.find(G=>G.id===a.value)||null}),p=Vue.computed(()=>{let N=g.value;return N?`${N.title}\xB7${N.name}`:""}),f=Vue.computed(()=>!a.value||!s.expertRoleDefinitions?null:s.expertRoleDefinitions[a.value]||null),m=Vue.computed(()=>!a.value||Zt[a.value]?null:s.customExpertRoles.find(N=>N.id===a.value)||null),v=Vue.ref(new Set([ap])),b=Vue.computed(()=>e.modelValue),h=Vue.computed(()=>lp(i.value)),k=Vue.computed(()=>{let N=[...h.value];return N.push({id:"custom",name:o.value?"\u81EA\u5B9A\u4E49":"Custom",icon:"\u2728",order:99}),N}),S=Vue.computed(()=>v.value.has("custom")),y=Vue.computed(()=>new Set(h.value.map(N=>N.id))),w=Vue.computed(()=>ip().filter(N=>y.value.has(N.teamId)&&v.value.has(N.teamId)));Vue.watch(()=>e.visible,N=>{N&&(s.fetchExpertRoleDefinitions(),s.fetchCustomExpertRoles())});let P=N=>{a.value=N,Zt[N]&&s.fetchExpertRoleDefinitions()},x=N=>{c.value=N,l.value=!0},Y=()=>{s.fetchCustomExpertRoles()},L=N=>{d.value=N},U=async()=>{if(d.value){try{let N=d.value.id,G=b.value.filter(de=>de.role!==N);G.length!==b.value.length&&t("update:modelValue",G),await s.deleteCustomExpertRole(N)}catch{}d.value=null}},E=N=>{if(!(v.value.size===1&&v.value.has(N)))if(v.value=new Set([N]),N==="custom"){let G=new Set(s.customExpertRoles.map(we=>we.id)),de=b.value.filter(we=>G.has(we.role));de.length!==b.value.length&&t("update:modelValue",de)}else{let G=b.value.filter(de=>{let we=Zt[de.role];return we&&we.group===N});G.length!==b.value.length&&t("update:modelValue",G)}},oe=(N,G)=>b.value.some(de=>de.role===N&&de.action===(G||null)),q=N=>b.value.some(G=>G.role===N&&!G.action),I=N=>b.value.some(G=>G.role===N),T=N=>b.value.length>=Cn&&!I(N),R=(N,G)=>oe(N,G)?!1:!!(I(N)||b.value.length>=Cn),M=N=>{if(q(N.id)){t("update:modelValue",b.value.filter(G=>!(G.role===N.id&&!G.action)));return}if(I(N.id)){t("update:modelValue",[...b.value.filter(G=>G.role!==N.id),{role:N.id,action:null}]);return}b.value.length>=Cn||t("update:modelValue",[...b.value,{role:N.id,action:null}])},$=(N,G)=>{if(oe(N.id,G.id)){t("update:modelValue",b.value.filter(de=>!(de.role===N.id&&de.action===G.id)));return}if(I(N.id)){t("update:modelValue",[...b.value.filter(de=>de.role!==N.id),{role:N.id,action:G.id}]);return}b.value.length>=Cn||t("update:modelValue",[...b.value,{role:N.id,action:G.id}])};return{store:s,roleListRef:r,enabledTeams:v,selections:b,availableTeams:h,allTeamTabs:k,filteredGroups:w,isZh:o,isCustomTabActive:S,viewingRoleId:a,viewingRoleMeta:g,viewingRoleTitle:p,viewingRoleDef:f,viewingCustomRole:m,viewRole:P,editorOpen:l,editingRole:c,openEditor:x,onEditorSaved:Y,deletingRole:d,confirmDeleteRole:L,executeDelete:U,toggleTeam:E,isSelected:oe,isRoleOnlySelected:q,hasRoleSelection:I,isRoleDisabled:T,isDisabled:R,toggleRoleOnly:M,toggleAction:$,toggleCustomRoleOnly:N=>{M(N)},toggleCustomAction:(N,G)=>{$(N,G)},getSelectionLabelFull:N=>{if(Zt[N.role])return In(N);let de=s.customExpertRoles.find(we=>we.id===N.role);if(!de)return N.role;if(N.action){let we=de.actions?.find(se=>se.id===N.action);return we?`${de.name}\xB7${we.name}`:de.name}return de.name},removeSelection:N=>{let G=[...b.value];G.splice(N,1),t("update:modelValue",G)},clearAll:()=>{t("update:modelValue",[])},getSelectionLabel:In}}}});var da,ed=B(()=>{di();da={name:"SubAgentPanel",props:{visible:{type:Boolean,default:!1}},emits:["close"],template:`
5353
5356
  <div class="subagent-panel" :class="{ open: visible, expanded: store.activeSubagentId }" role="complementary" aria-label="Sub-Agents">
5354
5357
  <!-- Expanded Mode: Full message thread for a subagent -->
5355
5358
  <template v-if="store.activeSubagentId && activeAgent">
@@ -5423,7 +5426,7 @@ ${String(e||"").trim()}
5423
5426
  </div>
5424
5427
  </template>
5425
5428
  </div>
5426
- `,setup(e,{emit:t}){let s=Pinia.useChatStore(),n=Vue.ref(null),r=v=>{v.key==="Escape"&&e.visible&&(s.activeSubagentId?s.activeSubagentId=null:t("close"))};Vue.onMounted(()=>{document.addEventListener("keydown",r),Vue.nextTick(()=>Wt(n.value))}),Vue.onUnmounted(()=>document.removeEventListener("keydown",r));let i=Vue.computed(()=>s.currentSubagents),o=Vue.computed(()=>[...i.value].sort((v,y)=>v.status==="running"&&y.status!=="running"?-1:v.status!=="running"&&y.status==="running"?1:(y.startTime||0)-(v.startTime||0))),a=Vue.computed(()=>s.activeSubagentId&&i.value.find(v=>v.id===s.activeSubagentId)||null),l=Vue.computed(()=>s.activeSubagentMessages),c=v=>{s.activeSubagentId=v},d=()=>{s.activeSubagentId=null},u=v=>{if(!v.messages||v.messages.length===0)return null;for(let y=v.messages.length-1;y>=0;y--)if(v.messages[y].type==="text")return v.messages[y];return null},g=(v,y)=>{if(!v)return"";let h=v.replace(/[#*_`~\[\]()>|\\]/g,"").replace(/\n+/g," ").trim();return h.length>y?h.substring(0,y)+"...":h},p=v=>v?bf(v):"",f=Vue.computed(()=>l.value.map(v=>`${v.type||""}:${v.content||""}`).join("\0")),m=()=>{Vue.nextTick(()=>{let v=n.value;v&&(Wt(v),v.scrollTop=v.scrollHeight)})};return Vue.watch(()=>[s.activeSubagentId,l.value.length,f.value],m),{store:s,allSubagents:i,sortedSubagents:o,activeAgent:a,activeMessages:l,expandAgent:c,closeExpanded:d,getLastMessage:u,truncate:g,renderMd:p,messagesRef:n}}}});var qm,Vm=B(()=>{qm={name:"BtwOverlay",template:`
5429
+ `,setup(e,{emit:t}){let s=Pinia.useChatStore(),n=Vue.ref(null),r=v=>{v.key==="Escape"&&e.visible&&(s.activeSubagentId?s.activeSubagentId=null:t("close"))};Vue.onMounted(()=>{document.addEventListener("keydown",r),Vue.nextTick(()=>Wt(n.value))}),Vue.onUnmounted(()=>document.removeEventListener("keydown",r));let i=Vue.computed(()=>s.currentSubagents),o=Vue.computed(()=>[...i.value].sort((v,b)=>v.status==="running"&&b.status!=="running"?-1:v.status!=="running"&&b.status==="running"?1:(b.startTime||0)-(v.startTime||0))),a=Vue.computed(()=>s.activeSubagentId&&i.value.find(v=>v.id===s.activeSubagentId)||null),l=Vue.computed(()=>s.activeSubagentMessages),c=v=>{s.activeSubagentId=v},d=()=>{s.activeSubagentId=null},u=v=>{if(!v.messages||v.messages.length===0)return null;for(let b=v.messages.length-1;b>=0;b--)if(v.messages[b].type==="text")return v.messages[b];return null},g=(v,b)=>{if(!v)return"";let h=v.replace(/[#*_`~\[\]()>|\\]/g,"").replace(/\n+/g," ").trim();return h.length>b?h.substring(0,b)+"...":h},p=v=>v?bf(v):"",f=Vue.computed(()=>l.value.map(v=>`${v.type||""}:${v.content||""}`).join("\0")),m=()=>{Vue.nextTick(()=>{let v=n.value;v&&(Wt(v),v.scrollTop=v.scrollHeight)})};return Vue.watch(()=>[s.activeSubagentId,l.value.length,f.value],m),{store:s,allSubagents:i,sortedSubagents:o,activeAgent:a,activeMessages:l,expandAgent:c,closeExpanded:d,getLastMessage:u,truncate:g,renderMd:p,messagesRef:n}}}});var qm,Vm=B(()=>{qm={name:"BtwOverlay",template:`
5427
5430
  <div v-if="store.btwMode" class="btw-float" role="log" aria-live="polite" aria-label="Side question conversation">
5428
5431
  <div class="btw-card">
5429
5432
  <div class="btw-header">
@@ -5661,7 +5664,7 @@ ${String(e||"").trim()}
5661
5664
  <p class="pane-empty-text">{{ $t('splitScreen.selectFromSidebar') }}</p>
5662
5665
  </div>
5663
5666
  </div>
5664
- `,setup(e){let t=Pinia.useChatStore(),s=Vue.ref(null),n=Vue.computed(()=>t.activePanelId===e.paneId),r=Vue.computed(()=>t.panels.find(te=>te.id===e.paneId)?.conversationId||null),i=Vue.computed(()=>r.value?t.messagesMap[r.value]||[]:[]),o=Vue.computed(()=>r.value?!!t.processingConversations[r.value]:!1),a=Vue.computed(()=>i.value.some(re=>re.isStreaming)),l=Vue.computed(()=>o.value&&!a.value),c=Vue.ref(0),d=Vue.ref(Date.now()),u=Vue.ref(null),g=Vue.ref(null),p=null,f=Vue.ref("cat"),m=new URLSearchParams(window.location.search).get("preview"),v=Vue.ref(5),y=Vue.ref(95),h=Vue.ref("bark-both"),k=Vue.ref(1),S=Vue.ref(-1),b=null;function w(){if(!c.value)return;let re=u.value,te=g.value;if(re&&te){let V=re.parentElement,ce=Math.max(0,(V?.clientWidth||0)-80);qo(re,te,Oo(Date.now()-c.value,ce))}}let P=Vo({onFrame:w});function x(){if(!c.value||f.value!=="dog")return;d.value=Date.now();let re=(d.value-c.value)%18e3;if(re<2e3)v.value=5,y.value=95,h.value="bark-both",k.value=1,S.value=-1;else if(re<5e3){let te=(re-2e3)/3e3;v.value=5+te*25,y.value=95,h.value="left-approach",k.value=1,S.value=-1}else if(re<8e3){let te=(re-5e3)/3e3;v.value=30,y.value=95-te*25,h.value="right-approach",k.value=1,S.value=-1}else if(re<1e4){let te=(re-8e3)/2e3;v.value=30+te*13,y.value=70-te*13,h.value="both-approach",k.value=1,S.value=-1}else if(re<11e3)v.value=43,y.value=57,h.value="snap",k.value=1,S.value=-1;else if(re<12500)v.value=43,y.value=57,h.value="stunned",k.value=1,S.value=-1;else if(re<15e3){let te=(re-12500)/2500;v.value=43-te*38,y.value=57+te*38,h.value="retreat",k.value=-1,S.value=1}else re<17e3?(v.value=5,y.value=95,h.value="rehang",k.value=-1,S.value=1):(v.value=5,y.value=95,h.value="reset",k.value=1,S.value=-1);b=requestAnimationFrame(x)}let Y=Vue.computed(()=>{let re=v.value*1.2;return k.value<0?`translate(${re+13.5}, 0) scale(-1, 1)`:`translate(${re-13.5}, 0)`}),L=Vue.computed(()=>{let re=y.value*1.2;return S.value>0?`translate(${re-10.5}, 2)`:`translate(${re+10.5}, 2) scale(-1, 1)`}),U=Vue.computed(()=>{let re=h.value;return re==="bark-both"||re==="left-approach"||re==="right-approach"||re==="both-approach"||re==="reset"}),E=Vue.computed(()=>{let re=v.value*1.2,te=10;if(U.value){let X=Math.max(0,(re-3)*.12);return`M3,18 Q${(3+re)/2},${18+X} ${re},${te}`}if(h.value==="rehang")return`M${re},${te} Q${re-3},20 3,18`;let V=k.value<0?1:-1,ce=re+V*8;return`M${re},${te} Q${re},18 ${ce},22`}),oe=Vue.computed(()=>{let re=y.value*1.2,te=10;if(U.value){let X=Math.max(0,(118-re)*.12);return`M118,18 Q${(118+re)/2},${18+X} ${re},${te}`}if(h.value==="rehang")return`M${re},${te} Q${re+3},20 118,18`;let V=S.value>0?-1:1,ce=re+V*8;return`M${re},${te} Q${re},18 ${ce},22`}),q=Vue.computed(()=>h.value==="snap"?.2:.4),I=Vue.computed(()=>h.value==="snap"?.2:.4),T=Vue.computed(()=>v.value*1.2),R=Vue.computed(()=>y.value*1.2),M=Vue.computed(()=>m==="cat"||m==="dog"||m==="animation"?!0:l.value);Vue.watch(l,re=>{re?(c.value=Date.now(),d.value=Date.now(),p||(p=setInterval(()=>{d.value=Date.now()},1e3)),f.value="cat",v.value=5,y.value=95,h.value="bark-both",k.value=1,S.value=-1,f.value==="cat"?P.start():b=requestAnimationFrame(x)):(c.value=0,p&&(clearInterval(p),p=null),P.stop(),b&&(cancelAnimationFrame(b),b=null))},{immediate:!0}),(m==="cat"||m==="dog"||m==="animation")&&(c.value=Date.now(),d.value=Date.now(),m==="dog"?f.value="dog":f.value="cat",f.value==="cat"?P.start():(v.value=5,y.value=95,h.value="bark-both",k.value=1,S.value=-1,b=requestAnimationFrame(x))),Vue.onUnmounted(()=>{p&&(clearInterval(p),p=null),P.stop(),b&&(cancelAnimationFrame(b),b=null)});let $=Vue.computed(()=>{if(!o.value)return null;if(t.connectionState!=="connected")return"disconnected";let re=r.value;if(t.compactStatus?.conversationId===re&&t.compactStatus?.status==="compacting")return"compacting";let te=t.sessionHealth?.[re];return te?te.status:c.value&&d.value-c.value>8e3?"thinking":null});function j(){let re=r.value;if(!re)return;let te=t.conversations.find(V=>V.id===re);t.sendWsMessage({type:"refresh_conversation",conversationId:re,agentId:te?.agentId})}let z=Vue.computed(()=>{let re=i.value,te=[],V=null,ce=0,X=()=>{V&&(V.isActive=V.isStreaming===!0,co(V),(V.textContent||V.toolMsgs.length>0||V.todoMsg||V.askMsg)&&te.push(V),V=null)},F=()=>{ce++,V={type:"assistant-turn",id:"turn_"+ce,textContent:"",textSegments:[],isStreaming:!1,isActive:!1,isHistory:!1,todoMsg:null,toolMsgs:[],askMsg:null,messages:[]}};for(let Z=0;Z<re.length;Z++){let fe=re[Z];if(fe.type==="user"){if(!fe.content||!fe.content.trim())continue;X(),te.push({type:"user",id:fe.id||"u_"+Z,message:fe});continue}if(fe.type==="system"||fe.type==="error"){X(),te.push({type:fe.type,id:fe.id||"s_"+Z,message:fe});continue}if(!(fe.type==="tool-result"||fe.type==="tool_result")){if(fe.type==="assistant"){V||F(),lo(V,fe),fe.isStreaming&&(V.isStreaming=!0),fe.isHistory&&(V.isHistory=!0),V.messages.push(fe);continue}if(fe.type==="tool-use"){V||F();let Re=re[Z+1],J=Re&&(Re.type==="tool-result"||Re.type==="tool_result"),D={...fe,hasResult:J||fe.hasResult||!1,toolResult:fe.toolResult||null};fe.toolName==="TodoWrite"?V.todoMsg=D:fe.toolName==="AskUserQuestion"?V.askMsg=D:V.toolMsgs.push(D),V.messages.push(fe);continue}X(),te.push({type:fe.type||"unknown",id:fe.id||"x_"+Z,message:fe})}}return X(),te}),Q=(re,te)=>{if(!r.value)return;let V=te||[];t.sendMessageToConversation(r.value,re,V)},ae=()=>{r.value&&t.cancelExecutionForConversation(r.value)};function ke(){t.setActivePanel(e.paneId)}function N(){t.removePanel(e.paneId)}let G=Vue.computed(()=>t.getPaneRightPanel(e.paneId));function de(){t.setPaneRightPanel(e.paneId,null)}let we=Vue.ref(!0),se=50,ve=()=>{if(!s.value)return!0;let{scrollTop:re,scrollHeight:te,clientHeight:V}=s.value;return te-re-V<=se},Ie=()=>{s.value&&(s.value.scrollTop=s.value.scrollHeight)},ue=()=>{we.value=ve()};return Vue.watch(()=>i.value.length,()=>{we.value&&Vue.nextTick(Ie)}),Vue.watch(()=>{let re=i.value,te=re[re.length-1];return te?.isStreaming?te.content?.length:0},()=>{we.value&&Vue.nextTick(Ie)}),Vue.watch(r,()=>{s.value&&s.value.removeEventListener("scroll",ue),we.value=!0,Vue.nextTick(()=>{s.value&&(s.value.addEventListener("scroll",ue),Ie())})}),Vue.onMounted(()=>{s.value&&(s.value.addEventListener("scroll",ue),Ie())}),Vue.onUnmounted(()=>{s.value&&s.value.removeEventListener("scroll",ue)}),{store:t,containerRef:s,isActivePanel:n,conversationId:r,messages:i,isProcessing:o,showTypingDots:l,previewShowTypingDots:M,waitingStatus:$,animationType:f,catWalkRef:u,catSpriteRef:g,dogPhase:h,spikeTransform:Y,teddyTransform:L,leashPathL:E,leashPathR:oe,leashOpacityL:q,leashOpacityR:I,questionLX:T,questionRX:R,refreshSession:j,turnGroups:z,sendFn:Q,cancelFn:ae,setActive:ke,closePane:N,paneRightPanel:G,closePanePanel:de}}}});var ua,sd=B(()=>{ua={name:"SidebarModeToggle",props:{view:{type:String,required:!0},disabled:{type:Boolean,default:!1}},emits:["flip"],computed:{isYeaft(){return this.view==="yeaft"},chatLabel(){return this.$t("sidebar.toggle.chat")},yeaftLabel(){return this.$t("sidebar.toggle.yeaft")},titleText(){return this.isYeaft?this.chatLabel:this.yeaftLabel}},methods:{onClick(){this.disabled||this.$emit("flip",this.isYeaft?"chat":"yeaft")},onKeydown(e){this.disabled||(e.key==="Enter"||e.key===" "?(e.preventDefault(),this.onClick()):e.key==="ArrowLeft"&&this.isYeaft?(e.preventDefault(),this.$emit("flip","chat")):e.key==="ArrowRight"&&!this.isYeaft&&(e.preventDefault(),this.$emit("flip","yeaft")))}},template:`
5667
+ `,setup(e){let t=Pinia.useChatStore(),s=Vue.ref(null),n=Vue.computed(()=>t.activePanelId===e.paneId),r=Vue.computed(()=>t.panels.find(te=>te.id===e.paneId)?.conversationId||null),i=Vue.computed(()=>r.value?t.messagesMap[r.value]||[]:[]),o=Vue.computed(()=>r.value?!!t.processingConversations[r.value]:!1),a=Vue.computed(()=>i.value.some(re=>re.isStreaming)),l=Vue.computed(()=>o.value&&!a.value),c=Vue.ref(0),d=Vue.ref(Date.now()),u=Vue.ref(null),g=Vue.ref(null),p=null,f=Vue.ref("cat"),m=new URLSearchParams(window.location.search).get("preview"),v=Vue.ref(5),b=Vue.ref(95),h=Vue.ref("bark-both"),k=Vue.ref(1),S=Vue.ref(-1),y=null;function w(){if(!c.value)return;let re=u.value,te=g.value;if(re&&te){let V=re.parentElement,ce=Math.max(0,(V?.clientWidth||0)-80);qo(re,te,Oo(Date.now()-c.value,ce))}}let P=Vo({onFrame:w});function x(){if(!c.value||f.value!=="dog")return;d.value=Date.now();let re=(d.value-c.value)%18e3;if(re<2e3)v.value=5,b.value=95,h.value="bark-both",k.value=1,S.value=-1;else if(re<5e3){let te=(re-2e3)/3e3;v.value=5+te*25,b.value=95,h.value="left-approach",k.value=1,S.value=-1}else if(re<8e3){let te=(re-5e3)/3e3;v.value=30,b.value=95-te*25,h.value="right-approach",k.value=1,S.value=-1}else if(re<1e4){let te=(re-8e3)/2e3;v.value=30+te*13,b.value=70-te*13,h.value="both-approach",k.value=1,S.value=-1}else if(re<11e3)v.value=43,b.value=57,h.value="snap",k.value=1,S.value=-1;else if(re<12500)v.value=43,b.value=57,h.value="stunned",k.value=1,S.value=-1;else if(re<15e3){let te=(re-12500)/2500;v.value=43-te*38,b.value=57+te*38,h.value="retreat",k.value=-1,S.value=1}else re<17e3?(v.value=5,b.value=95,h.value="rehang",k.value=-1,S.value=1):(v.value=5,b.value=95,h.value="reset",k.value=1,S.value=-1);y=requestAnimationFrame(x)}let Y=Vue.computed(()=>{let re=v.value*1.2;return k.value<0?`translate(${re+13.5}, 0) scale(-1, 1)`:`translate(${re-13.5}, 0)`}),L=Vue.computed(()=>{let re=b.value*1.2;return S.value>0?`translate(${re-10.5}, 2)`:`translate(${re+10.5}, 2) scale(-1, 1)`}),U=Vue.computed(()=>{let re=h.value;return re==="bark-both"||re==="left-approach"||re==="right-approach"||re==="both-approach"||re==="reset"}),E=Vue.computed(()=>{let re=v.value*1.2,te=10;if(U.value){let X=Math.max(0,(re-3)*.12);return`M3,18 Q${(3+re)/2},${18+X} ${re},${te}`}if(h.value==="rehang")return`M${re},${te} Q${re-3},20 3,18`;let V=k.value<0?1:-1,ce=re+V*8;return`M${re},${te} Q${re},18 ${ce},22`}),oe=Vue.computed(()=>{let re=b.value*1.2,te=10;if(U.value){let X=Math.max(0,(118-re)*.12);return`M118,18 Q${(118+re)/2},${18+X} ${re},${te}`}if(h.value==="rehang")return`M${re},${te} Q${re+3},20 118,18`;let V=S.value>0?-1:1,ce=re+V*8;return`M${re},${te} Q${re},18 ${ce},22`}),q=Vue.computed(()=>h.value==="snap"?.2:.4),I=Vue.computed(()=>h.value==="snap"?.2:.4),T=Vue.computed(()=>v.value*1.2),R=Vue.computed(()=>b.value*1.2),M=Vue.computed(()=>m==="cat"||m==="dog"||m==="animation"?!0:l.value);Vue.watch(l,re=>{re?(c.value=Date.now(),d.value=Date.now(),p||(p=setInterval(()=>{d.value=Date.now()},1e3)),f.value="cat",v.value=5,b.value=95,h.value="bark-both",k.value=1,S.value=-1,f.value==="cat"?P.start():y=requestAnimationFrame(x)):(c.value=0,p&&(clearInterval(p),p=null),P.stop(),y&&(cancelAnimationFrame(y),y=null))},{immediate:!0}),(m==="cat"||m==="dog"||m==="animation")&&(c.value=Date.now(),d.value=Date.now(),m==="dog"?f.value="dog":f.value="cat",f.value==="cat"?P.start():(v.value=5,b.value=95,h.value="bark-both",k.value=1,S.value=-1,y=requestAnimationFrame(x))),Vue.onUnmounted(()=>{p&&(clearInterval(p),p=null),P.stop(),y&&(cancelAnimationFrame(y),y=null)});let $=Vue.computed(()=>{if(!o.value)return null;if(t.connectionState!=="connected")return"disconnected";let re=r.value;if(t.compactStatus?.conversationId===re&&t.compactStatus?.status==="compacting")return"compacting";let te=t.sessionHealth?.[re];return te?te.status:c.value&&d.value-c.value>8e3?"thinking":null});function j(){let re=r.value;if(!re)return;let te=t.conversations.find(V=>V.id===re);t.sendWsMessage({type:"refresh_conversation",conversationId:re,agentId:te?.agentId})}let z=Vue.computed(()=>{let re=i.value,te=[],V=null,ce=0,X=()=>{V&&(V.isActive=V.isStreaming===!0,co(V),(V.textContent||V.toolMsgs.length>0||V.todoMsg||V.askMsg)&&te.push(V),V=null)},F=()=>{ce++,V={type:"assistant-turn",id:"turn_"+ce,textContent:"",textSegments:[],isStreaming:!1,isActive:!1,isHistory:!1,todoMsg:null,toolMsgs:[],askMsg:null,messages:[]}};for(let Z=0;Z<re.length;Z++){let fe=re[Z];if(fe.type==="user"){if(!fe.content||!fe.content.trim())continue;X(),te.push({type:"user",id:fe.id||"u_"+Z,message:fe});continue}if(fe.type==="system"||fe.type==="error"){X(),te.push({type:fe.type,id:fe.id||"s_"+Z,message:fe});continue}if(!(fe.type==="tool-result"||fe.type==="tool_result")){if(fe.type==="assistant"){V||F(),lo(V,fe),fe.isStreaming&&(V.isStreaming=!0),fe.isHistory&&(V.isHistory=!0),V.messages.push(fe);continue}if(fe.type==="tool-use"){V||F();let Re=re[Z+1],J=Re&&(Re.type==="tool-result"||Re.type==="tool_result"),D={...fe,hasResult:J||fe.hasResult||!1,toolResult:fe.toolResult||null};fe.toolName==="TodoWrite"?V.todoMsg=D:fe.toolName==="AskUserQuestion"?V.askMsg=D:V.toolMsgs.push(D),V.messages.push(fe);continue}X(),te.push({type:fe.type||"unknown",id:fe.id||"x_"+Z,message:fe})}}return X(),te}),Q=(re,te)=>{if(!r.value)return;let V=te||[];t.sendMessageToConversation(r.value,re,V)},ae=()=>{r.value&&t.cancelExecutionForConversation(r.value)};function ke(){t.setActivePanel(e.paneId)}function N(){t.removePanel(e.paneId)}let G=Vue.computed(()=>t.getPaneRightPanel(e.paneId));function de(){t.setPaneRightPanel(e.paneId,null)}let we=Vue.ref(!0),se=50,ve=()=>{if(!s.value)return!0;let{scrollTop:re,scrollHeight:te,clientHeight:V}=s.value;return te-re-V<=se},Ie=()=>{s.value&&(s.value.scrollTop=s.value.scrollHeight)},ue=()=>{we.value=ve()};return Vue.watch(()=>i.value.length,()=>{we.value&&Vue.nextTick(Ie)}),Vue.watch(()=>{let re=i.value,te=re[re.length-1];return te?.isStreaming?te.content?.length:0},()=>{we.value&&Vue.nextTick(Ie)}),Vue.watch(r,()=>{s.value&&s.value.removeEventListener("scroll",ue),we.value=!0,Vue.nextTick(()=>{s.value&&(s.value.addEventListener("scroll",ue),Ie())})}),Vue.onMounted(()=>{s.value&&(s.value.addEventListener("scroll",ue),Ie())}),Vue.onUnmounted(()=>{s.value&&s.value.removeEventListener("scroll",ue)}),{store:t,containerRef:s,isActivePanel:n,conversationId:r,messages:i,isProcessing:o,showTypingDots:l,previewShowTypingDots:M,waitingStatus:$,animationType:f,catWalkRef:u,catSpriteRef:g,dogPhase:h,spikeTransform:Y,teddyTransform:L,leashPathL:E,leashPathR:oe,leashOpacityL:q,leashOpacityR:I,questionLX:T,questionRX:R,refreshSession:j,turnGroups:z,sendFn:Q,cancelFn:ae,setActive:ke,closePane:N,paneRightPanel:G,closePanePanel:de}}}});var ua,sd=B(()=>{ua={name:"SidebarModeToggle",props:{view:{type:String,required:!0},disabled:{type:Boolean,default:!1}},emits:["flip"],computed:{isYeaft(){return this.view==="yeaft"},chatLabel(){return this.$t("sidebar.toggle.chat")},yeaftLabel(){return this.$t("sidebar.toggle.yeaft")},titleText(){return this.isYeaft?this.chatLabel:this.yeaftLabel}},methods:{onClick(){this.disabled||this.$emit("flip",this.isYeaft?"chat":"yeaft")},onKeydown(e){this.disabled||(e.key==="Enter"||e.key===" "?(e.preventDefault(),this.onClick()):e.key==="ArrowLeft"&&this.isYeaft?(e.preventDefault(),this.$emit("flip","chat")):e.key==="ArrowRight"&&!this.isYeaft&&(e.preventDefault(),this.$emit("flip","yeaft")))}},template:`
5665
5668
  <button
5666
5669
  type="button"
5667
5670
  class="mode-toggle"
@@ -6299,7 +6302,7 @@ ${String(e||"").trim()}
6299
6302
  </div>
6300
6303
  </div>
6301
6304
  </Teleport>
6302
- `,data(){return{form:{provider:["yeaft","copilot","claude-code"].includes(this.initialProvider)?this.initialProvider:"yeaft",name:"",vpIds:[],defaultVpId:null,workDir:"",agentId:this.initialAgentId||null},busy:!1,submitError:"",...cd(),vpPickerTouched:!1,vpRosterOpen:!1,vpRosterPlacement:"down",vpRosterAvailableHeight:null,scannedSessions:[],restoreScanning:!1,restoring:null,restoreError:"",vpSnapshotTimer:null}},computed:{chat(){try{if(typeof window<"u"&&window.Pinia?.useChatStore)return window.Pinia.useChatStore()}catch{}return null},vpStore(){try{if(typeof window<"u"&&window.Pinia?.useVpStore)return window.Pinia.useVpStore()}catch{}return null},sessionsStore(){try{if(typeof window<"u"&&window.Pinia?.useSessionsStore)return window.Pinia.useSessionsStore()}catch{}return null},isYeaftProvider(){return this.form.provider==="yeaft"},vpLibraryReady(){let e=this.vpStore;return!!(e&&e.snapshotStatus==="ready"&&e.snapshotAgentId===this.form.agentId&&e.lastVpSnapshotAgentId===this.form.agentId)},vpList(){return this.vpLibraryReady?this.vpStore?.vpList||[]:[]},vpDomainSections(){return Rn(this.vpList)},vpListSignature(){return(this.vpList||[]).map(e=>e&&e.vpId).filter(Boolean).join(",")},vpLibraryEmpty(){let e=this.vpStore;return!e||!this.vpLibraryReady?!1:e.emptyLibrary===!0?!0:!!(e.lastSnapshotAt&&e.lastSnapshotAt>0&&(e.vpOrder?.length||0)===0)},vpLibraryError(){let e=this.vpStore;return!e||e.snapshotStatus!=="error"?!1:!e.snapshotAgentId||e.snapshotAgentId===this.form.agentId},agentOptions(){let e=this.chat;return!e||!Array.isArray(e.agents)?[]:e.agents.map(t=>({id:t.id,name:t.name,online:!!t.online,workDir:t.workDir||""}))},agentSelectOptions(){return this.agentOptions.map(e=>({value:e.id,label:e.name||e.id,sublabel:e.online?"":this.$t("settings.dashboard.offline"),disabled:!e.online}))},providerOptions(){return[{value:"yeaft",label:"Yeaft"},{value:"copilot",label:this.$t("provider.copilot")},{value:"claude-code",label:this.$t("provider.claudeCode")}]},agentSignature(){return this.agentOptions.map(e=>`${e.id}:${e.online?1:0}`).join(",")},folderPickerAgentId(){return this.form.agentId||this.chat?.currentAgent||""},defaultWorkDir(){return this.agentOptions.find(t=>t.id===this.form.agentId)?.workDir||this.chat?.currentAgentInfo?.workDir||""},workDirPlaceholder(){return this.defaultWorkDir||this.$t("modal.newConv.inputOrSelect")},allSessions(){return this.sessionsStore?.sessionList||[]},agentSessions(){let e=this.form.agentId||null;return e?this.allSessions.filter(t=>{let s=t&&t.agentId;return!s||s===e}):this.allSessions},folderAggregates(){let e=new Map;for(let t of this.agentSessions){let s=t&&typeof t.workDir=="string"?t.workDir.trim():"";if(!s)continue;let n=e.get(s)||{path:s,count:0};n.count+=1,e.set(s,n)}return Array.from(e.values()).sort((t,s)=>t.path.localeCompare(s.path))},sessionsInDir(){let e=this.form.agentId||null;return(Array.isArray(this.scannedSessions)?this.scannedSessions:[]).filter(s=>s&&s.id).map(s=>({...s,...s.agentId||e?{agentId:s.agentId||e}:{}}))},chatFolderRows(){return(this.chat?.folders||[]).map(e=>({path:e.path||e.name||"",count:Number(e.sessionCount)||0})).filter(e=>e.path)},createFolderRows(){return this.isYeaftProvider?this.folderAggregates:this.chatFolderRows},createSessionRows(){return this.isYeaftProvider?this.sessionsInDir:(this.chat?.historySessions||[]).map(e=>({...e,id:e.sessionId,name:e.title,createdAt:e.lastModified}))},canSubmit(){if(this.isYeaftProvider&&(!this.vpLibraryReady||this.form.vpIds.length===0)||!this.form.agentId)return!1;let e=this.agentOptions.find(t=>t.id===this.form.agentId);return!!(e&&e.online)},vpRosterSummary(){let e=this.form.vpIds||[];return e.length===0?this.$t("yeaft.session.create.vpNone"):e.length<=3?e.map(t=>this.vpLabelFor(t)).join(this.$t("common.comma")):this.$t("yeaft.session.create.vpCount",{n:e.length})},vpRosterPopupStyle(){return Number.isFinite(this.vpRosterAvailableHeight)?{"--vp-roster-available-height":`${this.vpRosterAvailableHeight}px`}:{}}},mounted(){window.addEventListener("keydown",this.onEsc),window.addEventListener("resize",this.scheduleVpRosterLayout),window.visualViewport?.addEventListener("resize",this.scheduleVpRosterLayout),window.visualViewport?.addEventListener("scroll",this.scheduleVpRosterLayout),window.addEventListener("workbench-message",this.handleFolderPickerMessage),document.addEventListener("click",this.handleOutsideRosterClick,!0),this.seedAgentDefault(),this.subscribeVpsFor(this.form.agentId),this.applyDefaultSelection()},watch:{vpListSignature(){this.applyDefaultSelection(),this.scheduleVpRosterLayout()},agentSignature(){this.seedAgentDefault(),this.scheduleVpRosterLayout()},"form.provider"(e,t){e!==t&&(this.form.workDir="",this.scannedSessions=[],this.restoreError="",e==="yeaft"?(this.subscribeVpsFor(this.form.agentId),this.applyDefaultSelection()):this.form.agentId&&this.chat?.listFoldersForAgent?.(this.form.agentId,e))},"form.agentId"(e,t){e!==t&&(this.isYeaftProvider&&this.subscribeVpsFor(e),this.form.vpIds=[],this.form.defaultVpId=null,this.vpPickerTouched=!1,this.isYeaftProvider&&this.applyDefaultSelection(),this.scannedSessions=[],this.restoreError="",!this.isYeaftProvider&&e&&this.chat?.listFoldersForAgent?.(e,this.form.provider),(this.form.workDir||"").trim()&&this.loadProviderSessions())},"form.workDir"(e,t){e===t||(this.restoreError="",this.scannedSessions=[],!(e||"").trim())||this.loadProviderSessions()}},beforeUnmount(){window.removeEventListener("keydown",this.onEsc),window.removeEventListener("resize",this.scheduleVpRosterLayout),window.visualViewport?.removeEventListener("resize",this.scheduleVpRosterLayout),window.visualViewport?.removeEventListener("scroll",this.scheduleVpRosterLayout),window.removeEventListener("workbench-message",this.handleFolderPickerMessage),document.removeEventListener("click",this.handleOutsideRosterClick,!0),this._vpRosterLayoutFrame&&cancelAnimationFrame(this._vpRosterLayoutFrame),this._folderPickerTimer&&clearTimeout(this._folderPickerTimer),this.vpSnapshotTimer&&clearTimeout(this.vpSnapshotTimer)},methods:{toggleVpRoster(){if(this.vpRosterOpen){this.closeVpRoster();return}this.vpRosterPlacement="down",this.vpRosterAvailableHeight=null,this.vpRosterOpen=!0,this.$nextTick(this.scheduleVpRosterLayout)},closeVpRoster(){this.vpRosterOpen=!1,this.vpRosterAvailableHeight=null},scheduleVpRosterLayout(){!this.vpRosterOpen||this._vpRosterLayoutFrame||(this._vpRosterLayoutFrame=requestAnimationFrame(()=>{this._vpRosterLayoutFrame=null,this.updateVpRosterLayout()}))},updateVpRosterLayout(){if(!this.vpRosterOpen)return;let e=this.$refs.vpRosterTrigger,t=this.$refs.vpRosterPopup,s=e?.closest?.(".resume-modal");if(!e||!t||!s)return;let n=t.style.maxHeight;t.style.maxHeight="none";let r=t.scrollHeight;t.style.maxHeight=n;let i=window.visualViewport,o=i?i.offsetTop:0,a=i?i.height:window.innerHeight,l={top:o,bottom:o+a},c=s.getBoundingClientRect(),d=kS(e.getBoundingClientRect(),c,l,r);this.vpRosterPlacement=d.placement,this.vpRosterAvailableHeight=d.availableHeight},seedAgentDefault(){try{let e=this.agentOptions;if(!Array.isArray(e)||e.length===0||e.find(i=>i.id===this.form.agentId&&i.online))return;let s=this.chat,n=s&&s.currentAgent||null,r=e.find(i=>i.id===n&&i.online)||e.find(i=>i.online)||null;r&&(this.form.agentId=r.id)}catch{}},subscribeVpsFor(e,{force:t=!1}={}){let s=this.chat,n=e||s?.currentAgent||null,r=this.vpStore;if(!s||typeof s.sendWsMessage!="function"||!n){let l=`vp_snapshot_${Date.now()}_${Math.random().toString(36).slice(2,8)}`;return r?.beginSnapshot?.(n,l),r?.failSnapshot?.(n,l,"No online Agent is available."),!1}if(!t&&r?.snapshotStatus==="ready"&&r.snapshotAgentId===n&&r.lastVpSnapshotAgentId===n)return this.vpSnapshotTimer&&clearTimeout(this.vpSnapshotTimer),this.vpSnapshotTimer=null,!0;let o=`vp_snapshot_${Date.now()}_${Math.random().toString(36).slice(2,8)}`;return r?.beginSnapshot?.(n,o),s.sendWsMessage({type:"yeaft_vp_subscribe",agentId:n,requestId:o})===!1?(r?.failSnapshot?.(n,o,"WebSocket is not connected."),!1):(this.vpSnapshotTimer&&clearTimeout(this.vpSnapshotTimer),this.vpSnapshotTimer=setTimeout(()=>{this.vpSnapshotTimer=null,r?.snapshotStatus==="loading"&&r.snapshotRequestId===o&&r.failSnapshot(n,o,"VP library request timed out.")},1e4),!0)},retryVpSnapshot(){this.subscribeVpsFor(this.form.agentId,{force:!0})},loadProviderSessions(){if(this.isYeaftProvider)return this.loadRestoreCandidates();let e=(this.form.workDir||"").trim();!e||!this.form.agentId||this.chat?.listHistorySessionsForAgent?.(this.form.agentId,e,this.form.provider)},async loadRestoreCandidates(){if(this.restoreScanning)return;let e=(this.form.workDir||"").trim();if(!e){this.scannedSessions=[];return}let t=this.chat;if(!t||typeof t.sessionCrudRequest!="function"){this.restoreError=this.$t("yeaft.restore.modal.scanError",{message:"store unavailable"});return}let s=this.form.agentId||null;if(!s){this.scannedSessions=[],this.restoreError=this.$t("yeaft.restore.modal.scanError",{message:"no agent selected"});return}this.restoreScanning=!0,this.restoreError="";try{let n=await t.sessionCrudRequest("scan_workdir",{workDir:e},{agentId:s});if(n&&n.ok){let r=Array.isArray(n.sessions)?n.sessions:Array.isArray(n.groups)?n.groups:[];this.scannedSessions=r}else{this.scannedSessions=[];let r=n?.error?.message||n?.error?.code||"unknown";this.restoreError=this.$t("yeaft.restore.modal.scanError",{message:r})}}catch(n){this.scannedSessions=[],this.restoreError=this.$t("yeaft.restore.modal.scanError",{message:n?.message||String(n)})}finally{this.restoreScanning=!1}},async onRestoreClick(e){if(!e||!e.id||this.restoring)return;let t=this.chat;if(!t||typeof t.sessionCrudRequest!="function"){this.restoreError=this.$t("yeaft.restore.modal.restoreError",{message:"store unavailable"});return}let s=this.form.agentId||null;if(!s){this.restoreError=this.$t("yeaft.restore.modal.restoreError",{message:"no agent selected"});return}this.restoring=e.id,this.restoreError="";try{let n=await t.sessionCrudRequest("restore",{sessionId:e.id,workDir:(this.form.workDir||"").trim()},{agentId:s});if(n&&n.ok){let i=n.session||n.group||e,o=i?.agentId||e.agentId||s;o&&t.currentAgent!==o&&typeof t.selectAgent=="function"&&t.selectAgent(o),this.sessionsStore&&this.sessionsStore.setActive(i.id||e.id,o),typeof t.setActiveSessionFilter=="function"&&t.setActiveSessionFilter(i.id||e.id,{agentId:o,force:!0}),this.$emit("created",i),this.$emit("close");return}let r=n?.error?.message||n?.error?.code||"unknown";this.restoreError=this.$t("yeaft.restore.modal.restoreError",{message:r})}catch(n){this.restoreError=this.$t("yeaft.restore.modal.restoreError",{message:n?.message||String(n)})}finally{this.restoring=null}},applyDefaultSelection(){if(this.vpPickerTouched)return;let e=this.vpList||[];if(e.length===0)return;let t=e.map(o=>o&&o.vpId).filter(Boolean);if(t.length===0)return;let s=Array.isArray(this.form.vpIds)?this.form.vpIds:[],n=s.filter(o=>t.includes(o)),r=this.form.defaultVpId&&n.includes(this.form.defaultVpId);if(n.length>0&&r){n.length!==s.length&&(this.form.vpIds=n);return}let i=t.includes(Gm)?Gm:n[0]||t[0];this.form.vpIds=[i],this.form.defaultVpId=i},toggleVp(e,t){this.vpPickerTouched=!0,t?(this.form.vpIds.includes(e)||this.form.vpIds.push(e),this.form.defaultVpId||(this.form.defaultVpId=e)):(this.form.vpIds=this.form.vpIds.filter(s=>s!==e),this.form.defaultVpId&&!this.form.vpIds.includes(this.form.defaultVpId)&&(this.form.defaultVpId=this.form.vpIds[0]||null))},vpLabelFor(e){let t=this.vpStore?.vpLabel;return typeof t=="function"?t(e):e},vpDescriptionFor(e){let t=this.vpStore?.vpDescription;return typeof t=="function"?t(e):""},vpTextColorFor(e){let t=this.vpStore?.vpTextColor;return typeof t=="function"?t(e):"var(--text-primary)"},selectFolder(e){this.form.workDir=e},selectSession(e){if(!(!e||!e.id)){if(!this.isYeaftProvider){let t=e.workDir||(this.form.workDir||"").trim()||this.defaultWorkDir;this.chat?.selectAgent?.(this.form.agentId),this.chat._pendingSessionTitle=e.name||e.title||null,this.chat?.resumeConversation?.(e.id,t,this.form.agentId,this.chatProviderOptions()),this.$emit("close");return}e.legacyImport?this.onRestoreClick(e):this.resumeExisting(e)}},chatProviderOptions(){let e={provider:this.form.provider};return this.form.provider==="copilot"&&(e.providerOptions={allowAllTools:!0}),e},resumeExisting(e){if(!e||!e.id)return;let t=this.chat,s=e.agentId||this.form.agentId||null,n=(t?.hiddenSessionCatalog||[]).find(r=>r?.runtimeProvider==="yeaft"&&r?.routeRef?.agentId===s&&r?.routeRef?.sessionId===e.id);if(n&&t?.restoreCatalogSession?.(n)!==!0){this.restoreError=this.$t("yeaft.restore.modal.restoreError",{message:"catalog unavailable"});return}s&&t&&t.currentAgent!==s&&typeof t.selectAgent=="function"&&t.selectAgent(s),this.sessionsStore&&this.sessionsStore.setActive(e.id,s),t&&typeof t.setActiveSessionFilter=="function"&&t.setActiveSessionFilter(e.id,{agentId:s,force:!0}),this.$emit("created",{...e,...s?{agentId:s}:{}}),this.$emit("close")},handleOutsideRosterClick(e){if(!this.vpRosterOpen)return;let t=this.$refs.vpRosterRoot;t&&(t.contains(e.target)||this.closeVpRoster())},getLastPathSegment(e){return Ai(e)},formatDate(e){return ma(e,this.$t.bind(this))},onEsc(e){if(e.key==="Escape"&&!this.folderPickerOpen){if(this.vpRosterOpen){this.closeVpRoster();return}this.busy||this.requestClose()}},onOverlayClick(){this.busy||this.requestClose()},requestClose(){this.$emit("close")},folderPickerInitialDir(){return this.form.workDir||this.defaultWorkDir||""},folderPickerSetWorkDir(e){this.form.workDir=e},...dd,async onSubmit(){if(!(this.busy||!this.canSubmit)){this.submitError="",this.busy=!0;try{if(!this.chat){this.submitError=this.$t("yeaft.session.error.unknown",{message:"store unavailable"});return}if(!this.isYeaftProvider){let d=this.form.workDir.trim()||this.defaultWorkDir;this.chat.selectAgent?.(this.form.agentId),this.chat.createConversation?.(d,this.form.agentId,null,this.chatProviderOptions()),this.$emit("created",{provider:this.form.provider,workDir:d}),this.$emit("close");return}if(typeof this.chat.createYeaftSession!="function"){this.submitError=this.$t("yeaft.session.error.unknown",{message:"store unavailable"});return}let e=new Set((this.vpList||[]).map(d=>d&&d.vpId).filter(Boolean)),t=this.form.vpIds.filter(d=>e.has(d));if(t.length===0){this.submitError=this.$t("yeaft.session.error.unknown",{message:"no valid VP selected"});return}let s=this.form.defaultVpId&&t.includes(this.form.defaultVpId)?this.form.defaultVpId:t[0],r=this.form.name.trim()||Ai(this.form.workDir.trim())||this.$t("yeaft.session.create.untitled"),i=await this.chat.createYeaftSession({displayName:r,vpIds:t,defaultVpId:s,workDir:this.form.workDir.trim(),agentId:this.form.agentId||null});if(i&&i.ok){let d=this.chat,u=i.session||i.group||null,g=u&&u.id,p=u?.agentId||this.form.agentId||null;g&&(p&&d&&d.currentAgent!==p&&typeof d.selectAgent=="function"&&d.selectAgent(p),this.sessionsStore&&this.sessionsStore.setActive(g,p),d&&typeof d.setActiveSessionFilter=="function"&&d.setActiveSessionFilter(g,{agentId:p,force:!0})),this.$emit("created",u),this.$emit("close");return}let o=i?.error?.code||"unknown",a=i?.error?.message||"",l=`yeaft.session.error.${o}`,c=this.$t(l,{message:a});this.submitError=c===l?this.$t("yeaft.session.error.unknown",{message:a}):c}catch(e){this.submitError=this.$t("yeaft.session.error.unknown",{message:e?.message||String(e)})}finally{this.busy=!1}}}}}});var Xm,Zm=B(()=>{Lo();$o();di();Xm={name:"WorkCenterActionDetail",components:{UserTurnBlock:cr,VpTurnBlock:lr},props:{action:{type:Object,default:null},canMessage:{type:Boolean,default:!1},messages:{type:Array,default:()=>[]},messagesNextCursor:{type:[String,Number],default:null},messagesLoading:{type:Boolean,default:!1},messagesError:{type:String,default:""},previewingAttachmentId:{type:String,default:null},attachmentError:{type:String,default:""}},emits:["back","close","load-earlier-messages","open-attachment","quote","edit-as-new"],computed:{executorName(){return this.action?.assignedVp?.name||this.action?.assignedVp?.id||this.action?.requiredRole||this.tr("workCenter.actionExecutorPending","Executor pending")},hasMessages(){return this.messages.length>0},waitingQuestion(){return this.action?.status!=="waiting"?"":String(this.action?.canonicalResult?.waitingReason||"").trim()},conversationBlocks(){return this.messages.map(e=>{let t=Number(e?.updatedAt||e?.createdAt)||0;if(e?.role==="user")return{key:e.id,kind:"user",message:{id:e.id,messageId:e.id,type:"user",content:e.text||"",attachments:Array.isArray(e.attachments)?e.attachments:[],quote:e.quote||null,timestamp:t}};let s=e.speaker||{},n=this.messageSpeaker(e),r=s.id||`work-center-action:${this.action?.id||"unknown"}`;return{key:e.id,kind:"assistant",speakerName:n,turn:{id:e.id,messageId:e.id,atMessageId:e.id,turnId:e.turnId||e.id,textContent:e.text||"",textSegments:e.text?[{key:e.id,content:e.text,kind:e.status==="running"?"progress":"result",isStreaming:e.status==="running"}]:[],isStreaming:e.status==="running",speakerVpId:r,speakerTimestamp:t,showSpeakerHeader:!0,timestamp:t,createdAt:t,todoMsg:null,toolMsgs:[],toolSummaryCount:0,imageMsgs:[],askMsg:null,attachments:Array.isArray(e.attachments)?e.attachments:[]}}})}},watch:{messages:{deep:!0,handler(){this.$nextTick(()=>Wt(this.$el))}}},mounted(){this.$nextTick(()=>Wt(this.$el))},methods:{tr(e,t){let s=this.$t?this.$t(e):e;return s&&s!==e?s:t},statusLabel(e){return this.tr(`workCenter.status.${e}`,String(e||"").replace("_"," "))},actionSequence(){let e=Number(this.action?.sequence);return Number.isFinite(e)&&e>0?e:1},messageSpeaker(e){if(e?.role==="user")return this.tr("workCenter.you","You");let t=this.$t("workCenter.actionNumber",{number:this.actionSequence()}),s=e?.speaker?.name||e?.speaker?.id||"";return s?this.$t("workCenter.messageSpeakerRole",{name:s,role:t}):t},time(e){if(!e)return"";try{return new Date(Number(e)).toLocaleString()}catch{return""}},formatAttachmentSize(e){let t=Math.max(0,Number(e)||0);return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/1024/1024).toFixed(1)} MB`},openAttachment(e){this.$emit("open-attachment",e?.attachment||e,e?.trigger||null)}},template:`
6305
+ `,data(){return{form:{provider:["yeaft","copilot","claude-code"].includes(this.initialProvider)?this.initialProvider:"yeaft",name:"",vpIds:[],defaultVpId:null,workDir:"",agentId:this.initialAgentId||null},busy:!1,submitError:"",...cd(),vpPickerTouched:!1,vpRosterOpen:!1,vpRosterPlacement:"down",vpRosterAvailableHeight:null,scannedSessions:[],restoreScanning:!1,restoring:null,restoreError:"",vpSnapshotTimer:null}},computed:{chat(){try{if(typeof window<"u"&&window.Pinia?.useChatStore)return window.Pinia.useChatStore()}catch{}return null},vpStore(){try{if(typeof window<"u"&&window.Pinia?.useVpStore)return window.Pinia.useVpStore()}catch{}return null},sessionsStore(){try{if(typeof window<"u"&&window.Pinia?.useSessionsStore)return window.Pinia.useSessionsStore()}catch{}return null},isYeaftProvider(){return this.form.provider==="yeaft"},vpLibraryReady(){let e=this.vpStore;return!!(e&&e.snapshotStatus==="ready"&&e.snapshotAgentId===this.form.agentId&&e.lastVpSnapshotAgentId===this.form.agentId)},vpList(){return this.vpLibraryReady?this.vpStore?.vpList||[]:[]},vpDomainSections(){return Rn(this.vpList)},vpListSignature(){return(this.vpList||[]).map(e=>e&&e.vpId).filter(Boolean).join(",")},vpLibraryEmpty(){let e=this.vpStore;return!e||!this.vpLibraryReady?!1:e.emptyLibrary===!0?!0:!!(e.lastSnapshotAt&&e.lastSnapshotAt>0&&(e.vpOrder?.length||0)===0)},vpLibraryError(){let e=this.vpStore;return!e||e.snapshotStatus!=="error"?!1:!e.snapshotAgentId||e.snapshotAgentId===this.form.agentId},agentOptions(){let e=this.chat;return!e||!Array.isArray(e.agents)?[]:e.agents.map(t=>({id:t.id,name:t.name,online:!!t.online,workDir:t.workDir||""}))},agentSelectOptions(){return this.agentOptions.map(e=>({value:e.id,label:e.name||e.id,sublabel:e.online?"":this.$t("settings.dashboard.offline"),disabled:!e.online}))},providerOptions(){return[{value:"yeaft",label:"Yeaft"},{value:"copilot",label:this.$t("provider.copilot")},{value:"claude-code",label:this.$t("provider.claudeCode")}]},agentSignature(){return this.agentOptions.map(e=>`${e.id}:${e.online?1:0}`).join(",")},folderPickerAgentId(){return this.form.agentId||this.chat?.currentAgent||""},defaultWorkDir(){return this.agentOptions.find(t=>t.id===this.form.agentId)?.workDir||this.chat?.currentAgentInfo?.workDir||""},workDirPlaceholder(){return this.defaultWorkDir||this.$t("modal.newConv.inputOrSelect")},allSessions(){return this.sessionsStore?.sessionList||[]},agentSessions(){let e=this.form.agentId||null;return e?this.allSessions.filter(t=>{let s=t&&t.agentId;return!s||s===e}):this.allSessions},folderAggregates(){let e=new Map;for(let t of this.agentSessions){let s=t&&typeof t.workDir=="string"?t.workDir.trim():"";if(!s)continue;let n=e.get(s)||{path:s,count:0};n.count+=1,e.set(s,n)}return Array.from(e.values()).sort((t,s)=>t.path.localeCompare(s.path))},sessionsInDir(){let e=this.form.agentId||null;return(Array.isArray(this.scannedSessions)?this.scannedSessions:[]).filter(s=>s&&s.id).map(s=>({...s,...s.agentId||e?{agentId:s.agentId||e}:{}}))},chatFolderRows(){return(this.chat?.folders||[]).map(e=>({path:e.path||e.name||"",count:Number(e.sessionCount)||0})).filter(e=>e.path)},createFolderRows(){return this.isYeaftProvider?this.folderAggregates:this.chatFolderRows},createSessionRows(){return this.isYeaftProvider?this.sessionsInDir:(this.chat?.historySessions||[]).map(e=>({...e,id:e.sessionId,name:e.title,createdAt:e.lastModified}))},canSubmit(){if(this.isYeaftProvider&&(!this.vpLibraryReady||this.form.vpIds.length===0)||!this.form.agentId)return!1;let e=this.agentOptions.find(t=>t.id===this.form.agentId);return!!(e&&e.online)},vpRosterSummary(){let e=this.form.vpIds||[];return e.length===0?this.$t("yeaft.session.create.vpNone"):e.length<=3?e.map(t=>this.vpLabelFor(t)).join(this.$t("common.comma")):this.$t("yeaft.session.create.vpCount",{n:e.length})},vpRosterPopupStyle(){return Number.isFinite(this.vpRosterAvailableHeight)?{"--vp-roster-available-height":`${this.vpRosterAvailableHeight}px`}:{}}},mounted(){window.addEventListener("keydown",this.onEsc),window.addEventListener("resize",this.scheduleVpRosterLayout),window.visualViewport?.addEventListener("resize",this.scheduleVpRosterLayout),window.visualViewport?.addEventListener("scroll",this.scheduleVpRosterLayout),window.addEventListener("workbench-message",this.handleFolderPickerMessage),document.addEventListener("click",this.handleOutsideRosterClick,!0),this.seedAgentDefault(),this.subscribeVpsFor(this.form.agentId),this.applyDefaultSelection()},watch:{vpListSignature(){this.applyDefaultSelection(),this.scheduleVpRosterLayout()},agentSignature(){this.seedAgentDefault(),this.scheduleVpRosterLayout()},"form.provider"(e,t){e!==t&&(this.form.workDir="",this.scannedSessions=[],this.restoreError="",e==="yeaft"?(this.subscribeVpsFor(this.form.agentId),this.applyDefaultSelection()):this.form.agentId&&this.chat?.listFoldersForAgent?.(this.form.agentId,e))},"form.agentId"(e,t){e!==t&&(this.isYeaftProvider&&this.subscribeVpsFor(e),this.form.vpIds=[],this.form.defaultVpId=null,this.vpPickerTouched=!1,this.isYeaftProvider&&this.applyDefaultSelection(),this.scannedSessions=[],this.restoreError="",!this.isYeaftProvider&&e&&this.chat?.listFoldersForAgent?.(e,this.form.provider),(this.form.workDir||"").trim()&&this.loadProviderSessions())},"form.workDir"(e,t){e===t||(this.restoreError="",this.scannedSessions=[],!(e||"").trim())||this.loadProviderSessions()}},beforeUnmount(){window.removeEventListener("keydown",this.onEsc),window.removeEventListener("resize",this.scheduleVpRosterLayout),window.visualViewport?.removeEventListener("resize",this.scheduleVpRosterLayout),window.visualViewport?.removeEventListener("scroll",this.scheduleVpRosterLayout),window.removeEventListener("workbench-message",this.handleFolderPickerMessage),document.removeEventListener("click",this.handleOutsideRosterClick,!0),this._vpRosterLayoutFrame&&cancelAnimationFrame(this._vpRosterLayoutFrame),this._folderPickerTimer&&clearTimeout(this._folderPickerTimer),this.vpSnapshotTimer&&clearTimeout(this.vpSnapshotTimer)},methods:{toggleVpRoster(){if(this.vpRosterOpen){this.closeVpRoster();return}this.vpRosterPlacement="down",this.vpRosterAvailableHeight=null,this.vpRosterOpen=!0,this.$nextTick(this.scheduleVpRosterLayout)},closeVpRoster(){this.vpRosterOpen=!1,this.vpRosterAvailableHeight=null},scheduleVpRosterLayout(){!this.vpRosterOpen||this._vpRosterLayoutFrame||(this._vpRosterLayoutFrame=requestAnimationFrame(()=>{this._vpRosterLayoutFrame=null,this.updateVpRosterLayout()}))},updateVpRosterLayout(){if(!this.vpRosterOpen)return;let e=this.$refs.vpRosterTrigger,t=this.$refs.vpRosterPopup,s=e?.closest?.(".resume-modal");if(!e||!t||!s)return;let n=t.style.maxHeight;t.style.maxHeight="none";let r=t.scrollHeight;t.style.maxHeight=n;let i=window.visualViewport,o=i?i.offsetTop:0,a=i?i.height:window.innerHeight,l={top:o,bottom:o+a},c=s.getBoundingClientRect(),d=kS(e.getBoundingClientRect(),c,l,r);this.vpRosterPlacement=d.placement,this.vpRosterAvailableHeight=d.availableHeight},seedAgentDefault(){try{let e=this.agentOptions;if(!Array.isArray(e)||e.length===0||e.find(i=>i.id===this.form.agentId&&i.online))return;let s=this.chat,n=s&&s.currentAgent||null,r=e.find(i=>i.id===n&&i.online)||e.find(i=>i.online)||null;r&&(this.form.agentId=r.id)}catch{}},subscribeVpsFor(e,{force:t=!1}={}){let s=this.chat,n=e||s?.currentAgent||null,r=this.vpStore;if(!s||typeof s.sendWsMessage!="function"||!n){let l=`vp_snapshot_${Date.now()}_${Math.random().toString(36).slice(2,8)}`;return r?.beginSnapshot?.(n,l),r?.failSnapshot?.(n,l,"No online Agent is available."),!1}if(!t&&r?.snapshotStatus==="ready"&&r.snapshotAgentId===n&&r.lastVpSnapshotAgentId===n)return this.vpSnapshotTimer&&clearTimeout(this.vpSnapshotTimer),this.vpSnapshotTimer=null,!0;let o=`vp_snapshot_${Date.now()}_${Math.random().toString(36).slice(2,8)}`;return r?.beginSnapshot?.(n,o),s.sendWsMessage({type:"yeaft_vp_subscribe",agentId:n,requestId:o})===!1?(r?.failSnapshot?.(n,o,"WebSocket is not connected."),!1):(this.vpSnapshotTimer&&clearTimeout(this.vpSnapshotTimer),this.vpSnapshotTimer=setTimeout(()=>{this.vpSnapshotTimer=null,r?.snapshotStatus==="loading"&&r.snapshotRequestId===o&&r.failSnapshot(n,o,"VP library request timed out.")},1e4),!0)},retryVpSnapshot(){this.subscribeVpsFor(this.form.agentId,{force:!0})},loadProviderSessions(){if(this.isYeaftProvider)return this.loadRestoreCandidates();let e=(this.form.workDir||"").trim();!e||!this.form.agentId||this.chat?.listHistorySessionsForAgent?.(this.form.agentId,e,this.form.provider)},async loadRestoreCandidates(){if(this.restoreScanning)return;let e=(this.form.workDir||"").trim();if(!e){this.scannedSessions=[];return}let t=this.chat;if(!t||typeof t.sessionCrudRequest!="function"){this.restoreError=this.$t("yeaft.restore.modal.scanError",{message:"store unavailable"});return}let s=this.form.agentId||null;if(!s){this.scannedSessions=[],this.restoreError=this.$t("yeaft.restore.modal.scanError",{message:"no agent selected"});return}this.restoreScanning=!0,this.restoreError="";try{let n=await t.sessionCrudRequest("scan_workdir",{workDir:e},{agentId:s});if(n&&n.ok){let r=Array.isArray(n.sessions)?n.sessions:Array.isArray(n.groups)?n.groups:[];this.scannedSessions=r}else{this.scannedSessions=[];let r=n?.error?.message||n?.error?.code||"unknown";this.restoreError=this.$t("yeaft.restore.modal.scanError",{message:r})}}catch(n){this.scannedSessions=[],this.restoreError=this.$t("yeaft.restore.modal.scanError",{message:n?.message||String(n)})}finally{this.restoreScanning=!1}},async onRestoreClick(e){if(!e||!e.id||this.restoring)return;let t=this.chat;if(!t||typeof t.sessionCrudRequest!="function"){this.restoreError=this.$t("yeaft.restore.modal.restoreError",{message:"store unavailable"});return}let s=this.form.agentId||null;if(!s){this.restoreError=this.$t("yeaft.restore.modal.restoreError",{message:"no agent selected"});return}this.restoring=e.id,this.restoreError="";try{let n=await t.sessionCrudRequest("restore",{sessionId:e.id,workDir:(this.form.workDir||"").trim()},{agentId:s});if(n&&n.ok){let i=n.session||n.group||e,o=i?.agentId||e.agentId||s;o&&t.currentAgent!==o&&typeof t.selectAgent=="function"&&t.selectAgent(o),this.sessionsStore&&this.sessionsStore.setActive(i.id||e.id,o),typeof t.setActiveSessionFilter=="function"&&t.setActiveSessionFilter(i.id||e.id,{agentId:o,force:!0}),this.$emit("created",i),this.$emit("close");return}let r=n?.error?.message||n?.error?.code||"unknown";this.restoreError=this.$t("yeaft.restore.modal.restoreError",{message:r})}catch(n){this.restoreError=this.$t("yeaft.restore.modal.restoreError",{message:n?.message||String(n)})}finally{this.restoring=null}},applyDefaultSelection(){if(this.vpPickerTouched)return;let e=this.vpList||[];if(e.length===0)return;let t=e.map(o=>o&&o.vpId).filter(Boolean);if(t.length===0)return;let s=Array.isArray(this.form.vpIds)?this.form.vpIds:[],n=s.filter(o=>t.includes(o)),r=this.form.defaultVpId&&n.includes(this.form.defaultVpId);if(n.length>0&&r){n.length!==s.length&&(this.form.vpIds=n);return}let i=t.includes(Gm)?Gm:n[0]||t[0];this.form.vpIds=[i],this.form.defaultVpId=i},toggleVp(e,t){this.vpPickerTouched=!0,t?(this.form.vpIds.includes(e)||this.form.vpIds.push(e),this.form.defaultVpId||(this.form.defaultVpId=e)):(this.form.vpIds=this.form.vpIds.filter(s=>s!==e),this.form.defaultVpId&&!this.form.vpIds.includes(this.form.defaultVpId)&&(this.form.defaultVpId=this.form.vpIds[0]||null))},vpLabelFor(e){let t=this.vpStore?.vpLabel;return typeof t=="function"?t(e):e},vpDescriptionFor(e){let t=this.vpStore?.vpDescription;return typeof t=="function"?t(e):""},vpTextColorFor(e){let t=this.vpStore?.vpTextColor;return typeof t=="function"?t(e):"var(--text-primary)"},selectFolder(e){this.form.workDir=e},selectSession(e){if(!(!e||!e.id)){if(!this.isYeaftProvider){let t=e.workDir||(this.form.workDir||"").trim()||this.defaultWorkDir;this.chat?.selectAgent?.(this.form.agentId),this.chat._pendingSessionTitle=e.name||e.title||null,this.chat?.resumeConversation?.(e.id,t,this.form.agentId,this.chatProviderOptions()),this.$emit("close");return}e.legacyImport?this.onRestoreClick(e):this.resumeExisting(e)}},chatProviderOptions(){let e={provider:this.form.provider};return this.form.provider==="copilot"&&(e.providerOptions={allowAllTools:!0}),e},resumeExisting(e){if(!e||!e.id)return;let t=this.chat,s=e.agentId||this.form.agentId||null,n=(t?.hiddenSessionCatalog||[]).find(r=>r?.runtimeProvider==="yeaft"&&r?.routeRef?.agentId===s&&r?.routeRef?.sessionId===e.id);if(n&&t?.restoreCatalogSession?.(n)!==!0){this.restoreError=this.$t("yeaft.restore.modal.restoreError",{message:"catalog unavailable"});return}s&&t&&t.currentAgent!==s&&typeof t.selectAgent=="function"&&t.selectAgent(s),this.sessionsStore&&this.sessionsStore.setActive(e.id,s),t&&typeof t.setActiveSessionFilter=="function"&&t.setActiveSessionFilter(e.id,{agentId:s,force:!0}),this.$emit("created",{...e,...s?{agentId:s}:{}}),this.$emit("close")},handleOutsideRosterClick(e){if(!this.vpRosterOpen)return;let t=this.$refs.vpRosterRoot;t&&(t.contains(e.target)||this.closeVpRoster())},getLastPathSegment(e){return Ai(e)},formatDate(e){return ma(e,this.$t.bind(this))},onEsc(e){if(e.key==="Escape"&&!this.folderPickerOpen){if(this.vpRosterOpen){this.closeVpRoster();return}this.busy||this.requestClose()}},onOverlayClick(){this.busy||this.requestClose()},requestClose(){this.$emit("close")},folderPickerInitialDir(){return this.form.workDir||this.defaultWorkDir||""},folderPickerSetWorkDir(e){this.form.workDir=e},...dd,async onSubmit(){if(!(this.busy||!this.canSubmit)){this.submitError="",this.busy=!0;try{if(!this.chat){this.submitError=this.$t("yeaft.session.error.unknown",{message:"store unavailable"});return}if(!this.isYeaftProvider){let d=this.form.workDir.trim()||this.defaultWorkDir;this.chat.selectAgent?.(this.form.agentId),this.chat.createConversation?.(d,this.form.agentId,null,this.chatProviderOptions()),this.$emit("created",{provider:this.form.provider,workDir:d}),this.$emit("close");return}if(typeof this.chat.createYeaftSession!="function"){this.submitError=this.$t("yeaft.session.error.unknown",{message:"store unavailable"});return}let e=new Set((this.vpList||[]).map(d=>d&&d.vpId).filter(Boolean)),t=this.form.vpIds.filter(d=>e.has(d));if(t.length===0){this.submitError=this.$t("yeaft.session.error.unknown",{message:"no valid VP selected"});return}let s=this.form.defaultVpId&&t.includes(this.form.defaultVpId)?this.form.defaultVpId:t[0],r=this.form.name.trim()||Ai(this.form.workDir.trim())||this.$t("yeaft.session.create.untitled"),i=await this.chat.createYeaftSession({displayName:r,vpIds:t,defaultVpId:s,workDir:this.form.workDir.trim(),agentId:this.form.agentId||null});if(i&&i.ok){let d=this.chat,u=i.session||i.group||null,g=u&&u.id,p=u?.agentId||this.form.agentId||null;g&&(p&&d&&d.currentAgent!==p&&typeof d.selectAgent=="function"&&d.selectAgent(p),this.sessionsStore&&this.sessionsStore.setActive(g,p),d&&typeof d.setActiveSessionFilter=="function"&&d.setActiveSessionFilter(g,{agentId:p,force:!0})),this.$emit("created",u),this.$emit("close");return}let o=i?.error?.code||"unknown",a=i?.error?.message||"",l=`yeaft.session.error.${o}`,c=this.$t(l,{message:a});this.submitError=c===l?this.$t("yeaft.session.error.unknown",{message:a}):c}catch(e){this.submitError=this.$t("yeaft.session.error.unknown",{message:e?.message||String(e)})}finally{this.busy=!1}}}}}});var Xm,Zm=B(()=>{Lo();$o();di();Xm={name:"WorkCenterActionDetail",components:{UserTurnBlock:cr,VpTurnBlock:lr},props:{action:{type:Object,default:null},canMessage:{type:Boolean,default:!1},messages:{type:Array,default:()=>[]},messagesNextCursor:{type:[String,Number],default:null},messagesLoading:{type:Boolean,default:!1},messagesError:{type:String,default:""},previewingAttachmentId:{type:String,default:null},attachmentError:{type:String,default:""}},emits:["back","close","load-earlier-messages","open-attachment","quote","edit-as-new"],computed:{executorName(){return this.action?.assignedVp?.name||this.action?.assignedVp?.id||this.action?.requiredRole||this.tr("workCenter.actionExecutorPending","Executor pending")},hasMessages(){return this.messages.length>0},waitingQuestion(){return this.action?.status!=="waiting"?"":String(this.action?.canonicalResult?.waitingReason||"").trim()},conversationBlocks(){return this.messages.map(e=>{let t=Number(e?.updatedAt||e?.createdAt)||0;if(e?.role==="user")return{key:e.id,kind:"user",message:{id:e.id,messageId:e.id,type:"user",content:e.text||"",attachments:Array.isArray(e.attachments)?e.attachments:[],quote:e.quote||null,timestamp:t}};let s=e.speaker||{},n=this.messageSpeaker(e),r=s.id||`work-center-action:${this.action?.id||"unknown"}`;return{key:e.id,kind:"assistant",speakerName:n,turn:{id:e.id,messageId:e.id,atMessageId:e.id,turnId:e.turnId||e.id,textContent:e.text||"",textSegments:e.text?[{key:e.id,content:e.text,kind:e.status==="running"?"progress":"result",isStreaming:e.status==="running"}]:[],isStreaming:e.status==="running",speakerVpId:r,speakerTimestamp:t,showSpeakerHeader:!0,timestamp:t,createdAt:t,todoMsg:null,toolMsgs:(Array.isArray(e.toolEvents)?e.toolEvents:[]).map((i,o)=>({type:"tool-use",toolId:i.id||`${e.id}:tool:${o}`,toolName:i.name,toolInput:i.resource?{displayResource:i.resource}:null,hasResult:i.status!=="running",isError:i.status==="error",startTime:Number(i.startedAt)||0})),toolSummaryCount:Array.isArray(e.toolEvents)?e.toolEvents.length:0,imageMsgs:[],askMsg:null,attachments:Array.isArray(e.attachments)?e.attachments:[]}}})}},watch:{messages:{deep:!0,handler(){this.$nextTick(()=>Wt(this.$el))}}},mounted(){this.$nextTick(()=>Wt(this.$el))},methods:{tr(e,t){let s=this.$t?this.$t(e):e;return s&&s!==e?s:t},statusLabel(e){return this.tr(`workCenter.status.${e}`,String(e||"").replace("_"," "))},actionSequence(){let e=Number(this.action?.sequence);return Number.isFinite(e)&&e>0?e:1},messageSpeaker(e){if(e?.role==="user")return this.tr("workCenter.you","You");let t=this.$t("workCenter.actionNumber",{number:this.actionSequence()}),s=e?.speaker?.name||e?.speaker?.id||"";return s?this.$t("workCenter.messageSpeakerRole",{name:s,role:t}):t},time(e){if(!e)return"";try{return new Date(Number(e)).toLocaleString()}catch{return""}},formatAttachmentSize(e){let t=Math.max(0,Number(e)||0);return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/1024/1024).toFixed(1)} MB`},openAttachment(e){this.$emit("open-attachment",e?.attachment||e,e?.trigger||null)}},template:`
6303
6306
  <section class="work-center-action-detail-pane" v-if="action">
6304
6307
  <header class="work-center-action-detail-header">
6305
6308
  <button class="work-center-icon-button" type="button" @click="$emit('back')" :title="tr('workCenter.backToActions', 'Back to Actions')" :aria-label="tr('workCenter.backToActions', 'Back to Actions')">
@@ -8382,7 +8385,7 @@ ${String(e||"").trim()}
8382
8385
  </footer>
8383
8386
  </section>
8384
8387
  `}});function MS(e){let t=String(e||"").trim();return t?t.startsWith("[")&&t.endsWith("]")?yv(t.slice(1,-1)).map(s=>s.trim().replace(/^["']|["']$/g,"")).map(s=>bv(s)).filter(Boolean):yv(t).map(s=>bv(s.trim())).filter(Boolean):[]}function yv(e){let t=[],s="",n=0,r="",i=!1;for(let o of String(e||"")){if(i){s+=o,i=!1;continue}if(o==="\\"&&r){s+=o,i=!0;continue}if(r){s+=o,o===r&&(r="");continue}if(o==='"'||o==="'"){r=o,s+=o;continue}if((o==="{"||o==="[")&&(n+=1),(o==="}"||o==="]")&&n>0&&(n-=1),o===","&&n===0){s.trim()&&t.push(s.trim()),s="";continue}s+=o}return s.trim()&&t.push(s.trim()),t}function bv(e){let t=String(e||"").trim();if(!t||t==="[object Object]")return"";if(t.startsWith("{")&&t.endsWith("}"))try{let s=JSON.parse(t);return String(s.id||s.messageId||s.uuid||"").trim()}catch{return""}return t}function PS(e){let t={},s=String(e||"").split(/\r?\n/);for(let n of s){let r=n.match(/^([A-Za-z][A-Za-z0-9_-]*):\s*(.*)$/);if(!r)continue;let i=r[1],o=r[2].trim();i==="tags"||i==="sourceMessages"?t[i]=MS(o):t[i]=o.replace(/^["']|["']$/g,"")}return t}function RS(e){let t=String(e||"").trim();if(!t)return[];let s=[],n=/(?:^|\n)---\s*\n([\s\S]*?)\n---\s*\n([\s\S]*?)(?=\n---\s*\n|$)/g;for(let r of t.matchAll(n)){let i=r[1].trim(),o=r[2].trim(),a=PS(i);s.push({id:a.id||`segment-${s.length+1}`,scope:a.scope||"",kind:a.kind||"memory",tags:Array.isArray(a.tags)?a.tags:[],sourceMessages:Array.isArray(a.sourceMessages)?a.sourceMessages:[],createdAt:a.createdAt||"",updatedAt:a.updatedAt||"",content:o,preview:wr(o,180)})}return s.length?s:[{id:"memory-1",scope:"",kind:"raw",tags:[],sourceMessages:[],createdAt:"",updatedAt:"",content:t,preview:wr(t,180)}]}function wr(e,t=160){let s=String(e||"").replace(/\s+/g," ").trim();return s.length<=t?s:`${s.slice(0,t).trim()}...`}function _S(e){let t=String(e||"").trim();return t?(t.split(/\r?\n/).map(n=>n.trim()).find(Boolean)||"").replace(/^#+\s*/,"").replace(/^[-*]\s*/,"").trim():""}function ES(e){return String(e||"").replace(/\s+/g," ").trim()}function wv(e,t){return t?.sessionId||String(e||"").replace(/^sessions\//,"")}function DS(e,t,s){let n=wv(e,t);return ES(s?.[e]||s?.[n]||t?.sessionTitle||t?.title||t?.name||_S(t?.summaryText))||n||e}function kv(e,t){let s=String(t||"").trim().toLowerCase();return s?(Array.isArray(e)?e:[]).filter(n=>[n.title,n.scope,n.sessionId,n.status,n.summaryPreview,n.snapshot?.summaryText].map(i=>String(i||"").toLowerCase()).join(`
8385
- `).includes(s)):Array.isArray(e)?e:[]}function Sv({latest:e={},snapshots:t={},promptLoads:s={},events:n=[],sessionTitles:r={}}={}){let i=new Set([...Object.keys(e||{}),...Object.keys(t||{}),...Object.keys(s||{})]);for(let o of Array.isArray(n)?n:[])o?.scope&&i.add(o.scope);return Array.from(i).map(o=>{let a=t?.[o]||null,l=e?.[o]||null,c=a?.lastError||l?.error||null,d=l?.status||(c?"error":a?.hasOutput?"completed":"never-ran"),u=s?.[o]||null,g=(Array.isArray(n)?n:[]).filter(S=>S?.scope===o),p=g[g.length-1]||null,f=l?.finishedAt||l?.startedAt||a?.lastDreamAt||p?.at||a?.loadedAt||"",m=RS(a?.memoryText||""),v=wv(o,a),y=DS(o,a,r),h=c?wr(c.message||c.error||c.raw||"",180):"",k=wr(h||a?.summaryText||a?.memoryText||p?.detail||"",180);return{key:o,title:y,scope:o,sessionId:v,status:d,lastAt:f,latestRun:l,snapshot:a,lastError:c,promptLoad:u,events:g,segmentCount:m.length,segments:m,summaryPreview:k,subtitle:k,hasRequestResponse:g.some(S=>S?.request||S?.response||S?.systemPrompt||S?.rawRequest||S?.rawResponse)}}).sort((o,a)=>String(a.lastAt||"").localeCompare(String(o.lastAt||"")))}var Iv=B(()=>{});var Cv,$S,Av,xv=B(()=>{Iv();cl();Cv=1,$S=5,Av={name:"YeaftDebugPanel",emits:["close"],data(){return{expandedTurns:{},expandedLoops:{},expandedSections:{},expandedToolDetails:{},copiedFlash:null,copiedFlashAt:0,_expandSnapshot:null,dreamExpanded:!1,expandedDreamEvents:{},expandedDreamSegments:{},activeDreamItemKey:null,dreamItemSearch:"",activeTab:"requests"}},watch:{turns(e,t){let s=e&&e[0];!s||!s.turnId||(t&&t[0]&&t[0].turnId)===s.turnId&&this.expandedTurns[s.turnId]||(this.expandedTurns={...this.expandedTurns,[s.turnId]:!0},this.ensureRequestDetailLoaded(s.turnId))},searchQuery(e,t){let s=!!(t&&t.trim()),n=!!(e&&e.trim());if(!s&&n){this._expandSnapshot={turns:{...this.expandedTurns},loops:{...this.expandedLoops}};let r={},i={};for(let o of this.turns)r[o.turnId]=!0,o.loops&&o.loops.length>0&&(i[`${o.turnId}#${o.loops[0].loopNumber}`]=!0);this.expandedTurns=r,this.expandedLoops=i}else if(s&&!n&&this._expandSnapshot)this.expandedTurns=this._expandSnapshot.turns,this.expandedLoops=this._expandSnapshot.loops,this._expandSnapshot=null;else if(n){let r={...this.expandedTurns};for(let i of this.turns)r[i.turnId]===void 0&&(r[i.turnId]=!0);this.expandedTurns=r}}},computed:{store(){return window.Pinia?.useChatStore?.()||null},sessionsStore(){return window.Pinia?.useSessionsStore?.()||null},turns(){let e=this.store&&this.store.yeaftDebugPanel||{},t=e.turnId?this.store&&this.store.yeaftDebugTurnsById&&this.store.yeaftDebugTurnsById[e.turnId]:null;if(!t)return[];let s=this.debugLoopsForTurn(t.turnId),n=s.length>0?s:Array.isArray(t.loops)?t.loops:[],r={...t,loops:n};return[{...this.decorateTurnTokenBreakdowns(r),latestRequest:this.latestRequestForTurn(r)}]},currentTurnId(){return this.store&&this.store.yeaftDebugPanel&&this.store.yeaftDebugPanel.turnId||""},currentTurnSessionId(){return this.store&&this.store.yeaftDebugPanel&&this.store.yeaftDebugPanel.sessionId||""},panelStatus(){return this.store&&this.store.yeaftDebugPanel&&this.store.yeaftDebugPanel.status||"idle"},panelLoading(){return this.panelStatus==="loading"},searchQuery:{get(){return this.store&&this.store.yeaftDebugSearch||""},set(e){this.store&&this.store.setYeaftDebugSearch(e)}},sessionFilter:{get(){if(!this.store)return"";let e=this.store.yeaftDebugSessionFilter;return e??""},set(e){this.store&&(e?this.store.setYeaftDebugSessionFilter(e):this.store.setYeaftDebugSessionFilter(null))}},availableSessions(){return this.store&&this.store.yeaftDebugAvailableSessions||[]},turnTotal(){return this.store&&this.store.yeaftDebugTurnTotal||0},showingMatchedHint(){return this.turnTotal>this.turns.length},requestHistoryLoading(){return!!this.store?.yeaftDebugHistoryLoading},requestHistoryError(){let e=this.store?.yeaftDebugHistoryError||"";return e==="debug_history_timeout"?this.$t("yeaft.debugHistoryUnavailable"):e},requestHistoryProjectionNotice(){return this.store?.yeaftDebugHistoryProjection?.truncated===!0?this.$t("yeaft.debugHistoryTruncated"):""},toolStats(){return this.store?.yeaftToolStats||null},toolStatsLoading(){return!!this.store?.yeaftToolStatsLoading},rankedToolRows(){let e=this.toolStats?.snapshot||{},t=Object.entries(e).map(([r,i])=>({name:r,...i})),s=new Set(t.map(r=>r.name)),n=Array.isArray(this.toolStats?.registered)?this.toolStats.registered:[];for(let r of n)typeof r!="string"||!r||s.has(r)||(t.push({name:r,callCount:0,errorCount:0,errorRate:0,avgMs:0,p50Ms:0,p95Ms:0,lastCalledAt:null,lastError:null}),s.add(r));return t.sort((r,i)=>{let o=(i.callCount||0)-(r.callCount||0);return o!==0?o:r.name.localeCompare(i.name)}),t},unusedToolRows(){return Array.isArray(this.toolStats?.unused)?this.toolStats.unused:[]},toolStatsFetchedAtLabel(){let e=this.toolStats?.fetchedAt;if(!e)return"";try{return new Date(e).toLocaleTimeString()}catch{return""}},dreamLatest(){return this.store&&this.store.yeaftDreamLatestForActiveSession||null},dreamLatestLabel(){let e=this.dreamLatest;if(!e)return"";if(e.status==="running")return`running \xB7 ${e.phase||"..."}`;if(e.status==="error")return`error \xB7 ${e.error||"unknown"}`;if(e.status==="skipped")return"skipped";let t=["done"];typeof e.mergedCount=="number"&&t.push(`merged ${e.mergedCount}`);let s=this.formatDreamMetrics(e);return s&&t.push(s),t.join(" \xB7 ")},dreamLatestKindLabel(){let e=this.dreamLatest;return e?e.manual?"manual":"auto":""},dreamSnapshot(){return this.store&&this.store.yeaftDreamSnapshotForActiveSession||null},dreamPromptLoad(){return this.store&&this.store.yeaftDreamPromptLoadForActiveSession||null},dreamPromptLoadSummary(){let e=this.dreamPromptLoad,t=e&&typeof e.summary=="string"?e.summary.trim():"";return t&&e.truncated?`${t}
8388
+ `).includes(s)):Array.isArray(e)?e:[]}function Sv({latest:e={},snapshots:t={},promptLoads:s={},events:n=[],sessionTitles:r={}}={}){let i=new Set([...Object.keys(e||{}),...Object.keys(t||{}),...Object.keys(s||{})]);for(let o of Array.isArray(n)?n:[])o?.scope&&i.add(o.scope);return Array.from(i).map(o=>{let a=t?.[o]||null,l=e?.[o]||null,c=a?.lastError||l?.error||null,d=l?.status||(c?"error":a?.hasOutput?"completed":"never-ran"),u=s?.[o]||null,g=(Array.isArray(n)?n:[]).filter(S=>S?.scope===o),p=g[g.length-1]||null,f=l?.finishedAt||l?.startedAt||a?.lastDreamAt||p?.at||a?.loadedAt||"",m=RS(a?.memoryText||""),v=wv(o,a),b=DS(o,a,r),h=c?wr(c.message||c.error||c.raw||"",180):"",k=wr(h||a?.summaryText||a?.memoryText||p?.detail||"",180);return{key:o,title:b,scope:o,sessionId:v,status:d,lastAt:f,latestRun:l,snapshot:a,lastError:c,promptLoad:u,events:g,segmentCount:m.length,segments:m,summaryPreview:k,subtitle:k,hasRequestResponse:g.some(S=>S?.request||S?.response||S?.systemPrompt||S?.rawRequest||S?.rawResponse)}}).sort((o,a)=>String(a.lastAt||"").localeCompare(String(o.lastAt||"")))}var Iv=B(()=>{});var Cv,$S,Av,xv=B(()=>{Iv();cl();Cv=1,$S=5,Av={name:"YeaftDebugPanel",emits:["close"],data(){return{expandedTurns:{},expandedLoops:{},expandedSections:{},expandedToolDetails:{},copiedFlash:null,copiedFlashAt:0,_expandSnapshot:null,dreamExpanded:!1,expandedDreamEvents:{},expandedDreamSegments:{},activeDreamItemKey:null,dreamItemSearch:"",activeTab:"requests"}},watch:{turns(e,t){let s=e&&e[0];!s||!s.turnId||(t&&t[0]&&t[0].turnId)===s.turnId&&this.expandedTurns[s.turnId]||(this.expandedTurns={...this.expandedTurns,[s.turnId]:!0},this.ensureRequestDetailLoaded(s.turnId))},searchQuery(e,t){let s=!!(t&&t.trim()),n=!!(e&&e.trim());if(!s&&n){this._expandSnapshot={turns:{...this.expandedTurns},loops:{...this.expandedLoops}};let r={},i={};for(let o of this.turns)r[o.turnId]=!0,o.loops&&o.loops.length>0&&(i[`${o.turnId}#${o.loops[0].loopNumber}`]=!0);this.expandedTurns=r,this.expandedLoops=i}else if(s&&!n&&this._expandSnapshot)this.expandedTurns=this._expandSnapshot.turns,this.expandedLoops=this._expandSnapshot.loops,this._expandSnapshot=null;else if(n){let r={...this.expandedTurns};for(let i of this.turns)r[i.turnId]===void 0&&(r[i.turnId]=!0);this.expandedTurns=r}}},computed:{store(){return window.Pinia?.useChatStore?.()||null},sessionsStore(){return window.Pinia?.useSessionsStore?.()||null},turns(){let e=this.store&&this.store.yeaftDebugPanel||{},t=e.turnId?this.store&&this.store.yeaftDebugTurnsById&&this.store.yeaftDebugTurnsById[e.turnId]:null;if(!t)return[];let s=this.debugLoopsForTurn(t.turnId),n=s.length>0?s:Array.isArray(t.loops)?t.loops:[],r={...t,loops:n};return[{...this.decorateTurnTokenBreakdowns(r),latestRequest:this.latestRequestForTurn(r)}]},currentTurnId(){return this.store&&this.store.yeaftDebugPanel&&this.store.yeaftDebugPanel.turnId||""},currentTurnSessionId(){return this.store&&this.store.yeaftDebugPanel&&this.store.yeaftDebugPanel.sessionId||""},panelStatus(){return this.store&&this.store.yeaftDebugPanel&&this.store.yeaftDebugPanel.status||"idle"},panelLoading(){return this.panelStatus==="loading"},searchQuery:{get(){return this.store&&this.store.yeaftDebugSearch||""},set(e){this.store&&this.store.setYeaftDebugSearch(e)}},sessionFilter:{get(){if(!this.store)return"";let e=this.store.yeaftDebugSessionFilter;return e??""},set(e){this.store&&(e?this.store.setYeaftDebugSessionFilter(e):this.store.setYeaftDebugSessionFilter(null))}},availableSessions(){return this.store&&this.store.yeaftDebugAvailableSessions||[]},turnTotal(){return this.store&&this.store.yeaftDebugTurnTotal||0},showingMatchedHint(){return this.turnTotal>this.turns.length},requestHistoryLoading(){return!!this.store?.yeaftDebugHistoryLoading},requestHistoryError(){let e=this.store?.yeaftDebugHistoryError||"";return e==="debug_history_timeout"?this.$t("yeaft.debugHistoryUnavailable"):e},requestHistoryProjectionNotice(){return this.store?.yeaftDebugHistoryProjection?.truncated===!0?this.$t("yeaft.debugHistoryTruncated"):""},toolStats(){return this.store?.yeaftToolStats||null},toolStatsLoading(){return!!this.store?.yeaftToolStatsLoading},rankedToolRows(){let e=this.toolStats?.snapshot||{},t=Object.entries(e).map(([r,i])=>({name:r,...i})),s=new Set(t.map(r=>r.name)),n=Array.isArray(this.toolStats?.registered)?this.toolStats.registered:[];for(let r of n)typeof r!="string"||!r||s.has(r)||(t.push({name:r,callCount:0,errorCount:0,errorRate:0,avgMs:0,p50Ms:0,p95Ms:0,lastCalledAt:null,lastError:null}),s.add(r));return t.sort((r,i)=>{let o=(i.callCount||0)-(r.callCount||0);return o!==0?o:r.name.localeCompare(i.name)}),t},unusedToolRows(){return Array.isArray(this.toolStats?.unused)?this.toolStats.unused:[]},toolStatsFetchedAtLabel(){let e=this.toolStats?.fetchedAt;if(!e)return"";try{return new Date(e).toLocaleTimeString()}catch{return""}},dreamLatest(){return this.store&&this.store.yeaftDreamLatestForActiveSession||null},dreamLatestLabel(){let e=this.dreamLatest;if(!e)return"";if(e.status==="running")return`running \xB7 ${e.phase||"..."}`;if(e.status==="error")return`error \xB7 ${e.error||"unknown"}`;if(e.status==="skipped")return"skipped";let t=["done"];typeof e.mergedCount=="number"&&t.push(`merged ${e.mergedCount}`);let s=this.formatDreamMetrics(e);return s&&t.push(s),t.join(" \xB7 ")},dreamLatestKindLabel(){let e=this.dreamLatest;return e?e.manual?"manual":"auto":""},dreamSnapshot(){return this.store&&this.store.yeaftDreamSnapshotForActiveSession||null},dreamPromptLoad(){return this.store&&this.store.yeaftDreamPromptLoadForActiveSession||null},dreamPromptLoadSummary(){let e=this.dreamPromptLoad,t=e&&typeof e.summary=="string"?e.summary.trim():"";return t&&e.truncated?`${t}
8386
8389
  ... truncated`:t},dreamSnapshotSummary(){let e=this.dreamSnapshot,t=e&&typeof e.summaryText=="string"?e.summaryText.trim():"";return t&&e.summaryTruncated?`${t}
8387
8390
  ... truncated`:t},dreamSnapshotMemory(){let e=this.dreamSnapshot,t=e&&typeof e.memoryText=="string"?e.memoryText.trim():"";return t&&e.memoryTruncated?`${t}
8388
8391
  ... truncated`:t},dreamEvents(){let e=this.store&&this.store.yeaftDreamEventsForActiveSession||[];return Array.isArray(e)?e:[]},dreamEventCount(){return this.dreamEvents.length},dreamSessionTitles(){let e={},t=(r,i)=>{let o=String(i||"").trim();r&&o&&(e[r]=o)},s=this.sessionsStore?.sessions||{};for(let r of Object.values(s))!r||!r.id||(t(r.id,r.name||r.title),t(`sessions/${r.id}`,r.name||r.title));let n=this.store?.yeaftActiveSessionFilter;return n&&t(n,this.store?.yeaftActiveSessionName||this.store?.currentSessionTitle),e},allDreamItems(){let e=this.store||{},t=e.yeaftDreamEvents||{},s=Object.values(t).flatMap(n=>Array.isArray(n)?n:[]);return Sv({latest:e.yeaftDreamLatest||{},snapshots:e.yeaftDreamSnapshots||{},promptLoads:e.yeaftDreamPromptLoads||{},events:s,sessionTitles:this.dreamSessionTitles})},dreamItems(){return kv(this.allDreamItems,this.dreamItemSearch)},activeDreamItem(){return this.activeDreamItemKey&&this.dreamItems.find(e=>e.key===this.activeDreamItemKey)||null},activeDreamRequestEvents(){let e=this.activeDreamItem;return e?e.events.filter(t=>t&&(t.request||t.response||t.rawRequest||t.rawResponse||t.systemPrompt||this.dreamLoopUserContent(t))):[]}},methods:{debugSessionId(e){return this.formatDebugSessionId(e&&(e.sessionId||e.groupId)||"")},debugDreamSessionId(e){return this.formatDebugSessionId(e&&(e.sessionId||e.groupId)||"")},formatDebugSessionId(e){let t=String(e||"");return t.startsWith("grp_")?t.slice(4):t},toggleTurn(e){let t=!this.expandedTurns[e];this.expandedTurns={...this.expandedTurns,[e]:t},t&&this.ensureRequestDetailLoaded(e)},debugLoopsForTurn(e){return(Array.isArray(this.store?.yeaftDebugLoops)?this.store.yeaftDebugLoops:[]).filter(s=>s&&s.turnId===e)},debugTurnNeedsDetailLoad(e){if(!e||!e.turnId)return!1;if(!e.detailsLoaded)return!0;let t=this.debugLoopsForTurn(e.turnId),s=Math.max(0,Number(e.loopCount||0)),n=new Set;for(let i of t){let o=Number(i?.loopNumber||0);Number.isFinite(o)&&o>0&&n.add(o)}if((n.size>0?Math.max(...n):0)>n.size||s>t.length)return!0;for(let i=1;i<=s;i++)if(!n.has(i))return!0;return!1},ensureRequestDetailLoaded(e){let t=this.store?.yeaftDebugTurnsById?.[e];!t||!this.store||typeof this.store.loadYeaftDebugHistory!="function"||this.debugTurnNeedsDetailLoad(t)&&this.store.loadYeaftDebugHistory({limit:Cv,dreamLimit:0,detailTurnId:e,groupId:t.sessionId||null})},toggleDream(){this.dreamExpanded=!this.dreamExpanded},dreamEventDetail(e){if(!e)return"";let t=e.phase||"unknown",s=[],n=!0;if(t==="start")s.push(e.manual?"manual trigger":"auto trigger");else if(t==="load-diff")this.debugDreamSessionId(e)&&s.push(`session ${this.debugDreamSessionId(e)}`);else if(t==="triage")typeof e.segments=="number"&&s.push(`${e.segments} segs`),typeof e.actions=="number"&&s.push(`${e.actions} actions`),e.status&&s.push(e.status);else if(t==="merge")typeof e.targets=="number"&&s.push(`${e.targets} targets`);else if(t==="apply")e.target&&s.push(e.target),e.status&&s.push(e.status),typeof e.mergedCount=="number"&&s.push(`merged ${e.mergedCount}`);else if(t==="done"){let r=typeof e.sessions=="number"?e.sessions:e.groups;typeof r=="number"&&s.push(`${r} sessions`),typeof e.targets=="number"&&s.push(`${e.targets} targets`),typeof e.duration=="number"&&s.push(this.formatMs(e.duration))}else t==="result"?(s.push(e.success?"success":"error"),typeof e.entriesCreated=="number"&&s.push(`entries ${e.entriesCreated}`),this.formatDreamMetrics(e)&&s.push(this.formatDreamMetrics(e)),!e.success&&e.error&&s.push(e.error),e.skipped&&s.push(`skipped: ${e.skippedReason||"unknown"}`)):n=!1;if(!n||s.length===0){let r=new Set(["type","phase","sessionId","groupId","target","ts","at"]);for(let[i,o]of Object.entries(e))r.has(i)||o!=null&&typeof o!="object"&&s.push(`${i}=${o}`)}return e.error&&!s.includes(e.error)&&s.unshift(`error: ${e.error}`),s.join(" \xB7 ")},dreamEventStatus(e){return e?e.status==="skipped"||e.skipped?"skipped":e.status==="error"||e.phase==="error"?"error":e.status==="done"||e.status==="success"||e.phase==="done"?"success":e.phase==="result"?e.success?"success":"error":"running":"running"},dreamEventTrigger(e){return e?e.trigger?e.trigger:e.source?e.source:e.manual===!0?"manual":e.manual===!1?"auto":"-":"-"},dreamEventCall(e){if(!e)return"-";let t=e.phase||"unknown",s=e.status||"";return t==="start"?"scheduler -> runDream":t==="load-diff"?"runDream -> loadSessionDiff":t==="triage"?s?`triageSessionSegments \xB7 ${s}`:"triageSessionSegments":t==="merge"?"mergeByTarget":t==="apply"?s?`applyMergedTarget \xB7 ${s}`:"applyMergedTarget":t==="done"?"runDream completed":t==="result"?"web-bridge -> yeaft_dream_result":t},dreamEventLocation(e){return e?e.target?e.target:e.scope?e.scope:this.debugDreamSessionId(e)?`session/${this.debugDreamSessionId(e)}`:e.vpId?`vp/${e.vpId}`:"-":"-"},dreamEventResult(e){if(!e)return"-";let t=[];return e.skipped&&t.push(`skipped: ${e.skippedReason||"unknown"}`),e.reason&&t.push(`reason: ${e.reason}`),typeof e.entriesCreated=="number"&&t.push(`entries ${e.entriesCreated}`),typeof e.targetsApplied=="number"&&t.push(`applied ${e.targetsApplied}`),typeof e.sessionsProcessed=="number"&&t.push(`sessions ${e.sessionsProcessed}`),typeof e.sessionsSkipped=="number"&&t.push(`skipped sessions ${e.sessionsSkipped}`),typeof e.segments=="number"&&t.push(`segments ${e.segments}`),typeof e.actions=="number"&&t.push(`actions ${e.actions}`),typeof e.targets=="number"&&t.push(`targets ${e.targets}`),typeof e.duration=="number"&&t.push(this.formatMs(e.duration)),this.formatDreamMetrics(e)&&t.push(this.formatDreamMetrics(e)),Array.isArray(e.targetErrors)&&e.targetErrors.length>0&&t.push(`errors ${e.targetErrors.length}: ${this.truncate(e.targetErrors.map(s=>s.target?`${s.target}: ${s.error}`:s.error).join("; "),160)}`),e.error&&t.push(`error: ${e.error}`),t.length>0?t.join(" \xB7 "):this.dreamEventDetail(e)},dreamEventKind(e){if(!e)return"progress";let t=e.type;return t==="loop"?"loop":t==="turn_close"||t==="dream_turn_close"?"turn_close":t==="dream_run"&&e.phase==="result"?"result":"progress"},isDreamEventExpandable(e){let t=this.dreamEventKind(e);return t==="loop"?!!(e&&(e.systemPrompt||e.response||Array.isArray(e.messages)&&e.messages.length>0)):t==="turn_close"||t==="result"?!!(e&&(e.metrics||e.passBreakdown||e.resultSummary)):t==="progress"?!!(e&&(e.memoryMdPreview||e.summaryMdPreview)):!1},dreamEventKey(e){return e?`${e.at||0}:${e.turnId||""}:${e.phase||e.type||""}`:""},toggleDreamEvent(e){let t=this.dreamEventKey(e);if(!t)return;let s=new Set(this.dreamEvents.map(r=>this.dreamEventKey(r))),n={};for(let[r,i]of Object.entries(this.expandedDreamEvents))s.has(r)&&(n[r]=i);n[t]=!n[t],this.expandedDreamEvents=n},isDreamEventExpanded(e){return!!this.expandedDreamEvents[this.dreamEventKey(e)]},dreamLoopUserContent(e){let t=Array.isArray(e?.messages)?e.messages:[];for(let s of t)if(s&&s.role==="user"){if(typeof s.content=="string")return s.content;if(s.content!=null)return JSON.stringify(s.content,null,2)}return""},formatPassBreakdown(e){if(!e||typeof e!="object")return"";let t=[];for(let[s,n]of Object.entries(e)){if(!n)continue;let r=[s+":"];n.llmCallCount&&r.push(`${n.llmCallCount} call`),n.totalTokens&&r.push(`${this.formatTokens(n.totalTokens)} tok`),n.durationMs&&r.push(this.formatMs(n.durationMs)),t.push(r.join(" "))}return t.join(" \xB7 ")},copyDreamEventAsMarkdown(e){if(!e)return;let t=this.dreamEventKind(e),s=[`# Dream event \xB7 ${t} \xB7 ${e.phase||e.type||"?"}`];if(s.push(`- at: ${this.formatTimestamp(e.at)}`),e.turnId&&s.push(`- turnId: ${e.turnId}`),this.debugDreamSessionId(e)&&s.push(`- sessionId: ${this.debugDreamSessionId(e)}`),e.target&&s.push(`- target: ${e.target}`),t==="loop"){s.push(`- pass: ${e.pass||"-"}`),s.push(`- model: ${e.model||"-"}`),s.push(`- latency: ${this.formatMs(e.latencyMs)}`);let n=e.usage||{};s.push(`- tokens: ${this.formatUsageBreakdown(n)}`),s.push("","## System prompt","```",e.systemPrompt||"","```"),s.push("","## User message","```",this.dreamLoopUserContent(e),"```"),s.push("","## Response","```",e.response||"","```")}else if(t==="turn_close"){s.push(`- loopCount: ${e.loopCount??e.metrics?.llmCallCount??0}`),s.push(`- totalTokens: ${e.totalTokens??e.metrics?.totalTokens??0}`),s.push(`- totalMs: ${e.totalMs??e.metrics?.durationMs??0}`);let n=e.passBreakdown||e.metrics?.passBreakdown;n&&s.push("","## Pass breakdown","```json",JSON.stringify(n,null,2),"```")}else t==="result"?(s.push(`- status: ${e.status||"-"}`),e.error&&s.push(`- error: ${e.error}`),e.resultSummary&&s.push("","## Result summary","```json",JSON.stringify(e.resultSummary,null,2),"```"),e.metrics&&s.push("","## Metrics","```json",JSON.stringify(e.metrics,null,2),"```")):(e.memoryMdPreview&&s.push("","## memory.md (preview)","```",e.memoryMdPreview,"```"),e.summaryMdPreview&&s.push("","## summary.md (preview)","```",e.summaryMdPreview,"```"),!e.memoryMdPreview&&!e.summaryMdPreview&&s.push("","## Raw","```json",JSON.stringify(e,null,2),"```"));this.copyText(s.join(`
@@ -9082,9 +9085,9 @@ ${String(e||"").trim()}
9082
9085
  </div>
9083
9086
  </section>
9084
9087
  </aside>
9085
- `,setup(e,{emit:t}){let s=window.Pinia&&window.Pinia.useVpStore?window.Pinia.useVpStore():null,n=q=>s&&typeof s.vpTextColor=="function"?s.vpTextColor(q):"var(--text-primary)",r=Vue.getCurrentInstance(),i=r&&r.appContext.config.globalProperties.$t||(q=>q),o=Vue.computed(()=>(typeof e.announcementText=="string"?e.announcementText:"").trim()),a=Vue.computed(()=>!!o.value),l=Vue.computed(()=>{let q=o.value.replace(/\s+/g," ");return q.length<=96?q:q.slice(0,95)+"\u2026"}),c=Vue.ref({}),d=new Map,u=new Map,g=q=>{let I=d.get(q);I&&(I.scrollTop=I.scrollHeight,u.set(q,!0))},p=q=>{let I=!c.value[q];c.value={...c.value,[q]:I},I&&(u.set(q,!0),Vue.nextTick(()=>g(q)))},f=(q,I)=>{I?(d.set(q,I),u.has(q)||u.set(q,!0),Vue.nextTick(()=>{u.get(q)&&g(q)})):d.delete(q)},m=q=>{let I=d.get(q);if(!I)return;let T=I.scrollHeight-I.scrollTop-I.clientHeight;u.set(q,T<8)};Vue.watch(()=>JSON.stringify((Array.isArray(e.tasks)?e.tasks:[]).map(q=>[q.id,q?.log?.preview||""])),()=>Vue.nextTick(()=>{d.forEach((q,I)=>{u.get(I)&&g(I)})}));let v=q=>{let I=q?.ownerVpId||"";return I?s&&typeof s.vpLabel=="function"?s.vpLabel(I):I:"unknown"},y=q=>{if(!q)return"";try{return new Date(q).toLocaleTimeString()}catch{return String(q)}},h=q=>{switch(q?.kind){case"sub_agent":return i("yeaft.sessionStatus.task.kind.subAgent");case"shell":return i("yeaft.sessionStatus.task.kind.shell");default:return q?.kind||""}},k=q=>{let I=q?.runtime?.command;return typeof I=="string"?I.trim():""},S=q=>{let I=[],T=q?.title||q?.id||"",R=k(q);return T&&I.push(`${i("yeaft.sessionStatus.task.title")}: ${T}`),R&&I.push(`${i("yeaft.sessionStatus.task.command")}: ${R}`),I.join(`
9086
- `)},b=q=>`${q?.agentId||""}${q?.sessionId||""}::${q?.id||""}`,w=q=>q?.status==="running"&&(q.kind==="shell"&&!!q.runtime?.pid||q.kind==="sub_agent"&&!!q.runtime?.subAgentId),P=q=>!!(q?.id&&e.stoppingTasksById?.[b(q)]),x=q=>qS(q,i),Y=q=>Pv(q,i),L=q=>{switch(q.status){case"idle":return i("yeaft.vpTimeline.status.idle");case"typing":return i("yeaft.vpTimeline.status.typing");case"thinking":return i("yeaft.vpTimeline.status.thinking");case"retrying":return i("yeaft.vpTimeline.status.retrying");case"streaming":return i("yeaft.vpTimeline.status.streaming");case"tool":return i("yeaft.vpTimeline.status.tool");case"error":return i("yeaft.vpTimeline.status.error");case"offline":return i("yeaft.vpTimeline.status.offline");default:return q.status}},U=new Set(["typing","thinking","retrying","streaming","tool"]);return{hasAnnouncement:a,announcementPreview:l,statusLabel:L,isActiveStatus:q=>U.has(q),threadCountTitle:q=>{let I=Array.isArray(q&&q.threads)?q.threads:[];return I.length?I.slice(0,5).map(T=>`${T.title||T.threadId||"thread"}: ${T.status||"idle"}`).join(`
9087
- `):""},vpTextColorFor:n,expandedTasks:c,toggleTaskExpanded:p,taskOwnerName:v,formatTaskTime:y,taskKindLabel:h,shellTaskCommand:k,taskSummaryTitle:S,isTaskCancellable:w,isTaskStopping:P,taskDetailLines:x,subAgentTaskStreamText:Y,setTaskLogRef:f,onTaskLogScroll:m}}}});var Ev,Dv=B(()=>{Ev={name:"YeaftSessionActions",emits:["toggle-search","reload-messages","toggle-session-status","toggle-workbench","reload-page","fork-session"],props:{showFork:{type:Boolean,default:!1},forkDisabled:{type:Boolean,default:!1},forkState:{type:String,default:"idle"},forkTitle:{type:String,default:""},searchOpen:{type:Boolean,default:!1},loadingMoreHistory:{type:Boolean,default:!1},sessionStatusVisible:{type:Boolean,default:!0},workbenchVisible:{type:Boolean,default:!1},canUseWorkbench:{type:Boolean,default:!1},showPageReload:{type:Boolean,default:!1}},template:`
9088
+ `,setup(e,{emit:t}){let s=window.Pinia&&window.Pinia.useVpStore?window.Pinia.useVpStore():null,n=q=>s&&typeof s.vpTextColor=="function"?s.vpTextColor(q):"var(--text-primary)",r=Vue.getCurrentInstance(),i=r&&r.appContext.config.globalProperties.$t||(q=>q),o=Vue.computed(()=>(typeof e.announcementText=="string"?e.announcementText:"").trim()),a=Vue.computed(()=>!!o.value),l=Vue.computed(()=>{let q=o.value.replace(/\s+/g," ");return q.length<=96?q:q.slice(0,95)+"\u2026"}),c=Vue.ref({}),d=new Map,u=new Map,g=q=>{let I=d.get(q);I&&(I.scrollTop=I.scrollHeight,u.set(q,!0))},p=q=>{let I=!c.value[q];c.value={...c.value,[q]:I},I&&(u.set(q,!0),Vue.nextTick(()=>g(q)))},f=(q,I)=>{I?(d.set(q,I),u.has(q)||u.set(q,!0),Vue.nextTick(()=>{u.get(q)&&g(q)})):d.delete(q)},m=q=>{let I=d.get(q);if(!I)return;let T=I.scrollHeight-I.scrollTop-I.clientHeight;u.set(q,T<8)};Vue.watch(()=>JSON.stringify((Array.isArray(e.tasks)?e.tasks:[]).map(q=>[q.id,q?.log?.preview||""])),()=>Vue.nextTick(()=>{d.forEach((q,I)=>{u.get(I)&&g(I)})}));let v=q=>{let I=q?.ownerVpId||"";return I?s&&typeof s.vpLabel=="function"?s.vpLabel(I):I:"unknown"},b=q=>{if(!q)return"";try{return new Date(q).toLocaleTimeString()}catch{return String(q)}},h=q=>{switch(q?.kind){case"sub_agent":return i("yeaft.sessionStatus.task.kind.subAgent");case"shell":return i("yeaft.sessionStatus.task.kind.shell");default:return q?.kind||""}},k=q=>{let I=q?.runtime?.command;return typeof I=="string"?I.trim():""},S=q=>{let I=[],T=q?.title||q?.id||"",R=k(q);return T&&I.push(`${i("yeaft.sessionStatus.task.title")}: ${T}`),R&&I.push(`${i("yeaft.sessionStatus.task.command")}: ${R}`),I.join(`
9089
+ `)},y=q=>`${q?.agentId||""}${q?.sessionId||""}::${q?.id||""}`,w=q=>q?.status==="running"&&(q.kind==="shell"&&!!q.runtime?.pid||q.kind==="sub_agent"&&!!q.runtime?.subAgentId),P=q=>!!(q?.id&&e.stoppingTasksById?.[y(q)]),x=q=>qS(q,i),Y=q=>Pv(q,i),L=q=>{switch(q.status){case"idle":return i("yeaft.vpTimeline.status.idle");case"typing":return i("yeaft.vpTimeline.status.typing");case"thinking":return i("yeaft.vpTimeline.status.thinking");case"retrying":return i("yeaft.vpTimeline.status.retrying");case"streaming":return i("yeaft.vpTimeline.status.streaming");case"tool":return i("yeaft.vpTimeline.status.tool");case"error":return i("yeaft.vpTimeline.status.error");case"offline":return i("yeaft.vpTimeline.status.offline");default:return q.status}},U=new Set(["typing","thinking","retrying","streaming","tool"]);return{hasAnnouncement:a,announcementPreview:l,statusLabel:L,isActiveStatus:q=>U.has(q),threadCountTitle:q=>{let I=Array.isArray(q&&q.threads)?q.threads:[];return I.length?I.slice(0,5).map(T=>`${T.title||T.threadId||"thread"}: ${T.status||"idle"}`).join(`
9090
+ `):""},vpTextColorFor:n,expandedTasks:c,toggleTaskExpanded:p,taskOwnerName:v,formatTaskTime:b,taskKindLabel:h,shellTaskCommand:k,taskSummaryTitle:S,isTaskCancellable:w,isTaskStopping:P,taskDetailLines:x,subAgentTaskStreamText:Y,setTaskLogRef:f,onTaskLogScroll:m}}}});var Ev,Dv=B(()=>{Ev={name:"YeaftSessionActions",emits:["toggle-search","reload-messages","toggle-session-status","toggle-workbench","reload-page","fork-session"],props:{showFork:{type:Boolean,default:!1},forkDisabled:{type:Boolean,default:!1},forkState:{type:String,default:"idle"},forkTitle:{type:String,default:""},searchOpen:{type:Boolean,default:!1},loadingMoreHistory:{type:Boolean,default:!1},sessionStatusVisible:{type:Boolean,default:!0},workbenchVisible:{type:Boolean,default:!1},canUseWorkbench:{type:Boolean,default:!1},showPageReload:{type:Boolean,default:!1}},template:`
9088
9091
  <div class="yeaft-session-actions">
9089
9092
  <button
9090
9093
  v-if="showFork"
@@ -9614,7 +9617,7 @@ ${String(e||"").trim()}
9614
9617
  @open-vp-library="openVpLibraryFromGroupSettings"
9615
9618
  />
9616
9619
  </div>
9617
- `,setup(){let e=Pinia.useChatStore(),t=Pinia.useAuthStore(),s=Pinia.useVpStore(),n=Vue.getCurrentInstance(),r=n&&n.appContext.config.globalProperties.$t||(A=>A),i=Vue.computed(()=>!!(e.yeaftDebugPanel&&e.yeaftDebugPanel.open)),o=Vue.ref(null),a=Vue.ref(!1),l=Vue.ref(!1),c=Vue.ref(null),d=Vue.ref("operations"),u=Vue.ref(!1),g=Vue.ref(""),p=Vue.ref(!1),f=Vue.ref(""),m=Vue.ref("vp"),v=Vue.ref(null),y=Vue.ref(null),h=Vue.ref(null),k=Vue.ref(null),S=Vue.ref(null),b=Vue.ref(null),w=Vue.ref(!1),P=Vue.ref(null),x=Vue.computed(()=>e.getYeaftHistoryOutlineState()),Y=Vue.ref(e.yeaftHistorySearchState?.query||""),L=null,U=()=>{try{return window.Pinia?.useSessionsStore?.()||null}catch{return null}},E=()=>{let A=U();return{agentId:e.currentAgent||null,sessionId:e.yeaftActiveSessionFilter||A?.activeSessionId||null}},oe=()=>zv,q=(A="")=>{let{agentId:pe,sessionId:Te}=E();e.yeaftHistorySearchState={requestId:null,agentId:pe,sessionId:Te,query:"",senderKey:A,loading:!1,results:[],hasMore:!1,nextBeforeSeq:null,error:null}},I=Vue.computed(()=>{let A=e.currentAgent||"agent",pe=U(),Te=e.yeaftActiveSessionFilter||pe?.activeSessionId||"session";return`yeaft:${A}:${Te}`});Vue.watch(I,()=>{h.value=null});let T=null,R=null,M=A=>{if(!A)return!1;let pe=String(A.tagName||"").toLowerCase();return pe==="textarea"||pe==="input"||A.isContentEditable===!0},$=({recoverScroll:A=!1}={})=>{let pe=k.value;if(!pe)return;if(!he.value){pe.style.removeProperty("--yeaft-visual-viewport-height");return}let Te=window.visualViewport,tt=Math.max(1,Math.round(Te?.height||window.innerHeight||1));pe.style.setProperty("--yeaft-visual-viewport-height",`${tt}px`),!(!A||Te&&window.innerHeight&&Te.height<window.innerHeight*.85||M(document.activeElement))&&window.scrollTo(0,0)},j=(A={})=>{T!=null&&cancelAnimationFrame(T),T=requestAnimationFrame(()=>{T=null,$(A)})},z=()=>{j({recoverScroll:!0}),R&&clearTimeout(R),R=setTimeout(()=>{R=null,j({recoverScroll:!0})},260)},Q=Vue.computed(()=>e.hasCapability("terminal")||e.hasCapability("file_editor")||e.hasCapability("browser_runtime")&&e.hasCapability("browser_webrtc")&&(e.hasCapability("browser_capture_tab")||e.hasCapability("browser_capture_cdp"))),ae=Vue.computed(()=>!0),ke=A=>{let pe=A&&A.id?A.id:null;pe&&(he.value&&J(),e.setActiveSessionFilter(pe,{agentId:A.agentId||null}),he.value&&e.closeSessionSidebar())},N=A=>{},G=Vue.ref(null),de=Vue.ref(!1),we=320,se=Math.max(we,Math.round(window.innerWidth*.25)),ve=localStorage.getItem("yeaft-debug-width"),Ie=Vue.ref(ve?parseInt(ve,10):se),ue=Vue.computed(()=>({"--yeaft-detail-width":Ie.value+"px"})),re=A=>{de.value=!0;let pe=A.clientX,Te=Ie.value,tt=window.innerWidth*.6,je=qs=>{let un=pe-qs.clientX,ys=Math.min(tt,Math.max(we,Te+un));Ie.value=ys},wt=()=>{de.value=!1,document.removeEventListener("mousemove",je),document.removeEventListener("mouseup",wt),localStorage.setItem("yeaft-debug-width",String(Ie.value))};document.addEventListener("mousemove",je),document.addEventListener("mouseup",wt)},te="yeaft-session-status-visible",V="(max-width: 768px)",ce="(max-width: 1024px)",X=()=>{if(typeof window>"u")return!1;try{return typeof window.matchMedia=="function"?window.matchMedia(V).matches:Number(window.innerWidth)<=768}catch{return!1}},F=()=>{if(X())return!1;try{let A=localStorage.getItem(te);return!(A==="0"||A==="false")}catch{return!0}},Z=Vue.ref(F()),fe=A=>{if(Z.value=!!A,!X())try{localStorage.setItem(te,Z.value?"1":"0")}catch{}},Re=()=>{let A=!Z.value;A&&(e.workbenchExpanded&&e.toggleWorkbench(),e.closeYeaftDebugPanel()),fe(A)},J=()=>fe(!1),D=()=>{e.workbenchExpanded||J(),e.toggleWorkbench()};Vue.watch(i,A=>{A&&J()},{flush:"sync"}),Vue.watch(()=>e.workbenchExpanded,A=>{A&&J()},{flush:"sync"});let ye=220,Me=280,ze=(()=>{try{return localStorage.getItem("yeaft-vp-timeline-width")}catch{return null}})(),Ye=ze?parseInt(ze,10):NaN,rt=Vue.ref(Number.isFinite(Ye)&&Ye>=ye?Ye:Me),ut=Vue.computed(()=>({"--yeaft-vp-timeline-width":rt.value+"px"})),at=A=>{let pe=A.clientX,Te=rt.value,tt=Math.max(ye,Math.floor(window.innerWidth*.4)),je=qs=>{let un=pe-qs.clientX,ys=Math.min(tt,Math.max(ye,Te+un));rt.value=ys},wt=()=>{document.removeEventListener("mousemove",je),document.removeEventListener("mouseup",wt);try{localStorage.setItem("yeaft-vp-timeline-width",String(rt.value))}catch{}};document.addEventListener("mousemove",je),document.addEventListener("mouseup",wt)},W=typeof window.matchMedia=="function"?window.matchMedia(V):null,ie=typeof window.matchMedia=="function"?window.matchMedia(ce):null,me=(A,pe)=>A?A.matches:window.innerWidth<=pe,he=Vue.ref(me(W,768)),Ee=Vue.ref(me(ie,1024)),Ue=Vue.computed(()=>he.value?!e.sessionSidebarOpen:e.sidebarCollapsed),Mt=()=>{let A=he.value;he.value=me(W,768),Ee.value=me(ie,1024),he.value&&!A&&J()},Qe=()=>{Mt(),z()},mt=A=>{A&&(typeof A.addEventListener=="function"?A.addEventListener("change",Qe):typeof A.addListener=="function"&&A.addListener(Qe))},Et=A=>{A&&(typeof A.removeEventListener=="function"?A.removeEventListener("change",Qe):typeof A.removeListener=="function"&&A.removeListener(Qe))},et=()=>{L&&(clearTimeout(L),L=null),Y.value="",q(oe()),w.value=!1,P.value=null},lt=()=>{let A=oe();Y.value="",q(A),w.value=!0,e.searchYeaftHistory("",{senderKey:A}),Vue.nextTick(()=>b.value?.focus?.())},_=()=>{w.value?et():lt()},ee=A=>{let pe=typeof A.composedPath=="function"?A.composedPath():[];w.value&&Zf(A.target,pe)&&et()},Se=A=>{Y.value=A,L&&clearTimeout(L),P.value=null,L=setTimeout(()=>{L=null,e.searchYeaftHistory(Y.value,{senderKey:e.yeaftHistorySearchState.senderKey})},220)},_e=A=>{if(!e.searchYeaftHistory("",{append:!0,senderKey:zv}))return;let pe=Vue.watch(()=>x.value.loading,Te=>{Te||(pe(),b.value?.restoreOlderScroll?.(A))})},Fe=()=>e.searchYeaftHistory(e.yeaftHistorySearchState.query,{append:!0,senderKey:e.yeaftHistorySearchState.senderKey}),Xe=A=>{e.hasCapability("session_history_window_prefetch")&&e.loadYeaftHistoryWindow(A)},pt=A=>{let pe=e.beginYeaftHistoryReveal?.(A)||null;return Jf({result:A,revealWindow:Te=>e.revealYeaftHistoryResult(Te,pe),nextTick:()=>Vue.nextTick(),revealMessage:Te=>S.value?.revealMessage?.(Te),isMobile:he.value,closeOutline:et}).finally(()=>e.finishYeaftHistoryReveal?.(pe))},gt=A=>{if((A.metaKey||A.ctrlKey)&&String(A.key).toLowerCase()==="f"){A.preventDefault(),lt();return}if(A.key==="Escape"){if(w.value){et();return}if(o.value){es();return}}};Vue.onMounted(()=>{Mt(),window.addEventListener("resize",Qe),mt(W),mt(ie),window.visualViewport?.addEventListener("resize",z),window.visualViewport?.addEventListener("scroll",z),document.addEventListener("click",an),document.addEventListener("click",ee),document.addEventListener("keydown",gt),j()}),Vue.onUnmounted(()=>{window.removeEventListener("resize",Qe),Et(W),Et(ie),window.visualViewport?.removeEventListener("resize",z),window.visualViewport?.removeEventListener("scroll",z),document.removeEventListener("click",an),document.removeEventListener("click",ee),document.removeEventListener("keydown",gt),T!=null&&cancelAnimationFrame(T),R&&clearTimeout(R),L&&clearTimeout(L)}),Vue.watch(()=>e.yeaftConversationId,A=>{A&&e.activeConversations[0]!==A&&(e.activeConversations=[A])}),Vue.watch(()=>[e.currentAgent,e.yeaftActiveSessionFilter],()=>{he.value&&J(),et(),q(oe())});let Dt=()=>{e.leaveYeaft()},$t=(A,pe,Te,tt=null)=>{if(ne.value)return!1;let je=U();if(je&&je.activeNeedsInvite){let ys=je.activeSession;return ys&&Os.delete(ys.id),!1}let wt=e.yeaftActiveSessionFilter||je&&je.activeSessionId||"grp_default",qs=Uo(A).mentions,un=Array.isArray(pe)?pe:void 0;return e.sendYeaftSessionMessage({groupId:wt,text:A,mentions:qs,attachments:un,quote:Te,...tt?{quickSend:tt}:{}})},Lt=A=>{A&&(h.value=A,y.value?.focusInput?.())},tn=A=>{h.value=null,y.value?.replaceDraft?.(A||"")},Dn=()=>{let A=U(),pe=e.yeaftActiveSessionFilter||A?.activeSessionId||null;pe&&e.cancelYeaftSession(pe)},Sr=()=>{if(he.value){e.toggleSessionSidebar();return}e.toggleSidebar()},Jt=()=>{e.closeYeaftDebugPanel()},sn=()=>{e.reloadYeaftMessages()},nn=()=>{if(typeof e.requestYeaftSessionInventory=="function"){e.requestYeaftSessionInventory();return}e._hasHandledAgentList=!1,e._hasHandledYeaftSessionHydrate=!1,e.yeaftSessionHydrateError=null,e.sendWsMessage({type:"get_agents"})},$n=()=>{window.location.reload()},rn=Vue.computed(()=>{let A=U(),pe=e.yeaftActiveSessionFilter||A?.activeSessionId||null;return pe?e.isYeaftSessionProcessing(pe,e.currentAgent||null):!1}),Ze=Vue.computed(()=>{let A=U();if(!A||!A.sessions)return null;let pe=e.yeaftActiveSessionFilter||null;if(pe&&typeof A.sessionById=="function"){let Te=A.sessionById(pe,e.currentAgent||null);if(Te)return Te}if(A.activeSessionId&&typeof A.sessionById=="function"){let Te=A.sessionById(A.activeSessionId,e.currentAgent||null);if(Te)return Te}return typeof A.sessionById=="function"?A.sessionById("grp_default",e.currentAgent||null):null}),Ut=Vue.computed(()=>{let A=e.yeaftActiveSessionFilter||Ze.value?.id,pe=e.currentAgent;return A&&pe?{routeRef:{runtimeProvider:"yeaft",agentId:pe,sessionId:A}}:null}),Fs=Vue.computed(()=>{let A=Ut.value?.routeRef;return A?.agentId&&A?.sessionId?`yeaft:${A.agentId}:${A.sessionId}`:null}),O=Vue.computed(()=>Fs.value&&e.sessionForkPendingKey===Fs.value?e.sessionForkState:"idle"),ne=Vue.computed(()=>O.value==="copying"),be=Vue.computed(()=>e.sessionForkUnavailableReason(Ut.value)),Pe=async()=>{if(!Ut.value||be.value)return;let A=await e.copyCatalogSession(Ut.value);if(!A?.ok){let pe=A?.error?.code||"unknown",Te=`yeaft.session.error.${pe}`,tt=r(Te),je=tt===Te?A?.error?.message||pe:tt;await ht(r("yeaft.session.copyFailed",{message:je}))}},qe=()=>jv({activeSessionFilter:e.yeaftActiveSessionFilter,sessionsStore:U(),topbarGroup:Ze.value}),it=Vue.computed(()=>{let A=Ze.value||{},pe=typeof A.id=="string"?A.id.trim():"",Te=[A.title,A.name,A.config?.title,A.config?.name];for(let tt of Te){let je=typeof tt=="string"?tt.trim():"";if(je&&!(pe&&je===pe)&&!/^(sessions?|groups?)\//i.test(je)&&!/^session_[A-Za-z0-9_-]+$/.test(je)&&!(A.workDir&&je===A.workDir))return je}return""}),Je=Vue.computed(()=>{let A=Ze.value?.workDir;return typeof A=="string"?A.trim():""}),Pt=Vue.computed(()=>Ze.value&&typeof Ze.value.announcement=="string"?Ze.value.announcement:""),At=Vue.computed(()=>Mm(Ze.value,e.yeaftModel||"")),bt=Vue.computed(()=>{let A=At.value;return A&&e.yeaftAvailableModels.find(pe=>Ci(pe,A))||null}),xt=Vue.computed(()=>bt.value?.label||bt.value?.id||At.value),Kt=A=>Qc(A?.effortOptions),Ft=Vue.computed(()=>Rm(Ze.value,e.yeaftModelEffort||"")),He=Vue.computed(()=>{let A=Array.isArray(bt.value?.effortOptions)?bt.value.effortOptions.filter(Boolean):[];return A.length?A.includes(Ft.value)?Ft.value:Xc(A):null}),ct=Vue.computed(()=>_m(e.yeaftAvailableModels)),Ir=Vue.computed(()=>Kt(bt.value)),Ca=A=>{A==="model"&&!ct.value.length||A==="effort"&&!Ir.value.length||(o.value=o.value===A?null:A)},es=(A=null)=>{(!A||o.value===A)&&(o.value=null)},Ti=(A,pe)=>{let Te=A.currentTarget;if(A.relatedTarget){Te?.contains(A.relatedTarget)||es(pe);return}setTimeout(()=>{Te?.contains(document.activeElement)||es(pe)},0)},Mi=(A,pe=null)=>{if(!A)return;let Te=Ze.value?.id||null;e.switchYeaftModel(A,Te,pe),es()},vs=A=>{if(!Ir.value.includes(A)||!At.value)return;let pe=Ze.value?.id||null;e.switchYeaftModel(At.value,pe,A),es()},on=A=>!A||!Number.isFinite(A)||A<=0?"":A>=1e6?`${Math.round(A/1e5)/10}m`:A>=1e3?`${Math.round(A/1e3)}k`:String(A),zt=A=>{let pe=on(A?.contextWindow),Te=on(A?.maxOutput);return pe&&Te?`${pe} \xB7 ${Te} out`:pe},an=A=>{if(!o.value)return;A.target.closest(".yeaft-composer-choice")||es()},Pi=(A,pe="operations")=>{c.value=A||null,d.value=["operations","trace","llm"].includes(pe)?pe:"operations",l.value=!0},Cr=()=>{a.value||(m.value="vp",v.value=null),a.value=!a.value},ln=({initialTab:A="vp",editVpId:pe=null}={})=>{m.value=["vp","search","mcp","security"].includes(A)?A:"vp",v.value=m.value==="vp"&&pe||null,a.value=!0},Ln=()=>{es(),Pi(e.currentAgent||null,"llm")},Ri=async()=>{if(!(g.value||p.value)){p.value=!0,f.value="";try{let A={"Content-Type":"application/json"};t.token&&(A.Authorization=`Bearer ${t.token}`);let pe=await fetch("/api/user/agent-secret",{headers:A});if(!pe.ok){let je=r("yeaft.onboarding.secretError");try{let wt=await pe.json();wt?.error&&(je=wt.error)}catch{}throw new Error(je)}let Te=await pe.json(),tt=Te?.agentSecret||Te?.agent_secret||"";if(g.value=String(tt||"").trim(),!g.value)throw new Error(r("yeaft.onboarding.secretError"))}catch(A){f.value=A?.message||r("yeaft.onboarding.secretError")}finally{p.value=!1}}},Fn=()=>{u.value=!0},_i=A=>{u.value=!1},Os=Vue.reactive(new Set),ts=Vue.computed(()=>{let A=U();return A?A.activeSession:null}),Aa=A=>{if(!A)return"";if(A.id==="grp_default"&&(A.name==="Default"||!A.name))try{let pe=typeof window<"u"?window.i18n:null;if(pe&&pe.global&&typeof pe.global.t=="function")return pe.global.t("yeaft.session.defaultName")}catch{}return A.name||A.id||""},Ei=Vue.computed(()=>Aa(ts.value)),Di=Vue.computed(()=>{let A=U();if(!A||!A.activeNeedsInvite)return!1;let pe=A.activeSession;return pe?!Os.has(pe.id):!1}),xa=Vue.computed(()=>{let A=U();return!!(A&&A.activeNeedsInvite)}),Ar=Vue.computed(()=>{let A=U();return e._hasHandledAgentList===!0&&e._hasHandledYeaftSessionHydrate===!0&&!!(A&&A.hasLoadedSnapshot)}),On=Vue.computed(()=>{let A=U();return Nv({agentInventoryReady:e._hasHandledAgentList===!0,hasYeaftAgent:Uv(e),sessionsReady:e._hasHandledYeaftSessionHydrate===!0&&!!(A&&A.hasLoadedSnapshot),sessionsEmpty:!!(A&&A.isEmpty)})});Vue.watch(On,A=>{A&&Ri()},{immediate:!0});let $i=()=>{let A=ts.value;A&&Os.add(A.id),Ae(A?A.id:null)},Ta=()=>{let A=ts.value;A&&Os.add(A.id)},Li=Vue.ref(!1),C=Vue.ref(null),H=Vue.ref(null),K=Vue.ref("session"),Ce=Vue.ref(""),De=(A={})=>{let pe=A&&(A.sessionId||A.groupId)||null,Te=A&&A.editVpId||"",tt=Te?"members":A&&A.section||"session";pe&&(C.value=pe,H.value=A&&A.agentId||null,K.value=tt,Ce.value=Te,Li.value=!0)},xe=()=>{let A=qe();A&&De({sessionId:A,section:"session"})},ft=()=>{Li.value=!1,C.value=null,H.value=null,Ce.value=""},Ne=()=>{ft(),ln({initialTab:"vp"})},Ae=A=>{A&&De({sessionId:A,section:"members"})};Vue.watch(()=>{let A=ts.value;return A?A.id+":"+(Array.isArray(A.roster)?A.roster.length:0)+":"+(A.defaultVpId||""):""},(A,pe)=>{let Te=ts.value;Te&&A!==pe&&Array.isArray(Te.roster)&&Te.roster.length>0&&Os.delete(Te.id)});let Ot=()=>{a.value=!1},Yt=Vue.computed(()=>!a.value&&!On.value&&Z.value),cn=Vue.computed(()=>{let A=U(),pe=e.yeaftActiveSessionFilter||A?.activeSessionId||null;if(!pe)return[];let tt=(typeof A?.sessionById=="function"?A.sessionById(pe,e.currentAgent||null):null)?.agentId||e.currentAgent||null,je=tt?`${tt}${pe}`:pe,wt=e.yeaftActiveTasksBySession?.[je]||{};return NS(wt)}),Ma=Vue.computed(()=>{if(!e.yeaftConversationId)return[];let pe=U(),Te=e.yeaftActiveSessionFilter||pe?.activeSessionId||null;if(!Te)return[];let tt=Vv(pe,Te,e.currentAgent||null),je=tt&&Array.isArray(tt.roster)?tt.roster:[];if(je.length===0)return[];let wt=new Set(je),qs=qv(je,s.vpList||[]),un=e.vpStatuses||{},ys={},Fi=e.currentAgent||null;for(let dt of Object.values(un)){if(!dt||!dt.vpId)continue;let Oi=dt.sessionId??dt.groupId;Oi&&Oi!==Te||Fi&&dt.agentId&&dt.agentId!==Fi||wt.has(dt.vpId)&&(ys[dt.vpId]=dt)}let yd={};for(let dt of Object.values(e.activeVpTurns||{}))!dt?.turnId||!dt?.sessionId||dt.sessionId!==Te||Fi&&dt.agentId&&dt.agentId!==Fi||Object.entries(e.stoppingVpTurnIds||{}).some(([Oi])=>e.activeVpTurns?.[Oi]===dt)&&(yd[dt.turnId]=!0);return Hv({vpList:qs,vpStatuses:ys,stoppingVpTurnIds:yd,connectionState:e.connectionState,vpLabelOf:dt=>s.vpLabel(dt),vpDescriptionOf:dt=>s.vpDescription(dt)})});return{store:e,pageRef:k,effectiveSidebarCollapsed:Ue,debugMode:i,composerMenuOpen:o,topbarGroup:Ze,forkSessionRow:Ut,forkSessionKey:Fs,activeSessionForkState:O,isActiveSessionCopying:ne,forkUnavailableReason:be,forkCurrentSession:Pe,topbarSessionTitle:it,topbarFolderPath:Je,topbarModel:At,topbarModelLabel:xt,topbarEffort:He,topbarModelRows:ct,topbarEffortOptions:Ir,selectableEffortsForModel:Kt,modelOptionMatchesRef:Ci,showSettings:a,showAgentSettings:l,agentSettingsAgentId:c,agentSettingsInitialCategory:d,sessionCreateOpen:u,settingsInitialTab:m,settingsInitialEditVpId:v,chatInputRef:y,messageQuote:h,messageListRef:S,historySearchRef:b,historySearchOpen:w,historySearchActiveMessageId:P,historyOutlineState:x,toggleHistorySearch:_,closeHistorySearch:et,onHistorySearchQuery:Se,loadOlderHistoryOutline:_e,loadMoreHistorySearchResults:Fe,previewHistorySearchResult:Xe,selectHistorySearchResult:pt,yeaftInputDraftKey:I,openSettings:ln,isMobile:he,isNarrowDetail:Ee,detailPanel:G,isResizingDetail:de,detailWidthStyle:ue,startDetailResize:re,isProcessing:rn,goBack:Dt,sendMessage:$t,setMessageQuote:Lt,editMessageAsNew:tn,cancelYeaft:Dn,toggleSidebar:Sr,closeDebug:Jt,reloadMessages:sn,retryConversationInventory:nn,reloadPage:$n,toggleComposerMenu:Ca,closeComposerMenu:es,onComposerMenuFocusout:Ti,selectModel:Mi,selectEffort:vs,openLlmConfig:Ln,trackOverlayPointerDown:gs,trackOverlayPointerUp:fs,clearOverlayPointerGesture:hs,openSessionCreate:Fn,onSessionCreated:_i,formatTokens:on,formatModelCtx:zt,toggleSettings:Cr,openAgentSettings:Pi,onSettingsSaved:Ot,sidebarV2Enabled:ae,onSelectGroupV2:ke,onSelectChat:N,canUseWorkbench:Q,shouldShowInviteModal:Di,inviteGroupName:Ei,onInviteOpenLibrary:$i,onInviteDismiss:Ta,isActiveGroupEmpty:xa,conversationInventoryReady:Ar,showOnboardingGuide:On,agentSecret:g,agentSecretLoading:p,agentSecretError:f,groupSettingsOpen:Li,groupSettingsId:C,groupSettingsAgentId:H,groupSettingsSection:K,groupSettingsEditVpId:Ce,openSessionSettings:De,openAnnouncementSettings:xe,closeGroupSettings:ft,openVpLibraryFromGroupSettings:Ne,openMemberEditor:Ae,showVpTimeline:Yt,vpTimelineRows:Ma,sessionStatusTasksForActiveSession:cn,sessionStatusAnnouncementText:Pt,sessionStatusVisible:Z,toggleSessionStatus:Re,closeSessionStatus:J,toggleWorkbench:D,timelineWidthStyle:ut,startTimelineResize:at,onEditVpFromTimeline:A=>{if(!A)return;let pe=qe();pe&&De({sessionId:pe,section:"members",editVpId:A})},onMentionVpFromTimeline:A=>{if(!A)return;let pe=y.value;pe&&typeof pe.appendMention=="function"&&pe.appendMention(A)},onCancelVpFromTimeline:A=>{if(!A)return;let pe=U(),Te=e.yeaftActiveSessionFilter||pe?.activeSessionId||null;Te&&typeof e.cancelVpTurnForSession=="function"&&e.cancelVpTurnForSession(A,Te)},onCancelTaskFromTimeline:A=>!A?.id||!A.sessionId||typeof e.cancelYeaftTask!="function"?!1:e.cancelYeaftTask({agentId:A.agentId,sessionId:A.sessionId,taskId:A.id})}}}});var WS,Xv,Zv=B(()=>{Ct();WS=["button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])","a[href]",'[tabindex]:not([tabindex="-1"])'].join(","),Xv={name:"AppDialog",setup(){let e=Wg(),t=Vue.ref(null),s=Vue.ref(null),n=null,r=[],i=g=>{if(g){r=Array.from(document.body.children).filter(p=>p!==t.value?.closest(".app-dialog-overlay")&&!p.classList.contains("app-dialog-overlay")),r.forEach(p=>{p.inert=!0});return}r.forEach(p=>{p.inert=!1}),r=[]},o=()=>{Vue.nextTick(()=>{e.type==="prompt"?s.value?.focus?.():t.value?.querySelector(".app-dialog-confirm")?.focus?.()})};Vue.watch(()=>e.open,(g,p)=>{g&&!p?(n=document.activeElement,Vue.nextTick(()=>i(!0))):!g&&p&&(i(!1),Vue.nextTick(()=>{n?.isConnected&&n.focus?.(),n=null}))}),Vue.watch(()=>e.id,o);let a=()=>{e.type==="alert"?Ao(!0):Ao(!1)},l=()=>Ao(!0,e.value),c=g=>{let p=Array.from(t.value?.querySelectorAll(WS)||[]);if(p.length===0){g.preventDefault(),t.value?.focus?.();return}let f=p[0],m=p[p.length-1];g.shiftKey&&document.activeElement===f?(g.preventDefault(),m.focus()):!g.shiftKey&&document.activeElement===m&&(g.preventDefault(),f.focus())},d=g=>{g.key==="Escape"?(g.preventDefault(),a()):g.key==="Tab"&&c(g)},u=g=>{e.open&&d(g)};return Vue.onMounted(()=>document.addEventListener("keydown",u)),Vue.onBeforeUnmount(()=>{document.removeEventListener("keydown",u),i(!1)}),{state:e,dialog:t,input:s,cancel:a,confirm:l,onKeydown:d}},template:`
9620
+ `,setup(){let e=Pinia.useChatStore(),t=Pinia.useAuthStore(),s=Pinia.useVpStore(),n=Vue.getCurrentInstance(),r=n&&n.appContext.config.globalProperties.$t||(A=>A),i=Vue.computed(()=>!!(e.yeaftDebugPanel&&e.yeaftDebugPanel.open)),o=Vue.ref(null),a=Vue.ref(!1),l=Vue.ref(!1),c=Vue.ref(null),d=Vue.ref("operations"),u=Vue.ref(!1),g=Vue.ref(""),p=Vue.ref(!1),f=Vue.ref(""),m=Vue.ref("vp"),v=Vue.ref(null),b=Vue.ref(null),h=Vue.ref(null),k=Vue.ref(null),S=Vue.ref(null),y=Vue.ref(null),w=Vue.ref(!1),P=Vue.ref(null),x=Vue.computed(()=>e.getYeaftHistoryOutlineState()),Y=Vue.ref(e.yeaftHistorySearchState?.query||""),L=null,U=()=>{try{return window.Pinia?.useSessionsStore?.()||null}catch{return null}},E=()=>{let A=U();return{agentId:e.currentAgent||null,sessionId:e.yeaftActiveSessionFilter||A?.activeSessionId||null}},oe=()=>zv,q=(A="")=>{let{agentId:pe,sessionId:Te}=E();e.yeaftHistorySearchState={requestId:null,agentId:pe,sessionId:Te,query:"",senderKey:A,loading:!1,results:[],hasMore:!1,nextBeforeSeq:null,error:null}},I=Vue.computed(()=>{let A=e.currentAgent||"agent",pe=U(),Te=e.yeaftActiveSessionFilter||pe?.activeSessionId||"session";return`yeaft:${A}:${Te}`});Vue.watch(I,()=>{h.value=null});let T=null,R=null,M=A=>{if(!A)return!1;let pe=String(A.tagName||"").toLowerCase();return pe==="textarea"||pe==="input"||A.isContentEditable===!0},$=({recoverScroll:A=!1}={})=>{let pe=k.value;if(!pe)return;if(!he.value){pe.style.removeProperty("--yeaft-visual-viewport-height");return}let Te=window.visualViewport,tt=Math.max(1,Math.round(Te?.height||window.innerHeight||1));pe.style.setProperty("--yeaft-visual-viewport-height",`${tt}px`),!(!A||Te&&window.innerHeight&&Te.height<window.innerHeight*.85||M(document.activeElement))&&window.scrollTo(0,0)},j=(A={})=>{T!=null&&cancelAnimationFrame(T),T=requestAnimationFrame(()=>{T=null,$(A)})},z=()=>{j({recoverScroll:!0}),R&&clearTimeout(R),R=setTimeout(()=>{R=null,j({recoverScroll:!0})},260)},Q=Vue.computed(()=>e.hasCapability("terminal")||e.hasCapability("file_editor")||e.hasCapability("browser_runtime")&&e.hasCapability("browser_webrtc")&&(e.hasCapability("browser_capture_tab")||e.hasCapability("browser_capture_cdp"))),ae=Vue.computed(()=>!0),ke=A=>{let pe=A&&A.id?A.id:null;pe&&(he.value&&J(),e.setActiveSessionFilter(pe,{agentId:A.agentId||null}),he.value&&e.closeSessionSidebar())},N=A=>{},G=Vue.ref(null),de=Vue.ref(!1),we=320,se=Math.max(we,Math.round(window.innerWidth*.25)),ve=localStorage.getItem("yeaft-debug-width"),Ie=Vue.ref(ve?parseInt(ve,10):se),ue=Vue.computed(()=>({"--yeaft-detail-width":Ie.value+"px"})),re=A=>{de.value=!0;let pe=A.clientX,Te=Ie.value,tt=window.innerWidth*.6,je=qs=>{let un=pe-qs.clientX,ys=Math.min(tt,Math.max(we,Te+un));Ie.value=ys},wt=()=>{de.value=!1,document.removeEventListener("mousemove",je),document.removeEventListener("mouseup",wt),localStorage.setItem("yeaft-debug-width",String(Ie.value))};document.addEventListener("mousemove",je),document.addEventListener("mouseup",wt)},te="yeaft-session-status-visible",V="(max-width: 768px)",ce="(max-width: 1024px)",X=()=>{if(typeof window>"u")return!1;try{return typeof window.matchMedia=="function"?window.matchMedia(V).matches:Number(window.innerWidth)<=768}catch{return!1}},F=()=>{if(X())return!1;try{let A=localStorage.getItem(te);return!(A==="0"||A==="false")}catch{return!0}},Z=Vue.ref(F()),fe=A=>{if(Z.value=!!A,!X())try{localStorage.setItem(te,Z.value?"1":"0")}catch{}},Re=()=>{let A=!Z.value;A&&(e.workbenchExpanded&&e.toggleWorkbench(),e.closeYeaftDebugPanel()),fe(A)},J=()=>fe(!1),D=()=>{e.workbenchExpanded||J(),e.toggleWorkbench()};Vue.watch(i,A=>{A&&J()},{flush:"sync"}),Vue.watch(()=>e.workbenchExpanded,A=>{A&&J()},{flush:"sync"});let ye=220,Me=280,ze=(()=>{try{return localStorage.getItem("yeaft-vp-timeline-width")}catch{return null}})(),Ye=ze?parseInt(ze,10):NaN,rt=Vue.ref(Number.isFinite(Ye)&&Ye>=ye?Ye:Me),ut=Vue.computed(()=>({"--yeaft-vp-timeline-width":rt.value+"px"})),at=A=>{let pe=A.clientX,Te=rt.value,tt=Math.max(ye,Math.floor(window.innerWidth*.4)),je=qs=>{let un=pe-qs.clientX,ys=Math.min(tt,Math.max(ye,Te+un));rt.value=ys},wt=()=>{document.removeEventListener("mousemove",je),document.removeEventListener("mouseup",wt);try{localStorage.setItem("yeaft-vp-timeline-width",String(rt.value))}catch{}};document.addEventListener("mousemove",je),document.addEventListener("mouseup",wt)},W=typeof window.matchMedia=="function"?window.matchMedia(V):null,ie=typeof window.matchMedia=="function"?window.matchMedia(ce):null,me=(A,pe)=>A?A.matches:window.innerWidth<=pe,he=Vue.ref(me(W,768)),Ee=Vue.ref(me(ie,1024)),Ue=Vue.computed(()=>he.value?!e.sessionSidebarOpen:e.sidebarCollapsed),Mt=()=>{let A=he.value;he.value=me(W,768),Ee.value=me(ie,1024),he.value&&!A&&J()},Qe=()=>{Mt(),z()},mt=A=>{A&&(typeof A.addEventListener=="function"?A.addEventListener("change",Qe):typeof A.addListener=="function"&&A.addListener(Qe))},Et=A=>{A&&(typeof A.removeEventListener=="function"?A.removeEventListener("change",Qe):typeof A.removeListener=="function"&&A.removeListener(Qe))},et=()=>{L&&(clearTimeout(L),L=null),Y.value="",q(oe()),w.value=!1,P.value=null},lt=()=>{let A=oe();Y.value="",q(A),w.value=!0,e.searchYeaftHistory("",{senderKey:A}),Vue.nextTick(()=>y.value?.focus?.())},_=()=>{w.value?et():lt()},ee=A=>{let pe=typeof A.composedPath=="function"?A.composedPath():[];w.value&&Zf(A.target,pe)&&et()},Se=A=>{Y.value=A,L&&clearTimeout(L),P.value=null,L=setTimeout(()=>{L=null,e.searchYeaftHistory(Y.value,{senderKey:e.yeaftHistorySearchState.senderKey})},220)},_e=A=>{if(!e.searchYeaftHistory("",{append:!0,senderKey:zv}))return;let pe=Vue.watch(()=>x.value.loading,Te=>{Te||(pe(),y.value?.restoreOlderScroll?.(A))})},Fe=()=>e.searchYeaftHistory(e.yeaftHistorySearchState.query,{append:!0,senderKey:e.yeaftHistorySearchState.senderKey}),Xe=A=>{e.hasCapability("session_history_window_prefetch")&&e.loadYeaftHistoryWindow(A)},pt=A=>{let pe=e.beginYeaftHistoryReveal?.(A)||null;return Jf({result:A,revealWindow:Te=>e.revealYeaftHistoryResult(Te,pe),nextTick:()=>Vue.nextTick(),revealMessage:Te=>S.value?.revealMessage?.(Te),isMobile:he.value,closeOutline:et}).finally(()=>e.finishYeaftHistoryReveal?.(pe))},gt=A=>{if((A.metaKey||A.ctrlKey)&&String(A.key).toLowerCase()==="f"){A.preventDefault(),lt();return}if(A.key==="Escape"){if(w.value){et();return}if(o.value){es();return}}};Vue.onMounted(()=>{Mt(),window.addEventListener("resize",Qe),mt(W),mt(ie),window.visualViewport?.addEventListener("resize",z),window.visualViewport?.addEventListener("scroll",z),document.addEventListener("click",an),document.addEventListener("click",ee),document.addEventListener("keydown",gt),j()}),Vue.onUnmounted(()=>{window.removeEventListener("resize",Qe),Et(W),Et(ie),window.visualViewport?.removeEventListener("resize",z),window.visualViewport?.removeEventListener("scroll",z),document.removeEventListener("click",an),document.removeEventListener("click",ee),document.removeEventListener("keydown",gt),T!=null&&cancelAnimationFrame(T),R&&clearTimeout(R),L&&clearTimeout(L)}),Vue.watch(()=>e.yeaftConversationId,A=>{A&&e.activeConversations[0]!==A&&(e.activeConversations=[A])}),Vue.watch(()=>[e.currentAgent,e.yeaftActiveSessionFilter],()=>{he.value&&J(),et(),q(oe())});let Dt=()=>{e.leaveYeaft()},$t=(A,pe,Te,tt=null)=>{if(ne.value)return!1;let je=U();if(je&&je.activeNeedsInvite){let ys=je.activeSession;return ys&&Os.delete(ys.id),!1}let wt=e.yeaftActiveSessionFilter||je&&je.activeSessionId||"grp_default",qs=Uo(A).mentions,un=Array.isArray(pe)?pe:void 0;return e.sendYeaftSessionMessage({groupId:wt,text:A,mentions:qs,attachments:un,quote:Te,...tt?{quickSend:tt}:{}})},Lt=A=>{A&&(h.value=A,b.value?.focusInput?.())},tn=A=>{h.value=null,b.value?.replaceDraft?.(A||"")},Dn=()=>{let A=U(),pe=e.yeaftActiveSessionFilter||A?.activeSessionId||null;pe&&e.cancelYeaftSession(pe)},Sr=()=>{if(he.value){e.toggleSessionSidebar();return}e.toggleSidebar()},Jt=()=>{e.closeYeaftDebugPanel()},sn=()=>{e.reloadYeaftMessages()},nn=()=>{if(typeof e.requestYeaftSessionInventory=="function"){e.requestYeaftSessionInventory();return}e._hasHandledAgentList=!1,e._hasHandledYeaftSessionHydrate=!1,e.yeaftSessionHydrateError=null,e.sendWsMessage({type:"get_agents"})},$n=()=>{window.location.reload()},rn=Vue.computed(()=>{let A=U(),pe=e.yeaftActiveSessionFilter||A?.activeSessionId||null;return pe?e.isYeaftSessionProcessing(pe,e.currentAgent||null):!1}),Ze=Vue.computed(()=>{let A=U();if(!A||!A.sessions)return null;let pe=e.yeaftActiveSessionFilter||null;if(pe&&typeof A.sessionById=="function"){let Te=A.sessionById(pe,e.currentAgent||null);if(Te)return Te}if(A.activeSessionId&&typeof A.sessionById=="function"){let Te=A.sessionById(A.activeSessionId,e.currentAgent||null);if(Te)return Te}return typeof A.sessionById=="function"?A.sessionById("grp_default",e.currentAgent||null):null}),Ut=Vue.computed(()=>{let A=e.yeaftActiveSessionFilter||Ze.value?.id,pe=e.currentAgent;return A&&pe?{routeRef:{runtimeProvider:"yeaft",agentId:pe,sessionId:A}}:null}),Fs=Vue.computed(()=>{let A=Ut.value?.routeRef;return A?.agentId&&A?.sessionId?`yeaft:${A.agentId}:${A.sessionId}`:null}),O=Vue.computed(()=>Fs.value&&e.sessionForkPendingKey===Fs.value?e.sessionForkState:"idle"),ne=Vue.computed(()=>O.value==="copying"),be=Vue.computed(()=>e.sessionForkUnavailableReason(Ut.value)),Pe=async()=>{if(!Ut.value||be.value)return;let A=await e.copyCatalogSession(Ut.value);if(!A?.ok){let pe=A?.error?.code||"unknown",Te=`yeaft.session.error.${pe}`,tt=r(Te),je=tt===Te?A?.error?.message||pe:tt;await ht(r("yeaft.session.copyFailed",{message:je}))}},qe=()=>jv({activeSessionFilter:e.yeaftActiveSessionFilter,sessionsStore:U(),topbarGroup:Ze.value}),it=Vue.computed(()=>{let A=Ze.value||{},pe=typeof A.id=="string"?A.id.trim():"",Te=[A.title,A.name,A.config?.title,A.config?.name];for(let tt of Te){let je=typeof tt=="string"?tt.trim():"";if(je&&!(pe&&je===pe)&&!/^(sessions?|groups?)\//i.test(je)&&!/^session_[A-Za-z0-9_-]+$/.test(je)&&!(A.workDir&&je===A.workDir))return je}return""}),Je=Vue.computed(()=>{let A=Ze.value?.workDir;return typeof A=="string"?A.trim():""}),Pt=Vue.computed(()=>Ze.value&&typeof Ze.value.announcement=="string"?Ze.value.announcement:""),At=Vue.computed(()=>Mm(Ze.value,e.yeaftModel||"")),bt=Vue.computed(()=>{let A=At.value;return A&&e.yeaftAvailableModels.find(pe=>Ci(pe,A))||null}),xt=Vue.computed(()=>bt.value?.label||bt.value?.id||At.value),Kt=A=>Qc(A?.effortOptions),Ft=Vue.computed(()=>Rm(Ze.value,e.yeaftModelEffort||"")),He=Vue.computed(()=>{let A=Array.isArray(bt.value?.effortOptions)?bt.value.effortOptions.filter(Boolean):[];return A.length?A.includes(Ft.value)?Ft.value:Xc(A):null}),ct=Vue.computed(()=>_m(e.yeaftAvailableModels)),Ir=Vue.computed(()=>Kt(bt.value)),Ca=A=>{A==="model"&&!ct.value.length||A==="effort"&&!Ir.value.length||(o.value=o.value===A?null:A)},es=(A=null)=>{(!A||o.value===A)&&(o.value=null)},Ti=(A,pe)=>{let Te=A.currentTarget;if(A.relatedTarget){Te?.contains(A.relatedTarget)||es(pe);return}setTimeout(()=>{Te?.contains(document.activeElement)||es(pe)},0)},Mi=(A,pe=null)=>{if(!A)return;let Te=Ze.value?.id||null;e.switchYeaftModel(A,Te,pe),es()},vs=A=>{if(!Ir.value.includes(A)||!At.value)return;let pe=Ze.value?.id||null;e.switchYeaftModel(At.value,pe,A),es()},on=A=>!A||!Number.isFinite(A)||A<=0?"":A>=1e6?`${Math.round(A/1e5)/10}m`:A>=1e3?`${Math.round(A/1e3)}k`:String(A),zt=A=>{let pe=on(A?.contextWindow),Te=on(A?.maxOutput);return pe&&Te?`${pe} \xB7 ${Te} out`:pe},an=A=>{if(!o.value)return;A.target.closest(".yeaft-composer-choice")||es()},Pi=(A,pe="operations")=>{c.value=A||null,d.value=["operations","trace","llm"].includes(pe)?pe:"operations",l.value=!0},Cr=()=>{a.value||(m.value="vp",v.value=null),a.value=!a.value},ln=({initialTab:A="vp",editVpId:pe=null}={})=>{m.value=["vp","search","mcp","security"].includes(A)?A:"vp",v.value=m.value==="vp"&&pe||null,a.value=!0},Ln=()=>{es(),Pi(e.currentAgent||null,"llm")},Ri=async()=>{if(!(g.value||p.value)){p.value=!0,f.value="";try{let A={"Content-Type":"application/json"};t.token&&(A.Authorization=`Bearer ${t.token}`);let pe=await fetch("/api/user/agent-secret",{headers:A});if(!pe.ok){let je=r("yeaft.onboarding.secretError");try{let wt=await pe.json();wt?.error&&(je=wt.error)}catch{}throw new Error(je)}let Te=await pe.json(),tt=Te?.agentSecret||Te?.agent_secret||"";if(g.value=String(tt||"").trim(),!g.value)throw new Error(r("yeaft.onboarding.secretError"))}catch(A){f.value=A?.message||r("yeaft.onboarding.secretError")}finally{p.value=!1}}},Fn=()=>{u.value=!0},_i=A=>{u.value=!1},Os=Vue.reactive(new Set),ts=Vue.computed(()=>{let A=U();return A?A.activeSession:null}),Aa=A=>{if(!A)return"";if(A.id==="grp_default"&&(A.name==="Default"||!A.name))try{let pe=typeof window<"u"?window.i18n:null;if(pe&&pe.global&&typeof pe.global.t=="function")return pe.global.t("yeaft.session.defaultName")}catch{}return A.name||A.id||""},Ei=Vue.computed(()=>Aa(ts.value)),Di=Vue.computed(()=>{let A=U();if(!A||!A.activeNeedsInvite)return!1;let pe=A.activeSession;return pe?!Os.has(pe.id):!1}),xa=Vue.computed(()=>{let A=U();return!!(A&&A.activeNeedsInvite)}),Ar=Vue.computed(()=>{let A=U();return e._hasHandledAgentList===!0&&e._hasHandledYeaftSessionHydrate===!0&&!!(A&&A.hasLoadedSnapshot)}),On=Vue.computed(()=>{let A=U();return Nv({agentInventoryReady:e._hasHandledAgentList===!0,hasYeaftAgent:Uv(e),sessionsReady:e._hasHandledYeaftSessionHydrate===!0&&!!(A&&A.hasLoadedSnapshot),sessionsEmpty:!!(A&&A.isEmpty)})});Vue.watch(On,A=>{A&&Ri()},{immediate:!0});let $i=()=>{let A=ts.value;A&&Os.add(A.id),Ae(A?A.id:null)},Ta=()=>{let A=ts.value;A&&Os.add(A.id)},Li=Vue.ref(!1),C=Vue.ref(null),H=Vue.ref(null),K=Vue.ref("session"),Ce=Vue.ref(""),De=(A={})=>{let pe=A&&(A.sessionId||A.groupId)||null,Te=A&&A.editVpId||"",tt=Te?"members":A&&A.section||"session";pe&&(C.value=pe,H.value=A&&A.agentId||null,K.value=tt,Ce.value=Te,Li.value=!0)},xe=()=>{let A=qe();A&&De({sessionId:A,section:"session"})},ft=()=>{Li.value=!1,C.value=null,H.value=null,Ce.value=""},Ne=()=>{ft(),ln({initialTab:"vp"})},Ae=A=>{A&&De({sessionId:A,section:"members"})};Vue.watch(()=>{let A=ts.value;return A?A.id+":"+(Array.isArray(A.roster)?A.roster.length:0)+":"+(A.defaultVpId||""):""},(A,pe)=>{let Te=ts.value;Te&&A!==pe&&Array.isArray(Te.roster)&&Te.roster.length>0&&Os.delete(Te.id)});let Ot=()=>{a.value=!1},Yt=Vue.computed(()=>!a.value&&!On.value&&Z.value),cn=Vue.computed(()=>{let A=U(),pe=e.yeaftActiveSessionFilter||A?.activeSessionId||null;if(!pe)return[];let tt=(typeof A?.sessionById=="function"?A.sessionById(pe,e.currentAgent||null):null)?.agentId||e.currentAgent||null,je=tt?`${tt}${pe}`:pe,wt=e.yeaftActiveTasksBySession?.[je]||{};return NS(wt)}),Ma=Vue.computed(()=>{if(!e.yeaftConversationId)return[];let pe=U(),Te=e.yeaftActiveSessionFilter||pe?.activeSessionId||null;if(!Te)return[];let tt=Vv(pe,Te,e.currentAgent||null),je=tt&&Array.isArray(tt.roster)?tt.roster:[];if(je.length===0)return[];let wt=new Set(je),qs=qv(je,s.vpList||[]),un=e.vpStatuses||{},ys={},Fi=e.currentAgent||null;for(let dt of Object.values(un)){if(!dt||!dt.vpId)continue;let Oi=dt.sessionId??dt.groupId;Oi&&Oi!==Te||Fi&&dt.agentId&&dt.agentId!==Fi||wt.has(dt.vpId)&&(ys[dt.vpId]=dt)}let yd={};for(let dt of Object.values(e.activeVpTurns||{}))!dt?.turnId||!dt?.sessionId||dt.sessionId!==Te||Fi&&dt.agentId&&dt.agentId!==Fi||Object.entries(e.stoppingVpTurnIds||{}).some(([Oi])=>e.activeVpTurns?.[Oi]===dt)&&(yd[dt.turnId]=!0);return Hv({vpList:qs,vpStatuses:ys,stoppingVpTurnIds:yd,connectionState:e.connectionState,vpLabelOf:dt=>s.vpLabel(dt),vpDescriptionOf:dt=>s.vpDescription(dt)})});return{store:e,pageRef:k,effectiveSidebarCollapsed:Ue,debugMode:i,composerMenuOpen:o,topbarGroup:Ze,forkSessionRow:Ut,forkSessionKey:Fs,activeSessionForkState:O,isActiveSessionCopying:ne,forkUnavailableReason:be,forkCurrentSession:Pe,topbarSessionTitle:it,topbarFolderPath:Je,topbarModel:At,topbarModelLabel:xt,topbarEffort:He,topbarModelRows:ct,topbarEffortOptions:Ir,selectableEffortsForModel:Kt,modelOptionMatchesRef:Ci,showSettings:a,showAgentSettings:l,agentSettingsAgentId:c,agentSettingsInitialCategory:d,sessionCreateOpen:u,settingsInitialTab:m,settingsInitialEditVpId:v,chatInputRef:b,messageQuote:h,messageListRef:S,historySearchRef:y,historySearchOpen:w,historySearchActiveMessageId:P,historyOutlineState:x,toggleHistorySearch:_,closeHistorySearch:et,onHistorySearchQuery:Se,loadOlderHistoryOutline:_e,loadMoreHistorySearchResults:Fe,previewHistorySearchResult:Xe,selectHistorySearchResult:pt,yeaftInputDraftKey:I,openSettings:ln,isMobile:he,isNarrowDetail:Ee,detailPanel:G,isResizingDetail:de,detailWidthStyle:ue,startDetailResize:re,isProcessing:rn,goBack:Dt,sendMessage:$t,setMessageQuote:Lt,editMessageAsNew:tn,cancelYeaft:Dn,toggleSidebar:Sr,closeDebug:Jt,reloadMessages:sn,retryConversationInventory:nn,reloadPage:$n,toggleComposerMenu:Ca,closeComposerMenu:es,onComposerMenuFocusout:Ti,selectModel:Mi,selectEffort:vs,openLlmConfig:Ln,trackOverlayPointerDown:gs,trackOverlayPointerUp:fs,clearOverlayPointerGesture:hs,openSessionCreate:Fn,onSessionCreated:_i,formatTokens:on,formatModelCtx:zt,toggleSettings:Cr,openAgentSettings:Pi,onSettingsSaved:Ot,sidebarV2Enabled:ae,onSelectGroupV2:ke,onSelectChat:N,canUseWorkbench:Q,shouldShowInviteModal:Di,inviteGroupName:Ei,onInviteOpenLibrary:$i,onInviteDismiss:Ta,isActiveGroupEmpty:xa,conversationInventoryReady:Ar,showOnboardingGuide:On,agentSecret:g,agentSecretLoading:p,agentSecretError:f,groupSettingsOpen:Li,groupSettingsId:C,groupSettingsAgentId:H,groupSettingsSection:K,groupSettingsEditVpId:Ce,openSessionSettings:De,openAnnouncementSettings:xe,closeGroupSettings:ft,openVpLibraryFromGroupSettings:Ne,openMemberEditor:Ae,showVpTimeline:Yt,vpTimelineRows:Ma,sessionStatusTasksForActiveSession:cn,sessionStatusAnnouncementText:Pt,sessionStatusVisible:Z,toggleSessionStatus:Re,closeSessionStatus:J,toggleWorkbench:D,timelineWidthStyle:ut,startTimelineResize:at,onEditVpFromTimeline:A=>{if(!A)return;let pe=qe();pe&&De({sessionId:pe,section:"members",editVpId:A})},onMentionVpFromTimeline:A=>{if(!A)return;let pe=b.value;pe&&typeof pe.appendMention=="function"&&pe.appendMention(A)},onCancelVpFromTimeline:A=>{if(!A)return;let pe=U(),Te=e.yeaftActiveSessionFilter||pe?.activeSessionId||null;Te&&typeof e.cancelVpTurnForSession=="function"&&e.cancelVpTurnForSession(A,Te)},onCancelTaskFromTimeline:A=>!A?.id||!A.sessionId||typeof e.cancelYeaftTask!="function"?!1:e.cancelYeaftTask({agentId:A.agentId,sessionId:A.sessionId,taskId:A.id})}}}});var WS,Xv,Zv=B(()=>{Ct();WS=["button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])","a[href]",'[tabindex]:not([tabindex="-1"])'].join(","),Xv={name:"AppDialog",setup(){let e=Wg(),t=Vue.ref(null),s=Vue.ref(null),n=null,r=[],i=g=>{if(g){r=Array.from(document.body.children).filter(p=>p!==t.value?.closest(".app-dialog-overlay")&&!p.classList.contains("app-dialog-overlay")),r.forEach(p=>{p.inert=!0});return}r.forEach(p=>{p.inert=!1}),r=[]},o=()=>{Vue.nextTick(()=>{e.type==="prompt"?s.value?.focus?.():t.value?.querySelector(".app-dialog-confirm")?.focus?.()})};Vue.watch(()=>e.open,(g,p)=>{g&&!p?(n=document.activeElement,Vue.nextTick(()=>i(!0))):!g&&p&&(i(!1),Vue.nextTick(()=>{n?.isConnected&&n.focus?.(),n=null}))}),Vue.watch(()=>e.id,o);let a=()=>{e.type==="alert"?Ao(!0):Ao(!1)},l=()=>Ao(!0,e.value),c=g=>{let p=Array.from(t.value?.querySelectorAll(WS)||[]);if(p.length===0){g.preventDefault(),t.value?.focus?.();return}let f=p[0],m=p[p.length-1];g.shiftKey&&document.activeElement===f?(g.preventDefault(),m.focus()):!g.shiftKey&&document.activeElement===m&&(g.preventDefault(),f.focus())},d=g=>{g.key==="Escape"?(g.preventDefault(),a()):g.key==="Tab"&&c(g)},u=g=>{e.open&&d(g)};return Vue.onMounted(()=>document.addEventListener("keydown",u)),Vue.onBeforeUnmount(()=>{document.removeEventListener("keydown",u),i(!1)}),{state:e,dialog:t,input:s,cancel:a,confirm:l,onKeydown:d}},template:`
9618
9621
  <Teleport to="body">
9619
9622
  <div v-if="state.open" class="modal-overlay app-dialog-overlay" @click.self="cancel">
9620
9623
  <section ref="dialog" class="modal app-dialog" role="dialog" aria-modal="true" tabindex="-1" :aria-labelledby="'app-dialog-title-' + state.id" :aria-describedby="'app-dialog-message-' + state.id">