@yeaft/webchat-agent 1.0.313 → 1.0.314
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.
- package/local-runtime/version.json +1 -1
- package/local-runtime/web/app.bundle.js +42 -43
- package/local-runtime/web/app.bundle.js.gz +0 -0
- package/local-runtime/web/index.html +2 -2
- package/local-runtime/web/style.bundle.css +1 -1
- package/local-runtime/web/style.bundle.css.gz +0 -0
- package/package.json +1 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
var F=(e,t,s)=>()=>{if(s)throw s[0];try{return e&&(t=e(e=0)),t}catch(n){throw s=[n],n}};var gm=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(s){throw t=0,s}};function kl(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 Sl(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 Il(e){return e&&typeof e=="object"&&typeof e.n=="string"&&typeof e.c=="string"}function at(e){return nacl.util.decodeBase64(e)}var mr=F(()=>{});function At(){return globalThis.localStorage||null}function Al(){let e=vr();for(let t of oo)try{t(e)}catch{}}function mm(){try{At()?.removeItem(un),At()?.removeItem(pn)}catch{}}function hm(e){return String(e||"").trim()||null}function Cl(e,t){if(!fn(t))return{};try{let s=JSON.parse(At()?.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)?(At()?.removeItem(e),{}):s.records}catch{try{At()?.removeItem(e)}catch{}return{}}}function xl(e,t,s){if(!fn(s))return!1;try{return At()?.setItem(e,JSON.stringify({ownerId:s.ownerId,records:t||{}})),!0}catch{return!1}}function lt(e){let t=hm(e);if(!t)return ao(),null;if(ss!==t){ss=t,hr+=1;for(let s of[un,pn])try{let n=JSON.parse(At()?.getItem(s)||"null");(!n||n.ownerId!==t)&&At()?.removeItem(s)}catch{try{At()?.removeItem(s)}catch{}}Al()}return vr()}function ao(){ss=null,hr+=1,mm(),Al()}function vr(){return ss?{ownerId:ss,epoch:hr}:null}function fn(e){return!!e&&!!ss&&e.ownerId===ss&&e.epoch===hr}function Tl(e){return{drafts:Cl(un,e),outbox:Cl(pn,e)}}function lo(e,t){return xl(un,e,t)}function gn(e,t){return xl(pn,e,t)}function Ml(e){return typeof e!="function"?()=>{}:(oo.add(e),()=>oo.delete(e))}var un,pn,ss,hr,oo,Zy,co=F(()=>{un="yeaft-work-center-composer-drafts-v1",pn="yeaft-work-center-message-outbox-v1",ss=null,hr=0,oo=new Set;Zy=Object.freeze({drafts:un,outbox:pn})});var vm,ym,_e,ct=F(()=>{mr();co();({defineStore:vm}=Pinia),ym=1800*1e3,_e=vm("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",lt(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?at(n.sessionKey):null,this.role=n.role||"pro",this.userId=n.userId||null,lt(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?at(r.sessionKey):null,this.role=r.role||"pro",this.userId=r.userId||null,lt(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?at(s.sessionKey):null,this.role=s.role||"pro",this.userId=s.userId||null,lt(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?at(s.sessionKey):null,this.role=s.role||"pro",this.userId=s.userId||null,lt(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?at(s.sessionKey):null,this.role=s.role||"pro",this.userId=s.userId||null,lt(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?at(n.sessionKey):null,this.role=n.role||"pro",this.userId=n.userId||null,lt(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?at(r):null,this.role=i||"pro",this.userId=o||null,lt(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");return i&&this.token===e&&(!o||o===e)&&(this.token=i,localStorage.setItem("authToken",i)),r?.role&&(this.role=r.role),this.userId=r?.userId||null,lt(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,ym),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{}this.clearStoredSession()},clearStoredSession(e=null){this.reset(),localStorage.removeItem("authToken"),e&&(this.error=e)},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,lt(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=at(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"}:(this.clearStoredSession(),{success:!0})}catch(s){return{success:!1,error:s.message||"Network error"}}},reset(){ao(),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 Ee(e,t){let s=xt?.value||"zh-CN",r=(Ps[s]||Ps["zh-CN"]||{})[e];if(r===void 0&&s!=="zh-CN"&&(r=(Ps["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 bm(){return xt?.value||"zh-CN"}function mn(e){Ps[e]&&(xt&&(xt.value=e),localStorage.setItem("locale",e),document.documentElement.setAttribute("lang",e))}function wm(){let e=localStorage.getItem("locale");return e&&Ps[e]?e:(navigator.language||navigator.userLanguage||"").startsWith("en")?"en":"zh-CN"}function Pl(e,t){return Ps=t,xt=Vue.ref(wm()),document.documentElement.setAttribute("lang",xt.value),e.config.globalProperties.$t=Ee,e.config.globalProperties.$locale=xt,e.provide("t",Ee),e.provide("locale",xt),{t:Ee,setLocale:mn,getLocale:bm,locale:xt}}var xt,Ps,Tt=F(()=>{xt=null,Ps={}});function yr(e){if(e==null||e==="")return"claude-code";if(km.has(e))return e;throw new Error(`Unknown Chat runtime provider: ${e}`)}function Rs(e){if(typeof e!="string"||!e)throw new Error("Chat catalog key requires conversationId");return`chat:${e}`}function br(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 uo(e,t){let s=e.sessionCatalog.map(n=>({...n}));return e.sessionCatalogMutationRequests[t]={previousCatalog:s},s}function Rl(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),!0):!1}function _l(e,t,s="recent",n=null){let r=Rs(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 El(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 km,po=F(()=>{km=new Set(["claude-code","copilot"])});function _s(e,t,s=""){hn&&(clearTimeout(hn),hn=null),e.sessionLoading=t,e.sessionLoadingText=s,t&&(hn=setTimeout(()=>{e.sessionLoading&&(e.sessionLoading=!1,e.sessionLoadingText=""),hn=null},Sm))}function gt(e){_s(e,!1)}function Dl(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:yr(t.provider),catalogKey:t.catalogKey||null},e.recoveryDismissed=!1)}}function Ll(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:yr(r)}),e.pendingRecovery=null,e.recoveryDismissed=!1},500)}function $l(e){e.recoveryDismissed=!0,e.pendingRecovery=null}function Vl(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]=[],_s(e,!0,Ee("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 Fl(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 Es(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=yr(t.provider),n={sessionId:t.claudeSessionId,workDir:t.workDir,agentId:t.agentId||e.currentAgent,provider:s,catalogKey:Rs(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 Ol(e){return e.lastUsedSession}function Hl(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 ql(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 Nl(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 Bl(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 Wl(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 jl(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 Ul(e,t=20){if(_e().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 zl(e,t){if(!_e().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 fo(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 Kl(e,t){let s=fo(e,t);return s&&s.online}var Sm,hn,ns=F(()=>{ct();Tt();po();Sm=3e4,hn=null});function Yl(e){return e?.code===1008&&String(e.reason||"").toLowerCase().includes("authentication")}function Gl(e){let t=vn;vn=[];for(let{resolve:s,reject:n,timer:r}of t)clearTimeout(r),e?s():n(new Error("WebSocket reconnect failed"))}function Ql(e,t){if(!e.ws||e.ws.readyState!==WebSocket.OPEN)return!1;if(e.currentView==="yeaft"&&Cm.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=kl(t,e.sessionKey);e.ws.send(JSON.stringify(s))}else e.ws.send(JSON.stringify(t));return!0}catch{return!1}}function yn(e,t=1e4){return e.ws&&e.ws.readyState===WebSocket.OPEN?Promise.resolve():new Promise((s,n)=>{let r=setTimeout(()=>{vn=vn.filter(i=>i.resolve!==s),n(new Error("WebSocket reconnect timeout"))},t);vn.push({resolve:s,reject:n,timer:r}),(!e.ws||e.ws.readyState!==WebSocket.CONNECTING)&&(e.reconnectAttempts=0,e.connect())})}function Xl(e,t){try{let s=JSON.parse(t);return e.sessionKey&&Il(s)?Sl(s,e.sessionKey):s}catch{return null}}function Zl(e){let t=_e(),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.yeaftSessionHydrateRequestId=null,e.yeaftSessionHydrateSlices=[],e.yeaftSessionHydrateError=null,e._yeaftSessionInventorySocketQuarantined=!1,e.pendingAgentSelection=null,e.agentSwitching=!1,e.ws&&(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,e.chatHistoryConnectionGeneration=Number(e.chatHistoryConnectionGeneration||0)+1;for(let[l,c]of Object.entries(e.projectMutationRequests||{}))c?.resolve?.({ok:!1,requestId:l,error:{code:"connection_changed"}});e.projectMutationRequests={},e.sessionProjects=[];for(let[l,c]of Object.entries(e.chatHistoryRequests||{}))c?.loading&&(e.chatHistoryRequests[l]={...c,loading:!1,cancelled:!0,error:"connection_changed"});let i=Object.values(e.sessionCatalogMutationRequests||{});i.length>0&&(e.sessionCatalog=i[0].previousCatalog,e.sessionCatalogMutationRequests={}),e.sessionCatalogLoaded=!1,e.sessionCatalog=[],e.activeCatalogKey=null,e._wsAuthToken=n,e._wsAuthGeneration=r;let o=`${s}//${location.host}?type=web`;n&&(o+=`&token=${encodeURIComponent(n)}`);let a=new WebSocket(o);e.ws=a,a.onopen=()=>{if(a===e.ws){e.connectionState="connected",e.reconnectAttempts=0,e.startHeartbeat();try{a.send(JSON.stringify({type:"client_hello",plaintextOk:!0}))}catch{}Gl(!0)}},a.onmessage=l=>{if(a!==e.ws)return;let c=e.parseWsMessage(l.data);c&&(c.type,e.handleMessage({...c,_wsAuthToken:n,_wsAuthGeneration:r}))},a.onclose=l=>{if(a!==e.ws){Yl(l)&&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.yeaftSessionHydrateRequestId=null,e.yeaftSessionHydrateSlices=[],e.yeaftSessionHydrateError=null,e.pendingAgentSelection=null,e.agentSwitching=!1;let c=e.connectionState==="updating";if(e.connectionState=c?"updating":"disconnected",e.stopHeartbeat(),gt(e),Yl(l)){t.handleAuthFailure?.(void 0,n,r),e.reconnectAttempts=0,Gl(!1);return}if(e._yeaftReconnectCatchUpPending=!0,c){e.reconnectAttempts=0,e.reconnectTimer=setTimeout(()=>{e.connect()},2e3);return}e.scheduleReconnect()},e.ws.onerror=l=>{}}function Jl(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 ec(e){e.reconnectAttempts=0,e.connect()}function tc(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 sc(e){e.heartbeatTimer&&(clearInterval(e.heartbeatTimer),e.heartbeatTimer=null)}function nc(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 vn,Cm,go=F(()=>{ct();mr();ns();vn=[];Cm=new Set(["sync_messages","refresh_conversation","select_conversation","cancel_execution","update_conversation_settings","ask_user_answer"])});function Tm(e){return e?.type==="tool-use"}function mo(e){return e?.type==="tool-summary"}function ho(e){return Tm(e)&&!xm.has(e.toolName)}function oc(e,t,s,n=s){let r=t==="history"&&(n?.dbMessageId||n?.id)||null;return{...r?{id:`tool_summary_${t}_${r}`,dbMessageId:n?.dbMessageId||null}:{},type:"tool-summary",count:e,omittedCount:e,source:t,isHistory:t!=="live",timestamp:s?.timestamp||s?.startTime||n?.timestamp||n?.startTime||null,sessionId:s?.sessionId??s?.groupId??null,turnId:s?.turnId||null,vpId:s?.vpId||null,speakerVpId:s?.speakerVpId||null}}function Mm(e,t){return!mo(e)||!mo(t)?!1:(e.turnId||null)===(t.turnId||null)&&(e.sessionId||null)===(t.sessionId||null)&&(e.speakerVpId||e.vpId||null)===(t.speakerVpId||t.vpId||null)&&(e.source||null)===(t.source||null)}function Pm(e,t){let s=(Number(e.count)||0)+(Number(t.count)||0);return e.count=s,e.omittedCount=s,!e.timestamp&&t.timestamp&&(e.timestamp=t.timestamp),Number(t.dbMessageId||0)>Number(e.dbMessageId||0)&&(e.dbMessageId=t.dbMessageId,t.id&&(e.id=t.id)),e}function rc(e){return[e?.sessionId||"",e?.turnId||"",e?.speakerVpId||e?.vpId||""].join("")}function ic(e,t,s,n,r=n){if(!t)return;let i=oc(t,s,n,r),o=e[e.length-1];Mm(o,i)?Pm(o,i):e.push(i)}function vo(e=[]){let t=[],s=0,n=null,r=null;for(let i of e){if(ho(i)&&i.isHistory){s+=1,n||(n=i),r=i;continue}ic(t,s,"history",n,r),s=0,n=null,r=null,t.push(i)}return ic(t,s,"history",n,r),t}function ac(e=[],t={}){let s=Number.isFinite(t.maxDetailed)?Math.max(1,t.maxDetailed):100;if(!Array.isArray(e)||e.length<=s)return e;let n=e.length;for(let p=e.length-1;p>=0;p-=1){let g=e[p];if(g?.type==="user"||g?.type==="system"||g?.type==="error")break;n=p}let r=e.slice(n),i=new Map;for(let p of r){if(!ho(p)||p.isHistory)continue;let g=rc(p);i.set(g,(i.get(g)||0)+1)}let o=new Map;for(let[p,g]of i)g>s&&o.set(p,g-s);if(o.size===0)return e;let a=new Map,l=new Map,c=new Set,d=[],u=(p,g,v)=>{a.set(p,(a.get(p)||0)+g),!l.has(p)&&v&&l.set(p,v)},f=(p,g)=>{if(c.has(p))return;let v=a.get(p)||0;v<=0||(d.push(oc(v,"live",l.get(p)||g)),c.add(p))};for(let p of r){let g=rc(p);if(mo(p)&&p.source==="live"&&o.has(g)){u(g,Number(p.count)||0,p);continue}if(ho(p)&&!p.isHistory&&o.has(g)){let v=o.get(g)||0;if(v>0){o.set(g,v-1),u(g,1,p);continue}}f(g,p),d.push(p)}for(let p of a.keys())f(p,l.get(p));return e.splice(n,e.length-n,...d),e}var xm,yo=F(()=>{xm=new Set(["TodoWrite","AskUserQuestion"])});function bo(e,t){return t?t===e.yeaftConversationId?!0:Object.values(e.yeaftConversationIdsByAgent||{}).includes(t):!1}function bn(e,t,s){s&&(s.type!=="assistant"&&s.type!=="tool-use"||bo(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 _m(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 wr(e){let t=e?.messageId??e?.dbMessageId??e?.id;return t==null||t===""?null:String(t)}function wo(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==="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 lc(e=[],t=[]){let s=[],n=new Map,r=new Map;for(let i of[...e,...t]){if(!i)continue;let o=wr(i),a=i.type==="user"&&i.clientMessageId?String(i.clientMessageId):null;if(o&&n.has(o)){wo(n.get(o),i);continue}if(a&&r.has(a)){let l=r.get(a);wo(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 cc(e,t,s){return!e||e!==t?!1:!s?.loaded&&!s?.loading}function dc(e,t){return!!t&&!!e?.loaded&&!e?.loading&&Number.isFinite(e?.latestSeq)}function ko({sessionState:e,hasCachedSessionRows:t,force:s=!1}={}){return e?.loading?!1:s?!e?.loaded:e?.loaded?!1:!t}function Em(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"&&wr(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,bn(e,t,o),!0):!1}function kr(e,t,s){if(!t)return;let n={...s,id:s.dbMessageId||s.id||Date.now().toString()+Math.random().toString(36).substr(2,9),timestamp:_m(s)};bo(e,t)&&!n.sessionId&&(n.sessionId=e._currentYeaftSessionId||e.yeaftActiveSessionFilter||Rm),bo(e,t)&&(!n.vpId&&e._currentYeaftVpId&&(n.vpId=e._currentYeaftVpId),!n.turnId&&e._currentYeaftTurnId&&(n.turnId=e._currentYeaftTurnId),bn(e,t,n)),e.messagesMap[t]||(e.messagesMap[t]=[]);let r=wr(s);if(r){let i=e.messagesMap[t].find(o=>wr(o)===r);if(i)return wo(i,n),t===e.yeaftConversationId&&e.messagesMap[t].sort((o,a)=>o.timestamp-a.timestamp),i}return e.messagesMap[t].push(n),ac(e.messagesMap[t]),t===e.yeaftConversationId&&e.messagesMap[t].sort((i,o)=>i.timestamp-o.timestamp),n}function uc(e,t,s,n={}){if(!t||!s)return;e.messagesMap[t]||(e.messagesMap[t]=[]);let r=e.messagesMap[t];if(Em(e,t,n,s))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(bn(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}kr(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(bn(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 kr(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 pc(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())),bn(e,t,o),o.type==="user")break}}function fc(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 gc(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 rs(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 mc(e){return{id:e.id,dbMessageId:e.id,timestamp:e.created_at}}function hc(e){return e?e.message_type==="tool_use"&&!Dm.has(e.tool_name)?{...mc(e),type:"tool-use",toolName:e.tool_name||"unknown",hasResult:!0,isHistory:!0,startTime:e.created_at||0}:So(e):null}function So(e){if(!e)return null;let t=mc(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 Rm,Dm,Ds=F(()=>{yo();Rm="grp_default";Dm=new Set(["TodoWrite","AskUserQuestion"])});function is(e,t){return e._closedAt?.[t]?Date.now()-e._closedAt[t]<3e4:!1}function Ls(e,t){Ae(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]){Ae(e,t);return}s()},3e4))},45e3);e._processingWatchdogs[t]=n}function Sr(e,t){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)?wn(e,t):Ls(e,t))}function Ae(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)}function vc(e,t){Ae(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 wn(e,t){Ae(e,t),e._processingWatchdogs||(e._processingWatchdogs={}),e._yeaftWatchdogConvs||(e._yeaftWatchdogConvs=new Set),e._yeaftWatchdogConvs.add(t),e._processingWatchdogs[t]=setTimeout(()=>{if(e.processingConversations[t]){delete e.processingConversations[t];let s=e.executionStatusMap[t];s&&(s.currentTool=null),e.finishStreamingForConversation(t)}delete e._processingWatchdogs[t]},15e4)}var jt=F(()=>{});function Io(e,t){return t&&Array.isArray(e?._yeaftRetiredConversationIdsByAgent?.[t])?e._yeaftRetiredConversationIdsByAgent[t]:[]}function $s(e,t,s){return!t||!s?!1:Io(e,t).includes(s)}function Co(e,t){let s=e?._yeaftRetiredConversationTargetsByAgent?.[t];return s&&typeof s=="object"?s:{}}function yc(e,t,s){if(!t||!s)return null;let n=Co(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 kn(e,t,s,n=null){if(!t||!s)return;let r=Io(e,t).filter(a=>a!==s).concat(s).slice(-8);e._yeaftRetiredConversationIdsByAgent={...e._yeaftRetiredConversationIdsByAgent||{},[t]:r};let i=Co(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 Ao(e,t,s){if(!t||!s||!e?._yeaftRetiredConversationIdsByAgent)return;let n=Io(e,t).filter(i=>i!==s);e._yeaftRetiredConversationIdsByAgent={...e._yeaftRetiredConversationIdsByAgent,[t]:n};let r={...Co(e,t)};delete r[s],e._yeaftRetiredConversationTargetsByAgent={...e._yeaftRetiredConversationTargetsByAgent||{},[t]:r}}var Ir=F(()=>{});function Vm(e,t,s){let n=e.messagesMap?.[t]||[],r=e.messagesMap?.[s]||[];e.messagesMap||(e.messagesMap={}),e.messagesMap[s]=lc(r,n).sort((i,o)=>(i.timestamp||0)-(o.timestamp||0))}function Fm(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 Cr(e,t){return!!e&&Object.prototype.hasOwnProperty.call(e,t)}function Vs(e,t,s,{removeSource:n}){Cr(e,t)&&(Cr(e,s)||(e[s]=n?e[t]:Fm(e[t])),n&&delete e[t])}function mt(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 Ar(e,t,s,n){return!t||!s||!n||s===n?!1:(e._yeaftPendingConversationPromotions={...e._yeaftPendingConversationPromotions||{},[t]:{sourceConversationId:s,targetConversationId:n}},!0)}function Sn(e,t,s=null){let n=mt(e,t,s);if(!n)return null;let r={...e._yeaftPendingConversationPromotions||{}};return delete r[t],e._yeaftPendingConversationPromotions=r,n}function In(e,t,s){let n=mt(e,t);return!n||!s||n.targetConversationId===s?null:(ht(e,n.targetConversationId,s,{removeSource:!0}),kn(e,t,n.targetConversationId,s),Ar(e,t,n.sourceConversationId,s),n)}function ht(e,t,s,{removeSource:n=!0}={}){if(!t||!s||t===s)return!1;Vm(e,t,s),Vs(e.processingConversations,t,s,{removeSource:n}),Vs(e.executionStatusMap,t,s,{removeSource:n}),Vs(e.refreshingSessionMap,t,s,{removeSource:n}),Vs(e._closedAt,t,s,{removeSource:n}),Vs(e._autoRefreshed,t,s,{removeSource:n}),Vs(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._processingWatchdogs?.[t];if(n&&i&&Ae(e,t),n&&e._pongTimeouts?.[t]&&(clearTimeout(e._pongTimeouts[t]),delete e._pongTimeouts[t]),n&&(i||r)&&!!e.processingConversations?.[s])if(e._processingWatchdogs?.[s])e._yeaftWatchdogConvs?.add(s);else{let a=Cr(e.sessionHealth,s),l=e.sessionHealth?.[s],c=Cr(e._autoRefreshed,s),d=e._autoRefreshed?.[s];wn(e,s),a&&(e.sessionHealth||(e.sessionHealth={}),e.sessionHealth[s]=l),c&&(e._autoRefreshed||(e._autoRefreshed={}),e._autoRefreshed[s]=d)}return n&&e.messagesMap&&delete e.messagesMap[t],!0}var xo=F(()=>{Ds();Ir();jt()});function xr(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 To=F(()=>{});function Mo(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}function Om(){return Date.now()}function Hm(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`pt_${crypto.randomUUID()}`:`pt_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,10)}`}function qm(e,t=160){return typeof e!="string"?e:e.length>t?`${e.slice(0,t)}...[truncated]`:e}function Nm(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"?qm(n):n);return t}function Cn(){return Hm()}function Ze(e,t={}){!e||!t.traceId||(Array.isArray(e._perfTraceQueue)||(e._perfTraceQueue=[]),e._perfTraceQueue.push({traceId:t.traceId,source:"web",phase:t.phase||"unknown",at:Om(),monotonicMs:Mo(),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:Nm(t.detail)}),e._perfTraceQueue.length>200&&e._perfTraceQueue.splice(0,e._perfTraceQueue.length-200),Bm(e))}function Bm(e){!e||e._perfTraceFlushTimer||(e._perfTraceFlushTimer=setTimeout(()=>Wm(e),250))}function Wm(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 Tr(e,t={}){if(typeof requestAnimationFrame!="function")return;let s=Mo();requestAnimationFrame(()=>{requestAnimationFrame(()=>{Ze(e,{...t,phase:t.phase||"render.next_paint",durationMs:Mo()-s})})})}var Po=F(()=>{});function Pe(e,t){let s=t==null?"__all__":String(t);return e?`${e}${s}`:s}var Mr=F(()=>{});function Ro(e){return typeof e=="string"&&e?e:null}function Fs(e,t){return e?.yeaftSessionHistoryState?.[t]||null}function An(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:Pe(s,t)}}function wc(e,{agentId:t,sessionId:s,mode:n="recent",preserveLoaded:r=!1,latestSeq:i=null}={}){if(!t||!s)return null;let o=Pe(t,s),a=Fs(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,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.count=0)),e.yeaftSessionHistoryState={...e.yeaftSessionHistoryState||{},[o]:d},xn(e),{sessionKey:o,requestId:c,generation:l,state:d}}function _o(e,t={}){let s=t.sessionId??t.groupId??null;if(!s)return!1;let n=t.agentId||e?.yeaftSessionAgentById?.[s]||null,r=Pe(n,s),i=Fs(e,r),o=Ro(t.requestId);if(!i)return o===null;let a=Ro(i.requestId);return o?o===a:a===null}function kc(e,t={},s={},n="chunk"){if(!_o(e,t))return null;let r=t.sessionId??t.groupId??null,i=t.agentId||e?.yeaftSessionAgentById?.[r]||null,o=Pe(i,r),a=Fs(e,o)||{},l=Ro(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},xn(e),d}function Sc(e,{agentId:t,sessionId:s,requestId:n,error:r="history_load_failed"}={}){if(!t||!s||!n)return!1;let i=Pe(t,s),o=Fs(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()}},xn(e),!0)}function xn(e){let{sessionKey:t}=An(e),s=t?Fs(e,t):null;return e.yeaftLoadingMoreHistory=!!s?.loading,e.yeaftHistoryLoadError=s?.error||null,e.yeaftHasMoreHistory=!!s?.hasMore,e.yeaftOldestLoadedSeq=Number.isFinite(s?.oldestSeq)?s.oldestSeq:null,s}function Eo(e){let{sessionKey:t}=An(e);return t?Fs(e,t):null}var bc,Do=F(()=>{Mr();bc=15e3});function xc(e){return e.filter(t=>!(t.type==="user"&&(!t.content||!t.content.trim())))}function Ic(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 jm(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 Um(e){return Array.isArray(e?.toolCalls)?e.toolCalls.filter(t=>t?.name!=="TodoWrite").length:Number(e?.toolSummaryCount||0)||0}function zm(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 Km(e,t){return e.speakerVpId||e.vpId||e.vp_id||e.authorVpId||e.authorVP||zm(t)}function Pr(e){return e&&(e.messageId||e.id)?e.messageId||e.id:null}function Ym(e){e.sort((t,s)=>(t.timestamp||0)-(s.timestamp||0))}function Gm(e,t){if(!e||!t||e.type!=="assistant"||t.type!=="assistant"||(e.sessionId??null)!==(t.sessionId??null))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||!(e.isStreaming||e.isHistory!==!0)||t._hasPersistedTurnId!==!0)return!1;let a=e.turnId||"",l=t.turnId||"";if(!a||!l||a!==l)return!1;let c=typeof e.content=="string"?e.content:"",d=typeof t.content=="string"?t.content:"";return!!c&&!!d&&(d.startsWith(c)||c.startsWith(d))}function Lo(e,t){let s=new Map,n=new Map;e.forEach((i,o)=>{let a=Pr(i);a&&s.set(a,o),i?.type==="user"&&i.clientMessageId&&n.set(i.clientMessageId,o)});let r=0;for(let i of t){let o=Pr(i),a=o&&s.has(o)?s.get(o):null;if(a===null&&i?.type==="user"&&i.clientMessageId&&n.has(i.clientMessageId)&&(a=n.get(i.clientMessageId)),a===null&&i?.type==="assistant"&&(a=e.findIndex(l=>Gm(l,i))),a!==null&&a>=0){let l=Pr(e[a]);e[a]={...e[a],...i},o&&s.set(o,a),l&&l!==o&&s.get(l)===a&&s.delete(l),i?.type==="user"&&i.clientMessageId&&n.set(i.clientMessageId,a)}else o&&s.set(o,e.length),i?.type==="user"&&i.clientMessageId&&n.set(i.clientMessageId,e.length),e.push(i),r+=1}return Ym(e),r}function Rr(e){return e?e.sessionId??e.groupId??null:null}function Qm(e){return!e||e.type!=="user"||!e.clientMessageId?!1:Pr(e)===e.clientMessageId}function Xm(e,t,s){let n=e.some(o=>o&&(s==null||Rr(o)===s));if(t.length===0&&n)return{insertedRows:0,preservedEmpty:!0};let r=t.reduce((o,a)=>Math.max(o,a?.timestamp||0),0),i=e.filter(o=>o?s!=null&&Rr(o)!==s||o.isStreaming||o.type==="tool-use"&&o.toolName==="AskUserQuestion"&&(o.askAnswered||o.askPending||o.askExpired)||Qm(o)?!0:r>0&&(o.timestamp||0)>r:!1);return e.splice(0,e.length,...i),Lo(e,t),{insertedRows:t.length,preservedEmpty:!1}}function Zm(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 Jm(e,t){let s=typeof e.yeaftConversationId=="string"?e.yeaftConversationId:"";return s.startsWith(`yeaft-local-${t}-`)||/^yeaft-local-\d/.test(s)?s:null}function eh(e,t,s,n){let r=t.agentId||s&&e.yeaftSessionAgentById?.[s]||null;if(!r||!n||e.currentView!=="yeaft")return;let i=An(e);if(i.sessionId!==(s||null)||i.agentId&&i.agentId!==r)return;let o=e.yeaftConversationId||null;if($s(e,r,n)){let d=e.yeaftConversationIdsByAgent?.[r]||null;d&&d!==n&&ht(e,n,d,{removeSource:n!==e.yeaftConversationId});return}let a=mt(e,r);a&&a.targetConversationId!==n&&In(e,r,n);let l=mt(e,r,n);if(l&&(ht(e,l.sourceConversationId,n,{removeSource:!0}),Sn(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=Jm(e,r);c&&(ht(e,c,n,{removeSource:!0}),e.yeaftConversationIdsByAgent={...e.yeaftConversationIdsByAgent||{},[r]:n},e.yeaftConversationId=n,e.activeConversations=[n])}function Ut(e,t){let s=e.messagesMap[t]||[];for(let n of s)n.type==="tool-use"&&!n.hasResult&&(n.hasResult=!0,n.toolName==="AskUserQuestion"&&!n.askAnswered&&!n.selectedAnswers&&(n.isHistory=!0,n.askRequestId=null))}function Tc(e,t){gt(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:Ee("store.convCreated",{agent:s?.name||t.agentId,workDir:t.workDir})}),e.saveOpenSessions()}function Mc(e,t){gt(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)),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:Ee("store.convResumed",{agent:s?.name||t.agentId,sessionId:t.claudeSessionId?t.claudeSessionId.slice(0,8)+"...":""})}),t.dbMessages&&t.dbMessages.length>0){let n=xc(t.dbMessages.map(o=>e.formatDbMessageForHistoryHydration(o)).flat().filter(Boolean)),r=vo(n),i=e.messagesMap[t.conversationId]||[];for(let o of r)i.push(o)}e.hasMoreMessages=!!t.hasMoreMessages,e.chatSessionState[t.conversationId]={lastSeenDbId:rs(e.messagesMap[t.conversationId]),hasMoreOlder:!!t.hasMoreMessages},e.saveOpenSessions()}function $o(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],Ae(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:Ee("chat.session.closed")}));for(let n of e.panels)n.conversationId===t.conversationId&&(n.conversationId=null);e.saveOpenSessions()}function Pc(e,t){let s=t.conversationId;if(s){delete e.processingConversations[s],Ae(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),Ut(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 Rc(e,t){let s=t.conversationId;if(s){delete e.processingConversations[s],Ae(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),Ut(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 _c(e,t){if(t.conversationId){if(t.isProcessing&&!is(e,t.conversationId)&&!e._turnCompletedConvs?.has(t.conversationId))e.processingConversations[t.conversationId]=!0;else if(e.processingConversations[t.conversationId]){delete e.processingConversations[t.conversationId],Ae(e,t.conversationId);let s=e.executionStatusMap[t.conversationId];s&&(s.currentTool=null),e.finishStreamingForConversation(t.conversationId)}}}function Ec(e,t){let s=t.conversationId||e.currentConversation;if(s){delete e.processingConversations[s],Ae(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),Ut(e,s)}}function Dc(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=vo(xc((t.messages||[]).map(a=>e.formatDbMessageForHistoryHydration(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&&xr(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),gt(e);let o=e.chatSessionState[t.conversationId]?.hasMoreOlder;e.chatSessionState[t.conversationId]={lastSeenDbId:rs(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 Lc(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{formatted:i}=$c(t.messages,s,"window",e.messagesMap[r]);return Lo(e.messagesMap[r],i),r}function Cc(e){return e?.toolId?[Rr(e)??"",e.vpId||e.speakerVpId||"",e.turnId||"",e.threadId||"main",e.toolId].join("\0"):null}function Ac(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.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 th(e,t){return(e||[]).find(s=>s?.type==="tool-use"&&(s.toolName==="AskUser"||s.toolName==="AskUserQuestion")&&s.toolId===t.toolCallId&&Rr(s)===t.sessionId&&(s.vpId||s.speakerVpId||"")===(t.vpId||"")&&(s.turnId||"")===(t.turnId||"")&&(s.threadId||"main")===(t.threadId||"main"))||null}function $c(e,t,s,n){let r=new Set((n||[]).map(l=>l&&(l.messageId||l.id)).filter(Boolean)),i=new Set,o=[],a=0;for(let l of e){if(!l||l._reflection||l.internal||l.systemOnly||l.systemOnlyMessage||Zm(l.content))continue;let c=l.id||l.messageId||null,d=l.clientMessageId||null;if(!(c&&i.has(c))&&!(c&&s!=="recent"&&r.has(c))){if(c&&i.add(c),l.role==="user"){a+=1;let u=c||l.messageId||l.turnId||null,f=l.sessionId??l.groupId??t??null;o.push({...c?{id:c,messageId:c}:{},type:"user",content:l.content,timestamp:Ic(l),sessionId:f,turnId:l.turnId||u,...d?{clientMessageId:d}:{},...Array.isArray(l.attachments)&&l.attachments.length>0?{attachments:l.attachments}:{},...l.quote?{quote:l.quote}:{},isStreaming:!1})}else if(l.role==="assistant"){a+=1;let u=c||l.messageId||l.turnId||null,f=l.sessionId??l.groupId??t??null,p=Km(l,f),g=Ic(l),v=!!l.turnId,h=l.turnId||u,A=typeof l.content=="string"?l.content:l.content||"",w=Array.isArray(l.todos)?l.todos:jm(l.toolCalls);(typeof A!="string"||A.trim())&&o.push({...c?{id:c,messageId:c}:{},type:"assistant",content:A,timestamp:g,sessionId:f,turnId:h,_hasPersistedTurnId:v,...p?{vpId:p,speakerVpId:p}:{},...l.responseKind==="progress"||l.responseKind==="result"?{responseKind:l.responseKind}:{},...l.incomplete===!0?{incomplete:!0}:{},...typeof l.stopReason=="string"&&l.stopReason?{stopReason:l.stopReason}:{},isStreaming:!1,isHistory:!0}),Array.isArray(w)&&w.length>0&&o.push({...c?{id:`${c}:todos`,messageId:`${c}:todos`}:{},type:"tool-use",toolName:"TodoWrite",toolInput:{todos:w},timestamp:g,sessionId:f,turnId:h,...p?{vpId:p,speakerVpId:p}:{},isStreaming:!1,isHistory:!0,hasResult:!0});for(let y of Array.isArray(l.images)?l.images:[])y?.assetId&&o.push({id:`${c||u||h}:image:${y.assetId}`,messageId:`${c||u||h}:image:${y.assetId}`,type:"chat-image",...y,timestamp:g,sessionId:f,turnId:h,...p?{vpId:p,speakerVpId:p}:{},isStreaming:!1,isHistory:!0});for(let y of Array.isArray(l.askUserResults)?l.askUserResults:[]){if(!y?.toolCallId||y.status!=="answered"&&y.status!=="expired")continue;let m=[{question:typeof y.question=="string"?y.question:"",options:(Array.isArray(y.options)?y.options:[]).filter($=>typeof $=="string").map($=>({label:$,description:""})),multiSelect:!1}],b={toolCallId:y.toolCallId,sessionId:f,vpId:p||"",turnId:h||"",threadId:l.threadId||"main"},T=th(n,b);if(T){Ac(T,y,m);continue}let L=Ac({id:`${c||u||h}:ask:${y.toolCallId}`,messageId:`${c||u||h}:ask:${y.toolCallId}`,type:"tool-use",timestamp:g,sessionId:f,turnId:h,threadId:b.threadId,...p?{vpId:p,speakerVpId:p}:{},isStreaming:!1},y,m),N=Cc(L);(!N||!o.some($=>Cc($)===N))&&o.push(L)}let k=Um(l);k>0&&o.push({...c?{id:`${c}:tool-summary`,messageId:`${c}:tool-summary`,persistedMessageId:c}:{},type:"tool-summary",count:k,omittedCount:k,source:"history",timestamp:g,sessionId:f,turnId:h,...p?{vpId:p,speakerVpId:p}:{},isStreaming:!1,isHistory:!0})}}}return{formatted:o,acceptedHistoryMessages:a}}function Vc(e,t){let s=t.sessionId!=null?t.sessionId:t.groupId,n=t.agentId||s&&e.yeaftSessionAgentById?.[s]||null;if($s(e,n,t.conversationId)){let b=e.yeaftConversationIdsByAgent?.[n]||null;if(!b||b===t.conversationId)return;ht(e,t.conversationId,b,{removeSource:t.conversationId!==e.yeaftConversationId}),t={...t,conversationId:b}}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:[];t.perfTraceId&&Ze(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 o=t.agentId||(s&&e.yeaftSessionAgentById?e.yeaftSessionAgentById[s]:null),a=o&&e.yeaftConversationIdsByAgent?e.yeaftConversationIdsByAgent[o]:null,l=t.conversationId||a||e.yeaftConversationId;if(!l){e.yeaftLoadingMoreHistory=!1;return}eh(e,t,s,l),e.messagesMap[l]||(e.messagesMap[l]=[]);let{formatted:c,acceptedHistoryMessages:d}=$c(i,s,r,e.messagesMap[l]),u=0,f=!1;if(r==="recent"){let b=Xm(e.messagesMap[l],c,s??null);u=b.insertedRows,f=b.preservedEmpty}else if(c.length>0)if(r==="older"){if(e.messagesMap[l].splice(0,0,...c),u=c.length,typeof e.expandYeaftMessageWindow=="function"){let b=e.yeaftActiveSessionFilter?s??null:null;e.expandYeaftMessageWindow(b,t.turns||10)}}else u=Lo(e.messagesMap[l],c);let p=Pe(t.agentId||null,s),g=e.yeaftSessionHistoryState?.[p]||{},v=typeof t.latestSeq=="number"?t.latestSeq:g.latestSeq??null,h=r==="delta"?{...g,loaded:!0,loading:!1,latestSeq:v,syncingAfterSeq:null,count:(g.count||0)+u}:{...f?g:{},loaded:!0,loading:!1,hasMore:f?!!g.hasMore:!!t.hasMore,oldestSeq:f?Number.isFinite(g.oldestSeq)?g.oldestSeq:e.yeaftOldestLoadedSeq:typeof t.oldestSeq=="number"?t.oldestSeq:e.yeaftOldestLoadedSeq,count:r==="older"?(g.count||0)+u:f?g.count||0:d,latestSeq:f&&!Number.isFinite(t.latestSeq)?g.latestSeq??null:v,syncingAfterSeq:null};t.requestId&&typeof e.finishYeaftHistoryLoad=="function"?e.finishYeaftHistoryLoad(t,h,"chunk"):e.yeaftSessionHistoryState&&(e.yeaftSessionHistoryState={...e.yeaftSessionHistoryState,[p]:h});let A=An(e),w=A.sessionId===(s||null),k=!t.agentId||!A.agentId||t.agentId===A.agentId,y=w&&k,m=Pe(null,A.sessionId);if(t.perfTraceId&&(Ze(e,{traceId:t.perfTraceId,phase:"history.chunk_applied",agentId:t.agentId||null,sessionId:s||null,messageType:t.type,detail:{mode:r,formattedCount:c.length,insertedRows:u,acceptedHistoryMessages:d,preservedEmptyRecent:f}}),Tr(e,{traceId:t.perfTraceId,phase:"history.next_paint",agentId:t.agentId||null,sessionId:s||null,messageType:t.type,detail:{mode:r,insertedRows:u}})),y)e.yeaftHasMoreHistory=h.hasMore,typeof t.oldestSeq=="number"&&(e.yeaftOldestLoadedSeq=t.oldestSeq),e.yeaftLoadingMoreHistory=!1;else if(e.yeaftLoadingMoreHistory){let b=e.yeaftSessionHistoryState?.[A.sessionKey]||e.yeaftSessionHistoryState?.[m]||null;e.yeaftLoadingMoreHistory=!!b?.loading}}var _r=F(()=>{jt();xo();Ir();ns();To();Ds();yo();Tt();Po();Do();Mr()});function Fc(e,t){if(e.promoteYeaftHistoryOutlineRow?.(t))return;let s=t?.sessionId??t?.groupId??e._currentYeaftSessionId??null;s&&e.invalidateYeaftHistoryOutline?.(s)}function sh(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 Vo(e,t){return e.executionStatusMap[t]||(e.executionStatusMap[t]={currentTool:null,toolHistory:[],lastActivity:null}),e.executionStatusMap[t]}function Oc(e,t,s){if(!t)return;let n=Vo(e,t);if(n.lastActivity=Date.now(),Sr(e,t),s.type==="system"){if(s.subtype==="init"){let r=e.conversations.find(i=>i.id===t);r&&r.connecting&&(r.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 r=s.message?.content;if(!r)return;let i=e.messagesMap[t]||[];for(let o of i)o.type==="tool-use"&&!o.hasResult&&(o.hasResult=!0);for(let o of n.toolHistory)o.status==="running"&&(o.status="done");if(n.currentTool=null,typeof r=="string"){e.appendToAssistantMessageForConversation(t,r,{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(r))return;if(r.length===0){e.finishStreamingForConversation(t);return}for(let o of r)o.type==="text"?e.appendToAssistantMessageForConversation(t,o.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}):o.type==="image_asset"&&o.image?e.addMessageToConversation(t,{type:"chat-image",...o.image,sessionId:e._currentYeaftSessionId||null,vpId:e._currentYeaftVpId||null,speakerVpId:e._currentYeaftVpId||null,turnId:e._currentYeaftTurnId||null,threadId:e._currentYeaftThreadId||null}):o.type==="tool_summary"?e.addMessageToConversation(t,{type:"tool-summary",count:Number(o.count||o.omittedCount||0)||0,omittedCount:Number(o.omittedCount||o.count||0)||0,source:o.source||"history",isHistory:o.source!=="live",sessionId:e._currentYeaftSessionId||null,vpId:e._currentYeaftVpId||null,turnId:e._currentYeaftTurnId||null,threadId:e._currentYeaftThreadId||null}):o.type==="tool_use"&&(e.finishStreamingForConversation(t,{completeLifecycle:!1}),n.currentTool={name:o.name,input:o.input,startTime:Date.now()},n.toolHistory.unshift({name:o.name,input:o.input,timestamp:Date.now(),status:"running"}),n.toolHistory.length>20&&n.toolHistory.pop(),e.addMessageToConversation(t,{type:"tool-use",toolId:o.id||o.tool_use_id||null,toolName:o.name,toolInput:o.input,startTime:Date.now(),sessionId:e._currentYeaftSessionId||null,vpId:e._currentYeaftVpId||null,turnId:e._currentYeaftTurnId||null,threadId:e._currentYeaftThreadId||null}))}else if(s.type==="user"){let r=s.internal===!0||s.message?.internal===!0||s.userAuthored===!1||s.message?.userAuthored===!1,i=s.message?.content,o=sh(i);if(typeof o=="string"&&(o.includes("<local-command-caveat>")||o.includes("<command-name>")))return;if(typeof o=="string"&&o.includes("<local-command-stdout>")){let l=o.match(/<local-command-stdout>([\s\S]*?)<\/local-command-stdout>/);if(l){e.appendToAssistantMessageForConversation(t,l[1].trim()),e.finishStreamingForConversation(t);return}}let a=[];if(s.tool_use_result)a=Array.isArray(s.tool_use_result)?s.tool_use_result:[s.tool_use_result];else if(s.message?.content){let l=s.message.content;a=(Array.isArray(l)?l:[]).filter(d=>d.type==="tool_result")}if(a.length>0){let l=e.messagesMap[t]||[];for(let c of a){if(n.toolHistory.length>0){let p=n.toolHistory.findIndex(g=>g.status==="running");p>=0&&(n.toolHistory[p].status="done")}let d=c.tool_use_id||c.toolUseId||c.tool_call_id||c.toolCallId||null,u=c.content||c,f=!1;if(d){for(let p=l.length-1;p>=0;p--)if(l[p].type==="tool-use"&&l[p].toolId===d){l[p].hasResult=!0,l[p].toolResult=c.is_update&&l[p].toolResult?`${l[p].toolResult}
|
|
1
|
+
var F=(e,t,s)=>()=>{if(s)throw s[0];try{return e&&(t=e(e=0)),t}catch(n){throw s=[n],n}};var gm=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(s){throw t=0,s}};function kl(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 Sl(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 Il(e){return e&&typeof e=="object"&&typeof e.n=="string"&&typeof e.c=="string"}function at(e){return nacl.util.decodeBase64(e)}var mr=F(()=>{});function At(){return globalThis.localStorage||null}function Al(){let e=vr();for(let t of oo)try{t(e)}catch{}}function mm(){try{At()?.removeItem(un),At()?.removeItem(pn)}catch{}}function hm(e){return String(e||"").trim()||null}function Cl(e,t){if(!fn(t))return{};try{let s=JSON.parse(At()?.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)?(At()?.removeItem(e),{}):s.records}catch{try{At()?.removeItem(e)}catch{}return{}}}function xl(e,t,s){if(!fn(s))return!1;try{return At()?.setItem(e,JSON.stringify({ownerId:s.ownerId,records:t||{}})),!0}catch{return!1}}function lt(e){let t=hm(e);if(!t)return ao(),null;if(ss!==t){ss=t,hr+=1;for(let s of[un,pn])try{let n=JSON.parse(At()?.getItem(s)||"null");(!n||n.ownerId!==t)&&At()?.removeItem(s)}catch{try{At()?.removeItem(s)}catch{}}Al()}return vr()}function ao(){ss=null,hr+=1,mm(),Al()}function vr(){return ss?{ownerId:ss,epoch:hr}:null}function fn(e){return!!e&&!!ss&&e.ownerId===ss&&e.epoch===hr}function Tl(e){return{drafts:Cl(un,e),outbox:Cl(pn,e)}}function lo(e,t){return xl(un,e,t)}function gn(e,t){return xl(pn,e,t)}function Ml(e){return typeof e!="function"?()=>{}:(oo.add(e),()=>oo.delete(e))}var un,pn,ss,hr,oo,Zy,co=F(()=>{un="yeaft-work-center-composer-drafts-v1",pn="yeaft-work-center-message-outbox-v1",ss=null,hr=0,oo=new Set;Zy=Object.freeze({drafts:un,outbox:pn})});var vm,ym,_e,ct=F(()=>{mr();co();({defineStore:vm}=Pinia),ym=1800*1e3,_e=vm("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",lt(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?at(n.sessionKey):null,this.role=n.role||"pro",this.userId=n.userId||null,lt(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?at(r.sessionKey):null,this.role=r.role||"pro",this.userId=r.userId||null,lt(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?at(s.sessionKey):null,this.role=s.role||"pro",this.userId=s.userId||null,lt(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?at(s.sessionKey):null,this.role=s.role||"pro",this.userId=s.userId||null,lt(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?at(s.sessionKey):null,this.role=s.role||"pro",this.userId=s.userId||null,lt(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?at(n.sessionKey):null,this.role=n.role||"pro",this.userId=n.userId||null,lt(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?at(r):null,this.role=i||"pro",this.userId=o||null,lt(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");return i&&this.token===e&&(!o||o===e)&&(this.token=i,localStorage.setItem("authToken",i)),r?.role&&(this.role=r.role),this.userId=r?.userId||null,lt(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,ym),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{}this.clearStoredSession()},clearStoredSession(e=null){this.reset(),localStorage.removeItem("authToken"),e&&(this.error=e)},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,lt(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=at(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"}:(this.clearStoredSession(),{success:!0})}catch(s){return{success:!1,error:s.message||"Network error"}}},reset(){ao(),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 Ee(e,t){let s=xt?.value||"zh-CN",r=(Ps[s]||Ps["zh-CN"]||{})[e];if(r===void 0&&s!=="zh-CN"&&(r=(Ps["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 bm(){return xt?.value||"zh-CN"}function mn(e){Ps[e]&&(xt&&(xt.value=e),localStorage.setItem("locale",e),document.documentElement.setAttribute("lang",e))}function wm(){let e=localStorage.getItem("locale");return e&&Ps[e]?e:(navigator.language||navigator.userLanguage||"").startsWith("en")?"en":"zh-CN"}function Pl(e,t){return Ps=t,xt=Vue.ref(wm()),document.documentElement.setAttribute("lang",xt.value),e.config.globalProperties.$t=Ee,e.config.globalProperties.$locale=xt,e.provide("t",Ee),e.provide("locale",xt),{t:Ee,setLocale:mn,getLocale:bm,locale:xt}}var xt,Ps,Tt=F(()=>{xt=null,Ps={}});function yr(e){if(e==null||e==="")return"claude-code";if(km.has(e))return e;throw new Error(`Unknown Chat runtime provider: ${e}`)}function Rs(e){if(typeof e!="string"||!e)throw new Error("Chat catalog key requires conversationId");return`chat:${e}`}function br(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 uo(e,t){let s=e.sessionCatalog.map(n=>({...n}));return e.sessionCatalogMutationRequests[t]={previousCatalog:s},s}function Rl(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),!0):!1}function _l(e,t,s="recent",n=null){let r=Rs(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 El(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 km,po=F(()=>{km=new Set(["claude-code","copilot"])});function _s(e,t,s=""){hn&&(clearTimeout(hn),hn=null),e.sessionLoading=t,e.sessionLoadingText=s,t&&(hn=setTimeout(()=>{e.sessionLoading&&(e.sessionLoading=!1,e.sessionLoadingText=""),hn=null},Sm))}function gt(e){_s(e,!1)}function Dl(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:yr(t.provider),catalogKey:t.catalogKey||null},e.recoveryDismissed=!1)}}function Ll(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:yr(r)}),e.pendingRecovery=null,e.recoveryDismissed=!1},500)}function $l(e){e.recoveryDismissed=!0,e.pendingRecovery=null}function Vl(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]=[],_s(e,!0,Ee("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 Fl(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 Es(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=yr(t.provider),n={sessionId:t.claudeSessionId,workDir:t.workDir,agentId:t.agentId||e.currentAgent,provider:s,catalogKey:Rs(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 Ol(e){return e.lastUsedSession}function Hl(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 ql(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 Nl(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 Bl(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 Wl(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 jl(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 Ul(e,t=20){if(_e().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 zl(e,t){if(!_e().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 fo(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 Kl(e,t){let s=fo(e,t);return s&&s.online}var Sm,hn,ns=F(()=>{ct();Tt();po();Sm=3e4,hn=null});function Yl(e){return e?.code===1008&&String(e.reason||"").toLowerCase().includes("authentication")}function Gl(e){let t=vn;vn=[];for(let{resolve:s,reject:n,timer:r}of t)clearTimeout(r),e?s():n(new Error("WebSocket reconnect failed"))}function Ql(e,t){if(!e.ws||e.ws.readyState!==WebSocket.OPEN)return!1;if(e.currentView==="yeaft"&&Cm.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=kl(t,e.sessionKey);e.ws.send(JSON.stringify(s))}else e.ws.send(JSON.stringify(t));return!0}catch{return!1}}function yn(e,t=1e4){return e.ws&&e.ws.readyState===WebSocket.OPEN?Promise.resolve():new Promise((s,n)=>{let r=setTimeout(()=>{vn=vn.filter(i=>i.resolve!==s),n(new Error("WebSocket reconnect timeout"))},t);vn.push({resolve:s,reject:n,timer:r}),(!e.ws||e.ws.readyState!==WebSocket.CONNECTING)&&(e.reconnectAttempts=0,e.connect())})}function Xl(e,t){try{let s=JSON.parse(t);return e.sessionKey&&Il(s)?Sl(s,e.sessionKey):s}catch{return null}}function Zl(e){let t=_e(),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.yeaftSessionHydrateRequestId=null,e.yeaftSessionHydrateSlices=[],e.yeaftSessionHydrateError=null,e._yeaftSessionInventorySocketQuarantined=!1,e.pendingAgentSelection=null,e.agentSwitching=!1,e.ws&&(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,e.chatHistoryConnectionGeneration=Number(e.chatHistoryConnectionGeneration||0)+1;for(let[l,c]of Object.entries(e.projectMutationRequests||{}))c?.resolve?.({ok:!1,requestId:l,error:{code:"connection_changed"}});e.projectMutationRequests={},e.sessionProjects=[];for(let[l,c]of Object.entries(e.chatHistoryRequests||{}))c?.loading&&(e.chatHistoryRequests[l]={...c,loading:!1,cancelled:!0,error:"connection_changed"});let i=Object.values(e.sessionCatalogMutationRequests||{});i.length>0&&(e.sessionCatalog=i[0].previousCatalog,e.sessionCatalogMutationRequests={}),e.sessionCatalogLoaded=!1,e.sessionCatalog=[],e.activeCatalogKey=null,e._wsAuthToken=n,e._wsAuthGeneration=r;let o=`${s}//${location.host}?type=web`;n&&(o+=`&token=${encodeURIComponent(n)}`);let a=new WebSocket(o);e.ws=a,a.onopen=()=>{if(a===e.ws){e.connectionState="connected",e.reconnectAttempts=0,e.startHeartbeat();try{a.send(JSON.stringify({type:"client_hello",plaintextOk:!0}))}catch{}Gl(!0)}},a.onmessage=l=>{if(a!==e.ws)return;let c=e.parseWsMessage(l.data);c&&(c.type,e.handleMessage({...c,_wsAuthToken:n,_wsAuthGeneration:r}))},a.onclose=l=>{if(a!==e.ws){Yl(l)&&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.yeaftSessionHydrateRequestId=null,e.yeaftSessionHydrateSlices=[],e.yeaftSessionHydrateError=null,e.pendingAgentSelection=null,e.agentSwitching=!1;let c=e.connectionState==="updating";if(e.connectionState=c?"updating":"disconnected",e.stopHeartbeat(),gt(e),Yl(l)){t.handleAuthFailure?.(void 0,n,r),e.reconnectAttempts=0,Gl(!1);return}if(e._yeaftReconnectCatchUpPending=!0,c){e.reconnectAttempts=0,e.reconnectTimer=setTimeout(()=>{e.connect()},2e3);return}e.scheduleReconnect()},e.ws.onerror=l=>{}}function Jl(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 ec(e){e.reconnectAttempts=0,e.connect()}function tc(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 sc(e){e.heartbeatTimer&&(clearInterval(e.heartbeatTimer),e.heartbeatTimer=null)}function nc(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 vn,Cm,go=F(()=>{ct();mr();ns();vn=[];Cm=new Set(["sync_messages","refresh_conversation","select_conversation","cancel_execution","update_conversation_settings","ask_user_answer"])});function Tm(e){return e?.type==="tool-use"}function mo(e){return e?.type==="tool-summary"}function ho(e){return Tm(e)&&!xm.has(e.toolName)}function oc(e,t,s,n=s){let r=t==="history"&&(n?.dbMessageId||n?.id)||null;return{...r?{id:`tool_summary_${t}_${r}`,dbMessageId:n?.dbMessageId||null}:{},type:"tool-summary",count:e,omittedCount:e,source:t,isHistory:t!=="live",timestamp:s?.timestamp||s?.startTime||n?.timestamp||n?.startTime||null,sessionId:s?.sessionId??s?.groupId??null,turnId:s?.turnId||null,vpId:s?.vpId||null,speakerVpId:s?.speakerVpId||null}}function Mm(e,t){return!mo(e)||!mo(t)?!1:(e.turnId||null)===(t.turnId||null)&&(e.sessionId||null)===(t.sessionId||null)&&(e.speakerVpId||e.vpId||null)===(t.speakerVpId||t.vpId||null)&&(e.source||null)===(t.source||null)}function Pm(e,t){let s=(Number(e.count)||0)+(Number(t.count)||0);return e.count=s,e.omittedCount=s,!e.timestamp&&t.timestamp&&(e.timestamp=t.timestamp),Number(t.dbMessageId||0)>Number(e.dbMessageId||0)&&(e.dbMessageId=t.dbMessageId,t.id&&(e.id=t.id)),e}function rc(e){return[e?.sessionId||"",e?.turnId||"",e?.speakerVpId||e?.vpId||""].join("")}function ic(e,t,s,n,r=n){if(!t)return;let i=oc(t,s,n,r),o=e[e.length-1];Mm(o,i)?Pm(o,i):e.push(i)}function vo(e=[]){let t=[],s=0,n=null,r=null;for(let i of e){if(ho(i)&&i.isHistory){s+=1,n||(n=i),r=i;continue}ic(t,s,"history",n,r),s=0,n=null,r=null,t.push(i)}return ic(t,s,"history",n,r),t}function ac(e=[],t={}){let s=Number.isFinite(t.maxDetailed)?Math.max(1,t.maxDetailed):100;if(!Array.isArray(e)||e.length<=s)return e;let n=e.length;for(let p=e.length-1;p>=0;p-=1){let g=e[p];if(g?.type==="user"||g?.type==="system"||g?.type==="error")break;n=p}let r=e.slice(n),i=new Map;for(let p of r){if(!ho(p)||p.isHistory)continue;let g=rc(p);i.set(g,(i.get(g)||0)+1)}let o=new Map;for(let[p,g]of i)g>s&&o.set(p,g-s);if(o.size===0)return e;let a=new Map,l=new Map,c=new Set,d=[],u=(p,g,h)=>{a.set(p,(a.get(p)||0)+g),!l.has(p)&&h&&l.set(p,h)},f=(p,g)=>{if(c.has(p))return;let h=a.get(p)||0;h<=0||(d.push(oc(h,"live",l.get(p)||g)),c.add(p))};for(let p of r){let g=rc(p);if(mo(p)&&p.source==="live"&&o.has(g)){u(g,Number(p.count)||0,p);continue}if(ho(p)&&!p.isHistory&&o.has(g)){let h=o.get(g)||0;if(h>0){o.set(g,h-1),u(g,1,p);continue}}f(g,p),d.push(p)}for(let p of a.keys())f(p,l.get(p));return e.splice(n,e.length-n,...d),e}var xm,yo=F(()=>{xm=new Set(["TodoWrite","AskUserQuestion"])});function bo(e,t){return t?t===e.yeaftConversationId?!0:Object.values(e.yeaftConversationIdsByAgent||{}).includes(t):!1}function bn(e,t,s){s&&(s.type!=="assistant"&&s.type!=="tool-use"||bo(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 _m(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 wr(e){let t=e?.messageId??e?.dbMessageId??e?.id;return t==null||t===""?null:String(t)}function wo(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==="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 lc(e=[],t=[]){let s=[],n=new Map,r=new Map;for(let i of[...e,...t]){if(!i)continue;let o=wr(i),a=i.type==="user"&&i.clientMessageId?String(i.clientMessageId):null;if(o&&n.has(o)){wo(n.get(o),i);continue}if(a&&r.has(a)){let l=r.get(a);wo(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 cc(e,t,s){return!e||e!==t?!1:!s?.loaded&&!s?.loading}function dc(e,t){return!!t&&!!e?.loaded&&!e?.loading&&Number.isFinite(e?.latestSeq)}function ko({sessionState:e,hasCachedSessionRows:t,force:s=!1}={}){return e?.loading?!1:s?!e?.loaded:e?.loaded?!1:!t}function Em(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"&&wr(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,bn(e,t,o),!0):!1}function kr(e,t,s){if(!t)return;let n={...s,id:s.dbMessageId||s.id||Date.now().toString()+Math.random().toString(36).substr(2,9),timestamp:_m(s)};bo(e,t)&&!n.sessionId&&(n.sessionId=e._currentYeaftSessionId||e.yeaftActiveSessionFilter||Rm),bo(e,t)&&(!n.vpId&&e._currentYeaftVpId&&(n.vpId=e._currentYeaftVpId),!n.turnId&&e._currentYeaftTurnId&&(n.turnId=e._currentYeaftTurnId),bn(e,t,n)),e.messagesMap[t]||(e.messagesMap[t]=[]);let r=wr(s);if(r){let i=e.messagesMap[t].find(o=>wr(o)===r);if(i)return wo(i,n),t===e.yeaftConversationId&&e.messagesMap[t].sort((o,a)=>o.timestamp-a.timestamp),i}return e.messagesMap[t].push(n),ac(e.messagesMap[t]),t===e.yeaftConversationId&&e.messagesMap[t].sort((i,o)=>i.timestamp-o.timestamp),n}function uc(e,t,s,n={}){if(!t||!s)return;e.messagesMap[t]||(e.messagesMap[t]=[]);let r=e.messagesMap[t];if(Em(e,t,n,s))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(bn(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}kr(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(bn(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 kr(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 pc(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())),bn(e,t,o),o.type==="user")break}}function fc(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 gc(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 rs(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 mc(e){return{id:e.id,dbMessageId:e.id,timestamp:e.created_at}}function hc(e){return e?e.message_type==="tool_use"&&!Dm.has(e.tool_name)?{...mc(e),type:"tool-use",toolName:e.tool_name||"unknown",hasResult:!0,isHistory:!0,startTime:e.created_at||0}:So(e):null}function So(e){if(!e)return null;let t=mc(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 Rm,Dm,Ds=F(()=>{yo();Rm="grp_default";Dm=new Set(["TodoWrite","AskUserQuestion"])});function is(e,t){return e._closedAt?.[t]?Date.now()-e._closedAt[t]<3e4:!1}function Ls(e,t){Ae(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]){Ae(e,t);return}s()},3e4))},45e3);e._processingWatchdogs[t]=n}function Sr(e,t){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)?wn(e,t):Ls(e,t))}function Ae(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)}function vc(e,t){Ae(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 wn(e,t){Ae(e,t),e._processingWatchdogs||(e._processingWatchdogs={}),e._yeaftWatchdogConvs||(e._yeaftWatchdogConvs=new Set),e._yeaftWatchdogConvs.add(t),e._processingWatchdogs[t]=setTimeout(()=>{if(e.processingConversations[t]){delete e.processingConversations[t];let s=e.executionStatusMap[t];s&&(s.currentTool=null),e.finishStreamingForConversation(t)}delete e._processingWatchdogs[t]},15e4)}var jt=F(()=>{});function Io(e,t){return t&&Array.isArray(e?._yeaftRetiredConversationIdsByAgent?.[t])?e._yeaftRetiredConversationIdsByAgent[t]:[]}function $s(e,t,s){return!t||!s?!1:Io(e,t).includes(s)}function Co(e,t){let s=e?._yeaftRetiredConversationTargetsByAgent?.[t];return s&&typeof s=="object"?s:{}}function yc(e,t,s){if(!t||!s)return null;let n=Co(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 kn(e,t,s,n=null){if(!t||!s)return;let r=Io(e,t).filter(a=>a!==s).concat(s).slice(-8);e._yeaftRetiredConversationIdsByAgent={...e._yeaftRetiredConversationIdsByAgent||{},[t]:r};let i=Co(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 Ao(e,t,s){if(!t||!s||!e?._yeaftRetiredConversationIdsByAgent)return;let n=Io(e,t).filter(i=>i!==s);e._yeaftRetiredConversationIdsByAgent={...e._yeaftRetiredConversationIdsByAgent,[t]:n};let r={...Co(e,t)};delete r[s],e._yeaftRetiredConversationTargetsByAgent={...e._yeaftRetiredConversationTargetsByAgent||{},[t]:r}}var Ir=F(()=>{});function Vm(e,t,s){let n=e.messagesMap?.[t]||[],r=e.messagesMap?.[s]||[];e.messagesMap||(e.messagesMap={}),e.messagesMap[s]=lc(r,n).sort((i,o)=>(i.timestamp||0)-(o.timestamp||0))}function Fm(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 Cr(e,t){return!!e&&Object.prototype.hasOwnProperty.call(e,t)}function Vs(e,t,s,{removeSource:n}){Cr(e,t)&&(Cr(e,s)||(e[s]=n?e[t]:Fm(e[t])),n&&delete e[t])}function mt(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 Ar(e,t,s,n){return!t||!s||!n||s===n?!1:(e._yeaftPendingConversationPromotions={...e._yeaftPendingConversationPromotions||{},[t]:{sourceConversationId:s,targetConversationId:n}},!0)}function Sn(e,t,s=null){let n=mt(e,t,s);if(!n)return null;let r={...e._yeaftPendingConversationPromotions||{}};return delete r[t],e._yeaftPendingConversationPromotions=r,n}function In(e,t,s){let n=mt(e,t);return!n||!s||n.targetConversationId===s?null:(ht(e,n.targetConversationId,s,{removeSource:!0}),kn(e,t,n.targetConversationId,s),Ar(e,t,n.sourceConversationId,s),n)}function ht(e,t,s,{removeSource:n=!0}={}){if(!t||!s||t===s)return!1;Vm(e,t,s),Vs(e.processingConversations,t,s,{removeSource:n}),Vs(e.executionStatusMap,t,s,{removeSource:n}),Vs(e.refreshingSessionMap,t,s,{removeSource:n}),Vs(e._closedAt,t,s,{removeSource:n}),Vs(e._autoRefreshed,t,s,{removeSource:n}),Vs(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._processingWatchdogs?.[t];if(n&&i&&Ae(e,t),n&&e._pongTimeouts?.[t]&&(clearTimeout(e._pongTimeouts[t]),delete e._pongTimeouts[t]),n&&(i||r)&&!!e.processingConversations?.[s])if(e._processingWatchdogs?.[s])e._yeaftWatchdogConvs?.add(s);else{let a=Cr(e.sessionHealth,s),l=e.sessionHealth?.[s],c=Cr(e._autoRefreshed,s),d=e._autoRefreshed?.[s];wn(e,s),a&&(e.sessionHealth||(e.sessionHealth={}),e.sessionHealth[s]=l),c&&(e._autoRefreshed||(e._autoRefreshed={}),e._autoRefreshed[s]=d)}return n&&e.messagesMap&&delete e.messagesMap[t],!0}var xo=F(()=>{Ds();Ir();jt()});function xr(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 To=F(()=>{});function Mo(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}function Om(){return Date.now()}function Hm(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`pt_${crypto.randomUUID()}`:`pt_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,10)}`}function qm(e,t=160){return typeof e!="string"?e:e.length>t?`${e.slice(0,t)}...[truncated]`:e}function Nm(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"?qm(n):n);return t}function Cn(){return Hm()}function Ze(e,t={}){!e||!t.traceId||(Array.isArray(e._perfTraceQueue)||(e._perfTraceQueue=[]),e._perfTraceQueue.push({traceId:t.traceId,source:"web",phase:t.phase||"unknown",at:Om(),monotonicMs:Mo(),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:Nm(t.detail)}),e._perfTraceQueue.length>200&&e._perfTraceQueue.splice(0,e._perfTraceQueue.length-200),Bm(e))}function Bm(e){!e||e._perfTraceFlushTimer||(e._perfTraceFlushTimer=setTimeout(()=>Wm(e),250))}function Wm(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 Tr(e,t={}){if(typeof requestAnimationFrame!="function")return;let s=Mo();requestAnimationFrame(()=>{requestAnimationFrame(()=>{Ze(e,{...t,phase:t.phase||"render.next_paint",durationMs:Mo()-s})})})}var Po=F(()=>{});function Pe(e,t){let s=t==null?"__all__":String(t);return e?`${e}${s}`:s}var Mr=F(()=>{});function Ro(e){return typeof e=="string"&&e?e:null}function Fs(e,t){return e?.yeaftSessionHistoryState?.[t]||null}function An(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:Pe(s,t)}}function wc(e,{agentId:t,sessionId:s,mode:n="recent",preserveLoaded:r=!1,latestSeq:i=null}={}){if(!t||!s)return null;let o=Pe(t,s),a=Fs(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,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.count=0)),e.yeaftSessionHistoryState={...e.yeaftSessionHistoryState||{},[o]:d},xn(e),{sessionKey:o,requestId:c,generation:l,state:d}}function _o(e,t={}){let s=t.sessionId??t.groupId??null;if(!s)return!1;let n=t.agentId||e?.yeaftSessionAgentById?.[s]||null,r=Pe(n,s),i=Fs(e,r),o=Ro(t.requestId);if(!i)return o===null;let a=Ro(i.requestId);return o?o===a:a===null}function kc(e,t={},s={},n="chunk"){if(!_o(e,t))return null;let r=t.sessionId??t.groupId??null,i=t.agentId||e?.yeaftSessionAgentById?.[r]||null,o=Pe(i,r),a=Fs(e,o)||{},l=Ro(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},xn(e),d}function Sc(e,{agentId:t,sessionId:s,requestId:n,error:r="history_load_failed"}={}){if(!t||!s||!n)return!1;let i=Pe(t,s),o=Fs(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()}},xn(e),!0)}function xn(e){let{sessionKey:t}=An(e),s=t?Fs(e,t):null;return e.yeaftLoadingMoreHistory=!!s?.loading,e.yeaftHistoryLoadError=s?.error||null,e.yeaftHasMoreHistory=!!s?.hasMore,e.yeaftOldestLoadedSeq=Number.isFinite(s?.oldestSeq)?s.oldestSeq:null,s}function Eo(e){let{sessionKey:t}=An(e);return t?Fs(e,t):null}var bc,Do=F(()=>{Mr();bc=15e3});function xc(e){return e.filter(t=>!(t.type==="user"&&(!t.content||!t.content.trim())))}function Ic(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 jm(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 Um(e){return Array.isArray(e?.toolCalls)?e.toolCalls.filter(t=>t?.name!=="TodoWrite").length:Number(e?.toolSummaryCount||0)||0}function zm(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 Km(e,t){return e.speakerVpId||e.vpId||e.vp_id||e.authorVpId||e.authorVP||zm(t)}function Pr(e){return e&&(e.messageId||e.id)?e.messageId||e.id:null}function Ym(e){e.sort((t,s)=>(t.timestamp||0)-(s.timestamp||0))}function Gm(e,t){if(!e||!t||e.type!=="assistant"||t.type!=="assistant"||(e.sessionId??null)!==(t.sessionId??null))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||!(e.isStreaming||e.isHistory!==!0)||t._hasPersistedTurnId!==!0)return!1;let a=e.turnId||"",l=t.turnId||"";if(!a||!l||a!==l)return!1;let c=typeof e.content=="string"?e.content:"",d=typeof t.content=="string"?t.content:"";return!!c&&!!d&&(d.startsWith(c)||c.startsWith(d))}function Lo(e,t){let s=new Map,n=new Map;e.forEach((i,o)=>{let a=Pr(i);a&&s.set(a,o),i?.type==="user"&&i.clientMessageId&&n.set(i.clientMessageId,o)});let r=0;for(let i of t){let o=Pr(i),a=o&&s.has(o)?s.get(o):null;if(a===null&&i?.type==="user"&&i.clientMessageId&&n.has(i.clientMessageId)&&(a=n.get(i.clientMessageId)),a===null&&i?.type==="assistant"&&(a=e.findIndex(l=>Gm(l,i))),a!==null&&a>=0){let l=Pr(e[a]);e[a]={...e[a],...i},o&&s.set(o,a),l&&l!==o&&s.get(l)===a&&s.delete(l),i?.type==="user"&&i.clientMessageId&&n.set(i.clientMessageId,a)}else o&&s.set(o,e.length),i?.type==="user"&&i.clientMessageId&&n.set(i.clientMessageId,e.length),e.push(i),r+=1}return Ym(e),r}function Rr(e){return e?e.sessionId??e.groupId??null:null}function Qm(e){return!e||e.type!=="user"||!e.clientMessageId?!1:Pr(e)===e.clientMessageId}function Xm(e,t,s){let n=e.some(o=>o&&(s==null||Rr(o)===s));if(t.length===0&&n)return{insertedRows:0,preservedEmpty:!0};let r=t.reduce((o,a)=>Math.max(o,a?.timestamp||0),0),i=e.filter(o=>o?s!=null&&Rr(o)!==s||o.isStreaming||o.type==="tool-use"&&o.toolName==="AskUserQuestion"&&(o.askAnswered||o.askPending||o.askExpired)||Qm(o)?!0:r>0&&(o.timestamp||0)>r:!1);return e.splice(0,e.length,...i),Lo(e,t),{insertedRows:t.length,preservedEmpty:!1}}function Zm(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 Jm(e,t){let s=typeof e.yeaftConversationId=="string"?e.yeaftConversationId:"";return s.startsWith(`yeaft-local-${t}-`)||/^yeaft-local-\d/.test(s)?s:null}function eh(e,t,s,n){let r=t.agentId||s&&e.yeaftSessionAgentById?.[s]||null;if(!r||!n||e.currentView!=="yeaft")return;let i=An(e);if(i.sessionId!==(s||null)||i.agentId&&i.agentId!==r)return;let o=e.yeaftConversationId||null;if($s(e,r,n)){let d=e.yeaftConversationIdsByAgent?.[r]||null;d&&d!==n&&ht(e,n,d,{removeSource:n!==e.yeaftConversationId});return}let a=mt(e,r);a&&a.targetConversationId!==n&&In(e,r,n);let l=mt(e,r,n);if(l&&(ht(e,l.sourceConversationId,n,{removeSource:!0}),Sn(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=Jm(e,r);c&&(ht(e,c,n,{removeSource:!0}),e.yeaftConversationIdsByAgent={...e.yeaftConversationIdsByAgent||{},[r]:n},e.yeaftConversationId=n,e.activeConversations=[n])}function Ut(e,t){let s=e.messagesMap[t]||[];for(let n of s)n.type==="tool-use"&&!n.hasResult&&(n.hasResult=!0,n.toolName==="AskUserQuestion"&&!n.askAnswered&&!n.selectedAnswers&&(n.isHistory=!0,n.askRequestId=null))}function Tc(e,t){gt(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:Ee("store.convCreated",{agent:s?.name||t.agentId,workDir:t.workDir})}),e.saveOpenSessions()}function Mc(e,t){gt(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)),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:Ee("store.convResumed",{agent:s?.name||t.agentId,sessionId:t.claudeSessionId?t.claudeSessionId.slice(0,8)+"...":""})}),t.dbMessages&&t.dbMessages.length>0){let n=xc(t.dbMessages.map(o=>e.formatDbMessageForHistoryHydration(o)).flat().filter(Boolean)),r=vo(n),i=e.messagesMap[t.conversationId]||[];for(let o of r)i.push(o)}e.hasMoreMessages=!!t.hasMoreMessages,e.chatSessionState[t.conversationId]={lastSeenDbId:rs(e.messagesMap[t.conversationId]),hasMoreOlder:!!t.hasMoreMessages},e.saveOpenSessions()}function $o(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],Ae(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:Ee("chat.session.closed")}));for(let n of e.panels)n.conversationId===t.conversationId&&(n.conversationId=null);e.saveOpenSessions()}function Pc(e,t){let s=t.conversationId;if(s){delete e.processingConversations[s],Ae(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),Ut(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 Rc(e,t){let s=t.conversationId;if(s){delete e.processingConversations[s],Ae(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),Ut(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 _c(e,t){if(t.conversationId){if(t.isProcessing&&!is(e,t.conversationId)&&!e._turnCompletedConvs?.has(t.conversationId))e.processingConversations[t.conversationId]=!0;else if(e.processingConversations[t.conversationId]){delete e.processingConversations[t.conversationId],Ae(e,t.conversationId);let s=e.executionStatusMap[t.conversationId];s&&(s.currentTool=null),e.finishStreamingForConversation(t.conversationId)}}}function Ec(e,t){let s=t.conversationId||e.currentConversation;if(s){delete e.processingConversations[s],Ae(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),Ut(e,s)}}function Dc(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=vo(xc((t.messages||[]).map(a=>e.formatDbMessageForHistoryHydration(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&&xr(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),gt(e);let o=e.chatSessionState[t.conversationId]?.hasMoreOlder;e.chatSessionState[t.conversationId]={lastSeenDbId:rs(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 Lc(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{formatted:i}=$c(t.messages,s,"window",e.messagesMap[r]);return Lo(e.messagesMap[r],i),r}function Cc(e){return e?.toolId?[Rr(e)??"",e.vpId||e.speakerVpId||"",e.turnId||"",e.threadId||"main",e.toolId].join("\0"):null}function Ac(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.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 th(e,t){return(e||[]).find(s=>s?.type==="tool-use"&&(s.toolName==="AskUser"||s.toolName==="AskUserQuestion")&&s.toolId===t.toolCallId&&Rr(s)===t.sessionId&&(s.vpId||s.speakerVpId||"")===(t.vpId||"")&&(s.turnId||"")===(t.turnId||"")&&(s.threadId||"main")===(t.threadId||"main"))||null}function $c(e,t,s,n){let r=new Set((n||[]).map(l=>l&&(l.messageId||l.id)).filter(Boolean)),i=new Set,o=[],a=0;for(let l of e){if(!l||l._reflection||l.internal||l.systemOnly||l.systemOnlyMessage||Zm(l.content))continue;let c=l.id||l.messageId||null,d=l.clientMessageId||null;if(!(c&&i.has(c))&&!(c&&s!=="recent"&&r.has(c))){if(c&&i.add(c),l.role==="user"){a+=1;let u=c||l.messageId||l.turnId||null,f=l.sessionId??l.groupId??t??null;o.push({...c?{id:c,messageId:c}:{},type:"user",content:l.content,timestamp:Ic(l),sessionId:f,turnId:l.turnId||u,...d?{clientMessageId:d}:{},...Array.isArray(l.attachments)&&l.attachments.length>0?{attachments:l.attachments}:{},...l.quote?{quote:l.quote}:{},isStreaming:!1})}else if(l.role==="assistant"){a+=1;let u=c||l.messageId||l.turnId||null,f=l.sessionId??l.groupId??t??null,p=Km(l,f),g=Ic(l),h=!!l.turnId,v=l.turnId||u,C=typeof l.content=="string"?l.content:l.content||"",w=Array.isArray(l.todos)?l.todos:jm(l.toolCalls);(typeof C!="string"||C.trim())&&o.push({...c?{id:c,messageId:c}:{},type:"assistant",content:C,timestamp:g,sessionId:f,turnId:v,_hasPersistedTurnId:h,...p?{vpId:p,speakerVpId:p}:{},...l.responseKind==="progress"||l.responseKind==="result"?{responseKind:l.responseKind}:{},...l.incomplete===!0?{incomplete:!0}:{},...typeof l.stopReason=="string"&&l.stopReason?{stopReason:l.stopReason}:{},isStreaming:!1,isHistory:!0}),Array.isArray(w)&&w.length>0&&o.push({...c?{id:`${c}:todos`,messageId:`${c}:todos`}:{},type:"tool-use",toolName:"TodoWrite",toolInput:{todos:w},timestamp:g,sessionId:f,turnId:v,...p?{vpId:p,speakerVpId:p}:{},isStreaming:!1,isHistory:!0,hasResult:!0});for(let y of Array.isArray(l.images)?l.images:[])y?.assetId&&o.push({id:`${c||u||v}:image:${y.assetId}`,messageId:`${c||u||v}:image:${y.assetId}`,type:"chat-image",...y,timestamp:g,sessionId:f,turnId:v,...p?{vpId:p,speakerVpId:p}:{},isStreaming:!1,isHistory:!0});for(let y of Array.isArray(l.askUserResults)?l.askUserResults:[]){if(!y?.toolCallId||y.status!=="answered"&&y.status!=="expired")continue;let m=[{question:typeof y.question=="string"?y.question:"",options:(Array.isArray(y.options)?y.options:[]).filter($=>typeof $=="string").map($=>({label:$,description:""})),multiSelect:!1}],b={toolCallId:y.toolCallId,sessionId:f,vpId:p||"",turnId:v||"",threadId:l.threadId||"main"},T=th(n,b);if(T){Ac(T,y,m);continue}let L=Ac({id:`${c||u||v}:ask:${y.toolCallId}`,messageId:`${c||u||v}:ask:${y.toolCallId}`,type:"tool-use",timestamp:g,sessionId:f,turnId:v,threadId:b.threadId,...p?{vpId:p,speakerVpId:p}:{},isStreaming:!1},y,m),N=Cc(L);(!N||!o.some($=>Cc($)===N))&&o.push(L)}let k=Um(l);k>0&&o.push({...c?{id:`${c}:tool-summary`,messageId:`${c}:tool-summary`,persistedMessageId:c}:{},type:"tool-summary",count:k,omittedCount:k,source:"history",timestamp:g,sessionId:f,turnId:v,...p?{vpId:p,speakerVpId:p}:{},isStreaming:!1,isHistory:!0})}}}return{formatted:o,acceptedHistoryMessages:a}}function Vc(e,t){let s=t.sessionId!=null?t.sessionId:t.groupId,n=t.agentId||s&&e.yeaftSessionAgentById?.[s]||null;if($s(e,n,t.conversationId)){let b=e.yeaftConversationIdsByAgent?.[n]||null;if(!b||b===t.conversationId)return;ht(e,t.conversationId,b,{removeSource:t.conversationId!==e.yeaftConversationId}),t={...t,conversationId:b}}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:[];t.perfTraceId&&Ze(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 o=t.agentId||(s&&e.yeaftSessionAgentById?e.yeaftSessionAgentById[s]:null),a=o&&e.yeaftConversationIdsByAgent?e.yeaftConversationIdsByAgent[o]:null,l=t.conversationId||a||e.yeaftConversationId;if(!l){e.yeaftLoadingMoreHistory=!1;return}eh(e,t,s,l),e.messagesMap[l]||(e.messagesMap[l]=[]);let{formatted:c,acceptedHistoryMessages:d}=$c(i,s,r,e.messagesMap[l]),u=0,f=!1;if(r==="recent"){let b=Xm(e.messagesMap[l],c,s??null);u=b.insertedRows,f=b.preservedEmpty}else if(c.length>0)if(r==="older"){if(e.messagesMap[l].splice(0,0,...c),u=c.length,typeof e.expandYeaftMessageWindow=="function"){let b=e.yeaftActiveSessionFilter?s??null:null;e.expandYeaftMessageWindow(b,t.turns||10)}}else u=Lo(e.messagesMap[l],c);let p=Pe(t.agentId||null,s),g=e.yeaftSessionHistoryState?.[p]||{},h=typeof t.latestSeq=="number"?t.latestSeq:g.latestSeq??null,v=r==="delta"?{...g,loaded:!0,loading:!1,latestSeq:h,syncingAfterSeq:null,count:(g.count||0)+u}:{...f?g:{},loaded:!0,loading:!1,hasMore:f?!!g.hasMore:!!t.hasMore,oldestSeq:f?Number.isFinite(g.oldestSeq)?g.oldestSeq:e.yeaftOldestLoadedSeq:typeof t.oldestSeq=="number"?t.oldestSeq:e.yeaftOldestLoadedSeq,count:r==="older"?(g.count||0)+u:f?g.count||0:d,latestSeq:f&&!Number.isFinite(t.latestSeq)?g.latestSeq??null:h,syncingAfterSeq:null};t.requestId&&typeof e.finishYeaftHistoryLoad=="function"?e.finishYeaftHistoryLoad(t,v,"chunk"):e.yeaftSessionHistoryState&&(e.yeaftSessionHistoryState={...e.yeaftSessionHistoryState,[p]:v});let C=An(e),w=C.sessionId===(s||null),k=!t.agentId||!C.agentId||t.agentId===C.agentId,y=w&&k,m=Pe(null,C.sessionId);if(t.perfTraceId&&(Ze(e,{traceId:t.perfTraceId,phase:"history.chunk_applied",agentId:t.agentId||null,sessionId:s||null,messageType:t.type,detail:{mode:r,formattedCount:c.length,insertedRows:u,acceptedHistoryMessages:d,preservedEmptyRecent:f}}),Tr(e,{traceId:t.perfTraceId,phase:"history.next_paint",agentId:t.agentId||null,sessionId:s||null,messageType:t.type,detail:{mode:r,insertedRows:u}})),y)e.yeaftHasMoreHistory=v.hasMore,typeof t.oldestSeq=="number"&&(e.yeaftOldestLoadedSeq=t.oldestSeq),e.yeaftLoadingMoreHistory=!1;else if(e.yeaftLoadingMoreHistory){let b=e.yeaftSessionHistoryState?.[C.sessionKey]||e.yeaftSessionHistoryState?.[m]||null;e.yeaftLoadingMoreHistory=!!b?.loading}}var _r=F(()=>{jt();xo();Ir();ns();To();Ds();yo();Tt();Po();Do();Mr()});function Fc(e,t){if(e.promoteYeaftHistoryOutlineRow?.(t))return;let s=t?.sessionId??t?.groupId??e._currentYeaftSessionId??null;s&&e.invalidateYeaftHistoryOutline?.(s)}function sh(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 Vo(e,t){return e.executionStatusMap[t]||(e.executionStatusMap[t]={currentTool:null,toolHistory:[],lastActivity:null}),e.executionStatusMap[t]}function Oc(e,t,s){if(!t)return;let n=Vo(e,t);if(n.lastActivity=Date.now(),Sr(e,t),s.type==="system"){if(s.subtype==="init"){let r=e.conversations.find(i=>i.id===t);r&&r.connecting&&(r.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 r=s.message?.content;if(!r)return;let i=e.messagesMap[t]||[];for(let o of i)o.type==="tool-use"&&!o.hasResult&&(o.hasResult=!0);for(let o of n.toolHistory)o.status==="running"&&(o.status="done");if(n.currentTool=null,typeof r=="string"){e.appendToAssistantMessageForConversation(t,r,{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(r))return;if(r.length===0){e.finishStreamingForConversation(t);return}for(let o of r)o.type==="text"?e.appendToAssistantMessageForConversation(t,o.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}):o.type==="image_asset"&&o.image?e.addMessageToConversation(t,{type:"chat-image",...o.image,sessionId:e._currentYeaftSessionId||null,vpId:e._currentYeaftVpId||null,speakerVpId:e._currentYeaftVpId||null,turnId:e._currentYeaftTurnId||null,threadId:e._currentYeaftThreadId||null}):o.type==="tool_summary"?e.addMessageToConversation(t,{type:"tool-summary",count:Number(o.count||o.omittedCount||0)||0,omittedCount:Number(o.omittedCount||o.count||0)||0,source:o.source||"history",isHistory:o.source!=="live",sessionId:e._currentYeaftSessionId||null,vpId:e._currentYeaftVpId||null,turnId:e._currentYeaftTurnId||null,threadId:e._currentYeaftThreadId||null}):o.type==="tool_use"&&(e.finishStreamingForConversation(t,{completeLifecycle:!1}),n.currentTool={name:o.name,input:o.input,startTime:Date.now()},n.toolHistory.unshift({name:o.name,input:o.input,timestamp:Date.now(),status:"running"}),n.toolHistory.length>20&&n.toolHistory.pop(),e.addMessageToConversation(t,{type:"tool-use",toolId:o.id||o.tool_use_id||null,toolName:o.name,toolInput:o.input,startTime:Date.now(),sessionId:e._currentYeaftSessionId||null,vpId:e._currentYeaftVpId||null,turnId:e._currentYeaftTurnId||null,threadId:e._currentYeaftThreadId||null}))}else if(s.type==="user"){let r=s.internal===!0||s.message?.internal===!0||s.userAuthored===!1||s.message?.userAuthored===!1,i=s.message?.content,o=sh(i);if(typeof o=="string"&&(o.includes("<local-command-caveat>")||o.includes("<command-name>")))return;if(typeof o=="string"&&o.includes("<local-command-stdout>")){let l=o.match(/<local-command-stdout>([\s\S]*?)<\/local-command-stdout>/);if(l){e.appendToAssistantMessageForConversation(t,l[1].trim()),e.finishStreamingForConversation(t);return}}let a=[];if(s.tool_use_result)a=Array.isArray(s.tool_use_result)?s.tool_use_result:[s.tool_use_result];else if(s.message?.content){let l=s.message.content;a=(Array.isArray(l)?l:[]).filter(d=>d.type==="tool_result")}if(a.length>0){let l=e.messagesMap[t]||[];for(let c of a){if(n.toolHistory.length>0){let p=n.toolHistory.findIndex(g=>g.status==="running");p>=0&&(n.toolHistory[p].status="done")}let d=c.tool_use_id||c.toolUseId||c.tool_call_id||c.toolCallId||null,u=c.content||c,f=!1;if(d){for(let p=l.length-1;p>=0;p--)if(l[p].type==="tool-use"&&l[p].toolId===d){l[p].hasResult=!0,l[p].toolResult=c.is_update&&l[p].toolResult?`${l[p].toolResult}
|
|
2
2
|
|
|
3
|
-
${u}`:u,f=!0;break}}if(!f){for(let p=l.length-1;p>=0;p--)if(l[p].type==="tool-use"&&!l[p].hasResult){l[p].hasResult=!0,l[p].toolResult=u;break}}}n.currentTool=null}else if(!r&&(typeof o=="string"&&o.trim()||Array.isArray(s.message?.attachments)&&s.message.attachments.length>0)){let l=s.message?.clientMessageId||s.clientMessageId||null,c={type:"user",content:o,clientMessageId:l},d=e.messagesMap[t]||[];if(d.some(f=>xr(f,c))){if(l){for(let f=d.length-1;f>=0;f--)if(d[f].type==="user"&&d[f].clientMessageId===l){s.dbMessageId&&!d[f].dbMessageId&&(d[f].dbMessageId=s.dbMessageId),s.message?.id&&!d[f].messageId&&(d[f].id=s.message.id,d[f].messageId=s.message.id),s.ts&&!d[f].ts&&(d[f].ts=s.ts),Fc(e,d[f]);break}}}else{let f=e.addMessageToConversation(t,{...s.message?.id?{id:s.message.id,messageId:s.message.id}:{},...s.ts?{ts:s.ts}:{},type:"user",content:o,...s.message?.attachments?{attachments:s.message.attachments}:{},...s.message?.quote?{quote:s.message.quote}:{},...l?{clientMessageId:l}:{}});Fc(e,f)}}}else if(s.type==="result"){delete e.processingConversations[t],Ae(e,t);let r=e.conversations.find(c=>c.id===t);r&&r.connecting&&(r.connecting=!1);let i=e._currentYeaftSessionId||null;if(e._currentYeaftTurnId){let c=Object.entries(e.activeVpTurns||{}).find(([,d])=>(d?.turnId===e._currentYeaftTurnId||!d?.turnId&&d===e.activeVpTurns[e._currentYeaftTurnId])&&(!e._currentYeaftAgentId||!d?.agentId||d.agentId===e._currentYeaftAgentId));if(c){let[d,u]=c,{[d]:f,...p}=e.activeVpTurns;!i&&u?.sessionId&&(i=u.sessionId),e.activeVpTurns=p}}if(i&&e._currentYeaftVpId&&e.vpStatuses){let c=e._currentYeaftTurnId||null,d={...e.vpStatuses||{}},u=!1;for(let[f,p]of Object.entries(d))!p||p.vpId!==e._currentYeaftVpId||e._currentYeaftAgentId&&p.agentId&&p.agentId!==e._currentYeaftAgentId||(p.sessionId||p.groupId||null)!==i||c&&p.turnId&&p.turnId!==c||(d[f]={...p,state:"idle",turnId:null,since:Date.now()},u=!0);u&&(e.vpStatuses=d)}i&&typeof e.clearYeaftSessionProcessingIfIdle=="function"&&e.clearYeaftSessionProcessingIfIdle(i,{agentId:e._currentYeaftAgentId||null}),e._closedAt||(e._closedAt={}),e._closedAt[t]=Date.now(),e._turnCompletedConvs||(e._turnCompletedConvs=new Set),e._turnCompletedConvs.add(t),n.currentTool=null,Ut(e,t);let o=e.messagesMap[t]||[],a=s.result_text||"";if(typeof a=="string"&&a.trim()){let c=!1;for(let d=o.length-1;d>=0;d--){if(o[d].type==="assistant"){c=!0;break}if(o[d].type==="user")break}c||e.appendToAssistantMessageForConversation(t,a.trim())}e.finishStreamingForConversation(t),!e.promoteCompletedYeaftHistoryOutline?.(t,e._currentYeaftTurnId||null)&&i&&e.invalidateYeaftHistoryOutline?.(i),e.sweepStaleStreamingForConversation(t)}}var Hc=F(()=>{jt();_r();To()});function os(e){if(e==null)return e;try{return JSON.parse(JSON.stringify(e))}catch{return e}}function Er(e,t){if(!t)return e??null;if(Object.prototype.hasOwnProperty.call(t,"base"))return os(t.base)??null;if(Object.prototype.hasOwnProperty.call(t,"replacement"))return os(t.replacement)??null;let s=e&&typeof e=="object"&&!Array.isArray(e)?os(e):{};if(t.set&&typeof t.set=="object")for(let[n,r]of Object.entries(t.set))s[n]=os(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]=os(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]=os(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(os(t.body.messagesAppend)||[])}s.body=n}return s}function qc(e,t){return!t||!Object.prototype.hasOwnProperty.call(t,"rawRequestDelta")?e??null:Er(e??null,t.rawRequestDelta)}function Tn(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 rh(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 Nc(e){let t=0,s=0;if(e&&Array.isArray(e.messages))for(let i of e.messages){let{messageText:o,toolText:a}=rh(i);for(let l of o)t+=Tn(l);for(let l of a)s+=Tn(l)}let n=0,r=0;if(e&&typeof e.response=="string"&&(n+=Tn(e.response)),e&&Array.isArray(e.toolCalls)){for(let i of e.toolCalls)if(i&&(r+=Tn(String(i.name||"")),i.input!==void 0))try{r+=Tn(JSON.stringify(i.input))}catch{}}return{inputMessageTokens:t,inputToolTokens:s,outputMessageTokens:n,outputToolTokens:r,inputTotalEstimated:t+s,outputTotalEstimated:n+r}}function Fo(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 Bc(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 Oo=F(()=>{});function dt(e,t){return!e||!t?"":`${e}${t}`}function Mn(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 Ho(e){return e?`${e}`:""}function qo(e,t){return!e||!t?"":`${e}${t}`}var Pn=F(()=>{});function ih(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 Wc(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 jc(e,t){let s=Array.isArray(e.agents)?e.agents:[],n=e._hasHandledAgentList===!0,r=e.currentAgent||null,i=!!(r&&s.some(a=>a&&a.id===r&&a.online));e.agents=t.agents,e._hasHandledAgentList=!0;let o=e.currentAgent||null;if(o){let a=e._yeaftAgentSeen&&e._yeaftAgentSeen.id===o?e._yeaftAgentSeen:null,l=t.agents.find(c=>c.id===o)||null;e.currentView==="yeaft"&&ih(a,l)&&(e._yeaftReconnectCatchUpPending=!0),l?e._yeaftAgentSeen={id:o,online:!!l.online,version:l.version!=null?l.version:null}:a?a.online&&(e._yeaftAgentSeen={id:o,online:!1,version:a.version}):e._yeaftAgentSeen={id:o,online:!1,version:null}}{let a=new Set(t.agents.map(l=>l.id));for(let l of t.agents)e.proxyPorts[l.id]=l.proxyPorts||[],l.yeaftStatus&&typeof e.cacheYeaftAgentStatus=="function"&&e.cacheYeaftAgentStatus(l.id,l.yeaftStatus);for(let l of Object.keys(e.proxyPorts))a.has(l)||delete e.proxyPorts[l]}if(e.currentAgent){let a=t.agents.find(l=>l.id===e.currentAgent);a&&(e.currentAgentInfo=a)}if(e.currentView==="yeaft"&&!e.currentAgent){let a=t.agents.find(l=>l.online);a&&(e.currentAgent=a.id,e.currentAgentInfo=a)}if(e.currentView==="yeaft"&&typeof e.loadOpenedYeaftSessionsForConnectedAgents=="function"){let a=t.agents.filter(l=>l&&l.online&&l.id).map(l=>l.id);e.loadOpenedYeaftSessionsForConnectedAgents(a)}{let a=[],l=new Set;for(let d of t.agents)for(let u of d.conversations||[])l.has(u.id)||(l.add(u.id),a.push({...u,type:u.type,agentId:d.id,agentName:d.name}),u.title&&(u.customTitle&&(e.customConversationTitles[u.id]=u.title),e.conversationTitles[u.id]||(e.conversationTitles[u.id]=u.title)));for(let d of a){d.agentOnline=!0;let u=e.conversations.find(f=>f.id===d.id);if(u)u.claudeSessionId=d.claudeSessionId||u.claudeSessionId,u.processing=d.processing,u.userId=d.userId,u.username=d.username,u.agentId=d.agentId,u.agentName=d.agentName,u.agentOnline=!0,d.type&&(u.type=d.type),d.name!==void 0&&(u.name=d.name);else{let f=e._recentlyDeletedSessions?.[d.id];if(f&&Date.now()-f<15e3)continue;e.conversations.push(d)}d.pinned&&!e.pinnedSessions.includes(d.id)&&e.pinnedSessions.push(d.id)}let c=new Set(t.agents.map(d=>d.id));e.conversations=e.conversations.filter(d=>{if(l.has(d.id)||e.activeConversations.includes(d.id))return!0;if(d.agentId&&c.has(d.agentId)){let u=e._recentlyDeletedSessions?.[d.id];return u&&Date.now()-u<15e3||(delete e.messagesMap[d.id],delete e.processingConversations[d.id],Ae(e,d.id),delete e.executionStatusMap[d.id]),!1}return d.agentId&&!c.has(d.agentId)&&(d.agentOnline=!1),!0});for(let d of a)if(d.processing&&!is(e,d.id)&&!e._turnCompletedConvs?.has(d.id))e.processingConversations[d.id]=!0;else if(e.processingConversations[d.id]){delete e.processingConversations[d.id],Ae(e,d.id);let u=e.executionStatusMap[d.id];u&&(u.currentTool=null),e.finishStreamingForConversation(d.id)}for(let d of Object.keys(e.processingConversations))if(!l.has(d)){if(d.startsWith("yeaft-"))continue;delete e.processingConversations[d],Ae(e,d);let u=e.executionStatusMap[d];u&&(u.currentTool=null),e.finishStreamingForConversation(d)}}if(localStorage.setItem("pinned-sessions",JSON.stringify(e.pinnedSessions)),e._closedAt){let a=Date.now();for(let l of Object.keys(e._closedAt))a-e._closedAt[l]>3e4&&(delete e._closedAt[l],e._turnCompletedConvs?.delete(l))}if(e.currentAgent){let a=t.agents.find(l=>l.id===e.currentAgent&&l.online);if(a){let l=!!e._yeaftReconnectCatchUpPending,d=l||n&&!i;if(e.currentAgentInfo=a,d&&(e._offlineConversationRestoreKey=null,e.sendWsMessage({type:"select_agent",agentId:e.currentAgent,silent:!0})),e.currentView==="yeaft"&&typeof e.requestYeaftSessionBootstrap=="function"){e._yeaftReconnectCatchUpPending=!1;let u=l||!e.yeaftSessionReady||!e.yeaftModel||!e.yeaftStatus;(u||l)&&e.requestYeaftSessionBootstrap({forceSessionReady:u,catchUpHistory:l})}if(!d)return;if(e.currentConversation){let u=e.conversations.find(g=>g.id===e.currentConversation);e.sendWsMessage({type:"select_conversation",conversationId:e.currentConversation});let f=e.messagesMap[e.currentConversation]||[],p=rs(f);p!=null?e.requestChatHistory?.(e.currentConversation,{mode:"delta",afterMessageId:p}):e.requestChatHistory?.(e.currentConversation,{mode:"recent",turns:5}),e.sendWsMessage({type:"refresh_conversation",conversationId:e.currentConversation})}else e.recoveryDismissed||Wc(e);return}else{let l=`${e.currentAgent||""}:${e.currentConversation||""}`;e.currentConversation&&(!n||i||e._offlineConversationRestoreKey!==l)&&(e._offlineConversationRestoreKey=l,e.sendWsMessage({type:"select_conversation",conversationId:e.currentConversation}));return}}if(!e.currentConversation&&!e.currentAgent&&!e.recoveryDismissed){let a=e.lastViewedConversation||localStorage.getItem("lastViewedConversation"),l=e.lastUsedAgent;if(a){let c=e.conversations.find(d=>d.id===a);if(c){let d=t.agents.find(u=>u.id===c.agentId&&u.online);if(d){Wc(e,{agentId:c.agentId,agentInfo:d});return}}}l&&(e.agents.find(d=>d.id===l&&d.online)?e.selectAgent(l):e.checkPendingRecovery())}}function Uc(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"],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(f=>f.id===e.currentConversation);u&&!a.find(f=>f.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&&!is(e,u.id)&&!e._turnCompletedConvs?.has(u.id))e.processingConversations[u.id]=!0;else if(e.processingConversations[u.id]){delete e.processingConversations[u.id],Ae(e,u.id);let f=e.executionStatusMap[u.id];f&&(f.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],Ae(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(f=>f.id===e.currentConversation);e.currentWorkDir=u?.workDir||e.currentWorkDir||t.workDir,gt(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(f=>f.id===u)&&(e.autoRestoreConversation(u),e.pendingRecovery=null)}Fl(e)}return!0}var zc=F(()=>{jt();ns();Ds()});function oh(e={}){return{providers:e.providers||[],primaryModel:e.primaryModel||null,fastModel:e.fastModel||null,language:e.language||"en"}}function Kc(){return window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore()}function dh(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 uh(e){let t=Kc(),s=null;try{s=localStorage.getItem("lastViewedYeaftSession")||null}catch{}let n=Mn(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 Yc(e){let t=Kc(),s=uh(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 ph(e){let t=e.yeaftSessionHydrateRequestId||null;e.yeaftSessionInventoryCompleteSupported!==!1||!t||(clearTimeout(e._legacyYeaftSessionHydrateTimer),e._legacyYeaftSessionHydrateTimer=setTimeout(()=>{e.yeaftSessionHydrateRequestId===t&&(e._legacyYeaftSessionHydrateTimer=null,Yc(e),e._hasHandledYeaftSessionHydrate=!0,e.yeaftSessionHydrateRequestId=null,e.yeaftSessionHydrateError=null,e._yeaftSessionInventorySocketQuarantined=!0)},ch))}function fh(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=Er(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=Er(n.rawRequest,t.rawRequestDelta)),n}function gh(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=fh(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??null,rawRequestBase:i}})}function Gc(e,t){let s=_e();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"auth_result":if(t.success){if(e.authenticated=!0,t.sessionKey&&(e.sessionKey=at(t.sessionKey),s.setSessionKey(t.sessionKey)),t.acceptPlaintext===!0&&(e.serverEncryptionRequired=!1),e.yeaftSessionInventoryCompleteSupported=t.yeaftSessionInventoryComplete===!0,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||Ee("login.error.loginFailed")}),s.handleAuthFailure?.(void 0,t._wsAuthToken,t._wsAuthGeneration);break;case"agent_list":jc(e,t),e.workCenterOpen&&e.workCenterAgentId&&e.listWorkItems(e.workCenterAgentId).catch(()=>{});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;dh(e,t),e.yeaftSessionInventoryCompleteSupported!==!0&&ph(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?Yc(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);break;case"session_ui_metadata_updated":{if(!e.finishSessionCatalogMutation?.(t)||t.ok!==!0)break;let n=e.sessionCatalog.find(r=>r.catalogKey===t.catalogKey);n&&(n.pinned=t.pinned===!0,n.sortRank=Number.isFinite(t.sortRank)?t.sortRank:null);break}case"session_catalog_reorder_result":e.finishSessionCatalogMutation?.(t);break;case"agent_selected":if(!Uc(e,t))break;e.workCenterOpen&&e.workCenterAgentId&&e.listWorkItems(e.workCenterAgentId).catch(()=>{});break;case"conversation_created":Tc(e,t);break;case"conversation_resumed":Mc(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":Dc(e,t);break;case"conversation_deleted":$o(e,t);break;case"conversation_delete_result":t.ok&&$o(e,t);break;case"turn_completed":Pc(e,t);break;case"conversation_closed":Rc(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":Vc(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=Lc(e,t);e.handleYeaftHistoryWindow(t,n);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=typeof t?.requestId=="string"?t.requestId:"",r=typeof t?.detailTurnId=="string"&&t.detailTurnId;if(n&&!r&&n!==e._yeaftDebugHistoryLatestListRequestId)break;e._fetchYeaftDebugHistoryTimer&&(clearTimeout(e._fetchYeaftDebugHistoryTimer),e._fetchYeaftDebugHistoryTimer=null),e._yeaftDebugHistoryInFlightKey=null;let i=Array.isArray(t?.turns)?t.turns:[],o=t?.search?lh:ah,a=r?i:i.slice(-o),l=new Set(a.map(m=>m?.turnId).filter(Boolean)),c=gh(Array.isArray(t?.loops)?t.loops:[]),d=r?c:c.filter(m=>!m?.turnId||l.has(m.turnId)),u=Array.isArray(t?.dreamEvents)?t.dreamEvents:[];e.yeaftDebugHistoryHasMore=!!t?.hasMore||!r&&i.length>a.length,!t?.detailTurnId&&Number.isFinite(t?.limit)&&t.limit>0&&(e.yeaftDebugHistoryLimit=Math.min(o,t.limit)),(!e.yeaftDebugTurnsById||typeof e.yeaftDebugTurnsById!="object")&&(e.yeaftDebugTurnsById={}),Array.isArray(e.yeaftDebugLoops)||(e.yeaftDebugLoops=[]),Array.isArray(e.yeaftDebugTurnOrder)||(e.yeaftDebugTurnOrder=[]);let f=r?{...e.yeaftDebugTurnsById}:{};for(let m of a){let b=m?.turnId;if(!b)continue;let T=f[b];if(T){let L=m?.detailsLoaded?{...T,...m}:{...m,...T};L.memoryLoaded==null&&T.memoryLoaded!=null&&(L.memoryLoaded=T.memoryLoaded),L.memoryAdjust==null&&T.memoryAdjust!=null&&(L.memoryAdjust=T.memoryAdjust),f[b]=L}else f[b]=m}e.yeaftDebugTurnsById=f;let p=m=>m?.loopInstanceId||`${m?.turnId||""}#${m?.loopNumber||0}`,g=e.yeaftDebugLoops,v=new Map;for(let m of g)m&&v.set(p(m),m);let h=new Set,A=[];for(let m of d){if(!m)continue;let b=p(m);h.add(b),A.push(v.get(b)||m)}if(r)for(let m of g)!m||h.has(p(m))||A.push(m);e.yeaftDebugLoops=A;let w=new Set,k=[],y=m=>{!m||w.has(m)||(w.add(m),k.push(m))};if(r){for(let m of e.yeaftDebugTurnOrder)y(m);for(let m of a)y(m?.turnId)}else for(let m of a)y(m?.turnId);e.yeaftDebugTurnOrder=r?k:k.slice(-o);for(let m of u){if(!m)continue;let b=null,T=m.sessionId||m.groupId;typeof m.target=="string"&&m.target.includes("/")?b=m.target:typeof T=="string"&&T?b=`group/${T}`:b="*",typeof e._appendDreamEvent=="function"&&e._appendDreamEvent(b,m),m.type==="dream_progress"&&typeof e.handleYeaftOutput=="function"&&e.handleYeaftOutput({event:m})}e.yeaftDebugHistoryLoading=!1,e.yeaftDebugHistoryError=typeof t?.error=="string"?t.error:null,e.yeaftDebugHistoryFetchedAt=Date.now();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"))&>(e),["No conversation selected","Agent is still syncing","No agent available"].some(c=>t.message?.includes(c))&&n&&(delete e.processingConversations[n],Ae(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 f=e.messagesMap[n];if(f){let p=f.findIndex(g=>g.id===u.id);p>=0&&f.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 f=u.findIndex(p=>p.id===d);f>=0&&u.splice(f,1)}},5e3)}!r&&n&&(delete e.processingConversations[n],Ae(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":_c(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":Ec(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"){Ae(e,n),vc(e,n);break}if(t.status==="ok")e.sessionHealth?.[n]&&delete e.sessionHealth[n],!t.isProcessing&&e.processingConversations[n]&&(delete e.processingConversations[n],Ae(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],Ae(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"restart_agent_ack":window.dispatchEvent(new CustomEvent("agent-restart-ack",{detail:{agentId:t.agentId}}));break;case"upgrade_agent_ack":window.dispatchEvent(new CustomEvent("agent-upgrade-ack",{detail:{agentId:t.agentId,success:t.success,error:t.error,alreadyLatest:t.alreadyLatest,version:t.version,reason:t.reason,currentNode:t.currentNode,requiredNode:t.requiredNode}}));break;case"terminal_created":case"terminal_output":case"terminal_closed":case"terminal_error":case"file_content":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":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||oh(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"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 ah,lh,ch,Qc=F(()=>{ct();mr();Tt();jt();ns();Oo();Pn();zc();_r();ah=1,lh=5,ch=500});function Zc(){return Object.values(Xc).sort((t,s)=>t.order-s.order).map(t=>({teamId:t.id,team:t,roles:Object.values(ut).filter(s=>s.group===t.id)}))}function Jc(e){let t=[];for(let s of Object.values(ut)){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 as(e,t){let s=ut[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 No(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=>!ut[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(f=>f.id===l);if(!d)return null;let u;if(c&&d.actions){let f=d.actions.find(p=>p.id===c);f?s?(u=(r?f.messageTemplate:f.messageTemplateEn)||"",u+=s):u=(r?f.defaultMessage:f.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(f=>f.id===l),u=ut[l];if(d)if(c){let f=d.actions?.find(p=>p.id===c);f&&o.push((r?f.messageTemplate:f.messageTemplateEn)||"")}else o.push((r?d.messagePrefix:d.messagePrefixEn)||"");else if(u)return null}return o.length===0?null:{effectivePrompt:o.join(`
|
|
3
|
+
${u}`:u,f=!0;break}}if(!f){for(let p=l.length-1;p>=0;p--)if(l[p].type==="tool-use"&&!l[p].hasResult){l[p].hasResult=!0,l[p].toolResult=u;break}}}n.currentTool=null}else if(!r&&(typeof o=="string"&&o.trim()||Array.isArray(s.message?.attachments)&&s.message.attachments.length>0)){let l=s.message?.clientMessageId||s.clientMessageId||null,c={type:"user",content:o,clientMessageId:l},d=e.messagesMap[t]||[];if(d.some(f=>xr(f,c))){if(l){for(let f=d.length-1;f>=0;f--)if(d[f].type==="user"&&d[f].clientMessageId===l){s.dbMessageId&&!d[f].dbMessageId&&(d[f].dbMessageId=s.dbMessageId),s.message?.id&&!d[f].messageId&&(d[f].id=s.message.id,d[f].messageId=s.message.id),s.ts&&!d[f].ts&&(d[f].ts=s.ts),Fc(e,d[f]);break}}}else{let f=e.addMessageToConversation(t,{...s.message?.id?{id:s.message.id,messageId:s.message.id}:{},...s.ts?{ts:s.ts}:{},type:"user",content:o,...s.message?.attachments?{attachments:s.message.attachments}:{},...s.message?.quote?{quote:s.message.quote}:{},...l?{clientMessageId:l}:{}});Fc(e,f)}}}else if(s.type==="result"){delete e.processingConversations[t],Ae(e,t);let r=e.conversations.find(c=>c.id===t);r&&r.connecting&&(r.connecting=!1);let i=e._currentYeaftSessionId||null;if(e._currentYeaftTurnId){let c=Object.entries(e.activeVpTurns||{}).find(([,d])=>(d?.turnId===e._currentYeaftTurnId||!d?.turnId&&d===e.activeVpTurns[e._currentYeaftTurnId])&&(!e._currentYeaftAgentId||!d?.agentId||d.agentId===e._currentYeaftAgentId));if(c){let[d,u]=c,{[d]:f,...p}=e.activeVpTurns;!i&&u?.sessionId&&(i=u.sessionId),e.activeVpTurns=p}}if(i&&e._currentYeaftVpId&&e.vpStatuses){let c=e._currentYeaftTurnId||null,d={...e.vpStatuses||{}},u=!1;for(let[f,p]of Object.entries(d))!p||p.vpId!==e._currentYeaftVpId||e._currentYeaftAgentId&&p.agentId&&p.agentId!==e._currentYeaftAgentId||(p.sessionId||p.groupId||null)!==i||c&&p.turnId&&p.turnId!==c||(d[f]={...p,state:"idle",turnId:null,since:Date.now()},u=!0);u&&(e.vpStatuses=d)}i&&typeof e.clearYeaftSessionProcessingIfIdle=="function"&&e.clearYeaftSessionProcessingIfIdle(i,{agentId:e._currentYeaftAgentId||null}),e._closedAt||(e._closedAt={}),e._closedAt[t]=Date.now(),e._turnCompletedConvs||(e._turnCompletedConvs=new Set),e._turnCompletedConvs.add(t),n.currentTool=null,Ut(e,t);let o=e.messagesMap[t]||[],a=s.result_text||"";if(typeof a=="string"&&a.trim()){let c=!1;for(let d=o.length-1;d>=0;d--){if(o[d].type==="assistant"){c=!0;break}if(o[d].type==="user")break}c||e.appendToAssistantMessageForConversation(t,a.trim())}e.finishStreamingForConversation(t),!e.promoteCompletedYeaftHistoryOutline?.(t,e._currentYeaftTurnId||null)&&i&&e.invalidateYeaftHistoryOutline?.(i),e.sweepStaleStreamingForConversation(t)}}var Hc=F(()=>{jt();_r();To()});function os(e){if(e==null)return e;try{return JSON.parse(JSON.stringify(e))}catch{return e}}function Er(e,t){if(!t)return e??null;if(Object.prototype.hasOwnProperty.call(t,"base"))return os(t.base)??null;if(Object.prototype.hasOwnProperty.call(t,"replacement"))return os(t.replacement)??null;let s=e&&typeof e=="object"&&!Array.isArray(e)?os(e):{};if(t.set&&typeof t.set=="object")for(let[n,r]of Object.entries(t.set))s[n]=os(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]=os(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]=os(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(os(t.body.messagesAppend)||[])}s.body=n}return s}function qc(e,t){return!t||!Object.prototype.hasOwnProperty.call(t,"rawRequestDelta")?e??null:Er(e??null,t.rawRequestDelta)}function Tn(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 rh(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 Nc(e){let t=0,s=0;if(e&&Array.isArray(e.messages))for(let i of e.messages){let{messageText:o,toolText:a}=rh(i);for(let l of o)t+=Tn(l);for(let l of a)s+=Tn(l)}let n=0,r=0;if(e&&typeof e.response=="string"&&(n+=Tn(e.response)),e&&Array.isArray(e.toolCalls)){for(let i of e.toolCalls)if(i&&(r+=Tn(String(i.name||"")),i.input!==void 0))try{r+=Tn(JSON.stringify(i.input))}catch{}}return{inputMessageTokens:t,inputToolTokens:s,outputMessageTokens:n,outputToolTokens:r,inputTotalEstimated:t+s,outputTotalEstimated:n+r}}function Fo(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 Bc(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 Oo=F(()=>{});function dt(e,t){return!e||!t?"":`${e}${t}`}function Mn(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 Ho(e){return e?`${e}`:""}function qo(e,t){return!e||!t?"":`${e}${t}`}var Pn=F(()=>{});function ih(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 Wc(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 jc(e,t){let s=Array.isArray(e.agents)?e.agents:[],n=e._hasHandledAgentList===!0,r=e.currentAgent||null,i=!!(r&&s.some(a=>a&&a.id===r&&a.online));e.agents=t.agents,e._hasHandledAgentList=!0;let o=e.currentAgent||null;if(o){let a=e._yeaftAgentSeen&&e._yeaftAgentSeen.id===o?e._yeaftAgentSeen:null,l=t.agents.find(c=>c.id===o)||null;e.currentView==="yeaft"&&ih(a,l)&&(e._yeaftReconnectCatchUpPending=!0),l?e._yeaftAgentSeen={id:o,online:!!l.online,version:l.version!=null?l.version:null}:a?a.online&&(e._yeaftAgentSeen={id:o,online:!1,version:a.version}):e._yeaftAgentSeen={id:o,online:!1,version:null}}{let a=new Set(t.agents.map(l=>l.id));for(let l of t.agents)e.proxyPorts[l.id]=l.proxyPorts||[],l.yeaftStatus&&typeof e.cacheYeaftAgentStatus=="function"&&e.cacheYeaftAgentStatus(l.id,l.yeaftStatus);for(let l of Object.keys(e.proxyPorts))a.has(l)||delete e.proxyPorts[l]}if(e.currentAgent){let a=t.agents.find(l=>l.id===e.currentAgent);a&&(e.currentAgentInfo=a)}if(e.currentView==="yeaft"&&!e.currentAgent){let a=t.agents.find(l=>l.online);a&&(e.currentAgent=a.id,e.currentAgentInfo=a)}if(e.currentView==="yeaft"&&typeof e.loadOpenedYeaftSessionsForConnectedAgents=="function"){let a=t.agents.filter(l=>l&&l.online&&l.id).map(l=>l.id);e.loadOpenedYeaftSessionsForConnectedAgents(a)}{let a=[],l=new Set;for(let d of t.agents)for(let u of d.conversations||[])l.has(u.id)||(l.add(u.id),a.push({...u,type:u.type,agentId:d.id,agentName:d.name}),u.title&&(u.customTitle&&(e.customConversationTitles[u.id]=u.title),e.conversationTitles[u.id]||(e.conversationTitles[u.id]=u.title)));for(let d of a){d.agentOnline=!0;let u=e.conversations.find(f=>f.id===d.id);if(u)u.claudeSessionId=d.claudeSessionId||u.claudeSessionId,u.processing=d.processing,u.userId=d.userId,u.username=d.username,u.agentId=d.agentId,u.agentName=d.agentName,u.agentOnline=!0,d.type&&(u.type=d.type),d.name!==void 0&&(u.name=d.name);else{let f=e._recentlyDeletedSessions?.[d.id];if(f&&Date.now()-f<15e3)continue;e.conversations.push(d)}d.pinned&&!e.pinnedSessions.includes(d.id)&&e.pinnedSessions.push(d.id)}let c=new Set(t.agents.map(d=>d.id));e.conversations=e.conversations.filter(d=>{if(l.has(d.id)||e.activeConversations.includes(d.id))return!0;if(d.agentId&&c.has(d.agentId)){let u=e._recentlyDeletedSessions?.[d.id];return u&&Date.now()-u<15e3||(delete e.messagesMap[d.id],delete e.processingConversations[d.id],Ae(e,d.id),delete e.executionStatusMap[d.id]),!1}return d.agentId&&!c.has(d.agentId)&&(d.agentOnline=!1),!0});for(let d of a)if(d.processing&&!is(e,d.id)&&!e._turnCompletedConvs?.has(d.id))e.processingConversations[d.id]=!0;else if(e.processingConversations[d.id]){delete e.processingConversations[d.id],Ae(e,d.id);let u=e.executionStatusMap[d.id];u&&(u.currentTool=null),e.finishStreamingForConversation(d.id)}for(let d of Object.keys(e.processingConversations))if(!l.has(d)){if(d.startsWith("yeaft-"))continue;delete e.processingConversations[d],Ae(e,d);let u=e.executionStatusMap[d];u&&(u.currentTool=null),e.finishStreamingForConversation(d)}}if(localStorage.setItem("pinned-sessions",JSON.stringify(e.pinnedSessions)),e._closedAt){let a=Date.now();for(let l of Object.keys(e._closedAt))a-e._closedAt[l]>3e4&&(delete e._closedAt[l],e._turnCompletedConvs?.delete(l))}if(e.currentAgent){let a=t.agents.find(l=>l.id===e.currentAgent&&l.online);if(a){let l=!!e._yeaftReconnectCatchUpPending,d=l||n&&!i;if(e.currentAgentInfo=a,d&&(e._offlineConversationRestoreKey=null,e.sendWsMessage({type:"select_agent",agentId:e.currentAgent,silent:!0})),e.currentView==="yeaft"&&typeof e.requestYeaftSessionBootstrap=="function"){e._yeaftReconnectCatchUpPending=!1;let u=l||!e.yeaftSessionReady||!e.yeaftModel||!e.yeaftStatus;(u||l)&&e.requestYeaftSessionBootstrap({forceSessionReady:u,catchUpHistory:l})}if(!d)return;if(e.currentConversation){let u=e.conversations.find(g=>g.id===e.currentConversation);e.sendWsMessage({type:"select_conversation",conversationId:e.currentConversation});let f=e.messagesMap[e.currentConversation]||[],p=rs(f);p!=null?e.requestChatHistory?.(e.currentConversation,{mode:"delta",afterMessageId:p}):e.requestChatHistory?.(e.currentConversation,{mode:"recent",turns:5}),e.sendWsMessage({type:"refresh_conversation",conversationId:e.currentConversation})}else e.recoveryDismissed||Wc(e);return}else{let l=`${e.currentAgent||""}:${e.currentConversation||""}`;e.currentConversation&&(!n||i||e._offlineConversationRestoreKey!==l)&&(e._offlineConversationRestoreKey=l,e.sendWsMessage({type:"select_conversation",conversationId:e.currentConversation}));return}}if(!e.currentConversation&&!e.currentAgent&&!e.recoveryDismissed){let a=e.lastViewedConversation||localStorage.getItem("lastViewedConversation"),l=e.lastUsedAgent;if(a){let c=e.conversations.find(d=>d.id===a);if(c){let d=t.agents.find(u=>u.id===c.agentId&&u.online);if(d){Wc(e,{agentId:c.agentId,agentInfo:d});return}}}l&&(e.agents.find(d=>d.id===l&&d.online)?e.selectAgent(l):e.checkPendingRecovery())}}function Uc(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"],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(f=>f.id===e.currentConversation);u&&!a.find(f=>f.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&&!is(e,u.id)&&!e._turnCompletedConvs?.has(u.id))e.processingConversations[u.id]=!0;else if(e.processingConversations[u.id]){delete e.processingConversations[u.id],Ae(e,u.id);let f=e.executionStatusMap[u.id];f&&(f.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],Ae(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(f=>f.id===e.currentConversation);e.currentWorkDir=u?.workDir||e.currentWorkDir||t.workDir,gt(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(f=>f.id===u)&&(e.autoRestoreConversation(u),e.pendingRecovery=null)}Fl(e)}return!0}var zc=F(()=>{jt();ns();Ds()});function oh(e={}){return{providers:e.providers||[],primaryModel:e.primaryModel||null,fastModel:e.fastModel||null,language:e.language||"en"}}function Kc(){return window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore()}function dh(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 uh(e){let t=Kc(),s=null;try{s=localStorage.getItem("lastViewedYeaftSession")||null}catch{}let n=Mn(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 Yc(e){let t=Kc(),s=uh(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 ph(e){let t=e.yeaftSessionHydrateRequestId||null;e.yeaftSessionInventoryCompleteSupported!==!1||!t||(clearTimeout(e._legacyYeaftSessionHydrateTimer),e._legacyYeaftSessionHydrateTimer=setTimeout(()=>{e.yeaftSessionHydrateRequestId===t&&(e._legacyYeaftSessionHydrateTimer=null,Yc(e),e._hasHandledYeaftSessionHydrate=!0,e.yeaftSessionHydrateRequestId=null,e.yeaftSessionHydrateError=null,e._yeaftSessionInventorySocketQuarantined=!0)},ch))}function fh(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=Er(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=Er(n.rawRequest,t.rawRequestDelta)),n}function gh(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=fh(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??null,rawRequestBase:i}})}function Gc(e,t){let s=_e();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"auth_result":if(t.success){if(e.authenticated=!0,t.sessionKey&&(e.sessionKey=at(t.sessionKey),s.setSessionKey(t.sessionKey)),t.acceptPlaintext===!0&&(e.serverEncryptionRequired=!1),e.yeaftSessionInventoryCompleteSupported=t.yeaftSessionInventoryComplete===!0,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||Ee("login.error.loginFailed")}),s.handleAuthFailure?.(void 0,t._wsAuthToken,t._wsAuthGeneration);break;case"agent_list":jc(e,t),e.workCenterOpen&&e.workCenterAgentId&&e.listWorkItems(e.workCenterAgentId).catch(()=>{});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;dh(e,t),e.yeaftSessionInventoryCompleteSupported!==!0&&ph(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?Yc(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);break;case"session_ui_metadata_updated":{if(!e.finishSessionCatalogMutation?.(t)||t.ok!==!0)break;let n=e.sessionCatalog.find(r=>r.catalogKey===t.catalogKey);n&&(n.pinned=t.pinned===!0,n.sortRank=Number.isFinite(t.sortRank)?t.sortRank:null);break}case"session_catalog_reorder_result":e.finishSessionCatalogMutation?.(t);break;case"agent_selected":if(!Uc(e,t))break;e.workCenterOpen&&e.workCenterAgentId&&e.listWorkItems(e.workCenterAgentId).catch(()=>{});break;case"conversation_created":Tc(e,t);break;case"conversation_resumed":Mc(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":Dc(e,t);break;case"conversation_deleted":$o(e,t);break;case"conversation_delete_result":t.ok&&$o(e,t);break;case"turn_completed":Pc(e,t);break;case"conversation_closed":Rc(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":Vc(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=Lc(e,t);e.handleYeaftHistoryWindow(t,n);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=typeof t?.requestId=="string"?t.requestId:"",r=typeof t?.detailTurnId=="string"&&t.detailTurnId;if(n&&!r&&n!==e._yeaftDebugHistoryLatestListRequestId)break;e._fetchYeaftDebugHistoryTimer&&(clearTimeout(e._fetchYeaftDebugHistoryTimer),e._fetchYeaftDebugHistoryTimer=null),e._yeaftDebugHistoryInFlightKey=null;let i=Array.isArray(t?.turns)?t.turns:[],o=t?.search?lh:ah,a=r?i:i.slice(-o),l=new Set(a.map(m=>m?.turnId).filter(Boolean)),c=gh(Array.isArray(t?.loops)?t.loops:[]),d=r?c:c.filter(m=>!m?.turnId||l.has(m.turnId)),u=Array.isArray(t?.dreamEvents)?t.dreamEvents:[];e.yeaftDebugHistoryHasMore=!!t?.hasMore||!r&&i.length>a.length,!t?.detailTurnId&&Number.isFinite(t?.limit)&&t.limit>0&&(e.yeaftDebugHistoryLimit=Math.min(o,t.limit)),(!e.yeaftDebugTurnsById||typeof e.yeaftDebugTurnsById!="object")&&(e.yeaftDebugTurnsById={}),Array.isArray(e.yeaftDebugLoops)||(e.yeaftDebugLoops=[]),Array.isArray(e.yeaftDebugTurnOrder)||(e.yeaftDebugTurnOrder=[]);let f=r?{...e.yeaftDebugTurnsById}:{};for(let m of a){let b=m?.turnId;if(!b)continue;let T=f[b];if(T){let L=m?.detailsLoaded?{...T,...m}:{...m,...T};L.memoryLoaded==null&&T.memoryLoaded!=null&&(L.memoryLoaded=T.memoryLoaded),L.memoryAdjust==null&&T.memoryAdjust!=null&&(L.memoryAdjust=T.memoryAdjust),f[b]=L}else f[b]=m}e.yeaftDebugTurnsById=f;let p=m=>m?.loopInstanceId||`${m?.turnId||""}#${m?.loopNumber||0}`,g=e.yeaftDebugLoops,h=new Map;for(let m of g)m&&h.set(p(m),m);let v=new Set,C=[];for(let m of d){if(!m)continue;let b=p(m);v.add(b),C.push(h.get(b)||m)}if(r)for(let m of g)!m||v.has(p(m))||C.push(m);e.yeaftDebugLoops=C;let w=new Set,k=[],y=m=>{!m||w.has(m)||(w.add(m),k.push(m))};if(r){for(let m of e.yeaftDebugTurnOrder)y(m);for(let m of a)y(m?.turnId)}else for(let m of a)y(m?.turnId);e.yeaftDebugTurnOrder=r?k:k.slice(-o);for(let m of u){if(!m)continue;let b=null,T=m.sessionId||m.groupId;typeof m.target=="string"&&m.target.includes("/")?b=m.target:typeof T=="string"&&T?b=`group/${T}`:b="*",typeof e._appendDreamEvent=="function"&&e._appendDreamEvent(b,m),m.type==="dream_progress"&&typeof e.handleYeaftOutput=="function"&&e.handleYeaftOutput({event:m})}e.yeaftDebugHistoryLoading=!1,e.yeaftDebugHistoryError=typeof t?.error=="string"?t.error:null,e.yeaftDebugHistoryFetchedAt=Date.now();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"))&>(e),["No conversation selected","Agent is still syncing","No agent available"].some(c=>t.message?.includes(c))&&n&&(delete e.processingConversations[n],Ae(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 f=e.messagesMap[n];if(f){let p=f.findIndex(g=>g.id===u.id);p>=0&&f.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 f=u.findIndex(p=>p.id===d);f>=0&&u.splice(f,1)}},5e3)}!r&&n&&(delete e.processingConversations[n],Ae(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":_c(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":Ec(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"){Ae(e,n),vc(e,n);break}if(t.status==="ok")e.sessionHealth?.[n]&&delete e.sessionHealth[n],!t.isProcessing&&e.processingConversations[n]&&(delete e.processingConversations[n],Ae(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],Ae(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"restart_agent_ack":window.dispatchEvent(new CustomEvent("agent-restart-ack",{detail:{agentId:t.agentId}}));break;case"upgrade_agent_ack":window.dispatchEvent(new CustomEvent("agent-upgrade-ack",{detail:{agentId:t.agentId,success:t.success,error:t.error,alreadyLatest:t.alreadyLatest,version:t.version,reason:t.reason,currentNode:t.currentNode,requiredNode:t.requiredNode}}));break;case"terminal_created":case"terminal_output":case"terminal_closed":case"terminal_error":case"file_content":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":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||oh(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"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 ah,lh,ch,Qc=F(()=>{ct();mr();Tt();jt();ns();Oo();Pn();zc();_r();ah=1,lh=5,ch=500});function Zc(){return Object.values(Xc).sort((t,s)=>t.order-s.order).map(t=>({teamId:t.id,team:t,roles:Object.values(ut).filter(s=>s.group===t.id)}))}function Jc(e){let t=[];for(let s of Object.values(ut)){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 as(e,t){let s=ut[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 No(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=>!ut[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(f=>f.id===l);if(!d)return null;let u;if(c&&d.actions){let f=d.actions.find(p=>p.id===c);f?s?(u=(r?f.messageTemplate:f.messageTemplateEn)||"",u+=s):u=(r?f.defaultMessage:f.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(f=>f.id===l),u=ut[l];if(d)if(c){let f=d.actions?.find(p=>p.id===c);f&&o.push((r?f.messageTemplate:f.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 td(e){return Object.values(Xc).filter(t=>e||!t.adminOnly).sort((t,s)=>t.order-s.order)}var Xc,ut,ed,ls,Rn=F(()=>{Xc={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}},ut={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"}]}};ed="dev",ls=3});function yh(e,t){return!t||!e?.yeaftConversationIdsByAgent?[]:Object.entries(e.yeaftConversationIdsByAgent).filter(([,s])=>s===t).map(([s])=>s).filter(Boolean)}function sd(){return`cm_${crypto.randomUUID()}`}function nd(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 rd(e,t,s=null,n=null,r={}){let i=s||e.currentAgent;if(!i){e.addMessage({type:"error",content:Ee("chat.agent.selectFirst")});return}_s(e,!0,Ee("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 id(e,t,s,n=null,r=null,i=null){let o=n||e.currentAgent;if(!o){e.addMessage({type:"error",content:Ee("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)),_s(e,!0,Ee("chat.session.loadingHistory"));let c={type:"resume_conversation",agentId:o,claudeSessionId:t,workDir:s||e.currentAgentWorkDir};a!==null&&(c.disallowedTools=a),typeof l.provider=="string"&&(c.provider=l.provider),l.providerOptions&&typeof l.providerOptions=="object"&&(c.providerOptions=l.providerOptions),e.sendWsMessage(c)}function od(e,t,s){if(e.panels.length>1){let a=e.activePanelId||e.panels[0]?.id;a&&e.setPanelConversation(a,t);return}if(t===e.currentConversation)return;let n=e.conversations.find(a=>a.id===t&&a.type!=="yeaft");if(n&&n.agentId&&n.agentId!==e.currentAgent){let a=e.agents.find(l=>l.id===n.agentId);a&&(e.currentAgent=n.agentId,e.currentAgentInfo=a,e.sendWsMessage({type:"select_agent",agentId:n.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],n&&(e.currentWorkDir=n.workDir);let r=e.messagesMap[t],i=rs(r);i!==null?e.requestChatHistory?.(t,{mode:"delta",afterMessageId:i}):((!r||r.length===0)&&(e.messagesMap[t]=[],_s(e,!0,Ee("chat.session.loadingHistory"))),e.requestChatHistory?.(t,{mode:"recent",turns:5})),e.loadingMoreMessages=!1;let o=e.chatSessionState[t];e.hasMoreMessages=!!o?.hasMoreOlder,Es(e)}function Bo(e,t,s){t&&e.sendWsMessage({type:"update_conversation_settings",conversationId:t,...s})}function ad(e,t,s){let n=e.currentConversation;if(!n)return;let r=e.conversationMcpServers[n];if(r){let f=r.find(p=>p.name===t);f&&(f.enabled=s)}let i=e.conversationMcpServers[n]||[],o=e.conversationMcpServerTools[n]||{},a=[];for(let f of i)if(!f.enabled){let p=o[f.name];p&&p.length>0?a.push(...p):a.push(`mcp__${f.name}`)}let u=[...(e.conversations.find(f=>f.id===n)?.disallowedTools||[]).filter(f=>!f.startsWith("mcp__")),...a];Bo(e,n,{disallowedTools:u})}function ld(e,t,s){return t?e.sendWsMessage({type:"delete_conversation",requestId:`delete_${crypto.randomUUID()}`,conversationId:t,...s?{agentId:s}:{}}):!1}function cd(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 dd(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=sd();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),Ls(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=No(n.expertSelections,e.customExpertRoles,t,e.language||"zh-CN");c&&(l.expertMessage=c.effectivePrompt)}e.sendWsMessage(l)||yn(e).then(()=>{e.sendWsMessage(l)}).catch(()=>{e.addMessage({type:"system",content:Ee("chat.connection.reconnectFailed")}),delete e.processingConversations[e.currentConversation],Ae(e,e.currentConversation)})}function ud(e){if(!e.currentConversation||!e.processingConversations[e.currentConversation])return;let t=e.currentConversation;e.sendWsMessage({type:"cancel_execution",conversationId:t}),delete e.processingConversations[t],Ae(e,t),e._closedAt||(e._closedAt={}),e._closedAt[t]=Date.now();let s=e.executionStatusMap[t];s&&(s.currentTool=null),e.finishStreamingForConversation(t),Ut(e,t),e.addMessage({type:"system",content:Ee("chat.execution.cancelled")})}function pd(e,t,s,n){let r=n||e.currentConversation,o=(e.messagesMap[r]||[]).find(g=>g.type==="tool-use"&&g.toolName==="AskUserQuestion"&&g.askRequestId===t),a=e.currentView==="yeaft"||!!o?.sessionId;if(a&&o?.askPending)return;let l=o?.sessionId||e.yeaftActiveSessionFilter||null,c=typeof o?.agentId=="string"&&o.agentId?o.agentId:null,d=a?yh(e,r):[],u=d.length===1?d[0]:null;if(c&&u&&c!==u)return!1;let f=a&&!c&&!u&&typeof e.agentIdForSession=="function"?e.agentIdForSession(l):null,p=e.sendWsMessage(a?{type:"yeaft_ask_user_answer",agentId:c||u||f||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});if(o&&!a)o.askAnswered=!0,o.selectedAnswers=s;else if(o&&p!==!1){let g=++vh;o.askPending=!0,o.pendingAnswers=s,o.askSubmitGeneration=g;let v=setTimeout(()=>{o.askSubmitGeneration!==g||o.askPending!==!0||(o.askPending=!1,o.pendingAnswers=null,o.askSubmitGeneration=null)},hh);typeof v?.unref=="function"&&v.unref()}p!==!1&&r&&!e.processingConversations[r]&&(e.processingConversations[r]=!0,e._closedAt?.[r]&&delete e._closedAt[r],e.getOrCreateExecutionStatus(r))}function fd(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})),Es(e)))}function gd(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),Es(e))}function md(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=sd();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),Ls(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=No(r.expertSelections,e.customExpertRoles,s,e.language||"zh-CN");d&&(c.expertMessage=d.effectivePrompt)}e.sendWsMessage(c)||yn(e).then(()=>{e.sendWsMessage(c)}).catch(()=>{e.addMessageToConversation(t,{type:"system",content:Ee("chat.connection.reconnectFailed")}),delete e.processingConversations[t],Ae(e,t)})}function hd(e,t){if(!t||!e.processingConversations[t])return;e.sendWsMessage({type:"cancel_execution",conversationId:t}),delete e.processingConversations[t],Ae(e,t),e._closedAt||(e._closedAt={}),e._closedAt[t]=Date.now();let s=e.executionStatusMap[t];s&&(s.currentTool=null),e.finishStreamingForConversation(t),Ut(e,t),e.addMessageToConversation(t,{type:"system",content:Ee("chat.execution.cancelled")})}function vd(e){e.ws&&e.ws.readyState===WebSocket.OPEN&&(typeof e.requestYeaftSessionInventory=="function"?e.requestYeaftSessionInventory():e.sendWsMessage({type:"get_agents"}))}function yd(e){!e.currentAgent||!e.currentConversation||e.sendWsMessage({type:"refresh_conversation",conversationId:e.currentConversation})}function bd(e,t){t&&e.sendWsMessage({type:"restart_agent",agentId:t})}function wd(e,t){t&&e.sendWsMessage({type:"upgrade_agent",agentId:t})}var hh,vh,kd=F(()=>{jt();ns();go();_r();Ds();Tt();Rn();hh=1e4,vh=0});function wh(e=globalThis.localStorage){try{return e?.getItem(Id)==="yeaft"?"yeaft":Sd}catch{return Sd}}function Wo(e,t=globalThis.localStorage){if(e!=="chat"&&e!=="yeaft")return!1;try{return t?.setItem(Id,e),!!t}catch{return!1}}function Cd(e=globalThis.localStorage){let t=wh(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 jo(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 Ad(e){let t=jo(e);return e.activeConversations=[e.yeaftConversationId],t}function xd(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 Id,Sd,Td=F(()=>{Id="yeaft-preferred-conversation-view",Sd="chat"});function Md(e,t,s){let n={...e||{}},r={...n[t]||{}};return r[s]=(r[s]||0)+1,n[t]=r,n}function Pd(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 Rd=F(()=>{});function Uo(e){return e.currentView==="yeaft"?e.yeaftConversationId||null:e.activeConversations[0]||null}var _d=F(()=>{});function Ed({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 Dd=F(()=>{});function Re(e){let t=Number(e);return Number.isFinite(t)?t:null}function Hs(e){let t=Re(e);return Number.isInteger(t)&&t>0?t:null}function zo(e){let t=Re(e);return Number.isInteger(t)&&t>=0?t:null}function Ld(e){return Ih.has(e)?1:0}function Ch(e,t){if(!e)return t||null;if(!t)return e;let s=Re(e.progressRevision),n=Re(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=Ld(e.status),i=Ld(t.status);if(r!==i)return i>r?t:e;let o=Re(e.updatedAt)??Re(e.createdAt)??0;return(Re(t.updatedAt)??Re(t.createdAt)??0)>o?t:e}function Os(e){return Math.max(0,Number(e)||0)}function $d(e){return typeof e?.id=="string"&&e.id.startsWith("event:")?e.id.slice(6):null}function Ah(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 xh(e,t){let s=Os(e?.createdAt)-Os(t?.createdAt);if(s)return s;let n=$d(e),r=$d(t);if(n!=null&&r!=null)return Ah(n,r);let i=e?.role==="user"?0:1,o=t?.role==="user"?0:1;if(i!==o)return i-o;let a=Os(e?.generation)-Os(t?.generation);return a||Os(e?.attempt)-Os(t?.attempt)||String(e?.id||"").localeCompare(String(t?.id||""))}function _n(...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,Ch(t.get(r.id),r))}return[...t.values()].sort(xh)}function st(e){let t=Number(e);return Number.isInteger(t)&&t>0?t:1}function qs(e,t,s,n){return`${e}:${t}:${s}:${st(n)}`}function En(e,t,s,n){return`${e}:${t}:${s}:${st(n)}`}function Ns(e,t){if(!e||!t||e.id!==t.id)return!1;let s=Re(e.revision),n=Re(t.revision);if(s!=null&&n!=null&&s!==n)return s<n;let r=Re(e.coordinatorRevision),i=Re(t.coordinatorRevision);if(r!=null&&i!=null&&r!==i)return r<i;let o=Re(e.updatedAt),a=Re(t.updatedAt);return o!=null&&a!=null&&o<a}function Vd(e,t){if(Ns(e,t))return!0;if(!e||!t||e.id!==t.id)return!1;let s=Re(e.revision),n=Re(t.revision);return e.currentActionId!==t.currentActionId&&s!=null&&n!=null&&s<=n}function Ko(e,t){let s=Hs(e?.generation),n=Hs(t?.generation);if(s!=null&&n!=null&&s!==n)return n<s;let r=zo(e?.attempt),i=zo(t?.attempt);if(r!=null&&i!=null&&r!==i)return i<r;let o=Re(e?.progressRevision),a=Re(t?.progressRevision);return o!=null&&a!=null&&a<o}function Yo(e,t){if(!e||e.id!==t?.id||Ns(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(g=>g?.id===t.eventActionId)?t.eventActionId:null,a=o||r!==i&&r||i;if(!a)return null;let l=s.find(g=>g?.id===a)||null,c=n.find(g=>g?.id===a)||(t.currentAction?.id===a?t.currentAction:null);if(l&&c&&Ko(l,c))return null;let d=Hs(l?.generation),u=Hs(c?.generation),f=zo(c?.attempt),p={actionId:a,generation:u||d||1,...f==null?{}:{attempt:f}};return o||r!==i||!l||d!=null&&u!=null&&u>d||l?.status==="running"&&c?.status&&c.status!=="running"?p:null}function Fd(e,t){if(!e||e.id!==t?.id||Ns(t,e))return!1;let s=Re(t.coordinatorRevision),n=Re(e.coordinatorRevision)??0;return s!=null&&s>n?!0:Yo(e,t)!=null}function Od(e,t){if(!e||e.id!==t?.id||Ns(t,e))return e;let s={...e},n=!Array.isArray(e.actions)||!Array.isArray(t.actionStats);if(Array.isArray(e.actions)&&Array.isArray(t.actionStats)){let r=new Map(t.actionStats.map(o=>[o?.id,o])),i=!1;n=!0,s.actions=e.actions.map(o=>{let a=r.get(o?.id);if(!a)return o;if(i=!0,Ko(o,a))return n=!1,o;if(Re(a?.progressRevision)==null){let{response:u,messages:f,...p}=a;return{...o,...p}}let c=Hs(o?.generation),d=Hs(a?.generation);if(c!=null&&d!=null&&d>c){let{messages:u,thread:f,liveMessage:p,response:g,failure:v,messageCursor:h,messageCount:A,failureReason:w,...k}=o;return{...k,...a}}return{...o,...a}}),i||(n=!1)}for(let r of Sh)!n&&Th.has(r)||Object.prototype.hasOwnProperty.call(t,r)&&(s[r]=t[r]);return s}function Hd(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?Ko(r,n):!1})}function qd(e,t){return Re(e?.revision)===Re(t?.revision)&&Re(e?.coordinatorRevision)===Re(t?.coordinatorRevision)&&Re(e?.updatedAt)===Re(t?.updatedAt)}function Nd(e,t){return!e||!t||e.id!==t.id?!1:Ns(e,t)?!0:qd(t,e)&&Hd(t.actions,e.actions)}function Dr(e,t){let s=Array.isArray(e)?e:[],n=s.find(i=>i.id===t?.id)||null,r=n&&Ns(t,n)?n:t;return n&&r===t&&qd(n,t)&&Hd(n.actionStats,t.actionStats)&&(r=n),r?.id?[r,...s.filter(i=>i.id!==r.id)].sort((i,o)=>Number(o.updatedAt||0)-Number(i.updatedAt||0)):s}var Sh,Ih,Th,Go=F(()=>{Sh=Object.freeze(["revision","planRevision","ledgerRevision","coordinatorRevision","title","goal","workItemType","planningMode","status","lifecycle","attentionState","activeActionIds","attentionActionIds","currentActionId","currentAction","executionStats","failureReason","origin","linkedSessionIds","createdAt","updatedAt"]);Ih=new Set(["completed","failed","cancelled","superseded","interrupted"]);Th=new Set(["status","lifecycle","attentionState","activeActionIds","attentionActionIds","currentActionId","currentAction","executionStats","failureReason"])});function cs(e){return typeof e=="string"?e.trim():""}function Bd(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 vt(e){let t=Bd(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 Mh(e){return Array.isArray(e)?e.slice(0,100).map(t=>({content:cs(t?.content).slice(0,2e3),status:["pending","in_progress","completed"].includes(t?.status)?t.status:"pending",...cs(t?.activeForm)?{activeForm:cs(t.activeForm).slice(0,2e3)}:{}})).filter(t=>t.content):[]}function Lr(e){if(!e||typeof e!="object")return null;let t=cs(e.content).slice(0,1e5),s=Mh(e.todos);if(!t&&s.length===0)return null;let n=e.role==="assistant"?"assistant":"user",r=Bd(e.timestamp);return{id:cs(e.id).slice(0,256)||null,role:n,author:cs(e.author).slice(0,256)||(n==="assistant"?"Assistant":"User"),content:t,...r?{timestamp:r}:{},...s.length>0?{todos:s}:{}}}function Wd(e,t){return Lr({id:e?.messageId||e?.id||null,role:"user",author:t,content:e?.content||"",timestamp:e?.timestamp||e?.createdAt||e?.ts||e?.time||null})}function jd(e,t){let s=e?.todoMsg?.toolInput?.todos,n=Array.isArray(e?.toolMsgs)?e.toolMsgs.map(o=>cs(o?.toolName)).filter(Boolean):[],r=Number(e?.toolSummaryCount||0)||0,i=n.length>0?`Tool actions: ${n.join(", ")}`:r>0?`Tool actions: ${r}`:"";return Lr({id:e?.atMessageId||e?.messageId||e?.id||e?.turnId||null,role:"assistant",author:t,content:e?.textContent||i,timestamp:e?.timestamp||e?.createdAt||e?.speakerTimestamp||null,todos:s})}var ds=F(()=>{});function Ud(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 Ph(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 zd(e,t={}){if(!Array.isArray(e)||!t.turnId)return!1;let s=e.filter(n=>Ph(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(Ud(s[n].content).trim()){s[n].responseKind="result";break}}return!0}function $r(e,t){if(!e||!t)return;let s=Ud(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 td(e){return Object.values(Xc).filter(t=>e||!t.adminOnly).sort((t,s)=>t.order-s.order)}var Xc,ut,ed,ls,Rn=F(()=>{Xc={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}},ut={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"}]}};ed="dev",ls=3});function yh(e,t){return!t||!e?.yeaftConversationIdsByAgent?[]:Object.entries(e.yeaftConversationIdsByAgent).filter(([,s])=>s===t).map(([s])=>s).filter(Boolean)}function sd(){return`cm_${crypto.randomUUID()}`}function nd(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 rd(e,t,s=null,n=null,r={}){let i=s||e.currentAgent;if(!i){e.addMessage({type:"error",content:Ee("chat.agent.selectFirst")});return}_s(e,!0,Ee("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 id(e,t,s,n=null,r=null,i=null){let o=n||e.currentAgent;if(!o){e.addMessage({type:"error",content:Ee("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)),_s(e,!0,Ee("chat.session.loadingHistory"));let c={type:"resume_conversation",agentId:o,claudeSessionId:t,workDir:s||e.currentAgentWorkDir};a!==null&&(c.disallowedTools=a),typeof l.provider=="string"&&(c.provider=l.provider),l.providerOptions&&typeof l.providerOptions=="object"&&(c.providerOptions=l.providerOptions),e.sendWsMessage(c)}function od(e,t,s){if(e.panels.length>1){let a=e.activePanelId||e.panels[0]?.id;a&&e.setPanelConversation(a,t);return}if(t===e.currentConversation)return;let n=e.conversations.find(a=>a.id===t&&a.type!=="yeaft");if(n&&n.agentId&&n.agentId!==e.currentAgent){let a=e.agents.find(l=>l.id===n.agentId);a&&(e.currentAgent=n.agentId,e.currentAgentInfo=a,e.sendWsMessage({type:"select_agent",agentId:n.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],n&&(e.currentWorkDir=n.workDir);let r=e.messagesMap[t],i=rs(r);i!==null?e.requestChatHistory?.(t,{mode:"delta",afterMessageId:i}):((!r||r.length===0)&&(e.messagesMap[t]=[],_s(e,!0,Ee("chat.session.loadingHistory"))),e.requestChatHistory?.(t,{mode:"recent",turns:5})),e.loadingMoreMessages=!1;let o=e.chatSessionState[t];e.hasMoreMessages=!!o?.hasMoreOlder,Es(e)}function Bo(e,t,s){t&&e.sendWsMessage({type:"update_conversation_settings",conversationId:t,...s})}function ad(e,t,s){let n=e.currentConversation;if(!n)return;let r=e.conversationMcpServers[n];if(r){let f=r.find(p=>p.name===t);f&&(f.enabled=s)}let i=e.conversationMcpServers[n]||[],o=e.conversationMcpServerTools[n]||{},a=[];for(let f of i)if(!f.enabled){let p=o[f.name];p&&p.length>0?a.push(...p):a.push(`mcp__${f.name}`)}let u=[...(e.conversations.find(f=>f.id===n)?.disallowedTools||[]).filter(f=>!f.startsWith("mcp__")),...a];Bo(e,n,{disallowedTools:u})}function ld(e,t,s){return t?e.sendWsMessage({type:"delete_conversation",requestId:`delete_${crypto.randomUUID()}`,conversationId:t,...s?{agentId:s}:{}}):!1}function cd(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 dd(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=sd();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),Ls(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=No(n.expertSelections,e.customExpertRoles,t,e.language||"zh-CN");c&&(l.expertMessage=c.effectivePrompt)}e.sendWsMessage(l)||yn(e).then(()=>{e.sendWsMessage(l)}).catch(()=>{e.addMessage({type:"system",content:Ee("chat.connection.reconnectFailed")}),delete e.processingConversations[e.currentConversation],Ae(e,e.currentConversation)})}function ud(e){if(!e.currentConversation||!e.processingConversations[e.currentConversation])return;let t=e.currentConversation;e.sendWsMessage({type:"cancel_execution",conversationId:t}),delete e.processingConversations[t],Ae(e,t),e._closedAt||(e._closedAt={}),e._closedAt[t]=Date.now();let s=e.executionStatusMap[t];s&&(s.currentTool=null),e.finishStreamingForConversation(t),Ut(e,t),e.addMessage({type:"system",content:Ee("chat.execution.cancelled")})}function pd(e,t,s,n){let r=n||e.currentConversation,o=(e.messagesMap[r]||[]).find(g=>g.type==="tool-use"&&g.toolName==="AskUserQuestion"&&g.askRequestId===t),a=e.currentView==="yeaft"||!!o?.sessionId;if(a&&o?.askPending)return;let l=o?.sessionId||e.yeaftActiveSessionFilter||null,c=typeof o?.agentId=="string"&&o.agentId?o.agentId:null,d=a?yh(e,r):[],u=d.length===1?d[0]:null;if(c&&u&&c!==u)return!1;let f=a&&!c&&!u&&typeof e.agentIdForSession=="function"?e.agentIdForSession(l):null,p=e.sendWsMessage(a?{type:"yeaft_ask_user_answer",agentId:c||u||f||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});if(o&&!a)o.askAnswered=!0,o.selectedAnswers=s;else if(o&&p!==!1){let g=++vh;o.askPending=!0,o.pendingAnswers=s,o.askSubmitGeneration=g;let h=setTimeout(()=>{o.askSubmitGeneration!==g||o.askPending!==!0||(o.askPending=!1,o.pendingAnswers=null,o.askSubmitGeneration=null)},hh);typeof h?.unref=="function"&&h.unref()}p!==!1&&r&&!e.processingConversations[r]&&(e.processingConversations[r]=!0,e._closedAt?.[r]&&delete e._closedAt[r],e.getOrCreateExecutionStatus(r))}function fd(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})),Es(e)))}function gd(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),Es(e))}function md(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=sd();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),Ls(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=No(r.expertSelections,e.customExpertRoles,s,e.language||"zh-CN");d&&(c.expertMessage=d.effectivePrompt)}e.sendWsMessage(c)||yn(e).then(()=>{e.sendWsMessage(c)}).catch(()=>{e.addMessageToConversation(t,{type:"system",content:Ee("chat.connection.reconnectFailed")}),delete e.processingConversations[t],Ae(e,t)})}function hd(e,t){if(!t||!e.processingConversations[t])return;e.sendWsMessage({type:"cancel_execution",conversationId:t}),delete e.processingConversations[t],Ae(e,t),e._closedAt||(e._closedAt={}),e._closedAt[t]=Date.now();let s=e.executionStatusMap[t];s&&(s.currentTool=null),e.finishStreamingForConversation(t),Ut(e,t),e.addMessageToConversation(t,{type:"system",content:Ee("chat.execution.cancelled")})}function vd(e){e.ws&&e.ws.readyState===WebSocket.OPEN&&(typeof e.requestYeaftSessionInventory=="function"?e.requestYeaftSessionInventory():e.sendWsMessage({type:"get_agents"}))}function yd(e){!e.currentAgent||!e.currentConversation||e.sendWsMessage({type:"refresh_conversation",conversationId:e.currentConversation})}function bd(e,t){t&&e.sendWsMessage({type:"restart_agent",agentId:t})}function wd(e,t){t&&e.sendWsMessage({type:"upgrade_agent",agentId:t})}var hh,vh,kd=F(()=>{jt();ns();go();_r();Ds();Tt();Rn();hh=1e4,vh=0});function wh(e=globalThis.localStorage){try{return e?.getItem(Id)==="yeaft"?"yeaft":Sd}catch{return Sd}}function Wo(e,t=globalThis.localStorage){if(e!=="chat"&&e!=="yeaft")return!1;try{return t?.setItem(Id,e),!!t}catch{return!1}}function Cd(e=globalThis.localStorage){let t=wh(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 jo(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 Ad(e){let t=jo(e);return e.activeConversations=[e.yeaftConversationId],t}function xd(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 Id,Sd,Td=F(()=>{Id="yeaft-preferred-conversation-view",Sd="chat"});function Md(e,t,s){let n={...e||{}},r={...n[t]||{}};return r[s]=(r[s]||0)+1,n[t]=r,n}function Pd(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 Rd=F(()=>{});function Uo(e){return e.currentView==="yeaft"?e.yeaftConversationId||null:e.activeConversations[0]||null}var _d=F(()=>{});function Ed({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 Dd=F(()=>{});function Re(e){let t=Number(e);return Number.isFinite(t)?t:null}function Hs(e){let t=Re(e);return Number.isInteger(t)&&t>0?t:null}function zo(e){let t=Re(e);return Number.isInteger(t)&&t>=0?t:null}function Ld(e){return Ih.has(e)?1:0}function Ch(e,t){if(!e)return t||null;if(!t)return e;let s=Re(e.progressRevision),n=Re(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=Ld(e.status),i=Ld(t.status);if(r!==i)return i>r?t:e;let o=Re(e.updatedAt)??Re(e.createdAt)??0;return(Re(t.updatedAt)??Re(t.createdAt)??0)>o?t:e}function Os(e){return Math.max(0,Number(e)||0)}function $d(e){return typeof e?.id=="string"&&e.id.startsWith("event:")?e.id.slice(6):null}function Ah(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 xh(e,t){let s=Os(e?.createdAt)-Os(t?.createdAt);if(s)return s;let n=$d(e),r=$d(t);if(n!=null&&r!=null)return Ah(n,r);let i=e?.role==="user"?0:1,o=t?.role==="user"?0:1;if(i!==o)return i-o;let a=Os(e?.generation)-Os(t?.generation);return a||Os(e?.attempt)-Os(t?.attempt)||String(e?.id||"").localeCompare(String(t?.id||""))}function _n(...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,Ch(t.get(r.id),r))}return[...t.values()].sort(xh)}function st(e){let t=Number(e);return Number.isInteger(t)&&t>0?t:1}function qs(e,t,s,n){return`${e}:${t}:${s}:${st(n)}`}function En(e,t,s,n){return`${e}:${t}:${s}:${st(n)}`}function Ns(e,t){if(!e||!t||e.id!==t.id)return!1;let s=Re(e.revision),n=Re(t.revision);if(s!=null&&n!=null&&s!==n)return s<n;let r=Re(e.coordinatorRevision),i=Re(t.coordinatorRevision);if(r!=null&&i!=null&&r!==i)return r<i;let o=Re(e.updatedAt),a=Re(t.updatedAt);return o!=null&&a!=null&&o<a}function Vd(e,t){if(Ns(e,t))return!0;if(!e||!t||e.id!==t.id)return!1;let s=Re(e.revision),n=Re(t.revision);return e.currentActionId!==t.currentActionId&&s!=null&&n!=null&&s<=n}function Ko(e,t){let s=Hs(e?.generation),n=Hs(t?.generation);if(s!=null&&n!=null&&s!==n)return n<s;let r=zo(e?.attempt),i=zo(t?.attempt);if(r!=null&&i!=null&&r!==i)return i<r;let o=Re(e?.progressRevision),a=Re(t?.progressRevision);return o!=null&&a!=null&&a<o}function Yo(e,t){if(!e||e.id!==t?.id||Ns(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(g=>g?.id===t.eventActionId)?t.eventActionId:null,a=o||r!==i&&r||i;if(!a)return null;let l=s.find(g=>g?.id===a)||null,c=n.find(g=>g?.id===a)||(t.currentAction?.id===a?t.currentAction:null);if(l&&c&&Ko(l,c))return null;let d=Hs(l?.generation),u=Hs(c?.generation),f=zo(c?.attempt),p={actionId:a,generation:u||d||1,...f==null?{}:{attempt:f}};return o||r!==i||!l||d!=null&&u!=null&&u>d||l?.status==="running"&&c?.status&&c.status!=="running"?p:null}function Fd(e,t){if(!e||e.id!==t?.id||Ns(t,e))return!1;let s=Re(t.coordinatorRevision),n=Re(e.coordinatorRevision)??0;return s!=null&&s>n?!0:Yo(e,t)!=null}function Od(e,t){if(!e||e.id!==t?.id||Ns(t,e))return e;let s={...e},n=!Array.isArray(e.actions)||!Array.isArray(t.actionStats);if(Array.isArray(e.actions)&&Array.isArray(t.actionStats)){let r=new Map(t.actionStats.map(o=>[o?.id,o])),i=!1;n=!0,s.actions=e.actions.map(o=>{let a=r.get(o?.id);if(!a)return o;if(i=!0,Ko(o,a))return n=!1,o;if(Re(a?.progressRevision)==null){let{response:u,messages:f,...p}=a;return{...o,...p}}let c=Hs(o?.generation),d=Hs(a?.generation);if(c!=null&&d!=null&&d>c){let{messages:u,thread:f,liveMessage:p,response:g,failure:h,messageCursor:v,messageCount:C,failureReason:w,...k}=o;return{...k,...a}}return{...o,...a}}),i||(n=!1)}for(let r of Sh)!n&&Th.has(r)||Object.prototype.hasOwnProperty.call(t,r)&&(s[r]=t[r]);return s}function Hd(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?Ko(r,n):!1})}function qd(e,t){return Re(e?.revision)===Re(t?.revision)&&Re(e?.coordinatorRevision)===Re(t?.coordinatorRevision)&&Re(e?.updatedAt)===Re(t?.updatedAt)}function Nd(e,t){return!e||!t||e.id!==t.id?!1:Ns(e,t)?!0:qd(t,e)&&Hd(t.actions,e.actions)}function Dr(e,t){let s=Array.isArray(e)?e:[],n=s.find(i=>i.id===t?.id)||null,r=n&&Ns(t,n)?n:t;return n&&r===t&&qd(n,t)&&Hd(n.actionStats,t.actionStats)&&(r=n),r?.id?[r,...s.filter(i=>i.id!==r.id)].sort((i,o)=>Number(o.updatedAt||0)-Number(i.updatedAt||0)):s}var Sh,Ih,Th,Go=F(()=>{Sh=Object.freeze(["revision","planRevision","ledgerRevision","coordinatorRevision","title","goal","workItemType","planningMode","status","lifecycle","attentionState","activeActionIds","attentionActionIds","currentActionId","currentAction","executionStats","failureReason","origin","linkedSessionIds","createdAt","updatedAt"]);Ih=new Set(["completed","failed","cancelled","superseded","interrupted"]);Th=new Set(["status","lifecycle","attentionState","activeActionIds","attentionActionIds","currentActionId","currentAction","executionStats","failureReason"])});function cs(e){return typeof e=="string"?e.trim():""}function Bd(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 vt(e){let t=Bd(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 Mh(e){return Array.isArray(e)?e.slice(0,100).map(t=>({content:cs(t?.content).slice(0,2e3),status:["pending","in_progress","completed"].includes(t?.status)?t.status:"pending",...cs(t?.activeForm)?{activeForm:cs(t.activeForm).slice(0,2e3)}:{}})).filter(t=>t.content):[]}function Lr(e){if(!e||typeof e!="object")return null;let t=cs(e.content).slice(0,1e5),s=Mh(e.todos);if(!t&&s.length===0)return null;let n=e.role==="assistant"?"assistant":"user",r=Bd(e.timestamp);return{id:cs(e.id).slice(0,256)||null,role:n,author:cs(e.author).slice(0,256)||(n==="assistant"?"Assistant":"User"),content:t,...r?{timestamp:r}:{},...s.length>0?{todos:s}:{}}}function Wd(e,t){return Lr({id:e?.messageId||e?.id||null,role:"user",author:t,content:e?.content||"",timestamp:e?.timestamp||e?.createdAt||e?.ts||e?.time||null})}function jd(e,t){let s=e?.todoMsg?.toolInput?.todos,n=Array.isArray(e?.toolMsgs)?e.toolMsgs.map(o=>cs(o?.toolName)).filter(Boolean):[],r=Number(e?.toolSummaryCount||0)||0,i=n.length>0?`Tool actions: ${n.join(", ")}`:r>0?`Tool actions: ${r}`:"";return Lr({id:e?.atMessageId||e?.messageId||e?.id||e?.turnId||null,role:"assistant",author:t,content:e?.textContent||i,timestamp:e?.timestamp||e?.createdAt||e?.speakerTimestamp||null,todos:s})}var ds=F(()=>{});function Ud(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 Ph(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 zd(e,t={}){if(!Array.isArray(e)||!t.turnId)return!1;let s=e.filter(n=>Ph(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(Ud(s[n].content).trim()){s[n].responseKind="result";break}}return!0}function $r(e,t){if(!e||!t)return;let s=Ud(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 Vr(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||Qo.has(l?.status)||Qo.has(l?.turnEndReason)||Qo.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 Qo,Fr=F(()=>{Qo=new Set(["aborted","errored","error","cancelled","canceled"])});function Xo(e){return e?.type==="user"&&typeof e.content=="string"&&e.content.trim()}function Zo(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 Jo(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 Kd(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(Xo(i)||i.type==="system"||i.type==="error"){n(r),s={start:r,kind:i.type};continue}if(!Zo(i)){s||(s={start:r,kind:"other"});continue}(!s||s.kind==="assistant"&&Jo(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 Yd(e,t){return t?e&&(e.sessionId??e.groupId)===t:!0}function ea(e=[],t=null,s=5){let n=Math.max(1,Number.isFinite(s)?Math.floor(s):5),r=[],i=[],o=null,a=c=>{o&&(i.push({start:o.start,end:c,kind:o.kind}),o=null)};for(let c of e){if(!Yd(c,t))continue;let d=r.length;if(r.push(c),Xo(c)||c.type==="system"||c.type==="error"){a(d),o={start:d,kind:c.type};continue}if(!Zo(c)){o||(o={start:d,kind:"other"});continue}(!o||o.kind==="assistant"&&Jo(o,c))&&(a(d),o={start:d,kind:"assistant",turnId:c.turnId||"",speakerVpId:c.speakerVpId||c.vpId||""}),o.lastTurnId=c.turnId||o.lastTurnId||"",o.speakerVpId=o.speakerVpId||c.speakerVpId||c.vpId||""}if(a(r.length),i.length<=n)return r;let l=i[i.length-n];return r.slice(l.start)}function Gd(e=[],t=null,s=5){let n=Math.max(1,s||5),r=0,i=null,o=()=>i?(i=null,r+=1,r>n):!1;for(let a of e)if(Yd(a,t)){if(Xo(a)||a.type==="system"||a.type==="error"){if(o())return!0;i={kind:a.type};continue}if(!Zo(a)){i||(i={kind:"other"});continue}if(!i||i.kind==="assistant"&&Jo(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 5}function Dn(){return 20}var Qd=F(()=>{});function _h(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=fs();for(let r of n?.sessionList||[])r?.id===t&&r?.agentId&&s.add(r.agentId)}return s}function du(e,t){let s=_h(e,t);return s.size===1?s.values().next().value:null}function Nr(e,t,s){return!!s&&du(e,t)===s}function pt(e,t,s){return!e||e.sessionId!==t?!1:s?e.agentId===s:!e.agentId}function Xd(e,t,s=null){if(!t)return!1;let n=s||Ce(e,t),r=dt(n,t);if(r&&e.yeaftProcessingSessions?.[r]||e.yeaftProcessingSessions?.[t]&&Nr(e,t,n))return!0;for(let i of Object.values(e.activeVpTurns||{}))if(pt(i,t,n))return!0;for(let i of Object.values(e.vpStatuses||{}))if(pt(i,t,n)&&Br.has(i?.state))return!0;return!1}function Eh(e,t,s,n=null){let r={...e.yeaftProcessingSessions||{}};if(t){let i=Ho(t);if(r=Object.fromEntries(Object.entries(r).filter(([o])=>n?o!==dt(t,n):!o.startsWith(i))),n)Nr(e,n,t)&&delete r[n];else for(let o of Object.keys(r))Nr(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||!Br.has(i?.state))continue;let a=dt(t,o)||o;r[a]=!0}return r}function Bs(e,t,s){let n=qo(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 Zd(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=Ho(t);e.yeaftProcessingSessions=Object.fromEntries(Object.entries(e.yeaftProcessingSessions||{}).filter(([n])=>!n.startsWith(s)))}function Mt(e,t){return`${e||""}:${t||""}`}function Fh(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 Oh(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 Hh(e={}){return{agentId:e.agentId||"",workItemId:e.workItemId||"",target:Fh(e.target),text:String(e.text||""),attachments:Array.isArray(e.attachments)?e.attachments.map(t=>({fileId:t?.fileId||"",name:t?.name||"",mimeType:t?.mimeType||"",size:Math.max(0,Number(t?.size)||0)})):[],revision:Number(e.revision)||0,planRevision:Number(e.planRevision)||0,ledgerRevision:Number(e.ledgerRevision)||0,coordinatorRevision:Number(e.coordinatorRevision)||0}}function eu(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 tu(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 qh(e,t){return oa.every(s=>!t[s]||e[s]===t[s])}function uu(e,t){return oa.every(s=>!e[s]||!t[s]||e[s]===t[s])}function su(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=>qh(tu(o,s),t));if(r.length===1)return r[0];let i=n.filter(o=>uu(tu(o,s),t));return i.length===1?i[0]:null}function pu(e){return oa.map(t=>e[t]||"").join("\0")}function Nh(e,t,s){let n=pu(t),r={...e._yeaftAskTerminalEvents||{},[n]:{identity:t,event:s,receivedAt:Date.now()}},i=Object.keys(r);if(i.length>Jd){i.sort((o,a)=>r[o].receivedAt-r[a].receivedAt);for(let o of i.slice(0,i.length-Jd))delete r[o]}e._yeaftAskTerminalEvents=r}function nu(e,t){let s=e._yeaftAskTerminalEvents||{},n=pu(t),r=s[n]?n:null;if(!r){let l=Object.entries(s).filter(([,c])=>uu(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 Bh(e,t,s){return(e.messagesMap?.[t]||[]).some(n=>n?.type==="tool-use"&&n.sessionId===s&&n.hasResult===!1)}function ta(e,t){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 Wh(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 jh(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 Ln(e){return e?.role==="assistant"&&e?.turnId?`response:${e.turnId}:${e.speakerVpId||e.vpId||""}`:e?.clientMessageId?`client:${e.clientMessageId}`:`message:${e?.messageId||""}`}function ru(e){let t=e?.updatedAt||e?.endedAt||e?.createdAt,s=t?Date.parse(t):NaN;return Number.isFinite(s)?s:0}function sa(e,t,s){return`${dt(e,t)}::${s||""}`}function na(e){let t=Object.entries(e||{}),s=t.filter(([,r])=>r?.status==="running"),n=t.filter(([,r])=>r&&r.status!=="running"&&ia.has(r.status)).sort((r,i)=>ru(i[1])-ru(r[1])).slice(0,Lh);return Object.fromEntries([...s,...n])}function fs(){try{return typeof window>"u"?null:window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore()||null}catch{return null}}function Ce(e,t,s=null){if(s)return s;if(t){let n=fs(),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 Uh(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 iu(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"&&Uh(n?.version||r?.version,"1.0.166")}function ps(e,{fallbackDefault:t=!1}={}){if(e?.yeaftActiveSessionFilter)return e.yeaftActiveSessionFilter;let s=fs();return s?.activeSessionId?s.activeSessionId:t?"grp_default":null}function qr(e){let t=e.yeaftDebugSessionFilter;if(t==="__all__")return null;if(t)return t;let s=ps(e);return s||(fs()?.sessions?.grp_default?"grp_default":null)}function zt(e,t,s=null){return s||t&&e?.yeaftConversationIdsByAgent?.[t]||e?.yeaftConversationId||null}function Pt(e,t=null){let s=t||e?.yeaftActiveSessionFilter||null,n=Ce(e,s);return(n&&e?.yeaftConversationIdsByAgent?e.yeaftConversationIdsByAgent[n]:null)||e?.yeaftConversationId||null}function ou(e,t,s){if(e?.currentView!=="yeaft")return!1;let n=e?.yeaftActiveSessionFilter||null;if(n&&t!==n)return!1;let r=Ce(e,n);return!r||!s||r===s}var Rh,Ve,Or,Hr,Dh,Lh,ia,Br,$h,Vh,Jd,oa,au,ra,lu,cu,gs,Wr=F(()=>{ct();co();Tt();go();Ds();Hc();Qc();kd();ns();jt();Td();xo();Ir();Rd();_d();Dd();po();Go();Po();ds();Fr();Mr();Do();Pn();Qd();({defineStore:Rh}=Pinia),Ve=Object.freeze([]),Or=(e,t,s)=>`${e||""}::${t||""}::${s}`;Hr=5,Dh=15e3,Lh=8,ia=new Set(["succeeded","failed","cancelled","orphaned"]),Br=new Set(["typing","thinking","retrying","streaming","tool"]),$h=Object.freeze(["model","availableModels","refreshedAt","catalogRefreshedAt","catalogEpoch","catalogRevision","catalogDigest","refreshStartedAt","refreshReason","refreshError","refreshing"]),Vh=8,Jd=64;oa=Object.freeze(["conversationId","agentId","requestId","toolCallId","sessionId","vpId","turnId","threadId"]);au=1e3,ra=1,lu=5,cu=200,gs=Rh("chat",{state:()=>({ws:null,authenticated:!1,_hasHandledAgentList:!1,_hasHandledYeaftSessionHydrate:!1,yeaftSessionInventoryCompleteSupported:null,yeaftSessionHydrateRequestId:null,yeaftSessionHydrateSlices:[],yeaftSessionHydrateError:null,_yeaftSessionInventorySocketQuarantined:!1,sessionKey:null,serverEncryptionRequired:!0,connectionState:"disconnected",reconnectAttempts:0,maxReconnectAttempts:10,reconnectTimer:null,agents:[],currentAgent:null,currentAgentInfo:null,conversations:[],activeConversations:[],currentWorkDir:null,messagesMap:{},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,sidebarCollapsed:!1,sessionSidebarOpen:!1,compactStatus:null,clearStatus:null,refreshingSession:!1,refreshingSessionMap:{},proxyPorts:{},hasMoreMessages:!1,loadingMoreMessages:!1,chatHistoryRequests:{},chatHistoryRequestIdSupported:null,chatHistoryConnectionGeneration:0,sessionCatalog:[],sessionProjects:[],sessionCatalogLoaded:!1,sessionCatalogMutationRequests:{},projectMutationRequests:{},activeCatalogKey:null,openUnifiedSessionCreate:!1,openUnifiedChatCreate:!1,pendingUnifiedSessionSettings:null,yeaftHasMoreHistory:!1,yeaftLoadingMoreHistory:!1,yeaftOldestLoadedSeq:null,yeaftHistoryLoadError:null,yeaftSessionHistoryState:{},yeaftMessageWindowState:{},yeaftBootstrapMetaLoadingKey:null,yeaftHistoryPerfTraceBySession:{},yeaftHistorySearchState:{requestId:null,agentId:null,sessionId:null,query:"",senderKey:"",loading:!1,results:[],hasMore:!1,nextBeforeSeq:null,error:null},yeaftHistoryOutlineBySession:{},_yeaftHistoryOutlineTimeouts:{},_yeaftHistorySearchTimeout:null,_yeaftHistoryWindowPendingByKey:{},_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,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")||"[]"),...Cd(),workCenterOpen:!1,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,yeaftDebugHistoryLimit:ra,yeaftDebugHistoryHasMore:!1,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=>Uo(e),activeSessionRoute(e){if(e.currentView==="yeaft"){let n=ps(e);return n?{runtimeProvider:"yeaft",agentId:Ce(e,n),sessionId:n}:null}let t=Uo(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]||Ve;if(e.currentView==="yeaft"){let n=e.yeaftActiveSessionFilter||"__all__",r=e.yeaftMessageWindowState[n]?.visibleTurns||us();return ea(s,e.yeaftActiveSessionFilter||null,r)}return s},yeaftAllMessages:e=>{let t=Pt(e);return t&&e.messagesMap[t]||Ve},yeaftVisibleMessages(e){let t=Pt(e),s=t&&e.messagesMap[t]||Ve,n=e.yeaftActiveSessionFilter||"__all__",r=e.yeaftMessageWindowState[n]?.visibleTurns||us();return ea(s,e.yeaftActiveSessionFilter||null,r)},hasHiddenYeaftMessages(e){if(e.currentView!=="yeaft")return!1;let t=Pt(e),s=t&&e.messagesMap[t]||Ve,n=e.yeaftActiveSessionFilter||"__all__",r=e.yeaftMessageWindowState[n]?.visibleTurns||us();return Gd(s,e.yeaftActiveSessionFilter||null,r)},activeYeaftHistoryState(e){return Eo(e)},yeaftInitialHistoryLoading(e){let t=Eo(e);return e.currentView==="yeaft"&&!!e.yeaftActiveSessionFilter&&!!t?.loading&&!t?.loaded&&this.yeaftVisibleMessages.length===0},vpsTypingInCurrentConv(e){let t=this.activeConversationId;if(!t)return Ve;let s=(e.yeaftVpTyping||{})[t];if(!s)return Ve;let n=Object.keys(s).filter(r=>(s[r]||0)>0);return n.length===0?Ve: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=qr(e);if(!t)return null;let s=`sessions/${t}`;return e.yeaftDreamLatest?.[s]||null},yeaftDreamSnapshotForActiveSession(e){let t=qr(e);if(!t)return null;let s=`sessions/${t}`;return e.yeaftDreamSnapshots?.[s]||null},yeaftDreamPromptLoadForActiveSession(e){let t=qr(e);if(!t)return null;let s=`sessions/${t}`;return e.yeaftDreamPromptLoads?.[s]||null},yeaftDreamEventsForActiveSession(e){let t=qr(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||Ve,s=e.yeaftDebugTurnsById||{},n=e.yeaftDebugLoops||Ve,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],f=s[u];if(!f||o&&f.sessionId&&f.sessionId!==o)continue;let p=a[u]||Ve,g=l[u]||Ve,v=p.length,h=0,A=0;for(let y of p){let m=y&&y.usage;m&&Number.isFinite(m.totalTokens)?h+=m.totalTokens:m&&(h+=(m.totalInputTokens||(m.inputTokens||0)+(m.cacheReadTokens||0)+(m.cacheWriteTokens||0))+(m.outputTokens||0)),y&&Number.isFinite(y.latencyMs)&&(A+=y.latencyMs)}let w=!f.closedAt,k={...f,loopCount:w||!f.loopCount?v:f.loopCount,totalTokens:w||!f.totalTokens?h:f.totalTokens,totalMs:w||!f.totalMs?A:f.totalMs,loops:p,reflections:g};c.push(k)}return c},yeaftDebugAvailableSessions:e=>{let t=new Set;for(let s of e.yeaftDebugTurnOrder||Ve){let n=e.yeaftDebugTurnsById[s];n&&n.sessionId&&t.add(n.sessionId)}return Array.from(t).sort()},yeaftDebugTurnTotal:e=>(e.yeaftDebugTurnOrder||Ve).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=ps(e);return t?Xd(e,t,Ce(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"?fs()?.activeSession?.workDir||e.yeaftYeaftDir||e.currentAgentInfo?.workDir||"":e.currentWorkDir||e.currentAgentInfo?.workDir||"",currentAgentCapabilities:e=>e.currentAgentInfo?.capabilities||["terminal","file_editor","background_tasks"],hasCapability:e=>t=>(e.currentAgentInfo?.capabilities||["terminal","file_editor","background_tasks"]).includes(t),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)=>Xd(e,t,s),isYeaftSessionUnread:e=>(t,s=null)=>{if(!t)return!1;let n=Ce(e,t,s);return n?!!e.yeaftUnreadSessionKeys?.[br(n,t)]:!1},showRecoveryBanner:e=>e.pendingRecovery&&!e.recoveryDismissed&&!e.currentConversation,currentSubagents:e=>{if(!e.currentConversation)return Ve;let t=e.subagents[e.currentConversation];return t?Object.values(t):Ve},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 Ve;let t=e.subagents[e.currentConversation];if(!t)return Ve;let s=t[e.activeSubagentId];return(Array.isArray(s?.messages)?s.messages:Ve).filter(r=>r?.type==="text")},selectedTaskInfo:()=>null,currentMcpServers:e=>e.currentConversation&&e.conversationMcpServers[e.currentConversation]||Ve},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&&Wo("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),xd(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[0]?.id||null;if(!s)return this.workCenterOpen=!1,this.workCenterAgentId=null,!1;if(this.currentAgent!==s){this.selectAgent(s),this.currentAgent=s;let n=this.agents.find(r=>r.id===s);n&&(this.currentAgentInfo=n)}return this.workCenterAgentId=s,this.workCenterOpen=!0,this.listWorkItems(s).catch(()=>{}),!0},leaveWorkCenter(){this.workCenterOpen=!1},enterWorkCenterFromSession(e,t=""){if(!e?.id)return;let s=e.agentId||Ce(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=Ml(()=>{fn(this._workCenterBrowserFence)||this.clearWorkCenterBrowserState()}));let e=vr();if(!e)return this._workCenterBrowserFence=null,this.workCenterComposerDrafts={},this.workCenterMessageOutbox={},!1;if(!fn(this._workCenterBrowserFence)){let t=Tl(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 Mt(e,t)},saveWorkCenterComposerDraft(e,t,s={}){let n=Mt(e,t);if(!e||!t)return;let r={...this.workCenterComposerDrafts||{},[n]:{text:String(s.text||""),attachments:Array.isArray(s.attachments)?s.attachments:[],target:Oh(s.target),error:String(s.error||"")}};return lo(r,this._workCenterBrowserFence)?(this.workCenterComposerDrafts=r,!0):!1},loadWorkCenterComposerDraft(e,t){return this.workCenterComposerDrafts?.[Mt(e,t)]||null},removeWorkCenterComposerDraft(e,t){let s=Mt(e,t),n={...this.workCenterComposerDrafts||{}};return delete n[s],lo(n,this._workCenterBrowserFence)?(this.workCenterComposerDrafts=n,!0):!1},prepareWorkCenterMessageEnvelope(e={}){let t=Hh(e),s=Mt(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 gn(i,this._workCenterBrowserFence)?(this.workCenterMessageOutbox=i,r):null},loadWorkCenterMessageEnvelope(e,t){return this.workCenterMessageOutbox?.[Mt(e,t)]||null},replaceWorkCenterMessageEnvelopeAttachments(e,t,s=[]){let n=Mt(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 gn(o,this._workCenterBrowserFence)?(this.workCenterMessageOutbox=o,i):null},discardWorkCenterMessageEnvelope(e,t){let s=Mt(e,t),n={...this.workCenterMessageOutbox||{}};return delete n[s],gn(n,this._workCenterBrowserFence)?(this.workCenterMessageOutbox=n,!0):!1},confirmWorkCenterMessageEnvelope(e,t,s){let n=Mt(e,t),r=this.workCenterMessageOutbox?.[n];if(!r||r.clientMessageId!==s)return!1;let i={...this.workCenterMessageOutbox||{}};return delete i[n],gn(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=Dr(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=l,u=this._workCenterListEventsByAgent[s]||{};for(let f of Object.values(u))Number(f?.generation)<=o||f?.queryKey!==r||(d=this.applyWorkItemBoardSummary(d,f.summary,n));this.workCenterItemsByAgent={...this.workCenterItemsByAgent,[s]:d},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 f=[...this.workCenterItemsByAgent[t]||[]];for(let g of Array.isArray(d?.items)?d.items:[]){if(this.workItemDeleted(t,g?.id))continue;let v=f.findIndex(h=>h.id===g.id);v<0?f.push(g):f[v]=Dr([f[v]],g)[0]}let p=this._workCenterListEventsByAgent[t]||{};for(let g of Object.values(p))Number(g?.generation)<=o||g?.queryKey!==r||(f=this.applyWorkItemBoardSummary(f,g.summary,n));return this.workCenterItemsByAgent={...this.workCenterItemsByAgent,[t]:f},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];return n?.id===t?.id&&Nd(t,n)?!1:(this.workCenterDetailByAgent={...this.workCenterDetailByAgent,[e]:t},!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=st(n),i=qs(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=st(s),a=qs(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)||st(u?.generation)!==o||Number(this._workCenterActionMessageGenerationByKey[a]||0)!==l)return u;let f=this.workCenterActionMessages[a]?.messages||[],p=_n(f,u?.messages||[]),g=this.workCenterActionMessages[a],v=g?.nextCursor,h=n==null?null:Number(n),A=v==null?null:Number(v),w=!g||h==null||A!=null&&h===A;return this.workCenterActionMessages={...this.workCenterActionMessages,[a]:{generation:o,messages:p,nextCursor:w?u?.nextCursor??null:v,total:Math.max(Number(u?.total)||0,Number(g?.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 f=Object.keys(u).some(p=>p.startsWith(`${a}:`));this.workCenterActionMessagesLoading={...this.workCenterActionMessagesLoading,[a]:f}}}})();return this._workCenterActionMessageRequests={...this._workCenterActionMessageRequests,[c]:d},d},async loadWorkItemActionRequests(e,t,s,n=null){let r=n||this.workCenterAgentId||this.currentAgent,i=st(s),o=En(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)&&st(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=st(s),c=`${En(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),f=!this.workItemDeleted(o,e)&&st(u?.generation)===a&&this._workCenterActionRequestDetailsGeneration[c]===d;return f&&(this.workCenterActionRequestDetails={...this.workCenterActionRequestDetails,[c]:u?.request||null}),f?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){let n=s||this.workCenterAgentId||this.currentAgent,r=this.beginWorkCenterDetailWrite(n),i=await this.workCenterRequest("resume",{id:e,revision:t},n);return await this.listWorkItems(n,this._workCenterListFiltersByAgent[n]||{}),this.commitWorkCenterDetail(n,i,r),i},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={}){if(!this.hydrateWorkCenterBrowserState())throw new Error("Work Center browser owner is unavailable; sign in again and retry");let a=i||this.workCenterAgentId||this.currentAgent,l=this.prepareWorkCenterMessageEnvelope({agentId:a,workItemId:e,target:s,text:t,attachments:r,revision:n,planRevision:o.planRevision,ledgerRevision:o.ledgerRevision,coordinatorRevision:o.coordinatorRevision});if(!l)throw new Error("Work Center browser owner changed; reopen Work Center and try again");let c=l.clientMessageId,d=this.workCenterDetailByAgent[a]?.id===e?this.workCenterDetailByAgent[a]:null,u=await this.workCenterRequest("post_work_item_message",{id:l.workItemId,clientMessageId:c,text:l.text,target:l.target,revision:l.revision,planRevision:l.planRevision||Number(d?.planRevision)||0,ledgerRevision:l.ledgerRevision||Number(d?.ledgerRevision)||0,coordinatorRevision:Number.isInteger(Number(l.coordinatorRevision))?Number(l.coordinatorRevision):Number(d?.coordinatorRevision)||0,attachments:l.attachments},a);if(l.target.kind==="coordinator"){if(!u?.accepted)throw new Error("Work Center Coordinator did not accept the message");return this.confirmWorkCenterMessageEnvelope(a,e,c),u}return await this.listWorkItems(a,this._workCenterListFiltersByAgent[a]||{}),this.confirmWorkCenterMessageEnvelope(a,e,c),u},async sendWorkItemMessage(e,t,s,n=[],r=null,i={}){let o=r||this.workCenterAgentId||this.currentAgent,a=this.workCenterDetailByAgent[o]?.id===e?this.workCenterDetailByAgent[o]:null,l=await this.workCenterRequest("work_item_message",{id:e,text:t,revision:s,planRevision:Number.isInteger(Number(i.planRevision))?Number(i.planRevision):Number(a?.planRevision)||0,ledgerRevision:Number.isInteger(Number(i.ledgerRevision))?Number(i.ledgerRevision):Number(a?.ledgerRevision)||0,coordinatorRevision:Number.isInteger(Number(i.coordinatorRevision))?Number(i.coordinatorRevision):Number(a?.coordinatorRevision)||0,attachments:Array.isArray(n)?n:[]},o);if(!l?.accepted)throw new Error("Work Center Coordinator did not accept the message");return l},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){let a=o||this.workCenterAgentId||this.currentAgent,l=Number(this._workCenterActionInputGenerationByAgent[a]||0)+1;this._workCenterActionInputGenerationByAgent={...this._workCenterActionInputGenerationByAgent,[a]:l};let c=await this.workCenterRequest("action_input",{id:e,text:t,actionId:s,revision:n,generation:r,attachments:i},a);await this.listWorkItems(a,this._workCenterListFiltersByAgent[a]||{});let d=this.workCenterDetailByAgent[a],u=d?.actions?.find(p=>p?.id===s),f=d?.id===e&&Number(d.revision)===Number(n)&&u&&Number(u.generation)===Number(r);return this._workCenterActionInputGenerationByAgent[a]===l&&f&&!Vd(c,d)?(this.workCenterDetailByAgent={...this.workCenterDetailByAgent,[a]:c},c):d?.id===e?d:c},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(([,f])=>f?.agentId===e&&f.clientMessageId===t.clientMessageId);if(u){let[f,p]=u;clearTimeout(p.timer),delete this.workCenterPending[f],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=Dr(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(A=>A?.id===t.actionId)?{...s,eventActionId:t.actionId}:s,f=Yo(d,u),p=Number(s.coordinatorRevision),g=Number(d.coordinatorRevision)||0,v=Number.isInteger(p)&&p>g,h=Fd(d,u);this.workCenterDetailByAgent={...this.workCenterDetailByAgent,[e]:Od(d,s)},h&&this.refreshWorkItemDetailAfterActionChange(e,s,v?null:f)}},async refreshWorkItemDetailAfterActionChange(e,t,s=null){let n=s?(Array.isArray(t.actionStats)?t.actionStats:[]).find(v=>v?.id===s.actionId):(Array.isArray(t.actionStats)?t.actionStats:[]).find(v=>v?.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 f=this.beginWorkCenterDetailWrite(e),p={key:u,generation:f};this._workCenterDetailEventRefreshByAgent={...this._workCenterDetailEventRefreshByAgent,[e]:p},s&&this.invalidateWorkItemActionMessages(e,t.id,s.actionId,s.generation);let g=r&&o!=null?this.loadWorkItemActionMessages(t.id,r,o,null,e).catch(()=>null):null;try{let v=await this.workCenterRequest("get",{id:t.id},e),h=this.workCenterDetailByAgent[e],A=h?.actions?.find(T=>T?.id===r),w=v?.actions?.find(T=>T?.id===r),k=o==null||st(A?.generation)===o,y=o==null||st(w?.generation)>=o,m=l==null||Number(v?.coordinatorRevision)===l,b=l!=null||k&&y&&(t.currentActionId==null?v?.currentActionId==null:h?.currentActionId===t.currentActionId&&v?.currentActionId===t.currentActionId);h?.id===t.id&&m&&b&&this.commitWorkCenterDetail(e,v,f)&&g&&await g}catch{}finally{if(this._workCenterDetailEventRefreshByAgent[e]===p){let v={...this._workCenterDetailEventRefreshByAgent};delete v[e],this._workCenterDetailEventRefreshByAgent=v}}},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),f=Array.isArray(this._yeaftRetiredCatalogEpochsByAgent?.[e])?this._yeaftRetiredCatalogEpochsByAgent[e]:[],p=!!a&&f.includes(a),g=!!a&&a===o,v=i>0?g&&i===r:c>0&&c===l,h=i>0?!!a&&(a!==o||i>r):r===0&&c>l,A=i>0?!!t.catalogDigest&&!!n.catalogDigest&&t.catalogDigest===n.catalogDigest:t.catalogDigest===n.catalogDigest,w=u&&!p&&(h||v&&A),y=w||s&&r===0&&l===0&&!u&&d,m={...t};if(!y)for(let T of $h)delete m[T];let b={...n,...m};if(y){if(w&&o&&a&&o!==a){let T=[...f.filter(L=>L!==o),o].slice(-Vh);this._yeaftRetiredCatalogEpochsByAgent={...this._yeaftRetiredCatalogEpochsByAgent||{},[e]:T}}b.availableModels=t.availableModels,b.catalogRefreshedAt=w?c:null,b.catalogEpoch=w&&a||null,b.catalogRevision=w&&i||null,b.catalogDigest=w&&t.catalogDigest||null}this.yeaftStatusByAgent={...this.yeaftStatusByAgent,[e]:b},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 Ce(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))},Dh),e):(this.yeaftSessionHydrateRequestId=null,this.yeaftSessionHydrateSlices=[],this.yeaftSessionHydrateError="session_inventory_send_failed",null)},beginYeaftHistoryLoad(e){let t=wc(this,e);if(!t)return null;let{agentId:s,sessionId:n}=e||{};return setTimeout(()=>{Sc(this,{agentId:s,sessionId:n,requestId:t.requestId,error:"history_load_timeout"})},bc),t},finishYeaftHistoryLoad(e,t={},s="chunk"){return kc(this,e,t,s)},isCurrentYeaftHistoryResponse(e){return _o(this,e)},syncActiveYeaftHistoryLoad(){return xn(this)},enterYeaft(e=null,{deferBootstrap:t=!1}={}){let s=this.currentAgent;jo(this);let n=ps(this),r=!e&&n?Ce(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]=[]),Ad(this),this.currentView="yeaft",Wo("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=ps(this),r=n?Ce(this,n):this.currentAgent,i=Pe(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(w=>w&&(w.sessionId??w.groupId??null)===n),d=!!n&&ko({sessionState:o,hasCachedSessionRows:c,force:!!s}),u=!!n&&!d&&dc(o,t);if(!a&&!d&&!u)return!1;let f=`${r}:${n||"__none__"}`,p=a&&!d&&!u;if(p&&this.yeaftBootstrapMetaLoadingKey===f)return!1;p&&(this.yeaftBootstrapMetaLoadingKey=f);let g=null;n&&d?g=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&&(g=this.beginYeaftHistoryLoad({agentId:r,sessionId:n,mode:"delta",preserveLoaded:!0,latestSeq:l}));let v={type:"yeaft_load_history",agentId:r,sessionId:n,...g?{requestId:g.requestId}:{}};u?v.afterSeq=l:v.limit=d?Hr:0;let h=Cn();v.perfTraceId=h;let A=u?"delta":d?"recent":"metadata";return n&&(this.yeaftHistoryPerfTraceBySession={...this.yeaftHistoryPerfTraceBySession||{},[i]:h}),Ze(this,{traceId:h,phase:"history.request_send",agentId:r,sessionId:n,messageType:v.type,bytes:JSON.stringify(v).length,detail:{mode:A,limit:v.limit??null,afterSeq:v.afterSeq??null,hasCachedSessionRows:c,needSessionReady:a}}),this.sendWsMessage(v),!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}={}){if(!this.currentAgent)return;let o=typeof i=="string"?i.trim():(this.yeaftDebugSearch||"").trim(),a=typeof r=="string"&&r,l=o&&!a?lu:ra,c=Number.isFinite(t)&&t>0?t:this.yeaftDebugHistoryLimit||l,d=Math.max(1,Math.min(l,c)),u=a?"detail":"list",f=`dbg_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,10)}`,p=JSON.stringify({agentId:this.currentAgent,groupId:e||null,limit:d,dreamLimit:Number.isFinite(s)&&s>0?s:5,indexOnly:!!n,detailTurnId:r||null,search:a?"":o});if(this._yeaftDebugHistoryInFlightKey===p)return;this._yeaftDebugHistoryInFlightKey=p,a||(this._yeaftDebugHistoryLatestListRequestId=f),this.yeaftDebugHistoryLimit=d,this.yeaftDebugHistoryLoading=!0,this.yeaftDebugHistoryError=null;let g={type:"yeaft_fetch_debug_history",agentId:this.currentAgent,requestId:f,requestKind:u,limit:d,dreamLimit:Number.isFinite(s)&&s>0?s:5};n&&(g.indexOnly=!0),typeof r=="string"&&r?g.detailTurnId=r:o&&(g.search=o),typeof e=="string"&&e&&(g.sessionId=e),this.sendWsMessage(g),this._fetchYeaftDebugHistoryTimer&&clearTimeout(this._fetchYeaftDebugHistoryTimer),this._fetchYeaftDebugHistoryTimer=setTimeout(()=>{this.yeaftDebugHistoryLoading&&(this.yeaftDebugHistoryLoading=!1,this.yeaftDebugHistoryError="Debug history is unavailable right now. Try again after the agent reconnects."),this._yeaftDebugHistoryInFlightKey=null,this._fetchYeaftDebugHistoryTimer=null},1e4)},agentIdForSession(e){return Ce(this,e)},sendYeaftSessionMessage({groupId:e,text:t,mentions:s,attachments:n,quote:r}){let i=Ce(this,e);if(!e||!i)return;let o=Array.isArray(n)?n.filter(g=>g&&g.fileId):[],a=Lr(r),l=o.length>0;if(!t?.trim()&&!l)return;let c=t?.trim()?t:"(attached files)",d=`u_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,10)}`,u=Cn();this.yeaftPerfTraceByMessageId={...this.yeaftPerfTraceByMessageId||{},[d]:u},Ze(this,{traceId:u,phase:"send.prepare",agentId:i,sessionId:e,turnId:d,messageType:"yeaft_session_send",detail:{mentionCount:Array.isArray(s)?s.length:0,attachmentCount:o.length,quoted:!!a}});let f=Pt(this,e);if(f){let g={id:d,messageId:d,clientMessageId:d,type:"user",content:c,sessionId:e,turnId:d,...a?{quote:a}:{}};if(o.length>0&&(g.attachments=o.map(v=>({fileId:v.fileId,name:v.name,preview:v.preview,isImage:!!v.isImage,mimeType:v.mimeType||""}))),this.addMessageToConversation(f,g),this.processingConversations[f]=!0,e){let v=dt(i,e);this.yeaftProcessingSessions={...this.yeaftProcessingSessions,...v?{[v]:!0}:{}}}this._turnCompletedConvs?.delete(f),this._closedAt?.[f]&&delete this._closedAt[f],this.getOrCreateExecutionStatus(f),wn(this,f)}let p={type:"yeaft_session_send",agentId:i,id:d,sessionId:e,text:c,mentions:Array.isArray(s)?s:[],perfTraceId:u,...a?{quote:a}:{}};o.length>0&&(p.attachments=o.map(g=>({fileId:g.fileId,isImage:!!g.isImage}))),Ze(this,{traceId:u,phase:"send.websocket_send",agentId:i,sessionId:e,turnId:d,messageType:p.type,bytes:JSON.stringify(p).length}),this.sendWsMessage(p)},cancelYeaftTask({agentId:e=null,sessionId:t,taskId:s}){let n=typeof t=="string"?t.trim():"",r=typeof s=="string"?s.trim():"",i=Ce(this,n,e);return!i||!n||!r?!1:(this.yeaftStoppingTasksById={...this.yeaftStoppingTasksById,[sa(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)},getYeaftMessageWindowKey(e=null){return e||this.yeaftActiveSessionFilter||"__all__"},pruneYeaftMessageWindow(e=null){if(this.currentView!=="yeaft")return;let t=this.getYeaftMessageWindowKey(e);this.yeaftMessageWindowState={...this.yeaftMessageWindowState,[t]:{visibleTurns:us()}}},expandYeaftMessageWindow(e=null,t=Dn()){if(this.currentView!=="yeaft")return;let s=this.getYeaftMessageWindowKey(e),r=(this.yeaftMessageWindowState[s]?.visibleTurns||us())+Math.max(1,Number.isFinite(t)?Math.floor(t):Dn());this.yeaftMessageWindowState={...this.yeaftMessageWindowState,[s]:{visibleTurns:r}}},isYeaftMessageCached(e,t,s=null){let n=e||this.yeaftActiveSessionFilter||null,r=s||Pt(this,n);return!r||!t?!1:(this.messagesMap[r]||[]).some(i=>(!n||(i?.sessionId??i?.groupId??null)===n)&&((i?.id||i?.messageId)===t||i?.persistedMessageId===t))},revealYeaftMessage(e,t,s=null){let n=e||this.yeaftActiveSessionFilter||null,r=s||Pt(this,n);if(!r||!t)return!1;let i=(this.messagesMap[r]||[]).filter(u=>n?(u?.sessionId??u?.groupId??null)===n:!0),o=i.findIndex(u=>(u?.id||u?.messageId)===t||u?.persistedMessageId===t);if(o<0)return!1;let a=Kd(i),l=a.findIndex(u=>o>=u.start&&o<u.end);if(l<0)return!1;let c=Math.max(us(),a.length-l),d=this.getYeaftMessageWindowKey(n);return this.yeaftMessageWindowState={...this.yeaftMessageWindowState,[d]:{visibleTurns:c}},!0},getYeaftHistoryOutlineState(e=null,t=null){let s=e||this.yeaftActiveSessionFilter||null,n=Ce(this,s,t),r=Pe(n,s),i=this.yeaftHistoryOutlineBySession[r]||{requestId:null,agentId:n,sessionId:s,loading:!1,results:[],hasMore:!1,nextBeforeSeq:null,totalCount:null,loaded:!1,error:null},o=Pt(this,s),a=o?this.messagesMap[o]||[]:[],l=new Map((i.results||[]).map(f=>[Ln(f),f])),c=0;for(let f of a){if((f?.sessionId??f?.groupId??null)!==s)continue;let p=f.messageId||f.id;if(!p)continue;let g=f.type==="user"&&!!f.clientMessageId&&p===f.clientMessageId,v=f.type==="assistant"&&f.isStreaming===!0;if(!g&&!v)continue;let h=f.type,A=f.turnId||f.threadId||p,w=f.speakerVpId||f.vpId||null,k=Ln({role:h,messageId:p,clientMessageId:f.clientMessageId,turnId:A,speakerVpId:w}),y=l.get(k),b=(typeof f.content=="string"?f.content:"").replace(/\s+/g," ").trim();l.set(k,{...y,messageId:Number.isFinite(y?.seq)?y.messageId:p,...f.clientMessageId?{clientMessageId:f.clientMessageId}:{},turnId:A,role:h,speakerVpId:w||y?.speakerVpId||null,timestamp:f.timestamp||f.ts||y?.timestamp||null,snippet:b.length>180?`${b.slice(0,180).trimEnd()}\u2026`:b||y?.snippet||""}),y||(c+=1)}let d=f=>{let p=typeof f=="number"?f:Date.parse(f||"");return Number.isFinite(p)?p:0},u=Array.from(l.values()).sort((f,p)=>Number.isFinite(f.seq)&&Number.isFinite(p.seq)?f.seq-p.seq:d(f.timestamp)-d(p.timestamp));return{...i,results:u,totalCount:Number.isFinite(i.totalCount)?i.totalCount+c:i.totalCount}},promoteYeaftHistoryOutlineRow(e){let t=e?.sessionId??e?.groupId??null,s=Ce(this,t),n=Pe(s,t),r=this.yeaftHistoryOutlineBySession[n];if(!t||!s||!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=jh(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(),f=Ln({role:i,messageId:o,clientMessageId:e.clientMessageId,turnId:l,speakerVpId:c}),p=new Map((r.results||[]).map(k=>[Ln(k),k])),g=p.get(f);p.set(f,{...g,messageId:o,...e.clientMessageId?{clientMessageId:e.clientMessageId}:{},turnId:l,seq:a,role:i,speakerVpId:c,timestamp:e.timestamp||e.ts||g?.timestamp||null,snippet:u.length>180?`${u.slice(0,180).trimEnd()}\u2026`:u||g?.snippet||""});let v=50,h=Array.from(p.values()).sort((k,y)=>(k.seq||0)-(y.seq||0)),A=h.length>v,w=h.slice(-v);return this.yeaftHistoryOutlineBySession={...this.yeaftHistoryOutlineBySession,[n]:{...r,results:w,hasMore:r.hasMore||A,nextBeforeSeq:A&&Number.isFinite(w[0]?.seq)?w[0].seq:r.nextBeforeSeq,totalCount:Number.isFinite(r.totalCount)&&!g?r.totalCount+1:r.totalCount}},!0},promoteCompletedYeaftHistoryOutline(e,t=null){let s=this.messagesMap[e]||[],n=null,r=[];for(let i=s.length-1;i>=0;i--){let o=s[i];if(o?.type==="user")break;if(t&&o?.turnId&&o.turnId!==t||o?.type!=="assistant")continue;let a=typeof o.content=="string"?o.content.replace(/\s+/g," ").trim():"";n?!String(n.content||"").trim()&&a&&(n=o):n=o,a&&r.unshift(a)}return n?this.promoteYeaftHistoryOutlineRow({...n,content:r.join(" ")}):!1},invalidateYeaftHistoryOutline(e){let t=Ce(this,e),s=Pe(t,e),n=this.yeaftHistoryOutlineBySession[s];return!e||!t||!n?!1:n.loading?(this.yeaftHistoryOutlineBySession={...this.yeaftHistoryOutlineBySession,[s]:{...n,refreshPending:!0}},!0):(this.yeaftHistoryOutlineBySession={...this.yeaftHistoryOutlineBySession,[s]:{...n,loaded:!1,refreshPending:!1}},this.currentView==="yeaft"&&this.yeaftActiveSessionFilter===e?this.loadYeaftHistoryOutline({force:!0}):!0)},loadYeaftHistoryOutline({append:e=!1,force:t=!1,targetSessionId:s=null,targetAgentId:n=null}={}){if(this.currentView!=="yeaft"&&!s)return!1;let r=s||this.yeaftActiveSessionFilter||null,i=n||Ce(this,r);if(!r||!i)return!1;let o=Pe(i,r),a=this.getYeaftHistoryOutlineState(r,i);if(!e&&a.loaded&&!t)return!0;if(e&&(!a.hasMore||!Number.isFinite(a.nextBeforeSeq))||a.loading)return!1;if(!iu(this,i,"session_history_outline"))return this.yeaftHistoryOutlineBySession={...this.yeaftHistoryOutlineBySession,[o]:{...a,error:"unsupported",loading:!1}},!1;let l=`history_outline_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,c={...a,requestId:l,agentId:i,sessionId:r,loading:!0,requestAppend:e,refreshPending:!1,error:null};this.yeaftHistoryOutlineBySession={...this.yeaftHistoryOutlineBySession,[o]:c};let d=this._yeaftHistoryOutlineTimeouts[o];d&&clearTimeout(d);let u=setTimeout(()=>{let f=this.yeaftHistoryOutlineBySession[o];if(f?.requestId!==l)return;let p={...this._yeaftHistoryOutlineTimeouts};delete p[o],this._yeaftHistoryOutlineTimeouts=p;let g=f.refreshPending===!0;this.yeaftHistoryOutlineBySession={...this.yeaftHistoryOutlineBySession,[o]:{...f,requestId:null,loading:!1,requestAppend:!1,loaded:g?!1:f.loaded,refreshPending:!1,error:g?null:"timeout"}},g&&this.loadYeaftHistoryOutline({force:!0,targetSessionId:r,targetAgentId:i})},1e4);return this._yeaftHistoryOutlineTimeouts={...this._yeaftHistoryOutlineTimeouts,[o]:u},this.sendWsMessage({type:"yeaft_load_history_outline",agentId:i,sessionId:r,requestId:l,limit:50,...e&&Number.isFinite(a.nextBeforeSeq)?{beforeSeq:a.nextBeforeSeq}:{},includeTotal:!a.loaded}),!0},handleYeaftHistoryOutline(e){if(!e?.agentId||!e?.sessionId)return!1;let t=Pe(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=Array.isArray(e.results)?e.results:[],o=s.requestAppend?[...s.results||[],...i]:i,a=new Map(o.filter(d=>d?.messageId).map(d=>[Ln(d),d])),l=Array.from(a.values()).sort((d,u)=>(d.seq||0)-(u.seq||0)),c=s.refreshPending===!0;return this.yeaftHistoryOutlineBySession={...this.yeaftHistoryOutlineBySession,[t]:{...s,requestId:null,loading:!1,requestAppend:!1,refreshPending:!1,loaded:c?!1:!e.error,results:l,hasMore:!!e.hasMore,nextBeforeSeq:Number.isFinite(e.nextBeforeSeq)?e.nextBeforeSeq:null,totalCount:Number.isFinite(e.totalCount)?e.totalCount:s.totalCount,error:c?null:e.error||null}},c&&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=Ce(this,i);if(this._yeaftHistorySearchTimeout&&(clearTimeout(this._yeaftHistorySearchTimeout),this._yeaftHistorySearchTimeout=null),!i||!o||n.length<2&&!r)return this.yeaftHistorySearchState={requestId:null,agentId:o,sessionId:i,query:n,senderKey:r,loading:!1,results:[],hasMore:!1,nextBeforeSeq:null,error:null},!1;let a=this.yeaftHistorySearchState||{};if(!iu(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,error:"unsupported"},!1;let l=`history_search_${Date.now()}_${Math.random().toString(36).slice(2,8)}`;return 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,error:null},this._yeaftHistorySearchTimeout=setTimeout(()=>{this.yeaftHistorySearchState?.requestId===l&&(this._yeaftHistorySearchTimeout=null,this.yeaftHistorySearchState={...this.yeaftHistorySearchState,loading:!1,error:"timeout"})},1e4),this.sendWsMessage({type:"yeaft_search_history",agentId:o,sessionId:i,requestId:l,query:n,senderKey:r,limit:20,...t&&a.query===n&&a.senderKey===r&&Number.isFinite(a.nextBeforeSeq)?{beforeSeq:a.nextBeforeSeq}:{}}),!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:[],n=new Map((t.results||[]).map(r=>[r.messageId,r]));for(let r of s)r?.messageId&&n.set(r.messageId,r);return this.yeaftHistorySearchState={...t,loading:!1,results:Array.from(n.values()),hasMore:!!e.hasMore,nextBeforeSeq:Number.isFinite(e.nextBeforeSeq)?e.nextBeforeSeq:null,error:e.error||null},!0},loadYeaftHistoryWindow(e){let t=this.yeaftActiveSessionFilter||null,s=Ce(this,t);if(!t||!s||!e?.messageId||!Number.isFinite(e.seq))return Promise.resolve(!1);if(this.isYeaftMessageCached(t,e.messageId))return Promise.resolve(!0);let n=Pe(s,`${t}:${e.messageId}`),r=this._yeaftHistoryWindowPendingByKey||{};if(r[n]?.promise)return r[n].promise;let i=`history_window_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,o=null,a=new Promise(c=>{o=c}),l=setTimeout(()=>{if(this._yeaftHistoryWindowPendingByKey?.[n]?.requestId!==i)return;let{[n]:d,...u}=this._yeaftHistoryWindowPendingByKey;this._yeaftHistoryWindowPendingByKey=u,o(!1)},1e4);return this._yeaftHistoryWindowPendingByKey={...r,[n]:{requestId:i,agentId:s,sessionId:t,messageId:e.messageId,resolve:o,timeout:l,promise:a}},this.sendWsMessage({type:"yeaft_load_history_window",agentId:s,sessionId:t,requestId:i,anchorMessageId:e.messageId,anchorSeq:e.seq,beforeTurns:5,afterTurns:5}),a},async revealYeaftHistoryResult(e){let t=this.yeaftActiveSessionFilter||null,s=Ce(this,t),n=Pt(this,t);return!t||!s||!n||!e?.messageId||!await this.loadYeaftHistoryWindow(e)||this.currentView!=="yeaft"||this.yeaftActiveSessionFilter!==t||Ce(this,t)!==s||Pt(this,t)!==n?!1:this.revealYeaftMessage(t,e.messageId,n)},handleYeaftHistoryWindow(e,t=null){let n=Object.entries(this._yeaftHistoryWindowPendingByKey||{}).find(([,c])=>c?.requestId===e?.requestId);if(!n)return!1;let[r,i]=n;if(e.agentId!==i.agentId||e.sessionId!==i.sessionId)return!1;clearTimeout(i.timeout);let{[r]:o,...a}=this._yeaftHistoryWindowPendingByKey;this._yeaftHistoryWindowPendingByKey=a;let l=!e.error&&!!t&&this.isYeaftMessageCached(i.sessionId,i.messageId,t);return i.resolve(!!l),!!l},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=$s(this,t,s);if(e.data&&n){if(e.data.type!=="result")return;let i=yc(this,t,s);if(!i)return;let o=e.turnId?Bs(this,t,e.turnId):"",a=!!(o&&this.activeVpTurns?.[o])||(this.messagesMap?.[i]||[]).some(l=>l?.turnId===e.turnId&&(l.isStreaming||l.status==="pending"));if(!e.turnId||!a)return;e={...e,conversationId:i}}if(e.perfTraceId&&(Ze(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 i=e.agentId||this.yeaftAgentId||this.currentAgent||null,o=zt(this,i,e.conversationId),a=e.turnId?Bs(this,e.agentId||null,e.turnId):"";if(a&&this.activeVpTurns?.[a]?.retryAttempt){let{retryAttempt:l,retryMax:c,retryDelayMs:d,retryReason:u,retryRecoveryMode:f,...p}=this.activeVpTurns[a];this.activeVpTurns={...this.activeVpTurns,[a]:p}}if(o){let l=e.sessionId??e.groupId??null,c=ou(this,l,i),d=i&&this.yeaftConversationIdsByAgent?this.yeaftConversationIdsByAgent[i]:null,u=mt(this,i);u&&u.targetConversationId!==o?In(this,i,o):!u&&d&&d!==o&&!String(d).startsWith("yeaft-local-")&&(ht(this,d,o,{removeSource:d!==this.yeaftConversationId}),kn(this,i,d,o)),Ao(this,i,o);let f=mt(this,i,o),p=f?.sourceConversationId||d,g=!c&&p===this.yeaftConversationId;if(this.currentView==="yeaft"&&i&&p&&p!==o){let y=!g&&(!!f||String(p).startsWith("yeaft-local-"));ht(this,p,o,{removeSource:y}),g?Ar(this,i,p,o):y&&Sn(this,i,o)}i&&(this.yeaftConversationIdsByAgent={...this.yeaftConversationIdsByAgent||{},[i]:o}),(c||!this.yeaftConversationId)&&(this.yeaftConversationId=o),c&&(this.activeConversations=[o]),this.messagesMap[o]||(this.messagesMap[o]=[]),this.currentView==="yeaft"&&(e.data?.type==="user"||e.data?.type==="text_delta")&&this.pruneYeaftMessageWindow(this.yeaftActiveSessionFilter&&e.sessionId||null);let v=this._currentYeaftAgentId,h=this._currentYeaftSessionId,A=this._currentYeaftVpId,w=this._currentYeaftTurnId,k=this._currentYeaftThreadId;i&&(this._currentYeaftAgentId=i),l!=null&&(this._currentYeaftSessionId=l),e.vpId&&(this._currentYeaftVpId=e.vpId),e.turnId&&(this._currentYeaftTurnId=e.turnId),e.threadId&&(this._currentYeaftThreadId=e.threadId);try{this.currentView==="yeaft"&&l&&(!this.yeaftActiveSessionFilter||l===this.yeaftActiveSessionFilter)&&this.pruneYeaftMessageWindow(this.yeaftActiveSessionFilter?l:null);let m=typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now();if(this.handleAssistantOutputFrame(o,e.data),e.perfTraceId){let P=typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now();Ze(this,{traceId:e.perfTraceId,phase:"store.apply_output",agentId:e.agentId||null,sessionId:l||null,vpId:e.vpId||null,turnId:e.turnId||null,threadId:e.threadId||null,messageType:e.data?.type||null,durationMs:P-m}),Tr(this,{traceId:e.perfTraceId,agentId:e.agentId||null,sessionId:l||null,vpId:e.vpId||null,turnId:e.turnId||null,threadId:e.threadId||null,messageType:e.data?.type||null})}let b=e.data,T=b?.message?.id||b?.id||null,L=Wh(T),N=Array.isArray(b?.message?.content)?b.message.content:[],$=N.some(P=>P?.type==="tool_use"),D=!!b?.tool_use_result||N.some(P=>P?.type==="tool_result");if(l){let P=!D&&!Bh(this,o,l)&&(b?.type==="user"||b?.type==="assistant"&&!$)?L:null,M=Pe(e.agentId||null,l),C=this.yeaftSessionHistoryState[M]||{},R=Number.isFinite(C.latestSeq)?C.latestSeq:-1;P!==null&&P>R&&(this.yeaftSessionHistoryState={...this.yeaftSessionHistoryState,[M]:{...C,latestSeq:P}})}}finally{this._currentYeaftAgentId=v,this._currentYeaftSessionId=h,this._currentYeaftVpId=A,this._currentYeaftTurnId=w,this._currentYeaftThreadId=k}}return}let r=e.event;if(r)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 i=zt(this,e.agentId||null,e.conversationId);if(!i||!r.requestId)break;let o=eu(e,r,i),a=()=>{let l=this.messagesMap[i]||[],c=su(l,o,i);if(c){if(c.askAnswered||c.askExpired)return!0;c.toolName="AskUserQuestion",r.toolCallId&&!c.toolId&&(c.toolId=r.toolCallId),c.agentId=o.agentId||c.agentId||null,c.askRequestId=r.requestId,c.askQuestions=r.questions||[],c.askCreatedAt=r.createdAt||null,c.askExpiresAt=r.expiresAt||null,r.replay&&(c.askPending=!1,c.pendingAnswers=null,c.askSubmitGeneration=null),c.isHistory=!1;let f=nu(this,o);return f&&ta(c,f),this.messagesMap={...this.messagesMap,[i]:l.slice()},!0}if(!r.replay)return!1;let d={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:o.agentId,sessionId:o.sessionId,vpId:o.vpId,speakerVpId:o.vpId,turnId:o.turnId,threadId:o.threadId||"main",hasResult:!1,isHistory:!1,timestamp:r.createdAt||Date.now()},u=nu(this,o);return u&&ta(d,u),l.push(d),this.messagesMap={...this.messagesMap,[i]:l.slice()},!0};if(!a()){let l=0,c=setInterval(()=>{l+=1,(a()||l>=10)&&clearInterval(c)},200)}break}case"ask_user_answered":case"ask_user_expired":{let i=zt(this,e.agentId||null,e.conversationId);if(!i||!r.requestId)break;let o=this.messagesMap[i]||[],a=eu(e,r,i),l=su(o,a,i);if(!l){Nh(this,a,r);break}ta(l,r),this.messagesMap={...this.messagesMap,[i]:o.slice()};break}case"session_ready":{let i=r.conversationId,o=e.agentId||this.currentAgent;if($s(this,o,i))break;let a=o&&this.yeaftConversationIdsByAgent?this.yeaftConversationIdsByAgent[o]:null,l=this.yeaftConversationId?String(this.yeaftConversationId):"",c=l.startsWith("yeaft-local-")&&(!o||l.startsWith(`yeaft-local-${o}-`)||/^yeaft-local-\d/.test(l))?this.yeaftConversationId:null,d=a||c,u=r.sessionId||e.sessionId||null,f=ou(this,u,o),p=mt(this,o);p&&p.targetConversationId!==i?In(this,o,i):!p&&a&&a!==i&&!String(a).startsWith("yeaft-local-")&&kn(this,o,a,i),Ao(this,o,i);let v=mt(this,o,i)?.sourceConversationId||d,h=!f&&v===this.yeaftConversationId;if(v&&v!==i){let m=!h;ht(this,v,i,{removeSource:m}),h?Ar(this,o,v,i):m&&Sn(this,o,i)}else this.messagesMap[i]||(this.messagesMap[i]=[]);o&&(this.yeaftConversationIdsByAgent={...this.yeaftConversationIdsByAgent||{},[o]:i},this.cacheYeaftAgentStatus(o,r,{allowBootstrapCatalog:f})),f&&(this.yeaftModel=r.model,this.yeaftModelEffort=r.modelEffort||null,this.yeaftSessionReady=!0,this.yeaftBootstrapMetaLoadingKey=null,o?this.applyCachedYeaftStatus(o):this.yeaftAvailableModels=r.availableModels||[]);let A=Array.isArray(r.tasks)?r.tasks:[],w={};for(let[m,b]of Object.entries(this.yeaftActiveTasksBySession||{})){let T=Object.fromEntries(Object.entries(b||{}).filter(([,N])=>N?.id&&(N.agentId&&N.agentId!==o||ia.has(N.status)))),L=na(T);Object.keys(L).length>0&&(w[m]=L)}for(let m of A){if(!m?.id||!m.sessionId||m.status!=="running")continue;let b=Pe(o,m.sessionId);w[b]={...w[b]||{},[m.id]:{...m,agentId:o}}}this.yeaftActiveTasksBySession=w,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=i),f&&(this.activeConversations=[i]);let k=e.agentId||this.currentAgent||null,y=k||"__current__";this._yeaftVpSubscribedAgentKey!==y&&(this._yeaftVpSubscribedAgentKey=y,this.sendWsMessage(k?{type:"yeaft_vp_subscribe",agentId:k}:{type:"yeaft_vp_subscribe"}));break}case"yeaft_status":{let i=e.agentId||this.currentAgent;i&&this.cacheYeaftAgentStatus(i,r);break}case"context_usage":break;case"turn_open":{if(!r.turnId)break;let i={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,totalTokens:0,loopCount:0,memoryLoaded:null,memoryLoadedMeta:null,memoryAdjust:null,tools:[],detailsLoaded:!0};this.yeaftDebugTurnsById={...this.yeaftDebugTurnsById,[r.turnId]:i},this.yeaftDebugTurnOrder.includes(r.turnId)||(this.yeaftDebugTurnOrder=[...this.yeaftDebugTurnOrder,r.turnId]);break}case"turn_close":{if(!r.turnId)break;let i=this.yeaftDebugTurnsById[r.turnId];if(!i)break;this.yeaftDebugTurnsById={...this.yeaftDebugTurnsById,[r.turnId]:{...i,closedAt:Date.now(),totalMs:r.totalMs||0,totalTokens:r.totalTokens||0,loopCount:r.loopCount||i.loopCount||0}};break}case"memory_used":{if(!r.turnId)break;let i=this.yeaftDebugTurnsById[r.turnId];if(!i)break;this.yeaftDebugTurnsById={...this.yeaftDebugTurnsById,[r.turnId]:{...i,memoryLoaded:Array.isArray(r.loaded)?r.loaded:[],memoryLoadedMeta:r.meta||null}};break}case"dream_memory_loaded":{let i=Array.isArray(r.resident)?r.resident:[];if(r.turnId){let a=this.yeaftDebugTurnsById[r.turnId];a&&(this.yeaftDebugTurnsById={...this.yeaftDebugTurnsById,[r.turnId]:{...a,dreamMemoryLoaded:i,dreamMemoryLoadedInto:r.loadedInto||"system_prompt.memory"}})}let o={};for(let a of i){let l=a&&typeof a.scope=="string"?a.scope:null,c=l&&/^sessions\/[^/]+$/.test(l)?l:l&&/^group\/[^/]+$/.test(l)?`sessions/${l.slice(6)}`:null;c&&(o[c]={scope:c,sourceScope:l,sessionId:c.slice(9),turnId:r.turnId||null,vpId:r.vpId||null,loadedInto:r.loadedInto||"system_prompt.memory",summary:a.summary||"",truncated:!!a.truncated,receivedAt:Date.now()})}Object.keys(o).length>0&&(this.yeaftDreamPromptLoads={...this.yeaftDreamPromptLoads,...o});break}case"memory_adjust":{if(!r.turnId)break;let i=this.yeaftDebugTurnsById[r.turnId];if(!i)break;this.yeaftDebugTurnsById={...this.yeaftDebugTurnsById,[r.turnId]:{...i,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(!r.turnId)break;let i=this.yeaftDebugTurnsById[r.turnId];if(!i)break;let o=[...i.tools||[],{loopNumber:r.loopNumber||0,callId:r.callId||null,name:r.name||"?",durationMs:r.durationMs||0,isError:!!r.isError,toolOutput:r.toolOutput==null?null:String(r.toolOutput)}];this.yeaftDebugTurnsById={...this.yeaftDebugTurnsById,[r.turnId]:{...i,tools:o}};break}case"loop":{if(this.yeaftDebugLoops.push({turnId:r.turnId||null,loopNumber:r.loopNumber||0,model:r.model,systemPrompt:r.systemPrompt,messages:r.messages,response:r.response,toolCalls:r.toolCalls,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,rawRequest:r.rawRequest||null,rawResponse:r.rawResponse||null,sessionId:e.sessionId||null,vpId:e.vpId||r.vpId||null}),this.yeaftDebugLoops.length>au){let i=Ed({loops:this.yeaftDebugLoops,turnsById:this.yeaftDebugTurnsById,turnOrder:this.yeaftDebugTurnOrder,maxLoops:Math.max(au,this.yeaftDebugHistoryLimit||0)});this.yeaftDebugLoops=i.loops,this.yeaftDebugTurnsById=i.turnsById,this.yeaftDebugTurnOrder=i.turnOrder}break}case"llm_retry":{if(!e.turnId)break;let i=Bs(this,e.agentId||null,e.turnId),o=this.activeVpTurns?.[i];if(!o)break;let a=r.reason==="stream_idle_timeout"?"stream_idle_timeout":"transient_error";this.activeVpTurns={...this.activeVpTurns,[i]:{...o,retryAttempt:r.attempt||0,retryMax:r.maxRetries||0,retryDelayMs:r.delayMs||0,retryReason:a,retryRecoveryMode:r.recoveryMode||"restart"}};break}case"recall":case"consolidate":case"fallback":case"thinking_delta":break;case"reflection":{let i=zt(this,e.agentId||null,e.conversationId)||"unknown",o=Array.isArray(r.loopRange)?r.loopRange:[0,0],a=`${i}:${r.trigger}:${o[0]}-${o[1]}`,l=this.yeaftReflectionCards[a],c=this.messagesMap[i]||[],d=l?l.anchorMsgId:c.length>0&&c[c.length-1].id||null,u=l?l.anchorOrder:c.length;this.yeaftReflectionCards={...this.yeaftReflectionCards,[a]:{key:a,conversationId:i,turnId:r.turnId||l&&l.turnId||null,loopNumber:r.loopNumber||l&&l.loopNumber||null,trigger:r.trigger,status:r.status,loopRange:o,toolCount:r.toolCount||0,content:r.content||"",durationMs:r.durationMs||0,error:r.error||null,sessionId:e.sessionId||null,anchorMsgId:d,anchorOrder:u,updatedAt:Date.now()}};break}case"model_switched":this.yeaftModel=r.model,this.yeaftModelEffort=r.modelEffort||null;break;case"yeaft_task_event":{let i=r.task;if(!i?.id||!i.sessionId)break;let o=e.agentId||Ce(this,i.sessionId),a=Pe(o,i.sessionId),l={...i,agentId:o},c={...this.yeaftActiveTasksBySession},d={...c[a]||{}};i.status==="running"||ia.has(i.status)?d[i.id]=l:delete d[i.id];let u=na(d);if(Object.keys(u).length>0?c[a]=u:delete c[a],this.yeaftActiveTasksBySession=c,i.status!=="running"){let{[sa(o,i.sessionId,i.id)]:f,...p}=this.yeaftStoppingTasksById||{};this.yeaftStoppingTasksById=p}break}case"yeaft_task_cancel_result":{let i=r.taskId||r.task?.id||null,o=r.task?.sessionId||r.sessionId||e.sessionId||null,a=e.agentId||Ce(this,o);if(i&&o&&r.success===!1){let{[sa(a,o,i)]:c,...d}=this.yeaftStoppingTasksById||{};this.yeaftStoppingTasksById=d}let l=r.task;if(l?.id&&l.sessionId){let c=Pe(a,l.sessionId),d={...this.yeaftActiveTasksBySession},u={...d[c]||{}};u[l.id]={...l,agentId:a};let f=na(u);Object.keys(f).length>0?d[c]=f:delete d[c],this.yeaftActiveTasksBySession=d}break}case"sub_agent_event":{let i=zt(this,e.agentId||null,e.conversationId)||"unknown",o=r.agentId;if(!o)break;let a=r.payload||{},l=`${i}:${o}`,c=this.yeaftSubAgentCards[l],d=this.messagesMap[i]||[],u=c?c.anchorMsgId:d.length>0&&d[d.length-1].id||null,f=c?c.anchorOrder:d.length,p=c?{...c}:{key:l,conversationId:i,agentId:o,agentName:a.agentName||"sub-agent",status:"running",text:"",toolCallCount:0,turns:0,error:null,expanded:!1,anchorMsgId:u,anchorOrder:f,updatedAt:Date.now(),sessionId:e.sessionId||null};switch(a.agentName&&!p.agentName&&(p.agentName=a.agentName),a.type){case"sub_agent_status":p.status=a.status||p.status,a.error&&(p.error=a.error);break;case"text_delta":break;case"tool_use":case"tool_call":p.toolCallCount=Number(p.toolCallCount||0)+1;break;case"tool_start":break;case"tool_result":case"tool_end":break;case"sub_agent_turn_end":{p.turns+=1;let g=typeof a.content=="string"?a.content.trim():"";g&&(p.text=p.text?`${p.text}
|
|
8
|
+
`))}function Vr(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||Qo.has(l?.status)||Qo.has(l?.turnEndReason)||Qo.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 Qo,Fr=F(()=>{Qo=new Set(["aborted","errored","error","cancelled","canceled"])});function Xo(e){return e?.type==="user"&&typeof e.content=="string"&&e.content.trim()}function Zo(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 Jo(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 Kd(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(Xo(i)||i.type==="system"||i.type==="error"){n(r),s={start:r,kind:i.type};continue}if(!Zo(i)){s||(s={start:r,kind:"other"});continue}(!s||s.kind==="assistant"&&Jo(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 Yd(e,t){return t?e&&(e.sessionId??e.groupId)===t:!0}function ea(e=[],t=null,s=5){let n=Math.max(1,Number.isFinite(s)?Math.floor(s):5),r=[],i=[],o=null,a=c=>{o&&(i.push({start:o.start,end:c,kind:o.kind}),o=null)};for(let c of e){if(!Yd(c,t))continue;let d=r.length;if(r.push(c),Xo(c)||c.type==="system"||c.type==="error"){a(d),o={start:d,kind:c.type};continue}if(!Zo(c)){o||(o={start:d,kind:"other"});continue}(!o||o.kind==="assistant"&&Jo(o,c))&&(a(d),o={start:d,kind:"assistant",turnId:c.turnId||"",speakerVpId:c.speakerVpId||c.vpId||""}),o.lastTurnId=c.turnId||o.lastTurnId||"",o.speakerVpId=o.speakerVpId||c.speakerVpId||c.vpId||""}if(a(r.length),i.length<=n)return r;let l=i[i.length-n];return r.slice(l.start)}function Gd(e=[],t=null,s=5){let n=Math.max(1,s||5),r=0,i=null,o=()=>i?(i=null,r+=1,r>n):!1;for(let a of e)if(Yd(a,t)){if(Xo(a)||a.type==="system"||a.type==="error"){if(o())return!0;i={kind:a.type};continue}if(!Zo(a)){i||(i={kind:"other"});continue}if(!i||i.kind==="assistant"&&Jo(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 5}function Dn(){return 20}var Qd=F(()=>{});function _h(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=fs();for(let r of n?.sessionList||[])r?.id===t&&r?.agentId&&s.add(r.agentId)}return s}function du(e,t){let s=_h(e,t);return s.size===1?s.values().next().value:null}function Nr(e,t,s){return!!s&&du(e,t)===s}function pt(e,t,s){return!e||e.sessionId!==t?!1:s?e.agentId===s:!e.agentId}function Xd(e,t,s=null){if(!t)return!1;let n=s||Ce(e,t),r=dt(n,t);if(r&&e.yeaftProcessingSessions?.[r]||e.yeaftProcessingSessions?.[t]&&Nr(e,t,n))return!0;for(let i of Object.values(e.activeVpTurns||{}))if(pt(i,t,n))return!0;for(let i of Object.values(e.vpStatuses||{}))if(pt(i,t,n)&&Br.has(i?.state))return!0;return!1}function Eh(e,t,s,n=null){let r={...e.yeaftProcessingSessions||{}};if(t){let i=Ho(t);if(r=Object.fromEntries(Object.entries(r).filter(([o])=>n?o!==dt(t,n):!o.startsWith(i))),n)Nr(e,n,t)&&delete r[n];else for(let o of Object.keys(r))Nr(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||!Br.has(i?.state))continue;let a=dt(t,o)||o;r[a]=!0}return r}function Bs(e,t,s){let n=qo(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 Zd(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=Ho(t);e.yeaftProcessingSessions=Object.fromEntries(Object.entries(e.yeaftProcessingSessions||{}).filter(([n])=>!n.startsWith(s)))}function Mt(e,t){return`${e||""}:${t||""}`}function Fh(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 Oh(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 Hh(e={}){return{agentId:e.agentId||"",workItemId:e.workItemId||"",target:Fh(e.target),text:String(e.text||""),attachments:Array.isArray(e.attachments)?e.attachments.map(t=>({fileId:t?.fileId||"",name:t?.name||"",mimeType:t?.mimeType||"",size:Math.max(0,Number(t?.size)||0)})):[],revision:Number(e.revision)||0,planRevision:Number(e.planRevision)||0,ledgerRevision:Number(e.ledgerRevision)||0,coordinatorRevision:Number(e.coordinatorRevision)||0}}function eu(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 tu(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 qh(e,t){return oa.every(s=>!t[s]||e[s]===t[s])}function uu(e,t){return oa.every(s=>!e[s]||!t[s]||e[s]===t[s])}function su(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=>qh(tu(o,s),t));if(r.length===1)return r[0];let i=n.filter(o=>uu(tu(o,s),t));return i.length===1?i[0]:null}function pu(e){return oa.map(t=>e[t]||"").join("\0")}function Nh(e,t,s){let n=pu(t),r={...e._yeaftAskTerminalEvents||{},[n]:{identity:t,event:s,receivedAt:Date.now()}},i=Object.keys(r);if(i.length>Jd){i.sort((o,a)=>r[o].receivedAt-r[a].receivedAt);for(let o of i.slice(0,i.length-Jd))delete r[o]}e._yeaftAskTerminalEvents=r}function nu(e,t){let s=e._yeaftAskTerminalEvents||{},n=pu(t),r=s[n]?n:null;if(!r){let l=Object.entries(s).filter(([,c])=>uu(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 Bh(e,t,s){return(e.messagesMap?.[t]||[]).some(n=>n?.type==="tool-use"&&n.sessionId===s&&n.hasResult===!1)}function ta(e,t){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 Wh(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 jh(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 Ln(e){return e?.role==="assistant"&&e?.turnId?`response:${e.turnId}:${e.speakerVpId||e.vpId||""}`:e?.clientMessageId?`client:${e.clientMessageId}`:`message:${e?.messageId||""}`}function ru(e){let t=e?.updatedAt||e?.endedAt||e?.createdAt,s=t?Date.parse(t):NaN;return Number.isFinite(s)?s:0}function sa(e,t,s){return`${dt(e,t)}::${s||""}`}function na(e){let t=Object.entries(e||{}),s=t.filter(([,r])=>r?.status==="running"),n=t.filter(([,r])=>r&&r.status!=="running"&&ia.has(r.status)).sort((r,i)=>ru(i[1])-ru(r[1])).slice(0,Lh);return Object.fromEntries([...s,...n])}function fs(){try{return typeof window>"u"?null:window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore()||null}catch{return null}}function Ce(e,t,s=null){if(s)return s;if(t){let n=fs(),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 Uh(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 iu(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"&&Uh(n?.version||r?.version,"1.0.166")}function ps(e,{fallbackDefault:t=!1}={}){if(e?.yeaftActiveSessionFilter)return e.yeaftActiveSessionFilter;let s=fs();return s?.activeSessionId?s.activeSessionId:t?"grp_default":null}function qr(e){let t=e.yeaftDebugSessionFilter;if(t==="__all__")return null;if(t)return t;let s=ps(e);return s||(fs()?.sessions?.grp_default?"grp_default":null)}function zt(e,t,s=null){return s||t&&e?.yeaftConversationIdsByAgent?.[t]||e?.yeaftConversationId||null}function Pt(e,t=null){let s=t||e?.yeaftActiveSessionFilter||null,n=Ce(e,s);return(n&&e?.yeaftConversationIdsByAgent?e.yeaftConversationIdsByAgent[n]:null)||e?.yeaftConversationId||null}function ou(e,t,s){if(e?.currentView!=="yeaft")return!1;let n=e?.yeaftActiveSessionFilter||null;if(n&&t!==n)return!1;let r=Ce(e,n);return!r||!s||r===s}var Rh,Ve,Or,Hr,Dh,Lh,ia,Br,$h,Vh,Jd,oa,au,ra,lu,cu,gs,Wr=F(()=>{ct();co();Tt();go();Ds();Hc();Qc();kd();ns();jt();Td();xo();Ir();Rd();_d();Dd();po();Go();Po();ds();Fr();Mr();Do();Pn();Qd();({defineStore:Rh}=Pinia),Ve=Object.freeze([]),Or=(e,t,s)=>`${e||""}::${t||""}::${s}`;Hr=5,Dh=15e3,Lh=8,ia=new Set(["succeeded","failed","cancelled","orphaned"]),Br=new Set(["typing","thinking","retrying","streaming","tool"]),$h=Object.freeze(["model","availableModels","refreshedAt","catalogRefreshedAt","catalogEpoch","catalogRevision","catalogDigest","refreshStartedAt","refreshReason","refreshError","refreshing"]),Vh=8,Jd=64;oa=Object.freeze(["conversationId","agentId","requestId","toolCallId","sessionId","vpId","turnId","threadId"]);au=1e3,ra=1,lu=5,cu=200,gs=Rh("chat",{state:()=>({ws:null,authenticated:!1,_hasHandledAgentList:!1,_hasHandledYeaftSessionHydrate:!1,yeaftSessionInventoryCompleteSupported:null,yeaftSessionHydrateRequestId:null,yeaftSessionHydrateSlices:[],yeaftSessionHydrateError:null,_yeaftSessionInventorySocketQuarantined:!1,sessionKey:null,serverEncryptionRequired:!0,connectionState:"disconnected",reconnectAttempts:0,maxReconnectAttempts:10,reconnectTimer:null,agents:[],currentAgent:null,currentAgentInfo:null,conversations:[],activeConversations:[],currentWorkDir:null,messagesMap:{},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,sidebarCollapsed:!1,sessionSidebarOpen:!1,compactStatus:null,clearStatus:null,refreshingSession:!1,refreshingSessionMap:{},proxyPorts:{},hasMoreMessages:!1,loadingMoreMessages:!1,chatHistoryRequests:{},chatHistoryRequestIdSupported:null,chatHistoryConnectionGeneration:0,sessionCatalog:[],sessionProjects:[],sessionCatalogLoaded:!1,sessionCatalogMutationRequests:{},projectMutationRequests:{},activeCatalogKey:null,openUnifiedSessionCreate:!1,openUnifiedChatCreate:!1,pendingUnifiedSessionSettings:null,yeaftHasMoreHistory:!1,yeaftLoadingMoreHistory:!1,yeaftOldestLoadedSeq:null,yeaftHistoryLoadError:null,yeaftSessionHistoryState:{},yeaftMessageWindowState:{},yeaftBootstrapMetaLoadingKey:null,yeaftHistoryPerfTraceBySession:{},yeaftHistorySearchState:{requestId:null,agentId:null,sessionId:null,query:"",senderKey:"",loading:!1,results:[],hasMore:!1,nextBeforeSeq:null,error:null},yeaftHistoryOutlineBySession:{},_yeaftHistoryOutlineTimeouts:{},_yeaftHistorySearchTimeout:null,_yeaftHistoryWindowPendingByKey:{},_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,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")||"[]"),...Cd(),workCenterOpen:!1,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,yeaftDebugHistoryLimit:ra,yeaftDebugHistoryHasMore:!1,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=>Uo(e),activeSessionRoute(e){if(e.currentView==="yeaft"){let n=ps(e);return n?{runtimeProvider:"yeaft",agentId:Ce(e,n),sessionId:n}:null}let t=Uo(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]||Ve;if(e.currentView==="yeaft"){let n=e.yeaftActiveSessionFilter||"__all__",r=e.yeaftMessageWindowState[n]?.visibleTurns||us();return ea(s,e.yeaftActiveSessionFilter||null,r)}return s},yeaftAllMessages:e=>{let t=Pt(e);return t&&e.messagesMap[t]||Ve},yeaftVisibleMessages(e){let t=Pt(e),s=t&&e.messagesMap[t]||Ve,n=e.yeaftActiveSessionFilter||"__all__",r=e.yeaftMessageWindowState[n]?.visibleTurns||us();return ea(s,e.yeaftActiveSessionFilter||null,r)},hasHiddenYeaftMessages(e){if(e.currentView!=="yeaft")return!1;let t=Pt(e),s=t&&e.messagesMap[t]||Ve,n=e.yeaftActiveSessionFilter||"__all__",r=e.yeaftMessageWindowState[n]?.visibleTurns||us();return Gd(s,e.yeaftActiveSessionFilter||null,r)},activeYeaftHistoryState(e){return Eo(e)},yeaftInitialHistoryLoading(e){let t=Eo(e);return e.currentView==="yeaft"&&!!e.yeaftActiveSessionFilter&&!!t?.loading&&!t?.loaded&&this.yeaftVisibleMessages.length===0},vpsTypingInCurrentConv(e){let t=this.activeConversationId;if(!t)return Ve;let s=(e.yeaftVpTyping||{})[t];if(!s)return Ve;let n=Object.keys(s).filter(r=>(s[r]||0)>0);return n.length===0?Ve: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=qr(e);if(!t)return null;let s=`sessions/${t}`;return e.yeaftDreamLatest?.[s]||null},yeaftDreamSnapshotForActiveSession(e){let t=qr(e);if(!t)return null;let s=`sessions/${t}`;return e.yeaftDreamSnapshots?.[s]||null},yeaftDreamPromptLoadForActiveSession(e){let t=qr(e);if(!t)return null;let s=`sessions/${t}`;return e.yeaftDreamPromptLoads?.[s]||null},yeaftDreamEventsForActiveSession(e){let t=qr(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||Ve,s=e.yeaftDebugTurnsById||{},n=e.yeaftDebugLoops||Ve,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],f=s[u];if(!f||o&&f.sessionId&&f.sessionId!==o)continue;let p=a[u]||Ve,g=l[u]||Ve,h=p.length,v=0,C=0;for(let y of p){let m=y&&y.usage;m&&Number.isFinite(m.totalTokens)?v+=m.totalTokens:m&&(v+=(m.totalInputTokens||(m.inputTokens||0)+(m.cacheReadTokens||0)+(m.cacheWriteTokens||0))+(m.outputTokens||0)),y&&Number.isFinite(y.latencyMs)&&(C+=y.latencyMs)}let w=!f.closedAt,k={...f,loopCount:w||!f.loopCount?h:f.loopCount,totalTokens:w||!f.totalTokens?v:f.totalTokens,totalMs:w||!f.totalMs?C:f.totalMs,loops:p,reflections:g};c.push(k)}return c},yeaftDebugAvailableSessions:e=>{let t=new Set;for(let s of e.yeaftDebugTurnOrder||Ve){let n=e.yeaftDebugTurnsById[s];n&&n.sessionId&&t.add(n.sessionId)}return Array.from(t).sort()},yeaftDebugTurnTotal:e=>(e.yeaftDebugTurnOrder||Ve).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=ps(e);return t?Xd(e,t,Ce(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"?fs()?.activeSession?.workDir||e.yeaftYeaftDir||e.currentAgentInfo?.workDir||"":e.currentWorkDir||e.currentAgentInfo?.workDir||"",currentAgentCapabilities:e=>e.currentAgentInfo?.capabilities||["terminal","file_editor","background_tasks"],hasCapability:e=>t=>(e.currentAgentInfo?.capabilities||["terminal","file_editor","background_tasks"]).includes(t),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)=>Xd(e,t,s),isYeaftSessionUnread:e=>(t,s=null)=>{if(!t)return!1;let n=Ce(e,t,s);return n?!!e.yeaftUnreadSessionKeys?.[br(n,t)]:!1},showRecoveryBanner:e=>e.pendingRecovery&&!e.recoveryDismissed&&!e.currentConversation,currentSubagents:e=>{if(!e.currentConversation)return Ve;let t=e.subagents[e.currentConversation];return t?Object.values(t):Ve},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 Ve;let t=e.subagents[e.currentConversation];if(!t)return Ve;let s=t[e.activeSubagentId];return(Array.isArray(s?.messages)?s.messages:Ve).filter(r=>r?.type==="text")},selectedTaskInfo:()=>null,currentMcpServers:e=>e.currentConversation&&e.conversationMcpServers[e.currentConversation]||Ve},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&&Wo("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),xd(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[0]?.id||null;if(!s)return this.workCenterOpen=!1,this.workCenterAgentId=null,!1;if(this.currentAgent!==s){this.selectAgent(s),this.currentAgent=s;let n=this.agents.find(r=>r.id===s);n&&(this.currentAgentInfo=n)}return this.workCenterAgentId=s,this.workCenterOpen=!0,this.listWorkItems(s).catch(()=>{}),!0},leaveWorkCenter(){this.workCenterOpen=!1},enterWorkCenterFromSession(e,t=""){if(!e?.id)return;let s=e.agentId||Ce(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=Ml(()=>{fn(this._workCenterBrowserFence)||this.clearWorkCenterBrowserState()}));let e=vr();if(!e)return this._workCenterBrowserFence=null,this.workCenterComposerDrafts={},this.workCenterMessageOutbox={},!1;if(!fn(this._workCenterBrowserFence)){let t=Tl(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 Mt(e,t)},saveWorkCenterComposerDraft(e,t,s={}){let n=Mt(e,t);if(!e||!t)return;let r={...this.workCenterComposerDrafts||{},[n]:{text:String(s.text||""),attachments:Array.isArray(s.attachments)?s.attachments:[],target:Oh(s.target),error:String(s.error||"")}};return lo(r,this._workCenterBrowserFence)?(this.workCenterComposerDrafts=r,!0):!1},loadWorkCenterComposerDraft(e,t){return this.workCenterComposerDrafts?.[Mt(e,t)]||null},removeWorkCenterComposerDraft(e,t){let s=Mt(e,t),n={...this.workCenterComposerDrafts||{}};return delete n[s],lo(n,this._workCenterBrowserFence)?(this.workCenterComposerDrafts=n,!0):!1},prepareWorkCenterMessageEnvelope(e={}){let t=Hh(e),s=Mt(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 gn(i,this._workCenterBrowserFence)?(this.workCenterMessageOutbox=i,r):null},loadWorkCenterMessageEnvelope(e,t){return this.workCenterMessageOutbox?.[Mt(e,t)]||null},replaceWorkCenterMessageEnvelopeAttachments(e,t,s=[]){let n=Mt(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 gn(o,this._workCenterBrowserFence)?(this.workCenterMessageOutbox=o,i):null},discardWorkCenterMessageEnvelope(e,t){let s=Mt(e,t),n={...this.workCenterMessageOutbox||{}};return delete n[s],gn(n,this._workCenterBrowserFence)?(this.workCenterMessageOutbox=n,!0):!1},confirmWorkCenterMessageEnvelope(e,t,s){let n=Mt(e,t),r=this.workCenterMessageOutbox?.[n];if(!r||r.clientMessageId!==s)return!1;let i={...this.workCenterMessageOutbox||{}};return delete i[n],gn(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=Dr(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=l,u=this._workCenterListEventsByAgent[s]||{};for(let f of Object.values(u))Number(f?.generation)<=o||f?.queryKey!==r||(d=this.applyWorkItemBoardSummary(d,f.summary,n));this.workCenterItemsByAgent={...this.workCenterItemsByAgent,[s]:d},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 f=[...this.workCenterItemsByAgent[t]||[]];for(let g of Array.isArray(d?.items)?d.items:[]){if(this.workItemDeleted(t,g?.id))continue;let h=f.findIndex(v=>v.id===g.id);h<0?f.push(g):f[h]=Dr([f[h]],g)[0]}let p=this._workCenterListEventsByAgent[t]||{};for(let g of Object.values(p))Number(g?.generation)<=o||g?.queryKey!==r||(f=this.applyWorkItemBoardSummary(f,g.summary,n));return this.workCenterItemsByAgent={...this.workCenterItemsByAgent,[t]:f},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];return n?.id===t?.id&&Nd(t,n)?!1:(this.workCenterDetailByAgent={...this.workCenterDetailByAgent,[e]:t},!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=st(n),i=qs(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=st(s),a=qs(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)||st(u?.generation)!==o||Number(this._workCenterActionMessageGenerationByKey[a]||0)!==l)return u;let f=this.workCenterActionMessages[a]?.messages||[],p=_n(f,u?.messages||[]),g=this.workCenterActionMessages[a],h=g?.nextCursor,v=n==null?null:Number(n),C=h==null?null:Number(h),w=!g||v==null||C!=null&&v===C;return this.workCenterActionMessages={...this.workCenterActionMessages,[a]:{generation:o,messages:p,nextCursor:w?u?.nextCursor??null:h,total:Math.max(Number(u?.total)||0,Number(g?.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 f=Object.keys(u).some(p=>p.startsWith(`${a}:`));this.workCenterActionMessagesLoading={...this.workCenterActionMessagesLoading,[a]:f}}}})();return this._workCenterActionMessageRequests={...this._workCenterActionMessageRequests,[c]:d},d},async loadWorkItemActionRequests(e,t,s,n=null){let r=n||this.workCenterAgentId||this.currentAgent,i=st(s),o=En(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)&&st(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=st(s),c=`${En(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),f=!this.workItemDeleted(o,e)&&st(u?.generation)===a&&this._workCenterActionRequestDetailsGeneration[c]===d;return f&&(this.workCenterActionRequestDetails={...this.workCenterActionRequestDetails,[c]:u?.request||null}),f?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){let n=s||this.workCenterAgentId||this.currentAgent,r=this.beginWorkCenterDetailWrite(n),i=await this.workCenterRequest("resume",{id:e,revision:t},n);return await this.listWorkItems(n,this._workCenterListFiltersByAgent[n]||{}),this.commitWorkCenterDetail(n,i,r),i},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={}){if(!this.hydrateWorkCenterBrowserState())throw new Error("Work Center browser owner is unavailable; sign in again and retry");let a=i||this.workCenterAgentId||this.currentAgent,l=this.prepareWorkCenterMessageEnvelope({agentId:a,workItemId:e,target:s,text:t,attachments:r,revision:n,planRevision:o.planRevision,ledgerRevision:o.ledgerRevision,coordinatorRevision:o.coordinatorRevision});if(!l)throw new Error("Work Center browser owner changed; reopen Work Center and try again");let c=l.clientMessageId,d=this.workCenterDetailByAgent[a]?.id===e?this.workCenterDetailByAgent[a]:null,u=await this.workCenterRequest("post_work_item_message",{id:l.workItemId,clientMessageId:c,text:l.text,target:l.target,revision:l.revision,planRevision:l.planRevision||Number(d?.planRevision)||0,ledgerRevision:l.ledgerRevision||Number(d?.ledgerRevision)||0,coordinatorRevision:Number.isInteger(Number(l.coordinatorRevision))?Number(l.coordinatorRevision):Number(d?.coordinatorRevision)||0,attachments:l.attachments},a);if(l.target.kind==="coordinator"){if(!u?.accepted)throw new Error("Work Center Coordinator did not accept the message");return this.confirmWorkCenterMessageEnvelope(a,e,c),u}return await this.listWorkItems(a,this._workCenterListFiltersByAgent[a]||{}),this.confirmWorkCenterMessageEnvelope(a,e,c),u},async sendWorkItemMessage(e,t,s,n=[],r=null,i={}){let o=r||this.workCenterAgentId||this.currentAgent,a=this.workCenterDetailByAgent[o]?.id===e?this.workCenterDetailByAgent[o]:null,l=await this.workCenterRequest("work_item_message",{id:e,text:t,revision:s,planRevision:Number.isInteger(Number(i.planRevision))?Number(i.planRevision):Number(a?.planRevision)||0,ledgerRevision:Number.isInteger(Number(i.ledgerRevision))?Number(i.ledgerRevision):Number(a?.ledgerRevision)||0,coordinatorRevision:Number.isInteger(Number(i.coordinatorRevision))?Number(i.coordinatorRevision):Number(a?.coordinatorRevision)||0,attachments:Array.isArray(n)?n:[]},o);if(!l?.accepted)throw new Error("Work Center Coordinator did not accept the message");return l},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){let a=o||this.workCenterAgentId||this.currentAgent,l=Number(this._workCenterActionInputGenerationByAgent[a]||0)+1;this._workCenterActionInputGenerationByAgent={...this._workCenterActionInputGenerationByAgent,[a]:l};let c=await this.workCenterRequest("action_input",{id:e,text:t,actionId:s,revision:n,generation:r,attachments:i},a);await this.listWorkItems(a,this._workCenterListFiltersByAgent[a]||{});let d=this.workCenterDetailByAgent[a],u=d?.actions?.find(p=>p?.id===s),f=d?.id===e&&Number(d.revision)===Number(n)&&u&&Number(u.generation)===Number(r);return this._workCenterActionInputGenerationByAgent[a]===l&&f&&!Vd(c,d)?(this.workCenterDetailByAgent={...this.workCenterDetailByAgent,[a]:c},c):d?.id===e?d:c},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(([,f])=>f?.agentId===e&&f.clientMessageId===t.clientMessageId);if(u){let[f,p]=u;clearTimeout(p.timer),delete this.workCenterPending[f],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=Dr(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(C=>C?.id===t.actionId)?{...s,eventActionId:t.actionId}:s,f=Yo(d,u),p=Number(s.coordinatorRevision),g=Number(d.coordinatorRevision)||0,h=Number.isInteger(p)&&p>g,v=Fd(d,u);this.workCenterDetailByAgent={...this.workCenterDetailByAgent,[e]:Od(d,s)},v&&this.refreshWorkItemDetailAfterActionChange(e,s,h?null:f)}},async refreshWorkItemDetailAfterActionChange(e,t,s=null){let n=s?(Array.isArray(t.actionStats)?t.actionStats:[]).find(h=>h?.id===s.actionId):(Array.isArray(t.actionStats)?t.actionStats:[]).find(h=>h?.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 f=this.beginWorkCenterDetailWrite(e),p={key:u,generation:f};this._workCenterDetailEventRefreshByAgent={...this._workCenterDetailEventRefreshByAgent,[e]:p},s&&this.invalidateWorkItemActionMessages(e,t.id,s.actionId,s.generation);let g=r&&o!=null?this.loadWorkItemActionMessages(t.id,r,o,null,e).catch(()=>null):null;try{let h=await this.workCenterRequest("get",{id:t.id},e),v=this.workCenterDetailByAgent[e],C=v?.actions?.find(T=>T?.id===r),w=h?.actions?.find(T=>T?.id===r),k=o==null||st(C?.generation)===o,y=o==null||st(w?.generation)>=o,m=l==null||Number(h?.coordinatorRevision)===l,b=l!=null||k&&y&&(t.currentActionId==null?h?.currentActionId==null:v?.currentActionId===t.currentActionId&&h?.currentActionId===t.currentActionId);v?.id===t.id&&m&&b&&this.commitWorkCenterDetail(e,h,f)&&g&&await g}catch{}finally{if(this._workCenterDetailEventRefreshByAgent[e]===p){let h={...this._workCenterDetailEventRefreshByAgent};delete h[e],this._workCenterDetailEventRefreshByAgent=h}}},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),f=Array.isArray(this._yeaftRetiredCatalogEpochsByAgent?.[e])?this._yeaftRetiredCatalogEpochsByAgent[e]:[],p=!!a&&f.includes(a),g=!!a&&a===o,h=i>0?g&&i===r:c>0&&c===l,v=i>0?!!a&&(a!==o||i>r):r===0&&c>l,C=i>0?!!t.catalogDigest&&!!n.catalogDigest&&t.catalogDigest===n.catalogDigest:t.catalogDigest===n.catalogDigest,w=u&&!p&&(v||h&&C),y=w||s&&r===0&&l===0&&!u&&d,m={...t};if(!y)for(let T of $h)delete m[T];let b={...n,...m};if(y){if(w&&o&&a&&o!==a){let T=[...f.filter(L=>L!==o),o].slice(-Vh);this._yeaftRetiredCatalogEpochsByAgent={...this._yeaftRetiredCatalogEpochsByAgent||{},[e]:T}}b.availableModels=t.availableModels,b.catalogRefreshedAt=w?c:null,b.catalogEpoch=w&&a||null,b.catalogRevision=w&&i||null,b.catalogDigest=w&&t.catalogDigest||null}this.yeaftStatusByAgent={...this.yeaftStatusByAgent,[e]:b},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 Ce(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))},Dh),e):(this.yeaftSessionHydrateRequestId=null,this.yeaftSessionHydrateSlices=[],this.yeaftSessionHydrateError="session_inventory_send_failed",null)},beginYeaftHistoryLoad(e){let t=wc(this,e);if(!t)return null;let{agentId:s,sessionId:n}=e||{};return setTimeout(()=>{Sc(this,{agentId:s,sessionId:n,requestId:t.requestId,error:"history_load_timeout"})},bc),t},finishYeaftHistoryLoad(e,t={},s="chunk"){return kc(this,e,t,s)},isCurrentYeaftHistoryResponse(e){return _o(this,e)},syncActiveYeaftHistoryLoad(){return xn(this)},enterYeaft(e=null,{deferBootstrap:t=!1}={}){let s=this.currentAgent;jo(this);let n=ps(this),r=!e&&n?Ce(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]=[]),Ad(this),this.currentView="yeaft",Wo("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=ps(this),r=n?Ce(this,n):this.currentAgent,i=Pe(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(w=>w&&(w.sessionId??w.groupId??null)===n),d=!!n&&ko({sessionState:o,hasCachedSessionRows:c,force:!!s}),u=!!n&&!d&&dc(o,t);if(!a&&!d&&!u)return!1;let f=`${r}:${n||"__none__"}`,p=a&&!d&&!u;if(p&&this.yeaftBootstrapMetaLoadingKey===f)return!1;p&&(this.yeaftBootstrapMetaLoadingKey=f);let g=null;n&&d?g=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&&(g=this.beginYeaftHistoryLoad({agentId:r,sessionId:n,mode:"delta",preserveLoaded:!0,latestSeq:l}));let h={type:"yeaft_load_history",agentId:r,sessionId:n,...g?{requestId:g.requestId}:{}};u?h.afterSeq=l:h.limit=d?Hr:0;let v=Cn();h.perfTraceId=v;let C=u?"delta":d?"recent":"metadata";return n&&(this.yeaftHistoryPerfTraceBySession={...this.yeaftHistoryPerfTraceBySession||{},[i]:v}),Ze(this,{traceId:v,phase:"history.request_send",agentId:r,sessionId:n,messageType:h.type,bytes:JSON.stringify(h).length,detail:{mode:C,limit:h.limit??null,afterSeq:h.afterSeq??null,hasCachedSessionRows:c,needSessionReady:a}}),this.sendWsMessage(h),!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}={}){if(!this.currentAgent)return;let o=typeof i=="string"?i.trim():(this.yeaftDebugSearch||"").trim(),a=typeof r=="string"&&r,l=o&&!a?lu:ra,c=Number.isFinite(t)&&t>0?t:this.yeaftDebugHistoryLimit||l,d=Math.max(1,Math.min(l,c)),u=a?"detail":"list",f=`dbg_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,10)}`,p=JSON.stringify({agentId:this.currentAgent,groupId:e||null,limit:d,dreamLimit:Number.isFinite(s)&&s>0?s:5,indexOnly:!!n,detailTurnId:r||null,search:a?"":o});if(this._yeaftDebugHistoryInFlightKey===p)return;this._yeaftDebugHistoryInFlightKey=p,a||(this._yeaftDebugHistoryLatestListRequestId=f),this.yeaftDebugHistoryLimit=d,this.yeaftDebugHistoryLoading=!0,this.yeaftDebugHistoryError=null;let g={type:"yeaft_fetch_debug_history",agentId:this.currentAgent,requestId:f,requestKind:u,limit:d,dreamLimit:Number.isFinite(s)&&s>0?s:5};n&&(g.indexOnly=!0),typeof r=="string"&&r?g.detailTurnId=r:o&&(g.search=o),typeof e=="string"&&e&&(g.sessionId=e),this.sendWsMessage(g),this._fetchYeaftDebugHistoryTimer&&clearTimeout(this._fetchYeaftDebugHistoryTimer),this._fetchYeaftDebugHistoryTimer=setTimeout(()=>{this.yeaftDebugHistoryLoading&&(this.yeaftDebugHistoryLoading=!1,this.yeaftDebugHistoryError="Debug history is unavailable right now. Try again after the agent reconnects."),this._yeaftDebugHistoryInFlightKey=null,this._fetchYeaftDebugHistoryTimer=null},1e4)},agentIdForSession(e){return Ce(this,e)},sendYeaftSessionMessage({groupId:e,text:t,mentions:s,attachments:n,quote:r}){let i=Ce(this,e);if(!e||!i)return;let o=Array.isArray(n)?n.filter(g=>g&&g.fileId):[],a=Lr(r),l=o.length>0;if(!t?.trim()&&!l)return;let c=t?.trim()?t:"(attached files)",d=`u_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,10)}`,u=Cn();this.yeaftPerfTraceByMessageId={...this.yeaftPerfTraceByMessageId||{},[d]:u},Ze(this,{traceId:u,phase:"send.prepare",agentId:i,sessionId:e,turnId:d,messageType:"yeaft_session_send",detail:{mentionCount:Array.isArray(s)?s.length:0,attachmentCount:o.length,quoted:!!a}});let f=Pt(this,e);if(f){let g={id:d,messageId:d,clientMessageId:d,type:"user",content:c,sessionId:e,turnId:d,...a?{quote:a}:{}};if(o.length>0&&(g.attachments=o.map(h=>({fileId:h.fileId,name:h.name,preview:h.preview,isImage:!!h.isImage,mimeType:h.mimeType||""}))),this.addMessageToConversation(f,g),this.processingConversations[f]=!0,e){let h=dt(i,e);this.yeaftProcessingSessions={...this.yeaftProcessingSessions,...h?{[h]:!0}:{}}}this._turnCompletedConvs?.delete(f),this._closedAt?.[f]&&delete this._closedAt[f],this.getOrCreateExecutionStatus(f),wn(this,f)}let p={type:"yeaft_session_send",agentId:i,id:d,sessionId:e,text:c,mentions:Array.isArray(s)?s:[],perfTraceId:u,...a?{quote:a}:{}};o.length>0&&(p.attachments=o.map(g=>({fileId:g.fileId,isImage:!!g.isImage}))),Ze(this,{traceId:u,phase:"send.websocket_send",agentId:i,sessionId:e,turnId:d,messageType:p.type,bytes:JSON.stringify(p).length}),this.sendWsMessage(p)},cancelYeaftTask({agentId:e=null,sessionId:t,taskId:s}){let n=typeof t=="string"?t.trim():"",r=typeof s=="string"?s.trim():"",i=Ce(this,n,e);return!i||!n||!r?!1:(this.yeaftStoppingTasksById={...this.yeaftStoppingTasksById,[sa(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)},getYeaftMessageWindowKey(e=null){return e||this.yeaftActiveSessionFilter||"__all__"},pruneYeaftMessageWindow(e=null){if(this.currentView!=="yeaft")return;let t=this.getYeaftMessageWindowKey(e);this.yeaftMessageWindowState={...this.yeaftMessageWindowState,[t]:{visibleTurns:us()}}},expandYeaftMessageWindow(e=null,t=Dn()){if(this.currentView!=="yeaft")return;let s=this.getYeaftMessageWindowKey(e),r=(this.yeaftMessageWindowState[s]?.visibleTurns||us())+Math.max(1,Number.isFinite(t)?Math.floor(t):Dn());this.yeaftMessageWindowState={...this.yeaftMessageWindowState,[s]:{visibleTurns:r}}},isYeaftMessageCached(e,t,s=null){let n=e||this.yeaftActiveSessionFilter||null,r=s||Pt(this,n);return!r||!t?!1:(this.messagesMap[r]||[]).some(i=>(!n||(i?.sessionId??i?.groupId??null)===n)&&((i?.id||i?.messageId)===t||i?.persistedMessageId===t))},revealYeaftMessage(e,t,s=null){let n=e||this.yeaftActiveSessionFilter||null,r=s||Pt(this,n);if(!r||!t)return!1;let i=(this.messagesMap[r]||[]).filter(u=>n?(u?.sessionId??u?.groupId??null)===n:!0),o=i.findIndex(u=>(u?.id||u?.messageId)===t||u?.persistedMessageId===t);if(o<0)return!1;let a=Kd(i),l=a.findIndex(u=>o>=u.start&&o<u.end);if(l<0)return!1;let c=Math.max(us(),a.length-l),d=this.getYeaftMessageWindowKey(n);return this.yeaftMessageWindowState={...this.yeaftMessageWindowState,[d]:{visibleTurns:c}},!0},getYeaftHistoryOutlineState(e=null,t=null){let s=e||this.yeaftActiveSessionFilter||null,n=Ce(this,s,t),r=Pe(n,s),i=this.yeaftHistoryOutlineBySession[r]||{requestId:null,agentId:n,sessionId:s,loading:!1,results:[],hasMore:!1,nextBeforeSeq:null,totalCount:null,loaded:!1,error:null},o=Pt(this,s),a=o?this.messagesMap[o]||[]:[],l=new Map((i.results||[]).map(f=>[Ln(f),f])),c=0;for(let f of a){if((f?.sessionId??f?.groupId??null)!==s)continue;let p=f.messageId||f.id;if(!p)continue;let g=f.type==="user"&&!!f.clientMessageId&&p===f.clientMessageId,h=f.type==="assistant"&&f.isStreaming===!0;if(!g&&!h)continue;let v=f.type,C=f.turnId||f.threadId||p,w=f.speakerVpId||f.vpId||null,k=Ln({role:v,messageId:p,clientMessageId:f.clientMessageId,turnId:C,speakerVpId:w}),y=l.get(k),b=(typeof f.content=="string"?f.content:"").replace(/\s+/g," ").trim();l.set(k,{...y,messageId:Number.isFinite(y?.seq)?y.messageId:p,...f.clientMessageId?{clientMessageId:f.clientMessageId}:{},turnId:C,role:v,speakerVpId:w||y?.speakerVpId||null,timestamp:f.timestamp||f.ts||y?.timestamp||null,snippet:b.length>180?`${b.slice(0,180).trimEnd()}\u2026`:b||y?.snippet||""}),y||(c+=1)}let d=f=>{let p=typeof f=="number"?f:Date.parse(f||"");return Number.isFinite(p)?p:0},u=Array.from(l.values()).sort((f,p)=>Number.isFinite(f.seq)&&Number.isFinite(p.seq)?f.seq-p.seq:d(f.timestamp)-d(p.timestamp));return{...i,results:u,totalCount:Number.isFinite(i.totalCount)?i.totalCount+c:i.totalCount}},promoteYeaftHistoryOutlineRow(e){let t=e?.sessionId??e?.groupId??null,s=Ce(this,t),n=Pe(s,t),r=this.yeaftHistoryOutlineBySession[n];if(!t||!s||!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=jh(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(),f=Ln({role:i,messageId:o,clientMessageId:e.clientMessageId,turnId:l,speakerVpId:c}),p=new Map((r.results||[]).map(k=>[Ln(k),k])),g=p.get(f);p.set(f,{...g,messageId:o,...e.clientMessageId?{clientMessageId:e.clientMessageId}:{},turnId:l,seq:a,role:i,speakerVpId:c,timestamp:e.timestamp||e.ts||g?.timestamp||null,snippet:u.length>180?`${u.slice(0,180).trimEnd()}\u2026`:u||g?.snippet||""});let h=50,v=Array.from(p.values()).sort((k,y)=>(k.seq||0)-(y.seq||0)),C=v.length>h,w=v.slice(-h);return this.yeaftHistoryOutlineBySession={...this.yeaftHistoryOutlineBySession,[n]:{...r,results:w,hasMore:r.hasMore||C,nextBeforeSeq:C&&Number.isFinite(w[0]?.seq)?w[0].seq:r.nextBeforeSeq,totalCount:Number.isFinite(r.totalCount)&&!g?r.totalCount+1:r.totalCount}},!0},promoteCompletedYeaftHistoryOutline(e,t=null){let s=this.messagesMap[e]||[],n=null,r=[];for(let i=s.length-1;i>=0;i--){let o=s[i];if(o?.type==="user")break;if(t&&o?.turnId&&o.turnId!==t||o?.type!=="assistant")continue;let a=typeof o.content=="string"?o.content.replace(/\s+/g," ").trim():"";n?!String(n.content||"").trim()&&a&&(n=o):n=o,a&&r.unshift(a)}return n?this.promoteYeaftHistoryOutlineRow({...n,content:r.join(" ")}):!1},invalidateYeaftHistoryOutline(e){let t=Ce(this,e),s=Pe(t,e),n=this.yeaftHistoryOutlineBySession[s];return!e||!t||!n?!1:n.loading?(this.yeaftHistoryOutlineBySession={...this.yeaftHistoryOutlineBySession,[s]:{...n,refreshPending:!0}},!0):(this.yeaftHistoryOutlineBySession={...this.yeaftHistoryOutlineBySession,[s]:{...n,loaded:!1,refreshPending:!1}},this.currentView==="yeaft"&&this.yeaftActiveSessionFilter===e?this.loadYeaftHistoryOutline({force:!0}):!0)},loadYeaftHistoryOutline({append:e=!1,force:t=!1,targetSessionId:s=null,targetAgentId:n=null}={}){if(this.currentView!=="yeaft"&&!s)return!1;let r=s||this.yeaftActiveSessionFilter||null,i=n||Ce(this,r);if(!r||!i)return!1;let o=Pe(i,r),a=this.getYeaftHistoryOutlineState(r,i);if(!e&&a.loaded&&!t)return!0;if(e&&(!a.hasMore||!Number.isFinite(a.nextBeforeSeq))||a.loading)return!1;if(!iu(this,i,"session_history_outline"))return this.yeaftHistoryOutlineBySession={...this.yeaftHistoryOutlineBySession,[o]:{...a,error:"unsupported",loading:!1}},!1;let l=`history_outline_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,c={...a,requestId:l,agentId:i,sessionId:r,loading:!0,requestAppend:e,refreshPending:!1,error:null};this.yeaftHistoryOutlineBySession={...this.yeaftHistoryOutlineBySession,[o]:c};let d=this._yeaftHistoryOutlineTimeouts[o];d&&clearTimeout(d);let u=setTimeout(()=>{let f=this.yeaftHistoryOutlineBySession[o];if(f?.requestId!==l)return;let p={...this._yeaftHistoryOutlineTimeouts};delete p[o],this._yeaftHistoryOutlineTimeouts=p;let g=f.refreshPending===!0;this.yeaftHistoryOutlineBySession={...this.yeaftHistoryOutlineBySession,[o]:{...f,requestId:null,loading:!1,requestAppend:!1,loaded:g?!1:f.loaded,refreshPending:!1,error:g?null:"timeout"}},g&&this.loadYeaftHistoryOutline({force:!0,targetSessionId:r,targetAgentId:i})},1e4);return this._yeaftHistoryOutlineTimeouts={...this._yeaftHistoryOutlineTimeouts,[o]:u},this.sendWsMessage({type:"yeaft_load_history_outline",agentId:i,sessionId:r,requestId:l,limit:50,...e&&Number.isFinite(a.nextBeforeSeq)?{beforeSeq:a.nextBeforeSeq}:{},includeTotal:!a.loaded}),!0},handleYeaftHistoryOutline(e){if(!e?.agentId||!e?.sessionId)return!1;let t=Pe(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=Array.isArray(e.results)?e.results:[],o=s.requestAppend?[...s.results||[],...i]:i,a=new Map(o.filter(d=>d?.messageId).map(d=>[Ln(d),d])),l=Array.from(a.values()).sort((d,u)=>(d.seq||0)-(u.seq||0)),c=s.refreshPending===!0;return this.yeaftHistoryOutlineBySession={...this.yeaftHistoryOutlineBySession,[t]:{...s,requestId:null,loading:!1,requestAppend:!1,refreshPending:!1,loaded:c?!1:!e.error,results:l,hasMore:!!e.hasMore,nextBeforeSeq:Number.isFinite(e.nextBeforeSeq)?e.nextBeforeSeq:null,totalCount:Number.isFinite(e.totalCount)?e.totalCount:s.totalCount,error:c?null:e.error||null}},c&&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=Ce(this,i);if(this._yeaftHistorySearchTimeout&&(clearTimeout(this._yeaftHistorySearchTimeout),this._yeaftHistorySearchTimeout=null),!i||!o||n.length<2&&!r)return this.yeaftHistorySearchState={requestId:null,agentId:o,sessionId:i,query:n,senderKey:r,loading:!1,results:[],hasMore:!1,nextBeforeSeq:null,error:null},!1;let a=this.yeaftHistorySearchState||{};if(!iu(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,error:"unsupported"},!1;let l=`history_search_${Date.now()}_${Math.random().toString(36).slice(2,8)}`;return 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,error:null},this._yeaftHistorySearchTimeout=setTimeout(()=>{this.yeaftHistorySearchState?.requestId===l&&(this._yeaftHistorySearchTimeout=null,this.yeaftHistorySearchState={...this.yeaftHistorySearchState,loading:!1,error:"timeout"})},1e4),this.sendWsMessage({type:"yeaft_search_history",agentId:o,sessionId:i,requestId:l,query:n,senderKey:r,limit:20,...t&&a.query===n&&a.senderKey===r&&Number.isFinite(a.nextBeforeSeq)?{beforeSeq:a.nextBeforeSeq}:{}}),!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:[],n=new Map((t.results||[]).map(r=>[r.messageId,r]));for(let r of s)r?.messageId&&n.set(r.messageId,r);return this.yeaftHistorySearchState={...t,loading:!1,results:Array.from(n.values()),hasMore:!!e.hasMore,nextBeforeSeq:Number.isFinite(e.nextBeforeSeq)?e.nextBeforeSeq:null,error:e.error||null},!0},loadYeaftHistoryWindow(e){let t=this.yeaftActiveSessionFilter||null,s=Ce(this,t);if(!t||!s||!e?.messageId||!Number.isFinite(e.seq))return Promise.resolve(!1);if(this.isYeaftMessageCached(t,e.messageId))return Promise.resolve(!0);let n=Pe(s,`${t}:${e.messageId}`),r=this._yeaftHistoryWindowPendingByKey||{};if(r[n]?.promise)return r[n].promise;let i=`history_window_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,o=null,a=new Promise(c=>{o=c}),l=setTimeout(()=>{if(this._yeaftHistoryWindowPendingByKey?.[n]?.requestId!==i)return;let{[n]:d,...u}=this._yeaftHistoryWindowPendingByKey;this._yeaftHistoryWindowPendingByKey=u,o(!1)},1e4);return this._yeaftHistoryWindowPendingByKey={...r,[n]:{requestId:i,agentId:s,sessionId:t,messageId:e.messageId,resolve:o,timeout:l,promise:a}},this.sendWsMessage({type:"yeaft_load_history_window",agentId:s,sessionId:t,requestId:i,anchorMessageId:e.messageId,anchorSeq:e.seq,beforeTurns:5,afterTurns:5}),a},async revealYeaftHistoryResult(e){let t=this.yeaftActiveSessionFilter||null,s=Ce(this,t),n=Pt(this,t);return!t||!s||!n||!e?.messageId||!await this.loadYeaftHistoryWindow(e)||this.currentView!=="yeaft"||this.yeaftActiveSessionFilter!==t||Ce(this,t)!==s||Pt(this,t)!==n?!1:this.revealYeaftMessage(t,e.messageId,n)},handleYeaftHistoryWindow(e,t=null){let n=Object.entries(this._yeaftHistoryWindowPendingByKey||{}).find(([,c])=>c?.requestId===e?.requestId);if(!n)return!1;let[r,i]=n;if(e.agentId!==i.agentId||e.sessionId!==i.sessionId)return!1;clearTimeout(i.timeout);let{[r]:o,...a}=this._yeaftHistoryWindowPendingByKey;this._yeaftHistoryWindowPendingByKey=a;let l=!e.error&&!!t&&this.isYeaftMessageCached(i.sessionId,i.messageId,t);return i.resolve(!!l),!!l},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=$s(this,t,s);if(e.data&&n){if(e.data.type!=="result")return;let i=yc(this,t,s);if(!i)return;let o=e.turnId?Bs(this,t,e.turnId):"",a=!!(o&&this.activeVpTurns?.[o])||(this.messagesMap?.[i]||[]).some(l=>l?.turnId===e.turnId&&(l.isStreaming||l.status==="pending"));if(!e.turnId||!a)return;e={...e,conversationId:i}}if(e.perfTraceId&&(Ze(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 i=e.agentId||this.yeaftAgentId||this.currentAgent||null,o=zt(this,i,e.conversationId),a=e.turnId?Bs(this,e.agentId||null,e.turnId):"";if(a&&this.activeVpTurns?.[a]?.retryAttempt){let{retryAttempt:l,retryMax:c,retryDelayMs:d,retryReason:u,retryRecoveryMode:f,...p}=this.activeVpTurns[a];this.activeVpTurns={...this.activeVpTurns,[a]:p}}if(o){let l=e.sessionId??e.groupId??null,c=ou(this,l,i),d=i&&this.yeaftConversationIdsByAgent?this.yeaftConversationIdsByAgent[i]:null,u=mt(this,i);u&&u.targetConversationId!==o?In(this,i,o):!u&&d&&d!==o&&!String(d).startsWith("yeaft-local-")&&(ht(this,d,o,{removeSource:d!==this.yeaftConversationId}),kn(this,i,d,o)),Ao(this,i,o);let f=mt(this,i,o),p=f?.sourceConversationId||d,g=!c&&p===this.yeaftConversationId;if(this.currentView==="yeaft"&&i&&p&&p!==o){let y=!g&&(!!f||String(p).startsWith("yeaft-local-"));ht(this,p,o,{removeSource:y}),g?Ar(this,i,p,o):y&&Sn(this,i,o)}i&&(this.yeaftConversationIdsByAgent={...this.yeaftConversationIdsByAgent||{},[i]:o}),(c||!this.yeaftConversationId)&&(this.yeaftConversationId=o),c&&(this.activeConversations=[o]),this.messagesMap[o]||(this.messagesMap[o]=[]),this.currentView==="yeaft"&&(e.data?.type==="user"||e.data?.type==="text_delta")&&this.pruneYeaftMessageWindow(this.yeaftActiveSessionFilter&&e.sessionId||null);let h=this._currentYeaftAgentId,v=this._currentYeaftSessionId,C=this._currentYeaftVpId,w=this._currentYeaftTurnId,k=this._currentYeaftThreadId;i&&(this._currentYeaftAgentId=i),l!=null&&(this._currentYeaftSessionId=l),e.vpId&&(this._currentYeaftVpId=e.vpId),e.turnId&&(this._currentYeaftTurnId=e.turnId),e.threadId&&(this._currentYeaftThreadId=e.threadId);try{this.currentView==="yeaft"&&l&&(!this.yeaftActiveSessionFilter||l===this.yeaftActiveSessionFilter)&&this.pruneYeaftMessageWindow(this.yeaftActiveSessionFilter?l:null);let m=typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now();if(this.handleAssistantOutputFrame(o,e.data),e.perfTraceId){let P=typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now();Ze(this,{traceId:e.perfTraceId,phase:"store.apply_output",agentId:e.agentId||null,sessionId:l||null,vpId:e.vpId||null,turnId:e.turnId||null,threadId:e.threadId||null,messageType:e.data?.type||null,durationMs:P-m}),Tr(this,{traceId:e.perfTraceId,agentId:e.agentId||null,sessionId:l||null,vpId:e.vpId||null,turnId:e.turnId||null,threadId:e.threadId||null,messageType:e.data?.type||null})}let b=e.data,T=b?.message?.id||b?.id||null,L=Wh(T),N=Array.isArray(b?.message?.content)?b.message.content:[],$=N.some(P=>P?.type==="tool_use"),D=!!b?.tool_use_result||N.some(P=>P?.type==="tool_result");if(l){let P=!D&&!Bh(this,o,l)&&(b?.type==="user"||b?.type==="assistant"&&!$)?L:null,M=Pe(e.agentId||null,l),A=this.yeaftSessionHistoryState[M]||{},R=Number.isFinite(A.latestSeq)?A.latestSeq:-1;P!==null&&P>R&&(this.yeaftSessionHistoryState={...this.yeaftSessionHistoryState,[M]:{...A,latestSeq:P}})}}finally{this._currentYeaftAgentId=h,this._currentYeaftSessionId=v,this._currentYeaftVpId=C,this._currentYeaftTurnId=w,this._currentYeaftThreadId=k}}return}let r=e.event;if(r)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 i=zt(this,e.agentId||null,e.conversationId);if(!i||!r.requestId)break;let o=eu(e,r,i),a=()=>{let l=this.messagesMap[i]||[],c=su(l,o,i);if(c){if(c.askAnswered||c.askExpired)return!0;c.toolName="AskUserQuestion",r.toolCallId&&!c.toolId&&(c.toolId=r.toolCallId),c.agentId=o.agentId||c.agentId||null,c.askRequestId=r.requestId,c.askQuestions=r.questions||[],c.askCreatedAt=r.createdAt||null,c.askExpiresAt=r.expiresAt||null,r.replay&&(c.askPending=!1,c.pendingAnswers=null,c.askSubmitGeneration=null),c.isHistory=!1;let f=nu(this,o);return f&&ta(c,f),this.messagesMap={...this.messagesMap,[i]:l.slice()},!0}if(!r.replay)return!1;let d={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:o.agentId,sessionId:o.sessionId,vpId:o.vpId,speakerVpId:o.vpId,turnId:o.turnId,threadId:o.threadId||"main",hasResult:!1,isHistory:!1,timestamp:r.createdAt||Date.now()},u=nu(this,o);return u&&ta(d,u),l.push(d),this.messagesMap={...this.messagesMap,[i]:l.slice()},!0};if(!a()){let l=0,c=setInterval(()=>{l+=1,(a()||l>=10)&&clearInterval(c)},200)}break}case"ask_user_answered":case"ask_user_expired":{let i=zt(this,e.agentId||null,e.conversationId);if(!i||!r.requestId)break;let o=this.messagesMap[i]||[],a=eu(e,r,i),l=su(o,a,i);if(!l){Nh(this,a,r);break}ta(l,r),this.messagesMap={...this.messagesMap,[i]:o.slice()};break}case"session_ready":{let i=r.conversationId,o=e.agentId||this.currentAgent;if($s(this,o,i))break;let a=o&&this.yeaftConversationIdsByAgent?this.yeaftConversationIdsByAgent[o]:null,l=this.yeaftConversationId?String(this.yeaftConversationId):"",c=l.startsWith("yeaft-local-")&&(!o||l.startsWith(`yeaft-local-${o}-`)||/^yeaft-local-\d/.test(l))?this.yeaftConversationId:null,d=a||c,u=r.sessionId||e.sessionId||null,f=ou(this,u,o),p=mt(this,o);p&&p.targetConversationId!==i?In(this,o,i):!p&&a&&a!==i&&!String(a).startsWith("yeaft-local-")&&kn(this,o,a,i),Ao(this,o,i);let h=mt(this,o,i)?.sourceConversationId||d,v=!f&&h===this.yeaftConversationId;if(h&&h!==i){let m=!v;ht(this,h,i,{removeSource:m}),v?Ar(this,o,h,i):m&&Sn(this,o,i)}else this.messagesMap[i]||(this.messagesMap[i]=[]);o&&(this.yeaftConversationIdsByAgent={...this.yeaftConversationIdsByAgent||{},[o]:i},this.cacheYeaftAgentStatus(o,r,{allowBootstrapCatalog:f})),f&&(this.yeaftModel=r.model,this.yeaftModelEffort=r.modelEffort||null,this.yeaftSessionReady=!0,this.yeaftBootstrapMetaLoadingKey=null,o?this.applyCachedYeaftStatus(o):this.yeaftAvailableModels=r.availableModels||[]);let C=Array.isArray(r.tasks)?r.tasks:[],w={};for(let[m,b]of Object.entries(this.yeaftActiveTasksBySession||{})){let T=Object.fromEntries(Object.entries(b||{}).filter(([,N])=>N?.id&&(N.agentId&&N.agentId!==o||ia.has(N.status)))),L=na(T);Object.keys(L).length>0&&(w[m]=L)}for(let m of C){if(!m?.id||!m.sessionId||m.status!=="running")continue;let b=Pe(o,m.sessionId);w[b]={...w[b]||{},[m.id]:{...m,agentId:o}}}this.yeaftActiveTasksBySession=w,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=i),f&&(this.activeConversations=[i]);let k=e.agentId||this.currentAgent||null,y=k||"__current__";this._yeaftVpSubscribedAgentKey!==y&&(this._yeaftVpSubscribedAgentKey=y,this.sendWsMessage(k?{type:"yeaft_vp_subscribe",agentId:k}:{type:"yeaft_vp_subscribe"}));break}case"yeaft_status":{let i=e.agentId||this.currentAgent;i&&this.cacheYeaftAgentStatus(i,r);break}case"context_usage":break;case"turn_open":{if(!r.turnId)break;let i={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,totalTokens:0,loopCount:0,memoryLoaded:null,memoryLoadedMeta:null,memoryAdjust:null,tools:[],detailsLoaded:!0};this.yeaftDebugTurnsById={...this.yeaftDebugTurnsById,[r.turnId]:i},this.yeaftDebugTurnOrder.includes(r.turnId)||(this.yeaftDebugTurnOrder=[...this.yeaftDebugTurnOrder,r.turnId]);break}case"turn_close":{if(!r.turnId)break;let i=this.yeaftDebugTurnsById[r.turnId];if(!i)break;this.yeaftDebugTurnsById={...this.yeaftDebugTurnsById,[r.turnId]:{...i,closedAt:Date.now(),totalMs:r.totalMs||0,totalTokens:r.totalTokens||0,loopCount:r.loopCount||i.loopCount||0}};break}case"memory_used":{if(!r.turnId)break;let i=this.yeaftDebugTurnsById[r.turnId];if(!i)break;this.yeaftDebugTurnsById={...this.yeaftDebugTurnsById,[r.turnId]:{...i,memoryLoaded:Array.isArray(r.loaded)?r.loaded:[],memoryLoadedMeta:r.meta||null}};break}case"dream_memory_loaded":{let i=Array.isArray(r.resident)?r.resident:[];if(r.turnId){let a=this.yeaftDebugTurnsById[r.turnId];a&&(this.yeaftDebugTurnsById={...this.yeaftDebugTurnsById,[r.turnId]:{...a,dreamMemoryLoaded:i,dreamMemoryLoadedInto:r.loadedInto||"system_prompt.memory"}})}let o={};for(let a of i){let l=a&&typeof a.scope=="string"?a.scope:null,c=l&&/^sessions\/[^/]+$/.test(l)?l:l&&/^group\/[^/]+$/.test(l)?`sessions/${l.slice(6)}`:null;c&&(o[c]={scope:c,sourceScope:l,sessionId:c.slice(9),turnId:r.turnId||null,vpId:r.vpId||null,loadedInto:r.loadedInto||"system_prompt.memory",summary:a.summary||"",truncated:!!a.truncated,receivedAt:Date.now()})}Object.keys(o).length>0&&(this.yeaftDreamPromptLoads={...this.yeaftDreamPromptLoads,...o});break}case"memory_adjust":{if(!r.turnId)break;let i=this.yeaftDebugTurnsById[r.turnId];if(!i)break;this.yeaftDebugTurnsById={...this.yeaftDebugTurnsById,[r.turnId]:{...i,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(!r.turnId)break;let i=this.yeaftDebugTurnsById[r.turnId];if(!i)break;let o=[...i.tools||[],{loopNumber:r.loopNumber||0,callId:r.callId||null,name:r.name||"?",durationMs:r.durationMs||0,isError:!!r.isError,toolOutput:r.toolOutput==null?null:String(r.toolOutput)}];this.yeaftDebugTurnsById={...this.yeaftDebugTurnsById,[r.turnId]:{...i,tools:o}};break}case"loop":{if(this.yeaftDebugLoops.push({turnId:r.turnId||null,loopNumber:r.loopNumber||0,model:r.model,systemPrompt:r.systemPrompt,messages:r.messages,response:r.response,toolCalls:r.toolCalls,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,rawRequest:r.rawRequest||null,rawResponse:r.rawResponse||null,sessionId:e.sessionId||null,vpId:e.vpId||r.vpId||null}),this.yeaftDebugLoops.length>au){let i=Ed({loops:this.yeaftDebugLoops,turnsById:this.yeaftDebugTurnsById,turnOrder:this.yeaftDebugTurnOrder,maxLoops:Math.max(au,this.yeaftDebugHistoryLimit||0)});this.yeaftDebugLoops=i.loops,this.yeaftDebugTurnsById=i.turnsById,this.yeaftDebugTurnOrder=i.turnOrder}break}case"llm_retry":{if(!e.turnId)break;let i=Bs(this,e.agentId||null,e.turnId),o=this.activeVpTurns?.[i];if(!o)break;let a=r.reason==="stream_idle_timeout"?"stream_idle_timeout":"transient_error";this.activeVpTurns={...this.activeVpTurns,[i]:{...o,retryAttempt:r.attempt||0,retryMax:r.maxRetries||0,retryDelayMs:r.delayMs||0,retryReason:a,retryRecoveryMode:r.recoveryMode||"restart"}};break}case"recall":case"consolidate":case"fallback":case"thinking_delta":break;case"reflection":{let i=zt(this,e.agentId||null,e.conversationId)||"unknown",o=Array.isArray(r.loopRange)?r.loopRange:[0,0],a=`${i}:${r.trigger}:${o[0]}-${o[1]}`,l=this.yeaftReflectionCards[a],c=this.messagesMap[i]||[],d=l?l.anchorMsgId:c.length>0&&c[c.length-1].id||null,u=l?l.anchorOrder:c.length;this.yeaftReflectionCards={...this.yeaftReflectionCards,[a]:{key:a,conversationId:i,turnId:r.turnId||l&&l.turnId||null,loopNumber:r.loopNumber||l&&l.loopNumber||null,trigger:r.trigger,status:r.status,loopRange:o,toolCount:r.toolCount||0,content:r.content||"",durationMs:r.durationMs||0,error:r.error||null,sessionId:e.sessionId||null,anchorMsgId:d,anchorOrder:u,updatedAt:Date.now()}};break}case"model_switched":this.yeaftModel=r.model,this.yeaftModelEffort=r.modelEffort||null;break;case"yeaft_task_event":{let i=r.task;if(!i?.id||!i.sessionId)break;let o=e.agentId||Ce(this,i.sessionId),a=Pe(o,i.sessionId),l={...i,agentId:o},c={...this.yeaftActiveTasksBySession},d={...c[a]||{}};i.status==="running"||ia.has(i.status)?d[i.id]=l:delete d[i.id];let u=na(d);if(Object.keys(u).length>0?c[a]=u:delete c[a],this.yeaftActiveTasksBySession=c,i.status!=="running"){let{[sa(o,i.sessionId,i.id)]:f,...p}=this.yeaftStoppingTasksById||{};this.yeaftStoppingTasksById=p}break}case"yeaft_task_cancel_result":{let i=r.taskId||r.task?.id||null,o=r.task?.sessionId||r.sessionId||e.sessionId||null,a=e.agentId||Ce(this,o);if(i&&o&&r.success===!1){let{[sa(a,o,i)]:c,...d}=this.yeaftStoppingTasksById||{};this.yeaftStoppingTasksById=d}let l=r.task;if(l?.id&&l.sessionId){let c=Pe(a,l.sessionId),d={...this.yeaftActiveTasksBySession},u={...d[c]||{}};u[l.id]={...l,agentId:a};let f=na(u);Object.keys(f).length>0?d[c]=f:delete d[c],this.yeaftActiveTasksBySession=d}break}case"sub_agent_event":{let i=zt(this,e.agentId||null,e.conversationId)||"unknown",o=r.agentId;if(!o)break;let a=r.payload||{},l=`${i}:${o}`,c=this.yeaftSubAgentCards[l],d=this.messagesMap[i]||[],u=c?c.anchorMsgId:d.length>0&&d[d.length-1].id||null,f=c?c.anchorOrder:d.length,p=c?{...c}:{key:l,conversationId:i,agentId:o,agentName:a.agentName||"sub-agent",status:"running",text:"",toolCallCount:0,turns:0,error:null,expanded:!1,anchorMsgId:u,anchorOrder:f,updatedAt:Date.now(),sessionId:e.sessionId||null};switch(a.agentName&&!p.agentName&&(p.agentName=a.agentName),a.type){case"sub_agent_status":p.status=a.status||p.status,a.error&&(p.error=a.error);break;case"text_delta":break;case"tool_use":case"tool_call":p.toolCallCount=Number(p.toolCallCount||0)+1;break;case"tool_start":break;case"tool_result":case"tool_end":break;case"sub_agent_turn_end":{p.turns+=1;let g=typeof a.content=="string"?a.content.trim():"";g&&(p.text=p.text?`${p.text}
|
|
9
9
|
|
|
10
|
-
${g}`:g),p.status!=="failed"&&p.status!=="closed"&&(p.status=a.status||"idle");break}case"error":a.error&&(p.error=a.error.message||String(a.error));break;default:break}p.updatedAt=Date.now(),this.yeaftSubAgentCards={...this.yeaftSubAgentCards,[l]:p};break}case"history_loaded":{let i={...r,agentId:e.agentId||null,requestId:r.requestId||e.requestId||null};if(i.requestId&&!this.isCurrentYeaftHistoryResponse(i))break;let o=e.agentId||null,a=r.sessionId??null,l=Pe(o,a),c=e.perfTraceId||this.yeaftHistoryPerfTraceBySession?.[l];c&&Ze(this,{traceId:c,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 d=r.mode==="delta"?"delta":"recent",u=this.yeaftSessionHistoryState[l]||{},f=Number.isFinite(r.latestSeq)?r.latestSeq:Number.isFinite(u.latestSeq)?u.latestSeq:null,p=d==="delta"?{...u,loaded:!0,loading:!1,latestSeq:f,syncingAfterSeq:null,count:(u.count||0)+(r.count||0)}:{loaded:!0,loading:!1,hasMore:!!r.hasMore,oldestSeq:typeof r.oldestSeq=="number"?r.oldestSeq:null,count:typeof r.count=="number"?r.count:0,latestSeq:f,syncingAfterSeq:null},g=i.requestId?this.finishYeaftHistoryLoad(i,p,"completion"):null;g||(this.yeaftSessionHistoryState={...this.yeaftSessionHistoryState,[l]:p});let v=Pe(o?this.currentAgent:null,this.yeaftActiveSessionFilter??null);if(l===v)d==="recent"&&(this.yeaftHasMoreHistory=p.hasMore,this.yeaftOldestLoadedSeq=p.oldestSeq),this.yeaftLoadingMoreHistory=!!g?.loading;else if(this.yeaftLoadingMoreHistory){let h=this.yeaftSessionHistoryState[v]||null;this.yeaftLoadingMoreHistory=!!h?.loading}}break;case"vp_snapshot":{let i=window.Pinia?.useVpStore?.()||window.__useVpStore&&window.__useVpStore();i&&i.applySnapshot(r,e.agentId||null,e.requestId||null);break}case"vp_snapshot_error":{let i=window.Pinia?.useVpStore?.()||window.__useVpStore&&window.__useVpStore();i&&i.failSnapshot(e.agentId||null,e.requestId||null,r.error||r.message||"VP library request failed");break}case"vp_updated":{let i=window.Pinia?.useVpStore?.()||window.__useVpStore&&window.__useVpStore();i&&r.vp&&i.upsert(r.vp,r.reason,e.agentId||null);break}case"vp_removed":{let i=window.Pinia?.useVpStore?.()||window.__useVpStore&&window.__useVpStore();i&&r.vpId&&i.remove(r.vpId,r.reason,e.agentId||null);break}case"vp_crud_result":{let i=this._vpCrudPending&&this._vpCrudPending.get(r.requestId);i&&(this._vpCrudPending.delete(r.requestId),i.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 i=window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore(),o=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 u=Array.isArray(this.yeaftSessionHydrateSlices)?this.yeaftSessionHydrateSlices.filter(f=>f.agentId!==(e.agentId||null)):[];this.yeaftSessionHydrateSlices=[...u,{agentId:e.agentId||null,sessions:o}];break}let a=i&&i.activeSessionId||null,l=i?.activeSessionKey&&i.sessions?.[i.activeSessionKey]?.agentId||null;i&&(i.applySnapshot(o,e.agentId||null),this._hasHandledYeaftSessionHydrate=!0,this.yeaftSessionHydrateError=null);let c=i&&i.activeSessionId||null,d=i?.activeSessionKey&&i.sessions?.[i.activeSessionKey]?.agentId||null;if(this.currentView==="yeaft"&&c){let u=d||Ce(this,c,e.agentId||null),f=Pe(u,c),p=this.yeaftSessionHistoryState[f]||null;this.setActiveSessionFilter(c,{agentId:u,force:l!==u||cc(c,a,p)})}break}case"group_roster_changed":case"session_roster_changed":{let i=window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore();i&&i.applyRosterChange(r,e.agentId||null);break}case"group_crud_result":case"session_crud_result":{let i=window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore();i&&i.applyCrudResult(r,e.agentId||null);let o=this._sessionCrudPending&&this._sessionCrudPending.get(r.requestId);if(o){this._sessionCrudPending.delete(r.requestId);let a=r.session||r.group||null,l=a&&e.agentId&&!a.agentId?{...a,agentId:e.agentId}:a,c=r.sessionId||null,d=r.sessions||null;o.resolve({ok:!!r.ok,op:r.op,session:l,sessionId:c,sessions:d,config:r.config||null,error:r.error||null})}break}case"vp_turn_start":{if(!r.turnId||!r.vpId)break;let i=qo(e.agentId||null,r.turnId)||r.turnId;if(this.activeVpTurns={...this.activeVpTurns,[i]:{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 o=dt(e.agentId||null,r.sessionId);this.yeaftProcessingSessions={...this.yeaftProcessingSessions,...o?{[o]:!0}:{[r.sessionId]:!0}}}break}case"vp_turn_end":{if(!r.turnId)break;let i=Bs(this,e.agentId||null,r.turnId),o=r.sessionId||this.activeVpTurns?.[i]?.sessionId||null;r.reason==="end_turn"&&o&&this.markYeaftSessionUnread(o,e.agentId||null);let{[i]:a,...l}=this.activeVpTurns;this.activeVpTurns=l;let{[i]:c,...d}=this.stoppingVpTurnIds;this.stoppingVpTurnIds=d,this.clearYeaftSessionProcessingIfIdle(r.sessionId||a?.sessionId||null,{agentId:e.agentId||a?.agentId||null});let f={end_turn:"completed",route_forward:"completed",aborted:"aborted",errored:"errored",error:"errored",cancelled:"cancelled",canceled:"cancelled"}[r.reason]||"completed",p=Date.now(),g=zt(this,e.agentId||null,e.conversationId);if(g&&Array.isArray(this.messagesMap[g])){let v=this.messagesMap[g],h=zd(v,r);for(let A=0;A<v.length;A++){let w=v[A];if(!w||w.type!=="assistant")continue;let k=w.sessionId??w.groupId;r.sessionId&&k&&k!==r.sessionId||r.vpId&&w.speakerVpId&&w.speakerVpId!==r.vpId||r.turnId&&w.turnId&&w.turnId!==r.turnId||w.status&&w.status!=="pending"||(w.status=f,w.turnEndAt=p,w.turnEndReason=r.reason||null,r.detail&&(w.turnEndDetail=r.detail),Number.isFinite(r.durationMs)&&(w.turnDurationMs=r.durationMs),h=!0)}h&&(this.messagesMap={...this.messagesMap,[g]:v.slice()})}break}case"yeaft_turn_aborted":{let i=Array.isArray(r.turnIds)?r.turnIds.filter(Boolean):[];r.turnId&&i.push(r.turnId);let o=r.sessionId||null,a=r.vpId||null,l=new Set;for(let f of i){let p=Bs(this,e.agentId||null,f),g=this.activeVpTurns?.[p]||null;(!g||pt(g,g.sessionId,e.agentId||null))&&l.add(p)}if(a)for(let[f,p]of Object.entries(this.activeVpTurns||{}))!p||p.vpId!==a||pt(p,o,e.agentId||null)&&l.add(f);if(l.size===0)break;let c=o,d={...this.activeVpTurns||{}},u={...this.stoppingVpTurnIds||{}};for(let f of l){let p=d[f];!c&&p?.sessionId&&(c=p.sessionId),delete d[f],delete u[f]}this.activeVpTurns=d,this.stoppingVpTurnIds=u,this.clearYeaftSessionProcessingIfIdle(c||null,{agentId:e.agentId||null});break}case"yeaft_aborted":{let i=r.sessionId||e.sessionId||null;i?(this.activeVpTurns=Object.fromEntries(Object.entries(this.activeVpTurns||{}).filter(([,o])=>!pt(o,i,e.agentId||null))),this.stoppingVpTurnIds=Object.fromEntries(Object.entries(this.stoppingVpTurnIds||{}).filter(([o])=>this.activeVpTurns?.[o])),this.vpStatuses=Object.fromEntries(Object.entries(this.vpStatuses||{}).filter(([,o])=>!pt(o,i,e.agentId||null))),this.clearYeaftSessionProcessingIfIdle(i,{agentId:e.agentId||null,ignoreStatuses:!0})):r.all&&Zd(this,e.agentId||null);break}case"vp_typing_start":{if(!r.vpId)break;let i=zt(this,e.agentId||null,e.conversationId);if(!i)break;this.yeaftVpTyping=Md(this.yeaftVpTyping,i,r.vpId);break}case"vp_typing_end":{if(!r.vpId)break;let i=zt(this,e.agentId||null,e.conversationId);if(!i)break;this.yeaftVpTyping=Pd(this.yeaftVpTyping,i,r.vpId);break}case"vp_status_changed":{if(!r.vpId||!r.state)break;let i=r.sessionId||null,o=e.agentId||null,a=Or(o,i,r.vpId),l={agentId:o,state:r.state,since:r.since||Date.now(),turnId:r.turnId||null,title:r.title||"",sessionId:i,vpId:r.vpId};if(this.vpStatuses={...this.vpStatuses,[a]:l},i&&Br.has(r.state)){let c=dt(o,i);this.yeaftProcessingSessions={...this.yeaftProcessingSessions,...c?{[c]:!0}:{[i]:!0}}}else i&&this.clearYeaftSessionProcessingIfIdle(i,{agentId:o});this.restoreActiveYeaftSessionFromStatuses([l],o);break}case"vp_status_snapshot":{let i=Array.isArray(r.statuses)?r.statuses:[],o=r.sessionId;if(o==null){let a={...this.vpStatuses||{}};if(e.agentId)for(let[l,c]of Object.entries(a))(!c?.agentId||c.agentId===e.agentId)&&delete a[l];else for(let l of Object.keys(a))delete a[l];for(let l of i){if(!l||!l.vpId)continue;let c=l.sessionId||l.groupId||null,d=Or(e.agentId||null,c,l.vpId);a[d]={agentId:e.agentId||null,state:l.state,since:l.since||Date.now(),turnId:l.turnId||null,title:l.title||"",sessionId:c,vpId:l.vpId}}this.vpStatuses=a}else{let a={...this.vpStatuses};for(let[l,c]of Object.entries(a))c&&c.sessionId===o&&(!e.agentId||!c.agentId||c.agentId===e.agentId)&&delete a[l];for(let l of i){if(!l||!l.vpId)continue;let c=l.sessionId||l.groupId||null,d=Or(e.agentId||null,c,l.vpId);a[d]={agentId:e.agentId||null,state:l.state,since:l.since||Date.now(),turnId:l.turnId||null,title:l.title||"",sessionId:c,vpId:l.vpId}}this.vpStatuses=a}this.yeaftProcessingSessions=Eh(this,e.agentId||null,i,o??null),this.restoreActiveYeaftSessionFromStatuses(i,e.agentId||null);break}case"yeaft_dream_snapshot":{let i=r&&r.snapshot,o=i&&typeof i.scope=="string"?i.scope:null;o&&(this.yeaftDreamSnapshots={...this.yeaftDreamSnapshots,[o]:{...i,receivedAt:Date.now()}});break}case"yeaft_dream_status":{let i=window.Pinia?.useVpStore?.()||window.__useVpStore&&window.__useVpStore();i&&i.applyDreamStatus(r);break}case"yeaft_dream_result":{let i=window.Pinia?.useVpStore?.()||window.__useVpStore&&window.__useVpStore();i&&i.applyDreamResult(r),r?.snapshot?.scope&&(this.yeaftDreamSnapshots={...this.yeaftDreamSnapshots,[r.snapshot.scope]:{...r.snapshot,receivedAt:Date.now()}});{let o=typeof r?.snapshot?.scope=="string"&&r.snapshot.scope?r.snapshot.scope:typeof r?.sessionId=="string"&&r.sessionId?`sessions/${r.sessionId}`:null;if(!o)break;let a=this.yeaftDreamLatest[o]||null;this.yeaftDreamLatest={...this.yeaftDreamLatest,[o]:{scope:o,phase:"result",status:r.skipped?"skipped":r.success?"success":"error",startedAt:a?.startedAt??null,finishedAt:Date.now(),mergedCount:typeof r.entriesCreated=="number"?r.entriesCreated:a?.mergedCount??null,error:r.skipped||r.success?null:r.error||"unknown",manual:typeof r?.manual=="boolean"?r.manual:a?.manual??null,durationMs:typeof r.durationMs=="number"?r.durationMs:a?.durationMs??null,llmCallCount:typeof r.llmCallCount=="number"?r.llmCallCount:a?.llmCallCount??0,inputTokens:typeof r.inputTokens=="number"?r.inputTokens:a?.inputTokens??0,outputTokens:typeof r.outputTokens=="number"?r.outputTokens:a?.outputTokens??0,totalTokens:typeof r.totalTokens=="number"?r.totalTokens:a?.totalTokens??0,metrics:r.metrics||a?.metrics||null,passBreakdown:r.passBreakdown||r.metrics?.passBreakdown||a?.passBreakdown||null,isRunning:!1}},this._appendDreamEvent(o,{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 i=r?.phase||"unknown",o=null;typeof r?.target=="string"&&r.target.includes("/")?o=r.target:typeof r?.sessionId=="string"&&r.sessionId?o=`sessions/${r.sessionId}`:o="*";let a=i==="done",l=i==="error"||r?.status==="error",c=!a&&!l,d=u=>{let f=this.yeaftDreamLatest[u]||null;return{scope:u,phase:i,status:l?"error":a?"success":"running",startedAt:f?.startedAt&&c?f.startedAt:r?.ts||f?.startedAt||Date.now(),finishedAt:a||l?r?.ts||Date.now():null,mergedCount:typeof r?.mergedCount=="number"?r.mergedCount:typeof r?.targets=="number"?r.targets:f?.mergedCount??null,error:l?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:c}};if(o==="*"){let u={...this.yeaftDreamLatest,"*":d("*")};for(let f of Object.keys(this.yeaftDreamLatest))f!=="*"&&(u[f]=d(f));this.yeaftDreamLatest=u}else this.yeaftDreamLatest={...this.yeaftDreamLatest,[o]:d(o)};this._appendDreamEvent(o,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>cu&&a.splice(0,a.length-cu),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",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=setTimeout(()=>{this._sessionCrudPending&&this._sessionCrudPending.has(n)&&(this._sessionCrudPending.delete(n),c({ok:!1,op:e,error:{code:"timeout",message:"group_crud timeout"}}))},1e4);this._sessionCrudPending.set(n,{resolve:u=>{clearTimeout(d),c(u)}}),this.sendWsMessage(o)})},markYeaftSessionUnread(e,t=null){if(!e)return!1;let s=Ce(this,e,t);if(!s)return!1;let n=br(s,e);return this.currentView==="yeaft"&&this.yeaftActiveSessionFilter===e&&Ce(this,e)===s||this.yeaftUnreadSessionKeys?.[n]?!1:(this.yeaftUnreadSessionKeys={...this.yeaftUnreadSessionKeys,[n]:!0},!0)},markYeaftSessionRead(e,t=null){if(!e)return!1;let s=Ce(this,e,t);if(!s)return!1;let n=br(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||du(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?Ce(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 c=this.agents.find(d=>d.id===r);this.activateYeaftAgent(r,c||null)}else r&&n&&this.activateYeaftAgent(r);if(r&&n&&this.markYeaftSessionRead(n,r),!o&&n===s)return;let a=Pe(r,n),l=this.yeaftSessionHistoryState[a]||null;if(this.pruneYeaftMessageWindow(n),r&&n){this.yeaftSessionAgentById={...this.yeaftSessionAgentById||{},[n]:r};let c=this.yeaftConversationIdsByAgent?.[r]||null;c||(c=`yeaft-local-${r}-${Date.now()}`,this.yeaftConversationIdsByAgent={...this.yeaftConversationIdsByAgent||{},[r]:c}),this.yeaftConversationId=c,this.messagesMap[c]||(this.messagesMap[c]=[]),this.currentView==="yeaft"&&(this.activeConversations=[c])}try{let c=window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore();c&&typeof c.setActive=="function"&&c.setActive(n,r||null);let d=c?.activeSessionKey||null;d?localStorage.setItem("lastViewedYeaftSession",d):localStorage.removeItem("lastViewedYeaftSession")}catch{}if(this.syncActiveYeaftHistoryLoad(),!l?.loading&&r&&n){let c=Number.isFinite(l?.latestSeq)?l.latestSeq:null,d={type:"yeaft_load_history",agentId:r,sessionId:n},u=!!l?.loaded,f=ko({sessionState:l,hasCachedSessionRows:!1,force:o});if(!f&&c!==null?d.afterSeq=c:d.limit=Hr,!f&&u&&c===null){this.yeaftSessionHistoryState={...this.yeaftSessionHistoryState,[a]:{...l||{hasMore:!1,oldestSeq:null,count:0},loaded:!0,loading:!1,syncingAfterSeq:null}},this.syncActiveYeaftHistoryLoad();return}let p=null;if(!f&&u){if(l?.syncingAfterSeq===c)return;p=this.beginYeaftHistoryLoad({agentId:r,sessionId:n,mode:"delta",preserveLoaded:!0,latestSeq:c}),this.yeaftSessionHistoryState={...this.yeaftSessionHistoryState,[a]:{...this.yeaftSessionHistoryState[a],syncingAfterSeq:c}}}else p=this.beginYeaftHistoryLoad({agentId:r,sessionId:n,mode:"recent",preserveLoaded:!1,latestSeq:f?null:c});p&&(d.requestId=p.requestId),this.sendWsMessage(d)}},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:Ce(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()?lu:ra,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}})},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&&(Ae(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.yeaftDebugSearch="",this.yeaftDebugSessionFilter=null,this._yeaftDebugSearchTimer&&(clearTimeout(this._yeaftDebugSearchTimer),this._yeaftDebugSearchTimer=null),this._fetchYeaftDebugHistoryTimer&&(clearTimeout(this._fetchYeaftDebugHistoryTimer),this._fetchYeaftDebugHistoryTimer=null),this._yeaftDebugHistoryInFlightKey=null,this._yeaftDebugHistoryLatestListRequestId=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},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){let s=new Set;if(this.sessionCatalog=(Array.isArray(e)?e:[]).filter(n=>!n?.catalogKey||s.has(n.catalogKey)?!1:(s.add(n.catalogKey),!0)).map(n=>({...n})),Array.isArray(t)){this.sessionProjects=t.filter(r=>r?.id).map(r=>({...r,members:Array.isArray(r.members)?r.members.filter(i=>i?.agentId&&i?.sessionId):r.agentId?(r.sessionIds||[]).map(i=>({agentId:r.agentId,sessionId:i})):[]}));let n=new Map;for(let r of this.sessionProjects)for(let i of r.members)n.set(`${i.agentId}${i.sessionId}`,r.id);this.sessionCatalog=this.sessionCatalog.map(r=>r.runtimeProvider==="yeaft"?{...r,projectId:n.get(`${r.routeRef?.agentId}${r.routeRef?.sessionId}`)||null}:r)}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),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;return!t||t.connectionGeneration!==Number(this.chatHistoryConnectionGeneration||0)?!1:(delete this.projectMutationRequests[e.requestId],e.ok&&Array.isArray(e.projects)&&this.applySessionCatalogSnapshot(this.sessionCatalog,e.projects),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=uo(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)},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},reorderCatalogSessions(e){if(!Array.isArray(e)||e.length===0||Object.keys(this.sessionCatalogMutationRequests).length>0)return!1;let t=`session_order_${crypto.randomUUID()}`,s=uo(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){return Rl(this,e)},openCatalogSession(e){if(!e?.catalogKey||!e.routeRef)return!1;let{runtimeProvider:t,agentId:s,sessionId:n}=e.routeRef;return this.activeCatalogKey=e.catalogKey,t==="yeaft"?(this.enterYeaft(s,{deferBootstrap:!0}),this.setActiveSessionFilter(n,{agentId:s,force:!0}),!0):t!=="claude-code"&&t!=="copilot"?!1:(this.currentView==="yeaft"&&this.leaveYeaft(),this.selectConversation(n,s),!0)},requestChatHistory(e,{mode:t="recent",turns:s=null,beforeId:n=null,afterMessageId:r=null}={}){if(!e)return null;let i=Rs(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})?a:(El(this,i,a,"send_failed"),null)},beginChatHistoryRequest(e,t="recent",s=null){return _l(this,e,t,s)},isCurrentChatHistoryResponse(e){if(!e?.conversationId||!e?.requestId||!e?.catalogKey)return!1;let t=Rs(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 Ql(this,e)},parseWsMessage(e){return Xl(this,e)},connect(){Zl(this)},ensureConnected(){return yn(this)},scheduleReconnect(){Jl(this)},manualReconnect(){ec(this)},startHeartbeat(){tc(this)},stopHeartbeat(){sc(this)},setupVisibilityHandler(){nc(this)},handleMessage(e){Gc(this,e)},getOrCreateExecutionStatus(e){return Vo(this,e)},handleAssistantOutputFrame(e,t){Oc(this,e,t)},handleClaudeOutput(e,t){this.handleAssistantOutputFrame(e,t)},addMessageToConversation(e,t){kr(this,e,t)},appendToAssistantMessageForConversation(e,t,s){uc(this,e,t,s)},finishStreamingForConversation(e,t){pc(this,e,t)},sweepStaleStreamingForConversation(e){fc(this,e)},appendToAssistantMessage(e){this.appendToAssistantMessageForConversation(this.currentConversation,e)},finishStreaming(){this.finishStreamingForConversation(this.currentConversation)},addMessage(e){this.addMessageToConversation(this.currentConversation,e)},loadHistoryMessages(e){gc(this,e)},formatDbMessage(e){return So(e)},formatDbMessageForHistoryHydration(e){return hc(e)},selectAgent(e){return nd(this,e)},createConversation(e,t=null,s=null,n=void 0){rd(this,e,t,s,n)},resumeConversation(e,t,s=null,n=null,r=null){id(this,e,t,s,n,r)},selectConversation(e,t){od(this,e,t)},updateConversationSettings(e,t){Bo(this,e,t)},toggleConversationMcp(e,t){ad(this,e,t)},deleteConversation(e,t){cd(this,e,t)},closeSession(e,t){ld(this,e,t)},appendColumn(e){fd(this,e)},removeColumn(e){gd(this,e)},sendMessageToConversation(e,t,s=[],n={}){md(this,e,t,s,n)},cancelExecutionForConversation(e){hd(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){let s=this.panels.find(n=>n.id===e);s&&(s.conversationId=t,t&&!this.activeConversations.includes(t)&&this.activeConversations.push(t),t&&!this.messagesMap[t]&&(this.messagesMap[t]=[],this.requestChatHistory(t,{mode:"recent",turns:5})),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?!!fs()?.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=Ce(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?fs()?.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||Ce(this,e);if(Object.values(this.activeVpTurns||{}).some(a=>pt(a,e,n))||!s&&Object.values(this.vpStatuses||{}).some(l=>pt(l,e,n)&&Br.has(l?.state)))return;let i=dt(n,e),o={...this.yeaftProcessingSessions||{}};i&&delete o[i],Nr(this,e,n)&&delete o[e],this.yeaftProcessingSessions=o},sendMessage(e,t=[],s={}){dd(this,e,t,s)},cancelExecution(){ud(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],Zd(this,this.currentAgent)},cancelYeaftSession(e){let t=Ce(this,e);!t||!e||(this.sendWsMessage({type:"yeaft_abort_all",agentId:t,sessionId:e}),this.activeVpTurns=Object.fromEntries(Object.entries(this.activeVpTurns||{}).filter(([,s])=>!pt(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])=>!pt(s,e,t))),this.clearYeaftSessionProcessingIfIdle(e,{agentId:t,ignoreStatuses:!0}))},cancelVpTurn(e,{sessionId:t=null,vpId:s=null}={}){let n=Ce(this,t);if(!n||!e)return;let r=Bs(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=Ce(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||!pt(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?.[Or(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){pd(this,e,t,s)},refreshAgents(){vd(this)},refreshConversation(){yd(this)},restartAgent(e){bd(this,e)},upgradeAgent(e){wd(this,e)},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=ps(this),t=Ce(this,e);if(!t)return!1;let s=Pe(t,e),n=this.yeaftConversationId,r=this.beginYeaftHistoryLoad({agentId:t,sessionId:e,mode:"recent",preserveLoaded:!1});if(!r)return!1;let i=Cn();this.yeaftHistoryPerfTraceBySession={...this.yeaftHistoryPerfTraceBySession||{},[s]:i};let o={type:"yeaft_load_history",agentId:t,limit:Hr,sessionId:e,requestId:r.requestId,perfTraceId:i};return Ze(this,{traceId:i,phase:"history.request_send",agentId:t,sessionId:e,messageType:o.type,bytes:JSON.stringify(o).length,detail:{mode:"manual-reload",limit:Hr}}),this.sendWsMessage(o),!0},loadMoreYeaftHistory(e=Dn()){if(this.currentView!=="yeaft"||this.yeaftLoadingMoreHistory||!this.yeaftHasMoreHistory||this.yeaftOldestLoadedSeq==null)return;let t=ps(this),s=Ce(this,t);if(!s)return;let n=Math.min(50,Math.max(1,Number.isFinite(e)?Math.floor(e):Dn())),r=Pe(s,t),i=this.beginYeaftHistoryLoad({agentId:s,sessionId:t,mode:"older",preserveLoaded:!0,latestSeq:this.yeaftSessionHistoryState[r]?.latestSeq??null});if(!i)return;let o=Cn();this.yeaftHistoryPerfTraceBySession={...this.yeaftHistoryPerfTraceBySession||{},[r]:o};let a={type:"yeaft_load_more_history",agentId:s,sessionId:t,requestId:i.requestId,beforeSeq:this.yeaftOldestLoadedSeq,turns:n,perfTraceId:o};Ze(this,{traceId:o,phase:"history_more.request_send",agentId:s,sessionId:t,messageType:a.type,bytes:JSON.stringify(a).length,detail:{beforeSeq:a.beforeSeq,turns:a.turns}}),this.sendWsMessage(a)},checkPendingRecovery(){Dl(this)},performRecovery(){Ll(this)},dismissRecovery(){$l(this)},autoRestoreConversation(e){Vl(this,e)},saveOpenSessions(){Es(this)},getLastSession(){return Ol(this)},clearLastSession(){Hl(this)},listHistorySessions(e){ql(this,e)},listFolders(){return Nl(this)},listFoldersForAgent(e,t){return Bl(this,e,t)},listModelsForAgent(e,t){return Wl(this,e,t)},listHistorySessionsForAgent(e,t,s){jl(this,e,t,s)},async loadGlobalSessions(e=20){return Ul(this,e)},async deleteGlobalSession(e){return zl(this,e)},findAgentForSession(e){return fo(this,e)},isSessionResumable(e){return Kl(this,e)},_isRecentlyClosed(e){return is(this,e)},_startProcessingWatchdog(e){Ls(this,e)},_resetProcessingWatchdog(e){Sr(this,e)},_stopProcessingWatchdog(e){Ae(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,mn(e),this.currentAgent)try{this.sendWsMessage({type:"update_llm_config",agentId:this.currentAgent,config:{language:e}})}catch{}},async fetchCustomExpertRoles(){let e=_e();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=_e();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=_e();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=_e();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}},toggleWorkbench(){this.workbenchExpanded=!this.workbenchExpanded,this.workbenchExpanded||(this.workbenchMaximized=!1)},toggleSidebar(){this.sidebarCollapsed=!this.sidebarCollapsed},toggleSessionSidebar(){this.sessionSidebarOpen=!this.sessionSidebarOpen},closeSessionSidebar(){this.sessionSidebarOpen=!1},toggleWorkbenchMaximized(){this.workbenchMaximized=!this.workbenchMaximized},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})},openFileInExplorer(e){this.currentConversation&&(this.workbenchExpanded=!0,window.dispatchEvent(new CustomEvent("open-file-in-explorer",{detail:{filePath:e,conversationId:this.currentConversation}})))},logout(){_e().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.subagents={},this.activeSubagentId=null,this.activeRightPanel=null,this.pinnedSessions=[],this.clearWorkCenterBrowserState(),this.ws&&this.ws.close()}}})});function aa(e,t){!e||typeof e.handleYeaftOutput!="function"||!t||e.handleYeaftOutput({event:t})}function Yh(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 ca(e){if(!e)return Kt[0];let t=String(e).toLowerCase();return Kh[t]||Kt[Yh(t)%Kt.length]}function Gh(e){return ca(e).background}function Qh(e){return ca(e).foreground}function la(){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 Xh(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 zh,Kt,Kh,Lw,yt,Ws=F(()=>{({defineStore:zh}=Pinia);Kt=[{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)"}],Kh=Object.freeze({steve:Kt[8],ada:Kt[3],linus:Kt[0],martin:Kt[4]}),Lw=Kt.map(e=>e.background);yt=zh("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?la().startsWith("zh")&&s.displayNameZh?s.displayNameZh:s.displayName||s.vpId||t:t},vpDescription:e=>t=>Xh(e.vps[t],la()),vpInitial:e=>t=>{let s=e.vps[t],n=la().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:Gh(t)},vpTextColor:()=>e=>Qh(e),vpAvatarMotif:()=>e=>ca(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(aa(s,{type:"dream_progress",phase:"start",groupId:e,manual:!0,trigger:"manual",source:"header-button",ts:n}),!s||typeof s.sendWsMessage!="function"){aa(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&&aa(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 da(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 jr(e){return!e||typeof e!="object"?0:da(e.lastMessageAt)||da(e.updatedAt)||da(e.createdAt)||0}function ua(e,t){let s=jr(t)-jr(e);return s!==0?s:String(e?.id||"").localeCompare(String(t?.id||""))}function fu(e){return[...Array.isArray(e)?e:[]].sort(ua)}var Ur=F(()=>{});function gu(){try{if(typeof localStorage>"u")return{};let e=JSON.parse(localStorage.getItem(yu)||"{}");return e&&typeof e=="object"?e:{}}catch{return{}}}function Zh(e){try{typeof localStorage<"u"&&localStorage.setItem(yu,JSON.stringify(e&&typeof e=="object"?e:{}))}catch{}}function mu(){try{return typeof localStorage>"u"?[]:$n(JSON.parse(localStorage.getItem(bu)||"[]"))}catch{return[]}}function Jh(e){try{typeof localStorage<"u"&&localStorage.setItem(bu,JSON.stringify($n(e)))}catch{}}function wu(e,t){return`${e||""}${t||""}`}function Rt(e){return e&&e.agentId&&e.id?wu(e.agentId,e.id):""}function bt(e,t){return t?e?wu(e,t):String(t):""}function ev(e){return typeof e=="string"?e:String(e||"")}function nt(e,t,s=null){let n=ev(t);if(!n)return"";let r=bt(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=Vn();if(l?.currentAgent){let c=a.find(d=>e.sessions[d]?.agentId===l.currentAgent);if(c)return c}return a[0]||""}function pa(e,t,s=null){return nt(e,t,s)||""}function fa(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 tv(e){let t=e._preferredExactSessionIdentity||null;if(!t)return!1;e._preferredExactSessionIdentity=null;let s=e.sessions[t.key]||null,n=Vn(),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=Mn(localStorage.getItem("lastViewedYeaftSession")||"");o.agentId===t.agentId&&o.sessionId===t.sessionId&&localStorage.removeItem("lastViewedYeaftSession")}catch{}return!0}function zr(e){let t=e._retiredBareActiveSessionId||null;if(!t)return!1;let s=Vn();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")||"";Mn(r).sessionId===t&&localStorage.removeItem("lastViewedYeaftSession")}catch{}return!0}function $n(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 ga(e,t){let s=$n(e),n=new Set(s),r=$n(t).filter(o=>n.has(o)),i=new Set(r);return[...r,...s.filter(o=>!i.has(o))]}function Kr(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 hu(e){return!e||typeof e!="object"?!1:e.running===!0||e.active===!0||e.isActive===!0||e.isRunning===!0}function vu(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 Vn(){try{if(typeof window<"u"&&window.Pinia&&typeof window.Pinia.useChatStore=="function")return window.Pinia.useChatStore()}catch{}return null}var yu,bu,sv,ku,Su=F(()=>{Ur();Pn();yu="yeaft-session-order-by-agent",bu="yeaft-session-order-global";({defineStore:sv}=Pinia);ku=sv("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=Vn(),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,f)=>{let p=Number.isFinite(u?.sortOrder)?u.sortOrder:Number.MAX_SAFE_INTEGER,g=Number.isFinite(f?.sortOrder)?f.sortOrder:Number.MAX_SAFE_INTEGER;return p!==g?p-g:ua(u,f)}),a=[...o(r),...o(i)],l=mu();if(l.length===0)return a;let c=new Map(l.map((d,u)=>[d,u]));return a.sort((d,u)=>{let f=c.has(Rt(d))?c.get(Rt(d)):Number.MAX_SAFE_INTEGER,p=c.has(Rt(u))?c.get(Rt(u)):Number.MAX_SAFE_INTEGER;return f!==p?f-p:0})},sessionCount(e){return e.sessionOrder.length},sessionById:e=>(t,s=null)=>{let n=nt(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){fa(this);let o={...this.sessions},a=new Set;for(let p of n){if(!p||!p.id)continue;let g=bt(t,p.id);a.add(g),o[g]=this._normalize(p,t,Kr(this.sessions[g]))}for(let p of this.sessionOrder){let g=this.sessions[p];g&&g.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 g=bt(t,p.id);o[g]&&!c.has(g)&&d.push(g)}this.sessions=o;let u=[...l,...d],f=mu();if(f.length>0){let p=new Map(u.map(A=>[Rt(o[A]),A]).filter(([A])=>A)),g=f.map(A=>p.get(A)).filter(Boolean),v=new Set(g);u=[...g,...u.filter(A=>!v.has(A))];let h=new Map(f.map((A,w)=>[A,w]));for(let A of u){let w=Rt(o[A]);w&&h.has(w)&&(o[A]={...o[A],sortOrder:h.get(w)})}}if(t&&f.length===0){let p=gu(),g=$n(p[t]);if(g.length>0){let v=g.map(m=>bt(t,m)),h=new Set(v),A=ga(u.filter(m=>o[m]?.agentId===t),v),w=this.sessionOrder.some(m=>o[m]?.agentId===t),k=0;w?u=this.sessionOrder.filter(m=>o[m]).map(m=>o[m]?.agentId===t?A[k++]:m).concat(A.slice(k)):u=u.map(m=>o[m]?.agentId===t?A[k++]:m);let y=new Map(v.map((m,b)=>[m,b]));for(let m of A)o[m]&&h.has(m)&&(o[m]={...o[m],sortOrder:y.get(m)})}}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=bt(null,c.id);a[d]=this._normalize(c,null,Kr(this.sessions[d])),l.push(d)}this.sessions=a,this.sessionOrder=l,this.inventoryIdentityMode="legacy-bare"}s||(r=tv(this)||zr(this)),this.lastSnapshotAt=Date.now();let i=Vn();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?nt(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,y)=>vu(this.sessions[y])-vu(this.sessions[k]))[0]||null,f=u?this.sessions[u]?.id:null,p=this.sessionList[0]||null,g=p?.id||null,v=g?nt(this,g,p?.raw?.agentId||null):"",h=f||(d?c.id:null)||g,A=u||(d?l:"")||v||pa(this,h,t),w=this.activeSessionKey?this.sessions[this.activeSessionKey]?.agentId:null;if(this.activeSessionId&&!nt(this,this.activeSessionId,w)?(this.activeSessionId=h,this.activeSessionKey=A||null):!this.activeSessionId&&this.sessionOrder.length>0&&!this._retiredBareActiveSessionId?(this.activeSessionId=h,this.activeSessionKey=A||null):this.activeSessionId&&(this.activeSessionKey=pa(this,this.activeSessionId,w)||this.activeSessionKey),i&&!this._retiredBareActiveSessionId){let k=this.activeSessionId||h,y=null;if((i.yeaftActiveSessionFilter&&!nt(this,i.yeaftActiveSessionFilter)||!i.yeaftActiveSessionFilter&&k)&&(y=k),y){let m=pa(this,y),b=m&&this.sessions[m]?.agentId||null;i.currentView==="yeaft"&&typeof i.setActiveSessionFilter=="function"?i.setActiveSessionFilter(y,{agentId:b,force:!0}):i.yeaftActiveSessionFilter=y,this.activeSessionKey=m||this.activeSessionKey}}}if(i&&typeof i.applyServerPinSnapshot=="function"){let o=new Set;for(let l of n){if(!l||!l.id)continue;let c=bt(t,l.id),d=this.sessions[c];d&&d.pinned&&o.add(l.id)}let a=l=>{let c=nt(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)fa(this);else if(this.inventoryIdentityMode!=="legacy-bare")return;let r=nt(this,s,n)||bt(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),zr(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},zr(this)},applyCrudResult(e,t=null){if(!e)return;this.lastCrudResult={...e,at:Date.now()},e.requestId&&this.pending[e.requestId]&&delete this.pending[e.requestId];let s=e.session||e.group||null,n=t||e.agentId||s?.agentId||null;e.ok&&e.op==="list"&&Array.isArray(e.sessions)&&this.applySnapshot(e.sessions,n),e.ok&&(e.op==="create"||e.op==="restore")&&s&&s.id&&this.applySnapshotUpsert(s,n)&&this.setActive(s.id,n);let r=e.sessionId||e.groupId,i=this.inventoryIdentityMode==="legacy-bare",o=r&&(n||i)?nt(this,r,n):"";if(e.ok&&(e.op==="archive"||e.op==="delete")&&r&&o&&(delete this.sessions[o],this.sessionOrder=this.sessionOrder.filter(a=>a!==o),(this.activeSessionKey===o||i&&this.activeSessionId===r)&&(this.activeSessionKey=this.sessionOrder[0]||null,this.activeSessionId=this.activeSessionKey&&this.sessions[this.activeSessionKey]?.id||null)),e.ok&&e.op==="update_config"&&r){let a=o?this.sessions[o]:null;a&&(this.sessions[o]={...a,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)fa(this);else if(this.inventoryIdentityMode!=="legacy-bare")return"";let n=nt(this,e.id,s)||bt(s,e.id),r=!!this.sessions[n],i=this.sessions[n]||{};return this.sessions[n]={...i,...this._normalize(e,s,Kr(i))},r||this.sessionOrder.push(n),zr(this),n},setActive(e,t=null){let s=nt(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=ga(s,t.map(l=>bt(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=gu(),a=n.map(l=>this.sessions[l]?.id).filter(Boolean);return o[e]=a,Zh(o),a},reorderSessionsGlobally(e){let t=this.sessionOrder.map(a=>Rt(this.sessions[a])).filter(Boolean),s=ga(t,e);if(s.length===0)return[];let n=new Map(this.sessionOrder.map(a=>[Rt(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=Rt(this.sessions[a]);l&&o.has(l)&&(this.sessions[a]={...this.sessions[a],sortOrder:o.get(l)})}return Jh(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=nt(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=bt(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:hu(e),active:hu(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:Kr(e,s),sortOrder:Number.isFinite(e.sortOrder)?e.sortOrder:null}}}})});function Yr(){try{if(window.Pinia&&typeof window.Pinia.useAuthStore=="function")return window.Pinia.useAuthStore()}catch{}return null}function ma(){try{return localStorage.getItem("authToken")||null}catch{return null}}function Au(){let e=Yr();if(e)try{return e.getActiveToken?.()||e.token||ma()}catch{return e.token||ma()}return ma()}function rv(e,t){if(!e)return!1;let s=Au();if(s&&s!==t)return!1;try{localStorage.setItem("authToken",e)}catch{}let n=Yr();return n&&(n.token=e),!0}function iv(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 Cu(e){return!e||typeof window>"u"||!window.location?!1:e.origin===window.location.origin&&e.pathname.startsWith("/api/")}function ov(e){if(!e)return!1;let t=e.pathname;return!!(nv.has(t)||t.startsWith("/api/auth/sso/poll/")||/^\/api\/auth\/sso\/[^/]+\/start(?:-qr)?$/.test(t))}function av(e,t){return t?.headers?new Headers(t.headers):e&&typeof e=="object"&&e.headers?new Headers(e.headers):new Headers}function lv(e){let t=e.get("Authorization");return!t||!t.startsWith("Bearer ")?null:t.slice(7)}function cv(e,t){return{...e||{},headers:t}}function dv(e,t,s,n){let r=Yr();r&&typeof r.handleAuthResponse=="function"?r.handleAuthResponse(e,t,s,n):r&&typeof r.handleAuthFailure=="function"&&n&&r.handleAuthFailure(void 0,t,s)}function xu(){if(Iu||typeof window>"u"||!window.fetch)return;Iu=!0;let e=window.fetch.bind(window);window.fetch=async function(s,n){let r=iv(s),i=Cu(r)&&!ov(r),o=Cu(r)?{...n||{},credentials:"same-origin"}:n,a=null,l=i?Yr():null,c=l?.authGeneration,d=!!l?.isAuthenticated;if(i){let f=av(s,n);a=lv(f),a||(a=Au(),a&&(f.set("Authorization",`Bearer ${a}`),o=cv(o,f)))}let u=await e(s,o);try{let f=u.headers&&u.headers.get&&u.headers.get("X-New-Token");f&&rv(f,a),i&&u.status===401&&dv(u,a,c,d)}catch{}return u}}var Iu,nv,Tu=F(()=>{Iu=!1,nv=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 Mu,Pu=F(()=>{Mu={"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.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","mermaid.export":"\u5BFC\u51FA","mermaid.exportMd":"\u5BFC\u51FA MD","mermaid.exportPng":"\u5BFC\u51FA PNG","mermaid.exportJpg":"\u5BFC\u51FA JPG","chat.toolActionsOmitted":"\u5DF2\u7701\u7565 {count} \u4E2A\u5386\u53F2\u5DE5\u5177\u52A8\u4F5C","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.none":"\u6682\u65E0 Agent","chat.agent.restarting":"\u91CD\u542F\u4E2D","chat.agent.restart":"\u91CD\u542F","chat.agent.restartConfirm":`\u786E\u5B9A\u8981\u91CD\u542F Agent "{name}" \u5417\uFF1F
|
|
10
|
+
${g}`:g),p.status!=="failed"&&p.status!=="closed"&&(p.status=a.status||"idle");break}case"error":a.error&&(p.error=a.error.message||String(a.error));break;default:break}p.updatedAt=Date.now(),this.yeaftSubAgentCards={...this.yeaftSubAgentCards,[l]:p};break}case"history_loaded":{let i={...r,agentId:e.agentId||null,requestId:r.requestId||e.requestId||null};if(i.requestId&&!this.isCurrentYeaftHistoryResponse(i))break;let o=e.agentId||null,a=r.sessionId??null,l=Pe(o,a),c=e.perfTraceId||this.yeaftHistoryPerfTraceBySession?.[l];c&&Ze(this,{traceId:c,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 d=r.mode==="delta"?"delta":"recent",u=this.yeaftSessionHistoryState[l]||{},f=Number.isFinite(r.latestSeq)?r.latestSeq:Number.isFinite(u.latestSeq)?u.latestSeq:null,p=d==="delta"?{...u,loaded:!0,loading:!1,latestSeq:f,syncingAfterSeq:null,count:(u.count||0)+(r.count||0)}:{loaded:!0,loading:!1,hasMore:!!r.hasMore,oldestSeq:typeof r.oldestSeq=="number"?r.oldestSeq:null,count:typeof r.count=="number"?r.count:0,latestSeq:f,syncingAfterSeq:null},g=i.requestId?this.finishYeaftHistoryLoad(i,p,"completion"):null;g||(this.yeaftSessionHistoryState={...this.yeaftSessionHistoryState,[l]:p});let h=Pe(o?this.currentAgent:null,this.yeaftActiveSessionFilter??null);if(l===h)d==="recent"&&(this.yeaftHasMoreHistory=p.hasMore,this.yeaftOldestLoadedSeq=p.oldestSeq),this.yeaftLoadingMoreHistory=!!g?.loading;else if(this.yeaftLoadingMoreHistory){let v=this.yeaftSessionHistoryState[h]||null;this.yeaftLoadingMoreHistory=!!v?.loading}}break;case"vp_snapshot":{let i=window.Pinia?.useVpStore?.()||window.__useVpStore&&window.__useVpStore();i&&i.applySnapshot(r,e.agentId||null,e.requestId||null);break}case"vp_snapshot_error":{let i=window.Pinia?.useVpStore?.()||window.__useVpStore&&window.__useVpStore();i&&i.failSnapshot(e.agentId||null,e.requestId||null,r.error||r.message||"VP library request failed");break}case"vp_updated":{let i=window.Pinia?.useVpStore?.()||window.__useVpStore&&window.__useVpStore();i&&r.vp&&i.upsert(r.vp,r.reason,e.agentId||null);break}case"vp_removed":{let i=window.Pinia?.useVpStore?.()||window.__useVpStore&&window.__useVpStore();i&&r.vpId&&i.remove(r.vpId,r.reason,e.agentId||null);break}case"vp_crud_result":{let i=this._vpCrudPending&&this._vpCrudPending.get(r.requestId);i&&(this._vpCrudPending.delete(r.requestId),i.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 i=window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore(),o=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 u=Array.isArray(this.yeaftSessionHydrateSlices)?this.yeaftSessionHydrateSlices.filter(f=>f.agentId!==(e.agentId||null)):[];this.yeaftSessionHydrateSlices=[...u,{agentId:e.agentId||null,sessions:o}];break}let a=i&&i.activeSessionId||null,l=i?.activeSessionKey&&i.sessions?.[i.activeSessionKey]?.agentId||null;i&&(i.applySnapshot(o,e.agentId||null),this._hasHandledYeaftSessionHydrate=!0,this.yeaftSessionHydrateError=null);let c=i&&i.activeSessionId||null,d=i?.activeSessionKey&&i.sessions?.[i.activeSessionKey]?.agentId||null;if(this.currentView==="yeaft"&&c){let u=d||Ce(this,c,e.agentId||null),f=Pe(u,c),p=this.yeaftSessionHistoryState[f]||null;this.setActiveSessionFilter(c,{agentId:u,force:l!==u||cc(c,a,p)})}break}case"group_roster_changed":case"session_roster_changed":{let i=window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore();i&&i.applyRosterChange(r,e.agentId||null);break}case"group_crud_result":case"session_crud_result":{let i=window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore();i&&i.applyCrudResult(r,e.agentId||null);let o=this._sessionCrudPending&&this._sessionCrudPending.get(r.requestId);if(o){this._sessionCrudPending.delete(r.requestId);let a=r.session||r.group||null,l=a&&e.agentId&&!a.agentId?{...a,agentId:e.agentId}:a,c=r.sessionId||null,d=r.sessions||null;o.resolve({ok:!!r.ok,op:r.op,session:l,sessionId:c,sessions:d,config:r.config||null,error:r.error||null})}break}case"vp_turn_start":{if(!r.turnId||!r.vpId)break;let i=qo(e.agentId||null,r.turnId)||r.turnId;if(this.activeVpTurns={...this.activeVpTurns,[i]:{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 o=dt(e.agentId||null,r.sessionId);this.yeaftProcessingSessions={...this.yeaftProcessingSessions,...o?{[o]:!0}:{[r.sessionId]:!0}}}break}case"vp_turn_end":{if(!r.turnId)break;let i=Bs(this,e.agentId||null,r.turnId),o=r.sessionId||this.activeVpTurns?.[i]?.sessionId||null;r.reason==="end_turn"&&o&&this.markYeaftSessionUnread(o,e.agentId||null);let{[i]:a,...l}=this.activeVpTurns;this.activeVpTurns=l;let{[i]:c,...d}=this.stoppingVpTurnIds;this.stoppingVpTurnIds=d,this.clearYeaftSessionProcessingIfIdle(r.sessionId||a?.sessionId||null,{agentId:e.agentId||a?.agentId||null});let f={end_turn:"completed",route_forward:"completed",aborted:"aborted",errored:"errored",error:"errored",cancelled:"cancelled",canceled:"cancelled"}[r.reason]||"completed",p=Date.now(),g=zt(this,e.agentId||null,e.conversationId);if(g&&Array.isArray(this.messagesMap[g])){let h=this.messagesMap[g],v=zd(h,r);for(let C=0;C<h.length;C++){let w=h[C];if(!w||w.type!=="assistant")continue;let k=w.sessionId??w.groupId;r.sessionId&&k&&k!==r.sessionId||r.vpId&&w.speakerVpId&&w.speakerVpId!==r.vpId||r.turnId&&w.turnId&&w.turnId!==r.turnId||w.status&&w.status!=="pending"||(w.status=f,w.turnEndAt=p,w.turnEndReason=r.reason||null,r.detail&&(w.turnEndDetail=r.detail),Number.isFinite(r.durationMs)&&(w.turnDurationMs=r.durationMs),v=!0)}v&&(this.messagesMap={...this.messagesMap,[g]:h.slice()})}break}case"yeaft_turn_aborted":{let i=Array.isArray(r.turnIds)?r.turnIds.filter(Boolean):[];r.turnId&&i.push(r.turnId);let o=r.sessionId||null,a=r.vpId||null,l=new Set;for(let f of i){let p=Bs(this,e.agentId||null,f),g=this.activeVpTurns?.[p]||null;(!g||pt(g,g.sessionId,e.agentId||null))&&l.add(p)}if(a)for(let[f,p]of Object.entries(this.activeVpTurns||{}))!p||p.vpId!==a||pt(p,o,e.agentId||null)&&l.add(f);if(l.size===0)break;let c=o,d={...this.activeVpTurns||{}},u={...this.stoppingVpTurnIds||{}};for(let f of l){let p=d[f];!c&&p?.sessionId&&(c=p.sessionId),delete d[f],delete u[f]}this.activeVpTurns=d,this.stoppingVpTurnIds=u,this.clearYeaftSessionProcessingIfIdle(c||null,{agentId:e.agentId||null});break}case"yeaft_aborted":{let i=r.sessionId||e.sessionId||null;i?(this.activeVpTurns=Object.fromEntries(Object.entries(this.activeVpTurns||{}).filter(([,o])=>!pt(o,i,e.agentId||null))),this.stoppingVpTurnIds=Object.fromEntries(Object.entries(this.stoppingVpTurnIds||{}).filter(([o])=>this.activeVpTurns?.[o])),this.vpStatuses=Object.fromEntries(Object.entries(this.vpStatuses||{}).filter(([,o])=>!pt(o,i,e.agentId||null))),this.clearYeaftSessionProcessingIfIdle(i,{agentId:e.agentId||null,ignoreStatuses:!0})):r.all&&Zd(this,e.agentId||null);break}case"vp_typing_start":{if(!r.vpId)break;let i=zt(this,e.agentId||null,e.conversationId);if(!i)break;this.yeaftVpTyping=Md(this.yeaftVpTyping,i,r.vpId);break}case"vp_typing_end":{if(!r.vpId)break;let i=zt(this,e.agentId||null,e.conversationId);if(!i)break;this.yeaftVpTyping=Pd(this.yeaftVpTyping,i,r.vpId);break}case"vp_status_changed":{if(!r.vpId||!r.state)break;let i=r.sessionId||null,o=e.agentId||null,a=Or(o,i,r.vpId),l={agentId:o,state:r.state,since:r.since||Date.now(),turnId:r.turnId||null,title:r.title||"",sessionId:i,vpId:r.vpId};if(this.vpStatuses={...this.vpStatuses,[a]:l},i&&Br.has(r.state)){let c=dt(o,i);this.yeaftProcessingSessions={...this.yeaftProcessingSessions,...c?{[c]:!0}:{[i]:!0}}}else i&&this.clearYeaftSessionProcessingIfIdle(i,{agentId:o});this.restoreActiveYeaftSessionFromStatuses([l],o);break}case"vp_status_snapshot":{let i=Array.isArray(r.statuses)?r.statuses:[],o=r.sessionId;if(o==null){let a={...this.vpStatuses||{}};if(e.agentId)for(let[l,c]of Object.entries(a))(!c?.agentId||c.agentId===e.agentId)&&delete a[l];else for(let l of Object.keys(a))delete a[l];for(let l of i){if(!l||!l.vpId)continue;let c=l.sessionId||l.groupId||null,d=Or(e.agentId||null,c,l.vpId);a[d]={agentId:e.agentId||null,state:l.state,since:l.since||Date.now(),turnId:l.turnId||null,title:l.title||"",sessionId:c,vpId:l.vpId}}this.vpStatuses=a}else{let a={...this.vpStatuses};for(let[l,c]of Object.entries(a))c&&c.sessionId===o&&(!e.agentId||!c.agentId||c.agentId===e.agentId)&&delete a[l];for(let l of i){if(!l||!l.vpId)continue;let c=l.sessionId||l.groupId||null,d=Or(e.agentId||null,c,l.vpId);a[d]={agentId:e.agentId||null,state:l.state,since:l.since||Date.now(),turnId:l.turnId||null,title:l.title||"",sessionId:c,vpId:l.vpId}}this.vpStatuses=a}this.yeaftProcessingSessions=Eh(this,e.agentId||null,i,o??null),this.restoreActiveYeaftSessionFromStatuses(i,e.agentId||null);break}case"yeaft_dream_snapshot":{let i=r&&r.snapshot,o=i&&typeof i.scope=="string"?i.scope:null;o&&(this.yeaftDreamSnapshots={...this.yeaftDreamSnapshots,[o]:{...i,receivedAt:Date.now()}});break}case"yeaft_dream_status":{let i=window.Pinia?.useVpStore?.()||window.__useVpStore&&window.__useVpStore();i&&i.applyDreamStatus(r);break}case"yeaft_dream_result":{let i=window.Pinia?.useVpStore?.()||window.__useVpStore&&window.__useVpStore();i&&i.applyDreamResult(r),r?.snapshot?.scope&&(this.yeaftDreamSnapshots={...this.yeaftDreamSnapshots,[r.snapshot.scope]:{...r.snapshot,receivedAt:Date.now()}});{let o=typeof r?.snapshot?.scope=="string"&&r.snapshot.scope?r.snapshot.scope:typeof r?.sessionId=="string"&&r.sessionId?`sessions/${r.sessionId}`:null;if(!o)break;let a=this.yeaftDreamLatest[o]||null;this.yeaftDreamLatest={...this.yeaftDreamLatest,[o]:{scope:o,phase:"result",status:r.skipped?"skipped":r.success?"success":"error",startedAt:a?.startedAt??null,finishedAt:Date.now(),mergedCount:typeof r.entriesCreated=="number"?r.entriesCreated:a?.mergedCount??null,error:r.skipped||r.success?null:r.error||"unknown",manual:typeof r?.manual=="boolean"?r.manual:a?.manual??null,durationMs:typeof r.durationMs=="number"?r.durationMs:a?.durationMs??null,llmCallCount:typeof r.llmCallCount=="number"?r.llmCallCount:a?.llmCallCount??0,inputTokens:typeof r.inputTokens=="number"?r.inputTokens:a?.inputTokens??0,outputTokens:typeof r.outputTokens=="number"?r.outputTokens:a?.outputTokens??0,totalTokens:typeof r.totalTokens=="number"?r.totalTokens:a?.totalTokens??0,metrics:r.metrics||a?.metrics||null,passBreakdown:r.passBreakdown||r.metrics?.passBreakdown||a?.passBreakdown||null,isRunning:!1}},this._appendDreamEvent(o,{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 i=r?.phase||"unknown",o=null;typeof r?.target=="string"&&r.target.includes("/")?o=r.target:typeof r?.sessionId=="string"&&r.sessionId?o=`sessions/${r.sessionId}`:o="*";let a=i==="done",l=i==="error"||r?.status==="error",c=!a&&!l,d=u=>{let f=this.yeaftDreamLatest[u]||null;return{scope:u,phase:i,status:l?"error":a?"success":"running",startedAt:f?.startedAt&&c?f.startedAt:r?.ts||f?.startedAt||Date.now(),finishedAt:a||l?r?.ts||Date.now():null,mergedCount:typeof r?.mergedCount=="number"?r.mergedCount:typeof r?.targets=="number"?r.targets:f?.mergedCount??null,error:l?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:c}};if(o==="*"){let u={...this.yeaftDreamLatest,"*":d("*")};for(let f of Object.keys(this.yeaftDreamLatest))f!=="*"&&(u[f]=d(f));this.yeaftDreamLatest=u}else this.yeaftDreamLatest={...this.yeaftDreamLatest,[o]:d(o)};this._appendDreamEvent(o,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>cu&&a.splice(0,a.length-cu),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",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=setTimeout(()=>{this._sessionCrudPending&&this._sessionCrudPending.has(n)&&(this._sessionCrudPending.delete(n),c({ok:!1,op:e,error:{code:"timeout",message:"group_crud timeout"}}))},1e4);this._sessionCrudPending.set(n,{resolve:u=>{clearTimeout(d),c(u)}}),this.sendWsMessage(o)})},markYeaftSessionUnread(e,t=null){if(!e)return!1;let s=Ce(this,e,t);if(!s)return!1;let n=br(s,e);return this.currentView==="yeaft"&&this.yeaftActiveSessionFilter===e&&Ce(this,e)===s||this.yeaftUnreadSessionKeys?.[n]?!1:(this.yeaftUnreadSessionKeys={...this.yeaftUnreadSessionKeys,[n]:!0},!0)},markYeaftSessionRead(e,t=null){if(!e)return!1;let s=Ce(this,e,t);if(!s)return!1;let n=br(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||du(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?Ce(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 c=this.agents.find(d=>d.id===r);this.activateYeaftAgent(r,c||null)}else r&&n&&this.activateYeaftAgent(r);if(r&&n&&this.markYeaftSessionRead(n,r),!o&&n===s)return;let a=Pe(r,n),l=this.yeaftSessionHistoryState[a]||null;if(this.pruneYeaftMessageWindow(n),r&&n){this.yeaftSessionAgentById={...this.yeaftSessionAgentById||{},[n]:r};let c=this.yeaftConversationIdsByAgent?.[r]||null;c||(c=`yeaft-local-${r}-${Date.now()}`,this.yeaftConversationIdsByAgent={...this.yeaftConversationIdsByAgent||{},[r]:c}),this.yeaftConversationId=c,this.messagesMap[c]||(this.messagesMap[c]=[]),this.currentView==="yeaft"&&(this.activeConversations=[c])}try{let c=window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore();c&&typeof c.setActive=="function"&&c.setActive(n,r||null);let d=c?.activeSessionKey||null;d?localStorage.setItem("lastViewedYeaftSession",d):localStorage.removeItem("lastViewedYeaftSession")}catch{}if(this.syncActiveYeaftHistoryLoad(),!l?.loading&&r&&n){let c=Number.isFinite(l?.latestSeq)?l.latestSeq:null,d={type:"yeaft_load_history",agentId:r,sessionId:n},u=!!l?.loaded,f=ko({sessionState:l,hasCachedSessionRows:!1,force:o});if(!f&&c!==null?d.afterSeq=c:d.limit=Hr,!f&&u&&c===null){this.yeaftSessionHistoryState={...this.yeaftSessionHistoryState,[a]:{...l||{hasMore:!1,oldestSeq:null,count:0},loaded:!0,loading:!1,syncingAfterSeq:null}},this.syncActiveYeaftHistoryLoad();return}let p=null;if(!f&&u){if(l?.syncingAfterSeq===c)return;p=this.beginYeaftHistoryLoad({agentId:r,sessionId:n,mode:"delta",preserveLoaded:!0,latestSeq:c}),this.yeaftSessionHistoryState={...this.yeaftSessionHistoryState,[a]:{...this.yeaftSessionHistoryState[a],syncingAfterSeq:c}}}else p=this.beginYeaftHistoryLoad({agentId:r,sessionId:n,mode:"recent",preserveLoaded:!1,latestSeq:f?null:c});p&&(d.requestId=p.requestId),this.sendWsMessage(d)}},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:Ce(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()?lu:ra,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}})},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&&(Ae(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.yeaftDebugSearch="",this.yeaftDebugSessionFilter=null,this._yeaftDebugSearchTimer&&(clearTimeout(this._yeaftDebugSearchTimer),this._yeaftDebugSearchTimer=null),this._fetchYeaftDebugHistoryTimer&&(clearTimeout(this._fetchYeaftDebugHistoryTimer),this._fetchYeaftDebugHistoryTimer=null),this._yeaftDebugHistoryInFlightKey=null,this._yeaftDebugHistoryLatestListRequestId=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},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){let s=new Set;if(this.sessionCatalog=(Array.isArray(e)?e:[]).filter(n=>!n?.catalogKey||s.has(n.catalogKey)?!1:(s.add(n.catalogKey),!0)).map(n=>({...n})),Array.isArray(t)){this.sessionProjects=t.filter(r=>r?.id).map(r=>({...r,members:Array.isArray(r.members)?r.members.filter(i=>i?.agentId&&i?.sessionId):r.agentId?(r.sessionIds||[]).map(i=>({agentId:r.agentId,sessionId:i})):[]}));let n=new Map;for(let r of this.sessionProjects)for(let i of r.members)n.set(`${i.agentId}${i.sessionId}`,r.id);this.sessionCatalog=this.sessionCatalog.map(r=>r.runtimeProvider==="yeaft"?{...r,projectId:n.get(`${r.routeRef?.agentId}${r.routeRef?.sessionId}`)||null}:r)}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),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;return!t||t.connectionGeneration!==Number(this.chatHistoryConnectionGeneration||0)?!1:(delete this.projectMutationRequests[e.requestId],e.ok&&Array.isArray(e.projects)&&this.applySessionCatalogSnapshot(this.sessionCatalog,e.projects),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=uo(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)},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},reorderCatalogSessions(e){if(!Array.isArray(e)||e.length===0||Object.keys(this.sessionCatalogMutationRequests).length>0)return!1;let t=`session_order_${crypto.randomUUID()}`,s=uo(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){return Rl(this,e)},openCatalogSession(e){if(!e?.catalogKey||!e.routeRef)return!1;let{runtimeProvider:t,agentId:s,sessionId:n}=e.routeRef;return this.activeCatalogKey=e.catalogKey,t==="yeaft"?(this.enterYeaft(s,{deferBootstrap:!0}),this.setActiveSessionFilter(n,{agentId:s,force:!0}),!0):t!=="claude-code"&&t!=="copilot"?!1:(this.currentView==="yeaft"&&this.leaveYeaft(),this.selectConversation(n,s),!0)},requestChatHistory(e,{mode:t="recent",turns:s=null,beforeId:n=null,afterMessageId:r=null}={}){if(!e)return null;let i=Rs(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})?a:(El(this,i,a,"send_failed"),null)},beginChatHistoryRequest(e,t="recent",s=null){return _l(this,e,t,s)},isCurrentChatHistoryResponse(e){if(!e?.conversationId||!e?.requestId||!e?.catalogKey)return!1;let t=Rs(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 Ql(this,e)},parseWsMessage(e){return Xl(this,e)},connect(){Zl(this)},ensureConnected(){return yn(this)},scheduleReconnect(){Jl(this)},manualReconnect(){ec(this)},startHeartbeat(){tc(this)},stopHeartbeat(){sc(this)},setupVisibilityHandler(){nc(this)},handleMessage(e){Gc(this,e)},getOrCreateExecutionStatus(e){return Vo(this,e)},handleAssistantOutputFrame(e,t){Oc(this,e,t)},handleClaudeOutput(e,t){this.handleAssistantOutputFrame(e,t)},addMessageToConversation(e,t){kr(this,e,t)},appendToAssistantMessageForConversation(e,t,s){uc(this,e,t,s)},finishStreamingForConversation(e,t){pc(this,e,t)},sweepStaleStreamingForConversation(e){fc(this,e)},appendToAssistantMessage(e){this.appendToAssistantMessageForConversation(this.currentConversation,e)},finishStreaming(){this.finishStreamingForConversation(this.currentConversation)},addMessage(e){this.addMessageToConversation(this.currentConversation,e)},loadHistoryMessages(e){gc(this,e)},formatDbMessage(e){return So(e)},formatDbMessageForHistoryHydration(e){return hc(e)},selectAgent(e){return nd(this,e)},createConversation(e,t=null,s=null,n=void 0){rd(this,e,t,s,n)},resumeConversation(e,t,s=null,n=null,r=null){id(this,e,t,s,n,r)},selectConversation(e,t){od(this,e,t)},updateConversationSettings(e,t){Bo(this,e,t)},toggleConversationMcp(e,t){ad(this,e,t)},deleteConversation(e,t){cd(this,e,t)},closeSession(e,t){ld(this,e,t)},appendColumn(e){fd(this,e)},removeColumn(e){gd(this,e)},sendMessageToConversation(e,t,s=[],n={}){md(this,e,t,s,n)},cancelExecutionForConversation(e){hd(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){let s=this.panels.find(n=>n.id===e);s&&(s.conversationId=t,t&&!this.activeConversations.includes(t)&&this.activeConversations.push(t),t&&!this.messagesMap[t]&&(this.messagesMap[t]=[],this.requestChatHistory(t,{mode:"recent",turns:5})),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?!!fs()?.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=Ce(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?fs()?.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||Ce(this,e);if(Object.values(this.activeVpTurns||{}).some(a=>pt(a,e,n))||!s&&Object.values(this.vpStatuses||{}).some(l=>pt(l,e,n)&&Br.has(l?.state)))return;let i=dt(n,e),o={...this.yeaftProcessingSessions||{}};i&&delete o[i],Nr(this,e,n)&&delete o[e],this.yeaftProcessingSessions=o},sendMessage(e,t=[],s={}){dd(this,e,t,s)},cancelExecution(){ud(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],Zd(this,this.currentAgent)},cancelYeaftSession(e){let t=Ce(this,e);!t||!e||(this.sendWsMessage({type:"yeaft_abort_all",agentId:t,sessionId:e}),this.activeVpTurns=Object.fromEntries(Object.entries(this.activeVpTurns||{}).filter(([,s])=>!pt(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])=>!pt(s,e,t))),this.clearYeaftSessionProcessingIfIdle(e,{agentId:t,ignoreStatuses:!0}))},cancelVpTurn(e,{sessionId:t=null,vpId:s=null}={}){let n=Ce(this,t);if(!n||!e)return;let r=Bs(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=Ce(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||!pt(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?.[Or(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){pd(this,e,t,s)},refreshAgents(){vd(this)},refreshConversation(){yd(this)},restartAgent(e){bd(this,e)},upgradeAgent(e){wd(this,e)},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=ps(this),t=Ce(this,e);if(!t)return!1;let s=Pe(t,e),n=this.yeaftConversationId,r=this.beginYeaftHistoryLoad({agentId:t,sessionId:e,mode:"recent",preserveLoaded:!1});if(!r)return!1;let i=Cn();this.yeaftHistoryPerfTraceBySession={...this.yeaftHistoryPerfTraceBySession||{},[s]:i};let o={type:"yeaft_load_history",agentId:t,limit:Hr,sessionId:e,requestId:r.requestId,perfTraceId:i};return Ze(this,{traceId:i,phase:"history.request_send",agentId:t,sessionId:e,messageType:o.type,bytes:JSON.stringify(o).length,detail:{mode:"manual-reload",limit:Hr}}),this.sendWsMessage(o),!0},loadMoreYeaftHistory(e=Dn()){if(this.currentView!=="yeaft"||this.yeaftLoadingMoreHistory||!this.yeaftHasMoreHistory||this.yeaftOldestLoadedSeq==null)return;let t=ps(this),s=Ce(this,t);if(!s)return;let n=Math.min(50,Math.max(1,Number.isFinite(e)?Math.floor(e):Dn())),r=Pe(s,t),i=this.beginYeaftHistoryLoad({agentId:s,sessionId:t,mode:"older",preserveLoaded:!0,latestSeq:this.yeaftSessionHistoryState[r]?.latestSeq??null});if(!i)return;let o=Cn();this.yeaftHistoryPerfTraceBySession={...this.yeaftHistoryPerfTraceBySession||{},[r]:o};let a={type:"yeaft_load_more_history",agentId:s,sessionId:t,requestId:i.requestId,beforeSeq:this.yeaftOldestLoadedSeq,turns:n,perfTraceId:o};Ze(this,{traceId:o,phase:"history_more.request_send",agentId:s,sessionId:t,messageType:a.type,bytes:JSON.stringify(a).length,detail:{beforeSeq:a.beforeSeq,turns:a.turns}}),this.sendWsMessage(a)},checkPendingRecovery(){Dl(this)},performRecovery(){Ll(this)},dismissRecovery(){$l(this)},autoRestoreConversation(e){Vl(this,e)},saveOpenSessions(){Es(this)},getLastSession(){return Ol(this)},clearLastSession(){Hl(this)},listHistorySessions(e){ql(this,e)},listFolders(){return Nl(this)},listFoldersForAgent(e,t){return Bl(this,e,t)},listModelsForAgent(e,t){return Wl(this,e,t)},listHistorySessionsForAgent(e,t,s){jl(this,e,t,s)},async loadGlobalSessions(e=20){return Ul(this,e)},async deleteGlobalSession(e){return zl(this,e)},findAgentForSession(e){return fo(this,e)},isSessionResumable(e){return Kl(this,e)},_isRecentlyClosed(e){return is(this,e)},_startProcessingWatchdog(e){Ls(this,e)},_resetProcessingWatchdog(e){Sr(this,e)},_stopProcessingWatchdog(e){Ae(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,mn(e),this.currentAgent)try{this.sendWsMessage({type:"update_llm_config",agentId:this.currentAgent,config:{language:e}})}catch{}},async fetchCustomExpertRoles(){let e=_e();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=_e();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=_e();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=_e();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}},toggleWorkbench(){this.workbenchExpanded=!this.workbenchExpanded,this.workbenchExpanded||(this.workbenchMaximized=!1)},toggleSidebar(){this.sidebarCollapsed=!this.sidebarCollapsed},toggleSessionSidebar(){this.sessionSidebarOpen=!this.sessionSidebarOpen},closeSessionSidebar(){this.sessionSidebarOpen=!1},toggleWorkbenchMaximized(){this.workbenchMaximized=!this.workbenchMaximized},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})},openFileInExplorer(e){this.currentConversation&&(this.workbenchExpanded=!0,window.dispatchEvent(new CustomEvent("open-file-in-explorer",{detail:{filePath:e,conversationId:this.currentConversation}})))},logout(){_e().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.subagents={},this.activeSubagentId=null,this.activeRightPanel=null,this.pinnedSessions=[],this.clearWorkCenterBrowserState(),this.ws&&this.ws.close()}}})});function aa(e,t){!e||typeof e.handleYeaftOutput!="function"||!t||e.handleYeaftOutput({event:t})}function Yh(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 ca(e){if(!e)return Kt[0];let t=String(e).toLowerCase();return Kh[t]||Kt[Yh(t)%Kt.length]}function Gh(e){return ca(e).background}function Qh(e){return ca(e).foreground}function la(){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 Xh(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 zh,Kt,Kh,Lw,yt,Ws=F(()=>{({defineStore:zh}=Pinia);Kt=[{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)"}],Kh=Object.freeze({steve:Kt[8],ada:Kt[3],linus:Kt[0],martin:Kt[4]}),Lw=Kt.map(e=>e.background);yt=zh("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?la().startsWith("zh")&&s.displayNameZh?s.displayNameZh:s.displayName||s.vpId||t:t},vpDescription:e=>t=>Xh(e.vps[t],la()),vpInitial:e=>t=>{let s=e.vps[t],n=la().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:Gh(t)},vpTextColor:()=>e=>Qh(e),vpAvatarMotif:()=>e=>ca(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(aa(s,{type:"dream_progress",phase:"start",groupId:e,manual:!0,trigger:"manual",source:"header-button",ts:n}),!s||typeof s.sendWsMessage!="function"){aa(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&&aa(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 da(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 jr(e){return!e||typeof e!="object"?0:da(e.lastMessageAt)||da(e.updatedAt)||da(e.createdAt)||0}function ua(e,t){let s=jr(t)-jr(e);return s!==0?s:String(e?.id||"").localeCompare(String(t?.id||""))}function fu(e){return[...Array.isArray(e)?e:[]].sort(ua)}var Ur=F(()=>{});function gu(){try{if(typeof localStorage>"u")return{};let e=JSON.parse(localStorage.getItem(yu)||"{}");return e&&typeof e=="object"?e:{}}catch{return{}}}function Zh(e){try{typeof localStorage<"u"&&localStorage.setItem(yu,JSON.stringify(e&&typeof e=="object"?e:{}))}catch{}}function mu(){try{return typeof localStorage>"u"?[]:$n(JSON.parse(localStorage.getItem(bu)||"[]"))}catch{return[]}}function Jh(e){try{typeof localStorage<"u"&&localStorage.setItem(bu,JSON.stringify($n(e)))}catch{}}function wu(e,t){return`${e||""}${t||""}`}function Rt(e){return e&&e.agentId&&e.id?wu(e.agentId,e.id):""}function bt(e,t){return t?e?wu(e,t):String(t):""}function ev(e){return typeof e=="string"?e:String(e||"")}function nt(e,t,s=null){let n=ev(t);if(!n)return"";let r=bt(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=Vn();if(l?.currentAgent){let c=a.find(d=>e.sessions[d]?.agentId===l.currentAgent);if(c)return c}return a[0]||""}function pa(e,t,s=null){return nt(e,t,s)||""}function fa(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 tv(e){let t=e._preferredExactSessionIdentity||null;if(!t)return!1;e._preferredExactSessionIdentity=null;let s=e.sessions[t.key]||null,n=Vn(),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=Mn(localStorage.getItem("lastViewedYeaftSession")||"");o.agentId===t.agentId&&o.sessionId===t.sessionId&&localStorage.removeItem("lastViewedYeaftSession")}catch{}return!0}function zr(e){let t=e._retiredBareActiveSessionId||null;if(!t)return!1;let s=Vn();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")||"";Mn(r).sessionId===t&&localStorage.removeItem("lastViewedYeaftSession")}catch{}return!0}function $n(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 ga(e,t){let s=$n(e),n=new Set(s),r=$n(t).filter(o=>n.has(o)),i=new Set(r);return[...r,...s.filter(o=>!i.has(o))]}function Kr(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 hu(e){return!e||typeof e!="object"?!1:e.running===!0||e.active===!0||e.isActive===!0||e.isRunning===!0}function vu(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 Vn(){try{if(typeof window<"u"&&window.Pinia&&typeof window.Pinia.useChatStore=="function")return window.Pinia.useChatStore()}catch{}return null}var yu,bu,sv,ku,Su=F(()=>{Ur();Pn();yu="yeaft-session-order-by-agent",bu="yeaft-session-order-global";({defineStore:sv}=Pinia);ku=sv("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=Vn(),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,f)=>{let p=Number.isFinite(u?.sortOrder)?u.sortOrder:Number.MAX_SAFE_INTEGER,g=Number.isFinite(f?.sortOrder)?f.sortOrder:Number.MAX_SAFE_INTEGER;return p!==g?p-g:ua(u,f)}),a=[...o(r),...o(i)],l=mu();if(l.length===0)return a;let c=new Map(l.map((d,u)=>[d,u]));return a.sort((d,u)=>{let f=c.has(Rt(d))?c.get(Rt(d)):Number.MAX_SAFE_INTEGER,p=c.has(Rt(u))?c.get(Rt(u)):Number.MAX_SAFE_INTEGER;return f!==p?f-p:0})},sessionCount(e){return e.sessionOrder.length},sessionById:e=>(t,s=null)=>{let n=nt(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){fa(this);let o={...this.sessions},a=new Set;for(let p of n){if(!p||!p.id)continue;let g=bt(t,p.id);a.add(g),o[g]=this._normalize(p,t,Kr(this.sessions[g]))}for(let p of this.sessionOrder){let g=this.sessions[p];g&&g.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 g=bt(t,p.id);o[g]&&!c.has(g)&&d.push(g)}this.sessions=o;let u=[...l,...d],f=mu();if(f.length>0){let p=new Map(u.map(C=>[Rt(o[C]),C]).filter(([C])=>C)),g=f.map(C=>p.get(C)).filter(Boolean),h=new Set(g);u=[...g,...u.filter(C=>!h.has(C))];let v=new Map(f.map((C,w)=>[C,w]));for(let C of u){let w=Rt(o[C]);w&&v.has(w)&&(o[C]={...o[C],sortOrder:v.get(w)})}}if(t&&f.length===0){let p=gu(),g=$n(p[t]);if(g.length>0){let h=g.map(m=>bt(t,m)),v=new Set(h),C=ga(u.filter(m=>o[m]?.agentId===t),h),w=this.sessionOrder.some(m=>o[m]?.agentId===t),k=0;w?u=this.sessionOrder.filter(m=>o[m]).map(m=>o[m]?.agentId===t?C[k++]:m).concat(C.slice(k)):u=u.map(m=>o[m]?.agentId===t?C[k++]:m);let y=new Map(h.map((m,b)=>[m,b]));for(let m of C)o[m]&&v.has(m)&&(o[m]={...o[m],sortOrder:y.get(m)})}}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=bt(null,c.id);a[d]=this._normalize(c,null,Kr(this.sessions[d])),l.push(d)}this.sessions=a,this.sessionOrder=l,this.inventoryIdentityMode="legacy-bare"}s||(r=tv(this)||zr(this)),this.lastSnapshotAt=Date.now();let i=Vn();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?nt(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,y)=>vu(this.sessions[y])-vu(this.sessions[k]))[0]||null,f=u?this.sessions[u]?.id:null,p=this.sessionList[0]||null,g=p?.id||null,h=g?nt(this,g,p?.raw?.agentId||null):"",v=f||(d?c.id:null)||g,C=u||(d?l:"")||h||pa(this,v,t),w=this.activeSessionKey?this.sessions[this.activeSessionKey]?.agentId:null;if(this.activeSessionId&&!nt(this,this.activeSessionId,w)?(this.activeSessionId=v,this.activeSessionKey=C||null):!this.activeSessionId&&this.sessionOrder.length>0&&!this._retiredBareActiveSessionId?(this.activeSessionId=v,this.activeSessionKey=C||null):this.activeSessionId&&(this.activeSessionKey=pa(this,this.activeSessionId,w)||this.activeSessionKey),i&&!this._retiredBareActiveSessionId){let k=this.activeSessionId||v,y=null;if((i.yeaftActiveSessionFilter&&!nt(this,i.yeaftActiveSessionFilter)||!i.yeaftActiveSessionFilter&&k)&&(y=k),y){let m=pa(this,y),b=m&&this.sessions[m]?.agentId||null;i.currentView==="yeaft"&&typeof i.setActiveSessionFilter=="function"?i.setActiveSessionFilter(y,{agentId:b,force:!0}):i.yeaftActiveSessionFilter=y,this.activeSessionKey=m||this.activeSessionKey}}}if(i&&typeof i.applyServerPinSnapshot=="function"){let o=new Set;for(let l of n){if(!l||!l.id)continue;let c=bt(t,l.id),d=this.sessions[c];d&&d.pinned&&o.add(l.id)}let a=l=>{let c=nt(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)fa(this);else if(this.inventoryIdentityMode!=="legacy-bare")return;let r=nt(this,s,n)||bt(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),zr(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},zr(this)},applyCrudResult(e,t=null){if(!e)return;this.lastCrudResult={...e,at:Date.now()},e.requestId&&this.pending[e.requestId]&&delete this.pending[e.requestId];let s=e.session||e.group||null,n=t||e.agentId||s?.agentId||null;e.ok&&e.op==="list"&&Array.isArray(e.sessions)&&this.applySnapshot(e.sessions,n),e.ok&&(e.op==="create"||e.op==="restore")&&s&&s.id&&this.applySnapshotUpsert(s,n)&&this.setActive(s.id,n);let r=e.sessionId||e.groupId,i=this.inventoryIdentityMode==="legacy-bare",o=r&&(n||i)?nt(this,r,n):"";if(e.ok&&(e.op==="archive"||e.op==="delete")&&r&&o&&(delete this.sessions[o],this.sessionOrder=this.sessionOrder.filter(a=>a!==o),(this.activeSessionKey===o||i&&this.activeSessionId===r)&&(this.activeSessionKey=this.sessionOrder[0]||null,this.activeSessionId=this.activeSessionKey&&this.sessions[this.activeSessionKey]?.id||null)),e.ok&&e.op==="update_config"&&r){let a=o?this.sessions[o]:null;a&&(this.sessions[o]={...a,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)fa(this);else if(this.inventoryIdentityMode!=="legacy-bare")return"";let n=nt(this,e.id,s)||bt(s,e.id),r=!!this.sessions[n],i=this.sessions[n]||{};return this.sessions[n]={...i,...this._normalize(e,s,Kr(i))},r||this.sessionOrder.push(n),zr(this),n},setActive(e,t=null){let s=nt(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=ga(s,t.map(l=>bt(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=gu(),a=n.map(l=>this.sessions[l]?.id).filter(Boolean);return o[e]=a,Zh(o),a},reorderSessionsGlobally(e){let t=this.sessionOrder.map(a=>Rt(this.sessions[a])).filter(Boolean),s=ga(t,e);if(s.length===0)return[];let n=new Map(this.sessionOrder.map(a=>[Rt(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=Rt(this.sessions[a]);l&&o.has(l)&&(this.sessions[a]={...this.sessions[a],sortOrder:o.get(l)})}return Jh(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=nt(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=bt(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:hu(e),active:hu(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:Kr(e,s),sortOrder:Number.isFinite(e.sortOrder)?e.sortOrder:null}}}})});function Yr(){try{if(window.Pinia&&typeof window.Pinia.useAuthStore=="function")return window.Pinia.useAuthStore()}catch{}return null}function ma(){try{return localStorage.getItem("authToken")||null}catch{return null}}function Au(){let e=Yr();if(e)try{return e.getActiveToken?.()||e.token||ma()}catch{return e.token||ma()}return ma()}function rv(e,t){if(!e)return!1;let s=Au();if(s&&s!==t)return!1;try{localStorage.setItem("authToken",e)}catch{}let n=Yr();return n&&(n.token=e),!0}function iv(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 Cu(e){return!e||typeof window>"u"||!window.location?!1:e.origin===window.location.origin&&e.pathname.startsWith("/api/")}function ov(e){if(!e)return!1;let t=e.pathname;return!!(nv.has(t)||t.startsWith("/api/auth/sso/poll/")||/^\/api\/auth\/sso\/[^/]+\/start(?:-qr)?$/.test(t))}function av(e,t){return t?.headers?new Headers(t.headers):e&&typeof e=="object"&&e.headers?new Headers(e.headers):new Headers}function lv(e){let t=e.get("Authorization");return!t||!t.startsWith("Bearer ")?null:t.slice(7)}function cv(e,t){return{...e||{},headers:t}}function dv(e,t,s,n){let r=Yr();r&&typeof r.handleAuthResponse=="function"?r.handleAuthResponse(e,t,s,n):r&&typeof r.handleAuthFailure=="function"&&n&&r.handleAuthFailure(void 0,t,s)}function xu(){if(Iu||typeof window>"u"||!window.fetch)return;Iu=!0;let e=window.fetch.bind(window);window.fetch=async function(s,n){let r=iv(s),i=Cu(r)&&!ov(r),o=Cu(r)?{...n||{},credentials:"same-origin"}:n,a=null,l=i?Yr():null,c=l?.authGeneration,d=!!l?.isAuthenticated;if(i){let f=av(s,n);a=lv(f),a||(a=Au(),a&&(f.set("Authorization",`Bearer ${a}`),o=cv(o,f)))}let u=await e(s,o);try{let f=u.headers&&u.headers.get&&u.headers.get("X-New-Token");f&&rv(f,a),i&&u.status===401&&dv(u,a,c,d)}catch{}return u}}var Iu,nv,Tu=F(()=>{Iu=!1,nv=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 Mu,Pu=F(()=>{Mu={"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.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","mermaid.export":"\u5BFC\u51FA","mermaid.exportMd":"\u5BFC\u51FA MD","mermaid.exportPng":"\u5BFC\u51FA PNG","mermaid.exportJpg":"\u5BFC\u51FA JPG","chat.toolActionsOmitted":"\u5DF2\u7701\u7565 {count} \u4E2A\u5386\u53F2\u5DE5\u5177\u52A8\u4F5C","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.none":"\u6682\u65E0 Agent","chat.agent.restarting":"\u91CD\u542F\u4E2D","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.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.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.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.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.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.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.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","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.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.setupKicker":"Agent \u63A5\u5165","welcome.setupTitle":"\u8FDE\u63A5\u4F60\u7684\u7B2C\u4E00\u4E2A Yeaft Agent","welcome.setupDesc":"\u590D\u5236\u4E24\u6761\u547D\u4EE4\u5373\u53EF\u8FDE\u63A5\u672C\u673A Agent\u3002\u6A21\u578B\u53EF\u7528 GitHub Copilot \u81EA\u52A8\u914D\u7F6E\u3002","welcome.setupInstallTitle":"\u5B89\u88C5 CLI","welcome.setupCopilotTitle":"\u914D\u7F6E\u6A21\u578B","welcome.setupRunTitle":"\u542F\u52A8 Agent","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","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.scrollToLatest":"\u2193 \u6700\u65B0","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.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.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.invitations":"\u9080\u8BF7","auth.sessionExpired":"\u767B\u5F55\u5DF2\u8FC7\u671F\uFF0C\u8BF7\u91CD\u65B0\u767B\u5F55\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 Agent","settings.security.agentCmdService":"\u8FD0\u884C Agent server","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":"\u5148\u8FD0\u884C\u5B89\u88C5\u547D\u4EE4\uFF1B\u5982\u679C\u672C\u673A\u5DF2\u6709 GitHub Copilot token\uFF0CYeaft \u4F1A\u81EA\u52A8\u914D\u7F6E github-copilot/gpt-5.5\u3002Copilot \u547D\u4EE4\u53EA\u4F5C\u4E3A\u515C\u5E95\u4F7F\u7528\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.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.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.configureLlm":"\u6253\u5F00 LLM \u8BBE\u7F6E","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 yeaft-agent","yeaft.onboarding.installDesc":"\u5B89\u88C5\u547D\u4EE4\u884C Agent \u5305\u3002","yeaft.onboarding.connectTitle":"\u8FDE\u63A5\u8FD9\u4E2A Agent","yeaft.onboarding.connectDesc":"\u4E0B\u9762\u7684\u547D\u4EE4\u5DF2\u7ECF\u5E26\u4E0A\u5F53\u524D server URL \u548C\u81EA\u52A8\u751F\u6210\u7684 secret\u3002","yeaft.onboarding.llmTitle":"\u4F7F\u7528 GitHub Copilot","yeaft.onboarding.llmDesc":"\u5148\u767B\u5F55 GitHub CLI\uFF0C\u7136\u540E\u628A gpt-5.5 \u8BBE\u4E3A Yeaft \u9ED8\u8BA4\u6A21\u578B\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.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.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.userUsage":"\u7528\u6237\u7528\u91CF","settings.dashboard.agentList":"Agent \u5217\u8868","settings.dashboard.onlineUserList":"\u5728\u7EBF\u7528\u6237","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.lastLogin":"\u6700\u540E\u767B\u5F55","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.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":"\u5207\u6362\u5230 Terminal \u6807\u7B7E\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.collapseAll":"\u6298\u53E0\u6240\u6709","files.openFolder":"\u6253\u5F00\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.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.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.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.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.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.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.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.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.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.noCriteria":"\u672A\u63D0\u4F9B\u9A8C\u6536\u6761\u4EF6","workCenter.failureReason":"\u5931\u8D25\u539F\u56E0","workCenter.workflow":"\u4EFB\u52A1\u6D41","workCenter.actionFlow":"Action \u6D41\u7A0B","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":"\u4F9D\u8D56\u9879","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 \u67E5\u770B\u5B9E\u9645\u6267\u884C","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.failedAt":"\u5931\u8D25\u65F6\u95F4","workCenter.actionFailureRecovery":"\u5728\u5DE6\u4FA7\u5BF9\u8BDD\u8F93\u5165\u6846\u4E2D\u5C06\u76EE\u6807\u8BBE\u4E3A\u6B64 Action\uFF0C\u518D\u53D1\u9001\u4FEE\u6B63\u8BF4\u660E\uFF1B\u6267\u884C\u89C6\u56FE\u4F1A\u5C55\u793A\u4FDD\u7559\u4E0B\u6765\u7684\u5DE5\u5177\u8BC1\u636E\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.sendTo":"\u53D1\u9001\u7ED9","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.composerTargetAction":"Action {sequence}\uFF1A{name}","workCenter.sendToTarget":"\u53D1\u9001\u7ED9 {target}","workCenter.targetThisAction":"\u53D1\u9001\u7ED9\u6B64 Action","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.assistant":"Yeaft","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\uFF0CTriage \u4F1A\u751F\u6210\u76EE\u6807\u3001\u9A8C\u6536\u6761\u4EF6\u548C Actions\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":"Triage \u4F1A\u751F\u6210\u6807\u9898\u3001\u76EE\u6807\u3001\u9A8C\u6536\u6761\u4EF6\u3001\u7C7B\u578B\u548C\u6267\u884C\u8BA1\u5212\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.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.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.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":"Triage \u4F1A\u9488\u5BF9\u4EFB\u52A1\u52A8\u6001\u9009\u62E9 Action \u548C\u6267\u884C\u8005\u3002","workCenter.settings.aiWorkflowHelp":"Triage \u4F1A\u4E3A\u6BCF\u4E2A Work Item \u5206\u7C7B\u5E76\u751F\u6210\u7ECF\u8FC7\u6821\u9A8C\u7684 1\u20138 \u4E2A\u4EFB\u52A1\u4E13\u5C5E Action\u3002\u5185\u7F6E Action \u7B56\u7565\u53EA\u662F\u53EF\u590D\u7528\u9ED8\u8BA4\u503C\uFF1B\u9700\u8981\u65F6 triage \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":"AI \u52A8\u6001\u89C4\u5212\u6267\u884C","workCenter.aiPlanHelp":"Triage \u4F1A\u9009\u62E9\u4EFB\u52A1\u7C7B\u578B\u3001Action\u3001\u6267\u884C\u8005\u548C\u6700\u5C0F\u53EF\u9760\u6D41\u7A0B\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 Ru,_u=F(()=>{Ru={"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.search":"Search","common.back":"Back","common.noSubdirectories":"No subdirectories","common.drives":"Drives","common.rootDir":"Root","common.comma":", ","common.select":"Select","mermaid.export":"Export","mermaid.exportMd":"Export MD","mermaid.exportPng":"Export PNG","mermaid.exportJpg":"Export JPG","chat.toolActionsOmitted":"{count} older tool actions omitted","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.none":"No Agents","chat.agent.restarting":"Restarting","chat.agent.restart":"Restart","chat.agent.restartConfirm":`Are you sure you want to restart Agent "{name}"?
|
|
13
13
|
All active conversations will be interrupted.`,"chat.agent.upgrade":"Upgrade","chat.agent.upgrading":"Upgrading","chat.agent.upgradeConfirm":`Upgrade Agent "{name}" to the latest version?
|
|
@@ -303,7 +303,7 @@ The agent will restart after upgrading.`,"chat.agent.alreadyLatest":"Agent is al
|
|
|
303
303
|
</template>
|
|
304
304
|
</div>
|
|
305
305
|
</div>
|
|
306
|
-
`,setup(){let e=_e(),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),f=Vue.ref(null),p=Vue.ref(null),g=Vue.ref(""),
|
|
306
|
+
`,setup(){let e=_e(),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),f=Vue.ref(null),p=Vue.ref(null),g=Vue.ref(""),h=Vue.ref(localStorage.getItem("loginMode")==="credentials"?"credentials":"oauth");Vue.watch(h,B=>localStorage.setItem("loginMode",B));let v=Vue.ref(""),C=Vue.ref(""),w=Vue.ref(""),k=Vue.ref(""),y=Vue.ref(""),m=Vue.ref(!1),b=Vue.ref(""),T=Vue.ref(""),L=Vue.ref(""),N=Vue.ref(""),$=Vue.ref(""),D=Vue.ref(""),P=Vue.ref(!1),M=Vue.ref(!1),A=()=>{a.value="",e.error=null,b.value="email",T.value="",N.value="",$.value="",D.value="",L.value="",M.value=!1},R=()=>{b.value="",L.value="",M.value=!1},j=async()=>{if(a.value="",!T.value||!/.+@.+\..+/.test(T.value)){a.value=t("login.forgot.emailInvalid");return}P.value=!0;try{let B=await e.requestPasswordReset(T.value.trim());if(!B)return;L.value=B,b.value="verify"}finally{P.value=!1}},O=async()=>{if(a.value="",!N.value){a.value=t("login.error.enterVerifyCode");return}if(!$.value||$.value.length<6){a.value=t("login.error.passwordMinLen");return}if($.value!==D.value){a.value=t("login.error.passwordMismatch");return}P.value=!0;try{await e.verifyPasswordReset(L.value,N.value,$.value)&&(M.value=!0,setTimeout(()=>{R(),h.value="credentials"},1500))}finally{P.value=!1}},Y={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>'},te=Vue.computed(()=>["alipay","microsoft","github","google","wechat"].filter(H=>H==="microsoft"?e.aadEnabled:!!e.ssoProviders[H]).map(H=>({key:H,label:t(`login.${H}`),icon:Y[H]}))),he=()=>{c.value&&c.value.focus()},ce=()=>{h.value="credentials",Vue.nextTick(()=>{l.value&&l.value.focus()})},ke=()=>{let B=e.qrPanel;if(!B||!B.authorizeUrl)return;let H=`alipays://platformapi/startapp?appId=20000067&url=${encodeURIComponent(B.authorizeUrl)}`;window.location.href=H},ve=B=>{if(a.value="",B==="microsoft"){e.loginWithMicrosoft();return}if(B==="alipay"){Qr()?e.loginWithSso(B):js()?e.loginWithAlipayMobile():e.startSsoQr(B).then(H=>{H&&x()});return}if(B==="wechat"){if(js()||Gr()){a.value=t("login.wechat.mobileUnsupported");return}e.startSsoQr(B).then(H=>{H&&x()});return}e.loginWithSso(B)},ge=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()})},x=()=>{if(e.qrPanel&&typeof qrcode=="function")try{let B=qrcode(0,"M");B.addData(e.qrPanel.authorizeUrl,"Byte"),B.make(),g.value=B.createDataURL(6,4)}catch{}},K=Vue.computed(()=>{let B=e.qrPanel?.provider;return t(B==="alipay"?"login.qr.titleAlipay":B==="wechat"?"login.qr.titleWechat":"login.qr.title")});Vue.watch(()=>e.qrPanel?.authorizeUrl,B=>{B?x():g.value=""});let re=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()}))},ye=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()}))},W=async()=>{if(a.value="",m.value=!1,!C.value||C.value.length<2){a.value=t("login.error.usernameMinLen");return}if(!w.value||w.value.length<6){a.value=t("login.error.passwordMinLen");return}if(w.value!==k.value){a.value=t("login.error.passwordMismatch");return}await e.register(C.value,w.value,y.value||void 0,v.value)&&(m.value=!0,n.value=C.value,v.value="",C.value="",w.value="",k.value="",y.value="",setTimeout(()=>e.backToCredentials(),1500))},ne=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(),te.value.length===0&&h.value==="oauth"&&(h.value="credentials"),e.loginStep==="credentials"&&h.value==="credentials"&&l.value&&l.value.focus()}),Vue.watch(()=>e.loginStep,B=>{Vue.nextTick(()=>{B==="credentials"&&h.value==="credentials"&&l.value?l.value.focus():(B==="totp"||B==="totp-setup")&&u.value?u.value.focus():B==="verification"&&d.value?d.value.focus():B==="register"&&f.value&&f.value.focus()})}),{authStore:e,currentLocale:s,toggleLang:()=>{mn(s.value==="zh-CN"?"en":"zh-CN")},loginMode:h,switchToCredentials:ce,enabledProviders:te,handleProviderClick:ve,relaunchAlipayMobile:ke,qrCanvas:p,qrDataUrl:g,qrPanelTitle:K,username:n,password:r,verificationCode:i,totpCode:o,localError:a,usernameInput:l,passwordInput:c,codeInput:d,totpInput:u,regCodeInput:f,regInvitationCode:v,regUsername:C,regPassword:w,regPasswordConfirm:k,regEmail:y,registerSuccess:m,focusPassword:he,login:ge,verify:ne,verifyTotp:re,setupTotp:ye,doRegister:W,forgotStep:b,forgotEmail:T,forgotResetToken:L,forgotCode:N,forgotNewPassword:$,forgotConfirm:D,forgotLoading:P,forgotSuccess:M,enterForgotMode:A,exitForgotMode:R,submitForgotEmail:j,submitForgotReset:O}}}});var Xr,ya=F(()=>{Xr={name:"ChatHeader",emits:["toggle-sidebar","close-pane"],props:{conversationId:{type:String,default:null},paneId:{type:String,default:null},showClosePane:{type:Boolean,default:!1}},template:`
|
|
307
307
|
<header class="chat-header">
|
|
308
308
|
<!-- Mobile sidebar toggle \u2014 hidden on desktop and in split mode -->
|
|
309
309
|
<button class="header-sidebar-toggle" v-if="!store.isSplitMode"
|
|
@@ -405,7 +405,7 @@ The agent will restart after upgrading.`,"chat.agent.alreadyLatest":"Agent is al
|
|
|
405
405
|
</button>
|
|
406
406
|
</div>
|
|
407
407
|
</header>
|
|
408
|
-
`,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(x=>x.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=(x,K=!0)=>{let re=i.value;return re?!!re[x]:o.value?K:!1},l=Vue.computed(()=>a("compact")),c=Vue.computed(()=>a("clear")),d=Vue.computed(()=>a("expert")),u=Vue.computed(()=>a("mcp")),f=Vue.computed(()=>{if(!n.value)return"Yeaft";let x=t.getConversationTitle(n.value);if(x)return x;let re=t.conversations.find(ye=>ye.id===n.value)?.workDir||t.currentWorkDir;if(re){let ye=re.split(/[/\\]/);return ye[ye.length-1]||ye[ye.length-2]||re}return s("chatHeader.newConv")}),p=Vue.computed(()=>{if(!n.value)return"";let K=t.conversations.find(ye=>ye.id===n.value)?.agentId;return K&&t.agents.find(ye=>ye.id===K)?.name||""}),g=Vue.computed(()=>t.clearStatus?.conversationId===n.value?!0:t.compactStatus?t.compactStatus.conversationId===n.value:!1),
|
|
408
|
+
`,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(x=>x.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=(x,K=!0)=>{let re=i.value;return re?!!re[x]:o.value?K:!1},l=Vue.computed(()=>a("compact")),c=Vue.computed(()=>a("clear")),d=Vue.computed(()=>a("expert")),u=Vue.computed(()=>a("mcp")),f=Vue.computed(()=>{if(!n.value)return"Yeaft";let x=t.getConversationTitle(n.value);if(x)return x;let re=t.conversations.find(ye=>ye.id===n.value)?.workDir||t.currentWorkDir;if(re){let ye=re.split(/[/\\]/);return ye[ye.length-1]||ye[ye.length-2]||re}return s("chatHeader.newConv")}),p=Vue.computed(()=>{if(!n.value)return"";let K=t.conversations.find(ye=>ye.id===n.value)?.agentId;return K&&t.agents.find(ye=>ye.id===K)?.name||""}),g=Vue.computed(()=>t.clearStatus?.conversationId===n.value?!0:t.compactStatus?t.compactStatus.conversationId===n.value:!1),h=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"),C=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"):""),w=Vue.computed(()=>n.value&&(t.conversations.find(K=>K.id===n.value)?.workDir||t.currentWorkDir)||""),k=Vue.computed(()=>!t.contextUsage||t.contextUsage.conversationId!==n.value?null:t.contextUsage),y=Vue.computed(()=>{let x=k.value?.percentage||0;return x>=80?"context-danger":x>=50?"context-warn":"context-ok"}),m=Vue.computed(()=>{if(!k.value)return"";let x=(k.value.inputTokens/1e3).toFixed(0),K=(k.value.maxTokens/1e3).toFixed(0);return`Context: ${x}k / ${K}k`}),b=Vue.computed(()=>t.isRefreshingSession(n.value)),T=Vue.computed(()=>t.compactStatus?.status==="compacting"&&t.compactStatus?.conversationId===n.value),L=Vue.computed(()=>t.clearStatus?.status==="clearing"&&t.clearStatus?.conversationId===n.value),N=Vue.computed(()=>n.value?!t.isRefreshingSession(n.value):!1),$=()=>{t.isRefreshingSession(n.value)||!n.value||(t.setRefreshingSession(n.value,!0),t.startRefreshTimeout(n.value),t.processingConversations[n.value]||(t.messagesMap[n.value]=[]),t.requestChatHistory(n.value,{mode:"recent",turns:5}))},D=()=>{T.value||t.sendMessage("/compact")},P=()=>{window.location.reload()},M=()=>{L.value||confirm(s("chatHeader.confirmClear"))&&(t.clearStatus={conversationId:n.value,status:"clearing"},t.sendMessage("/clear"))},A=Vue.computed(()=>t.getPaneRightPanel(e.paneId)),R=Vue.ref(null),j=Vue.computed(()=>{if(!t.mcpPanelOpen||!R.value)return null;let x=R.value.getBoundingClientRect();return{top:`${x.bottom+6}px`,right:`${window.innerWidth-x.right}px`}}),O=Vue.computed(()=>t.currentMcpServers.filter(x=>x.enabled).length),Y=Vue.computed(()=>!!t.conversations.find(K=>K.id===n.value)?.needRestart),te=()=>{t.mcpPanelOpen=!t.mcpPanelOpen},he=()=>{t.togglePaneRightPanel("experts",e.paneId)},ce=()=>{t.togglePaneRightPanel("subagents",e.paneId)},ke=Vue.computed(()=>t.runningSubagentCount),ve=(x,K)=>{t.toggleConversationMcp(x,K)},ge=x=>{t.mcpPanelOpen&&!x.target.closest(".mcp-dropdown")&&!x.target.closest(".mcp-config-wrapper")&&(t.mcpPanelOpen=!1)};return Vue.onMounted(()=>{document.addEventListener("click",ge)}),Vue.onUnmounted(()=>{document.removeEventListener("click",ge)}),{store:t,effectiveConvId:n,effectiveRightPanel:A,isClaudeCode:o,canCompact:l,canClear:c,canExpert:d,canMcp:u,headerTitle:f,showStatusBanner:g,statusBannerClass:h,statusBannerSpinner:v,statusBannerMessage:C,contextUsage:k,contextColorClass:y,contextLabel:m,isRefreshing:b,isCompacting:T,isClearing:L,canRefresh:N,refreshSession:$,reloadPage:P,compactContext:D,clearMessages:M,mcpBtnRef:R,mcpDropdownStyle:j,mcpEnabledCount:O,currentConvNeedRestart:Y,toggleMcpPanel:te,toggleMcpServer:ve,toggleExpertPanel:he,toggleSubAgentPanel:ce,runningSubagentCount:ke}}}});function Fn(e=globalThis.location){let t=e?.protocol==="https:"?"wss:":"ws:",s=e?.host||"localhost";return`${t}//${s}`}function Zr(){return"npm install -g @yeaft/webchat-agent"}function Jr(){return"yeaft-agent llm use github-copilot --model gpt-5.5"}function ba(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 ei({profile:e=null,agentSecret:t="",serverWsUrl:s=Fn()}={}){if(!t)return"";let n=ba(e);return`yeaft-agent install --server ${s} --secret ${t} --name ${n}`}var wa=F(()=>{});function Us(e,{alt:t="Preview",closeLabel:s="Close",trigger:n=null}={}){if(!e)return;let r=document.createElement("div");r.className="image-preview-overlay",r.setAttribute("role","dialog"),r.setAttribute("aria-modal","true"),r.setAttribute("aria-label",t);let i=document.createElement("img");i.className="image-preview-img",i.src=e,i.alt=t;let o=document.createElement("button");o.type="button",o.className="image-preview-close",o.setAttribute("aria-label",s),o.textContent="\xD7",r.append(i,o),document.body.appendChild(r),r.offsetHeight,r.classList.add("visible"),o.focus();let a=!1,l=()=>r.remove(),c=()=>{a||(a=!0,r.classList.remove("visible"),r.addEventListener("transitionend",l,{once:!0}),setTimeout(l,250),document.removeEventListener("keydown",d),n?.isConnected&&typeof n.focus=="function"&&n.focus())},d=u=>{u.key==="Escape"&&c(),u.key==="Tab"&&(u.preventDefault(),o.focus())};o.addEventListener("click",c),r.addEventListener("click",u=>{u.target===r&&c()}),document.addEventListener("keydown",d)}var ti=F(()=>{});function fv(e){let t=[];for(let s of e)s==="\b"?t.pop():t.push(s);return t.join("")}function gv(e){let t=e.split("\r"),s=t[t.length-1]||"";return fv(s)}function Ou(e){return e.replace(/\r\n/g,`
|
|
409
409
|
`).split(`
|
|
410
410
|
`).map(t=>gv(t)).join(`
|
|
411
411
|
`)}function Hu(e){return e.replace(uv,"").replace(pv,"")}function mv(e){return e?e.split(";").filter(t=>t!=="").map(t=>Number(t)).filter(Number.isFinite):[0]}function Lu(e,t){let s=t==="bg"&&e>=30&&e<=37||t==="bg"&&e>=90&&e<=97?e+10:e;return t==="bg"?Ca.get(s):Ia.get(s)}function $u(e,t,s){let n=Aa[0],r=1/0;for(let i of Aa){let o=(i.r-e)**2+(i.g-t)**2+(i.b-s)**2;o<r&&(n=i,r=o)}return n.code}function hv(e){if(e<0||e>255)return null;if(e<16){let s=Aa[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:Sa[Math.floor(t/36)],g:Sa[Math.floor(t%36/6)],b:Sa[t%6]}}function Vu(e,t,s,n){let r=s[n+1];if(r===5){let i=s[n+2];if(Number.isFinite(i)){let o=hv(i);o&&(e[t]=Lu($u(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]=Lu($u(i,o,a),t)||""),n+5}return n+2}function vv(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(Ia.has(i))s.fg=Ia.get(i);else if(Ca.has(i))s.bg=Ca.get(i);else if(i===38){r=Vu(s,"fg",n,r);continue}else if(i===48){r=Vu(s,"bg",n,r);continue}r+=1}return s}function yv(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 Fu(e,t,s){let n=Hu(t);if(!n)return;let r=yv(s),i=e[e.length-1];i&&i.className===r?i.text+=n:e.push({text:n,className:r})}function _t(e){if(e==null)return"";let t=typeof e=="string"?e:String(e);return t?Hu(Ou(t)):""}function qu(e){if(e==null)return[];let t=typeof e=="string"?e:String(e);if(!t)return[];let s=Ou(t),n=[],r={fg:"",bg:"",bold:!1,dim:!1,italic:!1,underline:!1},i=0;ka.lastIndex=0;for(let o=ka.exec(s);o;o=ka.exec(s))Fu(n,s.slice(i,o.index),r),r=vv(r,mv(o[1])),i=o.index+o[0].length;return Fu(n,s.slice(i),r),n}var uv,ka,pv,Ia,Ca,Aa,Sa,On=F(()=>{uv=/[\u001b\u009b](?:[\[\]()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><~]|\][^\u0007]*(?:\u0007|\u001b\\)|[PX^_][\s\S]*?\u001b\\)/g,ka=/(?:\u001b\[|\u009b)([0-9;]*)m/g,pv=/[\u0000-\u0008\u000b\u000c\u000e-\u001a\u001c-\u001f\u007f-\u009f]/g,Ia=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"]]),Ca=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"]]),Aa=[{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}],Sa=[0,95,135,175,215,255]});var zs,si=F(()=>{ti();Rn();On();ds();zs={name:"MessageItem",props:{message:{type:Object,required:!0},sessionActions:{type:Boolean,default:!1}},emits:["quote","edit-as-new"],template:`
|
|
@@ -494,7 +494,7 @@ The agent will restart after upgrading.`,"chat.agent.alreadyLatest":"Agent is al
|
|
|
494
494
|
{{ displayContent }}
|
|
495
495
|
</template>
|
|
496
496
|
</div>
|
|
497
|
-
`,setup(e){let t=Pinia.useChatStore(),s=Vue.ref(!1),n=Vue.inject("t"),r=Vue.computed(()=>["message",e.message.type]),i=()=>{let
|
|
497
|
+
`,setup(e){let t=Pinia.useChatStore(),s=Vue.ref(!1),n=Vue.inject("t"),r=Vue.computed(()=>["message",e.message.type]),i=()=>{let v=e.message;return typeof v.timestamp=="number"&&v.timestamp>0?v.timestamp:typeof v.createdAt=="number"&&v.createdAt>0?v.createdAt:null},o=Vue.computed(()=>vt(i())),a=Vue.computed(()=>{let v=i();if(!v)return"";try{return new Date(v).toLocaleString()}catch{return""}}),l=Vue.computed(()=>_t(e.message.content||"")),c=Vue.computed(()=>Wd(e.message,n("message.you")));return{messageClass:r,messageTime:o,messageTimeFull:a,displayContent:l,userQuote:c,showAttachments:s,toggleAttachments:()=>{s.value=!s.value},previewAttachment:(v,C)=>{v?.preview&&Us(v.preview,{alt:v.name||n("message.imagePreview"),closeLabel:n("common.close"),trigger:C})},t:n,formatExpertLabel:v=>as(v,t.customExpertRoles),getAttachmentsText:v=>{if(!v||v.length===0)return"";let C=v.filter(y=>y.isImage).length,w=v.length-C,k=[];return C>0&&k.push(n("message.imageCount",{count:C})),w>0&&k.push(n("message.fileCount",{count:w})),k.join(n("common.comma"))},todoStatusSymbol:v=>v==="completed"?"\u2713":v==="in_progress"?"\u2192":"\u25CB",getFileIcon:v=>v?v.startsWith("image/")?"\u{1F5BC}\uFE0F":v.startsWith("video/")?"\u{1F3AC}":v.startsWith("audio/")?"\u{1F3B5}":v.includes("pdf")?"\u{1F4D5}":v.includes("word")||v.includes("document")?"\u{1F4DD}":v.includes("sheet")||v.includes("excel")?"\u{1F4CA}":v.includes("presentation")||v.includes("powerpoint")?"\u{1F4FD}\uFE0F":v.includes("zip")||v.includes("compressed")||v.includes("archive")?"\u{1F4E6}":v.includes("text")||v.includes("json")||v.includes("xml")?"\u{1F4C3}":"\u{1F4C4}":"\u{1F4C4}"}}}});function xa(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 Nu(e,t=s=>s){let s=xa(e);return s.text?`Route ${s.target}: ${t(s.text,70)}`:`Route ${s.target}`}var Ta=F(()=>{});var ni,Ma=F(()=>{On();ni={name:"TerminalOutput",props:{content:{default:""}},template:`
|
|
498
498
|
<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>
|
|
499
499
|
`,setup(e){return{tokens:Vue.computed(()=>qu(e.content))}}}});var ri,Pa=F(()=>{Ta();On();Ma();ri={name:"ToolLine",components:{TerminalOutput:ni},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:`
|
|
500
500
|
<div>
|
|
@@ -533,9 +533,9 @@ The agent will restart after upgrading.`,"chat.agent.alreadyLatest":"Agent is al
|
|
|
533
533
|
</div>
|
|
534
534
|
`,setup(e,{emit:t}){let s=Vue.ref(e.toolName==="Edit"),n=Vue.computed(()=>e.expanded===null?s.value:!!e.expanded),r=m=>{s.value=!!m,t("update:expanded",!!m)},i=Vue.computed(()=>{if(!e.startTime)return"";let m=new Date(e.startTime),b=m.getHours().toString().padStart(2,"0"),T=m.getMinutes().toString().padStart(2,"0"),L=m.getSeconds().toString().padStart(2,"0");return`${b}:${T}:${L}`}),o=Vue.computed(()=>e.toolName==="Edit"),a=Vue.computed(()=>{let m=e.toolInput;return m&&m.old_string!==void 0&&m.new_string!==void 0}),l=Vue.computed(()=>{let m=e.toolInput;return m?e.toolName==="Edit"?a.value:e.toolName==="Bash"?!!(m.command?.length>60||e.hasResult):e.toolName==="Read"?!!m.file_path:e.toolName==="Write"?!!m.content:Object.keys(m).length>0:!1}),c=m=>{if(!m)return"";if(typeof m=="string")return m;if(Array.isArray(m))return m.map(b=>typeof b=="string"?b:b?.type==="text"?b.text:"").filter(Boolean).join(`
|
|
535
535
|
`);if(m?.type==="text"&&m?.text)return m.text;if(m?.content){if(typeof m.content=="string")return m.content;if(Array.isArray(m.content))return m.content.map(b=>typeof b=="string"?b:b?.type==="text"?b.text:"").filter(Boolean).join(`
|
|
536
|
-
`)}return""},d=Vue.computed(()=>e.toolName!=="Bash"?"":c(e.toolResult)),u=Vue.computed(()=>e.toolName!=="__SubagentResult"?"":_t(e.toolInput?.result||e.toolInput?.summary||y(e.toolInput))),f=Vue.computed(()=>e.toolName!=="__CompactSummary"?"":_t(e.toolInput?.summary||y(e.toolInput))),p=()=>{l.value&&r(!n.value)},g=(m,b=80)=>{if(!m||m.length<=b)return m||"";let T=Math.ceil(b*.6),L=b-T-3;return m.slice(0,T)+"..."+m.slice(-L)},
|
|
536
|
+
`)}return""},d=Vue.computed(()=>e.toolName!=="Bash"?"":c(e.toolResult)),u=Vue.computed(()=>e.toolName!=="__SubagentResult"?"":_t(e.toolInput?.result||e.toolInput?.summary||y(e.toolInput))),f=Vue.computed(()=>e.toolName!=="__CompactSummary"?"":_t(e.toolInput?.summary||y(e.toolInput))),p=()=>{l.value&&r(!n.value)},g=(m,b=80)=>{if(!m||m.length<=b)return m||"";let T=Math.ceil(b*.6),L=b-T-3;return m.slice(0,T)+"..."+m.slice(-L)},h=m=>({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}"})[m]||"\u2699\uFE0F",v=m=>_t(m).replace(/\s+/g," ").trim(),C=(m,b)=>{if(!b)return m;if(m==="Read"&&b.file_path){let T=`Read ${b.file_path}`;if(b.offset||b.limit){let L=(b.offset||0)+1,N=b.limit?L+b.limit-1:"\u221E";T+=`:${L}-${N}`}return T}if(m==="Edit"&&b.file_path)return`Edit ${b.file_path}`;if(m==="Write"&&b.file_path)return`Write ${b.file_path}`;if(m==="Bash"&&b.command){let T=b.command;return g(T,80)}if(m==="Glob"&&b.pattern)return`Glob ${b.pattern}`+(b.path?` in ${b.path}`:"");if(m==="Grep"&&b.pattern){let T=`Grep "${b.pattern}"`;return b.path&&(T+=` in ${b.path}`),b.glob&&(T+=` (${b.glob})`),T}if(m==="Task"){let T=b.subagent_type||"agent",L=b.description||g(b.prompt||"",40);return`Task [${T}]: ${L}`}if(m==="WebFetch"&&b.url)try{let T=new URL(b.url);return`Fetch ${T.hostname}${T.pathname.length>20?g(T.pathname,20):T.pathname}`}catch{return`Fetch ${b.url.slice(0,50)}`}if(m==="WebSearch"&&b.query)return`Search "${b.query}"`;if(m==="TodoWrite"&&b.todos)return`Todo: ${b.todos.filter(L=>L.status==="completed").length}/${b.todos.length} done`;if(m==="RouteForward")return Nu(b,g);if(m==="__SubagentResult"){let T=v(b.summary||b.status||"completed");return`Sub-agent: ${g(T,80)}`}return m==="__CompactSummary"?`Context summarized (${_t(b.summary||"").length} chars)`:m},w=m=>{let b=document.createElement("div");return b.textContent=m,b.innerHTML},k=m=>{if(!m||m.old_string===void 0||m.new_string===void 0)return"";let b='<div class="diff-compact">';return m.old_string.split(`
|
|
537
537
|
`).forEach(T=>{b+=`<div class="diff-line del">- ${w(T)}</div>`}),m.new_string.split(`
|
|
538
|
-
`).forEach(T=>{b+=`<div class="diff-line add">+ ${w(T)}</div>`}),b+="</div>",b},y=m=>{try{return JSON.stringify(m,null,2)}catch{return String(m)}};return{isExpanded:n,isEditTool:o,hasDiff:a,hasExpandableContent:l,bashOutput:d,syntheticResultOutput:u,compactSummaryOutput:f,formattedTime:i,toggle:p,getToolIcon:
|
|
538
|
+
`).forEach(T=>{b+=`<div class="diff-line add">+ ${w(T)}</div>`}),b+="</div>",b},y=m=>{try{return JSON.stringify(m,null,2)}catch{return String(m)}};return{isExpanded:n,isEditTool:o,hasDiff:a,hasExpandableContent:l,bashOutput:d,syntheticResultOutput:u,compactSummaryOutput:f,formattedTime:i,toggle:p,getToolIcon:h,getToolOneLine:C,renderDiff:k,formatInput:y}}}});var Bu,Wu=F(()=>{Bu={name:"AskCard",props:{askMsg:{type:Object,required:!0},compact:{type:Boolean,default:!1}},emits:["submit"],template:`
|
|
539
539
|
<div class="ask-card-wrapper">
|
|
540
540
|
<!-- Collapsed summary after submission; history later confirms the answer. -->
|
|
541
541
|
<div v-if="isAnswered" class="ask-summary">
|
|
@@ -618,7 +618,7 @@ The agent will restart after upgrading.`,"chat.agent.alreadyLatest":"Agent is al
|
|
|
618
618
|
</div>
|
|
619
619
|
</div>
|
|
620
620
|
</div>
|
|
621
|
-
`,setup(e,{emit:t}){let s=Vue.reactive({}),n=Vue.reactive({}),r=Vue.computed(()=>{let p=e.askMsg;return p&&(!!p.askAnswered||!!p.selectedAnswers||!!p.askPending)}),i=Vue.computed(()=>{let p=e.askMsg;return p?!!p.askExpired||!p.askRequestId&&!p.askAnswered&&!p.selectedAnswers&&!!p.isHistory:!1}),o=Vue.computed(()=>{let p=e.askMsg;return p?.askQuestions||p?.toolInput?.questions||[]}),a=(p,g)=>{let
|
|
621
|
+
`,setup(e,{emit:t}){let s=Vue.reactive({}),n=Vue.reactive({}),r=Vue.computed(()=>{let p=e.askMsg;return p&&(!!p.askAnswered||!!p.selectedAnswers||!!p.askPending)}),i=Vue.computed(()=>{let p=e.askMsg;return p?!!p.askExpired||!p.askRequestId&&!p.askAnswered&&!p.selectedAnswers&&!!p.isHistory:!1}),o=Vue.computed(()=>{let p=e.askMsg;return p?.askQuestions||p?.toolInput?.questions||[]}),a=(p,g)=>{let h=s[p];return Array.isArray(h)?h.includes(g):h===g},l=(p,g)=>{if(!r.value)if(n[p.question]="",p.multiSelect){let h=s[p.question]||[],v=Array.isArray(h)?[...h]:[],C=v.indexOf(g.label);C>=0?v.splice(C,1):v.push(g.label),s[p.question]=v}else s[p.question]=g.label},c=(p,g)=>{n[p]=g,g&&delete s[p]},d=Vue.computed(()=>{let p=o.value;return!p||p.length===0?!1:p.some(g=>{let h=s[g.question];return n[g.question]?!0:Array.isArray(h)?h.length>0:!!h})}),u=()=>{if(r.value||e.askMsg.askPending||!d.value)return;let p=o.value,g={};for(let v of p){let C=n[v.question];if(C)g[v.question]=C;else{let w=s[v.question];Array.isArray(w)&&w.length>0?g[v.question]=w.join(", "):w&&(g[v.question]=w)}}let h=e.askMsg.askRequestId;h&&t("submit",h,g)},f=Vue.computed(()=>{let p=e.askMsg?.selectedAnswers||e.askMsg?.pendingAnswers;return p?Object.values(p).filter(h=>h&&h!=="-").join(", "):""});return{isAnswered:r,isExpired:i,questions:o,isOptionSelected:a,selectOption:l,setCustomAnswer:c,customAnswers:n,hasAnySelection:d,submitAnswers:u,summaryText:f}}}});var ju,Uu=F(()=>{Ws();ju={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:`
|
|
622
622
|
<span class="vp-badge" :class="{ compact }">
|
|
623
623
|
<span class="vp-badge-text">
|
|
624
624
|
<span class="vp-badge-name" :style="nameStyle">{{ displayName }}</span>
|
|
@@ -655,7 +655,7 @@ The agent will restart after upgrading.`,"chat.agent.alreadyLatest":"Agent is al
|
|
|
655
655
|
:title="$t ? $t('yeaft.vp.speaker.stop') : 'Stop'"
|
|
656
656
|
><svg viewBox="0 0 24 24" width="14" height="14"><rect x="6" y="6" width="12" height="12" rx="2" fill="currentColor"/></svg></button>
|
|
657
657
|
</div>
|
|
658
|
-
`,setup(e){let t=gs(),s=Vue.computed(()=>t.isVpTypingInCurrentConv(e.vpId)),n=Vue.computed(()=>vt(e.timestamp)),r=Vue.computed(()=>{if(!e.timestamp)return"";try{return new Date(e.timestamp).toLocaleString()}catch{return""}});return{isTyping:s,timestampText:n,timestampFullText:r}}}});function zu(e,t){let s=t?.status||"pending",n=!!e&&e.isStreaming!==!0,i=s==="in_progress"&&n?"stopped":s;return{...t,rawStatus:s,displayStatus:i,displayText:i==="in_progress"?t?.activeForm||t?.content||"":t?.content||""}}var Ku=F(()=>{});function _a(e,t){return`${String(e||"mermaid-diagram").replace(/[^a-z0-9_-]+/gi,"-").replace(/^-+|-+$/g,"")||"mermaid-diagram"}.${t}`}function wv(e){if(typeof document>"u")return String(e||"").replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'");let t=document.createElement("textarea");return t.innerHTML=String(e||""),t.value}function kv(e,t){return e!=="mermaid"?"":` data-mermaid-source="${encodeURIComponent(wv(t))}"`}function Sv(e){let t=e?.dataset?.mermaidSource;if(!t)return"";try{return decodeURIComponent(t)}catch{return""}}function Xu(e,t){let s=document.createElement("a");s.href=e,s.download=t,document.body.appendChild(s),s.click(),s.remove()}function Zu(e,t){let s=URL.createObjectURL(e);Xu(s,t),setTimeout(()=>URL.revokeObjectURL(s),0)}function Iv(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 Ju(e,t){return typeof getComputedStyle>"u"||typeof document>"u"?t:getComputedStyle(document.documentElement).getPropertyValue(e).trim()||t}function Cv(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 Av(e,t,s,n){if(!window.htmlToImage)return!1;let r=_a("mermaid-diagram",t==="jpg"?"jpg":"png"),i={backgroundColor:Ju("--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 Xu(o,r),!0}async function Qu(e,t){let s=e.querySelector("svg");if(!s)throw new Error("No Mermaid SVG found");let{width:n,height:r}=Iv(s);try{if(await Av(s,t,n,r))return}catch{}let i=s.cloneNode(!0);Cv(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((
|
|
658
|
+
`,setup(e){let t=gs(),s=Vue.computed(()=>t.isVpTypingInCurrentConv(e.vpId)),n=Vue.computed(()=>vt(e.timestamp)),r=Vue.computed(()=>{if(!e.timestamp)return"";try{return new Date(e.timestamp).toLocaleString()}catch{return""}});return{isTyping:s,timestampText:n,timestampFullText:r}}}});function zu(e,t){let s=t?.status||"pending",n=!!e&&e.isStreaming!==!0,i=s==="in_progress"&&n?"stopped":s;return{...t,rawStatus:s,displayStatus:i,displayText:i==="in_progress"?t?.activeForm||t?.content||"":t?.content||""}}var Ku=F(()=>{});function _a(e,t){return`${String(e||"mermaid-diagram").replace(/[^a-z0-9_-]+/gi,"-").replace(/^-+|-+$/g,"")||"mermaid-diagram"}.${t}`}function wv(e){if(typeof document>"u")return String(e||"").replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'");let t=document.createElement("textarea");return t.innerHTML=String(e||""),t.value}function kv(e,t){return e!=="mermaid"?"":` data-mermaid-source="${encodeURIComponent(wv(t))}"`}function Sv(e){let t=e?.dataset?.mermaidSource;if(!t)return"";try{return decodeURIComponent(t)}catch{return""}}function Xu(e,t){let s=document.createElement("a");s.href=e,s.download=t,document.body.appendChild(s),s.click(),s.remove()}function Zu(e,t){let s=URL.createObjectURL(e);Xu(s,t),setTimeout(()=>URL.revokeObjectURL(s),0)}function Iv(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 Ju(e,t){return typeof getComputedStyle>"u"||typeof document>"u"?t:getComputedStyle(document.documentElement).getPropertyValue(e).trim()||t}function Cv(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 Av(e,t,s,n){if(!window.htmlToImage)return!1;let r=_a("mermaid-diagram",t==="jpg"?"jpg":"png"),i={backgroundColor:Ju("--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 Xu(o,r),!0}async function Qu(e,t){let s=e.querySelector("svg");if(!s)throw new Error("No Mermaid SVG found");let{width:n,height:r}=Iv(s);try{if(await Av(s,t,n,r))return}catch{}let i=s.cloneNode(!0);Cv(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,C)=>{c.onload=v,c.onerror=()=>C(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)),f=document.createElement("canvas");f.width=Math.ceil(n*u),f.height=Math.ceil(r*u);let p=f.getContext("2d");if(!p)throw new Error("Canvas is not available");p.scale(u,u),t==="jpg"&&(p.fillStyle=Ju("--bg-main","white"),p.fillRect(0,0,n,r)),p.drawImage(c,0,0,n,r);let g=t==="jpg"?"image/jpeg":"image/png",h=await new Promise((v,C)=>{f.toBlob(w=>w?v(w):C(new Error("Failed to export Mermaid image")),g,.92)});Zu(h,_a("mermaid-diagram",t==="jpg"?"jpg":"png"))}finally{URL.revokeObjectURL(l)}}function xv(e){let t=`\`\`\`mermaid
|
|
659
659
|
${String(e||"").trim()}
|
|
660
660
|
\`\`\`
|
|
661
661
|
`;Zu(new Blob([t],{type:"text/markdown;charset=utf-8"}),_a("mermaid-diagram","md"))}function Tv(e,t){let s=document.createElement("div");s.className="mermaid-export-controls",s.setAttribute("aria-label",Ee("mermaid.export"));let n=[{label:Ee("mermaid.exportMd"),action:()=>xv(t)},{label:Ee("mermaid.exportPng"),action:()=>Qu(e,"png")},{label:Ee("mermaid.exportJpg"),action:()=>Qu(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 Mv(){Yu||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}),Yu=!0)}function Pv(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=kv(i,n);return`<div class="code-block-wrapper">
|
|
@@ -857,7 +857,7 @@ ${String(e||"").trim()}
|
|
|
857
857
|
<!-- H2.f.6: Fork-from-here button removed (single-conversation model). -->
|
|
858
858
|
</div>
|
|
859
859
|
</div>
|
|
860
|
-
`,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.inject("t"),f=(W,ne)=>{s.answerUserQuestion(W,ne,e.conversationId||void 0)},p=Vue.computed(()=>(Array.isArray(e.turn?.toolMsgs)?e.turn.toolMsgs:[]).filter(ne=>ne?.toolName==="RouteForward").map((ne,U)=>({...xa(ne.toolInput||{}),key:ne.toolId||`${ne.startTime||0}:${U}`}))),g=Vue.computed(()=>(Array.isArray(e.turn?.toolMsgs)?e.turn.toolMsgs:[]).filter(ne=>ne?.toolName!=="RouteForward")),
|
|
860
|
+
`,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.inject("t"),f=(W,ne)=>{s.answerUserQuestion(W,ne,e.conversationId||void 0)},p=Vue.computed(()=>(Array.isArray(e.turn?.toolMsgs)?e.turn.toolMsgs:[]).filter(ne=>ne?.toolName==="RouteForward").map((ne,U)=>({...xa(ne.toolInput||{}),key:ne.toolId||`${ne.startTime||0}:${U}`}))),g=Vue.computed(()=>(Array.isArray(e.turn?.toolMsgs)?e.turn.toolMsgs:[]).filter(ne=>ne?.toolName!=="RouteForward")),h=Vue.computed(()=>g.value.length>0||Number(e.turn.toolSummaryCount||0)>0),v=Vue.computed(()=>{let W=g.value;return W[W.length-1]}),C=Vue.computed(()=>g.value.slice(0,-1)),w=Vue.computed(()=>Math.max(0,g.value.length-1)),k=Vue.computed(()=>{let W=Number(e.turn.toolSummaryCount||0);return W?typeof u=="function"?u("chat.toolActionsOmitted",{count:W}):`${W} older tool actions omitted`:""}),y=Vue.computed(()=>{let W=e.turn?.todoMsg?.toolInput?.todos;return Array.isArray(W)?W.map(ne=>zu(e.turn,ne)):[]}),m=()=>{a(!o.value)},b=(W,ne,U)=>{let B=e.toolStatePrefix||e.turn.id||e.turn.turnId||"assistant-turn",H=W?.toolName||"tool",_=W?.startTime||ne;return`${B}:tool:${U}:${ne}:${H}:${_}`},T=(W,ne,U)=>{let B=b(W,ne,U);return e.toolExpandStates&&Object.prototype.hasOwnProperty.call(e.toolExpandStates,B)?!!e.toolExpandStates[B]:null},L=(W,ne,U,B)=>{t("update-tool-expanded",{key:b(W,ne,U),value:!!B})};typeof marked<"u"&&marked.setOptions({highlight:function(W,ne){if(typeof hljs<"u"&&ne&&hljs.getLanguage(ne))try{return hljs.highlight(W,{language:ne}).value}catch{}return W},breaks:!0,gfm:!0});let $=W=>{let ne=W;if(typeof ne!="string"&&(Array.isArray(ne)?ne=ne.map(U=>typeof U=="string"?U:U&&U.type==="text"&&U.text||"").join(""):ne=String(ne)),ne=_t(ne),!ne)return"";try{if(typeof marked<"u"){let U=marked.parse(ne);return R(A(U))}}catch{}return j(ne)},D=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}]:[]),P=Vue.computed(()=>D.value.filter(W=>W.kind!=="result")),M=Vue.computed(()=>D.value.filter(W=>W.kind==="result")),A=W=>W.replace(/<pre><code([^>]*)>([\s\S]*?)<\/code><\/pre>/g,(ne,U,B)=>{let H=U.match(/class="language-(\w+)"/);return`<div class="code-block-wrapper">
|
|
861
861
|
<div class="code-block-header">
|
|
862
862
|
<span class="code-lang">${H?H[1]:""}</span>
|
|
863
863
|
<button class="code-copy-btn" onclick="window.copyCodeBlock(this)" title="Copy">
|
|
@@ -867,7 +867,7 @@ ${String(e||"").trim()}
|
|
|
867
867
|
</button>
|
|
868
868
|
</div>
|
|
869
869
|
<pre><code${U}>${B}</code></pre>
|
|
870
|
-
</div>`}),R=W=>W.replace(/<table>([\s\S]*?)<\/table>/g,ne=>`<div class="table-scroll-wrapper">${ne}</div>`),j=W=>{if(!W)return"";typeof W!="string"&&(W=String(W));let ne=U=>{let B=document.createElement("div");return B.textContent=U,B.innerHTML};return W.replace(/```(\w*)\n([\s\S]*?)```/g,(U,B,H)=>`<div class="code-block-wrapper"><pre><code class="language-${B}">${ne(H.trim())}</code></pre></div>`).replace(/`([^`]+)`/g,"<code>$1</code>").replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>").replace(/\*([^*]+)\*/g,"<em>$1</em>").replace(/^### (.+)$/gm,"<h3>$1</h3>").replace(/^## (.+)$/gm,"<h2>$1</h2>").replace(/^# (.+)$/gm,"<h1>$1</h1>").replace(/\n/g,"<br>")},O=async()=>{try{await navigator.clipboard.writeText(e.turn.textContent||""),n.value=!0,setTimeout(()=>{n.value=!1},2e3)}catch{}},Y=async()=>{try{await navigator.clipboard.writeText(e.turn.textContent||""),r.value=!0,setTimeout(()=>{r.value=!1},2e3)}catch{}},te=()=>{let W=e.turn.textContent||"";if(!W)return;let ne=new Blob([W],{type:"text/markdown;charset=utf-8"}),U=URL.createObjectURL(ne),B=document.createElement("a");B.download=`response-${Date.now()}.md`,B.href=U,B.click(),URL.revokeObjectURL(U)},he=async()=>{if(!(l.value||!window.htmlToImage)){l.value=!0;try{let W=c.value;if(!W)return;let ne=W.querySelector(".turn-content");if(!ne)return;let U=getComputedStyle(document.body).getPropertyValue("--bg-main").trim()||"#ffffff";ne.classList.add("screenshot-mode");try{let H=ne.getBoundingClientRect(),_=await window.htmlToImage.toPng(ne,{backgroundColor:U,pixelRatio:3,width:H.width+64,height:H.height+64,style:{padding:"32px"},filter:se=>!(se.classList&&(se.classList.contains("turn-header")||se.classList.contains("screenshot-btn")))}),J=document.createElement("a");J.download=`response-${Date.now()}.png`,J.href=_,J.click()}finally{ne.classList.remove("screenshot-mode")}}catch{}finally{l.value=!1}}};Vue.onMounted(()=>{window.copyCodeBlock||(window.copyCodeBlock=async function(W){let U=W.closest(".code-block-wrapper").querySelector("code");if(U)try{await navigator.clipboard.writeText(U.textContent),W.innerHTML='<svg viewBox="0 0 24 24" width="14" height="14"><path fill="currentColor" d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"/></svg>',setTimeout(()=>{W.innerHTML='<svg viewBox="0 0 24 24" width="14" height="14"><path fill="currentColor" d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg>'},2e3)}catch{}}),Vue.nextTick(()=>{typeof hljs<"u"&&document.querySelectorAll("pre code:not([data-highlighted])").forEach(W=>{hljs.highlightElement(W),W.dataset.highlighted="true"}),Ye(c.value)})}),Vue.watch(()=>e.turn.textContent,()=>{Vue.nextTick(()=>{typeof hljs<"u"&&document.querySelectorAll("pre code:not([data-highlighted])").forEach(W=>{hljs.highlightElement(W),W.dataset.highlighted="true"}),Ye(c.value)})});let ce=W=>{if(W?.src)return W.src;if(!W?.fileId)return"";let ne=W.previewToken||"";return`/api/preview/${W.fileId}?token=${ne}`},ke=W=>{d.add(W?.assetId||W?.id)},ve=(W,ne)=>{let U=ce(W);U&&Us(U,{alt:W?.filename||u("message.imagePreview"),closeLabel:u("common.close"),trigger:ne})},ge=W=>{if(W)try{typeof s.cancelVpTurn=="function"&&s.cancelVpTurn(W)}catch{}},x=()=>{let W=e.turn;return W?typeof W.timestamp=="number"&&W.timestamp>0?W.timestamp:typeof W.createdAt=="number"&&W.createdAt>0?W.createdAt:typeof W.speakerTimestamp=="number"&&W.speakerTimestamp>0?W.speakerTimestamp:null:null},K=Vue.computed(()=>vt(x())),re=Vue.computed(()=>{let W=x();if(!W)return"";try{return new Date(W).toLocaleString()}catch{return""}}),ye=Vue.computed(()=>jd(e.turn,e.quoteAuthor||u("message.assistant")));return{onStopTurn:ge,turnTime:K,turnTimeFull:re,assistantQuote:ye,copied:n,fullCopied:r,expanded:o,screenshotting:l,turnRef:c,showToolActions:
|
|
870
|
+
</div>`}),R=W=>W.replace(/<table>([\s\S]*?)<\/table>/g,ne=>`<div class="table-scroll-wrapper">${ne}</div>`),j=W=>{if(!W)return"";typeof W!="string"&&(W=String(W));let ne=U=>{let B=document.createElement("div");return B.textContent=U,B.innerHTML};return W.replace(/```(\w*)\n([\s\S]*?)```/g,(U,B,H)=>`<div class="code-block-wrapper"><pre><code class="language-${B}">${ne(H.trim())}</code></pre></div>`).replace(/`([^`]+)`/g,"<code>$1</code>").replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>").replace(/\*([^*]+)\*/g,"<em>$1</em>").replace(/^### (.+)$/gm,"<h3>$1</h3>").replace(/^## (.+)$/gm,"<h2>$1</h2>").replace(/^# (.+)$/gm,"<h1>$1</h1>").replace(/\n/g,"<br>")},O=async()=>{try{await navigator.clipboard.writeText(e.turn.textContent||""),n.value=!0,setTimeout(()=>{n.value=!1},2e3)}catch{}},Y=async()=>{try{await navigator.clipboard.writeText(e.turn.textContent||""),r.value=!0,setTimeout(()=>{r.value=!1},2e3)}catch{}},te=()=>{let W=e.turn.textContent||"";if(!W)return;let ne=new Blob([W],{type:"text/markdown;charset=utf-8"}),U=URL.createObjectURL(ne),B=document.createElement("a");B.download=`response-${Date.now()}.md`,B.href=U,B.click(),URL.revokeObjectURL(U)},he=async()=>{if(!(l.value||!window.htmlToImage)){l.value=!0;try{let W=c.value;if(!W)return;let ne=W.querySelector(".turn-content");if(!ne)return;let U=getComputedStyle(document.body).getPropertyValue("--bg-main").trim()||"#ffffff";ne.classList.add("screenshot-mode");try{let H=ne.getBoundingClientRect(),_=await window.htmlToImage.toPng(ne,{backgroundColor:U,pixelRatio:3,width:H.width+64,height:H.height+64,style:{padding:"32px"},filter:se=>!(se.classList&&(se.classList.contains("turn-header")||se.classList.contains("screenshot-btn")))}),J=document.createElement("a");J.download=`response-${Date.now()}.png`,J.href=_,J.click()}finally{ne.classList.remove("screenshot-mode")}}catch{}finally{l.value=!1}}};Vue.onMounted(()=>{window.copyCodeBlock||(window.copyCodeBlock=async function(W){let U=W.closest(".code-block-wrapper").querySelector("code");if(U)try{await navigator.clipboard.writeText(U.textContent),W.innerHTML='<svg viewBox="0 0 24 24" width="14" height="14"><path fill="currentColor" d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"/></svg>',setTimeout(()=>{W.innerHTML='<svg viewBox="0 0 24 24" width="14" height="14"><path fill="currentColor" d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg>'},2e3)}catch{}}),Vue.nextTick(()=>{typeof hljs<"u"&&document.querySelectorAll("pre code:not([data-highlighted])").forEach(W=>{hljs.highlightElement(W),W.dataset.highlighted="true"}),Ye(c.value)})}),Vue.watch(()=>e.turn.textContent,()=>{Vue.nextTick(()=>{typeof hljs<"u"&&document.querySelectorAll("pre code:not([data-highlighted])").forEach(W=>{hljs.highlightElement(W),W.dataset.highlighted="true"}),Ye(c.value)})});let ce=W=>{if(W?.src)return W.src;if(!W?.fileId)return"";let ne=W.previewToken||"";return`/api/preview/${W.fileId}?token=${ne}`},ke=W=>{d.add(W?.assetId||W?.id)},ve=(W,ne)=>{let U=ce(W);U&&Us(U,{alt:W?.filename||u("message.imagePreview"),closeLabel:u("common.close"),trigger:ne})},ge=W=>{if(W)try{typeof s.cancelVpTurn=="function"&&s.cancelVpTurn(W)}catch{}},x=()=>{let W=e.turn;return W?typeof W.timestamp=="number"&&W.timestamp>0?W.timestamp:typeof W.createdAt=="number"&&W.createdAt>0?W.createdAt:typeof W.speakerTimestamp=="number"&&W.speakerTimestamp>0?W.speakerTimestamp:null:null},K=Vue.computed(()=>vt(x())),re=Vue.computed(()=>{let W=x();if(!W)return"";try{return new Date(W).toLocaleString()}catch{return""}}),ye=Vue.computed(()=>jd(e.turn,e.quoteAuthor||u("message.assistant")));return{onStopTurn:ge,turnTime:K,turnTimeFull:re,assistantQuote:ye,copied:n,fullCopied:r,expanded:o,screenshotting:l,turnRef:c,showToolActions:h,latestTool:v,historyTools:C,latestToolIndex:w,actionTools:g,routeMessages:p,toolSummaryLabel:k,toggleExpand:m,toolExpandedValue:T,updateToolExpanded:L,textSegments:D,progressSegments:P,resultSegments:M,renderSegment:$,copyContent:O,copyFullResponse:Y,exportMarkdown:te,screenshotContent:he,onAskSubmit:f,imageSrc:ce,failedImages:d,handleImageError:ke,previewImage:ve,displayedTodos:y}}}});function ep(e){if(!Number.isFinite(e)||e<0)return"";let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let s=Math.floor(t/60),n=t%60,r=String(n).padStart(2,"0");if(s<60)return`${s}:${r}`;let i=Math.floor(s/60),o=s%60;return`${i}:${String(o).padStart(2,"0")}:${r}`}var tp=F(()=>{});var sp,np=F(()=>{ai();Wr();Ws();tp();ds();sp={name:"VpTurnBlock",components:{AssistantTurn:Ks},props:{turn:{type:Object,required:!0},conversationId:{type:String,default:null},nowMs:{type:Number,default:0},responseCollapsible:{type:Boolean,default:!1},responseCollapsed:{type:Boolean,default:!1},responseToggleLabel:{type:String,default:""}},emits:["toggle-response-collapse","quote"],template:`
|
|
871
871
|
<div class="vp-turn-block"
|
|
872
872
|
:class="{ 'vp-turn-block-streaming': turn.isStreaming }"
|
|
873
873
|
:data-turn-id="turn.turnId || ''"
|
|
@@ -942,7 +942,7 @@ ${String(e||"").trim()}
|
|
|
942
942
|
/>
|
|
943
943
|
</div>
|
|
944
944
|
</div>
|
|
945
|
-
`,setup(e){let t=gs(),s=yt(),n=Vue.getCurrentInstance(),r=n&&n.appContext.config.globalProperties.$t||(g=>g),i=Vue.computed(()=>{let g=e.turn&&e.turn.speakerVpId;return g?s.vpLabel(g)||g:""}),o=Vue.computed(()=>{let g=e.turn&&e.turn.speakerVpId;return!g||typeof s.vpTextColor!="function"?{}:{color:s.vpTextColor(g)}}),a=()=>{let g=e.turn&&e.turn.turnId;if(g)try{typeof t.cancelVpTurn=="function"&&t.cancelVpTurn(g)}catch{}},l=Vue.computed(()=>{let g=e.turn&&e.turn.speakerVpId;return g?t.isVpTypingInCurrentConv(g):!1}),c=Vue.computed(()=>!!(e.turn&&e.turn.isStreaming&&e.turn.turnId)),d=Vue.computed(()=>vt(e.turn.speakerTimestamp)),u=Vue.computed(()=>{let g=e.turn.speakerTimestamp;if(!g)return"";let
|
|
945
|
+
`,setup(e){let t=gs(),s=yt(),n=Vue.getCurrentInstance(),r=n&&n.appContext.config.globalProperties.$t||(g=>g),i=Vue.computed(()=>{let g=e.turn&&e.turn.speakerVpId;return g?s.vpLabel(g)||g:""}),o=Vue.computed(()=>{let g=e.turn&&e.turn.speakerVpId;return!g||typeof s.vpTextColor!="function"?{}:{color:s.vpTextColor(g)}}),a=()=>{let g=e.turn&&e.turn.turnId;if(g)try{typeof t.cancelVpTurn=="function"&&t.cancelVpTurn(g)}catch{}},l=Vue.computed(()=>{let g=e.turn&&e.turn.speakerVpId;return g?t.isVpTypingInCurrentConv(g):!1}),c=Vue.computed(()=>!!(e.turn&&e.turn.isStreaming&&e.turn.turnId)),d=Vue.computed(()=>vt(e.turn.speakerTimestamp)),u=Vue.computed(()=>{let g=e.turn.speakerTimestamp;if(!g)return"";let h=new Date(g);return Number.isNaN(h.getTime())?"":h.toLocaleString()}),f=Vue.computed(()=>{let g=e.turn.speakerTimestamp;if(!g||!e.nowMs)return"";let h=e.nowMs-g;return h<0?"":ep(h)}),p=Vue.computed(()=>{let g=e.turn&&e.turn.turnId,h=g?Object.values(t.activeVpTurns||{}).find(k=>k?.turnId===g&&(!t.currentAgent||!k?.agentId||k.agentId===t.currentAgent))||t.activeVpTurns?.[g]:null;if(!h?.retryAttempt||!h?.retryMax)return"";let v=h.retryRecoveryMode==="continue"?"yeaft.vp.turnBlock.retryingContinue":"yeaft.vp.turnBlock.retryingRequest",C=h.retryRecoveryMode==="continue"?`Response stalled; continuing with a fresh request (${h.retryAttempt}/${h.retryMax})`:`Response stalled; retrying with a fresh request (${h.retryAttempt}/${h.retryMax})`,w=r(v,{attempt:h.retryAttempt,max:h.retryMax});return w===v?C:w});return{onStopTurn:a,isTyping:l,showStop:c,displayName:i,speakerNameStyle:o,startedTimeText:d,startedTimeFullText:u,elapsedText:f,retryText:p}}}});function $v(e){let t=[];if(typeof e!="string"||!e.trim())return t;let s=e.split(`
|
|
946
946
|
`),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?`
|
|
947
947
|
`:"")+r)}n&&t.push(n);for(let r of t)r.body=r.body.trim();return t}var rp,ip=F(()=>{rp={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 $v(e)}},methods:{toggle(e){this.expanded={...this.expanded,[e]:!this.expanded[e]}}},template:`
|
|
948
948
|
<div class="reflection-card" :class="{ 'is-pending': isPending, 'is-error': isError }">
|
|
@@ -1015,7 +1015,7 @@ ${String(e||"").trim()}
|
|
|
1015
1015
|
/>
|
|
1016
1016
|
</div>
|
|
1017
1017
|
</div>
|
|
1018
|
-
`}});function Nn(e,t,s){return Math.min(Math.max(e,t),s)}function li(e){return e?typeof e=="string"?e.length:Array.isArray(e)?e.reduce((t,s)=>t+li(s),0):typeof e=="object"?Object.values(e).reduce((t,s)=>t+li(s),0):String(e).length:0}function dp(e){if(!e)return 260;let t=li(e.content||e.text||e.message||""),s=Array.isArray(e.attachments)?e.attachments.length:0;return Nn(110+Math.ceil(t/90)*18+s*120,120,1400)}function Vv(e){if(!e)return 260;let t=li(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 Nn(160+Math.ceil(t/95)*18+s*56+n*140+r*96,160,1400)}function Yt(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+Yt(n),0)+Math.max(0,t.length-1)*18:260}return e.type==="assistant-turn"?Vv(e):e.message?dp(e.message):dp(e)}function Ys(e,t=0){return String(e?.id||e?.messageId||e?.turnId||`virtual_${t}`)}function Fv(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):Yt(e);return Number.isFinite(o)&&o>0?o:260}function Ea(e,t={},s={}){let n=Array.isArray(e)?e:[],r=Math.max(0,Number(s.itemGap??18)),i=s.estimateHeight||Yt,o=[0],a=[];for(let l=0;l<n.length;l+=1){let c=Fv(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 up(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 Ov(e,t,s){let n=up(e,t);for(;n<s&&e[n]<t;)n+=1;return Nn(n,0,s)}function pp(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=Nn(up(l,i),0,r-1),f=Nn(Ov(l,d,r),u+1,r),p=Math.max(0,u-a),g=Math.min(r,f+a);return{start:p,end:g,visibleStart:u,visibleEnd:f,topSpacerHeight:l[p]||0,bottomSpacerHeight:Math.max(0,c-(l[g]||c)),totalHeight:c,items:n.slice(p,g).map((v
|
|
1018
|
+
`}});function Nn(e,t,s){return Math.min(Math.max(e,t),s)}function li(e){return e?typeof e=="string"?e.length:Array.isArray(e)?e.reduce((t,s)=>t+li(s),0):typeof e=="object"?Object.values(e).reduce((t,s)=>t+li(s),0):String(e).length:0}function dp(e){if(!e)return 260;let t=li(e.content||e.text||e.message||""),s=Array.isArray(e.attachments)?e.attachments.length:0;return Nn(110+Math.ceil(t/90)*18+s*120,120,1400)}function Vv(e){if(!e)return 260;let t=li(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 Nn(160+Math.ceil(t/95)*18+s*56+n*140+r*96,160,1400)}function Yt(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+Yt(n),0)+Math.max(0,t.length-1)*18:260}return e.type==="assistant-turn"?Vv(e):e.message?dp(e.message):dp(e)}function Ys(e,t=0){return String(e?.id||e?.messageId||e?.turnId||`virtual_${t}`)}function Fv(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):Yt(e);return Number.isFinite(o)&&o>0?o:260}function Ea(e,t={},s={}){let n=Array.isArray(e)?e:[],r=Math.max(0,Number(s.itemGap??18)),i=s.estimateHeight||Yt,o=[0],a=[];for(let l=0;l<n.length;l+=1){let c=Fv(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 up(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 Ov(e,t,s){let n=up(e,t);for(;n<s&&e[n]<t;)n+=1;return Nn(n,0,s)}function pp(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=Nn(up(l,i),0,r-1),f=Nn(Ov(l,d,r),u+1,r),p=Math.max(0,u-a),g=Math.min(r,f+a);return{start:p,end:g,visibleStart:u,visibleEnd:f,topSpacerHeight:l[p]||0,bottomSpacerHeight:Math.max(0,c-(l[g]||c)),totalHeight:c,items:n.slice(p,g).map((h,v)=>{let C=p+v;return{item:h,index:C,key:Ys(h,C),top:l[C]||0}})}}function fp(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}=Ea(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,f=a[i]||260;return d==="start"?Math.max(0,Math.min(u,l-c)):d==="end"?Math.max(0,Math.min(u+f-c,l-c)):Math.max(0,Math.min(u-(c-f)/2,l-c))}function ms({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 gp(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 mp({following:e=!0,atBottom:t=!1,userScroll:s=!1}={}){return(s||!!e)&&!!t}function hp({following:e=!0,atBottom:t=!1,resumeBoundaryReached:s=!1,direction:n=0}={}){let r=Number(n)||0;return r<0?!1:e?!!t:r>0&&!!s}function Nv(e){return Hv.has(String(e||""))}function vp(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 yp(e,t,s=globalThis.document){if(!e||e.defaultPrevented||!t||!Nv(e.key))return!1;let n=e.target;return!n||n.closest?.(qv)?!1:n===t||n===s?.body||n===s?.documentElement}var Hv,qv,Et,Da=F(()=>{Hv=new Set(["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "]),qv='input, textarea, select, button, a, [contenteditable], [role="button"], [role="link"]';Et=Object.freeze({itemHeight:260,viewportHeight:720,overscan:1,itemGap:18,bottomThreshold:80,resumeBottomThreshold:2,historyPrefetchViewports:2,historyPrefetchMinPx:600})});var Bn,bp,wp=F(()=>{Da();Bn=2,bp={name:"VirtualTranscript",props:{items:{type:Array,default:()=>[]},overscan:{type:Number,default:Et.overscan},itemGap:{type:Number,default:Et.itemGap},estimateHeight:{type:Function,default:Yt},initialAlign:{type:String,default:"start"}},emits:["scroll-state"],template:`
|
|
1019
1019
|
<div class="virtual-transcript" ref="rootRef">
|
|
1020
1020
|
<div
|
|
1021
1021
|
v-if="topSpacerHeight > 0"
|
|
@@ -1042,8 +1042,8 @@ ${String(e||"").trim()}
|
|
|
1042
1042
|
aria-hidden="true"
|
|
1043
1043
|
></div>
|
|
1044
1044
|
</div>
|
|
1045
|
-
`,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(Et.viewportHeight),l=Vue.reactive({}),c=new Map,d=new Map,u=new Map,f=null,p=null,g=null,
|
|
1046
|
-
`),()=>{c.clear(),e.items.forEach((U,B)=>c.set(Ys(U,B),B)),y&&!c.has(y)&&te(),Vue.nextTick(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"){f=new ResizeObserver(U=>{for(let B of U){let H=B.target?.dataset?.virtualId,_=Number(B.target?.dataset?.virtualIndex);H&&ce(H,_,B.target)}});for(let[U,B]of d.entries()){let H=c.get(U)??Number(B.dataset?.virtualIndex||0);K(U,H,B)}}}),Vue.onBeforeUnmount(()=>{r.value?.removeEventListener("scroll",j),window.removeEventListener("resize",j),f&&f.disconnect(),p&&cancelAnimationFrame(p),g&&cancelAnimationFrame(g),
|
|
1045
|
+
`,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(Et.viewportHeight),l=Vue.reactive({}),c=new Map,d=new Map,u=new Map,f=null,p=null,g=null,h=null,v=0,C=!1,w=0,k=!0,y=null,m="start",b=null,T=Vue.computed(()=>Ea(e.items,l,{itemGap:e.itemGap,estimateHeight:e.estimateHeight})),L=Vue.computed(()=>pp(e.items,T.value,{scrollTop:o.value,viewportHeight:a.value,overscan:e.overscan})),N=Vue.computed(()=>L.value.items),$=Vue.computed(()=>L.value.topSpacerHeight),D=Vue.computed(()=>L.value.bottomSpacerHeight);function P(U){U&&t("scroll-state",{scrollTop:U.scrollTop||0,scrollHeight:U.scrollHeight||0,clientHeight:U.clientHeight||0})}function M(){let U=r.value;U&&(a.value=Math.max(1,U.clientHeight||Et.viewportHeight),i&&e.items.length===0||(o.value=Math.max(0,U.scrollTop||0)),P(U))}function A(){let U=r.value;return!i||e.initialAlign!=="end"||e.items.length===0||!U?!1:(te(),U.scrollTop=U.scrollHeight,i=!1,M(),!0)}function R(){A()||M()}function j(){p||(p=requestAnimationFrame(()=>{p=null,M()}))}function O(U){return U?ms({scrollTop:U.scrollTop,scrollHeight:U.scrollHeight,clientHeight:U.clientHeight,threshold:Et.bottomThreshold}):!0}function Y({delta:U=0,toBottom:B=!1}={},H=w){if(H!==w||(Math.abs(U)>=Bn&&(v+=U),B&&(C=!0),h))return;let _=H;h=requestAnimationFrame(()=>{if(h=null,_!==w)return;let J=r.value;if(!J){v=0,C=!1;return}C?J.scrollTop=J.scrollHeight:Math.abs(v)>=Bn&&(J.scrollTop+=v),v=0,C=!1,M()})}function te(){y=null,b=null}function he({preserveTarget:U=!1}={}){w+=1,C=!1,v=0,U||te(),h&&cancelAnimationFrame(h),h=null}function ce(U,B,H){!U||!H||(u.set(U,{index:B,el:H}),!g&&(g=requestAnimationFrame(()=>{g=null;let _=Array.from(u.entries());u.clear(),ke(_)})))}function ke(U){let B=[];for(let[pe,oe]of U){let De=oe?.el;if(!De)continue;let $e=Math.ceil(De.getBoundingClientRect?.().height||De.offsetHeight||0);if(!Number.isFinite($e)||$e<=0)continue;let Fe=l[pe];if(Fe===$e)continue;let Ue=c.get(pe);B.push({key:pe,nextHeight:$e,previousHeight:Fe,itemIndex:Number.isFinite(Ue)?Ue:oe.index})}if(!B.length)return;let H=r.value,_=k&&O(H),J=L.value.visibleStart,se=!!y&&B.some(pe=>pe.key===y),me=0,z=!1;for(let pe of B){let{key:oe,nextHeight:De,previousHeight:$e,itemIndex:Fe}=pe;if(l[oe]=De,!H||!Number.isFinite($e))continue;let Ue=De-$e;Math.abs(Ue)<Bn||(Number.isFinite(Fe)&&Fe<J?me+=Ue:_&&(z=!0))}if(se){he({preserveTarget:!0}),ge(y,m);return}if(Math.abs(me)>=Bn||z){let pe={delta:me,toBottom:z},oe=w;z?Vue.nextTick(()=>Y(pe,oe)):Y(pe,oe)}}function ve(U,B="start"){let H=r.value,_=b||d.get(String(U));if(!H||!_)return!1;let J=H.getBoundingClientRect?.(),se=_.getBoundingClientRect?.();if(!J||!se)return!1;let me=Number(J.top),z=Number(H.clientHeight||a.value),ee=Number(se.height||0),pe=B==="center"&&ee<=z?me+(z-ee)/2:B==="end"&&ee<=z?Number(J.bottom)-ee:me,oe=Number(se.top)-pe;return Math.abs(oe)>=Bn&&(H.scrollTop+=oe),M(),!0}function ge(U,B="start",H){let _=String(U);y=_,m=B,H!==void 0&&(b=H);let J=()=>{y===_&&ve(_,m)};Vue.nextTick(J)}function x(U){let B=!!U;B&&te(),k!==B&&(k=B,k||he())}function K(U,B,H){c.set(U,B),H&&(d.set(U,H),f&&f.observe(H),Vue.nextTick(()=>ce(U,B,H)))}function re(U,B,H){if(!U)return;let _=d.get(U);if(_&&_!==H&&f&&f.unobserve(_),!H){d.delete(U);return}K(U,B,H)}async function ye(U,{align:B="center"}={}){let H=Number.isFinite(U)?Math.floor(U):-1,_=r.value;if(!_||H<0||H>=e.items.length)return!1;he({preserveTarget:!0});let J=Ys(e.items[H],H);return y=J,m=B,b=null,_.scrollTop=fp(e.items,H,l,{itemGap:e.itemGap,estimateHeight:e.estimateHeight,viewportHeight:_.clientHeight||a.value,align:B}),M(),await Vue.nextTick(),d.get(J)?(ge(J,B),!0):!1}function W(U,B={}){let H=c.get(String(U));return Number.isFinite(H)?ye(H,B):Promise.resolve(!1)}function ne(U,B,{align:H="start"}={}){let _=String(U||"");return!_||!B?!1:(y=_,m=H,b=B,ve(_,H),!0)}return s({scrollToKey:W,scrollToIndex:ye,anchorTarget:ne,clearTargetAnchor:te,cancelPendingBottomFollow:he,setBottomFollowEnabled:x}),Vue.watch(()=>e.items.map((U,B)=>Ys(U,B)).join(`
|
|
1046
|
+
`),()=>{c.clear(),e.items.forEach((U,B)=>c.set(Ys(U,B),B)),y&&!c.has(y)&&te(),Vue.nextTick(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"){f=new ResizeObserver(U=>{for(let B of U){let H=B.target?.dataset?.virtualId,_=Number(B.target?.dataset?.virtualIndex);H&&ce(H,_,B.target)}});for(let[U,B]of d.entries()){let H=c.get(U)??Number(B.dataset?.virtualIndex||0);K(U,H,B)}}}),Vue.onBeforeUnmount(()=>{r.value?.removeEventListener("scroll",j),window.removeEventListener("resize",j),f&&f.disconnect(),p&&cancelAnimationFrame(p),g&&cancelAnimationFrame(g),h&&cancelAnimationFrame(h),u.clear(),v=0,C=!1}),{rootRef:n,visibleEntries:N,topSpacerHeight:$,bottomSpacerHeight:D,setItemRef:re}}}});function Wn(e){return typeof e=="string"&&e.trim()?e.trim():""}function Bv(e){return Wn(e?.speakerVpId)||Wn(e?.vpId)}function kp(e,t){if(!e||!t)return!1;let s=Wn(e.speakerVpId),n=Bv(t);if(s&&n&&s!==n)return!0;if(e.isHistory&&t.isHistory)return!1;let r=Wn(e.turnId),i=Wn(t.turnId);return!!(r&&i&&r!==i)}var Sp=F(()=>{});function jn(e){return e?e.type!=="user"&&e.type!=="system"&&e.type!=="error":!1}function ci(e){let t=Array.isArray(e?.items)?e.items:[];return e?.responseCollapsed?t.filter(s=>!jn(s)):t}function Wv(e){return(Array.isArray(e?.items)?e.items:[]).filter(jn)}function Ip(e){let t=Wv(e);return t.length?t[0]:null}function jv(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 Cp(e){if(!e?.responseCollapsed)return[];let t=Ip(e);return jv(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 Ap(e,t){if(!e?.responseCollapsed||typeof t!="function")return null;let s=ci(e),n=Ip(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 xp=F(()=>{});function hs(e,t){typeof t!="string"||!/^m\d+$/.test(t)||e.includes(t)||e.push(t)}function Uv(e){if(!e)return[];let t=[];for(let s of Array.isArray(e.messages)?e.messages:[])hs(t,s?.id),hs(t,s?.messageId),hs(t,s?.persistedMessageId);return hs(t,e.message?.id),hs(t,e.messageId),hs(t,e.atMessageId),e.type!=="assistant-turn"&&hs(t,e.id),t}function Tp(e){return!e?.closest?.(".yeaft-conversation-outline, .yeaft-conversation-outline-sender-menu, .yeaft-search-btn")}async function Mp({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.messageId);return a&&r&&i?.(),!!a}function zv(e,t){if(!t)return null;for(let s of Array.isArray(e)?e:[]){if(!s)continue;let n=Array.isArray(s.items)?s.items:[s];for(let r of n){if(!Uv(r).includes(t))continue;let i=r?.id,o=s?.id;return!i||!o?null:{blockId:o,rowId:i,collapseKey:s.responseCollapseKey||null,requiresExpansion:!!(s.responseCollapsed&&r.type==="assistant-turn")}}}return null}async function Pp({blocks:e,messageId:t,collapseStates:s,scrollToBlock:n,findRow:r,anchorRow:i,flashRow:o,nextTick:a,align:l="start"}){let c=zv(e,t);if(!c||typeof n!="function"||typeof r!="function")return!1;if(c.requiresExpansion){if(!c.collapseKey||!s)return!1;s[c.collapseKey]=!1,await a?.()}if(!await n(c.blockId,{align:l}))return!1;await a?.();let u=r(c.rowId);return u?(typeof i=="function"?i(c.blockId,c.rowId,u,{align:l}):u.scrollIntoView?.({block:l,inline:"nearest"}),o?.(c.rowId),!0):!1}var La=F(()=>{});var di,$a=F(()=>{ct();wa();si();ai();np();Ra();ip();ap();cp();wp();Sp();Da();xp();La();ds();Fr();di={name:"MessageList",components:{MessageItem:zs,AssistantTurn:Ks,VpTurnBlock:sp,VpSpeakerHeader:ii,ReflectionCard:rp,SubAgentCard:op,UserTurnBlock:lp,VirtualTranscript:bp},template:`
|
|
1047
1047
|
<main class="chat-container" ref="containerRef">
|
|
1048
1048
|
<!-- Session Loading Overlay - only covers message area -->
|
|
1049
1049
|
<div class="session-loading-overlay" v-if="showSessionLoadingOverlay">
|
|
@@ -1665,7 +1665,7 @@ ${String(e||"").trim()}
|
|
|
1665
1665
|
{{ $t('message.scrollToLatest') }}
|
|
1666
1666
|
</button>
|
|
1667
1667
|
</main>
|
|
1668
|
-
`,emits:["new-conversation","resume-conversation","open-settings","quote-message","edit-message-as-new"],setup(e,{expose:t}){let s=Pinia.useChatStore(),n=_e(),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=S=>String(S?.id||S?.turnId||S?.messageId||S?.atMessageId||S?.message?.id||"turn_unknown"),f=S=>{let V=u(S);return Object.prototype.hasOwnProperty.call(l,V)?!!l[V]:!1},p=(S,V)=>{l[u(S)]=!!V},g=({key:S,value:V}={})=>{S&&(c[S]=!!V)},v=S=>{let V=Ap(S,Yt);return Number.isFinite(V)?V:Yt(S)},h=S=>ci(S),A=S=>{let V=Array.isArray(S?.collapsedResponsePreview)?S.collapsedResponsePreview:Cp(S);return Array.isArray(V)?V:V?[String(V)]:[]},w=S=>{let V=Array.isArray(S?.items)?S.items.find(we=>jn(we)):null,q=V?.speakerVpId||V?.vpId||V?.message?.speakerVpId||V?.message?.vpId||S?.vpId||"",ue=q&&r&&typeof r.vpLabel=="function"?r.vpLabel(q)||q:q||(typeof i=="function"?i("message.assistant"):"Assistant"),Se=q&&r&&typeof r.vpTextColor=="function"?{color:r.vpTextColor(q)}:{},ie=V?.speakerTimestamp||V?.timestamp||V?.createdAt||V?.message?.timestamp||V?.message?.createdAt||0,Oe="",je="";if(ie)try{let we=new Date(ie);Number.isNaN(we.getTime())||(Oe=vt(ie),je=we.toLocaleString())}catch{}return{name:ue,style:Se,timeText:Oe,fullTimeText:je}},k=S=>{let V=Array.isArray(S?.items)?S.items:[];for(let q=V.length-1;q>=0;q-=1)if(jn(V[q]))return V[q];return null},y=(S,V)=>!S?.responseCollapsible||!V?!1:k(S)===V,m=S=>!!(S?.responseCollapsible&&!ci(S).some(V=>y(S,V))),b=S=>{let V=S?.responseCollapseKey;V&&(d[V]=!S.responseCollapsed)},T=S=>{let V=Number(S?.responseCount||0),q=S?.responseCollapsed?"message.showResponses":"message.hideResponses",ue=(typeof i=="function"?i(q):"")||(S?.responseCollapsed?"Show {count} response(s)":"Hide response(s)");return String(ue).replace("{count}",String(V))},L=(()=>{try{return window.Pinia?.useSessionsStore?.()||null}catch{return null}}),N=Vue.computed(()=>{if(s.currentView!=="yeaft")return null;let S=L();if(!S)return null;let V=s.yeaftActiveSessionFilter||null;return V&&typeof S.sessionById=="function"&&S.sessionById(V,s.currentAgent||null)?V:S.activeSessionId&&typeof S.sessionById=="function"&&S.sessionById(S.activeSessionId,s.currentAgent||null)?S.activeSessionId:null}),$=Vue.computed(()=>{let S=s.currentView||"",V=s.currentAgent||"";if(S==="yeaft"){let q=s.yeaftActiveSessionFilter||N.value||"__all__";return[S,V,q].join("")}return[S,V,s.activeConversationId||""].join("")}),D=Vue.computed(()=>N.value!==null),P=Vue.computed(()=>s.agents.filter(S=>S.online)),M=Vue.ref(null),C=Vue.ref(null),R=Vue.ref(!1),j=Vue.ref(""),O=null,Y=0,te=n.token||"",he=()=>{M.value=null,C.value=null,j.value="",O=null,Y+=1},ce=Zr(),ke=Jr(),ve=Vue.computed(()=>ei({profile:M.value,agentSecret:C.value,serverWsUrl:Fn(location)})),ge=()=>{let S={"Content-Type":"application/json"};return n.token&&(S.Authorization=`Bearer ${n.token}`),S},x=async()=>{if(P.value.length>0||s.currentConversation)return;if(C.value||O)return O;R.value=!0,j.value="";let S=++Y;return O=(async()=>{let V=n.token||"",q=ge(),[ue,Se]=await Promise.all([fetch("/api/user/profile",{headers:q}),fetch("/api/user/agent-secret",{headers:q})]),ie=ue.ok?await ue.json():null;if(S!==Y||V!==(n.token||""))return;if(ie&&(M.value=ie),!Se.ok){let we="";try{we=(await Se.json())?.error||""}catch{}throw new Error(we||"Failed to load Agent secret")}let Oe=await Se.json();if(S!==Y||V!==(n.token||""))return;let je=Oe?.agentSecret||Oe?.agent_secret||null;C.value=je&&String(je).trim()?String(je):null})().catch(V=>{S===Y&&(j.value=V?.message||"Failed to load Agent secret")}).finally(()=>{S===Y&&(R.value=!1,O=null)}),O},K=async S=>{if(S)try{await navigator.clipboard.writeText(S)}catch{}},re=(S,V)=>{let q=S?.message||null,ue=S?.id||S?.atMessageId||q?.id||q?.messageId||`legacy_${V}`,Se=S?.speakerVpId||S?.vpId||q?.speakerVpId||q?.vpId||"";return{id:`message_${Se||"user"}_${ue}_${V}`,vpId:Se,messageId:ue}},ye=Vue.computed(()=>{let S=s.messages,V=[],q=null,ue=0,Se=()=>{if(q){q.isActive=!!(q.turnId&&Object.values(s.activeVpTurns||{}).some(tt=>((tt?.turnId||null)===q.turnId||!tt?.turnId&&s.activeVpTurns?.[q.turnId]===tt)&&(!s.currentAgent||!tt?.agentId||tt.agentId===s.currentAgent))),Vr(q);let we=!!(q.textContent||q.todoMsg||q.askMsg||q.imageMsgs.length>0),ae=q.toolMsgs.length>0||q.toolSummaryCount>0;(we||ae)&&(q.showSpeakerHeader=!!q.speakerVpId,V.push(q)),q=null}},ie=we=>{if(q){if(!q.speakerVpId){let ae=we.speakerVpId||we.vpId;ae&&(q.speakerVpId=ae,q.speakerTimestamp=typeof we.timestamp=="number"&&we.timestamp>0?we.timestamp:typeof we.createdAt=="number"?we.createdAt:0,typeof we.lastStateChangeCause=="string"&&!q.speakerStateCause&&(q.speakerStateCause=we.lastStateChangeCause))}!q.turnId&&we.turnId&&(q.turnId=we.turnId)}},Oe=()=>{ue++,q={type:"assistant-turn",id:"turn_"+ue,textContent:"",textSegments:[],isStreaming:!1,isActive:!1,isHistory:!1,todoMsg:null,toolMsgs:[],toolSummaryCount:0,imageMsgs:[],askMsg:null,messages:[],atMessageId:null,speakerVpId:null,speakerTimestamp:0,speakerStateCause:"",showSpeakerHeader:!1,turnId:null}},je=we=>{kp(q,we)&&Se()};for(let we=0;we<S.length;we++){let ae=S[we];if(ae.type==="user"){if(!ae.content||!ae.content.trim())continue;Se(),V.push({type:"user",id:ae.id||"u_"+we,message:ae});continue}if(ae.type==="system"||ae.type==="error"){Se(),V.push({type:ae.type,id:ae.id||"s_"+we,message:ae});continue}if(!(ae.type==="tool-result"||ae.type==="tool_result")){if(ae.type==="tool-summary"){je(ae),q||Oe(),ie(ae),ae.isHistory&&(q.isHistory=!0),q.toolSummaryCount+=Number(ae.count||ae.omittedCount||0)||0,q.messages.push(ae);continue}if(ae.type==="assistant"){je(ae),q||Oe(),$r(q,ae),ae.isStreaming&&(q.isStreaming=!0),ae.isHistory&&(q.isHistory=!0),ae.id&&/^m\d+$/.test(ae.id)&&(q.atMessageId=ae.id),ie(ae),q.messages.push(ae);continue}if(ae.type==="tool-use"){je(ae),q||Oe(),ie(ae);let tt=S[we+1],dn=tt&&(tt.type==="tool-result"||tt.type==="tool_result"),Nt={...ae,hasResult:dn||ae.hasResult||!1,toolResult:ae.toolResult||null};ae.isHistory&&(q.isHistory=!0),ae.toolName==="TodoWrite"?q.todoMsg=Nt:ae.toolName==="AskUserQuestion"?q.askMsg=Nt:q.toolMsgs.push(Nt),q.messages.push(ae);continue}if(ae.type==="chat-image"){je(ae),q||Oe(),ie(ae),ae.isHistory&&(q.isHistory=!0),q.imageMsgs.push(ae),q.messages.push(ae);continue}Se(),V.push({type:ae.type||"unknown",id:ae.id||"x_"+we,message:ae})}}return Se(),V}),W=Vue.computed(()=>{let S=[],V=null,q=()=>{V&&S.push(V),V=null};return ye.value.forEach((ue,Se)=>{if(!ue||ue.type==="system"||ue.type==="error"){q(),S.push(ue);return}let ie=re(ue,Se);if(ue.type==="user"||!V){q(),V={type:"message-block",id:`turn_${ie.messageId}_${Se}`,vpId:ie.vpId,messageId:ie.messageId,items:[ue]};return}V.items.push(ue),!V.vpId&&ie.vpId&&(V.vpId=ie.vpId)}),q(),S}),ne=Vue.computed(()=>{let S=s.yeaftReflectionCards||{},V=s.yeaftConversationId,q={__orphans:[]},ue=Object.values(S).filter(ie=>ie&&ie.conversationId===V).sort((ie,Oe)=>(ie.anchorOrder||0)-(Oe.anchorOrder||0)||(ie.updatedAt||0)-(Oe.updatedAt||0)),Se=new Set;for(let ie of s.messages||[])ie&&ie.id&&Se.add(ie.id);for(let ie of ue)ie.anchorMsgId&&Se.has(ie.anchorMsgId)?(q[ie.anchorMsgId]||(q[ie.anchorMsgId]=[]),q[ie.anchorMsgId].push(ie)):q.__orphans.push(ie);return q}),U=S=>S?S.type==="assistant-turn"?S.atMessageId||null:S.message&&S.message.id||null:null,B=S=>{let V=U(S);return V?(ne.value||{})[V]||[]:[]},H=Vue.computed(()=>(ne.value||{}).__orphans||[]),_=Vue.computed(()=>{let S=s.yeaftSubAgentCards||{},V=s.yeaftConversationId,q={__orphans:[]},ue=Object.values(S).filter(ie=>ie&&ie.conversationId===V).sort((ie,Oe)=>(ie.anchorOrder||0)-(Oe.anchorOrder||0)||(ie.updatedAt||0)-(Oe.updatedAt||0)),Se=new Set;for(let ie of s.messages||[])ie&&ie.id&&Se.add(ie.id);for(let ie of ue)ie.anchorMsgId&&Se.has(ie.anchorMsgId)?(q[ie.anchorMsgId]||(q[ie.anchorMsgId]=[]),q[ie.anchorMsgId].push(ie)):q.__orphans.push(ie);return q}),J=S=>{let V=U(S);return V?(_.value||{})[V]||[]:[]},se=Vue.computed(()=>(_.value||{}).__orphans||[]),me=Vue.ref(!0),z=Vue.ref(!1),ee=Et.bottomThreshold,pe=Et.resumeBottomThreshold,oe=!0,De=Vue.computed(()=>s.messages.some(S=>S.isStreaming)),$e=Vue.computed(()=>!s.activeConversationId||W.value.length>0?!1:s.currentView==="yeaft"?!!s.yeaftInitialHistoryLoading:!!s.sessionLoading),Fe=Vue.computed(()=>s.currentView==="yeaft"&&!!s.yeaftLoadingMoreHistory&&s.activeYeaftHistoryState?.mode==="older"),Ue=Vue.computed(()=>s.currentView==="yeaft"?"":s.sessionLoadingText||""),Zt=Vue.computed(()=>!!s.sessionLoading&&!$e.value),St=Vue.computed(()=>s.isProcessing&&!De.value),Lt=Vue.ref(Date.now()),It=null,$t=()=>{It||(It=setInterval(()=>{Lt.value=Date.now()},1e3))},ft=()=>{It&&(clearInterval(It),It=null)};Vue.watch(De,S=>{S?(Lt.value=Date.now(),$t()):ft()},{immediate:!0}),Vue.onBeforeUnmount(()=>ft());let Ne=Vue.ref(0),We=Vue.ref(Date.now()),Vt=null,Ge=null,E=Vue.ref("cat"),X=new URLSearchParams(window.location.search).get("preview"),fe=Vue.ref(0),de=Vue.ref(1),be=Vue.ref(5),Ie=Vue.ref(95),Le=Vue.ref("bark-both"),He=Vue.ref(1),Be=Vue.ref(-1),Ke=null;function Ft(){if(!Ne.value)return;We.value=Date.now();let S=(We.value-Ne.value)%19e3;if(S<4e3)fe.value=0,de.value=1;else if(S<11500){let V=S-4e3,q;V<2500?q=V/2500*16:V<5e3?q=16+(V-2500)/2500*29:q=45+(V-5e3)/2500*55,fe.value=q,de.value=1}else S<14e3?(fe.value=(1-(S-11500)/2500)*100,de.value=-1):(fe.value=0,de.value=1);Ge=requestAnimationFrame(Ft)}function tn(){if(!Ne.value||E.value!=="dog")return;We.value=Date.now();let S=(We.value-Ne.value)%18e3;if(S<2e3)be.value=5,Ie.value=95,Le.value="bark-both",He.value=1,Be.value=-1;else if(S<5e3){let V=(S-2e3)/3e3;be.value=5+V*25,Ie.value=95,Le.value="left-approach",He.value=1,Be.value=-1}else if(S<8e3){let V=(S-5e3)/3e3;be.value=30,Ie.value=95-V*25,Le.value="right-approach",He.value=1,Be.value=-1}else if(S<1e4){let V=(S-8e3)/2e3;be.value=30+V*13,Ie.value=70-V*13,Le.value="both-approach",He.value=1,Be.value=-1}else if(S<11e3)be.value=43,Ie.value=57,Le.value="snap",He.value=1,Be.value=-1;else if(S<12500)be.value=43,Ie.value=57,Le.value="stunned",He.value=1,Be.value=-1;else if(S<15e3){let V=(S-12500)/2500;be.value=43-V*38,Ie.value=57+V*38,Le.value="retreat",He.value=-1,Be.value=1}else S<17e3?(be.value=5,Ie.value=95,Le.value="rehang",He.value=-1,Be.value=1):(be.value=5,Ie.value=95,Le.value="reset",He.value=1,Be.value=-1);Ke=requestAnimationFrame(tn)}let Wi=Vue.computed(()=>{let S=be.value*1.2;return He.value<0?`translate(${S+13.5}, 0) scale(-1, 1)`:`translate(${S-13.5}, 0)`}),ji=Vue.computed(()=>{let S=Ie.value*1.2;return Be.value>0?`translate(${S-10.5}, 2)`:`translate(${S+10.5}, 2) scale(-1, 1)`}),er=Vue.computed(()=>{let S=Le.value;return S==="bark-both"||S==="left-approach"||S==="right-approach"||S==="both-approach"||S==="reset"}),tr=Vue.computed(()=>{let S=be.value*1.2,V=10;if(er.value){let Se=Math.max(0,(S-3)*.12);return`M3,18 Q${(3+S)/2},${18+Se} ${S},${V}`}if(Le.value==="rehang")return`M${S},${V} Q${S-3},20 3,18`;let q=He.value<0?1:-1,ue=S+q*8;return`M${S},${V} Q${S},18 ${ue},22`}),Ui=Vue.computed(()=>{let S=Ie.value*1.2,V=10;if(er.value){let Se=Math.max(0,(118-S)*.12);return`M118,18 Q${(118+S)/2},${18+Se} ${S},${V}`}if(Le.value==="rehang")return`M${S},${V} Q${S+3},20 118,18`;let q=Be.value>0?-1:1,ue=S+q*8;return`M${S},${V} Q${S},18 ${ue},22`}),zi=Vue.computed(()=>Le.value==="snap"?.2:.4),Ki=Vue.computed(()=>Le.value==="snap"?.2:.4),Yi=Vue.computed(()=>be.value*1.2),Gi=Vue.computed(()=>Ie.value*1.2),sn=X==="cat"||X==="dog"||X==="animation",sr=600,nn=Vue.ref(!1),et=null,nr=Vue.computed(()=>sn?!0:nn.value);Vue.watch(St,S=>{if(S)et&&(clearTimeout(et),et=null),nn.value=!0,Ne.value=Date.now(),We.value=Date.now(),E.value="cat",fe.value=0,de.value=1,be.value=5,Ie.value=95,Le.value="bark-both",He.value=1,Be.value=-1,E.value==="cat"?Ge=requestAnimationFrame(Ft):Ke=requestAnimationFrame(tn);else{let V=Ne.value?Date.now()-Ne.value:sr,q=Math.max(0,sr-V),ue=()=>{et=null,nn.value=!1,Ne.value=0,fe.value=0,de.value=1,Ge&&(cancelAnimationFrame(Ge),Ge=null),Ke&&(cancelAnimationFrame(Ke),Ke=null)};q===0?ue():(et&&clearTimeout(et),et=setTimeout(ue,q))}},{immediate:!0}),sn&&(Ne.value=Date.now(),We.value=Date.now(),X==="dog"?E.value="dog":E.value="cat",E.value==="cat"?Ge=requestAnimationFrame(Ft):(be.value=5,Ie.value=95,Le.value="bark-both",He.value=1,Be.value=-1,Ke=requestAnimationFrame(tn)));let Qi=Vue.computed(()=>{if(!s.isProcessing)return null;if(s.connectionState!=="connected")return"disconnected";let S=s.currentConversation;if(s.compactStatus?.conversationId===S&&s.compactStatus?.status==="compacting")return"compacting";let V=s.sessionHealth?.[S];return V?V.status:Ne.value&&We.value-Ne.value>8e3?"thinking":null}),Xi=Vue.computed(()=>{if(!Ne.value)return"speed-napping";let S=(We.value-Ne.value)%19e3;return S>=16e3?"speed-petted":S>=14e3?"speed-tired":S>=11500?"speed-crazy":S>=9e3?"speed-turbo":S>=6500?"speed-fast":S>=4e3?"speed-normal":"speed-napping"}),Zi=Vue.computed(()=>{let S=fe.value,V=de.value,ue={left:`calc(40px + (100% - 80px) * ${S/100})`};return V<0&&(ue.transform="scaleX(-1)"),ue});function Qe(){let S=s.currentConversation;if(!S)return;let V=s.conversations.find(q=>q.id===S);s.sendWsMessage({type:"refresh_conversation",conversationId:S,agentId:V?.agentId})}let rr=()=>{if(!o.value)return!0;let{scrollTop:S,scrollHeight:V,clientHeight:q}=o.value;return ms({scrollTop:S,scrollHeight:V,clientHeight:q,threshold:ee})},rn=(S,V=0,{allowContinuation:q=!1}={})=>{if(S>gp(V)){oe=!0;return}q&&(oe=!0),!(!oe||!or())&&(oe=!1,Jt())},Ji=S=>{if(!S)return"";let q=(Array.isArray(S.items)?S.items:[])[0]||null;return[S.type||"",S.messageId||"",S.turnId||"",S.vpId||"",q?.id||"",q?.turnId||"",q?.messageId||""].join(":")},ir=()=>{let S=W.value||[];return{blockCount:S.length,firstBlockIdentity:Ji(S[0])}},Is=(S,V)=>!S||!V?!1:V.blockCount>S.blockCount||V.firstBlockIdentity!==S.firstBlockIdentity,on=S=>{Vue.nextTick(()=>{if(!o.value)return;let V=ir();Is(S,V)&&rn(o.value.scrollTop||0,o.value.clientHeight||0,{allowContinuation:!0})})},eo=({scrollTop:S,scrollHeight:V,clientHeight:q})=>{let ue=ms({scrollTop:S,scrollHeight:V,clientHeight:q,threshold:ee});return me.value=ue,z.value=!ue,ue},Cs=()=>{z.value=!1,me.value=!0,a.value?.setBottomFollowEnabled?.(!0)},Ot=()=>{z.value=!0,me.value=!1,a.value?.setBottomFollowEnabled?.(!1),a.value?.cancelPendingBottomFollow?.()},to=({scrollTop:S,scrollHeight:V,clientHeight:q})=>{let ue=ms({scrollTop:S||0,scrollHeight:V||0,clientHeight:q||0,threshold:ee});me.value=mp({following:!z.value,atBottom:ue}),z.value=!me.value,a.value?.setBottomFollowEnabled?.(me.value),Ct||(es=Number(S||0)),rn(S||0,q||0)},so=(S,V)=>{let q=ir();if(!o.value){S(),on(q);return}let ue=o.value.scrollHeight,Se=o.value.scrollTop,ie=!1,Oe=null,je=()=>{ie||(ie=!0,Oe&&Oe(),Vue.nextTick(()=>{if(!o.value)return;let we=o.value.scrollHeight;o.value.scrollTop=we-ue+Se,on(q)}))};V&&(Oe=Vue.watch(V,we=>{we||je()})),S(),Vue.nextTick(()=>{(!V||!V())&&je()})},no=()=>{if(s.hasHiddenYeaftMessages){s.expandYeaftMessageWindow();return}s.loadMoreYeaftHistory()},or=()=>s.currentView==="yeaft"?s.hasHiddenYeaftMessages||s.yeaftHasMoreHistory&&!s.yeaftLoadingMoreHistory&&s.yeaftOldestLoadedSeq!=null:!!s.currentConversation&&s.hasMoreMessages&&!s.loadingMoreMessages,Jt=()=>{if(!or())return;let S=s.currentView==="yeaft";so(S?no:()=>s.loadMoreMessages(),S?()=>s.yeaftLoadingMoreHistory:()=>s.loadingMoreMessages)},Ct=!1,an=!1,Xe=null,es=0,ar=250,lr=()=>{Ct=!1,Xe&&(clearTimeout(Xe),Xe=null)},ts=()=>{an||(Xe&&clearTimeout(Xe),Xe=setTimeout(lr,ar))},As=S=>{Ct=!0,a.value?.clearTargetAnchor?.(),es=Number(o.value?.scrollTop||0),Number(S?.deltaY)<0&&Ot(),ts()},cr=S=>{vp(S,o.value)&&(an=!0,Ct=!0,a.value?.clearTargetAnchor?.(),es=Number(o.value?.scrollTop||0),Xe&&(clearTimeout(Xe),Xe=null))},xs=()=>{an=!1,ts()},dr=S=>{yp(S,o.value)&&((S.key==="ArrowUp"||S.key==="PageUp"||S.key==="Home")&&Ot(),Ct=!0,a.value?.clearTargetAnchor?.(),ts())},ur=()=>{let S=Number(o.value?.scrollTop||0),V=Ct?S-es:0,q=!z.value;es=S;let ue=rr(),Se=ms({scrollTop:S,scrollHeight:o.value?.scrollHeight||0,clientHeight:o.value?.clientHeight||0,threshold:pe});me.value=hp({following:q,atBottom:ue,resumeBoundaryReached:Se,direction:V}),z.value=!me.value,a.value?.setBottomFollowEnabled?.(me.value),me.value&&ln(),Ct&&ts(),o.value&&rn(o.value.scrollTop||0,o.value.clientHeight||0)},ln=()=>{s.currentView==="yeaft"&&s.pruneYeaftMessageWindow()},Ts=()=>{o.value&&(o.value.scrollTop=o.value.scrollHeight,Cs(),ln())},ro=()=>{Cs(),Vue.nextTick(Ts)},Ht=()=>{!z.value&&me.value&&(ln(),Vue.nextTick(Ts))},qt=S=>{if(!S)return"";if(Array.isArray(S.items))return S.items.map(qt).join(",");let V=S.message||{};return[S.type||"",S.id||"",S.atMessageId||"",S.turnId||"",S.messageId||"",S.speakerVpId||"",V.id||"",V.content?String(V.content).length:0,S.textContent?String(S.textContent).length:0,S.isStreaming||V.isStreaming?"streaming":"done"].join(":")},io=Vue.computed(()=>{let S=W.value||[];return[s.activeConversationId||"",N.value||"",qt(S[S.length-1])].join("|")});Vue.watch(()=>[s.currentConversation,P.value.length,n.token],()=>{let S=n.token||"";S!==te&&(te=S,he()),x()},{immediate:!0}),Vue.watch(io,Ht),Vue.watch(nr,S=>{S&&Ht()}),Vue.watch(()=>[s.activeConversationId,N.value],()=>{for(let S of Object.keys(l))delete l[S];for(let S of Object.keys(c))delete c[S];for(let S of Object.keys(d))delete d[S];Cs(),Vue.nextTick(Ts)});let cn=Vue.ref(null),pr=0;return t({revealMessage:async S=>S?(Ot(),await Pp({blocks:W.value,messageId:S,collapseStates:d,nextTick:Vue.nextTick,scrollToBlock:(q,ue)=>(Ot(),a.value?.scrollToKey?.(q,ue)),findRow:q=>{let ue=o.value?.querySelectorAll?.("[data-msg-id]")||[];return Array.from(ue).find(Se=>Se?.dataset?.msgId===q)||null},anchorRow:(q,ue,Se,ie)=>a.value?.anchorTarget?.(q,Se,ie),flashRow:q=>{let ue=++pr;cn.value=q,setTimeout(()=>{ue===pr&&(cn.value=null)},1800)}})):!1}),Vue.onMounted(()=>{Ts(),o.value&&(o.value.addEventListener("wheel",As,{passive:!0}),o.value.addEventListener("touchmove",As,{passive:!0}),o.value.addEventListener("pointerdown",cr,{passive:!0}),o.value.addEventListener("scroll",ur)),window.addEventListener("pointerup",xs,{passive:!0}),window.addEventListener("pointercancel",xs,{passive:!0}),window.addEventListener("keydown",dr)}),Vue.onUnmounted(()=>{o.value&&(o.value.removeEventListener("wheel",As),o.value.removeEventListener("touchmove",As),o.value.removeEventListener("pointerdown",cr),o.value.removeEventListener("scroll",ur)),window.removeEventListener("pointerup",xs),window.removeEventListener("pointercancel",xs),window.removeEventListener("keydown",dr),lr(),Vt&&(clearInterval(Vt),Vt=null),et&&(clearTimeout(et),et=null),Ge&&(cancelAnimationFrame(Ge),Ge=null),Ke&&(cancelAnimationFrame(Ke),Ke=null)}),{store:s,containerRef:o,virtualTranscriptRef:a,flashMsgId:cn,hasStreamingMessage:De,nowMs:Lt,showTypingDots:St,showInitialMessagesLoading:$e,showYeaftOlderHistoryLoading:Fe,showSessionLoadingOverlay:Zt,initialMessagesLoadingText:Ue,previewShowTypingDots:nr,isPreviewMode:sn,waitingStatus:Qi,animationType:E,catSpeed:Xi,catStyle:Zi,dogPhase:Le,spikeTransform:Wi,teddyTransform:ji,leashPathL:tr,leashPathR:Ui,leashOpacityL:zi,leashOpacityR:Ki,questionLX:Yi,questionRX:Gi,refreshSession:Qe,onlineAgents:P,welcomeInstallCommand:ce,welcomeLlmCommand:ke,welcomeServiceCommand:ve,welcomeSetupLoading:R,welcomeSetupError:j,copyWelcomeCommand:K,turnGroups:ye,messageBlocks:W,virtualTranscriptIdentity:$,estimateMessageBlockHeight:v,visibleItemsForBlock:h,collapsedResponsePreviewLines:A,collapsedResponsePreviewSpeaker:w,responseToggleBelongsToItem:y,showBlockResponseToggle:m,toggleMessageTurnResponse:b,responseCollapseLabel:T,turnUiKey:u,assistantTurnActionsExpandedFor:f,setAssistantTurnActionsExpanded:p,toolExpandStates:c,setToolExpanded:g,cardsForRow:B,orphanCards:H,subAgentCardsForRow:J,orphanSubAgentCards:se,useImStyleForUser:D,onClickLoadMore:Jt,onVirtualTranscriptScrollState:to,isAtBottom:me,scrollToLatest:ro}}}});function fi(...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 Dp(e,t,s){let n=t?e?.slashCommandsMap?.[t]:null;return e?.currentView==="yeaft"?fi(n):fi(n,s?e?.slashCommandsMap?.[`agent:${s}`]:null,e?.slashCommandsMap?.__preload__)}function Yv(e,t={},s=new Set){if(Kv.has(e)||Object.prototype.hasOwnProperty.call(pi,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 Lp(e,t={}){if(ui[e])return ui[e];if(pi[e])return pi[e];let s=e.startsWith("/")?e.slice(1):e;return t[s]?t[s]:Gv(s)}function Gv(e){return(e.includes(":")?e.split(":").pop():e).replace(/-/g," ").replace(/^\w/,s=>s.toUpperCase())}function $p(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=Yv(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)=>(Rp[o]??99)-(Rp[a]??99));return i.map((o,a)=>({label:Qv[o]||o,items:r[o],isLast:a===i.length-1}))}var ui,Kv,_p,pi,Ep,Qv,Rp,Vp=F(()=>{ui={"/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"},Kv=new Set(Object.keys(ui)),_p=Object.keys(ui),pi={"/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"},Ep=Object.keys(pi);Qv={skill:"Skills",builtin:"Built-in",project:"Commands"},Rp={skill:0,project:1,builtin:2}});function ey(e){return!(!e||typeof e!="string"||e.length<1||e.length>40||e.startsWith("_")||Zv.test(e)||Xv.has(e.toLowerCase()))}function gi(e){if(!e||typeof e!="string")return{text:e||"",mentions:[]};let t=new Set;Fp.lastIndex=0;let s;for(;(s=Fp.exec(e))!==null;){let n=s[2];if(ey(n)&&!t.has(n)&&(t.add(n),t.size>=Jv))break}return{text:e,mentions:Array.from(t)}}var Xv,Fp,Zv,Jv,Va=F(()=>{Xv=new Set(["all","user","system","everyone"]),Fp=/(^|[\s\p{P}])@([A-Za-z0-9_-]{1,40})(?=$|[\s\p{P}])/gu,Zv=/^[0-9]+$/,Jv=32});function Op(e){let t=typeof e?.vpId=="string"?e.vpId:"";return Fa.has(t)?Fa.get(t):e?.isStock===!0?"other":"custom"}function vs(e){let t=new Map(mi.map(s=>[s.id,[]]));for(let s of Array.isArray(e)?e:[])!s||typeof s.vpId!="string"||!s.vpId||t.get(Op(s)).push(s);return mi.map(s=>({id:s.id,labelKey:s.labelKey,vps:t.get(s.id)})).filter(s=>s.vps.length>0)}function Un(e){return vs(e).flatMap(t=>t.vps)}function Hp(e){let t=new Map(mi.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=Op(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 ty,mi,Fa,zn=F(()=>{ty=[{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:[]}],mi=Object.freeze(ty.map(e=>Object.freeze({id:e.id,labelKey:e.labelKey,vpIds:Object.freeze([...e.vpIds])}))),Fa=new Map;for(let e of mi)for(let t of e.vpIds)Fa.set(t,e.id)});function Oa(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 Un(c).slice(0,qp)}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:[],f=!1;for(let k of u){let y=String(k||"").toLowerCase();if(y&&y.startsWith(n)){f=!0;break}}if(f){l(c,i);continue}let p=String(c.displayName||"").toLowerCase(),g=String(c.displayNameZh||""),v=[c.description,c.descriptionZh,c.role,c.roleZh].map(k=>String(k||"").toLowerCase()),h=typeof t=="string"?t:"",A=p.includes(n)||h&&g.includes(h),w=n&&v.some(k=>k.includes(n));(A||w)&&l(c,o)}return[...Un(r),...Un(i),...Un(o)].slice(0,qp)}function Ha(e="chat-input"){return`${e}-vp-mention-listbox`}function qa(e,t){let s=String(t||"").replace(/[^A-Za-z0-9_.:-]/g,"-");return`${e}-vp-mention-option-${s}`}function sy(e){let t=0;return Hp(e).map(s=>({...s,items:s.vps.map(n=>({vp:n,flatIndex:t++}))}))}function Np(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 Bp(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 qp,Wp,jp=F(()=>{zn();qp=12;Wp={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:`
|
|
1668
|
+
`,emits:["new-conversation","resume-conversation","open-settings","quote-message","edit-message-as-new"],setup(e,{expose:t}){let s=Pinia.useChatStore(),n=_e(),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=S=>String(S?.id||S?.turnId||S?.messageId||S?.atMessageId||S?.message?.id||"turn_unknown"),f=S=>{let V=u(S);return Object.prototype.hasOwnProperty.call(l,V)?!!l[V]:!1},p=(S,V)=>{l[u(S)]=!!V},g=({key:S,value:V}={})=>{S&&(c[S]=!!V)},h=S=>{let V=Ap(S,Yt);return Number.isFinite(V)?V:Yt(S)},v=S=>ci(S),C=S=>{let V=Array.isArray(S?.collapsedResponsePreview)?S.collapsedResponsePreview:Cp(S);return Array.isArray(V)?V:V?[String(V)]:[]},w=S=>{let V=Array.isArray(S?.items)?S.items.find(we=>jn(we)):null,q=V?.speakerVpId||V?.vpId||V?.message?.speakerVpId||V?.message?.vpId||S?.vpId||"",ue=q&&r&&typeof r.vpLabel=="function"?r.vpLabel(q)||q:q||(typeof i=="function"?i("message.assistant"):"Assistant"),Se=q&&r&&typeof r.vpTextColor=="function"?{color:r.vpTextColor(q)}:{},ie=V?.speakerTimestamp||V?.timestamp||V?.createdAt||V?.message?.timestamp||V?.message?.createdAt||0,Oe="",je="";if(ie)try{let we=new Date(ie);Number.isNaN(we.getTime())||(Oe=vt(ie),je=we.toLocaleString())}catch{}return{name:ue,style:Se,timeText:Oe,fullTimeText:je}},k=S=>{let V=Array.isArray(S?.items)?S.items:[];for(let q=V.length-1;q>=0;q-=1)if(jn(V[q]))return V[q];return null},y=(S,V)=>!S?.responseCollapsible||!V?!1:k(S)===V,m=S=>!!(S?.responseCollapsible&&!ci(S).some(V=>y(S,V))),b=S=>{let V=S?.responseCollapseKey;V&&(d[V]=!S.responseCollapsed)},T=S=>{let V=Number(S?.responseCount||0),q=S?.responseCollapsed?"message.showResponses":"message.hideResponses",ue=(typeof i=="function"?i(q):"")||(S?.responseCollapsed?"Show {count} response(s)":"Hide response(s)");return String(ue).replace("{count}",String(V))},L=(()=>{try{return window.Pinia?.useSessionsStore?.()||null}catch{return null}}),N=Vue.computed(()=>{if(s.currentView!=="yeaft")return null;let S=L();if(!S)return null;let V=s.yeaftActiveSessionFilter||null;return V&&typeof S.sessionById=="function"&&S.sessionById(V,s.currentAgent||null)?V:S.activeSessionId&&typeof S.sessionById=="function"&&S.sessionById(S.activeSessionId,s.currentAgent||null)?S.activeSessionId:null}),$=Vue.computed(()=>{let S=s.currentView||"",V=s.currentAgent||"";if(S==="yeaft"){let q=s.yeaftActiveSessionFilter||N.value||"__all__";return[S,V,q].join("")}return[S,V,s.activeConversationId||""].join("")}),D=Vue.computed(()=>N.value!==null),P=Vue.computed(()=>s.agents.filter(S=>S.online)),M=Vue.ref(null),A=Vue.ref(null),R=Vue.ref(!1),j=Vue.ref(""),O=null,Y=0,te=n.token||"",he=()=>{M.value=null,A.value=null,j.value="",O=null,Y+=1},ce=Zr(),ke=Jr(),ve=Vue.computed(()=>ei({profile:M.value,agentSecret:A.value,serverWsUrl:Fn(location)})),ge=()=>{let S={"Content-Type":"application/json"};return n.token&&(S.Authorization=`Bearer ${n.token}`),S},x=async()=>{if(P.value.length>0||s.currentConversation)return;if(A.value||O)return O;R.value=!0,j.value="";let S=++Y;return O=(async()=>{let V=n.token||"",q=ge(),[ue,Se]=await Promise.all([fetch("/api/user/profile",{headers:q}),fetch("/api/user/agent-secret",{headers:q})]),ie=ue.ok?await ue.json():null;if(S!==Y||V!==(n.token||""))return;if(ie&&(M.value=ie),!Se.ok){let we="";try{we=(await Se.json())?.error||""}catch{}throw new Error(we||"Failed to load Agent secret")}let Oe=await Se.json();if(S!==Y||V!==(n.token||""))return;let je=Oe?.agentSecret||Oe?.agent_secret||null;A.value=je&&String(je).trim()?String(je):null})().catch(V=>{S===Y&&(j.value=V?.message||"Failed to load Agent secret")}).finally(()=>{S===Y&&(R.value=!1,O=null)}),O},K=async S=>{if(S)try{await navigator.clipboard.writeText(S)}catch{}},re=(S,V)=>{let q=S?.message||null,ue=S?.id||S?.atMessageId||q?.id||q?.messageId||`legacy_${V}`,Se=S?.speakerVpId||S?.vpId||q?.speakerVpId||q?.vpId||"";return{id:`message_${Se||"user"}_${ue}_${V}`,vpId:Se,messageId:ue}},ye=Vue.computed(()=>{let S=s.messages,V=[],q=null,ue=0,Se=()=>{if(q){q.isActive=!!(q.turnId&&Object.values(s.activeVpTurns||{}).some(tt=>((tt?.turnId||null)===q.turnId||!tt?.turnId&&s.activeVpTurns?.[q.turnId]===tt)&&(!s.currentAgent||!tt?.agentId||tt.agentId===s.currentAgent))),Vr(q);let we=!!(q.textContent||q.todoMsg||q.askMsg||q.imageMsgs.length>0),ae=q.toolMsgs.length>0||q.toolSummaryCount>0;(we||ae)&&(q.showSpeakerHeader=!!q.speakerVpId,V.push(q)),q=null}},ie=we=>{if(q){if(!q.speakerVpId){let ae=we.speakerVpId||we.vpId;ae&&(q.speakerVpId=ae,q.speakerTimestamp=typeof we.timestamp=="number"&&we.timestamp>0?we.timestamp:typeof we.createdAt=="number"?we.createdAt:0,typeof we.lastStateChangeCause=="string"&&!q.speakerStateCause&&(q.speakerStateCause=we.lastStateChangeCause))}!q.turnId&&we.turnId&&(q.turnId=we.turnId)}},Oe=()=>{ue++,q={type:"assistant-turn",id:"turn_"+ue,textContent:"",textSegments:[],isStreaming:!1,isActive:!1,isHistory:!1,todoMsg:null,toolMsgs:[],toolSummaryCount:0,imageMsgs:[],askMsg:null,messages:[],atMessageId:null,speakerVpId:null,speakerTimestamp:0,speakerStateCause:"",showSpeakerHeader:!1,turnId:null}},je=we=>{kp(q,we)&&Se()};for(let we=0;we<S.length;we++){let ae=S[we];if(ae.type==="user"){if(!ae.content||!ae.content.trim())continue;Se(),V.push({type:"user",id:ae.id||"u_"+we,message:ae});continue}if(ae.type==="system"||ae.type==="error"){Se(),V.push({type:ae.type,id:ae.id||"s_"+we,message:ae});continue}if(!(ae.type==="tool-result"||ae.type==="tool_result")){if(ae.type==="tool-summary"){je(ae),q||Oe(),ie(ae),ae.isHistory&&(q.isHistory=!0),q.toolSummaryCount+=Number(ae.count||ae.omittedCount||0)||0,q.messages.push(ae);continue}if(ae.type==="assistant"){je(ae),q||Oe(),$r(q,ae),ae.isStreaming&&(q.isStreaming=!0),ae.isHistory&&(q.isHistory=!0),ae.id&&/^m\d+$/.test(ae.id)&&(q.atMessageId=ae.id),ie(ae),q.messages.push(ae);continue}if(ae.type==="tool-use"){je(ae),q||Oe(),ie(ae);let tt=S[we+1],dn=tt&&(tt.type==="tool-result"||tt.type==="tool_result"),Nt={...ae,hasResult:dn||ae.hasResult||!1,toolResult:ae.toolResult||null};ae.isHistory&&(q.isHistory=!0),ae.toolName==="TodoWrite"?q.todoMsg=Nt:ae.toolName==="AskUserQuestion"?q.askMsg=Nt:q.toolMsgs.push(Nt),q.messages.push(ae);continue}if(ae.type==="chat-image"){je(ae),q||Oe(),ie(ae),ae.isHistory&&(q.isHistory=!0),q.imageMsgs.push(ae),q.messages.push(ae);continue}Se(),V.push({type:ae.type||"unknown",id:ae.id||"x_"+we,message:ae})}}return Se(),V}),W=Vue.computed(()=>{let S=[],V=null,q=()=>{V&&S.push(V),V=null};return ye.value.forEach((ue,Se)=>{if(!ue||ue.type==="system"||ue.type==="error"){q(),S.push(ue);return}let ie=re(ue,Se);if(ue.type==="user"||!V){q(),V={type:"message-block",id:`turn_${ie.messageId}_${Se}`,vpId:ie.vpId,messageId:ie.messageId,items:[ue]};return}V.items.push(ue),!V.vpId&&ie.vpId&&(V.vpId=ie.vpId)}),q(),S}),ne=Vue.computed(()=>{let S=s.yeaftReflectionCards||{},V=s.yeaftConversationId,q={__orphans:[]},ue=Object.values(S).filter(ie=>ie&&ie.conversationId===V).sort((ie,Oe)=>(ie.anchorOrder||0)-(Oe.anchorOrder||0)||(ie.updatedAt||0)-(Oe.updatedAt||0)),Se=new Set;for(let ie of s.messages||[])ie&&ie.id&&Se.add(ie.id);for(let ie of ue)ie.anchorMsgId&&Se.has(ie.anchorMsgId)?(q[ie.anchorMsgId]||(q[ie.anchorMsgId]=[]),q[ie.anchorMsgId].push(ie)):q.__orphans.push(ie);return q}),U=S=>S?S.type==="assistant-turn"?S.atMessageId||null:S.message&&S.message.id||null:null,B=S=>{let V=U(S);return V?(ne.value||{})[V]||[]:[]},H=Vue.computed(()=>(ne.value||{}).__orphans||[]),_=Vue.computed(()=>{let S=s.yeaftSubAgentCards||{},V=s.yeaftConversationId,q={__orphans:[]},ue=Object.values(S).filter(ie=>ie&&ie.conversationId===V).sort((ie,Oe)=>(ie.anchorOrder||0)-(Oe.anchorOrder||0)||(ie.updatedAt||0)-(Oe.updatedAt||0)),Se=new Set;for(let ie of s.messages||[])ie&&ie.id&&Se.add(ie.id);for(let ie of ue)ie.anchorMsgId&&Se.has(ie.anchorMsgId)?(q[ie.anchorMsgId]||(q[ie.anchorMsgId]=[]),q[ie.anchorMsgId].push(ie)):q.__orphans.push(ie);return q}),J=S=>{let V=U(S);return V?(_.value||{})[V]||[]:[]},se=Vue.computed(()=>(_.value||{}).__orphans||[]),me=Vue.ref(!0),z=Vue.ref(!1),ee=Et.bottomThreshold,pe=Et.resumeBottomThreshold,oe=!0,De=Vue.computed(()=>s.messages.some(S=>S.isStreaming)),$e=Vue.computed(()=>!s.activeConversationId||W.value.length>0?!1:s.currentView==="yeaft"?!!s.yeaftInitialHistoryLoading:!!s.sessionLoading),Fe=Vue.computed(()=>s.currentView==="yeaft"&&!!s.yeaftLoadingMoreHistory&&s.activeYeaftHistoryState?.mode==="older"),Ue=Vue.computed(()=>s.currentView==="yeaft"?"":s.sessionLoadingText||""),Zt=Vue.computed(()=>!!s.sessionLoading&&!$e.value),St=Vue.computed(()=>s.isProcessing&&!De.value),Lt=Vue.ref(Date.now()),It=null,$t=()=>{It||(It=setInterval(()=>{Lt.value=Date.now()},1e3))},ft=()=>{It&&(clearInterval(It),It=null)};Vue.watch(De,S=>{S?(Lt.value=Date.now(),$t()):ft()},{immediate:!0}),Vue.onBeforeUnmount(()=>ft());let Ne=Vue.ref(0),We=Vue.ref(Date.now()),Vt=null,Ge=null,E=Vue.ref("cat"),X=new URLSearchParams(window.location.search).get("preview"),fe=Vue.ref(0),de=Vue.ref(1),be=Vue.ref(5),Ie=Vue.ref(95),Le=Vue.ref("bark-both"),He=Vue.ref(1),Be=Vue.ref(-1),Ke=null;function Ft(){if(!Ne.value)return;We.value=Date.now();let S=(We.value-Ne.value)%19e3;if(S<4e3)fe.value=0,de.value=1;else if(S<11500){let V=S-4e3,q;V<2500?q=V/2500*16:V<5e3?q=16+(V-2500)/2500*29:q=45+(V-5e3)/2500*55,fe.value=q,de.value=1}else S<14e3?(fe.value=(1-(S-11500)/2500)*100,de.value=-1):(fe.value=0,de.value=1);Ge=requestAnimationFrame(Ft)}function tn(){if(!Ne.value||E.value!=="dog")return;We.value=Date.now();let S=(We.value-Ne.value)%18e3;if(S<2e3)be.value=5,Ie.value=95,Le.value="bark-both",He.value=1,Be.value=-1;else if(S<5e3){let V=(S-2e3)/3e3;be.value=5+V*25,Ie.value=95,Le.value="left-approach",He.value=1,Be.value=-1}else if(S<8e3){let V=(S-5e3)/3e3;be.value=30,Ie.value=95-V*25,Le.value="right-approach",He.value=1,Be.value=-1}else if(S<1e4){let V=(S-8e3)/2e3;be.value=30+V*13,Ie.value=70-V*13,Le.value="both-approach",He.value=1,Be.value=-1}else if(S<11e3)be.value=43,Ie.value=57,Le.value="snap",He.value=1,Be.value=-1;else if(S<12500)be.value=43,Ie.value=57,Le.value="stunned",He.value=1,Be.value=-1;else if(S<15e3){let V=(S-12500)/2500;be.value=43-V*38,Ie.value=57+V*38,Le.value="retreat",He.value=-1,Be.value=1}else S<17e3?(be.value=5,Ie.value=95,Le.value="rehang",He.value=-1,Be.value=1):(be.value=5,Ie.value=95,Le.value="reset",He.value=1,Be.value=-1);Ke=requestAnimationFrame(tn)}let Wi=Vue.computed(()=>{let S=be.value*1.2;return He.value<0?`translate(${S+13.5}, 0) scale(-1, 1)`:`translate(${S-13.5}, 0)`}),ji=Vue.computed(()=>{let S=Ie.value*1.2;return Be.value>0?`translate(${S-10.5}, 2)`:`translate(${S+10.5}, 2) scale(-1, 1)`}),er=Vue.computed(()=>{let S=Le.value;return S==="bark-both"||S==="left-approach"||S==="right-approach"||S==="both-approach"||S==="reset"}),tr=Vue.computed(()=>{let S=be.value*1.2,V=10;if(er.value){let Se=Math.max(0,(S-3)*.12);return`M3,18 Q${(3+S)/2},${18+Se} ${S},${V}`}if(Le.value==="rehang")return`M${S},${V} Q${S-3},20 3,18`;let q=He.value<0?1:-1,ue=S+q*8;return`M${S},${V} Q${S},18 ${ue},22`}),Ui=Vue.computed(()=>{let S=Ie.value*1.2,V=10;if(er.value){let Se=Math.max(0,(118-S)*.12);return`M118,18 Q${(118+S)/2},${18+Se} ${S},${V}`}if(Le.value==="rehang")return`M${S},${V} Q${S+3},20 118,18`;let q=Be.value>0?-1:1,ue=S+q*8;return`M${S},${V} Q${S},18 ${ue},22`}),zi=Vue.computed(()=>Le.value==="snap"?.2:.4),Ki=Vue.computed(()=>Le.value==="snap"?.2:.4),Yi=Vue.computed(()=>be.value*1.2),Gi=Vue.computed(()=>Ie.value*1.2),sn=X==="cat"||X==="dog"||X==="animation",sr=600,nn=Vue.ref(!1),et=null,nr=Vue.computed(()=>sn?!0:nn.value);Vue.watch(St,S=>{if(S)et&&(clearTimeout(et),et=null),nn.value=!0,Ne.value=Date.now(),We.value=Date.now(),E.value="cat",fe.value=0,de.value=1,be.value=5,Ie.value=95,Le.value="bark-both",He.value=1,Be.value=-1,E.value==="cat"?Ge=requestAnimationFrame(Ft):Ke=requestAnimationFrame(tn);else{let V=Ne.value?Date.now()-Ne.value:sr,q=Math.max(0,sr-V),ue=()=>{et=null,nn.value=!1,Ne.value=0,fe.value=0,de.value=1,Ge&&(cancelAnimationFrame(Ge),Ge=null),Ke&&(cancelAnimationFrame(Ke),Ke=null)};q===0?ue():(et&&clearTimeout(et),et=setTimeout(ue,q))}},{immediate:!0}),sn&&(Ne.value=Date.now(),We.value=Date.now(),X==="dog"?E.value="dog":E.value="cat",E.value==="cat"?Ge=requestAnimationFrame(Ft):(be.value=5,Ie.value=95,Le.value="bark-both",He.value=1,Be.value=-1,Ke=requestAnimationFrame(tn)));let Qi=Vue.computed(()=>{if(!s.isProcessing)return null;if(s.connectionState!=="connected")return"disconnected";let S=s.currentConversation;if(s.compactStatus?.conversationId===S&&s.compactStatus?.status==="compacting")return"compacting";let V=s.sessionHealth?.[S];return V?V.status:Ne.value&&We.value-Ne.value>8e3?"thinking":null}),Xi=Vue.computed(()=>{if(!Ne.value)return"speed-napping";let S=(We.value-Ne.value)%19e3;return S>=16e3?"speed-petted":S>=14e3?"speed-tired":S>=11500?"speed-crazy":S>=9e3?"speed-turbo":S>=6500?"speed-fast":S>=4e3?"speed-normal":"speed-napping"}),Zi=Vue.computed(()=>{let S=fe.value,V=de.value,ue={left:`calc(40px + (100% - 80px) * ${S/100})`};return V<0&&(ue.transform="scaleX(-1)"),ue});function Qe(){let S=s.currentConversation;if(!S)return;let V=s.conversations.find(q=>q.id===S);s.sendWsMessage({type:"refresh_conversation",conversationId:S,agentId:V?.agentId})}let rr=()=>{if(!o.value)return!0;let{scrollTop:S,scrollHeight:V,clientHeight:q}=o.value;return ms({scrollTop:S,scrollHeight:V,clientHeight:q,threshold:ee})},rn=(S,V=0,{allowContinuation:q=!1}={})=>{if(S>gp(V)){oe=!0;return}q&&(oe=!0),!(!oe||!or())&&(oe=!1,Jt())},Ji=S=>{if(!S)return"";let q=(Array.isArray(S.items)?S.items:[])[0]||null;return[S.type||"",S.messageId||"",S.turnId||"",S.vpId||"",q?.id||"",q?.turnId||"",q?.messageId||""].join(":")},ir=()=>{let S=W.value||[];return{blockCount:S.length,firstBlockIdentity:Ji(S[0])}},Is=(S,V)=>!S||!V?!1:V.blockCount>S.blockCount||V.firstBlockIdentity!==S.firstBlockIdentity,on=S=>{Vue.nextTick(()=>{if(!o.value)return;let V=ir();Is(S,V)&&rn(o.value.scrollTop||0,o.value.clientHeight||0,{allowContinuation:!0})})},eo=({scrollTop:S,scrollHeight:V,clientHeight:q})=>{let ue=ms({scrollTop:S,scrollHeight:V,clientHeight:q,threshold:ee});return me.value=ue,z.value=!ue,ue},Cs=()=>{z.value=!1,me.value=!0,a.value?.setBottomFollowEnabled?.(!0)},Ot=()=>{z.value=!0,me.value=!1,a.value?.setBottomFollowEnabled?.(!1),a.value?.cancelPendingBottomFollow?.()},to=({scrollTop:S,scrollHeight:V,clientHeight:q})=>{let ue=ms({scrollTop:S||0,scrollHeight:V||0,clientHeight:q||0,threshold:ee});me.value=mp({following:!z.value,atBottom:ue}),z.value=!me.value,a.value?.setBottomFollowEnabled?.(me.value),Ct||(es=Number(S||0)),rn(S||0,q||0)},so=(S,V)=>{let q=ir();if(!o.value){S(),on(q);return}let ue=o.value.scrollHeight,Se=o.value.scrollTop,ie=!1,Oe=null,je=()=>{ie||(ie=!0,Oe&&Oe(),Vue.nextTick(()=>{if(!o.value)return;let we=o.value.scrollHeight;o.value.scrollTop=we-ue+Se,on(q)}))};V&&(Oe=Vue.watch(V,we=>{we||je()})),S(),Vue.nextTick(()=>{(!V||!V())&&je()})},no=()=>{if(s.hasHiddenYeaftMessages){s.expandYeaftMessageWindow();return}s.loadMoreYeaftHistory()},or=()=>s.currentView==="yeaft"?s.hasHiddenYeaftMessages||s.yeaftHasMoreHistory&&!s.yeaftLoadingMoreHistory&&s.yeaftOldestLoadedSeq!=null:!!s.currentConversation&&s.hasMoreMessages&&!s.loadingMoreMessages,Jt=()=>{if(!or())return;let S=s.currentView==="yeaft";so(S?no:()=>s.loadMoreMessages(),S?()=>s.yeaftLoadingMoreHistory:()=>s.loadingMoreMessages)},Ct=!1,an=!1,Xe=null,es=0,ar=250,lr=()=>{Ct=!1,Xe&&(clearTimeout(Xe),Xe=null)},ts=()=>{an||(Xe&&clearTimeout(Xe),Xe=setTimeout(lr,ar))},As=S=>{Ct=!0,a.value?.clearTargetAnchor?.(),es=Number(o.value?.scrollTop||0),Number(S?.deltaY)<0&&Ot(),ts()},cr=S=>{vp(S,o.value)&&(an=!0,Ct=!0,a.value?.clearTargetAnchor?.(),es=Number(o.value?.scrollTop||0),Xe&&(clearTimeout(Xe),Xe=null))},xs=()=>{an=!1,ts()},dr=S=>{yp(S,o.value)&&((S.key==="ArrowUp"||S.key==="PageUp"||S.key==="Home")&&Ot(),Ct=!0,a.value?.clearTargetAnchor?.(),ts())},ur=()=>{let S=Number(o.value?.scrollTop||0),V=Ct?S-es:0,q=!z.value;es=S;let ue=rr(),Se=ms({scrollTop:S,scrollHeight:o.value?.scrollHeight||0,clientHeight:o.value?.clientHeight||0,threshold:pe});me.value=hp({following:q,atBottom:ue,resumeBoundaryReached:Se,direction:V}),z.value=!me.value,a.value?.setBottomFollowEnabled?.(me.value),me.value&&ln(),Ct&&ts(),o.value&&rn(o.value.scrollTop||0,o.value.clientHeight||0)},ln=()=>{s.currentView==="yeaft"&&s.pruneYeaftMessageWindow()},Ts=()=>{o.value&&(o.value.scrollTop=o.value.scrollHeight,Cs(),ln())},ro=()=>{Cs(),Vue.nextTick(Ts)},Ht=()=>{!z.value&&me.value&&(ln(),Vue.nextTick(Ts))},qt=S=>{if(!S)return"";if(Array.isArray(S.items))return S.items.map(qt).join(",");let V=S.message||{};return[S.type||"",S.id||"",S.atMessageId||"",S.turnId||"",S.messageId||"",S.speakerVpId||"",V.id||"",V.content?String(V.content).length:0,S.textContent?String(S.textContent).length:0,S.isStreaming||V.isStreaming?"streaming":"done"].join(":")},io=Vue.computed(()=>{let S=W.value||[];return[s.activeConversationId||"",N.value||"",qt(S[S.length-1])].join("|")});Vue.watch(()=>[s.currentConversation,P.value.length,n.token],()=>{let S=n.token||"";S!==te&&(te=S,he()),x()},{immediate:!0}),Vue.watch(io,Ht),Vue.watch(nr,S=>{S&&Ht()}),Vue.watch(()=>[s.activeConversationId,N.value],()=>{for(let S of Object.keys(l))delete l[S];for(let S of Object.keys(c))delete c[S];for(let S of Object.keys(d))delete d[S];Cs(),Vue.nextTick(Ts)});let cn=Vue.ref(null),pr=0;return t({revealMessage:async S=>S?(Ot(),await Pp({blocks:W.value,messageId:S,collapseStates:d,nextTick:Vue.nextTick,scrollToBlock:(q,ue)=>(Ot(),a.value?.scrollToKey?.(q,ue)),findRow:q=>{let ue=o.value?.querySelectorAll?.("[data-msg-id]")||[];return Array.from(ue).find(Se=>Se?.dataset?.msgId===q)||null},anchorRow:(q,ue,Se,ie)=>a.value?.anchorTarget?.(q,Se,ie),flashRow:q=>{let ue=++pr;cn.value=q,setTimeout(()=>{ue===pr&&(cn.value=null)},1800)}})):!1}),Vue.onMounted(()=>{Ts(),o.value&&(o.value.addEventListener("wheel",As,{passive:!0}),o.value.addEventListener("touchmove",As,{passive:!0}),o.value.addEventListener("pointerdown",cr,{passive:!0}),o.value.addEventListener("scroll",ur)),window.addEventListener("pointerup",xs,{passive:!0}),window.addEventListener("pointercancel",xs,{passive:!0}),window.addEventListener("keydown",dr)}),Vue.onUnmounted(()=>{o.value&&(o.value.removeEventListener("wheel",As),o.value.removeEventListener("touchmove",As),o.value.removeEventListener("pointerdown",cr),o.value.removeEventListener("scroll",ur)),window.removeEventListener("pointerup",xs),window.removeEventListener("pointercancel",xs),window.removeEventListener("keydown",dr),lr(),Vt&&(clearInterval(Vt),Vt=null),et&&(clearTimeout(et),et=null),Ge&&(cancelAnimationFrame(Ge),Ge=null),Ke&&(cancelAnimationFrame(Ke),Ke=null)}),{store:s,containerRef:o,virtualTranscriptRef:a,flashMsgId:cn,hasStreamingMessage:De,nowMs:Lt,showTypingDots:St,showInitialMessagesLoading:$e,showYeaftOlderHistoryLoading:Fe,showSessionLoadingOverlay:Zt,initialMessagesLoadingText:Ue,previewShowTypingDots:nr,isPreviewMode:sn,waitingStatus:Qi,animationType:E,catSpeed:Xi,catStyle:Zi,dogPhase:Le,spikeTransform:Wi,teddyTransform:ji,leashPathL:tr,leashPathR:Ui,leashOpacityL:zi,leashOpacityR:Ki,questionLX:Yi,questionRX:Gi,refreshSession:Qe,onlineAgents:P,welcomeInstallCommand:ce,welcomeLlmCommand:ke,welcomeServiceCommand:ve,welcomeSetupLoading:R,welcomeSetupError:j,copyWelcomeCommand:K,turnGroups:ye,messageBlocks:W,virtualTranscriptIdentity:$,estimateMessageBlockHeight:h,visibleItemsForBlock:v,collapsedResponsePreviewLines:C,collapsedResponsePreviewSpeaker:w,responseToggleBelongsToItem:y,showBlockResponseToggle:m,toggleMessageTurnResponse:b,responseCollapseLabel:T,turnUiKey:u,assistantTurnActionsExpandedFor:f,setAssistantTurnActionsExpanded:p,toolExpandStates:c,setToolExpanded:g,cardsForRow:B,orphanCards:H,subAgentCardsForRow:J,orphanSubAgentCards:se,useImStyleForUser:D,onClickLoadMore:Jt,onVirtualTranscriptScrollState:to,isAtBottom:me,scrollToLatest:ro}}}});function fi(...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 Dp(e,t,s){let n=t?e?.slashCommandsMap?.[t]:null;return e?.currentView==="yeaft"?fi(n):fi(n,s?e?.slashCommandsMap?.[`agent:${s}`]:null,e?.slashCommandsMap?.__preload__)}function Yv(e,t={},s=new Set){if(Kv.has(e)||Object.prototype.hasOwnProperty.call(pi,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 Lp(e,t={}){if(ui[e])return ui[e];if(pi[e])return pi[e];let s=e.startsWith("/")?e.slice(1):e;return t[s]?t[s]:Gv(s)}function Gv(e){return(e.includes(":")?e.split(":").pop():e).replace(/-/g," ").replace(/^\w/,s=>s.toUpperCase())}function $p(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=Yv(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)=>(Rp[o]??99)-(Rp[a]??99));return i.map((o,a)=>({label:Qv[o]||o,items:r[o],isLast:a===i.length-1}))}var ui,Kv,_p,pi,Ep,Qv,Rp,Vp=F(()=>{ui={"/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"},Kv=new Set(Object.keys(ui)),_p=Object.keys(ui),pi={"/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"},Ep=Object.keys(pi);Qv={skill:"Skills",builtin:"Built-in",project:"Commands"},Rp={skill:0,project:1,builtin:2}});function ey(e){return!(!e||typeof e!="string"||e.length<1||e.length>40||e.startsWith("_")||Zv.test(e)||Xv.has(e.toLowerCase()))}function gi(e){if(!e||typeof e!="string")return{text:e||"",mentions:[]};let t=new Set;Fp.lastIndex=0;let s;for(;(s=Fp.exec(e))!==null;){let n=s[2];if(ey(n)&&!t.has(n)&&(t.add(n),t.size>=Jv))break}return{text:e,mentions:Array.from(t)}}var Xv,Fp,Zv,Jv,Va=F(()=>{Xv=new Set(["all","user","system","everyone"]),Fp=/(^|[\s\p{P}])@([A-Za-z0-9_-]{1,40})(?=$|[\s\p{P}])/gu,Zv=/^[0-9]+$/,Jv=32});function Op(e){let t=typeof e?.vpId=="string"?e.vpId:"";return Fa.has(t)?Fa.get(t):e?.isStock===!0?"other":"custom"}function vs(e){let t=new Map(mi.map(s=>[s.id,[]]));for(let s of Array.isArray(e)?e:[])!s||typeof s.vpId!="string"||!s.vpId||t.get(Op(s)).push(s);return mi.map(s=>({id:s.id,labelKey:s.labelKey,vps:t.get(s.id)})).filter(s=>s.vps.length>0)}function Un(e){return vs(e).flatMap(t=>t.vps)}function Hp(e){let t=new Map(mi.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=Op(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 ty,mi,Fa,zn=F(()=>{ty=[{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:[]}],mi=Object.freeze(ty.map(e=>Object.freeze({id:e.id,labelKey:e.labelKey,vpIds:Object.freeze([...e.vpIds])}))),Fa=new Map;for(let e of mi)for(let t of e.vpIds)Fa.set(t,e.id)});function Oa(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 Un(c).slice(0,qp)}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:[],f=!1;for(let k of u){let y=String(k||"").toLowerCase();if(y&&y.startsWith(n)){f=!0;break}}if(f){l(c,i);continue}let p=String(c.displayName||"").toLowerCase(),g=String(c.displayNameZh||""),h=[c.description,c.descriptionZh,c.role,c.roleZh].map(k=>String(k||"").toLowerCase()),v=typeof t=="string"?t:"",C=p.includes(n)||v&&g.includes(v),w=n&&h.some(k=>k.includes(n));(C||w)&&l(c,o)}return[...Un(r),...Un(i),...Un(o)].slice(0,qp)}function Ha(e="chat-input"){return`${e}-vp-mention-listbox`}function qa(e,t){let s=String(t||"").replace(/[^A-Za-z0-9_.:-]/g,"-");return`${e}-vp-mention-option-${s}`}function sy(e){let t=0;return Hp(e).map(s=>({...s,items:s.vps.map(n=>({vp:n,flatIndex:t++}))}))}function Np(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 Bp(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 qp,Wp,jp=F(()=>{zn();qp=12;Wp={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:`
|
|
1669
1669
|
<div
|
|
1670
1670
|
class="slash-autocomplete vp-mention-autocomplete"
|
|
1671
1671
|
v-if="filteredList.length > 0"
|
|
@@ -1702,15 +1702,16 @@ ${String(e||"").trim()}
|
|
|
1702
1702
|
</div>
|
|
1703
1703
|
</div>
|
|
1704
1704
|
</div>
|
|
1705
|
-
`,setup(e){let t=Vue.computed(()=>Oa(e.vps,e.query)),s=Vue.computed(()=>sy(t.value)),n=Vue.computed(()=>Ha(e.inputId)),r=u=>qa(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 hi,Na=F(()=>{hi={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:
|
|
1705
|
+
`,setup(e){let t=Vue.computed(()=>Oa(e.vps,e.query)),s=Vue.computed(()=>sy(t.value)),n=Vue.computed(()=>Ha(e.inputId)),r=u=>qa(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 hi,Na=F(()=>{hi={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","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 h=n.value;if(!h)return;h.style.height="auto";let v=Math.min(h.scrollHeight,i);h.style.height=`${v}px`,r.value=h.scrollHeight>i},d=()=>{if(a===null){if(typeof requestAnimationFrame!="function"){c();return}a=requestAnimationFrame(()=>{a=null,c()})}},u=()=>{let h=n.value;h&&(h.style.height="auto",r.value=!1)},f=h=>{t("update:modelValue",h.target.value),t("input",h),c()},p=()=>Vue.nextTick(()=>n.value?.focus()),g=()=>n.value;return Vue.watch(()=>e.modelValue,h=>{Vue.nextTick(()=>{h?c():u()})}),Vue.onMounted(()=>{c();let h=s.value;!h||typeof ResizeObserver>"u"||(l=h.getBoundingClientRect().width,o=new ResizeObserver(v=>{let C=v[0]?.contentRect?.width??h.getBoundingClientRect().width;C!==l&&(l=C,d())}),o.observe(h))}),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:g,onInput:f,emit:t}},template:`
|
|
1706
1706
|
<div class="input-wrapper chat-composer" data-message-composer>
|
|
1707
|
-
<div class="textarea-wrapper">
|
|
1707
|
+
<div ref="textareaWrapperRef" class="textarea-wrapper">
|
|
1708
1708
|
<slot name="overlays"></slot>
|
|
1709
1709
|
<textarea
|
|
1710
1710
|
ref="textareaRef"
|
|
1711
1711
|
:value="modelValue"
|
|
1712
1712
|
:id="inputId || null"
|
|
1713
1713
|
:rows="rows"
|
|
1714
|
+
:class="{ 'is-scrollable': textareaScrollable }"
|
|
1714
1715
|
:placeholder="placeholder"
|
|
1715
1716
|
:disabled="disabled"
|
|
1716
1717
|
:aria-autocomplete="ariaAutocomplete"
|
|
@@ -1825,7 +1826,6 @@ ${String(e||"").trim()}
|
|
|
1825
1826
|
:disabled="isCompacting"
|
|
1826
1827
|
:can-send="canSend"
|
|
1827
1828
|
:show-stop="isStopVisible"
|
|
1828
|
-
:rows="3"
|
|
1829
1829
|
:input-id="inputElementId"
|
|
1830
1830
|
:send-label="$t('chatInput.send')"
|
|
1831
1831
|
:stop-label="$t('chatInput.stop')"
|
|
@@ -1910,8 +1910,8 @@ ${String(e||"").trim()}
|
|
|
1910
1910
|
</template>
|
|
1911
1911
|
</MessageComposer>
|
|
1912
1912
|
</footer>
|
|
1913
|
-
`,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(null),l=Vue.computed(()=>a.value?.getTextarea?.()||null),d=`chat-input-${Vue.getCurrentInstance()?.uid??0}`,u=Vue.ref(null),f=Vue.ref([]),p=Vue.computed(()=>f.value.some(E=>E.uploading)),g=Vue.ref(null),
|
|
1914
|
-
`||fe===0?j()?(
|
|
1913
|
+
`,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(null),l=Vue.computed(()=>a.value?.getTextarea?.()||null),d=`chat-input-${Vue.getCurrentInstance()?.uid??0}`,u=Vue.ref(null),f=Vue.ref([]),p=Vue.computed(()=>f.value.some(E=>E.uploading)),g=Vue.ref(null),h=Vue.ref(null),v=Vue.ref(null),C=Vue.computed(()=>!!e.sendFn),w=Vue.computed(()=>!s.btwMode),k=Vue.computed(()=>e.placeholderKey||"chatInput.placeholder"),y=Vue.computed(()=>e.showStop||!C.value&&s.isProcessing),m=Vue.computed({get:()=>s.expertSelections||[],set:E=>{s.expertSelections=E}}),b=Vue.ref(!1),T=Vue.ref(0),L=Vue.computed(()=>Jc(s.customExpertRoles)),N=Vue.computed(()=>{let E=o.value,X=E.lastIndexOf("@");if(X===-1||!b.value)return[];let fe=E.slice(X+1).toLowerCase();return L.value.filter(de=>fe?de.searchText.includes(fe):!0).filter(de=>!m.value.some(be=>be.role===de.roleId)).slice(0,12)}),$=E=>{if(m.value.length>=ls)return;let X={role:E.roleId,action:E.actionId};s.expertSelections=[...m.value,X];let fe=o.value,de=fe.lastIndexOf("@");de!==-1&&(o.value=fe.slice(0,de).trimEnd()),b.value=!1,Vue.nextTick(()=>l.value?.focus())},D=E=>{let X=[...m.value];X.splice(E,1),s.expertSelections=X},P=E=>as(E,s.customExpertRoles),M=E=>E==="completed"?"\u2713":E==="in_progress"?"\u2192":"\u25CB",A=Vue.ref(!1),R=Vue.ref(0),j=()=>s.currentView==="yeaft"&&!!s.currentAgent,O=Vue.computed(()=>{let E=o.value,X=E.lastIndexOf("@");return X<0||!A.value?"":E.slice(X+1)}),Y=Vue.computed(()=>{if(!i)return r.vpList||[];let E=s.yeaftActiveSessionFilter||i.activeSessionId||null,X=typeof i.sessionById=="function"?i.sessionById(E,s.currentAgent||null):i.sessions?.[E];return Np(r.vpList,X)}),te=Vue.computed(()=>Oa(Y.value,O.value)),he=Vue.computed(()=>!s.btwMode&&A.value&&!b.value&&te.value.length>0),ce=Ha(d),ke=Vue.computed(()=>{if(!he.value)return null;let E=te.value[R.value];return E?qa(d,E.vpId):null}),ve=E=>{!E||!E.vpId||(o.value=Bp(o.value,E.vpId),A.value=!1,R.value=0,Vue.nextTick(()=>l.value?.focus()))},ge=Vue.computed(()=>e.draftKey||e.conversationId||s.currentConversation||null);ge.value&&s.inputDrafts[ge.value]&&(o.value=s.inputDrafts[ge.value]),Vue.watch(o,E=>{let X=ge.value;X&&(E?s.inputDrafts[X]=E:delete s.inputDrafts[X])}),Vue.watch(te,E=>{if(E.length===0){R.value=0;return}R.value>=E.length&&(R.value=E.length-1)}),Vue.watch(ge,(E,X)=>{X&&o.value&&(s.inputDrafts[X]=o.value),o.value=E&&s.inputDrafts[E]||""});let x=E=>{if(!E||typeof E!="string")return;let X=o.value||"",fe=X.length>0&&!/\s$/.test(X),de=X+(fe?" ":"")+"@"+E+" ";o.value=de,Vue.nextTick(()=>{let be=l.value;be&&(be.focus(),be.setSelectionRange(de.length,de.length),se())})},K=Vue.ref(!1),re=Vue.ref(0),ye=Vue.computed(()=>{let E=e.conversationId||s.activeConversationId||s.currentConversation,X=s.currentAgent,fe=Dp(s,E,X),de=s.currentView==="yeaft"?Ep:_p;return fi(de,fe).map(Ie=>Ie.startsWith("/")?Ie:"/"+Ie)}),W=Vue.computed(()=>{let E=o.value.trim();if(!E.startsWith("/"))return[];let X=E.toLowerCase();return ye.value.filter(fe=>fe.toLowerCase().startsWith(X)&&fe.toLowerCase()!==X).map(fe=>({cmd:fe,desc:Lp(fe,s.slashCommandDescriptions)}))}),ne=Vue.computed(()=>$p(W.value,s.slashCommandDescriptions,ye.value)),U=Vue.computed(()=>W.value.map(E=>E.cmd)),B=Vue.computed(()=>e.conversationId||s.activeConversationId||s.currentConversation||null),H=Vue.computed(()=>s.compactStatus?.status==="compacting"&&s.compactStatus?.conversationId===B.value),_=E=>typeof E?.fileId=="string"&&E.fileId.trim().length>0,J=Vue.computed(()=>{if(H.value)return!1;let E=!!o.value.trim(),X=f.value.length>0;if(C.value){let Le=!p.value&&f.value.every(_);return(E||X)&&Le}let fe=m.value.length>0,de=m.value.some(Le=>Le.action),be=E||X||fe&&(E||de),Ie=!p.value&&f.value.every(_);return be&&s.currentAgent&&s.currentConversation&&Ie}),se=()=>a.value?.autoResize?.(),me=()=>a.value?.resetTextareaSize?.(),z=()=>{se();let E=o.value.trim();E.startsWith("/")&&!E.includes(" ")?(K.value=!0,re.value=0,b.value=!1):K.value=!1;let X=o.value,fe=X.lastIndexOf("@");if(fe!==-1&&!K.value){let de=fe>0?X[fe-1]:" ";de===" "||de===`
|
|
1914
|
+
`||fe===0?j()?(A.value=!0,R.value=0,b.value=!1):(b.value=!0,T.value=0,A.value=!1):(b.value=!1,A.value=!1)}else fe===-1&&(b.value=!1,A.value=!1)},ee=E=>{o.value=E+" ",K.value=!1,Vue.nextTick(()=>{l.value?.focus()})},pe=()=>{setTimeout(()=>{K.value=!1,b.value=!1,A.value=!1},150)},oe=async E=>{let X=Array.from(E.target.files||[]);X.length>0&&await Lt(X),E.target.value="",Vue.nextTick(()=>{l.value?.focus()})},De=async E=>{let X=E.clipboardData?.items;if(!X)return;let fe=[];for(let de of X)if(de.kind==="file"){let be=de.getAsFile();be&&fe.push(be)}fe.length>0&&(E.preventDefault(),await Lt(fe))},$e=E=>{let X=String(E||"").toLowerCase();return X==="image/png"?".png":X==="image/jpeg"?".jpg":X==="image/gif"?".gif":X==="image/webp"?".webp":X==="image/svg+xml"?".svg":X==="text/plain"?".txt":X==="application/json"?".json":""},Fe=(E,X)=>{let fe=typeof E?.name=="string"?E.name.trim():"";return fe||`${String(E?.type||"").startsWith("image/")?"pasted-image":"pasted-file"}-${Date.now()}-${X+1}${$e(E?.type)}`},Ue=1,Zt=E=>{let X=Number(E);return!Number.isFinite(X)||X<=0?"":X<1024?`${X} B`:X<1024*1024?`${Math.round(X/1024)} KB`:`${(X/(1024*1024)).toFixed(X<10*1024*1024?1:0)} MB`},St=async E=>{for(let X of E)X.uploading=!0,X.uploadError=!1;try{let X=new FormData;for(let He of E)X.append("files",He.file,He.uploadName);let fe={},de=n.getActiveToken?.()||n.token||null;de&&(fe.Authorization=`Bearer ${de}`);let be=await fetch("/api/upload",{method:"POST",headers:fe,body:X});if(!be.ok)throw new Error("Upload failed");let Ie=await be.json(),Le=Array.isArray(Ie.files)?Ie.files:[];for(let[He,Be]of E.entries()){let Ke=Le[He],Ft=typeof Ke?.fileId=="string"?Ke.fileId.trim():"";if(!Ft)throw new Error("Upload response is incomplete");Be.fileId=Ft,Be.uploading=!1,delete Be.uploadName}}catch{for(let fe of E)fe.fileId||(fe.uploading=!1,fe.uploadError=!0)}finally{Vue.nextTick(()=>l.value?.focus())}},Lt=async E=>{let X=[];for(let[fe,de]of E.entries()){let be=Fe(de,fe),Ie=Vue.reactive({localId:`attachment-${Ue++}`,file:de,name:be,size:de.size,uploadName:be,preview:null,uploading:!1,uploadError:!1,fileId:null});de.type.startsWith("image/")&&(Ie.preview=URL.createObjectURL(de)),f.value.push(Ie),X.push(Ie)}await St(X)},It=async E=>{!E||E.uploading||E.fileId||(E.uploadName=E.name,await St([E]))},$t=E=>{let X=f.value[E];X.preview&&URL.revokeObjectURL(X.preview),f.value.splice(E,1),Vue.nextTick(()=>{l.value?.focus()})},ft=()=>{if(!J.value)return;K.value=!1,b.value=!1,A.value=!1;let E=o.value.trim();if(e.sendFn){let de=f.value.filter(_).map(Ie=>({fileId:Ie.fileId,name:Ie.name,preview:Ie.preview,isImage:Ie.file?.type?.startsWith("image/")||!1,mimeType:Ie.file?.type||""})),be=de.length>0?de:void 0;e.quote?e.sendFn(E,be,e.quote):e.sendFn(E,be),f.value=[],e.quote&&t("quote-consumed"),o.value="",ge.value&&delete s.inputDrafts[ge.value],me();return}if(E==="/btw"||E.startsWith("/btw ")){let de=E.substring(4).trim();s.enterBtwMode(),de&&s.sendBtwQuestion(de),o.value="",ge.value&&delete s.inputDrafts[ge.value],me();return}if(s.btwMode){s.sendBtwQuestion(E),o.value="",ge.value&&delete s.inputDrafts[ge.value],me();return}let X=f.value.filter(_).map(de=>({fileId:de.fileId,name:de.name,preview:de.preview,isImage:de.file?.type?.startsWith("image/")||!1,mimeType:de.file?.type||""}));if(s.currentView==="yeaft"&&(E||X.length>0)){let de=gi(E).mentions,be=s.yeaftActiveSessionFilter||i?.activeSessionId||"grp_default";s.sendYeaftSessionMessage({groupId:be,text:E,mentions:de,attachments:X}),f.value=[],o.value="",ge.value&&delete s.inputDrafts[ge.value],me();return}let fe=[...m.value];s.sendMessage(o.value.trim(),X,{expertSelections:fe}),f.value=[],o.value="",s.expertSelections=[],ge.value&&delete s.inputDrafts[ge.value],me()},Ne=E=>{if(!(E.isComposing||E.keyCode===229)){if(E.key==="Escape"&&s.btwMode){E.preventDefault(),s.closeBtw();return}if(A.value){let X=te.value;if(X.length>0){if(E.key==="ArrowDown"){E.preventDefault(),R.value=(R.value+1)%X.length;return}if(E.key==="ArrowUp"){E.preventDefault(),R.value=(R.value-1+X.length)%X.length;return}if(E.key==="Tab"||E.key==="Enter"&&!E.shiftKey){E.preventDefault(),ve(X[R.value]);return}}if(E.key==="Escape"){E.preventDefault(),A.value=!1;return}}if(b.value&&N.value.length>0){if(E.key==="ArrowDown"){E.preventDefault(),T.value=(T.value+1)%N.value.length;return}if(E.key==="ArrowUp"){E.preventDefault(),T.value=(T.value-1+N.value.length)%N.value.length;return}if(E.key==="Tab"||E.key==="Enter"&&!E.shiftKey){E.preventDefault(),$(N.value[T.value]);return}if(E.key==="Escape"){E.preventDefault(),b.value=!1;return}}if(K.value&&U.value.length>0){if(E.key==="ArrowDown"){E.preventDefault(),re.value=(re.value+1)%U.value.length;return}if(E.key==="ArrowUp"){E.preventDefault(),re.value=(re.value-1+U.value.length)%U.value.length;return}if(E.key==="Tab"||E.key==="Enter"&&!E.shiftKey){E.preventDefault(),ee(U.value[re.value]);return}if(E.key==="Escape"){E.preventDefault(),K.value=!1;return}}E.key==="Enter"&&!E.shiftKey&&(E.preventDefault(),ft())}},We=()=>{e.cancelFn?e.cancelFn():s.cancelExecution()},Vt=E=>{o.value=typeof E=="string"?E:"",Vue.nextTick(()=>{se(),l.value?.focus();let X=o.value.length;l.value?.setSelectionRange(X,X)})},Ge=()=>Vue.nextTick(()=>l.value?.focus());return{store:s,inputText:o,inputRef:l,messageComposerRef:a,inputAreaRef:g,fileInput:u,attachments:f,uploading:p,canSend:J,isCompacting:H,isStopVisible:y,effectivePlaceholderKey:k,attachmentsAllowed:w,showAutocomplete:K,selectedIndex:re,filteredCommands:U,flatItems:W,groupedCommands:ne,autocompleteRef:h,sendFn:Vue.toRef(e,"sendFn"),expertSelections:m,showExpertAutocomplete:b,expertSelectedIndex:T,expertAutocompleteFiltered:N,expertAutocompleteRef:v,selectExpertItem:$,removeExpertSelection:D,getExpertLabel:P,todoStatusSymbol:M,autoResize:se,handleInput:z,selectCommand:ee,onBlur:pe,handleFileSelect:oe,handlePaste:De,formatFileSize:Zt,retryAttachment:It,removeAttachment:$t,send:ft,handleKeydown:Ne,cancelExecution:We,vpStore:r,inputElementId:d,showVpAutocomplete:A,vpMentionPopupOpen:he,vpMentionPopupId:ce,vpMentionActiveOptionId:ke,vpSelectedIndex:R,vpMentionQuery:O,mentionVpCandidates:Y,selectVpMention:ve,appendMention:x,replaceDraft:Vt,focusInput:Ge}}}});function Ba(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 Up(e){return e+":"+Math.random().toString(36).slice(2,8)}function Kn(e){return e?e.type==="pane"?[e.terminalId]:[...Kn(e.first),...Kn(e.second)]:[]}function bi(e){return e?e.type==="pane"?e.terminalId:bi(e.first):null}function yi(e,t,s){return e&&(e.type==="pane"?e.terminalId===t?s:e:{...e,first:yi(e.first,t,s),second:yi(e.second,t,s)})}function Gt(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=Gt(e.first,t),n=Gt(e.second,t);return s?n?{...e,first:s,second:n}:s:n}var zp=F(()=>{});var Kp,Yp=F(()=>{Kp={name:"PaneTree",props:{node:Object,terminals:Object,activePane:String,onActivate:Function,onClosePane:Function,setMountRef:Function},template:`
|
|
1915
1915
|
<div v-if="node.type === 'pane'"
|
|
1916
1916
|
class="terminal-pane"
|
|
1917
1917
|
:class="{ active: node.terminalId === activePane }"
|
|
@@ -1950,7 +1950,7 @@ ${String(e||"").trim()}
|
|
|
1950
1950
|
/>
|
|
1951
1951
|
</div>
|
|
1952
1952
|
</div>
|
|
1953
|
-
`,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,f=i.ratio;document.body.style.cursor=l?"col-resize":"row-resize",document.body.style.userSelect="none";let p=
|
|
1953
|
+
`,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,f=i.ratio;document.body.style.cursor=l?"col-resize":"row-resize",document.body.style.userSelect="none";let p=h=>{let C=(l?a?h.touches[0].clientX:h.clientX:a?h.touches[0].clientY:h.clientY)-c,w=Math.max(.1,Math.min(.9,f+C/u));i.ratio=w},g=()=>{document.body.style.cursor="",document.body.style.userSelect="",document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",g),document.removeEventListener("touchmove",p),document.removeEventListener("touchend",g),window.dispatchEvent(new CustomEvent("terminal-fit-all"))};document.addEventListener(a?"touchmove":"mousemove",p),document.addEventListener(a?"touchend":"mouseup",g)}}}}});var Gp,Qp=F(()=>{zp();Yp();Gp={name:"TerminalTab",components:{PaneTree:Kp},template:`
|
|
1954
1954
|
<div class="terminal-tab">
|
|
1955
1955
|
<div class="terminal-toolbar">
|
|
1956
1956
|
<button class="wb-btn" @click="splitPane('horizontal')" :disabled="!hasActivePane" :title="$t('terminal.splitH')">
|
|
@@ -1984,9 +1984,9 @@ ${String(e||"").trim()}
|
|
|
1984
1984
|
<div class="placeholder-text">{{ $t('terminal.autoCreate') }}</div>
|
|
1985
1985
|
</div>
|
|
1986
1986
|
</div>
|
|
1987
|
-
`,setup(){let e=Pinia.useChatStore(),t=Vue.inject("t"),s=Vue.reactive({}),n=Vue.reactive({}),r=Vue.reactive({}),i=Vue.ref(""),o={},a=!1,l=Vue.computed(()=>{let M=e.currentConversation;return M&&n[M]||null}),c=Vue.computed(()=>{let M=e.currentConversation;return M&&r[M]||""}),d=Vue.computed(()=>!!c.value),u=(M,C)=>{if(C){let R=o[M];if(o[M]=C,R&&R!==C){let j=s[M];j?.terminal?.element&&(C.innerHTML="",C.appendChild(j.terminal.element),Vue.nextTick(()=>{try{j.fitAddon?.fit()}catch{}}))}}},f=M=>{let C=e.currentConversation;C&&(r[C]=M)};async function p(){if(a)return!0;let M=typeof Terminal<"u"?Terminal.Terminal||Terminal:null,C=typeof FitAddon<"u"?FitAddon.FitAddon||FitAddon:null;if(!M||!C)try{await Ba("vendor/xterm.min.js"),await Ba("vendor/xterm-addon-fit.min.js"),M=typeof Terminal<"u"?Terminal.Terminal||Terminal:null,C=typeof FitAddon<"u"?FitAddon.FitAddon||FitAddon:null}catch{}return!M||!C?(i.value=t("terminal.xtermNotLoaded"),!1):(a=!0,!0)}function g(){let M=document.documentElement.getAttribute("data-theme")==="dark",R=getComputedStyle(document.documentElement).getPropertyValue("--bg-main").trim()||(M?"#212121":"#ffffff");return M?{background:R,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:R,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 v(M){if(!M||!e.currentAgent||!await p())return null;let C=Up(M),R=Terminal.Terminal||Terminal,j=FitAddon.FitAddon||FitAddon,O=new R({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:g(),allowProposedApi:!0}),Y=new j;return O.loadAddon(Y),O.attachCustomKeyEventHandler(te=>!((te.ctrlKey||te.metaKey)&&te.key==="v"||(te.ctrlKey||te.metaKey)&&te.key==="c"&&O.hasSelection())),s[C]={created:!0,connected:!1,terminal:O,fitAddon:Y},O.onData(te=>{e.sendWsMessage({type:"terminal_input",agentId:e.currentAgent,conversationId:M,terminalId:C,data:te,_clientId:e.clientId})}),C}async function h(M,C){let R=s[C];if(!R)return!1;let j=null;for(let O=0;O<10&&(await Vue.nextTick(),j=o[C],!(j||O>=2&&(await new Promise(Y=>setTimeout(Y,50)),j=o[C],j)));O++);return j?(R.terminal.open(j),R.fitAddon.fit(),e.sendWsMessage({type:"terminal_create",agentId:e.currentAgent,conversationId:M,terminalId:C,cols:R.terminal.cols,rows:R.terminal.rows,_clientId:e.clientId}),!0):(i.value=t("terminal.mountFailed"),R.terminal.dispose(),delete s[C],!1)}let A=!1;async function w(){let M=e.currentConversation;if(!M||!e.currentAgent||n[M]||A)return;A=!0,i.value="";let C=await v(M);if(!C){A=!1;return}n[M]=Vue.reactive({type:"pane",terminalId:C}),r[M]=C,await h(M,C)||(delete n[M],delete r[M]),A=!1}async function k(M){let C=e.currentConversation;if(!C||!r[C])return;let R=r[C],j=await v(C);if(!j)return;let O=Vue.reactive({type:"split",direction:M,ratio:.5,first:{type:"pane",terminalId:R},second:{type:"pane",terminalId:j}}),Y=yi(n[C],R,O);if(n[C]=Vue.reactive(Y),r[C]=j,!await h(C,j)){let he=Gt(n[C],j);he&&(n[C]=Vue.reactive(he)),r[C]=R;return}await Vue.nextTick(),b(C)}function y(M){let C=e.currentConversation;if(!C)return;let R=s[M];R&&(e.sendWsMessage({type:"terminal_close",agentId:e.currentAgent,conversationId:C,terminalId:M,_clientId:e.clientId}),R.terminal?.dispose(),delete s[M],delete o[M]);let j=Gt(n[C],M);j?(n[C]=Vue.reactive(j),r[C]===M&&(r[C]=bi(n[C])||""),Vue.nextTick(()=>b(C))):(delete n[C],delete r[C],Vue.nextTick(()=>w()))}function m(){let M=e.currentConversation;!M||!r[M]||y(r[M])}function b(M){if(M||(M=e.currentConversation),!M||!n[M])return;let C=Kn(n[M]);for(let R of C){let j=s[R];if(j?.fitAddon&&j.connected)try{j.fitAddon.fit(),e.sendWsMessage({type:"terminal_resize",agentId:e.currentAgent,conversationId:M,terminalId:R,cols:j.terminal.cols,rows:j.terminal.rows,_clientId:e.clientId})}catch{}}}function T(M){let C=M.detail;if(C)switch(C.type){case"terminal_created":{let R=C.terminalId||C.conversationId,j=s[R];if(j)if(C.success)j.connected=!0,i.value="";else{i.value=C.error||t("terminal.createFailed"),j.terminal?.dispose(),delete s[R];let O=C.conversationId;if(O&&n[O]){let Y=Gt(n[O],R);Y?n[O]=Vue.reactive(Y):(delete n[O],delete r[O])}}break}case"terminal_output":{let R=C.terminalId||C.conversationId,j=s[R];j?.terminal&&j.terminal.write(C.data);break}case"terminal_closed":{let R=C.terminalId||C.conversationId,j=s[R];if(j){j.terminal?.dispose(),delete s[R],delete o[R];let O=C.conversationId;if(O&&n[O]){let Y=Gt(n[O],R);Y?(n[O]=Vue.reactive(Y),r[O]===R&&(r[O]=bi(n[O])||"")):(delete n[O],delete r[O])}}break}case"terminal_error":{i.value=C.message||t("terminal.error");let R=C.terminalId;if(R&&s[R]&&!s[R].connected){s[R].terminal?.dispose(),delete s[R];let j=C.conversationId;if(j&&n[j]){let O=Gt(n[j],R);O?n[j]=Vue.reactive(O):(delete n[j],delete r[j])}}break}}}let L=null;function N(){clearTimeout(L),L=setTimeout(()=>b(),100)}function $(){b()}function D(M){let{conversationId:C}=M.detail;if(C&&n[C]){let R=Kn(n[C]);for(let j of R){let O=s[j];O&&(O.terminal?.dispose(),delete s[j],delete o[j])}delete n[C],delete r[C]}}Vue.onMounted(()=>{window.addEventListener("workbench-message",T),window.addEventListener("resize",N),window.addEventListener("terminal-fit-all",$),window.addEventListener("conversation-deleted",D)}),Vue.onUnmounted(()=>{window.removeEventListener("workbench-message",T),window.removeEventListener("resize",N),window.removeEventListener("terminal-fit-all",$),window.removeEventListener("conversation-deleted",D),clearTimeout(L);for(let M of Object.keys(s))s[M]?.terminal?.dispose()}),Vue.watch(()=>[e.currentConversation,e.workbenchExpanded],()=>{Vue.nextTick(()=>{if(!e.currentConversation||!e.workbenchExpanded)return;let C=document.querySelector(".terminal-tab");C&&C.offsetParent!==null&&w()})},{immediate:!0}),Vue.watch(()=>e.connectionState,(M,C)=>{if(M==="connected"&&C&&C!=="connected"){for(let R of Object.keys(s))s[R]?.terminal?.dispose(),delete s[R],delete o[R];for(let R of Object.keys(n))delete n[R],delete r[R];Vue.nextTick(()=>w())}}),Vue.watch(()=>e.currentConversation,()=>{Vue.nextTick(()=>b())});let P=null;return Vue.onMounted(()=>{let M=()=>{let R=document.querySelector(".terminal-tab");R&&R.offsetParent!==null&&(w(),b())};P=new MutationObserver(()=>{setTimeout(M,50)});let C=document.querySelector(".workbench-tab-content");C&&P.observe(C,{attributes:!0,subtree:!0,attributeFilter:["style"]})}),Vue.onUnmounted(()=>{P&&P.disconnect()}),{store:e,terminals:s,currentTree:l,currentActivePane:c,hasActivePane:d,terminalError:i,setMountRef:u,activatePane:f,splitPane:k,closeActivePane:m,closePane:y}}}});function wi(e){if(!e)return Yn(Z.default);let t=e.toLowerCase();if(Wa[t])return Wa[t]();let s=t.lastIndexOf(".");if(s>=0){let n=t.slice(s+1);if(Xp[n])return Xp[n]();let r=t;for(let[i,o]of Object.entries(Wa))if(r===i||r.endsWith("/"+i))return o()}return Yn(Z.default)}function ki(e=!1){return ny(Z.folder,e)}var Z,Yn,ny,Q,Xp,Wa,ja=F(()=>{Z={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",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"},Yn=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>`,ny=(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>`,Q=(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>`,Xp={js:()=>Q(Z.js,"JS"),mjs:()=>Q(Z.js,"JS"),cjs:()=>Q(Z.js,"JS"),ts:()=>Q(Z.ts,"TS"),mts:()=>Q(Z.ts,"TS"),jsx:()=>Q(Z.jsx,"JSX"),tsx:()=>Q(Z.tsx,"TSX"),html:()=>Q(Z.html,"</>"),htm:()=>Q(Z.html,"</>"),css:()=>Q(Z.css,"CSS"),scss:()=>Q(Z.scss,"SC"),sass:()=>Q(Z.scss,"SA"),less:()=>Q(Z.less,"LS"),vue:()=>Q(Z.vue,"V"),svelte:()=>Q(Z.svelte,"SV"),json:()=>Q(Z.json,"{ }"),yaml:()=>Q(Z.yaml,"YML"),yml:()=>Q(Z.yaml,"YML"),toml:()=>Q(Z.config,"TML"),xml:()=>Q(Z.xml,"</>"),csv:()=>Q(Z.config,"CSV"),md:()=>Q(Z.md,"MD"),markdown:()=>Q(Z.md,"MD"),txt:()=>Yn(Z.txt),log:()=>Yn(Z.log),pdf:()=>Q("#E53935","PDF"),py:()=>Q(Z.py,"PY"),rb:()=>Q(Z.rb,"RB"),go:()=>Q(Z.go,"GO"),rs:()=>Q(Z.rs,"RS"),java:()=>Q(Z.java,"JA"),cs:()=>Q(Z.cs,"C#"),cpp:()=>Q(Z.cpp,"C+"),cc:()=>Q(Z.cpp,"C+"),c:()=>Q(Z.c,"C"),h:()=>Q(Z.c,"H"),hpp:()=>Q(Z.cpp,"H+"),swift:()=>Q(Z.swift,"SW"),kt:()=>Q(Z.kt,"KT"),php:()=>Q(Z.php,"PHP"),lua:()=>Q(Z.lua,"LUA"),r:()=>Q(Z.r,"R"),dart:()=>Q(Z.dart,"DA"),sh:()=>Q(Z.sh,">_"),bash:()=>Q(Z.sh,">_"),zsh:()=>Q(Z.sh,">_"),fish:()=>Q(Z.sh,">_"),ps1:()=>Q(Z.ps1,"PS"),bat:()=>Q(Z.ps1,"BAT"),cmd:()=>Q(Z.ps1,"CMD"),sql:()=>Q(Z.sql,"SQL"),db:()=>Q(Z.sql,"DB"),sqlite:()=>Q(Z.sql,"DB"),svg:()=>Q(Z.svg,"SVG"),png:()=>Q(Z.img,"PNG"),jpg:()=>Q(Z.img,"JPG"),jpeg:()=>Q(Z.img,"JPG"),gif:()=>Q(Z.img,"GIF"),ico:()=>Q(Z.img,"ICO"),webp:()=>Q(Z.img,"WP"),lock:()=>Yn(Z.lock),env:()=>Q(Z.env,"ENV"),ini:()=>Q(Z.config,"INI"),cfg:()=>Q(Z.config,"CFG"),conf:()=>Q(Z.config,"CNF"),liquid:()=>Q(Z.liquid,"LQ"),ejs:()=>Q(Z.html,"EJS"),hbs:()=>Q(Z.html,"HBS"),pug:()=>Q(Z.html,"PUG"),wasm:()=>Q("#654FF0","WA"),proto:()=>Q(Z.config,"PB"),graphql:()=>Q("#E535AB","GQL"),gql:()=>Q("#E535AB","GQL")},Wa={dockerfile:()=>Q(Z.docker,"DK"),"docker-compose.yml":()=>Q(Z.docker,"DC"),"docker-compose.yaml":()=>Q(Z.docker,"DC"),".gitignore":()=>Q(Z.git,"GI"),".gitattributes":()=>Q(Z.git,"GA"),".gitmodules":()=>Q(Z.git,"GM"),".env":()=>Q(Z.env,"ENV"),".env.local":()=>Q(Z.env,"ENV"),".env.development":()=>Q(Z.env,"ENV"),".env.production":()=>Q(Z.env,"ENV"),"package.json":()=>Q("#CB3837","NPM"),"package-lock.json":()=>Q("#CB3837","NPM"),"tsconfig.json":()=>Q(Z.ts,"TSC"),eslintrc:()=>Q("#4B32C3","ESL"),".eslintrc.js":()=>Q("#4B32C3","ESL"),".eslintrc.json":()=>Q("#4B32C3","ESL"),".prettierrc":()=>Q("#F7B93E","PR"),makefile:()=>Q(Z.config,"MK"),"cmakelists.txt":()=>Q("#064F8C","CM"),"readme.md":()=>Q(Z.md,"RM"),license:()=>Q("#F5C518","LIC"),"license.md":()=>Q("#F5C518","LIC"),"cargo.toml":()=>Q(Z.rs,"CG"),"go.mod":()=>Q(Z.go,"MOD"),"go.sum":()=>Q(Z.go,"SUM"),gemfile:()=>Q(Z.rb,"GEM"),rakefile:()=>Q(Z.rb,"RK"),"requirements.txt":()=>Q(Z.py,"REQ"),pipfile:()=>Q(Z.py,"PIP"),csproj:()=>Q(Z.cs,"CSP"),".sln":()=>Q(Z.cs,"SLN"),slnx:()=>Q(Z.cs,"SLN")}});function ys(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function ry(e,t){if(!e||!t)return ys(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],f=d.index+(d[1]!==void 0?d[0].indexOf(d[1]):0);if(s.push({start:f,end:f+u.length,cls:l}),!c.global)break}},r=t.commentType||"slash";if((r==="slash"||r==="both")&&(n(Qs.comment1,xe.comment),n(Qs.commentBlock,xe.comment)),(r==="hash"||r==="both")&&n(Qs.commentHash,xe.comment),r==="html"&&n(t.commentHtml,xe.comment),t.commentLine&&n(t.commentLine,xe.comment),t.commentBlock&&n(t.commentBlock,xe.comment),n(Qs.string,xe.string),n(Qs.number,xe.number),t.keywords&&n(t.keywords,xe.keyword),t.builtins&&n(t.builtins,xe.builtin),t.operators&&n(t.operators,xe.operator),t.decorators&&n(t.decorators,xe.decorator),t.macros&&n(t.macros,xe.macro),t.preprocessor&&n(t.preprocessor,xe.preprocessor),t.attributes&&n(t.attributes,xe.attribute),t.tags&&n(t.tags,xe.tag),t.properties&&n(t.properties,xe.property),t.variables&&n(t.variables,xe.variable),t.headings&&n(t.headings,xe.heading),t.bold&&n(t.bold,xe.bold),t.links&&n(t.links,xe.link),t.keys&&n(t.keys,xe.key),t.sections&&n(t.sections,xe.section),t.selectors&&n(t.selectors,xe.keyword),t.values&&n(t.values,xe.number),t.code&&n(t.code,xe.string),t.italic&&n(t.italic,xe.builtin),t.attrs&&n(t.attrs,xe.attribute),s.length===0)return ys(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+=ys(e.slice(o,a.start))),i+=`<span class="${a.cls}">${ys(e.slice(a.start,a.end))}</span>`,o=a.end);return o<e.length&&(i+=ys(e.slice(o))),i}function iy(e){if(!e)return null;let t=e.split(".").pop()?.toLowerCase();if(!t)return null;let s=Zp[t];return typeof s=="string"&&(s=Zp[s]),s||null}function Jp(e,t){if(!e)return ys(e||"");let s=iy(t);return s?ry(e,s):ys(e)}var Qs,Zp,xe,ef=F(()=>{Qs={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},Zp={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}},xe={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 tf(e,t,s){let n=[],r=0,i=0;if(t!=null){let p=t.split(`
|
|
1987
|
+
`,setup(){let e=Pinia.useChatStore(),t=Vue.inject("t"),s=Vue.reactive({}),n=Vue.reactive({}),r=Vue.reactive({}),i=Vue.ref(""),o={},a=!1,l=Vue.computed(()=>{let M=e.currentConversation;return M&&n[M]||null}),c=Vue.computed(()=>{let M=e.currentConversation;return M&&r[M]||""}),d=Vue.computed(()=>!!c.value),u=(M,A)=>{if(A){let R=o[M];if(o[M]=A,R&&R!==A){let j=s[M];j?.terminal?.element&&(A.innerHTML="",A.appendChild(j.terminal.element),Vue.nextTick(()=>{try{j.fitAddon?.fit()}catch{}}))}}},f=M=>{let A=e.currentConversation;A&&(r[A]=M)};async function p(){if(a)return!0;let M=typeof Terminal<"u"?Terminal.Terminal||Terminal:null,A=typeof FitAddon<"u"?FitAddon.FitAddon||FitAddon:null;if(!M||!A)try{await Ba("vendor/xterm.min.js"),await Ba("vendor/xterm-addon-fit.min.js"),M=typeof Terminal<"u"?Terminal.Terminal||Terminal:null,A=typeof FitAddon<"u"?FitAddon.FitAddon||FitAddon:null}catch{}return!M||!A?(i.value=t("terminal.xtermNotLoaded"),!1):(a=!0,!0)}function g(){let M=document.documentElement.getAttribute("data-theme")==="dark",R=getComputedStyle(document.documentElement).getPropertyValue("--bg-main").trim()||(M?"#212121":"#ffffff");return M?{background:R,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:R,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(M){if(!M||!e.currentAgent||!await p())return null;let A=Up(M),R=Terminal.Terminal||Terminal,j=FitAddon.FitAddon||FitAddon,O=new R({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:g(),allowProposedApi:!0}),Y=new j;return O.loadAddon(Y),O.attachCustomKeyEventHandler(te=>!((te.ctrlKey||te.metaKey)&&te.key==="v"||(te.ctrlKey||te.metaKey)&&te.key==="c"&&O.hasSelection())),s[A]={created:!0,connected:!1,terminal:O,fitAddon:Y},O.onData(te=>{e.sendWsMessage({type:"terminal_input",agentId:e.currentAgent,conversationId:M,terminalId:A,data:te,_clientId:e.clientId})}),A}async function v(M,A){let R=s[A];if(!R)return!1;let j=null;for(let O=0;O<10&&(await Vue.nextTick(),j=o[A],!(j||O>=2&&(await new Promise(Y=>setTimeout(Y,50)),j=o[A],j)));O++);return j?(R.terminal.open(j),R.fitAddon.fit(),e.sendWsMessage({type:"terminal_create",agentId:e.currentAgent,conversationId:M,terminalId:A,cols:R.terminal.cols,rows:R.terminal.rows,_clientId:e.clientId}),!0):(i.value=t("terminal.mountFailed"),R.terminal.dispose(),delete s[A],!1)}let C=!1;async function w(){let M=e.currentConversation;if(!M||!e.currentAgent||n[M]||C)return;C=!0,i.value="";let A=await h(M);if(!A){C=!1;return}n[M]=Vue.reactive({type:"pane",terminalId:A}),r[M]=A,await v(M,A)||(delete n[M],delete r[M]),C=!1}async function k(M){let A=e.currentConversation;if(!A||!r[A])return;let R=r[A],j=await h(A);if(!j)return;let O=Vue.reactive({type:"split",direction:M,ratio:.5,first:{type:"pane",terminalId:R},second:{type:"pane",terminalId:j}}),Y=yi(n[A],R,O);if(n[A]=Vue.reactive(Y),r[A]=j,!await v(A,j)){let he=Gt(n[A],j);he&&(n[A]=Vue.reactive(he)),r[A]=R;return}await Vue.nextTick(),b(A)}function y(M){let A=e.currentConversation;if(!A)return;let R=s[M];R&&(e.sendWsMessage({type:"terminal_close",agentId:e.currentAgent,conversationId:A,terminalId:M,_clientId:e.clientId}),R.terminal?.dispose(),delete s[M],delete o[M]);let j=Gt(n[A],M);j?(n[A]=Vue.reactive(j),r[A]===M&&(r[A]=bi(n[A])||""),Vue.nextTick(()=>b(A))):(delete n[A],delete r[A],Vue.nextTick(()=>w()))}function m(){let M=e.currentConversation;!M||!r[M]||y(r[M])}function b(M){if(M||(M=e.currentConversation),!M||!n[M])return;let A=Kn(n[M]);for(let R of A){let j=s[R];if(j?.fitAddon&&j.connected)try{j.fitAddon.fit(),e.sendWsMessage({type:"terminal_resize",agentId:e.currentAgent,conversationId:M,terminalId:R,cols:j.terminal.cols,rows:j.terminal.rows,_clientId:e.clientId})}catch{}}}function T(M){let A=M.detail;if(A)switch(A.type){case"terminal_created":{let R=A.terminalId||A.conversationId,j=s[R];if(j)if(A.success)j.connected=!0,i.value="";else{i.value=A.error||t("terminal.createFailed"),j.terminal?.dispose(),delete s[R];let O=A.conversationId;if(O&&n[O]){let Y=Gt(n[O],R);Y?n[O]=Vue.reactive(Y):(delete n[O],delete r[O])}}break}case"terminal_output":{let R=A.terminalId||A.conversationId,j=s[R];j?.terminal&&j.terminal.write(A.data);break}case"terminal_closed":{let R=A.terminalId||A.conversationId,j=s[R];if(j){j.terminal?.dispose(),delete s[R],delete o[R];let O=A.conversationId;if(O&&n[O]){let Y=Gt(n[O],R);Y?(n[O]=Vue.reactive(Y),r[O]===R&&(r[O]=bi(n[O])||"")):(delete n[O],delete r[O])}}break}case"terminal_error":{i.value=A.message||t("terminal.error");let R=A.terminalId;if(R&&s[R]&&!s[R].connected){s[R].terminal?.dispose(),delete s[R];let j=A.conversationId;if(j&&n[j]){let O=Gt(n[j],R);O?n[j]=Vue.reactive(O):(delete n[j],delete r[j])}}break}}}let L=null;function N(){clearTimeout(L),L=setTimeout(()=>b(),100)}function $(){b()}function D(M){let{conversationId:A}=M.detail;if(A&&n[A]){let R=Kn(n[A]);for(let j of R){let O=s[j];O&&(O.terminal?.dispose(),delete s[j],delete o[j])}delete n[A],delete r[A]}}Vue.onMounted(()=>{window.addEventListener("workbench-message",T),window.addEventListener("resize",N),window.addEventListener("terminal-fit-all",$),window.addEventListener("conversation-deleted",D)}),Vue.onUnmounted(()=>{window.removeEventListener("workbench-message",T),window.removeEventListener("resize",N),window.removeEventListener("terminal-fit-all",$),window.removeEventListener("conversation-deleted",D),clearTimeout(L);for(let M of Object.keys(s))s[M]?.terminal?.dispose()}),Vue.watch(()=>[e.currentConversation,e.workbenchExpanded],()=>{Vue.nextTick(()=>{if(!e.currentConversation||!e.workbenchExpanded)return;let A=document.querySelector(".terminal-tab");A&&A.offsetParent!==null&&w()})},{immediate:!0}),Vue.watch(()=>e.connectionState,(M,A)=>{if(M==="connected"&&A&&A!=="connected"){for(let R of Object.keys(s))s[R]?.terminal?.dispose(),delete s[R],delete o[R];for(let R of Object.keys(n))delete n[R],delete r[R];Vue.nextTick(()=>w())}}),Vue.watch(()=>e.currentConversation,()=>{Vue.nextTick(()=>b())});let P=null;return Vue.onMounted(()=>{let M=()=>{let R=document.querySelector(".terminal-tab");R&&R.offsetParent!==null&&(w(),b())};P=new MutationObserver(()=>{setTimeout(M,50)});let A=document.querySelector(".workbench-tab-content");A&&P.observe(A,{attributes:!0,subtree:!0,attributeFilter:["style"]})}),Vue.onUnmounted(()=>{P&&P.disconnect()}),{store:e,terminals:s,currentTree:l,currentActivePane:c,hasActivePane:d,terminalError:i,setMountRef:u,activatePane:f,splitPane:k,closeActivePane:m,closePane:y}}}});function wi(e){if(!e)return Yn(Z.default);let t=e.toLowerCase();if(Wa[t])return Wa[t]();let s=t.lastIndexOf(".");if(s>=0){let n=t.slice(s+1);if(Xp[n])return Xp[n]();let r=t;for(let[i,o]of Object.entries(Wa))if(r===i||r.endsWith("/"+i))return o()}return Yn(Z.default)}function ki(e=!1){return ny(Z.folder,e)}var Z,Yn,ny,Q,Xp,Wa,ja=F(()=>{Z={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",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"},Yn=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>`,ny=(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>`,Q=(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>`,Xp={js:()=>Q(Z.js,"JS"),mjs:()=>Q(Z.js,"JS"),cjs:()=>Q(Z.js,"JS"),ts:()=>Q(Z.ts,"TS"),mts:()=>Q(Z.ts,"TS"),jsx:()=>Q(Z.jsx,"JSX"),tsx:()=>Q(Z.tsx,"TSX"),html:()=>Q(Z.html,"</>"),htm:()=>Q(Z.html,"</>"),css:()=>Q(Z.css,"CSS"),scss:()=>Q(Z.scss,"SC"),sass:()=>Q(Z.scss,"SA"),less:()=>Q(Z.less,"LS"),vue:()=>Q(Z.vue,"V"),svelte:()=>Q(Z.svelte,"SV"),json:()=>Q(Z.json,"{ }"),yaml:()=>Q(Z.yaml,"YML"),yml:()=>Q(Z.yaml,"YML"),toml:()=>Q(Z.config,"TML"),xml:()=>Q(Z.xml,"</>"),csv:()=>Q(Z.config,"CSV"),md:()=>Q(Z.md,"MD"),markdown:()=>Q(Z.md,"MD"),txt:()=>Yn(Z.txt),log:()=>Yn(Z.log),pdf:()=>Q("#E53935","PDF"),py:()=>Q(Z.py,"PY"),rb:()=>Q(Z.rb,"RB"),go:()=>Q(Z.go,"GO"),rs:()=>Q(Z.rs,"RS"),java:()=>Q(Z.java,"JA"),cs:()=>Q(Z.cs,"C#"),cpp:()=>Q(Z.cpp,"C+"),cc:()=>Q(Z.cpp,"C+"),c:()=>Q(Z.c,"C"),h:()=>Q(Z.c,"H"),hpp:()=>Q(Z.cpp,"H+"),swift:()=>Q(Z.swift,"SW"),kt:()=>Q(Z.kt,"KT"),php:()=>Q(Z.php,"PHP"),lua:()=>Q(Z.lua,"LUA"),r:()=>Q(Z.r,"R"),dart:()=>Q(Z.dart,"DA"),sh:()=>Q(Z.sh,">_"),bash:()=>Q(Z.sh,">_"),zsh:()=>Q(Z.sh,">_"),fish:()=>Q(Z.sh,">_"),ps1:()=>Q(Z.ps1,"PS"),bat:()=>Q(Z.ps1,"BAT"),cmd:()=>Q(Z.ps1,"CMD"),sql:()=>Q(Z.sql,"SQL"),db:()=>Q(Z.sql,"DB"),sqlite:()=>Q(Z.sql,"DB"),svg:()=>Q(Z.svg,"SVG"),png:()=>Q(Z.img,"PNG"),jpg:()=>Q(Z.img,"JPG"),jpeg:()=>Q(Z.img,"JPG"),gif:()=>Q(Z.img,"GIF"),ico:()=>Q(Z.img,"ICO"),webp:()=>Q(Z.img,"WP"),lock:()=>Yn(Z.lock),env:()=>Q(Z.env,"ENV"),ini:()=>Q(Z.config,"INI"),cfg:()=>Q(Z.config,"CFG"),conf:()=>Q(Z.config,"CNF"),liquid:()=>Q(Z.liquid,"LQ"),ejs:()=>Q(Z.html,"EJS"),hbs:()=>Q(Z.html,"HBS"),pug:()=>Q(Z.html,"PUG"),wasm:()=>Q("#654FF0","WA"),proto:()=>Q(Z.config,"PB"),graphql:()=>Q("#E535AB","GQL"),gql:()=>Q("#E535AB","GQL")},Wa={dockerfile:()=>Q(Z.docker,"DK"),"docker-compose.yml":()=>Q(Z.docker,"DC"),"docker-compose.yaml":()=>Q(Z.docker,"DC"),".gitignore":()=>Q(Z.git,"GI"),".gitattributes":()=>Q(Z.git,"GA"),".gitmodules":()=>Q(Z.git,"GM"),".env":()=>Q(Z.env,"ENV"),".env.local":()=>Q(Z.env,"ENV"),".env.development":()=>Q(Z.env,"ENV"),".env.production":()=>Q(Z.env,"ENV"),"package.json":()=>Q("#CB3837","NPM"),"package-lock.json":()=>Q("#CB3837","NPM"),"tsconfig.json":()=>Q(Z.ts,"TSC"),eslintrc:()=>Q("#4B32C3","ESL"),".eslintrc.js":()=>Q("#4B32C3","ESL"),".eslintrc.json":()=>Q("#4B32C3","ESL"),".prettierrc":()=>Q("#F7B93E","PR"),makefile:()=>Q(Z.config,"MK"),"cmakelists.txt":()=>Q("#064F8C","CM"),"readme.md":()=>Q(Z.md,"RM"),license:()=>Q("#F5C518","LIC"),"license.md":()=>Q("#F5C518","LIC"),"cargo.toml":()=>Q(Z.rs,"CG"),"go.mod":()=>Q(Z.go,"MOD"),"go.sum":()=>Q(Z.go,"SUM"),gemfile:()=>Q(Z.rb,"GEM"),rakefile:()=>Q(Z.rb,"RK"),"requirements.txt":()=>Q(Z.py,"REQ"),pipfile:()=>Q(Z.py,"PIP"),csproj:()=>Q(Z.cs,"CSP"),".sln":()=>Q(Z.cs,"SLN"),slnx:()=>Q(Z.cs,"SLN")}});function ys(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function ry(e,t){if(!e||!t)return ys(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],f=d.index+(d[1]!==void 0?d[0].indexOf(d[1]):0);if(s.push({start:f,end:f+u.length,cls:l}),!c.global)break}},r=t.commentType||"slash";if((r==="slash"||r==="both")&&(n(Qs.comment1,xe.comment),n(Qs.commentBlock,xe.comment)),(r==="hash"||r==="both")&&n(Qs.commentHash,xe.comment),r==="html"&&n(t.commentHtml,xe.comment),t.commentLine&&n(t.commentLine,xe.comment),t.commentBlock&&n(t.commentBlock,xe.comment),n(Qs.string,xe.string),n(Qs.number,xe.number),t.keywords&&n(t.keywords,xe.keyword),t.builtins&&n(t.builtins,xe.builtin),t.operators&&n(t.operators,xe.operator),t.decorators&&n(t.decorators,xe.decorator),t.macros&&n(t.macros,xe.macro),t.preprocessor&&n(t.preprocessor,xe.preprocessor),t.attributes&&n(t.attributes,xe.attribute),t.tags&&n(t.tags,xe.tag),t.properties&&n(t.properties,xe.property),t.variables&&n(t.variables,xe.variable),t.headings&&n(t.headings,xe.heading),t.bold&&n(t.bold,xe.bold),t.links&&n(t.links,xe.link),t.keys&&n(t.keys,xe.key),t.sections&&n(t.sections,xe.section),t.selectors&&n(t.selectors,xe.keyword),t.values&&n(t.values,xe.number),t.code&&n(t.code,xe.string),t.italic&&n(t.italic,xe.builtin),t.attrs&&n(t.attrs,xe.attribute),s.length===0)return ys(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+=ys(e.slice(o,a.start))),i+=`<span class="${a.cls}">${ys(e.slice(a.start,a.end))}</span>`,o=a.end);return o<e.length&&(i+=ys(e.slice(o))),i}function iy(e){if(!e)return null;let t=e.split(".").pop()?.toLowerCase();if(!t)return null;let s=Zp[t];return typeof s=="string"&&(s=Zp[s]),s||null}function Jp(e,t){if(!e)return ys(e||"");let s=iy(t);return s?ry(e,s):ys(e)}var Qs,Zp,xe,ef=F(()=>{Qs={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},Zp={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}},xe={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 tf(e,t,s){let n=[],r=0,i=0;if(t!=null){let p=t.split(`
|
|
1988
1988
|
`);for(let g=0;g<p.length;g++)n.push({type:"addition",oldNum:"",oldText:"",newNum:g+1,newText:p[g]}),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(`
|
|
1989
|
-
`),a=0,l=0,c=!1,d=[],u=[],f=()=>{let p=Math.max(d.length,u.length);for(let g=0;g<p;g++){let
|
|
1989
|
+
`),a=0,l=0,c=!1,d=[],u=[],f=()=>{let p=Math.max(d.length,u.length);for(let g=0;g<p;g++){let h=d[g],v=u[g];h&&v?n.push({type:"modification",oldNum:h.num,oldText:h.text,newNum:v.num,newText:v.text}):h?n.push({type:"deletion",oldNum:h.num,oldText:h.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 g=p.match(/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/);if(g){f(),a=parseInt(g[1]),l=parseInt(g[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&&f(),d.push({num:a++,text:p.substring(1)}),i++;else if(p.startsWith("+"))u.push({num:l++,text:p.substring(1)}),r++;else{f();let h=p.startsWith(" ")?p.substring(1):p;n.push({type:"context",oldNum:a++,oldText:h,newNum:l++,newText:h})}}return f(),{lines:n,stats:{additions:r,deletions:i},content:e}}var sf=F(()=>{});function nf(e,t){let{effectiveGitWorkDir:s,gitOperating:n,gitOpFeedback:r,commitMessage:i}=t,o=null,a=null,l=(y,m)=>{o&&clearTimeout(o),r.value={ok:y,message:m},o=setTimeout(()=>{r.value=null},4e3)},c=(y,m)=>{e.currentAgent&&(y.value=!0,m.value="",e.sendWsMessage({type:"git_status",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,workDir:s.value,_clientId:e.clientId}))},d=(y,m={})=>{e.currentAgent&&(n.value=!0,a&&clearTimeout(a),a=setTimeout(()=>{n.value&&(n.value=!1,l(!1,"Operation timed out"))},15e3),e.sendWsMessage({type:y,conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,workDir:s.value,_clientId:e.clientId,...m}))};return{showFeedback:l,loadGitStatus:c,gitOp:d,stageFile:y=>d("git_add",{filePath:y}),unstageFile:y=>d("git_reset",{filePath:y}),discardFile:y=>{confirm("Discard changes to "+y+"?")&&d("git_restore",{filePath:y})},stageAll:()=>d("git_add",{addAll:!0}),unstageAll:()=>d("git_reset",{resetAll:!0}),commitChanges:()=>{let y=i.value.trim();y&&d("git_commit",{commitMessage:y})},pushChanges:()=>d("git_push"),handleGitOpResult:(y,m)=>{n.value=!1,a&&(clearTimeout(a),a=null),y.success?(l(!0,y.message||y.operation+" succeeded"),y.operation==="commit"&&(i.value=""),m()):l(!1,y.error||y.operation+" failed")},cleanup:()=>{o&&clearTimeout(o),a&&clearTimeout(a)}}}var rf=F(()=>{});function of(e,t){let s=Vue.ref(!1),n=Vue.ref(""),r=Vue.ref([]),i=Vue.ref(!1),o=Vue.ref(""),a=g=>{i.value=!0,o.value="",e.sendWsMessage({type:"list_directory",conversationId:"_git_folder_picker",agentId:e.currentAgent,dirPath:g,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 g=t.value||"";n.value=g,r.value=[],e.sendWsMessage({type:"list_directory",conversationId:"_git_folder_picker",agentId:e.currentAgent,dirPath:g,workDir:t.value,_clientId:e.clientId})},folderPickerNavigateUp:()=>{if(!n.value)return;let g=n.value.includes("\\"),h=g?"\\":"/",v=n.value.replace(/[/\\]$/,"").split(/[/\\]/);if(v.pop(),v.length===0)n.value="",a("");else if(g&&v.length===1&&/^[A-Za-z]:$/.test(v[0]))n.value=v[0]+"\\",a(v[0]+"\\");else{let C=v.join(h);n.value=C,a(C)}},folderPickerSelectItem:g=>{o.value=g.name},folderPickerEnter:g=>{let h=n.value.includes("\\")||/^[A-Z]:/.test(g.name)?"\\":"/",v;n.value?v=n.value.replace(/[/\\]$/,"")+h+g.name:v=g.name+(g.name.endsWith("\\")?"":"\\"),n.value=v,a(v)},confirmFolderPicker:(g,h)=>{let v=n.value;if(v){if(o.value){let C=v.includes("\\")?"\\":"/";v=v.replace(/[/\\]$/,"")+C+o.value}g.value=v,s.value=!1,h()}},handleDirectoryListing:g=>g.conversationId!=="_git_folder_picker"?!1:(i.value=!1,r.value=(g.entries||[]).filter(h=>h.type==="directory").sort((h,v)=>h.name.localeCompare(v.name)),g.dirPath!=null&&(n.value=g.dirPath),!0)}}var af=F(()=>{});var lf,cf=F(()=>{ja();ef();sf();rf();af();lf={name:"GitStatusTab",template:`
|
|
1990
1990
|
<div class="git-status-tab git-three-col">
|
|
1991
1991
|
<!-- \u5DE6\u680F: \u6587\u4EF6\u5217\u8868 -->
|
|
1992
1992
|
<div class="git-col-files">
|
|
@@ -2230,7 +2230,7 @@ ${String(e||"").trim()}
|
|
|
2230
2230
|
</div>
|
|
2231
2231
|
</div>
|
|
2232
2232
|
</div>
|
|
2233
|
-
`,setup(){let e=Pinia.useChatStore(),t=Vue.inject("t"),s=H=>H.split(/[/\\]/).pop()||H,n=H=>{let _=H.split(/[/\\]/);return _.pop(),_.join("/")},r=H=>wi(s(H)),i=Vue.ref(null),o=Vue.reactive({staged:!1,modified:!1,untracked:!1}),a=H=>{o[H]=!o[H]},l=Vue.ref(!1),c=Vue.ref(""),d=Vue.ref(null),u=Vue.ref([]),f=Vue.computed(()=>e.effectiveWorkDir||""),p=Vue.ref(""),g=Vue.computed(()=>p.value.trim()||f.value),v=Vue.ref(null),h=Vue.ref(!1),A=Vue.ref(!1),w=Vue.ref(""),k=Vue.ref(null),y=Vue.ref([]),m=Vue.ref(null),b=Vue.ref(!0),T=Vue.ref(!1),L=Vue.ref(""),N=Vue.ref(null),$=Vue.ref(0),D=Vue.ref(0),P=H=>H==null||H===""?"":Jp(H,v.value||""),M=Vue.ref(parseInt(localStorage.getItem("gitDiffFontSize"))||12),C=H=>{M.value=Math.max(8,Math.min(24,H)),localStorage.setItem("gitDiffFontSize",M.value.toString())},R=()=>C(M.value+1),j=()=>C(M.value-1),O=H=>{H.deltaY<0?R():H.deltaY>0&&j()},Y=Vue.computed(()=>{let H=y.value;if(!H||H.length===0)return[];let _=H.length,J=[],se=0;for(;se<_;){let me=H[se];if(me.type==="addition"||me.type==="deletion"||me.type==="modification"){let z=me.type==="modification"?"modification":me.type,ee=se;for(;se<_&&(H[se].type===z||H[se].type==="modification"&&z!=="modification");)se++;let pe=se-ee;J.push({type:z,top:ee/_*100,height:Math.max(pe/_*100,.5)})}else se++}return J}),te=H=>{let _=i.value;if(!_)return;let J=H.currentTarget.getBoundingClientRect(),se=(H.clientY-J.top)/J.height;_.scrollTop=se*(_.scrollHeight-_.clientHeight)},he=Vue.computed(()=>u.value.filter(H=>H.indexStatus!==" "&&H.indexStatus!=="?")),ce=Vue.computed(()=>u.value.filter(H=>H.workTreeStatus==="M"||H.workTreeStatus==="D")),ke=Vue.computed(()=>u.value.filter(H=>H.indexStatus==="?"&&H.workTreeStatus==="?")),ve=nf(e,{effectiveGitWorkDir:g,gitOperating:T,gitOpFeedback:N,commitMessage:L}),ge=()=>ve.loadGitStatus(l,c),x=()=>{ge()},K=of(e,g),re=H=>ki(H),ye=()=>K.confirmFolderPicker(p,ge),W=(H,_)=>{v.value=H.path,h.value=_,A.value=!0,w.value="",k.value=null,y.value=[],m.value=null;let J=H.indexStatus==="?"&&H.workTreeStatus==="?";e.sendWsMessage({type:"git_diff",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,workDir:g.value,filePath:H.path,staged:_,untracked:J,fullFile:b.value,_clientId:e.clientId})},ne=()=>{if(b.value=!b.value,v.value){let H=u.value.find(_=>_.path===v.value);H&&W(H,h.value)}},U=H=>{let _=H.detail;if(_)switch(_.type){case"directory_listing":{if(K.handleDirectoryListing(_))return;break}case"git_status_result":{if(l.value=!1,_.error){c.value=_.error,d.value=null,u.value=[];return}if(c.value="",d.value=_.branch||"HEAD",u.value=_.files||[],$.value=_.ahead||0,D.value=_.behind||0,v.value){let J=u.value.find(se=>se.path===v.value);if(J){let se=J.indexStatus!==" "&&J.indexStatus!=="?";h.value=se}else v.value=null,k.value=null,y.value=[],m.value=null}break}case"git_diff_result":{if(A.value=!1,_.error){w.value=_.error;return}w.value="";let J=tf(_.diff,_.newFileContent,t);m.value=J.stats,y.value=J.lines,k.value=J.content;break}case"git_op_result":{ve.handleGitOpResult(_,ge);break}}};Vue.watch(()=>e.currentAgent,()=>{d.value=null,u.value=[],c.value="",v.value=null,k.value=null,e.currentAgent&&Vue.nextTick(()=>ge())}),Vue.watch(()=>e.currentConversation,()=>{e.currentAgent&&(v.value=null,k.value=null,y.value=[],m.value=null,Vue.nextTick(()=>ge()))});let B=()=>ge();return Vue.onMounted(()=>{window.addEventListener("workbench-message",U),e.currentAgent&&ge()}),Vue.onUnmounted(()=>{window.removeEventListener("workbench-message",U),ve.cleanup()}),{store:e,getFileName:s,getDirName:n,getFileIconHtml:r,hlLine:P,collapsedGroups:o,toggleGroup:a,gitLoading:l,gitError:c,gitBranch:d,gitFiles:u,gitWorkDir:p,defaultWorkDir:f,changeGitWorkDir:x,stagedFiles:he,modifiedFiles:ce,untrackedFiles:ke,selectedGitFile:v,selectedStaged:h,diffLoading:A,diffError:w,diffContent:k,diffLines:y,diffStats:m,diffFullFile:b,toggleDiffMode:ne,scrollMarkers:Y,diffScrollContainer:i,onMarkerClick:te,fontSize:M,zoomIn:R,zoomOut:j,onWheel:O,gitOperating:T,commitMessage:L,gitOpFeedback:N,gitAhead:$,gitBehind:D,stageFile:ve.stageFile,unstageFile:ve.unstageFile,discardFile:ve.discardFile,stageAll:ve.stageAll,unstageAll:ve.unstageAll,commitChanges:ve.commitChanges,pushChanges:ve.pushChanges,selectGitFile:W,refresh:B,folderPickerOpen:K.folderPickerOpen,folderPickerPath:K.folderPickerPath,folderPickerEntries:K.folderPickerEntries,folderPickerLoading:K.folderPickerLoading,folderPickerSelected:K.folderPickerSelected,getFolderIcon:re,openFolderPicker:K.openFolderPicker,folderPickerNavigateUp:K.folderPickerNavigateUp,folderPickerSelectItem:K.folderPickerSelectItem,folderPickerEnter:K.folderPickerEnter,confirmFolderPicker:ye}}}});function df(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=[],f=[],p=()=>{let $=e.value?.cmInstance;if(!$)return;let P=$.getWrapperElement().querySelector(".cm-find-scrollbar-annotations");P&&P.remove()},g=()=>{let $=e.value?.cmInstance;if(!$||f.length===0)return;p();let D=$.getWrapperElement();if(!D.querySelector(".CodeMirror-vscrollbar"))return;let M=$.lineCount();if(M===0)return;let C=document.createElement("div");C.className="cm-find-scrollbar-annotations";for(let R of f){let j=R.from.line/M*100,O=document.createElement("div");O.className="cm-find-scrollbar-tick",O.style.top=j+"%",C.appendChild(O)}D.appendChild(C)},v=()=>{for(let $ of u)try{$.clear()}catch{}u=[],f=[],a.value=0,l.value=-1,p()},h=$=>{let D=e.value?.cmInstance;if(!D||!f[$])return;for(let M=0;M<u.length;M++){if(!u[M])continue;let C=u[M].find();C&&(u[M].clear(),u[M]=D.markText(C.from,C.to,{className:"cm-find-highlight"}))}let P=f[$];if(u[$]){let M=u[$].find();M&&(u[$].clear(),u[$]=D.markText(M.from,M.to,{className:"cm-find-highlight cm-find-current"}))}setTimeout(()=>{D.scrollIntoView({from:P.from,to:P.to},100)},0)},A=()=>{v();let $=e.value?.cmInstance;if(!$||!n.value)return;let D=n.value;if(D.length<3)return;let P=$.getValue(),M=i.value,C=o.value,R=[];try{if(C){let j=M?"g":"gi",O=new RegExp(D,j),Y;for(;(Y=O.exec(P))!==null;){if(Y[0].length===0){O.lastIndex++;continue}let te=$.posFromIndex(Y.index),he=$.posFromIndex(Y.index+Y[0].length);if(R.push({from:te,to:he}),R.length>1e4)break}}else{let j=M?D:D.toLowerCase(),O=M?P:P.toLowerCase(),Y=0;for(;(Y=O.indexOf(j,Y))!==-1;){let te=$.posFromIndex(Y),he=$.posFromIndex(Y+D.length);if(R.push({from:te,to:he}),Y+=D.length,R.length>1e4)break}}}catch{return}f=R,a.value=R.length;for(let j of R)u.push($.markText(j.from,j.to,{className:"cm-find-highlight"}));if(R.length>0){let j=$.getCursor(),O=0;for(let Y=0;Y<R.length;Y++){if(CodeMirror.cmpPos(R[Y].from,j)>=0){O=Y;break}Y===R.length-1&&(O=0)}l.value=O,h(O)}g()};return{findBarVisible:t,replaceBarVisible:s,findQuery:n,replaceQuery:r,findCaseSensitive:i,findUseRegex:o,findMatchCount:a,findMatchIndex:l,findInputRef:c,replaceInputRef:d,clearFindMarkers:v,performFind:A,onFindInput:()=>{A()},findNext:()=>{if(f.length===0)return;let $=(l.value+1)%f.length;l.value=$,h($)},findPrev:()=>{if(f.length===0)return;let $=(l.value-1+f.length)%f.length;l.value=$,h($)},openFindBar:($=!1)=>{t.value=!0,s.value=$;let D=e.value?.cmInstance;if(D){let P=D.getSelection();P&&(n.value=P)}Vue.nextTick(()=>{c.value?.focus(),c.value?.select(),n.value&&A()})},closeFindBar:()=>{v(),t.value=!1,s.value=!1;let $=e.value?.cmInstance;$&&$.focus()},toggleReplaceBar:()=>{s.value=!s.value,s.value&&Vue.nextTick(()=>d.value?.focus())},replaceOne:()=>{let $=e.value?.cmInstance;if(!$||f.length===0||l.value<0)return;let D=f[l.value];$.replaceRange(r.value,D.from,D.to),A()},replaceAll:()=>{let $=e.value?.cmInstance;!$||f.length===0||($.operation(()=>{for(let D=f.length-1;D>=0;D--)$.replaceRange(r.value,f[D].from,f[D].to)}),A())}}}var uf=F(()=>{});function pf(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(""),f=Vue.ref("file"),p=Vue.ref(null),g=Vue.ref(!1),v=Vue.ref(""),h=Vue.ref(null),A=Vue.reactive({visible:!1,x:0,y:0,entry:null}),w=Vue.ref(!1),k=Vue.ref(""),y=Vue.ref(null),m=null,b=Vue.reactive({dragging:null,dropTarget:null}),T=Vue.ref(!1),L=(z,ee)=>{l&&clearTimeout(l),a.value={ok:z,message:ee},l=setTimeout(()=>{a.value=null},4e3)},N=()=>{o.value=!0,c&&clearTimeout(c),c=setTimeout(()=>{o.value&&(o.value=!1,L(!1,"Operation timed out"))},15e3)},$=z=>{r.has(z)?r.delete(z):r.add(z)},D=()=>{r.clear(),i.value=-1},P=z=>{f.value=z,u.value="",d.value=!0,Vue.nextTick(()=>p.value?.focus())},M=()=>{let z=u.value.trim();if(!z)return;d.value=!1;let ee=n.value||s();if(!ee)return;let pe=ee.includes("\\")?"\\":"/",oe=ee.replace(/[/\\]$/,"")+pe+z;N(),e.sendWsMessage({type:"create_file",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,filePath:oe,isDirectory:f.value==="directory",workDir:s(),_clientId:e.clientId})},C=(z,ee)=>{let pe=z.path.split("/").pop();confirm(ee("files.deleteConfirm",{name:pe})+(z.type==="directory"?ee("files.deleteDirHint"):""))&&(N(),e.sendWsMessage({type:"delete_files",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,paths:[z.path],workDir:s(),_clientId:e.clientId}))},R=z=>{let ee=r.size;ee!==0&&confirm(z("files.deleteSelectedConfirm",{count:ee}))&&(N(),e.sendWsMessage({type:"delete_files",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,paths:[...r],workDir:s(),_clientId:e.clientId}))},j=()=>{v.value=n.value||s()||"",g.value=!0,Vue.nextTick(()=>h.value?.focus())},O=()=>{let z=v.value.trim();!z||r.size===0||(g.value=!1,N(),e.sendWsMessage({type:"move_files",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,paths:[...r],destination:z,workDir:s(),_clientId:e.clientId}))},Y=(z,ee)=>{let De=z.clientX,$e=z.clientY;De+180>window.innerWidth&&(De=window.innerWidth-180),$e+240>window.innerHeight&&($e=window.innerHeight-240),A.entry=ee,A.x=De,A.y=$e,A.visible=!0},te=()=>{A.visible=!1};return{selectedPaths:r,lastClickedIndex:i,fileOperating:o,fileOpFeedback:a,newFileDialogVisible:d,newFileName:u,newFileType:f,newFileInput:p,moveDialogVisible:g,moveDestination:v,moveDestInput:h,contextMenu:A,renameDialogVisible:w,renameNewName:k,renameInput:y,dragState:b,externalDropActive:T,showFileOpFeedback:L,toggleSelection:$,clearSelection:D,showNewFileDialog:P,confirmNewFile:M,deleteSingleFile:C,deleteSelected:R,openMoveDialog:j,confirmMove:O,showContextMenu:Y,hideContextMenu:te,ctxRename:()=>{let z=A.entry;te(),z&&(k.value=z.name,w.value=!0,Vue.nextTick(()=>{let ee=y.value;if(ee)if(ee.focus(),z.type==="file"){let pe=z.name.lastIndexOf(".");pe>0?ee.setSelectionRange(0,pe):ee.select()}else ee.select()}))},confirmRename:()=>{let z=A.entry,ee=k.value.trim();if(!ee||!z||ee===z.name){w.value=!1;return}w.value=!1;let pe=z.path.replace(/\/$/,"").split("/");pe.pop();let oe=pe.join("/")||"/";N(),e.sendWsMessage({type:"move_files",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,paths:[z.path],destination:oe,newName:ee,workDir:s(),_clientId:e.clientId})},ctxCopy:()=>{let z=A.entry;if(te(),!z)return;let ee=z.path.replace(/\/$/,"").split("/");ee.pop();let pe=ee.join("/")||"/";N(),e.sendWsMessage({type:"copy_files",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,paths:[z.path],destination:pe,workDir:s(),_clientId:e.clientId})},ctxMoveTo:()=>{let z=A.entry;te(),z&&(r.clear(),r.add(z.path),j())},ctxDelete:z=>{let ee=A.entry;te(),ee&&C(ee,z)},ctxDownload:()=>{let z=A.entry;te(),!(!z||z.type!=="file")&&(m=z.path,e.sendWsMessage({type:"read_file",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,filePath:z.path,workDir:s(),_clientId:e.clientId}))},onDragStart:(z,ee)=>{b.dragging=ee,z.dataTransfer.setData("text/plain",ee.path),z.dataTransfer.effectAllowed="move"},onDragOver:(z,ee)=>{if(!b.dragging&&z.dataTransfer.types.includes("Files")){ee.type==="directory"&&(z.dataTransfer.dropEffect="copy",b.dropTarget=ee.path);return}!b.dragging||ee.type!=="directory"||ee.path!==b.dragging.path&&(ee.path.startsWith(b.dragging.path+"/")||(z.dataTransfer.dropEffect="move",b.dropTarget=ee.path))},onDragLeave:z=>{let ee=z.relatedTarget;ee&&z.currentTarget.contains(ee)||(b.dropTarget=null)},onDrop:(z,ee,pe)=>{if(b.dropTarget=null,!b.dragging&&z.dataTransfer.files.length>0&&ee.type==="directory"){pe(z.dataTransfer.files,ee.path);return}if(!b.dragging||ee.type!=="directory"){b.dragging=null;return}if(ee.path===b.dragging.path){b.dragging=null;return}N(),e.sendWsMessage({type:"move_files",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,paths:[b.dragging.path],destination:ee.path,workDir:s(),_clientId:e.clientId}),b.dragging=null},onTreeDragOver:z=>{b.dragging||z.dataTransfer.types.includes("Files")&&(z.dataTransfer.dropEffect="copy",T.value=!0)},onTreeDragLeave:z=>{let ee=z.relatedTarget;ee&&z.currentTarget.contains(ee)||(T.value=!1)},onTreeDrop:(z,ee,pe)=>{if(T.value=!1,!b.dragging&&z.dataTransfer.files.length>0){let oe=n.value||ee||s();pe(z.dataTransfer.files,oe)}},handleExternalFileDrop:async(z,ee)=>{if(!ee)return;let pe=[],oe=[];for(let De of z)oe.push(new Promise($e=>{let Fe=new FileReader;Fe.onload=()=>{let Ue=btoa(new Uint8Array(Fe.result).reduce((Zt,St)=>Zt+String.fromCharCode(St),""));pe.push({name:De.name,data:Ue}),$e()},Fe.onerror=()=>$e(),Fe.readAsArrayBuffer(De)}));await Promise.all(oe),pe.length!==0&&(o.value=!0,c&&clearTimeout(c),c=setTimeout(()=>{o.value&&(o.value=!1,L(!1,"Upload timed out"))},3e4),e.sendWsMessage({type:"upload_to_dir",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,files:pe,dirPath:ee,workDir:s(),_clientId:e.clientId}))},handleFileOpResult:(z,ee,pe)=>{o.value=!1,c&&(clearTimeout(c),c=null),L(z.success,z.success?z.message:z.error||"Operation failed"),z.success&&(pe&&ee(pe),(z.operation==="delete"||z.operation==="move")&&(r.clear(),i.value=-1))},getPendingDownload:()=>m,clearPendingDownload:()=>{m=null},cleanup:()=>{l&&clearTimeout(l),c&&clearTimeout(c)}}}var ff=F(()=>{});function gf(e,{getEffectiveWorkDir:t,normalizePath:s,selectedPaths:n,lastClickedIndex:r,openFileInTab:i,clearSelection:o}){let a=Vue.ref(""),l=Vue.ref(""),c=Vue.reactive({}),d=Vue.ref(!1),u=Vue.ref(null),f=Vue.computed(()=>{if(!l.value)return"EXPLORER";let P=l.value.replace(/[\\/]+$/,"").split(/[\\/]/);return(P[P.length-1]||l.value).toUpperCase()}),p=Vue.computed(()=>l.value?!!c[l.value]?.expanded:!1),g=()=>{if(!l.value)return;let P=c[l.value];P&&(P.expanded=!P.expanded)},v=()=>{for(let P of Object.keys(c))c[P]&&(c[P].expanded=!1)},h=()=>{d.value=!0,Vue.nextTick(()=>u.value?.focus())},A=()=>{d.value=!1,m()},w=()=>{d.value=!1},k=Vue.computed(()=>{let P=[],M=(C,R)=>{let j=c[C];if(!(!j||!j.entries))for(let O of j.entries)P.push({...O,depth:R}),O.type==="directory"&&c[O.path]?.expanded&&M(O.path,R+1)};return l.value&&c[l.value]?.expanded&&M(l.value,0),P}),y=P=>{let M=s(P);c[M]?c[M].loading=!0:c[M]={entries:[],expanded:!0,loaded:!1,loading:!0},e.sendWsMessage({type:"list_directory",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,dirPath:P,workDir:t(),_clientId:e.clientId})},m=()=>{let P=a.value.trim();if(!P)return;let M=s(P);l.value=M,Object.keys(c).forEach(C=>delete c[C]),c[M]={entries:[],expanded:!0,loaded:!1,loading:!0},e.sendWsMessage({type:"list_directory",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,dirPath:P,workDir:t(),_clientId:e.clientId})},b=P=>{let M=s(P),C=c[M];C?C.loaded?C.expanded=!C.expanded:(C.expanded=!0,y(P)):(c[M]={entries:[],expanded:!0,loaded:!1,loading:!1},y(P))},T=(P,M)=>{let C=k.value,R=C.findIndex(j=>j.path===P.path);if(M&&(M.shiftKey||M.ctrlKey||M.metaKey)){if(M.shiftKey&&r.value>=0&&R>=0){let j=Math.min(r.value,R),O=Math.max(r.value,R);!M.ctrlKey&&!M.metaKey&&n.clear();for(let Y=j;Y<=O;Y++)n.add(C[Y].path)}else n.has(P.path)?n.delete(P.path):n.add(P.path);r.value=R;return}n.size>0&&(n.clear(),r.value=-1),P.type==="directory"?b(P.path):i(P.path,P.name),r.value=R},L=P=>{let M=s(P.dirPath);if(P.error){c[M]&&(c[M].loading=!1);return}let C=(P.entries||[]).sort((O,Y)=>O.type===Y.type?O.name.localeCompare(Y.name):O.type==="directory"?-1:1),R=M.replace(/\/$/,""),j=C.map(O=>({...O,path:R+"/"+O.name}));c[M]?(c[M].entries=j,c[M].loaded=!0,c[M].loading=!1):c[M]={entries:j,expanded:!0,loaded:!0,loading:!1},M===l.value&&(a.value=P.dirPath)},N=()=>{Object.keys(c).forEach(P=>delete c[P])};return{treePath:a,treeRootPath:l,treeNodes:c,flattenedTree:k,editingTreePath:d,treePathInputRef:u,rootFolderName:f,rootExpanded:p,toggleRootExpand:g,collapseAll:v,startTreePathEdit:h,confirmTreePath:A,cancelTreePathEdit:w,loadTreeDirectory:y,loadRootDirectory:m,toggleDirectory:b,onTreeItemClick:T,handleDirectoryListing:L,clearTreeNodes:N,initFileBrowser:()=>{let P=t();if(P){let M=s(P);a.value=P,l.value=M,N(),y(P)}},refresh:()=>{l.value&&y(l.value)}}}var mf=F(()=>{});function Xs(e){let t=e.lastIndexOf(".");if(t<0)return"text";let s=e.substring(t).toLowerCase();return oy.has(s)?"office":ay.has(s)?"pdf":ly.has(s)?"image":"text"}function Dt(e){let t=e.lastIndexOf(".");return t<0?!1:cy.has(e.substring(t).toLowerCase())}function dy(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 hf(e,{activeFile:t,editorContainer:s,fontSize:n,clearFindMarkers:r,openFindBar:i,saveFile:o}){let a=Vue.ref(""),l=Vue.reactive({}),c=()=>{},d=()=>{},u=({openQuickOpen:w,openGoToLine:k})=>{c=w,d=k},f=(w,k=0)=>{if(!s.value){k<20&&setTimeout(()=>f(w,k+1),100);return}if(!w)return;if(s.value.innerHTML="",typeof CodeMirror>"u"){let b=document.createElement("textarea");b.value=w.content||"",b.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;",b.spellcheck=!1,b.addEventListener("input",()=>{w.content=b.value,w.isDirty=b.value!==w.originalContent}),b.addEventListener("keydown",T=>{(T.ctrlKey||T.metaKey)&&T.key==="s"&&(T.preventDefault(),o())}),s.value.appendChild(b),a.value="";return}let m=document.documentElement.getAttribute("data-theme")==="dark"?"material-darker":"default";try{let b=CodeMirror(s.value,{value:w.content||"",mode:dy(w.name),theme:m,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)}});b.on("change",()=>{let L=b.getValue();w.content=L,w.isDirty=L!==w.originalContent}),w.cmInstance=b,b.getWrapperElement().style.fontSize=n.value+"px";let T=e.currentConversation;T&&l[T]?.[w.path]&&b.setHistory(l[T][w.path]),Vue.nextTick(()=>{b.refresh(),setTimeout(()=>b.refresh(),200)}),a.value=""}catch(b){a.value=`Editor error: ${b.message}`}};return{debugStatus:a,undoHistoryMap:l,createEditor:f,destroyEditor:()=>{r();let w=t.value;w?.cmInstance&&(w.cmInstance.toTextArea&&w.cmInstance.toTextArea(),w.cmInstance=null),s.value&&(s.value.innerHTML="")},setKeyBindings:u,saveCurrentUndoHistory:()=>{let w=e.currentConversation;if(!w)return;let k=t.value;k?.cmInstance&&(l[w]||(l[w]={}),l[w][k.path]=k.cmInstance.getHistory())},saveAllUndoHistory:w=>{if(!w)return;let k=t.value;k?.cmInstance&&(l[w]||(l[w]={}),l[w][k.path]=k.cmInstance.getHistory())},cleanupUndoHistory:(w,k)=>{w&&l[w]&&delete l[w][k]},deleteConversationHistory:w=>{delete l[w]}}}var oy,ay,ly,cy,Gn=F(()=>{oy=new Set([".docx",".xlsx",".xls",".pptx",".ppt"]),ay=new Set([".pdf"]),ly=new Set([".png",".jpg",".jpeg",".gif",".webp",".bmp",".ico"]),cy=new Set([".md",".markdown",".mdx"])});function vf(e,{editorContainer:t,createEditor:s,t:n}){let r=Vue.ref(!0),i=Vue.ref(null),o=Vue.ref(null),a=Vue.computed(()=>{let p=e.value;return!!(p&&Dt(p.name))}),l=Vue.computed(()=>{let p=e.value;if(!p||!Dt(p.name)||p.content==null)return"";try{if(typeof marked<"u")return marked.parse(p.content)}catch{}return"<pre>"+(p.content||"")+"</pre>"});function c(){Ye(i.value)}async function d(){await Ye(i.value)}function u(){r.value=!1,Vue.nextTick(()=>{let p=e.value;p&&t.value&&s(p)})}return{mdPreviewMode:r,mdPreviewRef:i,officePreviewContainer:o,isActiveMarkdown:a,mdRenderedHtml:l,initMermaid:c,renderMermaidBlocks:d,switchToMdEdit:u,renderOfficeLocal:p=>{let g=o.value;if(!g||!p._arrayBuffer)return;g.innerHTML="";let v=("."+p.name.split(".").pop()).toLowerCase();if(v===".docx"&&window.docx)window.docx.renderAsync(p._arrayBuffer,g,null,{className:"docx-preview-content",inWrapper:!0,ignoreWidth:!1,ignoreHeight:!0}).catch(h=>{p.previewError=h.message});else if(v===".xlsx"||v===".xls")try{let h=XLSX.read(p._arrayBuffer,{type:"array"}),A=h.SheetNames[0],w=XLSX.utils.sheet_to_html(h.Sheets[A],{editable:!1});g.innerHTML='<div class="xlsx-sheet-tabs">'+h.SheetNames.map((k,y)=>`<button class="xlsx-sheet-tab${y===0?" active":""}" data-idx="${y}">${k}</button>`).join("")+'</div><div class="xlsx-table-wrap">'+w+"</div>",g.querySelectorAll(".xlsx-sheet-tab").forEach(k=>{k.addEventListener("click",()=>{let y=parseInt(k.dataset.idx),m=h.SheetNames[y],b=XLSX.utils.sheet_to_html(h.Sheets[m],{editable:!1});g.querySelector(".xlsx-table-wrap").innerHTML=b,g.querySelectorAll(".xlsx-sheet-tab").forEach(T=>T.classList.remove("active")),k.classList.add("active")})})}catch(h){p.previewError=h.message}else(v===".pptx"||v===".ppt")&&(g.innerHTML='<div class="preview-unsupported">'+(n?n("files.pptxNotSupported"):"PowerPoint preview not supported")+"</div>")}}}var yf=F(()=>{qn();Gn()});function bf(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,f=Vue.ref(!1),p=Vue.ref(""),g=Vue.ref([]),v=Vue.ref(0),h=Vue.ref(!1),A=Vue.ref(null),w=null,k=Vue.ref(!1),y=Vue.ref(""),m=Vue.ref(null),b=ce=>{!e.currentAgent||!ce.trim()||e.sendWsMessage({type:"file_search",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,query:ce.trim(),dirPath:s.value||t()||"",_clientId:e.clientId})},T=()=>{if(u&&clearTimeout(u),!l.value.trim()){c.value=[],d.value=!1;return}d.value=!0,u=setTimeout(()=>{b(l.value)},300)},L=()=>{l.value="",c.value=[],d.value=!1},N=ce=>{if(ce.type==="directory"){let ke=r(ce.fullPath);i.value=ke,s.value=ce.fullPath,Object.keys(o).forEach(ve=>delete o[ve]),a(ce.fullPath),L()}else n(ce.fullPath,ce.name),L()},$=()=>{f.value=!0,p.value="",g.value=[],v.value=0,h.value=!1,Vue.nextTick(()=>A.value?.focus())},D=()=>{f.value=!1,p.value="",g.value=[]},P=()=>{if(w&&clearTimeout(w),!p.value.trim()){g.value=[],h.value=!1;return}h.value=!0,v.value=0,w=setTimeout(()=>{b(p.value)},200)},M=()=>{g.value.length>0&&(v.value=(v.value+1)%g.value.length)},C=()=>{g.value.length>0&&(v.value=(v.value-1+g.value.length)%g.value.length)},R=ce=>{ce.type!=="directory"&&n(ce.fullPath,ce.name),D()},j=()=>{let ce=g.value[v.value];ce&&R(ce)},O=()=>{k.value=!0,y.value="",Vue.nextTick(()=>m.value?.focus())},Y=()=>{k.value=!1,y.value=""};return{searchQuery:l,searchResults:c,searchLoading:d,onSearchInput:T,clearSearch:L,onSearchResultClick:N,quickOpenVisible:f,quickOpenQuery:p,quickOpenResults:g,quickOpenSelectedIndex:v,quickOpenLoading:h,quickOpenInput:A,openQuickOpen:$,closeQuickOpen:D,onQuickOpenInput:P,quickOpenSelectNext:M,quickOpenSelectPrev:C,quickOpenConfirm:j,quickOpenOpenFile:R,goToLineVisible:k,goToLineValue:y,goToLineInput:m,openGoToLine:O,closeGoToLine:Y,goToLineConfirm:ce=>{let ke=parseInt(y.value);if(isNaN(ke)||ke<1)return;let ve=ce.value;if(ve?.cmInstance){let ge=ve.cmInstance,x=Math.min(ke-1,ge.lineCount()-1);ge.setCursor({line:x,ch:0}),ge.scrollIntoView({line:x,ch:0},100),ge.focus()}Y()},handleFileSearchResult:ce=>{let ke=ce.results||[];f.value?ce.query&&ce.query.trim()===p.value.trim()&&(g.value=ke,h.value=!1,v.value=0):ce.query&&ce.query.trim()===l.value.trim()&&(c.value=ke,d.value=!1)}}}var wf=F(()=>{});function kf(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(""),f=()=>{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:f,folderPickerNavigateUp:()=>{if(!l.value)return;let k=l.value.includes("\\"),y=k?"\\":"/",m=l.value.replace(/[/\\]$/,"").split(/[/\\]/);if(m.pop(),m.length===0)l.value="",p("");else if(k&&m.length===1&&/^[A-Za-z]:$/.test(m[0]))l.value=m[0]+"\\",p(m[0]+"\\");else{let b=m.join(y);l.value=b,p(b)}},folderPickerSelectItem:k=>{u.value=k.name},folderPickerEnter:k=>{let y;if(!l.value)y=k.name+(k.name.endsWith("\\")?"":"\\");else{let m=l.value.includes("\\")||/^[A-Z]:/.test(k.name)?"\\":"/";y=l.value.replace(/[/\\]$/,"")+m+k.name}l.value=y,p(y)},confirmFolderPicker:()=>{let k=l.value;if(!k)return;if(u.value){let m=k.includes("\\")?"\\":"/";k=k.replace(/[/\\]$/,"")+m+u.value}s.value=k,a.value=!1;let y=i(k);n.value=y,Object.keys(r).forEach(m=>delete r[m]),r[y]={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(y=>y.type==="directory").sort((y,m)=>y.name.localeCompare(m.name)),k.dirPath!=null&&(l.value=k.dirPath)}}}var Sf=F(()=>{});function If(e,{normalizePath:t,getEffectiveWorkDir:s,editorContainer:n,createEditor:r,destroyEditor:i,clearFindMarkers:o,saveCurrentUndoHistory:a,saveAllUndoHistory:l,cleanupUndoHistory:c,deleteConversationHistory:d,debugStatus:u,mdPreviewMode:f,renderOfficeLocal:p,performFind:g,findBarVisible:v,findQuery:h,t:A}){let w=Vue.reactive({}),k=Vue.ref([]),y=Vue.ref(-1),m=Vue.ref(!1),b=Vue.ref(!1),T=Vue.computed(()=>y.value>=0&&y.value<k.value.length?k.value[y.value]:null),L=null,N=()=>{L&&clearTimeout(L),L=setTimeout(()=>{e.sendWsMessage({type:"update_file_tabs",openFiles:k.value.map(O=>({path:O.path})),activeIndex:y.value})},500)},$=O=>{O&&(l(O),k.value.length>0?w[O]={files:k.value.map(Y=>({path:Y.path,name:Y.name,content:Y.content,originalContent:Y.originalContent,isDirty:Y.isDirty,fileType:Y.fileType})),activeIndex:y.value}:delete w[O],N())},D=O=>{if(i(),!O||!w[O]){k.value=[],y.value=-1;return}let Y=w[O];k.value=Y.files.map(te=>({...te,isDirty:te.isDirty||!1,originalContent:te.originalContent||te.content,cmInstance:null,fileType:te.fileType||Xs(te.name||""),blobUrl:null,previewUrl:null,previewLoading:!1,localPreviewReady:!1,previewError:null})),y.value=Y.activeIndex,Vue.nextTick(()=>{let te=T.value;te&&(!te.fileType||te.fileType==="text")&&n.value&&r(te)})};function P(O,Y){let te=t(O),he=k.value.findIndex(ve=>ve.path===te);if(he>=0){y.value!==he&&(o(),a(),y.value=he,Vue.nextTick(()=>{let ve=k.value[he];ve&&ve.content!=null&&(!ve.fileType||ve.fileType==="text")&&r(ve)})),$(e.currentConversation);return}a();let ce=Y||te.split(/[/\\]/).pop(),ke=Xs(ce);k.value.push({path:te,name:ce,content:null,originalContent:null,isDirty:!1,cmInstance:null,fileType:ke,blobUrl:null,previewUrl:null,previewLoading:ke!=="text",localPreviewReady:!1,previewError:null}),y.value=k.value.length-1,m.value=!0,ke==="text"&&i(),$(e.currentConversation),u.value=`Loading: ${O}`,e.sendWsMessage({type:"read_file",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,filePath:O,workDir:s(),_clientId:e.clientId})}let M=O=>{O!==y.value&&(o(),a(),y.value=O,$(e.currentConversation),Vue.nextTick(()=>{let Y=k.value[O];Y&&(!Y.fileType||Y.fileType==="text"?Dt(Y.name)?f.value=!0:Y.content!=null&&n.value&&(r(Y),v.value&&h.value&&Vue.nextTick(()=>g())):Y.fileType==="office"&&Y.localPreviewReady&&Vue.nextTick(()=>p(Y)))}))},C=O=>{let Y=k.value[O];if(Y?.isDirty&&!confirm(A("files.unsavedConfirm",{name:Y.name})))return;c(e.currentConversation,Y.path),Y.blobUrl&&URL.revokeObjectURL(Y.blobUrl);let te=O===y.value;k.value.splice(O,1),k.value.length===0?(y.value=-1,i()):y.value>=k.value.length?y.value=k.value.length-1:y.value>O?y.value--:te&&y.value>=k.value.length&&(y.value=k.value.length-1),$(e.currentConversation),k.value.length>0&&te&&Vue.nextTick(()=>{let he=k.value[y.value];he&&(!he.fileType||he.fileType==="text")&&he.content!=null&&n.value&&r(he)})};function R(){let O=T.value;!O||!O.isDirty||(b.value=!0,e.sendWsMessage({type:"write_file",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,filePath:O.path,content:O.content,workDir:s(),_clientId:e.clientId}))}return{fileTabsMap:w,openFiles:k,activeFileIndex:y,activeFile:T,fileLoading:m,fileSaving:b,saveTabsState:$,restoreTabsState:D,openFileInTab:P,switchToTab:M,closeFileTab:C,saveFile:R,handleConversationDeleted:O=>{let{conversationId:Y}=O.detail;Y&&(delete w[Y],d(Y))}}}var Cf=F(()=>{Gn()});function Af({store:e,normalizePath:t,getEffectiveWorkDir:s,openFiles:n,activeFileIndex:r,activeFile:i,fileLoading:o,fileSaving:a,saveTabsState:l,createEditor:c,openFileInTab:d,tree:u,fp:f,qo:p,ops:g,mdPreviewMode:v,renderOfficeLocal:h,editorContainer:A,debugStatus:w}){return{handleWorkbenchMessage:m=>{let b=m.detail;if(b)switch(b.type){case"directory_listing":{if(b.conversationId==="_folder_picker"){f.handleFolderPickerListing(b);return}u.handleDirectoryListing(b);break}case"file_content":{if(o.value=!1,b.error){w.value=`Error: ${b.error}`,g.clearPendingDownload();let N=t(b.filePath),$=n.value.find(D=>D.path===N);$&&($.previewLoading=!1,$.previewError=b.error);return}let T=t(b.filePath);if(g.getPendingDownload()&&t(g.getPendingDownload())===T){g.clearPendingDownload();try{if(b.binary){let N=`${location.protocol}//${location.host}/api/preview/${b.fileId}?token=${b.previewToken}`,$=document.createElement("a");$.href=N,$.download=T.split("/").pop()||"download",document.body.appendChild($),$.click(),document.body.removeChild($)}else{let N=new Blob([b.content||""],{type:"application/octet-stream"}),$=URL.createObjectURL(N),D=document.createElement("a");D.href=$,D.download=T.split("/").pop()||"download",document.body.appendChild(D),D.click(),document.body.removeChild(D),URL.revokeObjectURL($)}}catch{}return}let L=n.value.findIndex(N=>N.path===T);if(L>=0){let N=n.value[L];if(b.binary){N.previewLoading=!1;let $=`${location.protocol}//${location.host}/api/preview/${b.fileId}?token=${b.previewToken}`,D=N.fileType||Xs(N.name);N.fileType=D,D==="pdf"||D==="image"?fetch($).then(P=>P.blob()).then(P=>{N.blobUrl=URL.createObjectURL(P)}).catch(P=>{N.previewError=P.message}):D==="office"&&((localStorage.getItem("officePreviewMode")||"local")==="online"?N.previewUrl="https://view.officeapps.live.com/op/embed.aspx?src="+encodeURIComponent($):fetch($).then(M=>M.arrayBuffer()).then(M=>{N._arrayBuffer=M,N.localPreviewReady=!0,L===r.value&&Vue.nextTick(()=>h(N))}).catch(M=>{N.previewError=M.message})),l(e.currentConversation);return}N.content=b.content||"",N.originalContent=b.content||"",N.isDirty=!1,l(e.currentConversation),L===r.value&&(Dt(N.name)&&v.value||Vue.nextTick(()=>{setTimeout(()=>c(N),100)}))}break}case"file_saved":{if(a.value=!1,b.error)return;let T=t(b.filePath),L=n.value.find(N=>N.path===T);L&&(L.originalContent=L.content,L.isDirty=!1,l(e.currentConversation));break}case"file_search_result":{p.handleFileSearchResult(b);break}case"file_op_result":{g.handleFileOpResult(b,u.loadTreeDirectory,u.treeRootPath.value);break}case"file_tabs_restored":{if(b.openFiles?.length>0&&n.value.length===0){let T=b.activeIndex||0,L=b.openFiles.length;for(let N of b.openFiles){let $=t(N.path),D=$.split("/").pop(),P=Xs(D);n.value.push({path:$,name:D,content:null,originalContent:null,isDirty:!1,cmInstance:null,fileType:P,blobUrl:null,previewUrl:null,previewLoading:P!=="text",localPreviewReady:!1,previewError:null}),e.sendWsMessage({type:"read_file",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,filePath:N.path})}r.value=T>=0&&T<L?T:0}break}}},handleOpenFile:m=>{let{filePath:b}=m.detail,T=t(b);d(T,T.split("/").pop())}}}var xf=F(()=>{Gn()});var Tf,Mf=F(()=>{ja();uf();ff();mf();Gn();yf();wf();Sf();Cf();xf();Tf={name:"FilesTab",template:`
|
|
2233
|
+
`,setup(){let e=Pinia.useChatStore(),t=Vue.inject("t"),s=H=>H.split(/[/\\]/).pop()||H,n=H=>{let _=H.split(/[/\\]/);return _.pop(),_.join("/")},r=H=>wi(s(H)),i=Vue.ref(null),o=Vue.reactive({staged:!1,modified:!1,untracked:!1}),a=H=>{o[H]=!o[H]},l=Vue.ref(!1),c=Vue.ref(""),d=Vue.ref(null),u=Vue.ref([]),f=Vue.computed(()=>e.effectiveWorkDir||""),p=Vue.ref(""),g=Vue.computed(()=>p.value.trim()||f.value),h=Vue.ref(null),v=Vue.ref(!1),C=Vue.ref(!1),w=Vue.ref(""),k=Vue.ref(null),y=Vue.ref([]),m=Vue.ref(null),b=Vue.ref(!0),T=Vue.ref(!1),L=Vue.ref(""),N=Vue.ref(null),$=Vue.ref(0),D=Vue.ref(0),P=H=>H==null||H===""?"":Jp(H,h.value||""),M=Vue.ref(parseInt(localStorage.getItem("gitDiffFontSize"))||12),A=H=>{M.value=Math.max(8,Math.min(24,H)),localStorage.setItem("gitDiffFontSize",M.value.toString())},R=()=>A(M.value+1),j=()=>A(M.value-1),O=H=>{H.deltaY<0?R():H.deltaY>0&&j()},Y=Vue.computed(()=>{let H=y.value;if(!H||H.length===0)return[];let _=H.length,J=[],se=0;for(;se<_;){let me=H[se];if(me.type==="addition"||me.type==="deletion"||me.type==="modification"){let z=me.type==="modification"?"modification":me.type,ee=se;for(;se<_&&(H[se].type===z||H[se].type==="modification"&&z!=="modification");)se++;let pe=se-ee;J.push({type:z,top:ee/_*100,height:Math.max(pe/_*100,.5)})}else se++}return J}),te=H=>{let _=i.value;if(!_)return;let J=H.currentTarget.getBoundingClientRect(),se=(H.clientY-J.top)/J.height;_.scrollTop=se*(_.scrollHeight-_.clientHeight)},he=Vue.computed(()=>u.value.filter(H=>H.indexStatus!==" "&&H.indexStatus!=="?")),ce=Vue.computed(()=>u.value.filter(H=>H.workTreeStatus==="M"||H.workTreeStatus==="D")),ke=Vue.computed(()=>u.value.filter(H=>H.indexStatus==="?"&&H.workTreeStatus==="?")),ve=nf(e,{effectiveGitWorkDir:g,gitOperating:T,gitOpFeedback:N,commitMessage:L}),ge=()=>ve.loadGitStatus(l,c),x=()=>{ge()},K=of(e,g),re=H=>ki(H),ye=()=>K.confirmFolderPicker(p,ge),W=(H,_)=>{h.value=H.path,v.value=_,C.value=!0,w.value="",k.value=null,y.value=[],m.value=null;let J=H.indexStatus==="?"&&H.workTreeStatus==="?";e.sendWsMessage({type:"git_diff",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,workDir:g.value,filePath:H.path,staged:_,untracked:J,fullFile:b.value,_clientId:e.clientId})},ne=()=>{if(b.value=!b.value,h.value){let H=u.value.find(_=>_.path===h.value);H&&W(H,v.value)}},U=H=>{let _=H.detail;if(_)switch(_.type){case"directory_listing":{if(K.handleDirectoryListing(_))return;break}case"git_status_result":{if(l.value=!1,_.error){c.value=_.error,d.value=null,u.value=[];return}if(c.value="",d.value=_.branch||"HEAD",u.value=_.files||[],$.value=_.ahead||0,D.value=_.behind||0,h.value){let J=u.value.find(se=>se.path===h.value);if(J){let se=J.indexStatus!==" "&&J.indexStatus!=="?";v.value=se}else h.value=null,k.value=null,y.value=[],m.value=null}break}case"git_diff_result":{if(C.value=!1,_.error){w.value=_.error;return}w.value="";let J=tf(_.diff,_.newFileContent,t);m.value=J.stats,y.value=J.lines,k.value=J.content;break}case"git_op_result":{ve.handleGitOpResult(_,ge);break}}};Vue.watch(()=>e.currentAgent,()=>{d.value=null,u.value=[],c.value="",h.value=null,k.value=null,e.currentAgent&&Vue.nextTick(()=>ge())}),Vue.watch(()=>e.currentConversation,()=>{e.currentAgent&&(h.value=null,k.value=null,y.value=[],m.value=null,Vue.nextTick(()=>ge()))});let B=()=>ge();return Vue.onMounted(()=>{window.addEventListener("workbench-message",U),e.currentAgent&&ge()}),Vue.onUnmounted(()=>{window.removeEventListener("workbench-message",U),ve.cleanup()}),{store:e,getFileName:s,getDirName:n,getFileIconHtml:r,hlLine:P,collapsedGroups:o,toggleGroup:a,gitLoading:l,gitError:c,gitBranch:d,gitFiles:u,gitWorkDir:p,defaultWorkDir:f,changeGitWorkDir:x,stagedFiles:he,modifiedFiles:ce,untrackedFiles:ke,selectedGitFile:h,selectedStaged:v,diffLoading:C,diffError:w,diffContent:k,diffLines:y,diffStats:m,diffFullFile:b,toggleDiffMode:ne,scrollMarkers:Y,diffScrollContainer:i,onMarkerClick:te,fontSize:M,zoomIn:R,zoomOut:j,onWheel:O,gitOperating:T,commitMessage:L,gitOpFeedback:N,gitAhead:$,gitBehind:D,stageFile:ve.stageFile,unstageFile:ve.unstageFile,discardFile:ve.discardFile,stageAll:ve.stageAll,unstageAll:ve.unstageAll,commitChanges:ve.commitChanges,pushChanges:ve.pushChanges,selectGitFile:W,refresh:B,folderPickerOpen:K.folderPickerOpen,folderPickerPath:K.folderPickerPath,folderPickerEntries:K.folderPickerEntries,folderPickerLoading:K.folderPickerLoading,folderPickerSelected:K.folderPickerSelected,getFolderIcon:re,openFolderPicker:K.openFolderPicker,folderPickerNavigateUp:K.folderPickerNavigateUp,folderPickerSelectItem:K.folderPickerSelectItem,folderPickerEnter:K.folderPickerEnter,confirmFolderPicker:ye}}}});function df(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=[],f=[],p=()=>{let $=e.value?.cmInstance;if(!$)return;let P=$.getWrapperElement().querySelector(".cm-find-scrollbar-annotations");P&&P.remove()},g=()=>{let $=e.value?.cmInstance;if(!$||f.length===0)return;p();let D=$.getWrapperElement();if(!D.querySelector(".CodeMirror-vscrollbar"))return;let M=$.lineCount();if(M===0)return;let A=document.createElement("div");A.className="cm-find-scrollbar-annotations";for(let R of f){let j=R.from.line/M*100,O=document.createElement("div");O.className="cm-find-scrollbar-tick",O.style.top=j+"%",A.appendChild(O)}D.appendChild(A)},h=()=>{for(let $ of u)try{$.clear()}catch{}u=[],f=[],a.value=0,l.value=-1,p()},v=$=>{let D=e.value?.cmInstance;if(!D||!f[$])return;for(let M=0;M<u.length;M++){if(!u[M])continue;let A=u[M].find();A&&(u[M].clear(),u[M]=D.markText(A.from,A.to,{className:"cm-find-highlight"}))}let P=f[$];if(u[$]){let M=u[$].find();M&&(u[$].clear(),u[$]=D.markText(M.from,M.to,{className:"cm-find-highlight cm-find-current"}))}setTimeout(()=>{D.scrollIntoView({from:P.from,to:P.to},100)},0)},C=()=>{h();let $=e.value?.cmInstance;if(!$||!n.value)return;let D=n.value;if(D.length<3)return;let P=$.getValue(),M=i.value,A=o.value,R=[];try{if(A){let j=M?"g":"gi",O=new RegExp(D,j),Y;for(;(Y=O.exec(P))!==null;){if(Y[0].length===0){O.lastIndex++;continue}let te=$.posFromIndex(Y.index),he=$.posFromIndex(Y.index+Y[0].length);if(R.push({from:te,to:he}),R.length>1e4)break}}else{let j=M?D:D.toLowerCase(),O=M?P:P.toLowerCase(),Y=0;for(;(Y=O.indexOf(j,Y))!==-1;){let te=$.posFromIndex(Y),he=$.posFromIndex(Y+D.length);if(R.push({from:te,to:he}),Y+=D.length,R.length>1e4)break}}}catch{return}f=R,a.value=R.length;for(let j of R)u.push($.markText(j.from,j.to,{className:"cm-find-highlight"}));if(R.length>0){let j=$.getCursor(),O=0;for(let Y=0;Y<R.length;Y++){if(CodeMirror.cmpPos(R[Y].from,j)>=0){O=Y;break}Y===R.length-1&&(O=0)}l.value=O,v(O)}g()};return{findBarVisible:t,replaceBarVisible:s,findQuery:n,replaceQuery:r,findCaseSensitive:i,findUseRegex:o,findMatchCount:a,findMatchIndex:l,findInputRef:c,replaceInputRef:d,clearFindMarkers:h,performFind:C,onFindInput:()=>{C()},findNext:()=>{if(f.length===0)return;let $=(l.value+1)%f.length;l.value=$,v($)},findPrev:()=>{if(f.length===0)return;let $=(l.value-1+f.length)%f.length;l.value=$,v($)},openFindBar:($=!1)=>{t.value=!0,s.value=$;let D=e.value?.cmInstance;if(D){let P=D.getSelection();P&&(n.value=P)}Vue.nextTick(()=>{c.value?.focus(),c.value?.select(),n.value&&C()})},closeFindBar:()=>{h(),t.value=!1,s.value=!1;let $=e.value?.cmInstance;$&&$.focus()},toggleReplaceBar:()=>{s.value=!s.value,s.value&&Vue.nextTick(()=>d.value?.focus())},replaceOne:()=>{let $=e.value?.cmInstance;if(!$||f.length===0||l.value<0)return;let D=f[l.value];$.replaceRange(r.value,D.from,D.to),C()},replaceAll:()=>{let $=e.value?.cmInstance;!$||f.length===0||($.operation(()=>{for(let D=f.length-1;D>=0;D--)$.replaceRange(r.value,f[D].from,f[D].to)}),C())}}}var uf=F(()=>{});function pf(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(""),f=Vue.ref("file"),p=Vue.ref(null),g=Vue.ref(!1),h=Vue.ref(""),v=Vue.ref(null),C=Vue.reactive({visible:!1,x:0,y:0,entry:null}),w=Vue.ref(!1),k=Vue.ref(""),y=Vue.ref(null),m=null,b=Vue.reactive({dragging:null,dropTarget:null}),T=Vue.ref(!1),L=(z,ee)=>{l&&clearTimeout(l),a.value={ok:z,message:ee},l=setTimeout(()=>{a.value=null},4e3)},N=()=>{o.value=!0,c&&clearTimeout(c),c=setTimeout(()=>{o.value&&(o.value=!1,L(!1,"Operation timed out"))},15e3)},$=z=>{r.has(z)?r.delete(z):r.add(z)},D=()=>{r.clear(),i.value=-1},P=z=>{f.value=z,u.value="",d.value=!0,Vue.nextTick(()=>p.value?.focus())},M=()=>{let z=u.value.trim();if(!z)return;d.value=!1;let ee=n.value||s();if(!ee)return;let pe=ee.includes("\\")?"\\":"/",oe=ee.replace(/[/\\]$/,"")+pe+z;N(),e.sendWsMessage({type:"create_file",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,filePath:oe,isDirectory:f.value==="directory",workDir:s(),_clientId:e.clientId})},A=(z,ee)=>{let pe=z.path.split("/").pop();confirm(ee("files.deleteConfirm",{name:pe})+(z.type==="directory"?ee("files.deleteDirHint"):""))&&(N(),e.sendWsMessage({type:"delete_files",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,paths:[z.path],workDir:s(),_clientId:e.clientId}))},R=z=>{let ee=r.size;ee!==0&&confirm(z("files.deleteSelectedConfirm",{count:ee}))&&(N(),e.sendWsMessage({type:"delete_files",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,paths:[...r],workDir:s(),_clientId:e.clientId}))},j=()=>{h.value=n.value||s()||"",g.value=!0,Vue.nextTick(()=>v.value?.focus())},O=()=>{let z=h.value.trim();!z||r.size===0||(g.value=!1,N(),e.sendWsMessage({type:"move_files",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,paths:[...r],destination:z,workDir:s(),_clientId:e.clientId}))},Y=(z,ee)=>{let De=z.clientX,$e=z.clientY;De+180>window.innerWidth&&(De=window.innerWidth-180),$e+240>window.innerHeight&&($e=window.innerHeight-240),C.entry=ee,C.x=De,C.y=$e,C.visible=!0},te=()=>{C.visible=!1};return{selectedPaths:r,lastClickedIndex:i,fileOperating:o,fileOpFeedback:a,newFileDialogVisible:d,newFileName:u,newFileType:f,newFileInput:p,moveDialogVisible:g,moveDestination:h,moveDestInput:v,contextMenu:C,renameDialogVisible:w,renameNewName:k,renameInput:y,dragState:b,externalDropActive:T,showFileOpFeedback:L,toggleSelection:$,clearSelection:D,showNewFileDialog:P,confirmNewFile:M,deleteSingleFile:A,deleteSelected:R,openMoveDialog:j,confirmMove:O,showContextMenu:Y,hideContextMenu:te,ctxRename:()=>{let z=C.entry;te(),z&&(k.value=z.name,w.value=!0,Vue.nextTick(()=>{let ee=y.value;if(ee)if(ee.focus(),z.type==="file"){let pe=z.name.lastIndexOf(".");pe>0?ee.setSelectionRange(0,pe):ee.select()}else ee.select()}))},confirmRename:()=>{let z=C.entry,ee=k.value.trim();if(!ee||!z||ee===z.name){w.value=!1;return}w.value=!1;let pe=z.path.replace(/\/$/,"").split("/");pe.pop();let oe=pe.join("/")||"/";N(),e.sendWsMessage({type:"move_files",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,paths:[z.path],destination:oe,newName:ee,workDir:s(),_clientId:e.clientId})},ctxCopy:()=>{let z=C.entry;if(te(),!z)return;let ee=z.path.replace(/\/$/,"").split("/");ee.pop();let pe=ee.join("/")||"/";N(),e.sendWsMessage({type:"copy_files",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,paths:[z.path],destination:pe,workDir:s(),_clientId:e.clientId})},ctxMoveTo:()=>{let z=C.entry;te(),z&&(r.clear(),r.add(z.path),j())},ctxDelete:z=>{let ee=C.entry;te(),ee&&A(ee,z)},ctxDownload:()=>{let z=C.entry;te(),!(!z||z.type!=="file")&&(m=z.path,e.sendWsMessage({type:"read_file",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,filePath:z.path,workDir:s(),_clientId:e.clientId}))},onDragStart:(z,ee)=>{b.dragging=ee,z.dataTransfer.setData("text/plain",ee.path),z.dataTransfer.effectAllowed="move"},onDragOver:(z,ee)=>{if(!b.dragging&&z.dataTransfer.types.includes("Files")){ee.type==="directory"&&(z.dataTransfer.dropEffect="copy",b.dropTarget=ee.path);return}!b.dragging||ee.type!=="directory"||ee.path!==b.dragging.path&&(ee.path.startsWith(b.dragging.path+"/")||(z.dataTransfer.dropEffect="move",b.dropTarget=ee.path))},onDragLeave:z=>{let ee=z.relatedTarget;ee&&z.currentTarget.contains(ee)||(b.dropTarget=null)},onDrop:(z,ee,pe)=>{if(b.dropTarget=null,!b.dragging&&z.dataTransfer.files.length>0&&ee.type==="directory"){pe(z.dataTransfer.files,ee.path);return}if(!b.dragging||ee.type!=="directory"){b.dragging=null;return}if(ee.path===b.dragging.path){b.dragging=null;return}N(),e.sendWsMessage({type:"move_files",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,paths:[b.dragging.path],destination:ee.path,workDir:s(),_clientId:e.clientId}),b.dragging=null},onTreeDragOver:z=>{b.dragging||z.dataTransfer.types.includes("Files")&&(z.dataTransfer.dropEffect="copy",T.value=!0)},onTreeDragLeave:z=>{let ee=z.relatedTarget;ee&&z.currentTarget.contains(ee)||(T.value=!1)},onTreeDrop:(z,ee,pe)=>{if(T.value=!1,!b.dragging&&z.dataTransfer.files.length>0){let oe=n.value||ee||s();pe(z.dataTransfer.files,oe)}},handleExternalFileDrop:async(z,ee)=>{if(!ee)return;let pe=[],oe=[];for(let De of z)oe.push(new Promise($e=>{let Fe=new FileReader;Fe.onload=()=>{let Ue=btoa(new Uint8Array(Fe.result).reduce((Zt,St)=>Zt+String.fromCharCode(St),""));pe.push({name:De.name,data:Ue}),$e()},Fe.onerror=()=>$e(),Fe.readAsArrayBuffer(De)}));await Promise.all(oe),pe.length!==0&&(o.value=!0,c&&clearTimeout(c),c=setTimeout(()=>{o.value&&(o.value=!1,L(!1,"Upload timed out"))},3e4),e.sendWsMessage({type:"upload_to_dir",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,files:pe,dirPath:ee,workDir:s(),_clientId:e.clientId}))},handleFileOpResult:(z,ee,pe)=>{o.value=!1,c&&(clearTimeout(c),c=null),L(z.success,z.success?z.message:z.error||"Operation failed"),z.success&&(pe&&ee(pe),(z.operation==="delete"||z.operation==="move")&&(r.clear(),i.value=-1))},getPendingDownload:()=>m,clearPendingDownload:()=>{m=null},cleanup:()=>{l&&clearTimeout(l),c&&clearTimeout(c)}}}var ff=F(()=>{});function gf(e,{getEffectiveWorkDir:t,normalizePath:s,selectedPaths:n,lastClickedIndex:r,openFileInTab:i,clearSelection:o}){let a=Vue.ref(""),l=Vue.ref(""),c=Vue.reactive({}),d=Vue.ref(!1),u=Vue.ref(null),f=Vue.computed(()=>{if(!l.value)return"EXPLORER";let P=l.value.replace(/[\\/]+$/,"").split(/[\\/]/);return(P[P.length-1]||l.value).toUpperCase()}),p=Vue.computed(()=>l.value?!!c[l.value]?.expanded:!1),g=()=>{if(!l.value)return;let P=c[l.value];P&&(P.expanded=!P.expanded)},h=()=>{for(let P of Object.keys(c))c[P]&&(c[P].expanded=!1)},v=()=>{d.value=!0,Vue.nextTick(()=>u.value?.focus())},C=()=>{d.value=!1,m()},w=()=>{d.value=!1},k=Vue.computed(()=>{let P=[],M=(A,R)=>{let j=c[A];if(!(!j||!j.entries))for(let O of j.entries)P.push({...O,depth:R}),O.type==="directory"&&c[O.path]?.expanded&&M(O.path,R+1)};return l.value&&c[l.value]?.expanded&&M(l.value,0),P}),y=P=>{let M=s(P);c[M]?c[M].loading=!0:c[M]={entries:[],expanded:!0,loaded:!1,loading:!0},e.sendWsMessage({type:"list_directory",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,dirPath:P,workDir:t(),_clientId:e.clientId})},m=()=>{let P=a.value.trim();if(!P)return;let M=s(P);l.value=M,Object.keys(c).forEach(A=>delete c[A]),c[M]={entries:[],expanded:!0,loaded:!1,loading:!0},e.sendWsMessage({type:"list_directory",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,dirPath:P,workDir:t(),_clientId:e.clientId})},b=P=>{let M=s(P),A=c[M];A?A.loaded?A.expanded=!A.expanded:(A.expanded=!0,y(P)):(c[M]={entries:[],expanded:!0,loaded:!1,loading:!1},y(P))},T=(P,M)=>{let A=k.value,R=A.findIndex(j=>j.path===P.path);if(M&&(M.shiftKey||M.ctrlKey||M.metaKey)){if(M.shiftKey&&r.value>=0&&R>=0){let j=Math.min(r.value,R),O=Math.max(r.value,R);!M.ctrlKey&&!M.metaKey&&n.clear();for(let Y=j;Y<=O;Y++)n.add(A[Y].path)}else n.has(P.path)?n.delete(P.path):n.add(P.path);r.value=R;return}n.size>0&&(n.clear(),r.value=-1),P.type==="directory"?b(P.path):i(P.path,P.name),r.value=R},L=P=>{let M=s(P.dirPath);if(P.error){c[M]&&(c[M].loading=!1);return}let A=(P.entries||[]).sort((O,Y)=>O.type===Y.type?O.name.localeCompare(Y.name):O.type==="directory"?-1:1),R=M.replace(/\/$/,""),j=A.map(O=>({...O,path:R+"/"+O.name}));c[M]?(c[M].entries=j,c[M].loaded=!0,c[M].loading=!1):c[M]={entries:j,expanded:!0,loaded:!0,loading:!1},M===l.value&&(a.value=P.dirPath)},N=()=>{Object.keys(c).forEach(P=>delete c[P])};return{treePath:a,treeRootPath:l,treeNodes:c,flattenedTree:k,editingTreePath:d,treePathInputRef:u,rootFolderName:f,rootExpanded:p,toggleRootExpand:g,collapseAll:h,startTreePathEdit:v,confirmTreePath:C,cancelTreePathEdit:w,loadTreeDirectory:y,loadRootDirectory:m,toggleDirectory:b,onTreeItemClick:T,handleDirectoryListing:L,clearTreeNodes:N,initFileBrowser:()=>{let P=t();if(P){let M=s(P);a.value=P,l.value=M,N(),y(P)}},refresh:()=>{l.value&&y(l.value)}}}var mf=F(()=>{});function Xs(e){let t=e.lastIndexOf(".");if(t<0)return"text";let s=e.substring(t).toLowerCase();return oy.has(s)?"office":ay.has(s)?"pdf":ly.has(s)?"image":"text"}function Dt(e){let t=e.lastIndexOf(".");return t<0?!1:cy.has(e.substring(t).toLowerCase())}function dy(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 hf(e,{activeFile:t,editorContainer:s,fontSize:n,clearFindMarkers:r,openFindBar:i,saveFile:o}){let a=Vue.ref(""),l=Vue.reactive({}),c=()=>{},d=()=>{},u=({openQuickOpen:w,openGoToLine:k})=>{c=w,d=k},f=(w,k=0)=>{if(!s.value){k<20&&setTimeout(()=>f(w,k+1),100);return}if(!w)return;if(s.value.innerHTML="",typeof CodeMirror>"u"){let b=document.createElement("textarea");b.value=w.content||"",b.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;",b.spellcheck=!1,b.addEventListener("input",()=>{w.content=b.value,w.isDirty=b.value!==w.originalContent}),b.addEventListener("keydown",T=>{(T.ctrlKey||T.metaKey)&&T.key==="s"&&(T.preventDefault(),o())}),s.value.appendChild(b),a.value="";return}let m=document.documentElement.getAttribute("data-theme")==="dark"?"material-darker":"default";try{let b=CodeMirror(s.value,{value:w.content||"",mode:dy(w.name),theme:m,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)}});b.on("change",()=>{let L=b.getValue();w.content=L,w.isDirty=L!==w.originalContent}),w.cmInstance=b,b.getWrapperElement().style.fontSize=n.value+"px";let T=e.currentConversation;T&&l[T]?.[w.path]&&b.setHistory(l[T][w.path]),Vue.nextTick(()=>{b.refresh(),setTimeout(()=>b.refresh(),200)}),a.value=""}catch(b){a.value=`Editor error: ${b.message}`}};return{debugStatus:a,undoHistoryMap:l,createEditor:f,destroyEditor:()=>{r();let w=t.value;w?.cmInstance&&(w.cmInstance.toTextArea&&w.cmInstance.toTextArea(),w.cmInstance=null),s.value&&(s.value.innerHTML="")},setKeyBindings:u,saveCurrentUndoHistory:()=>{let w=e.currentConversation;if(!w)return;let k=t.value;k?.cmInstance&&(l[w]||(l[w]={}),l[w][k.path]=k.cmInstance.getHistory())},saveAllUndoHistory:w=>{if(!w)return;let k=t.value;k?.cmInstance&&(l[w]||(l[w]={}),l[w][k.path]=k.cmInstance.getHistory())},cleanupUndoHistory:(w,k)=>{w&&l[w]&&delete l[w][k]},deleteConversationHistory:w=>{delete l[w]}}}var oy,ay,ly,cy,Gn=F(()=>{oy=new Set([".docx",".xlsx",".xls",".pptx",".ppt"]),ay=new Set([".pdf"]),ly=new Set([".png",".jpg",".jpeg",".gif",".webp",".bmp",".ico"]),cy=new Set([".md",".markdown",".mdx"])});function vf(e,{editorContainer:t,createEditor:s,t:n}){let r=Vue.ref(!0),i=Vue.ref(null),o=Vue.ref(null),a=Vue.computed(()=>{let p=e.value;return!!(p&&Dt(p.name))}),l=Vue.computed(()=>{let p=e.value;if(!p||!Dt(p.name)||p.content==null)return"";try{if(typeof marked<"u")return marked.parse(p.content)}catch{}return"<pre>"+(p.content||"")+"</pre>"});function c(){Ye(i.value)}async function d(){await Ye(i.value)}function u(){r.value=!1,Vue.nextTick(()=>{let p=e.value;p&&t.value&&s(p)})}return{mdPreviewMode:r,mdPreviewRef:i,officePreviewContainer:o,isActiveMarkdown:a,mdRenderedHtml:l,initMermaid:c,renderMermaidBlocks:d,switchToMdEdit:u,renderOfficeLocal:p=>{let g=o.value;if(!g||!p._arrayBuffer)return;g.innerHTML="";let h=("."+p.name.split(".").pop()).toLowerCase();if(h===".docx"&&window.docx)window.docx.renderAsync(p._arrayBuffer,g,null,{className:"docx-preview-content",inWrapper:!0,ignoreWidth:!1,ignoreHeight:!0}).catch(v=>{p.previewError=v.message});else if(h===".xlsx"||h===".xls")try{let v=XLSX.read(p._arrayBuffer,{type:"array"}),C=v.SheetNames[0],w=XLSX.utils.sheet_to_html(v.Sheets[C],{editable:!1});g.innerHTML='<div class="xlsx-sheet-tabs">'+v.SheetNames.map((k,y)=>`<button class="xlsx-sheet-tab${y===0?" active":""}" data-idx="${y}">${k}</button>`).join("")+'</div><div class="xlsx-table-wrap">'+w+"</div>",g.querySelectorAll(".xlsx-sheet-tab").forEach(k=>{k.addEventListener("click",()=>{let y=parseInt(k.dataset.idx),m=v.SheetNames[y],b=XLSX.utils.sheet_to_html(v.Sheets[m],{editable:!1});g.querySelector(".xlsx-table-wrap").innerHTML=b,g.querySelectorAll(".xlsx-sheet-tab").forEach(T=>T.classList.remove("active")),k.classList.add("active")})})}catch(v){p.previewError=v.message}else(h===".pptx"||h===".ppt")&&(g.innerHTML='<div class="preview-unsupported">'+(n?n("files.pptxNotSupported"):"PowerPoint preview not supported")+"</div>")}}}var yf=F(()=>{qn();Gn()});function bf(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,f=Vue.ref(!1),p=Vue.ref(""),g=Vue.ref([]),h=Vue.ref(0),v=Vue.ref(!1),C=Vue.ref(null),w=null,k=Vue.ref(!1),y=Vue.ref(""),m=Vue.ref(null),b=ce=>{!e.currentAgent||!ce.trim()||e.sendWsMessage({type:"file_search",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,query:ce.trim(),dirPath:s.value||t()||"",_clientId:e.clientId})},T=()=>{if(u&&clearTimeout(u),!l.value.trim()){c.value=[],d.value=!1;return}d.value=!0,u=setTimeout(()=>{b(l.value)},300)},L=()=>{l.value="",c.value=[],d.value=!1},N=ce=>{if(ce.type==="directory"){let ke=r(ce.fullPath);i.value=ke,s.value=ce.fullPath,Object.keys(o).forEach(ve=>delete o[ve]),a(ce.fullPath),L()}else n(ce.fullPath,ce.name),L()},$=()=>{f.value=!0,p.value="",g.value=[],h.value=0,v.value=!1,Vue.nextTick(()=>C.value?.focus())},D=()=>{f.value=!1,p.value="",g.value=[]},P=()=>{if(w&&clearTimeout(w),!p.value.trim()){g.value=[],v.value=!1;return}v.value=!0,h.value=0,w=setTimeout(()=>{b(p.value)},200)},M=()=>{g.value.length>0&&(h.value=(h.value+1)%g.value.length)},A=()=>{g.value.length>0&&(h.value=(h.value-1+g.value.length)%g.value.length)},R=ce=>{ce.type!=="directory"&&n(ce.fullPath,ce.name),D()},j=()=>{let ce=g.value[h.value];ce&&R(ce)},O=()=>{k.value=!0,y.value="",Vue.nextTick(()=>m.value?.focus())},Y=()=>{k.value=!1,y.value=""};return{searchQuery:l,searchResults:c,searchLoading:d,onSearchInput:T,clearSearch:L,onSearchResultClick:N,quickOpenVisible:f,quickOpenQuery:p,quickOpenResults:g,quickOpenSelectedIndex:h,quickOpenLoading:v,quickOpenInput:C,openQuickOpen:$,closeQuickOpen:D,onQuickOpenInput:P,quickOpenSelectNext:M,quickOpenSelectPrev:A,quickOpenConfirm:j,quickOpenOpenFile:R,goToLineVisible:k,goToLineValue:y,goToLineInput:m,openGoToLine:O,closeGoToLine:Y,goToLineConfirm:ce=>{let ke=parseInt(y.value);if(isNaN(ke)||ke<1)return;let ve=ce.value;if(ve?.cmInstance){let ge=ve.cmInstance,x=Math.min(ke-1,ge.lineCount()-1);ge.setCursor({line:x,ch:0}),ge.scrollIntoView({line:x,ch:0},100),ge.focus()}Y()},handleFileSearchResult:ce=>{let ke=ce.results||[];f.value?ce.query&&ce.query.trim()===p.value.trim()&&(g.value=ke,v.value=!1,h.value=0):ce.query&&ce.query.trim()===l.value.trim()&&(c.value=ke,d.value=!1)}}}var wf=F(()=>{});function kf(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(""),f=()=>{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:f,folderPickerNavigateUp:()=>{if(!l.value)return;let k=l.value.includes("\\"),y=k?"\\":"/",m=l.value.replace(/[/\\]$/,"").split(/[/\\]/);if(m.pop(),m.length===0)l.value="",p("");else if(k&&m.length===1&&/^[A-Za-z]:$/.test(m[0]))l.value=m[0]+"\\",p(m[0]+"\\");else{let b=m.join(y);l.value=b,p(b)}},folderPickerSelectItem:k=>{u.value=k.name},folderPickerEnter:k=>{let y;if(!l.value)y=k.name+(k.name.endsWith("\\")?"":"\\");else{let m=l.value.includes("\\")||/^[A-Z]:/.test(k.name)?"\\":"/";y=l.value.replace(/[/\\]$/,"")+m+k.name}l.value=y,p(y)},confirmFolderPicker:()=>{let k=l.value;if(!k)return;if(u.value){let m=k.includes("\\")?"\\":"/";k=k.replace(/[/\\]$/,"")+m+u.value}s.value=k,a.value=!1;let y=i(k);n.value=y,Object.keys(r).forEach(m=>delete r[m]),r[y]={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(y=>y.type==="directory").sort((y,m)=>y.name.localeCompare(m.name)),k.dirPath!=null&&(l.value=k.dirPath)}}}var Sf=F(()=>{});function If(e,{normalizePath:t,getEffectiveWorkDir:s,editorContainer:n,createEditor:r,destroyEditor:i,clearFindMarkers:o,saveCurrentUndoHistory:a,saveAllUndoHistory:l,cleanupUndoHistory:c,deleteConversationHistory:d,debugStatus:u,mdPreviewMode:f,renderOfficeLocal:p,performFind:g,findBarVisible:h,findQuery:v,t:C}){let w=Vue.reactive({}),k=Vue.ref([]),y=Vue.ref(-1),m=Vue.ref(!1),b=Vue.ref(!1),T=Vue.computed(()=>y.value>=0&&y.value<k.value.length?k.value[y.value]:null),L=null,N=()=>{L&&clearTimeout(L),L=setTimeout(()=>{e.sendWsMessage({type:"update_file_tabs",openFiles:k.value.map(O=>({path:O.path})),activeIndex:y.value})},500)},$=O=>{O&&(l(O),k.value.length>0?w[O]={files:k.value.map(Y=>({path:Y.path,name:Y.name,content:Y.content,originalContent:Y.originalContent,isDirty:Y.isDirty,fileType:Y.fileType})),activeIndex:y.value}:delete w[O],N())},D=O=>{if(i(),!O||!w[O]){k.value=[],y.value=-1;return}let Y=w[O];k.value=Y.files.map(te=>({...te,isDirty:te.isDirty||!1,originalContent:te.originalContent||te.content,cmInstance:null,fileType:te.fileType||Xs(te.name||""),blobUrl:null,previewUrl:null,previewLoading:!1,localPreviewReady:!1,previewError:null})),y.value=Y.activeIndex,Vue.nextTick(()=>{let te=T.value;te&&(!te.fileType||te.fileType==="text")&&n.value&&r(te)})};function P(O,Y){let te=t(O),he=k.value.findIndex(ve=>ve.path===te);if(he>=0){y.value!==he&&(o(),a(),y.value=he,Vue.nextTick(()=>{let ve=k.value[he];ve&&ve.content!=null&&(!ve.fileType||ve.fileType==="text")&&r(ve)})),$(e.currentConversation);return}a();let ce=Y||te.split(/[/\\]/).pop(),ke=Xs(ce);k.value.push({path:te,name:ce,content:null,originalContent:null,isDirty:!1,cmInstance:null,fileType:ke,blobUrl:null,previewUrl:null,previewLoading:ke!=="text",localPreviewReady:!1,previewError:null}),y.value=k.value.length-1,m.value=!0,ke==="text"&&i(),$(e.currentConversation),u.value=`Loading: ${O}`,e.sendWsMessage({type:"read_file",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,filePath:O,workDir:s(),_clientId:e.clientId})}let M=O=>{O!==y.value&&(o(),a(),y.value=O,$(e.currentConversation),Vue.nextTick(()=>{let Y=k.value[O];Y&&(!Y.fileType||Y.fileType==="text"?Dt(Y.name)?f.value=!0:Y.content!=null&&n.value&&(r(Y),h.value&&v.value&&Vue.nextTick(()=>g())):Y.fileType==="office"&&Y.localPreviewReady&&Vue.nextTick(()=>p(Y)))}))},A=O=>{let Y=k.value[O];if(Y?.isDirty&&!confirm(C("files.unsavedConfirm",{name:Y.name})))return;c(e.currentConversation,Y.path),Y.blobUrl&&URL.revokeObjectURL(Y.blobUrl);let te=O===y.value;k.value.splice(O,1),k.value.length===0?(y.value=-1,i()):y.value>=k.value.length?y.value=k.value.length-1:y.value>O?y.value--:te&&y.value>=k.value.length&&(y.value=k.value.length-1),$(e.currentConversation),k.value.length>0&&te&&Vue.nextTick(()=>{let he=k.value[y.value];he&&(!he.fileType||he.fileType==="text")&&he.content!=null&&n.value&&r(he)})};function R(){let O=T.value;!O||!O.isDirty||(b.value=!0,e.sendWsMessage({type:"write_file",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,filePath:O.path,content:O.content,workDir:s(),_clientId:e.clientId}))}return{fileTabsMap:w,openFiles:k,activeFileIndex:y,activeFile:T,fileLoading:m,fileSaving:b,saveTabsState:$,restoreTabsState:D,openFileInTab:P,switchToTab:M,closeFileTab:A,saveFile:R,handleConversationDeleted:O=>{let{conversationId:Y}=O.detail;Y&&(delete w[Y],d(Y))}}}var Cf=F(()=>{Gn()});function Af({store:e,normalizePath:t,getEffectiveWorkDir:s,openFiles:n,activeFileIndex:r,activeFile:i,fileLoading:o,fileSaving:a,saveTabsState:l,createEditor:c,openFileInTab:d,tree:u,fp:f,qo:p,ops:g,mdPreviewMode:h,renderOfficeLocal:v,editorContainer:C,debugStatus:w}){return{handleWorkbenchMessage:m=>{let b=m.detail;if(b)switch(b.type){case"directory_listing":{if(b.conversationId==="_folder_picker"){f.handleFolderPickerListing(b);return}u.handleDirectoryListing(b);break}case"file_content":{if(o.value=!1,b.error){w.value=`Error: ${b.error}`,g.clearPendingDownload();let N=t(b.filePath),$=n.value.find(D=>D.path===N);$&&($.previewLoading=!1,$.previewError=b.error);return}let T=t(b.filePath);if(g.getPendingDownload()&&t(g.getPendingDownload())===T){g.clearPendingDownload();try{if(b.binary){let N=`${location.protocol}//${location.host}/api/preview/${b.fileId}?token=${b.previewToken}`,$=document.createElement("a");$.href=N,$.download=T.split("/").pop()||"download",document.body.appendChild($),$.click(),document.body.removeChild($)}else{let N=new Blob([b.content||""],{type:"application/octet-stream"}),$=URL.createObjectURL(N),D=document.createElement("a");D.href=$,D.download=T.split("/").pop()||"download",document.body.appendChild(D),D.click(),document.body.removeChild(D),URL.revokeObjectURL($)}}catch{}return}let L=n.value.findIndex(N=>N.path===T);if(L>=0){let N=n.value[L];if(b.binary){N.previewLoading=!1;let $=`${location.protocol}//${location.host}/api/preview/${b.fileId}?token=${b.previewToken}`,D=N.fileType||Xs(N.name);N.fileType=D,D==="pdf"||D==="image"?fetch($).then(P=>P.blob()).then(P=>{N.blobUrl=URL.createObjectURL(P)}).catch(P=>{N.previewError=P.message}):D==="office"&&((localStorage.getItem("officePreviewMode")||"local")==="online"?N.previewUrl="https://view.officeapps.live.com/op/embed.aspx?src="+encodeURIComponent($):fetch($).then(M=>M.arrayBuffer()).then(M=>{N._arrayBuffer=M,N.localPreviewReady=!0,L===r.value&&Vue.nextTick(()=>v(N))}).catch(M=>{N.previewError=M.message})),l(e.currentConversation);return}N.content=b.content||"",N.originalContent=b.content||"",N.isDirty=!1,l(e.currentConversation),L===r.value&&(Dt(N.name)&&h.value||Vue.nextTick(()=>{setTimeout(()=>c(N),100)}))}break}case"file_saved":{if(a.value=!1,b.error)return;let T=t(b.filePath),L=n.value.find(N=>N.path===T);L&&(L.originalContent=L.content,L.isDirty=!1,l(e.currentConversation));break}case"file_search_result":{p.handleFileSearchResult(b);break}case"file_op_result":{g.handleFileOpResult(b,u.loadTreeDirectory,u.treeRootPath.value);break}case"file_tabs_restored":{if(b.openFiles?.length>0&&n.value.length===0){let T=b.activeIndex||0,L=b.openFiles.length;for(let N of b.openFiles){let $=t(N.path),D=$.split("/").pop(),P=Xs(D);n.value.push({path:$,name:D,content:null,originalContent:null,isDirty:!1,cmInstance:null,fileType:P,blobUrl:null,previewUrl:null,previewLoading:P!=="text",localPreviewReady:!1,previewError:null}),e.sendWsMessage({type:"read_file",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,filePath:N.path})}r.value=T>=0&&T<L?T:0}break}}},handleOpenFile:m=>{let{filePath:b}=m.detail,T=t(b);d(T,T.split("/").pop())}}}var xf=F(()=>{Gn()});var Tf,Mf=F(()=>{ja();uf();ff();mf();Gn();yf();wf();Sf();Cf();xf();Tf={name:"FilesTab",template:`
|
|
2234
2234
|
<div class="files-tab file-two-col" :class="{ 'mobile-editor-view': isMobile && mobileView === 'editor' }" ref="rootEl">
|
|
2235
2235
|
<!-- \u5DE6\u680F: \u5C42\u7EA7\u76EE\u5F55\u6811 -->
|
|
2236
2236
|
<div class="file-col-tree" :class="{ 'drop-active': externalDropActive }" :style="{ flex: '0 0 ' + treePanelWidth + 'px', transition: isTreeResizing ? 'none' : undefined, fontSize: fontSize + 'px' }" @wheel.ctrl.prevent="onWheel"
|
|
@@ -2657,7 +2657,7 @@ ${String(e||"").trim()}
|
|
|
2657
2657
|
</template>
|
|
2658
2658
|
</div>
|
|
2659
2659
|
</div>
|
|
2660
|
-
`,setup(){let e=Pinia.useChatStore(),t=Vue.inject("t"),s=()=>e.effectiveWorkDir||"",n=x=>x?x.replace(/\\/g,"/"):"",r=x=>wi(x),i=x=>ki(x),o=x=>x==null?"":x<1024?x+" B":x<1024*1024?(x/1024).toFixed(1)+" KB":(x/(1024*1024)).toFixed(1)+" MB",a=Vue.ref(null),l=Vue.ref(null),c=Vue.ref(window.innerWidth<=768),d=Vue.ref("tree"),u=()=>{d.value="tree"},f=Vue.ref(parseInt(localStorage.getItem("filesFontSize"))||15),p=x=>{f.value=Math.max(8,Math.min(24,x)),localStorage.setItem("filesFontSize",f.value.toString());let K=y.activeFile.value;K?.cmInstance&&(K.cmInstance.getWrapperElement().style.fontSize=f.value+"px",K.cmInstance.refresh())},g=()=>p(f.value+1),v=()=>p(f.value-1),h=x=>{x.deltaY<0?g():v()},A=Vue.ref(parseInt(localStorage.getItem("filePanelWidth"))||220),w=Vue.ref(!1),k=x=>{x.preventDefault();let K=x.type==="touchstart";w.value=!0;let re=K?x.touches[0].clientX:x.clientX,ye=A.value;document.body.style.cursor="col-resize",document.body.style.userSelect="none";let W=x.target.closest(".file-two-col"),ne=W?W.offsetWidth*.5:400,U=H=>{let _=K?H.touches[0].clientX:H.clientX;A.value=Math.max(120,Math.min(ne,ye+(_-re)))},B=()=>{w.value=!1,document.body.style.cursor="",document.body.style.userSelect="",localStorage.setItem("filePanelWidth",A.value.toString()),document.removeEventListener("mousemove",U),document.removeEventListener("mouseup",B),document.removeEventListener("touchmove",U),document.removeEventListener("touchend",B)};document.addEventListener(K?"touchmove":"mousemove",U),document.addEventListener(K?"touchend":"mouseup",B)},y,m,b=Vue.computed(()=>y?y.activeFile.value:null),T=Vue.computed(()=>m?m.treePath.value:""),L=df(b),N=hf(e,{activeFile:b,editorContainer:l,fontSize:f,clearFindMarkers:L.clearFindMarkers,openFindBar:L.openFindBar,saveFile:()=>y.saveFile()}),$=vf(b,{editorContainer:l,createEditor:N.createEditor,t}),D=pf(e,{getEffectiveWorkDir:s,treePath:T});y=If(e,{normalizePath:n,getEffectiveWorkDir:s,editorContainer:l,createEditor:N.createEditor,destroyEditor:N.destroyEditor,clearFindMarkers:L.clearFindMarkers,saveCurrentUndoHistory:N.saveCurrentUndoHistory,saveAllUndoHistory:N.saveAllUndoHistory,cleanupUndoHistory:N.cleanupUndoHistory,deleteConversationHistory:N.deleteConversationHistory,debugStatus:N.debugStatus,mdPreviewMode:$.mdPreviewMode,renderOfficeLocal:$.renderOfficeLocal,performFind:L.performFind,findBarVisible:L.findBarVisible,findQuery:L.findQuery,t}),m=gf(e,{getEffectiveWorkDir:s,normalizePath:n,selectedPaths:D.selectedPaths,lastClickedIndex:D.lastClickedIndex,openFileInTab:(...x)=>y.openFileInTab(...x),clearSelection:D.clearSelection});let P=bf(e,{getEffectiveWorkDir:s,treePath:m.treePath,openFileInTab:(...x)=>y.openFileInTab(...x),normalizePath:n,treeRootPath:m.treeRootPath,treeNodes:m.treeNodes,loadTreeDirectory:m.loadTreeDirectory});N.setKeyBindings({openQuickOpen:P.openQuickOpen,openGoToLine:P.openGoToLine});let M=kf(e,{getEffectiveWorkDir:s,treePath:m.treePath,treeRootPath:m.treeRootPath,treeNodes:m.treeNodes,normalizePath:n,loadTreeDirectory:m.loadTreeDirectory}),C=Af({store:e,normalizePath:n,getEffectiveWorkDir:s,openFiles:y.openFiles,activeFileIndex:y.activeFileIndex,activeFile:y.activeFile,fileLoading:y.fileLoading,fileSaving:y.fileSaving,saveTabsState:y.saveTabsState,createEditor:N.createEditor,openFileInTab:y.openFileInTab,tree:m,fp:M,qo:P,ops:D,mdPreviewMode:$.mdPreviewMode,renderOfficeLocal:$.renderOfficeLocal,editorContainer:l,debugStatus:N.debugStatus}),R=x=>D.deleteSingleFile(x,t),j=()=>D.deleteSelected(t),O=()=>D.ctxDelete(t),Y=(x,K)=>D.onDrop(x,K,D.handleExternalFileDrop),te=x=>D.onTreeDrop(x,m.treeRootPath.value,D.handleExternalFileDrop),he=()=>P.goToLineConfirm(y.activeFile);Vue.watch(()=>e.currentAgent,()=>{y.saveTabsState(e.currentConversation),N.destroyEditor(),m.clearTreeNodes(),y.openFiles.value=[],y.activeFileIndex.value=-1,y.fileLoading.value=!1,e.currentAgent&&Vue.nextTick(()=>m.initFileBrowser())});let ce=e.currentConversation;Vue.watch(()=>e.currentConversation,x=>{y.saveTabsState(ce),ce=x,y.restoreTabsState(x);let K=s(),re=n(K);K&&re!==m.treeRootPath.value&&(m.treePath.value=K,m.treeRootPath.value=re,m.clearTreeNodes(),m.loadTreeDirectory(K))}),Vue.watch(()=>e.theme,x=>{let K=y.activeFile.value;K?.cmInstance&&K.cmInstance.setOption("theme",x==="dark"?"material-darker":"default")}),Vue.watch(()=>s(),x=>{if(x&&!m.treeRootPath.value){let K=n(x);m.treePath.value=x,m.treeRootPath.value=K,m.clearTreeNodes(),m.loadTreeDirectory(x)}}),Vue.watch(()=>y.activeFile.value?.content,(x,K)=>{let re=y.activeFile.value;if(re&&x!=null&&K==null&&!re.cmInstance&&(!re.fileType||re.fileType==="text")){if(Dt(re.name)&&$.mdPreviewMode.value)return;Vue.nextTick(()=>{setTimeout(()=>{re.cmInstance||N.createEditor(re)},150)})}}),Vue.watch([$.mdRenderedHtml,$.mdPreviewMode],([x,K])=>{x&&K&&Vue.nextTick(()=>{setTimeout(()=>$.renderMermaidBlocks(),50)})});let ke=x=>{!(a.value&&a.value.offsetParent!==null)&&!P.quickOpenVisible.value&&!P.goToLineVisible.value&&!L.findBarVisible.value||((x.ctrlKey||x.metaKey)&&x.key==="p"?(x.preventDefault(),P.quickOpenVisible.value?P.closeQuickOpen():P.openQuickOpen()):(x.ctrlKey||x.metaKey)&&x.key==="g"?(x.preventDefault(),P.goToLineVisible.value?P.closeGoToLine():P.openGoToLine()):(x.ctrlKey||x.metaKey)&&x.key==="f"?y.activeFile.value&&(x.preventDefault(),L.openFindBar(!1)):(x.ctrlKey||x.metaKey)&&(x.key==="r"||x.key==="h")?y.activeFile.value&&(x.preventDefault(),L.openFindBar(!0)):x.key==="Escape"&&(L.findBarVisible.value&&L.closeFindBar(),D.selectedPaths.size>0&&D.clearSelection(),P.quickOpenVisible.value&&P.closeQuickOpen(),P.goToLineVisible.value&&P.closeGoToLine()))},ve=()=>{D.hideContextMenu()},ge=()=>{c.value=window.innerWidth<=768};return Vue.watch(()=>y.activeFileIndex.value,(x,K)=>{c.value&&x>=0&&x!==K&&(d.value="editor")}),Vue.watch(()=>y.openFiles.value.length,x=>{c.value&&x===0&&(d.value="tree")}),Vue.onMounted(()=>{window.addEventListener("workbench-message",C.handleWorkbenchMessage),window.addEventListener("open-file-in-explorer",C.handleOpenFile),window.addEventListener("conversation-deleted",y.handleConversationDeleted),window.addEventListener("keydown",ke),document.addEventListener("click",ve),window.addEventListener("resize",ge),$.initMermaid(),e.currentAgent&&(m.initFileBrowser(),e.sendWsMessage({type:"restore_file_tabs"}))}),Vue.onUnmounted(()=>{window.removeEventListener("workbench-message",C.handleWorkbenchMessage),window.removeEventListener("open-file-in-explorer",C.handleOpenFile),window.removeEventListener("conversation-deleted",y.handleConversationDeleted),window.removeEventListener("keydown",ke),document.removeEventListener("click",ve),window.removeEventListener("resize",ge),N.destroyEditor(),D.cleanup()}),{store:e,debugStatus:N.debugStatus,rootEl:a,isMobile:c,mobileView:d,mobileGoBack:u,fontSize:f,zoomIn:g,zoomOut:v,onWheel:h,treePath:m.treePath,treeRootPath:m.treeRootPath,treeNodes:m.treeNodes,flattenedTree:m.flattenedTree,editingTreePath:m.editingTreePath,treePathInputRef:m.treePathInputRef,rootFolderName:m.rootFolderName,rootExpanded:m.rootExpanded,toggleRootExpand:m.toggleRootExpand,collapseAll:m.collapseAll,startTreePathEdit:m.startTreePathEdit,confirmTreePath:m.confirmTreePath,cancelTreePathEdit:m.cancelTreePathEdit,treePanelWidth:A,isTreeResizing:w,startTreeResize:k,openFiles:y.openFiles,activeFileIndex:y.activeFileIndex,activeFile:y.activeFile,fileLoading:y.fileLoading,fileSaving:y.fileSaving,editorContainer:l,officePreviewContainer:$.officePreviewContainer,mdPreviewRef:$.mdPreviewRef,isActiveMarkdown:$.isActiveMarkdown,mdPreviewMode:$.mdPreviewMode,mdRenderedHtml:$.mdRenderedHtml,switchToMdEdit:$.switchToMdEdit,folderPickerOpen:M.folderPickerOpen,folderPickerPath:M.folderPickerPath,folderPickerEntries:M.folderPickerEntries,folderPickerLoading:M.folderPickerLoading,folderPickerSelected:M.folderPickerSelected,searchQuery:P.searchQuery,searchResults:P.searchResults,searchLoading:P.searchLoading,onSearchInput:P.onSearchInput,clearSearch:P.clearSearch,onSearchResultClick:P.onSearchResultClick,quickOpenVisible:P.quickOpenVisible,quickOpenQuery:P.quickOpenQuery,quickOpenResults:P.quickOpenResults,quickOpenSelectedIndex:P.quickOpenSelectedIndex,quickOpenLoading:P.quickOpenLoading,quickOpenInput:P.quickOpenInput,openQuickOpen:P.openQuickOpen,closeQuickOpen:P.closeQuickOpen,onQuickOpenInput:P.onQuickOpenInput,quickOpenSelectNext:P.quickOpenSelectNext,quickOpenSelectPrev:P.quickOpenSelectPrev,quickOpenConfirm:P.quickOpenConfirm,quickOpenOpenFile:P.quickOpenOpenFile,goToLineVisible:P.goToLineVisible,goToLineValue:P.goToLineValue,goToLineInput:P.goToLineInput,openGoToLine:P.openGoToLine,closeGoToLine:P.closeGoToLine,goToLineConfirm:he,findBarVisible:L.findBarVisible,replaceBarVisible:L.replaceBarVisible,findQuery:L.findQuery,replaceQuery:L.replaceQuery,findCaseSensitive:L.findCaseSensitive,findUseRegex:L.findUseRegex,findMatchCount:L.findMatchCount,findMatchIndex:L.findMatchIndex,findInputRef:L.findInputRef,replaceInputRef:L.replaceInputRef,onFindInput:L.onFindInput,findNext:L.findNext,findPrev:L.findPrev,openFindBar:L.openFindBar,closeFindBar:L.closeFindBar,toggleReplaceBar:L.toggleReplaceBar,replaceOne:L.replaceOne,replaceAll:L.replaceAll,selectedPaths:D.selectedPaths,fileOperating:D.fileOperating,fileOpFeedback:D.fileOpFeedback,newFileDialogVisible:D.newFileDialogVisible,newFileName:D.newFileName,newFileType:D.newFileType,newFileInput:D.newFileInput,moveDialogVisible:D.moveDialogVisible,moveDestination:D.moveDestination,moveDestInput:D.moveDestInput,toggleSelection:D.toggleSelection,clearSelection:D.clearSelection,showNewFileDialog:D.showNewFileDialog,confirmNewFile:D.confirmNewFile,deleteSingleFile:R,deleteSelected:j,openMoveDialog:D.openMoveDialog,confirmMove:D.confirmMove,contextMenu:D.contextMenu,showContextMenu:D.showContextMenu,hideContextMenu:D.hideContextMenu,ctxRename:D.ctxRename,ctxCopy:D.ctxCopy,ctxMoveTo:D.ctxMoveTo,ctxDelete:O,ctxDownload:D.ctxDownload,renameDialogVisible:D.renameDialogVisible,renameNewName:D.renameNewName,renameInput:D.renameInput,confirmRename:D.confirmRename,dragState:D.dragState,externalDropActive:D.externalDropActive,onDragStart:D.onDragStart,onDragOver:D.onDragOver,onDragLeave:D.onDragLeave,onDrop:Y,onTreeDragOver:D.onTreeDragOver,onTreeDragLeave:D.onTreeDragLeave,onTreeDrop:te,loadRootDirectory:m.loadRootDirectory,onTreeItemClick:m.onTreeItemClick,openFileInTab:y.openFileInTab,switchToTab:y.switchToTab,closeFileTab:y.closeFileTab,saveFile:y.saveFile,openFolderPicker:M.openFolderPicker,folderPickerNavigateUp:M.folderPickerNavigateUp,folderPickerSelectItem:M.folderPickerSelectItem,folderPickerEnter:M.folderPickerEnter,confirmFolderPicker:M.confirmFolderPicker,getFileIcon:()=>"",getFileIconHtml:r,getFolderIcon:i,formatSize:o,refresh:m.refresh,placeholderPath:Vue.computed(()=>{let x=s();return x?t("files.workDir",{dir:x}):t("files.enterDirPath")})}}}});var Si,Ua=F(()=>{Qp();cf();Mf();Si={name:"WorkbenchPanel",components:{TerminalTab:Gp,GitStatusTab:lf,FilesTab:Tf},template:`
|
|
2660
|
+
`,setup(){let e=Pinia.useChatStore(),t=Vue.inject("t"),s=()=>e.effectiveWorkDir||"",n=x=>x?x.replace(/\\/g,"/"):"",r=x=>wi(x),i=x=>ki(x),o=x=>x==null?"":x<1024?x+" B":x<1024*1024?(x/1024).toFixed(1)+" KB":(x/(1024*1024)).toFixed(1)+" MB",a=Vue.ref(null),l=Vue.ref(null),c=Vue.ref(window.innerWidth<=768),d=Vue.ref("tree"),u=()=>{d.value="tree"},f=Vue.ref(parseInt(localStorage.getItem("filesFontSize"))||15),p=x=>{f.value=Math.max(8,Math.min(24,x)),localStorage.setItem("filesFontSize",f.value.toString());let K=y.activeFile.value;K?.cmInstance&&(K.cmInstance.getWrapperElement().style.fontSize=f.value+"px",K.cmInstance.refresh())},g=()=>p(f.value+1),h=()=>p(f.value-1),v=x=>{x.deltaY<0?g():h()},C=Vue.ref(parseInt(localStorage.getItem("filePanelWidth"))||220),w=Vue.ref(!1),k=x=>{x.preventDefault();let K=x.type==="touchstart";w.value=!0;let re=K?x.touches[0].clientX:x.clientX,ye=C.value;document.body.style.cursor="col-resize",document.body.style.userSelect="none";let W=x.target.closest(".file-two-col"),ne=W?W.offsetWidth*.5:400,U=H=>{let _=K?H.touches[0].clientX:H.clientX;C.value=Math.max(120,Math.min(ne,ye+(_-re)))},B=()=>{w.value=!1,document.body.style.cursor="",document.body.style.userSelect="",localStorage.setItem("filePanelWidth",C.value.toString()),document.removeEventListener("mousemove",U),document.removeEventListener("mouseup",B),document.removeEventListener("touchmove",U),document.removeEventListener("touchend",B)};document.addEventListener(K?"touchmove":"mousemove",U),document.addEventListener(K?"touchend":"mouseup",B)},y,m,b=Vue.computed(()=>y?y.activeFile.value:null),T=Vue.computed(()=>m?m.treePath.value:""),L=df(b),N=hf(e,{activeFile:b,editorContainer:l,fontSize:f,clearFindMarkers:L.clearFindMarkers,openFindBar:L.openFindBar,saveFile:()=>y.saveFile()}),$=vf(b,{editorContainer:l,createEditor:N.createEditor,t}),D=pf(e,{getEffectiveWorkDir:s,treePath:T});y=If(e,{normalizePath:n,getEffectiveWorkDir:s,editorContainer:l,createEditor:N.createEditor,destroyEditor:N.destroyEditor,clearFindMarkers:L.clearFindMarkers,saveCurrentUndoHistory:N.saveCurrentUndoHistory,saveAllUndoHistory:N.saveAllUndoHistory,cleanupUndoHistory:N.cleanupUndoHistory,deleteConversationHistory:N.deleteConversationHistory,debugStatus:N.debugStatus,mdPreviewMode:$.mdPreviewMode,renderOfficeLocal:$.renderOfficeLocal,performFind:L.performFind,findBarVisible:L.findBarVisible,findQuery:L.findQuery,t}),m=gf(e,{getEffectiveWorkDir:s,normalizePath:n,selectedPaths:D.selectedPaths,lastClickedIndex:D.lastClickedIndex,openFileInTab:(...x)=>y.openFileInTab(...x),clearSelection:D.clearSelection});let P=bf(e,{getEffectiveWorkDir:s,treePath:m.treePath,openFileInTab:(...x)=>y.openFileInTab(...x),normalizePath:n,treeRootPath:m.treeRootPath,treeNodes:m.treeNodes,loadTreeDirectory:m.loadTreeDirectory});N.setKeyBindings({openQuickOpen:P.openQuickOpen,openGoToLine:P.openGoToLine});let M=kf(e,{getEffectiveWorkDir:s,treePath:m.treePath,treeRootPath:m.treeRootPath,treeNodes:m.treeNodes,normalizePath:n,loadTreeDirectory:m.loadTreeDirectory}),A=Af({store:e,normalizePath:n,getEffectiveWorkDir:s,openFiles:y.openFiles,activeFileIndex:y.activeFileIndex,activeFile:y.activeFile,fileLoading:y.fileLoading,fileSaving:y.fileSaving,saveTabsState:y.saveTabsState,createEditor:N.createEditor,openFileInTab:y.openFileInTab,tree:m,fp:M,qo:P,ops:D,mdPreviewMode:$.mdPreviewMode,renderOfficeLocal:$.renderOfficeLocal,editorContainer:l,debugStatus:N.debugStatus}),R=x=>D.deleteSingleFile(x,t),j=()=>D.deleteSelected(t),O=()=>D.ctxDelete(t),Y=(x,K)=>D.onDrop(x,K,D.handleExternalFileDrop),te=x=>D.onTreeDrop(x,m.treeRootPath.value,D.handleExternalFileDrop),he=()=>P.goToLineConfirm(y.activeFile);Vue.watch(()=>e.currentAgent,()=>{y.saveTabsState(e.currentConversation),N.destroyEditor(),m.clearTreeNodes(),y.openFiles.value=[],y.activeFileIndex.value=-1,y.fileLoading.value=!1,e.currentAgent&&Vue.nextTick(()=>m.initFileBrowser())});let ce=e.currentConversation;Vue.watch(()=>e.currentConversation,x=>{y.saveTabsState(ce),ce=x,y.restoreTabsState(x);let K=s(),re=n(K);K&&re!==m.treeRootPath.value&&(m.treePath.value=K,m.treeRootPath.value=re,m.clearTreeNodes(),m.loadTreeDirectory(K))}),Vue.watch(()=>e.theme,x=>{let K=y.activeFile.value;K?.cmInstance&&K.cmInstance.setOption("theme",x==="dark"?"material-darker":"default")}),Vue.watch(()=>s(),x=>{if(x&&!m.treeRootPath.value){let K=n(x);m.treePath.value=x,m.treeRootPath.value=K,m.clearTreeNodes(),m.loadTreeDirectory(x)}}),Vue.watch(()=>y.activeFile.value?.content,(x,K)=>{let re=y.activeFile.value;if(re&&x!=null&&K==null&&!re.cmInstance&&(!re.fileType||re.fileType==="text")){if(Dt(re.name)&&$.mdPreviewMode.value)return;Vue.nextTick(()=>{setTimeout(()=>{re.cmInstance||N.createEditor(re)},150)})}}),Vue.watch([$.mdRenderedHtml,$.mdPreviewMode],([x,K])=>{x&&K&&Vue.nextTick(()=>{setTimeout(()=>$.renderMermaidBlocks(),50)})});let ke=x=>{!(a.value&&a.value.offsetParent!==null)&&!P.quickOpenVisible.value&&!P.goToLineVisible.value&&!L.findBarVisible.value||((x.ctrlKey||x.metaKey)&&x.key==="p"?(x.preventDefault(),P.quickOpenVisible.value?P.closeQuickOpen():P.openQuickOpen()):(x.ctrlKey||x.metaKey)&&x.key==="g"?(x.preventDefault(),P.goToLineVisible.value?P.closeGoToLine():P.openGoToLine()):(x.ctrlKey||x.metaKey)&&x.key==="f"?y.activeFile.value&&(x.preventDefault(),L.openFindBar(!1)):(x.ctrlKey||x.metaKey)&&(x.key==="r"||x.key==="h")?y.activeFile.value&&(x.preventDefault(),L.openFindBar(!0)):x.key==="Escape"&&(L.findBarVisible.value&&L.closeFindBar(),D.selectedPaths.size>0&&D.clearSelection(),P.quickOpenVisible.value&&P.closeQuickOpen(),P.goToLineVisible.value&&P.closeGoToLine()))},ve=()=>{D.hideContextMenu()},ge=()=>{c.value=window.innerWidth<=768};return Vue.watch(()=>y.activeFileIndex.value,(x,K)=>{c.value&&x>=0&&x!==K&&(d.value="editor")}),Vue.watch(()=>y.openFiles.value.length,x=>{c.value&&x===0&&(d.value="tree")}),Vue.onMounted(()=>{window.addEventListener("workbench-message",A.handleWorkbenchMessage),window.addEventListener("open-file-in-explorer",A.handleOpenFile),window.addEventListener("conversation-deleted",y.handleConversationDeleted),window.addEventListener("keydown",ke),document.addEventListener("click",ve),window.addEventListener("resize",ge),$.initMermaid(),e.currentAgent&&(m.initFileBrowser(),e.sendWsMessage({type:"restore_file_tabs"}))}),Vue.onUnmounted(()=>{window.removeEventListener("workbench-message",A.handleWorkbenchMessage),window.removeEventListener("open-file-in-explorer",A.handleOpenFile),window.removeEventListener("conversation-deleted",y.handleConversationDeleted),window.removeEventListener("keydown",ke),document.removeEventListener("click",ve),window.removeEventListener("resize",ge),N.destroyEditor(),D.cleanup()}),{store:e,debugStatus:N.debugStatus,rootEl:a,isMobile:c,mobileView:d,mobileGoBack:u,fontSize:f,zoomIn:g,zoomOut:h,onWheel:v,treePath:m.treePath,treeRootPath:m.treeRootPath,treeNodes:m.treeNodes,flattenedTree:m.flattenedTree,editingTreePath:m.editingTreePath,treePathInputRef:m.treePathInputRef,rootFolderName:m.rootFolderName,rootExpanded:m.rootExpanded,toggleRootExpand:m.toggleRootExpand,collapseAll:m.collapseAll,startTreePathEdit:m.startTreePathEdit,confirmTreePath:m.confirmTreePath,cancelTreePathEdit:m.cancelTreePathEdit,treePanelWidth:C,isTreeResizing:w,startTreeResize:k,openFiles:y.openFiles,activeFileIndex:y.activeFileIndex,activeFile:y.activeFile,fileLoading:y.fileLoading,fileSaving:y.fileSaving,editorContainer:l,officePreviewContainer:$.officePreviewContainer,mdPreviewRef:$.mdPreviewRef,isActiveMarkdown:$.isActiveMarkdown,mdPreviewMode:$.mdPreviewMode,mdRenderedHtml:$.mdRenderedHtml,switchToMdEdit:$.switchToMdEdit,folderPickerOpen:M.folderPickerOpen,folderPickerPath:M.folderPickerPath,folderPickerEntries:M.folderPickerEntries,folderPickerLoading:M.folderPickerLoading,folderPickerSelected:M.folderPickerSelected,searchQuery:P.searchQuery,searchResults:P.searchResults,searchLoading:P.searchLoading,onSearchInput:P.onSearchInput,clearSearch:P.clearSearch,onSearchResultClick:P.onSearchResultClick,quickOpenVisible:P.quickOpenVisible,quickOpenQuery:P.quickOpenQuery,quickOpenResults:P.quickOpenResults,quickOpenSelectedIndex:P.quickOpenSelectedIndex,quickOpenLoading:P.quickOpenLoading,quickOpenInput:P.quickOpenInput,openQuickOpen:P.openQuickOpen,closeQuickOpen:P.closeQuickOpen,onQuickOpenInput:P.onQuickOpenInput,quickOpenSelectNext:P.quickOpenSelectNext,quickOpenSelectPrev:P.quickOpenSelectPrev,quickOpenConfirm:P.quickOpenConfirm,quickOpenOpenFile:P.quickOpenOpenFile,goToLineVisible:P.goToLineVisible,goToLineValue:P.goToLineValue,goToLineInput:P.goToLineInput,openGoToLine:P.openGoToLine,closeGoToLine:P.closeGoToLine,goToLineConfirm:he,findBarVisible:L.findBarVisible,replaceBarVisible:L.replaceBarVisible,findQuery:L.findQuery,replaceQuery:L.replaceQuery,findCaseSensitive:L.findCaseSensitive,findUseRegex:L.findUseRegex,findMatchCount:L.findMatchCount,findMatchIndex:L.findMatchIndex,findInputRef:L.findInputRef,replaceInputRef:L.replaceInputRef,onFindInput:L.onFindInput,findNext:L.findNext,findPrev:L.findPrev,openFindBar:L.openFindBar,closeFindBar:L.closeFindBar,toggleReplaceBar:L.toggleReplaceBar,replaceOne:L.replaceOne,replaceAll:L.replaceAll,selectedPaths:D.selectedPaths,fileOperating:D.fileOperating,fileOpFeedback:D.fileOpFeedback,newFileDialogVisible:D.newFileDialogVisible,newFileName:D.newFileName,newFileType:D.newFileType,newFileInput:D.newFileInput,moveDialogVisible:D.moveDialogVisible,moveDestination:D.moveDestination,moveDestInput:D.moveDestInput,toggleSelection:D.toggleSelection,clearSelection:D.clearSelection,showNewFileDialog:D.showNewFileDialog,confirmNewFile:D.confirmNewFile,deleteSingleFile:R,deleteSelected:j,openMoveDialog:D.openMoveDialog,confirmMove:D.confirmMove,contextMenu:D.contextMenu,showContextMenu:D.showContextMenu,hideContextMenu:D.hideContextMenu,ctxRename:D.ctxRename,ctxCopy:D.ctxCopy,ctxMoveTo:D.ctxMoveTo,ctxDelete:O,ctxDownload:D.ctxDownload,renameDialogVisible:D.renameDialogVisible,renameNewName:D.renameNewName,renameInput:D.renameInput,confirmRename:D.confirmRename,dragState:D.dragState,externalDropActive:D.externalDropActive,onDragStart:D.onDragStart,onDragOver:D.onDragOver,onDragLeave:D.onDragLeave,onDrop:Y,onTreeDragOver:D.onTreeDragOver,onTreeDragLeave:D.onTreeDragLeave,onTreeDrop:te,loadRootDirectory:m.loadRootDirectory,onTreeItemClick:m.onTreeItemClick,openFileInTab:y.openFileInTab,switchToTab:y.switchToTab,closeFileTab:y.closeFileTab,saveFile:y.saveFile,openFolderPicker:M.openFolderPicker,folderPickerNavigateUp:M.folderPickerNavigateUp,folderPickerSelectItem:M.folderPickerSelectItem,folderPickerEnter:M.folderPickerEnter,confirmFolderPicker:M.confirmFolderPicker,getFileIcon:()=>"",getFileIconHtml:r,getFolderIcon:i,formatSize:o,refresh:m.refresh,placeholderPath:Vue.computed(()=>{let x=s();return x?t("files.workDir",{dir:x}):t("files.enterDirPath")})}}}});var Si,Ua=F(()=>{Qp();cf();Mf();Si={name:"WorkbenchPanel",components:{TerminalTab:Gp,GitStatusTab:lf,FilesTab:Tf},template:`
|
|
2661
2661
|
<div class="workbench-panel" :class="{ expanded: store.workbenchExpanded, maximized: store.workbenchMaximized }" :style="panelStyle">
|
|
2662
2662
|
<!-- \u5C55\u5F00\u65F6\u7684\u5B8C\u6574\u9762\u677F -->
|
|
2663
2663
|
<div class="workbench-content" v-if="store.workbenchExpanded">
|
|
@@ -2711,7 +2711,7 @@ ${String(e||"").trim()}
|
|
|
2711
2711
|
<!-- \u62D6\u62FD\u8C03\u6574\u5BBD\u5EA6\u624B\u67C4 -->
|
|
2712
2712
|
<div class="resize-handle" @mousedown="startResize" @touchstart.prevent="startResize" v-if="store.workbenchExpanded"></div>
|
|
2713
2713
|
</div>
|
|
2714
|
-
`,setup(){let e=Pinia.useChatStore(),t=Vue.computed(()=>e.hasCapability("terminal")),s=Vue.computed(()=>e.hasCapability("file_editor")),n=Vue.computed(()=>!1),r=Vue.reactive({}),i=()=>s.value?"files":t.value?"terminal":"files",o=Vue.computed(()=>{let
|
|
2714
|
+
`,setup(){let e=Pinia.useChatStore(),t=Vue.computed(()=>e.hasCapability("terminal")),s=Vue.computed(()=>e.hasCapability("file_editor")),n=Vue.computed(()=>!1),r=Vue.reactive({}),i=()=>s.value?"files":t.value?"terminal":"files",o=Vue.computed(()=>{let h=e.currentConversation,v=h&&r[h]||"files";return v==="terminal"&&!t.value||(v==="git"||v==="files"||v==="explorer")&&!s.value?i():v==="explorer"?"git":v}),a=h=>{let v=e.currentConversation;v&&(r[v]=h)},l=Vue.ref(0),c=Vue.ref(!1),d=Vue.ref(!1),u=Vue.computed(()=>{if(!e.workbenchExpanded)return{};if(e.workbenchMaximized)return{};if(window.innerWidth<=768)return{};if(!d.value)return c.value?{transition:"none"}:{};let h={width:l.value+"px"};return c.value&&(h.transition="none"),h}),f=h=>{h.preventDefault();let v=h.type==="touchstart",C=v?h.touches[0].clientX:h.clientX;if(c.value=!0,!d.value){let m=h.target.closest(".workbench-panel");m&&(l.value=m.offsetWidth),d.value=!0}let w=l.value;document.body.style.cursor="col-resize",document.body.style.userSelect="none";let k=m=>{let T=(v?m.touches[0].clientX:m.clientX)-C,L=Math.max(900,window.innerWidth-100);l.value=Math.max(280,Math.min(L,w+T))},y=()=>{c.value=!1,document.body.style.cursor="",document.body.style.userSelect="",document.removeEventListener("mousemove",k),document.removeEventListener("mouseup",y),document.removeEventListener("touchmove",k),document.removeEventListener("touchend",y)};document.addEventListener(v?"touchmove":"mousemove",k),document.addEventListener(v?"touchend":"mouseup",y)},p=()=>{let h=e.currentConversation;h&&s.value&&(r[h]="files")},g=h=>{let{conversationId:v}=h.detail;v&&delete r[v]};return Vue.onMounted(()=>{window.addEventListener("open-file-in-explorer",p),window.addEventListener("conversation-deleted",g)}),Vue.onUnmounted(()=>{window.removeEventListener("open-file-in-explorer",p),window.removeEventListener("conversation-deleted",g)}),{store:e,activeTab:o,setTab:a,hasTerminal:t,hasExplorer:s,hasTasks:n,panelStyle:u,startResize:f}}}});function rt(e){let t=e?.currentTarget;t&&Qn.set(t,{startedOnOverlay:e.target===t,endedOnOverlay:!1})}function it(e){let t=e?.currentTarget,s=t&&Qn.get(t);s&&(s.endedOnOverlay=e.target===t)}function ot(e){let t=e?.currentTarget;t&&Qn.delete(t)}function Je(e){let t=e?.currentTarget;if(!t)return!1;let s=Qn.get(t),n=e.target===t&&s?.startedOnOverlay===!0&&s.endedOnOverlay===!0;return Qn.delete(t),n}var Qn,bs=F(()=>{Qn=new WeakMap});var wt,Pf,Rf=F(()=>{ct();wt=20,Pf={name:"DashboardTab",template:`
|
|
2715
2715
|
<div class="db-container">
|
|
2716
2716
|
<!-- Loading state -->
|
|
2717
2717
|
<div v-if="loading && !loaded" class="db-loading">{{ $t('settings.dashboard.loading') }}</div>
|
|
@@ -3355,7 +3355,7 @@ ${String(e||"").trim()}
|
|
|
3355
3355
|
</button>
|
|
3356
3356
|
</div>
|
|
3357
3357
|
</div>
|
|
3358
|
-
`,setup(e,{emit:t}){let s=Pinia.useChatStore(),n=Vue.getCurrentInstance(),r=m=>n?.proxy?.$t?.(m)??m,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 m=i.value;l.backend=m?.backend||"tavily",l.key="",c.value=!1}Vue.watch(i,u,{immediate:!0});let f=Vue.computed(()=>c.value?l.key:""),p=Vue.computed(()=>{let m=i.value;return m?!!((m.backend||"tavily")!==l.backend||c.value):c.value});function g(m){c.value=!0,l.key=m.target.value}function
|
|
3358
|
+
`,setup(e,{emit:t}){let s=Pinia.useChatStore(),n=Vue.getCurrentInstance(),r=m=>n?.proxy?.$t?.(m)??m,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 m=i.value;l.backend=m?.backend||"tavily",l.key="",c.value=!1}Vue.watch(i,u,{immediate:!0});let f=Vue.computed(()=>c.value?l.key:""),p=Vue.computed(()=>{let m=i.value;return m?!!((m.backend||"tavily")!==l.backend||c.value):c.value});function g(m){c.value=!0,l.key=m.target.value}function h(){!c.value&&i.value?.tavilyKeyConfigured&&(c.value=!0,l.key="")}function v(){c.value=!0,l.key=""}function C(){u()}async function w(){if(!(d.value||!p.value)){d.value=!0;try{let m={backend:l.backend};c.value&&(m.tavilyApiKey=l.key.trim());let b=await s.updateSearchSettings(m);b?.error?t("message",b.error,!0):(t("message",r("search.settings.saveSuccess"),!1),c.value&&await s.loadTavilyUsage())}catch(m){t("message",m.message||String(m),!0)}finally{d.value=!1}}}async function k(){await s.loadTavilyUsage()}function y(m,b){return b?Math.min(100,Math.round(m/b*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:f,saving:d,dirty:p,onKeyInput:g,onKeyFocus:h,clearKey:v,reset:C,save:w,refreshUsage:k,pct:y}}}});var Of,Hf=F(()=>{Of={name:"McpTab",emits:["message"],template:`
|
|
3359
3359
|
<div class="mcp-settings-tab">
|
|
3360
3360
|
<div class="settings-section">
|
|
3361
3361
|
<h3 class="settings-section-title">
|
|
@@ -3458,7 +3458,7 @@ ${String(e||"").trim()}
|
|
|
3458
3458
|
</div>
|
|
3459
3459
|
</div>
|
|
3460
3460
|
</div>
|
|
3461
|
-
`,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(y=>[y.name,y]));return i.value.map(y=>{let m=k.get(y.name);return{...y,ready:!!(m&&m.ready),toolCount:m?m.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 f(k){if(!k)return[];let y=[],m=/"([^"]*)"|'([^']*)'|(\S+)/g,b;for(;(b=m.exec(k))!==null;)y.push(b[1]??b[2]??b[3]);return y}function p(k){if(!k)return{};let y={},m=k.split(/\r?\n/);for(let b of m){let T=b.trim();if(!T||T.startsWith("#"))continue;let L=T.indexOf("=");if(L<0)continue;let N=T.slice(0,L).trim(),$=T.slice(L+1);N&&(y[N]=$)}return y}function g(){d.value="";let k=(c.name||"").trim(),y=(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(!y)return d.value=r("settings.mcp.errors.commandRequired"),null;let m=[],b={};try{m=f(c.argsRaw)}catch{return d.value=r("settings.mcp.errors.argsParse"),null}try{b=p(c.envRaw)}catch{return d.value=r("settings.mcp.errors.envParse"),null}return{name:k,command:y,args:m,env:b}}async function
|
|
3461
|
+
`,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(y=>[y.name,y]));return i.value.map(y=>{let m=k.get(y.name);return{...y,ready:!!(m&&m.ready),toolCount:m?m.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 f(k){if(!k)return[];let y=[],m=/"([^"]*)"|'([^']*)'|(\S+)/g,b;for(;(b=m.exec(k))!==null;)y.push(b[1]??b[2]??b[3]);return y}function p(k){if(!k)return{};let y={},m=k.split(/\r?\n/);for(let b of m){let T=b.trim();if(!T||T.startsWith("#"))continue;let L=T.indexOf("=");if(L<0)continue;let N=T.slice(0,L).trim(),$=T.slice(L+1);N&&(y[N]=$)}return y}function g(){d.value="";let k=(c.name||"").trim(),y=(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(!y)return d.value=r("settings.mcp.errors.commandRequired"),null;let m=[],b={};try{m=f(c.argsRaw)}catch{return d.value=r("settings.mcp.errors.argsParse"),null}try{b=p(c.envRaw)}catch{return d.value=r("settings.mcp.errors.envParse"),null}return{name:k,command:y,args:m,env:b}}async function h(){let k=g();if(!k)return;let y=await s.addYeaftMcpServer(k);if(y?.error){t("message",y.error,!0);return}y?.connectError?t("message",r("settings.mcp.connectFailed")+": "+y.connectError,!0):t("message",r("settings.mcp.addSuccess"),!1),u()}async function v(k){if(!k||!confirm(r("settings.mcp.confirmRemove").replace("{name}",k)))return;let y=await s.removeYeaftMcpServer(k);y?.error?t("message",y.error,!0):t("message",r("settings.mcp.removeSuccess"),!1)}async function C(k){let y=await s.reloadYeaftMcpServer(k);y?.error?t("message",y.error,!0):t("message",r("settings.mcp.reloadSuccess"),!1)}async function w(){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:h,removeOne:v,reloadOne:C,reloadAll:w}}}});var Ii,za=F(()=>{ct();va();wa();bs();Rf();$f();Ff();Hf();Ii={name:"SettingsPanel",components:{DashboardTab:Pf,VpCrudPanel:Lf,SearchSettingsTab:Vf,McpTab:Of},props:{visible:Boolean,initialTab:{type:String,default:""},initialSubTab:{type:String,default:""},initialEditVpId:{type:String,default:""}},emits:["close"],template:`
|
|
3462
3462
|
<div
|
|
3463
3463
|
class="settings-overlay"
|
|
3464
3464
|
v-if="visible"
|
|
@@ -4167,7 +4167,7 @@ ${String(e||"").trim()}
|
|
|
4167
4167
|
</div>
|
|
4168
4168
|
</div>
|
|
4169
4169
|
</div>
|
|
4170
|
-
`,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},f=Vue.computed(()=>{if(!a.value)return null;let x=ut[a.value];return x||s.customExpertRoles.find(K=>K.id===a.value)||null}),p=Vue.computed(()=>{let x=f.value;return x?`${x.title}\xB7${x.name}`:""}),g=Vue.computed(()=>!a.value||!s.expertRoleDefinitions?null:s.expertRoleDefinitions[a.value]||null),
|
|
4170
|
+
`,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},f=Vue.computed(()=>{if(!a.value)return null;let x=ut[a.value];return x||s.customExpertRoles.find(K=>K.id===a.value)||null}),p=Vue.computed(()=>{let x=f.value;return x?`${x.title}\xB7${x.name}`:""}),g=Vue.computed(()=>!a.value||!s.expertRoleDefinitions?null:s.expertRoleDefinitions[a.value]||null),h=Vue.computed(()=>!a.value||ut[a.value]?null:s.customExpertRoles.find(x=>x.id===a.value)||null),v=Vue.ref(new Set([ed])),C=Vue.computed(()=>e.modelValue),w=Vue.computed(()=>td(i.value)),k=Vue.computed(()=>{let x=[...w.value];return x.push({id:"custom",name:o.value?"\u81EA\u5B9A\u4E49":"Custom",icon:"\u2728",order:99}),x}),y=Vue.computed(()=>v.value.has("custom")),m=Vue.computed(()=>new Set(w.value.map(x=>x.id))),b=Vue.computed(()=>Zc().filter(x=>m.value.has(x.teamId)&&v.value.has(x.teamId)));Vue.watch(()=>e.visible,x=>{x&&(s.fetchExpertRoleDefinitions(),s.fetchCustomExpertRoles())});let T=x=>{a.value=x,ut[x]&&s.fetchExpertRoleDefinitions()},L=x=>{c.value=x,l.value=!0},N=()=>{s.fetchCustomExpertRoles()},$=x=>{d.value=x},D=async()=>{if(d.value){try{let x=d.value.id,K=C.value.filter(re=>re.role!==x);K.length!==C.value.length&&t("update:modelValue",K),await s.deleteCustomExpertRole(x)}catch{}d.value=null}},P=x=>{if(!(v.value.size===1&&v.value.has(x)))if(v.value=new Set([x]),x==="custom"){let K=new Set(s.customExpertRoles.map(ye=>ye.id)),re=C.value.filter(ye=>K.has(ye.role));re.length!==C.value.length&&t("update:modelValue",re)}else{let K=C.value.filter(re=>{let ye=ut[re.role];return ye&&ye.group===x});K.length!==C.value.length&&t("update:modelValue",K)}},M=(x,K)=>C.value.some(re=>re.role===x&&re.action===(K||null)),A=x=>C.value.some(K=>K.role===x&&!K.action),R=x=>C.value.some(K=>K.role===x),j=x=>C.value.length>=ls&&!R(x),O=(x,K)=>M(x,K)?!1:!!(R(x)||C.value.length>=ls),Y=x=>{if(A(x.id)){t("update:modelValue",C.value.filter(K=>!(K.role===x.id&&!K.action)));return}if(R(x.id)){t("update:modelValue",[...C.value.filter(K=>K.role!==x.id),{role:x.id,action:null}]);return}C.value.length>=ls||t("update:modelValue",[...C.value,{role:x.id,action:null}])},te=(x,K)=>{if(M(x.id,K.id)){t("update:modelValue",C.value.filter(re=>!(re.role===x.id&&re.action===K.id)));return}if(R(x.id)){t("update:modelValue",[...C.value.filter(re=>re.role!==x.id),{role:x.id,action:K.id}]);return}C.value.length>=ls||t("update:modelValue",[...C.value,{role:x.id,action:K.id}])};return{store:s,roleListRef:r,enabledTeams:v,selections:C,availableTeams:w,allTeamTabs:k,filteredGroups:b,isZh:o,isCustomTabActive:y,viewingRoleId:a,viewingRoleMeta:f,viewingRoleTitle:p,viewingRoleDef:g,viewingCustomRole:h,viewRole:T,editorOpen:l,editingRole:c,openEditor:L,onEditorSaved:N,deletingRole:d,confirmDeleteRole:$,executeDelete:D,toggleTeam:P,isSelected:M,isRoleOnlySelected:A,hasRoleSelection:R,isRoleDisabled:j,isDisabled:O,toggleRoleOnly:Y,toggleAction:te,toggleCustomRoleOnly:x=>{Y(x)},toggleCustomAction:(x,K)=>{te(x,K)},getSelectionLabelFull:x=>{if(ut[x.role])return as(x);let re=s.customExpertRoles.find(ye=>ye.id===x.role);if(!re)return x.role;if(x.action){let ye=re.actions?.find(W=>W.id===x.action);return ye?`${re.name}\xB7${ye.name}`:re.name}return re.name},removeSelection:x=>{let K=[...C.value];K.splice(x,1),t("update:modelValue",K)},clearAll:()=>{t("update:modelValue",[])},getSelectionLabel:as}}}});var Ai,Ya=F(()=>{qn();Ai={name:"SubAgentPanel",props:{visible:{type:Boolean,default:!1}},emits:["close"],template:`
|
|
4171
4171
|
<div class="subagent-panel" :class="{ open: visible, expanded: store.activeSubagentId }" role="complementary" aria-label="Sub-Agents">
|
|
4172
4172
|
<!-- Expanded Mode: Full message thread for a subagent -->
|
|
4173
4173
|
<template v-if="store.activeSubagentId && activeAgent">
|
|
@@ -4241,7 +4241,7 @@ ${String(e||"").trim()}
|
|
|
4241
4241
|
</div>
|
|
4242
4242
|
</template>
|
|
4243
4243
|
</div>
|
|
4244
|
-
`,setup(e,{emit:t}){let s=Pinia.useChatStore(),n=Vue.ref(null),r=
|
|
4244
|
+
`,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(()=>Ye(n.value))}),Vue.onUnmounted(()=>document.removeEventListener("keydown",r));let i=Vue.computed(()=>s.currentSubagents),o=Vue.computed(()=>[...i.value].sort((v,C)=>v.status==="running"&&C.status!=="running"?-1:v.status!=="running"&&C.status==="running"?1:(C.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 C=v.messages.length-1;C>=0;C--)if(v.messages[C].type==="text")return v.messages[C];return null},f=(v,C)=>{if(!v)return"";let w=v.replace(/[#*_`~\[\]()>|\\]/g,"").replace(/\n+/g," ").trim();return w.length>C?w.substring(0,C)+"...":w},p=v=>v?oi(v):"",g=Vue.computed(()=>l.value.map(v=>`${v.type||""}:${v.content||""}`).join("\0")),h=()=>{Vue.nextTick(()=>{let v=n.value;v&&(Ye(v),v.scrollTop=v.scrollHeight)})};return Vue.watch(()=>[s.activeSubagentId,l.value.length,g.value],h),{store:s,allSubagents:i,sortedSubagents:o,activeAgent:a,activeMessages:l,expandAgent:c,closeExpanded:d,getLastMessage:u,truncate:f,renderMd:p,messagesRef:n}}}});var Bf,Wf=F(()=>{Bf={name:"BtwOverlay",template:`
|
|
4245
4245
|
<div v-if="store.btwMode" class="btw-float" role="log" aria-live="polite" aria-label="Side question conversation">
|
|
4246
4246
|
<div class="btw-card">
|
|
4247
4247
|
<div class="btw-header">
|
|
@@ -4479,7 +4479,7 @@ ${String(e||"").trim()}
|
|
|
4479
4479
|
<p class="pane-empty-text">{{ $t('splitScreen.selectFromSidebar') }}</p>
|
|
4480
4480
|
</div>
|
|
4481
4481
|
</div>
|
|
4482
|
-
`,setup(e){let t=Pinia.useChatStore(),s=Vue.ref(null),n=Vue.computed(()=>t.activePanelId===e.paneId),r=Vue.computed(()=>t.panels.find(J=>J.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(_=>_.isStreaming)),l=Vue.computed(()=>o.value&&!a.value),c=Vue.ref(0),d=Vue.ref(Date.now()),u=null,f=Vue.ref("cat"),p=new URLSearchParams(window.location.search).get("preview"),g=Vue.ref(0),v=Vue.ref(1),h=Vue.ref(5),A=Vue.ref(95),w=Vue.ref("bark-both"),k=Vue.ref(1),y=Vue.ref(-1),m=null;function b(){if(!c.value)return;d.value=Date.now();let _=(d.value-c.value)%19e3;if(_<4e3)g.value=0,v.value=1;else if(_<11500){let J=_-4e3,se;J<2500?se=J/2500*16:J<5e3?se=16+(J-2500)/2500*29:se=45+(J-5e3)/2500*55,g.value=se,v.value=1}else _<14e3?(g.value=(1-(_-11500)/2500)*100,v.value=-1):(g.value=0,v.value=1);u=requestAnimationFrame(b)}function T(){if(!c.value||f.value!=="dog")return;d.value=Date.now();let _=(d.value-c.value)%18e3;if(_<2e3)h.value=5,A.value=95,w.value="bark-both",k.value=1,y.value=-1;else if(_<5e3){let J=(_-2e3)/3e3;h.value=5+J*25,A.value=95,w.value="left-approach",k.value=1,y.value=-1}else if(_<8e3){let J=(_-5e3)/3e3;h.value=30,A.value=95-J*25,w.value="right-approach",k.value=1,y.value=-1}else if(_<1e4){let J=(_-8e3)/2e3;h.value=30+J*13,A.value=70-J*13,w.value="both-approach",k.value=1,y.value=-1}else if(_<11e3)h.value=43,A.value=57,w.value="snap",k.value=1,y.value=-1;else if(_<12500)h.value=43,A.value=57,w.value="stunned",k.value=1,y.value=-1;else if(_<15e3){let J=(_-12500)/2500;h.value=43-J*38,A.value=57+J*38,w.value="retreat",k.value=-1,y.value=1}else _<17e3?(h.value=5,A.value=95,w.value="rehang",k.value=-1,y.value=1):(h.value=5,A.value=95,w.value="reset",k.value=1,y.value=-1);m=requestAnimationFrame(T)}let L=Vue.computed(()=>{let _=h.value*1.2;return k.value<0?`translate(${_+13.5}, 0) scale(-1, 1)`:`translate(${_-13.5}, 0)`}),N=Vue.computed(()=>{let _=A.value*1.2;return y.value>0?`translate(${_-10.5}, 2)`:`translate(${_+10.5}, 2) scale(-1, 1)`}),$=Vue.computed(()=>{let _=w.value;return _==="bark-both"||_==="left-approach"||_==="right-approach"||_==="both-approach"||_==="reset"}),D=Vue.computed(()=>{let _=h.value*1.2,J=10;if($.value){let z=Math.max(0,(_-3)*.12);return`M3,18 Q${(3+_)/2},${18+z} ${_},${J}`}if(w.value==="rehang")return`M${_},${J} Q${_-3},20 3,18`;let se=k.value<0?1:-1,me=_+se*8;return`M${_},${J} Q${_},18 ${me},22`}),P=Vue.computed(()=>{let _=A.value*1.2,J=10;if($.value){let z=Math.max(0,(118-_)*.12);return`M118,18 Q${(118+_)/2},${18+z} ${_},${J}`}if(w.value==="rehang")return`M${_},${J} Q${_+3},20 118,18`;let se=y.value>0?-1:1,me=_+se*8;return`M${_},${J} Q${_},18 ${me},22`}),M=Vue.computed(()=>w.value==="snap"?.2:.4),C=Vue.computed(()=>w.value==="snap"?.2:.4),R=Vue.computed(()=>h.value*1.2),j=Vue.computed(()=>A.value*1.2),O=Vue.computed(()=>p==="cat"||p==="dog"||p==="animation"?!0:l.value);Vue.watch(l,_=>{_?(c.value=Date.now(),d.value=Date.now(),f.value="cat",g.value=0,v.value=1,h.value=5,A.value=95,w.value="bark-both",k.value=1,y.value=-1,f.value==="cat"?u=requestAnimationFrame(b):m=requestAnimationFrame(T)):(c.value=0,g.value=0,v.value=1,u&&(cancelAnimationFrame(u),u=null),m&&(cancelAnimationFrame(m),m=null))},{immediate:!0}),(p==="cat"||p==="dog"||p==="animation")&&(c.value=Date.now(),d.value=Date.now(),p==="dog"?f.value="dog":f.value="cat",f.value==="cat"?u=requestAnimationFrame(b):(h.value=5,A.value=95,w.value="bark-both",k.value=1,y.value=-1,m=requestAnimationFrame(T))),Vue.onUnmounted(()=>{u&&(cancelAnimationFrame(u),u=null),m&&(cancelAnimationFrame(m),m=null)});let Y=Vue.computed(()=>{if(!o.value)return null;if(t.connectionState!=="connected")return"disconnected";let _=r.value;if(t.compactStatus?.conversationId===_&&t.compactStatus?.status==="compacting")return"compacting";let J=t.sessionHealth?.[_];return J?J.status:c.value&&d.value-c.value>8e3?"thinking":null}),te=Vue.computed(()=>{if(!c.value)return"speed-napping";let _=(d.value-c.value)%19e3;return _>=16e3?"speed-petted":_>=14e3?"speed-tired":_>=11500?"speed-crazy":_>=9e3?"speed-turbo":_>=6500?"speed-fast":_>=4e3?"speed-normal":"speed-napping"}),he=Vue.computed(()=>{let _=g.value,J=v.value,me={left:`calc(40px + (100% - 80px) * ${_/100})`};return J<0&&(me.transform="scaleX(-1)"),me});function ce(){let _=r.value;if(!_)return;let J=t.conversations.find(se=>se.id===_);t.sendWsMessage({type:"refresh_conversation",conversationId:_,agentId:J?.agentId})}let ke=Vue.computed(()=>{let _=i.value,J=[],se=null,me=0,z=()=>{se&&(se.isActive=se.isStreaming===!0,Vr(se),(se.textContent||se.toolMsgs.length>0||se.todoMsg||se.askMsg)&&J.push(se),se=null)},ee=()=>{me++,se={type:"assistant-turn",id:"turn_"+me,textContent:"",textSegments:[],isStreaming:!1,isActive:!1,isHistory:!1,todoMsg:null,toolMsgs:[],askMsg:null,messages:[]}};for(let pe=0;pe<_.length;pe++){let oe=_[pe];if(oe.type==="user"){if(!oe.content||!oe.content.trim())continue;z(),J.push({type:"user",id:oe.id||"u_"+pe,message:oe});continue}if(oe.type==="system"||oe.type==="error"){z(),J.push({type:oe.type,id:oe.id||"s_"+pe,message:oe});continue}if(!(oe.type==="tool-result"||oe.type==="tool_result")){if(oe.type==="assistant"){se||ee(),$r(se,oe),oe.isStreaming&&(se.isStreaming=!0),oe.isHistory&&(se.isHistory=!0),se.messages.push(oe);continue}if(oe.type==="tool-use"){se||ee();let De=_[pe+1],$e=De&&(De.type==="tool-result"||De.type==="tool_result"),Fe={...oe,hasResult:$e||oe.hasResult||!1,toolResult:oe.toolResult||null};oe.toolName==="TodoWrite"?se.todoMsg=Fe:oe.toolName==="AskUserQuestion"?se.askMsg=Fe:se.toolMsgs.push(Fe),se.messages.push(oe);continue}z(),J.push({type:oe.type||"unknown",id:oe.id||"x_"+pe,message:oe})}}return z(),J}),ve=(_,J)=>{if(!r.value)return;let se=J||[];t.sendMessageToConversation(r.value,_,se)},ge=()=>{r.value&&t.cancelExecutionForConversation(r.value)};function x(){t.setActivePanel(e.paneId)}function K(){t.removePanel(e.paneId)}let re=Vue.computed(()=>t.getPaneRightPanel(e.paneId));function ye(){t.setPaneRightPanel(e.paneId,null)}let W=Vue.ref(!0),ne=50,U=()=>{if(!s.value)return!0;let{scrollTop:_,scrollHeight:J,clientHeight:se}=s.value;return J-_-se<=ne},B=()=>{s.value&&(s.value.scrollTop=s.value.scrollHeight)},H=()=>{W.value=U()};return Vue.watch(()=>i.value.length,()=>{W.value&&Vue.nextTick(B)}),Vue.watch(()=>{let _=i.value,J=_[_.length-1];return J?.isStreaming?J.content?.length:0},()=>{W.value&&Vue.nextTick(B)}),Vue.watch(r,()=>{s.value&&s.value.removeEventListener("scroll",H),W.value=!0,Vue.nextTick(()=>{s.value&&(s.value.addEventListener("scroll",H),B())})}),Vue.onMounted(()=>{s.value&&(s.value.addEventListener("scroll",H),B())}),Vue.onUnmounted(()=>{s.value&&s.value.removeEventListener("scroll",H)}),{store:t,containerRef:s,isActivePanel:n,conversationId:r,messages:i,isProcessing:o,showTypingDots:l,previewShowTypingDots:O,waitingStatus:Y,animationType:f,catSpeed:te,catStyle:he,dogPhase:w,spikeTransform:L,teddyTransform:N,leashPathL:D,leashPathR:P,leashOpacityL:M,leashOpacityR:C,questionLX:R,questionRX:j,refreshSession:ce,turnGroups:ke,sendFn:ve,cancelFn:ge,setActive:x,closePane:K,paneRightPanel:re,closePanePanel:ye}}}});var hy,Qt,Xn=F(()=>{hy=0,Qt={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(-1),l=`modern-select-${++hy}`,c=`${l}-menu`,d=Vue.ref({}),u=Vue.computed(()=>e.options.find(T=>T.value===e.modelValue)||null),f=Vue.computed(()=>{if(!e.searchable||!n.value.trim())return e.options;let T=n.value.trim().toLowerCase();return e.options.filter(L=>String(L.label||"").toLowerCase().includes(T)||String(L.sublabel||"").toLowerCase().includes(T)||String(L.value||"").toLowerCase().includes(T))}),p=T=>`${l}-option-${T}`,g=Vue.computed(()=>s.value&&a.value>=0&&a.value<f.value.length?p(a.value):void 0);function v(){let T=r.value,L=i.value;if(!T||!L)return;let N=6,$=8,D=T.getBoundingClientRect(),P=document.documentElement.clientWidth||window.innerWidth,M=document.documentElement.clientHeight||window.innerHeight,C=Math.min(Math.max(D.width,e.menuMinWidth),Math.max(0,P-$*2)),R=Math.min(L.scrollHeight,304),j=Math.max(0,M-D.bottom-N-$),O=Math.max(0,D.top-N-$),Y=j<R&&O>j,te=Math.max(48,Math.min(R,Y?O:j)),he=D.right-C,ce=Math.min(Math.max($,he),Math.max($,P-$-C));d.value={top:`${Y?D.top-N-te:D.bottom+N}px`,left:`${ce}px`,width:`${C}px`,maxHeight:`${te}px`,"--modern-select-list-max-height":`${Math.max(36,te-(e.searchable?58:12))}px`}}function h(){e.disabled||(s.value=!s.value,s.value&&(n.value="",a.value=f.value.findIndex(T=>T.value===e.modelValue),Vue.nextTick(()=>{v(),e.searchable&&o.value?.focus&&o.value.focus();let T=i.value?.querySelector(".modern-select-option.is-active");T?.scrollIntoView&&T.scrollIntoView({block:"nearest"})})))}function A(){s.value=!1}function w(T){!T||T.disabled||(t("update:modelValue",T.value),t("change",T.value),A())}function k(T){if(!f.value.length)return;let L=a.value;for(let N=0;N<f.value.length;N+=1)if(L=(L+T+f.value.length)%f.value.length,!f.value[L]?.disabled){a.value=L;return}}function y(T){if(!s.value){(T.key==="Enter"||T.key===" "||T.key==="ArrowDown")&&(T.preventDefault(),h());return}if(T.key==="Escape"){T.preventDefault(),A();return}if(T.key==="ArrowDown")T.preventDefault(),k(1);else if(T.key==="ArrowUp")T.preventDefault(),k(-1);else if(T.key==="Enter"){T.preventDefault();let L=f.value[a.value];L&&w(L)}}function m(T){s.value&&(r.value?.contains(T.target)||i.value?.contains(T.target)||A())}let b=()=>{s.value&&v()};return Vue.onMounted(()=>{document.addEventListener("mousedown",m),window.addEventListener("resize",b),window.addEventListener("scroll",b,!0)}),Vue.onBeforeUnmount(()=>{document.removeEventListener("mousedown",m),window.removeEventListener("resize",b),window.removeEventListener("scroll",b,!0)}),Vue.watch(()=>e.modelValue,()=>{}),{open:s,search:n,triggerEl:r,menuEl:i,searchEl:o,activeIdx:a,selected:u,filtered:f,menuId:c,menuStyle:d,optionId:p,activeOptionId:g,toggle:h,close:A,pick:w,onKey:y}},template:`
|
|
4482
|
+
`,setup(e){let t=Pinia.useChatStore(),s=Vue.ref(null),n=Vue.computed(()=>t.activePanelId===e.paneId),r=Vue.computed(()=>t.panels.find(J=>J.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(_=>_.isStreaming)),l=Vue.computed(()=>o.value&&!a.value),c=Vue.ref(0),d=Vue.ref(Date.now()),u=null,f=Vue.ref("cat"),p=new URLSearchParams(window.location.search).get("preview"),g=Vue.ref(0),h=Vue.ref(1),v=Vue.ref(5),C=Vue.ref(95),w=Vue.ref("bark-both"),k=Vue.ref(1),y=Vue.ref(-1),m=null;function b(){if(!c.value)return;d.value=Date.now();let _=(d.value-c.value)%19e3;if(_<4e3)g.value=0,h.value=1;else if(_<11500){let J=_-4e3,se;J<2500?se=J/2500*16:J<5e3?se=16+(J-2500)/2500*29:se=45+(J-5e3)/2500*55,g.value=se,h.value=1}else _<14e3?(g.value=(1-(_-11500)/2500)*100,h.value=-1):(g.value=0,h.value=1);u=requestAnimationFrame(b)}function T(){if(!c.value||f.value!=="dog")return;d.value=Date.now();let _=(d.value-c.value)%18e3;if(_<2e3)v.value=5,C.value=95,w.value="bark-both",k.value=1,y.value=-1;else if(_<5e3){let J=(_-2e3)/3e3;v.value=5+J*25,C.value=95,w.value="left-approach",k.value=1,y.value=-1}else if(_<8e3){let J=(_-5e3)/3e3;v.value=30,C.value=95-J*25,w.value="right-approach",k.value=1,y.value=-1}else if(_<1e4){let J=(_-8e3)/2e3;v.value=30+J*13,C.value=70-J*13,w.value="both-approach",k.value=1,y.value=-1}else if(_<11e3)v.value=43,C.value=57,w.value="snap",k.value=1,y.value=-1;else if(_<12500)v.value=43,C.value=57,w.value="stunned",k.value=1,y.value=-1;else if(_<15e3){let J=(_-12500)/2500;v.value=43-J*38,C.value=57+J*38,w.value="retreat",k.value=-1,y.value=1}else _<17e3?(v.value=5,C.value=95,w.value="rehang",k.value=-1,y.value=1):(v.value=5,C.value=95,w.value="reset",k.value=1,y.value=-1);m=requestAnimationFrame(T)}let L=Vue.computed(()=>{let _=v.value*1.2;return k.value<0?`translate(${_+13.5}, 0) scale(-1, 1)`:`translate(${_-13.5}, 0)`}),N=Vue.computed(()=>{let _=C.value*1.2;return y.value>0?`translate(${_-10.5}, 2)`:`translate(${_+10.5}, 2) scale(-1, 1)`}),$=Vue.computed(()=>{let _=w.value;return _==="bark-both"||_==="left-approach"||_==="right-approach"||_==="both-approach"||_==="reset"}),D=Vue.computed(()=>{let _=v.value*1.2,J=10;if($.value){let z=Math.max(0,(_-3)*.12);return`M3,18 Q${(3+_)/2},${18+z} ${_},${J}`}if(w.value==="rehang")return`M${_},${J} Q${_-3},20 3,18`;let se=k.value<0?1:-1,me=_+se*8;return`M${_},${J} Q${_},18 ${me},22`}),P=Vue.computed(()=>{let _=C.value*1.2,J=10;if($.value){let z=Math.max(0,(118-_)*.12);return`M118,18 Q${(118+_)/2},${18+z} ${_},${J}`}if(w.value==="rehang")return`M${_},${J} Q${_+3},20 118,18`;let se=y.value>0?-1:1,me=_+se*8;return`M${_},${J} Q${_},18 ${me},22`}),M=Vue.computed(()=>w.value==="snap"?.2:.4),A=Vue.computed(()=>w.value==="snap"?.2:.4),R=Vue.computed(()=>v.value*1.2),j=Vue.computed(()=>C.value*1.2),O=Vue.computed(()=>p==="cat"||p==="dog"||p==="animation"?!0:l.value);Vue.watch(l,_=>{_?(c.value=Date.now(),d.value=Date.now(),f.value="cat",g.value=0,h.value=1,v.value=5,C.value=95,w.value="bark-both",k.value=1,y.value=-1,f.value==="cat"?u=requestAnimationFrame(b):m=requestAnimationFrame(T)):(c.value=0,g.value=0,h.value=1,u&&(cancelAnimationFrame(u),u=null),m&&(cancelAnimationFrame(m),m=null))},{immediate:!0}),(p==="cat"||p==="dog"||p==="animation")&&(c.value=Date.now(),d.value=Date.now(),p==="dog"?f.value="dog":f.value="cat",f.value==="cat"?u=requestAnimationFrame(b):(v.value=5,C.value=95,w.value="bark-both",k.value=1,y.value=-1,m=requestAnimationFrame(T))),Vue.onUnmounted(()=>{u&&(cancelAnimationFrame(u),u=null),m&&(cancelAnimationFrame(m),m=null)});let Y=Vue.computed(()=>{if(!o.value)return null;if(t.connectionState!=="connected")return"disconnected";let _=r.value;if(t.compactStatus?.conversationId===_&&t.compactStatus?.status==="compacting")return"compacting";let J=t.sessionHealth?.[_];return J?J.status:c.value&&d.value-c.value>8e3?"thinking":null}),te=Vue.computed(()=>{if(!c.value)return"speed-napping";let _=(d.value-c.value)%19e3;return _>=16e3?"speed-petted":_>=14e3?"speed-tired":_>=11500?"speed-crazy":_>=9e3?"speed-turbo":_>=6500?"speed-fast":_>=4e3?"speed-normal":"speed-napping"}),he=Vue.computed(()=>{let _=g.value,J=h.value,me={left:`calc(40px + (100% - 80px) * ${_/100})`};return J<0&&(me.transform="scaleX(-1)"),me});function ce(){let _=r.value;if(!_)return;let J=t.conversations.find(se=>se.id===_);t.sendWsMessage({type:"refresh_conversation",conversationId:_,agentId:J?.agentId})}let ke=Vue.computed(()=>{let _=i.value,J=[],se=null,me=0,z=()=>{se&&(se.isActive=se.isStreaming===!0,Vr(se),(se.textContent||se.toolMsgs.length>0||se.todoMsg||se.askMsg)&&J.push(se),se=null)},ee=()=>{me++,se={type:"assistant-turn",id:"turn_"+me,textContent:"",textSegments:[],isStreaming:!1,isActive:!1,isHistory:!1,todoMsg:null,toolMsgs:[],askMsg:null,messages:[]}};for(let pe=0;pe<_.length;pe++){let oe=_[pe];if(oe.type==="user"){if(!oe.content||!oe.content.trim())continue;z(),J.push({type:"user",id:oe.id||"u_"+pe,message:oe});continue}if(oe.type==="system"||oe.type==="error"){z(),J.push({type:oe.type,id:oe.id||"s_"+pe,message:oe});continue}if(!(oe.type==="tool-result"||oe.type==="tool_result")){if(oe.type==="assistant"){se||ee(),$r(se,oe),oe.isStreaming&&(se.isStreaming=!0),oe.isHistory&&(se.isHistory=!0),se.messages.push(oe);continue}if(oe.type==="tool-use"){se||ee();let De=_[pe+1],$e=De&&(De.type==="tool-result"||De.type==="tool_result"),Fe={...oe,hasResult:$e||oe.hasResult||!1,toolResult:oe.toolResult||null};oe.toolName==="TodoWrite"?se.todoMsg=Fe:oe.toolName==="AskUserQuestion"?se.askMsg=Fe:se.toolMsgs.push(Fe),se.messages.push(oe);continue}z(),J.push({type:oe.type||"unknown",id:oe.id||"x_"+pe,message:oe})}}return z(),J}),ve=(_,J)=>{if(!r.value)return;let se=J||[];t.sendMessageToConversation(r.value,_,se)},ge=()=>{r.value&&t.cancelExecutionForConversation(r.value)};function x(){t.setActivePanel(e.paneId)}function K(){t.removePanel(e.paneId)}let re=Vue.computed(()=>t.getPaneRightPanel(e.paneId));function ye(){t.setPaneRightPanel(e.paneId,null)}let W=Vue.ref(!0),ne=50,U=()=>{if(!s.value)return!0;let{scrollTop:_,scrollHeight:J,clientHeight:se}=s.value;return J-_-se<=ne},B=()=>{s.value&&(s.value.scrollTop=s.value.scrollHeight)},H=()=>{W.value=U()};return Vue.watch(()=>i.value.length,()=>{W.value&&Vue.nextTick(B)}),Vue.watch(()=>{let _=i.value,J=_[_.length-1];return J?.isStreaming?J.content?.length:0},()=>{W.value&&Vue.nextTick(B)}),Vue.watch(r,()=>{s.value&&s.value.removeEventListener("scroll",H),W.value=!0,Vue.nextTick(()=>{s.value&&(s.value.addEventListener("scroll",H),B())})}),Vue.onMounted(()=>{s.value&&(s.value.addEventListener("scroll",H),B())}),Vue.onUnmounted(()=>{s.value&&s.value.removeEventListener("scroll",H)}),{store:t,containerRef:s,isActivePanel:n,conversationId:r,messages:i,isProcessing:o,showTypingDots:l,previewShowTypingDots:O,waitingStatus:Y,animationType:f,catSpeed:te,catStyle:he,dogPhase:w,spikeTransform:L,teddyTransform:N,leashPathL:D,leashPathR:P,leashOpacityL:M,leashOpacityR:A,questionLX:R,questionRX:j,refreshSession:ce,turnGroups:ke,sendFn:ve,cancelFn:ge,setActive:x,closePane:K,paneRightPanel:re,closePanePanel:ye}}}});var hy,Qt,Xn=F(()=>{hy=0,Qt={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(-1),l=`modern-select-${++hy}`,c=`${l}-menu`,d=Vue.ref({}),u=Vue.computed(()=>e.options.find(T=>T.value===e.modelValue)||null),f=Vue.computed(()=>{if(!e.searchable||!n.value.trim())return e.options;let T=n.value.trim().toLowerCase();return e.options.filter(L=>String(L.label||"").toLowerCase().includes(T)||String(L.sublabel||"").toLowerCase().includes(T)||String(L.value||"").toLowerCase().includes(T))}),p=T=>`${l}-option-${T}`,g=Vue.computed(()=>s.value&&a.value>=0&&a.value<f.value.length?p(a.value):void 0);function h(){let T=r.value,L=i.value;if(!T||!L)return;let N=6,$=8,D=T.getBoundingClientRect(),P=document.documentElement.clientWidth||window.innerWidth,M=document.documentElement.clientHeight||window.innerHeight,A=Math.min(Math.max(D.width,e.menuMinWidth),Math.max(0,P-$*2)),R=Math.min(L.scrollHeight,304),j=Math.max(0,M-D.bottom-N-$),O=Math.max(0,D.top-N-$),Y=j<R&&O>j,te=Math.max(48,Math.min(R,Y?O:j)),he=D.right-A,ce=Math.min(Math.max($,he),Math.max($,P-$-A));d.value={top:`${Y?D.top-N-te:D.bottom+N}px`,left:`${ce}px`,width:`${A}px`,maxHeight:`${te}px`,"--modern-select-list-max-height":`${Math.max(36,te-(e.searchable?58:12))}px`}}function v(){e.disabled||(s.value=!s.value,s.value&&(n.value="",a.value=f.value.findIndex(T=>T.value===e.modelValue),Vue.nextTick(()=>{h(),e.searchable&&o.value?.focus&&o.value.focus();let T=i.value?.querySelector(".modern-select-option.is-active");T?.scrollIntoView&&T.scrollIntoView({block:"nearest"})})))}function C(){s.value=!1}function w(T){!T||T.disabled||(t("update:modelValue",T.value),t("change",T.value),C())}function k(T){if(!f.value.length)return;let L=a.value;for(let N=0;N<f.value.length;N+=1)if(L=(L+T+f.value.length)%f.value.length,!f.value[L]?.disabled){a.value=L;return}}function y(T){if(!s.value){(T.key==="Enter"||T.key===" "||T.key==="ArrowDown")&&(T.preventDefault(),v());return}if(T.key==="Escape"){T.preventDefault(),C();return}if(T.key==="ArrowDown")T.preventDefault(),k(1);else if(T.key==="ArrowUp")T.preventDefault(),k(-1);else if(T.key==="Enter"){T.preventDefault();let L=f.value[a.value];L&&w(L)}}function m(T){s.value&&(r.value?.contains(T.target)||i.value?.contains(T.target)||C())}let b=()=>{s.value&&h()};return Vue.onMounted(()=>{document.addEventListener("mousedown",m),window.addEventListener("resize",b),window.addEventListener("scroll",b,!0)}),Vue.onBeforeUnmount(()=>{document.removeEventListener("mousedown",m),window.removeEventListener("resize",b),window.removeEventListener("scroll",b,!0)}),Vue.watch(()=>e.modelValue,()=>{}),{open:s,search:n,triggerEl:r,menuEl:i,searchEl:o,activeIdx:a,selected:u,filtered:f,menuId:c,menuStyle:d,optionId:p,activeOptionId:g,toggle:v,close:C,pick:w,onKey:y}},template:`
|
|
4483
4483
|
<div class="modern-select" :class="{ 'is-open': open, 'is-disabled': disabled }">
|
|
4484
4484
|
<button
|
|
4485
4485
|
type="button"
|
|
@@ -6005,7 +6005,6 @@ ${String(e||"").trim()}
|
|
|
6005
6005
|
:disabled="composerTargetUnavailable || composerDraftLocked"
|
|
6006
6006
|
:can-send="composerCanSend"
|
|
6007
6007
|
:sending="workItemMessageSending"
|
|
6008
|
-
:rows="3"
|
|
6009
6008
|
:send-label="$t('workCenter.sendToTarget', { target: composerTargetLabel })"
|
|
6010
6009
|
@input="onWorkItemMessageInput"
|
|
6011
6010
|
@keydown="onWorkItemMessageKeydown"
|
|
@@ -6706,7 +6705,7 @@ ${String(e||"").trim()}
|
|
|
6706
6705
|
</div>
|
|
6707
6706
|
</div>
|
|
6708
6707
|
</div>
|
|
6709
|
-
`,data(){return{showAgentDropdown:!1,showSettingsPanel:!1,restartingAgents:{},upgradingAgents:{},showConversationModal:!1,unifiedSessionCreateOpen:!1,unifiedSessionCreateProvider:"yeaft",convModalAgent:"",convModalWorkDir:"",convModalProvider:"claude-code",selectedResumeSession:null,historyLoaded:!1,windowWidth:window.innerWidth,folderPickerOpen:!1,folderPickerPath:"",folderPickerEntries:[],folderPickerLoading:!1,folderPickerSelected:"",folderPickerTarget:"",serverVersion:"",chatGroupCollapsed:!1,sidebarTab:"chat",editingChatId:null,editingChatName:"",activeSessionMenu:null}},computed:{store(){return Pinia.useChatStore()},providerOptions(){return[{value:"claude-code",label:this.$t("provider.claudeCode")},{value:"copilot",label:this.$t("provider.copilot")}]},agentOptions(){return this.store.agents.filter(e=>e.online).map(e=>({value:e.id,label:`${e.name}${e.latency?` (${e.latency}ms)`:""}`}))},canUseWorkbench(){let e=_e().role;return e==="admin"||e==="pro"},selectedConvModalAgentWorkDir(){return this.convModalAgent&&this.store.agents.find(t=>t.id===this.convModalAgent)?.workDir||""},onlineAgents(){return this.store.agents.filter(e=>e.online)},onlineAgentCount(){return this.onlineAgents.length},workCenterAgents(){return this.onlineAgents.filter(e=>Array.isArray(e.capabilities)&&e.capabilities.includes("work_center"))},isMobileView(){return this.windowWidth<=768},effectiveSidebarCollapsed(){return this.isMobileView?!this.store.sessionSidebarOpen:this.store.sidebarCollapsed},normalConversations(){return this.sortByActivity(this.store.conversations.filter(e=>e.agentOnline!==!1))},pinnedChatConversations(){let e=this.store.conversations.filter(t=>t.agentOnline!==!1&&this.store.isSessionPinned(t.id));return this.sortByActivity(e)},unpinnedChatConversations(){return this.sortByActivity(this.store.conversations.filter(e=>e.agentOnline!==!1&&!this.store.isSessionPinned(e.id)))},chatSessionCount(){return this.store.conversations.filter(e=>e.agentOnline!==!1).length}},methods:{onSidebarCollapse(){ag({isMobileView:this.isMobileView,showMobileSidebar:this.store.sessionSidebarOpen,closeMobileSidebar:()=>this.store.closeSessionSidebar(),toggleSidebar:()=>this.store.toggleSidebar()})},onModeFlip(e){e==="yeaft"?this.store.enterYeaft():this.store.leaveYeaft()},sortByActivity(e){return fu(e)},isCatalogSessionUnread(e){return e?.runtimeProvider!=="yeaft"?!1:this.store.isYeaftSessionUnread(e.routeRef?.sessionId,e.routeRef?.agentId)},onUnifiedCreate(e="yeaft"){this.unifiedSessionCreateProvider=["yeaft","copilot","claude-code"].includes(e)?e:"yeaft",this.unifiedSessionCreateOpen=!0},openWorkCenter(e=null){let t=this.workCenterAgents.find(s=>s.id===e)||this.workCenterAgents.find(s=>s.id===this.store.workCenterAgentId)||this.workCenterAgents[0];t&&this.store.enterWorkCenter(t.id)},onUnifiedSessionAction({action:e,row:t,title:s,sessions:n}={}){if(!t?.routeRef)return;let{runtimeProvider:r,agentId:i,sessionId:o}=t.routeRef;e==="rename"?this.store.renameCatalogSession({row:t,title:s}):e==="reorder"?this.store.reorderCatalogSessions(n):e==="pin"?this.store.toggleCatalogSessionPin(t):e==="remove"&&r!=="yeaft"?confirm(this.$t("chat.delete.confirm"))&&this.closeSession(o,i):r==="yeaft"&&e==="remove"?this.store.sessionCrudRequest("archive",{sessionId:o},{agentId:i}):r==="yeaft"&&e==="settings"&&(this.store.pendingUnifiedSessionSettings={sessionId:o,agentId:i,section:"session"},this.store.openCatalogSession(t))},openConversationModal({preserveProvider:e=!1}={}){this.showConversationModal=!0,e||(this.convModalProvider="claude-code"),this.convModalAgent="",this.convModalWorkDir="",this.selectedResumeSession=null,this.historyLoaded=!1,this._foldersRetried=!1;let t=this.store.agents.filter(r=>r.online),n=t.find(r=>r.id===this.store.currentAgent)||t[0];n&&(this.convModalAgent=n.id,this.store.listFoldersForAgent(this.convModalAgent,this.convModalProvider).then(()=>{this.showConversationModal&&this.store.folders.length===0&&!this._foldersRetried&&(this._foldersRetried=!0,setTimeout(()=>{this.showConversationModal&&this.convModalAgent&&this.store.listFoldersForAgent(this.convModalAgent,this.convModalProvider)},1500))}))},openConversationModalResume(){this.openConversationModal()},closeConversationModal(){this.showConversationModal=!1,this.convModalAgent="",this.convModalWorkDir="",this.selectedResumeSession=null,this.historyLoaded=!1},onConvModalAgentChange(){this.convModalAgent&&(this.convModalWorkDir="",this.selectedResumeSession=null,this.historyLoaded=!1,this.store.listFoldersForAgent(this.convModalAgent,this.convModalProvider))},onConvModalProviderChange(){this.convModalWorkDir="",this.selectedResumeSession=null,this.historyLoaded=!1,this.convModalAgent&&this.store.listFoldersForAgent(this.convModalAgent,this.convModalProvider)},onConvModalWorkDirInput(){this.historyLoaded=!1,this.selectedResumeSession=null,this._workDirInputTimer&&clearTimeout(this._workDirInputTimer),this._workDirInputTimer=setTimeout(()=>{this.convModalWorkDir.trim()&&this.convModalAgent&&(this.store.listHistorySessionsForAgent(this.convModalAgent,this.convModalWorkDir.trim(),this.convModalProvider),this.historyLoaded=!0)},500)},selectConvModalFolder(e){this.convModalWorkDir=e,this.selectedResumeSession=null,this.convModalAgent&&(this.store.listHistorySessionsForAgent(this.convModalAgent,e,this.convModalProvider),this.historyLoaded=!0)},loadConvModalFolders(){this.convModalAgent&&this.store.listFoldersForAgent(this.convModalAgent,this.convModalProvider)},loadConvModalSessions(){this.convModalAgent&&this.convModalWorkDir.trim()&&(this.store.listHistorySessionsForAgent(this.convModalAgent,this.convModalWorkDir.trim(),this.convModalProvider),this.historyLoaded=!0)},toggleAgentDropdown(){this.showAgentDropdown=!this.showAgentDropdown,this.showAgentDropdown&&this.store.refreshAgents()},selectAgent(e){this.store.selectAgent(e),this.showAgentDropdown=!1},createNewConversation(){if(!this.convModalAgent)return;this.store.selectAgent(this.convModalAgent);let e=this.convModalWorkDir.trim()||this.selectedConvModalAgentWorkDir;this.store.createConversation(e,this.convModalAgent,null,this.buildConvOpts()),this.closeConversationModal()},buildConvOpts(){let e={provider:this.convModalProvider};return this.convModalProvider==="copilot"&&(e.providerOptions={allowAllTools:!0}),e},resumeSession(e){if(!this.convModalAgent)return;this.store.selectAgent(this.convModalAgent),this.store._pendingSessionTitle=e.title;let t=e.workDir||this.convModalWorkDir.trim()||this.selectedConvModalAgentWorkDir;this.store.resumeConversation(e.sessionId,t,this.convModalAgent,this.buildConvOpts()),this.closeConversationModal()},resumeSelectedSession(){if(!this.convModalAgent||!this.selectedResumeSession)return;this.store.selectAgent(this.convModalAgent),this.store._pendingSessionTitle=this.selectedResumeSession.title;let e=this.selectedResumeSession.workDir||this.convModalWorkDir.trim()||this.selectedConvModalAgentWorkDir;this.store.resumeConversation(this.selectedResumeSession.sessionId,e,this.convModalAgent,this.buildConvOpts()),this.closeConversationModal()},formatDate(e){return _i(e,this.$t.bind(this))},selectConversation(e,t){this.store.leaveWorkCenter(),this.store.selectConversation(e,t),this.store.closeSessionSidebar()},onSessionClick(e){if(e.agentOnline===!1){this.store.addMessage({type:"system",content:this.$t("chat.session.agentOffline")});return}if(this.store.isSplitMode&&this.store.activePanelId){this.store.leaveWorkCenter(),this.store.setPanelConversation(this.store.activePanelId,e.id),this.store.closeSessionSidebar();return}this.selectConversation(e.id,e.agentId)},closeSession(e,t){this.store.closeSession(e,t)},deleteConversation(e,t){confirm(this.$t("chat.delete.confirm"))&&this.store.deleteConversation(e,t)},getConversationTitle(e){let t=this.store.getConversationTitle(e.id);return t?t.length>30?t.slice(0,30)+"...":t:e.claudeSessionId?e.claudeSessionId.slice(0,8)+"...":e.id.slice(0,8)+"..."},getConversationFullTitle(e){let t=this.store.getConversationTitle(e.id);if(t&&t.length>30)return t},startChatRename(e){this.editingChatId=e.id,this.editingChatName=this.store.customConversationTitles[e.id]||this.store.conversationTitles[e.id]||"",this.$nextTick(()=>{let t=this.$refs.chatRenameInput;if(t){let s=Array.isArray(t)?t[0]:t;s.focus(),s.select()}})},commitChatRename(){if(!this.editingChatId)return;let e=this.editingChatId,t=this.editingChatName.trim();this.editingChatId=null,this.editingChatName="",this.store.renameChatSession(e,t)},cancelChatRename(){this.editingChatId=null,this.editingChatName=""},toggleSessionMenu(e){this.activeSessionMenu=this.activeSessionMenu===e?null:e},closeSessionMenu(){this.activeSessionMenu=null},getConversationTime(e){let s=this.store.executionStatusMap[e.id]?.lastActivity||e.createdAt;if(!s)return"";let n=new Date(s),r=new Date,i=r-n;return i<6e4?this.$t("chat.time.justNow"):i<36e5?this.$t("chat.time.minutesAgo",{count:Math.floor(i/6e4)}):n.toDateString()===r.toDateString()?n.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}):n.toLocaleDateString(void 0,{month:"numeric",day:"numeric"})},providerLabel(e){return e==="copilot"?this.$t("provider.copilot"):e==="claude-code"?this.$t("provider.claudeCode"):e||""},shortenPath(e){return Oi(e)},formatTime(e){return e?new Date(e).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit"}):""},getLastPathSegment(e){return Zn(e)},getParentPath(e){if(!e)return"";let t=e.split(/[/\\]/);return t.length<=2?"":t.slice(0,-1).join("/")},handleResize(){this.windowWidth=window.innerWidth},restartAgent(e){let s=this.store.agents.find(n=>n.id===e)?.name||e;confirm(this.$t("chat.agent.restartConfirm",{name:s}))&&(this.restartingAgents[e]=!0,setTimeout(()=>{delete this.restartingAgents[e]},12e4),this.store.restartAgent(e))},upgradeAgent(e){let t=this.store.agents.find(n=>n.id===e),s=t?.name||e;confirm(this.$t("chat.agent.upgradeConfirm",{name:s}))&&(this.upgradingAgents[e]={since:Date.now(),oldVersion:t?.version||null},setTimeout(()=>{delete this.upgradingAgents[e]},12e4),this.store.upgradeAgent(e))},openFolderPicker(e){let t=this.convModalAgent;if(!t)return;this.folderPickerTarget=e,this.folderPickerOpen=!0,this.folderPickerSelected="",this.folderPickerLoading=!0;let s=this.convModalWorkDir,n=this.store.agents.find(o=>o.id===t),r=s||n?.workDir||"";this.folderPickerPath=r,this.folderPickerEntries=[];let i=()=>{this.store.sendWsMessage({type:"list_directory",conversationId:"_workdir_picker",agentId:t,dirPath:r,workDir:n?.workDir||""})};i(),this._folderPickerTimer&&clearTimeout(this._folderPickerTimer),this._folderPickerTimer=setTimeout(()=>{this.folderPickerLoading&&this.folderPickerOpen&&i()},5e3)},loadFolderPickerDir(e){let t=this.convModalAgent;if(!t)return;this.folderPickerLoading=!0,this.folderPickerSelected="",this.folderPickerEntries=[];let s=this.store.agents.find(r=>r.id===t),n=()=>{this.store.sendWsMessage({type:"list_directory",conversationId:"_workdir_picker",agentId:t,dirPath:e,workDir:s?.workDir||""})};n(),this._folderPickerTimer&&clearTimeout(this._folderPickerTimer),this._folderPickerTimer=setTimeout(()=>{this.folderPickerLoading&&this.folderPickerOpen&&n()},5e3)},folderPickerNavigateUp(){if(!this.folderPickerPath)return;let e=this.folderPickerPath.includes("\\"),t=e?"\\":"/",s=this.folderPickerPath.replace(/[/\\]$/,"").split(/[/\\]/);if(s.pop(),s.length===0)this.folderPickerPath="",this.loadFolderPickerDir("");else if(e&&s.length===1&&/^[A-Za-z]:$/.test(s[0]))this.folderPickerPath=s[0]+"\\",this.loadFolderPickerDir(s[0]+"\\");else{let n=s.join(t);this.folderPickerPath=n,this.loadFolderPickerDir(n)}},folderPickerSelectItem(e){this.folderPickerSelected=e.name},folderPickerEnter(e){let s=this.folderPickerPath.includes("\\")||/^[A-Z]:/.test(e.name)?"\\":"/",n;this.folderPickerPath?n=this.folderPickerPath.replace(/[/\\]$/,"")+s+e.name:/^[A-Z]:$/.test(e.name)?n=e.name+"\\":n="/"+e.name,this.folderPickerPath=n,this.loadFolderPickerDir(n)},confirmFolderPicker(){let e=this.folderPickerPath;if(e){if(this.folderPickerSelected){let t=e.includes("\\")?"\\":"/";e=e.replace(/[/\\]$/,"")+t+this.folderPickerSelected}this.convModalWorkDir=e,this.selectedResumeSession=null,this.convModalAgent&&(this.store.listHistorySessionsForAgent(this.convModalAgent,e,this.convModalProvider),this.historyLoaded=!0),this.folderPickerOpen=!1}},handleFolderPickerMessage(e){let t=e.detail;!t||t.type!=="directory_listing"||t.conversationId!=="_workdir_picker"||(this._folderPickerTimer&&(clearTimeout(this._folderPickerTimer),this._folderPickerTimer=null),this.folderPickerLoading=!1,this.folderPickerEntries=(t.entries||[]).filter(s=>s.type==="directory").sort((s,n)=>s.name.localeCompare(n.name)),t.dirPath!=null&&(this.folderPickerPath=t.dirPath))}},mounted(){if(this.store.openUnifiedChatCreate){let e=this.store.openUnifiedChatCreate;this.store.openUnifiedChatCreate=!1,this.convModalProvider=e==="copilot"?"copilot":"claude-code",this.openConversationModal({preserveProvider:!0})}this._clickOutsideHandler=e=>{e.target.closest(".agent-selector")||(this.showAgentDropdown=!1),!e.target.closest(".session-dots-btn")&&!e.target.closest(".session-menu")&&(this.activeSessionMenu=null)},document.addEventListener("click",this._clickOutsideHandler),window.addEventListener("resize",this.handleResize),window.addEventListener("workbench-message",this.handleFolderPickerMessage),fetch("/api/version").then(e=>e.json()).then(e=>{this.serverVersion=e.version}).catch(()=>{}),this._agentRestartAckHandler=e=>{let{agentId:t}=e.detail},window.addEventListener("agent-restart-ack",this._agentRestartAckHandler),this._agentUpgradeAckHandler=e=>{let{agentId:t,success:s,error:n,alreadyLatest:r,version:i,reason:o,currentNode:a,requiredNode:l}=e.detail;s?r&&(delete this.upgradingAgents[t],alert(this.$t("chat.agent.alreadyLatest",{version:i||""}))):(delete this.upgradingAgents[t],alert(o==="node_incompatible"?this.$t("chat.agent.nodeIncompatible",{current:a||"?",required:l||"?",version:i||""}):`Agent upgrade failed: ${n||"Unknown error"}`))},window.addEventListener("agent-upgrade-ack",this._agentUpgradeAckHandler),this._checkRestartingAgents=this.$watch(()=>this.store.agents.map(e=>e.id+":"+e.online),()=>{for(let e of Object.keys(this.restartingAgents)){let t=this.store.agents.find(s=>s.id===e);(t?.online||!t)&&delete this.restartingAgents[e]}for(let e of Object.keys(this.upgradingAgents)){let t=this.store.agents.find(r=>r.id===e),s=this.upgradingAgents[e],n=Date.now()-(s?.since||0);!t||n>12e4?delete this.upgradingAgents[e]:t.online&&(n<3e3?setTimeout(()=>{this.store.agents.find(o=>o.id===e)?.online&&delete this.upgradingAgents[e]},3e3-n):delete this.upgradingAgents[e])}})},beforeUnmount(){document.removeEventListener("click",this._clickOutsideHandler),window.removeEventListener("resize",this.handleResize),window.removeEventListener("workbench-message",this.handleFolderPickerMessage),window.removeEventListener("agent-restart-ack",this._agentRestartAckHandler),window.removeEventListener("agent-upgrade-ack",this._agentUpgradeAckHandler),this._checkRestartingAgents&&this._checkRestartingAgents(),this._folderPickerTimer&&clearTimeout(this._folderPickerTimer)}}});function ug(e={}){let{sessions:t,activeSessionId:s,activeSessionKey:n,pinnedSessionIds:r,onlineAgentIds:i}=e,o=s||null,a=n||null,l=Object.prototype.hasOwnProperty.call(e,"activeSessionKey"),c=Array.isArray(r)?r:[],d=Array.isArray(i)?new Set(i.filter(Boolean)):null,u=new Map;c.forEach((p,g)=>{typeof p=="string"&&p&&!u.has(p)&&u.set(p,g)});let f=[];for(let p of Array.isArray(t)?t:[]){if(!p||!p.id||d&&p.agentId&&!d.has(p.agentId))continue;let g=String(p.id),v=p.agentId?`${p.agentId}${g}`:g;f.push({kind:"session",id:g,raw:p,pinned:!!p.pinned||!p.agentId&&u.has(g),active:l?v===a:g===o,processing:!!p.running||!!p.active||!!p.isRunning||!!p.isActive,_manualOrder:Number.isFinite(p.sortOrder)?p.sortOrder:Number.MAX_SAFE_INTEGER,_activityTime:jr(p)})}return f.sort((p,g)=>{if(p.pinned!==g.pinned)return p.pinned?-1:1;if(p._manualOrder!==g._manualOrder)return p._manualOrder-g._manualOrder;if(p._activityTime!==g._activityTime)return g._activityTime-p._activityTime;let v=u.has(p.id)?u.get(p.id):Number.MAX_SAFE_INTEGER,h=u.has(g.id)?u.get(g.id):Number.MAX_SAFE_INTEGER;return v!==h?v-h:p.id.localeCompare(g.id)}),f.map(({_manualOrder:p,_activityTime:g,...v})=>v)}var pg=F(()=>{Ur()});var Ay,cC,fg,gg=F(()=>{Ei();Qa();Xa();Za();Ja();el();ul();pg();Ay=3600*1e3,cC=24*Ay,fg={name:"YeaftSidebar",components:{SessionCreateModal:Js,SidebarModeToggle:xi,SidebarAgentHeader:Ti,SidebarWorkCenter:Mi,SessionSidebarShell:Pi,UnifiedSessionList:Ri},emits:["select-group","select-chat","toggle-sidebar","back","open-settings","open-group-settings"],template:`
|
|
6708
|
+
`,data(){return{showAgentDropdown:!1,showSettingsPanel:!1,restartingAgents:{},upgradingAgents:{},showConversationModal:!1,unifiedSessionCreateOpen:!1,unifiedSessionCreateProvider:"yeaft",convModalAgent:"",convModalWorkDir:"",convModalProvider:"claude-code",selectedResumeSession:null,historyLoaded:!1,windowWidth:window.innerWidth,folderPickerOpen:!1,folderPickerPath:"",folderPickerEntries:[],folderPickerLoading:!1,folderPickerSelected:"",folderPickerTarget:"",serverVersion:"",chatGroupCollapsed:!1,sidebarTab:"chat",editingChatId:null,editingChatName:"",activeSessionMenu:null}},computed:{store(){return Pinia.useChatStore()},providerOptions(){return[{value:"claude-code",label:this.$t("provider.claudeCode")},{value:"copilot",label:this.$t("provider.copilot")}]},agentOptions(){return this.store.agents.filter(e=>e.online).map(e=>({value:e.id,label:`${e.name}${e.latency?` (${e.latency}ms)`:""}`}))},canUseWorkbench(){let e=_e().role;return e==="admin"||e==="pro"},selectedConvModalAgentWorkDir(){return this.convModalAgent&&this.store.agents.find(t=>t.id===this.convModalAgent)?.workDir||""},onlineAgents(){return this.store.agents.filter(e=>e.online)},onlineAgentCount(){return this.onlineAgents.length},workCenterAgents(){return this.onlineAgents.filter(e=>Array.isArray(e.capabilities)&&e.capabilities.includes("work_center"))},isMobileView(){return this.windowWidth<=768},effectiveSidebarCollapsed(){return this.isMobileView?!this.store.sessionSidebarOpen:this.store.sidebarCollapsed},normalConversations(){return this.sortByActivity(this.store.conversations.filter(e=>e.agentOnline!==!1))},pinnedChatConversations(){let e=this.store.conversations.filter(t=>t.agentOnline!==!1&&this.store.isSessionPinned(t.id));return this.sortByActivity(e)},unpinnedChatConversations(){return this.sortByActivity(this.store.conversations.filter(e=>e.agentOnline!==!1&&!this.store.isSessionPinned(e.id)))},chatSessionCount(){return this.store.conversations.filter(e=>e.agentOnline!==!1).length}},methods:{onSidebarCollapse(){ag({isMobileView:this.isMobileView,showMobileSidebar:this.store.sessionSidebarOpen,closeMobileSidebar:()=>this.store.closeSessionSidebar(),toggleSidebar:()=>this.store.toggleSidebar()})},onModeFlip(e){e==="yeaft"?this.store.enterYeaft():this.store.leaveYeaft()},sortByActivity(e){return fu(e)},isCatalogSessionUnread(e){return e?.runtimeProvider!=="yeaft"?!1:this.store.isYeaftSessionUnread(e.routeRef?.sessionId,e.routeRef?.agentId)},onUnifiedCreate(e="yeaft"){this.unifiedSessionCreateProvider=["yeaft","copilot","claude-code"].includes(e)?e:"yeaft",this.unifiedSessionCreateOpen=!0},openWorkCenter(e=null){let t=this.workCenterAgents.find(s=>s.id===e)||this.workCenterAgents.find(s=>s.id===this.store.workCenterAgentId)||this.workCenterAgents[0];t&&this.store.enterWorkCenter(t.id)},onUnifiedSessionAction({action:e,row:t,title:s,sessions:n}={}){if(!t?.routeRef)return;let{runtimeProvider:r,agentId:i,sessionId:o}=t.routeRef;e==="rename"?this.store.renameCatalogSession({row:t,title:s}):e==="reorder"?this.store.reorderCatalogSessions(n):e==="pin"?this.store.toggleCatalogSessionPin(t):e==="remove"&&r!=="yeaft"?confirm(this.$t("chat.delete.confirm"))&&this.closeSession(o,i):r==="yeaft"&&e==="remove"?this.store.sessionCrudRequest("archive",{sessionId:o},{agentId:i}):r==="yeaft"&&e==="settings"&&(this.store.pendingUnifiedSessionSettings={sessionId:o,agentId:i,section:"session"},this.store.openCatalogSession(t))},openConversationModal({preserveProvider:e=!1}={}){this.showConversationModal=!0,e||(this.convModalProvider="claude-code"),this.convModalAgent="",this.convModalWorkDir="",this.selectedResumeSession=null,this.historyLoaded=!1,this._foldersRetried=!1;let t=this.store.agents.filter(r=>r.online),n=t.find(r=>r.id===this.store.currentAgent)||t[0];n&&(this.convModalAgent=n.id,this.store.listFoldersForAgent(this.convModalAgent,this.convModalProvider).then(()=>{this.showConversationModal&&this.store.folders.length===0&&!this._foldersRetried&&(this._foldersRetried=!0,setTimeout(()=>{this.showConversationModal&&this.convModalAgent&&this.store.listFoldersForAgent(this.convModalAgent,this.convModalProvider)},1500))}))},openConversationModalResume(){this.openConversationModal()},closeConversationModal(){this.showConversationModal=!1,this.convModalAgent="",this.convModalWorkDir="",this.selectedResumeSession=null,this.historyLoaded=!1},onConvModalAgentChange(){this.convModalAgent&&(this.convModalWorkDir="",this.selectedResumeSession=null,this.historyLoaded=!1,this.store.listFoldersForAgent(this.convModalAgent,this.convModalProvider))},onConvModalProviderChange(){this.convModalWorkDir="",this.selectedResumeSession=null,this.historyLoaded=!1,this.convModalAgent&&this.store.listFoldersForAgent(this.convModalAgent,this.convModalProvider)},onConvModalWorkDirInput(){this.historyLoaded=!1,this.selectedResumeSession=null,this._workDirInputTimer&&clearTimeout(this._workDirInputTimer),this._workDirInputTimer=setTimeout(()=>{this.convModalWorkDir.trim()&&this.convModalAgent&&(this.store.listHistorySessionsForAgent(this.convModalAgent,this.convModalWorkDir.trim(),this.convModalProvider),this.historyLoaded=!0)},500)},selectConvModalFolder(e){this.convModalWorkDir=e,this.selectedResumeSession=null,this.convModalAgent&&(this.store.listHistorySessionsForAgent(this.convModalAgent,e,this.convModalProvider),this.historyLoaded=!0)},loadConvModalFolders(){this.convModalAgent&&this.store.listFoldersForAgent(this.convModalAgent,this.convModalProvider)},loadConvModalSessions(){this.convModalAgent&&this.convModalWorkDir.trim()&&(this.store.listHistorySessionsForAgent(this.convModalAgent,this.convModalWorkDir.trim(),this.convModalProvider),this.historyLoaded=!0)},toggleAgentDropdown(){this.showAgentDropdown=!this.showAgentDropdown,this.showAgentDropdown&&this.store.refreshAgents()},selectAgent(e){this.store.selectAgent(e),this.showAgentDropdown=!1},createNewConversation(){if(!this.convModalAgent)return;this.store.selectAgent(this.convModalAgent);let e=this.convModalWorkDir.trim()||this.selectedConvModalAgentWorkDir;this.store.createConversation(e,this.convModalAgent,null,this.buildConvOpts()),this.closeConversationModal()},buildConvOpts(){let e={provider:this.convModalProvider};return this.convModalProvider==="copilot"&&(e.providerOptions={allowAllTools:!0}),e},resumeSession(e){if(!this.convModalAgent)return;this.store.selectAgent(this.convModalAgent),this.store._pendingSessionTitle=e.title;let t=e.workDir||this.convModalWorkDir.trim()||this.selectedConvModalAgentWorkDir;this.store.resumeConversation(e.sessionId,t,this.convModalAgent,this.buildConvOpts()),this.closeConversationModal()},resumeSelectedSession(){if(!this.convModalAgent||!this.selectedResumeSession)return;this.store.selectAgent(this.convModalAgent),this.store._pendingSessionTitle=this.selectedResumeSession.title;let e=this.selectedResumeSession.workDir||this.convModalWorkDir.trim()||this.selectedConvModalAgentWorkDir;this.store.resumeConversation(this.selectedResumeSession.sessionId,e,this.convModalAgent,this.buildConvOpts()),this.closeConversationModal()},formatDate(e){return _i(e,this.$t.bind(this))},selectConversation(e,t){this.store.leaveWorkCenter(),this.store.selectConversation(e,t),this.store.closeSessionSidebar()},onSessionClick(e){if(e.agentOnline===!1){this.store.addMessage({type:"system",content:this.$t("chat.session.agentOffline")});return}if(this.store.isSplitMode&&this.store.activePanelId){this.store.leaveWorkCenter(),this.store.setPanelConversation(this.store.activePanelId,e.id),this.store.closeSessionSidebar();return}this.selectConversation(e.id,e.agentId)},closeSession(e,t){this.store.closeSession(e,t)},deleteConversation(e,t){confirm(this.$t("chat.delete.confirm"))&&this.store.deleteConversation(e,t)},getConversationTitle(e){let t=this.store.getConversationTitle(e.id);return t?t.length>30?t.slice(0,30)+"...":t:e.claudeSessionId?e.claudeSessionId.slice(0,8)+"...":e.id.slice(0,8)+"..."},getConversationFullTitle(e){let t=this.store.getConversationTitle(e.id);if(t&&t.length>30)return t},startChatRename(e){this.editingChatId=e.id,this.editingChatName=this.store.customConversationTitles[e.id]||this.store.conversationTitles[e.id]||"",this.$nextTick(()=>{let t=this.$refs.chatRenameInput;if(t){let s=Array.isArray(t)?t[0]:t;s.focus(),s.select()}})},commitChatRename(){if(!this.editingChatId)return;let e=this.editingChatId,t=this.editingChatName.trim();this.editingChatId=null,this.editingChatName="",this.store.renameChatSession(e,t)},cancelChatRename(){this.editingChatId=null,this.editingChatName=""},toggleSessionMenu(e){this.activeSessionMenu=this.activeSessionMenu===e?null:e},closeSessionMenu(){this.activeSessionMenu=null},getConversationTime(e){let s=this.store.executionStatusMap[e.id]?.lastActivity||e.createdAt;if(!s)return"";let n=new Date(s),r=new Date,i=r-n;return i<6e4?this.$t("chat.time.justNow"):i<36e5?this.$t("chat.time.minutesAgo",{count:Math.floor(i/6e4)}):n.toDateString()===r.toDateString()?n.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}):n.toLocaleDateString(void 0,{month:"numeric",day:"numeric"})},providerLabel(e){return e==="copilot"?this.$t("provider.copilot"):e==="claude-code"?this.$t("provider.claudeCode"):e||""},shortenPath(e){return Oi(e)},formatTime(e){return e?new Date(e).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit"}):""},getLastPathSegment(e){return Zn(e)},getParentPath(e){if(!e)return"";let t=e.split(/[/\\]/);return t.length<=2?"":t.slice(0,-1).join("/")},handleResize(){this.windowWidth=window.innerWidth},restartAgent(e){let s=this.store.agents.find(n=>n.id===e)?.name||e;confirm(this.$t("chat.agent.restartConfirm",{name:s}))&&(this.restartingAgents[e]=!0,setTimeout(()=>{delete this.restartingAgents[e]},12e4),this.store.restartAgent(e))},upgradeAgent(e){let t=this.store.agents.find(n=>n.id===e),s=t?.name||e;confirm(this.$t("chat.agent.upgradeConfirm",{name:s}))&&(this.upgradingAgents[e]={since:Date.now(),oldVersion:t?.version||null},setTimeout(()=>{delete this.upgradingAgents[e]},12e4),this.store.upgradeAgent(e))},openFolderPicker(e){let t=this.convModalAgent;if(!t)return;this.folderPickerTarget=e,this.folderPickerOpen=!0,this.folderPickerSelected="",this.folderPickerLoading=!0;let s=this.convModalWorkDir,n=this.store.agents.find(o=>o.id===t),r=s||n?.workDir||"";this.folderPickerPath=r,this.folderPickerEntries=[];let i=()=>{this.store.sendWsMessage({type:"list_directory",conversationId:"_workdir_picker",agentId:t,dirPath:r,workDir:n?.workDir||""})};i(),this._folderPickerTimer&&clearTimeout(this._folderPickerTimer),this._folderPickerTimer=setTimeout(()=>{this.folderPickerLoading&&this.folderPickerOpen&&i()},5e3)},loadFolderPickerDir(e){let t=this.convModalAgent;if(!t)return;this.folderPickerLoading=!0,this.folderPickerSelected="",this.folderPickerEntries=[];let s=this.store.agents.find(r=>r.id===t),n=()=>{this.store.sendWsMessage({type:"list_directory",conversationId:"_workdir_picker",agentId:t,dirPath:e,workDir:s?.workDir||""})};n(),this._folderPickerTimer&&clearTimeout(this._folderPickerTimer),this._folderPickerTimer=setTimeout(()=>{this.folderPickerLoading&&this.folderPickerOpen&&n()},5e3)},folderPickerNavigateUp(){if(!this.folderPickerPath)return;let e=this.folderPickerPath.includes("\\"),t=e?"\\":"/",s=this.folderPickerPath.replace(/[/\\]$/,"").split(/[/\\]/);if(s.pop(),s.length===0)this.folderPickerPath="",this.loadFolderPickerDir("");else if(e&&s.length===1&&/^[A-Za-z]:$/.test(s[0]))this.folderPickerPath=s[0]+"\\",this.loadFolderPickerDir(s[0]+"\\");else{let n=s.join(t);this.folderPickerPath=n,this.loadFolderPickerDir(n)}},folderPickerSelectItem(e){this.folderPickerSelected=e.name},folderPickerEnter(e){let s=this.folderPickerPath.includes("\\")||/^[A-Z]:/.test(e.name)?"\\":"/",n;this.folderPickerPath?n=this.folderPickerPath.replace(/[/\\]$/,"")+s+e.name:/^[A-Z]:$/.test(e.name)?n=e.name+"\\":n="/"+e.name,this.folderPickerPath=n,this.loadFolderPickerDir(n)},confirmFolderPicker(){let e=this.folderPickerPath;if(e){if(this.folderPickerSelected){let t=e.includes("\\")?"\\":"/";e=e.replace(/[/\\]$/,"")+t+this.folderPickerSelected}this.convModalWorkDir=e,this.selectedResumeSession=null,this.convModalAgent&&(this.store.listHistorySessionsForAgent(this.convModalAgent,e,this.convModalProvider),this.historyLoaded=!0),this.folderPickerOpen=!1}},handleFolderPickerMessage(e){let t=e.detail;!t||t.type!=="directory_listing"||t.conversationId!=="_workdir_picker"||(this._folderPickerTimer&&(clearTimeout(this._folderPickerTimer),this._folderPickerTimer=null),this.folderPickerLoading=!1,this.folderPickerEntries=(t.entries||[]).filter(s=>s.type==="directory").sort((s,n)=>s.name.localeCompare(n.name)),t.dirPath!=null&&(this.folderPickerPath=t.dirPath))}},mounted(){if(this.store.openUnifiedChatCreate){let e=this.store.openUnifiedChatCreate;this.store.openUnifiedChatCreate=!1,this.convModalProvider=e==="copilot"?"copilot":"claude-code",this.openConversationModal({preserveProvider:!0})}this._clickOutsideHandler=e=>{e.target.closest(".agent-selector")||(this.showAgentDropdown=!1),!e.target.closest(".session-dots-btn")&&!e.target.closest(".session-menu")&&(this.activeSessionMenu=null)},document.addEventListener("click",this._clickOutsideHandler),window.addEventListener("resize",this.handleResize),window.addEventListener("workbench-message",this.handleFolderPickerMessage),fetch("/api/version").then(e=>e.json()).then(e=>{this.serverVersion=e.version}).catch(()=>{}),this._agentRestartAckHandler=e=>{let{agentId:t}=e.detail},window.addEventListener("agent-restart-ack",this._agentRestartAckHandler),this._agentUpgradeAckHandler=e=>{let{agentId:t,success:s,error:n,alreadyLatest:r,version:i,reason:o,currentNode:a,requiredNode:l}=e.detail;s?r&&(delete this.upgradingAgents[t],alert(this.$t("chat.agent.alreadyLatest",{version:i||""}))):(delete this.upgradingAgents[t],alert(o==="node_incompatible"?this.$t("chat.agent.nodeIncompatible",{current:a||"?",required:l||"?",version:i||""}):`Agent upgrade failed: ${n||"Unknown error"}`))},window.addEventListener("agent-upgrade-ack",this._agentUpgradeAckHandler),this._checkRestartingAgents=this.$watch(()=>this.store.agents.map(e=>e.id+":"+e.online),()=>{for(let e of Object.keys(this.restartingAgents)){let t=this.store.agents.find(s=>s.id===e);(t?.online||!t)&&delete this.restartingAgents[e]}for(let e of Object.keys(this.upgradingAgents)){let t=this.store.agents.find(r=>r.id===e),s=this.upgradingAgents[e],n=Date.now()-(s?.since||0);!t||n>12e4?delete this.upgradingAgents[e]:t.online&&(n<3e3?setTimeout(()=>{this.store.agents.find(o=>o.id===e)?.online&&delete this.upgradingAgents[e]},3e3-n):delete this.upgradingAgents[e])}})},beforeUnmount(){document.removeEventListener("click",this._clickOutsideHandler),window.removeEventListener("resize",this.handleResize),window.removeEventListener("workbench-message",this.handleFolderPickerMessage),window.removeEventListener("agent-restart-ack",this._agentRestartAckHandler),window.removeEventListener("agent-upgrade-ack",this._agentUpgradeAckHandler),this._checkRestartingAgents&&this._checkRestartingAgents(),this._folderPickerTimer&&clearTimeout(this._folderPickerTimer)}}});function ug(e={}){let{sessions:t,activeSessionId:s,activeSessionKey:n,pinnedSessionIds:r,onlineAgentIds:i}=e,o=s||null,a=n||null,l=Object.prototype.hasOwnProperty.call(e,"activeSessionKey"),c=Array.isArray(r)?r:[],d=Array.isArray(i)?new Set(i.filter(Boolean)):null,u=new Map;c.forEach((p,g)=>{typeof p=="string"&&p&&!u.has(p)&&u.set(p,g)});let f=[];for(let p of Array.isArray(t)?t:[]){if(!p||!p.id||d&&p.agentId&&!d.has(p.agentId))continue;let g=String(p.id),h=p.agentId?`${p.agentId}${g}`:g;f.push({kind:"session",id:g,raw:p,pinned:!!p.pinned||!p.agentId&&u.has(g),active:l?h===a:g===o,processing:!!p.running||!!p.active||!!p.isRunning||!!p.isActive,_manualOrder:Number.isFinite(p.sortOrder)?p.sortOrder:Number.MAX_SAFE_INTEGER,_activityTime:jr(p)})}return f.sort((p,g)=>{if(p.pinned!==g.pinned)return p.pinned?-1:1;if(p._manualOrder!==g._manualOrder)return p._manualOrder-g._manualOrder;if(p._activityTime!==g._activityTime)return g._activityTime-p._activityTime;let h=u.has(p.id)?u.get(p.id):Number.MAX_SAFE_INTEGER,v=u.has(g.id)?u.get(g.id):Number.MAX_SAFE_INTEGER;return h!==v?h-v:p.id.localeCompare(g.id)}),f.map(({_manualOrder:p,_activityTime:g,...h})=>h)}var pg=F(()=>{Ur()});var Ay,cC,fg,gg=F(()=>{Ei();Qa();Xa();Za();Ja();el();ul();pg();Ay=3600*1e3,cC=24*Ay,fg={name:"YeaftSidebar",components:{SessionCreateModal:Js,SidebarModeToggle:xi,SidebarAgentHeader:Ti,SidebarWorkCenter:Mi,SessionSidebarShell:Pi,UnifiedSessionList:Ri},emits:["select-group","select-chat","toggle-sidebar","back","open-settings","open-group-settings"],template:`
|
|
6710
6709
|
<SessionSidebarShell class="yeaft-sidebar" :collapsed="collapsed">
|
|
6711
6710
|
<template #collapsed>
|
|
6712
6711
|
<!-- Collapsed Icon Bar \u2014 mirrors Chat's .sidebar-collapsed-bar so the
|
|
@@ -7120,7 +7119,7 @@ ${String(e||"").trim()}
|
|
|
7120
7119
|
</div>
|
|
7121
7120
|
</Teleport>
|
|
7122
7121
|
`}});function Ty(e){let t=String(e||"").trim();return t?t.startsWith("[")&&t.endsWith("]")?bg(t.slice(1,-1)).map(s=>s.trim().replace(/^["']|["']$/g,"")).map(s=>wg(s)).filter(Boolean):bg(t).map(s=>wg(s.trim())).filter(Boolean):[]}function bg(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 wg(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 My(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]=Ty(o):t[i]=o.replace(/^["']|["']$/g,"")}return t}function Py(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=My(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:en(o,180)})}return s.length?s:[{id:"memory-1",scope:"",kind:"raw",tags:[],sourceMessages:[],createdAt:"",updatedAt:"",content:t,preview:en(t,180)}]}function en(e,t=160){let s=String(e||"").replace(/\s+/g," ").trim();return s.length<=t?s:`${s.slice(0,t).trim()}...`}function Ry(e){let t=String(e||"").trim();return t?(t.split(/\r?\n/).map(n=>n.trim()).find(Boolean)||"").replace(/^#+\s*/,"").replace(/^[-*]\s*/,"").trim():""}function _y(e){return String(e||"").replace(/\s+/g," ").trim()}function kg(e,t){return t?.sessionId||String(e||"").replace(/^sessions\//,"")}function Ey(e,t,s){let n=kg(e,t);return _y(s?.[e]||s?.[n]||t?.sessionTitle||t?.title||t?.name||Ry(t?.summaryText))||n||e}function Sg(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(`
|
|
7123
|
-
`).includes(s)):Array.isArray(e)?e:[]}function Ig({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,f=(Array.isArray(n)?n:[]).filter(y=>y?.scope===o),p=f[f.length-1]||null,g=l?.finishedAt||l?.startedAt||a?.lastDreamAt||p?.at||a?.loadedAt||"",
|
|
7122
|
+
`).includes(s)):Array.isArray(e)?e:[]}function Ig({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,f=(Array.isArray(n)?n:[]).filter(y=>y?.scope===o),p=f[f.length-1]||null,g=l?.finishedAt||l?.startedAt||a?.lastDreamAt||p?.at||a?.loadedAt||"",h=Py(a?.memoryText||""),v=kg(o,a),C=Ey(o,a,r),w=c?en(c.message||c.error||c.raw||"",180):"",k=en(w||a?.summaryText||a?.memoryText||p?.detail||"",180);return{key:o,title:C,scope:o,sessionId:v,status:d,lastAt:g,latestRun:l,snapshot:a,lastError:c,promptLoad:u,events:f,segmentCount:h.length,segments:h,summaryPreview:k,subtitle:k,hasRequestResponse:f.some(y=>y?.request||y?.response||y?.systemPrompt||y?.rawRequest||y?.rawResponse)}}).sort((o,a)=>String(a.lastAt||"").localeCompare(String(o.lastAt||"")))}var Cg=F(()=>{});var Hi,Dy,Ag,xg=F(()=>{Cg();Oo();Hi=1,Dy=5,Ag={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:{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}},"store.currentAgent"(e,t){e&&e!==t&&this.store&&typeof this.store.loadYeaftDebugHistory=="function"&&this.store.loadYeaftDebugHistory({limit:Hi,dreamLimit:5,indexOnly:!0})}},computed:{store(){return window.Pinia?.useChatStore?.()||null},sessionsStore(){return window.Pinia?.useSessionsStore?.()||null},turns(){return(this.store&&this.store.yeaftDebugTurnsForActiveSession||[]).map(t=>this.decorateTurnTokenBreakdowns(t))},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(){return this.store?.yeaftDebugHistoryError||""},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}
|
|
7124
7123
|
... truncated`:t},dreamSnapshotSummary(){let e=this.dreamSnapshot,t=e&&typeof e.summaryText=="string"?e.summaryText.trim():"";return t&&e.summaryTruncated?`${t}
|
|
7125
7124
|
... truncated`:t},dreamSnapshotMemory(){let e=this.dreamSnapshot,t=e&&typeof e.memoryText=="string"?e.memoryText.trim():"";return t&&e.memoryTruncated?`${t}
|
|
7126
7125
|
... 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 Ig({latest:e.yeaftDreamLatest||{},snapshots:e.yeaftDreamSnapshots||{},promptLoads:e.yeaftDreamPromptLoads||{},events:s,sessionTitles:this.dreamSessionTitles})},dreamItems(){return Sg(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))):[]}},mounted(){this.store&&typeof this.store.loadYeaftDebugHistory=="function"&&this.store.loadYeaftDebugHistory({limit:Hi,dreamLimit:5,indexOnly:!0})},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:Hi,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(`
|
|
@@ -7825,9 +7824,9 @@ ${String(e||"").trim()}
|
|
|
7825
7824
|
</div>
|
|
7826
7825
|
</section>
|
|
7827
7826
|
</aside>
|
|
7828
|
-
`,setup(e,{emit:t}){let s=window.Pinia&&window.Pinia.useVpStore?window.Pinia.useVpStore():null,n=
|
|
7829
|
-
`)},m=
|
|
7830
|
-
`):""},vpTextColorFor:n,expandedTasks:c,toggleTaskExpanded:p,taskOwnerName:
|
|
7827
|
+
`,setup(e,{emit:t}){let s=window.Pinia&&window.Pinia.useVpStore?window.Pinia.useVpStore():null,n=A=>s&&typeof s.vpTextColor=="function"?s.vpTextColor(A):"var(--text-primary)",r=Vue.getCurrentInstance(),i=r&&r.appContext.config.globalProperties.$t||(A=>A),o=Vue.computed(()=>(typeof e.announcementText=="string"?e.announcementText:"").trim()),a=Vue.computed(()=>!!o.value),l=Vue.computed(()=>{let A=o.value.replace(/\s+/g," ");return A.length<=96?A:A.slice(0,95)+"\u2026"}),c=Vue.ref({}),d=new Map,u=new Map,f=A=>{let R=d.get(A);R&&(R.scrollTop=R.scrollHeight,u.set(A,!0))},p=A=>{let R=!c.value[A];c.value={...c.value,[A]:R},R&&(u.set(A,!0),Vue.nextTick(()=>f(A)))},g=(A,R)=>{R?(d.set(A,R),u.has(A)||u.set(A,!0),Vue.nextTick(()=>{u.get(A)&&f(A)})):d.delete(A)},h=A=>{let R=d.get(A);if(!R)return;let j=R.scrollHeight-R.scrollTop-R.clientHeight;u.set(A,j<8)};Vue.watch(()=>JSON.stringify((Array.isArray(e.tasks)?e.tasks:[]).map(A=>[A.id,A?.log?.preview||""])),()=>Vue.nextTick(()=>{d.forEach((A,R)=>{u.get(R)&&f(R)})}));let v=A=>{let R=A?.ownerVpId||"";return R?s&&typeof s.vpLabel=="function"?s.vpLabel(R):R:"unknown"},C=A=>{if(!A)return"";try{return new Date(A).toLocaleTimeString()}catch{return String(A)}},w=A=>{switch(A?.kind){case"sub_agent":return i("yeaft.sessionStatus.task.kind.subAgent");case"shell":return i("yeaft.sessionStatus.task.kind.shell");default:return A?.kind||""}},k=A=>{let R=A?.runtime?.command;return typeof R=="string"?R.trim():""},y=A=>{let R=[],j=A?.title||A?.id||"",O=k(A);return j&&R.push(`${i("yeaft.sessionStatus.task.title")}: ${j}`),O&&R.push(`${i("yeaft.sessionStatus.task.command")}: ${O}`),R.join(`
|
|
7828
|
+
`)},m=A=>`${A?.agentId||""}${A?.sessionId||""}::${A?.id||""}`,b=A=>A?.kind==="shell"&&A?.status==="running"&&!!A?.runtime?.pid,T=A=>!!(A?.id&&e.stoppingTasksById?.[m(A)]),L=A=>Fy(A,i),N=A=>Pg(A,i),$=A=>{switch(A.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 A.status}},D=new Set(["typing","thinking","retrying","streaming","tool"]);return{hasAnnouncement:a,announcementPreview:l,statusLabel:$,isActiveStatus:A=>D.has(A),threadCountTitle:A=>{let R=Array.isArray(A&&A.threads)?A.threads:[];return R.length?R.slice(0,5).map(j=>`${j.title||j.threadId||"thread"}: ${j.status||"idle"}`).join(`
|
|
7829
|
+
`):""},vpTextColorFor:n,expandedTasks:c,toggleTaskExpanded:p,taskOwnerName:v,formatTaskTime:C,taskKindLabel:w,shellTaskCommand:k,taskSummaryTitle:y,isTaskCancellable:b,isTaskStopping:T,taskDetailLines:L,subAgentTaskStreamText:N,setTaskLogRef:g,onTaskLogScroll:h}}}});var Eg,Dg=F(()=>{Eg={name:"YeaftSessionActions",emits:["toggle-search","reload-messages","toggle-session-status","toggle-debug","reload-page"],props:{searchOpen:{type:Boolean,default:!1},loadingMoreHistory:{type:Boolean,default:!1},sessionStatusVisible:{type:Boolean,default:!0},debugMode:{type:Boolean,default:!1},showPageReload:{type:Boolean,default:!1}},template:`
|
|
7831
7830
|
<div class="yeaft-session-actions">
|
|
7832
7831
|
<button
|
|
7833
7832
|
ref="searchButtonRef"
|
|
@@ -7967,7 +7966,7 @@ ${String(e||"").trim()}
|
|
|
7967
7966
|
>{{ $t('yeaft.outline.moreMatches') }}</button>
|
|
7968
7967
|
</div>
|
|
7969
7968
|
</section>
|
|
7970
|
-
`,setup(e,{emit:t,expose:s}){let n=Vue.ref(null),r=Vue.ref(null),i=Vue.computed(()=>String(e.searchState.query||"").trim().length>=2||!!e.searchState.senderKey);Vue.watch(()=>e.senderOptions.map(w=>w.key),w=>{let k=e.searchState.senderKey||"";k&&!w.includes(k)&&t("sender-invalid")},{flush:"sync"});let o=Vue.computed(()=>Hy(i.value?e.searchState.results:e.outlineState.results)),a=Vue.computed(()=>{let w=o.value.findIndex(k=>k?.messageId===e.activeMessageId);return w>=0?w:0}),l=Vue.computed(()=>i.value?e.searchState.loading:e.outlineState.loading),c=Vue.computed(()=>{if(i.value)return`${e.searchState.results.length}${e.searchState.hasMore?"+":""}`;let w=e.outlineState.totalCount;return Number.isFinite(w)?String(w):String(e.outlineState.results.length||"")}),d=Vue.computed(()=>{let w=i.value?e.searchState.error:e.outlineState.error;return w?w==="unsupported"?"yeaft.outline.unsupported":"yeaft.outline.error":""}),u=()=>Vue.nextTick(()=>{n.value?.focus?.(),r.value&&(r.value.scrollTop=0)}),f=()=>{let w=r.value;t("load-older",{scrollHeight:w?.scrollHeight||0,scrollTop:w?.scrollTop||0})},p=()=>{if(i.value||e.outlineState.loading||!e.outlineState.hasMore)return;let w=r.value;w&&w.scrollHeight-w.scrollTop-w.clientHeight<=40&&f()},g=w=>{t("move",w?.messageId||null),t("preview",w)},
|
|
7969
|
+
`,setup(e,{emit:t,expose:s}){let n=Vue.ref(null),r=Vue.ref(null),i=Vue.computed(()=>String(e.searchState.query||"").trim().length>=2||!!e.searchState.senderKey);Vue.watch(()=>e.senderOptions.map(w=>w.key),w=>{let k=e.searchState.senderKey||"";k&&!w.includes(k)&&t("sender-invalid")},{flush:"sync"});let o=Vue.computed(()=>Hy(i.value?e.searchState.results:e.outlineState.results)),a=Vue.computed(()=>{let w=o.value.findIndex(k=>k?.messageId===e.activeMessageId);return w>=0?w:0}),l=Vue.computed(()=>i.value?e.searchState.loading:e.outlineState.loading),c=Vue.computed(()=>{if(i.value)return`${e.searchState.results.length}${e.searchState.hasMore?"+":""}`;let w=e.outlineState.totalCount;return Number.isFinite(w)?String(w):String(e.outlineState.results.length||"")}),d=Vue.computed(()=>{let w=i.value?e.searchState.error:e.outlineState.error;return w?w==="unsupported"?"yeaft.outline.unsupported":"yeaft.outline.error":""}),u=()=>Vue.nextTick(()=>{n.value?.focus?.(),r.value&&(r.value.scrollTop=0)}),f=()=>{let w=r.value;t("load-older",{scrollHeight:w?.scrollHeight||0,scrollTop:w?.scrollTop||0})},p=()=>{if(i.value||e.outlineState.loading||!e.outlineState.hasMore)return;let w=r.value;w&&w.scrollHeight-w.scrollTop-w.clientHeight<=40&&f()},g=w=>{t("move",w?.messageId||null),t("preview",w)},h=w=>{let k=Math.max(0,Math.min(o.value.length-1,w)),y=o.value[k];t("move",y?.messageId||null),y&&t("preview",y)},v=w=>{w.key==="Escape"?(w.preventDefault(),t("close")):w.key==="ArrowDown"&&o.value.length?(w.preventDefault(),h(a.value+1)):w.key==="ArrowUp"&&o.value.length?(w.preventDefault(),h(a.value-1)):w.key==="Enter"&&o.value.length&&(w.preventDefault(),t("select",o.value[a.value]||o.value[0]))};return Vue.watch([o,()=>e.activeMessageId],([w,k])=>{w.some(y=>y?.messageId===k)||t("move",w[0]?.messageId||null)},{immediate:!0}),s({focus:u,restoreOlderScroll:({scrollTop:w=0}={})=>Vue.nextTick(()=>{r.value&&(r.value.scrollTop=w)})}),Vue.onMounted(u),{inputRef:n,listRef:r,isSearching:i,visibleResults:o,activeIndex:a,isLoading:l,countLabel:c,errorKey:d,focus:u,loadOlder:f,onScroll:p,onKeyDown:v,previewResult:g,formatOutlineTime:Oy}}}});function Og(e,t){if(!Array.isArray(e)||e.length===0)return[];let s=new Map;if(Array.isArray(t))for(let i of t)i&&i.vpId&&s.set(i.vpId,i);let n=new Set,r=[];for(let i of e)!i||n.has(i)||(n.add(i),r.push(s.get(i)||{vpId:i}));return r}function fl(e,t,s=null){return!t||!e?null:typeof e.sessionById=="function"?e.sessionById(t,s||null)||null:e.sessions?.[t]||null}function qy(e,t){if(!t)return"idle";if(t.connectionState&&t.connectionState!=="connected")return"offline";let s=t.vpStatuses&&t.vpStatuses[e];return s&&s.state?s.state:"idle"}function Hg(e){let{vpList:t,vpStatuses:s,stoppingVpTurnIds:n,connectionState:r,vpLabelOf:i,vpDescriptionOf:o}=e||{},a={vpStatuses:s||{},stoppingVpTurnIds:n||{},connectionState:r||null},l=(f,p)=>{if(typeof i=="function"){let g=i(f);if(g)return g}return p&&(p.displayName||p.displayNameZh)||f},c=(f,p)=>{if(typeof o=="function"){let g=o(f);if(g)return g}return p&&(p.description||p.role||p.descriptionZh||p.roleZh)||""},d=new Set,u=[];if(Array.isArray(t))for(let f of t)!f||!f.vpId||(d.add(f.vpId),u.push(Fg(f.vpId,l(f.vpId,f),c(f.vpId,f),a)));if(s)for(let f of Object.keys(s))!f||d.has(f)||(d.add(f),u.push(Fg(f,l(f,null),c(f,null),a)));return u}function Fg(e,t,s,n){let r=n&&n.vpStatuses&&n.vpStatuses[e];return{vpId:e,displayName:t||e,description:s||"",status:qy(e,n),turnId:r?.turnId||null,isStopping:!!(r?.turnId&&n?.stoppingVpTurnIds?.[r.turnId]),runningThreadCount:r&&Number.isFinite(r.runningThreadCount)?r.runningThreadCount:0,threads:r&&Array.isArray(r.threads)?r.threads:[]}}var qg=F(()=>{});function qi(e){return!e||typeof e!="object"?"":typeof e.ref=="string"&&e.ref?e.ref:typeof e.provider=="string"&&e.provider&&typeof e.id=="string"&&e.id?`${e.provider}/${e.id}`:typeof e.id=="string"?e.id:""}function Jn(e,t){return!e||!t?!1:e.id===t||qi(e)===t}function Bg(e,t=""){let s=e?.config?.model;return typeof s=="string"&&s.trim()?s.trim():typeof t=="string"&&t.trim()?t.trim():""}function Wg(e){if(!Array.isArray(e))return[];let t=[];for(let s of e){if(typeof s!="string")continue;let n=s.trim();!n||t.includes(n)||t.push(n)}return t}function gl(e){return Wg(e).filter(t=>(Ng[t]??-1)>=Ng.medium)}function ml(e){let t=Wg(e);return t.length?t.length===1?t[0]:t[t.length-2]:""}function jg(e,t=""){let s=e?.config?.modelEffort;return typeof s=="string"&&s.trim()?s.trim():typeof t=="string"&&t.trim()?t.trim():""}function Ug(e){let t=[];for(let s of Array.isArray(e)?e:[]){let n=qi(s);if(!n)continue;let r=s.label||s.id||n,i=gl(s?.effortOptions);t.push({model:s,modelRef:n,label:r,efforts:i,defaultEffort:ml(i)||null})}return t}var Ng,zg=F(()=>{Ng=Object.freeze({minimal:0,low:1,medium:2,high:3,xhigh:4,max:5})});function Kg({agentInventoryReady:e=!1,hasYeaftAgent:t=!1,sessionsReady:s=!1,sessionsEmpty:n=!1}={}){return!e||s&&!n?!1:t?s?n:!1:!0}var Yg=F(()=>{});function Gg({activeSessionFilter:e=null,sessionsStore:t=null,topbarGroup:s=null}={}){return e||t?.activeSessionId||s?.id||null}function Qg(e={}){return e.currentAgentInfo?.online?!0:Array.isArray(e.agents)&&e.agents.some(t=>t&&t.online)}var Xg=F(()=>{});function Zg(e={}){return!e?.warning}var Jg=F(()=>{});function nm(e,t){return e&&t?`${e}:${t}`:""}function rm(e){if(e!==void 0)return e;try{return globalThis.localStorage}catch{return null}}function im(e){try{let t=JSON.parse(e?.getItem(hl)||"{}");return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}catch{return{}}}function Ny({agentId:e,sessionId:t,validKeys:s=[],storage:n}={}){let r=s.length===0||s.includes(Ni)?Ni:"",i=nm(e,t);if(!i)return r;let o=rm(n),a=im(o);if(!Object.prototype.hasOwnProperty.call(a,i))return r;let l=typeof a[i]=="string"?a[i]:"";if(l===sm)return"";if(l&&s.includes(l))return l;delete a[i];try{o?.setItem(hl,JSON.stringify(a))}catch{}return r}function em({agentId:e,sessionId:t,senderKey:s,storage:n}={}){let r=nm(e,t);if(!r)return!1;let i=rm(n);if(!i)return!1;let o=im(i);o[r]=s||sm;try{return i.setItem(hl,JSON.stringify(o)),!0}catch{return!1}}function tm(e){let t=e?.updatedAt||e?.endedAt||e?.createdAt,s=t?Date.parse(t):NaN;return Number.isFinite(s)?s:0}function By(e){return Object.values(e||{}).filter(Boolean).sort((t,s)=>t.status==="running"&&s.status!=="running"?-1:t.status!=="running"&&s.status==="running"?1:tm(s)-tm(t))}var hl,sm,Ni,om,am=F(()=>{vi();$a();za();gg();hg();Ei();yg();Ua();xg();_g();Dg();Vg();cl();dl();Va();qg();zg();bs();Yg();Xg();Jg();La();hl="yeaft-history-sender-preferences",sm="__all__",Ni="user";om={name:"YeaftPage",components:{ChatInput:Gs,MessageList:di,SettingsPanel:Ii,YeaftSidebar:fg,SessionInviteModal:mg,SessionCreateModal:Js,SessionSettingsModal:vg,WorkbenchPanel:Si,WorkCenterPage:Fi,YeaftDebugPanel:Ag,VpTimelinePane:Rg,YeaftSessionActions:Eg,YeaftConversationOutline:$g,LlmTab:Vi},template:`
|
|
7971
7970
|
<div class="yeaft-page" ref="pageRef">
|
|
7972
7971
|
<!-- Mobile sidebar overlay -->
|
|
7973
7972
|
<div class="yeaft-sidebar-overlay" v-if="store.sessionSidebarOpen && isMobile" @click="store.closeSessionSidebar()"></div>
|
|
@@ -8368,7 +8367,7 @@ ${String(e||"").trim()}
|
|
|
8368
8367
|
@open-vp-library="openVpLibraryFromGroupSettings"
|
|
8369
8368
|
/>
|
|
8370
8369
|
</div>
|
|
8371
|
-
`,setup(){let e=Pinia.useChatStore(),t=Pinia.useAuthStore(),s=Pinia.useVpStore(),n=Vue.getCurrentInstance(),r=n&&n.appContext.config.globalProperties.$t||(I=>I),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(""),f=Vue.ref(!1),p=Vue.ref(""),g=null,v=Vue.ref("vp"),h=Vue.ref(null),A=Vue.ref(null),w=Vue.ref(null),k=Vue.ref(null),y=Vue.ref(null),m=Vue.ref(null),b=Vue.ref(!1),T=Vue.ref(null),L=Vue.computed(()=>e.getYeaftHistoryOutlineState()),N=Vue.computed(()=>{let I=P(),G=e.yeaftActiveSessionFilter||I?.activeSessionId||null,le=G?fl(I,G,e.currentAgent||null):null,Te=Array.isArray(le?.roster)?le.roster:[];return[{key:"user",label:r("yeaft.outline.you")},...Te.map(Me=>({key:`vp:${Me}`,label:s.vpLabel(Me)}))]}),$=Vue.ref(e.yeaftHistorySearchState?.query||""),D=null,P=()=>{try{return window.Pinia?.useSessionsStore?.()||null}catch{return null}},M=()=>{let I=P();return{agentId:e.currentAgent||null,sessionId:e.yeaftActiveSessionFilter||I?.activeSessionId||null}},C=()=>Ny({...M(),validKeys:N.value.map(I=>I.key)}),R=(I="")=>{let{agentId:G,sessionId:le}=M();e.yeaftHistorySearchState={requestId:null,agentId:G,sessionId:le,query:"",senderKey:I,loading:!1,results:[],hasMore:!1,nextBeforeSeq:null,error:null}},j=Vue.computed(()=>{let I=e.currentAgent||"agent",G=P(),le=e.yeaftActiveSessionFilter||G?.activeSessionId||"session";return`yeaft:${I}:${le}`});Vue.watch(j,()=>{w.value=null});let O=null,Y=null,te=I=>{if(!I)return!1;let G=String(I.tagName||"").toLowerCase();return G==="textarea"||G==="input"||I.isContentEditable===!0},he=({recoverScroll:I=!1}={})=>{let G=k.value;if(!G)return;if(!We.value){G.style.removeProperty("--yeaft-visual-viewport-height");return}let le=window.visualViewport,Te=Math.max(1,Math.round(le?.height||window.innerHeight||1));G.style.setProperty("--yeaft-visual-viewport-height",`${Te}px`),!(!I||le&&window.innerHeight&&le.height<window.innerHeight*.85||te(document.activeElement))&&window.scrollTo(0,0)},ce=(I={})=>{O!=null&&cancelAnimationFrame(O),O=requestAnimationFrame(()=>{O=null,he(I)})},ke=()=>{ce({recoverScroll:!0}),Y&&clearTimeout(Y),Y=setTimeout(()=>{Y=null,ce({recoverScroll:!0})},260)},ve=Vue.computed(()=>e.hasCapability("terminal")||e.hasCapability("file_editor")),ge=Vue.computed(()=>!0),x=I=>{let G=I&&I.id?I.id:null;G&&(e.setActiveSessionFilter(G,{agentId:I.agentId||null}),We.value&&e.closeSessionSidebar())},K=I=>{},re=Vue.ref(null),ye=Vue.ref(!1),W=320,ne=Math.max(W,Math.round(window.innerWidth*.25)),U=localStorage.getItem("yeaft-debug-width"),B=Vue.ref(U?parseInt(U,10):ne),H=Vue.computed(()=>({"--yeaft-detail-width":B.value+"px"})),_=I=>{ye.value=!0;let G=I.clientX,le=B.value,Te=window.innerWidth*.6,Me=Bt=>{let Wt=G-Bt.clientX,Ms=Math.min(Te,Math.max(W,le+Wt));B.value=Ms},ze=()=>{ye.value=!1,document.removeEventListener("mousemove",Me),document.removeEventListener("mouseup",ze),localStorage.setItem("yeaft-debug-width",String(B.value))};document.addEventListener("mousemove",Me),document.addEventListener("mouseup",ze)},J="yeaft-session-status-visible",se=()=>{try{let I=localStorage.getItem(J);return!(I==="0"||I==="false")}catch{return!0}},me=Vue.ref(se()),z=I=>{me.value=!!I;try{localStorage.setItem(J,me.value?"1":"0")}catch{}},ee=()=>z(!me.value),pe=()=>z(!1),oe=220,De=280,$e=(()=>{try{return localStorage.getItem("yeaft-vp-timeline-width")}catch{return null}})(),Fe=$e?parseInt($e,10):NaN,Ue=Vue.ref(Number.isFinite(Fe)&&Fe>=oe?Fe:De),Zt=Vue.computed(()=>({"--yeaft-vp-timeline-width":Ue.value+"px"})),St=I=>{let G=I.clientX,le=Ue.value,Te=Math.max(oe,Math.floor(window.innerWidth*.4)),Me=Bt=>{let Wt=G-Bt.clientX,Ms=Math.min(Te,Math.max(oe,le+Wt));Ue.value=Ms},ze=()=>{document.removeEventListener("mousemove",Me),document.removeEventListener("mouseup",ze);try{localStorage.setItem("yeaft-vp-timeline-width",String(Ue.value))}catch{}};document.addEventListener("mousemove",Me),document.addEventListener("mouseup",ze)},Lt="(max-width: 768px)",It="(max-width: 1024px)",$t=typeof window.matchMedia=="function"?window.matchMedia(Lt):null,ft=typeof window.matchMedia=="function"?window.matchMedia(It):null,Ne=(I,G)=>I?I.matches:window.innerWidth<=G,We=Vue.ref(Ne($t,768)),Vt=Vue.ref(Ne(ft,1024)),Ge=Vue.computed(()=>We.value?!e.sessionSidebarOpen:e.sidebarCollapsed),E=()=>{We.value=Ne($t,768),Vt.value=Ne(ft,1024)},X=()=>{E(),ke()},fe=I=>{I&&(typeof I.addEventListener=="function"?I.addEventListener("change",X):typeof I.addListener=="function"&&I.addListener(X))},de=I=>{I&&(typeof I.removeEventListener=="function"?I.removeEventListener("change",X):typeof I.removeListener=="function"&&I.removeListener(X))},be=()=>{D&&(clearTimeout(D),D=null),$.value="",R(C()),b.value=!1,T.value=null},Ie=()=>{let I=C();$.value="",R(I),b.value=!0,e.loadYeaftHistoryOutline(),I&&e.searchYeaftHistory("",{senderKey:I}),Vue.nextTick(()=>m.value?.focus?.())},Le=()=>{b.value?be():Ie()},He=I=>{b.value&&Tp(I.target)&&be()},Be=I=>{$.value=I,D&&clearTimeout(D),T.value=null,D=setTimeout(()=>{D=null,e.searchYeaftHistory($.value,{senderKey:e.yeaftHistorySearchState.senderKey})},220)},Ke=I=>{D&&clearTimeout(D),D=null,T.value=null,em({...M(),senderKey:I}),e.searchYeaftHistory($.value,{senderKey:I})},Ft=()=>{em({...M(),senderKey:Ni}),T.value=null,e.searchYeaftHistory($.value,{senderKey:Ni})},tn=I=>{if(!e.loadYeaftHistoryOutline({append:!0}))return;let G=Vue.watch(()=>L.value.loading,le=>{le||(G(),m.value?.restoreOlderScroll?.(I))})},Wi=()=>e.searchYeaftHistory(e.yeaftHistorySearchState.query,{append:!0,senderKey:e.yeaftHistorySearchState.senderKey}),ji=I=>{e.hasCapability("session_history_window_prefetch")&&e.loadYeaftHistoryWindow(I)},er=I=>Mp({result:I,revealWindow:G=>e.revealYeaftHistoryResult(G),nextTick:()=>Vue.nextTick(),revealMessage:G=>y.value?.revealMessage?.(G),isMobile:We.value,closeOutline:be}),tr=I=>{if((I.metaKey||I.ctrlKey)&&String(I.key).toLowerCase()==="f"){I.preventDefault(),Ie();return}if(I.key==="Escape"){if(b.value){be();return}if(o.value){Jt();return}}};Vue.onMounted(()=>{E(),window.addEventListener("resize",X),fe($t),fe(ft),window.visualViewport?.addEventListener("resize",ke),window.visualViewport?.addEventListener("scroll",ke),document.addEventListener("click",ar),document.addEventListener("click",He),document.addEventListener("keydown",tr),ce()}),Vue.onUnmounted(()=>{window.removeEventListener("resize",X),de($t),de(ft),window.visualViewport?.removeEventListener("resize",ke),window.visualViewport?.removeEventListener("scroll",ke),document.removeEventListener("click",ar),document.removeEventListener("click",He),document.removeEventListener("keydown",tr),O!=null&&cancelAnimationFrame(O),Y&&clearTimeout(Y),D&&clearTimeout(D)}),Vue.watch(()=>e.yeaftConversationId,I=>{I&&e.activeConversations[0]!==I&&(e.activeConversations=[I])}),Vue.watch(()=>[e.currentAgent,e.yeaftActiveSessionFilter],()=>{be(),R(C())});let Ui=()=>{e.leaveYeaft()},zi=(I,G,le)=>{let Te=P();if(Te&&Te.activeNeedsInvite){let Wt=Te.activeSession;Wt&&Ht.delete(Wt.id);return}let Me=e.yeaftActiveSessionFilter||Te&&Te.activeSessionId||"grp_default",ze=gi(I).mentions,Bt=Array.isArray(G)?G:void 0;e.sendYeaftSessionMessage({groupId:Me,text:I,mentions:ze,attachments:Bt,quote:le})},Ki=I=>{I&&(w.value=I,A.value?.focusInput?.())},Yi=I=>{w.value=null,A.value?.replaceDraft?.(I||"")},Gi=()=>{let I=P(),G=e.yeaftActiveSessionFilter||I?.activeSessionId||null;G&&e.cancelYeaftSession(G)},sn=(I="")=>{let G=Qe.value;G&&e.enterWorkCenterFromSession(G,I)},sr=()=>{if(We.value){e.toggleSessionSidebar();return}e.toggleSidebar()},nn=()=>{i.value=!i.value},et=()=>{i.value=!1},nr=()=>{e.reloadYeaftMessages()},Qi=()=>{if(typeof e.requestYeaftSessionInventory=="function"){e.requestYeaftSessionInventory();return}e._hasHandledAgentList=!1,e._hasHandledYeaftSessionHydrate=!1,e.yeaftSessionHydrateError=null,e.sendWsMessage({type:"get_agents"})},Xi=()=>{window.location.reload()},Zi=Vue.computed(()=>{let I=P(),G=e.yeaftActiveSessionFilter||I?.activeSessionId||null;return G?e.isYeaftSessionProcessing(G,e.currentAgent||null):!1}),Qe=Vue.computed(()=>{let I=P();if(!I||!I.sessions)return null;let G=e.yeaftActiveSessionFilter||null;if(G&&typeof I.sessionById=="function"){let le=I.sessionById(G,e.currentAgent||null);if(le)return le}if(I.activeSessionId&&typeof I.sessionById=="function"){let le=I.sessionById(I.activeSessionId,e.currentAgent||null);if(le)return le}return typeof I.sessionById=="function"?I.sessionById("grp_default",e.currentAgent||null):null}),rr=()=>Gg({activeSessionFilter:e.yeaftActiveSessionFilter,sessionsStore:P(),topbarGroup:Qe.value}),rn=Vue.computed(()=>{let I=Qe.value||{},G=typeof I.id=="string"?I.id.trim():"",le=[I.title,I.name,I.config?.title,I.config?.name];for(let Te of le){let Me=typeof Te=="string"?Te.trim():"";if(Me&&!(G&&Me===G)&&!/^(sessions?|groups?)\//i.test(Me)&&!/^session_[A-Za-z0-9_-]+$/.test(Me)&&!(I.workDir&&Me===I.workDir))return Me}return""}),Ji=Vue.computed(()=>{let I=Qe.value?.workDir;return typeof I=="string"?I.trim():""}),ir=Vue.computed(()=>Qe.value&&typeof Qe.value.announcement=="string"?Qe.value.announcement:""),Is=Vue.computed(()=>Bg(Qe.value,e.yeaftModel||"")),on=Vue.computed(()=>{let I=Is.value;return I&&e.yeaftAvailableModels.find(G=>Jn(G,I))||null}),eo=I=>gl(I?.effortOptions),Cs=Vue.computed(()=>jg(Qe.value,e.yeaftModelEffort||"")),Ot=Vue.computed(()=>{let I=Array.isArray(on.value?.effortOptions)?on.value.effortOptions.filter(Boolean):[];return I.length?I.includes(Cs.value)?Cs.value:ml(I):null}),to=Vue.computed(()=>Ug(e.yeaftAvailableModels)),so=(I,G)=>Jn(I,Is.value)?G?G===Ot.value:!eo(I).length:!1,no=I=>!I||!Jn(I.model,Is.value)?!1:I.efforts.length?I.efforts.includes(Ot.value):!0,or=()=>{o.value=!0},Jt=()=>{o.value=!1},Ct=I=>{I.stopPropagation(),e.yeaftAvailableModels.length&&(o.value?Jt():or())},an=(I,G=null)=>{if(!I)return;let le=Qe.value?.id||null;e.switchYeaftModel(I,le,G),Jt()},Xe=I=>!I||!Number.isFinite(I)||I<=0?"":I>=1e6?`${Math.round(I/1e5)/10}m`:I>=1e3?`${Math.round(I/1e3)}k`:String(I),es=I=>{let G=Xe(I?.contextWindow),le=Xe(I?.maxOutput);return G&&le?`${G} \xB7 ${le} out`:G},ar=I=>{if(!o.value)return;I.target.closest(".yeaft-composer-model-control")||Jt()},lr=()=>{a.value||(v.value="vp",h.value=null),a.value=!a.value},ts=({initialTab:I="vp",editVpId:G=null}={})=>{v.value=["vp","search","mcp"].includes(I)?I:"vp",h.value=v.value==="vp"&&G||null,a.value=!0},As=()=>{o.value=!1,l.value=!0},cr=I=>{Je(I)&&(l.value=!1)},xs=async()=>{if(!(u.value||f.value)){f.value=!0,p.value="";try{let I={"Content-Type":"application/json"};t.token&&(I.Authorization=`Bearer ${t.token}`);let G=await fetch("/api/user/agent-secret",{headers:I});if(!G.ok){let Me=r("yeaft.onboarding.secretError");try{let ze=await G.json();ze?.error&&(Me=ze.error)}catch{}throw new Error(Me)}let le=await G.json(),Te=le?.agentSecret||le?.agent_secret||"";if(u.value=String(Te||"").trim(),!u.value)throw new Error(r("yeaft.onboarding.secretError"))}catch(I){p.value=I?.message||r("yeaft.onboarding.secretError")}finally{f.value=!1}}},dr=()=>{c.value=!0},ur=I=>{c.value=!1},ln=async(I,G)=>{if(G&&!(typeof navigator>"u"||!navigator.clipboard?.writeText))try{let le=typeof G=="string"?G:G?.value||"";if(!le)return;await navigator.clipboard.writeText(le),d.value=I||"",g&&clearTimeout(g),g=setTimeout(()=>{d.value="",g=null},1800)}catch{}},Ts=(I,G)=>{},ro=(I={})=>{Zg(I)&&(l.value=!1)},Ht=Vue.reactive(new Set),qt=Vue.computed(()=>{let I=P();return I?I.activeSession:null}),io=I=>{if(!I)return"";if(I.id==="grp_default"&&(I.name==="Default"||!I.name))try{let G=typeof window<"u"?window.i18n:null;if(G&&G.global&&typeof G.global.t=="function")return G.global.t("yeaft.session.defaultName")}catch{}return I.name||I.id||""},cn=Vue.computed(()=>io(qt.value)),pr=Vue.computed(()=>{let I=P();if(!I||!I.activeNeedsInvite)return!1;let G=I.activeSession;return G?!Ht.has(G.id):!1}),vl=Vue.computed(()=>{let I=P();return!!(I&&I.activeNeedsInvite)}),S=Vue.computed(()=>{let I=P();return e._hasHandledAgentList===!0&&e._hasHandledYeaftSessionHydrate===!0&&!!(I&&I.hasLoadedSnapshot)}),V=Vue.computed(()=>{let I=P();return Kg({agentInventoryReady:e._hasHandledAgentList===!0,hasYeaftAgent:Qg(e),sessionsReady:e._hasHandledYeaftSessionHydrate===!0&&!!(I&&I.hasLoadedSnapshot),sessionsEmpty:!!(I&&I.isEmpty)})});Vue.watch(V,I=>{I&&xs()},{immediate:!0});let q="npm install -g @yeaft/webchat-agent",ue=Vue.computed(()=>{let G=(typeof window<"u"&&window.location?.origin?window.location.origin:"http://localhost:3456").replace(/^http:/,"ws:").replace(/^https:/,"wss:"),le=u.value||r("yeaft.onboarding.secretPending");return`yeaft-agent install --server ${G} --name yeaft-agent --secret ${le}`}),Se="gh auth login && yeaft-agent llm use github-copilot --model gpt-5.5",ie=()=>{let I=qt.value;I&&Ht.add(I.id),bl(I?I.id:null)},Oe=()=>{let I=qt.value;I&&Ht.add(I.id)},je=Vue.ref(!1),we=Vue.ref(null),ae=Vue.ref(null),tt=Vue.ref("session"),dn=Vue.ref(""),Nt=(I={})=>{let G=I&&(I.sessionId||I.groupId)||null,le=I&&I.editVpId||"",Te=le?"members":I&&I.section||"session";G&&(we.value=G,ae.value=I&&I.agentId||null,tt.value=Te,dn.value=le,je.value=!0)},lm=()=>{let I=rr();I&&Nt({sessionId:I,section:"session"})},yl=()=>{je.value=!1,we.value=null,ae.value=null,dn.value=""},cm=()=>{yl(),ts({initialTab:"vp"})},bl=I=>{I&&Nt({sessionId:I,section:"members"})};Vue.watch(()=>{let I=qt.value;return I?I.id+":"+(Array.isArray(I.roster)?I.roster.length:0)+":"+(I.defaultVpId||""):""},(I,G)=>{let le=qt.value;le&&I!==G&&Array.isArray(le.roster)&&le.roster.length>0&&Ht.delete(le.id)}),typeof Vue.onBeforeUnmount=="function"&&Vue.onBeforeUnmount(()=>{g&&clearTimeout(g),g=null});let dm=()=>{a.value=!1},um=Vue.computed(()=>!a.value&&!V.value&&me.value),pm=Vue.computed(()=>{let I=P(),G=e.yeaftActiveSessionFilter||I?.activeSessionId||null;if(!G)return[];let Te=(typeof I?.sessionById=="function"?I.sessionById(G,e.currentAgent||null):null)?.agentId||e.currentAgent||null,Me=Te?`${Te}${G}`:G,ze=e.yeaftActiveTasksBySession?.[Me]||{};return By(ze)}),fm=Vue.computed(()=>{if(!e.yeaftConversationId)return[];let G=P(),le=e.yeaftActiveSessionFilter||G?.activeSessionId||null;if(!le)return[];let Te=fl(G,le,e.currentAgent||null),Me=Te&&Array.isArray(Te.roster)?Te.roster:[];if(Me.length===0)return[];let ze=new Set(Me),Bt=Og(Me,s.vpList||[]),Wt=e.vpStatuses||{},Ms={},fr=e.currentAgent||null;for(let qe of Object.values(Wt)){if(!qe||!qe.vpId)continue;let gr=qe.sessionId??qe.groupId;gr&&gr!==le||fr&&qe.agentId&&qe.agentId!==fr||ze.has(qe.vpId)&&(Ms[qe.vpId]=qe)}let wl={};for(let qe of Object.values(e.activeVpTurns||{}))!qe?.turnId||!qe?.sessionId||qe.sessionId!==le||fr&&qe.agentId&&qe.agentId!==fr||Object.entries(e.stoppingVpTurnIds||{}).some(([gr])=>e.activeVpTurns?.[gr]===qe)&&(wl[qe.turnId]=!0);return Hg({vpList:Bt,vpStatuses:Ms,stoppingVpTurnIds:wl,connectionState:e.connectionState,vpLabelOf:qe=>s.vpLabel(qe),vpDescriptionOf:qe=>s.vpDescription(qe)})});return{store:e,pageRef:k,effectiveSidebarCollapsed:Ge,debugMode:i,modelDropdownOpen:o,topbarGroup:Qe,topbarSessionTitle:rn,topbarFolderPath:Ji,topbarModel:Is,topbarEffort:Ot,topbarModelRows:to,selectableEffortsForModel:eo,isModelSelectionActive:so,isModelRowActive:no,modelOptionRef:qi,modelOptionMatchesRef:Jn,showSettings:a,showLlmConfig:l,sessionCreateOpen:c,settingsInitialTab:v,settingsInitialEditVpId:h,chatInputRef:A,messageQuote:w,messageListRef:y,historySearchRef:m,historySearchOpen:b,historySearchActiveMessageId:T,historyOutlineState:L,historySenderOptions:N,toggleHistorySearch:Le,closeHistorySearch:be,onHistorySearchQuery:Be,onHistorySenderChange:Ke,onHistorySenderInvalid:Ft,loadOlderHistoryOutline:tn,loadMoreHistorySearchResults:Wi,previewHistorySearchResult:ji,selectHistorySearchResult:er,yeaftInputDraftKey:j,openSettings:ts,isMobile:We,isNarrowDetail:Vt,detailPanel:re,isResizingDetail:ye,detailWidthStyle:H,startDetailResize:_,isProcessing:Zi,goBack:Ui,sendMessage:zi,setMessageQuote:Ki,editMessageAsNew:Yi,cancelYeaft:Gi,openWorkItemDraft:sn,toggleSidebar:sr,toggleDebug:nn,closeDebug:et,reloadMessages:nr,retryConversationInventory:Qi,reloadPage:Xi,toggleModelDropdown:Ct,selectModel:an,openLlmConfig:As,trackOverlayPointerDown:rt,trackOverlayPointerUp:it,clearOverlayPointerGesture:ot,closeLlmConfigFromOverlay:cr,openSessionCreate:dr,onSessionCreated:ur,copyOnboardingCommand:ln,copiedOnboardingCommand:d,onLlmConfigMessage:Ts,onLlmConfigSaved:ro,formatTokens:Xe,formatModelCtx:es,toggleSettings:lr,onSettingsSaved:dm,sidebarV2Enabled:ge,onSelectGroupV2:x,onSelectChat:K,canUseWorkbench:ve,shouldShowInviteModal:pr,inviteGroupName:cn,onInviteOpenLibrary:ie,onInviteDismiss:Oe,isActiveGroupEmpty:vl,conversationInventoryReady:S,showOnboardingGuide:V,installAgentCommand:q,connectAgentCommand:ue,copilotCommand:Se,agentSecret:u,agentSecretLoading:f,agentSecretError:p,groupSettingsOpen:je,groupSettingsId:we,groupSettingsAgentId:ae,groupSettingsSection:tt,groupSettingsEditVpId:dn,openSessionSettings:Nt,openAnnouncementSettings:lm,closeGroupSettings:yl,openVpLibraryFromGroupSettings:cm,openMemberEditor:bl,showVpTimeline:um,vpTimelineRows:fm,sessionStatusTasksForActiveSession:pm,sessionStatusAnnouncementText:ir,sessionStatusVisible:me,toggleSessionStatus:ee,closeSessionStatus:pe,timelineWidthStyle:Zt,startTimelineResize:St,onEditVpFromTimeline:I=>{if(!I)return;let G=rr();G&&Nt({sessionId:G,section:"members",editVpId:I})},onMentionVpFromTimeline:I=>{if(!I)return;let G=A.value;G&&typeof G.appendMention=="function"&&G.appendMention(I)},onCancelVpFromTimeline:I=>{if(!I)return;let G=P(),le=e.yeaftActiveSessionFilter||G?.activeSessionId||null;le&&typeof e.cancelVpTurnForSession=="function"&&e.cancelVpTurnForSession(I,le)},onCancelTaskFromTimeline:I=>!I?.id||!I.sessionId||typeof e.cancelYeaftTask!="function"?!1:e.cancelYeaftTask({agentId:I.agentId,sessionId:I.sessionId,taskId:I.id})}}}});var Uy=gm(()=>{Wr();ct();Ws();Su();Tt();Tu();Pu();_u();Du();dg();am();Ga();Pa();window.Pinia={...Pinia,useChatStore:null,useAuthStore:null};var Wy={components:{LoginPage:Eu,ChatPage:cg,YeaftPage:om},template:`
|
|
8370
|
+
`,setup(){let e=Pinia.useChatStore(),t=Pinia.useAuthStore(),s=Pinia.useVpStore(),n=Vue.getCurrentInstance(),r=n&&n.appContext.config.globalProperties.$t||(I=>I),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(""),f=Vue.ref(!1),p=Vue.ref(""),g=null,h=Vue.ref("vp"),v=Vue.ref(null),C=Vue.ref(null),w=Vue.ref(null),k=Vue.ref(null),y=Vue.ref(null),m=Vue.ref(null),b=Vue.ref(!1),T=Vue.ref(null),L=Vue.computed(()=>e.getYeaftHistoryOutlineState()),N=Vue.computed(()=>{let I=P(),G=e.yeaftActiveSessionFilter||I?.activeSessionId||null,le=G?fl(I,G,e.currentAgent||null):null,Te=Array.isArray(le?.roster)?le.roster:[];return[{key:"user",label:r("yeaft.outline.you")},...Te.map(Me=>({key:`vp:${Me}`,label:s.vpLabel(Me)}))]}),$=Vue.ref(e.yeaftHistorySearchState?.query||""),D=null,P=()=>{try{return window.Pinia?.useSessionsStore?.()||null}catch{return null}},M=()=>{let I=P();return{agentId:e.currentAgent||null,sessionId:e.yeaftActiveSessionFilter||I?.activeSessionId||null}},A=()=>Ny({...M(),validKeys:N.value.map(I=>I.key)}),R=(I="")=>{let{agentId:G,sessionId:le}=M();e.yeaftHistorySearchState={requestId:null,agentId:G,sessionId:le,query:"",senderKey:I,loading:!1,results:[],hasMore:!1,nextBeforeSeq:null,error:null}},j=Vue.computed(()=>{let I=e.currentAgent||"agent",G=P(),le=e.yeaftActiveSessionFilter||G?.activeSessionId||"session";return`yeaft:${I}:${le}`});Vue.watch(j,()=>{w.value=null});let O=null,Y=null,te=I=>{if(!I)return!1;let G=String(I.tagName||"").toLowerCase();return G==="textarea"||G==="input"||I.isContentEditable===!0},he=({recoverScroll:I=!1}={})=>{let G=k.value;if(!G)return;if(!We.value){G.style.removeProperty("--yeaft-visual-viewport-height");return}let le=window.visualViewport,Te=Math.max(1,Math.round(le?.height||window.innerHeight||1));G.style.setProperty("--yeaft-visual-viewport-height",`${Te}px`),!(!I||le&&window.innerHeight&&le.height<window.innerHeight*.85||te(document.activeElement))&&window.scrollTo(0,0)},ce=(I={})=>{O!=null&&cancelAnimationFrame(O),O=requestAnimationFrame(()=>{O=null,he(I)})},ke=()=>{ce({recoverScroll:!0}),Y&&clearTimeout(Y),Y=setTimeout(()=>{Y=null,ce({recoverScroll:!0})},260)},ve=Vue.computed(()=>e.hasCapability("terminal")||e.hasCapability("file_editor")),ge=Vue.computed(()=>!0),x=I=>{let G=I&&I.id?I.id:null;G&&(e.setActiveSessionFilter(G,{agentId:I.agentId||null}),We.value&&e.closeSessionSidebar())},K=I=>{},re=Vue.ref(null),ye=Vue.ref(!1),W=320,ne=Math.max(W,Math.round(window.innerWidth*.25)),U=localStorage.getItem("yeaft-debug-width"),B=Vue.ref(U?parseInt(U,10):ne),H=Vue.computed(()=>({"--yeaft-detail-width":B.value+"px"})),_=I=>{ye.value=!0;let G=I.clientX,le=B.value,Te=window.innerWidth*.6,Me=Bt=>{let Wt=G-Bt.clientX,Ms=Math.min(Te,Math.max(W,le+Wt));B.value=Ms},ze=()=>{ye.value=!1,document.removeEventListener("mousemove",Me),document.removeEventListener("mouseup",ze),localStorage.setItem("yeaft-debug-width",String(B.value))};document.addEventListener("mousemove",Me),document.addEventListener("mouseup",ze)},J="yeaft-session-status-visible",se=()=>{try{let I=localStorage.getItem(J);return!(I==="0"||I==="false")}catch{return!0}},me=Vue.ref(se()),z=I=>{me.value=!!I;try{localStorage.setItem(J,me.value?"1":"0")}catch{}},ee=()=>z(!me.value),pe=()=>z(!1),oe=220,De=280,$e=(()=>{try{return localStorage.getItem("yeaft-vp-timeline-width")}catch{return null}})(),Fe=$e?parseInt($e,10):NaN,Ue=Vue.ref(Number.isFinite(Fe)&&Fe>=oe?Fe:De),Zt=Vue.computed(()=>({"--yeaft-vp-timeline-width":Ue.value+"px"})),St=I=>{let G=I.clientX,le=Ue.value,Te=Math.max(oe,Math.floor(window.innerWidth*.4)),Me=Bt=>{let Wt=G-Bt.clientX,Ms=Math.min(Te,Math.max(oe,le+Wt));Ue.value=Ms},ze=()=>{document.removeEventListener("mousemove",Me),document.removeEventListener("mouseup",ze);try{localStorage.setItem("yeaft-vp-timeline-width",String(Ue.value))}catch{}};document.addEventListener("mousemove",Me),document.addEventListener("mouseup",ze)},Lt="(max-width: 768px)",It="(max-width: 1024px)",$t=typeof window.matchMedia=="function"?window.matchMedia(Lt):null,ft=typeof window.matchMedia=="function"?window.matchMedia(It):null,Ne=(I,G)=>I?I.matches:window.innerWidth<=G,We=Vue.ref(Ne($t,768)),Vt=Vue.ref(Ne(ft,1024)),Ge=Vue.computed(()=>We.value?!e.sessionSidebarOpen:e.sidebarCollapsed),E=()=>{We.value=Ne($t,768),Vt.value=Ne(ft,1024)},X=()=>{E(),ke()},fe=I=>{I&&(typeof I.addEventListener=="function"?I.addEventListener("change",X):typeof I.addListener=="function"&&I.addListener(X))},de=I=>{I&&(typeof I.removeEventListener=="function"?I.removeEventListener("change",X):typeof I.removeListener=="function"&&I.removeListener(X))},be=()=>{D&&(clearTimeout(D),D=null),$.value="",R(A()),b.value=!1,T.value=null},Ie=()=>{let I=A();$.value="",R(I),b.value=!0,e.loadYeaftHistoryOutline(),I&&e.searchYeaftHistory("",{senderKey:I}),Vue.nextTick(()=>m.value?.focus?.())},Le=()=>{b.value?be():Ie()},He=I=>{b.value&&Tp(I.target)&&be()},Be=I=>{$.value=I,D&&clearTimeout(D),T.value=null,D=setTimeout(()=>{D=null,e.searchYeaftHistory($.value,{senderKey:e.yeaftHistorySearchState.senderKey})},220)},Ke=I=>{D&&clearTimeout(D),D=null,T.value=null,em({...M(),senderKey:I}),e.searchYeaftHistory($.value,{senderKey:I})},Ft=()=>{em({...M(),senderKey:Ni}),T.value=null,e.searchYeaftHistory($.value,{senderKey:Ni})},tn=I=>{if(!e.loadYeaftHistoryOutline({append:!0}))return;let G=Vue.watch(()=>L.value.loading,le=>{le||(G(),m.value?.restoreOlderScroll?.(I))})},Wi=()=>e.searchYeaftHistory(e.yeaftHistorySearchState.query,{append:!0,senderKey:e.yeaftHistorySearchState.senderKey}),ji=I=>{e.hasCapability("session_history_window_prefetch")&&e.loadYeaftHistoryWindow(I)},er=I=>Mp({result:I,revealWindow:G=>e.revealYeaftHistoryResult(G),nextTick:()=>Vue.nextTick(),revealMessage:G=>y.value?.revealMessage?.(G),isMobile:We.value,closeOutline:be}),tr=I=>{if((I.metaKey||I.ctrlKey)&&String(I.key).toLowerCase()==="f"){I.preventDefault(),Ie();return}if(I.key==="Escape"){if(b.value){be();return}if(o.value){Jt();return}}};Vue.onMounted(()=>{E(),window.addEventListener("resize",X),fe($t),fe(ft),window.visualViewport?.addEventListener("resize",ke),window.visualViewport?.addEventListener("scroll",ke),document.addEventListener("click",ar),document.addEventListener("click",He),document.addEventListener("keydown",tr),ce()}),Vue.onUnmounted(()=>{window.removeEventListener("resize",X),de($t),de(ft),window.visualViewport?.removeEventListener("resize",ke),window.visualViewport?.removeEventListener("scroll",ke),document.removeEventListener("click",ar),document.removeEventListener("click",He),document.removeEventListener("keydown",tr),O!=null&&cancelAnimationFrame(O),Y&&clearTimeout(Y),D&&clearTimeout(D)}),Vue.watch(()=>e.yeaftConversationId,I=>{I&&e.activeConversations[0]!==I&&(e.activeConversations=[I])}),Vue.watch(()=>[e.currentAgent,e.yeaftActiveSessionFilter],()=>{be(),R(A())});let Ui=()=>{e.leaveYeaft()},zi=(I,G,le)=>{let Te=P();if(Te&&Te.activeNeedsInvite){let Wt=Te.activeSession;Wt&&Ht.delete(Wt.id);return}let Me=e.yeaftActiveSessionFilter||Te&&Te.activeSessionId||"grp_default",ze=gi(I).mentions,Bt=Array.isArray(G)?G:void 0;e.sendYeaftSessionMessage({groupId:Me,text:I,mentions:ze,attachments:Bt,quote:le})},Ki=I=>{I&&(w.value=I,C.value?.focusInput?.())},Yi=I=>{w.value=null,C.value?.replaceDraft?.(I||"")},Gi=()=>{let I=P(),G=e.yeaftActiveSessionFilter||I?.activeSessionId||null;G&&e.cancelYeaftSession(G)},sn=(I="")=>{let G=Qe.value;G&&e.enterWorkCenterFromSession(G,I)},sr=()=>{if(We.value){e.toggleSessionSidebar();return}e.toggleSidebar()},nn=()=>{i.value=!i.value},et=()=>{i.value=!1},nr=()=>{e.reloadYeaftMessages()},Qi=()=>{if(typeof e.requestYeaftSessionInventory=="function"){e.requestYeaftSessionInventory();return}e._hasHandledAgentList=!1,e._hasHandledYeaftSessionHydrate=!1,e.yeaftSessionHydrateError=null,e.sendWsMessage({type:"get_agents"})},Xi=()=>{window.location.reload()},Zi=Vue.computed(()=>{let I=P(),G=e.yeaftActiveSessionFilter||I?.activeSessionId||null;return G?e.isYeaftSessionProcessing(G,e.currentAgent||null):!1}),Qe=Vue.computed(()=>{let I=P();if(!I||!I.sessions)return null;let G=e.yeaftActiveSessionFilter||null;if(G&&typeof I.sessionById=="function"){let le=I.sessionById(G,e.currentAgent||null);if(le)return le}if(I.activeSessionId&&typeof I.sessionById=="function"){let le=I.sessionById(I.activeSessionId,e.currentAgent||null);if(le)return le}return typeof I.sessionById=="function"?I.sessionById("grp_default",e.currentAgent||null):null}),rr=()=>Gg({activeSessionFilter:e.yeaftActiveSessionFilter,sessionsStore:P(),topbarGroup:Qe.value}),rn=Vue.computed(()=>{let I=Qe.value||{},G=typeof I.id=="string"?I.id.trim():"",le=[I.title,I.name,I.config?.title,I.config?.name];for(let Te of le){let Me=typeof Te=="string"?Te.trim():"";if(Me&&!(G&&Me===G)&&!/^(sessions?|groups?)\//i.test(Me)&&!/^session_[A-Za-z0-9_-]+$/.test(Me)&&!(I.workDir&&Me===I.workDir))return Me}return""}),Ji=Vue.computed(()=>{let I=Qe.value?.workDir;return typeof I=="string"?I.trim():""}),ir=Vue.computed(()=>Qe.value&&typeof Qe.value.announcement=="string"?Qe.value.announcement:""),Is=Vue.computed(()=>Bg(Qe.value,e.yeaftModel||"")),on=Vue.computed(()=>{let I=Is.value;return I&&e.yeaftAvailableModels.find(G=>Jn(G,I))||null}),eo=I=>gl(I?.effortOptions),Cs=Vue.computed(()=>jg(Qe.value,e.yeaftModelEffort||"")),Ot=Vue.computed(()=>{let I=Array.isArray(on.value?.effortOptions)?on.value.effortOptions.filter(Boolean):[];return I.length?I.includes(Cs.value)?Cs.value:ml(I):null}),to=Vue.computed(()=>Ug(e.yeaftAvailableModels)),so=(I,G)=>Jn(I,Is.value)?G?G===Ot.value:!eo(I).length:!1,no=I=>!I||!Jn(I.model,Is.value)?!1:I.efforts.length?I.efforts.includes(Ot.value):!0,or=()=>{o.value=!0},Jt=()=>{o.value=!1},Ct=I=>{I.stopPropagation(),e.yeaftAvailableModels.length&&(o.value?Jt():or())},an=(I,G=null)=>{if(!I)return;let le=Qe.value?.id||null;e.switchYeaftModel(I,le,G),Jt()},Xe=I=>!I||!Number.isFinite(I)||I<=0?"":I>=1e6?`${Math.round(I/1e5)/10}m`:I>=1e3?`${Math.round(I/1e3)}k`:String(I),es=I=>{let G=Xe(I?.contextWindow),le=Xe(I?.maxOutput);return G&&le?`${G} \xB7 ${le} out`:G},ar=I=>{if(!o.value)return;I.target.closest(".yeaft-composer-model-control")||Jt()},lr=()=>{a.value||(h.value="vp",v.value=null),a.value=!a.value},ts=({initialTab:I="vp",editVpId:G=null}={})=>{h.value=["vp","search","mcp"].includes(I)?I:"vp",v.value=h.value==="vp"&&G||null,a.value=!0},As=()=>{o.value=!1,l.value=!0},cr=I=>{Je(I)&&(l.value=!1)},xs=async()=>{if(!(u.value||f.value)){f.value=!0,p.value="";try{let I={"Content-Type":"application/json"};t.token&&(I.Authorization=`Bearer ${t.token}`);let G=await fetch("/api/user/agent-secret",{headers:I});if(!G.ok){let Me=r("yeaft.onboarding.secretError");try{let ze=await G.json();ze?.error&&(Me=ze.error)}catch{}throw new Error(Me)}let le=await G.json(),Te=le?.agentSecret||le?.agent_secret||"";if(u.value=String(Te||"").trim(),!u.value)throw new Error(r("yeaft.onboarding.secretError"))}catch(I){p.value=I?.message||r("yeaft.onboarding.secretError")}finally{f.value=!1}}},dr=()=>{c.value=!0},ur=I=>{c.value=!1},ln=async(I,G)=>{if(G&&!(typeof navigator>"u"||!navigator.clipboard?.writeText))try{let le=typeof G=="string"?G:G?.value||"";if(!le)return;await navigator.clipboard.writeText(le),d.value=I||"",g&&clearTimeout(g),g=setTimeout(()=>{d.value="",g=null},1800)}catch{}},Ts=(I,G)=>{},ro=(I={})=>{Zg(I)&&(l.value=!1)},Ht=Vue.reactive(new Set),qt=Vue.computed(()=>{let I=P();return I?I.activeSession:null}),io=I=>{if(!I)return"";if(I.id==="grp_default"&&(I.name==="Default"||!I.name))try{let G=typeof window<"u"?window.i18n:null;if(G&&G.global&&typeof G.global.t=="function")return G.global.t("yeaft.session.defaultName")}catch{}return I.name||I.id||""},cn=Vue.computed(()=>io(qt.value)),pr=Vue.computed(()=>{let I=P();if(!I||!I.activeNeedsInvite)return!1;let G=I.activeSession;return G?!Ht.has(G.id):!1}),vl=Vue.computed(()=>{let I=P();return!!(I&&I.activeNeedsInvite)}),S=Vue.computed(()=>{let I=P();return e._hasHandledAgentList===!0&&e._hasHandledYeaftSessionHydrate===!0&&!!(I&&I.hasLoadedSnapshot)}),V=Vue.computed(()=>{let I=P();return Kg({agentInventoryReady:e._hasHandledAgentList===!0,hasYeaftAgent:Qg(e),sessionsReady:e._hasHandledYeaftSessionHydrate===!0&&!!(I&&I.hasLoadedSnapshot),sessionsEmpty:!!(I&&I.isEmpty)})});Vue.watch(V,I=>{I&&xs()},{immediate:!0});let q="npm install -g @yeaft/webchat-agent",ue=Vue.computed(()=>{let G=(typeof window<"u"&&window.location?.origin?window.location.origin:"http://localhost:3456").replace(/^http:/,"ws:").replace(/^https:/,"wss:"),le=u.value||r("yeaft.onboarding.secretPending");return`yeaft-agent install --server ${G} --name yeaft-agent --secret ${le}`}),Se="gh auth login && yeaft-agent llm use github-copilot --model gpt-5.5",ie=()=>{let I=qt.value;I&&Ht.add(I.id),bl(I?I.id:null)},Oe=()=>{let I=qt.value;I&&Ht.add(I.id)},je=Vue.ref(!1),we=Vue.ref(null),ae=Vue.ref(null),tt=Vue.ref("session"),dn=Vue.ref(""),Nt=(I={})=>{let G=I&&(I.sessionId||I.groupId)||null,le=I&&I.editVpId||"",Te=le?"members":I&&I.section||"session";G&&(we.value=G,ae.value=I&&I.agentId||null,tt.value=Te,dn.value=le,je.value=!0)},lm=()=>{let I=rr();I&&Nt({sessionId:I,section:"session"})},yl=()=>{je.value=!1,we.value=null,ae.value=null,dn.value=""},cm=()=>{yl(),ts({initialTab:"vp"})},bl=I=>{I&&Nt({sessionId:I,section:"members"})};Vue.watch(()=>{let I=qt.value;return I?I.id+":"+(Array.isArray(I.roster)?I.roster.length:0)+":"+(I.defaultVpId||""):""},(I,G)=>{let le=qt.value;le&&I!==G&&Array.isArray(le.roster)&&le.roster.length>0&&Ht.delete(le.id)}),typeof Vue.onBeforeUnmount=="function"&&Vue.onBeforeUnmount(()=>{g&&clearTimeout(g),g=null});let dm=()=>{a.value=!1},um=Vue.computed(()=>!a.value&&!V.value&&me.value),pm=Vue.computed(()=>{let I=P(),G=e.yeaftActiveSessionFilter||I?.activeSessionId||null;if(!G)return[];let Te=(typeof I?.sessionById=="function"?I.sessionById(G,e.currentAgent||null):null)?.agentId||e.currentAgent||null,Me=Te?`${Te}${G}`:G,ze=e.yeaftActiveTasksBySession?.[Me]||{};return By(ze)}),fm=Vue.computed(()=>{if(!e.yeaftConversationId)return[];let G=P(),le=e.yeaftActiveSessionFilter||G?.activeSessionId||null;if(!le)return[];let Te=fl(G,le,e.currentAgent||null),Me=Te&&Array.isArray(Te.roster)?Te.roster:[];if(Me.length===0)return[];let ze=new Set(Me),Bt=Og(Me,s.vpList||[]),Wt=e.vpStatuses||{},Ms={},fr=e.currentAgent||null;for(let qe of Object.values(Wt)){if(!qe||!qe.vpId)continue;let gr=qe.sessionId??qe.groupId;gr&&gr!==le||fr&&qe.agentId&&qe.agentId!==fr||ze.has(qe.vpId)&&(Ms[qe.vpId]=qe)}let wl={};for(let qe of Object.values(e.activeVpTurns||{}))!qe?.turnId||!qe?.sessionId||qe.sessionId!==le||fr&&qe.agentId&&qe.agentId!==fr||Object.entries(e.stoppingVpTurnIds||{}).some(([gr])=>e.activeVpTurns?.[gr]===qe)&&(wl[qe.turnId]=!0);return Hg({vpList:Bt,vpStatuses:Ms,stoppingVpTurnIds:wl,connectionState:e.connectionState,vpLabelOf:qe=>s.vpLabel(qe),vpDescriptionOf:qe=>s.vpDescription(qe)})});return{store:e,pageRef:k,effectiveSidebarCollapsed:Ge,debugMode:i,modelDropdownOpen:o,topbarGroup:Qe,topbarSessionTitle:rn,topbarFolderPath:Ji,topbarModel:Is,topbarEffort:Ot,topbarModelRows:to,selectableEffortsForModel:eo,isModelSelectionActive:so,isModelRowActive:no,modelOptionRef:qi,modelOptionMatchesRef:Jn,showSettings:a,showLlmConfig:l,sessionCreateOpen:c,settingsInitialTab:h,settingsInitialEditVpId:v,chatInputRef:C,messageQuote:w,messageListRef:y,historySearchRef:m,historySearchOpen:b,historySearchActiveMessageId:T,historyOutlineState:L,historySenderOptions:N,toggleHistorySearch:Le,closeHistorySearch:be,onHistorySearchQuery:Be,onHistorySenderChange:Ke,onHistorySenderInvalid:Ft,loadOlderHistoryOutline:tn,loadMoreHistorySearchResults:Wi,previewHistorySearchResult:ji,selectHistorySearchResult:er,yeaftInputDraftKey:j,openSettings:ts,isMobile:We,isNarrowDetail:Vt,detailPanel:re,isResizingDetail:ye,detailWidthStyle:H,startDetailResize:_,isProcessing:Zi,goBack:Ui,sendMessage:zi,setMessageQuote:Ki,editMessageAsNew:Yi,cancelYeaft:Gi,openWorkItemDraft:sn,toggleSidebar:sr,toggleDebug:nn,closeDebug:et,reloadMessages:nr,retryConversationInventory:Qi,reloadPage:Xi,toggleModelDropdown:Ct,selectModel:an,openLlmConfig:As,trackOverlayPointerDown:rt,trackOverlayPointerUp:it,clearOverlayPointerGesture:ot,closeLlmConfigFromOverlay:cr,openSessionCreate:dr,onSessionCreated:ur,copyOnboardingCommand:ln,copiedOnboardingCommand:d,onLlmConfigMessage:Ts,onLlmConfigSaved:ro,formatTokens:Xe,formatModelCtx:es,toggleSettings:lr,onSettingsSaved:dm,sidebarV2Enabled:ge,onSelectGroupV2:x,onSelectChat:K,canUseWorkbench:ve,shouldShowInviteModal:pr,inviteGroupName:cn,onInviteOpenLibrary:ie,onInviteDismiss:Oe,isActiveGroupEmpty:vl,conversationInventoryReady:S,showOnboardingGuide:V,installAgentCommand:q,connectAgentCommand:ue,copilotCommand:Se,agentSecret:u,agentSecretLoading:f,agentSecretError:p,groupSettingsOpen:je,groupSettingsId:we,groupSettingsAgentId:ae,groupSettingsSection:tt,groupSettingsEditVpId:dn,openSessionSettings:Nt,openAnnouncementSettings:lm,closeGroupSettings:yl,openVpLibraryFromGroupSettings:cm,openMemberEditor:bl,showVpTimeline:um,vpTimelineRows:fm,sessionStatusTasksForActiveSession:pm,sessionStatusAnnouncementText:ir,sessionStatusVisible:me,toggleSessionStatus:ee,closeSessionStatus:pe,timelineWidthStyle:Zt,startTimelineResize:St,onEditVpFromTimeline:I=>{if(!I)return;let G=rr();G&&Nt({sessionId:G,section:"members",editVpId:I})},onMentionVpFromTimeline:I=>{if(!I)return;let G=C.value;G&&typeof G.appendMention=="function"&&G.appendMention(I)},onCancelVpFromTimeline:I=>{if(!I)return;let G=P(),le=e.yeaftActiveSessionFilter||G?.activeSessionId||null;le&&typeof e.cancelVpTurnForSession=="function"&&e.cancelVpTurnForSession(I,le)},onCancelTaskFromTimeline:I=>!I?.id||!I.sessionId||typeof e.cancelYeaftTask!="function"?!1:e.cancelYeaftTask({agentId:I.agentId,sessionId:I.sessionId,taskId:I.id})}}}});var Uy=gm(()=>{Wr();ct();Ws();Su();Tt();Tu();Pu();_u();Du();dg();am();Ga();Pa();window.Pinia={...Pinia,useChatStore:null,useAuthStore:null};var Wy={components:{LoginPage:Eu,ChatPage:cg,YeaftPage:om},template:`
|
|
8372
8371
|
<div v-if="!authStore.initialized" class="auth-bootstrap" aria-busy="true"><span class="session-loading-spinner"></span></div>
|
|
8373
8372
|
<LoginPage v-else-if="!authStore.isAuthenticated" />
|
|
8374
8373
|
<template v-else>
|