@yeaft/webchat-agent 1.0.520 → 1.0.522
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 +7 -7
- 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,4 +1,4 @@
|
|
|
1
|
-
var W=(e,t,s)=>()=>{if(s)throw s[0];try{return e&&(t=e(e=0)),t}catch(n){throw s=[n],n}};var Uv=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(s){throw t=0,s}};function rd(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 id(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 od(e){return e&&typeof e=="object"&&typeof e.n=="string"&&typeof e.c=="string"}function Bt(e){return nacl.util.decodeBase64(e)}var $i=W(()=>{});function gs(){return globalThis.localStorage||null}function ld(){let e=Oi();for(let t of Ia)try{t(e)}catch{}}function Kv(){try{gs()?.removeItem(kr),gs()?.removeItem(Sr)}catch{}}function zv(e){return String(e||"").trim()||null}function ad(e,t){if(!Ir(t))return{};try{let s=JSON.parse(gs()?.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)?(gs()?.removeItem(e),{}):s.records}catch{try{gs()?.removeItem(e)}catch{}return{}}}function cd(e,t,s){if(!Ir(s))return!1;try{return gs()?.setItem(e,JSON.stringify({ownerId:s.ownerId,records:t||{}})),!0}catch{return!1}}function Nt(e){let t=zv(e);if(!t)return Ca(),null;if(nn!==t){nn=t,Li+=1;for(let s of[kr,Sr])try{let n=JSON.parse(gs()?.getItem(s)||"null");(!n||n.ownerId!==t)&&gs()?.removeItem(s)}catch{try{gs()?.removeItem(s)}catch{}}ld()}return Oi()}function Ca(){nn=null,Li+=1,Kv(),ld()}function Oi(){return nn?{ownerId:nn,epoch:Li}:null}function Ir(e){return!!e&&!!nn&&e.ownerId===nn&&e.epoch===Li}function dd(e){return{drafts:ad(kr,e),outbox:ad(Sr,e)}}function Aa(e,t){return cd(kr,e,t)}function Cr(e,t){return cd(Sr,e,t)}function ud(e){return typeof e!="function"?()=>{}:(Ia.add(e),()=>Ia.delete(e))}var kr,Sr,nn,Li,Ia,LS,xa=W(()=>{kr="yeaft-work-center-composer-drafts-v1",Sr="yeaft-work-center-message-outbox-v1",nn=null,Li=0,Ia=new Set;LS=Object.freeze({drafts:kr,outbox:Sr})});function Ta(){try{globalThis.Pinia?.useChatStore?.()?.clearYeaftHistoryMemory?.()}catch{}}function hs(e){let t=String(e||"").trim()||null;Vi!==t&&Ta(),Vi=t}function Gv(){Ta(),Vi=null}var Yv,Vi,Qv,je,Lt=W(()=>{$i();xa();({defineStore:Yv}=Pinia);Vi=null;Qv=1800*1e3,je=Yv("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",Nt(this.userId),hs(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?Bt(n.sessionKey):null,this.role=n.role||"pro",this.userId=n.userId||null,Nt(this.userId),hs(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?Bt(r.sessionKey):null,this.role=r.role||"pro",this.userId=r.userId||null,Nt(this.userId),hs(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?Bt(s.sessionKey):null,this.role=s.role||"pro",this.userId=s.userId||null,Nt(this.userId),hs(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?Bt(s.sessionKey):null,this.role=s.role||"pro",this.userId=s.userId||null,Nt(this.userId),hs(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?Bt(s.sessionKey):null,this.role=s.role||"pro",this.userId=s.userId||null,Nt(this.userId),hs(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?Bt(n.sessionKey):null,this.role=n.role||"pro",this.userId=n.userId||null,Nt(this.userId),hs(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?Bt(r):null,this.role=i||"pro",this.userId=o||null,Nt(this.userId),hs(this.userId),this.authGeneration+=1,this.isAuthenticated=!0,this.loginStep="authenticated",localStorage.setItem("authToken",n),this.startSessionRefresh();try{history.replaceState(null,"",window.location.pathname+window.location.search)}catch{}return!0},async loadIdentities(){if(this.isAuthenticated){this.identitiesLoading=!0,this.identitiesError=null;try{let e=await fetch("/api/auth/identities"),t=await e.json();if(!e.ok||!t.success){this.identitiesError=t.error||"Failed to load identities";return}this.linkedIdentities=t.identities||[],this.hasPassword=!!t.hasPassword}catch(e){this.identitiesError=e.message||"Network error"}finally{this.identitiesLoading=!1}}},async unbindIdentity(e){if(!this.isAuthenticated)return!1;this.identitiesError=null;try{let t=await fetch(`/api/auth/identities/${encodeURIComponent(e)}`,{method:"DELETE"}),s=await t.json();return!t.ok||!s.success?(this.identitiesError=s.error||"Failed to unbind",!1):(this.linkedIdentities=this.linkedIdentities.filter(n=>n.provider!==e),!0)}catch(t){return this.identitiesError=t.message||"Network error",!1}},async refreshSession(){let e=this.token,t=this.authGeneration,s=this.isAuthenticated;try{let n=await fetch("/api/user/profile",{headers:e?{Authorization:`Bearer ${e}`}:{}});if(this.handleAuthResponse(n,e,t,s)||!n.ok)return!1;let r=await n.json().catch(()=>({}));if(t!==this.authGeneration||this.token!==e)return this.isAuthenticated;let i=n.headers?.get?.("X-New-Token"),o=localStorage.getItem("authToken");i&&this.token===e&&(!o||o===e)&&(this.token=i,localStorage.setItem("authToken",i)),r?.role&&(this.role=r.role);let a=this.userId;return this.userId=r?.userId||null,Nt(this.userId),a!==this.userId&&Ta(),Vi=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,Qv),this._sessionRefreshVisibilityHandler=e,typeof document<"u"&&document.addEventListener("visibilitychange",e),typeof window<"u"&&window.addEventListener("pageshow",e)},stopSessionRefresh(){this._sessionRefreshTimer&&(clearInterval(this._sessionRefreshTimer),this._sessionRefreshTimer=null),this._sessionRefreshVisibilityHandler&&(typeof document<"u"&&document.removeEventListener("visibilitychange",this._sessionRefreshVisibilityHandler),typeof window<"u"&&window.removeEventListener("pageshow",this._sessionRefreshVisibilityHandler),this._sessionRefreshVisibilityHandler=null)},async logout(){try{let e={"Content-Type":"application/json"};this.token&&(e.Authorization=`Bearer ${this.token}`),await fetch("/api/auth/logout",{method:"POST",headers:e})}catch{}await this.clearStoredSession()},clearStoredSession(e=null){let t=this.reset();return localStorage.removeItem("authToken"),e&&(this.error=e),t},getActiveToken(){if(this.token)return this.token;let e=localStorage.getItem("authToken");return e&&(this.token=e),this.token},handleAuthResponse(e,t=null,s=this.authGeneration,n=this.isAuthenticated,r=void 0){if(!e||e.status!==401||!n||s!==this.authGeneration)return!1;let i=this.token||localStorage.getItem("authToken")||null;return t!==i?!1:(this.handleAuthFailure(r,t,s),!0)},handleAuthFailure(e="Session expired. Please log in again.",t=null,s=this.authGeneration){if(s!==this.authGeneration)return!1;let n=this.token||localStorage.getItem("authToken")||null;return t!==n||this.clearStoredSession(e),!1},async restoreSession(){let e=localStorage.getItem("authToken"),t=this.authGeneration,s=this.isAuthenticated||!!e;try{let n=await fetch("/api/user/profile",{headers:e?{Authorization:`Bearer ${e}`}:{}});if(this.handleAuthResponse(n,e,t,s))return!1;if(!n.ok)return this.error="Failed to restore session",!1;let r=await n.json();if(t!==this.authGeneration)return this.isAuthenticated;let i=n.headers?.get?.("X-New-Token"),o=this.getActiveToken();if(o!==e)return this.isAuthenticated;let a=i&&(!o||o===e)?i:o||e;return this.token=a,a&&a!==e&&localStorage.setItem("authToken",a),this.role=r?.role||"pro",this.userId=r?.userId||null,Nt(this.userId),hs(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=Bt(e))},backToCredentials(){this.loginStep="credentials",this.tempToken=null,this.emailHint=null,this.setupToken=null,this.totpSecret=null,this.qrCode=null,this.error=null},async requestPasswordReset(e){this.error=null;try{let s=await(await fetch("/api/auth/password-reset/request",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e})})).json();return s.success?s.resetToken||null:(this.error=s.error||"Failed to request password reset",null)}catch(t){return this.error=t.message||"Network error",null}},async verifyPasswordReset(e,t,s){this.error=null;try{let r=await(await fetch("/api/auth/password-reset/verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({resetToken:e,code:t,newPassword:s})})).json();return r.success?!0:(this.error=r.error||"Failed to reset password",!1)}catch(n){return this.error=n.message||"Network error",!1}},async deleteAccount({currentPassword:e,confirm:t}={}){if(!this.isAuthenticated)return{success:!1,error:"Not authenticated"};try{let s=await fetch("/api/user/me",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({currentPassword:e,confirm:t})}),n=await s.json();return!s.ok||!n.success?{success:!1,error:n.error||"Failed to delete account"}:(await this.clearStoredSession(),{success:!0})}catch(s){return{success:!1,error:s.message||"Network error"}}},reset(){Ca(),Gv(),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=ms?.value||"zh-CN",r=($n[s]||$n["zh-CN"]||{})[e];if(r===void 0&&s!=="zh-CN"&&(r=($n["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 Xv(){return ms?.value||"zh-CN"}function Ar(e){$n[e]&&(ms&&(ms.value=e),localStorage.setItem("locale",e),document.documentElement.setAttribute("lang",e))}function Zv(){let e=localStorage.getItem("locale");return e&&$n[e]?e:(navigator.language||navigator.userLanguage||"").startsWith("en")?"en":"zh-CN"}function pd(e,t){return $n=t,ms=Vue.ref(Zv()),document.documentElement.setAttribute("lang",ms.value),e.config.globalProperties.$t=Ee,e.config.globalProperties.$locale=ms,e.provide("t",Ee),e.provide("locale",ms),{t:Ee,setLocale:Ar,getLocale:Xv,locale:ms}}var ms,$n,zt=W(()=>{ms=null,$n={}});function Ln(e){return e?.capabilityMetadataProvided!==!0?!0:Array.isArray(e.capabilities)&&e.capabilities.includes(Ma)}var Ma,qi=W(()=>{Ma="yeaft_plugins"});function Fi(e){if(e?.capabilityMetadataProvided!==!0)return!1;let t=Array.isArray(e.capabilities)?e.capabilities:[];return t.includes(Ma)&&t.includes(Jv)}var Jv,Pa=W(()=>{qi();Jv="yeaft_managed_skills"});function rn(e){if(e==null||e==="")return"claude-code";if(ey.has(e))return e;throw new Error(`Unknown Chat runtime provider: ${e}`)}function Vs(e){if(typeof e!="string"||!e)throw new Error("Chat catalog key requires conversationId");return`chat:${e}`}function xr(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 Tr(e,t,s={}){let n=e.sessionCatalog.map(i=>({...i})),r=Array.isArray(e.hiddenSessionCatalog)?e.hiddenSessionCatalog.map(i=>({...i})):null;return e.sessionCatalogMutationRequests[t]={previousCatalog:n,previousHiddenCatalog:r,...s},n}function fd(e,t){let s=t?.requestId?e.sessionCatalogMutationRequests[t.requestId]:null;return s?(delete e.sessionCatalogMutationRequests[t.requestId],t.ok!==!0&&(e.sessionCatalog=s.previousCatalog,Array.isArray(s.previousHiddenCatalog)&&(e.hiddenSessionCatalog=s.previousHiddenCatalog)),!0):!1}function gd(e,t,s="recent",n=null){let r=Vs(t),i=e.chatHistoryRequests[r]||{},o=Number(i.generation||0)+1,a=`chat_history_${o}_${crypto.randomUUID()}`;return e.chatHistoryRequests[r]={requestId:a,catalogKey:r,generation:o,mode:s,cursor:n,connectionGeneration:Number(e.chatHistoryConnectionGeneration||0),loading:!0,cancelled:!1,error:null},a}function Ra(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 ey,Hi=W(()=>{ey=new Set(["claude-code","copilot"])});function On(e,t,s=""){Mr&&(clearTimeout(Mr),Mr=null),e.sessionLoading=t,e.sessionLoadingText=s,t&&(Mr=setTimeout(()=>{e.sessionLoading&&(e.sessionLoading=!1,e.sessionLoadingText=""),Mr=null},ty))}function Yt(e){On(e,!1)}function hd(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:rn(t.provider),catalogKey:t.catalogKey||null},e.recoveryDismissed=!1)}}function md(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:rn(r)}),e.pendingRecovery=null,e.recoveryDismissed=!1},500)}function vd(e){e.recoveryDismissed=!0,e.pendingRecovery=null}function yd(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]=[],On(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 bd(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 on(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=rn(t.provider),n={sessionId:t.claudeSessionId,workDir:t.workDir,agentId:t.agentId||e.currentAgent,provider:s,catalogKey:Vs(t.id),version:2};localStorage.setItem("lastUsedSession",JSON.stringify(n)),localStorage.setItem("lastViewedSessionRef",JSON.stringify(n)),e.lastUsedSession=n}}e.lastUsedAgent=e.currentAgent,e.panels.length>0?localStorage.setItem("panels",JSON.stringify(e.panels)):localStorage.removeItem("panels")}}function wd(e){return e.lastUsedSession}function kd(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 Sd(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 Id(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 Cd(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 Ad(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 xd(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 Td(e,t=20){if(je().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 Md(e,t){if(!je().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 _a(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 Pd(e,t){let s=_a(e,t);return s&&s.online}var ty,Mr,an=W(()=>{Lt();zt();Hi();ty=3e4,Mr=null});function Rd(){typeof window>"u"||typeof window.dispatchEvent!="function"||typeof CustomEvent>"u"||window.dispatchEvent(new CustomEvent("browser-runtime-transport-reset"))}function _d(e){return e?.code===1008&&String(e.reason||"").toLowerCase().includes("authentication")}function Dd(e){let t=Pr;Pr=[];for(let{resolve:s,reject:n,timer:r}of t)clearTimeout(r),e?s():n(new Error("WebSocket reconnect failed"))}function Ed(e,t){if(!e.ws||e.ws.readyState!==WebSocket.OPEN)return!1;if(e.currentView==="yeaft"&&ny.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=rd(t,e.sessionKey);e.ws.send(JSON.stringify(s))}else e.ws.send(JSON.stringify(t));return!0}catch{return!1}}function Rr(e,t=1e4){return e.ws&&e.ws.readyState===WebSocket.OPEN?Promise.resolve():new Promise((s,n)=>{let r=setTimeout(()=>{Pr=Pr.filter(i=>i.resolve!==s),n(new Error("WebSocket reconnect timeout"))},t);Pr.push({resolve:s,reject:n,timer:r}),(!e.ws||e.ws.readyState!==WebSocket.CONNECTING)&&(e.reconnectAttempts=0,e.connect())})}function $d(e,t){try{let s=JSON.parse(t);return e.sessionKey&&od(s)?id(s,e.sessionKey):s}catch{return null}}function Ld(e){let t=je(),s=location.protocol==="https:"?"wss:":"ws:";e.reconnectTimer&&(clearTimeout(e.reconnectTimer),e.reconnectTimer=null);let n=t.getActiveToken?.()||t.token||null,r=t.authGeneration;if(e.ws&&e.ws.readyState===WebSocket.CONNECTING&&e._wsAuthToken===n&&e._wsAuthGeneration===r)return;clearTimeout(e._legacyYeaftSessionHydrateTimer),e._legacyYeaftSessionHydrateTimer=null,e._hasHandledAgentList=!1,e._hasHandledYeaftSessionHydrate=!1,e.yeaftSessionInventoryCompleteSupported=null,e.workbenchRouteProtocolSupported=null,e.browserRuntimeProtocolSupported=null,e.browserRuntimeSetupProtocolSupported=null,e.browserRuntimeServerEnabled=!1,Rd(),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,Array.isArray(i[0].previousHiddenCatalog)&&(e.hiddenSessionCatalog=i[0].previousHiddenCatalog),e.sessionCatalogMutationRequests={}),e.sessionCatalogLoaded=!1,e.sessionCatalog=[],e.hiddenSessionCatalog=[],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,workbenchRouteProtocol:1,browserRuntimeProtocol:1,browserRuntimeSetupProtocol:1}))}catch{}Dd(!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){_d(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.workbenchRouteProtocolSupported=null,e.browserRuntimeProtocolSupported=null,e.browserRuntimeSetupProtocolSupported=null,e.browserRuntimeServerEnabled=!1,Rd(),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(),Yt(e),_d(l)){t.handleAuthFailure?.(void 0,n,r),e.reconnectAttempts=0,Dd(!1);return}if(e._yeaftReconnectCatchUpPending=!0,c){e.reconnectAttempts=0,e.reconnectTimer=setTimeout(()=>{e.connect()},2e3);return}e.scheduleReconnect()},e.ws.onerror=l=>{}}function Od(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 Vd(e){e.reconnectAttempts=0,e.connect()}function qd(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 Fd(e){e.heartbeatTimer&&(clearInterval(e.heartbeatTimer),e.heartbeatTimer=null)}function Hd(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 Pr,ny,Da=W(()=>{Lt();$i();an();Pr=[];ny=new Set(["sync_messages","refresh_conversation","select_conversation","cancel_execution","update_conversation_settings","ask_user_answer"])});function Pe(e,t){let s=t==null?"__all__":String(t);return e?`${e}${s}`:s}function _r(e){return typeof e?.entryId=="string"&&e.entryId?`entry:${e.entryId}`:e?.role==="assistant"&&e?.turnId?`live-response:${e.turnId}:${e.speakerVpId||e.vpId||""}`:typeof e?.clientMessageId=="string"&&e.clientMessageId?`client:${e.clientMessageId}`:`message:${e?.messageId||""}`}function Dr(e,t,s){return typeof s!="string"||!s?null:`${Pe(e,t)}message:${s}`}function qs(e,t,s){return typeof s!="string"||!s?null:`${Pe(e,t)}client:${s}`}var Vn=W(()=>{});function Ea(e){return typeof e=="string"&&e?e:null}function qn(e,t){return e?.yeaftSessionHistoryState?.[t]||null}function Wt(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 Nd(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=qn(e,o)||{},l=Number(a.generation||0)+1,c=`yeaft_history_${l}_${crypto.randomUUID()}`,d={...a,loaded:!!a.loaded,loading:!0,error:null,requestId:c,generation:l,mode:n,background:n==="prefetch",requestedAt:Date.now(),latestSeq:Number.isFinite(i)?i:a.latestSeq??null};return delete d.completionSeen,r||(d.syncingAfterSeq=null,a.loaded||(d.hasMore=!1,d.oldestSeq=null,d.serverOldestFetchedSeq=null,d.serverHasMore=!1,d.gapQueue=[],d.requestedBeforeSeqs=[],d.count=0)),e.yeaftSessionHistoryState={...e.yeaftSessionHistoryState||{},[o]:d},ln(e),{sessionKey:o,requestId:c,generation:l,state:d}}function $a(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=qn(e,r),o=Ea(t.requestId);if(!i)return o===null;let a=Ea(i.requestId);return o?o===a:a===null}function Wd(e,t={},s={},n="chunk"){if(!$a(e,t))return null;let r=t.sessionId??t.groupId??null,i=t.agentId||e?.yeaftSessionAgentById?.[r]||null,o=Pe(i,r),a=qn(e,o)||{},l=Ea(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},ln(e),d}function Er(e,{agentId:t,sessionId:s,requestId:n,error:r="history_load_failed"}={}){if(!t||!s||!n)return!1;let i=Pe(t,s),o=qn(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()}},ln(e),!0)}function ln(e){let{sessionKey:t}=Wt(e),s=t?qn(e,t):null;return e.yeaftLoadingMoreHistory=!!s?.loading&&s?.mode!=="prefetch",e.yeaftHistoryLoadError=s?.error||null,e.yeaftHasMoreHistory=!!s?.hasMore,e.yeaftOldestLoadedSeq=Number.isFinite(s?.serverOldestFetchedSeq)?s.serverOldestFetchedSeq:Number.isFinite(s?.oldestSeq)?s.oldestSeq:null,s}function La(e){let{sessionKey:t}=Wt(e);return t?qn(e,t):null}var Bd,Bi=W(()=>{Vn();Bd=15e3});function Oa(e){return e?.sessionId??e?.groupId??null}function qa(e){for(let t of[e?.persistedMessageId,e?.messageId,e?.id]){if(typeof t!="string")continue;let s=t.match(/^(m\d+)/);if(s)return s[1]}return null}function ct(e){return e?.isStreaming||e?.status==="pending"?!1:Number.isFinite(e?.seq)||!!qa(e)||e?.isHistory===!0&&!e?.clientMessageId}function Ni(e){if(Number.isFinite(e?.seq))return Number(e.seq);let s=qa(e)?.match(/^m(\d+)$/);if(s)return Number(s[1]);let n=typeof e?.id=="string"?e.id.match(/^(\d+)/):null;return n?Number(n[1]):null}function iy(e){try{return new TextEncoder().encode(JSON.stringify(e)).length}catch{return 0}}function oy(e){return e?e.isStreaming||e.status==="pending"||e.type==="tool-use"&&(e.askPending||!e.hasResult&&(e.toolName==="AskUser"||e.toolName==="AskUserQuestion"))?!0:e.type!=="user"||!e.clientMessageId?!1:!e.dbMessageId&&!qa(e):!1}function ay(e){let t=[],s=null;for(let n of e)(n?.type==="user"||!s)&&(s={rows:[],protected:!1},t.push(s)),s.rows.push(n),oy(n)&&(s.protected=!0);return t}function Ud(e,{conversationId:t,agentId:s=null,sessionId:n=null,limits:r=jd}={}){let i=e?.messagesMap?.[t];if(!Array.isArray(i)||i.length===0||!s||!n)return{evictedRows:0,keptRows:0};let o=b=>Oa(b)===n,a=i.filter(o),l=ay(a);if(l.length===0)return{evictedRows:0,keptRows:0};let c=l.filter(b=>b.protected),d=new Set(c),u=Number.isFinite(r.maxTurnsPerSession)?Math.max(0,Math.floor(r.maxTurnsPerSession)):Va,p=Math.max(0,u-c.length);for(let b=l.length-1;b>=0&&p>0;b-=1){let k=l[b];d.has(k)||(d.add(k),p-=1)}let f=new Set(l.filter(b=>d.has(b)).flatMap(b=>b.rows)),g=a.filter(b=>!f.has(b));if(g.length===0)return{evictedRows:0,keptRows:f.size};let v=i.filter(b=>!o(b)||f.has(b));i.splice(0,i.length,...v);let m=Pe(s,n),y=e.yeaftHistoryCacheState?.[m]||null,h=Kd(a.filter(b=>f.has(b))),S=JSON.stringify(y?.ranges||[])===JSON.stringify(h.ranges)?Number(y?.rangeEpoch)||0:(Number(y?.rangeEpoch)||0)+1;if(e.yeaftHistoryCacheState={...e.yeaftHistoryCacheState||{},[m]:{...y||{},agentId:s,sessionId:n,conversationId:t,lastAccessed:Date.now(),rangeEpoch:S,...h}},g.some(ct)){let b=h.ranges[0]?.startSeq??null,k=e.yeaftSessionHistoryState?.[m]||{};e.yeaftSessionHistoryState={...e.yeaftSessionHistoryState||{},[m]:{...k,serverOldestFetchedSeq:b,oldestSeq:b,serverHasMore:b!==null,hasMore:b!==null,gapTraversalInitialized:!1,gapQueue:[],requestedBeforeSeqs:[],completedHistoryWorkKeys:[],pendingPageKind:null,pendingPageBeforeSeq:null,pendingGapStopAtSeq:null,pendingCacheEpoch:null,pendingHistoryWorkKey:null,paginationError:null,count:h.rowCount}};let P=Wt(e);P.agentId===s&&P.sessionId===n&&ln(e)}return{evictedRows:g.length,keptRows:f.size}}function ly(e){let t=[],s=null;for(let n of e)ct(n)&&((n?.type==="user"||!s)&&(s=[],t.push(s)),s.push(n));return t}function cy(e,t){let s=Number.isFinite(t.maxTurnsPerSession)?Math.max(0,Math.floor(t.maxTurnsPerSession)):Va,n=ly(e),r=new Set(n.slice(-s).flat());for(let i of n)if(i.some(o=>o?._historyWindowDetached===!0))for(let o of i)r.add(o);return r}function dy(e){let t=Array.from(new Set(e.map(Ni).filter(Number.isFinite))).sort((n,r)=>n-r),s=[];for(let n of t){let r=s.at(-1);r&&n<=r.endSeq+1?r.endSeq=n:s.push({startSeq:n,endSeq:n})}return s}function Kd(e){let t=e.filter(ct);return{rowCount:t.length,byteCount:t.reduce((s,n)=>s+iy(n),0),ranges:dy(t)}}function uy(e,t,s){let n=new Set((t||[]).map(r=>r?.stableKey).filter(Boolean));if(n.size!==0)for(let r of e)r?.stableKey&&n.has(r.stableKey)&&(r._historyCacheTouchedAt=s)}function py(e,{conversationId:t,agentId:s,sessionId:n,incomingRows:r,now:i,limits:o}){let a=e.messagesMap?.[t]||[],l=a.filter(h=>Oa(h)===n);uy(l,r,i);let c=cy(l,o),d=l.filter(h=>!ct(h)||c.has(h)),u=new Set(d),p=a.filter(h=>Oa(h)!==n||u.has(h));a.splice(0,a.length,...p);let f=Kd(d),g=Pe(s,n),v=e.yeaftHistoryCacheState?.[g]||null,y=JSON.stringify(v?.ranges||[])===JSON.stringify(f.ranges)?Number(v?.rangeEpoch)||0:(Number(v?.rangeEpoch)||0)+1;e.yeaftHistoryCacheState={...e.yeaftHistoryCacheState||{},[g]:{agentId:s,sessionId:n,conversationId:t,lastAccessed:i,rangeEpoch:y,...f}}}function zd(e,t,s,n=Date.now()){if(!t||!s)return;let r=Pe(t,s),i=e.yeaftHistoryCacheState?.[r];i&&(e.yeaftHistoryCacheState={...e.yeaftHistoryCacheState||{},[r]:{...i,lastAccessed:n}})}function Fa(e,{conversationId:t,agentId:s,sessionId:n,incomingRows:r=[],now:i=Date.now(),limits:o=jd}={}){!e||!t||!s||!n||py(e,{conversationId:t,agentId:s,sessionId:n,incomingRows:r,now:i,limits:o})}var Va,jd,Wi=W(()=>{Vn();Bi();Va=500,jd=Object.freeze({maxTurnsPerSession:Va})});function vs(e){return e?.sessionId??e?.groupId??null}function Gd(e){let t=e?.stableKey??e?.uiKey??e?.messageId??e?.dbMessageId??e?.id;return t==null||t===""?null:String(t)}function fy(e,t){if(e?.type!=="assistant"||t?.type!=="assistant"||vs(e)!==vs(t)||e.isHistory===!0&&!e.isStreaming||t._hasPersistedTurnId!==!0||!e.turnId||!t.turnId||e.turnId!==t.turnId)return!1;let s=e.speakerVpId||e.vpId||"",n=t.speakerVpId||t.vpId||"";if(s&&n&&s!==n)return!1;let r=e.threadId||"",i=t.threadId||"";if(r&&i&&r!==i)return!1;let o=typeof e.content=="string"?e.content:"",a=typeof t.content=="string"?t.content:"";return!!o&&!!a&&(a.startsWith(o)||o.startsWith(a))}function Qd(e,t){let s=e.uiKey||t.uiKey||null;return Object.assign(e,t),s&&(e.uiKey=s),ct(t)&&(e.isStreaming=!1,e.status==="pending"&&(e.status="completed")),e}function ji(e){let t=ct(e),s=t?Ni(e):null,n=Number(e?.timestamp),r=Number.isFinite(n)&&n>0?n:t?-1/0:1/0;return[r,Number.isFinite(r)?0:Number.isFinite(s)?s:-1]}function gy(e,t,s){let n=[],r=new Map,i=new Map;for(let l=t;l<s;l+=1){let c=e[l],d=vs(c),u=ct(c)?Ni(c):null,p=i.get(d);if(!Number.isFinite(u)&&p){p.rows.push(c);continue}let f={sessionId:d,seq:u,rows:[c]};n.push(f),i.set(d,f),Number.isFinite(u)&&(r.has(d)||r.set(d,[]),r.get(d).push(f))}for(let l of r.values())l.sort((c,d)=>c.seq-d.seq);let o=new Map,a=t;for(let l of n){let c=l;if(Number.isFinite(l.seq)){let d=o.get(l.sessionId)||0;c=r.get(l.sessionId)[d],o.set(l.sessionId,d+1)}for(let d of c.rows)e[a++]=d}}function Ha(e){e.sort((t,s)=>{let n=ji(t),r=ji(s);for(let i=0;i<n.length;i+=1)if(n[i]!==r[i])return n[i]-r[i];return 0});for(let t=0;t<e.length;){let s=ji(e[t])[0],n=t+1;for(;n<e.length&&ji(e[n])[0]===s;)n+=1;Number.isFinite(s)&&n-t>1&&gy(e,t,n),t=n}return e}function hy(e,t){return Array.isArray(e.messagesMap?.[t])||(e.messagesMap=e.messagesMap||{},e.messagesMap[t]=[]),e.messagesMap[t]}function Ba(e,t){return e.filter(s=>t===void 0||vs(s)===t)}function Xd(e,t){let s=Gd(t);if(s){let n=e.find(r=>Gd(r)===s);if(n)return n}if(t?.type==="user"&&t.clientMessageId){let n=e.find(r=>r?.type==="user"&&r.clientMessageId===t.clientMessageId&&vs(r)===vs(t));if(n)return n}return t?.type==="assistant"&&e.find(n=>fy(n,t))||null}function Gt(e){if(!e||typeof e!="object")return null;let t=Yd.get(e);return t||(t=new Na(e),Yd.set(e,t)),t}var Yd,Na,$r=W(()=>{Wi();Yd=new WeakMap;Na=class{constructor(t){this.store=t}rows(t){return hy(this.store,t)}durableRows(t,s=void 0){return Ba(this.rows(t),s).filter(ct)}overlayRows(t,s=void 0){return Ba(this.rows(t),s).filter(n=>!ct(n))}snapshot(t,s=void 0){return{durableRows:this.durableRows(t,s),overlayRows:this.overlayRows(t,s)}}commitDurable({conversationId:t,sessionId:s=void 0,rows:n=[],mode:r="delta",replaceDurable:i=!1,preserveEmpty:o=!0}={}){if(!t)return{insertedRows:0,preservedEmpty:!1};let a=this.rows(t),l=Array.isArray(n)?n.filter(Boolean):[],c=Ba(a,s).length>0;if(o&&r==="recent"&&l.length===0&&c)return{insertedRows:0,inserted:[],preservedEmpty:!0};if(i){let p=a.filter(f=>vs(f)!==s||!ct(f));a.splice(0,a.length,...p)}let d=0,u=[];for(let p of l){let f=Xd(a,p);f?Qd(f,p):(a.push(p),u.push(p),d+=1)}return Ha(a),{insertedRows:d,inserted:u,preservedEmpty:!1}}upsertOverlay({conversationId:t,row:s}={}){if(!t||!s)return null;let n=this.rows(t),r=Xd(n,s);return r?Qd(r,s):n.push(s),Ha(n),r||s}appendOverlayText({conversationId:t,sessionId:s=void 0,turnId:n=null,text:r=""}={}){if(!t||!r)return null;let o=this.rows(t).findLast(a=>a?.type==="assistant"&&!ct(a)&&(s===void 0||vs(a)===s)&&(!n||a.turnId===n));return o?(o.content?r.startsWith(o.content)?o.content=r:o.content.endsWith(r)||(o.content+=r):o.content=r,o):null}replaceProjection(t,s=[]){let n=this.rows(t);return n.splice(0,n.length,...Array.isArray(s)?s:[]),Ha(n),n}removeDurable({conversationId:t,sessionId:s}={}){if(!t)return 0;let n=this.rows(t),r=n.filter(o=>vs(o)!==s||!ct(o)),i=n.length-r.length;return n.splice(0,n.length,...r),i}}});function Lr(e,t){return t?t===e.yeaftConversationId?!0:Object.values(e.yeaftConversationIdsByAgent||{}).includes(t):!1}function Fn(e,t,s){s&&(s.type!=="assistant"&&s.type!=="tool-use"||Lr(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 vy(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 Ui(e){let t=e?.stableKey??e?.messageId??e?.dbMessageId??e?.id;return t==null||t===""?null:String(t)}function Wa(e,t,s){if(!s||typeof s!="object")return null;if(typeof s.uiKey=="string"&&s.uiKey)return s.uiKey;let n=s.entryId||s.stableKey||s.atMessageId||s.messageId||s.dbMessageId||s.id||null;if(n!=null&&n!=="")return s.uiKey=String(n),s.uiKey;let r=`legacy:${t||"conversation"}:`,i=new Set((e?.messagesMap?.[t]||[]).map(a=>a?.uiKey).filter(a=>typeof a=="string"&&a)),o=Number(e?._messageUiKeySequence)||0;do o+=1;while(i.has(`${r}${o}`));return e&&(e._messageUiKeySequence=o),s.uiKey=`${r}${o}`,s.uiKey}function Or(e,t,s){for(let n of Array.isArray(s)?s:[])Wa(e,t,n);return s}function ja(e,t){if(!e||!t)return e;let s=e.type==="user"&&typeof e.id=="string"&&e.id===e.clientMessageId;for(let[n,r]of Object.entries(t))if(r!=null){if(n==="isStreaming"){e.isStreaming&&r===!1&&(e.isStreaming=!1);continue}if(!(n==="uiKey"&&e.uiKey)){if(n==="id"||n==="messageId"){if(s&&t.clientMessageId===e.clientMessageId&&t.messageId&&t.messageId!==e.clientMessageId)continue;(e[n]===void 0||e[n]===null||e[n]==="")&&(e[n]=r);continue}if(!(n==="turnId"&&s&&e.turnId===e.clientMessageId)){if(n==="content"&&typeof r=="string"){e.content||(e.content=r);continue}if(n==="responseKind"&&(r==="progress"||r==="result")){e.responseKind=r;continue}if(n==="attachments"&&Array.isArray(r)){(!Array.isArray(e.attachments)||e.attachments.length===0)&&(e.attachments=r);continue}(e[n]===void 0||e[n]===null||e[n]==="")&&(e[n]=r)}}}return e}function Zd(e=[],t=[]){let s=[],n=new Map,r=new Map;for(let i of[...e,...t]){if(!i)continue;let o=Ui(i),a=i.type==="user"&&i.clientMessageId?String(i.clientMessageId):null;if(o&&n.has(o)){ja(n.get(o),i);continue}if(a&&r.has(a)){let l=r.get(a);ja(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 Jd(e,t,s){return!e||e!==t?!1:!s?.loaded&&!s?.loading}function eu(e,t){return!!t&&!!e?.loaded&&!e?.loading&&Number.isFinite(e?.latestSeq)}function tu({sessionState:e,hasCachedSessionRows:t,force:s=!1}={}){return e?.loading?!1:s?!e?.loaded:e?.loaded?!1:!t}function yy(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"&&Ui(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,Fn(e,t,o),!0):!1}function Ki(e,t,s){if(!t)return;let n={...s};Wa(e,t,n);let r={...n,id:s.dbMessageId||s.id||Date.now().toString()+Math.random().toString(36).substr(2,9),timestamp:vy(s)};if(Lr(e,t)&&!r.sessionId&&(r.sessionId=e._currentYeaftSessionId||e.yeaftActiveSessionFilter||my),Lr(e,t)){let o=e._currentYeaftAgentId||Object.entries(e.yeaftConversationIdsByAgent||{}).find(([,c])=>c===t)?.[0]||e.currentAgent||null,a=typeof r.messageId=="string"&&/^m\d+$/.test(r.messageId)?r.messageId:typeof r.id=="string"&&/^m\d+$/.test(r.id)?r.id:null,l=typeof r.clientMessageId=="string"?r.clientMessageId:null;r.stableKey||(r.stableKey=a?Dr(o,r.sessionId,a):qs(o,r.sessionId,l)),r.uiKey||(r.uiKey=r.stableKey||null),!r.vpId&&e._currentYeaftVpId&&(r.vpId=e._currentYeaftVpId),!r.turnId&&e._currentYeaftTurnId&&(r.turnId=e._currentYeaftTurnId),Fn(e,t,r)}if(e.messagesMap[t]||(e.messagesMap[t]=[]),Wa(e,t,r),Lr(e,t))return Gt(e).upsertOverlay({conversationId:t,sessionId:r.sessionId,row:r});let i=Ui(s);if(i){let o=e.messagesMap[t].find(a=>Ui(a)===i);if(o)return ja(o,r),t===e.yeaftConversationId&&e.messagesMap[t].sort((a,l)=>a.timestamp-l.timestamp),o}return e.messagesMap[t].push(r),t===e.yeaftConversationId&&e.messagesMap[t].sort((o,a)=>o.timestamp-a.timestamp),r}function su(e,t,s,n={}){if(!t||!s)return;e.messagesMap[t]||(e.messagesMap[t]=[]);let r=e.messagesMap[t];if(yy(e,t,n,s))return;if(Lr(e,t)){let l=Gt(e).appendOverlayText({conversationId:t,sessionId:n.sessionId||e._currentYeaftSessionId||void 0,turnId:n.turnId||e._currentYeaftTurnId||null,text:s});if(l){Fn(e,t,l),n.id&&!l.id&&(l.id=n.id),n.id&&!l.messageId&&(l.messageId=n.id);return}}let i=e._currentYeaftTurnId;if(i){for(let a=r.length-1;a>=0;a--)if(r[a].turnId===i&&r[a].type==="assistant"&&r[a].isStreaming){if(Fn(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}Ki(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(Fn(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 Ki(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 nu(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())),Fn(e,t,o),o.type==="user")break}}function ru(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 iu(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 cn(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 by(e){return{id:e.id,dbMessageId:e.id,timestamp:e.created_at}}function ou(e){if(!e)return null;let t=by(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 my,Vr=W(()=>{$r();Vn();my="grp_default"});function dn(e,t){return e._closedAt?.[t]?Date.now()-e._closedAt[t]<3e4:!1}function Hn(e,t){qe(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]){qe(e,t);return}s()},3e4))},45e3);e._processingWatchdogs[t]=n}function zi(e,t){e._yeaftWatchdogPauseReasons?.[t]?.size||e.processingConversations[t]&&e._processingWatchdogs?.[t]&&(e._pongTimeouts?.[t]&&(clearTimeout(e._pongTimeouts[t]),delete e._pongTimeouts[t]),e.sessionHealth?.[t]&&delete e.sessionHealth[t],e._yeaftWatchdogConvs?.has(t)?Nn(e,t):Hn(e,t))}function qe(e,t){e._processingWatchdogs?.[t]&&(clearTimeout(e._processingWatchdogs[t]),clearInterval(e._processingWatchdogs[t]),delete e._processingWatchdogs[t]),e._pongTimeouts?.[t]&&(clearTimeout(e._pongTimeouts[t]),delete e._pongTimeouts[t]),e.sessionHealth?.[t]&&delete e.sessionHealth[t],e._autoRefreshed?.[t]&&delete e._autoRefreshed[t],e._yeaftWatchdogConvs?.delete(t),e._yeaftWatchdogPauseReasons&&delete e._yeaftWatchdogPauseReasons[t]}function qr(e,t,s="phase"){if(!t||!e.processingConversations[t])return;e._yeaftWatchdogPauseReasons||(e._yeaftWatchdogPauseReasons={});let n=e._yeaftWatchdogPauseReasons[t]||new Set;n.add(s),e._yeaftWatchdogPauseReasons[t]=n,e._processingWatchdogs?.[t]&&(clearTimeout(e._processingWatchdogs[t]),clearInterval(e._processingWatchdogs[t]),delete e._processingWatchdogs[t])}function Bn(e,t,s=null){if(!t)return;let n=e._yeaftWatchdogPauseReasons?.[t];n&&(s?n.delete(s):n.clear(),!n.size&&(delete e._yeaftWatchdogPauseReasons[t],e.processingConversations[t]&&Nn(e,t)))}function au(e,t){qe(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 Nn(e,t){let s=e._yeaftWatchdogPauseReasons?.[t];if(qe(e,t),e._processingWatchdogs||(e._processingWatchdogs={}),s?.size){e._yeaftWatchdogConvs||(e._yeaftWatchdogConvs=new Set),e._yeaftWatchdogPauseReasons||(e._yeaftWatchdogPauseReasons={}),e._yeaftWatchdogConvs.add(t),e._yeaftWatchdogPauseReasons[t]=new Set(s);return}e._yeaftWatchdogConvs||(e._yeaftWatchdogConvs=new Set),e._yeaftWatchdogConvs.add(t),e._processingWatchdogs[t]=setTimeout(()=>{if(e.processingConversations[t]){delete e.processingConversations[t];let n=e.executionStatusMap[t];n&&(n.currentTool=null),e.finishStreamingForConversation(t)}delete e._processingWatchdogs[t]},15e4)}var Fs=W(()=>{});function Ua(e,t){return t&&Array.isArray(e?._yeaftRetiredConversationIdsByAgent?.[t])?e._yeaftRetiredConversationIdsByAgent[t]:[]}function Wn(e,t,s){return!t||!s?!1:Ua(e,t).includes(s)}function Ka(e,t){let s=e?._yeaftRetiredConversationTargetsByAgent?.[t];return s&&typeof s=="object"?s:{}}function lu(e,t,s){if(!t||!s)return null;let n=Ka(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 Fr(e,t,s,n=null){if(!t||!s)return;let r=Ua(e,t).filter(a=>a!==s).concat(s).slice(-8);e._yeaftRetiredConversationIdsByAgent={...e._yeaftRetiredConversationIdsByAgent||{},[t]:r};let i=Ka(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 za(e,t,s){if(!t||!s||!e?._yeaftRetiredConversationIdsByAgent)return;let n=Ua(e,t).filter(i=>i!==s);e._yeaftRetiredConversationIdsByAgent={...e._yeaftRetiredConversationIdsByAgent,[t]:n};let r={...Ka(e,t)};delete r[s],e._yeaftRetiredConversationTargetsByAgent={...e._yeaftRetiredConversationTargetsByAgent||{},[t]:r}}var Yi=W(()=>{});function Sy(e,t,s){let n=e.messagesMap?.[t]||[],r=e.messagesMap?.[s]||[];e.messagesMap||(e.messagesMap={}),Or(e,t,n),Or(e,s,r);let i=Zd(r,n).sort((o,a)=>{let l=Number.isFinite(o?.seq)?o.seq:null,c=Number.isFinite(a?.seq)?a.seq:null;return l!==null&&c!==null&&l!==c?l-c:l!==null&&c===null?-1:l===null&&c!==null?1:(o?.timestamp||0)-(a?.timestamp||0)});Gt(e).replaceProjection(s,i)}function Iy(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 Gi(e,t){return!!e&&Object.prototype.hasOwnProperty.call(e,t)}function jn(e,t,s,{removeSource:n}){Gi(e,t)&&(Gi(e,s)||(e[s]=n?e[t]:Iy(e[t])),n&&delete e[t])}function Qt(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 Qi(e,t,s,n){return!t||!s||!n||s===n?!1:(e._yeaftPendingConversationPromotions={...e._yeaftPendingConversationPromotions||{},[t]:{sourceConversationId:s,targetConversationId:n}},!0)}function Hr(e,t,s=null){let n=Qt(e,t,s);if(!n)return null;let r={...e._yeaftPendingConversationPromotions||{}};return delete r[t],e._yeaftPendingConversationPromotions=r,n}function Br(e,t,s){let n=Qt(e,t);return!n||!s||n.targetConversationId===s?null:(Xt(e,n.targetConversationId,s,{removeSource:!0}),Fr(e,t,n.targetConversationId,s),Qi(e,t,n.sourceConversationId,s),n)}function Xt(e,t,s,{removeSource:n=!0}={}){if(!t||!s||t===s)return!1;Sy(e,t,s),e.yeaftHistoryCacheState&&(e.yeaftHistoryCacheState=Object.fromEntries(Object.entries(e.yeaftHistoryCacheState).map(([c,d])=>[c,d?.conversationId===t?{...d,conversationId:s}:d]))),jn(e.processingConversations,t,s,{removeSource:n}),jn(e.executionStatusMap,t,s,{removeSource:n}),jn(e.refreshingSessionMap,t,s,{removeSource:n}),jn(e._closedAt,t,s,{removeSource:n}),jn(e._autoRefreshed,t,s,{removeSource:n}),jn(e.sessionHealth,t,s,{removeSource:n}),e._turnCompletedConvs?.has(t)&&(e._turnCompletedConvs.add(s),n&&e._turnCompletedConvs.delete(t));let r=!!e._yeaftWatchdogConvs?.has(t),i=e._yeaftWatchdogPauseReasons?.[t],o=!!i?.size,a=!!e._processingWatchdogs?.[t];if(o&&(e._yeaftWatchdogPauseReasons||(e._yeaftWatchdogPauseReasons={}),e._yeaftWatchdogPauseReasons[s]=new Set(i)),n&&(a||o)&&qe(e,t),n&&e._pongTimeouts?.[t]&&(clearTimeout(e._pongTimeouts[t]),delete e._pongTimeouts[t]),n&&(a||r||o)&&!!e.processingConversations?.[s])if(e._processingWatchdogs?.[s])e._yeaftWatchdogConvs?.add(s);else{let c=Gi(e.sessionHealth,s),d=e.sessionHealth?.[s],u=Gi(e._autoRefreshed,s),p=e._autoRefreshed?.[s];Nn(e,s),c&&(e.sessionHealth||(e.sessionHealth={}),e.sessionHealth[s]=d),u&&(e._autoRefreshed||(e._autoRefreshed={}),e._autoRefreshed[s]=p)}return n&&e.messagesMap&&delete e.messagesMap[t],!0}var Ya=W(()=>{Vr();$r();Yi();Fs()});function Xi(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 Ga=W(()=>{});function Qa(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}function Cy(){return Date.now()}function Ay(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`pt_${crypto.randomUUID()}`:`pt_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,10)}`}function xy(e,t=160){return typeof e!="string"?e:e.length>t?`${e.slice(0,t)}...[truncated]`:e}function Ty(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"?xy(n):n);return t}function un(){return Ay()}function vt(e,t={}){!e||!t.traceId||(Array.isArray(e._perfTraceQueue)||(e._perfTraceQueue=[]),e._perfTraceQueue.push({traceId:t.traceId,source:"web",phase:t.phase||"unknown",at:Cy(),monotonicMs:Qa(),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:Ty(t.detail)}),e._perfTraceQueue.length>200&&e._perfTraceQueue.splice(0,e._perfTraceQueue.length-200),My(e))}function My(e){!e||e._perfTraceFlushTimer||(e._perfTraceFlushTimer=setTimeout(()=>Py(e),250))}function Py(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 Zi(e,t={}){if(typeof requestAnimationFrame!="function")return;let s=Qa();requestAnimationFrame(()=>{requestAnimationFrame(()=>{vt(e,{...t,phase:t.phase||"render.next_paint",durationMs:Qa()-s})})})}var Xa=W(()=>{});function Zt(e){return Number.isFinite(e)?Number(e):null}function Ry(e){return(Array.isArray(e)?e:[]).map(t=>({startSeq:Zt(t?.startSeq),endSeq:Zt(t?.endSeq)})).filter(t=>t.startSeq!==null&&t.endSeq!==null&&t.startSeq<=t.endSeq).sort((t,s)=>t.startSeq-s.startSeq)}function Nr(e){return Number.isFinite(e)&&e>=0?Math.floor(e):0}function pn(e){let t=Zt(e?.beforeSeq);if(t===null)return null;if(e?.kind==="gap"){let s=Zt(e.stopAtSeq);return s===null?null:`gap:${Nr(e.cacheEpoch)}:${s}:${t}`}return`server:${t}`}function Wr(e){let t=new Set((Array.isArray(e?.completedHistoryWorkKeys)?e.completedHistoryWorkKeys:[]).filter(s=>typeof s=="string"&&s));for(let s of Array.isArray(e?.requestedBeforeSeqs)?e.requestedBeforeSeqs:[])Number.isFinite(s)&&t.add(`server:${s}`);return t}function _y(e,t){let s=pn(t);if(!s)return e.completedHistoryWorkKeys||[];let n=Wr(e);return n.add(s),Array.from(n).slice(-256)}function Dy(e,t){if(!Number.isFinite(t))return e.requestedBeforeSeqs||[];let s=new Set((Array.isArray(e?.requestedBeforeSeqs)?e.requestedBeforeSeqs:[]).filter(Number.isFinite));return s.add(t),Array.from(s).sort((n,r)=>r-n).slice(-256)}function Ey(e,t={},s=0){let n=Ry(e),r=Nr(s),i=Wr(t),o=[];for(let a=1;a<n.length;a+=1){let l=n[a-1],c=n[a];if(l.endSeq+1>=c.startSeq)continue;let d={kind:"gap",beforeSeq:c.startSeq,stopAtSeq:l.endSeq+1,cacheEpoch:r};d.workKey=pn(d),i.has(d.workKey)||o.push(d)}return o.sort((a,l)=>l.beforeSeq-a.beforeSeq)}function cu(e,t,s){let n=Ey(e,t,s),r=Zt(t.serverOldestFetchedSeq??t.oldestSeq),i=n[0]||null;if(!i||r===null||i.beforeSeq<=r)return[];let o={kind:"gap",beforeSeq:i.beforeSeq,stopAtSeq:r,cacheEpoch:i.cacheEpoch};return o.workKey=pn(o),Wr(t).has(o.workKey)?[]:[o]}function du(e={},t=[],s=0){let n=Nr(s),r=Wr(e),i=e.serverHasMore!==!1,o=Zt(e.serverOldestFetchedSeq??e.oldestSeq),a=e.gapTraversalInitialized===!0,l=Array.isArray(e.gapQueue)?e.gapQueue.slice():[],c=null,d=null;if(i&&o!==null){let u={kind:"server",beforeSeq:o,stopAtSeq:null,cacheEpoch:n};u.workKey=pn(u),r.has(u.workKey)?(i=!1,d="history_cursor_repeated"):c=u}return!c&&!i&&(a||(l=cu(t,e,n),a=!0),c=l[0]||null),c?{request:c,state:{...e,serverHasMore:i,gapTraversalInitialized:a,gapQueue:l,pendingPageKind:c.kind,pendingPageBeforeSeq:c.beforeSeq,pendingGapStopAtSeq:c.stopAtSeq,pendingCacheEpoch:c.cacheEpoch,pendingHistoryWorkKey:c.workKey,hasMore:!0,paginationError:null}}:{request:null,state:{...e,serverHasMore:i,gapTraversalInitialized:a,gapQueue:l,hasMore:!1,paginationError:d}}}function uu(e={},{mode:t,oldestSeq:s,hasMore:n,ranges:r=[],pageKind:i=null,stopAtSeq:o=null,cacheEpoch:a=0}={}){if(t==="delta")return e;let l=Nr(a),c=Zt(s),d=Zt(e.pendingPageBeforeSeq),u=i||e.pendingPageKind||(t==="older"?"server":null),p=Zt(o??e.pendingGapStopAtSeq),f=Nr(e.pendingCacheEpoch??l),g={kind:u,beforeSeq:d,stopAtSeq:p,cacheEpoch:f},v=Zt(e.serverOldestFetchedSeq??e.oldestSeq),m=e.serverHasMore!==!1,y=Number(e.noProgressCount)||0,h=null,w=e.requestedBeforeSeqs||[],S=e.completedHistoryWorkKeys||[],b=e.gapTraversalInitialized===!0,k=Array.isArray(e.gapQueue)?e.gapQueue.slice():[];if(t==="recent")v=c,m=!!n,y=0,w=[],S=[],b=!1,k=[];else if(d===null)c!==null&&(v=v===null?c:Math.min(v,c)),m=!!n,y=0;else{w=Dy(e,d),S=_y(e,g);let x=c!==null&&c<d;if(u==="server")x?(v=v===null?c:Math.min(v,c),m=!!n,y=0):(m=!1,y+=1,h="history_cursor_no_progress");else if(u==="gap"){let B=pn(g);k=k.filter(U=>pn(U)!==B);let D=p!==null&&c!==null&&c<=p;if(x||D||n===!1){if(y=0,!D&&n!==!1&&c!==null&&p!==null){let U={kind:"gap",beforeSeq:c,stopAtSeq:p,cacheEpoch:f};U.workKey=pn(U),Wr({completedHistoryWorkKeys:S}).has(U.workKey)||k.unshift(U)}}else y+=1,h="history_cursor_no_progress"}}t==="older"&&!m&&!b&&(k=cu(r,{...e,serverOldestFetchedSeq:v,completedHistoryWorkKeys:S},l),b=!0);let P={...e,serverOldestFetchedSeq:v,serverHasMore:m,requestedBeforeSeqs:w,completedHistoryWorkKeys:S,gapTraversalInitialized:b,gapQueue:k,noProgressCount:y,oldestSeq:v,paginationError:h};return delete P.pendingPageKind,delete P.pendingPageBeforeSeq,delete P.pendingGapStopAtSeq,delete P.pendingCacheEpoch,delete P.pendingHistoryWorkKey,{...P,hasMore:m||k.length>0}}var Za=W(()=>{});function hu(e){return e.filter(t=>!(t.type==="user"&&(!t.content||!t.content.trim())))}function fn(e){let t=typeof e=="string"?e.match(/^m(\d+)$/):null,s=t?Number(t[1]):null;return Number.isFinite(s)?s:null}function pu(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 $y(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 Ly(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 Oy(e,t){return e.speakerVpId||e.vpId||e.vp_id||e.authorVpId||e.authorVP||Ly(t)}function Vy(e){return e?.stableKey||(e&&(e.messageId||e.id)?e.messageId||e.id:null)}function qy(e,t=null){if(!e||e.stableKey)return e;let s=Hs(e),n=e.messageId||e.id||null,r=e.type==="user"&&e.clientMessageId||null;return e.stableKey=r&&n===r?qs(t,s,r):Dr(t,s,n),Number.isFinite(e.seq)||(e.seq=fn(n)),e.uiKey||(e.uiKey=e.stableKey||null),e}function Hs(e){return e?e.sessionId??e.groupId??null:null}function Fy(e){return!e||e.type!=="user"||!e.clientMessageId?!1:(e.messageId||e.id||null)===e.clientMessageId}function Hy(e,t,s,n){let r=e.rows(t),i=r.some(c=>c&&(n==null||Hs(c)===n));if(s.length===0&&i)return{insertedRows:0,preservedEmpty:!0};let o=s.reduce((c,d)=>Math.max(c,d?.timestamp||0),0),a=r.filter(c=>c?n!=null&&Hs(c)!==n||ct(c)||c.isStreaming||c.type==="tool-use"&&c.toolName==="AskUserQuestion"&&(c.askAnswered||c.askPending||c.askExpired)||Fy(c)?!0:o>0&&(c.timestamp||0)>o:!1);return e.replaceProjection(t,a),{insertedRows:e.commitDurable({conversationId:t,sessionId:n,rows:s,mode:"recent",preserveEmpty:!1}).insertedRows,preservedEmpty:!1}}function By(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 Ny(e,t){let s=typeof e.yeaftConversationId=="string"?e.yeaftConversationId:"";return s.startsWith(`yeaft-local-${t}-`)||/^yeaft-local-\d/.test(s)?s:null}function Wy(e,t,s,n){let r=t.agentId||s&&e.yeaftSessionAgentById?.[s]||null;if(!r||!n||e.currentView!=="yeaft")return;let i=Wt(e);if(i.sessionId!==(s||null)||i.agentId&&i.agentId!==r)return;let o=e.yeaftConversationId||null;if(Wn(e,r,n)){let d=e.yeaftConversationIdsByAgent?.[r]||null;d&&d!==n&&Xt(e,n,d,{removeSource:n!==e.yeaftConversationId});return}let a=Qt(e,r);a&&a.targetConversationId!==n&&Br(e,r,n);let l=Qt(e,r,n);if(l&&(Xt(e,l.sourceConversationId,n,{removeSource:!0}),Hr(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=Ny(e,r);c&&(Xt(e,c,n,{removeSource:!0}),e.yeaftConversationIdsByAgent={...e.yeaftConversationIdsByAgent||{},[r]:n},e.yeaftConversationId=n,e.activeConversations=[n])}function Bs(e,t,s=null){let n=e.messagesMap[t]||[];for(let r of n)s&&Object.entries(s).some(([i,o])=>o&&r[i]!==o)||r.type==="tool-use"&&!r.hasResult&&(r.hasResult=!0,r.toolName==="AskUserQuestion"&&!r.askAnswered&&!r.selectedAnswers&&(r.isHistory=!0,r.askExpired=!0,r.askPending=!1,r.pendingAnswers=null,r.askSubmittedAt=null,r.askError=null,r.askRequestId=null))}function mu(e,t){Yt(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 vu(e,t){Yt(e);let s=e.agents.find(n=>n.id===t.agentId);if(e.conversations=e.conversations.filter(n=>n.id!==t.conversationId&&!(n.claudeSessionId&&n.claudeSessionId===t.claudeSessionId&&n.agentId===t.agentId&&(n.provider||"claude-code")===(t.provider||"claude-code"))),e.conversations.push({id:t.conversationId,agentId:t.agentId,agentName:s?.name||t.agentId,workDir:t.workDir,claudeSessionId:t.claudeSessionId,createdAt:Date.now(),processing:!1,connecting:(t.provider||"claude-code")!=="claude-code",type:"chat",provider:t.provider||"claude-code",capabilities:t.capabilities||null,disallowedTools:t.disallowedTools??null}),e.currentAgent=t.agentId,e.currentAgentInfo=s,e.panels.length>1){let n=e._pendingPaneId;if(e._pendingPaneId=null,n){let r=e.panels.find(i=>i.id===n);r&&(r.conversationId=t.conversationId)}else{let r=e.panels.find(i=>!i.conversationId);r&&(r.conversationId=t.conversationId)}e.activeConversations.includes(t.conversationId)||e.activeConversations.push(t.conversationId)}else e.activeConversations=[t.conversationId];if(e.currentWorkDir=t.workDir,e.messagesMap[t.conversationId]=[],e._pendingSessionTitle&&(e.conversationTitles[t.conversationId]=e._pendingSessionTitle,e._pendingSessionTitle=null),e.sendWsMessage({type:"select_conversation",conversationId:t.conversationId}),e.addMessage({type:"system",content:Ee("store.convResumed",{agent:s?.name||t.agentId,sessionId:t.claudeSessionId?t.claudeSessionId.slice(0,8)+"...":""})}),t.dbMessages&&t.dbMessages.length>0){let n=hu(t.dbMessages.map(i=>e.formatDbMessage(i)).flat().filter(Boolean)),r=e.messagesMap[t.conversationId]||[];for(let i of n)r.push(i)}e.hasMoreMessages=!!t.hasMoreMessages,e.chatSessionState[t.conversationId]={lastSeenDbId:cn(e.messagesMap[t.conversationId]),hasMoreOlder:!!t.hasMoreMessages},e.saveOpenSessions()}function Ja(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],qe(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 yu(e,t){let s=t.conversationId;if(s){delete e.processingConversations[s],qe(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),Bs(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 bu(e,t){let s=t.conversationId;if(s){delete e.processingConversations[s],qe(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),Bs(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 wu(e,t){if(t.conversationId){if(t.isProcessing&&!dn(e,t.conversationId)&&!e._turnCompletedConvs?.has(t.conversationId))e.processingConversations[t.conversationId]=!0;else if(e.processingConversations[t.conversationId]){delete e.processingConversations[t.conversationId],qe(e,t.conversationId);let s=e.executionStatusMap[t.conversationId];s&&(s.currentTool=null),e.finishStreamingForConversation(t.conversationId)}}}function ku(e,t){let s=t.conversationId||e.currentConversation;if(s){delete e.processingConversations[s],qe(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),Bs(e,s)}}function Su(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=hu((t.messages||[]).map(a=>e.formatDbMessage(a)).flat().filter(Boolean));if(i.length>0){let a=n.find(l=>l.dbMessageId);if(a&&i[0].dbMessageId&&i[i.length-1].dbMessageId<a.dbMessageId){let l=n.indexOf(a);e.debug,n.splice(l,0,...i)}else{e.debug;for(let l of i)if(!(l.dbMessageId&&n.some(c=>c.dbMessageId===l.dbMessageId))){if(l.dbMessageId&&(l.type==="assistant"||l.type==="user")){let c=null;if(l.type==="user"?c=n.find(d=>!d.dbMessageId&&!d.isStreaming&&Xi(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),Yt(e);let o=e.chatSessionState[t.conversationId]?.hasMoreOlder;e.chatSessionState[t.conversationId]={lastSeenDbId:cn(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 Iu(e,t){let s=t.sessionId??null,n=t.agentId||s&&e.yeaftSessionAgentById?.[s]||null,r=t.conversationId||n&&e.yeaftConversationIdsByAgent?.[n]||e.yeaftConversationId;if(!r||!s||!Array.isArray(t.messages))return null;e.messagesMap[r]||(e.messagesMap[r]=[]);let i=new Set(Array.isArray(t.sourceMessageIds)?t.sourceMessageIds:[]),o=new Set,a=new Set;for(let y of e.messagesMap[r]){if(Hs(y)!==s)continue;let h=y?.persistedMessageId||y?.messageId||y?.id||null;h&&o.add(h),h&&(y?._historyWindowPrefetched===!0||y?._historyWindowDetached===!0)&&a.add(h),!(!t.entryId||!i.has(h))&&(y.historyEntryId=t.entryId,Number.isFinite(t.indexGeneration)&&(y.historyIndexGeneration=t.indexGeneration))}let l=t.messages.filter(y=>t.prefetch===!0||!o.has(y?.id)||a.has(y?.id)).map(y=>t.entryId&&i.has(y?.id)?{...y,historyEntryId:t.entryId,...t.prefetch===!0?{_historyWindowPrefetched:!0}:{},...Number.isFinite(t.indexGeneration)?{historyIndexGeneration:t.indexGeneration}:{}}:y),{formatted:c}=Cu(l,s,"window",e.messagesMap[r],n),d=`history-window:${t.requestId||t.anchorMessageId||Date.now()}`;for(let y of c)y._historyWindowKey=d,y._historyWindowDetached=t.prefetch!==!0,y._historyWindowPrefetched=t.prefetch===!0;let u=Gt(e),p=u.rows(r),f=new Set(t.messages.map(y=>y?.id).filter(Boolean)),g=[];if(t.prefetch!==!0){for(let h of p){if(Hs(h)!==s)continue;let w=h?.persistedMessageId||h?.messageId||h?.id||null;f.has(w)&&(h._historyWindowPrefetched!==!0&&h._historyWindowDetached!==!0||(h._historyWindowKey=d,h._historyWindowDetached=!0,h._historyWindowPrefetched=!1,g.push(h)))}let y=p.filter(h=>Hs(h)!==s||h._historyWindowDetached!==!0||h._historyWindowKey===d);y.length!==p.length&&u.replaceProjection(r,y)}u.commitDurable({conversationId:r,sessionId:s,rows:c,mode:"window"});let v=c.length>0?c:g,m=Wt(e);return Fa(e,{conversationId:r,agentId:n,sessionId:s,incomingRows:v,activeAgentId:m.agentId,activeSessionId:m.sessionId}),r}function fu(e){return e?.toolId?[Hs(e)??"",e.vpId||e.speakerVpId||"",e.turnId||"",e.threadId||"main",e.toolId].join("\0"):null}function gu(e,t,s){return e.toolName="AskUserQuestion",e.toolId=t.toolCallId,e.toolInput={questions:s},e.askQuestions=s,e.askRequestId=null,e.askPending=!1,e.pendingAnswers=null,e.askSubmitGeneration=null,e.askSubmittedAt=null,e.askError=null,e.hasResult=!0,e.isHistory=!0,t.status==="answered"?(e.askAnswered=!0,e.selectedAnswers=t.answers,e.askExpired=!1):(e.askAnswered=!1,e.selectedAnswers=null,e.askExpired=!0),e}function jy(e,t){return(e||[]).find(s=>s?.type==="tool-use"&&(s.toolName==="AskUser"||s.toolName==="AskUserQuestion")&&s.toolId===t.toolCallId&&Hs(s)===t.sessionId&&(s.vpId||s.speakerVpId||"")===(t.vpId||"")&&(s.turnId||"")===(t.turnId||"")&&(s.threadId||"main")===(t.threadId||"main"))||null}function Cu(e,t,s,n,r=null){let i=new Set((n||[]).map(c=>Vy(qy(c,r))).filter(Boolean)),o=new Set,a=[],l=0;for(let c of e){if(!c||c._reflection||c.internal||c.systemOnly||c.systemOnlyMessage||By(c.content))continue;let d=c.id||c.messageId||null,u=c.clientMessageId||null,p=c.sessionId??c.groupId??t??null,f=Dr(r,p,d),g=u?qs(r,p,u):f,v=c.historyEntryId?{historyEntryId:c.historyEntryId,...Number.isFinite(c.historyIndexGeneration)?{historyIndexGeneration:c.historyIndexGeneration}:{}}:{};if(!(f&&o.has(f))&&!(f&&s!=="recent"&&i.has(f))){if(f&&o.add(f),c.role==="user"){l+=1;let m=d||c.messageId||c.turnId||null;a.push({...d?{id:d,messageId:d}:{},...f?{stableKey:f}:{},...g?{uiKey:g}:{},...v,seq:Number.isFinite(c.seq)?c.seq:fn(d),type:"user",content:c.content,timestamp:pu(c),sessionId:p,turnId:c.turnId||m,...u?{clientMessageId:u}:{},...Array.isArray(c.attachments)&&c.attachments.length>0?{attachments:c.attachments}:{},...c.quote?{quote:c.quote}:{},isStreaming:!1,isHistory:!0})}else if(c.role==="assistant"){l+=1;let m=d||c.messageId||c.turnId||null,y=Oy(c,p),h=pu(c),w=!!c.turnId,S=c.turnId||m,b=typeof c.content=="string"?c.content:c.content||"",k=Array.isArray(c.todos)?c.todos:$y(c.toolCalls),P=c.executionOrigin==="route_forward"?{executionOrigin:"route_forward"}:{};(typeof b!="string"||b.trim())&&a.push({...d?{id:d,messageId:d}:{},...f?{stableKey:f}:{},...g?{uiKey:g}:{},...v,seq:Number.isFinite(c.seq)?c.seq:fn(d),...c.entryId?{entryId:c.entryId}:{},...Array.isArray(c.sourceMessageIds)?{sourceMessageIds:c.sourceMessageIds}:{},type:"assistant",content:b,timestamp:h,sessionId:p,turnId:S,_hasPersistedTurnId:w,...P,...y?{vpId:y,speakerVpId:y}:{},...c.responseKind==="progress"||c.responseKind==="result"?{responseKind:c.responseKind}:{},...Number.isInteger(c.llmCallCount)&&c.llmCallCount>0?{llmCallCount:c.llmCallCount}:{},...Number.isFinite(c.inputTokens)&&c.inputTokens>=0?{inputTokens:c.inputTokens}:{},...Number.isFinite(c.outputTokens)&&c.outputTokens>=0?{outputTokens:c.outputTokens}:{},...Number.isFinite(c.totalTokens)&&c.totalTokens>=0?{totalTokens:c.totalTokens}:{},...Number.isFinite(c.totalMs)&&c.totalMs>=0?{totalMs:c.totalMs}:{},...typeof c.model=="string"&&c.model?{model:c.model}:{},...typeof c.effort=="string"&&c.effort?{effort:c.effort}:{},...c.incomplete===!0?{incomplete:!0}:{},...typeof c.stopReason=="string"&&c.stopReason?{stopReason:c.stopReason}:{},isStreaming:!1,isHistory:!0}),Array.isArray(k)&&k.length>0&&a.push({...d?{id:`${d}:todos`,messageId:`${d}:todos`}:{},...f?{stableKey:`${f}:todos`}:{},...v,seq:Number.isFinite(c.seq)?c.seq:fn(d),type:"tool-use",toolName:"TodoWrite",toolInput:{todos:k},timestamp:h,startTime:h||0,sessionId:p,turnId:S,...P,...y?{vpId:y,speakerVpId:y}:{},isStreaming:!1,isHistory:!0,hasResult:!0});for(let[x,B]of(Array.isArray(c.toolCalls)?c.toolCalls:[]).entries()){if(!B||B.name==="TodoWrite")continue;let D=B.id||`index:${x}`,U=encodeURIComponent(String(D));a.push({...d?{id:`${d}:tool:${U}`,messageId:`${d}:tool:${U}`,persistedMessageId:d}:{},...f?{stableKey:`${f}:tool:${U}`}:{},...v,seq:Number.isFinite(c.seq)?c.seq:fn(d),type:"tool-use",toolId:B.id||null,toolName:B.name||"unknown",toolInput:B.input||{},timestamp:h,startTime:h||0,sessionId:p,turnId:S,...c.threadId?{threadId:c.threadId}:{},...P,...y?{vpId:y,speakerVpId:y}:{},isStreaming:!1,isHistory:!0,hasResult:!0})}for(let x of Array.isArray(c.images)?c.images:[])x?.assetId&&a.push({id:`${d||m||S}:image:${x.assetId}`,messageId:`${d||m||S}:image:${x.assetId}`,...f?{stableKey:`${f}:image:${x.assetId}`}:{},...v,seq:Number.isFinite(c.seq)?c.seq:fn(d),type:"chat-image",...x,timestamp:h,sessionId:p,turnId:S,...P,...y?{vpId:y,speakerVpId:y}:{},isStreaming:!1,isHistory:!0});for(let x of Array.isArray(c.askUserResults)?c.askUserResults:[]){if(!x?.toolCallId||x.status!=="answered"&&x.status!=="expired")continue;let B=[{question:typeof x.question=="string"?x.question:"",options:(Array.isArray(x.options)?x.options:[]).filter(R=>typeof R=="string").map(R=>({label:R,description:""})),multiSelect:!1}],D={toolCallId:x.toolCallId,sessionId:p,vpId:y||"",turnId:S||"",threadId:c.threadId||"main"},U=jy(n,D);if(U){Object.assign(U,v),gu(U,x,B);let R=a.findIndex(J=>J?.type==="tool-use"&&J.toolId===x.toolCallId&&(J.sessionId??J.groupId??null)===(U.sessionId??U.groupId??null)&&(J.turnId||"")===(U.turnId||""));R>=0&&a.splice(R,1);continue}let F=gu({id:`${d||m||S}:ask:${x.toolCallId}`,messageId:`${d||m||S}:ask:${x.toolCallId}`,...f?{stableKey:`${f}:ask:${x.toolCallId}`}:{},...v,seq:Number.isFinite(c.seq)?c.seq:fn(d),type:"tool-use",timestamp:h,sessionId:p,turnId:S,threadId:D.threadId,...P,...y?{vpId:y,speakerVpId:y}:{},isStreaming:!1},x,B),O=fu(F);(!O||!a.some(R=>fu(R)===O))&&a.push(F);let M=a.findIndex(R=>R!==F&&R?.type==="tool-use"&&R.toolId===x.toolCallId&&(R.sessionId??R.groupId??null)===(F.sessionId??F.groupId??null)&&(R.turnId||"")===(F.turnId||""));M>=0&&a.splice(M,1)}}}}return{formatted:a,acceptedHistoryMessages:l}}function Au(e,t){let s=t.sessionId!=null?t.sessionId:t.groupId,n=t.agentId||s&&e.yeaftSessionAgentById?.[s]||null;if(Wn(e,n,t.conversationId)){let T=e.yeaftConversationIdsByAgent?.[n]||null;if(!T||T===t.conversationId)return;Xt(e,t.conversationId,T,{removeSource:t.conversationId!==e.yeaftConversationId}),t={...t,conversationId:T}}if(t.requestId&&typeof e.isCurrentYeaftHistoryResponse=="function"&&!e.isCurrentYeaftHistoryResponse(t))return;let r=t.mode==="recent"||t.mode==="delta"?t.mode:"older",i=Array.isArray(t.messages)?t.messages:[],o=t.agentId||s&&e.yeaftSessionAgentById?.[s]||null,a=Pe(o,s),l=e.yeaftSessionHistoryState?.[a]||null;typeof t.streamId=="string"&&typeof l?.streamId=="string"&&(t.streamId!==l.streamId||Number.isFinite(t.revision)&&Number.isFinite(l.revision)&&t.revision!==l.revision)&&(r="recent",typeof e.clearYeaftHistoryMemory=="function"&&e.clearYeaftHistoryMemory({agentId:o,sessionId:s,preserveLiveRows:!0,preserveSessionOwner:!0})),t.perfTraceId&&vt(e,{traceId:t.perfTraceId,phase:"history.chunk_received",agentId:t.agentId||null,sessionId:s||null,messageType:t.type,bytes:(()=>{try{return JSON.stringify(t).length}catch{return null}})(),detail:{mode:r,rawCount:i.length}});let d=t.agentId||(s&&e.yeaftSessionAgentById?e.yeaftSessionAgentById[s]:null),u=d&&e.yeaftConversationIdsByAgent?e.yeaftConversationIdsByAgent[d]:null,p=t.conversationId||u||e.yeaftConversationId;if(!p){e.yeaftLoadingMoreHistory=!1;return}Wy(e,t,s,p),e.messagesMap[p]||(e.messagesMap[p]=[]);let{formatted:f,acceptedHistoryMessages:g}=Cu(i,s,r,e.messagesMap[p],d);Or(e,p,f);let v=Gt(e),m=0,y=!1;if(r==="recent"){let T=Hy(v,p,f,s??null);m=T.insertedRows,y=T.preservedEmpty}else if(f.length>0&&(m=v.commitDurable({conversationId:p,sessionId:s??null,rows:f,mode:r}).insertedRows,r==="older"&&typeof e.expandYeaftMessageWindow=="function")){let N=e.yeaftActiveSessionFilter?s??null:null;e.expandYeaftMessageWindow(N,t.turns||10,d)}let h=Wt(e);Fa(e,{conversationId:p,agentId:d,sessionId:s,incomingRows:f,activeAgentId:h.agentId,activeSessionId:h.sessionId});let w=Pe(t.agentId||null,s),S=e.yeaftHistoryCacheState?.[w]||null,b=e.yeaftSessionHistoryState?.[w]||{},k=Number.isFinite(b.serverOldestFetchedSeq)?b.serverOldestFetchedSeq:Number.isFinite(b.oldestSeq)?b.oldestSeq:null,P=Number.isFinite(t.nextBeforeSeq)?t.nextBeforeSeq:Number.isFinite(t.oldestSeq)?t.oldestSeq:y?k:null,x=y&&!Number.isFinite(t.nextBeforeSeq)&&!Number.isFinite(t.oldestSeq)?b.serverHasMore??b.hasMore??!1:t.hasMore,B=r==="delta"?b:uu(b,{mode:r,oldestSeq:P,hasMore:x,ranges:S?.ranges||[],pageKind:t.pageKind,stopAtSeq:t.gapStopAtSeq,cacheEpoch:S?.rangeEpoch??t.cacheEpoch??0}),D=typeof t.latestSeq=="number"?t.latestSeq:b.latestSeq??null,U={streamId:typeof t.streamId=="string"?t.streamId:b.streamId??null,revision:Number.isFinite(t.revision)?t.revision:b.revision??null},F=r==="delta"?{...b,...U,loaded:!0,loading:!1,latestSeq:D,syncingAfterSeq:null,count:(b.count||0)+m}:{...B,...U,loaded:!0,loading:!1,count:S?S.rowCount:r==="older"?(b.count||0)+m:y?b.count||0:g,latestSeq:y&&!Number.isFinite(t.latestSeq)?b.latestSeq??null:D,syncingAfterSeq:null};t.requestId&&typeof e.finishYeaftHistoryLoad=="function"?e.finishYeaftHistoryLoad(t,F,"chunk"):e.yeaftSessionHistoryState&&(e.yeaftSessionHistoryState={...e.yeaftSessionHistoryState,[w]:F}),r==="delta"&&t.hasMoreAfter===!0&&Number.isFinite(F.latestSeq)&&F.latestSeq>Number(t.afterSeq??-1)&&typeof e.continueYeaftHistoryDelta=="function"&&queueMicrotask(()=>e.continueYeaftHistoryDelta(s,d,F.latestSeq));let O=Wt(e),M=O.sessionId===(s||null),R=!t.agentId||!O.agentId||t.agentId===O.agentId,J=M&&R,V=Pe(null,O.sessionId);if(t.perfTraceId&&(vt(e,{traceId:t.perfTraceId,phase:"history.chunk_applied",agentId:t.agentId||null,sessionId:s||null,messageType:t.type,detail:{mode:r,formattedCount:f.length,insertedRows:m,acceptedHistoryMessages:g,preservedEmptyRecent:y}}),Zi(e,{traceId:t.perfTraceId,phase:"history.next_paint",agentId:t.agentId||null,sessionId:s||null,messageType:t.type,detail:{mode:r,insertedRows:m}})),J)e.yeaftHasMoreHistory=F.hasMore,e.yeaftOldestLoadedSeq=Number.isFinite(F.serverOldestFetchedSeq)?F.serverOldestFetchedSeq:Number.isFinite(F.oldestSeq)?F.oldestSeq:e.yeaftOldestLoadedSeq,e.yeaftLoadingMoreHistory=!1;else if(e.yeaftLoadingMoreHistory){let T=e.yeaftSessionHistoryState?.[O.sessionKey]||e.yeaftSessionHistoryState?.[V]||null;e.yeaftLoadingMoreHistory=!!T?.loading}}var Ji=W(()=>{Fs();Ya();Yi();an();Ga();Vr();zt();Xa();Bi();Vn();Wi();Za();$r()});function xu(e,t,s=null){if(!s)return!1;if(e.promoteYeaftHistoryOutlineRow?.(t,s))return!0;let n=t?.sessionId??t?.groupId??e._currentYeaftSessionId??null;return n?!!e.invalidateYeaftHistoryOutline?.(n,s):!1}function Uy(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 el(e,t){return e.executionStatusMap[t]||(e.executionStatusMap[t]={currentTool:null,toolHistory:[],lastActivity:null}),e.executionStatusMap[t]}function Tu(e,t,s,n=null){if(!t)return;let r=el(e,t);if(r.lastActivity=Date.now(),zi(e,t),s.type==="system"){if(s.subtype==="init"){let i=e.conversations.find(o=>o.id===t);i&&i.connecting&&(i.connecting=!1);return}s.message&&e.addMessageToConversation(t,{type:"system",content:typeof s.message=="string"?s.message:JSON.stringify(s.message,null,2)});return}if(s.type==="assistant"){let i=s.message?.content;if(!i)return;let o=e.messagesMap[t]||[];for(let a of o)a.type==="tool-use"&&!a.hasResult&&(a.hasResult=!0);for(let a of r.toolHistory)a.status==="running"&&(a.status="done");if(r.currentTool=null,typeof i=="string"){e.appendToAssistantMessageForConversation(t,i,{id:s.message?.id||s.message?.messageId||null,ts:s.ts||s.message?.ts||s.message?.time||null,sessionId:e._currentYeaftSessionId||null,vpId:e._currentYeaftVpId||null,turnId:e._currentYeaftTurnId||null,threadId:e._currentYeaftThreadId||null});return}if(!Array.isArray(i))return;if(i.length===0){e.finishStreamingForConversation(t);return}for(let a of i)a.type==="text"?e.appendToAssistantMessageForConversation(t,a.text,{id:s.message?.id||s.message?.messageId||null,ts:s.ts||s.message?.ts||s.message?.time||null,sessionId:e._currentYeaftSessionId||null,vpId:e._currentYeaftVpId||null,turnId:e._currentYeaftTurnId||null,threadId:e._currentYeaftThreadId||null}):a.type==="image_asset"&&a.image?e.addMessageToConversation(t,{type:"chat-image",...a.image,sessionId:e._currentYeaftSessionId||null,vpId:e._currentYeaftVpId||null,speakerVpId:e._currentYeaftVpId||null,turnId:e._currentYeaftTurnId||null,threadId:e._currentYeaftThreadId||null}):a.type==="tool_use"&&(e.finishStreamingForConversation(t,{completeLifecycle:!1}),r.currentTool={name:a.name,input:a.input,startTime:Date.now()},r.toolHistory.unshift({name:a.name,input:a.input,timestamp:Date.now(),status:"running"}),r.toolHistory.length>20&&r.toolHistory.pop(),e.addMessageToConversation(t,{type:"tool-use",toolId:a.id||a.tool_use_id||null,toolName:a.name,toolInput:a.input,startTime:Date.now(),isHistory:a.history===!0||s.history===!0||s.isHistory===!0,sessionId:e._currentYeaftSessionId||null,vpId:e._currentYeaftVpId||null,turnId:e._currentYeaftTurnId||null,threadId:e._currentYeaftThreadId||null}))}else if(s.type==="user"){let i=s.internal===!0||s.message?.internal===!0||s.userAuthored===!1||s.message?.userAuthored===!1,o=s.message?.content,a=Uy(o);if(typeof a=="string"&&(a.includes("<local-command-caveat>")||a.includes("<command-name>")))return;if(typeof a=="string"&&a.includes("<local-command-stdout>")){let c=a.match(/<local-command-stdout>([\s\S]*?)<\/local-command-stdout>/);if(c){e.appendToAssistantMessageForConversation(t,c[1].trim()),e.finishStreamingForConversation(t);return}}let l=[];if(s.tool_use_result)l=Array.isArray(s.tool_use_result)?s.tool_use_result:[s.tool_use_result];else if(s.message?.content){let c=s.message.content;l=(Array.isArray(c)?c:[]).filter(u=>u.type==="tool_result")}if(l.length>0){let c=e.messagesMap[t]||[];for(let d of l){if(r.toolHistory.length>0){let g=r.toolHistory.findIndex(v=>v.status==="running");g>=0&&(r.toolHistory[g].status="done")}let u=d.tool_use_id||d.toolUseId||d.tool_call_id||d.toolCallId||null,p=d.content||d,f=!1;if(u){for(let g=c.length-1;g>=0;g--)if(c[g].type==="tool-use"&&c[g].toolId===u){c[g].hasResult=!0,c[g].toolResult=d.is_update&&c[g].toolResult?`${c[g].toolResult}
|
|
1
|
+
var W=(e,t,s)=>()=>{if(s)throw s[0];try{return e&&(t=e(e=0)),t}catch(n){throw s=[n],n}};var Uv=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(s){throw t=0,s}};function rd(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 id(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 od(e){return e&&typeof e=="object"&&typeof e.n=="string"&&typeof e.c=="string"}function Bt(e){return nacl.util.decodeBase64(e)}var $i=W(()=>{});function gs(){return globalThis.localStorage||null}function ld(){let e=Oi();for(let t of Ia)try{t(e)}catch{}}function Kv(){try{gs()?.removeItem(kr),gs()?.removeItem(Sr)}catch{}}function zv(e){return String(e||"").trim()||null}function ad(e,t){if(!Ir(t))return{};try{let s=JSON.parse(gs()?.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)?(gs()?.removeItem(e),{}):s.records}catch{try{gs()?.removeItem(e)}catch{}return{}}}function cd(e,t,s){if(!Ir(s))return!1;try{return gs()?.setItem(e,JSON.stringify({ownerId:s.ownerId,records:t||{}})),!0}catch{return!1}}function Nt(e){let t=zv(e);if(!t)return Ca(),null;if(nn!==t){nn=t,Li+=1;for(let s of[kr,Sr])try{let n=JSON.parse(gs()?.getItem(s)||"null");(!n||n.ownerId!==t)&&gs()?.removeItem(s)}catch{try{gs()?.removeItem(s)}catch{}}ld()}return Oi()}function Ca(){nn=null,Li+=1,Kv(),ld()}function Oi(){return nn?{ownerId:nn,epoch:Li}:null}function Ir(e){return!!e&&!!nn&&e.ownerId===nn&&e.epoch===Li}function dd(e){return{drafts:ad(kr,e),outbox:ad(Sr,e)}}function Aa(e,t){return cd(kr,e,t)}function Cr(e,t){return cd(Sr,e,t)}function ud(e){return typeof e!="function"?()=>{}:(Ia.add(e),()=>Ia.delete(e))}var kr,Sr,nn,Li,Ia,VS,xa=W(()=>{kr="yeaft-work-center-composer-drafts-v1",Sr="yeaft-work-center-message-outbox-v1",nn=null,Li=0,Ia=new Set;VS=Object.freeze({drafts:kr,outbox:Sr})});function Ta(){try{globalThis.Pinia?.useChatStore?.()?.clearYeaftHistoryMemory?.()}catch{}}function hs(e){let t=String(e||"").trim()||null;Vi!==t&&Ta(),Vi=t}function Gv(){Ta(),Vi=null}var Yv,Vi,Qv,je,Lt=W(()=>{$i();xa();({defineStore:Yv}=Pinia);Vi=null;Qv=1800*1e3,je=Yv("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",Nt(this.userId),hs(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?Bt(n.sessionKey):null,this.role=n.role||"pro",this.userId=n.userId||null,Nt(this.userId),hs(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?Bt(r.sessionKey):null,this.role=r.role||"pro",this.userId=r.userId||null,Nt(this.userId),hs(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?Bt(s.sessionKey):null,this.role=s.role||"pro",this.userId=s.userId||null,Nt(this.userId),hs(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?Bt(s.sessionKey):null,this.role=s.role||"pro",this.userId=s.userId||null,Nt(this.userId),hs(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?Bt(s.sessionKey):null,this.role=s.role||"pro",this.userId=s.userId||null,Nt(this.userId),hs(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?Bt(n.sessionKey):null,this.role=n.role||"pro",this.userId=n.userId||null,Nt(this.userId),hs(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?Bt(r):null,this.role=i||"pro",this.userId=o||null,Nt(this.userId),hs(this.userId),this.authGeneration+=1,this.isAuthenticated=!0,this.loginStep="authenticated",localStorage.setItem("authToken",n),this.startSessionRefresh();try{history.replaceState(null,"",window.location.pathname+window.location.search)}catch{}return!0},async loadIdentities(){if(this.isAuthenticated){this.identitiesLoading=!0,this.identitiesError=null;try{let e=await fetch("/api/auth/identities"),t=await e.json();if(!e.ok||!t.success){this.identitiesError=t.error||"Failed to load identities";return}this.linkedIdentities=t.identities||[],this.hasPassword=!!t.hasPassword}catch(e){this.identitiesError=e.message||"Network error"}finally{this.identitiesLoading=!1}}},async unbindIdentity(e){if(!this.isAuthenticated)return!1;this.identitiesError=null;try{let t=await fetch(`/api/auth/identities/${encodeURIComponent(e)}`,{method:"DELETE"}),s=await t.json();return!t.ok||!s.success?(this.identitiesError=s.error||"Failed to unbind",!1):(this.linkedIdentities=this.linkedIdentities.filter(n=>n.provider!==e),!0)}catch(t){return this.identitiesError=t.message||"Network error",!1}},async refreshSession(){let e=this.token,t=this.authGeneration,s=this.isAuthenticated;try{let n=await fetch("/api/user/profile",{headers:e?{Authorization:`Bearer ${e}`}:{}});if(this.handleAuthResponse(n,e,t,s)||!n.ok)return!1;let r=await n.json().catch(()=>({}));if(t!==this.authGeneration||this.token!==e)return this.isAuthenticated;let i=n.headers?.get?.("X-New-Token"),o=localStorage.getItem("authToken");i&&this.token===e&&(!o||o===e)&&(this.token=i,localStorage.setItem("authToken",i)),r?.role&&(this.role=r.role);let a=this.userId;return this.userId=r?.userId||null,Nt(this.userId),a!==this.userId&&Ta(),Vi=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,Qv),this._sessionRefreshVisibilityHandler=e,typeof document<"u"&&document.addEventListener("visibilitychange",e),typeof window<"u"&&window.addEventListener("pageshow",e)},stopSessionRefresh(){this._sessionRefreshTimer&&(clearInterval(this._sessionRefreshTimer),this._sessionRefreshTimer=null),this._sessionRefreshVisibilityHandler&&(typeof document<"u"&&document.removeEventListener("visibilitychange",this._sessionRefreshVisibilityHandler),typeof window<"u"&&window.removeEventListener("pageshow",this._sessionRefreshVisibilityHandler),this._sessionRefreshVisibilityHandler=null)},async logout(){try{let e={"Content-Type":"application/json"};this.token&&(e.Authorization=`Bearer ${this.token}`),await fetch("/api/auth/logout",{method:"POST",headers:e})}catch{}await this.clearStoredSession()},clearStoredSession(e=null){let t=this.reset();return localStorage.removeItem("authToken"),e&&(this.error=e),t},getActiveToken(){if(this.token)return this.token;let e=localStorage.getItem("authToken");return e&&(this.token=e),this.token},handleAuthResponse(e,t=null,s=this.authGeneration,n=this.isAuthenticated,r=void 0){if(!e||e.status!==401||!n||s!==this.authGeneration)return!1;let i=this.token||localStorage.getItem("authToken")||null;return t!==i?!1:(this.handleAuthFailure(r,t,s),!0)},handleAuthFailure(e="Session expired. Please log in again.",t=null,s=this.authGeneration){if(s!==this.authGeneration)return!1;let n=this.token||localStorage.getItem("authToken")||null;return t!==n||this.clearStoredSession(e),!1},async restoreSession(){let e=localStorage.getItem("authToken"),t=this.authGeneration,s=this.isAuthenticated||!!e;try{let n=await fetch("/api/user/profile",{headers:e?{Authorization:`Bearer ${e}`}:{}});if(this.handleAuthResponse(n,e,t,s))return!1;if(!n.ok)return this.error="Failed to restore session",!1;let r=await n.json();if(t!==this.authGeneration)return this.isAuthenticated;let i=n.headers?.get?.("X-New-Token"),o=this.getActiveToken();if(o!==e)return this.isAuthenticated;let a=i&&(!o||o===e)?i:o||e;return this.token=a,a&&a!==e&&localStorage.setItem("authToken",a),this.role=r?.role||"pro",this.userId=r?.userId||null,Nt(this.userId),hs(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=Bt(e))},backToCredentials(){this.loginStep="credentials",this.tempToken=null,this.emailHint=null,this.setupToken=null,this.totpSecret=null,this.qrCode=null,this.error=null},async requestPasswordReset(e){this.error=null;try{let s=await(await fetch("/api/auth/password-reset/request",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e})})).json();return s.success?s.resetToken||null:(this.error=s.error||"Failed to request password reset",null)}catch(t){return this.error=t.message||"Network error",null}},async verifyPasswordReset(e,t,s){this.error=null;try{let r=await(await fetch("/api/auth/password-reset/verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({resetToken:e,code:t,newPassword:s})})).json();return r.success?!0:(this.error=r.error||"Failed to reset password",!1)}catch(n){return this.error=n.message||"Network error",!1}},async deleteAccount({currentPassword:e,confirm:t}={}){if(!this.isAuthenticated)return{success:!1,error:"Not authenticated"};try{let s=await fetch("/api/user/me",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({currentPassword:e,confirm:t})}),n=await s.json();return!s.ok||!n.success?{success:!1,error:n.error||"Failed to delete account"}:(await this.clearStoredSession(),{success:!0})}catch(s){return{success:!1,error:s.message||"Network error"}}},reset(){Ca(),Gv(),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=ms?.value||"zh-CN",r=($n[s]||$n["zh-CN"]||{})[e];if(r===void 0&&s!=="zh-CN"&&(r=($n["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 Xv(){return ms?.value||"zh-CN"}function Ar(e){$n[e]&&(ms&&(ms.value=e),localStorage.setItem("locale",e),document.documentElement.setAttribute("lang",e))}function Zv(){let e=localStorage.getItem("locale");return e&&$n[e]?e:(navigator.language||navigator.userLanguage||"").startsWith("en")?"en":"zh-CN"}function pd(e,t){return $n=t,ms=Vue.ref(Zv()),document.documentElement.setAttribute("lang",ms.value),e.config.globalProperties.$t=Ee,e.config.globalProperties.$locale=ms,e.provide("t",Ee),e.provide("locale",ms),{t:Ee,setLocale:Ar,getLocale:Xv,locale:ms}}var ms,$n,zt=W(()=>{ms=null,$n={}});function Ln(e){return e?.capabilityMetadataProvided!==!0?!0:Array.isArray(e.capabilities)&&e.capabilities.includes(Ma)}var Ma,qi=W(()=>{Ma="yeaft_plugins"});function Fi(e){if(e?.capabilityMetadataProvided!==!0)return!1;let t=Array.isArray(e.capabilities)?e.capabilities:[];return t.includes(Ma)&&t.includes(Jv)}var Jv,Pa=W(()=>{qi();Jv="yeaft_managed_skills"});function rn(e){if(e==null||e==="")return"claude-code";if(ey.has(e))return e;throw new Error(`Unknown Chat runtime provider: ${e}`)}function Vs(e){if(typeof e!="string"||!e)throw new Error("Chat catalog key requires conversationId");return`chat:${e}`}function xr(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 Tr(e,t,s={}){let n=e.sessionCatalog.map(i=>({...i})),r=Array.isArray(e.hiddenSessionCatalog)?e.hiddenSessionCatalog.map(i=>({...i})):null;return e.sessionCatalogMutationRequests[t]={previousCatalog:n,previousHiddenCatalog:r,...s},n}function fd(e,t){let s=t?.requestId?e.sessionCatalogMutationRequests[t.requestId]:null;return s?(delete e.sessionCatalogMutationRequests[t.requestId],t.ok!==!0&&(e.sessionCatalog=s.previousCatalog,Array.isArray(s.previousHiddenCatalog)&&(e.hiddenSessionCatalog=s.previousHiddenCatalog)),!0):!1}function gd(e,t,s="recent",n=null){let r=Vs(t),i=e.chatHistoryRequests[r]||{},o=Number(i.generation||0)+1,a=`chat_history_${o}_${crypto.randomUUID()}`;return e.chatHistoryRequests[r]={requestId:a,catalogKey:r,generation:o,mode:s,cursor:n,connectionGeneration:Number(e.chatHistoryConnectionGeneration||0),loading:!0,cancelled:!1,error:null},a}function Ra(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 ey,Hi=W(()=>{ey=new Set(["claude-code","copilot"])});function On(e,t,s=""){Mr&&(clearTimeout(Mr),Mr=null),e.sessionLoading=t,e.sessionLoadingText=s,t&&(Mr=setTimeout(()=>{e.sessionLoading&&(e.sessionLoading=!1,e.sessionLoadingText=""),Mr=null},ty))}function Yt(e){On(e,!1)}function hd(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:rn(t.provider),catalogKey:t.catalogKey||null},e.recoveryDismissed=!1)}}function md(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:rn(r)}),e.pendingRecovery=null,e.recoveryDismissed=!1},500)}function vd(e){e.recoveryDismissed=!0,e.pendingRecovery=null}function yd(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]=[],On(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 bd(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 on(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=rn(t.provider),n={sessionId:t.claudeSessionId,workDir:t.workDir,agentId:t.agentId||e.currentAgent,provider:s,catalogKey:Vs(t.id),version:2};localStorage.setItem("lastUsedSession",JSON.stringify(n)),localStorage.setItem("lastViewedSessionRef",JSON.stringify(n)),e.lastUsedSession=n}}e.lastUsedAgent=e.currentAgent,e.panels.length>0?localStorage.setItem("panels",JSON.stringify(e.panels)):localStorage.removeItem("panels")}}function wd(e){return e.lastUsedSession}function kd(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 Sd(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 Id(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 Cd(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 Ad(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 xd(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 Td(e,t=20){if(je().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 Md(e,t){if(!je().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 _a(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 Pd(e,t){let s=_a(e,t);return s&&s.online}var ty,Mr,an=W(()=>{Lt();zt();Hi();ty=3e4,Mr=null});function Rd(){typeof window>"u"||typeof window.dispatchEvent!="function"||typeof CustomEvent>"u"||window.dispatchEvent(new CustomEvent("browser-runtime-transport-reset"))}function _d(e){return e?.code===1008&&String(e.reason||"").toLowerCase().includes("authentication")}function Dd(e){let t=Pr;Pr=[];for(let{resolve:s,reject:n,timer:r}of t)clearTimeout(r),e?s():n(new Error("WebSocket reconnect failed"))}function Ed(e,t){if(!e.ws||e.ws.readyState!==WebSocket.OPEN)return!1;if(e.currentView==="yeaft"&&ny.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=rd(t,e.sessionKey);e.ws.send(JSON.stringify(s))}else e.ws.send(JSON.stringify(t));return!0}catch{return!1}}function Rr(e,t=1e4){return e.ws&&e.ws.readyState===WebSocket.OPEN?Promise.resolve():new Promise((s,n)=>{let r=setTimeout(()=>{Pr=Pr.filter(i=>i.resolve!==s),n(new Error("WebSocket reconnect timeout"))},t);Pr.push({resolve:s,reject:n,timer:r}),(!e.ws||e.ws.readyState!==WebSocket.CONNECTING)&&(e.reconnectAttempts=0,e.connect())})}function $d(e,t){try{let s=JSON.parse(t);return e.sessionKey&&od(s)?id(s,e.sessionKey):s}catch{return null}}function Ld(e){let t=je(),s=location.protocol==="https:"?"wss:":"ws:";e.reconnectTimer&&(clearTimeout(e.reconnectTimer),e.reconnectTimer=null);let n=t.getActiveToken?.()||t.token||null,r=t.authGeneration;if(e.ws&&e.ws.readyState===WebSocket.CONNECTING&&e._wsAuthToken===n&&e._wsAuthGeneration===r)return;clearTimeout(e._legacyYeaftSessionHydrateTimer),e._legacyYeaftSessionHydrateTimer=null,e._hasHandledAgentList=!1,e._hasHandledYeaftSessionHydrate=!1,e.yeaftSessionInventoryCompleteSupported=null,e.workbenchRouteProtocolSupported=null,e.browserRuntimeProtocolSupported=null,e.browserRuntimeSetupProtocolSupported=null,e.browserRuntimeServerEnabled=!1,Rd(),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,Array.isArray(i[0].previousHiddenCatalog)&&(e.hiddenSessionCatalog=i[0].previousHiddenCatalog),e.sessionCatalogMutationRequests={}),e.sessionCatalogLoaded=!1,e.sessionCatalog=[],e.hiddenSessionCatalog=[],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,workbenchRouteProtocol:1,browserRuntimeProtocol:1,browserRuntimeSetupProtocol:1}))}catch{}Dd(!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){_d(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.workbenchRouteProtocolSupported=null,e.browserRuntimeProtocolSupported=null,e.browserRuntimeSetupProtocolSupported=null,e.browserRuntimeServerEnabled=!1,Rd(),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(),Yt(e),_d(l)){t.handleAuthFailure?.(void 0,n,r),e.reconnectAttempts=0,Dd(!1);return}if(e._yeaftReconnectCatchUpPending=!0,c){e.reconnectAttempts=0,e.reconnectTimer=setTimeout(()=>{e.connect()},2e3);return}e.scheduleReconnect()},e.ws.onerror=l=>{}}function Od(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 Vd(e){e.reconnectAttempts=0,e.connect()}function qd(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 Fd(e){e.heartbeatTimer&&(clearInterval(e.heartbeatTimer),e.heartbeatTimer=null)}function Hd(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 Pr,ny,Da=W(()=>{Lt();$i();an();Pr=[];ny=new Set(["sync_messages","refresh_conversation","select_conversation","cancel_execution","update_conversation_settings","ask_user_answer"])});function Pe(e,t){let s=t==null?"__all__":String(t);return e?`${e}${s}`:s}function _r(e){return typeof e?.entryId=="string"&&e.entryId?`entry:${e.entryId}`:e?.role==="assistant"&&e?.turnId?`live-response:${e.turnId}:${e.speakerVpId||e.vpId||""}`:typeof e?.clientMessageId=="string"&&e.clientMessageId?`client:${e.clientMessageId}`:`message:${e?.messageId||""}`}function Dr(e,t,s){return typeof s!="string"||!s?null:`${Pe(e,t)}message:${s}`}function qs(e,t,s){return typeof s!="string"||!s?null:`${Pe(e,t)}client:${s}`}var Vn=W(()=>{});function Ea(e){return typeof e=="string"&&e?e:null}function qn(e,t){return e?.yeaftSessionHistoryState?.[t]||null}function Wt(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 Nd(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=qn(e,o)||{},l=Number(a.generation||0)+1,c=`yeaft_history_${l}_${crypto.randomUUID()}`,d={...a,loaded:!!a.loaded,loading:!0,error:null,requestId:c,generation:l,mode:n,background:n==="prefetch",requestedAt:Date.now(),latestSeq:Number.isFinite(i)?i:a.latestSeq??null};return delete d.completionSeen,r||(d.syncingAfterSeq=null,a.loaded||(d.hasMore=!1,d.oldestSeq=null,d.serverOldestFetchedSeq=null,d.serverHasMore=!1,d.gapQueue=[],d.requestedBeforeSeqs=[],d.count=0)),e.yeaftSessionHistoryState={...e.yeaftSessionHistoryState||{},[o]:d},ln(e),{sessionKey:o,requestId:c,generation:l,state:d}}function $a(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=qn(e,r),o=Ea(t.requestId);if(!i)return o===null;let a=Ea(i.requestId);return o?o===a:a===null}function Wd(e,t={},s={},n="chunk"){if(!$a(e,t))return null;let r=t.sessionId??t.groupId??null,i=t.agentId||e?.yeaftSessionAgentById?.[r]||null,o=Pe(i,r),a=qn(e,o)||{},l=Ea(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},ln(e),d}function Er(e,{agentId:t,sessionId:s,requestId:n,error:r="history_load_failed"}={}){if(!t||!s||!n)return!1;let i=Pe(t,s),o=qn(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()}},ln(e),!0)}function ln(e){let{sessionKey:t}=Wt(e),s=t?qn(e,t):null;return e.yeaftLoadingMoreHistory=!!s?.loading&&s?.mode!=="prefetch",e.yeaftHistoryLoadError=s?.error||null,e.yeaftHasMoreHistory=!!s?.hasMore,e.yeaftOldestLoadedSeq=Number.isFinite(s?.serverOldestFetchedSeq)?s.serverOldestFetchedSeq:Number.isFinite(s?.oldestSeq)?s.oldestSeq:null,s}function La(e){let{sessionKey:t}=Wt(e);return t?qn(e,t):null}var Bd,Bi=W(()=>{Vn();Bd=15e3});function Oa(e){return e?.sessionId??e?.groupId??null}function qa(e){for(let t of[e?.persistedMessageId,e?.messageId,e?.id]){if(typeof t!="string")continue;let s=t.match(/^(m\d+)/);if(s)return s[1]}return null}function ct(e){return e?.isStreaming||e?.status==="pending"?!1:Number.isFinite(e?.seq)||!!qa(e)||e?.isHistory===!0&&!e?.clientMessageId}function Ni(e){if(Number.isFinite(e?.seq))return Number(e.seq);let s=qa(e)?.match(/^m(\d+)$/);if(s)return Number(s[1]);let n=typeof e?.id=="string"?e.id.match(/^(\d+)/):null;return n?Number(n[1]):null}function iy(e){try{return new TextEncoder().encode(JSON.stringify(e)).length}catch{return 0}}function oy(e){return e?e.isStreaming||e.status==="pending"||e.type==="tool-use"&&(e.askPending||!e.hasResult&&(e.toolName==="AskUser"||e.toolName==="AskUserQuestion"))?!0:e.type!=="user"||!e.clientMessageId?!1:!e.dbMessageId&&!qa(e):!1}function ay(e){let t=[],s=null;for(let n of e)(n?.type==="user"||!s)&&(s={rows:[],protected:!1},t.push(s)),s.rows.push(n),oy(n)&&(s.protected=!0);return t}function Ud(e,{conversationId:t,agentId:s=null,sessionId:n=null,limits:r=jd}={}){let i=e?.messagesMap?.[t];if(!Array.isArray(i)||i.length===0||!s||!n)return{evictedRows:0,keptRows:0};let o=b=>Oa(b)===n,a=i.filter(o),l=ay(a);if(l.length===0)return{evictedRows:0,keptRows:0};let c=l.filter(b=>b.protected),d=new Set(c),u=Number.isFinite(r.maxTurnsPerSession)?Math.max(0,Math.floor(r.maxTurnsPerSession)):Va,p=Math.max(0,u-c.length);for(let b=l.length-1;b>=0&&p>0;b-=1){let k=l[b];d.has(k)||(d.add(k),p-=1)}let f=new Set(l.filter(b=>d.has(b)).flatMap(b=>b.rows)),g=a.filter(b=>!f.has(b));if(g.length===0)return{evictedRows:0,keptRows:f.size};let v=i.filter(b=>!o(b)||f.has(b));i.splice(0,i.length,...v);let m=Pe(s,n),y=e.yeaftHistoryCacheState?.[m]||null,h=Kd(a.filter(b=>f.has(b))),S=JSON.stringify(y?.ranges||[])===JSON.stringify(h.ranges)?Number(y?.rangeEpoch)||0:(Number(y?.rangeEpoch)||0)+1;if(e.yeaftHistoryCacheState={...e.yeaftHistoryCacheState||{},[m]:{...y||{},agentId:s,sessionId:n,conversationId:t,lastAccessed:Date.now(),rangeEpoch:S,...h}},g.some(ct)){let b=h.ranges[0]?.startSeq??null,k=e.yeaftSessionHistoryState?.[m]||{};e.yeaftSessionHistoryState={...e.yeaftSessionHistoryState||{},[m]:{...k,serverOldestFetchedSeq:b,oldestSeq:b,serverHasMore:b!==null,hasMore:b!==null,gapTraversalInitialized:!1,gapQueue:[],requestedBeforeSeqs:[],completedHistoryWorkKeys:[],pendingPageKind:null,pendingPageBeforeSeq:null,pendingGapStopAtSeq:null,pendingCacheEpoch:null,pendingHistoryWorkKey:null,paginationError:null,count:h.rowCount}};let P=Wt(e);P.agentId===s&&P.sessionId===n&&ln(e)}return{evictedRows:g.length,keptRows:f.size}}function ly(e){let t=[],s=null;for(let n of e)ct(n)&&((n?.type==="user"||!s)&&(s=[],t.push(s)),s.push(n));return t}function cy(e,t){let s=Number.isFinite(t.maxTurnsPerSession)?Math.max(0,Math.floor(t.maxTurnsPerSession)):Va,n=ly(e),r=new Set(n.slice(-s).flat());for(let i of n)if(i.some(o=>o?._historyWindowDetached===!0))for(let o of i)r.add(o);return r}function dy(e){let t=Array.from(new Set(e.map(Ni).filter(Number.isFinite))).sort((n,r)=>n-r),s=[];for(let n of t){let r=s.at(-1);r&&n<=r.endSeq+1?r.endSeq=n:s.push({startSeq:n,endSeq:n})}return s}function Kd(e){let t=e.filter(ct);return{rowCount:t.length,byteCount:t.reduce((s,n)=>s+iy(n),0),ranges:dy(t)}}function uy(e,t,s){let n=new Set((t||[]).map(r=>r?.stableKey).filter(Boolean));if(n.size!==0)for(let r of e)r?.stableKey&&n.has(r.stableKey)&&(r._historyCacheTouchedAt=s)}function py(e,{conversationId:t,agentId:s,sessionId:n,incomingRows:r,now:i,limits:o}){let a=e.messagesMap?.[t]||[],l=a.filter(h=>Oa(h)===n);uy(l,r,i);let c=cy(l,o),d=l.filter(h=>!ct(h)||c.has(h)),u=new Set(d),p=a.filter(h=>Oa(h)!==n||u.has(h));a.splice(0,a.length,...p);let f=Kd(d),g=Pe(s,n),v=e.yeaftHistoryCacheState?.[g]||null,y=JSON.stringify(v?.ranges||[])===JSON.stringify(f.ranges)?Number(v?.rangeEpoch)||0:(Number(v?.rangeEpoch)||0)+1;e.yeaftHistoryCacheState={...e.yeaftHistoryCacheState||{},[g]:{agentId:s,sessionId:n,conversationId:t,lastAccessed:i,rangeEpoch:y,...f}}}function zd(e,t,s,n=Date.now()){if(!t||!s)return;let r=Pe(t,s),i=e.yeaftHistoryCacheState?.[r];i&&(e.yeaftHistoryCacheState={...e.yeaftHistoryCacheState||{},[r]:{...i,lastAccessed:n}})}function Fa(e,{conversationId:t,agentId:s,sessionId:n,incomingRows:r=[],now:i=Date.now(),limits:o=jd}={}){!e||!t||!s||!n||py(e,{conversationId:t,agentId:s,sessionId:n,incomingRows:r,now:i,limits:o})}var Va,jd,Wi=W(()=>{Vn();Bi();Va=500,jd=Object.freeze({maxTurnsPerSession:Va})});function vs(e){return e?.sessionId??e?.groupId??null}function Gd(e){let t=e?.stableKey??e?.uiKey??e?.messageId??e?.dbMessageId??e?.id;return t==null||t===""?null:String(t)}function fy(e,t){if(e?.type!=="assistant"||t?.type!=="assistant"||vs(e)!==vs(t)||e.isHistory===!0&&!e.isStreaming||t._hasPersistedTurnId!==!0||!e.turnId||!t.turnId||e.turnId!==t.turnId)return!1;let s=e.speakerVpId||e.vpId||"",n=t.speakerVpId||t.vpId||"";if(s&&n&&s!==n)return!1;let r=e.threadId||"",i=t.threadId||"";if(r&&i&&r!==i)return!1;let o=typeof e.content=="string"?e.content:"",a=typeof t.content=="string"?t.content:"";return!!o&&!!a&&(a.startsWith(o)||o.startsWith(a))}function Qd(e,t){let s=e.uiKey||t.uiKey||null;return Object.assign(e,t),s&&(e.uiKey=s),ct(t)&&(e.isStreaming=!1,e.status==="pending"&&(e.status="completed")),e}function ji(e){let t=ct(e),s=t?Ni(e):null,n=Number(e?.timestamp),r=Number.isFinite(n)&&n>0?n:t?-1/0:1/0;return[r,Number.isFinite(r)?0:Number.isFinite(s)?s:-1]}function gy(e,t,s){let n=[],r=new Map,i=new Map;for(let l=t;l<s;l+=1){let c=e[l],d=vs(c),u=ct(c)?Ni(c):null,p=i.get(d);if(!Number.isFinite(u)&&p){p.rows.push(c);continue}let f={sessionId:d,seq:u,rows:[c]};n.push(f),i.set(d,f),Number.isFinite(u)&&(r.has(d)||r.set(d,[]),r.get(d).push(f))}for(let l of r.values())l.sort((c,d)=>c.seq-d.seq);let o=new Map,a=t;for(let l of n){let c=l;if(Number.isFinite(l.seq)){let d=o.get(l.sessionId)||0;c=r.get(l.sessionId)[d],o.set(l.sessionId,d+1)}for(let d of c.rows)e[a++]=d}}function Ha(e){e.sort((t,s)=>{let n=ji(t),r=ji(s);for(let i=0;i<n.length;i+=1)if(n[i]!==r[i])return n[i]-r[i];return 0});for(let t=0;t<e.length;){let s=ji(e[t])[0],n=t+1;for(;n<e.length&&ji(e[n])[0]===s;)n+=1;Number.isFinite(s)&&n-t>1&&gy(e,t,n),t=n}return e}function hy(e,t){return Array.isArray(e.messagesMap?.[t])||(e.messagesMap=e.messagesMap||{},e.messagesMap[t]=[]),e.messagesMap[t]}function Ba(e,t){return e.filter(s=>t===void 0||vs(s)===t)}function Xd(e,t){let s=Gd(t);if(s){let n=e.find(r=>Gd(r)===s);if(n)return n}if(t?.type==="user"&&t.clientMessageId){let n=e.find(r=>r?.type==="user"&&r.clientMessageId===t.clientMessageId&&vs(r)===vs(t));if(n)return n}return t?.type==="assistant"&&e.find(n=>fy(n,t))||null}function Gt(e){if(!e||typeof e!="object")return null;let t=Yd.get(e);return t||(t=new Na(e),Yd.set(e,t)),t}var Yd,Na,$r=W(()=>{Wi();Yd=new WeakMap;Na=class{constructor(t){this.store=t}rows(t){return hy(this.store,t)}durableRows(t,s=void 0){return Ba(this.rows(t),s).filter(ct)}overlayRows(t,s=void 0){return Ba(this.rows(t),s).filter(n=>!ct(n))}snapshot(t,s=void 0){return{durableRows:this.durableRows(t,s),overlayRows:this.overlayRows(t,s)}}commitDurable({conversationId:t,sessionId:s=void 0,rows:n=[],mode:r="delta",replaceDurable:i=!1,preserveEmpty:o=!0}={}){if(!t)return{insertedRows:0,preservedEmpty:!1};let a=this.rows(t),l=Array.isArray(n)?n.filter(Boolean):[],c=Ba(a,s).length>0;if(o&&r==="recent"&&l.length===0&&c)return{insertedRows:0,inserted:[],preservedEmpty:!0};if(i){let p=a.filter(f=>vs(f)!==s||!ct(f));a.splice(0,a.length,...p)}let d=0,u=[];for(let p of l){let f=Xd(a,p);f?Qd(f,p):(a.push(p),u.push(p),d+=1)}return Ha(a),{insertedRows:d,inserted:u,preservedEmpty:!1}}upsertOverlay({conversationId:t,row:s}={}){if(!t||!s)return null;let n=this.rows(t),r=Xd(n,s);return r?Qd(r,s):n.push(s),Ha(n),r||s}appendOverlayText({conversationId:t,sessionId:s=void 0,turnId:n=null,text:r=""}={}){if(!t||!r)return null;let o=this.rows(t).findLast(a=>a?.type==="assistant"&&!ct(a)&&(s===void 0||vs(a)===s)&&(!n||a.turnId===n));return o?(o.content?r.startsWith(o.content)?o.content=r:o.content.endsWith(r)||(o.content+=r):o.content=r,o):null}replaceProjection(t,s=[]){let n=this.rows(t);return n.splice(0,n.length,...Array.isArray(s)?s:[]),Ha(n),n}removeDurable({conversationId:t,sessionId:s}={}){if(!t)return 0;let n=this.rows(t),r=n.filter(o=>vs(o)!==s||!ct(o)),i=n.length-r.length;return n.splice(0,n.length,...r),i}}});function Lr(e,t){return t?t===e.yeaftConversationId?!0:Object.values(e.yeaftConversationIdsByAgent||{}).includes(t):!1}function Fn(e,t,s){s&&(s.type!=="assistant"&&s.type!=="tool-use"||Lr(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 vy(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 Ui(e){let t=e?.stableKey??e?.messageId??e?.dbMessageId??e?.id;return t==null||t===""?null:String(t)}function Wa(e,t,s){if(!s||typeof s!="object")return null;if(typeof s.uiKey=="string"&&s.uiKey)return s.uiKey;let n=s.entryId||s.stableKey||s.atMessageId||s.messageId||s.dbMessageId||s.id||null;if(n!=null&&n!=="")return s.uiKey=String(n),s.uiKey;let r=`legacy:${t||"conversation"}:`,i=new Set((e?.messagesMap?.[t]||[]).map(a=>a?.uiKey).filter(a=>typeof a=="string"&&a)),o=Number(e?._messageUiKeySequence)||0;do o+=1;while(i.has(`${r}${o}`));return e&&(e._messageUiKeySequence=o),s.uiKey=`${r}${o}`,s.uiKey}function Or(e,t,s){for(let n of Array.isArray(s)?s:[])Wa(e,t,n);return s}function ja(e,t){if(!e||!t)return e;let s=e.type==="user"&&typeof e.id=="string"&&e.id===e.clientMessageId;for(let[n,r]of Object.entries(t))if(r!=null){if(n==="isStreaming"){e.isStreaming&&r===!1&&(e.isStreaming=!1);continue}if(!(n==="uiKey"&&e.uiKey)){if(n==="id"||n==="messageId"){if(s&&t.clientMessageId===e.clientMessageId&&t.messageId&&t.messageId!==e.clientMessageId)continue;(e[n]===void 0||e[n]===null||e[n]==="")&&(e[n]=r);continue}if(!(n==="turnId"&&s&&e.turnId===e.clientMessageId)){if(n==="content"&&typeof r=="string"){e.content||(e.content=r);continue}if(n==="responseKind"&&(r==="progress"||r==="result")){e.responseKind=r;continue}if(n==="attachments"&&Array.isArray(r)){(!Array.isArray(e.attachments)||e.attachments.length===0)&&(e.attachments=r);continue}(e[n]===void 0||e[n]===null||e[n]==="")&&(e[n]=r)}}}return e}function Zd(e=[],t=[]){let s=[],n=new Map,r=new Map;for(let i of[...e,...t]){if(!i)continue;let o=Ui(i),a=i.type==="user"&&i.clientMessageId?String(i.clientMessageId):null;if(o&&n.has(o)){ja(n.get(o),i);continue}if(a&&r.has(a)){let l=r.get(a);ja(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 Jd(e,t,s){return!e||e!==t?!1:!s?.loaded&&!s?.loading}function eu(e,t){return!!t&&!!e?.loaded&&!e?.loading&&Number.isFinite(e?.latestSeq)}function tu({sessionState:e,hasCachedSessionRows:t,force:s=!1}={}){return e?.loading?!1:s?!e?.loaded:e?.loaded?!1:!t}function yy(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"&&Ui(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,Fn(e,t,o),!0):!1}function Ki(e,t,s){if(!t)return;let n={...s};Wa(e,t,n);let r={...n,id:s.dbMessageId||s.id||Date.now().toString()+Math.random().toString(36).substr(2,9),timestamp:vy(s)};if(Lr(e,t)&&!r.sessionId&&(r.sessionId=e._currentYeaftSessionId||e.yeaftActiveSessionFilter||my),Lr(e,t)){let o=e._currentYeaftAgentId||Object.entries(e.yeaftConversationIdsByAgent||{}).find(([,c])=>c===t)?.[0]||e.currentAgent||null,a=typeof r.messageId=="string"&&/^m\d+$/.test(r.messageId)?r.messageId:typeof r.id=="string"&&/^m\d+$/.test(r.id)?r.id:null,l=typeof r.clientMessageId=="string"?r.clientMessageId:null;r.stableKey||(r.stableKey=a?Dr(o,r.sessionId,a):qs(o,r.sessionId,l)),r.uiKey||(r.uiKey=r.stableKey||null),!r.vpId&&e._currentYeaftVpId&&(r.vpId=e._currentYeaftVpId),!r.turnId&&e._currentYeaftTurnId&&(r.turnId=e._currentYeaftTurnId),Fn(e,t,r)}if(e.messagesMap[t]||(e.messagesMap[t]=[]),Wa(e,t,r),Lr(e,t))return Gt(e).upsertOverlay({conversationId:t,sessionId:r.sessionId,row:r});let i=Ui(s);if(i){let o=e.messagesMap[t].find(a=>Ui(a)===i);if(o)return ja(o,r),t===e.yeaftConversationId&&e.messagesMap[t].sort((a,l)=>a.timestamp-l.timestamp),o}return e.messagesMap[t].push(r),t===e.yeaftConversationId&&e.messagesMap[t].sort((o,a)=>o.timestamp-a.timestamp),r}function su(e,t,s,n={}){if(!t||!s)return;e.messagesMap[t]||(e.messagesMap[t]=[]);let r=e.messagesMap[t];if(yy(e,t,n,s))return;if(Lr(e,t)){let l=Gt(e).appendOverlayText({conversationId:t,sessionId:n.sessionId||e._currentYeaftSessionId||void 0,turnId:n.turnId||e._currentYeaftTurnId||null,text:s});if(l){Fn(e,t,l),n.id&&!l.id&&(l.id=n.id),n.id&&!l.messageId&&(l.messageId=n.id);return}}let i=e._currentYeaftTurnId;if(i){for(let a=r.length-1;a>=0;a--)if(r[a].turnId===i&&r[a].type==="assistant"&&r[a].isStreaming){if(Fn(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}Ki(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(Fn(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 Ki(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 nu(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())),Fn(e,t,o),o.type==="user")break}}function ru(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 iu(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 cn(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 by(e){return{id:e.id,dbMessageId:e.id,timestamp:e.created_at}}function ou(e){if(!e)return null;let t=by(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 my,Vr=W(()=>{$r();Vn();my="grp_default"});function dn(e,t){return e._closedAt?.[t]?Date.now()-e._closedAt[t]<3e4:!1}function Hn(e,t){qe(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]){qe(e,t);return}s()},3e4))},45e3);e._processingWatchdogs[t]=n}function zi(e,t){e._yeaftWatchdogPauseReasons?.[t]?.size||e.processingConversations[t]&&e._processingWatchdogs?.[t]&&(e._pongTimeouts?.[t]&&(clearTimeout(e._pongTimeouts[t]),delete e._pongTimeouts[t]),e.sessionHealth?.[t]&&delete e.sessionHealth[t],e._yeaftWatchdogConvs?.has(t)?Nn(e,t):Hn(e,t))}function qe(e,t){e._processingWatchdogs?.[t]&&(clearTimeout(e._processingWatchdogs[t]),clearInterval(e._processingWatchdogs[t]),delete e._processingWatchdogs[t]),e._pongTimeouts?.[t]&&(clearTimeout(e._pongTimeouts[t]),delete e._pongTimeouts[t]),e.sessionHealth?.[t]&&delete e.sessionHealth[t],e._autoRefreshed?.[t]&&delete e._autoRefreshed[t],e._yeaftWatchdogConvs?.delete(t),e._yeaftWatchdogPauseReasons&&delete e._yeaftWatchdogPauseReasons[t]}function qr(e,t,s="phase"){if(!t||!e.processingConversations[t])return;e._yeaftWatchdogPauseReasons||(e._yeaftWatchdogPauseReasons={});let n=e._yeaftWatchdogPauseReasons[t]||new Set;n.add(s),e._yeaftWatchdogPauseReasons[t]=n,e._processingWatchdogs?.[t]&&(clearTimeout(e._processingWatchdogs[t]),clearInterval(e._processingWatchdogs[t]),delete e._processingWatchdogs[t])}function Bn(e,t,s=null){if(!t)return;let n=e._yeaftWatchdogPauseReasons?.[t];n&&(s?n.delete(s):n.clear(),!n.size&&(delete e._yeaftWatchdogPauseReasons[t],e.processingConversations[t]&&Nn(e,t)))}function au(e,t){qe(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 Nn(e,t){let s=e._yeaftWatchdogPauseReasons?.[t];if(qe(e,t),e._processingWatchdogs||(e._processingWatchdogs={}),s?.size){e._yeaftWatchdogConvs||(e._yeaftWatchdogConvs=new Set),e._yeaftWatchdogPauseReasons||(e._yeaftWatchdogPauseReasons={}),e._yeaftWatchdogConvs.add(t),e._yeaftWatchdogPauseReasons[t]=new Set(s);return}e._yeaftWatchdogConvs||(e._yeaftWatchdogConvs=new Set),e._yeaftWatchdogConvs.add(t),e._processingWatchdogs[t]=setTimeout(()=>{if(e.processingConversations[t]){delete e.processingConversations[t];let n=e.executionStatusMap[t];n&&(n.currentTool=null),e.finishStreamingForConversation(t)}delete e._processingWatchdogs[t]},15e4)}var Fs=W(()=>{});function Ua(e,t){return t&&Array.isArray(e?._yeaftRetiredConversationIdsByAgent?.[t])?e._yeaftRetiredConversationIdsByAgent[t]:[]}function Wn(e,t,s){return!t||!s?!1:Ua(e,t).includes(s)}function Ka(e,t){let s=e?._yeaftRetiredConversationTargetsByAgent?.[t];return s&&typeof s=="object"?s:{}}function lu(e,t,s){if(!t||!s)return null;let n=Ka(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 Fr(e,t,s,n=null){if(!t||!s)return;let r=Ua(e,t).filter(a=>a!==s).concat(s).slice(-8);e._yeaftRetiredConversationIdsByAgent={...e._yeaftRetiredConversationIdsByAgent||{},[t]:r};let i=Ka(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 za(e,t,s){if(!t||!s||!e?._yeaftRetiredConversationIdsByAgent)return;let n=Ua(e,t).filter(i=>i!==s);e._yeaftRetiredConversationIdsByAgent={...e._yeaftRetiredConversationIdsByAgent,[t]:n};let r={...Ka(e,t)};delete r[s],e._yeaftRetiredConversationTargetsByAgent={...e._yeaftRetiredConversationTargetsByAgent||{},[t]:r}}var Yi=W(()=>{});function Sy(e,t,s){let n=e.messagesMap?.[t]||[],r=e.messagesMap?.[s]||[];e.messagesMap||(e.messagesMap={}),Or(e,t,n),Or(e,s,r);let i=Zd(r,n).sort((o,a)=>{let l=Number.isFinite(o?.seq)?o.seq:null,c=Number.isFinite(a?.seq)?a.seq:null;return l!==null&&c!==null&&l!==c?l-c:l!==null&&c===null?-1:l===null&&c!==null?1:(o?.timestamp||0)-(a?.timestamp||0)});Gt(e).replaceProjection(s,i)}function Iy(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 Gi(e,t){return!!e&&Object.prototype.hasOwnProperty.call(e,t)}function jn(e,t,s,{removeSource:n}){Gi(e,t)&&(Gi(e,s)||(e[s]=n?e[t]:Iy(e[t])),n&&delete e[t])}function Qt(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 Qi(e,t,s,n){return!t||!s||!n||s===n?!1:(e._yeaftPendingConversationPromotions={...e._yeaftPendingConversationPromotions||{},[t]:{sourceConversationId:s,targetConversationId:n}},!0)}function Hr(e,t,s=null){let n=Qt(e,t,s);if(!n)return null;let r={...e._yeaftPendingConversationPromotions||{}};return delete r[t],e._yeaftPendingConversationPromotions=r,n}function Br(e,t,s){let n=Qt(e,t);return!n||!s||n.targetConversationId===s?null:(Xt(e,n.targetConversationId,s,{removeSource:!0}),Fr(e,t,n.targetConversationId,s),Qi(e,t,n.sourceConversationId,s),n)}function Xt(e,t,s,{removeSource:n=!0}={}){if(!t||!s||t===s)return!1;Sy(e,t,s),e.yeaftHistoryCacheState&&(e.yeaftHistoryCacheState=Object.fromEntries(Object.entries(e.yeaftHistoryCacheState).map(([c,d])=>[c,d?.conversationId===t?{...d,conversationId:s}:d]))),jn(e.processingConversations,t,s,{removeSource:n}),jn(e.executionStatusMap,t,s,{removeSource:n}),jn(e.refreshingSessionMap,t,s,{removeSource:n}),jn(e._closedAt,t,s,{removeSource:n}),jn(e._autoRefreshed,t,s,{removeSource:n}),jn(e.sessionHealth,t,s,{removeSource:n}),e._turnCompletedConvs?.has(t)&&(e._turnCompletedConvs.add(s),n&&e._turnCompletedConvs.delete(t));let r=!!e._yeaftWatchdogConvs?.has(t),i=e._yeaftWatchdogPauseReasons?.[t],o=!!i?.size,a=!!e._processingWatchdogs?.[t];if(o&&(e._yeaftWatchdogPauseReasons||(e._yeaftWatchdogPauseReasons={}),e._yeaftWatchdogPauseReasons[s]=new Set(i)),n&&(a||o)&&qe(e,t),n&&e._pongTimeouts?.[t]&&(clearTimeout(e._pongTimeouts[t]),delete e._pongTimeouts[t]),n&&(a||r||o)&&!!e.processingConversations?.[s])if(e._processingWatchdogs?.[s])e._yeaftWatchdogConvs?.add(s);else{let c=Gi(e.sessionHealth,s),d=e.sessionHealth?.[s],u=Gi(e._autoRefreshed,s),p=e._autoRefreshed?.[s];Nn(e,s),c&&(e.sessionHealth||(e.sessionHealth={}),e.sessionHealth[s]=d),u&&(e._autoRefreshed||(e._autoRefreshed={}),e._autoRefreshed[s]=p)}return n&&e.messagesMap&&delete e.messagesMap[t],!0}var Ya=W(()=>{Vr();$r();Yi();Fs()});function Xi(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 Ga=W(()=>{});function Qa(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}function Cy(){return Date.now()}function Ay(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`pt_${crypto.randomUUID()}`:`pt_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,10)}`}function xy(e,t=160){return typeof e!="string"?e:e.length>t?`${e.slice(0,t)}...[truncated]`:e}function Ty(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"?xy(n):n);return t}function un(){return Ay()}function vt(e,t={}){!e||!t.traceId||(Array.isArray(e._perfTraceQueue)||(e._perfTraceQueue=[]),e._perfTraceQueue.push({traceId:t.traceId,source:"web",phase:t.phase||"unknown",at:Cy(),monotonicMs:Qa(),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:Ty(t.detail)}),e._perfTraceQueue.length>200&&e._perfTraceQueue.splice(0,e._perfTraceQueue.length-200),My(e))}function My(e){!e||e._perfTraceFlushTimer||(e._perfTraceFlushTimer=setTimeout(()=>Py(e),250))}function Py(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 Zi(e,t={}){if(typeof requestAnimationFrame!="function")return;let s=Qa();requestAnimationFrame(()=>{requestAnimationFrame(()=>{vt(e,{...t,phase:t.phase||"render.next_paint",durationMs:Qa()-s})})})}var Xa=W(()=>{});function Zt(e){return Number.isFinite(e)?Number(e):null}function Ry(e){return(Array.isArray(e)?e:[]).map(t=>({startSeq:Zt(t?.startSeq),endSeq:Zt(t?.endSeq)})).filter(t=>t.startSeq!==null&&t.endSeq!==null&&t.startSeq<=t.endSeq).sort((t,s)=>t.startSeq-s.startSeq)}function Nr(e){return Number.isFinite(e)&&e>=0?Math.floor(e):0}function pn(e){let t=Zt(e?.beforeSeq);if(t===null)return null;if(e?.kind==="gap"){let s=Zt(e.stopAtSeq);return s===null?null:`gap:${Nr(e.cacheEpoch)}:${s}:${t}`}return`server:${t}`}function Wr(e){let t=new Set((Array.isArray(e?.completedHistoryWorkKeys)?e.completedHistoryWorkKeys:[]).filter(s=>typeof s=="string"&&s));for(let s of Array.isArray(e?.requestedBeforeSeqs)?e.requestedBeforeSeqs:[])Number.isFinite(s)&&t.add(`server:${s}`);return t}function _y(e,t){let s=pn(t);if(!s)return e.completedHistoryWorkKeys||[];let n=Wr(e);return n.add(s),Array.from(n).slice(-256)}function Dy(e,t){if(!Number.isFinite(t))return e.requestedBeforeSeqs||[];let s=new Set((Array.isArray(e?.requestedBeforeSeqs)?e.requestedBeforeSeqs:[]).filter(Number.isFinite));return s.add(t),Array.from(s).sort((n,r)=>r-n).slice(-256)}function Ey(e,t={},s=0){let n=Ry(e),r=Nr(s),i=Wr(t),o=[];for(let a=1;a<n.length;a+=1){let l=n[a-1],c=n[a];if(l.endSeq+1>=c.startSeq)continue;let d={kind:"gap",beforeSeq:c.startSeq,stopAtSeq:l.endSeq+1,cacheEpoch:r};d.workKey=pn(d),i.has(d.workKey)||o.push(d)}return o.sort((a,l)=>l.beforeSeq-a.beforeSeq)}function cu(e,t,s){let n=Ey(e,t,s),r=Zt(t.serverOldestFetchedSeq??t.oldestSeq),i=n[0]||null;if(!i||r===null||i.beforeSeq<=r)return[];let o={kind:"gap",beforeSeq:i.beforeSeq,stopAtSeq:r,cacheEpoch:i.cacheEpoch};return o.workKey=pn(o),Wr(t).has(o.workKey)?[]:[o]}function du(e={},t=[],s=0){let n=Nr(s),r=Wr(e),i=e.serverHasMore!==!1,o=Zt(e.serverOldestFetchedSeq??e.oldestSeq),a=e.gapTraversalInitialized===!0,l=Array.isArray(e.gapQueue)?e.gapQueue.slice():[],c=null,d=null;if(i&&o!==null){let u={kind:"server",beforeSeq:o,stopAtSeq:null,cacheEpoch:n};u.workKey=pn(u),r.has(u.workKey)?(i=!1,d="history_cursor_repeated"):c=u}return!c&&!i&&(a||(l=cu(t,e,n),a=!0),c=l[0]||null),c?{request:c,state:{...e,serverHasMore:i,gapTraversalInitialized:a,gapQueue:l,pendingPageKind:c.kind,pendingPageBeforeSeq:c.beforeSeq,pendingGapStopAtSeq:c.stopAtSeq,pendingCacheEpoch:c.cacheEpoch,pendingHistoryWorkKey:c.workKey,hasMore:!0,paginationError:null}}:{request:null,state:{...e,serverHasMore:i,gapTraversalInitialized:a,gapQueue:l,hasMore:!1,paginationError:d}}}function uu(e={},{mode:t,oldestSeq:s,hasMore:n,ranges:r=[],pageKind:i=null,stopAtSeq:o=null,cacheEpoch:a=0}={}){if(t==="delta")return e;let l=Nr(a),c=Zt(s),d=Zt(e.pendingPageBeforeSeq),u=i||e.pendingPageKind||(t==="older"?"server":null),p=Zt(o??e.pendingGapStopAtSeq),f=Nr(e.pendingCacheEpoch??l),g={kind:u,beforeSeq:d,stopAtSeq:p,cacheEpoch:f},v=Zt(e.serverOldestFetchedSeq??e.oldestSeq),m=e.serverHasMore!==!1,y=Number(e.noProgressCount)||0,h=null,w=e.requestedBeforeSeqs||[],S=e.completedHistoryWorkKeys||[],b=e.gapTraversalInitialized===!0,k=Array.isArray(e.gapQueue)?e.gapQueue.slice():[];if(t==="recent")v=c,m=!!n,y=0,w=[],S=[],b=!1,k=[];else if(d===null)c!==null&&(v=v===null?c:Math.min(v,c)),m=!!n,y=0;else{w=Dy(e,d),S=_y(e,g);let x=c!==null&&c<d;if(u==="server")x?(v=v===null?c:Math.min(v,c),m=!!n,y=0):(m=!1,y+=1,h="history_cursor_no_progress");else if(u==="gap"){let B=pn(g);k=k.filter(U=>pn(U)!==B);let D=p!==null&&c!==null&&c<=p;if(x||D||n===!1){if(y=0,!D&&n!==!1&&c!==null&&p!==null){let U={kind:"gap",beforeSeq:c,stopAtSeq:p,cacheEpoch:f};U.workKey=pn(U),Wr({completedHistoryWorkKeys:S}).has(U.workKey)||k.unshift(U)}}else y+=1,h="history_cursor_no_progress"}}t==="older"&&!m&&!b&&(k=cu(r,{...e,serverOldestFetchedSeq:v,completedHistoryWorkKeys:S},l),b=!0);let P={...e,serverOldestFetchedSeq:v,serverHasMore:m,requestedBeforeSeqs:w,completedHistoryWorkKeys:S,gapTraversalInitialized:b,gapQueue:k,noProgressCount:y,oldestSeq:v,paginationError:h};return delete P.pendingPageKind,delete P.pendingPageBeforeSeq,delete P.pendingGapStopAtSeq,delete P.pendingCacheEpoch,delete P.pendingHistoryWorkKey,{...P,hasMore:m||k.length>0}}var Za=W(()=>{});function hu(e){return e.filter(t=>!(t.type==="user"&&(!t.content||!t.content.trim())))}function fn(e){let t=typeof e=="string"?e.match(/^m(\d+)$/):null,s=t?Number(t[1]):null;return Number.isFinite(s)?s:null}function pu(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 $y(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 Ly(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 Oy(e,t){return e.speakerVpId||e.vpId||e.vp_id||e.authorVpId||e.authorVP||Ly(t)}function Vy(e){return e?.stableKey||(e&&(e.messageId||e.id)?e.messageId||e.id:null)}function qy(e,t=null){if(!e||e.stableKey)return e;let s=Hs(e),n=e.messageId||e.id||null,r=e.type==="user"&&e.clientMessageId||null;return e.stableKey=r&&n===r?qs(t,s,r):Dr(t,s,n),Number.isFinite(e.seq)||(e.seq=fn(n)),e.uiKey||(e.uiKey=e.stableKey||null),e}function Hs(e){return e?e.sessionId??e.groupId??null:null}function Fy(e){return!e||e.type!=="user"||!e.clientMessageId?!1:(e.messageId||e.id||null)===e.clientMessageId}function Hy(e,t,s,n){let r=e.rows(t),i=r.some(c=>c&&(n==null||Hs(c)===n));if(s.length===0&&i)return{insertedRows:0,preservedEmpty:!0};let o=s.reduce((c,d)=>Math.max(c,d?.timestamp||0),0),a=r.filter(c=>c?n!=null&&Hs(c)!==n||ct(c)||c.isStreaming||c.type==="tool-use"&&c.toolName==="AskUserQuestion"&&(c.askAnswered||c.askPending||c.askExpired)||Fy(c)?!0:o>0&&(c.timestamp||0)>o:!1);return e.replaceProjection(t,a),{insertedRows:e.commitDurable({conversationId:t,sessionId:n,rows:s,mode:"recent",preserveEmpty:!1}).insertedRows,preservedEmpty:!1}}function By(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 Ny(e,t){let s=typeof e.yeaftConversationId=="string"?e.yeaftConversationId:"";return s.startsWith(`yeaft-local-${t}-`)||/^yeaft-local-\d/.test(s)?s:null}function Wy(e,t,s,n){let r=t.agentId||s&&e.yeaftSessionAgentById?.[s]||null;if(!r||!n||e.currentView!=="yeaft")return;let i=Wt(e);if(i.sessionId!==(s||null)||i.agentId&&i.agentId!==r)return;let o=e.yeaftConversationId||null;if(Wn(e,r,n)){let d=e.yeaftConversationIdsByAgent?.[r]||null;d&&d!==n&&Xt(e,n,d,{removeSource:n!==e.yeaftConversationId});return}let a=Qt(e,r);a&&a.targetConversationId!==n&&Br(e,r,n);let l=Qt(e,r,n);if(l&&(Xt(e,l.sourceConversationId,n,{removeSource:!0}),Hr(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=Ny(e,r);c&&(Xt(e,c,n,{removeSource:!0}),e.yeaftConversationIdsByAgent={...e.yeaftConversationIdsByAgent||{},[r]:n},e.yeaftConversationId=n,e.activeConversations=[n])}function Bs(e,t,s=null){let n=e.messagesMap[t]||[];for(let r of n)s&&Object.entries(s).some(([i,o])=>o&&r[i]!==o)||r.type==="tool-use"&&!r.hasResult&&(r.hasResult=!0,r.toolName==="AskUserQuestion"&&!r.askAnswered&&!r.selectedAnswers&&(r.isHistory=!0,r.askExpired=!0,r.askPending=!1,r.pendingAnswers=null,r.askSubmittedAt=null,r.askError=null,r.askRequestId=null))}function mu(e,t){Yt(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 vu(e,t){Yt(e);let s=e.agents.find(n=>n.id===t.agentId);if(e.conversations=e.conversations.filter(n=>n.id!==t.conversationId&&!(n.claudeSessionId&&n.claudeSessionId===t.claudeSessionId&&n.agentId===t.agentId&&(n.provider||"claude-code")===(t.provider||"claude-code"))),e.conversations.push({id:t.conversationId,agentId:t.agentId,agentName:s?.name||t.agentId,workDir:t.workDir,claudeSessionId:t.claudeSessionId,createdAt:Date.now(),processing:!1,connecting:(t.provider||"claude-code")!=="claude-code",type:"chat",provider:t.provider||"claude-code",capabilities:t.capabilities||null,disallowedTools:t.disallowedTools??null}),e.currentAgent=t.agentId,e.currentAgentInfo=s,e.panels.length>1){let n=e._pendingPaneId;if(e._pendingPaneId=null,n){let r=e.panels.find(i=>i.id===n);r&&(r.conversationId=t.conversationId)}else{let r=e.panels.find(i=>!i.conversationId);r&&(r.conversationId=t.conversationId)}e.activeConversations.includes(t.conversationId)||e.activeConversations.push(t.conversationId)}else e.activeConversations=[t.conversationId];if(e.currentWorkDir=t.workDir,e.messagesMap[t.conversationId]=[],e._pendingSessionTitle&&(e.conversationTitles[t.conversationId]=e._pendingSessionTitle,e._pendingSessionTitle=null),e.sendWsMessage({type:"select_conversation",conversationId:t.conversationId}),e.addMessage({type:"system",content:Ee("store.convResumed",{agent:s?.name||t.agentId,sessionId:t.claudeSessionId?t.claudeSessionId.slice(0,8)+"...":""})}),t.dbMessages&&t.dbMessages.length>0){let n=hu(t.dbMessages.map(i=>e.formatDbMessage(i)).flat().filter(Boolean)),r=e.messagesMap[t.conversationId]||[];for(let i of n)r.push(i)}e.hasMoreMessages=!!t.hasMoreMessages,e.chatSessionState[t.conversationId]={lastSeenDbId:cn(e.messagesMap[t.conversationId]),hasMoreOlder:!!t.hasMoreMessages},e.saveOpenSessions()}function Ja(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],qe(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 yu(e,t){let s=t.conversationId;if(s){delete e.processingConversations[s],qe(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),Bs(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 bu(e,t){let s=t.conversationId;if(s){delete e.processingConversations[s],qe(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),Bs(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 wu(e,t){if(t.conversationId){if(t.isProcessing&&!dn(e,t.conversationId)&&!e._turnCompletedConvs?.has(t.conversationId))e.processingConversations[t.conversationId]=!0;else if(e.processingConversations[t.conversationId]){delete e.processingConversations[t.conversationId],qe(e,t.conversationId);let s=e.executionStatusMap[t.conversationId];s&&(s.currentTool=null),e.finishStreamingForConversation(t.conversationId)}}}function ku(e,t){let s=t.conversationId||e.currentConversation;if(s){delete e.processingConversations[s],qe(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),Bs(e,s)}}function Su(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=hu((t.messages||[]).map(a=>e.formatDbMessage(a)).flat().filter(Boolean));if(i.length>0){let a=n.find(l=>l.dbMessageId);if(a&&i[0].dbMessageId&&i[i.length-1].dbMessageId<a.dbMessageId){let l=n.indexOf(a);e.debug,n.splice(l,0,...i)}else{e.debug;for(let l of i)if(!(l.dbMessageId&&n.some(c=>c.dbMessageId===l.dbMessageId))){if(l.dbMessageId&&(l.type==="assistant"||l.type==="user")){let c=null;if(l.type==="user"?c=n.find(d=>!d.dbMessageId&&!d.isStreaming&&Xi(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),Yt(e);let o=e.chatSessionState[t.conversationId]?.hasMoreOlder;e.chatSessionState[t.conversationId]={lastSeenDbId:cn(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 Iu(e,t){let s=t.sessionId??null,n=t.agentId||s&&e.yeaftSessionAgentById?.[s]||null,r=t.conversationId||n&&e.yeaftConversationIdsByAgent?.[n]||e.yeaftConversationId;if(!r||!s||!Array.isArray(t.messages))return null;e.messagesMap[r]||(e.messagesMap[r]=[]);let i=new Set(Array.isArray(t.sourceMessageIds)?t.sourceMessageIds:[]),o=new Set,a=new Set;for(let y of e.messagesMap[r]){if(Hs(y)!==s)continue;let h=y?.persistedMessageId||y?.messageId||y?.id||null;h&&o.add(h),h&&(y?._historyWindowPrefetched===!0||y?._historyWindowDetached===!0)&&a.add(h),!(!t.entryId||!i.has(h))&&(y.historyEntryId=t.entryId,Number.isFinite(t.indexGeneration)&&(y.historyIndexGeneration=t.indexGeneration))}let l=t.messages.filter(y=>t.prefetch===!0||!o.has(y?.id)||a.has(y?.id)).map(y=>t.entryId&&i.has(y?.id)?{...y,historyEntryId:t.entryId,...t.prefetch===!0?{_historyWindowPrefetched:!0}:{},...Number.isFinite(t.indexGeneration)?{historyIndexGeneration:t.indexGeneration}:{}}:y),{formatted:c}=Cu(l,s,"window",e.messagesMap[r],n),d=`history-window:${t.requestId||t.anchorMessageId||Date.now()}`;for(let y of c)y._historyWindowKey=d,y._historyWindowDetached=t.prefetch!==!0,y._historyWindowPrefetched=t.prefetch===!0;let u=Gt(e),p=u.rows(r),f=new Set(t.messages.map(y=>y?.id).filter(Boolean)),g=[];if(t.prefetch!==!0){for(let h of p){if(Hs(h)!==s)continue;let w=h?.persistedMessageId||h?.messageId||h?.id||null;f.has(w)&&(h._historyWindowPrefetched!==!0&&h._historyWindowDetached!==!0||(h._historyWindowKey=d,h._historyWindowDetached=!0,h._historyWindowPrefetched=!1,g.push(h)))}let y=p.filter(h=>Hs(h)!==s||h._historyWindowDetached!==!0||h._historyWindowKey===d);y.length!==p.length&&u.replaceProjection(r,y)}u.commitDurable({conversationId:r,sessionId:s,rows:c,mode:"window"});let v=c.length>0?c:g,m=Wt(e);return Fa(e,{conversationId:r,agentId:n,sessionId:s,incomingRows:v,activeAgentId:m.agentId,activeSessionId:m.sessionId}),r}function fu(e){return e?.toolId?[Hs(e)??"",e.vpId||e.speakerVpId||"",e.turnId||"",e.threadId||"main",e.toolId].join("\0"):null}function gu(e,t,s){return e.toolName="AskUserQuestion",e.toolId=t.toolCallId,e.toolInput={questions:s},e.askQuestions=s,e.askRequestId=null,e.askPending=!1,e.pendingAnswers=null,e.askSubmitGeneration=null,e.askSubmittedAt=null,e.askError=null,e.hasResult=!0,e.isHistory=!0,t.status==="answered"?(e.askAnswered=!0,e.selectedAnswers=t.answers,e.askExpired=!1):(e.askAnswered=!1,e.selectedAnswers=null,e.askExpired=!0),e}function jy(e,t){return(e||[]).find(s=>s?.type==="tool-use"&&(s.toolName==="AskUser"||s.toolName==="AskUserQuestion")&&s.toolId===t.toolCallId&&Hs(s)===t.sessionId&&(s.vpId||s.speakerVpId||"")===(t.vpId||"")&&(s.turnId||"")===(t.turnId||"")&&(s.threadId||"main")===(t.threadId||"main"))||null}function Cu(e,t,s,n,r=null){let i=new Set((n||[]).map(c=>Vy(qy(c,r))).filter(Boolean)),o=new Set,a=[],l=0;for(let c of e){if(!c||c._reflection||c.internal||c.systemOnly||c.systemOnlyMessage||By(c.content))continue;let d=c.id||c.messageId||null,u=c.clientMessageId||null,p=c.sessionId??c.groupId??t??null,f=Dr(r,p,d),g=u?qs(r,p,u):f,v=c.historyEntryId?{historyEntryId:c.historyEntryId,...Number.isFinite(c.historyIndexGeneration)?{historyIndexGeneration:c.historyIndexGeneration}:{}}:{};if(!(f&&o.has(f))&&!(f&&s!=="recent"&&i.has(f))){if(f&&o.add(f),c.role==="user"){l+=1;let m=d||c.messageId||c.turnId||null;a.push({...d?{id:d,messageId:d}:{},...f?{stableKey:f}:{},...g?{uiKey:g}:{},...v,seq:Number.isFinite(c.seq)?c.seq:fn(d),type:"user",content:c.content,timestamp:pu(c),sessionId:p,turnId:c.turnId||m,...u?{clientMessageId:u}:{},...Array.isArray(c.attachments)&&c.attachments.length>0?{attachments:c.attachments}:{},...c.quote?{quote:c.quote}:{},isStreaming:!1,isHistory:!0})}else if(c.role==="assistant"){l+=1;let m=d||c.messageId||c.turnId||null,y=Oy(c,p),h=pu(c),w=!!c.turnId,S=c.turnId||m,b=typeof c.content=="string"?c.content:c.content||"",k=Array.isArray(c.todos)?c.todos:$y(c.toolCalls),P=c.executionOrigin==="route_forward"?{executionOrigin:"route_forward"}:{};(typeof b!="string"||b.trim())&&a.push({...d?{id:d,messageId:d}:{},...f?{stableKey:f}:{},...g?{uiKey:g}:{},...v,seq:Number.isFinite(c.seq)?c.seq:fn(d),...c.entryId?{entryId:c.entryId}:{},...Array.isArray(c.sourceMessageIds)?{sourceMessageIds:c.sourceMessageIds}:{},type:"assistant",content:b,timestamp:h,sessionId:p,turnId:S,_hasPersistedTurnId:w,...P,...y?{vpId:y,speakerVpId:y}:{},...c.responseKind==="progress"||c.responseKind==="result"?{responseKind:c.responseKind}:{},...Number.isInteger(c.llmCallCount)&&c.llmCallCount>0?{llmCallCount:c.llmCallCount}:{},...Number.isFinite(c.inputTokens)&&c.inputTokens>=0?{inputTokens:c.inputTokens}:{},...Number.isFinite(c.outputTokens)&&c.outputTokens>=0?{outputTokens:c.outputTokens}:{},...Number.isFinite(c.totalTokens)&&c.totalTokens>=0?{totalTokens:c.totalTokens}:{},...Number.isFinite(c.totalMs)&&c.totalMs>=0?{totalMs:c.totalMs}:{},...typeof c.model=="string"&&c.model?{model:c.model}:{},...typeof c.effort=="string"&&c.effort?{effort:c.effort}:{},...c.incomplete===!0?{incomplete:!0}:{},...typeof c.stopReason=="string"&&c.stopReason?{stopReason:c.stopReason}:{},isStreaming:!1,isHistory:!0}),Array.isArray(k)&&k.length>0&&a.push({...d?{id:`${d}:todos`,messageId:`${d}:todos`}:{},...f?{stableKey:`${f}:todos`}:{},...v,seq:Number.isFinite(c.seq)?c.seq:fn(d),type:"tool-use",toolName:"TodoWrite",toolInput:{todos:k},timestamp:h,startTime:h||0,sessionId:p,turnId:S,...P,...y?{vpId:y,speakerVpId:y}:{},isStreaming:!1,isHistory:!0,hasResult:!0});for(let[x,B]of(Array.isArray(c.toolCalls)?c.toolCalls:[]).entries()){if(!B||B.name==="TodoWrite")continue;let D=B.id||`index:${x}`,U=encodeURIComponent(String(D));a.push({...d?{id:`${d}:tool:${U}`,messageId:`${d}:tool:${U}`,persistedMessageId:d}:{},...f?{stableKey:`${f}:tool:${U}`}:{},...v,seq:Number.isFinite(c.seq)?c.seq:fn(d),type:"tool-use",toolId:B.id||null,toolName:B.name||"unknown",toolInput:B.input||{},timestamp:h,startTime:h||0,sessionId:p,turnId:S,...c.threadId?{threadId:c.threadId}:{},...P,...y?{vpId:y,speakerVpId:y}:{},isStreaming:!1,isHistory:!0,hasResult:!0})}for(let x of Array.isArray(c.images)?c.images:[])x?.assetId&&a.push({id:`${d||m||S}:image:${x.assetId}`,messageId:`${d||m||S}:image:${x.assetId}`,...f?{stableKey:`${f}:image:${x.assetId}`}:{},...v,seq:Number.isFinite(c.seq)?c.seq:fn(d),type:"chat-image",...x,timestamp:h,sessionId:p,turnId:S,...P,...y?{vpId:y,speakerVpId:y}:{},isStreaming:!1,isHistory:!0});for(let x of Array.isArray(c.askUserResults)?c.askUserResults:[]){if(!x?.toolCallId||x.status!=="answered"&&x.status!=="expired")continue;let B=[{question:typeof x.question=="string"?x.question:"",options:(Array.isArray(x.options)?x.options:[]).filter(R=>typeof R=="string").map(R=>({label:R,description:""})),multiSelect:!1}],D={toolCallId:x.toolCallId,sessionId:p,vpId:y||"",turnId:S||"",threadId:c.threadId||"main"},U=jy(n,D);if(U){Object.assign(U,v),gu(U,x,B);let R=a.findIndex(J=>J?.type==="tool-use"&&J.toolId===x.toolCallId&&(J.sessionId??J.groupId??null)===(U.sessionId??U.groupId??null)&&(J.turnId||"")===(U.turnId||""));R>=0&&a.splice(R,1);continue}let F=gu({id:`${d||m||S}:ask:${x.toolCallId}`,messageId:`${d||m||S}:ask:${x.toolCallId}`,...f?{stableKey:`${f}:ask:${x.toolCallId}`}:{},...v,seq:Number.isFinite(c.seq)?c.seq:fn(d),type:"tool-use",timestamp:h,sessionId:p,turnId:S,threadId:D.threadId,...P,...y?{vpId:y,speakerVpId:y}:{},isStreaming:!1},x,B),O=fu(F);(!O||!a.some(R=>fu(R)===O))&&a.push(F);let M=a.findIndex(R=>R!==F&&R?.type==="tool-use"&&R.toolId===x.toolCallId&&(R.sessionId??R.groupId??null)===(F.sessionId??F.groupId??null)&&(R.turnId||"")===(F.turnId||""));M>=0&&a.splice(M,1)}}}}return{formatted:a,acceptedHistoryMessages:l}}function Au(e,t){let s=t.sessionId!=null?t.sessionId:t.groupId,n=t.agentId||s&&e.yeaftSessionAgentById?.[s]||null;if(Wn(e,n,t.conversationId)){let T=e.yeaftConversationIdsByAgent?.[n]||null;if(!T||T===t.conversationId)return;Xt(e,t.conversationId,T,{removeSource:t.conversationId!==e.yeaftConversationId}),t={...t,conversationId:T}}if(t.requestId&&typeof e.isCurrentYeaftHistoryResponse=="function"&&!e.isCurrentYeaftHistoryResponse(t))return;let r=t.mode==="recent"||t.mode==="delta"?t.mode:"older",i=Array.isArray(t.messages)?t.messages:[],o=t.agentId||s&&e.yeaftSessionAgentById?.[s]||null,a=Pe(o,s),l=e.yeaftSessionHistoryState?.[a]||null;typeof t.streamId=="string"&&typeof l?.streamId=="string"&&(t.streamId!==l.streamId||Number.isFinite(t.revision)&&Number.isFinite(l.revision)&&t.revision!==l.revision)&&(r="recent",typeof e.clearYeaftHistoryMemory=="function"&&e.clearYeaftHistoryMemory({agentId:o,sessionId:s,preserveLiveRows:!0,preserveSessionOwner:!0})),t.perfTraceId&&vt(e,{traceId:t.perfTraceId,phase:"history.chunk_received",agentId:t.agentId||null,sessionId:s||null,messageType:t.type,bytes:(()=>{try{return JSON.stringify(t).length}catch{return null}})(),detail:{mode:r,rawCount:i.length}});let d=t.agentId||(s&&e.yeaftSessionAgentById?e.yeaftSessionAgentById[s]:null),u=d&&e.yeaftConversationIdsByAgent?e.yeaftConversationIdsByAgent[d]:null,p=t.conversationId||u||e.yeaftConversationId;if(!p){e.yeaftLoadingMoreHistory=!1;return}Wy(e,t,s,p),e.messagesMap[p]||(e.messagesMap[p]=[]);let{formatted:f,acceptedHistoryMessages:g}=Cu(i,s,r,e.messagesMap[p],d);Or(e,p,f);let v=Gt(e),m=0,y=!1;if(r==="recent"){let T=Hy(v,p,f,s??null);m=T.insertedRows,y=T.preservedEmpty}else if(f.length>0&&(m=v.commitDurable({conversationId:p,sessionId:s??null,rows:f,mode:r}).insertedRows,r==="older"&&typeof e.expandYeaftMessageWindow=="function")){let N=e.yeaftActiveSessionFilter?s??null:null;e.expandYeaftMessageWindow(N,t.turns||10,d)}let h=Wt(e);Fa(e,{conversationId:p,agentId:d,sessionId:s,incomingRows:f,activeAgentId:h.agentId,activeSessionId:h.sessionId});let w=Pe(t.agentId||null,s),S=e.yeaftHistoryCacheState?.[w]||null,b=e.yeaftSessionHistoryState?.[w]||{},k=Number.isFinite(b.serverOldestFetchedSeq)?b.serverOldestFetchedSeq:Number.isFinite(b.oldestSeq)?b.oldestSeq:null,P=Number.isFinite(t.nextBeforeSeq)?t.nextBeforeSeq:Number.isFinite(t.oldestSeq)?t.oldestSeq:y?k:null,x=y&&!Number.isFinite(t.nextBeforeSeq)&&!Number.isFinite(t.oldestSeq)?b.serverHasMore??b.hasMore??!1:t.hasMore,B=r==="delta"?b:uu(b,{mode:r,oldestSeq:P,hasMore:x,ranges:S?.ranges||[],pageKind:t.pageKind,stopAtSeq:t.gapStopAtSeq,cacheEpoch:S?.rangeEpoch??t.cacheEpoch??0}),D=typeof t.latestSeq=="number"?t.latestSeq:b.latestSeq??null,U={streamId:typeof t.streamId=="string"?t.streamId:b.streamId??null,revision:Number.isFinite(t.revision)?t.revision:b.revision??null},F=r==="delta"?{...b,...U,loaded:!0,loading:!1,latestSeq:D,syncingAfterSeq:null,count:(b.count||0)+m}:{...B,...U,loaded:!0,loading:!1,count:S?S.rowCount:r==="older"?(b.count||0)+m:y?b.count||0:g,latestSeq:y&&!Number.isFinite(t.latestSeq)?b.latestSeq??null:D,syncingAfterSeq:null};t.requestId&&typeof e.finishYeaftHistoryLoad=="function"?e.finishYeaftHistoryLoad(t,F,"chunk"):e.yeaftSessionHistoryState&&(e.yeaftSessionHistoryState={...e.yeaftSessionHistoryState,[w]:F}),r==="delta"&&t.hasMoreAfter===!0&&Number.isFinite(F.latestSeq)&&F.latestSeq>Number(t.afterSeq??-1)&&typeof e.continueYeaftHistoryDelta=="function"&&queueMicrotask(()=>e.continueYeaftHistoryDelta(s,d,F.latestSeq));let O=Wt(e),M=O.sessionId===(s||null),R=!t.agentId||!O.agentId||t.agentId===O.agentId,J=M&&R,V=Pe(null,O.sessionId);if(t.perfTraceId&&(vt(e,{traceId:t.perfTraceId,phase:"history.chunk_applied",agentId:t.agentId||null,sessionId:s||null,messageType:t.type,detail:{mode:r,formattedCount:f.length,insertedRows:m,acceptedHistoryMessages:g,preservedEmptyRecent:y}}),Zi(e,{traceId:t.perfTraceId,phase:"history.next_paint",agentId:t.agentId||null,sessionId:s||null,messageType:t.type,detail:{mode:r,insertedRows:m}})),J)e.yeaftHasMoreHistory=F.hasMore,e.yeaftOldestLoadedSeq=Number.isFinite(F.serverOldestFetchedSeq)?F.serverOldestFetchedSeq:Number.isFinite(F.oldestSeq)?F.oldestSeq:e.yeaftOldestLoadedSeq,e.yeaftLoadingMoreHistory=!1;else if(e.yeaftLoadingMoreHistory){let T=e.yeaftSessionHistoryState?.[O.sessionKey]||e.yeaftSessionHistoryState?.[V]||null;e.yeaftLoadingMoreHistory=!!T?.loading}}var Ji=W(()=>{Fs();Ya();Yi();an();Ga();Vr();zt();Xa();Bi();Vn();Wi();Za();$r()});function xu(e,t,s=null){if(!s)return!1;if(e.promoteYeaftHistoryOutlineRow?.(t,s))return!0;let n=t?.sessionId??t?.groupId??e._currentYeaftSessionId??null;return n?!!e.invalidateYeaftHistoryOutline?.(n,s):!1}function Uy(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 el(e,t){return e.executionStatusMap[t]||(e.executionStatusMap[t]={currentTool:null,toolHistory:[],lastActivity:null}),e.executionStatusMap[t]}function Tu(e,t,s,n=null){if(!t)return;let r=el(e,t);if(r.lastActivity=Date.now(),zi(e,t),s.type==="system"){if(s.subtype==="init"){let i=e.conversations.find(o=>o.id===t);i&&i.connecting&&(i.connecting=!1);return}s.message&&e.addMessageToConversation(t,{type:"system",content:typeof s.message=="string"?s.message:JSON.stringify(s.message,null,2)});return}if(s.type==="assistant"){let i=s.message?.content;if(!i)return;let o=e.messagesMap[t]||[];for(let a of o)a.type==="tool-use"&&!a.hasResult&&(a.hasResult=!0);for(let a of r.toolHistory)a.status==="running"&&(a.status="done");if(r.currentTool=null,typeof i=="string"){e.appendToAssistantMessageForConversation(t,i,{id:s.message?.id||s.message?.messageId||null,ts:s.ts||s.message?.ts||s.message?.time||null,sessionId:e._currentYeaftSessionId||null,vpId:e._currentYeaftVpId||null,turnId:e._currentYeaftTurnId||null,threadId:e._currentYeaftThreadId||null});return}if(!Array.isArray(i))return;if(i.length===0){e.finishStreamingForConversation(t);return}for(let a of i)a.type==="text"?e.appendToAssistantMessageForConversation(t,a.text,{id:s.message?.id||s.message?.messageId||null,ts:s.ts||s.message?.ts||s.message?.time||null,sessionId:e._currentYeaftSessionId||null,vpId:e._currentYeaftVpId||null,turnId:e._currentYeaftTurnId||null,threadId:e._currentYeaftThreadId||null}):a.type==="image_asset"&&a.image?e.addMessageToConversation(t,{type:"chat-image",...a.image,sessionId:e._currentYeaftSessionId||null,vpId:e._currentYeaftVpId||null,speakerVpId:e._currentYeaftVpId||null,turnId:e._currentYeaftTurnId||null,threadId:e._currentYeaftThreadId||null}):a.type==="tool_use"&&(e.finishStreamingForConversation(t,{completeLifecycle:!1}),r.currentTool={name:a.name,input:a.input,startTime:Date.now()},r.toolHistory.unshift({name:a.name,input:a.input,timestamp:Date.now(),status:"running"}),r.toolHistory.length>20&&r.toolHistory.pop(),e.addMessageToConversation(t,{type:"tool-use",toolId:a.id||a.tool_use_id||null,toolName:a.name,toolInput:a.input,startTime:Date.now(),isHistory:a.history===!0||s.history===!0||s.isHistory===!0,sessionId:e._currentYeaftSessionId||null,vpId:e._currentYeaftVpId||null,turnId:e._currentYeaftTurnId||null,threadId:e._currentYeaftThreadId||null}))}else if(s.type==="user"){let i=s.internal===!0||s.message?.internal===!0||s.userAuthored===!1||s.message?.userAuthored===!1,o=s.message?.content,a=Uy(o);if(typeof a=="string"&&(a.includes("<local-command-caveat>")||a.includes("<command-name>")))return;if(typeof a=="string"&&a.includes("<local-command-stdout>")){let c=a.match(/<local-command-stdout>([\s\S]*?)<\/local-command-stdout>/);if(c){e.appendToAssistantMessageForConversation(t,c[1].trim()),e.finishStreamingForConversation(t);return}}let l=[];if(s.tool_use_result)l=Array.isArray(s.tool_use_result)?s.tool_use_result:[s.tool_use_result];else if(s.message?.content){let c=s.message.content;l=(Array.isArray(c)?c:[]).filter(u=>u.type==="tool_result")}if(l.length>0){let c=e.messagesMap[t]||[];for(let d of l){if(r.toolHistory.length>0){let g=r.toolHistory.findIndex(v=>v.status==="running");g>=0&&(r.toolHistory[g].status="done")}let u=d.tool_use_id||d.toolUseId||d.tool_call_id||d.toolCallId||null,p=d.content||d,f=!1;if(u){for(let g=c.length-1;g>=0;g--)if(c[g].type==="tool-use"&&c[g].toolId===u){c[g].hasResult=!0,c[g].toolResult=d.is_update&&c[g].toolResult?`${c[g].toolResult}
|
|
2
2
|
|
|
3
3
|
${p}`:p,f=!0;break}}if(!f){for(let g=c.length-1;g>=0;g--)if(c[g].type==="tool-use"&&!c[g].hasResult){c[g].hasResult=!0,c[g].toolResult=p;break}}}r.currentTool=null}else if(!i&&(typeof a=="string"&&a.trim()||Array.isArray(s.message?.attachments)&&s.message.attachments.length>0)){let c=s.message?.clientMessageId||s.clientMessageId||null,d={type:"user",content:a,clientMessageId:c},u=e.messagesMap[t]||[];if(u.some(f=>Xi(f,d))){if(c){for(let f=u.length-1;f>=0;f--)if(u[f].type==="user"&&u[f].clientMessageId===c){s.dbMessageId&&!u[f].dbMessageId&&(u[f].dbMessageId=s.dbMessageId),s.message?.id&&!u[f].messageId&&(u[f].id=s.message.id,u[f].messageId=s.message.id),s.ts&&!u[f].ts&&(u[f].ts=s.ts),xu(e,u[f],n);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:a,...s.message?.attachments?{attachments:s.message.attachments}:{},...s.message?.quote?{quote:s.message.quote}:{},...c?{clientMessageId:c}:{}});xu(e,f,n)}}}else if(s.type==="result"){delete e.processingConversations[t],qe(e,t);let i=e.conversations.find(d=>d.id===t);i&&i.connecting&&(i.connecting=!1);let o=e._currentYeaftSessionId||null;if(e._currentYeaftTurnId){let d=Object.entries(e.activeVpTurns||{}).find(([,u])=>(u?.turnId===e._currentYeaftTurnId||!u?.turnId&&u===e.activeVpTurns[e._currentYeaftTurnId])&&(!e._currentYeaftAgentId||!u?.agentId||u.agentId===e._currentYeaftAgentId));if(d){let[u,p]=d,{[u]:f,...g}=e.activeVpTurns;!o&&p?.sessionId&&(o=p.sessionId),e.activeVpTurns=g}}if(o&&e._currentYeaftVpId&&e.vpStatuses){let d=e._currentYeaftTurnId||null,u={...e.vpStatuses||{}},p=!1;for(let[f,g]of Object.entries(u))!g||g.vpId!==e._currentYeaftVpId||e._currentYeaftAgentId&&g.agentId&&g.agentId!==e._currentYeaftAgentId||(g.sessionId||g.groupId||null)!==o||d&&g.turnId&&g.turnId!==d||(u[f]={...g,state:"idle",turnId:null,since:Date.now()},p=!0);p&&(e.vpStatuses=u)}o&&typeof e.clearYeaftSessionProcessingIfIdle=="function"&&e.clearYeaftSessionProcessingIfIdle(o,{agentId:e._currentYeaftAgentId||null}),e._closedAt||(e._closedAt={}),e._closedAt[t]=Date.now(),e._turnCompletedConvs||(e._turnCompletedConvs=new Set),e._turnCompletedConvs.add(t),r.currentTool=null,Bs(e,t,e._currentYeaftSessionId?{sessionId:e._currentYeaftSessionId,vpId:e._currentYeaftVpId,turnId:e._currentYeaftTurnId,threadId:e._currentYeaftThreadId}:null);let a=e.messagesMap[t]||[],l=s.result_text||"";if(typeof l=="string"&&l.trim()){let d=!1;for(let u=a.length-1;u>=0;u--){if(a[u].type==="assistant"){d=!0;break}if(a[u].type==="user")break}d||e.appendToAssistantMessageForConversation(t,l.trim())}e.finishStreamingForConversation(t),!(n&&e.promoteCompletedYeaftHistoryOutline?.(t,e._currentYeaftTurnId||null,n))&&o&&n&&e.invalidateYeaftHistoryOutline?.(o,n),e.sweepStaleStreamingForConversation(t),o&&n&&e.pruneConversationMessageRetention?.(t,o,n)}}var Mu=W(()=>{Fs();Ji();Ga()});function gn(e){if(e==null)return e;try{return JSON.parse(JSON.stringify(e))}catch{return e}}function eo(e,t){if(!t)return e??null;if(Object.prototype.hasOwnProperty.call(t,"base"))return gn(t.base)??null;if(Object.prototype.hasOwnProperty.call(t,"replacement"))return gn(t.replacement)??null;let s=e&&typeof e=="object"&&!Array.isArray(e)?gn(e):{};if(t.set&&typeof t.set=="object")for(let[n,r]of Object.entries(t.set))s[n]=gn(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]=gn(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]=gn(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(gn(t.body.messagesAppend)||[])}s.body=n}return s}function Pu(e,t){return!t||!Object.prototype.hasOwnProperty.call(t,"rawRequestDelta")?e??null:eo(e??null,t.rawRequestDelta)}function jr(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 zy(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 Ru(e){let t=0,s=0;if(e&&Array.isArray(e.messages))for(let i of e.messages){let{messageText:o,toolText:a}=zy(i);for(let l of o)t+=jr(l);for(let l of a)s+=jr(l)}let n=0,r=0;if(e&&typeof e.response=="string"&&(n+=jr(e.response)),e&&Array.isArray(e.toolCalls)){for(let i of e.toolCalls)if(i&&(r+=jr(String(i.name||"")),i.input!==void 0))try{r+=jr(JSON.stringify(i.input))}catch{}}return{inputMessageTokens:t,inputToolTokens:s,outputMessageTokens:n,outputToolTokens:r,inputTotalEstimated:t+s,outputTotalEstimated:n+r}}function tl(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 _u(e,t){let s=Math.max(0,Math.floor(Number(e)||0)),n=t&&typeof t=="object"?t:{},r=[["systemPrompt",Math.max(0,Number(n.systemPromptTokens)||0)],["historyMessages",Math.max(0,Number(n.historyMessageTokens)||0)],["tools",Math.max(0,Number(n.toolDefinitionTokens)||0)],["currentTurn",Math.max(0,Number(n.currentTurnTokens)||0)]],i=r.reduce((c,[,d])=>c+d,0),o={systemPrompt:0,historyMessages:0,tools:0,currentTurn:0};if(s===0)return o;if(i===0)return o.currentTurn=s,o;let a=r.map(([c,d],u)=>{let p=d/i*s,f=Math.floor(p);return o[c]=f,{key:c,index:u,fraction:p-f}}),l=s-Object.values(o).reduce((c,d)=>c+d,0);a.sort((c,d)=>d.fraction-c.fraction||c.index-d.index);for(let c=0;c<l;c++)o[a[c%a.length].key]+=1;return o}function Du(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 sl=W(()=>{});function ys(e,t){return!e||!t?"":`${e}${t}`}function Ur(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 nl(e){return e?`${e}`:""}function rl(e,t){return!e||!t?"":`${e}${t}`}var to=W(()=>{});function Yy(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 Eu(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 $u(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;for(let[a,l]of Object.entries(e.agentOperations||{})){let c=t.agents.find(d=>d.id===a);for(let d of["restart","upgrade"]){let u=l?.[d];if(!u?.pending||!u.acknowledged)continue;if(!c?.online){u.sawOffline||(e.agentOperations={...e.agentOperations,[a]:{...e.agentOperations[a]||{},[d]:{...u,sawOffline:!0}}});continue}let p=d==="upgrade"&&u.oldVersion&&c.version!==u.oldVersion;!u.sawOffline&&!p||e.finishAgentOperation?.(a,d)}}let o=e.currentAgent||null;if(o){let a=e._yeaftAgentSeen&&e._yeaftAgentSeen.id===o?e._yeaftAgentSeen:null,l=t.agents.find(d=>d.id===o)||null;(e.currentView==="yeaft"||e.workCenterOpen&&e.workCenterAgentId===o)&&Yy(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(p=>p.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 p=e._recentlyDeletedSessions?.[d.id];if(p&&Date.now()-p<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],qe(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&&!dn(e,d.id)&&!e._turnCompletedConvs?.has(d.id))e.processingConversations[d.id]=!0;else if(e.processingConversations[d.id]){delete e.processingConversations[d.id],qe(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],qe(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})),d&&e.workCenterOpen&&e.workCenterAgentId===e.currentAgent&&typeof e.listWorkItems=="function"){let u=e._workCenterListFiltersByAgent?.[e.workCenterAgentId]||{};e.listWorkItems(e.workCenterAgentId,u).catch(()=>{})}if(e._yeaftReconnectCatchUpPending=!1,e.currentView==="yeaft"&&typeof e.requestYeaftSessionBootstrap=="function"){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 p=e.messagesMap[e.currentConversation]||[],f=cn(p);f!=null?e.requestChatHistory?.(e.currentConversation,{mode:"delta",afterMessageId:f}):e.requestChatHistory?.(e.currentConversation,{mode:"recent",turns:5}),e.sendWsMessage({type:"refresh_conversation",conversationId:e.currentConversation})}else e.recoveryDismissed||Eu(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){Eu(e,{agentId:c.agentId,agentInfo:d});return}}}l&&(e.agents.find(d=>d.id===l&&d.online)?e.selectAgent(l):e.checkPendingRecovery())}}function Lu(e,t){let s=e.pendingAgentSelection||null;if(s){if(!(typeof t.requestId=="string"&&t.requestId?t.requestId===s.requestId:t.agentId===s.agentId))return!1;if(e.pendingAgentSelection=null,t.ok===!1)return e.agentSwitching=!1,!1}else{if(t.requestId)return!1;if(e.currentAgent&&t.agentId!==e.currentAgent)return!1}e.agentSwitching=!1;let n=e.currentAgent===t.agentId,r={id:t.agentId,name:t.agentName,workDir:t.workDir,capabilities:t.capabilities||["terminal","file_editor","background_tasks"],...t.capabilityMetadataProvided===!0?{capabilityMetadataProvided:!0}:{},version:t.version||null};if(typeof e.activateYeaftAgent=="function"?e.activateYeaftAgent(t.agentId,r):(e.currentAgent=t.agentId,e.currentAgentInfo=r),Array.isArray(t.slashCommands)){let u=[...new Set(t.slashCommands)];e.slashCommandsMap[`agent:${t.agentId}`]=u}t.slashCommandDescriptions&&(e.slashCommandDescriptions={...e.slashCommandDescriptions,...t.slashCommandDescriptions});let i=t.conversations||[],o=new Set,a=i.filter(u=>o.has(u.id)?!1:(o.add(u.id),!0)).map(u=>({...u,agentId:t.agentId,agentName:t.agentName}));if(n&&e.currentConversation){let u=i.find(p=>p.id===e.currentConversation);u&&!a.find(p=>p.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&&!dn(e,u.id)&&!e._turnCompletedConvs?.has(u.id))e.processingConversations[u.id]=!0;else if(e.processingConversations[u.id]){delete e.processingConversations[u.id],qe(e,u.id);let p=e.executionStatusMap[u.id];p&&(p.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(f=>f.id===u)){delete e.processingConversations[u],qe(e,u);let f=e.executionStatusMap[u];f&&(f.currentTool=null),e.finishStreamingForConversation(u)}}if(e.currentView!=="yeaft"){if(n&&e.currentConversation){let u=e.conversations.find(p=>p.id===e.currentConversation);e.currentWorkDir=u?.workDir||e.currentWorkDir||t.workDir,Yt(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(p=>p.id===u)&&(e.autoRestoreConversation(u),e.pendingRecovery=null)}bd(e)}return!0}var Ou=W(()=>{Fs();an();Vr()});function Gy(e={}){return{providers:e.providers||[],primaryModel:e.primaryModel||null,fastModel:e.fastModel||null,language:e.language||"en"}}function Un(e){il.delete(e)}function eb(e,t){let s=il.get(e);s||(s=new Map,il.set(e,s));let n=typeof t?.agentId=="string"?t.agentId:"",r=typeof t?.requestId=="string"?t.requestId:"",i=Number(t?.chunkIndex),o=Number(t?.chunkCount),a=typeof t?.data=="string"?t.data:null,l=e.yeaftDebugPanel?.agentId||null,c=e._yeaftDebugHistoryPending?.payload,d=c?.requestId||e._yeaftDebugHistoryLatestDetailRequestId||e._yeaftDebugHistoryLatestListRequestId;if(!n||!r||l&&n!==l||c&&n!==c.agentId||r!==d||!Number.isSafeInteger(i)||!Number.isSafeInteger(o)||o<=1||i<0||i>=o||a==null||new TextEncoder().encode(a).byteLength>Jy)return null;let u=Date.now();for(let[v,m]of s)m.expiresAt<=u&&s.delete(v);let p=`${n}\0${r}`,f=s.get(p);if(!f){if(i!==0)return null;f={nextIndex:0,chunkCount:o,parts:[],bytes:0,expiresAt:u+Vu},s.set(p,f)}let g=new TextEncoder().encode(a).byteLength;if(f.chunkCount!==o||i!==f.nextIndex)return s.delete(p),null;if(f.parts.push(a),f.bytes+=g,f.nextIndex+=1,f.expiresAt=u+Vu,e.refreshYeaftDebugHistoryTimeout?.(r),f.nextIndex!==f.chunkCount)return null;s.delete(p);try{let v=JSON.parse(f.parts.join(""));return v?.type==="yeaft_debug_history"&&v.requestId===r?{...v,agentId:n}:null}catch{return null}}function qu(){return window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore()}function tb(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 sb(e){let t=qu(),s=null;try{s=localStorage.getItem("lastViewedYeaftSession")||null}catch{}let n=Ur(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 Fu(e){let t=qu(),s=sb(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 nb(e){let t=e.yeaftSessionHydrateRequestId||null;e.yeaftSessionInventoryCompleteSupported!==!1||!t||(clearTimeout(e._legacyYeaftSessionHydrateTimer),e._legacyYeaftSessionHydrateTimer=setTimeout(()=>{e.yeaftSessionHydrateRequestId===t&&(e._legacyYeaftSessionHydrateTimer=null,Fu(e),e._hasHandledYeaftSessionHydrate=!0,e.yeaftSessionHydrateRequestId=null,e.yeaftSessionHydrateError=null,e._yeaftSessionInventorySocketQuarantined=!0)},Zy))}function rb(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=eo(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=eo(n.rawRequest,t.rawRequestDelta)),n}function ib(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=rb(r,s.requestDelta);return t.set(n,o),{...s,systemPrompt:typeof s.systemPrompt=="string"&&s.systemPrompt?s.systemPrompt:o.systemPrompt,messages:Array.isArray(s.messages)&&s.messages.length>0?s.messages:o.messages,rawRequest:s.rawRequest===void 0?o.rawRequest:s.rawRequest,rawRequestBase:i}})}function Hu(e,t){let s=je();if(t?.type==="yeaft_debug_history_chunk"){let n=eb(e,t);if(!n)return;t=n}switch(e._lastPongAt=Date.now(),t.type){case"work_center_response":{let n=t.requestId?e.workCenterPending[t.requestId]:null;if(!n)break;clearTimeout(n.timer),delete e.workCenterPending[t.requestId],t.ok?n.resolve(t.data):n.reject(new Error(t.error||"Work Center request failed"));break}case"work_center_event":e.applyWorkCenterEvent(t.agentId,t.event);break;case"client_hello_ack":e.workbenchRouteProtocolSupported=t.workbenchRouteProtocol===1,e.browserRuntimeProtocolSupported=t.browserRuntimeProtocol===1,e.browserRuntimeSetupProtocolSupported=t.browserRuntimeSetupProtocol===1,e.browserRuntimeServerEnabled=t.browserRuntimeEnabled===!0,window.dispatchEvent(new CustomEvent("browser-runtime-message",{detail:t}));break;case"auth_result":if(t.success){if(e.authenticated=!0,t.sessionKey&&(e.sessionKey=Bt(t.sessionKey),s.setSessionKey(t.sessionKey)),t.acceptPlaintext===!0&&(e.serverEncryptionRequired=!1),e.yeaftSessionInventoryCompleteSupported=t.yeaftSessionInventoryComplete===!0,e.workbenchRouteProtocolSupported=!1,e.browserRuntimeProtocolSupported=!1,e.browserRuntimeSetupProtocolSupported=!1,e.browserRuntimeServerEnabled=t.browserRuntimeEnabled===!0,window.dispatchEvent(new CustomEvent("browser-runtime-message",{detail:t})),e.yeaftSessionHydrateSlices=[],e._hasHandledYeaftSessionHydrate=!1,e.yeaftSessionHydrateError=null,t.role&&(s.role=t.role),typeof e.requestYeaftSessionInventory=="function")e.requestYeaftSessionInventory();else{let n=e.conversations.map(r=>r.id).filter(Boolean);e.sendWsMessage({type:"get_agents",conversationIds:n.length>0?n:void 0})}e.checkPendingRecovery()}else e.addMessage({type:"error",content:t.error||Ee("login.error.loginFailed")}),s.handleAuthFailure?.(void 0,t._wsAuthToken,t._wsAuthGeneration);break;case"agent_list":$u(e,t);break;case"yeaft_session_hydrate":{if(e.yeaftSessionInventoryCompleteSupported===!0&&(!t.requestId||t.requestId!==e.yeaftSessionHydrateRequestId)||e.yeaftSessionInventoryCompleteSupported!==!0&&!e.yeaftSessionHydrateRequestId||t.requestId&&e.yeaftSessionHydrateRequestId&&t.requestId!==e.yeaftSessionHydrateRequestId)break;tb(e,t),e.yeaftSessionInventoryCompleteSupported!==!0&&nb(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?Fu(e):e.yeaftSessionHydrateSlices=[],e.yeaftSessionHydrateRequestId=null,e._hasHandledYeaftSessionHydrate=t.ok!==!1,e.yeaftSessionHydrateError=t.ok===!1?t.error||"session_inventory_failed":null;break;case"session_catalog_snapshot":e.applySessionCatalogSnapshot(t.catalog,t.projectsAuthoritative===!0?t.projects:null,t.hiddenCatalog);break;case"session_ui_metadata_updated":e.finishSessionCatalogMutation?.(t);break;case"session_catalog_reorder_result":e.finishSessionCatalogMutation?.(t);break;case"agent_selected":if(!Lu(e,t))break;e.workCenterOpen&&e.workCenterAgentId&&e.listWorkItems(e.workCenterAgentId).catch(()=>{});break;case"conversation_created":mu(e,t);break;case"conversation_resumed":vu(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":Su(e,t);break;case"conversation_deleted":Ja(e,t);break;case"conversation_delete_result":t.ok&&Ja(e,t);break;case"turn_completed":yu(e,t);break;case"conversation_closed":bu(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":Au(e,t);break;case"yeaft_history_outline":e.handleYeaftHistoryOutline(t);break;case"yeaft_history_search_result":e.handleYeaftHistorySearchResult(t);break;case"yeaft_history_window":{let n=e.pendingYeaftHistoryWindow?.(t);if(!n||(n.pending?.prefetch===!0&&(t.prefetch=!0),e.pendingYeaftHistoryWindow?.(t)?.pending!==n.pending))break;let r=t.error?null:Iu(e,t);e.handleYeaftHistoryWindow(t,r);break}case"yeaft_tool_stats":{e._fetchYeaftToolStatsTimer&&(clearTimeout(e._fetchYeaftToolStatsTimer),e._fetchYeaftToolStatsTimer=null);let n=t?.snapshot,r=n&&typeof n=="object"&&!Array.isArray(n)?n:{};e.yeaftToolStats={snapshot:r,registered:Array.isArray(t?.registered)?t.registered:[],unused:Array.isArray(t?.unused)?t.unused:[],error:typeof t?.error=="string"?t.error:null,notice:typeof t?.notice=="string"?t.notice:null,fetchedAt:Date.now()},e.yeaftToolStatsLoading=!1;break}case"yeaft_debug_history":{let n=e.yeaftDebugPanel?.agentId||null;if(n&&t?.agentId&&t.agentId!==n)break;let r=typeof t?.requestId=="string"?t.requestId:"",i=typeof t?.detailTurnId=="string"&&t.detailTurnId,o=i?e._yeaftDebugHistoryLatestDetailRequestId:e._yeaftDebugHistoryLatestListRequestId;if(o&&r!==o||!o&&r)break;let a=e._yeaftDebugHistoryPending?.payload;if(a&&(a.requestId!==r||a.agentId!==t.agentId||t.sessionId&&a.sessionId!==t.sessionId))break;e._yeaftDebugHistoryPending=null,Un(e),e._fetchYeaftDebugHistoryTimer&&(clearTimeout(e._fetchYeaftDebugHistoryTimer),e._fetchYeaftDebugHistoryTimer=null),e._yeaftDebugHistoryInFlightKey=null;let l=Array.isArray(t?.turns)?t.turns:[],c=t?.search?Xy:Qy,d=i?l:l.slice(-c),u=new Set(d.map(x=>x?.turnId).filter(Boolean)),p=ib(Array.isArray(t?.loops)?t.loops:[]),f=i?p:p.filter(x=>!x?.turnId||u.has(x.turnId)),g=Array.isArray(t?.dreamEvents)?t.dreamEvents:[];e.yeaftDebugHistoryHasMore=!!t?.hasMore||!i&&l.length>d.length,!t?.detailTurnId&&Number.isFinite(t?.limit)&&t.limit>0&&(e.yeaftDebugHistoryLimit=Math.min(c,t.limit)),(!e.yeaftDebugTurnsById||typeof e.yeaftDebugTurnsById!="object")&&(e.yeaftDebugTurnsById={}),Array.isArray(e.yeaftDebugLoops)||(e.yeaftDebugLoops=[]),Array.isArray(e.yeaftDebugTurnOrder)||(e.yeaftDebugTurnOrder=[]);let v=i?{...e.yeaftDebugTurnsById}:{};for(let x of d){let B=x?.turnId;if(!B)continue;let D=v[B];if(D){let U=x?.detailsLoaded?{...D,...x}:{...x,...D};U.memoryLoaded==null&&D.memoryLoaded!=null&&(U.memoryLoaded=D.memoryLoaded),U.memoryAdjust==null&&D.memoryAdjust!=null&&(U.memoryAdjust=D.memoryAdjust),v[B]=U}else v[B]=x}e.yeaftDebugTurnsById=v;let m=x=>x?.loopInstanceId||`${x?.turnId||""}#${x?.loopNumber||0}`,y=e.yeaftDebugLoops,h=new Map;for(let x of y)x&&h.set(m(x),x);let w=new Set,S=[];for(let x of f){if(!x)continue;let B=m(x);w.add(B);let D=h.get(B);S.push(i?{...D||{},...x}:D||x)}if(i)for(let x of y)!x||w.has(m(x))||S.push(x);e.yeaftDebugLoops=S;let b=new Set,k=[],P=x=>{!x||b.has(x)||(b.add(x),k.push(x))};if(i){for(let x of e.yeaftDebugTurnOrder)P(x);for(let x of d)P(x?.turnId)}else for(let x of d)P(x?.turnId);e.yeaftDebugTurnOrder=i?k:k.slice(-c);for(let x of g){if(!x)continue;let B=null,D=x.sessionId||x.groupId;typeof x.target=="string"&&x.target.includes("/")?B=x.target:typeof D=="string"&&D?B=`group/${D}`:B="*",typeof e._appendDreamEvent=="function"&&e._appendDreamEvent(B,x),x.type==="dream_progress"&&typeof e.handleYeaftOutput=="function"&&e.handleYeaftOutput({event:x})}e.yeaftDebugHistoryLoading=!1,e.yeaftDebugHistoryError=typeof t?.error=="string"?t.error:null,e.yeaftDebugHistoryProjection=t?.projection&&typeof t.projection=="object"?t.projection:null,e.yeaftDebugHistoryFetchedAt=Date.now(),e._yeaftDebugDetailDirty&&!e.yeaftDebugHistoryError&&e.scheduleYeaftDebugDetailRefresh?.({agentId:e.yeaftDebugPanel?.agentId,sessionId:e.yeaftDebugPanel?.sessionId},e.yeaftDebugPanel?.turnId),i&&e.yeaftDebugPanel&&e.yeaftDebugPanel.turnId===t.detailTurnId&&(e.yeaftDebugPanel={...e.yeaftDebugPanel,status:e.yeaftDebugHistoryError?"error":"ready",error:e.yeaftDebugHistoryError});break}case"chat_image":t.conversationId&&t.fileId&&e.addMessageToConversation(t.conversationId,{type:"chat-image",fileId:t.fileId,previewToken:t.previewToken,mimeType:t.mimeType});break;case"error":{let n=t.conversationId||e.currentConversation,r=["Permission denied","Agent not found","No conversation selected","Agent is still syncing","No agent available","Agent access denied"].some(c=>t.message?.includes(c));if((t.message?.includes("Agent is still syncing")||t.message?.includes("Agent not found"))&&Yt(e),["No conversation selected","Agent is still syncing","No agent available"].some(c=>t.message?.includes(c))&&n&&(delete e.processingConversations[n],qe(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 p=e.messagesMap[n];if(p){let f=p.findIndex(g=>g.id===u.id);f>=0&&p.splice(f,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 p=u.findIndex(f=>f.id===d);p>=0&&u.splice(p,1)}},5e3)}!r&&n&&(delete e.processingConversations[n],qe(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":wu(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":ku(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"){qe(e,n),au(e,n);break}if(t.status==="ok")e.sessionHealth?.[n]&&delete e.sessionHealth[n],!t.isProcessing&&e.processingConversations[n]&&(delete e.processingConversations[n],qe(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],qe(e,n),e.finishStreamingForConversation(n)}break}case"ask_user_question":if(t.conversationId){let n=()=>{let r=e.messagesMap[t.conversationId]||[];for(let i=r.length-1;i>=0;i--)if(r[i].type==="tool-use"&&r[i].toolName==="AskUserQuestion"&&!r[i].askRequestId)return r[i].askRequestId=t.requestId,r[i].askQuestions=t.questions,!0;return!1};if(!n()){let r=0,i=setInterval(()=>{r++,(n()||r>=10)&&clearInterval(i)},200)}}break;case"dream_enabled_changed":{let n=e.agentDreamState?.[t.agentId]||{},r=!!t.requestId&&n.requestId===t.requestId;if(!n.pending||!r)break;clearTimeout(n.timer);let i=typeof t.enabled=="boolean"?t.enabled:n.authoritative!==!1,o=Array.isArray(e.agents)?e.agents.find(a=>a.id===t.agentId):null;o&&(o.dreamEnabled=i),e.agentDreamState={...e.agentDreamState,[t.agentId]:{...n,pending:!1,timer:null,authoritative:i,error:t.error||null}};break}case"restart_agent_ack":{let n=e.agentOperations?.[t.agentId]?.restart,r=!!t.requestId&&n?.requestId===t.requestId;if(!n?.pending||!r)break;n.pending&&(e.agentOperations={...e.agentOperations,[t.agentId]:{...e.agentOperations[t.agentId]||{},restart:{...n,acknowledged:!0}}}),window.dispatchEvent(new CustomEvent("agent-restart-ack",{detail:{agentId:t.agentId,requestId:t.requestId}}));break}case"upgrade_agent_ack":{let n=e.agentOperations?.[t.agentId]?.upgrade,r=!!t.requestId&&n?.requestId===t.requestId;if(!n?.pending||!r)break;n.pending&&(!t.success||t.alreadyLatest?(n.batchId&&t.alreadyLatest?e.recordAgentUpgradeBatchResult?.(t.agentId,{status:"already_latest",version:t.version||null},n.batchId):n.batchId&&!t.success&&e.recordAgentUpgradeBatchResult?.(t.agentId,{status:"failed",error:t.error||null,reason:t.reason||null,version:t.version||null},n.batchId),e.finishAgentOperation?.(t.agentId,"upgrade",t.error||null)):e.agentOperations={...e.agentOperations,[t.agentId]:{...e.agentOperations[t.agentId]||{},upgrade:{...n,acknowledged:!0}}}),window.dispatchEvent(new CustomEvent("agent-upgrade-ack",{detail:{agentId:t.agentId,requestId:t.requestId,batchId:n.batchId||null,success:t.success,error:t.error,alreadyLatest:t.alreadyLatest,version:t.version,reason:t.reason,currentNode:t.currentNode,requiredNode:t.requiredNode,requiredCapability:t.requiredCapability}}));break}case"browser_runtime_status_result":case"browser_runtime_install_progress":case"browser_runtime_error":case"browser_session_created":case"browser_session_error":case"browser_session_snapshot":case"browser_session_list_result":case"browser_peer_prepared":case"browser_peer_offer":case"browser_peer_ice_candidate":case"browser_peer_state":case"browser_peer_error":window.dispatchEvent(new CustomEvent("browser-runtime-message",{detail:t}));break;case"terminal_created":case"terminal_output":case"terminal_closed":case"terminal_error":case"file_content":case"file_references_resolved":case"file_saved":case"directory_listing":case"git_status_result":case"git_diff_result":case"git_op_result":case"file_op_result":case"file_search_result":case"file_tabs_restored":t.type,t.type,window.dispatchEvent(new CustomEvent("workbench-message",{detail:t}));break;case"server_updating":e.connectionState="updating";break;case"context_usage":e.contextUsage={inputTokens:t.inputTokens,maxTokens:t.maxTokens,percentage:t.percentage,conversationId:t.conversationId};break;case"mcp_servers_list":case"mcp_config_updated":t.agentId&&t.servers&&(e.mcpServers[t.agentId]=t.servers);break;case"expert_roles_list":t.roles&&(e.expertRoleDefinitions=t.roles);break;case"llm_models_discovered":t.agentId&&(e.llmModelDiscovery=e.llmModelDiscovery||{},e.llmModelDiscovery[t.agentId]=t);break;case"llm_config":case"llm_config_updated":if(t.agentId){let n=t.agentConfig||Gy(t),r=t.effectiveConfig||n;e.llmConfig[t.agentId]={providers:t.providers||r.providers||[],primaryModel:t.primaryModel||r.primaryModel||null,fastModel:t.fastModel||r.fastModel||null,language:t.language||n.language||r.language||"en",needsSetup:t.needsSetup??r.needsSetup??!1,agentConfig:n,effectiveConfig:r,requestId:t.requestId||null,statusRefreshError:t.statusRefreshError||null,error:t.error||null,loaded:!0}}break;case"models_dev_registry":if(e.modelsDevRegistry={registry:t.registry||{},fetchedAt:t.fetchedAt||Date.now(),error:t.error||null,loaded:!0},e._modelsDevPending){let n=e._modelsDevPending;e._modelsDevPending=null,n.timer&&clearTimeout(n.timer);for(let r of n.resolvers)r(e.modelsDevRegistry)}break;case"yeaft_settings":case"yeaft_settings_updated":t.agentId&&(e.yeaftSettings[t.agentId]={maxConcurrentThreads:t.maxConcurrentThreads??6,autoArchiveIdleDays:t.autoArchiveIdleDays??30,error:t.error||null,loaded:!0,at:Date.now()});break;case"yeaft_plugins":case"yeaft_plugins_updated":{let n={plugins:t.plugins&&typeof t.plugins=="object"?t.plugins:{},error:t.error||null,loaded:!0,at:Date.now()};t.agentId&&(e.pluginConfigByAgent={...e.pluginConfigByAgent,[t.agentId]:n});let r=t.requestId?e._pluginPending?.[t.requestId]:null;r&&(clearTimeout(r.timer),delete e._pluginPending[t.requestId],r.resolve(n));break}case"yeaft_managed_skill_result":{let n=t.requestId?e._pluginPending?.[t.requestId]:null,r=n?.kind==="managed-skill"?n:null,i=t.catalog&&typeof t.catalog=="object"?{tools:Array.isArray(t.catalog.tools)?t.catalog.tools:[],skills:Array.isArray(t.catalog.skills)?t.catalog.skills:[],skillSources:Array.isArray(t.catalog.skillSources)?t.catalog.skillSources:[],mcpServers:Array.isArray(t.catalog.mcpServers)?t.catalog.mcpServers:[]}:{tools:[],skills:[],skillSources:[],mcpServers:[]};if(r&&e.managedSkillRequestByKey?.[r.key]===t.requestId){let o=e.pluginCatalogKey?.(r.agentId,r.workDir||"")||"";e.pluginCatalogByKey={...e.pluginCatalogByKey,[o]:{catalog:i,loading:!1,error:t.error||null,loaded:!0,at:Date.now()}}}r&&(clearTimeout(r.timer),delete e._pluginPending[t.requestId],r.resolve({catalog:i,error:t.error||null,result:t.result||null}));break}case"yeaft_plugin_catalog_result":{let n=t.requestId?e._pluginPending?.[t.requestId]:null,r=n?.kind==="catalog"?n:null,i=t.catalog&&typeof t.catalog=="object"?{tools:Array.isArray(t.catalog.tools)?t.catalog.tools:[],skills:Array.isArray(t.catalog.skills)?t.catalog.skills:[],skillSources:Array.isArray(t.catalog.skillSources)?t.catalog.skillSources:[],mcpServers:Array.isArray(t.catalog.mcpServers)?t.catalog.mcpServers:[]}:{tools:[],skills:[],skillSources:[],mcpServers:[]},o=r?.key;o&&e.pluginCatalogRequestByKey?.[o]===t.requestId&&(e.pluginCatalogByKey={...e.pluginCatalogByKey,[o]:{catalog:i,loading:!1,error:t.error||null,loaded:!0,at:Date.now()}}),r&&(clearTimeout(r.timer),delete e._pluginPending[t.requestId],r.resolve({catalog:i,error:t.error||null}));break}case"telemetry_settings":case"telemetry_settings_updated":{let n={enabled:t.enabled!==!1,retentionDays:t.retentionDays??3,flushIntervalMs:t.flushIntervalMs??1e3,maxQueueSize:t.maxQueueSize??5e3,rawExchangeMaxBytes:t.rawExchangeMaxBytes??524288,traceTextMaxBytes:t.traceTextMaxBytes??262144,error:t.error||null,loaded:!0,at:Date.now()},r=t.type==="telemetry_settings_updated"?"update":"load",i=t.requestId?{requestId:t.requestId,pending:e._telemetryPending?.[t.requestId]}:null,o=i?.pending;if(!o||o.agentId!==t.agentId||o.operation!==r)break;clearTimeout(o.timer),delete e._telemetryPending[i.requestId],e.telemetryRequestByAgent?.[o.agentId]===i.requestId&&(e.telemetrySettingsByAgent={...e.telemetrySettingsByAgent,[o.agentId]:n},e.currentAgent===o.agentId&&(e.telemetrySettings=n)),o.resolve(n);break}case"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 Qy,Xy,Zy,Jy,Vu,il,Bu=W(()=>{Lt();$i();zt();Fs();an();sl();to();Ou();Ji();Qy=1,Xy=5,Zy=500,Jy=512*1024,Vu=3e4,il=new WeakMap});function Wu(){return Object.values(Nu).sort((t,s)=>t.order-s.order).map(t=>({teamId:t.id,team:t,roles:Object.values(jt).filter(s=>s.group===t.id)}))}function ju(e){let t=[];for(let s of Object.values(jt)){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 hn(e,t){let s=jt[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 ol(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=>!jt[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(p=>p.id===l);if(!d)return null;let u;if(c&&d.actions){let p=d.actions.find(f=>f.id===c);p?s?(u=(r?p.messageTemplate:p.messageTemplateEn)||"",u+=s):u=(r?p.defaultMessage:p.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(p=>p.id===l),u=jt[l];if(d)if(c){let p=d.actions?.find(f=>f.id===c);p&&o.push((r?p.messageTemplate:p.messageTemplateEn)||"")}else o.push((r?d.messagePrefix:d.messagePrefixEn)||"");else if(u)return null}return o.length===0?null:{effectivePrompt:o.join(`
|
|
4
4
|
---
|
|
@@ -7,7 +7,7 @@ ${p}`:p,f=!0;break}}if(!f){for(let g=c.length-1;g>=0;g--)if(c[g].type==="tool-us
|
|
|
7
7
|
|
|
8
8
|
`))}function io(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||hl.has(l?.status)||hl.has(l?.turnEndReason)||hl.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 hl,oo=W(()=>{hl=new Set(["aborted","errored","error","cancelled","canceled"])});function bs(e){return typeof e=="string"?e.trim():""}function dt(e){let t=bs(e?.runtimeProvider),s=bs(e?.agentId),n=bs(e?.sessionId);return!t||!s||!n?"":[t,s,n].map(r=>encodeURIComponent(r)).join(":")}function bb(e){let t=0xcbf29ce484222325n;for(let s of String(e||""))t^=BigInt(s.codePointAt(0)),t=BigInt.asUintN(64,t*0x100000001b3n);return t.toString(16).padStart(16,"0")}function yn(e,t){let s=bs(e),n=bs(t);return!s||!n?"":`${s}@${bb(n)}`}function Yr(e,t="main"){if(!e)return"";let s=["main","files-folder-picker","git-folder-picker"].includes(t)?t:"main";return s==="main"?`_workbench:${e}`:`_workbench:${e}:${s}`}function es(e,t){let s=bs(e?.conversationId);if(!t||!s)return null;if(s===Yr(t))return"main";for(let n of["files-folder-picker","git-folder-picker"])if(s===Yr(t,n))return n;return null}function Qn(e,t){let s=(n={})=>{let r={runtimeProvider:bs(t.runtimeProvider),agentId:bs(t.agentId),sessionId:bs(t.sessionId)},i="main";n.conversationId==="_folder_picker"?i="files-folder-picker":n.conversationId==="_git_folder_picker"&&(i="git-folder-picker");let o={...n,agentId:r.agentId,workbenchRoute:r,workbenchRouteKey:t.routeKey,workbenchWorkspaceGeneration:t.workspaceGeneration,workbenchScope:i,conversationId:Yr(t.routeKey,i)};return!Object.hasOwn(o,"workDir")&&t.workDir&&(o.workDir=t.workDir),e.sendWsMessage(o)};return new Proxy(e,{get(n,r,i){return r==="currentAgent"?t.agentId||null:r==="currentConversation"?t.conversationId||t.sessionId||null:r==="effectiveWorkDir"?t.workDir||"":r==="activeSessionRoute"?{runtimeProvider:t.runtimeProvider,agentId:t.agentId,sessionId:t.sessionId}:r==="sendWsMessage"?s:Reflect.get(n,r,i)},set(n,r,i,o){return Reflect.set(n,r,i,o)}})}function Xn(e,t,s=""){return t?(e?.workbenchRouteKey?e.workbenchRouteKey===t:es(e,t)!==null)?s?e?.workbenchWorkspaceGeneration===s:!0:!1:!0}var ws=W(()=>{});function ml(e){return e?.type==="user"&&typeof e.content=="string"&&e.content.trim()}function vl(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 yl(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 bl(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(ml(i)||i.type==="system"||i.type==="error"){n(r),s={start:r,kind:i.type};continue}if(!vl(i)){s||(s={start:r,kind:"other"});continue}(!s||s.kind==="assistant"&&yl(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 Vp(e,t){return!e||e._historyWindowPrefetched===!0?!1:t?(e.sessionId??e.groupId)===t:!0}function wl(e=[],t=null,s=Gr,n=null){let r=Math.max(1,Number.isFinite(s)?Math.floor(s):Gr),i=[],o=[],a=null,l=d=>{a&&(o.push({start:a.start,end:d,kind:a.kind}),a=null)};for(let d of e){if(!Vp(d,t))continue;let u=i.length;if(i.push(d),ml(d)||d.type==="system"||d.type==="error"){l(u),a={start:u,kind:d.type};continue}if(!vl(d)){a||(a={start:u,kind:"other"});continue}(!a||a.kind==="assistant"&&yl(a,d))&&(l(u),a={start:u,kind:"assistant",turnId:d.turnId||"",speakerVpId:d.speakerVpId||d.vpId||""}),a.lastTurnId=d.turnId||a.lastTurnId||"",a.speakerVpId=a.speakerVpId||d.speakerVpId||d.vpId||""}if(l(i.length),o.length<=r)return i;let c=o[o.length-r];return i.slice(c.start)}function qp(e=[],t=null,s=Gr){let n=Math.max(1,s||Gr),r=0,i=null,o=()=>i?(i=null,r+=1,r>n):!1;for(let a of e)if(Vp(a,t)){if(ml(a)||a.type==="system"||a.type==="error"){if(o())return!0;i={kind:a.type};continue}if(!vl(a)){i||(i={kind:"other"});continue}if(!i||i.kind==="assistant"&&yl(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 Ws(){return Gr}function Qr(){return wb}var Gr,wb,Fp=W(()=>{Gr=Number.POSITIVE_INFINITY,wb=20});function Sb(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=ts();for(let r of n?.sessionList||[])r?.id===t&&r?.agentId&&s.add(r.agentId)}return s}function ef(e,t){let s=Sb(e,t);return s.size===1?s.values().next().value:null}function co(e,t,s){return!!s&&ef(e,t)===s}function Mt(e,t,s){return!e||e.sessionId!==t?!1:s?e.agentId===s:!e.agentId}function Hp(e,t,s=null){if(!t)return!1;let n=s||Me(e,t),r=ys(n,t);if(r&&e.yeaftProcessingSessions?.[r]||e.yeaftProcessingSessions?.[t]&&co(e,t,n))return!0;for(let i of Object.values(e.activeVpTurns||{}))if(Mt(i,t,n))return!0;for(let i of Object.values(e.vpStatuses||{}))if(Mt(i,t,n)&&Zr.has(i?.state))return!0;return!1}function Ib(e,t,s,n=null){let r={...e.yeaftProcessingSessions||{}};if(t){let i=nl(t);if(r=Object.fromEntries(Object.entries(r).filter(([o])=>n?o!==ys(t,n):!o.startsWith(i))),n)co(e,n,t)&&delete r[n];else for(let o of Object.keys(r))co(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||!Zr.has(i?.state))continue;let a=ys(t,o)||o;r[a]=!0}return r}function bn(e,t,s){let n=rl(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 Bp(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=nl(t);e.yeaftProcessingSessions=Object.fromEntries(Object.entries(e.yeaftProcessingSessions||{}).filter(([n])=>!n.startsWith(s)))}function ks(e,t){return`${e||""}:${t||""}`}function Rb(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 _b(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 Db(e={}){let t=It(e.quote);return{agentId:e.agentId||"",workItemId:e.workItemId||"",target:Rb(e.target),text:String(e.text||""),...t?{quote:t}:{},attachments:Array.isArray(e.attachments)?e.attachments.map(s=>({fileId:s?.fileId||"",name:s?.name||"",mimeType:s?.mimeType||"",size:Math.max(0,Number(s?.size)||0)})):[],revision:Number(e.revision)||0,planRevision:Number(e.planRevision)||0,ledgerRevision:Number(e.ledgerRevision)||0,coordinatorRevision:Number(e.coordinatorRevision)||0}}function jp(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 Up(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 Eb(e,t){return Tl.every(s=>!t[s]||e[s]===t[s])}function tf(e,t){return Tl.every(s=>!e[s]||!t[s]||e[s]===t[s])}function Kp(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=>Eb(Up(o,s),t));if(r.length===1)return r[0];let i=n.filter(o=>tf(Up(o,s),t));return i.length===1?i[0]:null}function sf(e){return Tl.map(t=>e[t]||"").join("\0")}function $b(e,t,s){let n=sf(t),r={...e._yeaftAskTerminalEvents||{},[n]:{identity:t,event:s,receivedAt:Date.now()}},i=Object.keys(r);if(i.length>Wp){i.sort((o,a)=>r[o].receivedAt-r[a].receivedAt);for(let o of i.slice(0,i.length-Wp))delete r[o]}e._yeaftAskTerminalEvents=r}function zp(e,t){let s=e._yeaftAskTerminalEvents||{},n=sf(t),r=s[n]?n:null;if(!r){let l=Object.entries(s).filter(([,c])=>tf(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 Lb(e,t,s){return(e.messagesMap?.[t]||[]).some(n=>n?.type==="tool-use"&&n.sessionId===s&&n.hasResult===!1)}function Sl(e,t){if(!(t.type==="ask_user_answer_rejected"&&(e.askAnswered||e.askExpired))){if(t.type==="ask_user_answer_rejected"&&t.reason==="agent_unavailable"){e.askError="agent_unavailable",e.askSubmittedAt=0;return}e.askError=t.type==="ask_user_answer_rejected"?t.reason||"unavailable":null,e.askSubmittedAt=null,t.type==="ask_user_answered"?(e.askAnswered=!0,e.selectedAnswers=t.answers||{},e.askExpired=!1):(e.isHistory=!0,e.askExpired=!0,e.askAnswered=!1,e.selectedAnswers=null),e.askPending=!1,e.pendingAnswers=null,e.askSubmitGeneration=null,e.askRequestId=null}}function Ob(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 Vb(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 Xr(e){return _r(e)}function Il(e,t,s){return`${ys(e,t)}::${s||""}`}function Cl(e){return Object.fromEntries(Object.entries(e||{}).filter(([,t])=>t?.status==="running"))}function ts(){try{return typeof window>"u"?null:window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore()||null}catch{return null}}function Yp(e){let t=ts();if(!t?.reorderSessionsGlobally)return;let s=(Array.isArray(e)?e:[]).filter(n=>n?.runtimeProvider==="yeaft").map(n=>`${n.routeRef?.agentId||""}${n.routeRef?.sessionId||""}`).filter(n=>!n.startsWith(""));t.reorderSessionsGlobally(s)}function Me(e,t,s=null){if(s)return s;if(t){let n=ts(),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 Gp(e){let t=Is(e),s=Me(e,t),n=ts()?.sessionById?.(t,s),r=e.currentAgentInfo?.id===s?e.currentAgentInfo:e.agents?.find(o=>o?.id===s),i=o=>typeof o=="string"?o.trim():"";return i(n?.workDir)||i(r?.workDir)}function qb(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 Tt(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"&&qb(n?.version||r?.version,"1.0.166")}function Is(e,{fallbackDefault:t=!1}={}){if(e?.yeaftActiveSessionFilter)return e.yeaftActiveSessionFilter;let s=ts();return s?.activeSessionId?s.activeSessionId:t?"grp_default":null}function lo(e){let t=e.yeaftDebugSessionFilter;if(t==="__all__")return null;if(t)return t;let s=Is(e);return s||(ts()?.sessions?.grp_default?"grp_default":null)}function Al(e,t="session"){return[e?.vpId||e?.ownerVpId||"vp",e?.threadId||"thread",e?.turnId||t].join(":")}function Ss(e,t,s=null){return s||t&&e?.yeaftConversationIdsByAgent?.[t]||e?.yeaftConversationId||null}function yt(e,t=null,s=null){let n=t||e?.yeaftActiveSessionFilter||null,r=s||Me(e,n);return(r&&e?.yeaftConversationIdsByAgent?e.yeaftConversationIdsByAgent[r]:null)||e?.yeaftConversationId||null}function Qp(e,t,s){if(e?.currentView!=="yeaft")return!1;let n=e?.yeaftActiveSessionFilter||null;if(n&&t!==n)return!1;let r=Me(e,n);return!r||!s||r===s}var kb,Qe,ao,kl,Cb,Ab,xb,Np,Tb,Zr,Mb,Pb,Wp,Tl,Xp,xl,Zp,Jp,wn,uo=W(()=>{Lt();xa();zt();qi();Pa();Da();Vr();Mu();Bu();up();an();Fs();$r();vp();Ya();Yi();wp();kp();Ip();Hi();gl();Xa();Ns();oo();ws();Vn();Bi();to();Fp();Wi();Za();({defineStore:kb}=Pinia),Qe=Object.freeze([]),ao=(e,t,s)=>`${e||""}::${t||""}::${s}`;kl=5,Cb=100,Ab=512*1024,xb=15e3,Np=Object.freeze([150,300,600,1e3]),Tb=new Set(["index_building","stale_result"]),Zr=new Set(["typing","thinking","retrying","streaming","tool"]),Mb=Object.freeze(["model","availableModels","refreshedAt","catalogRefreshedAt","catalogEpoch","catalogRevision","catalogDigest","refreshStartedAt","refreshReason","refreshError","refreshing"]),Pb=8,Wp=64;Tl=Object.freeze(["conversationId","agentId","requestId","toolCallId","sessionId","vpId","turnId","threadId"]);Xp=1e3,xl=1,Zp=5,Jp=200,wn=kb("chat",{state:()=>({ws:null,authenticated:!1,_hasHandledAgentList:!1,_hasHandledYeaftSessionHydrate:!1,yeaftSessionInventoryCompleteSupported:null,workbenchRouteProtocolSupported:null,browserRuntimeProtocolSupported:null,browserRuntimeSetupProtocolSupported:null,browserRuntimeServerEnabled:!1,yeaftSessionHydrateRequestId:null,yeaftSessionHydrateSlices:[],yeaftSessionHydrateError:null,_yeaftSessionInventorySocketQuarantined:!1,sessionKey:null,serverEncryptionRequired:!0,connectionState:"disconnected",reconnectAttempts:0,maxReconnectAttempts:10,reconnectTimer:null,agents:[],currentAgent:null,currentAgentInfo:null,conversations:[],activeConversations:[],currentWorkDir:null,messagesMap:{},_messageUiKeySequence:0,chatSessionState:{},panels:[],activePanelId:null,_pendingPaneId:null,conversationTitles:{},customConversationTitles:{},processingConversations:{},yeaftProcessingSessions:{},yeaftUnreadSessionKeys:{},theme:localStorage.getItem("theme")||(typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),themeFollowSystem:!localStorage.getItem("theme"),locale:localStorage.getItem("locale")||"zh-CN",executionStatusMap:{},sessionHealth:{},historySessions:[],historySessionsLoading:!1,folders:[],foldersLoading:!1,providerModels:[],providerModelsLoading:!1,contextUsage:null,lastUsedAgent:localStorage.getItem("lastUsedAgent")||null,lastUsedSession:JSON.parse(localStorage.getItem("lastUsedSession")||"null"),lastViewedConversation:localStorage.getItem("lastViewedConversation")||null,pendingRecovery:null,recoveryDismissed:!1,sessionLoading:!1,sessionLoadingText:"",agentSwitching:!1,pendingAgentSelection:null,_pendingSessionTitle:null,workbenchExpanded:!1,workbenchMaximized:!1,workbenchPanelStateByRoute:{},sidebarCollapsed:!1,sessionSidebarOpen:!1,compactStatus:null,clearStatus:null,refreshingSession:!1,refreshingSessionMap:{},proxyPorts:{},hasMoreMessages:!1,loadingMoreMessages:!1,chatHistoryRequests:{},chatHistoryRequestIdSupported:null,chatHistoryConnectionGeneration:0,sessionCatalog:[],hiddenSessionCatalog:[],sessionProjects:[],sessionCatalogLoaded:!1,sessionCatalogMutationRequests:{},projectMutationRequests:{},activeCatalogKey:null,openUnifiedSessionCreate:!1,openUnifiedChatCreate:!1,pendingUnifiedSessionSettings:null,pluginCenterOpen:!1,pluginCenterAgentId:null,pluginConfigByAgent:{},pluginCatalogByKey:{},pluginCatalogRequestByKey:{},managedSkillRequestByKey:{},_pluginPending:{},yeaftHasMoreHistory:!1,yeaftLoadingMoreHistory:!1,yeaftOldestLoadedSeq:null,yeaftHistoryLoadError:null,_yeaftManualHistoryRefresh:null,yeaftSessionHistoryState:{},yeaftMessageWindowState:{},yeaftHistoryCacheState:{},yeaftBootstrapMetaLoadingKey:null,yeaftHistoryPerfTraceBySession:{},_yeaftHistoryPrefetchBySession:{},yeaftHistorySearchState:{requestId:null,agentId:null,sessionId:null,query:"",senderKey:"",loading:!1,results:[],hasMore:!1,nextBeforeSeq:null,nextCursor:null,error:null},yeaftHistoryOutlineBySession:{},_yeaftHistoryOutlineTimeouts:{},_yeaftHistorySearchTimeout:null,_yeaftHistoryWindowPendingByKey:{},_yeaftHistoryResultRefreshByRequestId:{},_yeaftHistoryRevealLeases:{},_yeaftHistoryRevealSequence:0,yeaftHistoryFocusWindowBySession:{},_yeaftReconnectCatchUpPending:!1,_yeaftOpenedSessionsLoadedAgents:{},_yeaftAgentSeen:null,slashCommandsMap:{},slashCommandDescriptions:{},inputDrafts:{},mcpServers:{},expertRoleDefinitions:null,llmConfig:{},llmModelDiscovery:{},llmGithubDevice:null,modelsDevRegistry:{registry:{},fetchedAt:0,error:null,loaded:!1},_modelsDevPending:null,yeaftSettings:{},searchSettings:null,telemetrySettings:null,telemetrySettingsByAgent:{},telemetryRequestByAgent:{},agentOperations:{},agentUpgradeBatch:null,agentDreamState:{},tavilyUsage:null,tavilyUsageLoading:!1,_perfTraceQueue:[],_perfTraceFlushTimer:null,yeaftPerfTraceByMessageId:{},yeaftPerfTraceByTurnId:{},yeaftMcpServers:[],yeaftMcpRuntime:{connected:!1,toolCount:0,perServer:[]},yeaftMcpLoading:!1,yeaftMcpError:null,btwMode:!1,btwMessages:[],btwLoading:!1,btwSessionId:null,conversationMcpServers:{},conversationMcpServerTools:{},mcpPanelOpen:!1,expertSelections:[],customExpertRoles:[],subagents:{},activeSubagentId:null,activeRightPanel:null,pinnedSessions:JSON.parse(localStorage.getItem("pinned-sessions")||"[]"),...gp(),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,yeaftDebugHistoryProjection:null,yeaftDebugHistoryLimit:xl,yeaftDebugHistoryHasMore:!1,yeaftDebugPanel:{open:!1,status:"idle",requestId:null,agentId:null,sessionId:null,turnId:null,error:null},yeaftDebugSearch:"",yeaftDebugSessionFilter:null,yeaftDreamLatest:{},yeaftDreamSnapshots:{},yeaftDreamPromptLoads:{},yeaftDreamEvents:{},yeaftReflectionCards:{},yeaftSubAgentCards:{},yeaftSidebarV2Enabled:!0,yeaftActiveSessionFilter:null,_currentYeaftSessionId:null,_currentYeaftVpId:null,_currentYeaftTurnId:null,_currentYeaftThreadId:null,_yeaftAskTerminalEvents:{},activeVpTurns:{},vpStatuses:{},stoppingVpTurnIds:{},yeaftVpTyping:{},_vpCrudPending:null}),getters:{currentConversation:e=>e.activeConversations[0]||null,activeConversationId:e=>so(e),activeSessionRoute(e){if(e.currentView==="yeaft"){let n=Is(e);return n?{runtimeProvider:"yeaft",agentId:Me(e,n),sessionId:n}:null}let t=so(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]||Qe;if(e.currentView==="yeaft"){let n=e.yeaftActiveSessionFilter||null,r=Pe(Me(e,n),n),i=e.yeaftMessageWindowState[r]?.visibleTurns||Ws(),o=e.yeaftHistoryFocusWindowBySession?.[r]?.windowKey||null;return wl(s,e.yeaftActiveSessionFilter||null,i,o)}return s},yeaftAllMessages:e=>{let t=yt(e);return t&&e.messagesMap[t]||Qe},yeaftVisibleMessages(e){let t=yt(e),s=t&&e.messagesMap[t]||Qe,n=e.yeaftActiveSessionFilter||null,r=Pe(Me(e,n),n),i=e.yeaftMessageWindowState[r]?.visibleTurns||Ws(),o=e.yeaftHistoryFocusWindowBySession?.[r]?.windowKey||null;return wl(s,e.yeaftActiveSessionFilter||null,i,o)},hasHiddenYeaftMessages(e){if(e.currentView!=="yeaft")return!1;let t=yt(e),s=t&&e.messagesMap[t]||Qe,n=e.yeaftActiveSessionFilter||null,r=Pe(Me(e,n),n),i=e.yeaftMessageWindowState[r]?.visibleTurns||Ws();return qp(s,e.yeaftActiveSessionFilter||null,i)},activeYeaftHistoryState(e){return La(e)},yeaftManualHistoryRefreshLoading(e){let t=e._yeaftManualHistoryRefresh||null;if(!t?.requestId)return!1;let s=Pe(t.agentId,t.sessionId),n=Wt(e),r=e.yeaftSessionHistoryState?.[s]||null;return n.sessionKey===s&&r?.loading===!0&&r.requestId===t.requestId},yeaftInitialHistoryLoading(e){let t=La(e);return e.currentView==="yeaft"&&!!e.yeaftActiveSessionFilter&&!!t?.loading&&!t?.loaded&&this.yeaftVisibleMessages.length===0},vpsTypingInCurrentConv(e){let t=this.activeConversationId;if(!t)return Qe;let s=(e.yeaftVpTyping||{})[t];if(!s)return Qe;let n=Object.keys(s).filter(r=>(s[r]||0)>0);return n.length===0?Qe: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=lo(e);if(!t)return null;let s=`sessions/${t}`;return e.yeaftDreamLatest?.[s]||null},yeaftDreamSnapshotForActiveSession(e){let t=lo(e);if(!t)return null;let s=`sessions/${t}`;return e.yeaftDreamSnapshots?.[s]||null},yeaftDreamPromptLoadForActiveSession(e){let t=lo(e);if(!t)return null;let s=`sessions/${t}`;return e.yeaftDreamPromptLoads?.[s]||null},yeaftDreamEventsForActiveSession(e){let t=lo(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||Qe,s=e.yeaftDebugTurnsById||{},n=e.yeaftDebugLoops||Qe,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],p=s[u];if(!p||o&&p.sessionId&&p.sessionId!==o)continue;let f=a[u]||Qe,g=l[u]||Qe,v=f.length,m=0,y=0;for(let S of f){let b=S&&S.usage;b&&Number.isFinite(b.totalTokens)?m+=b.totalTokens:b&&(m+=(b.totalInputTokens||(b.inputTokens||0)+(b.cacheReadTokens||0)+(b.cacheWriteTokens||0))+(b.outputTokens||0)),S&&Number.isFinite(S.latencyMs)&&(y+=S.latencyMs)}let h=!p.closedAt,w={...p,loopCount:h||!p.loopCount?v:p.loopCount,totalTokens:h||!p.totalTokens?m:p.totalTokens,totalMs:h||!p.totalMs?y:p.totalMs,loops:f,reflections:g};c.push(w)}return c},yeaftDebugAvailableSessions:e=>{let t=new Set;for(let s of e.yeaftDebugTurnOrder||Qe){let n=e.yeaftDebugTurnsById[s];n&&n.sessionId&&t.add(n.sessionId)}return Array.from(t).sort()},yeaftDebugTurnTotal:e=>(e.yeaftDebugTurnOrder||Qe).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=Is(e);return t?Hp(e,t,Me(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"?Gp(e):e.currentWorkDir||e.currentAgentInfo?.workDir||"",fileReferenceResolutionContextKey:e=>{let t=e.currentView==="yeaft"?(()=>{let o=Is(e);return o?{runtimeProvider:"yeaft",agentId:Me(e,o),sessionId:o}:null})():(()=>{let o=so(e),a=e.conversations.find(l=>l?.id===o&&l.type!=="yeaft");return a?{runtimeProvider:a.provider==="copilot"?"copilot":"claude-code",agentId:a.agentId||e.currentAgent||null,sessionId:o}:null})(),s=t?.agentId||e.currentAgent||null,n=t?.runtimeProvider==="yeaft"?yt(e,t.sessionId,s):e.currentConversation,r=Tt(e,s,"file_reference_resolution");if(!s||!n||!r)return"";let i=e.currentView==="yeaft"?Gp(e):e.currentWorkDir||e.currentAgentInfo?.workDir||"";return JSON.stringify([e.connectionState,e.authenticated,e.workbenchRouteProtocolSupported,t?.runtimeProvider||"",s,t?.sessionId||"",n,i,Tt(e,s,"file_editor"),Tt(e,s,"workbench_session_routes"),Tt(e,s,"response_image_preview")])},currentAgentCapabilities:e=>e.currentAgentInfo?.capabilities||["terminal","file_editor","background_tasks"],hasCapability:e=>t=>(e.currentAgentInfo?.capabilities||["terminal","file_editor","background_tasks"]).includes(t),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)=>Hp(e,t,s),isSessionHistorySyncing:e=>t=>{let s=t?.sessionId||null;return s?t.runtimeProvider==="yeaft"?!!e.yeaftSessionHistoryState?.[Pe(t.agentId||null,s)]?.loading:!!e.chatHistoryRequests?.[Vs(s)]?.loading:!1},isYeaftSessionUnread:e=>(t,s=null)=>{if(!t)return!1;let n=Me(e,t,s);return n?!!e.yeaftUnreadSessionKeys?.[xr(n,t)]:!1},showRecoveryBanner:e=>e.pendingRecovery&&!e.recoveryDismissed&&!e.currentConversation,currentSubagents:e=>{if(!e.currentConversation)return Qe;let t=e.subagents[e.currentConversation];return t?Object.values(t):Qe},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 Qe;let t=e.subagents[e.currentConversation];if(!t)return Qe;let s=t[e.activeSubagentId];return(Array.isArray(s?.messages)?s.messages:Qe).filter(r=>r?.type==="text")},selectedTaskInfo:()=>null,currentMcpServers:e=>e.currentConversation&&e.conversationMcpServers[e.currentConversation]||Qe},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&&ll("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),mp(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},openPluginCenter(e=null){let t=this.agents.find(s=>s?.online&&s.id===e)||this.agents.find(s=>s?.online&&s.id===this.currentAgent)||this.agents.find(s=>s?.online)||null;return t?(this.pluginCenterAgentId=t.id,this.pluginCenterOpen=!0,!0):!1},closePluginCenter(){this.pluginCenterOpen=!1},pluginCatalogKey(e,t=""){return`${e||""}${String(t||"").trim()}`},loadPluginConfig(e=this.pluginCenterAgentId||this.currentAgent){if(!e)return Promise.resolve({plugins:{},error:"no agent"});let t=this.agents.find(n=>n?.id===e);if(!Ln(t))return Promise.resolve({plugins:{},error:"The selected Agent does not support Plugins; upgrade and restart the Agent"});let s=`plugins-get-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;return new Promise(n=>{let r=setTimeout(()=>{this._pluginPending?.[s]&&(delete this._pluginPending[s],n({plugins:{},error:"timeout"}))},1e4);this._pluginPending[s]={resolve:n,timer:r,kind:"config",agentId:e},this.sendWsMessage({type:"get_yeaft_plugins",agentId:e,requestId:s})})},savePluginConfig(e,t=this.pluginCenterAgentId||this.currentAgent){if(!t)return Promise.resolve({plugins:{},error:"no agent"});let s=this.agents.find(r=>r?.id===t);if(!Ln(s))return Promise.resolve({plugins:{},error:"The selected Agent does not support Plugins; upgrade and restart the Agent"});let n=`plugins-save-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;return new Promise(r=>{let i=setTimeout(()=>{this._pluginPending?.[n]&&(delete this._pluginPending[n],r({plugins:{},error:"timeout"}))},1e4);this._pluginPending[n]={resolve:r,timer:i,kind:"save",agentId:t},this.sendWsMessage({type:"update_yeaft_plugins",agentId:t,requestId:n,plugins:e})})},activePluginSession(){let e=this.yeaftActiveSessionFilter||ts()?.activeSessionId||null;if(!e)return{sessionId:"",workDir:""};let t=Me(this,e),s=ts()?.sessionById?.(e,t)||null;return{sessionId:e,agentId:s?.agentId||t||"",workDir:typeof s?.workDir=="string"?s.workDir.trim():""}},managedSkillRequestKey(e,t,s){return`${e||""}${t||""}${s||""}`},mutateManagedSkill({action:e,scope:t,skill:s,name:n,sessionId:r=""}={},i=this.pluginCenterAgentId||this.currentAgent){if(!i)return Promise.resolve({catalog:{tools:[],skills:[],skillSources:[],mcpServers:[]},error:"no agent"});let o=this.agents.find(c=>c?.id===i);if(!Fi(o))return Promise.resolve({catalog:{tools:[],skills:[],skillSources:[],mcpServers:[]},error:"The selected Agent does not support Skill management; upgrade and restart the Agent"});let a=`managed-skill-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,l=this.managedSkillRequestKey(i,t,r);return this.managedSkillRequestByKey={...this.managedSkillRequestByKey,[l]:a},new Promise(c=>{let d=setTimeout(()=>{this._pluginPending?.[a]&&(delete this._pluginPending[a],c({catalog:{tools:[],skills:[],skillSources:[],mcpServers:[]},error:"timeout"}))},1e4);this._pluginPending[a]={resolve:c,timer:d,kind:"managed-skill",agentId:i,key:l,workDir:t==="project"&&this.activePluginSession().workDir||""},this.sendWsMessage({type:"yeaft_managed_skill",agentId:i,requestId:a,action:e,scope:t,...r?{sessionId:r}:{},...s?{skill:s}:{},...n?{name:n}:{}})})},loadPluginCatalog(e=this.pluginCenterAgentId||this.currentAgent,t=""){if(!e)return Promise.resolve({catalog:{tools:[],skills:[],mcpServers:[]},error:"no agent"});let s=this.agents.find(i=>i?.id===e);if(!Ln(s))return Promise.resolve({catalog:{tools:[],skills:[],mcpServers:[]},error:"The selected Agent does not support Plugins; upgrade and restart the Agent"});let n=this.pluginCatalogKey(e,t),r=`plugins-catalog-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;return this.pluginCatalogRequestByKey={...this.pluginCatalogRequestByKey,[n]:r},this.pluginCatalogByKey={...this.pluginCatalogByKey,[n]:{...this.pluginCatalogByKey[n]||{},loading:!0,error:null}},new Promise(i=>{let o=setTimeout(()=>{this._pluginPending?.[r]&&(delete this._pluginPending[r],this.pluginCatalogRequestByKey?.[n]===r&&(this.pluginCatalogByKey={...this.pluginCatalogByKey,[n]:{...this.pluginCatalogByKey[n]||{},loading:!1,error:"timeout"}}),i({catalog:{tools:[],skills:[],mcpServers:[]},error:"timeout"}))},1e4);this._pluginPending[r]={resolve:i,timer:o,kind:"catalog",agentId:e,key:n},this.sendWsMessage({type:"yeaft_plugin_catalog",agentId:e,requestId:r,workDir:String(t||"").trim()})})},enterWorkCenterFromSession(e,t=""){if(!e?.id)return;let s=e.agentId||Me(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=ud(()=>{Ir(this._workCenterBrowserFence)||this.clearWorkCenterBrowserState()}));let e=Oi();if(!e)return this._workCenterBrowserFence=null,this.workCenterComposerDrafts={},this.workCenterMessageOutbox={},!1;if(!Ir(this._workCenterBrowserFence)){let t=dd(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 ks(e,t)},saveWorkCenterComposerDraft(e,t,s={}){let n=ks(e,t);if(!e||!t)return;let r=It(s.quote),i={...this.workCenterComposerDrafts||{},[n]:{text:String(s.text||""),...r?{quote:r}:{},attachments:Array.isArray(s.attachments)?s.attachments:[],target:_b(s.target),error:String(s.error||"")}};return Aa(i,this._workCenterBrowserFence)?(this.workCenterComposerDrafts=i,!0):!1},loadWorkCenterComposerDraft(e,t){return this.workCenterComposerDrafts?.[ks(e,t)]||null},removeWorkCenterComposerDraft(e,t){let s=ks(e,t),n={...this.workCenterComposerDrafts||{}};return delete n[s],Aa(n,this._workCenterBrowserFence)?(this.workCenterComposerDrafts=n,!0):!1},prepareWorkCenterMessageEnvelope(e={}){let t=Db(e),s=ks(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 Cr(i,this._workCenterBrowserFence)?(this.workCenterMessageOutbox=i,r):null},loadWorkCenterMessageEnvelope(e,t){return this.workCenterMessageOutbox?.[ks(e,t)]||null},replaceWorkCenterMessageEnvelopeAttachments(e,t,s=[]){let n=ks(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 Cr(o,this._workCenterBrowserFence)?(this.workCenterMessageOutbox=o,i):null},discardWorkCenterMessageEnvelope(e,t){let s=ks(e,t),n={...this.workCenterMessageOutbox||{}};return delete n[s],Cr(n,this._workCenterBrowserFence)?(this.workCenterMessageOutbox=n,!0):!1},confirmWorkCenterMessageEnvelope(e,t,s){let n=ks(e,t),r=this.workCenterMessageOutbox?.[n];if(!r||r.clientMessageId!==s)return!1;let i={...this.workCenterMessageOutbox||{}};return delete i[n],Cr(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=no(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 p of Object.values(u))Number(p?.generation)<=o||p?.queryKey!==r||(d=this.applyWorkItemBoardSummary(d,p.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 p=[...this.workCenterItemsByAgent[t]||[]];for(let g of Array.isArray(d?.items)?d.items:[]){if(this.workItemDeleted(t,g?.id))continue;let v=p.findIndex(m=>m.id===g.id);v<0?p.push(g):p[v]=no([p[v]],g)[0]}let f=this._workCenterListEventsByAgent[t]||{};for(let g of Object.values(f))Number(g?.generation)<=o||g?.queryKey!==r||(p=this.applyWorkItemBoardSummary(p,g.summary,n));return this.workCenterItemsByAgent={...this.workCenterItemsByAgent,[t]:p},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&&_p(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=Ot(n),i=Yn(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=Ot(s),a=Yn(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)||Ot(u?.generation)!==o||Number(this._workCenterActionMessageGenerationByKey[a]||0)!==l)return u;let p=this.workCenterActionMessages[a]?.messages||[],f=zr(p,u?.messages||[]),g=this.workCenterActionMessages[a],v=g?.nextCursor,m=n==null?null:Number(n),y=v==null?null:Number(v),h=!g||m==null||y!=null&&m===y;return this.workCenterActionMessages={...this.workCenterActionMessages,[a]:{generation:o,messages:f,nextCursor:h?u?.nextCursor??null:v,total:Math.max(Number(u?.total)||0,Number(g?.total)||0,f.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 p=Object.keys(u).some(f=>f.startsWith(`${a}:`));this.workCenterActionMessagesLoading={...this.workCenterActionMessagesLoading,[a]:p}}}})();return this._workCenterActionMessageRequests={...this._workCenterActionMessageRequests,[c]:d},d},async loadWorkItemActionRequests(e,t,s,n=null){let r=n||this.workCenterAgentId||this.currentAgent,i=Ot(s),o=ul(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)&&Ot(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=Ot(s),c=`${ul(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),p=!this.workItemDeleted(o,e)&&Ot(u?.generation)===a&&this._workCenterActionRequestDetailsGeneration[c]===d;return p&&(this.workCenterActionRequestDetails={...this.workCenterActionRequestDetails,[c]:u?.request||null}),p?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={},a=null){if(!this.hydrateWorkCenterBrowserState())throw new Error("Work Center browser owner is unavailable; sign in again and retry");let l=i||this.workCenterAgentId||this.currentAgent,c=this.prepareWorkCenterMessageEnvelope({agentId:l,workItemId:e,target:s,text:t,quote:a,attachments:r,revision:n,planRevision:o.planRevision,ledgerRevision:o.ledgerRevision,coordinatorRevision:o.coordinatorRevision});if(!c)throw new Error("Work Center browser owner changed; reopen Work Center and try again");let d=c.clientMessageId,u=this.workCenterDetailByAgent[l]?.id===e?this.workCenterDetailByAgent[l]:null,p=await this.workCenterRequest("post_work_item_message",{id:c.workItemId,clientMessageId:d,text:c.text,target:c.target,revision:c.revision,planRevision:c.planRevision||Number(u?.planRevision)||0,ledgerRevision:c.ledgerRevision||Number(u?.ledgerRevision)||0,coordinatorRevision:Number.isInteger(Number(c.coordinatorRevision))?Number(c.coordinatorRevision):Number(u?.coordinatorRevision)||0,...c.quote?{quote:c.quote}:{},attachments:c.attachments},l);if(c.target.kind==="coordinator"){if(!p?.accepted)throw new Error("Work Center Coordinator did not accept the message");return this.confirmWorkCenterMessageEnvelope(l,e,d),p}return await this.listWorkItems(l,this._workCenterListFiltersByAgent[l]||{}),this.confirmWorkCenterMessageEnvelope(l,e,d),p},async sendWorkItemMessage(e,t,s,n=[],r=null,i={},o=null){let a=r||this.workCenterAgentId||this.currentAgent,l=this.workCenterDetailByAgent[a]?.id===e?this.workCenterDetailByAgent[a]:null,c=await this.workCenterRequest("work_item_message",{id:e,text:t,revision:s,planRevision:Number.isInteger(Number(i.planRevision))?Number(i.planRevision):Number(l?.planRevision)||0,ledgerRevision:Number.isInteger(Number(i.ledgerRevision))?Number(i.ledgerRevision):Number(l?.ledgerRevision)||0,coordinatorRevision:Number.isInteger(Number(i.coordinatorRevision))?Number(i.coordinatorRevision):Number(l?.coordinatorRevision)||0,...It(o)?{quote:It(o)}:{},attachments:Array.isArray(n)?n:[]},a);if(!c?.accepted)throw new Error("Work Center Coordinator did not accept the message");return c},async retryWorkItemAction(e,t,s,n,r=null){let i=r||this.workCenterAgentId||this.currentAgent,o=this.beginWorkCenterDetailWrite(i),a=await this.workCenterRequest("retry_action",{id:e,actionId:t,revision:s,generation:n},i);return await this.listWorkItems(i,this._workCenterListFiltersByAgent[i]||{}),this.commitWorkCenterDetail(i,a,o),a},async sendWorkItemActionInput(e,t,s,n,r,i=[],o=null,a=null){let l=o||this.workCenterAgentId||this.currentAgent,c=Number(this._workCenterActionInputGenerationByAgent[l]||0)+1;this._workCenterActionInputGenerationByAgent={...this._workCenterActionInputGenerationByAgent,[l]:c};let d=It(a),u=await this.workCenterRequest("action_input",{id:e,text:t,actionId:s,revision:n,generation:r,attachments:i,...d?{quote:d}:{}},l);await this.listWorkItems(l,this._workCenterListFiltersByAgent[l]||{});let p=this.workCenterDetailByAgent[l],f=p?.actions?.find(v=>v?.id===s),g=p?.id===e&&Number(p.revision)===Number(n)&&f&&Number(f.generation)===Number(r);return this._workCenterActionInputGenerationByAgent[l]===c&&g&&!xp(u,p)?(this.workCenterDetailByAgent={...this.workCenterDetailByAgent,[l]:u},u):p?.id===e?p:u},async guideWorkItemAction(e,t,s,n,r,i=[],o=null){let a=o||this.workCenterAgentId||this.currentAgent,l=this.beginWorkCenterDetailWrite(a),c=await this.workCenterRequest("guide",{id:e,guidance:t,actionId:s,revision:n,generation:r,attachments:i},a);return await this.listWorkItems(a,this._workCenterListFiltersByAgent[a]||{}),this.commitWorkCenterDetail(a,c,l),c},previewWorkItemAttachment(e,t,s=null){let n=s||this.workCenterAgentId||this.currentAgent;return this.workCenterRequest("preview_attachment",{id:e,attachmentId:t},n)},applyWorkCenterEvent(e,t){if(!e||!t?.workItem)return;let s=t.workItem;if(t.clientMessageId){this.confirmWorkCenterMessageEnvelope(e,s.id,t.clientMessageId);let u=Object.entries(this.workCenterPending||{}).find(([,p])=>p?.agentId===e&&p.clientMessageId===t.clientMessageId);if(u){let[p,f]=u;clearTimeout(f.timer),delete this.workCenterPending[p],f.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=no(o,s).find(u=>u?.id===s.id)||s,l=Number(this._workCenterListEventGenerationByAgent[e]||0)+1;this._workCenterListEventGenerationByAgent={...this._workCenterListEventGenerationByAgent,[e]:l},this._workCenterListEventsByAgent={...this._workCenterListEventsByAgent,[e]:{...this._workCenterListEventsByAgent[e]||{},[s.id]:{generation:l,queryKey:this._workCenterListQueryByAgent[e]||null,summary:a}}};let c=this.applyWorkItemBoardSummary(n,a,r);this.workCenterItemsByAgent={...this.workCenterItemsByAgent,[e]:c};let d=this.workCenterDetailByAgent[e];if(d?.id===s.id){let u=t.type==="run.finished"&&t.actionId&&Array.isArray(s.actionStats)&&s.actionStats.some(y=>y?.id===t.actionId)?{...s,eventActionId:t.actionId}:s,p=fl(d,u),f=Number(s.coordinatorRevision),g=Number(d.coordinatorRevision)||0,v=Number.isInteger(f)&&f>g,m=Tp(d,u);this.workCenterDetailByAgent={...this.workCenterDetailByAgent,[e]:Mp(d,s)},m&&this.refreshWorkItemDetailAfterActionChange(e,s,v?null:p)}},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 p=this.beginWorkCenterDetailWrite(e),f={key:u,generation:p};this._workCenterDetailEventRefreshByAgent={...this._workCenterDetailEventRefreshByAgent,[e]:f},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),m=this.workCenterDetailByAgent[e],y=m?.actions?.find(P=>P?.id===r),h=v?.actions?.find(P=>P?.id===r),w=o==null||Ot(y?.generation)===o,S=o==null||Ot(h?.generation)>=o,b=l==null||Number(v?.coordinatorRevision)===l,k=l!=null||w&&S&&(t.currentActionId==null?v?.currentActionId==null:m?.currentActionId===t.currentActionId&&v?.currentActionId===t.currentActionId);m?.id===t.id&&b&&k&&this.commitWorkCenterDetail(e,v,p)&&g&&await g}catch{}finally{if(this._workCenterDetailEventRefreshByAgent[e]===f){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),p=Array.isArray(this._yeaftRetiredCatalogEpochsByAgent?.[e])?this._yeaftRetiredCatalogEpochsByAgent[e]:[],f=!!a&&p.includes(a),g=!!a&&a===o,v=i>0?g&&i===r:c>0&&c===l,m=i>0?!!a&&(a!==o||i>r):r===0&&c>l,y=i>0?!!t.catalogDigest&&!!n.catalogDigest&&t.catalogDigest===n.catalogDigest:t.catalogDigest===n.catalogDigest,h=u&&!f&&(m||v&&y),S=h||s&&r===0&&l===0&&!u&&d,b={...t};if(!S)for(let P of Mb)delete b[P];let k={...n,...b};if(S){if(h&&o&&a&&o!==a){let P=[...p.filter(x=>x!==o),o].slice(-Pb);this._yeaftRetiredCatalogEpochsByAgent={...this._yeaftRetiredCatalogEpochsByAgent||{},[e]:P}}k.availableModels=t.availableModels,k.catalogRefreshedAt=h?c:null,k.catalogEpoch=h&&a||null,k.catalogRevision=h&&i||null,k.catalogDigest=h&&t.catalogDigest||null}this.yeaftStatusByAgent={...this.yeaftStatusByAgent,[e]:k},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 Me(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))},xb),e):(this.yeaftSessionHydrateRequestId=null,this.yeaftSessionHydrateSlices=[],this.yeaftSessionHydrateError="session_inventory_send_failed",null)},beginYeaftHistoryLoad(e){let t=Nd(this,e);if(!t)return null;let{agentId:s,sessionId:n}=e||{};return setTimeout(()=>{Er(this,{agentId:s,sessionId:n,requestId:t.requestId,error:"history_load_timeout"})},Bd),t},finishYeaftHistoryLoad(e,t={},s="chunk"){return Wd(this,e,t,s)},isCurrentYeaftHistoryResponse(e){return $a(this,e)},syncActiveYeaftHistoryLoad(){return ln(this)},enterYeaft(e=null,{deferBootstrap:t=!1}={}){let s=this.currentAgent;cl(this);let n=Is(this),r=!e&&n?Me(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]=[]),hp(this),this.currentView="yeaft",ll("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=Is(this),r=n?Me(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(h=>h&&(h.sessionId??h.groupId??null)===n),d=!!n&&tu({sessionState:o,hasCachedSessionRows:c,force:!!s}),u=!!n&&!d&&eu(o,t);if(!a&&!d&&!u)return!1;let p=`${r}:${n||"__none__"}`,f=a&&!d&&!u;if(f&&this.yeaftBootstrapMetaLoadingKey===p)return!1;f&&(this.yeaftBootstrapMetaLoadingKey=p);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?kl:0;let m=un();v.perfTraceId=m;let y=u?"delta":d?"recent":"metadata";return n&&(this.yeaftHistoryPerfTraceBySession={...this.yeaftHistoryPerfTraceBySession||{},[i]:m}),vt(this,{traceId:m,phase:"history.request_send",agentId:r,sessionId:n,messageType:v.type,bytes:JSON.stringify(v).length,detail:{mode:y,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}={}){let o=Me(this,e);if(!o)return;let a=typeof i=="string"?i.trim():(this.yeaftDebugSearch||"").trim(),l=typeof r=="string"&&r,c=a&&!l?Zp:xl,d=Number.isFinite(t)&&t>0?t:this.yeaftDebugHistoryLimit||c,u=Math.max(1,Math.min(c,d)),p=l?"detail":"list",f=`dbg_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,10)}`,g=JSON.stringify({agentId:o,groupId:e||null,limit:u,dreamLimit:Number.isFinite(s)&&s>0?s:5,indexOnly:!!n,detailTurnId:r||null,search:l?"":a});if(this._yeaftDebugHistoryInFlightKey===g)return;this._yeaftDebugHistoryInFlightKey=g,l?this._yeaftDebugHistoryLatestDetailRequestId=f:this._yeaftDebugHistoryLatestListRequestId=f,this.yeaftDebugHistoryLimit=u,this.yeaftDebugHistoryLoading=!0,this.yeaftDebugHistoryError=null,this.yeaftDebugHistoryProjection=null;let v={type:"yeaft_fetch_debug_history",agentId:o,requestId:f,requestKind:p,limit:u,dreamLimit:Number.isFinite(s)&&s>0?s:5};n&&(v.indexOnly=!0),typeof r=="string"&&r?v.detailTurnId=r:a&&(v.search=a),typeof e=="string"&&e&&(v.sessionId=e),this._yeaftDebugHistoryPending={payload:v,attempt:0,startedAt:Date.now()},Un(this),this.refreshYeaftDebugHistoryTimeout(f),this.sendWsMessage(v)},scheduleYeaftDebugDetailRefresh(e,t){let s=this.yeaftDebugPanel;!s?.open||s.turnId!==t||s.agentId!==e.agentId||s.sessionId&&s.sessionId!==e.sessionId||(this._yeaftDebugDetailDirty=!0,!this._yeaftDebugDetailRefreshTimer&&(this._yeaftDebugDetailRefreshTimer=setTimeout(()=>{this._yeaftDebugDetailRefreshTimer=null,!(!this.yeaftDebugPanel?.open||this.yeaftDebugPanel.requestId!==s.requestId)&&(this.yeaftDebugHistoryLoading||(this._yeaftDebugDetailDirty=!1,this.loadYeaftDebugHistory({groupId:s.sessionId,detailTurnId:s.turnId})))},500)))},refreshYeaftDebugHistoryTimeout(e){let t=this._yeaftDebugHistoryPending;!t||t.payload.requestId!==e||(this._fetchYeaftDebugHistoryTimer&&clearTimeout(this._fetchYeaftDebugHistoryTimer),this._fetchYeaftDebugHistoryTimer=setTimeout(()=>{if(this._yeaftDebugHistoryPending===t){if(this.yeaftDebugHistoryLoading&&t.attempt<1){t.attempt+=1,t.startedAt=Date.now(),t.payload={...t.payload,requestId:`dbg_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,10)}`},t.payload.requestKind==="detail"?this._yeaftDebugHistoryLatestDetailRequestId=t.payload.requestId:this._yeaftDebugHistoryLatestListRequestId=t.payload.requestId,Un(this),this.refreshYeaftDebugHistoryTimeout(t.payload.requestId),this.sendWsMessage(t.payload);return}this.yeaftDebugHistoryLoading&&(this.yeaftDebugHistoryLoading=!1,this.yeaftDebugHistoryError="debug_history_timeout",this.yeaftDebugPanel?.status==="loading"&&(this.yeaftDebugPanel={...this.yeaftDebugPanel,status:"error",error:this.yeaftDebugHistoryError})),this._yeaftDebugHistoryInFlightKey=null,this._fetchYeaftDebugHistoryTimer=null,this._yeaftDebugHistoryPending=null,this._yeaftDebugHistoryLatestDetailRequestId=null,this._yeaftDebugHistoryLatestListRequestId=null,Un(this)}},Math.max(0,Math.min(3e4,3e5-(Date.now()-t.startedAt)))))},openYeaftTurnDebug({sessionId:e=null,turnId:t=null}={}){let s=Me(this,e);if(!s)return;this.workbenchExpanded=!1,this.workbenchMaximized=!1,this.rememberWorkbenchPanelState();let n=`dbgpanel_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,10)}`,r=t?"loading":"idle";this.yeaftDebugPanel={open:!0,status:r,requestId:n,agentId:s,sessionId:e||null,turnId:t||null,error:null},t&&this.loadYeaftDebugHistory({groupId:e||void 0,limit:1,dreamLimit:5,detailTurnId:t})},closeYeaftDebugPanel(){this._yeaftDebugDetailRefreshTimer&&clearTimeout(this._yeaftDebugDetailRefreshTimer),this._yeaftDebugDetailRefreshTimer=null,this._yeaftDebugDetailDirty=!1,this._fetchYeaftDebugHistoryTimer&&clearTimeout(this._fetchYeaftDebugHistoryTimer),this._fetchYeaftDebugHistoryTimer=null,this._yeaftDebugHistoryPending=null,this._yeaftDebugHistoryInFlightKey=null,this._yeaftDebugHistoryLatestDetailRequestId=null,this._yeaftDebugHistoryLatestListRequestId=null,this.yeaftDebugHistoryLoading=!1,Un(this);let t=(this.yeaftDebugPanel||{}).turnId||null;if(this.yeaftDebugPanel={open:!1,status:"idle",requestId:null,agentId:null,sessionId:null,turnId:null,error:null},t&&this.yeaftDebugTurnsById&&this.yeaftDebugTurnsById[t]){let s={...this.yeaftDebugTurnsById};delete s[t],this.yeaftDebugTurnsById=s,this.yeaftDebugTurnOrder=(this.yeaftDebugTurnOrder||[]).filter(n=>n!==t),this.yeaftDebugLoops=(this.yeaftDebugLoops||[]).filter(n=>!n||n.turnId!==t)}},agentIdForSession(e){return Me(this,e)},sendYeaftSessionMessage({groupId:e,text:t,mentions:s,attachments:n,quote:r,quickSend:i}){let o=Me(this,e);if(!e||!o||i&&(o!==this.currentAgent||this.connectionState!=="connected"||!this.agents?.some(m=>m.id===o&&m.online)))return!1;let a=Array.isArray(n)?n.filter(m=>m&&m.fileId):[],l=It(r),c=a.length>0;if(!t?.trim()&&!c)return;let d=t?.trim()?t:"(attached files)",u=Date.now(),p=`u_${u.toString(36)}_${Math.random().toString(36).slice(2,10)}`,f=un();this.yeaftPerfTraceByMessageId={...this.yeaftPerfTraceByMessageId||{},[p]:f},vt(this,{traceId:f,phase:"send.prepare",agentId:o,sessionId:e,turnId:p,messageType:"yeaft_session_send",detail:{mentionCount:Array.isArray(s)?s.length:0,attachmentCount:a.length,quoted:!!l}});let g=yt(this,e);if(g){let m={id:p,messageId:p,clientMessageId:p,stableKey:qs(o,e,p),uiKey:qs(o,e,p),type:"user",content:d,timestamp:u,sessionId:e,turnId:p,...l?{quote:l}:{}};if(a.length>0&&(m.attachments=a.map(y=>({fileId:y.fileId,name:y.name,preview:y.preview,isImage:!!y.isImage,mimeType:y.mimeType||""}))),Gt(this).upsertOverlay({conversationId:g,agentId:o,sessionId:e,row:m}),this.processingConversations[g]=!0,e){let y=ys(o,e);this.yeaftProcessingSessions={...this.yeaftProcessingSessions,...y?{[y]:!0}:{}}}this._turnCompletedConvs?.delete(g),this._closedAt?.[g]&&delete this._closedAt[g],this.getOrCreateExecutionStatus(g),Nn(this,g)}let v={type:"yeaft_session_send",agentId:o,id:p,sessionId:e,text:d,mentions:Array.isArray(s)?s:[],perfTraceId:f,...i?{quickSend:{model:i.model,effort:i.effort??null,maxOutputTokens:i.maxOutputTokens??null}}:{},...l?{quote:l}:{}};a.length>0&&(v.attachments=a.map(m=>({fileId:m.fileId,isImage:!!m.isImage}))),vt(this,{traceId:f,phase:"send.websocket_send",agentId:o,sessionId:e,turnId:p,messageType:v.type,bytes:JSON.stringify(v).length}),this.sendWsMessage(v)},cancelYeaftTask({agentId:e=null,sessionId:t,taskId:s}){let n=typeof t=="string"?t.trim():"",r=typeof s=="string"?s.trim():"",i=Me(this,n,e);return!i||!n||!r?!1:(this.yeaftStoppingTasksById={...this.yeaftStoppingTasksById,[Il(i,n,r)]:!0},this.sendWsMessage({type:"yeaft_task_cancel",agentId:i,sessionId:n,taskId:r,clientRequestId:`task_cancel_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}),!0)},continueYeaftHistoryDelta(e,t=null,s=null){let n=e||null,r=Me(this,n,t);if(!r||!n||!Number.isFinite(s))return!1;let i=Pe(r,n),o=this.yeaftSessionHistoryState?.[i]||null;if(o?.loading)return!1;let a=this.beginYeaftHistoryLoad({agentId:r,sessionId:n,mode:"delta",preserveLoaded:!0,latestSeq:s});if(!a)return!1;this.yeaftSessionHistoryState={...this.yeaftSessionHistoryState,[i]:{...this.yeaftSessionHistoryState[i],syncingAfterSeq:s}};let l={type:"yeaft_load_history",agentId:r,sessionId:n,requestId:a.requestId,afterSeq:s,maxRows:Cb,maxBytes:Ab,...typeof o?.streamId=="string"?{streamId:o.streamId}:{},...Number.isFinite(o?.revision)?{revision:o.revision}:{}};return this.sendWsMessage(l)?!0:(Er(this,{agentId:r,sessionId:n,requestId:a.requestId,error:"history_load_send_failed"}),!1)},clearYeaftHistoryMemory({agentId:e=null,sessionId:t=null,preserveLiveRows:s=!1,preserveSessionOwner:n=!1}={}){let r=e||null,i=t||null,o=r&&i?Pe(r,i):null,a={};for(let[v,m]of Object.entries(this._yeaftHistoryWindowPendingByKey||{})){if(!(!o||m?.agentId===r&&m?.sessionId===i)){a[v]=m;continue}clearTimeout(m?.timeout),m?.resolve?.(!1)}this._yeaftHistoryWindowPendingByKey=a;let l={};for(let[v,m]of Object.entries(this._yeaftHistoryPrefetchBySession||{})){if(o&&v!==o){l[v]=m;continue}m.cancelled=!0,m.idle&&typeof globalThis.cancelIdleCallback=="function"?globalThis.cancelIdleCallback(m.handle):clearTimeout(m.handle)}this._yeaftHistoryPrefetchBySession=l;let c={};for(let[v,m]of Object.entries(this._yeaftHistoryResultRefreshByRequestId||{})){if(!(!o||m?.agentId===r&&m?.sessionId===i)){c[v]=m;continue}clearTimeout(m?.timeout),m?.resolve?.(null)}this._yeaftHistoryResultRefreshByRequestId=c;let d=r&&this.yeaftConversationIdsByAgent?.[r]||null,u=o?new Set([d].filter(Boolean)):new Set(Object.values(this.yeaftConversationIdsByAgent||{}).filter(Boolean));!o&&this.yeaftConversationId&&u.add(this.yeaftConversationId);let p={...this.messagesMap||{}};for(let v of u)Array.isArray(p[v])&&(p[v]=o?p[v].filter(m=>(m?.sessionId??m?.groupId??null)!==i?!0:s&&!ct(m)):[]);this.messagesMap=p;let f=v=>{if(!o)return{};let{[o]:m,...y}=v||{};return y};if(this.yeaftSessionHistoryState=f(this.yeaftSessionHistoryState),this.yeaftHistoryCacheState=f(this.yeaftHistoryCacheState),this.yeaftMessageWindowState=f(this.yeaftMessageWindowState),this.yeaftHistoryFocusWindowBySession=f(this.yeaftHistoryFocusWindowBySession),this.yeaftHistoryOutlineBySession=f(this.yeaftHistoryOutlineBySession),o){let v=this._yeaftHistoryOutlineTimeouts?.[o];v&&clearTimeout(v),this._yeaftHistoryOutlineTimeouts=f(this._yeaftHistoryOutlineTimeouts)}else{for(let v of Object.values(this._yeaftHistoryOutlineTimeouts||{}))v&&clearTimeout(v);this._yeaftHistoryOutlineTimeouts={}}if((!o||this.yeaftHistorySearchState?.agentId===r&&this.yeaftHistorySearchState?.sessionId===i)&&(this._yeaftHistorySearchTimeout&&clearTimeout(this._yeaftHistorySearchTimeout),this._yeaftHistorySearchTimeout=null,this.yeaftHistorySearchState={requestId:null,agentId:null,sessionId:null,query:"",senderKey:"",loading:!1,results:[],hasMore:!1,nextBeforeSeq:null,nextCursor:null,error:null}),this._yeaftHistoryRevealLeases=o?Object.fromEntries(Object.entries(this._yeaftHistoryRevealLeases||{}).filter(([,v])=>v?.sessionKey!==o)):{},o||(this.yeaftHasMoreHistory=!1,this.yeaftLoadingMoreHistory=!1,this.yeaftOldestLoadedSeq=null),!n&&i&&this.yeaftSessionAgentById?.[i]===r){let{[i]:v,...m}=this.yeaftSessionAgentById;this.yeaftSessionAgentById=m}this.syncActiveYeaftHistoryLoad()},getYeaftMessageWindowKey(e=null,t=null){let s=e||this.yeaftActiveSessionFilter||null,n=Me(this,s,t);return Pe(n,s)},showLatestYeaftMessageWindow(e=null,t=null){let s=this.getYeaftMessageWindowKey(e,t);if(!s||!this.yeaftHistoryFocusWindowBySession?.[s])return!1;let{[s]:n,...r}=this.yeaftHistoryFocusWindowBySession;return this.yeaftHistoryFocusWindowBySession=r,!0},pruneYeaftMessageWindow(e=null,t=null){if(this.currentView!=="yeaft")return;let s=this.getYeaftMessageWindowKey(e,t);Object.values(this._yeaftHistoryRevealLeases||{}).some(r=>r?.sessionKey===s)||(this.yeaftMessageWindowState={...this.yeaftMessageWindowState,[s]:{visibleTurns:Ws()}})},expandYeaftMessageWindow(e=null,t=Qr(),s=null){if(this.currentView!=="yeaft")return;let n=this.getYeaftMessageWindowKey(e,s),i=(this.yeaftMessageWindowState[n]?.visibleTurns||Ws())+Math.max(1,Number.isFinite(t)?Math.floor(t):Qr());this.yeaftMessageWindowState={...this.yeaftMessageWindowState,[n]:{visibleTurns:i}}},isYeaftMessageCached(e,t,s=null,n=null){let r=e||this.yeaftActiveSessionFilter||null,i=s||yt(this,r,n);return!i||!t?!1:(this.messagesMap[i]||[]).some(o=>(!r||(o?.sessionId??o?.groupId??null)===r)&&((o?.id||o?.messageId)===t||o?.persistedMessageId===t))},revealYeaftMessage(e,t,s=null,n=null){let r=e||this.yeaftActiveSessionFilter||null,i=Me(this,r,n),o=s||yt(this,r,i);if(!o||!t)return!1;let a=(this.messagesMap[o]||[]).filter(m=>m?._historyWindowPrefetched===!0?!1:r?(m?.sessionId??m?.groupId??null)===r:!0),c=a.findIndex(m=>(m?.id||m?.messageId)===t||m?.persistedMessageId===t);if(c<0){let m=(this.messagesMap[o]||[]).find(y=>y?._historyWindowPrefetched===!0&&(y?.sessionId??y?.groupId??null)===r&&((y?.id||y?.messageId)===t||y?.persistedMessageId===t));if(!m)return!1;m._historyWindowPrefetched=!1,a.push(m),a.sort((y,h)=>{let w=Number.isFinite(y?.seq)?y.seq:null,S=Number.isFinite(h?.seq)?h.seq:null;return w!==null&&S!==null&&w!==S?w-S:w!==null&&S===null?-1:w===null&&S!==null?1:(y?.timestamp||0)-(h?.timestamp||0)}),c=a.indexOf(m)}let u=a[c]?._historyWindowKey||null,p=this.getYeaftMessageWindowKey(r,i);if(u){let m=(this.messagesMap[o]||[]).filter(h=>(h?.sessionId??h?.groupId??null)===r&&h?._historyWindowKey===u);return bl(m).length===0?!1:(this.yeaftHistoryFocusWindowBySession={...this.yeaftHistoryFocusWindowBySession||{},[p]:{windowKey:u,messageId:t,conversationId:o}},this.yeaftMessageWindowState={...this.yeaftMessageWindowState,[p]:{visibleTurns:Ws()}},!0)}let f=bl(a),g=f.findIndex(m=>c>=m.start&&c<m.end);if(g<0)return!1;let v=Math.max(Ws(),f.length-g);return this.yeaftMessageWindowState={...this.yeaftMessageWindowState,[p]:{visibleTurns:v}},!0},getYeaftHistoryOutlineState(e=null,t=null){let s=e||this.yeaftActiveSessionFilter||null,n=Me(this,s,t),r=Pe(n,s),i=this.yeaftHistoryOutlineBySession[r]||{requestId:null,agentId:n,sessionId:s,loading:!1,results:[],hasMore:!1,nextBeforeSeq:null,nextCursor:null,totalCount:null,loaded:!1,retryAttempt:0,error:null},o=yt(this,s,n),a=o?this.messagesMap[o]||[]:[],l=new Map((i.results||[]).map(p=>[Xr(p),p])),c=0;for(let p of a){if((p?.sessionId??p?.groupId??null)!==s)continue;let f=p.messageId||p.id;if(!f)continue;let g=p.type==="user"&&!!p.clientMessageId&&f===p.clientMessageId,v=p.type==="assistant"&&p.isStreaming===!0;if(!g&&!v)continue;let m=p.type,y=p.turnId||p.threadId||f,h=p.speakerVpId||p.vpId||null,w=Xr({role:m,messageId:f,clientMessageId:p.clientMessageId,turnId:y,speakerVpId:h}),S=l.get(w),k=(typeof p.content=="string"?p.content:"").replace(/\s+/g," ").trim();l.set(w,{...S,agentId:n,sessionId:s,messageId:Number.isFinite(S?.seq)?S.messageId:f,...p.clientMessageId?{clientMessageId:p.clientMessageId}:{},turnId:y,role:m,speakerVpId:h||S?.speakerVpId||null,timestamp:p.timestamp||p.ts||S?.timestamp||null,snippet:k.length>180?`${k.slice(0,180).trimEnd()}\u2026`:k||S?.snippet||""}),S||(c+=1)}let d=p=>{let f=typeof p=="number"?p:Date.parse(p||"");return Number.isFinite(f)?f:0},u=Array.from(l.values()).sort((p,f)=>Number.isFinite(p.seq)&&Number.isFinite(f.seq)?p.seq-f.seq:d(p.timestamp)-d(f.timestamp));return{...i,results:u,totalCount:Number.isFinite(i.totalCount)?i.totalCount+c:i.totalCount}},promoteYeaftHistoryOutlineRow(e,t=null){let s=e?.sessionId??e?.groupId??null,n=Pe(t,s),r=this.yeaftHistoryOutlineBySession[n];if(!s||!t||!r?.loaded||r.loading)return!1;let i=e?.type;if(i!=="user"&&i!=="assistant")return!1;let o=e.dbMessageId||e.messageId||e.id||null,a=Vb(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(),p=Xr({role:i,messageId:o,clientMessageId:e.clientMessageId,turnId:l,speakerVpId:c}),f=new Map((r.results||[]).map(w=>[Xr(w),w])),g=f.get(p);f.set(p,{...g,agentId:t,sessionId:s,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,m=Array.from(f.values()).sort((w,S)=>(w.seq||0)-(S.seq||0)),y=m.length>v,h=m.slice(-v);return this.yeaftHistoryOutlineBySession={...this.yeaftHistoryOutlineBySession,[n]:{...r,results:h,hasMore:r.hasMore||y,nextBeforeSeq:y&&Number.isFinite(h[0]?.seq)?h[0].seq:r.nextBeforeSeq,totalCount:Number.isFinite(r.totalCount)&&!g?r.totalCount+1:r.totalCount}},!0},promoteCompletedYeaftHistoryOutline(e,t=null,s=null){let n=this.messagesMap[e]||[],r=null,i=[];for(let o=n.length-1;o>=0;o--){let a=n[o];if(a?.type==="user")break;if(t&&a?.turnId&&a.turnId!==t||a?.type!=="assistant")continue;let l=typeof a.content=="string"?a.content.replace(/\s+/g," ").trim():"";r?!String(r.content||"").trim()&&l&&(r=a):r=a,l&&i.unshift(l)}return r?this.promoteYeaftHistoryOutlineRow({...r,content:i.join(" ")},s):!1},invalidateYeaftHistoryOutline(e,t=null){let s=Pe(t,e),n=this.yeaftHistoryOutlineBySession[s];if(!e||!t||!n)return!1;if(n.loading)return this.yeaftHistoryOutlineBySession={...this.yeaftHistoryOutlineBySession,[s]:{...n,refreshPending:!0}},!0;this.yeaftHistoryOutlineBySession={...this.yeaftHistoryOutlineBySession,[s]:{...n,loaded:!1,refreshPending:!1}};let r=Me(this,e);return this.currentView==="yeaft"&&this.yeaftActiveSessionFilter===e&&r===t?this.loadYeaftHistoryOutline({force:!0,targetSessionId:e,targetAgentId:t}):!0},loadYeaftHistoryOutline({append:e=!1,force:t=!1,targetSessionId:s=null,targetAgentId:n=null,retryAttempt:r=0}={}){if(this.currentView!=="yeaft"&&!s)return!1;let i=s||this.yeaftActiveSessionFilter||null,o=n||Me(this,i);if(!i||!o)return!1;let a=Pe(o,i),l=this.getYeaftHistoryOutlineState(i,o);if(!e&&l.loaded&&!t)return!0;if(e&&(!l.hasMore||!Number.isFinite(l.nextBeforeSeq))||l.loading)return!1;if(!Tt(this,o,"session_history_outline"))return this.yeaftHistoryOutlineBySession={...this.yeaftHistoryOutlineBySession,[a]:{...l,error:"unsupported",loading:!1}},!1;let c=`history_outline_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,d={...l,requestId:c,agentId:o,sessionId:i,loading:!0,requestAppend:e,refreshPending:!1,retryAttempt:r,error:null};this.yeaftHistoryOutlineBySession={...this.yeaftHistoryOutlineBySession,[a]:d};let u=this._yeaftHistoryOutlineTimeouts[a];u&&clearTimeout(u);let p=setTimeout(()=>{let v=this.yeaftHistoryOutlineBySession[a];if(v?.requestId!==c)return;let m={...this._yeaftHistoryOutlineTimeouts};delete m[a],this._yeaftHistoryOutlineTimeouts=m;let y=v.refreshPending===!0;this.yeaftHistoryOutlineBySession={...this.yeaftHistoryOutlineBySession,[a]:{...v,requestId:null,loading:!1,requestAppend:!1,loaded:y?!1:v.loaded,refreshPending:!1,error:y?null:"timeout"}},y&&this.loadYeaftHistoryOutline({force:!0,targetSessionId:i,targetAgentId:o})},1e4);this._yeaftHistoryOutlineTimeouts={...this._yeaftHistoryOutlineTimeouts,[a]:p};let f=un(),g={type:"yeaft_load_history_outline",agentId:o,sessionId:i,requestId:c,perfTraceId:f,limit:50,...e&&l.nextCursor?{cursor:l.nextCursor}:{},...e&&!l.nextCursor&&Number.isFinite(l.nextBeforeSeq)?{beforeSeq:l.nextBeforeSeq}:{}};return vt(this,{traceId:f,phase:"history_outline.request_send",agentId:o,sessionId:i,messageType:g.type,bytes:JSON.stringify(g).length,detail:{append:e,limit:g.limit}}),this.sendWsMessage(g),!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=Number.isInteger(s.retryAttempt)?s.retryAttempt:0;if(Tb.has(e.error)&&i<Np.length){let p=Np[i],f=setTimeout(()=>{let g=this.yeaftHistoryOutlineBySession[t];if(g?.requestId!==e.requestId||g.loading!==!0)return;let v={...this._yeaftHistoryOutlineTimeouts};delete v[t],this._yeaftHistoryOutlineTimeouts=v;let m=g.refreshPending===!0;this.yeaftHistoryOutlineBySession={...this.yeaftHistoryOutlineBySession,[t]:{...g,requestId:null,loading:!1,refreshPending:!1}},this.loadYeaftHistoryOutline({append:m?!1:s.requestAppend===!0,force:!0,targetSessionId:e.sessionId,targetAgentId:e.agentId,retryAttempt:i+1})},p);return this._yeaftHistoryOutlineTimeouts={...this._yeaftHistoryOutlineTimeouts,[t]:f},!0}let o=Array.isArray(e.results)?e.results.map(p=>({...p,agentId:e.agentId,sessionId:e.sessionId})):[],a=s.requestAppend?[...s.results||[],...o]:o,l=new Map(a.filter(p=>p?.messageId).map(p=>[Xr(p),p])),c=Array.from(l.values()).sort((p,f)=>(p.seq||0)-(f.seq||0)),d=s.refreshPending===!0;this.yeaftHistoryOutlineBySession={...this.yeaftHistoryOutlineBySession,[t]:{...s,requestId:null,loading:!1,requestAppend:!1,refreshPending:!1,loaded:d?!1:!e.error,results:c,hasMore:!!e.hasMore,nextBeforeSeq:Number.isFinite(e.nextBeforeSeq)?e.nextBeforeSeq:null,nextCursor:e.nextCursor&&typeof e.nextCursor=="object"?e.nextCursor:null,totalCount:Number.isFinite(e.totalCount)?e.totalCount:s.totalCount,error:d?null:e.error||null}};let u=this._yeaftHistoryResultRefreshByRequestId?.[e.requestId];if(u?.source==="outline"){clearTimeout(u.timeout);let{[e.requestId]:p,...f}=this._yeaftHistoryResultRefreshByRequestId;this._yeaftHistoryResultRefreshByRequestId=f;let g=c.find(v=>u.messageId&&v?.messageId===u.messageId||u.entryId&&v?.entryId===u.entryId);u.resolve(g||null)}return d&&this.loadYeaftHistoryOutline({force:!0,targetSessionId:e.sessionId,targetAgentId:e.agentId}),!0},searchYeaftHistory(e,{append:t=!1,senderKey:s=""}={}){if(this.currentView!=="yeaft")return!1;let n=typeof e=="string"?e.trim():"",r=typeof s=="string"&&(s==="user"||s.startsWith("vp:"))?s.slice(0,103):"",i=this.yeaftActiveSessionFilter||null,o=Me(this,i);if(this._yeaftHistorySearchTimeout&&(clearTimeout(this._yeaftHistorySearchTimeout),this._yeaftHistorySearchTimeout=null),!i||!o||Array.from(n).length<1&&!r)return this.yeaftHistorySearchState={requestId:null,agentId:o,sessionId:i,query:n,senderKey:r,loading:!1,results:[],hasMore:!1,nextBeforeSeq:null,nextCursor:null,error:null},!1;let a=this.yeaftHistorySearchState||{};if(!Tt(this,o,"session_history_search"))return this.yeaftHistorySearchState={requestId:null,agentId:o,sessionId:i,query:n,senderKey:r,loading:!1,results:[],hasMore:!1,nextBeforeSeq:null,nextCursor:null,error:"unsupported"},!1;let l=`history_search_${Date.now()}_${Math.random().toString(36).slice(2,8)}`;this.yeaftHistorySearchState={requestId:l,agentId:o,sessionId:i,query:n,senderKey:r,loading:!0,results:t&&a.query===n&&a.senderKey===r?a.results:[],hasMore:!1,nextBeforeSeq:t&&a.query===n&&a.senderKey===r?a.nextBeforeSeq:null,nextCursor:t&&a.query===n&&a.senderKey===r&&a.nextCursor||null,error:null},this._yeaftHistorySearchTimeout=setTimeout(()=>{this.yeaftHistorySearchState?.requestId===l&&(this._yeaftHistorySearchTimeout=null,this.yeaftHistorySearchState={...this.yeaftHistorySearchState,loading:!1,error:"timeout"})},1e4);let c=un(),d={type:"yeaft_search_history",agentId:o,sessionId:i,requestId:l,perfTraceId:c,query:n,senderKey:r,limit:20,...t&&a.query===n&&a.senderKey===r&&a.nextCursor?{cursor:a.nextCursor}:{},...t&&a.query===n&&a.senderKey===r&&!a.nextCursor&&Number.isFinite(a.nextBeforeSeq)?{beforeSeq:a.nextBeforeSeq}:{}};return vt(this,{traceId:c,phase:"history_search.request_send",agentId:o,sessionId:i,messageType:d.type,bytes:JSON.stringify(d).length,detail:{append:t,limit:d.limit,queryLength:Array.from(n).length,senderFilter:!!r}}),this.sendWsMessage(d),!0},handleYeaftHistorySearchResult(e){let t=this.yeaftHistorySearchState||{};if(!e||e.requestId!==t.requestId||e.agentId!==t.agentId||e.sessionId!==t.sessionId||e.query!==t.query||(e.senderKey||"")!==t.senderKey)return!1;this._yeaftHistorySearchTimeout&&(clearTimeout(this._yeaftHistorySearchTimeout),this._yeaftHistorySearchTimeout=null);let s=Array.isArray(e.results)?e.results.map(o=>({...o,agentId:e.agentId,sessionId:e.sessionId})):[],n=new Map((t.results||[]).map(o=>[_r(o),o]));for(let o of s)(o?.entryId||o?.messageId)&&n.set(_r(o),o);let r=Array.from(n.values());this.yeaftHistorySearchState={...t,loading:!1,results:r,hasMore:!!e.hasMore,nextBeforeSeq:Number.isFinite(e.nextBeforeSeq)?e.nextBeforeSeq:null,nextCursor:e.nextCursor&&typeof e.nextCursor=="object"?e.nextCursor:null,error:e.error||null};let i=this._yeaftHistoryResultRefreshByRequestId?.[e.requestId];if(i){clearTimeout(i.timeout);let{[e.requestId]:o,...a}=this._yeaftHistoryResultRefreshByRequestId;this._yeaftHistoryResultRefreshByRequestId=a;let l=r.find(c=>i.messageId&&c?.messageId===i.messageId||i.entryId&&c?.entryId===i.entryId);i.resolve(l||null)}return!0},reloadYeaftHistoryResult(e){let t=e?.sessionId||null,s=e?.agentId||null,n=this.yeaftHistorySearchState||{},i=n.agentId===s&&n.sessionId===t&&(Array.from(String(n.query||"").trim()).length>0||!!n.senderKey);if(!t||!s)return Promise.resolve(null);let o=i&&n.query||"",a=i&&n.senderKey||"",l=null,c=!1;if(i)c=this.searchYeaftHistory(o,{senderKey:a}),l=this.yeaftHistorySearchState?.requestId||null;else{let d=Pe(s,t),u=this.yeaftHistoryOutlineBySession?.[d]||null;u?.loading===!0&&u.requestAppend!==!0&&u.requestId?(c=!0,l=u.requestId):(c=this.loadYeaftHistoryOutline({force:!0,targetSessionId:t,targetAgentId:s}),l=this.yeaftHistoryOutlineBySession?.[d]?.requestId||null)}return!c||!l?Promise.resolve(null):new Promise(d=>{let u=setTimeout(()=>{if(this._yeaftHistoryResultRefreshByRequestId?.[l]?.resolve!==d)return;let{[l]:f,...g}=this._yeaftHistoryResultRefreshByRequestId;this._yeaftHistoryResultRefreshByRequestId=g,d(null)},1e4);this._yeaftHistoryResultRefreshByRequestId={...this._yeaftHistoryResultRefreshByRequestId||{},[l]:{agentId:s,sessionId:t,query:o,senderKey:a,source:i?"search":"outline",messageId:e?.messageId||null,entryId:e?.entryId||null,resolve:d,timeout:u}}})},loadYeaftHistoryWindow(e,{validateCached:t=!1}={}){let s=e?.sessionId||this.yeaftActiveSessionFilter||null,n=e?.agentId||Me(this,s),r=_r(e);if(!s||!n||!e?.entryId||!Number.isFinite(e.indexGeneration)||!Number.isFinite(e.entryStartSeq)||!e?.messageId||!Number.isFinite(e.seq))return Promise.resolve(!1);let i=yt(this,s,n);if((this.messagesMap[i]||[]).some(v=>(v?.sessionId??v?.groupId??null)===s&&v?.historyEntryId===e.entryId&&v?.historyIndexGeneration===e.indexGeneration)&&!t)return Promise.resolve(!0);let a=Pe(n,`${s}:${r}:generation:${e.indexGeneration}`),l=this._yeaftHistoryWindowPendingByKey||{};if(l[a]?.promise)return l[a].promise;let c=`history_window_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,d=null,u=null,p=new Promise(v=>{d=v});Object.defineProperty(p,"error",{get:()=>u});let f=v=>{u=v||null},g=setTimeout(()=>{if(this._yeaftHistoryWindowPendingByKey?.[a]?.requestId!==c)return;let{[a]:m,...y}=this._yeaftHistoryWindowPendingByKey;this._yeaftHistoryWindowPendingByKey=y,d(!1)},1e4);return this._yeaftHistoryWindowPendingByKey={...l,[a]:{requestId:c,agentId:n,sessionId:s,entryId:e.entryId||null,indexGeneration:Number.isFinite(e.indexGeneration)?e.indexGeneration:null,entryStartSeq:Number.isFinite(e.entryStartSeq)?e.entryStartSeq:null,resultId:r,messageId:e.messageId,prefetch:!t,validateCached:!!t,setError:f,resolve:d,timeout:g,promise:p}},this.sendWsMessage({type:"yeaft_load_history_window",agentId:n,sessionId:s,requestId:c,prefetch:!t,...e.entryId?{entryId:e.entryId}:{},...Number.isFinite(e.indexGeneration)?{indexGeneration:e.indexGeneration}:{},...Number.isFinite(e.entryStartSeq)?{entryStartSeq:e.entryStartSeq}:{},anchorMessageId:e.messageId,anchorSeq:e.seq,beforeTurns:5,afterTurns:5,maxRows:200,maxBytes:512*1024}),p},beginYeaftHistoryReveal(e){let t=e?.sessionId||null,s=e?.agentId||null,n=yt(this,t,s);if(!t||!s||!n)return null;let r=Pe(s,t),i=`${r}${n}`,o=++this._yeaftHistoryRevealSequence,a={key:i,token:o,sessionKey:r,agentId:s,sessionId:t,conversationId:n};return this._yeaftHistoryRevealLeases={...this._yeaftHistoryRevealLeases||{},[i]:a},a},finishYeaftHistoryReveal(e){if(!e?.key||!Number.isFinite(e.token)||this._yeaftHistoryRevealLeases?.[e.key]?.token!==e.token)return!1;let{[e.key]:s,...n}=this._yeaftHistoryRevealLeases;return this._yeaftHistoryRevealLeases=n,!0},async revealYeaftHistoryResult(e,t=null){let s=!t,n=t||this.beginYeaftHistoryReveal(e),r=e?.sessionId||null,i=e?.agentId||null,o=yt(this,r,i);if(!n||!r||!i||!o||!e?.messageId)return this.finishYeaftHistoryReveal(n),!1;let a=e,l=this.loadYeaftHistoryWindow(a,{validateCached:!0}),c=await l;if(!c&&l.error==="stale_result"){let u=await this.reloadYeaftHistoryResult(a);u&&(a=u,l=this.loadYeaftHistoryWindow(a,{validateCached:!0}),c=await l)}if(!c)return this.finishYeaftHistoryReveal(n),!1;if(this.currentView!=="yeaft"||this.yeaftActiveSessionFilter!==r||Me(this,r)!==i||yt(this,r,i)!==o)return this.finishYeaftHistoryReveal(n),!1;let d=this.revealYeaftMessage(r,a.messageId,o,i);return(!d||s)&&this.finishYeaftHistoryReveal(n),d},pendingYeaftHistoryWindow(e){let s=Object.entries(this._yeaftHistoryWindowPendingByKey||{}).find(([,i])=>i?.requestId===e?.requestId);if(!s)return null;let[n,r]=s;return e.agentId!==r.agentId||e.sessionId!==r.sessionId||e.entryId&&r.entryId&&e.entryId!==r.entryId||Number.isFinite(e.indexGeneration)&&Number.isFinite(r.indexGeneration)&&e.indexGeneration!==r.indexGeneration?null:{pendingKey:n,pending:r}},handleYeaftHistoryWindow(e,t=null){let s=this.pendingYeaftHistoryWindow(e);if(!s)return!1;let{pendingKey:n,pending:r}=s;r.prefetch===!0&&e.prefetch!==!0&&r.validateCached!==!0&&(e.prefetch=!0),clearTimeout(r.timeout);let{[n]:i,...o}=this._yeaftHistoryWindowPendingByKey;this._yeaftHistoryWindowPendingByKey=o;let a=!e.error&&!!t&&this.isYeaftMessageCached(r.sessionId,r.messageId,t,r.agentId);return r.setError?.(e.error||null),r.resolve(!!a),!!a},createYeaftSession({displayName:e,vpIds:t,defaultVpId:s,workDir:n,agentId:r}={}){let i=Array.isArray(t)?t.slice():[],o=s&&i.includes(s)?s:i[0]||null,a=(e||"").trim(),l=(n||"").trim(),c={roster:i,defaultVpId:o};return a&&(c.name=a),l&&(c.workDir=l),this.sessionCrudRequest("create",c,{agentId:r})},handleYeaftOutput(e){if(!e)return;let t=e.agentId||this.yeaftAgentId||this.currentAgent||null,s=e.conversationId||e.event?.conversationId||null,n=Wn(this,t,s);if(e.data&&n){if(e.data.type!=="result")return;let a=lu(this,t,s);if(!a)return;let l=e.turnId?bn(this,t,e.turnId):"",c=!!(l&&this.activeVpTurns?.[l])||(this.messagesMap?.[a]||[]).some(d=>d?.turnId===e.turnId&&(d.isStreaming||d.status==="pending"));if(!e.turnId||!c)return;e={...e,conversationId:a}}if(e.perfTraceId&&(vt(this,{traceId:e.perfTraceId,phase:"receive.yeaft_output",agentId:e.agentId||null,sessionId:e.sessionId||null,vpId:e.vpId||null,turnId:e.turnId||null,threadId:e.threadId||null,messageType:e.data?.type||e.event?.type||e.type}),e.turnId&&(this.yeaftPerfTraceByTurnId={...this.yeaftPerfTraceByTurnId||{},[e.turnId]:e.perfTraceId})),e.data){let a=e.agentId||null,l=Ss(this,a,e.conversationId);if(l){let d=Al(e,e.turnId||"session");for(let u of["retry","retrying","thinking"])Bn(this,l,`${u}:${d}`);e.data?.tool_use_result&&Bn(this,l,`tool:${d}`)}let c=e.turnId?bn(this,e.agentId||null,e.turnId):"";if(c&&this.activeVpTurns?.[c]?.retryAttempt){let{retryAttempt:d,retryMax:u,retryDelayMs:p,retryReason:f,retryRecoveryMode:g,...v}=this.activeVpTurns[c];this.activeVpTurns={...this.activeVpTurns,[c]:v}}if(l){let d=e.sessionId??e.groupId??null,u=Qp(this,d,a),p=a&&this.yeaftConversationIdsByAgent?this.yeaftConversationIdsByAgent[a]:null,f=Qt(this,a);f&&f.targetConversationId!==l?Br(this,a,l):!f&&p&&p!==l&&!String(p).startsWith("yeaft-local-")&&(Xt(this,p,l,{removeSource:p!==this.yeaftConversationId}),Fr(this,a,p,l)),za(this,a,l);let g=Qt(this,a,l),v=g?.sourceConversationId||p,m=!u&&v===this.yeaftConversationId;if(this.currentView==="yeaft"&&a&&v&&v!==l){let k=!m&&(!!g||String(v).startsWith("yeaft-local-"));Xt(this,v,l,{removeSource:k}),m?Qi(this,a,v,l):k&&Hr(this,a,l)}a&&(this.yeaftConversationIdsByAgent={...this.yeaftConversationIdsByAgent||{},[a]:l}),(u||!this.yeaftConversationId)&&(this.yeaftConversationId=l),u&&(this.activeConversations=[l]),this.messagesMap[l]||(this.messagesMap[l]=[]);let y=this._currentYeaftAgentId,h=this._currentYeaftSessionId,w=this._currentYeaftVpId,S=this._currentYeaftTurnId,b=this._currentYeaftThreadId;a&&(this._currentYeaftAgentId=a),d!=null&&(this._currentYeaftSessionId=d),e.vpId&&(this._currentYeaftVpId=e.vpId),e.turnId&&(this._currentYeaftTurnId=e.turnId),e.threadId&&(this._currentYeaftThreadId=e.threadId);try{let k=typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now();if(this.handleAssistantOutputFrame(l,e.data,a),e.perfTraceId){let O=typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now();vt(this,{traceId:e.perfTraceId,phase:"store.apply_output",agentId:e.agentId||null,sessionId:d||null,vpId:e.vpId||null,turnId:e.turnId||null,threadId:e.threadId||null,messageType:e.data?.type||null,durationMs:O-k}),Zi(this,{traceId:e.perfTraceId,agentId:e.agentId||null,sessionId:d||null,vpId:e.vpId||null,turnId:e.turnId||null,threadId:e.threadId||null,messageType:e.data?.type||null})}let P=e.data,x=P?.message?.id||P?.id||null,B=Ob(x),D=Array.isArray(P?.message?.content)?P.message.content:[],U=D.some(O=>O?.type==="tool_use"),F=!!P?.tool_use_result||D.some(O=>O?.type==="tool_result");if(d){let O=!F&&!Lb(this,l,d)&&(P?.type==="user"||P?.type==="assistant"&&!U)?B:null,M=Pe(e.agentId||null,d),R=this.yeaftSessionHistoryState[M]||{},J=Number.isFinite(R.latestSeq)?R.latestSeq:-1;O!==null&&O>J&&(this.yeaftSessionHistoryState={...this.yeaftSessionHistoryState,[M]:{...R,latestSeq:O}})}}finally{this._currentYeaftAgentId=y,this._currentYeaftSessionId=h,this._currentYeaftVpId=w,this._currentYeaftTurnId=S,this._currentYeaftThreadId=b}}return}let r=e.event;if(!r)return;let i={...r,vpId:r.vpId||e.vpId||null,threadId:r.threadId||e.threadId||null,turnId:r.turnId||e.turnId||null},o=Ss(this,e.agentId||null,e.conversationId);if(o){let a=Al(i);r.type==="tool_start"?qr(this,o,`tool:${a}`):r.type==="tool_end"?Bn(this,o,`tool:${a}`):r.type==="llm_retry"?qr(this,o,`retry:${a}`):r.type==="vp_async_task_wait_start"?qr(this,o,`async-wait:${a}`):r.type==="vp_async_task_wait_end"&&Bn(this,o,`async-wait:${a}`)}switch(r.type){case"project_mutation_result":r.projectsAuthoritative===!0?this.finishProjectMutation(r):this.finishLegacyProjectMutation(r,e.agentId||null);break;case"ask_user_question":{let a=Ss(this,e.agentId||null,e.conversationId);if(!a||!r.requestId)break;let l=jp(e,r,a),c=()=>{let d=this.messagesMap[a]||[],u=Kp(d,l,a);if(u){if(u.askAnswered||u.askExpired)return!0;u.toolName="AskUserQuestion",r.toolCallId&&!u.toolId&&(u.toolId=r.toolCallId),u.agentId=l.agentId||u.agentId||null;for(let v of["sessionId","vpId","turnId","threadId"])l[v]&&(u[v]=l[v]);u.hasResult=!1,u.askRequestId=r.requestId,u.askQuestions=r.questions||[],u.askCreatedAt=r.createdAt||null,u.askExpiresAt=r.expiresAt||null,u.isHistory=!1;let g=zp(this,l);return g&&Sl(u,g),this.messagesMap={...this.messagesMap,[a]:d.slice()},!0}if(!r.replay)return!1;let p={id:`ask-card-${r.requestId}`,type:"tool-use",toolName:"AskUserQuestion",toolId:r.toolCallId||null,toolInput:{questions:r.questions||[]},askRequestId:r.requestId,askQuestions:r.questions||[],askCreatedAt:r.createdAt||null,askExpiresAt:r.expiresAt||null,agentId:l.agentId,sessionId:l.sessionId,vpId:l.vpId,speakerVpId:l.vpId,turnId:l.turnId,threadId:l.threadId||"main",hasResult:!1,isHistory:!1,timestamp:r.createdAt||Date.now()},f=zp(this,l);return f&&Sl(p,f),d.push(p),this.messagesMap={...this.messagesMap,[a]:d.slice()},!0};if(!c()){let d=0,u=setInterval(()=>{d+=1,(c()||d>=10)&&clearInterval(u)},200)}break}case"ask_user_answered":case"ask_user_answer_rejected":case"ask_user_expired":{let a=Ss(this,e.agentId||null,e.conversationId);if(!a||!r.requestId)break;let l=this.messagesMap[a]||[],c=jp(e,r,a),d=Kp(l,c,a);if(!d){$b(this,c,r);break}Sl(d,r),this.messagesMap={...this.messagesMap,[a]:l.slice()};break}case"session_ready":{let a=r.conversationId,l=e.agentId||this.currentAgent;if(Wn(this,l,a))break;let c=l&&this.yeaftConversationIdsByAgent?this.yeaftConversationIdsByAgent[l]:null,d=this.yeaftConversationId?String(this.yeaftConversationId):"",u=d.startsWith("yeaft-local-")&&(!l||d.startsWith(`yeaft-local-${l}-`)||/^yeaft-local-\d/.test(d))?this.yeaftConversationId:null,p=c||u,f=r.sessionId||e.sessionId||null,g=Qp(this,f,l),v=Qt(this,l);v&&v.targetConversationId!==a?Br(this,l,a):!v&&c&&c!==a&&!String(c).startsWith("yeaft-local-")&&Fr(this,l,c,a),za(this,l,a);let y=Qt(this,l,a)?.sourceConversationId||p,h=!g&&y===this.yeaftConversationId;if(y&&y!==a){let P=!h;Xt(this,y,a,{removeSource:P}),h?Qi(this,l,y,a):P&&Hr(this,l,a)}else this.messagesMap[a]||(this.messagesMap[a]=[]);l&&(this.yeaftConversationIdsByAgent={...this.yeaftConversationIdsByAgent||{},[l]:a},this.cacheYeaftAgentStatus(l,r,{allowBootstrapCatalog:g})),g&&(this.yeaftModel=r.model,this.yeaftModelEffort=r.modelEffort||null,this.yeaftSessionReady=!0,this.yeaftBootstrapMetaLoadingKey=null,l?this.applyCachedYeaftStatus(l):this.yeaftAvailableModels=r.availableModels||[]);let w=Array.isArray(r.tasks)?r.tasks:[],S={};for(let[P,x]of Object.entries(this.yeaftActiveTasksBySession||{})){let B=Object.fromEntries(Object.entries(x||{}).filter(([,U])=>U?.id&&U.status==="running"&&U.agentId&&U.agentId!==l)),D=Cl(B);Object.keys(D).length>0&&(S[P]=D)}for(let P of w){if(!P?.id||!P.sessionId||P.status!=="running")continue;let x=Pe(l,P.sessionId);S[x]={...S[x]||{},[P.id]:{...P,agentId:l}}}this.yeaftActiveTasksBySession=S,g&&(r.yeaftDir&&(this.yeaftYeaftDir=r.yeaftDir),this.yeaftStatus={skills:r.skills,mcpServers:r.mcpServers,tools:r.tools,multiVp:!!r.multiVp}),(g||!this.yeaftConversationId)&&(this.yeaftConversationId=a),g&&(this.activeConversations=[a]);let b=e.agentId||this.currentAgent||null,k=b||"__current__";this._yeaftVpSubscribedAgentKey!==k&&(this._yeaftVpSubscribedAgentKey=k,this.sendWsMessage(b?{type:"yeaft_vp_subscribe",agentId:b}:{type:"yeaft_vp_subscribe"}));break}case"yeaft_status":{let a=e.agentId||this.currentAgent;a&&this.cacheYeaftAgentStatus(a,r);break}case"context_usage":break;case"turn_open":{if(!r.turnId)break;let a={turnId:r.turnId,userPrompt:r.userPrompt||"",vpId:r.vpId||e.vpId||null,sessionId:r.sessionId||e.sessionId||null,openedAt:r.at||Date.now(),closedAt:null,totalMs:0,inputTokens:0,outputTokens:0,totalTokens:0,loopCount:0,memoryLoaded:null,memoryLoadedMeta:null,memoryAdjust:null,tools:[],detailsLoaded:!0};this.yeaftDebugTurnsById={...this.yeaftDebugTurnsById,[r.turnId]:a};let l=bn(this,e.agentId||null,r.turnId),c=this.activeVpTurns?.[l];c&&Number.isFinite(r.at)&&(this.activeVpTurns={...this.activeVpTurns,[l]:{...c,startedAt:r.at}}),this.yeaftDebugTurnOrder.includes(r.turnId)||(this.yeaftDebugTurnOrder=[...this.yeaftDebugTurnOrder,r.turnId]);break}case"turn_close":{if(!r.turnId)break;let a=this.yeaftDebugTurnsById[r.turnId];if(!a)break;this.yeaftDebugTurnsById={...this.yeaftDebugTurnsById,[r.turnId]:{...a,closedAt:Date.now(),...Number.isFinite(r.totalMs)?{totalMs:r.totalMs}:{},...Number.isFinite(r.inputTokens)?{inputTokens:r.inputTokens}:{},...Number.isFinite(r.outputTokens)?{outputTokens:r.outputTokens}:{},...Number.isFinite(r.totalTokens)?{totalTokens:r.totalTokens}:{},loopCount:r.loopCount||a.loopCount||0,...typeof r.model=="string"&&r.model?{model:r.model}:{},...typeof r.effort=="string"&&r.effort?{effort:r.effort}:{}}};break}case"memory_used":{if(!r.turnId)break;let a=this.yeaftDebugTurnsById[r.turnId];if(!a)break;this.yeaftDebugTurnsById={...this.yeaftDebugTurnsById,[r.turnId]:{...a,memoryLoaded:Array.isArray(r.loaded)?r.loaded:[],memoryLoadedMeta:r.meta||null}};break}case"dream_memory_loaded":{let a=Array.isArray(r.resident)?r.resident:[];if(r.turnId){let c=this.yeaftDebugTurnsById[r.turnId];c&&(this.yeaftDebugTurnsById={...this.yeaftDebugTurnsById,[r.turnId]:{...c,dreamMemoryLoaded:a,dreamMemoryLoadedInto:r.loadedInto||"system_prompt.memory"}})}let l={};for(let c of a){let d=c&&typeof c.scope=="string"?c.scope:null,u=d&&/^sessions\/[^/]+$/.test(d)?d:d&&/^group\/[^/]+$/.test(d)?`sessions/${d.slice(6)}`:null;u&&(l[u]={scope:u,sourceScope:d,sessionId:u.slice(9),turnId:r.turnId||null,vpId:r.vpId||null,loadedInto:r.loadedInto||"system_prompt.memory",summary:c.summary||"",truncated:!!c.truncated,receivedAt:Date.now()})}Object.keys(l).length>0&&(this.yeaftDreamPromptLoads={...this.yeaftDreamPromptLoads,...l});break}case"memory_adjust":{if(!r.turnId)break;let a=this.yeaftDebugTurnsById[r.turnId];if(!a)break;this.yeaftDebugTurnsById={...this.yeaftDebugTurnsById,[r.turnId]:{...a,memoryAdjust:{sessionKey:r.sessionKey||null,added:r.added||0,evicted:r.evicted||0,skipped:r.skipped||0,reason:r.reason||""}}};break}case"tool_exec":{if(this.scheduleYeaftDebugDetailRefresh(e,r.turnId),!r.turnId)break;let a=this.yeaftDebugTurnsById[r.turnId];if(!a)break;let l=[...a.tools||[],{loopNumber:r.loopNumber||0,callId:r.callId||null,name:r.name||"?",durationMs:r.durationMs||0,isError:!!r.isError}];this.yeaftDebugTurnsById={...this.yeaftDebugTurnsById,[r.turnId]:{...a,tools:l}};break}case"loop":{if(this.scheduleYeaftDebugDetailRefresh(e,r.turnId),this.yeaftDebugLoops.push({turnId:r.turnId||null,loopNumber:r.loopNumber||0,model:r.model,usage:r.usage||{inputTokens:0,outputTokens:0,totalTokens:0},latencyMs:r.latencyMs,ttfbMs:r.ttfbMs,stopReason:r.stopReason,at:typeof r.at=="number"?r.at:null,sessionId:e.sessionId||null,vpId:e.vpId||r.vpId||null}),this.yeaftDebugLoops.length>Xp){let a=Sp({loops:this.yeaftDebugLoops,turnsById:this.yeaftDebugTurnsById,turnOrder:this.yeaftDebugTurnOrder,maxLoops:Math.max(Xp,this.yeaftDebugHistoryLimit||0)});this.yeaftDebugLoops=a.loops,this.yeaftDebugTurnsById=a.turnsById,this.yeaftDebugTurnOrder=a.turnOrder}break}case"llm_retry":{if(!e.turnId)break;let a=bn(this,e.agentId||null,e.turnId),l=this.activeVpTurns?.[a];if(!l)break;let c=r.reason==="stream_idle_timeout"?"stream_idle_timeout":"transient_error";this.activeVpTurns={...this.activeVpTurns,[a]:{...l,retryAttempt:r.attempt||0,retryMax:r.maxRetries||0,retryDelayMs:r.delayMs||0,retryReason:c,retryRecoveryMode:r.recoveryMode||"restart"}};break}case"recall":case"fallback":case"thinking_delta":break;case"reflection":{let a=Ss(this,e.agentId||null,e.conversationId)||"unknown",l=Array.isArray(r.loopRange)?r.loopRange:[0,0],c=`${a}:${r.trigger}:${l[0]}-${l[1]}`,d=this.yeaftReflectionCards[c],u=this.messagesMap[a]||[],p=d?d.anchorMsgId:u.length>0&&u[u.length-1].id||null,f=d?d.anchorOrder:u.length;this.yeaftReflectionCards={...this.yeaftReflectionCards,[c]:{key:c,conversationId:a,turnId:r.turnId||d&&d.turnId||null,loopNumber:r.loopNumber||d&&d.loopNumber||null,trigger:r.trigger,status:r.status,loopRange:l,toolCount:r.toolCount||0,content:r.content||"",durationMs:r.durationMs||0,error:r.error||null,sessionId:e.sessionId||null,anchorMsgId:p,anchorOrder:f,updatedAt:Date.now()}};break}case"model_switched":this.yeaftModel=r.model,this.yeaftModelEffort=r.modelEffort||null;break;case"yeaft_task_event":{let a=r.task;if(!a?.id||!a.sessionId)break;let l=e.agentId||Me(this,a.sessionId),c=Pe(l,a.sessionId),d={...a,agentId:l},u={...this.yeaftActiveTasksBySession},p={...u[c]||{}};a.status==="running"?p[a.id]=d:delete p[a.id];let f=Cl(p);if(Object.keys(f).length>0?u[c]=f:delete u[c],this.yeaftActiveTasksBySession=u,a.status!=="running"){let{[Il(l,a.sessionId,a.id)]:g,...v}=this.yeaftStoppingTasksById||{};this.yeaftStoppingTasksById=v}break}case"yeaft_task_cancel_result":{let a=r.taskId||r.task?.id||null,l=r.task?.sessionId||r.sessionId||e.sessionId||null,c=e.agentId||Me(this,l);if(a&&l&&r.success===!1){let{[Il(c,l,a)]:u,...p}=this.yeaftStoppingTasksById||{};this.yeaftStoppingTasksById=p}let d=r.task;if(d?.id&&d.sessionId){let u=Pe(c,d.sessionId),p={...this.yeaftActiveTasksBySession},f={...p[u]||{}};d.status==="running"?f[d.id]={...d,agentId:c}:delete f[d.id];let g=Cl(f);Object.keys(g).length>0?p[u]=g:delete p[u],this.yeaftActiveTasksBySession=p}break}case"sub_agent_event":{let a=Ss(this,e.agentId||null,e.conversationId)||"unknown",l=r.agentId;if(!l)break;let c=r.payload||{},d=`${a}:${l}`,u=this.yeaftSubAgentCards[d],p=this.messagesMap[a]||[],f=u?u.anchorMsgId:p.length>0&&p[p.length-1].id||null,g=u?u.anchorOrder:p.length,v=u?{...u}:{key:d,conversationId:a,agentId:l,agentName:c.agentName||"sub-agent",status:"running",text:"",toolCallCount:0,turns:0,error:null,expanded:!1,anchorMsgId:f,anchorOrder:g,updatedAt:Date.now(),sessionId:e.sessionId||null};switch(c.agentName&&!v.agentName&&(v.agentName=c.agentName),c.type){case"sub_agent_status":v.status=c.status||v.status,c.error&&(v.error=c.error);break;case"text_delta":break;case"tool_use":case"tool_call":v.toolCallCount=Number(v.toolCallCount||0)+1;break;case"tool_start":break;case"tool_result":case"tool_end":break;case"sub_agent_turn_end":{v.turns+=1;let m=typeof c.content=="string"?c.content.trim():"";m&&(v.text=v.text?`${v.text}
|
|
9
9
|
|
|
10
|
-
${m}`:m),v.status!=="failed"&&v.status!=="closed"&&(v.status=c.status||"idle");break}case"error":c.error&&(v.error=c.error.message||String(c.error));break;default:break}v.updatedAt=Date.now(),this.yeaftSubAgentCards={...this.yeaftSubAgentCards,[d]:v};break}case"history_loaded":{let a={...r,agentId:e.agentId||null,requestId:r.requestId||e.requestId||null};if(a.requestId&&!this.isCurrentYeaftHistoryResponse(a))break;let l=e.agentId||null,c=r.sessionId??null,d=Pe(l,c),u=e.perfTraceId||this.yeaftHistoryPerfTraceBySession?.[d];u&&vt(this,{traceId:u,phase:"history.loaded_event",agentId:e.agentId||null,sessionId:r.sessionId||null,messageType:r.type,detail:{mode:r.mode||"recent",count:r.count||0,hasMore:!!r.hasMore}});let p=r.mode==="delta"?"delta":"recent",f=this.yeaftSessionHistoryState[d]||{},g=Number.isFinite(r.latestSeq)?r.latestSeq:Number.isFinite(f.latestSeq)?f.latestSeq:null,v=Number.isFinite(r.nextBeforeSeq)?r.nextBeforeSeq:Number.isFinite(r.oldestSeq)?r.oldestSeq:Number.isFinite(f.serverOldestFetchedSeq)?f.serverOldestFetchedSeq:Number.isFinite(f.oldestSeq)?f.oldestSeq:null,m=p==="delta"?{...f,loaded:!0,loading:!1,latestSeq:g,syncingAfterSeq:null,count:(f.count||0)+(r.count||0)}:{...f,loaded:!0,loading:!1,hasMore:!!r.hasMore,serverHasMore:!!r.hasMore,oldestSeq:v,serverOldestFetchedSeq:v,count:typeof r.count=="number"?r.count:0,latestSeq:g,syncingAfterSeq:null},y=a.requestId?this.finishYeaftHistoryLoad(a,m,"completion"):null;y||(this.yeaftSessionHistoryState={...this.yeaftSessionHistoryState,[d]:m});let h=Pe(l?this.currentAgent:null,this.yeaftActiveSessionFilter??null);if(d===h)p==="recent"&&(this.yeaftHasMoreHistory=m.hasMore,this.yeaftOldestLoadedSeq=m.serverOldestFetchedSeq),this.yeaftLoadingMoreHistory=!!y?.loading;else if(this.yeaftLoadingMoreHistory){let w=this.yeaftSessionHistoryState[h]||null;this.yeaftLoadingMoreHistory=!!w?.loading}}break;case"vp_snapshot":{let a=window.Pinia?.useVpStore?.()||window.__useVpStore&&window.__useVpStore();a&&a.applySnapshot(r,e.agentId||null,e.requestId||null);break}case"vp_snapshot_error":{let a=window.Pinia?.useVpStore?.()||window.__useVpStore&&window.__useVpStore();a&&a.failSnapshot(e.agentId||null,e.requestId||null,r.error||r.message||"VP library request failed");break}case"vp_updated":{let a=window.Pinia?.useVpStore?.()||window.__useVpStore&&window.__useVpStore();a&&r.vp&&a.upsert(r.vp,r.reason,e.agentId||null);break}case"vp_removed":{let a=window.Pinia?.useVpStore?.()||window.__useVpStore&&window.__useVpStore();a&&r.vpId&&a.remove(r.vpId,r.reason,e.agentId||null);break}case"vp_crud_result":{let a=this._vpCrudPending&&this._vpCrudPending.get(r.requestId);a&&(this._vpCrudPending.delete(r.requestId),a.resolve({ok:!!r.ok,op:r.op,vpId:r.vpId,vp:r.vp,error:r.error||null}));break}case"group_list_updated":case"session_list_updated":case"yeaft_session_hydrate":{let a=window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore(),l=r.sessions||[];if(r.projectsAuthoritative===!0&&Array.isArray(r.projects)?this.applySessionCatalogSnapshot(this.sessionCatalog,r.projects):Array.isArray(r.projects)&&e.agentId&&this.applyLegacyProjectSnapshot(r.projects,e.agentId),r.type!=="yeaft_session_hydrate"&&this.yeaftSessionHydrateRequestId&&this.yeaftSessionInventoryCompleteSupported===!0){let f=Array.isArray(this.yeaftSessionHydrateSlices)?this.yeaftSessionHydrateSlices.filter(g=>g.agentId!==(e.agentId||null)):[];this.yeaftSessionHydrateSlices=[...f,{agentId:e.agentId||null,sessions:l}];break}let c=a&&a.activeSessionId||null,d=a?.activeSessionKey&&a.sessions?.[a.activeSessionKey]?.agentId||null;a&&(a.applySnapshot(l,e.agentId||null),this._hasHandledYeaftSessionHydrate=!0,this.yeaftSessionHydrateError=null);let u=a&&a.activeSessionId||null,p=a?.activeSessionKey&&a.sessions?.[a.activeSessionKey]?.agentId||null;if(this.currentView==="yeaft"&&u){let f=p||Me(this,u,e.agentId||null),g=Pe(f,u),v=this.yeaftSessionHistoryState[g]||null;this.setActiveSessionFilter(u,{agentId:f,force:d!==f||Jd(u,c,v)})}break}case"group_roster_changed":case"session_roster_changed":{let a=window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore();a&&a.applyRosterChange(r,e.agentId||null);break}case"group_crud_result":case"session_crud_result":{let a=window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore();a&&a.applyCrudResult(r,e.agentId||null),r.ok&&r.op==="delete"&&r.sessionId&&e.agentId&&this.clearYeaftHistoryMemory({agentId:e.agentId,sessionId:r.sessionId});let l=this._sessionCrudPending&&this._sessionCrudPending.get(r.requestId);l&&(()=>{if(this._sessionCrudPending?.get(r.requestId)!==l)return;this._sessionCrudPending.delete(r.requestId);let d=r.session||r.group||null,u=d&&e.agentId&&!d.agentId?{...d,agentId:e.agentId}:d,p=r.sessionId||null,f=r.sessions||null;l.resolve({ok:!!r.ok,op:r.op,session:u,sessionId:p,sessions:f,config:r.config||null,error:r.error||null})})();break}case"vp_turn_start":{if(!r.turnId||!r.vpId)break;let a=rl(e.agentId||null,r.turnId)||r.turnId;if(this.activeVpTurns={...this.activeVpTurns,[a]:{agentId:e.agentId||null,turnId:r.turnId,vpId:r.vpId,sessionId:r.sessionId||null,threadId:r.threadId||null,isStreaming:!0,startedAt:r.ts||Date.now()}},r.sessionId){let l=ys(e.agentId||null,r.sessionId);this.yeaftProcessingSessions={...this.yeaftProcessingSessions,...l?{[l]:!0}:{[r.sessionId]:!0}}}break}case"vp_turn_end":{if(!r.turnId)break;let a=bn(this,e.agentId||null,r.turnId),l=r.sessionId||this.activeVpTurns?.[a]?.sessionId||null;r.reason==="end_turn"&&l&&this.markYeaftSessionUnread(l,e.agentId||null);let{[a]:c,...d}=this.activeVpTurns;this.activeVpTurns=d;let{[a]:u,...p}=this.stoppingVpTurnIds;this.stoppingVpTurnIds=p;let f=r.sessionId||c?.sessionId||null,g=e.agentId||c?.agentId||null,v=r.vpId||c?.vpId||null;if(!(f&&v?Object.values(this.activeVpTurns||{}).some(b=>b?.vpId===v&&Mt(b,f,g)):!1)&&f&&v){let b={...this.vpStatuses||{}},k=!1;for(let[P,x]of Object.entries(b))x?.vpId===v&&Mt(x,f,g)&&Zr.has(x.state)&&(b[P]={...x,state:"idle",turnId:null,since:r.ts||Date.now()},k=!0);k&&(this.vpStatuses=b)}this.clearYeaftSessionProcessingIfIdle(f,{agentId:g});let h={end_turn:"completed",route_forward:"completed",aborted:"aborted",errored:"errored",error:"errored",cancelled:"cancelled",canceled:"cancelled"}[r.reason]||"completed",w=Date.now(),S=Ss(this,e.agentId||null,e.conversationId);if(S&&Array.isArray(this.messagesMap[S])){let b=this.messagesMap[S],k=Op(b,r);for(let P=0;P<b.length;P++){let x=b[P];if(!x||x.type!=="assistant")continue;let B=x.sessionId??x.groupId;r.sessionId&&B&&B!==r.sessionId||r.vpId&&x.speakerVpId&&x.speakerVpId!==r.vpId||r.turnId&&x.turnId&&x.turnId!==r.turnId||x.status&&x.status!=="pending"||(x.status=h,x.turnEndAt=w,x.turnEndReason=r.reason||null,r.detail&&(x.turnEndDetail=r.detail),Number.isFinite(r.durationMs)&&(x.turnDurationMs=r.durationMs),k=!0)}k&&(this.messagesMap={...this.messagesMap,[S]:b.slice()}),this.pruneConversationMessageRetention(S,f,g)}break}case"yeaft_turn_aborted":{let a=Array.isArray(r.turnIds)?r.turnIds.filter(Boolean):[];r.turnId&&a.push(r.turnId);let l=r.sessionId||null,c=r.vpId||null,d=new Set;for(let g of a){let v=bn(this,e.agentId||null,g),m=this.activeVpTurns?.[v]||null;(!m||Mt(m,m.sessionId,e.agentId||null))&&d.add(v)}if(c)for(let[g,v]of Object.entries(this.activeVpTurns||{}))!v||v.vpId!==c||Mt(v,l,e.agentId||null)&&d.add(g);if(d.size===0)break;let u=l,p={...this.activeVpTurns||{}},f={...this.stoppingVpTurnIds||{}};for(let g of d){let v=p[g];!u&&v?.sessionId&&(u=v.sessionId),delete p[g],delete f[g]}this.activeVpTurns=p,this.stoppingVpTurnIds=f,this.clearYeaftSessionProcessingIfIdle(u||null,{agentId:e.agentId||null});break}case"yeaft_aborted":{let a=r.sessionId||e.sessionId||null;a?(this.activeVpTurns=Object.fromEntries(Object.entries(this.activeVpTurns||{}).filter(([,l])=>!Mt(l,a,e.agentId||null))),this.stoppingVpTurnIds=Object.fromEntries(Object.entries(this.stoppingVpTurnIds||{}).filter(([l])=>this.activeVpTurns?.[l])),this.vpStatuses=Object.fromEntries(Object.entries(this.vpStatuses||{}).filter(([,l])=>!Mt(l,a,e.agentId||null))),this.clearYeaftSessionProcessingIfIdle(a,{agentId:e.agentId||null,ignoreStatuses:!0})):r.all&&Bp(this,e.agentId||null);break}case"vp_typing_start":{if(!r.vpId)break;let a=Ss(this,e.agentId||null,e.conversationId);if(!a)break;this.yeaftVpTyping=yp(this.yeaftVpTyping,a,r.vpId);break}case"vp_typing_end":{if(!r.vpId)break;let a=Ss(this,e.agentId||null,e.conversationId);if(!a)break;this.yeaftVpTyping=bp(this.yeaftVpTyping,a,r.vpId);break}case"vp_status_changed":{if(!r.vpId||!r.state)break;if(o){let u=Al(i);if(r.state==="thinking"||r.state==="retrying"||r.state==="tool")qr(this,o,`${r.state}:${u}`);else if(r.state==="streaming"||r.state==="idle"||r.state==="error")for(let p of["thinking","retrying","tool"])Bn(this,o,`${p}:${u}`)}let a=r.sessionId||null,l=e.agentId||null,c=ao(l,a,r.vpId),d={agentId:l,state:r.state,since:r.since||Date.now(),turnId:r.turnId||null,title:r.title||"",sessionId:a,vpId:r.vpId};if(this.vpStatuses={...this.vpStatuses,[c]:d},a&&Zr.has(r.state)){let u=ys(l,a);this.yeaftProcessingSessions={...this.yeaftProcessingSessions,...u?{[u]:!0}:{[a]:!0}}}else a&&this.clearYeaftSessionProcessingIfIdle(a,{agentId:l});this.restoreActiveYeaftSessionFromStatuses([d],l);break}case"vp_status_snapshot":{let a=Array.isArray(r.statuses)?r.statuses:[],l=r.sessionId;if(l==null){let c={...this.vpStatuses||{}};if(e.agentId)for(let[d,u]of Object.entries(c))(!u?.agentId||u.agentId===e.agentId)&&delete c[d];else for(let d of Object.keys(c))delete c[d];for(let d of a){if(!d||!d.vpId)continue;let u=d.sessionId||d.groupId||null,p=ao(e.agentId||null,u,d.vpId);c[p]={agentId:e.agentId||null,state:d.state,since:d.since||Date.now(),turnId:d.turnId||null,title:d.title||"",sessionId:u,vpId:d.vpId}}this.vpStatuses=c}else{let c={...this.vpStatuses};for(let[d,u]of Object.entries(c))u&&u.sessionId===l&&(!e.agentId||!u.agentId||u.agentId===e.agentId)&&delete c[d];for(let d of a){if(!d||!d.vpId)continue;let u=d.sessionId||d.groupId||null,p=ao(e.agentId||null,u,d.vpId);c[p]={agentId:e.agentId||null,state:d.state,since:d.since||Date.now(),turnId:d.turnId||null,title:d.title||"",sessionId:u,vpId:d.vpId}}this.vpStatuses=c}this.yeaftProcessingSessions=Ib(this,e.agentId||null,a,l??null),this.restoreActiveYeaftSessionFromStatuses(a,e.agentId||null);break}case"yeaft_dream_snapshot":{let a=r&&r.snapshot,l=a&&typeof a.scope=="string"?a.scope:null;l&&(this.yeaftDreamSnapshots={...this.yeaftDreamSnapshots,[l]:{...a,receivedAt:Date.now()}});break}case"yeaft_dream_status":{let a=window.Pinia?.useVpStore?.()||window.__useVpStore&&window.__useVpStore();a&&a.applyDreamStatus(r);break}case"yeaft_dream_result":{let a=window.Pinia?.useVpStore?.()||window.__useVpStore&&window.__useVpStore();a&&a.applyDreamResult(r),r?.snapshot?.scope&&(this.yeaftDreamSnapshots={...this.yeaftDreamSnapshots,[r.snapshot.scope]:{...r.snapshot,receivedAt:Date.now()}});{let l=typeof r?.snapshot?.scope=="string"&&r.snapshot.scope?r.snapshot.scope:typeof r?.sessionId=="string"&&r.sessionId?`sessions/${r.sessionId}`:null;if(!l)break;let c=this.yeaftDreamLatest[l]||null;this.yeaftDreamLatest={...this.yeaftDreamLatest,[l]:{scope:l,phase:"result",status:r.skipped?"skipped":r.success?"success":"error",startedAt:c?.startedAt??null,finishedAt:Date.now(),mergedCount:typeof r.entriesCreated=="number"?r.entriesCreated:c?.mergedCount??null,error:r.skipped||r.success?null:r.error||"unknown",manual:typeof r?.manual=="boolean"?r.manual:c?.manual??null,durationMs:typeof r.durationMs=="number"?r.durationMs:c?.durationMs??null,llmCallCount:typeof r.llmCallCount=="number"?r.llmCallCount:c?.llmCallCount??0,inputTokens:typeof r.inputTokens=="number"?r.inputTokens:c?.inputTokens??0,outputTokens:typeof r.outputTokens=="number"?r.outputTokens:c?.outputTokens??0,totalTokens:typeof r.totalTokens=="number"?r.totalTokens:c?.totalTokens??0,metrics:r.metrics||c?.metrics||null,passBreakdown:r.passBreakdown||r.metrics?.passBreakdown||c?.passBreakdown||null,isRunning:!1}},this._appendDreamEvent(l,{type:"dream_progress",phase:"result",sessionId:r.sessionId,status:r.skipped?"skipped":r.success?"success":"error",success:!!r.success,entriesCreated:typeof r.entriesCreated=="number"?r.entriesCreated:null,trigger:r.trigger||null,error:r.skipped||r.success?null:r.error||null,skipped:!!r.skipped,skippedReason:r.skippedReason||null,durationMs:typeof r.durationMs=="number"?r.durationMs:null,llmCallCount:typeof r.llmCallCount=="number"?r.llmCallCount:0,inputTokens:typeof r.inputTokens=="number"?r.inputTokens:0,outputTokens:typeof r.outputTokens=="number"?r.outputTokens:0,totalTokens:typeof r.totalTokens=="number"?r.totalTokens:0,metrics:r.metrics||null,passBreakdown:r.passBreakdown||r.metrics?.passBreakdown||null,ts:Date.now()})}break}case"dream_progress":{let a=r?.phase||"unknown",l=null;typeof r?.target=="string"&&r.target.includes("/")?l=r.target:typeof r?.sessionId=="string"&&r.sessionId?l=`sessions/${r.sessionId}`:l="*";let c=a==="done",d=a==="error"||r?.status==="error",u=!c&&!d,p=f=>{let g=this.yeaftDreamLatest[f]||null;return{scope:f,phase:a,status:d?"error":c?"success":"running",startedAt:g?.startedAt&&u?g.startedAt:r?.ts||g?.startedAt||Date.now(),finishedAt:c||d?r?.ts||Date.now():null,mergedCount:typeof r?.mergedCount=="number"?r.mergedCount:typeof r?.targets=="number"?r.targets:g?.mergedCount??null,error:d?r?.error||"unknown":null,manual:typeof r?.manual=="boolean"?r.manual:g?.manual??!1,durationMs:typeof r?.duration=="number"?r.duration:typeof r?.durationMs=="number"?r.durationMs:g?.durationMs??null,llmCallCount:typeof r?.llmCallCount=="number"?r.llmCallCount:g?.llmCallCount??0,inputTokens:typeof r?.inputTokens=="number"?r.inputTokens:g?.inputTokens??0,outputTokens:typeof r?.outputTokens=="number"?r.outputTokens:g?.outputTokens??0,totalTokens:typeof r?.totalTokens=="number"?r.totalTokens:g?.totalTokens??0,metrics:r?.metrics||g?.metrics||null,passBreakdown:r?.passBreakdown||r?.metrics?.passBreakdown||g?.passBreakdown||null,isRunning:u}};if(l==="*"){let f={...this.yeaftDreamLatest,"*":p("*")};for(let g of Object.keys(this.yeaftDreamLatest))g!=="*"&&(f[g]=p(g));this.yeaftDreamLatest=f}else this.yeaftDreamLatest={...this.yeaftDreamLatest,[l]:p(l)};this._appendDreamEvent(l,r);break}}},_appendDreamEvent(e,t){if(!e||!t)return;let s=Date.now(),n={...t,at:s},r=Array.isArray(this.yeaftDreamEvents?.[e])?this.yeaftDreamEvents[e]:[],i=l=>[l?.type||"",l?.phase||"",(l?.sessionId??l?.groupId)||"",l?.target||"",l?.ts||l?.at||""].join("|"),o=i(n);if(r.some(l=>i(l)===o))return;let a=[...r,n];a.length>Jp&&a.splice(0,a.length-Jp),this.yeaftDreamEvents={...this.yeaftDreamEvents,[e]:a}},fetchExpertRoleDefinitions(){if(this.expertRoleDefinitions)return;let e=this.currentAgent;e&&this.sendWsMessage({type:"get_expert_roles",agentId:e})},setYeaftSidebarEnabled(e){try{typeof localStorage<"u"&&localStorage.removeItem("yeaft-sidebar-enabled")}catch{}},vpCrudRequest(e,t){(!this._vpCrudPending||typeof this._vpCrudPending.get!="function")&&(this._vpCrudPending=new Map);let s="vpc_"+Date.now().toString(36)+"_"+Math.random().toString(36).slice(2,8),r={create:"yeaft_vp_create",update:"yeaft_vp_update",delete:"yeaft_vp_delete",read:"yeaft_vp_read"}[e];if(!r)return Promise.resolve({ok:!1,op:e,error:{code:"bad_op",message:"unknown op: "+e}});let i={type:r,requestId:s};return e==="create"||e==="update"?i.payload=t||{}:i.vpId=t,new Promise(o=>{let a=setTimeout(()=>{this._vpCrudPending&&this._vpCrudPending.has(s)&&(this._vpCrudPending.delete(s),o({ok:!1,op:e,error:{code:"timeout",message:"vp_crud timeout"}}))},1e4);this._vpCrudPending.set(s,{resolve:l=>{clearTimeout(a),o(l)}}),this.sendWsMessage(i)})},sessionCrudRequest(e,t,s={}){(!this._sessionCrudPending||typeof this._sessionCrudPending.get!="function")&&(this._sessionCrudPending=new Map);let n="grc_"+Date.now().toString(36)+"_"+Math.random().toString(36).slice(2,8),i={list:"yeaft_list_sessions",create:"yeaft_create_session",copy:"yeaft_copy_session",rename:"yeaft_rename_session",update:"yeaft_update_session",update_config:"yeaft_update_session_config",archive:"yeaft_archive_session",delete:"yeaft_delete_session",add_member:"yeaft_session_add_member",remove_member:"yeaft_session_remove_member",set_default_vp:"yeaft_session_set_default_vp",reorder:"reorder_yeaft_sessions",scan_workdir:"yeaft_scan_workdir_sessions",restore:"yeaft_restore_session"}[e];if(!i)return Promise.resolve({ok:!1,op:e,error:{code:"bad_op",message:"unknown op: "+e}});let o={type:i,requestId:n};e==="create"?o.payload=t||{}:t&&typeof t=="object"&&Object.assign(o,t);let a=s&&s.agentId?s.agentId:null;a&&(o.agentId=a);let l=window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore();return l&&l.markPending(n,e),new Promise(c=>{let d=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=Me(this,e,t);if(!s)return!1;let n=xr(s,e);return this.currentView==="yeaft"&&this.yeaftActiveSessionFilter===e&&Me(this,e)===s||this.yeaftUnreadSessionKeys?.[n]?!1:(this.yeaftUnreadSessionKeys={...this.yeaftUnreadSessionKeys,[n]:!0},!0)},markYeaftSessionRead(e,t=null){if(!e)return!1;let s=Me(this,e,t);if(!s)return!1;let n=xr(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||ef(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?Me(this,n,t.agentId||null):this.currentAgent,i=!!n&&n===s&&!!r&&!!this.currentAgent&&r!==this.currentAgent,o=!!t.force||i;if(this.yeaftActiveSessionFilter=n,r&&n&&this.currentAgent!==r){this.selectAgent(r);let l=this.agents.find(c=>c.id===r);this.activateYeaftAgent(r,l||null)}else r&&n&&this.activateYeaftAgent(r);r&&n&&(this.markYeaftSessionRead(n,r),zd(this,r,n));let a=!o&&n===s;if(r&&n){this.yeaftSessionAgentById={...this.yeaftSessionAgentById||{},[n]:r};let l=this.yeaftConversationIdsByAgent?.[r]||null;l||(l=`yeaft-local-${r}-${Date.now()}`,this.yeaftConversationIdsByAgent={...this.yeaftConversationIdsByAgent||{},[r]:l}),this.yeaftConversationId=l,this.messagesMap[l]||(this.messagesMap[l]=[]),this.currentView==="yeaft"&&(this.activeConversations=[l])}try{let l=window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore();l&&typeof l.setActive=="function"&&l.setActive(n,r||null);let c=l?.activeSessionKey||null;c?localStorage.setItem("lastViewedYeaftSession",c):localStorage.removeItem("lastViewedYeaftSession")}catch{}this.syncActiveYeaftHistoryLoad(),n&&r&&!a&&this.requestYeaftSessionBootstrap({forceSessionReady:!0,forceHistoryReplay:!0})},async switchYeaftModel(e,t=null,s=void 0){if(!e||!this.currentAgent)return;let n=t||null;if(n){let r={model:e};return s!==void 0&&(r.modelEffort=s||null),await this.sessionCrudRequest("update_config",{sessionId:n,config:r},{agentId:Me(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()?Zp:xl,dreamLimit:5,indexOnly:!0,search:this.yeaftDebugSearch})},250)},setYeaftDebugSessionFilter(e){e==null?this.yeaftDebugSessionFilter=null:this.yeaftDebugSessionFilter=String(e)},toggleSubAgentCardExpand(e){let t=this.yeaftSubAgentCards?.[e];t&&(this.yeaftSubAgentCards={...this.yeaftSubAgentCards,[e]:{...t,expanded:!t.expanded}})},requestTelemetrySettings(e,t,s=null){if(!t)return Promise.reject(new Error("no agent"));let n=`telemetry-${Date.now()}-${Math.random().toString(36).slice(2)}`;return this.telemetryRequestByAgent={...this.telemetryRequestByAgent,[t]:n},new Promise((r,i)=>{this._telemetryPending||(this._telemetryPending={});let o=setTimeout(()=>{if(delete this._telemetryPending[n],this.telemetryRequestByAgent?.[t]===n){let a={...this.telemetryRequestByAgent};delete a[t],this.telemetryRequestByAgent=a}i(new Error("Telemetry request timed out"))},15e3);this._telemetryPending[n]={resolve:r,reject:i,timer:o,agentId:t,operation:e,requestId:n},this.sendWsMessage({type:e==="load"?"get_telemetry_settings":"update_telemetry_settings",agentId:t,requestId:n,...e==="update"?{settings:s||{}}:{}})})},loadTelemetrySettings(e=this.currentAgent){return e?this.requestTelemetrySettings("load",e):Promise.resolve({enabled:!0,retentionDays:3,flushIntervalMs:1e3,maxQueueSize:5e3,rawExchangeMaxBytes:524288,traceTextMaxBytes:262144,loaded:!0})},updateTelemetrySettings(e,t=this.currentAgent){return this.requestTelemetrySettings("update",t,e)},restartAgent(e){if(!e||this.agentOperations?.[e]?.restart?.pending)return!1;let t=`restart-${Date.now()}-${Math.random().toString(36).slice(2)}`,s=setTimeout(()=>this.finishAgentOperation(e,"restart","timeout"),12e4);return this.agentOperations={...this.agentOperations,[e]:{...this.agentOperations[e]||{},restart:{pending:!0,acknowledged:!1,startedAt:Date.now(),requestId:t,timer:s,error:null}}},this.sendWsMessage({type:"restart_agent",agentId:e,requestId:t}),!0},upgradeAgent(e,t=null){if(!e||this.agentOperations?.[e]?.upgrade?.pending)return!1;let s=this.agents.find(i=>i.id===e),n=`upgrade-${Date.now()}-${Math.random().toString(36).slice(2)}`,r=setTimeout(()=>this.finishAgentOperation(e,"upgrade","timeout"),12e4);return this.agentOperations={...this.agentOperations,[e]:{...this.agentOperations[e]||{},upgrade:{pending:!0,acknowledged:!1,startedAt:Date.now(),requestId:n,oldVersion:s?.version||null,batchId:t,timer:r,error:null}}},this.sendWsMessage({type:"upgrade_agent",agentId:e,requestId:n}),!0},getUpgradableAgents(){return(this.agents||[]).filter(e=>e?.online&&Array.isArray(e.capabilities)&&e.capabilities.includes("remote_upgrade_safe")&&!e.capabilities.includes("container_agent")&&!this.agentOperations?.[e.id]?.restart?.pending&&!this.agentOperations?.[e.id]?.upgrade?.pending)},upgradeAllAgents(){if(this.agentUpgradeBatch?.pending)return null;let e=this.getUpgradableAgents();if(e.length===0)return null;let t={id:`upgrade-batch-${Date.now()}-${Math.random().toString(36).slice(2)}`,pending:!0,startedAt:Date.now(),agentIds:e.map(s=>s.id),skippedCount:Math.max(0,(this.agents||[]).length-e.length),results:{}};this.agentUpgradeBatch=t;for(let s of e)this.upgradeAgent(s.id,t.id)||this.recordAgentUpgradeBatchResult(s.id,{status:"failed",error:"not_started"},t.id);return t.agentIds.length},recordAgentUpgradeBatchResult(e,t={},s=null){let n=this.agentUpgradeBatch;if(!n?.pending||s&&n.id!==s||!n.agentIds.includes(e)||n.results[e])return null;let r={...n,results:{...n.results,[e]:{status:t.status||"failed",error:t.error||null,version:t.version||null,reason:t.reason||null}}},i=r.agentIds.every(o=>r.results[o]);return this.agentUpgradeBatch=i?{...r,pending:!1,completedAt:Date.now()}:r,i&&typeof window<"u"&&window.dispatchEvent(new CustomEvent("agent-upgrade-batch-complete",{detail:this.agentUpgradeBatch})),i?this.agentUpgradeBatch:null},finishAgentOperation(e,t,s=null){let n=this.agentOperations?.[e]?.[t];n&&(clearTimeout(n.timer),this.agentOperations={...this.agentOperations,[e]:{...this.agentOperations[e]||{},[t]:{...n,pending:!1,timer:null,error:s}}},t==="upgrade"&&n.batchId&&this.recordAgentUpgradeBatchResult(e,s?{status:"failed",error:s}:{status:"upgraded"},n.batchId))},loadSearchSettings(){return this.currentAgent?new Promise(e=>{this._searchPending||(this._searchPending={}),this._searchPending.load=e,this.sendWsMessage({type:"get_search_settings",agentId:this.currentAgent})}):(this.searchSettings={backend:"tavily",tavilyKeyConfigured:!1,tavilyKeyMasked:null,disableHtmlFallback:!1,loaded:!0},Promise.resolve(this.searchSettings))},updateSearchSettings(e){return this.currentAgent?new Promise(t=>{this._searchPending||(this._searchPending={}),this._searchPending.update=t,this.sendWsMessage({type:"update_search_settings",agentId:this.currentAgent,settings:e||{}})}):Promise.resolve({error:"no agent"})},loadTavilyUsage(){return this.currentAgent?(this.tavilyUsageLoading=!0,new Promise(e=>{this._searchPending||(this._searchPending={}),this._searchPending.usage=e,this.sendWsMessage({type:"get_tavily_usage",agentId:this.currentAgent})})):Promise.resolve(null)},loadYeaftMcpServers(){if(!this.currentAgent)return this.yeaftMcpServers=[],this.yeaftMcpRuntime={connected:!1,toolCount:0,perServer:[]},Promise.resolve({servers:[],runtime:this.yeaftMcpRuntime});this.yeaftMcpLoading=!0;let e=`mcp-list-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;return new Promise(t=>{this._mcpPending||(this._mcpPending={}),this._mcpPending[e]=t,this.sendWsMessage({type:"yeaft_mcp_list",agentId:this.currentAgent,requestId:e})})},addYeaftMcpServer(e){if(!this.currentAgent)return Promise.resolve({error:"no agent"});this.yeaftMcpLoading=!0;let t=`mcp-add-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;return new Promise(s=>{this._mcpPending||(this._mcpPending={}),this._mcpPending[t]=s,this.sendWsMessage({type:"yeaft_mcp_add",agentId:this.currentAgent,requestId:t,server:e||{}})})},removeYeaftMcpServer(e){if(!this.currentAgent)return Promise.resolve({error:"no agent"});this.yeaftMcpLoading=!0;let t=`mcp-rem-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;return new Promise(s=>{this._mcpPending||(this._mcpPending={}),this._mcpPending[t]=s,this.sendWsMessage({type:"yeaft_mcp_remove",agentId:this.currentAgent,requestId:t,name:e})})},reloadYeaftMcpServer(e){if(!this.currentAgent)return Promise.resolve({error:"no agent"});this.yeaftMcpLoading=!0;let t=`mcp-rel-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;return new Promise(s=>{this._mcpPending||(this._mcpPending={}),this._mcpPending[t]=s,this.sendWsMessage({type:"yeaft_mcp_reload",agentId:this.currentAgent,requestId:t,name:e||null})})},clearYeaftMessages(){let e=this.yeaftConversationId;e&&(qe(this,e),delete this.messagesMap[e],delete this.processingConversations[e],delete this.executionStatusMap[e],delete this.refreshingSessionMap[e],this._closedAt&&delete this._closedAt[e],this._turnCompletedConvs?.delete(e)),this.yeaftConversationId=this.currentAgent?`yeaft-local-${this.currentAgent}-${Date.now()}`:`yeaft-local-${Date.now()}`,this.currentAgent&&(this.yeaftConversationIdsByAgent={...this.yeaftConversationIdsByAgent||{},[this.currentAgent]:this.yeaftConversationId}),this.messagesMap[this.yeaftConversationId]=[],this.activeConversations=[this.yeaftConversationId],this.yeaftSessionReady=!1,this.yeaftModel=null,this.yeaftAvailableModels=[],this.yeaftStatus=null,this._yeaftAskTerminalEvents={},this.yeaftDebugLoops=[],this.yeaftDebugTurnsById={},this.yeaftDebugTurnOrder=[],this.yeaftDebugHistoryLoading=!1,this.yeaftDebugHistoryError=null,this.yeaftDebugHistoryFetchedAt=0,this.yeaftDebugHistoryProjection=null,this.yeaftDebugSearch="",this.yeaftDebugSessionFilter=null,this.yeaftDebugPanel={open:!1,status:"idle",requestId:null,agentId:null,sessionId:null,turnId:null,error:null},this._yeaftDebugSearchTimer&&(clearTimeout(this._yeaftDebugSearchTimer),this._yeaftDebugSearchTimer=null),this._fetchYeaftDebugHistoryTimer&&(clearTimeout(this._fetchYeaftDebugHistoryTimer),this._fetchYeaftDebugHistoryTimer=null),this._yeaftDebugHistoryInFlightKey=null,this._yeaftDebugHistoryLatestListRequestId=null,this._yeaftDebugHistoryLatestDetailRequestId=null,this.yeaftReflectionCards={},this.yeaftSubAgentCards={},this.yeaftDreamLatest={},this.yeaftDreamEvents={},this.vpStatuses={},this.currentAgent&&this.sendWsMessage({type:"yeaft_reset",agentId:this.currentAgent})},togglePaneRightPanel(e,t=null){if(t&&this.isSplitMode){let s=this.panels.find(n=>n.id===t);if(s){s.activeRightPanel=s.activeRightPanel===e?null:e;return}}this.activeRightPanel=this.activeRightPanel===e?null:e,this.activeRightPanel&&(this.workbenchExpanded=!1,this.workbenchMaximized=!1,this.rememberWorkbenchPanelState())},getPaneRightPanel(e){if(e&&this.isSplitMode){let t=this.panels.find(s=>s.id===e);if(t)return t.activeRightPanel}return this.activeRightPanel},setPaneRightPanel(e,t){if(e&&this.isSplitMode){let s=this.panels.find(n=>n.id===e);if(s){s.activeRightPanel=t;return}}this.activeRightPanel=t},applySessionCatalogSnapshot(e,t=null,s=null){let n=r=>{let i=new Set;return(Array.isArray(r)?r:[]).filter(o=>!o?.catalogKey||i.has(o.catalogKey)?!1:(i.add(o.catalogKey),!0)).map(o=>({...o}))};if(this.sessionCatalog=n(e),Array.isArray(s)&&(this.hiddenSessionCatalog=n(s)),Array.isArray(t)){this.sessionProjects=t.filter(i=>i?.id).map(i=>({...i,members:Array.isArray(i.members)?i.members.filter(o=>o?.agentId&&o?.sessionId):i.agentId?(i.sessionIds||[]).map(o=>({agentId:i.agentId,sessionId:o})):[]}));let r=new Map;for(let i of this.sessionProjects)for(let o of i.members)r.set(`${o.agentId}${o.sessionId}`,i.id);this.sessionCatalog=this.sessionCatalog.map(i=>i.runtimeProvider==="yeaft"?{...i,projectId:r.get(`${i.routeRef?.agentId}${i.routeRef?.sessionId}`)||null}:i)}this.sessionCatalogLoaded=!0},mutateProject(e,t={},s=null){let n=s||t.agentId||this.currentAgent||null;if(e==="move_session"&&!n)return Promise.resolve({ok:!1,error:{code:"missing_agent"}});let r=`project_${crypto.randomUUID()}`;return new Promise(i=>{let o=setTimeout(()=>{delete this.projectMutationRequests[r],i({ok:!1,error:{code:"timeout"}})},1e4);this.projectMutationRequests[r]={connectionGeneration:Number(this.chatHistoryConnectionGeneration||0),catalogOrder:Array.isArray(t.catalogOrder)?t.catalogOrder:null,resolve:l=>{clearTimeout(o),i(l)}},this.sendWsMessage({type:"yeaft_project_mutation",...n?{agentId:n,targetAgentId:n}:{},requestId:r,op:e,...t})||(clearTimeout(o),delete this.projectMutationRequests[r],i({ok:!1,error:{code:"send_failed"}}))})},applyLegacyProjectSnapshot(e,t){if(!t||!Array.isArray(e))return;let s=this.sessionProjects.filter(r=>r.legacyAgentId!==t),n=e.filter(r=>r?.id).map(r=>({...r,id:`${t}${r.id}`,legacyProjectId:r.id,legacyAgentId:t,members:(r.sessionIds||[]).map(i=>({agentId:t,sessionId:i}))}));this.applySessionCatalogSnapshot(this.sessionCatalog,[...s,...n])},finishLegacyProjectMutation(e,t){if(!e?.requestId)return!1;let s=this.projectMutationRequests[e.requestId]||null;return!s||s.connectionGeneration!==Number(this.chatHistoryConnectionGeneration||0)?!1:(delete this.projectMutationRequests[e.requestId],e.ok&&Array.isArray(e.projects)&&t&&this.applyLegacyProjectSnapshot(e.projects,t),s.resolve(e),!0)},finishProjectMutation(e){if(!e?.requestId)return!1;let t=this.projectMutationRequests[e.requestId]||null;if(!t||t.connectionGeneration!==Number(this.chatHistoryConnectionGeneration||0))return!1;if(delete this.projectMutationRequests[e.requestId],e.ok){if(Array.isArray(t.catalogOrder)){let s=new Map(this.sessionCatalog.map(r=>[r.catalogKey,r])),n=t.catalogOrder.map((r,i)=>{let o=s.get(r?.catalogKey);return o?{...o,sortRank:i}:null}).filter(Boolean);n.length===this.sessionCatalog.length&&(this.sessionCatalog=n,Yp(n))}Array.isArray(e.projects)&&this.applySessionCatalogSnapshot(this.sessionCatalog,e.projects)}return t.resolve(e),!0},toggleCatalogSessionPin(e){if(!e?.catalogKey||!e?.routeRef||Object.keys(this.sessionCatalogMutationRequests).length>0)return!1;let t=`session_ui_${crypto.randomUUID()}`,s=Tr(this,t),n=!e.pinned;return e.pinned=n,this.sendWsMessage({type:"set_session_ui_metadata",requestId:t,catalogKey:e.catalogKey,routeRef:e.routeRef,pinned:n,sortRank:Number.isFinite(e.sortRank)?e.sortRank:null})?!0:(this.sessionCatalog=s,delete this.sessionCatalogMutationRequests[t],!1)},hideCatalogSession(e){if(!e?.catalogKey||!e?.routeRef||Object.keys(this.sessionCatalogMutationRequests).length>0)return!1;let t=`session_hide_${crypto.randomUUID()}`,s=Tr(this,t);return this.sessionCatalog=this.sessionCatalog.filter(r=>r.catalogKey!==e.catalogKey),this.hiddenSessionCatalog=[...(this.hiddenSessionCatalog||[]).filter(r=>r.catalogKey!==e.catalogKey),{...e,hidden:!0}],this.sendWsMessage({type:"set_session_ui_metadata",requestId:t,catalogKey:e.catalogKey,routeRef:e.routeRef,hidden:!0,...Number.isFinite(e.sortRank)?{sortRank:e.sortRank}:{}})?!0:(this.sessionCatalog=s,this.hiddenSessionCatalog=Array.isArray(this.sessionCatalogMutationRequests[t]?.previousHiddenCatalog)?this.sessionCatalogMutationRequests[t].previousHiddenCatalog:[],delete this.sessionCatalogMutationRequests[t],!1)},restoreCatalogSession(e){if(!e?.catalogKey||!e?.routeRef||Object.keys(this.sessionCatalogMutationRequests).length>0)return!1;let t=`session_restore_${crypto.randomUUID()}`,s=Tr(this,t);return this.hiddenSessionCatalog=(this.hiddenSessionCatalog||[]).filter(r=>r.catalogKey!==e.catalogKey),this.sessionCatalog=this.sessionCatalog.some(r=>r.catalogKey===e.catalogKey)?this.sessionCatalog:[...this.sessionCatalog,{...e,hidden:!1}],this.sendWsMessage({type:"set_session_ui_metadata",requestId:t,catalogKey:e.catalogKey,routeRef:e.routeRef,hidden:!1,...Number.isFinite(e.sortRank)?{sortRank:e.sortRank}:{}})?!0:(this.sessionCatalog=s,this.hiddenSessionCatalog=Array.isArray(this.sessionCatalogMutationRequests[t]?.previousHiddenCatalog)?this.sessionCatalogMutationRequests[t].previousHiddenCatalog:[],delete this.sessionCatalogMutationRequests[t],!1)},renameCatalogSession({row:e,title:t}={}){if(!e?.routeRef||!t)return!1;let{runtimeProvider:s,agentId:n,sessionId:r}=e.routeRef;if(s==="yeaft")this.sessionCrudRequest("rename",{sessionId:r,name:t},{agentId:n});else if(s==="claude-code"||s==="copilot")this.renameChatSession(r,t,n);else return!1;return!0},async copyCatalogSession(e){let t=e?.routeRef;if(t?.runtimeProvider!=="yeaft"||!t.agentId||!t.sessionId)return{ok:!1,op:"copy",error:{code:"bad_route",message:"Yeaft Session route required"}};let s=await this.sessionCrudRequest("copy",{sessionId:t.sessionId},{agentId:t.agentId});if(!s?.ok||!s.session?.id)return s;let n={runtimeProvider:"yeaft",agentId:s.session.agentId||t.agentId,sessionId:s.session.id};return this.openCatalogSession({catalogKey:xr(n.agentId,n.sessionId),routeRef:n}),s},reorderCatalogSessions(e){if(!Array.isArray(e)||e.length===0||Object.keys(this.sessionCatalogMutationRequests).length>0)return!1;let t=`session_order_${crypto.randomUUID()}`,s=Tr(this,t);return this.sessionCatalog=e.map((r,i)=>({...r,sortRank:i})),this.sendWsMessage({type:"reorder_session_catalog",requestId:t,sessions:this.sessionCatalog.map((r,i)=>({catalogKey:r.catalogKey,routeRef:r.routeRef,pinned:!!r.pinned,sortRank:i}))})?!0:(this.sessionCatalog=s,delete this.sessionCatalogMutationRequests[t],!1)},finishSessionCatalogMutation(e){if(!fd(this,e))return!1;if(e?.ok===!0&&e?.type==="session_ui_metadata_updated"){let s=n=>{n&&(n.pinned=e.pinned===!0,Object.prototype.hasOwnProperty.call(e,"sortRank")&&(n.sortRank=Number.isFinite(e.sortRank)?e.sortRank:null))};s(this.sessionCatalog.find(n=>n.catalogKey===e.catalogKey)),s(this.hiddenSessionCatalog.find(n=>n.catalogKey===e.catalogKey))}return e?.ok===!0&&e?.type==="session_catalog_reorder_result"&&Yp(this.sessionCatalog),!0},openCatalogSession(e){if(!e?.catalogKey||!e.routeRef)return!1;let{runtimeProvider:t,agentId:s,sessionId:n}=e.routeRef;if(this.activeCatalogKey=e.catalogKey,t==="yeaft"){let r=this.isSessionHistorySyncing(e.routeRef);return this.enterYeaft(s,{deferBootstrap:!0}),this.setActiveSessionFilter(n,{agentId:s,force:!1}),r||this.reloadYeaftMessages(),!0}return t!=="claude-code"&&t!=="copilot"?!1:(this.currentView==="yeaft"&&this.leaveYeaft(),this.selectConversation(n,s,{refresh:!0}),!0)},syncChatConversationHistory(e){if(!e)return null;let t=Vs(e);if(this.chatHistoryRequests[t]?.loading)return this.chatHistoryRequests[t].requestId;let s=cn(this.messagesMap[e]);return this.requestChatHistory(e,s===null?{mode:"recent",turns:5}:{mode:"delta",afterMessageId:s})},requestChatHistory(e,{mode:t="recent",turns:s=null,beforeId:n=null,afterMessageId:r=null}={}){if(!e)return null;let i=Vs(e);if(this.chatHistoryRequestIdSupported!==!0&&this.chatHistoryRequests[i]?.loading)return null;let o=n??r??null,a=this.beginChatHistoryRequest(e,t,o);return this.sendWsMessage({type:"sync_messages",conversationId:e,...s!=null?{turns:s}:{},...n!=null?{beforeId:n}:{},...r!=null?{afterMessageId:r}:{},requestId:a})?(setTimeout(()=>{Ra(this,i,a,"history_load_timeout")},1e4),a):(Ra(this,i,a,"send_failed"),null)},beginChatHistoryRequest(e,t="recent",s=null){return gd(this,e,t,s)},isCurrentChatHistoryResponse(e){if(!e?.conversationId||!e?.requestId||!e?.catalogKey)return!1;let t=Vs(e.conversationId);if(e.catalogKey!==t)return!1;let s=this.chatHistoryRequests[t];return!!s&&s.loading===!0&&s.requestId===e.requestId&&Number(s.connectionGeneration||0)===Number(this.chatHistoryConnectionGeneration||0)},finishChatHistoryRequest(e){if(!this.isCurrentChatHistoryResponse(e))return!1;let t=this.chatHistoryRequests[e.catalogKey];return this.chatHistoryRequests[e.catalogKey]={...t,loading:!1},!0},isRefreshingSession(e){return e?!!this.refreshingSessionMap[e]:this.refreshingSession},setRefreshingSession(e,t){e&&(this.refreshingSessionMap[e]=t),this.refreshingSession=t},enterBtwMode(){this.btwMode=!0,this.btwMessages=[],this.btwLoading=!1,this.btwSessionId=null},sendBtwQuestion(e){this.currentConversation&&(this.btwMessages.push({role:"user",content:e}),this.btwMessages.push({role:"assistant",content:""}),this.btwLoading=!0,this.sendWsMessage({type:"btw_question",conversationId:this.currentConversation,question:e,btwSessionId:this.btwSessionId}))},closeBtw(){this.btwMode=!1,this.btwMessages=[],this.btwLoading=!1,this.btwSessionId=null},appendBtwDelta(e){let t=this.btwMessages[this.btwMessages.length-1];t&&t.role==="assistant"&&(t.content+=e)},addSubagent(e,t){this.subagents[e]||(this.subagents[e]={}),this.subagents[e][t.id]={id:t.id,slug:t.slug||t.id,type:t.type||"Task",description:t.description||"",parentToolUseId:t.parentToolUseId||null,status:"running",startTime:Date.now(),messages:[],toolCallCount:0},e===this.currentConversation&&this.activeRightPanel!=="subagents"&&(this.activeRightPanel="subagents")},appendSubagentMessage(e,t,s){let n=this.subagents[e];if(!n||!n[t])return;let r=n[t];if(s?.type==="tool"){r.toolCallCount=Number(r.toolCallCount||0)+1;return}s?.type==="text"&&r.messages.push(s)},completeSubagent(e,t){let s=this.subagents[e];!s||!s[t]||(s[t].status="completed")},sendWsMessage(e){return Ed(this,e)},parseWsMessage(e){return $d(this,e)},connect(){Ld(this)},ensureConnected(){return Rr(this)},scheduleReconnect(){Od(this)},manualReconnect(){Vd(this)},startHeartbeat(){qd(this)},stopHeartbeat(){Fd(this)},setupVisibilityHandler(){Hd(this)},handleMessage(e){Hu(this,e)},getOrCreateExecutionStatus(e){return el(this,e)},handleAssistantOutputFrame(e,t,s=null){Tu(this,e,t,s)},handleClaudeOutput(e,t){this.handleAssistantOutputFrame(e,t,null)},addMessageToConversation(e,t){return Ki(this,e,t)},pruneConversationMessageRetention(e,t=null,s=null,n=void 0){return Ud(this,{conversationId:e,sessionId:t,agentId:s,limits:n})},appendToAssistantMessageForConversation(e,t,s){su(this,e,t,s)},finishStreamingForConversation(e,t){nu(this,e,t)},sweepStaleStreamingForConversation(e){ru(this,e)},appendToAssistantMessage(e){this.appendToAssistantMessageForConversation(this.currentConversation,e)},finishStreaming(){this.finishStreamingForConversation(this.currentConversation)},addMessage(e){this.addMessageToConversation(this.currentConversation,e)},loadHistoryMessages(e){iu(this,e)},formatDbMessage(e){return ou(e)},selectAgent(e){return Yu(this,e)},createConversation(e,t=null,s=null,n=void 0){Gu(this,e,t,s,n)},resumeConversation(e,t,s=null,n=null,r=null){Qu(this,e,t,s,n,r)},selectConversation(e,t,s={}){Xu(this,e,t,s)},updateConversationSettings(e,t){al(this,e,t)},toggleConversationMcp(e,t){Zu(this,e,t)},deleteConversation(e,t){ep(this,e,t)},closeSession(e,t){Ju(this,e,t)},appendColumn(e){rp(this,e)},removeColumn(e){ip(this,e)},sendMessageToConversation(e,t,s=[],n={}){op(this,e,t,s,n)},cancelExecutionForConversation(e){ap(this,e)},addPanel(){if(this.panels.length>=3)return;let e=(t,s)=>({id:t,conversationId:s,activeRightPanel:null});if(this.panels.length===0){let t=localStorage.getItem("splitPanesSaved");if(t){try{let s=JSON.parse(t);if(Array.isArray(s)&&s.length>=2){let n=new Set(this.conversations.map(i=>i.id)),r=s.filter(i=>i&&typeof i.id=="string").map(i=>({...e(i.id,null),conversationId:i.conversationId&&n.has(i.conversationId)?i.conversationId:null}));if(r.length>=2){this.panels=r,this.activePanelId=r[0].id;for(let i of r)i.conversationId&&!this.activeConversations.includes(i.conversationId)&&this.activeConversations.push(i.conversationId),i.conversationId&&!this.messagesMap[i.conversationId]&&(this.messagesMap[i.conversationId]=[],this.requestChatHistory(i.conversationId,{mode:"recent",turns:5}));localStorage.removeItem("splitPanesSaved"),this.saveOpenSessions();return}}}catch{}localStorage.removeItem("splitPanesSaved")}this.panels=[e("panel-0",this.currentConversation),e("panel-1",null)],this.activePanelId="panel-0"}else{let t="panel-"+Date.now();this.panels.push(e(t,null))}this.saveOpenSessions()},removePanel(e){let t=this.panels.findIndex(s=>s.id===e);if(!(t<0)){if(this.panels.splice(t,1),this.panels.length<=1){let s=this.panels[0];s?.conversationId&&(this.activeConversations=[s.conversationId]),this.panels=[],this.activePanelId=null}else this.activePanelId===e&&(this.activePanelId=this.panels[0]?.id||null);this.saveOpenSessions()}},setPanelConversation(e,t,{refresh:s=!1}={}){let n=this.panels.find(i=>i.id===e);if(!n)return;let r=n.conversationId===t;n.conversationId=t,t&&!this.activeConversations.includes(t)&&this.activeConversations.push(t),t&&!this.messagesMap[t]?(this.messagesMap[t]=[],this.syncChatConversationHistory(t)):t&&(s||!r)&&this.syncChatConversationHistory(t),this.saveOpenSessions()},setActivePanel(e){this.activePanelId=e},splitToPanel(e){if(!e)return;let t=(s,n)=>({id:s,conversationId:n,activeRightPanel:null});if(this.panels.length===0)this.panels=[t("panel-0",this.currentConversation),t("panel-"+Date.now(),e)],this.activePanelId=this.panels[1].id;else if(this.panels.length>=3)this.panels[this.panels.length-1].conversationId=e,this.activePanelId=this.panels[this.panels.length-1].id;else{let s="panel-"+Date.now();this.panels.push(t(s,e)),this.activePanelId=s}this.activeConversations.includes(e)||this.activeConversations.push(e),this.messagesMap[e]||(this.messagesMap[e]=[],this.requestChatHistory(e,{mode:"recent",turns:5})),this.saveOpenSessions()},isInAnyPanel(e){return this.panels.some(t=>t.conversationId===e)},setSessionPinned(e,t,s={}){if(!e)return;let n=s&&s.agentId?s.agentId:null,r=n?!!ts()?.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=Me(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?ts()?.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||Me(this,e);if(Object.values(this.activeVpTurns||{}).some(a=>Mt(a,e,n))||!s&&Object.values(this.vpStatuses||{}).some(l=>Mt(l,e,n)&&Zr.has(l?.state)))return;let i=ys(n,e),o={...this.yeaftProcessingSessions||{}};i&&delete o[i],co(this,e,n)&&delete o[e],this.yeaftProcessingSessions=o},sendMessage(e,t=[],s={}){tp(this,e,t,s)},cancelExecution(){sp(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],Bp(this,this.currentAgent)},cancelYeaftSession(e){let t=Me(this,e);!t||!e||(this.sendWsMessage({type:"yeaft_abort_all",agentId:t,sessionId:e}),this.activeVpTurns=Object.fromEntries(Object.entries(this.activeVpTurns||{}).filter(([,s])=>!Mt(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])=>!Mt(s,e,t))),this.clearYeaftSessionProcessingIfIdle(e,{agentId:t,ignoreStatuses:!0}))},cancelVpTurn(e,{sessionId:t=null,vpId:s=null}={}){let n=Me(this,t);if(!n||!e)return;let r=bn(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=Me(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||!Mt(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?.[ao(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){np(this,e,t,s)},refreshAgents(){lp(this)},refreshConversation(){cp(this)},setDreamEnabled(e,t){if(!e||this.agentDreamState?.[e]?.pending)return!1;let s=this.agents.find(o=>o.id===e),n=t!==!1,r=`dream-${Date.now()}-${Math.random().toString(36).slice(2)}`,i=setTimeout(()=>{let o=this.agentDreamState?.[e];!o?.pending||o.requestId!==r||(this.agentDreamState={...this.agentDreamState,[e]:{...o,pending:!1,timer:null,error:"timeout"}})},15e3);return this.agentDreamState={...this.agentDreamState,[e]:{pending:!0,requestId:r,requested:n,authoritative:s?.dreamEnabled===!0,timer:i,error:null}},dp(this,e,n,r),!0},loadMoreMessages(){if(this.currentView==="yeaft"||this.loadingMoreMessages||!this.hasMoreMessages||!this.currentConversation)return;this.loadingMoreMessages=!0;let e=this._loadMoreGeneration=(this._loadMoreGeneration||0)+1,s=(this.messagesMap[this.currentConversation]||[]).find(i=>i.dbMessageId),n=this.currentConversation,r=s?.dbMessageId??null;this.requestChatHistory(n,{mode:"older",turns:5,beforeId:r}),setTimeout(()=>{this._loadMoreGeneration===e&&this.loadingMoreMessages&&this.currentConversation===n&&(this.loadingMoreMessages=!1)},1e4)},reloadYeaftMessages(){if(this.currentView!=="yeaft")return!1;let e=Is(this),t=Me(this,e);if(!t)return!1;let s=Pe(t,e),n=this.yeaftConversationId,r=this.yeaftSessionHistoryState?.[s];if(r?.loading)return r.requestId?(this._yeaftManualHistoryRefresh={agentId:t,sessionId:e,requestId:r.requestId},r.requestId):!1;let i=this.beginYeaftHistoryLoad({agentId:t,sessionId:e,mode:"recent",preserveLoaded:!1});if(!i)return!1;this._yeaftManualHistoryRefresh={agentId:t,sessionId:e,requestId:i.requestId};let o=un();this.yeaftHistoryPerfTraceBySession={...this.yeaftHistoryPerfTraceBySession||{},[s]:o};let a={type:"yeaft_load_history",agentId:t,limit:kl,sessionId:e,requestId:i.requestId,perfTraceId:o};return vt(this,{traceId:o,phase:"history.request_send",agentId:t,sessionId:e,messageType:a.type,bytes:JSON.stringify(a).length,detail:{mode:"manual-reload",limit:kl}}),this.sendWsMessage(a)?!0:(Er(this,{agentId:t,sessionId:e,requestId:i.requestId,error:"history_load_send_failed"}),!1)},loadMoreYeaftHistory(e=Qr(),{sessionId:t=null,agentId:s=null,background:n=!1}={}){if(this.currentView!=="yeaft")return!1;let r=t||Is(this),i=Me(this,r,s);if(!i||!r)return!1;let o=Pe(i,r),a=this.yeaftSessionHistoryState?.[o]||{};if(a.loading||!a.hasMore)return!1;let l=Math.min(50,Math.max(1,Number.isFinite(e)?Math.floor(e):Qr())),c=this.yeaftHistoryCacheState?.[o]?.ranges||[],d=Number(this.yeaftHistoryCacheState?.[o]?.rangeEpoch)||0,u=du(a,c,d);if(this.yeaftSessionHistoryState={...this.yeaftSessionHistoryState||{},[o]:u.state},!u.request)return this.syncActiveYeaftHistoryLoad(),!1;let p=this.beginYeaftHistoryLoad({agentId:i,sessionId:r,mode:n?"prefetch":"older",preserveLoaded:!0,latestSeq:this.yeaftSessionHistoryState[o]?.latestSeq??null});if(!p)return!1;let f=un();this.yeaftHistoryPerfTraceBySession={...this.yeaftHistoryPerfTraceBySession||{},[o]:f};let g={type:"yeaft_load_more_history",agentId:i,sessionId:r,requestId:p.requestId,beforeSeq:u.request.beforeSeq,pageKind:u.request.kind,gapStopAtSeq:u.request.stopAtSeq,cacheEpoch:u.request.cacheEpoch,turns:l,perfTraceId:f};return vt(this,{traceId:f,phase:"history_more.request_send",agentId:i,sessionId:r,messageType:g.type,bytes:JSON.stringify(g).length,detail:{beforeSeq:g.beforeSeq,turns:g.turns,pageKind:u.request.kind,gapStopAtSeq:u.request.stopAtSeq,background:n}}),this.sendWsMessage(g)?!0:(Er(this,{agentId:i,sessionId:r,requestId:p.requestId,error:"history_load_send_failed"}),!1)},checkPendingRecovery(){hd(this)},performRecovery(){md(this)},dismissRecovery(){vd(this)},autoRestoreConversation(e){yd(this,e)},saveOpenSessions(){on(this)},getLastSession(){return wd(this)},clearLastSession(){kd(this)},listHistorySessions(e){Sd(this,e)},listFolders(){return Id(this)},listFoldersForAgent(e,t){return Cd(this,e,t)},listModelsForAgent(e,t){return Ad(this,e,t)},listHistorySessionsForAgent(e,t,s){xd(this,e,t,s)},async loadGlobalSessions(e=20){return Td(this,e)},async deleteGlobalSession(e){return Md(this,e)},findAgentForSession(e){return _a(this,e)},isSessionResumable(e){return Pd(this,e)},_isRecentlyClosed(e){return dn(this,e)},_startProcessingWatchdog(e){Hn(this,e)},_resetProcessingWatchdog(e){zi(this,e)},_stopProcessingWatchdog(e){qe(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,Ar(e),this.currentAgent)try{this.sendWsMessage({type:"update_llm_config",agentId:this.currentAgent,config:{language:e}})}catch{}},async fetchCustomExpertRoles(){let e=je();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=je();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=je();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=je();try{let s={};t.token&&(s.Authorization=`Bearer ${t.token}`);let n=await fetch(`/api/expert-roles/custom/${e}`,{method:"DELETE",headers:s});if(n.ok)return this.customExpertRoles=this.customExpertRoles.filter(r=>r.id!==e),!0;{let r=await n.json().catch(()=>({}));throw new Error(r.error||"Failed to delete custom expert role")}}catch(s){throw s}},rememberWorkbenchPanelState(e=this.activeSessionRoute,t){let s=typeof e=="string"?e:dt(e);if(!s)return!1;let n=this.workbenchPanelStateByRoute[s]||{},r=Number.isFinite(t)&&t>0?Math.round(t):n.width;return this.workbenchPanelStateByRoute={...this.workbenchPanelStateByRoute,[s]:{expanded:!!this.workbenchExpanded,maximized:!!this.workbenchExpanded&&!!this.workbenchMaximized,...Number.isFinite(r)&&r>0?{width:r}:{}}},!0},workbenchPanelWidthForRoute(e=this.activeSessionRoute){let t=typeof e=="string"?e:dt(e),s=t?this.workbenchPanelStateByRoute[t]?.width:null;return Number.isFinite(s)&&s>0?s:null},restoreWorkbenchPanelState(e=this.activeSessionRoute){let t=dt(e),s=t?this.workbenchPanelStateByRoute[t]:null;return this.workbenchExpanded=!!s?.expanded,this.workbenchMaximized=!!s?.expanded&&!!s?.maximized,!!s},openWorkbench(){this.workbenchExpanded=!0,this.activeRightPanel=null,this.closeYeaftDebugPanel(),this.rememberWorkbenchPanelState()},toggleWorkbench(){if(this.workbenchExpanded){this.workbenchExpanded=!1,this.workbenchMaximized=!1,this.rememberWorkbenchPanelState();return}this.openWorkbench()},toggleSidebar(){this.sidebarCollapsed=!this.sidebarCollapsed},toggleSessionSidebar(){this.sessionSidebarOpen=!this.sessionSidebarOpen},closeSessionSidebar(){this.sessionSidebarOpen=!1},toggleWorkbenchMaximized(){this.workbenchMaximized=!this.workbenchMaximized,this.rememberWorkbenchPanelState()},renameChatSession(e,t,s=null){let n=t&&t.trim()?t.trim():"";n?this.customConversationTitles[e]=n:delete this.customConversationTitles[e],this.sendWsMessage({type:"update_conversation_settings",conversationId:e,...s?{agentId:s}:{},title:n})},resolveMessageFileReferences(e){let t=this.activeSessionRoute,s=t?.agentId||this.currentAgent||null,n=t?.runtimeProvider==="yeaft"?yt(this,t.sessionId,s):this.currentConversation,i=dt(t)&&s&&n&&this.workbenchRouteProtocolSupported===!0&&(s===this.currentAgent?this.hasCapability("file_reference_resolution")&&this.hasCapability("workbench_session_routes"):Tt(this,s,"file_reference_resolution")&&Tt(this,s,"workbench_session_routes")),o=[...new Set((Array.isArray(e)?e:[]).filter(u=>typeof u=="string"&&u.trim()).map(u=>u.trim()))].slice(0,32);if(!i||o.length===0)return null;let a=this.effectiveWorkDir||"",l=t?{runtimeProvider:t.runtimeProvider,agentId:t.agentId,sessionId:t.sessionId}:null,c=`file_refs_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`;return this.sendWsMessage({type:"resolve_file_references",requestId:c,references:o,agentId:s,conversationId:n,workDir:a,workbenchRoute:l})?c:null},requestMessageImagePreview(e){let t=this.activeSessionRoute,s=t?.agentId||this.currentAgent||null,n=t?.runtimeProvider==="yeaft"?yt(this,t.sessionId,s):this.currentConversation,i=dt(t)&&s&&n&&this.workbenchRouteProtocolSupported===!0&&(s===this.currentAgent?this.hasCapability("file_editor")&&this.hasCapability("workbench_session_routes")&&this.hasCapability("response_image_preview"):Tt(this,s,"file_editor")&&Tt(this,s,"workbench_session_routes")&&Tt(this,s,"response_image_preview")),o=typeof e=="string"?e.trim():"";if(!i||!o)return null;let a=`message_image_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`;return this.sendWsMessage({type:"read_file",requestId:a,filePath:o,responseImagePreview:!0,agentId:s,conversationId:n,workDir:this.effectiveWorkDir||"",workbenchRoute:{runtimeProvider:t.runtimeProvider,agentId:t.agentId,sessionId:t.sessionId}})?a:null},openFileInExplorer(e,{hideTree:t=!1,line:s=null}={}){let n=this.activeSessionRoute,r=n?{runtimeProvider:n.runtimeProvider,agentId:n.agentId,sessionId:n.sessionId}:null,i=dt(r),o=this.effectiveWorkDir||"",a=yn(i,o),l=r?.agentId||this.currentAgent||null,c=r?.runtimeProvider==="yeaft"?yt(this,r.sessionId,l):this.currentConversation,d=this.workbenchRouteProtocolSupported===!0&&(l===this.currentAgent?this.hasCapability("file_editor")&&this.hasCapability("workbench_session_routes"):Tt(this,l,"file_editor")&&Tt(this,l,"workbench_session_routes"));if(!l||!c||!d)return!1;let u=typeof e=="string"?e.trim():"";if(!u)return!1;let p=this.workbenchExpanded;this.openWorkbench(),this.workbenchMaximized=!1,this.rememberWorkbenchPanelState();let f=()=>{let g=dt(this.activeSessionRoute),v=this.effectiveWorkDir||"";g!==i||v!==o||yn(g,v)!==a||window.dispatchEvent(new CustomEvent("open-file-in-explorer",{detail:{filePath:u,agentId:l,conversationId:c,workDir:o,workbenchRoute:r,workbenchRouteKey:i,workspaceGeneration:a,hideTree:!!t,line:Number.isFinite(s)&&s>0?s:null}}))};return p?f():Vue.nextTick(f),!0},logout(){je().logout(),this.authenticated=!1,this.sessionKey=null,this.agents=[],this.currentAgent=null,this.currentAgentInfo=null,this.yeaftStatusByAgent={},this._yeaftRetiredCatalogEpochsByAgent={},this.conversations=[],this.activeConversations=[],this.messagesMap={},this.conversationTitles={},this.customConversationTitles={},this.processingConversations={},this.executionStatusMap={},this.workbenchExpanded=!1,this.workbenchMaximized=!1,this.workbenchPanelStateByRoute={},this.subagents={},this.activeSubagentId=null,this.activeRightPanel=null,this.pinnedSessions=[],this.clearWorkCenterBrowserState(),this.ws&&this.ws.close()}}})});function Ml(e,t){!e||typeof e.handleYeaftOutput!="function"||!t||e.handleYeaftOutput({event:t})}function Bb(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 Rl(e){if(!e)return js[0];let t=String(e).toLowerCase();return Hb[t]||js[Bb(t)%js.length]}function Nb(e){return Rl(e).background}function Wb(e){return Rl(e).foreground}function Pl(){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 jb(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 Fb,js,Hb,OC,ss,Zn=W(()=>{({defineStore:Fb}=Pinia);js=[{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)"}],Hb=Object.freeze({steve:js[8],ada:js[3],linus:js[0],martin:js[4]}),OC=js.map(e=>e.background);ss=Fb("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?Pl().startsWith("zh")&&s.displayNameZh?s.displayNameZh:s.displayName||s.vpId||t:t},vpDescription:e=>t=>jb(e.vps[t],Pl()),vpInitial:e=>t=>{let s=e.vps[t],n=Pl().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:Nb(t)},vpTextColor:()=>e=>Wb(e),vpAvatarMotif:()=>e=>Rl(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(Ml(s,{type:"dream_progress",phase:"start",groupId:e,manual:!0,trigger:"manual",source:"header-button",ts:n}),!s||typeof s.sendWsMessage!="function"){Ml(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&&Ml(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 _l(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 po(e){return!e||typeof e!="object"?0:_l(e.lastMessageAt)||_l(e.updatedAt)||_l(e.createdAt)||0}function Dl(e,t){let s=po(t)-po(e);return s!==0?s:String(e?.id||"").localeCompare(String(t?.id||""))}function nf(e){return[...Array.isArray(e)?e:[]].sort(Dl)}var fo=W(()=>{});function rf(){try{if(typeof localStorage>"u")return{};let e=JSON.parse(localStorage.getItem(cf)||"{}");return e&&typeof e=="object"?e:{}}catch{return{}}}function Ub(e){try{typeof localStorage<"u"&&localStorage.setItem(cf,JSON.stringify(e&&typeof e=="object"?e:{}))}catch{}}function of(){try{return typeof localStorage>"u"?[]:Jr(JSON.parse(localStorage.getItem(df)||"[]"))}catch{return[]}}function Kb(e){try{typeof localStorage<"u"&&localStorage.setItem(df,JSON.stringify(Jr(e)))}catch{}}function uf(e,t){return`${e||""}${t||""}`}function Cs(e){return e&&e.agentId&&e.id?uf(e.agentId,e.id):""}function ns(e,t){return t?e?uf(e,t):String(t):""}function zb(e){return typeof e=="string"?e:String(e||"")}function Vt(e,t,s=null){let n=zb(t);if(!n)return"";let r=ns(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=ei();if(l?.currentAgent){let c=a.find(d=>e.sessions[d]?.agentId===l.currentAgent);if(c)return c}return a[0]||""}function El(e,t,s=null){return Vt(e,t,s)||""}function $l(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 Yb(e){let t=e._preferredExactSessionIdentity||null;if(!t)return!1;e._preferredExactSessionIdentity=null;let s=e.sessions[t.key]||null,n=ei(),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=Ur(localStorage.getItem("lastViewedYeaftSession")||"");o.agentId===t.agentId&&o.sessionId===t.sessionId&&localStorage.removeItem("lastViewedYeaftSession")}catch{}return!0}function go(e){let t=e._retiredBareActiveSessionId||null;if(!t)return!1;let s=ei();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")||"";Ur(r).sessionId===t&&localStorage.removeItem("lastViewedYeaftSession")}catch{}return!0}function Jr(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 Ll(e,t){let s=Jr(e),n=new Set(s),r=Jr(t).filter(o=>n.has(o)),i=new Set(r);return[...r,...s.filter(o=>!i.has(o))]}function ho(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 af(e){return!e||typeof e!="object"?!1:e.running===!0||e.active===!0||e.isActive===!0||e.isRunning===!0}function lf(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 ei(){try{if(typeof window<"u"&&window.Pinia&&typeof window.Pinia.useChatStore=="function")return window.Pinia.useChatStore()}catch{}return null}var cf,df,Gb,pf,ff=W(()=>{fo();to();cf="yeaft-session-order-by-agent",df="yeaft-session-order-global";({defineStore:Gb}=Pinia);pf=Gb("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=ei(),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,p)=>{let f=Number.isFinite(u?.sortOrder)?u.sortOrder:Number.MAX_SAFE_INTEGER,g=Number.isFinite(p?.sortOrder)?p.sortOrder:Number.MAX_SAFE_INTEGER;return f!==g?f-g:Dl(u,p)}),a=[...o(r),...o(i)],l=of();if(l.length===0)return a;let c=new Map(l.map((d,u)=>[d,u]));return a.sort((d,u)=>{let p=c.has(Cs(d))?c.get(Cs(d)):Number.MAX_SAFE_INTEGER,f=c.has(Cs(u))?c.get(Cs(u)):Number.MAX_SAFE_INTEGER;return p!==f?p-f:0})},sessionCount(e){return e.sessionOrder.length},sessionById:e=>(t,s=null)=>{let n=Vt(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){$l(this);let o={...this.sessions},a=new Set;for(let f of n){if(!f||!f.id)continue;let g=ns(t,f.id);a.add(g),o[g]=this._normalize(f,t,ho(this.sessions[g]))}for(let f of this.sessionOrder){let g=this.sessions[f];g&&g.agentId===t&&!a.has(f)&&delete o[f]}let l=this.sessionOrder.filter(f=>o[f]),c=new Set(l),d=[];for(let f of n){if(!f||!f.id)continue;let g=ns(t,f.id);o[g]&&!c.has(g)&&d.push(g)}this.sessions=o;let u=[...l,...d],p=of();if(p.length>0){let f=new Map(u.map(y=>[Cs(o[y]),y]).filter(([y])=>y)),g=p.map(y=>f.get(y)).filter(Boolean),v=new Set(g);u=[...g,...u.filter(y=>!v.has(y))];let m=new Map(p.map((y,h)=>[y,h]));for(let y of u){let h=Cs(o[y]);h&&m.has(h)&&(o[y]={...o[y],sortOrder:m.get(h)})}}if(t&&p.length===0){let f=rf(),g=Jr(f[t]);if(g.length>0){let v=g.map(b=>ns(t,b)),m=new Set(v),y=Ll(u.filter(b=>o[b]?.agentId===t),v),h=this.sessionOrder.some(b=>o[b]?.agentId===t),w=0;h?u=this.sessionOrder.filter(b=>o[b]).map(b=>o[b]?.agentId===t?y[w++]:b).concat(y.slice(w)):u=u.map(b=>o[b]?.agentId===t?y[w++]:b);let S=new Map(v.map((b,k)=>[b,k]));for(let b of y)o[b]&&m.has(b)&&(o[b]={...o[b],sortOrder:S.get(b)})}}this.sessionOrder=u}else{if(this.inventoryIdentityMode==="agent-scoped")return;if(Object.values(this.sessions).some(c=>c&&c.agentId)){this.inventoryIdentityMode="agent-scoped";return}let a={},l=[];for(let c of n){if(!c||!c.id)continue;let d=ns(null,c.id);a[d]=this._normalize(c,null,ho(this.sessions[d])),l.push(d)}this.sessions=a,this.sessionOrder=l,this.inventoryIdentityMode="legacy-bare"}s||(r=Yb(this)||go(this)),this.lastSnapshotAt=Date.now();let i=ei();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?Vt(this,o,t):"",c=l?this.sessions[l]:null,d=c&&(!t||c.agentId===t),u=this.sessionOrder.filter(w=>this.sessions[w]&&(!t||this.sessions[w].agentId===t)&&this.sessions[w].running).sort((w,S)=>lf(this.sessions[S])-lf(this.sessions[w]))[0]||null,p=u?this.sessions[u]?.id:null,f=this.sessionList[0]||null,g=f?.id||null,v=g?Vt(this,g,f?.raw?.agentId||null):"",m=p||(d?c.id:null)||g,y=u||(d?l:"")||v||El(this,m,t),h=this.activeSessionKey?this.sessions[this.activeSessionKey]?.agentId:null;if(this.activeSessionId&&!Vt(this,this.activeSessionId,h)?(this.activeSessionId=m,this.activeSessionKey=y||null):!this.activeSessionId&&this.sessionOrder.length>0&&!this._retiredBareActiveSessionId?(this.activeSessionId=m,this.activeSessionKey=y||null):this.activeSessionId&&(this.activeSessionKey=El(this,this.activeSessionId,h)||this.activeSessionKey),i&&!this._retiredBareActiveSessionId){let w=this.activeSessionId||m,S=null;if((i.yeaftActiveSessionFilter&&!Vt(this,i.yeaftActiveSessionFilter)||!i.yeaftActiveSessionFilter&&w)&&(S=w),S){let b=El(this,S),k=b&&this.sessions[b]?.agentId||null;i.currentView==="yeaft"&&typeof i.setActiveSessionFilter=="function"?i.setActiveSessionFilter(S,{agentId:k,force:!0}):i.yeaftActiveSessionFilter=S,this.activeSessionKey=b||this.activeSessionKey}}}if(i&&typeof i.applyServerPinSnapshot=="function"){let o=new Set;for(let l of n){if(!l||!l.id)continue;let c=ns(t,l.id),d=this.sessions[c];d&&d.pinned&&o.add(l.id)}let a=l=>{let c=Vt(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)$l(this);else if(this.inventoryIdentityMode!=="legacy-bare")return;let r=Vt(this,s,n)||ns(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),go(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},go(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==="copy"||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)?Vt(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)$l(this);else if(this.inventoryIdentityMode!=="legacy-bare")return"";let n=Vt(this,e.id,s)||ns(s,e.id),r=!!this.sessions[n],i=this.sessions[n]||{};return this.sessions[n]={...i,...this._normalize(e,s,ho(i))},r||this.sessionOrder.push(n),go(this),n},setActive(e,t=null){let s=Vt(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=Ll(s,t.map(l=>ns(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=rf(),a=n.map(l=>this.sessions[l]?.id).filter(Boolean);return o[e]=a,Ub(o),a},reorderSessionsGlobally(e){let t=this.sessionOrder.map(a=>Cs(this.sessions[a])).filter(Boolean),s=Ll(t,e);if(s.length===0)return[];let n=new Map(this.sessionOrder.map(a=>[Cs(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=Cs(this.sessions[a]);l&&o.has(l)&&(this.sessions[a]={...this.sessions[a],sortOrder:o.get(l)})}return Kb(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=Vt(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=ns(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:af(e),active:af(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:ho(e,s),sortOrder:Number.isFinite(e.sortOrder)?e.sortOrder:null}}}})});function mo(){return globalThis.crypto?.randomUUID?.()||`browser-${Date.now()}-${Math.random().toString(16).slice(2)}`}function qt(e,t){return`${String(e||"")}\0${String(t||"")}`}function gf(e,t,s,n){return`${qt(e,t)}\0${String(s||"")}\0${String(n||"")}`}function Ol(e,t="Browser Runtime request failed"){return e?.safeError||e?.code||t}function Vl(e){return globalThis.Vue?.markRaw?.(e)||e}var Qb,Xb,Zb,Jb,ew,tw,sw,vo,ql=W(()=>{({defineStore:Qb}=Pinia),Xb=3e4,Zb=60*6e4,Jb=2e4,ew=5e3,tw=60*6e4,sw=256;vo=Qb("browser",{state:()=>({sessions:{},pending:{},peers:{},cancelledPeers:{},errors:{},errorCodes:{},peerDiagnostics:{},runtimeStatus:{},installProgress:{},protocolSupported:null,connectionEpoch:0,lastError:null,_cancelledPeerCleanupTimer:null,_messageListenerInstalled:!1}),actions:{chatStore(){return window.Pinia?.useChatStore?.()||null},installMessageListener(){if(this._messageListenerInstalled||typeof window>"u")return;this._messageListenerInstalled=!0;let e=this.chatStore();this.protocolSupported=e?.browserRuntimeProtocolSupported??null,window.addEventListener("browser-runtime-message",t=>this.handleMessage(t.detail)),window.addEventListener("browser-runtime-transport-reset",()=>this.handleTransportReset())},send(e){if(!this.chatStore()?.sendWsMessage?.(e))throw new Error("Browser Runtime transport unavailable")},beginRequest(e,t,s=Xb){let n=mo();return new Promise((r,i)=>{let o=setTimeout(()=>{delete this.pending[n],i(new Error(`${e} timed out`))},s);this.pending[n]={type:e,resolve:r,reject:i,timer:o,payload:t};try{this.send({type:e,requestId:n,...t})}catch(a){clearTimeout(o),delete this.pending[n],i(a)}})},completeRequest(e,t,s=null){let n=e?this.pending[e]:null;return n?(clearTimeout(n.timer),delete this.pending[e],s?n.reject(s):n.resolve(t),!0):!1},clearCancelledPeers(){clearTimeout(this._cancelledPeerCleanupTimer),this._cancelledPeerCleanupTimer=null,this.cancelledPeers={}},pruneCancelledPeers(e=Date.now()){clearTimeout(this._cancelledPeerCleanupTimer),this._cancelledPeerCleanupTimer=null;for(let[s,n]of Object.entries(this.cancelledPeers))Number(n.expiresAt)<=e&&delete this.cancelledPeers[s];let t=Math.min(...Object.values(this.cancelledPeers).map(s=>Number(s.expiresAt)).filter(Number.isFinite));Number.isFinite(t)&&(this._cancelledPeerCleanupTimer=setTimeout(()=>this.pruneCancelledPeers(),Math.max(1,t-Date.now())))},rememberCancelledPeer(e){let t=Date.now();for(this.pruneCancelledPeers(t);Object.keys(this.cancelledPeers).length>=sw;)delete this.cancelledPeers[Object.keys(this.cancelledPeers)[0]];this.cancelledPeers[gf(e.agentId,e.browserSessionId,e.requestId,e.connectionGeneration)]={agentId:e.agentId,browserSessionId:e.browserSessionId,requestId:e.requestId,connectionGeneration:e.connectionGeneration,expiresAt:t+tw},this.pruneCancelledPeers(t)},takeCancelledPeer(e){let t=gf(e.agentId,e.browserSessionId,e.requestId,e.connectionGeneration),s=this.cancelledPeers[t];return!s||(delete this.cancelledPeers[t],this.pruneCancelledPeers(),Number(s.expiresAt)<=Date.now())?null:s},async getRuntimeStatus(e){let t=await this.beginRequest("browser_runtime_status",{agentId:e});return this.runtimeStatus[e]=t,t},async installRuntime(e,t){let s=await this.beginRequest("browser_runtime_install",{agentId:e,confirmedBuildId:t?.buildId,confirmedDownloadBytes:Number(t?.downloadBytes)||0},Zb);return this.runtimeStatus[e]=s,delete this.installProgress[e],s},async enableRuntime(e){let t=await this.beginRequest("browser_runtime_enable",{agentId:e},6e4);return this.runtimeStatus[e]=t,t},async setupRuntime(e,t){return t?.installed?this.enableRuntime(e):this.installRuntime(e,t)},async createSession({agentId:e,sourceRef:t=null,initialUrl:s="about:blank",viewport:n=null,locale:r="en-US"}){let i=await this.beginRequest("browser_session_create",{agentId:e,sourceRef:t,options:{initialUrl:s,viewport:n||{width:1280,height:720,deviceScaleFactor:1},locale:r,capturePreference:"auto"}},45e3);return this.sessions[qt(e,i.browserSessionId)]=i,i},async listSessions(e){let t=await this.beginRequest("browser_session_list",{agentId:e}),s=new Set((t.sessions||[]).map(n=>qt(e,n.browserSessionId)));for(let n of Object.keys(this.sessions))n.startsWith(`${e}\0`)&&!s.has(n)&&delete this.sessions[n];for(let n of t.sessions||[])this.sessions[qt(e,n.browserSessionId)]={...n,agentId:e};return t.sessions||[]},async closeSession(e,t,s){await this.beginRequest("browser_session_close",{agentId:e,browserSessionId:t,expectedRevision:s})},async attach({agentId:e,browserSessionId:t,videoElement:s}){if(!s)throw new Error("Browser video element required");let n=qt(e,t);delete this.errors[n],delete this.errorCodes[n];let r=Number(this.connectionEpoch||0)+1;this.connectionEpoch=r;let i=mo(),o={localKey:n,agentId:e,browserSessionId:t,requestId:i,peerId:null,connectionGeneration:r,connection:null,videoElement:Vl(s),state:"preparing",remoteState:null,pendingOffer:null,pendingCandidates:[],answerPromise:null,channels:{},controlSeq:0,pointerSeq:0,iceServerCount:null,diagnostics:{connectionState:"new",iceConnectionState:"new",iceGatheringState:"new",candidateErrors:0,lastCandidateError:null},attachTimer:null,disconnectedTimer:null};return this.peers[n]=o,this.peerDiagnostics[n]=o.diagnostics,o.attachTimer=setTimeout(()=>{if(o.attachTimer=null,this.peers[n]!==o||o.connection?.connectionState==="connected")return;let a=o.iceServerCount===0?"browser_ice_servers_missing":o.diagnostics.iceConnectionState==="failed"?"browser_ice_connection_failed":"browser_peer_attach_timeout";this.failPeer(o,new Error(a),a)},Jb),this.send({type:"browser_peer_attach",agentId:e,browserSessionId:t,requestId:i,connectionGeneration:r,role:"interactive",clientCapabilities:{codecs:["video/VP8"],maxWidth:1920,maxHeight:1080,maxFps:30}}),o},async preparePeer(e,t){if(this.peers[e.localKey]!==e||e.connectionGeneration!==t.connectionGeneration)return;if(e.connection){if(e.peerId===t.peerId)return;throw new Error("Browser peer identity changed during preparation")}e.peerId=t.peerId;let s=Array.isArray(t.iceServers)?t.iceServers:[];e.iceServerCount=s.length;let n=Vl(new RTCPeerConnection({iceServers:s,iceTransportPolicy:t.iceTransportPolicy==="relay"?"relay":"all"}));e.connection=n,e.diagnostics.iceConnectionState=n.iceConnectionState||"new",e.diagnostics.iceGatheringState=n.iceGatheringState||"new",e.state="prepared",n.ondatachannel=i=>{if(this.peers[e.localKey]!==e)return;let o=i.channel;if(!["browser.control.v1","browser.pointer.v1","browser.state.v1"].includes(o?.label)){o?.close?.();return}e.channels[o.label]=Vl(o),o.onclose=()=>{e.channels[o.label]===o&&delete e.channels[o.label]}},n.ontrack=i=>{this.peers[e.localKey]===e&&(e.videoElement.srcObject=i.streams[0]||new MediaStream([i.track]),e.videoElement.play().catch(()=>{}))},n.onicecandidate=i=>{if(this.peers[e.localKey]===e)try{this.send({type:"browser_peer_ice_candidate",agentId:e.agentId,browserSessionId:e.browserSessionId,peerId:e.peerId,connectionGeneration:e.connectionGeneration,candidate:i.candidate?i.candidate.toJSON():null})}catch{}},n.onicecandidateerror=i=>{this.peers[e.localKey]===e&&(e.diagnostics.candidateErrors+=1,e.diagnostics.lastCandidateError={address:typeof i.address=="string"?i.address:null,port:Number(i.port)||null,url:typeof i.url=="string"?i.url:null,errorCode:Number(i.errorCode)||null,errorText:typeof i.errorText=="string"?i.errorText.slice(0,256):null})},n.oniceconnectionstatechange=()=>{this.peers[e.localKey]===e&&(e.diagnostics.iceConnectionState=n.iceConnectionState||"new")},n.onicegatheringstatechange=()=>{this.peers[e.localKey]===e&&(e.diagnostics.iceGatheringState=n.iceGatheringState||"new")},n.onconnectionstatechange=()=>{if(this.peers[e.localKey]===e){if(e.state=n.connectionState,e.diagnostics.connectionState=n.connectionState||"new",e.diagnostics.iceConnectionState=n.iceConnectionState||"new",e.diagnostics.iceGatheringState=n.iceGatheringState||"new",n.connectionState==="connected"){clearTimeout(e.attachTimer),e.attachTimer=null,clearTimeout(e.disconnectedTimer),e.disconnectedTimer=null;return}if(n.connectionState==="disconnected"){e.disconnectedTimer||(e.disconnectedTimer=setTimeout(()=>{if(e.disconnectedTimer=null,this.peers[e.localKey]!==e||n.connectionState==="connected")return;let i=e.iceServerCount===0?"browser_ice_servers_missing":"browser_ice_connection_failed";this.failPeer(e,new Error(i),i)},ew));return}if(["failed","closed"].includes(n.connectionState)){let i=e.iceServerCount===0?"browser_ice_servers_missing":"browser_ice_connection_failed";this.failPeer(e,new Error(i),i)}}};let r=e.pendingOffer;e.pendingOffer=null,r&&await this.acceptOffer(e,r)},async acceptOffer(e,t){if(!(this.peers[e.localKey]!==e||e.connectionGeneration!==Number(t.connectionGeneration))){if(!e.connection){(!e.peerId||e.peerId===t.peerId)&&(e.pendingOffer||(e.pendingOffer=t));return}if(e.peerId===t.peerId){if(e.answerPromise)return e.answerPromise;e.answerPromise=(async()=>{if(await e.connection.setRemoteDescription(t.description),await e.connection.setLocalDescription(await e.connection.createAnswer()),this.peers[e.localKey]===e){this.send({type:"browser_peer_answer",agentId:e.agentId,browserSessionId:e.browserSessionId,peerId:e.peerId,connectionGeneration:e.connectionGeneration,description:e.connection.localDescription});for(let s of e.pendingCandidates.splice(0))await e.connection.addIceCandidate(s)}})();try{await e.answerPromise}finally{e.answerPromise=null}}}},async acceptCandidate(e,t){if(!(this.peers[e.localKey]!==e||e.connectionGeneration!==Number(t.connectionGeneration)||!t.candidate)){if(!e.connection){(!e.peerId||e.peerId===t.peerId)&&e.pendingCandidates.push(t.candidate);return}e.peerId===t.peerId&&(e.connection.remoteDescription?await e.connection.addIceCandidate(t.candidate):e.pendingCandidates.push(t.candidate))}},interactiveReady(e,t){let s=this.peers[qt(e,t)];return s?.state==="connected"&&s.channels["browser.control.v1"]?.readyState==="open"&&s.channels["browser.pointer.v1"]?.readyState==="open"},sendControl(e,t,s){let n=this.peers[qt(e,t)],r=n?.channels["browser.control.v1"];return!n||n.state!=="connected"||r?.readyState!=="open"?!1:(r.send(JSON.stringify({version:1,connectionGeneration:n.connectionGeneration,controlSeq:++n.controlSeq,action:s})),!0)},sendPointer(e,t,s){let n=this.peers[qt(e,t)],r=n?.channels["browser.pointer.v1"];return!n||n.state!=="connected"||r?.readyState!=="open"?!1:(r.send(JSON.stringify({version:1,connectionGeneration:n.connectionGeneration,pointerSeq:++n.pointerSeq,action:s})),!0)},detach(e,t,{notify:s=!0}={}){let n=qt(e,t),r=this.peers[n];if(r){if(delete this.peers[n],clearTimeout(r.attachTimer),r.attachTimer=null,clearTimeout(r.disconnectedTimer),r.disconnectedTimer=null,s&&!r.peerId&&this.rememberCancelledPeer(r),s&&r.peerId)try{this.send({type:"browser_peer_detach",requestId:mo(),agentId:e,browserSessionId:t,peerId:r.peerId,connectionGeneration:r.connectionGeneration})}catch{}this.errorCodes[n]||delete this.peerDiagnostics[n];for(let i of Object.values(r.channels||{}))try{i?.close?.()}catch{}r.channels={};try{r.connection?.close()}catch{}r.videoElement&&(r.videoElement.srcObject=null)}},failPeer(e,t,s=null){this.peers[e.localKey]===e&&(this.lastError=t?.message||String(t),this.errors[e.localKey]=this.lastError,s?this.errorCodes[e.localKey]=s:delete this.errorCodes[e.localKey],this.detach(e.agentId,e.browserSessionId,{notify:!0}))},handleTransportReset(){this.protocolSupported=null,this.connectionEpoch+=1;for(let e of Object.values(this.pending))clearTimeout(e.timer),e.reject(new Error("Browser Runtime connection changed"));this.pending={};for(let e of Object.values(this.peers))this.detach(e.agentId,e.browserSessionId,{notify:!1});this.peers={},this.runtimeStatus={},this.installProgress={},this.errors={},this.errorCodes={},this.peerDiagnostics={},this.clearCancelledPeers()},handleMessage(e){if(!e?.type)return;if(e.type==="client_hello_ack"){this.protocolSupported=e.browserRuntimeProtocol===1;return}if(e.type==="auth_result"){this.protocolSupported=!1;return}if(e.type==="browser_runtime_error"){let n=new Error(Ol(e));n.code=e.code,this.completeRequest(e.requestId,null,n)||(this.lastError=n.message);return}if(e.type==="browser_runtime_install_progress"){this.installProgress[e.agentId]={downloadedBytes:Number(e.downloadedBytes)||0,totalBytes:Number(e.totalBytes)||0};return}if(e.type==="browser_runtime_status_result"){this.runtimeStatus[e.agentId]=e,this.completeRequest(e.requestId,e),e.state!=="installing"&&delete this.installProgress[e.agentId];return}if(e.type==="browser_session_error"){let n=new Error(Ol(e));n.code=e.code,this.completeRequest(e.requestId,null,n)||(this.lastError=n.message);return}if(e.type==="browser_session_created"){this.sessions[qt(e.agentId,e.browserSessionId)]=e,this.completeRequest(e.requestId,e);return}if(e.type==="browser_session_list_result"){this.completeRequest(e.requestId,e);return}if(e.type==="browser_session_snapshot"){let n=qt(e.agentId,e.browserSessionId);this.sessions[n]=e,this.completeRequest(e.requestId,e),["closed","failed"].includes(e.state)&&this.detach(e.agentId,e.browserSessionId,{notify:!1});return}let t=qt(e.agentId,e.browserSessionId),s=this.peers[t];if(!s||s.connectionGeneration!==Number(e.connectionGeneration)){if(e.type==="browser_peer_prepared"||e.type==="browser_peer_error"||e.type==="browser_peer_state"&&["failed","disconnected","closed"].includes(e.state)){let n=this.takeCancelledPeer(e);if(n&&e.type==="browser_peer_prepared")try{this.send({type:"browser_peer_detach",requestId:mo(),agentId:n.agentId,browserSessionId:n.browserSessionId,peerId:e.peerId,connectionGeneration:n.connectionGeneration})}catch{}}return}if(e.type==="browser_peer_error")this.failPeer(s,new Error(Ol(e,"Browser peer failed")),e.code||null);else if(e.type==="browser_peer_prepared")this.preparePeer(s,e).catch(n=>this.failPeer(s,n));else if(e.type==="browser_peer_offer")this.acceptOffer(s,e).catch(n=>this.failPeer(s,n));else if(e.type==="browser_peer_ice_candidate")this.acceptCandidate(s,e).catch(n=>this.failPeer(s,n));else if(e.type==="browser_peer_state"&&e.state&&(s.remoteState=e.state,["failed","disconnected","closed"].includes(e.state))){let n=s.iceServerCount===0?"browser_ice_servers_missing":"browser_ice_connection_failed";this.failPeer(s,new Error(n),n)}}}})});function yo(){try{if(window.Pinia&&typeof window.Pinia.useAuthStore=="function")return window.Pinia.useAuthStore()}catch{}return null}function Fl(){try{return localStorage.getItem("authToken")||null}catch{return null}}function vf(){let e=yo();if(e)try{return e.getActiveToken?.()||e.token||Fl()}catch{return e.token||Fl()}return Fl()}function rw(e,t){if(!e)return!1;let s=vf();if(s&&s!==t)return!1;try{localStorage.setItem("authToken",e)}catch{}let n=yo();return n&&(n.token=e),!0}function iw(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 mf(e){return!e||typeof window>"u"||!window.location?!1:e.origin===window.location.origin&&e.pathname.startsWith("/api/")}function ow(e){if(!e)return!1;let t=e.pathname;return!!(nw.has(t)||t.startsWith("/api/auth/sso/poll/")||/^\/api\/auth\/sso\/[^/]+\/start(?:-qr)?$/.test(t))}function aw(e,t){return t?.headers?new Headers(t.headers):e&&typeof e=="object"&&e.headers?new Headers(e.headers):new Headers}function lw(e){let t=e.get("Authorization");return!t||!t.startsWith("Bearer ")?null:t.slice(7)}function cw(e,t){return{...e||{},headers:t}}function dw(e,t,s,n){let r=yo();r&&typeof r.handleAuthResponse=="function"?r.handleAuthResponse(e,t,s,n):r&&typeof r.handleAuthFailure=="function"&&n&&r.handleAuthFailure(void 0,t,s)}function yf(){if(hf||typeof window>"u"||!window.fetch)return;hf=!0;let e=window.fetch.bind(window);window.fetch=async function(s,n){let r=iw(s),i=mf(r)&&!ow(r),o=mf(r)?{...n||{},credentials:"same-origin"}:n,a=null,l=i?yo():null,c=l?.authGeneration,d=!!l?.isAuthenticated;if(i){let p=aw(s,n);a=lw(p),a||(a=vf(),a&&(p.set("Authorization",`Bearer ${a}`),o=cw(o,p)))}let u=await e(s,o);try{let p=u.headers&&u.headers.get&&u.headers.get("X-New-Token");p&&rw(p,a),i&&u.status===401&&dw(u,a,c,d)}catch{}return u}}var hf,nw,bf=W(()=>{hf=!1,nw=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 wf,kf,Hl=W(()=>{wf={"quickSend.title":"Quick send","quickSend.description":"Add up to 5 send buttons for this Agent. Each sends your current message with its model and optional turn overrides.","quickSend.empty":"No quick sends configured. No extra send buttons are shown.","quickSend.offline":"This Agent is offline. Reconnect to load or save quick sends.","quickSend.entry":"Quick send {index}","quickSend.name":"Button name","quickSend.model":"Model","quickSend.chooseModel":"Choose a model","quickSend.noModels":"Configure models in the LLM category first.","quickSend.effort":"Reasoning effort","quickSend.maxOutputTokens":"Maximum output tokens","quickSend.default":"Default","quickSend.outputLimit":"Leave blank to use the model default: {max} tokens (also the maximum).","quickSend.add":"Add quick send","quickSend.remove":"Remove","quickSend.limit":"Maximum 5 quick sends.","quickSend.nameRequired":"Enter a button name (1\u201380 characters).","quickSend.modelRequired":"Choose an available model for each quick send.","quickSend.effortInvalid":"The selected effort is not available for this model.","quickSend.outputInvalid":"Output tokens must be a positive integer no greater than {max}.","quickSend.loadFailed":"Could not load quick sends. Refresh to retry.","quickSend.saveFailed":"Save was not confirmed. Refresh to check the saved configuration before retrying.","quickSend.saved":"Quick sends saved.","quickSend.savedRefreshWarning":"Quick sends saved, but runtime refresh failed: {error}"},kf={"quickSend.title":"\u5FEB\u6377\u53D1\u9001","quickSend.description":"\u4E3A\u6B64 Agent \u6DFB\u52A0\u6700\u591A 5 \u4E2A\u53D1\u9001\u6309\u94AE\u3002\u4F7F\u7528\u6307\u5B9A\u6A21\u578B\u548C\u53EF\u9009\u7684\u5355\u8F6E\u53C2\u6570\u53D1\u9001\u5F53\u524D\u6D88\u606F\u3002","quickSend.empty":"\u5C1A\u672A\u914D\u7F6E\u5FEB\u6377\u53D1\u9001\uFF0C\u4E0D\u4F1A\u663E\u793A\u989D\u5916\u7684\u53D1\u9001\u6309\u94AE\u3002","quickSend.offline":"\u6B64 Agent \u5DF2\u79BB\u7EBF\u3002\u91CD\u65B0\u8FDE\u63A5\u540E\u53EF\u52A0\u8F7D\u6216\u4FDD\u5B58\u5FEB\u6377\u53D1\u9001\u3002","quickSend.entry":"\u5FEB\u6377\u53D1\u9001 {index}","quickSend.name":"\u6309\u94AE\u540D\u79F0","quickSend.model":"\u6A21\u578B","quickSend.chooseModel":"\u9009\u62E9\u6A21\u578B","quickSend.noModels":"\u8BF7\u5148\u5728\u6A21\u578B\u914D\u7F6E\u5206\u7C7B\u4E2D\u6DFB\u52A0\u6A21\u578B\u3002","quickSend.effort":"\u63A8\u7406\u5F3A\u5EA6","quickSend.maxOutputTokens":"\u6700\u5927\u8F93\u51FA Token \u6570","quickSend.default":"\u9ED8\u8BA4","quickSend.outputLimit":"\u7559\u7A7A\u4F7F\u7528\u6A21\u578B\u9ED8\u8BA4\u503C\uFF1A{max} Token\uFF08\u4E5F\u662F\u53EF\u8BBE\u7F6E\u7684\u4E0A\u9650\uFF09\u3002","quickSend.add":"\u6DFB\u52A0\u5FEB\u6377\u53D1\u9001","quickSend.remove":"\u5220\u9664","quickSend.limit":"\u6700\u591A\u6DFB\u52A0 5 \u4E2A\u5FEB\u6377\u53D1\u9001\u3002","quickSend.nameRequired":"\u8BF7\u8F93\u5165\u6309\u94AE\u540D\u79F0\uFF081\u201380 \u4E2A\u5B57\u7B26\uFF09\u3002","quickSend.modelRequired":"\u8BF7\u4E3A\u6BCF\u4E2A\u5FEB\u6377\u53D1\u9001\u9009\u62E9\u53EF\u7528\u6A21\u578B\u3002","quickSend.effortInvalid":"\u6B64\u6A21\u578B\u4E0D\u652F\u6301\u6240\u9009\u63A8\u7406\u5F3A\u5EA6\u3002","quickSend.outputInvalid":"\u8F93\u51FA Token \u6570\u5FC5\u987B\u4E3A\u4E0D\u8D85\u8FC7 {max} \u7684\u6B63\u6574\u6570\u3002","quickSend.loadFailed":"\u65E0\u6CD5\u52A0\u8F7D\u5FEB\u6377\u53D1\u9001\uFF0C\u8BF7\u5237\u65B0\u91CD\u8BD5\u3002","quickSend.saveFailed":"\u5C1A\u672A\u786E\u8BA4\u4FDD\u5B58\u3002\u8BF7\u5148\u5237\u65B0\u68C0\u67E5\u5DF2\u4FDD\u5B58\u7684\u914D\u7F6E\uFF0C\u518D\u51B3\u5B9A\u662F\u5426\u91CD\u8BD5\u3002","quickSend.saved":"\u5FEB\u6377\u53D1\u9001\u5DF2\u4FDD\u5B58\u3002","quickSend.savedRefreshWarning":"\u5FEB\u6377\u53D1\u9001\u5DF2\u4FDD\u5B58\uFF0C\u4F46\u8FD0\u884C\u65F6\u5237\u65B0\u5931\u8D25\uFF1A{error}"}});var Sf,If,Bl=W(()=>{Sf={"userShortcuts.title":"Keyboard shortcuts","userShortcuts.scope":"These are your user preferences, stored only in this browser for this account. They do not sync across devices.","userShortcuts.showQuickSends":"Enable quick-send shortcuts","userShortcuts.quickSendHelp":"Preset names and request settings are configured in Agent settings. Quick-send shortcuts only work while the message composer is focused.","userShortcuts.help":"Shortcuts use simple Alt + key defaults. Click a binding to replace it, or clear it to disable the action. Escape cancels; Tab moves on. Global actions do not run in dialogs, inputs, editors or terminals.","userShortcuts.suggestion":"Suggestion: {binding}","userShortcuts.recording":"Press a shortcut\u2026","userShortcuts.unbound":"Not bound","userShortcuts.clear":"Clear","userShortcuts.clearAction":"Clear shortcut for {action}","userShortcuts.reset":"Reset shortcuts and hide buttons","userShortcuts.action.terminal":"Open terminal","userShortcuts.action.files":"Open files","userShortcuts.action.git":"Open Git","userShortcuts.action.newSession":"New session","userShortcuts.action.closeWorkbench":"Close workbench","userShortcuts.action.quickSend1":"Quick send 1","userShortcuts.action.quickSend2":"Quick send 2","userShortcuts.action.quickSend3":"Quick send 3","userShortcuts.action.quickSend4":"Quick send 4","userShortcuts.action.quickSend5":"Quick send 5","userShortcuts.error.invalid":"Use Ctrl, Meta or Alt with a letter or number; Shift is optional.","userShortcuts.error.reserved":"This combination conflicts with a browser or existing app shortcut.","userShortcuts.error.conflict":"This shortcut is already assigned to {action}. Clear it there first.","userShortcuts.error.storage":"Could not save preferences in this browser. Check browser storage permissions.","userShortcuts.error.unauthenticated":"Sign in before saving your shortcuts."},If={"userShortcuts.title":"\u952E\u76D8\u5FEB\u6377\u952E","userShortcuts.scope":"\u8FD9\u662F\u4F60\u7684\u7528\u6237\u504F\u597D\uFF0C\u6309\u5F53\u524D\u8D26\u53F7\u4EC5\u4FDD\u5B58\u5728\u6B64\u6D4F\u89C8\u5668\u4E2D\uFF0C\u4E0D\u8DE8\u8BBE\u5907\u540C\u6B65\u3002","userShortcuts.showQuickSends":"\u542F\u7528\u5FEB\u6377\u53D1\u9001\u5FEB\u6377\u952E","userShortcuts.quickSendHelp":"\u9884\u8BBE\u540D\u79F0\u4E0E\u8BF7\u6C42\u53C2\u6570\u5728 Agent \u8BBE\u7F6E\u4E2D\u914D\u7F6E\u3002\u5FEB\u6377\u53D1\u9001\u6309\u952E\u4EC5\u5728\u6D88\u606F\u8F93\u5165\u6846\u83B7\u5F97\u7126\u70B9\u65F6\u751F\u6548\u3002","userShortcuts.help":"\u9ED8\u8BA4\u4F7F\u7528\u7B80\u5355\u7684 Alt + \u5355\u952E\u3002\u70B9\u51FB\u7ED1\u5B9A\u6309\u94AE\u53EF\u66FF\u6362\uFF0C\u6E05\u9664\u540E\u53EF\u505C\u7528\u8BE5\u64CD\u4F5C\u3002Escape \u53D6\u6D88\uFF0CTab \u79FB\u81F3\u4E0B\u4E00\u9879\u3002\u5168\u5C40\u52A8\u4F5C\u4E0D\u62A2\u5360\u5F39\u7A97\u3001\u8F93\u5165\u6846\u3001\u7F16\u8F91\u5668\u6216\u7EC8\u7AEF\u7684\u6309\u952E\u3002","userShortcuts.suggestion":"\u63A8\u8350\uFF1A{binding}","userShortcuts.recording":"\u8BF7\u6309\u4E0B\u7EC4\u5408\u952E\u2026","userShortcuts.unbound":"\u672A\u7ED1\u5B9A","userShortcuts.clear":"\u6E05\u9664","userShortcuts.clearAction":"\u6E05\u9664\u201C{action}\u201D\u5FEB\u6377\u952E","userShortcuts.reset":"\u91CD\u7F6E\u5FEB\u6377\u952E\u5E76\u9690\u85CF\u6309\u94AE","userShortcuts.action.terminal":"\u6253\u5F00\u7EC8\u7AEF","userShortcuts.action.files":"\u6253\u5F00\u6587\u4EF6","userShortcuts.action.git":"\u6253\u5F00 Git","userShortcuts.action.newSession":"\u65B0\u5EFA\u4F1A\u8BDD","userShortcuts.action.closeWorkbench":"\u5173\u95ED\u5DE5\u4F5C\u53F0","userShortcuts.action.quickSend1":"\u5FEB\u6377\u53D1\u9001 1","userShortcuts.action.quickSend2":"\u5FEB\u6377\u53D1\u9001 2","userShortcuts.action.quickSend3":"\u5FEB\u6377\u53D1\u9001 3","userShortcuts.action.quickSend4":"\u5FEB\u6377\u53D1\u9001 4","userShortcuts.action.quickSend5":"\u5FEB\u6377\u53D1\u9001 5","userShortcuts.error.invalid":"\u8BF7\u4F7F\u7528 Ctrl\u3001Meta \u6216 Alt \u642D\u914D\u5B57\u6BCD\u6216\u6570\u5B57\uFF0C\u53EF\u52A0 Shift\u3002","userShortcuts.error.reserved":"\u8BE5\u7EC4\u5408\u4E0E\u6D4F\u89C8\u5668\u6216\u5E94\u7528\u5DF2\u6709\u5FEB\u6377\u952E\u51B2\u7A81\u3002","userShortcuts.error.conflict":"\u8BE5\u7EC4\u5408\u5DF2\u7ED1\u5B9A\u201C{action}\u201D\uFF0C\u8BF7\u5148\u6E05\u9664\u539F\u7ED1\u5B9A\u3002","userShortcuts.error.storage":"\u65E0\u6CD5\u5728\u6B64\u6D4F\u89C8\u5668\u4FDD\u5B58\u504F\u597D\uFF0C\u8BF7\u68C0\u67E5\u6D4F\u89C8\u5668\u5B58\u50A8\u6743\u9650\u3002","userShortcuts.error.unauthenticated":"\u8BF7\u5148\u767B\u5F55\u518D\u4FDD\u5B58\u5FEB\u6377\u952E\u3002"}});var Cf,Af=W(()=>{Hl();Bl();Cf={...kf,...If,"quickSend.composer.label":"\u5FEB\u6377\u53D1\u9001","quickSend.composer.send":"\u5FEB\u6377\u53D1\u9001 {number}\uFF1A{name}","common.loading":"\u52A0\u8F7D\u4E2D...","common.confirm":"\u786E\u5B9A","common.apply":"\u5E94\u7528","common.cancel":"\u53D6\u6D88","common.delete":"\u5220\u9664","common.copy":"\u590D\u5236","common.copied":"\u5DF2\u590D\u5236","common.close":"\u5173\u95ED","common.refresh":"\u5237\u65B0","common.open":"\u6253\u5F00","common.save":"\u4FDD\u5B58","common.saving":"\u4FDD\u5B58\u4E2D...","common.search":"\u641C\u7D22","common.back":"\u8FD4\u56DE","common.noSubdirectories":"\u65E0\u5B50\u76EE\u5F55","common.drives":"\u9A71\u52A8\u5668","common.rootDir":"\u6839\u76EE\u5F55","common.comma":"\uFF0C","common.select":"\u9009\u62E9","common.retry":"\u91CD\u8BD5","mermaid.export":"\u5BFC\u51FA","mermaid.exportMd":"\u5BFC\u51FA MD","mermaid.exportPng":"\u5BFC\u51FA PNG","mermaid.exportJpg":"\u5BFC\u51FA JPG","login.subtitle":"Yeaft Web Code Agent","login.username":"\u7528\u6237\u540D","login.password":"\u5BC6\u7801","login.login":"\u767B\u5F55","login.loggingIn":"\u767B\u5F55\u4E2D...","login.enterUsername":"\u8BF7\u8F93\u5165\u7528\u6237\u540D","login.enterPassword":"\u8BF7\u8F93\u5165\u5BC6\u7801","login.noAccount":"\u6CA1\u6709\u8D26\u53F7\uFF1F","login.registerWithCode":"\u6CE8\u518C\u65B0\u8D26\u53F7","login.or":"\u6216","login.usePassword":"\u4F7F\u7528\u8D26\u53F7\u5BC6\u7801\u767B\u5F55","login.useSso":"\u8FD4\u56DE\u5355\u70B9\u767B\u5F55","login.noProviders":"\u7BA1\u7406\u5458\u5C1A\u672A\u542F\u7528\u4EFB\u4F55\u7B2C\u4E09\u65B9\u767B\u5F55\u3002","login.microsoft":"\u4F7F\u7528 Microsoft \u8D26\u53F7\u767B\u5F55","login.github":"\u4F7F\u7528 GitHub \u8D26\u53F7\u767B\u5F55","login.google":"\u4F7F\u7528 Google \u8D26\u53F7\u767B\u5F55","login.wechat":"\u4F7F\u7528\u5FAE\u4FE1\u626B\u7801\u767B\u5F55","login.alipay":"\u4F7F\u7528\u652F\u4ED8\u5B9D\u8D26\u53F7\u767B\u5F55","login.wechat.mobileUnsupported":"\u5FAE\u4FE1\u767B\u5F55\u6682\u4EC5\u652F\u6301\u7535\u8111\u7AEF\uFF0C\u8BF7\u5728\u7535\u8111\u6D4F\u89C8\u5668\u4E2D\u626B\u7801\u767B\u5F55\u3002","login.alipay.mobileWaiting":"\u6B63\u5728\u7B49\u5F85\u4F60\u5728\u652F\u4ED8\u5B9D\u4E2D\u786E\u8BA4\u2026 \u5B8C\u6210\u540E\u8FD4\u56DE\u672C\u9875\u9762\u5C06\u81EA\u52A8\u767B\u5F55\u3002","login.alipay.relaunch":"\u91CD\u65B0\u6253\u5F00\u652F\u4ED8\u5B9D","login.qr.title":"\u626B\u7801\u767B\u5F55","login.qr.titleAlipay":"\u652F\u4ED8\u5B9D\u626B\u7801\u767B\u5F55","login.qr.titleWechat":"\u5FAE\u4FE1\u626B\u7801\u767B\u5F55","login.qr.hint":"\u8BF7\u4F7F\u7528\u624B\u673A\u626B\u63CF\u4E8C\u7EF4\u7801\u5B8C\u6210\u6388\u6743","login.error.enterUsername":"\u8BF7\u8F93\u5165\u7528\u6237\u540D","login.error.enterPassword":"\u8BF7\u8F93\u5165\u5BC6\u7801","login.error.enter6Digit":"\u8BF7\u8F93\u51656\u4F4D\u9A8C\u8BC1\u7801","login.error.enterInviteCode":"\u8BF7\u8F93\u5165\u9080\u8BF7\u7801","login.error.usernameMinLen":"\u7528\u6237\u540D\u81F3\u5C112\u4E2A\u5B57\u7B26","login.error.passwordMinLen":"\u5BC6\u7801\u81F3\u5C116\u4F4D","login.error.passwordMismatch":"\u4E24\u6B21\u5BC6\u7801\u4E0D\u4E00\u81F4","login.error.enterVerifyCode":"\u8BF7\u8F93\u5165\u9A8C\u8BC1\u7801","login.error.loginFailed":"\u767B\u5F55\u5931\u8D25","login.forgot.link":"\u5FD8\u8BB0\u5BC6\u7801\uFF1F","login.forgot.title":"\u91CD\u7F6E\u5BC6\u7801","login.forgot.emailHint":"\u8F93\u5165\u8D26\u6237\u7ED1\u5B9A\u7684\u90AE\u7BB1\uFF0C\u6211\u4EEC\u5C06\u53D1\u9001 6 \u4F4D\u91CD\u7F6E\u9A8C\u8BC1\u7801\u3002","login.forgot.sendCode":"\u53D1\u9001\u91CD\u7F6E\u9A8C\u8BC1\u7801","login.forgot.sending":"\u53D1\u9001\u4E2D...","login.forgot.codeSent":"\u5982\u679C\u90AE\u7BB1\u5DF2\u6CE8\u518C\uFF0C\u91CD\u7F6E\u9A8C\u8BC1\u7801\u5DF2\u53D1\u9001\u3002\u8BF7\u5728\u4E0B\u65B9\u8F93\u5165\u9A8C\u8BC1\u7801\u4E0E\u65B0\u5BC6\u7801\u3002","login.forgot.resetBtn":"\u91CD\u7F6E\u5BC6\u7801","login.forgot.resetting":"\u91CD\u7F6E\u4E2D...","login.forgot.success":"\u5BC6\u7801\u5DF2\u91CD\u7F6E\uFF0C\u53EF\u4EE5\u4F7F\u7528\u65B0\u5BC6\u7801\u767B\u5F55\u3002","login.forgot.emailInvalid":"\u8BF7\u8F93\u5165\u6709\u6548\u7684\u90AE\u7BB1","login.register.title":"\u65B0\u7528\u6237\u6CE8\u518C","login.register.inviteCode":"\u9080\u8BF7\u7801","login.register.username":"\u7528\u6237\u540D","login.register.password":"\u5BC6\u7801\uFF08\u81F3\u5C116\u4F4D\uFF09","login.register.confirmPassword":"\u786E\u8BA4\u5BC6\u7801","login.register.email":"\u90AE\u7BB1\uFF08\u53EF\u9009\uFF09","login.register.submit":"\u6CE8\u518C","login.register.submitting":"\u6CE8\u518C\u4E2D...","login.register.back":"\u8FD4\u56DE\u767B\u5F55","login.register.success":"\u6CE8\u518C\u6210\u529F\uFF0C\u8BF7\u767B\u5F55","login.register.enterCode":"\u8BF7\u8F93\u5165\u9080\u8BF7\u7801","login.register.usernameMin":"\u7528\u6237\u540D\u81F3\u5C112\u4E2A\u5B57\u7B26","login.register.passwordMin":"\u5BC6\u7801\u81F3\u5C116\u4F4D","login.register.passwordMismatch":"\u4E24\u6B21\u5BC6\u7801\u4E0D\u4E00\u81F4","login.totp.setupTitle":"\u8BBE\u7F6E\u53CC\u56E0\u7D20\u8BA4\u8BC1","login.totp.setupHint":"\u4F7F\u7528 Microsoft Authenticator \u6216 Google Authenticator \u626B\u63CF\u4E0B\u65B9\u4E8C\u7EF4\u7801","login.totp.manualKey":"\u6216\u624B\u52A8\u8F93\u5165\u5BC6\u94A5\uFF1A","login.totp.enterCode":"\u8F93\u51656\u4F4D\u9A8C\u8BC1\u7801","login.totp.complete":"\u5B8C\u6210\u8BBE\u7F6E","login.totp.verifying":"\u9A8C\u8BC1\u4E2D...","login.totp.verify":"\u9A8C\u8BC1","login.totp.prompt":"\u8BF7\u8F93\u5165 Authenticator \u5E94\u7528\u4E2D\u7684\u9A8C\u8BC1\u7801","login.totp.invalidCode":"\u8BF7\u8F93\u51656\u4F4D\u9A8C\u8BC1\u7801","login.email.codeSent":"\u9A8C\u8BC1\u7801\u5DF2\u53D1\u9001\u81F3 {email}","login.email.enterCode":"\u8F93\u5165\u9A8C\u8BC1\u7801","login.email.verify":"\u9A8C\u8BC1","login.email.verifying":"\u9A8C\u8BC1\u4E2D...","login.email.enterCodeError":"\u8BF7\u8F93\u5165\u9A8C\u8BC1\u7801","chat.agent.select":"\u9009\u62E9 Agent","chat.agent.manage":"\u7BA1\u7406 Agent","chat.agent.count":"{count} agents","chat.agent.none":"\u6682\u65E0 Agent","chat.agent.restarting":"\u91CD\u542F\u4E2D","agentSettings.open":"Agent \u8BBE\u7F6E","agentSettings.manage":"\u7BA1\u7406","agentSettings.eyebrow":"\u672C\u5730\u8FD0\u884C\u65F6","agentSettings.title":"Agent \u8BBE\u7F6E","agentSettings.description":"\u6309 Agent \u67E5\u770B\u548C\u914D\u7F6E\u672C\u5730\u8FD0\u884C\u65F6\uFF0C\u4E0D\u518D\u628A\u8FD0\u884C\u63A7\u5236\u6DF7\u5165\u8D26\u6237\u8BBE\u7F6E\u3002","agentSettings.agentList":"Agent","agentSettings.categories":"Agent \u8BBE\u7F6E\u5206\u7C7B","agentSettings.categories.operations":"\u64CD\u4F5C","agentSettings.categories.trace":"Trace","agentSettings.categories.llm":"LLM \u914D\u7F6E","agentSettings.selectedAgent":"\u5F53\u524D Agent","agentSettings.online":"\u5728\u7EBF","agentSettings.offline":"\u79BB\u7EBF","agentSettings.empty":"\u6682\u65E0\u53EF\u7528 Agent\u3002","agentSettings.runtime.title":"\u8FD0\u884C\u65F6","agentSettings.runtime.description":"\u8EAB\u4EFD\u3001\u5DE5\u4F5C\u76EE\u5F55\u548C\u672C\u5730\u540E\u53F0\u5904\u7406\u3002","agentSettings.runtime.version":"\u7248\u672C","agentSettings.runtime.updateAvailable":"\u53EF\u66F4\u65B0\u81F3 v{version}","agentSettings.runtime.updateUnknown":"\u65E0\u6CD5\u83B7\u53D6\u66F4\u65B0\u72B6\u6001","agentSettings.runtime.workDir":"\u5DE5\u4F5C\u76EE\u5F55","agentSettings.telemetry.title":"\u8BCA\u65AD","agentSettings.telemetry.saved":"\u8BCA\u65AD\u8BBE\u7F6E\u5DF2\u4FDD\u5B58\u3002","agentSettings.telemetry.loadFailed":"\u8BCA\u65AD\u8BBE\u7F6E\u52A0\u8F7D\u5931\u8D25\u3002","agentSettings.telemetry.saveFailed":"\u8BCA\u65AD\u8BBE\u7F6E\u4FDD\u5B58\u5931\u8D25\u3002","agentSettings.maintenance.title":"\u7EF4\u62A4","agentSettings.maintenance.description":"\u8FD9\u4E9B\u64CD\u4F5C\u4F1A\u4E2D\u65AD\u5F53\u524D Agent \u4E0A\u6B63\u5728\u8FD0\u884C\u7684\u5DE5\u4F5C\u3002","agentSettings.maintenance.upgradeFailed":"Agent \u5347\u7EA7\u5931\u8D25\u3002","chat.agent.dream":"Dream","chat.agent.dreamHint":"\u542F\u7528\u81EA\u52A8 Dream \u8BB0\u5FC6\u5904\u7406","chat.agent.restart":"\u91CD\u542F","chat.agent.restartConfirm":`\u786E\u5B9A\u8981\u91CD\u542F Agent "{name}" \u5417\uFF1F
|
|
10
|
+
${m}`:m),v.status!=="failed"&&v.status!=="closed"&&(v.status=c.status||"idle");break}case"error":c.error&&(v.error=c.error.message||String(c.error));break;default:break}v.updatedAt=Date.now(),this.yeaftSubAgentCards={...this.yeaftSubAgentCards,[d]:v};break}case"history_loaded":{let a={...r,agentId:e.agentId||null,requestId:r.requestId||e.requestId||null};if(a.requestId&&!this.isCurrentYeaftHistoryResponse(a))break;let l=e.agentId||null,c=r.sessionId??null,d=Pe(l,c),u=e.perfTraceId||this.yeaftHistoryPerfTraceBySession?.[d];u&&vt(this,{traceId:u,phase:"history.loaded_event",agentId:e.agentId||null,sessionId:r.sessionId||null,messageType:r.type,detail:{mode:r.mode||"recent",count:r.count||0,hasMore:!!r.hasMore}});let p=r.mode==="delta"?"delta":"recent",f=this.yeaftSessionHistoryState[d]||{},g=Number.isFinite(r.latestSeq)?r.latestSeq:Number.isFinite(f.latestSeq)?f.latestSeq:null,v=Number.isFinite(r.nextBeforeSeq)?r.nextBeforeSeq:Number.isFinite(r.oldestSeq)?r.oldestSeq:Number.isFinite(f.serverOldestFetchedSeq)?f.serverOldestFetchedSeq:Number.isFinite(f.oldestSeq)?f.oldestSeq:null,m=p==="delta"?{...f,loaded:!0,loading:!1,latestSeq:g,syncingAfterSeq:null,count:(f.count||0)+(r.count||0)}:{...f,loaded:!0,loading:!1,hasMore:!!r.hasMore,serverHasMore:!!r.hasMore,oldestSeq:v,serverOldestFetchedSeq:v,count:typeof r.count=="number"?r.count:0,latestSeq:g,syncingAfterSeq:null},y=a.requestId?this.finishYeaftHistoryLoad(a,m,"completion"):null;y||(this.yeaftSessionHistoryState={...this.yeaftSessionHistoryState,[d]:m});let h=Pe(l?this.currentAgent:null,this.yeaftActiveSessionFilter??null);if(d===h)p==="recent"&&(this.yeaftHasMoreHistory=m.hasMore,this.yeaftOldestLoadedSeq=m.serverOldestFetchedSeq),this.yeaftLoadingMoreHistory=!!y?.loading;else if(this.yeaftLoadingMoreHistory){let w=this.yeaftSessionHistoryState[h]||null;this.yeaftLoadingMoreHistory=!!w?.loading}}break;case"vp_snapshot":{let a=window.Pinia?.useVpStore?.()||window.__useVpStore&&window.__useVpStore();a&&a.applySnapshot(r,e.agentId||null,e.requestId||null);break}case"vp_snapshot_error":{let a=window.Pinia?.useVpStore?.()||window.__useVpStore&&window.__useVpStore();a&&a.failSnapshot(e.agentId||null,e.requestId||null,r.error||r.message||"VP library request failed");break}case"vp_updated":{let a=window.Pinia?.useVpStore?.()||window.__useVpStore&&window.__useVpStore();a&&r.vp&&a.upsert(r.vp,r.reason,e.agentId||null);break}case"vp_removed":{let a=window.Pinia?.useVpStore?.()||window.__useVpStore&&window.__useVpStore();a&&r.vpId&&a.remove(r.vpId,r.reason,e.agentId||null);break}case"vp_crud_result":{let a=this._vpCrudPending&&this._vpCrudPending.get(r.requestId);a&&(this._vpCrudPending.delete(r.requestId),a.resolve({ok:!!r.ok,op:r.op,vpId:r.vpId,vp:r.vp,error:r.error||null}));break}case"group_list_updated":case"session_list_updated":case"yeaft_session_hydrate":{let a=window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore(),l=r.sessions||[];if(r.projectsAuthoritative===!0&&Array.isArray(r.projects)?this.applySessionCatalogSnapshot(this.sessionCatalog,r.projects):Array.isArray(r.projects)&&e.agentId&&this.applyLegacyProjectSnapshot(r.projects,e.agentId),r.type!=="yeaft_session_hydrate"&&this.yeaftSessionHydrateRequestId&&this.yeaftSessionInventoryCompleteSupported===!0){let f=Array.isArray(this.yeaftSessionHydrateSlices)?this.yeaftSessionHydrateSlices.filter(g=>g.agentId!==(e.agentId||null)):[];this.yeaftSessionHydrateSlices=[...f,{agentId:e.agentId||null,sessions:l}];break}let c=a&&a.activeSessionId||null,d=a?.activeSessionKey&&a.sessions?.[a.activeSessionKey]?.agentId||null;a&&(a.applySnapshot(l,e.agentId||null),this._hasHandledYeaftSessionHydrate=!0,this.yeaftSessionHydrateError=null);let u=a&&a.activeSessionId||null,p=a?.activeSessionKey&&a.sessions?.[a.activeSessionKey]?.agentId||null;if(this.currentView==="yeaft"&&u){let f=p||Me(this,u,e.agentId||null),g=Pe(f,u),v=this.yeaftSessionHistoryState[g]||null;this.setActiveSessionFilter(u,{agentId:f,force:d!==f||Jd(u,c,v)})}break}case"group_roster_changed":case"session_roster_changed":{let a=window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore();a&&a.applyRosterChange(r,e.agentId||null);break}case"group_crud_result":case"session_crud_result":{let a=window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore();a&&a.applyCrudResult(r,e.agentId||null),r.ok&&r.op==="delete"&&r.sessionId&&e.agentId&&this.clearYeaftHistoryMemory({agentId:e.agentId,sessionId:r.sessionId});let l=this._sessionCrudPending&&this._sessionCrudPending.get(r.requestId);l&&(()=>{if(this._sessionCrudPending?.get(r.requestId)!==l)return;this._sessionCrudPending.delete(r.requestId);let d=r.session||r.group||null,u=d&&e.agentId&&!d.agentId?{...d,agentId:e.agentId}:d,p=r.sessionId||null,f=r.sessions||null;l.resolve({ok:!!r.ok,op:r.op,session:u,sessionId:p,sessions:f,config:r.config||null,error:r.error||null})})();break}case"vp_turn_start":{if(!r.turnId||!r.vpId)break;let a=rl(e.agentId||null,r.turnId)||r.turnId;if(this.activeVpTurns={...this.activeVpTurns,[a]:{agentId:e.agentId||null,turnId:r.turnId,vpId:r.vpId,sessionId:r.sessionId||null,threadId:r.threadId||null,isStreaming:!0,startedAt:r.ts||Date.now()}},r.sessionId){let l=ys(e.agentId||null,r.sessionId);this.yeaftProcessingSessions={...this.yeaftProcessingSessions,...l?{[l]:!0}:{[r.sessionId]:!0}}}break}case"vp_turn_end":{if(!r.turnId)break;let a=bn(this,e.agentId||null,r.turnId),l=r.sessionId||this.activeVpTurns?.[a]?.sessionId||null;r.reason==="end_turn"&&l&&this.markYeaftSessionUnread(l,e.agentId||null);let{[a]:c,...d}=this.activeVpTurns;this.activeVpTurns=d;let{[a]:u,...p}=this.stoppingVpTurnIds;this.stoppingVpTurnIds=p;let f=r.sessionId||c?.sessionId||null,g=e.agentId||c?.agentId||null,v=r.vpId||c?.vpId||null;if(!(f&&v?Object.values(this.activeVpTurns||{}).some(b=>b?.vpId===v&&Mt(b,f,g)):!1)&&f&&v){let b={...this.vpStatuses||{}},k=!1;for(let[P,x]of Object.entries(b))x?.vpId===v&&Mt(x,f,g)&&Zr.has(x.state)&&(b[P]={...x,state:"idle",turnId:null,since:r.ts||Date.now()},k=!0);k&&(this.vpStatuses=b)}this.clearYeaftSessionProcessingIfIdle(f,{agentId:g});let h={end_turn:"completed",route_forward:"completed",aborted:"aborted",errored:"errored",error:"errored",cancelled:"cancelled",canceled:"cancelled"}[r.reason]||"completed",w=Date.now(),S=Ss(this,e.agentId||null,e.conversationId);if(S&&Array.isArray(this.messagesMap[S])){let b=this.messagesMap[S],k=Op(b,r);for(let P=0;P<b.length;P++){let x=b[P];if(!x||x.type!=="assistant")continue;let B=x.sessionId??x.groupId;r.sessionId&&B&&B!==r.sessionId||r.vpId&&x.speakerVpId&&x.speakerVpId!==r.vpId||r.turnId&&x.turnId&&x.turnId!==r.turnId||x.status&&x.status!=="pending"||(x.status=h,x.turnEndAt=w,x.turnEndReason=r.reason||null,r.detail&&(x.turnEndDetail=r.detail),Number.isFinite(r.durationMs)&&(x.turnDurationMs=r.durationMs),k=!0)}k&&(this.messagesMap={...this.messagesMap,[S]:b.slice()}),this.pruneConversationMessageRetention(S,f,g)}break}case"yeaft_turn_aborted":{let a=Array.isArray(r.turnIds)?r.turnIds.filter(Boolean):[];r.turnId&&a.push(r.turnId);let l=r.sessionId||null,c=r.vpId||null,d=new Set;for(let g of a){let v=bn(this,e.agentId||null,g),m=this.activeVpTurns?.[v]||null;(!m||Mt(m,m.sessionId,e.agentId||null))&&d.add(v)}if(c)for(let[g,v]of Object.entries(this.activeVpTurns||{}))!v||v.vpId!==c||Mt(v,l,e.agentId||null)&&d.add(g);if(d.size===0)break;let u=l,p={...this.activeVpTurns||{}},f={...this.stoppingVpTurnIds||{}};for(let g of d){let v=p[g];!u&&v?.sessionId&&(u=v.sessionId),delete p[g],delete f[g]}this.activeVpTurns=p,this.stoppingVpTurnIds=f,this.clearYeaftSessionProcessingIfIdle(u||null,{agentId:e.agentId||null});break}case"yeaft_aborted":{let a=r.sessionId||e.sessionId||null;a?(this.activeVpTurns=Object.fromEntries(Object.entries(this.activeVpTurns||{}).filter(([,l])=>!Mt(l,a,e.agentId||null))),this.stoppingVpTurnIds=Object.fromEntries(Object.entries(this.stoppingVpTurnIds||{}).filter(([l])=>this.activeVpTurns?.[l])),this.vpStatuses=Object.fromEntries(Object.entries(this.vpStatuses||{}).filter(([,l])=>!Mt(l,a,e.agentId||null))),this.clearYeaftSessionProcessingIfIdle(a,{agentId:e.agentId||null,ignoreStatuses:!0})):r.all&&Bp(this,e.agentId||null);break}case"vp_typing_start":{if(!r.vpId)break;let a=Ss(this,e.agentId||null,e.conversationId);if(!a)break;this.yeaftVpTyping=yp(this.yeaftVpTyping,a,r.vpId);break}case"vp_typing_end":{if(!r.vpId)break;let a=Ss(this,e.agentId||null,e.conversationId);if(!a)break;this.yeaftVpTyping=bp(this.yeaftVpTyping,a,r.vpId);break}case"vp_status_changed":{if(!r.vpId||!r.state)break;if(o){let u=Al(i);if(r.state==="thinking"||r.state==="retrying"||r.state==="tool")qr(this,o,`${r.state}:${u}`);else if(r.state==="streaming"||r.state==="idle"||r.state==="error")for(let p of["thinking","retrying","tool"])Bn(this,o,`${p}:${u}`)}let a=r.sessionId||null,l=e.agentId||null,c=ao(l,a,r.vpId),d={agentId:l,state:r.state,since:r.since||Date.now(),turnId:r.turnId||null,title:r.title||"",sessionId:a,vpId:r.vpId};if(this.vpStatuses={...this.vpStatuses,[c]:d},a&&Zr.has(r.state)){let u=ys(l,a);this.yeaftProcessingSessions={...this.yeaftProcessingSessions,...u?{[u]:!0}:{[a]:!0}}}else a&&this.clearYeaftSessionProcessingIfIdle(a,{agentId:l});this.restoreActiveYeaftSessionFromStatuses([d],l);break}case"vp_status_snapshot":{let a=Array.isArray(r.statuses)?r.statuses:[],l=r.sessionId;if(l==null){let c={...this.vpStatuses||{}};if(e.agentId)for(let[d,u]of Object.entries(c))(!u?.agentId||u.agentId===e.agentId)&&delete c[d];else for(let d of Object.keys(c))delete c[d];for(let d of a){if(!d||!d.vpId)continue;let u=d.sessionId||d.groupId||null,p=ao(e.agentId||null,u,d.vpId);c[p]={agentId:e.agentId||null,state:d.state,since:d.since||Date.now(),turnId:d.turnId||null,title:d.title||"",sessionId:u,vpId:d.vpId}}this.vpStatuses=c}else{let c={...this.vpStatuses};for(let[d,u]of Object.entries(c))u&&u.sessionId===l&&(!e.agentId||!u.agentId||u.agentId===e.agentId)&&delete c[d];for(let d of a){if(!d||!d.vpId)continue;let u=d.sessionId||d.groupId||null,p=ao(e.agentId||null,u,d.vpId);c[p]={agentId:e.agentId||null,state:d.state,since:d.since||Date.now(),turnId:d.turnId||null,title:d.title||"",sessionId:u,vpId:d.vpId}}this.vpStatuses=c}this.yeaftProcessingSessions=Ib(this,e.agentId||null,a,l??null),this.restoreActiveYeaftSessionFromStatuses(a,e.agentId||null);break}case"yeaft_dream_snapshot":{let a=r&&r.snapshot,l=a&&typeof a.scope=="string"?a.scope:null;l&&(this.yeaftDreamSnapshots={...this.yeaftDreamSnapshots,[l]:{...a,receivedAt:Date.now()}});break}case"yeaft_dream_status":{let a=window.Pinia?.useVpStore?.()||window.__useVpStore&&window.__useVpStore();a&&a.applyDreamStatus(r);break}case"yeaft_dream_result":{let a=window.Pinia?.useVpStore?.()||window.__useVpStore&&window.__useVpStore();a&&a.applyDreamResult(r),r?.snapshot?.scope&&(this.yeaftDreamSnapshots={...this.yeaftDreamSnapshots,[r.snapshot.scope]:{...r.snapshot,receivedAt:Date.now()}});{let l=typeof r?.snapshot?.scope=="string"&&r.snapshot.scope?r.snapshot.scope:typeof r?.sessionId=="string"&&r.sessionId?`sessions/${r.sessionId}`:null;if(!l)break;let c=this.yeaftDreamLatest[l]||null;this.yeaftDreamLatest={...this.yeaftDreamLatest,[l]:{scope:l,phase:"result",status:r.skipped?"skipped":r.success?"success":"error",startedAt:c?.startedAt??null,finishedAt:Date.now(),mergedCount:typeof r.entriesCreated=="number"?r.entriesCreated:c?.mergedCount??null,error:r.skipped||r.success?null:r.error||"unknown",manual:typeof r?.manual=="boolean"?r.manual:c?.manual??null,durationMs:typeof r.durationMs=="number"?r.durationMs:c?.durationMs??null,llmCallCount:typeof r.llmCallCount=="number"?r.llmCallCount:c?.llmCallCount??0,inputTokens:typeof r.inputTokens=="number"?r.inputTokens:c?.inputTokens??0,outputTokens:typeof r.outputTokens=="number"?r.outputTokens:c?.outputTokens??0,totalTokens:typeof r.totalTokens=="number"?r.totalTokens:c?.totalTokens??0,metrics:r.metrics||c?.metrics||null,passBreakdown:r.passBreakdown||r.metrics?.passBreakdown||c?.passBreakdown||null,isRunning:!1}},this._appendDreamEvent(l,{type:"dream_progress",phase:"result",sessionId:r.sessionId,status:r.skipped?"skipped":r.success?"success":"error",success:!!r.success,entriesCreated:typeof r.entriesCreated=="number"?r.entriesCreated:null,trigger:r.trigger||null,error:r.skipped||r.success?null:r.error||null,skipped:!!r.skipped,skippedReason:r.skippedReason||null,durationMs:typeof r.durationMs=="number"?r.durationMs:null,llmCallCount:typeof r.llmCallCount=="number"?r.llmCallCount:0,inputTokens:typeof r.inputTokens=="number"?r.inputTokens:0,outputTokens:typeof r.outputTokens=="number"?r.outputTokens:0,totalTokens:typeof r.totalTokens=="number"?r.totalTokens:0,metrics:r.metrics||null,passBreakdown:r.passBreakdown||r.metrics?.passBreakdown||null,ts:Date.now()})}break}case"dream_progress":{let a=r?.phase||"unknown",l=null;typeof r?.target=="string"&&r.target.includes("/")?l=r.target:typeof r?.sessionId=="string"&&r.sessionId?l=`sessions/${r.sessionId}`:l="*";let c=a==="done",d=a==="error"||r?.status==="error",u=!c&&!d,p=f=>{let g=this.yeaftDreamLatest[f]||null;return{scope:f,phase:a,status:d?"error":c?"success":"running",startedAt:g?.startedAt&&u?g.startedAt:r?.ts||g?.startedAt||Date.now(),finishedAt:c||d?r?.ts||Date.now():null,mergedCount:typeof r?.mergedCount=="number"?r.mergedCount:typeof r?.targets=="number"?r.targets:g?.mergedCount??null,error:d?r?.error||"unknown":null,manual:typeof r?.manual=="boolean"?r.manual:g?.manual??!1,durationMs:typeof r?.duration=="number"?r.duration:typeof r?.durationMs=="number"?r.durationMs:g?.durationMs??null,llmCallCount:typeof r?.llmCallCount=="number"?r.llmCallCount:g?.llmCallCount??0,inputTokens:typeof r?.inputTokens=="number"?r.inputTokens:g?.inputTokens??0,outputTokens:typeof r?.outputTokens=="number"?r.outputTokens:g?.outputTokens??0,totalTokens:typeof r?.totalTokens=="number"?r.totalTokens:g?.totalTokens??0,metrics:r?.metrics||g?.metrics||null,passBreakdown:r?.passBreakdown||r?.metrics?.passBreakdown||g?.passBreakdown||null,isRunning:u}};if(l==="*"){let f={...this.yeaftDreamLatest,"*":p("*")};for(let g of Object.keys(this.yeaftDreamLatest))g!=="*"&&(f[g]=p(g));this.yeaftDreamLatest=f}else this.yeaftDreamLatest={...this.yeaftDreamLatest,[l]:p(l)};this._appendDreamEvent(l,r);break}}},_appendDreamEvent(e,t){if(!e||!t)return;let s=Date.now(),n={...t,at:s},r=Array.isArray(this.yeaftDreamEvents?.[e])?this.yeaftDreamEvents[e]:[],i=l=>[l?.type||"",l?.phase||"",(l?.sessionId??l?.groupId)||"",l?.target||"",l?.ts||l?.at||""].join("|"),o=i(n);if(r.some(l=>i(l)===o))return;let a=[...r,n];a.length>Jp&&a.splice(0,a.length-Jp),this.yeaftDreamEvents={...this.yeaftDreamEvents,[e]:a}},fetchExpertRoleDefinitions(){if(this.expertRoleDefinitions)return;let e=this.currentAgent;e&&this.sendWsMessage({type:"get_expert_roles",agentId:e})},setYeaftSidebarEnabled(e){try{typeof localStorage<"u"&&localStorage.removeItem("yeaft-sidebar-enabled")}catch{}},vpCrudRequest(e,t){(!this._vpCrudPending||typeof this._vpCrudPending.get!="function")&&(this._vpCrudPending=new Map);let s="vpc_"+Date.now().toString(36)+"_"+Math.random().toString(36).slice(2,8),r={create:"yeaft_vp_create",update:"yeaft_vp_update",delete:"yeaft_vp_delete",read:"yeaft_vp_read"}[e];if(!r)return Promise.resolve({ok:!1,op:e,error:{code:"bad_op",message:"unknown op: "+e}});let i={type:r,requestId:s};return e==="create"||e==="update"?i.payload=t||{}:i.vpId=t,new Promise(o=>{let a=setTimeout(()=>{this._vpCrudPending&&this._vpCrudPending.has(s)&&(this._vpCrudPending.delete(s),o({ok:!1,op:e,error:{code:"timeout",message:"vp_crud timeout"}}))},1e4);this._vpCrudPending.set(s,{resolve:l=>{clearTimeout(a),o(l)}}),this.sendWsMessage(i)})},sessionCrudRequest(e,t,s={}){(!this._sessionCrudPending||typeof this._sessionCrudPending.get!="function")&&(this._sessionCrudPending=new Map);let n="grc_"+Date.now().toString(36)+"_"+Math.random().toString(36).slice(2,8),i={list:"yeaft_list_sessions",create:"yeaft_create_session",copy:"yeaft_copy_session",rename:"yeaft_rename_session",update:"yeaft_update_session",update_config:"yeaft_update_session_config",archive:"yeaft_archive_session",delete:"yeaft_delete_session",add_member:"yeaft_session_add_member",remove_member:"yeaft_session_remove_member",set_default_vp:"yeaft_session_set_default_vp",reorder:"reorder_yeaft_sessions",scan_workdir:"yeaft_scan_workdir_sessions",restore:"yeaft_restore_session"}[e];if(!i)return Promise.resolve({ok:!1,op:e,error:{code:"bad_op",message:"unknown op: "+e}});let o={type:i,requestId:n};e==="create"?o.payload=t||{}:t&&typeof t=="object"&&Object.assign(o,t);let a=s&&s.agentId?s.agentId:null;a&&(o.agentId=a);let l=window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore();return l&&l.markPending(n,e),new Promise(c=>{let d=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=Me(this,e,t);if(!s)return!1;let n=xr(s,e);return this.currentView==="yeaft"&&this.yeaftActiveSessionFilter===e&&Me(this,e)===s||this.yeaftUnreadSessionKeys?.[n]?!1:(this.yeaftUnreadSessionKeys={...this.yeaftUnreadSessionKeys,[n]:!0},!0)},markYeaftSessionRead(e,t=null){if(!e)return!1;let s=Me(this,e,t);if(!s)return!1;let n=xr(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||ef(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?Me(this,n,t.agentId||null):this.currentAgent,i=!!n&&n===s&&!!r&&!!this.currentAgent&&r!==this.currentAgent,o=!!t.force||i;if(this.yeaftActiveSessionFilter=n,r&&n&&this.currentAgent!==r){this.selectAgent(r);let l=this.agents.find(c=>c.id===r);this.activateYeaftAgent(r,l||null)}else r&&n&&this.activateYeaftAgent(r);r&&n&&(this.markYeaftSessionRead(n,r),zd(this,r,n));let a=!o&&n===s;if(r&&n){this.yeaftSessionAgentById={...this.yeaftSessionAgentById||{},[n]:r};let l=this.yeaftConversationIdsByAgent?.[r]||null;l||(l=`yeaft-local-${r}-${Date.now()}`,this.yeaftConversationIdsByAgent={...this.yeaftConversationIdsByAgent||{},[r]:l}),this.yeaftConversationId=l,this.messagesMap[l]||(this.messagesMap[l]=[]),this.currentView==="yeaft"&&(this.activeConversations=[l])}try{let l=window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore();l&&typeof l.setActive=="function"&&l.setActive(n,r||null);let c=l?.activeSessionKey||null;c?localStorage.setItem("lastViewedYeaftSession",c):localStorage.removeItem("lastViewedYeaftSession")}catch{}this.syncActiveYeaftHistoryLoad(),n&&r&&!a&&this.requestYeaftSessionBootstrap({forceSessionReady:!0,forceHistoryReplay:!0})},async switchYeaftModel(e,t=null,s=void 0){if(!e||!this.currentAgent)return;let n=t||null;if(n){let r={model:e};return s!==void 0&&(r.modelEffort=s||null),await this.sessionCrudRequest("update_config",{sessionId:n,config:r},{agentId:Me(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()?Zp:xl,dreamLimit:5,indexOnly:!0,search:this.yeaftDebugSearch})},250)},setYeaftDebugSessionFilter(e){e==null?this.yeaftDebugSessionFilter=null:this.yeaftDebugSessionFilter=String(e)},toggleSubAgentCardExpand(e){let t=this.yeaftSubAgentCards?.[e];t&&(this.yeaftSubAgentCards={...this.yeaftSubAgentCards,[e]:{...t,expanded:!t.expanded}})},requestTelemetrySettings(e,t,s=null){if(!t)return Promise.reject(new Error("no agent"));let n=`telemetry-${Date.now()}-${Math.random().toString(36).slice(2)}`;return this.telemetryRequestByAgent={...this.telemetryRequestByAgent,[t]:n},new Promise((r,i)=>{this._telemetryPending||(this._telemetryPending={});let o=setTimeout(()=>{if(delete this._telemetryPending[n],this.telemetryRequestByAgent?.[t]===n){let a={...this.telemetryRequestByAgent};delete a[t],this.telemetryRequestByAgent=a}i(new Error("Telemetry request timed out"))},15e3);this._telemetryPending[n]={resolve:r,reject:i,timer:o,agentId:t,operation:e,requestId:n},this.sendWsMessage({type:e==="load"?"get_telemetry_settings":"update_telemetry_settings",agentId:t,requestId:n,...e==="update"?{settings:s||{}}:{}})})},loadTelemetrySettings(e=this.currentAgent){return e?this.requestTelemetrySettings("load",e):Promise.resolve({enabled:!0,retentionDays:3,flushIntervalMs:1e3,maxQueueSize:5e3,rawExchangeMaxBytes:524288,traceTextMaxBytes:262144,loaded:!0})},updateTelemetrySettings(e,t=this.currentAgent){return this.requestTelemetrySettings("update",t,e)},restartAgent(e){if(!e||this.agentOperations?.[e]?.restart?.pending)return!1;let t=`restart-${Date.now()}-${Math.random().toString(36).slice(2)}`,s=setTimeout(()=>this.finishAgentOperation(e,"restart","timeout"),12e4);return this.agentOperations={...this.agentOperations,[e]:{...this.agentOperations[e]||{},restart:{pending:!0,acknowledged:!1,startedAt:Date.now(),requestId:t,timer:s,error:null}}},this.sendWsMessage({type:"restart_agent",agentId:e,requestId:t}),!0},upgradeAgent(e,t=null){if(!e||this.agentOperations?.[e]?.upgrade?.pending)return!1;let s=this.agents.find(i=>i.id===e),n=`upgrade-${Date.now()}-${Math.random().toString(36).slice(2)}`,r=setTimeout(()=>this.finishAgentOperation(e,"upgrade","timeout"),12e4);return this.agentOperations={...this.agentOperations,[e]:{...this.agentOperations[e]||{},upgrade:{pending:!0,acknowledged:!1,startedAt:Date.now(),requestId:n,oldVersion:s?.version||null,batchId:t,timer:r,error:null}}},this.sendWsMessage({type:"upgrade_agent",agentId:e,requestId:n}),!0},getUpgradableAgents(){return(this.agents||[]).filter(e=>e?.online&&Array.isArray(e.capabilities)&&e.capabilities.includes("remote_upgrade_safe")&&!e.capabilities.includes("container_agent")&&!this.agentOperations?.[e.id]?.restart?.pending&&!this.agentOperations?.[e.id]?.upgrade?.pending)},upgradeAllAgents(){if(this.agentUpgradeBatch?.pending)return null;let e=this.getUpgradableAgents();if(e.length===0)return null;let t={id:`upgrade-batch-${Date.now()}-${Math.random().toString(36).slice(2)}`,pending:!0,startedAt:Date.now(),agentIds:e.map(s=>s.id),skippedCount:Math.max(0,(this.agents||[]).length-e.length),results:{}};this.agentUpgradeBatch=t;for(let s of e)this.upgradeAgent(s.id,t.id)||this.recordAgentUpgradeBatchResult(s.id,{status:"failed",error:"not_started"},t.id);return t.agentIds.length},recordAgentUpgradeBatchResult(e,t={},s=null){let n=this.agentUpgradeBatch;if(!n?.pending||s&&n.id!==s||!n.agentIds.includes(e)||n.results[e])return null;let r={...n,results:{...n.results,[e]:{status:t.status||"failed",error:t.error||null,version:t.version||null,reason:t.reason||null}}},i=r.agentIds.every(o=>r.results[o]);return this.agentUpgradeBatch=i?{...r,pending:!1,completedAt:Date.now()}:r,i&&typeof window<"u"&&window.dispatchEvent(new CustomEvent("agent-upgrade-batch-complete",{detail:this.agentUpgradeBatch})),i?this.agentUpgradeBatch:null},finishAgentOperation(e,t,s=null){let n=this.agentOperations?.[e]?.[t];n&&(clearTimeout(n.timer),this.agentOperations={...this.agentOperations,[e]:{...this.agentOperations[e]||{},[t]:{...n,pending:!1,timer:null,error:s}}},t==="upgrade"&&n.batchId&&this.recordAgentUpgradeBatchResult(e,s?{status:"failed",error:s}:{status:"upgraded"},n.batchId))},loadSearchSettings(){return this.currentAgent?new Promise(e=>{this._searchPending||(this._searchPending={}),this._searchPending.load=e,this.sendWsMessage({type:"get_search_settings",agentId:this.currentAgent})}):(this.searchSettings={backend:"tavily",tavilyKeyConfigured:!1,tavilyKeyMasked:null,disableHtmlFallback:!1,loaded:!0},Promise.resolve(this.searchSettings))},updateSearchSettings(e){return this.currentAgent?new Promise(t=>{this._searchPending||(this._searchPending={}),this._searchPending.update=t,this.sendWsMessage({type:"update_search_settings",agentId:this.currentAgent,settings:e||{}})}):Promise.resolve({error:"no agent"})},loadTavilyUsage(){return this.currentAgent?(this.tavilyUsageLoading=!0,new Promise(e=>{this._searchPending||(this._searchPending={}),this._searchPending.usage=e,this.sendWsMessage({type:"get_tavily_usage",agentId:this.currentAgent})})):Promise.resolve(null)},loadYeaftMcpServers(){if(!this.currentAgent)return this.yeaftMcpServers=[],this.yeaftMcpRuntime={connected:!1,toolCount:0,perServer:[]},Promise.resolve({servers:[],runtime:this.yeaftMcpRuntime});this.yeaftMcpLoading=!0;let e=`mcp-list-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;return new Promise(t=>{this._mcpPending||(this._mcpPending={}),this._mcpPending[e]=t,this.sendWsMessage({type:"yeaft_mcp_list",agentId:this.currentAgent,requestId:e})})},addYeaftMcpServer(e){if(!this.currentAgent)return Promise.resolve({error:"no agent"});this.yeaftMcpLoading=!0;let t=`mcp-add-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;return new Promise(s=>{this._mcpPending||(this._mcpPending={}),this._mcpPending[t]=s,this.sendWsMessage({type:"yeaft_mcp_add",agentId:this.currentAgent,requestId:t,server:e||{}})})},removeYeaftMcpServer(e){if(!this.currentAgent)return Promise.resolve({error:"no agent"});this.yeaftMcpLoading=!0;let t=`mcp-rem-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;return new Promise(s=>{this._mcpPending||(this._mcpPending={}),this._mcpPending[t]=s,this.sendWsMessage({type:"yeaft_mcp_remove",agentId:this.currentAgent,requestId:t,name:e})})},reloadYeaftMcpServer(e){if(!this.currentAgent)return Promise.resolve({error:"no agent"});this.yeaftMcpLoading=!0;let t=`mcp-rel-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;return new Promise(s=>{this._mcpPending||(this._mcpPending={}),this._mcpPending[t]=s,this.sendWsMessage({type:"yeaft_mcp_reload",agentId:this.currentAgent,requestId:t,name:e||null})})},clearYeaftMessages(){let e=this.yeaftConversationId;e&&(qe(this,e),delete this.messagesMap[e],delete this.processingConversations[e],delete this.executionStatusMap[e],delete this.refreshingSessionMap[e],this._closedAt&&delete this._closedAt[e],this._turnCompletedConvs?.delete(e)),this.yeaftConversationId=this.currentAgent?`yeaft-local-${this.currentAgent}-${Date.now()}`:`yeaft-local-${Date.now()}`,this.currentAgent&&(this.yeaftConversationIdsByAgent={...this.yeaftConversationIdsByAgent||{},[this.currentAgent]:this.yeaftConversationId}),this.messagesMap[this.yeaftConversationId]=[],this.activeConversations=[this.yeaftConversationId],this.yeaftSessionReady=!1,this.yeaftModel=null,this.yeaftAvailableModels=[],this.yeaftStatus=null,this._yeaftAskTerminalEvents={},this.yeaftDebugLoops=[],this.yeaftDebugTurnsById={},this.yeaftDebugTurnOrder=[],this.yeaftDebugHistoryLoading=!1,this.yeaftDebugHistoryError=null,this.yeaftDebugHistoryFetchedAt=0,this.yeaftDebugHistoryProjection=null,this.yeaftDebugSearch="",this.yeaftDebugSessionFilter=null,this.yeaftDebugPanel={open:!1,status:"idle",requestId:null,agentId:null,sessionId:null,turnId:null,error:null},this._yeaftDebugSearchTimer&&(clearTimeout(this._yeaftDebugSearchTimer),this._yeaftDebugSearchTimer=null),this._fetchYeaftDebugHistoryTimer&&(clearTimeout(this._fetchYeaftDebugHistoryTimer),this._fetchYeaftDebugHistoryTimer=null),this._yeaftDebugHistoryInFlightKey=null,this._yeaftDebugHistoryLatestListRequestId=null,this._yeaftDebugHistoryLatestDetailRequestId=null,this.yeaftReflectionCards={},this.yeaftSubAgentCards={},this.yeaftDreamLatest={},this.yeaftDreamEvents={},this.vpStatuses={},this.currentAgent&&this.sendWsMessage({type:"yeaft_reset",agentId:this.currentAgent})},togglePaneRightPanel(e,t=null){if(t&&this.isSplitMode){let s=this.panels.find(n=>n.id===t);if(s){s.activeRightPanel=s.activeRightPanel===e?null:e;return}}this.activeRightPanel=this.activeRightPanel===e?null:e,this.activeRightPanel&&(this.workbenchExpanded=!1,this.workbenchMaximized=!1,this.rememberWorkbenchPanelState())},getPaneRightPanel(e){if(e&&this.isSplitMode){let t=this.panels.find(s=>s.id===e);if(t)return t.activeRightPanel}return this.activeRightPanel},setPaneRightPanel(e,t){if(e&&this.isSplitMode){let s=this.panels.find(n=>n.id===e);if(s){s.activeRightPanel=t;return}}this.activeRightPanel=t},applySessionCatalogSnapshot(e,t=null,s=null){let n=r=>{let i=new Set;return(Array.isArray(r)?r:[]).filter(o=>!o?.catalogKey||i.has(o.catalogKey)?!1:(i.add(o.catalogKey),!0)).map(o=>({...o}))};if(this.sessionCatalog=n(e),Array.isArray(s)&&(this.hiddenSessionCatalog=n(s)),Array.isArray(t)){this.sessionProjects=t.filter(i=>i?.id).map(i=>({...i,members:Array.isArray(i.members)?i.members.filter(o=>o?.agentId&&o?.sessionId):i.agentId?(i.sessionIds||[]).map(o=>({agentId:i.agentId,sessionId:o})):[]}));let r=new Map;for(let i of this.sessionProjects)for(let o of i.members)r.set(`${o.agentId}${o.sessionId}`,i.id);this.sessionCatalog=this.sessionCatalog.map(i=>i.runtimeProvider==="yeaft"?{...i,projectId:r.get(`${i.routeRef?.agentId}${i.routeRef?.sessionId}`)||null}:i)}this.sessionCatalogLoaded=!0},mutateProject(e,t={},s=null){let n=s||t.agentId||this.currentAgent||null;if(e==="move_session"&&!n)return Promise.resolve({ok:!1,error:{code:"missing_agent"}});let r=`project_${crypto.randomUUID()}`;return new Promise(i=>{let o=setTimeout(()=>{delete this.projectMutationRequests[r],i({ok:!1,error:{code:"timeout"}})},1e4);this.projectMutationRequests[r]={connectionGeneration:Number(this.chatHistoryConnectionGeneration||0),catalogOrder:Array.isArray(t.catalogOrder)?t.catalogOrder:null,resolve:l=>{clearTimeout(o),i(l)}},this.sendWsMessage({type:"yeaft_project_mutation",...n?{agentId:n,targetAgentId:n}:{},requestId:r,op:e,...t})||(clearTimeout(o),delete this.projectMutationRequests[r],i({ok:!1,error:{code:"send_failed"}}))})},applyLegacyProjectSnapshot(e,t){if(!t||!Array.isArray(e))return;let s=this.sessionProjects.filter(r=>r.legacyAgentId!==t),n=e.filter(r=>r?.id).map(r=>({...r,id:`${t}${r.id}`,legacyProjectId:r.id,legacyAgentId:t,members:(r.sessionIds||[]).map(i=>({agentId:t,sessionId:i}))}));this.applySessionCatalogSnapshot(this.sessionCatalog,[...s,...n])},finishLegacyProjectMutation(e,t){if(!e?.requestId)return!1;let s=this.projectMutationRequests[e.requestId]||null;return!s||s.connectionGeneration!==Number(this.chatHistoryConnectionGeneration||0)?!1:(delete this.projectMutationRequests[e.requestId],e.ok&&Array.isArray(e.projects)&&t&&this.applyLegacyProjectSnapshot(e.projects,t),s.resolve(e),!0)},finishProjectMutation(e){if(!e?.requestId)return!1;let t=this.projectMutationRequests[e.requestId]||null;if(!t||t.connectionGeneration!==Number(this.chatHistoryConnectionGeneration||0))return!1;if(delete this.projectMutationRequests[e.requestId],e.ok){if(Array.isArray(t.catalogOrder)){let s=new Map(this.sessionCatalog.map(r=>[r.catalogKey,r])),n=t.catalogOrder.map((r,i)=>{let o=s.get(r?.catalogKey);return o?{...o,sortRank:i}:null}).filter(Boolean);n.length===this.sessionCatalog.length&&(this.sessionCatalog=n,Yp(n))}Array.isArray(e.projects)&&this.applySessionCatalogSnapshot(this.sessionCatalog,e.projects)}return t.resolve(e),!0},toggleCatalogSessionPin(e){if(!e?.catalogKey||!e?.routeRef||Object.keys(this.sessionCatalogMutationRequests).length>0)return!1;let t=`session_ui_${crypto.randomUUID()}`,s=Tr(this,t),n=!e.pinned;return e.pinned=n,this.sendWsMessage({type:"set_session_ui_metadata",requestId:t,catalogKey:e.catalogKey,routeRef:e.routeRef,pinned:n,sortRank:Number.isFinite(e.sortRank)?e.sortRank:null})?!0:(this.sessionCatalog=s,delete this.sessionCatalogMutationRequests[t],!1)},hideCatalogSession(e){if(!e?.catalogKey||!e?.routeRef||Object.keys(this.sessionCatalogMutationRequests).length>0)return!1;let t=`session_hide_${crypto.randomUUID()}`,s=Tr(this,t);return this.sessionCatalog=this.sessionCatalog.filter(r=>r.catalogKey!==e.catalogKey),this.hiddenSessionCatalog=[...(this.hiddenSessionCatalog||[]).filter(r=>r.catalogKey!==e.catalogKey),{...e,hidden:!0}],this.sendWsMessage({type:"set_session_ui_metadata",requestId:t,catalogKey:e.catalogKey,routeRef:e.routeRef,hidden:!0,...Number.isFinite(e.sortRank)?{sortRank:e.sortRank}:{}})?!0:(this.sessionCatalog=s,this.hiddenSessionCatalog=Array.isArray(this.sessionCatalogMutationRequests[t]?.previousHiddenCatalog)?this.sessionCatalogMutationRequests[t].previousHiddenCatalog:[],delete this.sessionCatalogMutationRequests[t],!1)},restoreCatalogSession(e){if(!e?.catalogKey||!e?.routeRef||Object.keys(this.sessionCatalogMutationRequests).length>0)return!1;let t=`session_restore_${crypto.randomUUID()}`,s=Tr(this,t);return this.hiddenSessionCatalog=(this.hiddenSessionCatalog||[]).filter(r=>r.catalogKey!==e.catalogKey),this.sessionCatalog=this.sessionCatalog.some(r=>r.catalogKey===e.catalogKey)?this.sessionCatalog:[...this.sessionCatalog,{...e,hidden:!1}],this.sendWsMessage({type:"set_session_ui_metadata",requestId:t,catalogKey:e.catalogKey,routeRef:e.routeRef,hidden:!1,...Number.isFinite(e.sortRank)?{sortRank:e.sortRank}:{}})?!0:(this.sessionCatalog=s,this.hiddenSessionCatalog=Array.isArray(this.sessionCatalogMutationRequests[t]?.previousHiddenCatalog)?this.sessionCatalogMutationRequests[t].previousHiddenCatalog:[],delete this.sessionCatalogMutationRequests[t],!1)},renameCatalogSession({row:e,title:t}={}){if(!e?.routeRef||!t)return!1;let{runtimeProvider:s,agentId:n,sessionId:r}=e.routeRef;if(s==="yeaft")this.sessionCrudRequest("rename",{sessionId:r,name:t},{agentId:n});else if(s==="claude-code"||s==="copilot")this.renameChatSession(r,t,n);else return!1;return!0},async copyCatalogSession(e){let t=e?.routeRef;if(t?.runtimeProvider!=="yeaft"||!t.agentId||!t.sessionId)return{ok:!1,op:"copy",error:{code:"bad_route",message:"Yeaft Session route required"}};let s=await this.sessionCrudRequest("copy",{sessionId:t.sessionId},{agentId:t.agentId});if(!s?.ok||!s.session?.id)return s;let n={runtimeProvider:"yeaft",agentId:s.session.agentId||t.agentId,sessionId:s.session.id};return this.openCatalogSession({catalogKey:xr(n.agentId,n.sessionId),routeRef:n}),s},reorderCatalogSessions(e){if(!Array.isArray(e)||e.length===0||Object.keys(this.sessionCatalogMutationRequests).length>0)return!1;let t=`session_order_${crypto.randomUUID()}`,s=Tr(this,t);return this.sessionCatalog=e.map((r,i)=>({...r,sortRank:i})),this.sendWsMessage({type:"reorder_session_catalog",requestId:t,sessions:this.sessionCatalog.map((r,i)=>({catalogKey:r.catalogKey,routeRef:r.routeRef,pinned:!!r.pinned,sortRank:i}))})?!0:(this.sessionCatalog=s,delete this.sessionCatalogMutationRequests[t],!1)},finishSessionCatalogMutation(e){if(!fd(this,e))return!1;if(e?.ok===!0&&e?.type==="session_ui_metadata_updated"){let s=n=>{n&&(n.pinned=e.pinned===!0,Object.prototype.hasOwnProperty.call(e,"sortRank")&&(n.sortRank=Number.isFinite(e.sortRank)?e.sortRank:null))};s(this.sessionCatalog.find(n=>n.catalogKey===e.catalogKey)),s(this.hiddenSessionCatalog.find(n=>n.catalogKey===e.catalogKey))}return e?.ok===!0&&e?.type==="session_catalog_reorder_result"&&Yp(this.sessionCatalog),!0},openCatalogSession(e){if(!e?.catalogKey||!e.routeRef)return!1;let{runtimeProvider:t,agentId:s,sessionId:n}=e.routeRef;if(this.activeCatalogKey=e.catalogKey,t==="yeaft"){let r=this.isSessionHistorySyncing(e.routeRef);return this.enterYeaft(s,{deferBootstrap:!0}),this.setActiveSessionFilter(n,{agentId:s,force:!1}),r||this.reloadYeaftMessages(),!0}return t!=="claude-code"&&t!=="copilot"?!1:(this.currentView==="yeaft"&&this.leaveYeaft(),this.selectConversation(n,s,{refresh:!0}),!0)},syncChatConversationHistory(e){if(!e)return null;let t=Vs(e);if(this.chatHistoryRequests[t]?.loading)return this.chatHistoryRequests[t].requestId;let s=cn(this.messagesMap[e]);return this.requestChatHistory(e,s===null?{mode:"recent",turns:5}:{mode:"delta",afterMessageId:s})},requestChatHistory(e,{mode:t="recent",turns:s=null,beforeId:n=null,afterMessageId:r=null}={}){if(!e)return null;let i=Vs(e);if(this.chatHistoryRequestIdSupported!==!0&&this.chatHistoryRequests[i]?.loading)return null;let o=n??r??null,a=this.beginChatHistoryRequest(e,t,o);return this.sendWsMessage({type:"sync_messages",conversationId:e,...s!=null?{turns:s}:{},...n!=null?{beforeId:n}:{},...r!=null?{afterMessageId:r}:{},requestId:a})?(setTimeout(()=>{Ra(this,i,a,"history_load_timeout")},1e4),a):(Ra(this,i,a,"send_failed"),null)},beginChatHistoryRequest(e,t="recent",s=null){return gd(this,e,t,s)},isCurrentChatHistoryResponse(e){if(!e?.conversationId||!e?.requestId||!e?.catalogKey)return!1;let t=Vs(e.conversationId);if(e.catalogKey!==t)return!1;let s=this.chatHistoryRequests[t];return!!s&&s.loading===!0&&s.requestId===e.requestId&&Number(s.connectionGeneration||0)===Number(this.chatHistoryConnectionGeneration||0)},finishChatHistoryRequest(e){if(!this.isCurrentChatHistoryResponse(e))return!1;let t=this.chatHistoryRequests[e.catalogKey];return this.chatHistoryRequests[e.catalogKey]={...t,loading:!1},!0},isRefreshingSession(e){return e?!!this.refreshingSessionMap[e]:this.refreshingSession},setRefreshingSession(e,t){e&&(this.refreshingSessionMap[e]=t),this.refreshingSession=t},enterBtwMode(){this.btwMode=!0,this.btwMessages=[],this.btwLoading=!1,this.btwSessionId=null},sendBtwQuestion(e){this.currentConversation&&(this.btwMessages.push({role:"user",content:e}),this.btwMessages.push({role:"assistant",content:""}),this.btwLoading=!0,this.sendWsMessage({type:"btw_question",conversationId:this.currentConversation,question:e,btwSessionId:this.btwSessionId}))},closeBtw(){this.btwMode=!1,this.btwMessages=[],this.btwLoading=!1,this.btwSessionId=null},appendBtwDelta(e){let t=this.btwMessages[this.btwMessages.length-1];t&&t.role==="assistant"&&(t.content+=e)},addSubagent(e,t){this.subagents[e]||(this.subagents[e]={}),this.subagents[e][t.id]={id:t.id,slug:t.slug||t.id,type:t.type||"Task",description:t.description||"",parentToolUseId:t.parentToolUseId||null,status:"running",startTime:Date.now(),messages:[],toolCallCount:0},e===this.currentConversation&&this.activeRightPanel!=="subagents"&&(this.activeRightPanel="subagents")},appendSubagentMessage(e,t,s){let n=this.subagents[e];if(!n||!n[t])return;let r=n[t];if(s?.type==="tool"){r.toolCallCount=Number(r.toolCallCount||0)+1;return}s?.type==="text"&&r.messages.push(s)},completeSubagent(e,t){let s=this.subagents[e];!s||!s[t]||(s[t].status="completed")},sendWsMessage(e){return Ed(this,e)},parseWsMessage(e){return $d(this,e)},connect(){Ld(this)},ensureConnected(){return Rr(this)},scheduleReconnect(){Od(this)},manualReconnect(){Vd(this)},startHeartbeat(){qd(this)},stopHeartbeat(){Fd(this)},setupVisibilityHandler(){Hd(this)},handleMessage(e){Hu(this,e)},getOrCreateExecutionStatus(e){return el(this,e)},handleAssistantOutputFrame(e,t,s=null){Tu(this,e,t,s)},handleClaudeOutput(e,t){this.handleAssistantOutputFrame(e,t,null)},addMessageToConversation(e,t){return Ki(this,e,t)},pruneConversationMessageRetention(e,t=null,s=null,n=void 0){return Ud(this,{conversationId:e,sessionId:t,agentId:s,limits:n})},appendToAssistantMessageForConversation(e,t,s){su(this,e,t,s)},finishStreamingForConversation(e,t){nu(this,e,t)},sweepStaleStreamingForConversation(e){ru(this,e)},appendToAssistantMessage(e){this.appendToAssistantMessageForConversation(this.currentConversation,e)},finishStreaming(){this.finishStreamingForConversation(this.currentConversation)},addMessage(e){this.addMessageToConversation(this.currentConversation,e)},loadHistoryMessages(e){iu(this,e)},formatDbMessage(e){return ou(e)},selectAgent(e){return Yu(this,e)},createConversation(e,t=null,s=null,n=void 0){Gu(this,e,t,s,n)},resumeConversation(e,t,s=null,n=null,r=null){Qu(this,e,t,s,n,r)},selectConversation(e,t,s={}){Xu(this,e,t,s)},updateConversationSettings(e,t){al(this,e,t)},toggleConversationMcp(e,t){Zu(this,e,t)},deleteConversation(e,t){ep(this,e,t)},closeSession(e,t){Ju(this,e,t)},appendColumn(e){rp(this,e)},removeColumn(e){ip(this,e)},sendMessageToConversation(e,t,s=[],n={}){op(this,e,t,s,n)},cancelExecutionForConversation(e){ap(this,e)},addPanel(){if(this.panels.length>=3)return;let e=(t,s)=>({id:t,conversationId:s,activeRightPanel:null});if(this.panels.length===0){let t=localStorage.getItem("splitPanesSaved");if(t){try{let s=JSON.parse(t);if(Array.isArray(s)&&s.length>=2){let n=new Set(this.conversations.map(i=>i.id)),r=s.filter(i=>i&&typeof i.id=="string").map(i=>({...e(i.id,null),conversationId:i.conversationId&&n.has(i.conversationId)?i.conversationId:null}));if(r.length>=2){this.panels=r,this.activePanelId=r[0].id;for(let i of r)i.conversationId&&!this.activeConversations.includes(i.conversationId)&&this.activeConversations.push(i.conversationId),i.conversationId&&!this.messagesMap[i.conversationId]&&(this.messagesMap[i.conversationId]=[],this.requestChatHistory(i.conversationId,{mode:"recent",turns:5}));localStorage.removeItem("splitPanesSaved"),this.saveOpenSessions();return}}}catch{}localStorage.removeItem("splitPanesSaved")}this.panels=[e("panel-0",this.currentConversation),e("panel-1",null)],this.activePanelId="panel-0"}else{let t="panel-"+Date.now();this.panels.push(e(t,null))}this.saveOpenSessions()},removePanel(e){let t=this.panels.findIndex(s=>s.id===e);if(!(t<0)){if(this.panels.splice(t,1),this.panels.length<=1){let s=this.panels[0];s?.conversationId&&(this.activeConversations=[s.conversationId]),this.panels=[],this.activePanelId=null}else this.activePanelId===e&&(this.activePanelId=this.panels[0]?.id||null);this.saveOpenSessions()}},setPanelConversation(e,t,{refresh:s=!1}={}){let n=this.panels.find(i=>i.id===e);if(!n)return;let r=n.conversationId===t;n.conversationId=t,t&&!this.activeConversations.includes(t)&&this.activeConversations.push(t),t&&!this.messagesMap[t]?(this.messagesMap[t]=[],this.syncChatConversationHistory(t)):t&&(s||!r)&&this.syncChatConversationHistory(t),this.saveOpenSessions()},setActivePanel(e){this.activePanelId=e},splitToPanel(e){if(!e)return;let t=(s,n)=>({id:s,conversationId:n,activeRightPanel:null});if(this.panels.length===0)this.panels=[t("panel-0",this.currentConversation),t("panel-"+Date.now(),e)],this.activePanelId=this.panels[1].id;else if(this.panels.length>=3)this.panels[this.panels.length-1].conversationId=e,this.activePanelId=this.panels[this.panels.length-1].id;else{let s="panel-"+Date.now();this.panels.push(t(s,e)),this.activePanelId=s}this.activeConversations.includes(e)||this.activeConversations.push(e),this.messagesMap[e]||(this.messagesMap[e]=[],this.requestChatHistory(e,{mode:"recent",turns:5})),this.saveOpenSessions()},isInAnyPanel(e){return this.panels.some(t=>t.conversationId===e)},setSessionPinned(e,t,s={}){if(!e)return;let n=s&&s.agentId?s.agentId:null,r=n?!!ts()?.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=Me(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?ts()?.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||Me(this,e);if(Object.values(this.activeVpTurns||{}).some(a=>Mt(a,e,n))||!s&&Object.values(this.vpStatuses||{}).some(l=>Mt(l,e,n)&&Zr.has(l?.state)))return;let i=ys(n,e),o={...this.yeaftProcessingSessions||{}};i&&delete o[i],co(this,e,n)&&delete o[e],this.yeaftProcessingSessions=o},sendMessage(e,t=[],s={}){tp(this,e,t,s)},cancelExecution(){sp(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],Bp(this,this.currentAgent)},cancelYeaftSession(e){let t=Me(this,e);!t||!e||(this.sendWsMessage({type:"yeaft_abort_all",agentId:t,sessionId:e}),this.activeVpTurns=Object.fromEntries(Object.entries(this.activeVpTurns||{}).filter(([,s])=>!Mt(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])=>!Mt(s,e,t))),this.clearYeaftSessionProcessingIfIdle(e,{agentId:t,ignoreStatuses:!0}))},cancelVpTurn(e,{sessionId:t=null,vpId:s=null}={}){let n=Me(this,t);if(!n||!e)return;let r=bn(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=Me(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||!Mt(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?.[ao(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){np(this,e,t,s)},refreshAgents(){lp(this)},refreshConversation(){cp(this)},setDreamEnabled(e,t){if(!e||this.agentDreamState?.[e]?.pending)return!1;let s=this.agents.find(o=>o.id===e),n=t!==!1,r=`dream-${Date.now()}-${Math.random().toString(36).slice(2)}`,i=setTimeout(()=>{let o=this.agentDreamState?.[e];!o?.pending||o.requestId!==r||(this.agentDreamState={...this.agentDreamState,[e]:{...o,pending:!1,timer:null,error:"timeout"}})},15e3);return this.agentDreamState={...this.agentDreamState,[e]:{pending:!0,requestId:r,requested:n,authoritative:s?.dreamEnabled===!0,timer:i,error:null}},dp(this,e,n,r),!0},loadMoreMessages(){if(this.currentView==="yeaft"||this.loadingMoreMessages||!this.hasMoreMessages||!this.currentConversation)return;this.loadingMoreMessages=!0;let e=this._loadMoreGeneration=(this._loadMoreGeneration||0)+1,s=(this.messagesMap[this.currentConversation]||[]).find(i=>i.dbMessageId),n=this.currentConversation,r=s?.dbMessageId??null;this.requestChatHistory(n,{mode:"older",turns:5,beforeId:r}),setTimeout(()=>{this._loadMoreGeneration===e&&this.loadingMoreMessages&&this.currentConversation===n&&(this.loadingMoreMessages=!1)},1e4)},reloadYeaftMessages(){if(this.currentView!=="yeaft")return!1;let e=Is(this),t=Me(this,e);if(!t)return!1;let s=Pe(t,e),n=this.yeaftConversationId,r=this.yeaftSessionHistoryState?.[s];if(r?.loading)return r.requestId?(this._yeaftManualHistoryRefresh={agentId:t,sessionId:e,requestId:r.requestId},r.requestId):!1;let i=this.beginYeaftHistoryLoad({agentId:t,sessionId:e,mode:"recent",preserveLoaded:!1});if(!i)return!1;this._yeaftManualHistoryRefresh={agentId:t,sessionId:e,requestId:i.requestId};let o=un();this.yeaftHistoryPerfTraceBySession={...this.yeaftHistoryPerfTraceBySession||{},[s]:o};let a={type:"yeaft_load_history",agentId:t,limit:kl,sessionId:e,requestId:i.requestId,perfTraceId:o};return vt(this,{traceId:o,phase:"history.request_send",agentId:t,sessionId:e,messageType:a.type,bytes:JSON.stringify(a).length,detail:{mode:"manual-reload",limit:kl}}),this.sendWsMessage(a)?!0:(Er(this,{agentId:t,sessionId:e,requestId:i.requestId,error:"history_load_send_failed"}),!1)},loadMoreYeaftHistory(e=Qr(),{sessionId:t=null,agentId:s=null,background:n=!1}={}){if(this.currentView!=="yeaft")return!1;let r=t||Is(this),i=Me(this,r,s);if(!i||!r)return!1;let o=Pe(i,r),a=this.yeaftSessionHistoryState?.[o]||{};if(a.loading||!a.hasMore)return!1;let l=Math.min(50,Math.max(1,Number.isFinite(e)?Math.floor(e):Qr())),c=this.yeaftHistoryCacheState?.[o]?.ranges||[],d=Number(this.yeaftHistoryCacheState?.[o]?.rangeEpoch)||0,u=du(a,c,d);if(this.yeaftSessionHistoryState={...this.yeaftSessionHistoryState||{},[o]:u.state},!u.request)return this.syncActiveYeaftHistoryLoad(),!1;let p=this.beginYeaftHistoryLoad({agentId:i,sessionId:r,mode:n?"prefetch":"older",preserveLoaded:!0,latestSeq:this.yeaftSessionHistoryState[o]?.latestSeq??null});if(!p)return!1;let f=un();this.yeaftHistoryPerfTraceBySession={...this.yeaftHistoryPerfTraceBySession||{},[o]:f};let g={type:"yeaft_load_more_history",agentId:i,sessionId:r,requestId:p.requestId,beforeSeq:u.request.beforeSeq,pageKind:u.request.kind,gapStopAtSeq:u.request.stopAtSeq,cacheEpoch:u.request.cacheEpoch,turns:l,perfTraceId:f};return vt(this,{traceId:f,phase:"history_more.request_send",agentId:i,sessionId:r,messageType:g.type,bytes:JSON.stringify(g).length,detail:{beforeSeq:g.beforeSeq,turns:g.turns,pageKind:u.request.kind,gapStopAtSeq:u.request.stopAtSeq,background:n}}),this.sendWsMessage(g)?!0:(Er(this,{agentId:i,sessionId:r,requestId:p.requestId,error:"history_load_send_failed"}),!1)},checkPendingRecovery(){hd(this)},performRecovery(){md(this)},dismissRecovery(){vd(this)},autoRestoreConversation(e){yd(this,e)},saveOpenSessions(){on(this)},getLastSession(){return wd(this)},clearLastSession(){kd(this)},listHistorySessions(e){Sd(this,e)},listFolders(){return Id(this)},listFoldersForAgent(e,t){return Cd(this,e,t)},listModelsForAgent(e,t){return Ad(this,e,t)},listHistorySessionsForAgent(e,t,s){xd(this,e,t,s)},async loadGlobalSessions(e=20){return Td(this,e)},async deleteGlobalSession(e){return Md(this,e)},findAgentForSession(e){return _a(this,e)},isSessionResumable(e){return Pd(this,e)},_isRecentlyClosed(e){return dn(this,e)},_startProcessingWatchdog(e){Hn(this,e)},_resetProcessingWatchdog(e){zi(this,e)},_stopProcessingWatchdog(e){qe(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,Ar(e),this.currentAgent)try{this.sendWsMessage({type:"update_llm_config",agentId:this.currentAgent,config:{language:e}})}catch{}},async fetchCustomExpertRoles(){let e=je();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=je();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=je();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=je();try{let s={};t.token&&(s.Authorization=`Bearer ${t.token}`);let n=await fetch(`/api/expert-roles/custom/${e}`,{method:"DELETE",headers:s});if(n.ok)return this.customExpertRoles=this.customExpertRoles.filter(r=>r.id!==e),!0;{let r=await n.json().catch(()=>({}));throw new Error(r.error||"Failed to delete custom expert role")}}catch(s){throw s}},rememberWorkbenchPanelState(e=this.activeSessionRoute,t){let s=typeof e=="string"?e:dt(e);if(!s)return!1;let n=this.workbenchPanelStateByRoute[s]||{},r=Number.isFinite(t)&&t>0?Math.round(t):n.width;return this.workbenchPanelStateByRoute={...this.workbenchPanelStateByRoute,[s]:{expanded:!!this.workbenchExpanded,maximized:!!this.workbenchExpanded&&!!this.workbenchMaximized,...Number.isFinite(r)&&r>0?{width:r}:{}}},!0},workbenchPanelWidthForRoute(e=this.activeSessionRoute){let t=typeof e=="string"?e:dt(e),s=t?this.workbenchPanelStateByRoute[t]?.width:null;return Number.isFinite(s)&&s>0?s:null},restoreWorkbenchPanelState(e=this.activeSessionRoute){let t=dt(e),s=t?this.workbenchPanelStateByRoute[t]:null;return this.workbenchExpanded=!!s?.expanded,this.workbenchMaximized=!!s?.expanded&&!!s?.maximized,!!s},openWorkbench(){this.workbenchExpanded=!0,this.activeRightPanel=null,this.closeYeaftDebugPanel(),this.rememberWorkbenchPanelState()},toggleWorkbench(){if(this.workbenchExpanded){this.workbenchExpanded=!1,this.workbenchMaximized=!1,this.rememberWorkbenchPanelState();return}this.openWorkbench()},toggleSidebar(){this.sidebarCollapsed=!this.sidebarCollapsed},toggleSessionSidebar(){this.sessionSidebarOpen=!this.sessionSidebarOpen},closeSessionSidebar(){this.sessionSidebarOpen=!1},toggleWorkbenchMaximized(){this.workbenchMaximized=!this.workbenchMaximized,this.rememberWorkbenchPanelState()},renameChatSession(e,t,s=null){let n=t&&t.trim()?t.trim():"";n?this.customConversationTitles[e]=n:delete this.customConversationTitles[e],this.sendWsMessage({type:"update_conversation_settings",conversationId:e,...s?{agentId:s}:{},title:n})},resolveMessageFileReferences(e){let t=this.activeSessionRoute,s=t?.agentId||this.currentAgent||null,n=t?.runtimeProvider==="yeaft"?yt(this,t.sessionId,s):this.currentConversation,i=dt(t)&&s&&n&&this.workbenchRouteProtocolSupported===!0&&(s===this.currentAgent?this.hasCapability("file_reference_resolution")&&this.hasCapability("workbench_session_routes"):Tt(this,s,"file_reference_resolution")&&Tt(this,s,"workbench_session_routes")),o=[...new Set((Array.isArray(e)?e:[]).filter(u=>typeof u=="string"&&u.trim()).map(u=>u.trim()))].slice(0,32);if(!i||o.length===0)return null;let a=this.effectiveWorkDir||"",l=t?{runtimeProvider:t.runtimeProvider,agentId:t.agentId,sessionId:t.sessionId}:null,c=`file_refs_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`;return this.sendWsMessage({type:"resolve_file_references",requestId:c,references:o,agentId:s,conversationId:n,workDir:a,workbenchRoute:l})?c:null},requestMessageImagePreview(e){let t=this.activeSessionRoute,s=t?.agentId||this.currentAgent||null,n=t?.runtimeProvider==="yeaft"?yt(this,t.sessionId,s):this.currentConversation,i=dt(t)&&s&&n&&this.workbenchRouteProtocolSupported===!0&&(s===this.currentAgent?this.hasCapability("file_editor")&&this.hasCapability("workbench_session_routes")&&this.hasCapability("response_image_preview"):Tt(this,s,"file_editor")&&Tt(this,s,"workbench_session_routes")&&Tt(this,s,"response_image_preview")),o=typeof e=="string"?e.trim():"";if(!i||!o)return null;let a=`message_image_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`;return this.sendWsMessage({type:"read_file",requestId:a,filePath:o,responseImagePreview:!0,agentId:s,conversationId:n,workDir:this.effectiveWorkDir||"",workbenchRoute:{runtimeProvider:t.runtimeProvider,agentId:t.agentId,sessionId:t.sessionId}})?a:null},openFileInExplorer(e,{hideTree:t=!1,line:s=null}={}){let n=this.activeSessionRoute,r=n?{runtimeProvider:n.runtimeProvider,agentId:n.agentId,sessionId:n.sessionId}:null,i=dt(r),o=this.effectiveWorkDir||"",a=yn(i,o),l=r?.agentId||this.currentAgent||null,c=r?.runtimeProvider==="yeaft"?yt(this,r.sessionId,l):this.currentConversation,d=this.workbenchRouteProtocolSupported===!0&&(l===this.currentAgent?this.hasCapability("file_editor")&&this.hasCapability("workbench_session_routes"):Tt(this,l,"file_editor")&&Tt(this,l,"workbench_session_routes"));if(!l||!c||!d)return!1;let u=typeof e=="string"?e.trim():"";if(!u)return!1;let p=this.workbenchExpanded;this.openWorkbench(),this.workbenchMaximized=!1,this.rememberWorkbenchPanelState();let f=()=>{let g=dt(this.activeSessionRoute),v=this.effectiveWorkDir||"";g!==i||v!==o||yn(g,v)!==a||window.dispatchEvent(new CustomEvent("open-file-in-explorer",{detail:{filePath:u,agentId:l,conversationId:c,workDir:o,workbenchRoute:r,workbenchRouteKey:i,workspaceGeneration:a,hideTree:!!t,line:Number.isFinite(s)&&s>0?s:null}}))};return p?f():Vue.nextTick(f),!0},logout(){je().logout(),this.authenticated=!1,this.sessionKey=null,this.agents=[],this.currentAgent=null,this.currentAgentInfo=null,this.yeaftStatusByAgent={},this._yeaftRetiredCatalogEpochsByAgent={},this.conversations=[],this.activeConversations=[],this.messagesMap={},this.conversationTitles={},this.customConversationTitles={},this.processingConversations={},this.executionStatusMap={},this.workbenchExpanded=!1,this.workbenchMaximized=!1,this.workbenchPanelStateByRoute={},this.subagents={},this.activeSubagentId=null,this.activeRightPanel=null,this.pinnedSessions=[],this.clearWorkCenterBrowserState(),this.ws&&this.ws.close()}}})});function Ml(e,t){!e||typeof e.handleYeaftOutput!="function"||!t||e.handleYeaftOutput({event:t})}function Bb(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 Rl(e){if(!e)return js[0];let t=String(e).toLowerCase();return Hb[t]||js[Bb(t)%js.length]}function Nb(e){return Rl(e).background}function Wb(e){return Rl(e).foreground}function Pl(){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 jb(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 Fb,js,Hb,qC,ss,Zn=W(()=>{({defineStore:Fb}=Pinia);js=[{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)"}],Hb=Object.freeze({steve:js[8],ada:js[3],linus:js[0],martin:js[4]}),qC=js.map(e=>e.background);ss=Fb("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?Pl().startsWith("zh")&&s.displayNameZh?s.displayNameZh:s.displayName||s.vpId||t:t},vpDescription:e=>t=>jb(e.vps[t],Pl()),vpInitial:e=>t=>{let s=e.vps[t],n=Pl().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:Nb(t)},vpTextColor:()=>e=>Wb(e),vpAvatarMotif:()=>e=>Rl(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(Ml(s,{type:"dream_progress",phase:"start",groupId:e,manual:!0,trigger:"manual",source:"header-button",ts:n}),!s||typeof s.sendWsMessage!="function"){Ml(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&&Ml(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 _l(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 po(e){return!e||typeof e!="object"?0:_l(e.lastMessageAt)||_l(e.updatedAt)||_l(e.createdAt)||0}function Dl(e,t){let s=po(t)-po(e);return s!==0?s:String(e?.id||"").localeCompare(String(t?.id||""))}function nf(e){return[...Array.isArray(e)?e:[]].sort(Dl)}var fo=W(()=>{});function rf(){try{if(typeof localStorage>"u")return{};let e=JSON.parse(localStorage.getItem(cf)||"{}");return e&&typeof e=="object"?e:{}}catch{return{}}}function Ub(e){try{typeof localStorage<"u"&&localStorage.setItem(cf,JSON.stringify(e&&typeof e=="object"?e:{}))}catch{}}function of(){try{return typeof localStorage>"u"?[]:Jr(JSON.parse(localStorage.getItem(df)||"[]"))}catch{return[]}}function Kb(e){try{typeof localStorage<"u"&&localStorage.setItem(df,JSON.stringify(Jr(e)))}catch{}}function uf(e,t){return`${e||""}${t||""}`}function Cs(e){return e&&e.agentId&&e.id?uf(e.agentId,e.id):""}function ns(e,t){return t?e?uf(e,t):String(t):""}function zb(e){return typeof e=="string"?e:String(e||"")}function Vt(e,t,s=null){let n=zb(t);if(!n)return"";let r=ns(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=ei();if(l?.currentAgent){let c=a.find(d=>e.sessions[d]?.agentId===l.currentAgent);if(c)return c}return a[0]||""}function El(e,t,s=null){return Vt(e,t,s)||""}function $l(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 Yb(e){let t=e._preferredExactSessionIdentity||null;if(!t)return!1;e._preferredExactSessionIdentity=null;let s=e.sessions[t.key]||null,n=ei(),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=Ur(localStorage.getItem("lastViewedYeaftSession")||"");o.agentId===t.agentId&&o.sessionId===t.sessionId&&localStorage.removeItem("lastViewedYeaftSession")}catch{}return!0}function go(e){let t=e._retiredBareActiveSessionId||null;if(!t)return!1;let s=ei();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")||"";Ur(r).sessionId===t&&localStorage.removeItem("lastViewedYeaftSession")}catch{}return!0}function Jr(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 Ll(e,t){let s=Jr(e),n=new Set(s),r=Jr(t).filter(o=>n.has(o)),i=new Set(r);return[...r,...s.filter(o=>!i.has(o))]}function ho(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 af(e){return!e||typeof e!="object"?!1:e.running===!0||e.active===!0||e.isActive===!0||e.isRunning===!0}function lf(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 ei(){try{if(typeof window<"u"&&window.Pinia&&typeof window.Pinia.useChatStore=="function")return window.Pinia.useChatStore()}catch{}return null}var cf,df,Gb,pf,ff=W(()=>{fo();to();cf="yeaft-session-order-by-agent",df="yeaft-session-order-global";({defineStore:Gb}=Pinia);pf=Gb("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=ei(),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,p)=>{let f=Number.isFinite(u?.sortOrder)?u.sortOrder:Number.MAX_SAFE_INTEGER,g=Number.isFinite(p?.sortOrder)?p.sortOrder:Number.MAX_SAFE_INTEGER;return f!==g?f-g:Dl(u,p)}),a=[...o(r),...o(i)],l=of();if(l.length===0)return a;let c=new Map(l.map((d,u)=>[d,u]));return a.sort((d,u)=>{let p=c.has(Cs(d))?c.get(Cs(d)):Number.MAX_SAFE_INTEGER,f=c.has(Cs(u))?c.get(Cs(u)):Number.MAX_SAFE_INTEGER;return p!==f?p-f:0})},sessionCount(e){return e.sessionOrder.length},sessionById:e=>(t,s=null)=>{let n=Vt(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){$l(this);let o={...this.sessions},a=new Set;for(let f of n){if(!f||!f.id)continue;let g=ns(t,f.id);a.add(g),o[g]=this._normalize(f,t,ho(this.sessions[g]))}for(let f of this.sessionOrder){let g=this.sessions[f];g&&g.agentId===t&&!a.has(f)&&delete o[f]}let l=this.sessionOrder.filter(f=>o[f]),c=new Set(l),d=[];for(let f of n){if(!f||!f.id)continue;let g=ns(t,f.id);o[g]&&!c.has(g)&&d.push(g)}this.sessions=o;let u=[...l,...d],p=of();if(p.length>0){let f=new Map(u.map(y=>[Cs(o[y]),y]).filter(([y])=>y)),g=p.map(y=>f.get(y)).filter(Boolean),v=new Set(g);u=[...g,...u.filter(y=>!v.has(y))];let m=new Map(p.map((y,h)=>[y,h]));for(let y of u){let h=Cs(o[y]);h&&m.has(h)&&(o[y]={...o[y],sortOrder:m.get(h)})}}if(t&&p.length===0){let f=rf(),g=Jr(f[t]);if(g.length>0){let v=g.map(b=>ns(t,b)),m=new Set(v),y=Ll(u.filter(b=>o[b]?.agentId===t),v),h=this.sessionOrder.some(b=>o[b]?.agentId===t),w=0;h?u=this.sessionOrder.filter(b=>o[b]).map(b=>o[b]?.agentId===t?y[w++]:b).concat(y.slice(w)):u=u.map(b=>o[b]?.agentId===t?y[w++]:b);let S=new Map(v.map((b,k)=>[b,k]));for(let b of y)o[b]&&m.has(b)&&(o[b]={...o[b],sortOrder:S.get(b)})}}this.sessionOrder=u}else{if(this.inventoryIdentityMode==="agent-scoped")return;if(Object.values(this.sessions).some(c=>c&&c.agentId)){this.inventoryIdentityMode="agent-scoped";return}let a={},l=[];for(let c of n){if(!c||!c.id)continue;let d=ns(null,c.id);a[d]=this._normalize(c,null,ho(this.sessions[d])),l.push(d)}this.sessions=a,this.sessionOrder=l,this.inventoryIdentityMode="legacy-bare"}s||(r=Yb(this)||go(this)),this.lastSnapshotAt=Date.now();let i=ei();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?Vt(this,o,t):"",c=l?this.sessions[l]:null,d=c&&(!t||c.agentId===t),u=this.sessionOrder.filter(w=>this.sessions[w]&&(!t||this.sessions[w].agentId===t)&&this.sessions[w].running).sort((w,S)=>lf(this.sessions[S])-lf(this.sessions[w]))[0]||null,p=u?this.sessions[u]?.id:null,f=this.sessionList[0]||null,g=f?.id||null,v=g?Vt(this,g,f?.raw?.agentId||null):"",m=p||(d?c.id:null)||g,y=u||(d?l:"")||v||El(this,m,t),h=this.activeSessionKey?this.sessions[this.activeSessionKey]?.agentId:null;if(this.activeSessionId&&!Vt(this,this.activeSessionId,h)?(this.activeSessionId=m,this.activeSessionKey=y||null):!this.activeSessionId&&this.sessionOrder.length>0&&!this._retiredBareActiveSessionId?(this.activeSessionId=m,this.activeSessionKey=y||null):this.activeSessionId&&(this.activeSessionKey=El(this,this.activeSessionId,h)||this.activeSessionKey),i&&!this._retiredBareActiveSessionId){let w=this.activeSessionId||m,S=null;if((i.yeaftActiveSessionFilter&&!Vt(this,i.yeaftActiveSessionFilter)||!i.yeaftActiveSessionFilter&&w)&&(S=w),S){let b=El(this,S),k=b&&this.sessions[b]?.agentId||null;i.currentView==="yeaft"&&typeof i.setActiveSessionFilter=="function"?i.setActiveSessionFilter(S,{agentId:k,force:!0}):i.yeaftActiveSessionFilter=S,this.activeSessionKey=b||this.activeSessionKey}}}if(i&&typeof i.applyServerPinSnapshot=="function"){let o=new Set;for(let l of n){if(!l||!l.id)continue;let c=ns(t,l.id),d=this.sessions[c];d&&d.pinned&&o.add(l.id)}let a=l=>{let c=Vt(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)$l(this);else if(this.inventoryIdentityMode!=="legacy-bare")return;let r=Vt(this,s,n)||ns(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),go(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},go(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==="copy"||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)?Vt(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)$l(this);else if(this.inventoryIdentityMode!=="legacy-bare")return"";let n=Vt(this,e.id,s)||ns(s,e.id),r=!!this.sessions[n],i=this.sessions[n]||{};return this.sessions[n]={...i,...this._normalize(e,s,ho(i))},r||this.sessionOrder.push(n),go(this),n},setActive(e,t=null){let s=Vt(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=Ll(s,t.map(l=>ns(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=rf(),a=n.map(l=>this.sessions[l]?.id).filter(Boolean);return o[e]=a,Ub(o),a},reorderSessionsGlobally(e){let t=this.sessionOrder.map(a=>Cs(this.sessions[a])).filter(Boolean),s=Ll(t,e);if(s.length===0)return[];let n=new Map(this.sessionOrder.map(a=>[Cs(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=Cs(this.sessions[a]);l&&o.has(l)&&(this.sessions[a]={...this.sessions[a],sortOrder:o.get(l)})}return Kb(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=Vt(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=ns(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:af(e),active:af(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:ho(e,s),sortOrder:Number.isFinite(e.sortOrder)?e.sortOrder:null}}}})});function mo(){return globalThis.crypto?.randomUUID?.()||`browser-${Date.now()}-${Math.random().toString(16).slice(2)}`}function qt(e,t){return`${String(e||"")}\0${String(t||"")}`}function gf(e,t,s,n){return`${qt(e,t)}\0${String(s||"")}\0${String(n||"")}`}function Ol(e,t="Browser Runtime request failed"){return e?.safeError||e?.code||t}function Vl(e){return globalThis.Vue?.markRaw?.(e)||e}var Qb,Xb,Zb,Jb,ew,tw,sw,vo,ql=W(()=>{({defineStore:Qb}=Pinia),Xb=3e4,Zb=60*6e4,Jb=2e4,ew=5e3,tw=60*6e4,sw=256;vo=Qb("browser",{state:()=>({sessions:{},pending:{},peers:{},cancelledPeers:{},errors:{},errorCodes:{},peerDiagnostics:{},runtimeStatus:{},installProgress:{},protocolSupported:null,connectionEpoch:0,lastError:null,_cancelledPeerCleanupTimer:null,_messageListenerInstalled:!1}),actions:{chatStore(){return window.Pinia?.useChatStore?.()||null},installMessageListener(){if(this._messageListenerInstalled||typeof window>"u")return;this._messageListenerInstalled=!0;let e=this.chatStore();this.protocolSupported=e?.browserRuntimeProtocolSupported??null,window.addEventListener("browser-runtime-message",t=>this.handleMessage(t.detail)),window.addEventListener("browser-runtime-transport-reset",()=>this.handleTransportReset())},send(e){if(!this.chatStore()?.sendWsMessage?.(e))throw new Error("Browser Runtime transport unavailable")},beginRequest(e,t,s=Xb){let n=mo();return new Promise((r,i)=>{let o=setTimeout(()=>{delete this.pending[n],i(new Error(`${e} timed out`))},s);this.pending[n]={type:e,resolve:r,reject:i,timer:o,payload:t};try{this.send({type:e,requestId:n,...t})}catch(a){clearTimeout(o),delete this.pending[n],i(a)}})},completeRequest(e,t,s=null){let n=e?this.pending[e]:null;return n?(clearTimeout(n.timer),delete this.pending[e],s?n.reject(s):n.resolve(t),!0):!1},clearCancelledPeers(){clearTimeout(this._cancelledPeerCleanupTimer),this._cancelledPeerCleanupTimer=null,this.cancelledPeers={}},pruneCancelledPeers(e=Date.now()){clearTimeout(this._cancelledPeerCleanupTimer),this._cancelledPeerCleanupTimer=null;for(let[s,n]of Object.entries(this.cancelledPeers))Number(n.expiresAt)<=e&&delete this.cancelledPeers[s];let t=Math.min(...Object.values(this.cancelledPeers).map(s=>Number(s.expiresAt)).filter(Number.isFinite));Number.isFinite(t)&&(this._cancelledPeerCleanupTimer=setTimeout(()=>this.pruneCancelledPeers(),Math.max(1,t-Date.now())))},rememberCancelledPeer(e){let t=Date.now();for(this.pruneCancelledPeers(t);Object.keys(this.cancelledPeers).length>=sw;)delete this.cancelledPeers[Object.keys(this.cancelledPeers)[0]];this.cancelledPeers[gf(e.agentId,e.browserSessionId,e.requestId,e.connectionGeneration)]={agentId:e.agentId,browserSessionId:e.browserSessionId,requestId:e.requestId,connectionGeneration:e.connectionGeneration,expiresAt:t+tw},this.pruneCancelledPeers(t)},takeCancelledPeer(e){let t=gf(e.agentId,e.browserSessionId,e.requestId,e.connectionGeneration),s=this.cancelledPeers[t];return!s||(delete this.cancelledPeers[t],this.pruneCancelledPeers(),Number(s.expiresAt)<=Date.now())?null:s},async getRuntimeStatus(e){let t=await this.beginRequest("browser_runtime_status",{agentId:e});return this.runtimeStatus[e]=t,t},async installRuntime(e,t){let s=await this.beginRequest("browser_runtime_install",{agentId:e,confirmedBuildId:t?.buildId,confirmedDownloadBytes:Number(t?.downloadBytes)||0},Zb);return this.runtimeStatus[e]=s,delete this.installProgress[e],s},async enableRuntime(e){let t=await this.beginRequest("browser_runtime_enable",{agentId:e},6e4);return this.runtimeStatus[e]=t,t},async setupRuntime(e,t){return t?.installed?this.enableRuntime(e):this.installRuntime(e,t)},async createSession({agentId:e,sourceRef:t=null,initialUrl:s="about:blank",viewport:n=null,locale:r="en-US"}){let i=await this.beginRequest("browser_session_create",{agentId:e,sourceRef:t,options:{initialUrl:s,viewport:n||{width:1280,height:720,deviceScaleFactor:1},locale:r,capturePreference:"auto"}},45e3);return this.sessions[qt(e,i.browserSessionId)]=i,i},async listSessions(e){let t=await this.beginRequest("browser_session_list",{agentId:e}),s=new Set((t.sessions||[]).map(n=>qt(e,n.browserSessionId)));for(let n of Object.keys(this.sessions))n.startsWith(`${e}\0`)&&!s.has(n)&&delete this.sessions[n];for(let n of t.sessions||[])this.sessions[qt(e,n.browserSessionId)]={...n,agentId:e};return t.sessions||[]},async closeSession(e,t,s){await this.beginRequest("browser_session_close",{agentId:e,browserSessionId:t,expectedRevision:s})},async attach({agentId:e,browserSessionId:t,videoElement:s}){if(!s)throw new Error("Browser video element required");let n=qt(e,t);delete this.errors[n],delete this.errorCodes[n];let r=Number(this.connectionEpoch||0)+1;this.connectionEpoch=r;let i=mo(),o={localKey:n,agentId:e,browserSessionId:t,requestId:i,peerId:null,connectionGeneration:r,connection:null,videoElement:Vl(s),state:"preparing",remoteState:null,pendingOffer:null,pendingCandidates:[],answerPromise:null,channels:{},controlSeq:0,pointerSeq:0,iceServerCount:null,diagnostics:{connectionState:"new",iceConnectionState:"new",iceGatheringState:"new",candidateErrors:0,lastCandidateError:null},attachTimer:null,disconnectedTimer:null};return this.peers[n]=o,this.peerDiagnostics[n]=o.diagnostics,o.attachTimer=setTimeout(()=>{if(o.attachTimer=null,this.peers[n]!==o||o.connection?.connectionState==="connected")return;let a=o.iceServerCount===0?"browser_ice_servers_missing":o.diagnostics.iceConnectionState==="failed"?"browser_ice_connection_failed":"browser_peer_attach_timeout";this.failPeer(o,new Error(a),a)},Jb),this.send({type:"browser_peer_attach",agentId:e,browserSessionId:t,requestId:i,connectionGeneration:r,role:"interactive",clientCapabilities:{codecs:["video/VP8"],maxWidth:1920,maxHeight:1080,maxFps:30}}),o},async preparePeer(e,t){if(this.peers[e.localKey]!==e||e.connectionGeneration!==t.connectionGeneration)return;if(e.connection){if(e.peerId===t.peerId)return;throw new Error("Browser peer identity changed during preparation")}e.peerId=t.peerId;let s=Array.isArray(t.iceServers)?t.iceServers:[];e.iceServerCount=s.length;let n=Vl(new RTCPeerConnection({iceServers:s,iceTransportPolicy:t.iceTransportPolicy==="relay"?"relay":"all"}));e.connection=n,e.diagnostics.iceConnectionState=n.iceConnectionState||"new",e.diagnostics.iceGatheringState=n.iceGatheringState||"new",e.state="prepared",n.ondatachannel=i=>{if(this.peers[e.localKey]!==e)return;let o=i.channel;if(!["browser.control.v1","browser.pointer.v1","browser.state.v1"].includes(o?.label)){o?.close?.();return}e.channels[o.label]=Vl(o),o.onclose=()=>{e.channels[o.label]===o&&delete e.channels[o.label]}},n.ontrack=i=>{this.peers[e.localKey]===e&&(e.videoElement.srcObject=i.streams[0]||new MediaStream([i.track]),e.videoElement.play().catch(()=>{}))},n.onicecandidate=i=>{if(this.peers[e.localKey]===e)try{this.send({type:"browser_peer_ice_candidate",agentId:e.agentId,browserSessionId:e.browserSessionId,peerId:e.peerId,connectionGeneration:e.connectionGeneration,candidate:i.candidate?i.candidate.toJSON():null})}catch{}},n.onicecandidateerror=i=>{this.peers[e.localKey]===e&&(e.diagnostics.candidateErrors+=1,e.diagnostics.lastCandidateError={address:typeof i.address=="string"?i.address:null,port:Number(i.port)||null,url:typeof i.url=="string"?i.url:null,errorCode:Number(i.errorCode)||null,errorText:typeof i.errorText=="string"?i.errorText.slice(0,256):null})},n.oniceconnectionstatechange=()=>{this.peers[e.localKey]===e&&(e.diagnostics.iceConnectionState=n.iceConnectionState||"new")},n.onicegatheringstatechange=()=>{this.peers[e.localKey]===e&&(e.diagnostics.iceGatheringState=n.iceGatheringState||"new")},n.onconnectionstatechange=()=>{if(this.peers[e.localKey]===e){if(e.state=n.connectionState,e.diagnostics.connectionState=n.connectionState||"new",e.diagnostics.iceConnectionState=n.iceConnectionState||"new",e.diagnostics.iceGatheringState=n.iceGatheringState||"new",n.connectionState==="connected"){clearTimeout(e.attachTimer),e.attachTimer=null,clearTimeout(e.disconnectedTimer),e.disconnectedTimer=null;return}if(n.connectionState==="disconnected"){e.disconnectedTimer||(e.disconnectedTimer=setTimeout(()=>{if(e.disconnectedTimer=null,this.peers[e.localKey]!==e||n.connectionState==="connected")return;let i=e.iceServerCount===0?"browser_ice_servers_missing":"browser_ice_connection_failed";this.failPeer(e,new Error(i),i)},ew));return}if(["failed","closed"].includes(n.connectionState)){let i=e.iceServerCount===0?"browser_ice_servers_missing":"browser_ice_connection_failed";this.failPeer(e,new Error(i),i)}}};let r=e.pendingOffer;e.pendingOffer=null,r&&await this.acceptOffer(e,r)},async acceptOffer(e,t){if(!(this.peers[e.localKey]!==e||e.connectionGeneration!==Number(t.connectionGeneration))){if(!e.connection){(!e.peerId||e.peerId===t.peerId)&&(e.pendingOffer||(e.pendingOffer=t));return}if(e.peerId===t.peerId){if(e.answerPromise)return e.answerPromise;e.answerPromise=(async()=>{if(await e.connection.setRemoteDescription(t.description),await e.connection.setLocalDescription(await e.connection.createAnswer()),this.peers[e.localKey]===e){this.send({type:"browser_peer_answer",agentId:e.agentId,browserSessionId:e.browserSessionId,peerId:e.peerId,connectionGeneration:e.connectionGeneration,description:e.connection.localDescription});for(let s of e.pendingCandidates.splice(0))await e.connection.addIceCandidate(s)}})();try{await e.answerPromise}finally{e.answerPromise=null}}}},async acceptCandidate(e,t){if(!(this.peers[e.localKey]!==e||e.connectionGeneration!==Number(t.connectionGeneration)||!t.candidate)){if(!e.connection){(!e.peerId||e.peerId===t.peerId)&&e.pendingCandidates.push(t.candidate);return}e.peerId===t.peerId&&(e.connection.remoteDescription?await e.connection.addIceCandidate(t.candidate):e.pendingCandidates.push(t.candidate))}},interactiveReady(e,t){let s=this.peers[qt(e,t)];return s?.state==="connected"&&s.channels["browser.control.v1"]?.readyState==="open"&&s.channels["browser.pointer.v1"]?.readyState==="open"},sendControl(e,t,s){let n=this.peers[qt(e,t)],r=n?.channels["browser.control.v1"];return!n||n.state!=="connected"||r?.readyState!=="open"?!1:(r.send(JSON.stringify({version:1,connectionGeneration:n.connectionGeneration,controlSeq:++n.controlSeq,action:s})),!0)},sendPointer(e,t,s){let n=this.peers[qt(e,t)],r=n?.channels["browser.pointer.v1"];return!n||n.state!=="connected"||r?.readyState!=="open"?!1:(r.send(JSON.stringify({version:1,connectionGeneration:n.connectionGeneration,pointerSeq:++n.pointerSeq,action:s})),!0)},detach(e,t,{notify:s=!0}={}){let n=qt(e,t),r=this.peers[n];if(r){if(delete this.peers[n],clearTimeout(r.attachTimer),r.attachTimer=null,clearTimeout(r.disconnectedTimer),r.disconnectedTimer=null,s&&!r.peerId&&this.rememberCancelledPeer(r),s&&r.peerId)try{this.send({type:"browser_peer_detach",requestId:mo(),agentId:e,browserSessionId:t,peerId:r.peerId,connectionGeneration:r.connectionGeneration})}catch{}this.errorCodes[n]||delete this.peerDiagnostics[n];for(let i of Object.values(r.channels||{}))try{i?.close?.()}catch{}r.channels={};try{r.connection?.close()}catch{}r.videoElement&&(r.videoElement.srcObject=null)}},failPeer(e,t,s=null){this.peers[e.localKey]===e&&(this.lastError=t?.message||String(t),this.errors[e.localKey]=this.lastError,s?this.errorCodes[e.localKey]=s:delete this.errorCodes[e.localKey],this.detach(e.agentId,e.browserSessionId,{notify:!0}))},handleTransportReset(){this.protocolSupported=null,this.connectionEpoch+=1;for(let e of Object.values(this.pending))clearTimeout(e.timer),e.reject(new Error("Browser Runtime connection changed"));this.pending={};for(let e of Object.values(this.peers))this.detach(e.agentId,e.browserSessionId,{notify:!1});this.peers={},this.runtimeStatus={},this.installProgress={},this.errors={},this.errorCodes={},this.peerDiagnostics={},this.clearCancelledPeers()},handleMessage(e){if(!e?.type)return;if(e.type==="client_hello_ack"){this.protocolSupported=e.browserRuntimeProtocol===1;return}if(e.type==="auth_result"){this.protocolSupported=!1;return}if(e.type==="browser_runtime_error"){let n=new Error(Ol(e));n.code=e.code,this.completeRequest(e.requestId,null,n)||(this.lastError=n.message);return}if(e.type==="browser_runtime_install_progress"){this.installProgress[e.agentId]={downloadedBytes:Number(e.downloadedBytes)||0,totalBytes:Number(e.totalBytes)||0};return}if(e.type==="browser_runtime_status_result"){this.runtimeStatus[e.agentId]=e,this.completeRequest(e.requestId,e),e.state!=="installing"&&delete this.installProgress[e.agentId];return}if(e.type==="browser_session_error"){let n=new Error(Ol(e));n.code=e.code,this.completeRequest(e.requestId,null,n)||(this.lastError=n.message);return}if(e.type==="browser_session_created"){this.sessions[qt(e.agentId,e.browserSessionId)]=e,this.completeRequest(e.requestId,e);return}if(e.type==="browser_session_list_result"){this.completeRequest(e.requestId,e);return}if(e.type==="browser_session_snapshot"){let n=qt(e.agentId,e.browserSessionId);this.sessions[n]=e,this.completeRequest(e.requestId,e),["closed","failed"].includes(e.state)&&this.detach(e.agentId,e.browserSessionId,{notify:!1});return}let t=qt(e.agentId,e.browserSessionId),s=this.peers[t];if(!s||s.connectionGeneration!==Number(e.connectionGeneration)){if(e.type==="browser_peer_prepared"||e.type==="browser_peer_error"||e.type==="browser_peer_state"&&["failed","disconnected","closed"].includes(e.state)){let n=this.takeCancelledPeer(e);if(n&&e.type==="browser_peer_prepared")try{this.send({type:"browser_peer_detach",requestId:mo(),agentId:n.agentId,browserSessionId:n.browserSessionId,peerId:e.peerId,connectionGeneration:n.connectionGeneration})}catch{}}return}if(e.type==="browser_peer_error")this.failPeer(s,new Error(Ol(e,"Browser peer failed")),e.code||null);else if(e.type==="browser_peer_prepared")this.preparePeer(s,e).catch(n=>this.failPeer(s,n));else if(e.type==="browser_peer_offer")this.acceptOffer(s,e).catch(n=>this.failPeer(s,n));else if(e.type==="browser_peer_ice_candidate")this.acceptCandidate(s,e).catch(n=>this.failPeer(s,n));else if(e.type==="browser_peer_state"&&e.state&&(s.remoteState=e.state,["failed","disconnected","closed"].includes(e.state))){let n=s.iceServerCount===0?"browser_ice_servers_missing":"browser_ice_connection_failed";this.failPeer(s,new Error(n),n)}}}})});function yo(){try{if(window.Pinia&&typeof window.Pinia.useAuthStore=="function")return window.Pinia.useAuthStore()}catch{}return null}function Fl(){try{return localStorage.getItem("authToken")||null}catch{return null}}function vf(){let e=yo();if(e)try{return e.getActiveToken?.()||e.token||Fl()}catch{return e.token||Fl()}return Fl()}function rw(e,t){if(!e)return!1;let s=vf();if(s&&s!==t)return!1;try{localStorage.setItem("authToken",e)}catch{}let n=yo();return n&&(n.token=e),!0}function iw(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 mf(e){return!e||typeof window>"u"||!window.location?!1:e.origin===window.location.origin&&e.pathname.startsWith("/api/")}function ow(e){if(!e)return!1;let t=e.pathname;return!!(nw.has(t)||t.startsWith("/api/auth/sso/poll/")||/^\/api\/auth\/sso\/[^/]+\/start(?:-qr)?$/.test(t))}function aw(e,t){return t?.headers?new Headers(t.headers):e&&typeof e=="object"&&e.headers?new Headers(e.headers):new Headers}function lw(e){let t=e.get("Authorization");return!t||!t.startsWith("Bearer ")?null:t.slice(7)}function cw(e,t){return{...e||{},headers:t}}function dw(e,t,s,n){let r=yo();r&&typeof r.handleAuthResponse=="function"?r.handleAuthResponse(e,t,s,n):r&&typeof r.handleAuthFailure=="function"&&n&&r.handleAuthFailure(void 0,t,s)}function yf(){if(hf||typeof window>"u"||!window.fetch)return;hf=!0;let e=window.fetch.bind(window);window.fetch=async function(s,n){let r=iw(s),i=mf(r)&&!ow(r),o=mf(r)?{...n||{},credentials:"same-origin"}:n,a=null,l=i?yo():null,c=l?.authGeneration,d=!!l?.isAuthenticated;if(i){let p=aw(s,n);a=lw(p),a||(a=vf(),a&&(p.set("Authorization",`Bearer ${a}`),o=cw(o,p)))}let u=await e(s,o);try{let p=u.headers&&u.headers.get&&u.headers.get("X-New-Token");p&&rw(p,a),i&&u.status===401&&dw(u,a,c,d)}catch{}return u}}var hf,nw,bf=W(()=>{hf=!1,nw=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 wf,kf,Hl=W(()=>{wf={"quickSend.title":"Quick send","quickSend.description":"Add up to 5 send buttons for this Agent. Each sends your current message with its model and optional turn overrides.","quickSend.empty":"No quick sends configured. No extra send buttons are shown.","quickSend.offline":"This Agent is offline. Reconnect to load or save quick sends.","quickSend.entry":"Quick send {index}","quickSend.name":"Button name","quickSend.model":"Model","quickSend.chooseModel":"Choose a model","quickSend.noModels":"Configure models in the LLM category first.","quickSend.effort":"Reasoning effort","quickSend.maxOutputTokens":"Maximum output tokens","quickSend.default":"Default","quickSend.outputLimit":"Leave blank to use the model default: {max} tokens (also the maximum).","quickSend.add":"Add quick send","quickSend.remove":"Remove","quickSend.limit":"Maximum 5 quick sends.","quickSend.nameRequired":"Enter a button name (1\u201380 characters).","quickSend.modelRequired":"Choose an available model for each quick send.","quickSend.effortInvalid":"The selected effort is not available for this model.","quickSend.outputInvalid":"Output tokens must be a positive integer no greater than {max}.","quickSend.loadFailed":"Could not load quick sends. Refresh to retry.","quickSend.saveFailed":"Save was not confirmed. Refresh to check the saved configuration before retrying.","quickSend.saved":"Quick sends saved.","quickSend.savedRefreshWarning":"Quick sends saved, but runtime refresh failed: {error}"},kf={"quickSend.title":"\u5FEB\u6377\u53D1\u9001","quickSend.description":"\u4E3A\u6B64 Agent \u6DFB\u52A0\u6700\u591A 5 \u4E2A\u53D1\u9001\u6309\u94AE\u3002\u4F7F\u7528\u6307\u5B9A\u6A21\u578B\u548C\u53EF\u9009\u7684\u5355\u8F6E\u53C2\u6570\u53D1\u9001\u5F53\u524D\u6D88\u606F\u3002","quickSend.empty":"\u5C1A\u672A\u914D\u7F6E\u5FEB\u6377\u53D1\u9001\uFF0C\u4E0D\u4F1A\u663E\u793A\u989D\u5916\u7684\u53D1\u9001\u6309\u94AE\u3002","quickSend.offline":"\u6B64 Agent \u5DF2\u79BB\u7EBF\u3002\u91CD\u65B0\u8FDE\u63A5\u540E\u53EF\u52A0\u8F7D\u6216\u4FDD\u5B58\u5FEB\u6377\u53D1\u9001\u3002","quickSend.entry":"\u5FEB\u6377\u53D1\u9001 {index}","quickSend.name":"\u6309\u94AE\u540D\u79F0","quickSend.model":"\u6A21\u578B","quickSend.chooseModel":"\u9009\u62E9\u6A21\u578B","quickSend.noModels":"\u8BF7\u5148\u5728\u6A21\u578B\u914D\u7F6E\u5206\u7C7B\u4E2D\u6DFB\u52A0\u6A21\u578B\u3002","quickSend.effort":"\u63A8\u7406\u5F3A\u5EA6","quickSend.maxOutputTokens":"\u6700\u5927\u8F93\u51FA Token \u6570","quickSend.default":"\u9ED8\u8BA4","quickSend.outputLimit":"\u7559\u7A7A\u4F7F\u7528\u6A21\u578B\u9ED8\u8BA4\u503C\uFF1A{max} Token\uFF08\u4E5F\u662F\u53EF\u8BBE\u7F6E\u7684\u4E0A\u9650\uFF09\u3002","quickSend.add":"\u6DFB\u52A0\u5FEB\u6377\u53D1\u9001","quickSend.remove":"\u5220\u9664","quickSend.limit":"\u6700\u591A\u6DFB\u52A0 5 \u4E2A\u5FEB\u6377\u53D1\u9001\u3002","quickSend.nameRequired":"\u8BF7\u8F93\u5165\u6309\u94AE\u540D\u79F0\uFF081\u201380 \u4E2A\u5B57\u7B26\uFF09\u3002","quickSend.modelRequired":"\u8BF7\u4E3A\u6BCF\u4E2A\u5FEB\u6377\u53D1\u9001\u9009\u62E9\u53EF\u7528\u6A21\u578B\u3002","quickSend.effortInvalid":"\u6B64\u6A21\u578B\u4E0D\u652F\u6301\u6240\u9009\u63A8\u7406\u5F3A\u5EA6\u3002","quickSend.outputInvalid":"\u8F93\u51FA Token \u6570\u5FC5\u987B\u4E3A\u4E0D\u8D85\u8FC7 {max} \u7684\u6B63\u6574\u6570\u3002","quickSend.loadFailed":"\u65E0\u6CD5\u52A0\u8F7D\u5FEB\u6377\u53D1\u9001\uFF0C\u8BF7\u5237\u65B0\u91CD\u8BD5\u3002","quickSend.saveFailed":"\u5C1A\u672A\u786E\u8BA4\u4FDD\u5B58\u3002\u8BF7\u5148\u5237\u65B0\u68C0\u67E5\u5DF2\u4FDD\u5B58\u7684\u914D\u7F6E\uFF0C\u518D\u51B3\u5B9A\u662F\u5426\u91CD\u8BD5\u3002","quickSend.saved":"\u5FEB\u6377\u53D1\u9001\u5DF2\u4FDD\u5B58\u3002","quickSend.savedRefreshWarning":"\u5FEB\u6377\u53D1\u9001\u5DF2\u4FDD\u5B58\uFF0C\u4F46\u8FD0\u884C\u65F6\u5237\u65B0\u5931\u8D25\uFF1A{error}"}});var Sf,If,Bl=W(()=>{Sf={"userShortcuts.title":"Keyboard shortcuts","userShortcuts.scope":"These are your user preferences, stored only in this browser for this account. They do not sync across devices.","userShortcuts.showQuickSends":"Enable quick-send shortcuts","userShortcuts.quickSendHelp":"Preset names and request settings are configured in Agent settings. Quick-send shortcuts only work while the message composer is focused.","userShortcuts.help":"Shortcuts use simple Alt + key defaults. Click a binding to replace it, or clear it to disable the action. Escape cancels; Tab moves on. Global actions stay available while the message composer is focused, and never run in dialogs, other text fields, editors or terminals.","userShortcuts.suggestion":"Suggestion: {binding}","userShortcuts.recording":"Press a shortcut\u2026","userShortcuts.unbound":"Not bound","userShortcuts.clear":"Clear","userShortcuts.clearAction":"Clear shortcut for {action}","userShortcuts.reset":"Reset shortcuts and hide buttons","userShortcuts.action.terminal":"Open terminal","userShortcuts.action.files":"Open files","userShortcuts.action.git":"Open Git","userShortcuts.action.newSession":"New session","userShortcuts.action.closeWorkbench":"Close workbench","userShortcuts.action.quickSend1":"Quick send 1","userShortcuts.action.quickSend2":"Quick send 2","userShortcuts.action.quickSend3":"Quick send 3","userShortcuts.action.quickSend4":"Quick send 4","userShortcuts.action.quickSend5":"Quick send 5","userShortcuts.error.invalid":"Use Ctrl, Meta or Alt with a letter or number; Shift is optional.","userShortcuts.error.reserved":"This combination conflicts with a browser or existing app shortcut.","userShortcuts.error.conflict":"This shortcut is already assigned to {action}. Clear it there first.","userShortcuts.error.storage":"Could not save preferences in this browser. Check browser storage permissions.","userShortcuts.error.unauthenticated":"Sign in before saving your shortcuts."},If={"userShortcuts.title":"\u952E\u76D8\u5FEB\u6377\u952E","userShortcuts.scope":"\u8FD9\u662F\u4F60\u7684\u7528\u6237\u504F\u597D\uFF0C\u6309\u5F53\u524D\u8D26\u53F7\u4EC5\u4FDD\u5B58\u5728\u6B64\u6D4F\u89C8\u5668\u4E2D\uFF0C\u4E0D\u8DE8\u8BBE\u5907\u540C\u6B65\u3002","userShortcuts.showQuickSends":"\u542F\u7528\u5FEB\u6377\u53D1\u9001\u5FEB\u6377\u952E","userShortcuts.quickSendHelp":"\u9884\u8BBE\u540D\u79F0\u4E0E\u8BF7\u6C42\u53C2\u6570\u5728 Agent \u8BBE\u7F6E\u4E2D\u914D\u7F6E\u3002\u5FEB\u6377\u53D1\u9001\u6309\u952E\u4EC5\u5728\u6D88\u606F\u8F93\u5165\u6846\u83B7\u5F97\u7126\u70B9\u65F6\u751F\u6548\u3002","userShortcuts.help":"\u9ED8\u8BA4\u4F7F\u7528\u7B80\u5355\u7684 Alt + \u5355\u952E\u3002\u70B9\u51FB\u7ED1\u5B9A\u6309\u94AE\u53EF\u66FF\u6362\uFF0C\u6E05\u9664\u540E\u53EF\u505C\u7528\u8BE5\u64CD\u4F5C\u3002Escape \u53D6\u6D88\uFF0CTab \u79FB\u81F3\u4E0B\u4E00\u9879\u3002\u6D88\u606F\u8F93\u5165\u6846\u83B7\u5F97\u7126\u70B9\u65F6\u4ECD\u53EF\u4F7F\u7528\u5168\u5C40\u52A8\u4F5C\uFF1B\u5F39\u7A97\u3001\u5176\u4ED6\u8F93\u5165\u6846\u3001\u7F16\u8F91\u5668\u4E0E\u7EC8\u7AEF\u4E2D\u7684\u6309\u952E\u4E0D\u4F1A\u88AB\u62A2\u5360\u3002","userShortcuts.suggestion":"\u63A8\u8350\uFF1A{binding}","userShortcuts.recording":"\u8BF7\u6309\u4E0B\u7EC4\u5408\u952E\u2026","userShortcuts.unbound":"\u672A\u7ED1\u5B9A","userShortcuts.clear":"\u6E05\u9664","userShortcuts.clearAction":"\u6E05\u9664\u201C{action}\u201D\u5FEB\u6377\u952E","userShortcuts.reset":"\u91CD\u7F6E\u5FEB\u6377\u952E\u5E76\u9690\u85CF\u6309\u94AE","userShortcuts.action.terminal":"\u6253\u5F00\u7EC8\u7AEF","userShortcuts.action.files":"\u6253\u5F00\u6587\u4EF6","userShortcuts.action.git":"\u6253\u5F00 Git","userShortcuts.action.newSession":"\u65B0\u5EFA\u4F1A\u8BDD","userShortcuts.action.closeWorkbench":"\u5173\u95ED\u5DE5\u4F5C\u53F0","userShortcuts.action.quickSend1":"\u5FEB\u6377\u53D1\u9001 1","userShortcuts.action.quickSend2":"\u5FEB\u6377\u53D1\u9001 2","userShortcuts.action.quickSend3":"\u5FEB\u6377\u53D1\u9001 3","userShortcuts.action.quickSend4":"\u5FEB\u6377\u53D1\u9001 4","userShortcuts.action.quickSend5":"\u5FEB\u6377\u53D1\u9001 5","userShortcuts.error.invalid":"\u8BF7\u4F7F\u7528 Ctrl\u3001Meta \u6216 Alt \u642D\u914D\u5B57\u6BCD\u6216\u6570\u5B57\uFF0C\u53EF\u52A0 Shift\u3002","userShortcuts.error.reserved":"\u8BE5\u7EC4\u5408\u4E0E\u6D4F\u89C8\u5668\u6216\u5E94\u7528\u5DF2\u6709\u5FEB\u6377\u952E\u51B2\u7A81\u3002","userShortcuts.error.conflict":"\u8BE5\u7EC4\u5408\u5DF2\u7ED1\u5B9A\u201C{action}\u201D\uFF0C\u8BF7\u5148\u6E05\u9664\u539F\u7ED1\u5B9A\u3002","userShortcuts.error.storage":"\u65E0\u6CD5\u5728\u6B64\u6D4F\u89C8\u5668\u4FDD\u5B58\u504F\u597D\uFF0C\u8BF7\u68C0\u67E5\u6D4F\u89C8\u5668\u5B58\u50A8\u6743\u9650\u3002","userShortcuts.error.unauthenticated":"\u8BF7\u5148\u767B\u5F55\u518D\u4FDD\u5B58\u5FEB\u6377\u952E\u3002"}});var Cf,Af=W(()=>{Hl();Bl();Cf={...kf,...If,"quickSend.composer.label":"\u5FEB\u6377\u53D1\u9001","quickSend.composer.send":"\u5FEB\u6377\u53D1\u9001 {number}\uFF1A{name}","common.loading":"\u52A0\u8F7D\u4E2D...","common.confirm":"\u786E\u5B9A","common.apply":"\u5E94\u7528","common.cancel":"\u53D6\u6D88","common.delete":"\u5220\u9664","common.copy":"\u590D\u5236","common.copied":"\u5DF2\u590D\u5236","common.close":"\u5173\u95ED","common.refresh":"\u5237\u65B0","common.open":"\u6253\u5F00","common.save":"\u4FDD\u5B58","common.saving":"\u4FDD\u5B58\u4E2D...","common.search":"\u641C\u7D22","common.back":"\u8FD4\u56DE","common.noSubdirectories":"\u65E0\u5B50\u76EE\u5F55","common.drives":"\u9A71\u52A8\u5668","common.rootDir":"\u6839\u76EE\u5F55","common.comma":"\uFF0C","common.select":"\u9009\u62E9","common.retry":"\u91CD\u8BD5","mermaid.export":"\u5BFC\u51FA","mermaid.exportMd":"\u5BFC\u51FA MD","mermaid.exportPng":"\u5BFC\u51FA PNG","mermaid.exportJpg":"\u5BFC\u51FA JPG","login.subtitle":"Yeaft Web Code Agent","login.username":"\u7528\u6237\u540D","login.password":"\u5BC6\u7801","login.login":"\u767B\u5F55","login.loggingIn":"\u767B\u5F55\u4E2D...","login.enterUsername":"\u8BF7\u8F93\u5165\u7528\u6237\u540D","login.enterPassword":"\u8BF7\u8F93\u5165\u5BC6\u7801","login.noAccount":"\u6CA1\u6709\u8D26\u53F7\uFF1F","login.registerWithCode":"\u6CE8\u518C\u65B0\u8D26\u53F7","login.or":"\u6216","login.usePassword":"\u4F7F\u7528\u8D26\u53F7\u5BC6\u7801\u767B\u5F55","login.useSso":"\u8FD4\u56DE\u5355\u70B9\u767B\u5F55","login.noProviders":"\u7BA1\u7406\u5458\u5C1A\u672A\u542F\u7528\u4EFB\u4F55\u7B2C\u4E09\u65B9\u767B\u5F55\u3002","login.microsoft":"\u4F7F\u7528 Microsoft \u8D26\u53F7\u767B\u5F55","login.github":"\u4F7F\u7528 GitHub \u8D26\u53F7\u767B\u5F55","login.google":"\u4F7F\u7528 Google \u8D26\u53F7\u767B\u5F55","login.wechat":"\u4F7F\u7528\u5FAE\u4FE1\u626B\u7801\u767B\u5F55","login.alipay":"\u4F7F\u7528\u652F\u4ED8\u5B9D\u8D26\u53F7\u767B\u5F55","login.wechat.mobileUnsupported":"\u5FAE\u4FE1\u767B\u5F55\u6682\u4EC5\u652F\u6301\u7535\u8111\u7AEF\uFF0C\u8BF7\u5728\u7535\u8111\u6D4F\u89C8\u5668\u4E2D\u626B\u7801\u767B\u5F55\u3002","login.alipay.mobileWaiting":"\u6B63\u5728\u7B49\u5F85\u4F60\u5728\u652F\u4ED8\u5B9D\u4E2D\u786E\u8BA4\u2026 \u5B8C\u6210\u540E\u8FD4\u56DE\u672C\u9875\u9762\u5C06\u81EA\u52A8\u767B\u5F55\u3002","login.alipay.relaunch":"\u91CD\u65B0\u6253\u5F00\u652F\u4ED8\u5B9D","login.qr.title":"\u626B\u7801\u767B\u5F55","login.qr.titleAlipay":"\u652F\u4ED8\u5B9D\u626B\u7801\u767B\u5F55","login.qr.titleWechat":"\u5FAE\u4FE1\u626B\u7801\u767B\u5F55","login.qr.hint":"\u8BF7\u4F7F\u7528\u624B\u673A\u626B\u63CF\u4E8C\u7EF4\u7801\u5B8C\u6210\u6388\u6743","login.error.enterUsername":"\u8BF7\u8F93\u5165\u7528\u6237\u540D","login.error.enterPassword":"\u8BF7\u8F93\u5165\u5BC6\u7801","login.error.enter6Digit":"\u8BF7\u8F93\u51656\u4F4D\u9A8C\u8BC1\u7801","login.error.enterInviteCode":"\u8BF7\u8F93\u5165\u9080\u8BF7\u7801","login.error.usernameMinLen":"\u7528\u6237\u540D\u81F3\u5C112\u4E2A\u5B57\u7B26","login.error.passwordMinLen":"\u5BC6\u7801\u81F3\u5C116\u4F4D","login.error.passwordMismatch":"\u4E24\u6B21\u5BC6\u7801\u4E0D\u4E00\u81F4","login.error.enterVerifyCode":"\u8BF7\u8F93\u5165\u9A8C\u8BC1\u7801","login.error.loginFailed":"\u767B\u5F55\u5931\u8D25","login.forgot.link":"\u5FD8\u8BB0\u5BC6\u7801\uFF1F","login.forgot.title":"\u91CD\u7F6E\u5BC6\u7801","login.forgot.emailHint":"\u8F93\u5165\u8D26\u6237\u7ED1\u5B9A\u7684\u90AE\u7BB1\uFF0C\u6211\u4EEC\u5C06\u53D1\u9001 6 \u4F4D\u91CD\u7F6E\u9A8C\u8BC1\u7801\u3002","login.forgot.sendCode":"\u53D1\u9001\u91CD\u7F6E\u9A8C\u8BC1\u7801","login.forgot.sending":"\u53D1\u9001\u4E2D...","login.forgot.codeSent":"\u5982\u679C\u90AE\u7BB1\u5DF2\u6CE8\u518C\uFF0C\u91CD\u7F6E\u9A8C\u8BC1\u7801\u5DF2\u53D1\u9001\u3002\u8BF7\u5728\u4E0B\u65B9\u8F93\u5165\u9A8C\u8BC1\u7801\u4E0E\u65B0\u5BC6\u7801\u3002","login.forgot.resetBtn":"\u91CD\u7F6E\u5BC6\u7801","login.forgot.resetting":"\u91CD\u7F6E\u4E2D...","login.forgot.success":"\u5BC6\u7801\u5DF2\u91CD\u7F6E\uFF0C\u53EF\u4EE5\u4F7F\u7528\u65B0\u5BC6\u7801\u767B\u5F55\u3002","login.forgot.emailInvalid":"\u8BF7\u8F93\u5165\u6709\u6548\u7684\u90AE\u7BB1","login.register.title":"\u65B0\u7528\u6237\u6CE8\u518C","login.register.inviteCode":"\u9080\u8BF7\u7801","login.register.username":"\u7528\u6237\u540D","login.register.password":"\u5BC6\u7801\uFF08\u81F3\u5C116\u4F4D\uFF09","login.register.confirmPassword":"\u786E\u8BA4\u5BC6\u7801","login.register.email":"\u90AE\u7BB1\uFF08\u53EF\u9009\uFF09","login.register.submit":"\u6CE8\u518C","login.register.submitting":"\u6CE8\u518C\u4E2D...","login.register.back":"\u8FD4\u56DE\u767B\u5F55","login.register.success":"\u6CE8\u518C\u6210\u529F\uFF0C\u8BF7\u767B\u5F55","login.register.enterCode":"\u8BF7\u8F93\u5165\u9080\u8BF7\u7801","login.register.usernameMin":"\u7528\u6237\u540D\u81F3\u5C112\u4E2A\u5B57\u7B26","login.register.passwordMin":"\u5BC6\u7801\u81F3\u5C116\u4F4D","login.register.passwordMismatch":"\u4E24\u6B21\u5BC6\u7801\u4E0D\u4E00\u81F4","login.totp.setupTitle":"\u8BBE\u7F6E\u53CC\u56E0\u7D20\u8BA4\u8BC1","login.totp.setupHint":"\u4F7F\u7528 Microsoft Authenticator \u6216 Google Authenticator \u626B\u63CF\u4E0B\u65B9\u4E8C\u7EF4\u7801","login.totp.manualKey":"\u6216\u624B\u52A8\u8F93\u5165\u5BC6\u94A5\uFF1A","login.totp.enterCode":"\u8F93\u51656\u4F4D\u9A8C\u8BC1\u7801","login.totp.complete":"\u5B8C\u6210\u8BBE\u7F6E","login.totp.verifying":"\u9A8C\u8BC1\u4E2D...","login.totp.verify":"\u9A8C\u8BC1","login.totp.prompt":"\u8BF7\u8F93\u5165 Authenticator \u5E94\u7528\u4E2D\u7684\u9A8C\u8BC1\u7801","login.totp.invalidCode":"\u8BF7\u8F93\u51656\u4F4D\u9A8C\u8BC1\u7801","login.email.codeSent":"\u9A8C\u8BC1\u7801\u5DF2\u53D1\u9001\u81F3 {email}","login.email.enterCode":"\u8F93\u5165\u9A8C\u8BC1\u7801","login.email.verify":"\u9A8C\u8BC1","login.email.verifying":"\u9A8C\u8BC1\u4E2D...","login.email.enterCodeError":"\u8BF7\u8F93\u5165\u9A8C\u8BC1\u7801","chat.agent.select":"\u9009\u62E9 Agent","chat.agent.manage":"\u7BA1\u7406 Agent","chat.agent.count":"{count} agents","chat.agent.none":"\u6682\u65E0 Agent","chat.agent.restarting":"\u91CD\u542F\u4E2D","agentSettings.open":"Agent \u8BBE\u7F6E","agentSettings.manage":"\u7BA1\u7406","agentSettings.eyebrow":"\u672C\u5730\u8FD0\u884C\u65F6","agentSettings.title":"Agent \u8BBE\u7F6E","agentSettings.description":"\u6309 Agent \u67E5\u770B\u548C\u914D\u7F6E\u672C\u5730\u8FD0\u884C\u65F6\uFF0C\u4E0D\u518D\u628A\u8FD0\u884C\u63A7\u5236\u6DF7\u5165\u8D26\u6237\u8BBE\u7F6E\u3002","agentSettings.agentList":"Agent","agentSettings.categories":"Agent \u8BBE\u7F6E\u5206\u7C7B","agentSettings.categories.operations":"\u64CD\u4F5C","agentSettings.categories.trace":"Trace","agentSettings.categories.llm":"LLM \u914D\u7F6E","agentSettings.selectedAgent":"\u5F53\u524D Agent","agentSettings.online":"\u5728\u7EBF","agentSettings.offline":"\u79BB\u7EBF","agentSettings.empty":"\u6682\u65E0\u53EF\u7528 Agent\u3002","agentSettings.runtime.title":"\u8FD0\u884C\u65F6","agentSettings.runtime.description":"\u8EAB\u4EFD\u3001\u5DE5\u4F5C\u76EE\u5F55\u548C\u672C\u5730\u540E\u53F0\u5904\u7406\u3002","agentSettings.runtime.version":"\u7248\u672C","agentSettings.runtime.updateAvailable":"\u53EF\u66F4\u65B0\u81F3 v{version}","agentSettings.runtime.updateUnknown":"\u65E0\u6CD5\u83B7\u53D6\u66F4\u65B0\u72B6\u6001","agentSettings.runtime.workDir":"\u5DE5\u4F5C\u76EE\u5F55","agentSettings.telemetry.title":"\u8BCA\u65AD","agentSettings.telemetry.saved":"\u8BCA\u65AD\u8BBE\u7F6E\u5DF2\u4FDD\u5B58\u3002","agentSettings.telemetry.loadFailed":"\u8BCA\u65AD\u8BBE\u7F6E\u52A0\u8F7D\u5931\u8D25\u3002","agentSettings.telemetry.saveFailed":"\u8BCA\u65AD\u8BBE\u7F6E\u4FDD\u5B58\u5931\u8D25\u3002","agentSettings.maintenance.title":"\u7EF4\u62A4","agentSettings.maintenance.description":"\u8FD9\u4E9B\u64CD\u4F5C\u4F1A\u4E2D\u65AD\u5F53\u524D Agent \u4E0A\u6B63\u5728\u8FD0\u884C\u7684\u5DE5\u4F5C\u3002","agentSettings.maintenance.upgradeFailed":"Agent \u5347\u7EA7\u5931\u8D25\u3002","chat.agent.dream":"Dream","chat.agent.dreamHint":"\u542F\u7528\u81EA\u52A8 Dream \u8BB0\u5FC6\u5904\u7406","chat.agent.restart":"\u91CD\u542F","chat.agent.restartConfirm":`\u786E\u5B9A\u8981\u91CD\u542F Agent "{name}" \u5417\uFF1F
|
|
11
11
|
\u6240\u6709\u6D3B\u8DC3\u7684\u4F1A\u8BDD\u5C06\u88AB\u4E2D\u65AD\u3002`,"chat.agent.upgrade":"\u5347\u7EA7","chat.agent.upgrading":"\u5347\u7EA7\u4E2D","chat.agent.upgradeConfirm":`\u5347\u7EA7 Agent "{name}" \u5230\u6700\u65B0\u7248\u672C\uFF1F
|
|
12
12
|
\u5347\u7EA7\u5B8C\u6210\u540E Agent \u4F1A\u81EA\u52A8\u91CD\u542F\u3002`,"chat.agent.upgradeAll":"\u5168\u90E8\u5347\u7EA7","chat.agent.upgradingAll":"\u5168\u90E8\u5347\u7EA7\u4E2D\u2026","chat.agent.upgradeAllConfirm":`\u786E\u5B9A\u5C06 {count} \u4E2A\u7B26\u5408\u6761\u4EF6\u7684 Agent \u5347\u7EA7\u5230\u6700\u65B0\u7248\u672C\u5417\uFF1F
|
|
13
13
|
\u5347\u7EA7\u5B8C\u6210\u540E\u5B83\u4EEC\u4F1A\u81EA\u52A8\u91CD\u542F\u3002\u53E6\u6709 {skipped} \u4E2A Agent \u56E0\u5F53\u524D\u4E0D\u53EF\u7528\u6216\u4E0D\u652F\u6301\u5B89\u5168\u8FDC\u7A0B\u5347\u7EA7\u800C\u8DF3\u8FC7\u3002`,"chat.agent.upgradeAllSummary":"Agent \u6279\u91CF\u5347\u7EA7\u5B8C\u6210\uFF1A\u5347\u7EA7\u6210\u529F {upgraded} \u4E2A\uFF0C\u5DF2\u662F\u6700\u65B0 {latest} \u4E2A\uFF0C\u5931\u8D25 {failed} \u4E2A\uFF0C\u8DF3\u8FC7 {skipped} \u4E2A\u3002","chat.agent.alreadyLatest":"Agent \u5DF2\u662F\u6700\u65B0\u7248\u672C (v{version})\uFF0C\u65E0\u9700\u5347\u7EA7\u3002","chat.agent.nodeIncompatible":"Agent \u5347\u7EA7\u4E2D\u6B62\uFF1A\u76EE\u6807\u7248\u672C v{version} \u9700\u8981 Node {required}\uFF0C\u4F46\u5F53\u524D\u673A\u5668\u8FD0\u884C\u7684\u662F Node {current}\u3002\u8BF7\u5148\u5347\u7EA7 Node.js \u518D\u91CD\u8BD5\u3002","chat.agent.manualUpgradeRequired":'Agent v{version} \u6CA1\u6709\u58F0\u660E\u5B89\u5168\u8FDC\u7A0B\u5347\u7EA7\u80FD\u529B\uFF1B\u65E7\u5BA2\u6237\u7AEF\u53C8\u672A\u4E0A\u62A5\u8DB3\u591F\u7684\u5E73\u53F0\u4FE1\u606F\uFF0CServer \u65E0\u6CD5\u6392\u9664 Windows \u5305\u76EE\u5F55\u9501\u5B9A\u6545\u969C\u3002\u4E3A\u907F\u514D\u91CD\u590D\u6267\u884C\u5DF2\u77E5\u4F1A\u5931\u8D25\u7684\u5347\u7EA7\uFF0C\u672C\u6B21\u64CD\u4F5C\u5DF2\u88AB\u963B\u6B62\u3002\u8BF7\u5148\u505C\u6B62\u8BE5\u673A\u5668\u4E0A\u6240\u9009\u7684 Agent/\u670D\u52A1\uFF1A\u82E5\u7531 PM2 \u6216\u5176\u4ED6\u670D\u52A1\u7BA1\u7406\u5668\u8FD0\u884C\uFF0C\u8BF7\u5728\u90A3\u91CC\u505C\u6B62\u8FD9\u4E2A\u7CBE\u786E\u5B9E\u4F8B\uFF1B\u82E5\u5728\u524D\u53F0\u7EC8\u7AEF\u8FD0\u884C\uFF0C\u8BF7\u7EC8\u6B62\u8BE5\u8FDB\u7A0B\u3002\u786E\u8BA4\u8BE5\u8FDB\u7A0B\u5DF2\u7ECF\u9000\u51FA\u540E\uFF0C\u518D\u6267\u884C "npm install -g @yeaft/webchat-agent@latest --registry=https://pkg.yeaft.com/"\uFF1B\u6700\u540E\u4F7F\u7528\u539F\u914D\u7F6E\u542F\u52A8\u540C\u4E00 Agent \u5B9E\u4F8B\u3002\u5B8C\u6210\u8FD9\u6B21\u5F15\u5BFC\u540E\uFF0C\u540E\u7EED\u53EF\u7EE7\u7EED\u5728\u6D4F\u89C8\u5668\u4E2D\u5347\u7EA7\u3002',"chat.agent.containerImageUpgradeRequired":'\u5BB9\u5668 Agent v{version} \u7531 Docker \u955C\u50CF\u7BA1\u7406\uFF0C\u4E0D\u80FD\u5728\u5BB9\u5668\u5185\u4F7F\u7528 npm \u81EA\u5347\u7EA7\u3002\u8BF7\u5728 Docker Host \u4E0A\u6267\u884C "docker pull <configured-agent-image>"\uFF0C\u7136\u540E\u901A\u8FC7\u73B0\u6709 Server/Sandbox \u751F\u547D\u5468\u671F\u6216\u539F\u6765\u7684 "yeaft-agent container install" \u547D\u4EE4\u91CD\u5EFA\u540C\u4E00\u4E2A\u5BB9\u5668\u3002\u4FDD\u7559\u73B0\u6709\u7684 /home/yeaft/.yeaft \u548C /workspace \u6301\u4E45\u5377\uFF0C\u5E76\u590D\u7528 Host \u7AEF\u539F\u6709\u7684 0600 agent-secret \u6587\u4EF6\uFF1B\u4E0D\u8981\u5728\u91CD\u5EFA\u65F6\u5220\u9664\u8FD9\u4E9B\u5377\u3002',"chat.agent.online":"{count} \u4E2A Agent \u5728\u7EBF","chat.agent.selectFirst":"\u8BF7\u5148\u9009\u62E9\u4E00\u4E2A Agent","chat.agent.yeaft":"Yeaft \u5BF9\u8BDD","sidebar.toggle.chat":"\u5207\u6362\u5230 Chat","sidebar.toggle.yeaft":"\u5207\u6362\u5230 Yeaft","sidebar.surface.label":"\u4FA7\u680F\u89C6\u56FE","sidebar.surface.sessions":"\u4F1A\u8BDD","sidebar.provider.label":"\u4F1A\u8BDD Provider","sidebar.provider.claude":"Claude","sidebar.sessions.new":"\u65B0\u5EFA\u4F1A\u8BDD","sidebar.sessions.newChat":"\u65B0\u5EFA\u804A\u5929","sidebar.sessions.emptyProvider":"\u6B64 Provider \u6682\u65E0\u4F1A\u8BDD","sidebar.sessions.menu":"\u4F1A\u8BDD\u83DC\u5355","sidebar.sessions.unread":"\u672A\u8BFB","sidebar.sessions.pinned":"\u5DF2\u7F6E\u9876","sidebar.sessions.processing":"\u6B63\u5728\u56DE\u590D","sidebar.sessions.hidden":"\u5DF2\u9690\u85CF\u7684\u4F1A\u8BDD","sidebar.sessions.remove":"\u4ECE\u4FA7\u680F\u79FB\u9664","sidebar.sessions.agent":"Agent","sidebar.sessions.provider":"Provider","sidebar.projects.title":"\u9879\u76EE","sidebar.projects.menu":"\u9879\u76EE\u83DC\u5355","sidebar.projects.new":"\u65B0\u5EFA\u9879\u76EE","sidebar.projects.newSession":"\u5728{name}\u4E2D\u521B\u5EFA Session","sidebar.projects.assignFailed":"Session \u5DF2\u521B\u5EFA\uFF0C\u4F46\u65E0\u6CD5\u52A0\u5165{name}\u3002\u9519\u8BEF\uFF1A{message}","sidebar.projects.empty":"\u6682\u65E0\u9879\u76EE","sidebar.projects.noSessions":"\u5C06 Yeaft \u804A\u5929\u62D6\u5230\u8FD9\u91CC","sidebar.projects.namePrompt":"\u9879\u76EE\u540D\u79F0","sidebar.projects.renamePrompt":"\u91CD\u547D\u540D\u9879\u76EE","sidebar.projects.rename":"\u91CD\u547D\u540D\u9879\u76EE","sidebar.projects.delete":"\u5220\u9664\u9879\u76EE","sidebar.projects.deleteConfirm":"\u5220\u9664\u9879\u76EE\u201C{name}\u201D\uFF1F\u5176\u4E2D\u804A\u5929\u4F1A\u79FB\u56DE\u6700\u8FD1\u3002","sidebar.projects.remove":"\u79FB\u51FA\u9879\u76EE","sidebar.projects.moveMenu":"\u79FB\u52A8\u5230 Projects","sidebar.projects.moveBack":"\u8FD4\u56DE","sidebar.projects.moveEmpty":"\u6CA1\u6709\u5176\u4ED6 Project","sidebar.projects.moveTo":"\u79FB\u5230 {name}","sidebar.projects.instructions":"Project \u6307\u4EE4","sidebar.projects.instructionsTitle":"{name} \u6307\u4EE4","sidebar.projects.instructionsHint":"\u8FD9\u4E9B\u6307\u4EE4\u4F1A\u52A0\u5165\u6B64 Project \u5185\u6BCF\u4E2A Session \u7684 system prompt\u3002","sidebar.projects.instructionsPlaceholder":"\u8F93\u5165\u5171\u4EAB\u7684\u7F16\u7801\u89C4\u8303\u3001\u7EA6\u675F\u6216\u5DE5\u4F5C\u6D41\u8BF4\u660E\u2026","sidebar.recents.title":"\u6700\u8FD1","sidebar.recents.empty":"\u6682\u65E0\u804A\u5929","yeaft.back":"\u8FD4\u56DE","yeaft.session.people":"\u6210\u5458","yeaft.session.peopleEmpty":"\u6682\u65E0\u6210\u5458","yeaft.session.runningTasks":"\u8FD0\u884C\u4E2D\u7684\u4EFB\u52A1","yeaft.session.tasksEmpty":"\u6682\u65E0\u8FD0\u884C\u4EFB\u52A1","yeaft.session.owner":"\u8D1F\u8D23\u4EBA","yeaft.session.started":"\u5F00\u59CB\u65F6\u95F4","yeaft.breadcrumb.label":"Thread \u8FC7\u6EE4","yeaft.breadcrumb.mainStream":"\u4E3B\u6D41","yeaft.breadcrumb.backHint":"\u8FD4\u56DE\u5168\u6D41 (Esc)","yeaft.featureDetail.ariaLabel":"Task \u8BE6\u60C5","yeaft.featureDetail.replyTo":"\u56DE\u590D\u5230:","yeaft.featureDetail.forkHint":"\u8BE5 task \u6682\u65E0\u6D3B\u8DC3 thread \u2014 \u8BF7 fork \u65B0 thread \u540E\u56DE\u590D\u3002","yeaft.featureDetail.empty":"\u8BE5 task \u6682\u65E0\u6D88\u606F\u3002","yeaft.featureDetail.threadPillHint":"\u6253\u5F00 thread","yeaft.featureDetail.summary.aria":"\u4EFB\u52A1\u6458\u8981\u65F6\u95F4\u7EBF","yeaft.featureDetail.summary.title":"\u6458\u8981\u65F6\u95F4\u7EBF","yeaft.featureDetail.summary.loading":"\u6B63\u5728\u52A0\u8F7D\u6458\u8981\u5386\u53F2\u2026","yeaft.featureDetail.summary.empty":"\u6682\u65E0\u6458\u8981\u3002","yeaft.featureDetail.summary.error":"\u6458\u8981\u52A0\u8F7D\u5931\u8D25\uFF1A{error}","yeaft.featureDetail.summary.showArchived":"\u663E\u793A\u5DF2\u5F52\u6863","yeaft.featureDetail.related.aria":"\u5173\u8054\u4EFB\u52A1","yeaft.featureDetail.related.title":"\u5173\u8054\u4EFB\u52A1","yeaft.featureDetail.related.unlink":"\u53D6\u6D88\u5173\u8054","yeaft.featureDetail.members.aria":"\u4EFB\u52A1\u6210\u5458","yeaft.featureDetail.members.title":"\u6210\u5458","yeaft.featureDetail.members.abort":"\u4E2D\u6B62","yeaft.featureDetail.members.kick":"\u8E22\u51FA","yeaft.model":"\u6A21\u578B","yeaft.placeholder":"\u95EE\u6211\u4EFB\u4F55\u95EE\u9898...","yeaft.inbox":"\u6536\u4EF6\u7BB1","yeaft.inbox.tooltip":"\u4F60\u7684\u9ED8\u8BA4\u5BF9\u8BDD\u7EBF\u7A0B \u2014\u2014 \u4E0E Yeaft \u7684\u4E00\u5BF9\u4E00\u804A\u5929\u3002\u53EF\u4EE5\u4E3A\u5177\u4F53\u8BDD\u9898\u6216\u4EFB\u52A1\u521B\u5EFA\u65B0\u7EBF\u7A0B\u3002","yeaft.sidebar.activeThreads":"\u6D3B\u8DC3","yeaft.sidebar.idleThreads":"\u9759\u9ED8","yeaft.sidebar.archivedThreads":"\u5DF2\u5F52\u6863","yeaft.sidebar.tasks":"\u4EFB\u52A1","yeaft.sidebar.emptyActive":"\u6682\u65E0\u6D3B\u8DC3 thread","yeaft.sidebar.emptyIdle":"\u6682\u65E0\u9759\u9ED8 thread","yeaft.sidebar.emptyArchived":"\u6682\u65E0\u5F52\u6863 thread","yeaft.sidebar.emptyTasks":"\u65E0\u5339\u914D\u4EFB\u52A1","yeaft.sidebar.results":"\u641C\u7D22\u7ED3\u679C","yeaft.sidebar.resultsThreads":"Threads","yeaft.sidebar.kindThread":"thread","yeaft.sidebar.cancel":"\u53D6\u6D88","yeaft.sidebar.mergeInto":"\u5408\u5E76\u5230\u2026","yeaft.sidebar.mergeNoCandidates":"\u6CA1\u6709\u53EF\u5408\u5E76\u7684\u5176\u4ED6\u7EBF\u7A0B","yeaft.sidebar.mergeConfirmTitle":"\u5408\u5E76\u8FD9\u4E2A\u7EBF\u7A0B\uFF1F","yeaft.sidebar.mergeIrreversible":"\u6B64\u64CD\u4F5C\u4E0D\u53EF\u64A4\u9500\uFF0C\u6E90\u7EBF\u7A0B\u5C06\u88AB\u5F52\u6863\uFF0C\u5176\u6D88\u606F\u4F1A\u88AB\u79FB\u52A8\u5230\u76EE\u6807\u7EBF\u7A0B\u3002","yeaft.sidebar.mergeConfirm":"\u5408\u5E76","yeaft.settings.sidebarV2":"\u5B9E\u9A8C\u529F\u80FD\uFF1A\u4FA7\u8FB9\u680F V2","yeaft.settings.sidebarV2Hint":"Thread \u5217\u8868 + \u4EFB\u52A1\u6811\uFF08\u9884\u89C8\uFF09\u3002","yeaft.clearConfirm":"\u6E05\u7A7A\u6240\u6709\u6D88\u606F\uFF1F","yeaft.mode":"\u6A21\u5F0F","yeaft.agent":"\u667A\u80FD\u4F53","yeaft.connecting":"\u8FDE\u63A5\u4E2D...","yeaft.ready":"\u5C31\u7EEA","yeaft.tools":"\u4E2A\u5DE5\u5177","yeaft.skills":"\u4E2A\u6280\u80FD","yeaft.mcp":"\u4E2A MCP","yeaft.showSidebar":"\u663E\u793A\u4FA7\u680F","yeaft.hideSidebar":"\u9690\u85CF\u4FA7\u680F","yeaft.debug":"\u8C03\u8BD5","yeaft.debugClose":"\u5173\u95ED\u8C03\u8BD5\u9762\u677F","yeaft.debugTurns":"\u8F6E","yeaft.debugTabToolStats":"\u5DE5\u5177\u7EDF\u8BA1","yeaft.debugTabDream":"Dream","yeaft.debugTabRequestLog":"\u8BF7\u6C42\u65E5\u5FD7","yeaft.debugHistoryLoad":"\u52A0\u8F7D\u8BF7\u6C42\u5386\u53F2","yeaft.debugHistoryLoading":"\u52A0\u8F7D\u4E2D...","yeaft.debugHistoryLoaded":"\u5DF2\u52A0\u8F7D {count} \u6761","yeaft.debugHistoryUnavailable":"\u8C03\u8BD5\u8F68\u8FF9\u8BF7\u6C42\u8D85\u65F6\u3002Agent \u53EF\u80FD\u79BB\u7EBF\uFF0C\u6216\u54CD\u5E94\u5DF2\u88AB\u4E22\u5F03\uFF0C\u8BF7\u91CD\u8BD5\u3002","yeaft.debugHistoryTruncated":"\u8BE5\u8F68\u8FF9\u8FC7\u5927\uFF0C\u65E0\u6CD5\u5728\u4E00\u6B21\u54CD\u5E94\u4E2D\u5B8C\u6574\u4F20\u8F93\u3002\u6B64\u5904\u663E\u793A\u5927\u5B57\u6BB5\u9884\u89C8\uFF0C\u5B8C\u6574\u8F68\u8FF9\u4ECD\u4FDD\u7559\u5728 Agent\u3002","yeaft.debugSearchPlaceholder":"\u6B63\u5219\u641C\u7D22\u8BF7\u6C42\u65E5\u5FD7","yeaft.debugSearchHint":"\u9ED8\u8BA4\u663E\u793A\u5168\u5C40\u6700\u8FD1 10 \u6761\uFF1B\u641C\u7D22\u4F1A\u8DE8 Session \u5339\u914D\u8BF7\u6C42\u6458\u8981\u3002","yeaft.debugTurnAction":"\u67E5\u770B\u8BE5\u8F6E\u5BF9\u8BDD\u7684\u8C03\u8BD5\u8F68\u8FF9","yeaft.debugTurnContext":"\u8C03\u8BD5\u8F68\u8FF9","yeaft.debugPanelEmpty":"\u60AC\u505C\u5728 AI \u56DE\u590D\u4E0A\uFF0C\u70B9\u51FB\u8C03\u8BD5\u56FE\u6807\u5373\u53EF\u67E5\u770B\u8BE5\u8F6E\u5BF9\u8BDD\u7684\u8C03\u8BD5\u8F68\u8FF9\u3002","yeaft.dreamDebug.title":"Dream \u751F\u547D\u5468\u671F","yeaft.dreamDebug.trigger":"\u89E6\u53D1","yeaft.dreamDebug.status":"\u72B6\u6001","yeaft.dreamDebug.started":"\u5F00\u59CB","yeaft.dreamDebug.finished":"\u7ED3\u675F","yeaft.dreamDebug.time":"\u65F6\u95F4","yeaft.dreamDebug.phase":"\u9636\u6BB5","yeaft.dreamDebug.call":"\u8C03\u7528","yeaft.dreamDebug.location":"\u751F\u6210\u4F4D\u7F6E","yeaft.dreamDebug.result":"\u7ED3\u679C","yeaft.dreamDebug.noLatest":"\u8FD9\u4E2A\u4F1A\u8BDD\u8FD8\u6CA1\u6709\u8BB0\u5F55\u5230 Dream \u68C0\u67E5\u3002","yeaft.dreamDebug.noEvents":"\u8FD9\u4E2A\u4F1A\u8BDD\u8FD8\u6CA1\u6709 Dream \u4E8B\u4EF6\u3002","yeaft.dreamDebug.outputTitle":"\u672C session \u5DF2\u52A0\u8F7D\u7684 Dream \u8F93\u51FA","yeaft.dreamDebug.scope":"Scope","yeaft.dreamDebug.lastDream":"\u4E0A\u6B21 Dream","yeaft.dreamDebug.messagesCovered":"\u5DF2\u8986\u76D6\u6D88\u606F\u6570","yeaft.dreamDebug.noOutput":"\u8FD9\u4E2A session \u8FD8\u6CA1\u6709\u5199\u5165 Dream \u8F93\u51FA\u3002","yeaft.dreamDebug.promptLoadTitle":"\u5DF2\u52A0\u8F7D\u8FDB system prompt \u7684 Dream \u8BB0\u5FC6","yeaft.dreamDebug.loadedInto":"\u52A0\u8F7D\u4F4D\u7F6E","yeaft.dreamDebug.vp":"VP","yeaft.dreamDebug.summaryToPrompt":"summary.md -> system prompt","yeaft.dreamDebug.itemList":"Dream \u8FD0\u884C\u548C Scope","yeaft.dreamDebug.searchPlaceholder":"\u6309\u6807\u9898\u3001ID \u6216\u6458\u8981\u641C\u7D22 Dream Session...","yeaft.dreamDebug.noSearchResults":"\u6CA1\u6709\u5339\u914D\u7684 Dream Session\u3002","yeaft.dreamDebug.noSummary":"\u6682\u65E0\u6458\u8981","yeaft.dreamDebug.segments":"\u6BB5","yeaft.dreamDebug.lastError":"\u6700\u8FD1\u9519\u8BEF","yeaft.dreamDebug.overview":"\u6982\u89C8","yeaft.dreamDebug.sessionId":"Session ID","yeaft.dreamDebug.loadedAt":"\u52A0\u8F7D\u65F6\u95F4","yeaft.dreamDebug.layers":"\u5C42\u7EA7","yeaft.dreamDebug.summaryLayer":"Resident summary","yeaft.dreamDebug.noPromptLoad":"\u8FD9\u4E2A scope \u6682\u65E0 prompt-load \u8BB0\u5F55\u3002","yeaft.dreamDebug.segmentTitle":"Segments","yeaft.dreamDebug.sourceMessages":"\u6765\u6E90\u6D88\u606F","yeaft.dreamDebug.createdAt":"\u521B\u5EFA\u65F6\u95F4","yeaft.dreamDebug.updatedAt":"\u66F4\u65B0\u65F6\u95F4","yeaft.dreamDebug.noSegments":"\u8FD9\u4E2A scope \u6682\u65E0 memory segments\u3002","yeaft.dreamDebug.requestResponse":"Request / Response","yeaft.dreamDebug.noRequestResponse":"\u8FD9\u4E2A scope \u8FD8\u6CA1\u6709\u6301\u4E45\u5316\u7684 Dream request/response \u65E5\u5FD7\u3002","yeaft.dreamDebug.empty":"\u6682\u65E0 Dream debug \u6570\u636E\u3002","yeaft.debugGroupFollowMain":"\u8DDF\u968F\u4E3B\u9762\u677F","yeaft.debugGroupAll":"\u5168\u90E8\u4F1A\u8BDD","yeaft.debugAssistantResponse":"Assistant \u56DE\u590D","yeaft.debugViewAssistantResponse":"\u67E5\u770B\u56DE\u590D","yeaft.debugLatestRequestBody":"\u6700\u8FD1\u53EF\u7528\u8BF7\u6C42\u4F53","yeaft.debugLatestSystemPrompt":"\u6700\u8FD1\u53EF\u7528\u7CFB\u7EDF\u63D0\u793A","yeaft.debugRequestBodyUnavailable":"\u6B64 Turn \u6682\u65E0\u53EF\u7528\u8BF7\u6C42\u4F53\u3002","yeaft.debugSystemPromptUnavailable":"\u6B64 Turn \u6682\u65E0\u53EF\u7528\u7CFB\u7EDF\u63D0\u793A\u3002","yeaft.debugInputSystemShort":"\u7CFB\u7EDF","yeaft.debugInputHistoryShort":"\u5386\u53F2","yeaft.debugInputToolsShort":"\u5DE5\u5177\u5B9A\u4E49","yeaft.debugInputCurrentShort":"\u5F53\u524D","yeaft.debugInputTokenBreakdown":"Provider \u8F93\u5165 {total}\uFF1A\u7CFB\u7EDF\u63D0\u793A {system}\u3001\u5386\u53F2\u6D88\u606F {history}\u3001\u5DE5\u5177\u5B9A\u4E49 {tools}\u3001\u5F53\u524D Turn {current}\uFF08\u4F30\u7B97\u62C6\u5206\uFF09","yeaft.debugToolInput":"\u8F93\u5165","yeaft.debugToolResult":"\u7ED3\u679C","yeaft.debugToolRunning":"\u6267\u884C\u4E2D","yeaft.debugToolRunningNoResult":"\u6267\u884C\u4E2D\uFF0C\u6682\u65E0\u7ED3\u679C","yeaft.debugShowDetails":"\u5C55\u5F00","yeaft.debugHideDetails":"\u6536\u8D77","yeaft.debugTurnStartedAt":"\u56DE\u5408\u5F00\u59CB\u65F6\u95F4","yeaft.debugRequestAt":"\u8BF7\u6C42\u65F6\u95F4","yeaft.debugRequestAtDerived":"\u7531\u56DE\u5408\u5F00\u59CB\u65F6\u95F4\u63A8\u7B97\uFF08\u65E7 loop\uFF09","yeaft.turn":"\u7B2C {n} \u8F6E","yeaft.systemPrompt":"\u7CFB\u7EDF\u63D0\u793A","yeaft.messagesLabel":"\u6D88\u606F","yeaft.response":"\u56DE\u590D","yeaft.toolCalls":"\u5DE5\u5177\u8C03\u7528","yeaft.functionCalls":"\u51FD\u6570\u8C03\u7528","yeaft.request":"\u8BF7\u6C42","yeaft.pending":"(\u7B49\u5F85\u4E2D)","yeaft.inputTokens":"\u8F93\u5165","yeaft.outputTokens":"\u8F93\u51FA","yeaft.duration":"\u8017\u65F6","yeaft.noDebugData":"\u6682\u65E0\u8C03\u8BD5\u6570\u636E","yeaft.showDebug":"\u663E\u793A\u8C03\u8BD5\u9762\u677F","yeaft.hideDebug":"\u9690\u85CF\u8C03\u8BD5\u9762\u677F","yeaft.reloadPage":"\u5237\u65B0\u9875\u9762","yeaft.reloadMessages":"\u91CD\u65B0\u52A0\u8F7D\u6D88\u606F","sidebar.sessions.syncing":"\u6B63\u5728\u540C\u6B65\u6700\u65B0\u6D88\u606F","yeaft.historySearch.label":"\u641C\u7D22 Session \u5386\u53F2\u6D88\u606F","yeaft.historySearch.button":"\u641C\u7D22\u6D88\u606F","yeaft.historySearch.placeholder":"\u641C\u7D22\u5F53\u524D Session \u7684\u6D88\u606F","yeaft.historySearch.searching":"\u6B63\u5728\u641C\u7D22\u2026","yeaft.historySearch.minChars":"\u81F3\u5C11\u8F93\u5165 2 \u4E2A\u5B57\u7B26","yeaft.historySearch.empty":"\u6CA1\u6709\u5339\u914D\u7684\u6D88\u606F","yeaft.historySearch.error":"\u641C\u7D22\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5","yeaft.historySearch.unsupported":"\u8BF7\u5347\u7EA7\u5F53\u524D Agent \u540E\u518D\u641C\u7D22 Session \u5386\u53F2\u6D88\u606F","yeaft.historySearch.more":"\u52A0\u8F7D\u66F4\u591A\u7ED3\u679C","yeaft.historySearch.you":"\u4F60","yeaft.historySearch.assistant":"\u52A9\u624B","yeaft.outline.label":"\u5386\u53F2\u6D88\u606F","yeaft.outline.sender":"\u53D1\u9001\u8005","yeaft.outline.allSenders":"\u5168\u90E8\u53D1\u9001\u8005","yeaft.outline.title":"\u5386\u53F2\u6D88\u606F","yeaft.outline.placeholder":"\u641C\u7D22\u5F53\u524D\u5BF9\u8BDD","yeaft.outline.searching":"\u6B63\u5728\u641C\u7D22\u2026","yeaft.outline.loading":"\u6B63\u5728\u52A0\u8F7D\u2026","yeaft.outline.older":"\u52A0\u8F7D\u66F4\u65E9\u6D88\u606F","yeaft.outline.moreMatches":"\u52A0\u8F7D\u66F4\u591A\u5339\u914D\u9879","yeaft.outline.minChars":"\u81F3\u5C11\u8F93\u5165 2 \u4E2A\u5B57\u7B26","yeaft.outline.empty":"\u6682\u65E0\u6D88\u606F","yeaft.outline.noMatches":"\u6CA1\u6709\u5339\u914D\u7684\u6D88\u606F","yeaft.outline.error":"\u5927\u7EB2\u52A0\u8F7D\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5","yeaft.outline.unsupported":"\u8BF7\u5347\u7EA7\u5F53\u524D Agent \u540E\u518D\u4F7F\u7528\u5BF9\u8BDD\u5927\u7EB2","yeaft.outline.you":"\u4F60","yeaft.outline.assistant":"\u52A9\u624B","yeaft.outline.nonText":"\u975E\u6587\u672C\u56DE\u590D","yeaft.switchModel":"\u5207\u6362\u6A21\u578B","yeaft.modelMenu.title":"\u6A21\u578B\u548C LLM \u8BBE\u7F6E","yeaft.modelMenu.label":"\u6A21\u578B","yeaft.modelMenu.effort":"\u63A8\u7406\u5F3A\u5EA6","yeaft.modelMenu.effort.openaiReasoning":"\u63A8\u7406\u5F3A\u5EA6","yeaft.modelMenu.effort.anthropicBudget":"\u601D\u8003\u9884\u7B97","yeaft.modelMenu.effort.anthropicAdaptive":"\u81EA\u9002\u5E94\u601D\u8003\u5F3A\u5EA6","yeaft.modelMenu.effort.minimal":"\u6700\u5C0F","yeaft.modelMenu.effort.low":"\u4F4E","yeaft.modelMenu.effort.medium":"\u4E2D","yeaft.modelMenu.effort.high":"\u9AD8","yeaft.modelMenu.effort.xhigh":"\u8D85\u9AD8","yeaft.modelMenu.effort.max":"\u6700\u9AD8","yeaft.modelMenu.effort.ultra":"\u6781\u81F4","yeaft.modelMenu.noEffort":"\u5F53\u524D\u6A21\u578B\u6CA1\u6709\u53EF\u517C\u5BB9\u6620\u5C04\u7684\u63A8\u7406\u5F3A\u5EA6\u63A7\u5236\u3002","yeaft.modelMenu.configureHint":"Provider\u3001\u5BC6\u94A5\u3001\u6A21\u578B\u5217\u8868","yeaft.settings.title":"\u8BBE\u7F6E","yeaft.settings.tabs.vp":"VP \u5E93","yeaft.settings.tabs.search":"\u641C\u7D22","search.settings.backendTitle":"\u641C\u7D22\u540E\u7AEF","search.settings.backendDesc":"\u9009\u62E9 WebSearch \u5DE5\u5177\u9ED8\u8BA4\u4F7F\u7528\u7684\u540E\u7AEF\u3002\u4E3B\u540E\u7AEF\u5931\u8D25\u65F6,\u5F15\u64CE\u4F1A\u81EA\u52A8\u964D\u7EA7\u5230 HTML \u6293\u53D6\u3002","search.settings.backend.tavily":"Tavily","search.settings.backend.tavilyHint":"\u6258\u7BA1\u641C\u7D22 API\u3002\u514D\u8D39\u989D\u5EA6 1000 \u6B21/\u6708\u3002\u63A8\u8350\u3002","search.settings.backend.playwright":"Playwright \u670D\u52A1","search.settings.backend.playwrightHint":"\u81EA\u5EFA\u7684\u6D4F\u89C8\u5668\u5F0F\u641C\u7D22/\u6293\u53D6\u670D\u52A1,\u9002\u5408 IP \u4FE1\u8A89\u5DEE\u88AB bot \u68C0\u6D4B\u7684\u73AF\u5883\u3002\u5C1A\u672A\u4E0A\u7EBF\u3002","search.settings.comingSoon":"\u5373\u5C06\u63A8\u51FA","search.settings.tavilyKeyTitle":"Tavily API key","search.settings.tavilyKeyDesc":"\u4FDD\u5B58\u5728 agent \u7684 ~/.yeaft/config.json \u4E2D\u3002\u514D\u8D39\u7533\u8BF7:","search.settings.tavilyKeyUnchanged":"\u4FDD\u6301\u4E0D\u53D8","search.settings.clearKey":"\u6E05\u9664","search.settings.usageTitle":"\u672C\u6708\u7528\u91CF","search.settings.usageRefresh":"\u5237\u65B0","search.settings.usageLoading":"\u52A0\u8F7D\u4E2D\u2026","search.settings.usagePlan":"\u8BA1\u5212","search.settings.usageUsed":"\u5DF2\u7528","search.settings.usagePaygo":"\u6309\u91CF\u4ED8\u8D39","search.settings.usageError":"\u52A0\u8F7D\u7528\u91CF\u5931\u8D25","search.settings.save":"\u4FDD\u5B58","search.settings.saving":"\u4FDD\u5B58\u4E2D\u2026","search.settings.saveSuccess":"\u5DF2\u4FDD\u5B58","search.settings.cancel":"\u91CD\u7F6E","yeaft.settings.yeaftTitle":"\u7EBF\u7A0B\u5E76\u53D1\u4E0E\u5F52\u6863","yeaft.settings.yeaftDesc":"\u8C03\u6574\u53EF\u540C\u65F6\u8FD0\u884C\u7684\u7EBF\u7A0B\u6570\u91CF\uFF0C\u4EE5\u53CA\u95F2\u7F6E\u7EBF\u7A0B\u7684\u81EA\u52A8\u5F52\u6863\u65F6\u957F\u3002","yeaft.settings.maxConcurrentLabel":"\u6700\u5927\u5E76\u53D1\u7EBF\u7A0B\u6570","yeaft.settings.maxConcurrentHint":"\u540C\u65F6\u5728\u7EBF\u7684\u7EBF\u7A0B\u603B\u6570\u4E0A\u9650\uFF08\u542B\u59CB\u7EC8\u5B58\u5728\u7684 main \u4E3B\u7EBF\u7A0B\uFF09\u3002\u8D85\u8FC7\u6B64\u4E0A\u9650\u7684\u65B0\u7EBF\u7A0B\u5C06\u88AB\u62D2\u7EDD\uFF0C\u76F4\u81F3\u5DF2\u6709\u7EBF\u7A0B\u88AB\u5F52\u6863\u6216\u7EC8\u6B62\u3002\u8303\u56F4\uFF1A1-50\u3002","yeaft.settings.archiveIdleDaysLabel":"\u95F2\u7F6E\u591A\u4E45\u540E\u81EA\u52A8\u5F52\u6863\u7EBF\u7A0B\uFF08\u5929\uFF09","yeaft.settings.archiveIdleDaysHint":"\u65E0\u6D3B\u52A8\u8D85\u8FC7\u6B64\u5929\u6570\u7684\u7EBF\u7A0B\u5C06\u88AB\u5F52\u6863\u3002\u8303\u56F4\uFF1A1-3650\u3002","yeaft.settings.yeaftSaveBtn":"\u4FDD\u5B58","yeaft.settings.yeaftSaving":"\u4FDD\u5B58\u4E2D...","yeaft.settings.yeaftSaved":"\u5DF2\u4FDD\u5B58","yeaft.settings.yeaftLoading":"\u52A0\u8F7D\u4E2D...","yeaft.settings.yeaftLoadError":"\u52A0\u8F7D Yeaft \u8BBE\u7F6E\u5931\u8D25","yeaft.settings.yeaftSaveError":"\u4FDD\u5B58 Yeaft \u8BBE\u7F6E\u5931\u8D25","yeaft.settings.rangeErrorConcurrent":"\u5FC5\u987B\u5728 1 \u5230 50 \u4E4B\u95F4","yeaft.settings.rangeErrorArchive":"\u5FC5\u987B\u5728 1 \u5230 3650 \u4E4B\u95F4","chat.session.creating":"\u6B63\u5728\u521B\u5EFA\u4F1A\u8BDD...","chat.session.loadingHistory":"\u6B63\u5728\u52A0\u8F7D\u4F1A\u8BDD\u5386\u53F2...","yeaft.historyLoad.error":"\u4F1A\u8BDD\u5386\u53F2\u6682\u65F6\u65E0\u6CD5\u52A0\u8F7D\uFF0C\u6D88\u606F\u4ECD\u5B89\u5168\u4FDD\u5B58\u5728 Agent \u4E2D\u3002","yeaft.historyLoad.retry":"\u91CD\u65B0\u52A0\u8F7D","yeaft.sessionInventory.error":"\u6682\u65F6\u65E0\u6CD5\u52A0\u8F7D Session\uFF0C\u4F1A\u8BDD\u4ECD\u5B89\u5168\u4FDD\u5B58\u5728 Agent \u4E2D\u3002","yeaft.sessionInventory.retry":"\u91CD\u65B0\u52A0\u8F7D Session","chat.session.closed":"\u4F1A\u8BDD\u5DF2\u5173\u95ED","chat.session.agentOffline":"Agent \u5DF2\u79BB\u7EBF\uFF0C\u8BE5\u4F1A\u8BDD\u5C06\u5728 Agent \u91CD\u65B0\u4E0A\u7EBF\u540E\u6062\u590D\u3002","chat.execution.cancelled":"\u6267\u884C\u5DF2\u53D6\u6D88","chat.sidebar.expand":"\u5C55\u5F00\u83DC\u5355","chat.sidebar.collapse":"\u6536\u8D77\u4FA7\u8FB9\u680F","chat.sidebar.workbench":"\u5DE5\u5177\u9762\u677F","chat.sidebar.newConv":"\u4F1A\u8BDD","chat.sidebar.recentChats":"\u6700\u8FD1\u4F1A\u8BDD","chat.sidebar.resumeConv":"\u6062\u590D\u4F1A\u8BDD","chat.sidebar.lightMode":"\u6D45\u8272\u6A21\u5F0F","chat.sidebar.darkMode":"\u6DF1\u8272\u6A21\u5F0F","chat.sidebar.settings":"\u8BBE\u7F6E","chat.sidebar.emptyHint":"\u70B9\u51FB\u4E0A\u65B9\u6309\u94AE\u521B\u5EFA\u65B0\u4F1A\u8BDD","chat.sidebar.closeConv":"\u5173\u95ED\u4F1A\u8BDD","chat.sidebar.renameConv":"\u91CD\u547D\u540D","chat.sidebar.pin":"\u7F6E\u9876","chat.sidebar.unpin":"\u53D6\u6D88\u7F6E\u9876","chat.connection.connecting":"\u8FDE\u63A5\u4E2D...","chat.connection.reconnecting":"\u91CD\u8FDE\u4E2D ({current}/{max})...","chat.connection.updating":"\u670D\u52A1\u6B63\u5728\u66F4\u65B0\uFF0C\u8BF7\u7A0D\u5019...","chat.connection.disconnected":"\u8FDE\u63A5\u65AD\u5F00","chat.connection.reconnect":"\u91CD\u8FDE","chat.connection.reconnectFailed":"\u8FDE\u63A5\u65AD\u5F00\uFF0C\u8BF7\u70B9\u51FB\u91CD\u8FDE\u6309\u94AE\u91CD\u8BD5\u3002","chat.time.justNow":"\u521A\u521A","chat.time.minutesAgo":"{count}\u5206\u949F\u524D","chat.time.daysAgo":"{count}\u5929\u524D","chat.time.today":"\u4ECA\u5929","chat.time.yesterday":"\u6628\u5929","chat.delete.confirm":"\u786E\u5B9A\u8981\u5173\u95ED\u8FD9\u4E2A\u4F1A\u8BDD\u5417\uFF1F\u8FD9\u5C06\u7EC8\u6B62\u5BF9\u5E94\u7684 Claude \u8FDB\u7A0B\u3002","chat.delete.enterWorkDir":"\u8BF7\u8F93\u5165\u5DE5\u4F5C\u76EE\u5F55\u8DEF\u5F84","modal.newConv.workDir":"\u5DE5\u4F5C\u76EE\u5F55","modal.newConv.inputOrSelect":"\u8F93\u5165\u6216\u9009\u62E9\u5DE5\u4F5C\u76EE\u5F55","modal.newConv.browse":"\u6D4F\u89C8\u76EE\u5F55","modal.newConv.noWorkDirs":"\u6682\u65E0\u5DE5\u4F5C\u76EE\u5F55","modal.newConv.selectAgent":"\u8BF7\u5148\u9009\u62E9\u4E00\u4E2A\u5728\u7EBF\u7684 Agent","modal.newConv.create":"\u521B\u5EFA\u4F1A\u8BDD","modal.newConv.folderLabel":"\u{1F4C1} \u5DE5\u4F5C\u76EE\u5F55","modal.newConv.provider":"\u63D0\u4F9B\u65B9","modal.newConv.model":"\u6A21\u578B","provider.claudeCode":"Claude Code","provider.copilot":"Copilot","modal.resume.workDir":"\u5DE5\u4F5C\u76EE\u5F55","modal.resume.inputOrSelect":"\u8F93\u5165\u6216\u9009\u62E9\u5DE5\u4F5C\u76EE\u5F55","modal.resume.browse":"\u6D4F\u89C8\u76EE\u5F55","modal.resume.tabFolders":"\u5DE5\u4F5C\u76EE\u5F55","modal.resume.tabSessions":"\u5386\u53F2\u4F1A\u8BDD","modal.resume.noWorkDirs":"\u6682\u65E0\u5DE5\u4F5C\u76EE\u5F55","modal.resume.selectWorkDir":"\u8BF7\u5148\u9009\u62E9\u5DE5\u4F5C\u76EE\u5F55","modal.resume.noSessions":"\u8BE5\u76EE\u5F55\u4E0B\u6CA1\u6709\u5386\u53F2\u4F1A\u8BDD","modal.resume.untitled":"\u672A\u547D\u540D\u4F1A\u8BDD","modal.resume.folderLabel":"\u{1F4C1} \u5DE5\u4F5C\u76EE\u5F55","modal.resume.sessionLabel":"\u{1F4AC} \u5386\u53F2\u4F1A\u8BDD","modal.resume.selectAgent":"\u8BF7\u5148\u9009\u62E9\u4E00\u4E2A\u5728\u7EBF\u7684 Agent","modal.folderPicker.title":"\u9009\u62E9\u5DE5\u4F5C\u76EE\u5F55","modal.folderPicker.parentDir":"\u4E0A\u7EA7\u76EE\u5F55","welcome.subtitle":"\u9762\u5411 Session\u3001\u5DE5\u5177\u548C VP \u534F\u4F5C\u7684 Web Code Agent","welcome.agentOnline":"{count} \u4E2A Agent \u5728\u7EBF","welcome.noAgents":"\u6682\u65E0\u5728\u7EBF Agent","welcome.noAgentsHint":"\u8BF7\u5148\u542F\u52A8 Agent \u7A0B\u5E8F\u8FDE\u63A5\u5230\u670D\u52A1\u5668","welcome.noAgent":"\u6682\u65E0\u5728\u7EBF Agent","welcome.noAgentHint":"\u8BF7\u5148\u542F\u52A8 Agent \u7A0B\u5E8F\u8FDE\u63A5\u5230\u670D\u52A1\u5668","welcome.setupAgent":"\u8BBE\u7F6E Agent","welcome.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.askSubmitting":"\u56DE\u7B54\u5DF2\u53D1\u9001\uFF0C\u7B49\u5F85 Agent \u786E\u8BA4\u2026","message.askUnconfirmed":"\u5C1A\u672A\u6536\u5230\u786E\u8BA4\uFF0C\u8BF7\u68C0\u67E5\u8FDE\u63A5\u540E\u91CD\u53D1\u540C\u4E00\u56DE\u7B54\u3002","message.askRetry":"\u91CD\u53D1\u56DE\u7B54","message.askSendFailed":"\u56DE\u7B54\u672A\u53D1\u9001\uFF0C\u8BF7\u68C0\u67E5\u8FDE\u63A5\u540E\u91CD\u8BD5\u3002","message.askAgentUnavailable":"Agent \u6682\u4E0D\u53EF\u7528\uFF0C\u8BF7\u6062\u590D\u8FDE\u63A5\u540E\u91CD\u53D1\u56DE\u7B54\u3002","message.askIdentityMismatch":"\u6B64\u95EE\u9898\u4E0E\u5F53\u524D\u8BF7\u6C42\u4E0D\u4E00\u81F4\uFF0C\u8BF7\u8BA9\u89D2\u8272\u91CD\u65B0\u63D0\u95EE\u3002","message.askExpired":"\u6B64\u95EE\u9898\u5DF2\u5931\u6548\uFF0C\u8BF7\u8BA9\u89D2\u8272\u91CD\u65B0\u63D0\u95EE","message.openInEditor":"\u5728\u7F16\u8F91\u5668\u4E2D\u6253\u5F00","message.resultDone":"\u5B8C\u6210","message.done":"\u5B8C\u6210","message.resultRead":"\u8BFB\u53D6 {file}","message.readFile":"\u8BFB\u53D6 {name}","message.file":"\u6587\u4EF6","message.attachImages":"{count} \u5F20\u56FE\u7247","message.imageCount":"{count} \u5F20\u56FE\u7247","message.imagePreview":"\u56FE\u7247\u9884\u89C8","message.zoomOut":"\u7F29\u5C0F\u56FE\u7247","message.zoomIn":"\u653E\u5927\u56FE\u7247","message.resetZoom":"\u91CD\u7F6E\u56FE\u7247\u7F29\u653E","message.previousImage":"\u4E0A\u4E00\u5F20\u56FE\u7247","message.nextImage":"\u4E0B\u4E00\u5F20\u56FE\u7247","message.imagePosition":"\u7B2C {current} \u5F20\uFF0C\u5171 {total} \u5F20","message.imageUnavailable":"\u56FE\u7247\u65E0\u6CD5\u52A0\u8F7D","message.attachFiles":"{count} \u4E2A\u6587\u4EF6","message.fileCount":"{count} \u4E2A\u6587\u4EF6","message.quote":"\u5F15\u7528","message.removeQuote":"\u5220\u9664\u5F15\u7528","message.replyingTo":"\u6B63\u5728\u56DE\u590D {author}","message.quotedFrom":"\u5F15\u7528\u81EA {author}","message.editAsNew":"\u7F16\u8F91","message.you":"\u4F60","input.upload":"\u4E0A\u4F20\u6587\u4EF6","input.placeholder":"\u8F93\u5165\u6D88\u606F...","input.send":"\u53D1\u9001","input.stopExecution":"\u505C\u6B62\u6267\u884C","chatInput.upload":"\u4E0A\u4F20\u6587\u4EF6","chatInput.uploading":"\u6B63\u5728\u4E0A\u4F20\u2026","chatInput.uploadFailed":"\u4E0A\u4F20\u5931\u8D25","chatInput.retryUpload":"\u91CD\u8BD5","chatInput.removeAttachment":"\u79FB\u9664\u9644\u4EF6","chatInput.placeholder":"\u8F93\u5165\u6D88\u606F...","chatInput.send":"\u53D1\u9001","chatInput.stop":"\u505C\u6B62\u6267\u884C","tools.thinking":"\u601D\u8003\u4E2D...","tools.read":"\u6B63\u5728\u8BFB\u53D6\u6587\u4EF6","tools.write":"\u6B63\u5728\u5199\u5165\u6587\u4EF6","tools.edit":"\u6B63\u5728\u7F16\u8F91\u6587\u4EF6","tools.bash":"\u6B63\u5728\u6267\u884C\u547D\u4EE4","tools.glob":"\u6B63\u5728\u641C\u7D22\u6587\u4EF6","tools.grep":"\u6B63\u5728\u641C\u7D22\u5185\u5BB9","tools.task":"\u6B63\u5728\u6267\u884C\u4EFB\u52A1","tools.webFetch":"\u6B63\u5728\u83B7\u53D6\u7F51\u9875","tools.webSearch":"\u6B63\u5728\u641C\u7D22\u7F51\u7EDC","tools.todoWrite":"\u6B63\u5728\u66F4\u65B0\u4EFB\u52A1","tools.executing":"\u6B63\u5728\u6267\u884C {name}","status.thinking":"\u601D\u8003\u4E2D...","status.reading":"\u6B63\u5728\u8BFB\u53D6\u6587\u4EF6","status.writing":"\u6B63\u5728\u5199\u5165\u6587\u4EF6","status.editing":"\u6B63\u5728\u7F16\u8F91\u6587\u4EF6","status.executing":"\u6B63\u5728\u6267\u884C\u547D\u4EE4","status.searchingFiles":"\u6B63\u5728\u641C\u7D22\u6587\u4EF6","status.searchingContent":"\u6B63\u5728\u641C\u7D22\u5185\u5BB9","status.executingTask":"\u6B63\u5728\u6267\u884C\u4EFB\u52A1","status.fetching":"\u6B63\u5728\u83B7\u53D6\u7F51\u9875","status.searching":"\u6B63\u5728\u641C\u7D22\u7F51\u7EDC","status.updatingTasks":"\u6B63\u5728\u66F4\u65B0\u4EFB\u52A1","status.executingTool":"\u6B63\u5728\u6267\u884C {name}","header.compacting":"\u6B63\u5728\u538B\u7F29\u4E0A\u4E0B\u6587...","header.compacted":"\u4E0A\u4E0B\u6587\u538B\u7F29\u5B8C\u6210","chatHeader.newConv":"\u4F1A\u8BDD","chatHeader.compacting":"\u6B63\u5728\u538B\u7F29\u4E0A\u4E0B\u6587...","chatHeader.compactDone":"\u4E0A\u4E0B\u6587\u538B\u7F29\u5B8C\u6210","chatHeader.compact":"\u538B\u7F29\u4E0A\u4E0B\u6587","chatHeader.resume":"\u6062\u590D\u4F1A\u8BDD","chatHeader.refresh":"\u5237\u65B0\u6D88\u606F","chatHeader.reloadPage":"\u5237\u65B0\u9875\u9762","chatHeader.clear":"\u6E05\u7A7A\u6D88\u606F","chatHeader.clearing":"\u6B63\u5728\u6E05\u7A7A\u4E0A\u4E0B\u6587...","chatHeader.clearDone":"\u4E0A\u4E0B\u6587\u5DF2\u6E05\u7A7A","chatHeader.confirmClear":"\u786E\u5B9A\u8981\u6E05\u7A7A\u5F53\u524D\u4F1A\u8BDD\u7684\u6240\u6709\u6D88\u606F\u5417\uFF1F","chatHeader.mcpConfig":"MCP \u670D\u52A1\u5668\u914D\u7F6E","chatHeader.mcpNeedRestart":"\u66F4\u6539\u5C06\u5728\u91CD\u542F\u4F1A\u8BDD\u540E\u751F\u6548\u3002","chatHeader.expertPanel":"\u5E2E\u5E2E\u56E2","chatHeader.subAgentPanel":"\u5B50\u4EE3\u7406","settings.close":"\u5173\u95ED\u8BBE\u7F6E","settings.tabs.account":"\u8D26\u53F7","settings.tabs.security":"\u5B89\u5168","settings.tabs.general":"\u901A\u7528","settings.tabs.sandbox":"Sandbox","settings.tabs.invitations":"\u9080\u8BF7","auth.sessionExpired":"\u767B\u5F55\u5DF2\u8FC7\u671F\uFF0C\u8BF7\u91CD\u65B0\u767B\u5F55\u3002","settings.sandbox.description":"\u5728\u672C Server \u7BA1\u7406\u7684 Docker \u5BB9\u5668\u4E2D\u8FD0\u884C\u4E00\u4E2A\u6301\u4E45\u5316 Yeaft Agent\u3002","settings.sandbox.containerAgent":"Docker \u5316 Yeaft Agent","settings.sandbox.serverManaged":"Server \u53EA\u7BA1\u7406\u6B64\u5BB9\u5668\u7684\u542F\u52A8\u3001\u505C\u6B62\u548C\u5220\u9664\uFF1B\u5BB9\u5668\u5185 Agent \u4ECD\u4F7F\u7528\u666E\u901A Yeaft \u8FDE\u63A5\u3002","settings.sandbox.agentName":"Agent \u540D\u79F0","settings.sandbox.sizeLabel":"\u89C4\u683C","settings.sandbox.enable":"\u542F\u7528 Sandbox","settings.sandbox.creating":"\u6B63\u5728\u8BBE\u7F6E\u2026","settings.sandbox.start":"\u542F\u52A8","settings.sandbox.stop":"\u505C\u6B62","settings.sandbox.retry":"\u91CD\u8BD5","settings.sandbox.remove":"\u79FB\u9664","settings.sandbox.removeConfirm":"\u6C38\u4E45\u79FB\u9664\u6B64 Sandbox\uFF0C\u5E76\u5220\u9664 home \u548C workspace \u6570\u636E\uFF1F\u6B64\u64CD\u4F5C\u65E0\u6CD5\u64A4\u9500\u3002","settings.sandbox.size.small":"\u5C0F\u578B","settings.sandbox.size.normal":"\u6807\u51C6","settings.sandbox.state.reserving":"\u6B63\u5728\u8BBE\u7F6E","settings.sandbox.state.provisioning":"\u6B63\u5728\u51C6\u5907 Sandbox","settings.sandbox.state.starting":"\u6B63\u5728\u542F\u52A8","settings.sandbox.state.waiting_for_agent":"\u6B63\u5728\u7B49\u5F85 Agent","settings.sandbox.state.stopping":"\u6B63\u5728\u505C\u6B62","settings.sandbox.state.removing":"\u6B63\u5728\u79FB\u9664","settings.sandbox.state.removed":"\u5DF2\u79FB\u9664","settings.sandbox.state.running":"\u8FD0\u884C\u4E2D","settings.sandbox.state.stopped":"\u5DF2\u505C\u6B62","settings.sandbox.state.failed":"\u5931\u8D25","settings.sandbox.state.remove_failed":"\u79FB\u9664\u5931\u8D25","settings.sandbox.state.recovery_required":"\u9700\u8981\u6062\u590D\u5904\u7406","settings.sandbox.stage.reserving_capacity":"\u6B63\u5728\u9884\u7559\u5BB9\u91CF","settings.sandbox.stage.starting":"\u6B63\u5728\u542F\u52A8 Sandbox","settings.sandbox.stage.stopping":"\u6B63\u5728\u505C\u6B62 Sandbox","settings.sandbox.stage.retrying":"\u6B63\u5728\u91CD\u8BD5\u64CD\u4F5C","settings.sandbox.stage.removing":"\u6B63\u5728\u79FB\u9664 Sandbox","settings.sandbox.stage.complete":"\u5DF2\u5B8C\u6210","settings.sandbox.stage.dispatching":"\u6B63\u5728\u5B89\u5168\u5206\u53D1","settings.sandbox.stage.capacity_rejected":"\u6B63\u5728\u7B49\u5F85\u5BB9\u91CF","settings.sandbox.unavailable.disabled":"\u6B64 Server \u5C1A\u672A\u542F\u7528 Sandbox\u3002\u5347\u7EA7\u672C\u673A Agent \u4E0D\u4F1A\u81EA\u52A8\u542F\u7528\uFF1B\u9700\u8981 Server \u7BA1\u7406\u5458\u5F00\u542F Docker \u7BA1\u7406\u3002","settings.sandbox.unavailable.dockerUnavailable":"Server \u65E0\u6CD5\u4F7F\u7528 Docker\uFF0C\u8BF7\u68C0\u67E5 Sandbox \u7684 Server \u90E8\u7F72\u914D\u7F6E\u3002","settings.sandbox.unavailable.notEntitled":"\u6B64\u8D26\u53F7\u6682\u4E0D\u53EF\u4F7F\u7528 Sandbox\u3002","settings.sandbox.unavailable.capacityUnavailable":"Sandbox \u6682\u65F6\u4E0D\u53EF\u7528\u3002","settings.sandbox.error.SANDBOX_LOAD_FAILED":"\u65E0\u6CD5\u52A0\u8F7D Sandbox \u72B6\u6001\u3002","settings.sandbox.retryLoad":"\u91CD\u8BD5","settings.sandbox.error.SANDBOX_CREATE_FAILED":"\u65E0\u6CD5\u521B\u5EFA Sandbox\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002","settings.sandbox.error.SANDBOX_ACTION_FAILED":"\u65E0\u6CD5\u5B89\u6392 Sandbox \u64CD\u4F5C\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002","settings.sandbox.error.SANDBOX_OPERATION_TIMEOUT":"\u64CD\u4F5C\u5DF2\u8D85\u65F6\uFF0C\u8BF7\u91CD\u8BD5\u6216\u79FB\u9664 Sandbox\u3002","settings.sandbox.error.SANDBOX_RUNTIME_FAILED":"Sandbox \u8FD0\u884C\u65F6\u62A5\u544A\u5931\u8D25\u3002","settings.sandbox.error.SANDBOX_CGROUP_SLICE_UNAVAILABLE":"\u65E0\u6CD5\u5728\u5BBF\u4E3B\u673A\u521D\u59CB\u5316\u5171\u4EAB\u8D44\u6E90 slice\uFF08\u9700\u8981 cgroup v2 \u4E0E root \u6743\u9650\uFF09\u3002\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458\uFF0C\u6216\u79FB\u9664 SANDBOX_CGROUP_PARENT \u4EE5\u5173\u95ED\u8D44\u6E90\u4E0A\u9650\u3002","settings.account.username":"\u7528\u6237\u540D","settings.account.role":"\u89D2\u8272","settings.account.email":"\u90AE\u7BB1","settings.account.emailNotSet":"\u672A\u8BBE\u7F6E","settings.account.profileLoadFailed":"\u8D26\u53F7\u8D44\u6599\u52A0\u8F7D\u5931\u8D25","settings.account.logout":"\u9000\u51FA\u767B\u5F55","settings.account.roleAdmin":"\u7BA1\u7406\u5458","settings.account.rolePro":"Pro","settings.account.linkedAccounts":"\u5DF2\u5173\u8054\u8D26\u6237","settings.account.linkedDesc":"\u5173\u8054\u7B2C\u4E09\u65B9\u767B\u5F55\u540E\uFF0C\u4F7F\u7528\u4EFB\u610F\u4E00\u79CD\u65B9\u5F0F\u90FD\u80FD\u767B\u5F55\u6B64\u8D26\u53F7\u3002","settings.account.bind":"\u7ED1\u5B9A","settings.account.unbind":"\u89E3\u7ED1","settings.account.linked":"\u5DF2\u7ED1\u5B9A","settings.account.providerDisabled":"\u672A\u914D\u7F6E","settings.account.cantUnbindLast":"\u4E0D\u80FD\u89E3\u7ED1\u552F\u4E00\u7684\u767B\u5F55\u65B9\u5F0F","settings.account.unbindFailed":"\u89E3\u7ED1\u5931\u8D25\uFF1A{error}","settings.account.bindFailed":"\u7ED1\u5B9A\u5931\u8D25","settings.account.ssoBoundMsg":"\u5DF2\u6210\u529F\u7ED1\u5B9A {provider}\u3002","settings.account.ssoConflictMsg":"\u8BE5 {provider} \u8D26\u53F7\u5DF2\u88AB\u5176\u4ED6\u7528\u6237\u7ED1\u5B9A\u3002","settings.account.providerMicrosoft":"Microsoft","settings.account.providerGithub":"GitHub","settings.account.providerGoogle":"Google","settings.account.providerWechat":"\u5FAE\u4FE1","settings.account.providerAlipay":"\u652F\u4ED8\u5B9D","settings.security.agentKey":"Agent \u5BC6\u94A5","settings.security.agentKeyDesc":"\u7528\u4E8E Agent \u8FDE\u63A5\u8BA4\u8BC1\u7684\u5171\u4EAB\u5BC6\u94A5","settings.security.agentSetupCommands":"Agent \u63A5\u5165\u547D\u4EE4","settings.security.agentCmdInstall":"\u5B89\u88C5 Agent","settings.security.agentCmdService":"\u8FD0\u884C Agent server","settings.security.agentCmdContainer":"\u5728 Docker \u4E2D\u8FD0\u884C Agent","settings.security.agentCmdContainerDesc":"\u4E00\u6761\u547D\u4EE4\u5373\u53EF\u3002\u9996\u6B21\u8FD0\u884C\u4F1A\u81EA\u52A8\u521D\u59CB\u5316\u5171\u4EAB CPU/\u5185\u5B58\u9650\u5236\uFF08\u4F1A\u63D0\u793A\u8F93\u5165\u4E00\u6B21 sudo \u5BC6\u7801\uFF09\uFF1B\u4F20 --no-slice \u53EF\u4E0D\u542F\u7528\u8D44\u6E90\u4FDD\u62A4\u3002\u673A\u5668\u4E0A\u9700\u8981\u5DF2\u5B89\u88C5 Docker\u3002","settings.security.agentCmdNeedsSecret":"\u8BF7\u5148\u751F\u6210 Agent \u5BC6\u94A5\uFF0C\u4EE5\u521B\u5EFA\u5305\u542B server \u5730\u5740\u548C\u5BC6\u94A5\u7684\u547D\u4EE4\u3002","settings.security.agentCmdLlm":"Copilot \u624B\u52A8\u515C\u5E95","settings.security.agentCmdLlmDesc":"\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.general.telemetry":"\u6027\u80FD\u9065\u6D4B","settings.general.telemetryDesc":"\u5728\u672C\u5730\u6279\u91CF\u8BB0\u5F55\u8017\u65F6\u8BCA\u65AD\uFF1Btrace \u5185\u5BB9\u4E0D\u4F1A\u53D1\u9001\u5230\u670D\u52A1\u5668\u3002","settings.general.telemetryOn":"\u5F00\u542F","settings.general.telemetryOff":"\u5173\u95ED","settings.general.telemetryRawLimit":"Provider \u539F\u59CB\u8BF7\u6C42/\u54CD\u5E94\u4E0A\u9650\uFF08\u5B57\u8282\uFF09","settings.general.telemetryTraceTextLimit":"Debug Prompt \u4E0E\u6D88\u606F\u4E0A\u9650\uFF08\u5B57\u8282\uFF09","settings.invite.create":"\u521B\u5EFA\u9080\u8BF7\u7801","settings.invite.normalUser":"\u666E\u901A\u7528\u6237","settings.invite.proUser":"Pro \u7528\u6237","settings.invite.createBtn":"\u521B\u5EFA\u9080\u8BF7\u7801","settings.invite.creating":"\u521B\u5EFA\u4E2D...","settings.invite.list":"\u9080\u8BF7\u7801\u5217\u8868","settings.invite.used":"\u5DF2\u4F7F\u7528","settings.invite.expired":"\u5DF2\u8FC7\u671F","settings.invite.available":"\u53EF\u7528","settings.invite.usedBy":"\u4F7F\u7528\u8005: {user}","settings.invite.expiredAt":"\u8FC7\u671F\u4E8E: {time}","settings.invite.expiresAt":"\u6709\u6548\u81F3: {time}","settings.invite.noInvites":"\u6682\u65E0\u9080\u8BF7\u7801","settings.msg.copiedClipboard":"\u5DF2\u590D\u5236\u5230\u526A\u8D34\u677F","settings.msg.copyFailed":"\u590D\u5236\u5931\u8D25","settings.msg.keyReset":"\u5BC6\u94A5\u5DF2\u91CD\u7F6E","settings.msg.resetFailed":"\u91CD\u7F6E\u5931\u8D25","settings.msg.changeFailed":"\u4FEE\u6539\u5931\u8D25","settings.msg.inviteCreated":"\u9080\u8BF7\u7801\u5DF2\u521B\u5EFA","settings.msg.createFailed":"\u521B\u5EFA\u5931\u8D25","settings.msg.inviteCopied":"\u9080\u8BF7\u7801\u5DF2\u590D\u5236","settings.msg.inviteDeleted":"\u9080\u8BF7\u7801\u5DF2\u5220\u9664","settings.msg.deleteFailed":"\u5220\u9664\u5931\u8D25","settings.tabs.llm":"LLM","settings.tabs.yeaft":"Yeaft","settings.yeaft.tabs.vp":"VP \u5E93","settings.yeaft.tabs.search":"\u641C\u7D22","settings.yeaft.tabs.mcp":"MCP","settings.mcp.title":"MCP \u670D\u52A1\u5668","settings.mcp.description":"\u901A\u8FC7 Model Context Protocol \u7ED9 Yeaft \u63A5\u5165\u66F4\u591A\u5DE5\u5177\u3002\u914D\u7F6E\u5199\u5165 agent \u4E0A\u7684 ~/.yeaft/config.json\uFF0C\u5DE5\u5177\u4F1A\u4EE5 mcp__<server>__<tool> \u7684\u5F62\u5F0F\u51FA\u73B0\u5728 LLM \u5DE5\u5177\u5217\u8868\u91CC\u3002","settings.mcp.reloadAll":"\u5168\u90E8\u91CD\u8FDE","settings.mcp.reloadOne":"\u91CD\u65B0\u8FDE\u63A5\u6B64\u670D\u52A1\u5668","settings.mcp.loading":"\u5904\u7406\u4E2D\u2026","settings.mcp.connected":"\u5DF2\u8FDE\u63A5","settings.mcp.disconnected":"\u672A\u8FDE\u63A5","settings.mcp.tools":"\u4E2A\u5DE5\u5177","settings.mcp.remove":"\u79FB\u9664","settings.mcp.empty":"\u8FD8\u6CA1\u6709\u914D\u7F6E MCP \u670D\u52A1\u5668\uFF0C\u53EF\u4EE5\u5728\u4E0B\u65B9\u6DFB\u52A0\u4E00\u4E2A\u3002","settings.mcp.addServer":"\u6DFB\u52A0\u670D\u52A1\u5668","settings.mcp.addServerDesc":"\u5927\u90E8\u5206 MCP \u670D\u52A1\u5668\u662F\u672C\u5730\u547D\u4EE4 \u2014 Yeaft \u4F1A\u901A\u8FC7 stdio \u542F\u52A8\u5B83\u5E76\u81EA\u52A8\u53D1\u73B0\u53EF\u7528\u5DE5\u5177\u3002","settings.mcp.serverName":"\u540D\u79F0","settings.mcp.command":"\u547D\u4EE4","settings.mcp.args":"\u53C2\u6570","settings.mcp.argsPlaceholder":"\u4F8B\u5982\uFF1A-y @modelcontextprotocol/server-filesystem /tmp","settings.mcp.env":"\u73AF\u5883\u53D8\u91CF","settings.mcp.envPlaceholder":"\u6BCF\u884C\u4E00\u4E2A KEY=value\uFF0C# \u5F00\u5934\u7684\u884C\u4F1A\u88AB\u5FFD\u7565\u3002","settings.mcp.saving":"\u4FDD\u5B58\u4E2D\u2026","settings.mcp.add":"\u6DFB\u52A0","settings.mcp.cancel":"\u6E05\u7A7A","settings.mcp.connectFailed":"\u5DF2\u4FDD\u5B58\u4F46\u8FDE\u63A5\u5931\u8D25","settings.mcp.addSuccess":"\u670D\u52A1\u5668\u5DF2\u6DFB\u52A0","settings.mcp.removeSuccess":"\u670D\u52A1\u5668\u5DF2\u79FB\u9664","settings.mcp.reloadSuccess":"\u5DF2\u8BF7\u6C42\u91CD\u8FDE","settings.mcp.confirmRemove":'\u79FB\u9664 MCP \u670D\u52A1\u5668 "{name}"\uFF1F\u4E0B\u4E00\u4E2A LLM turn \u8D77\u5B83\u7684\u5DE5\u5177\u5C06\u4E0D\u518D\u53EF\u89C1\u3002',"settings.mcp.errors.nameRequired":"\u8BF7\u586B\u5199\u540D\u79F0","settings.mcp.errors.nameFormat":"\u540D\u79F0\u53EA\u80FD\u5305\u542B\u5C0F\u5199\u5B57\u6BCD\u3001\u6570\u5B57\u3001\u77ED\u6A2A\u7EBF\u548C\u4E0B\u5212\u7EBF","settings.mcp.errors.commandRequired":"\u8BF7\u586B\u5199\u547D\u4EE4","settings.mcp.errors.argsParse":"\u53C2\u6570\u89E3\u6790\u5931\u8D25","settings.mcp.errors.envParse":"\u73AF\u5883\u53D8\u91CF\u89E3\u6790\u5931\u8D25","yeaft.session.title":"\u4F1A\u8BDD","yeaft.session.new":"+ \u65B0\u5EFA\u4F1A\u8BDD","yeaft.session.create.title":"\u65B0\u5EFA\u4F1A\u8BDD","yeaft.session.create.subtitle":"\u9009\u62E9\u8FD0\u884C\u4F4D\u7F6E\u548C\u5904\u7406\u4F1A\u8BDD\u7684 Provider\u3002","yeaft.session.create.close":"\u5173\u95ED","yeaft.session.create.nameLabel":"\u540D\u79F0","yeaft.session.create.namePlaceholder":"\u4F1A\u8BDD\u540D\u79F0\uFF08\u53EF\u9009\uFF09","yeaft.session.create.workDirLabel":"\u5DE5\u4F5C\u76EE\u5F55","yeaft.session.create.agentLabel":"Agent","yeaft.session.create.vpPicker":"\u9009\u62E9 VP","yeaft.session.create.vpNone":"\u672A\u9009\u62E9 VP","yeaft.session.create.vpCount":"\u5DF2\u9009 {n} \u4E2A VP","yeaft.session.create.untitled":"\u672A\u547D\u540D\u4F1A\u8BDD","yeaft.session.create.rosterEmpty":"\u6682\u65E0\u53EF\u7528 VP \u2014 \u8BF7\u5148\u5230\u89D2\u8272\u5E93\u521B\u5EFA\u3002","yeaft.session.create.rosterLoading":"VP \u52A0\u8F7D\u4E2D\u2026","yeaft.session.create.rosterError":"\u65E0\u6CD5\u4ECE\u5F53\u524D Agent \u52A0\u8F7D VP\u3002","yeaft.session.create.rosterRetry":"\u91CD\u8BD5","yeaft.vp.domain.general":"\u901A\u7528\u4E0E\u534F\u4F5C","yeaft.vp.domain.productDesign":"\u4EA7\u54C1\u4E0E\u4F53\u9A8C\u8BBE\u8BA1","yeaft.vp.domain.softwareSystems":"\u8F6F\u4EF6\u4E0E\u7CFB\u7EDF","yeaft.vp.domain.securityReliability":"\u5B89\u5168\u4E0E\u53EF\u9760\u6027","yeaft.vp.domain.scienceAnalysis":"\u79D1\u5B66\u4E0E\u5206\u6790","yeaft.vp.domain.philosophyPsychology":"\u54F2\u5B66\u4E0E\u5FC3\u7406","yeaft.vp.domain.strategyHistory":"\u6218\u7565\u4E0E\u5386\u53F2","yeaft.vp.domain.businessManagement":"\u5546\u4E1A\u4E0E\u7BA1\u7406","yeaft.vp.domain.artsCulture":"\u827A\u672F\u4E0E\u6587\u5316","yeaft.vp.domain.other":"\u5176\u4ED6\u9886\u57DF","yeaft.vp.domain.custom":"\u81EA\u5B9A\u4E49 VP","yeaft.session.create.defaultVpHint":"\u5F53\u6CA1\u6709 @ \u63D0\u53CA\u65F6\u9ED8\u8BA4\u56DE\u7B54\u7684 VP\u3002","yeaft.session.create.folderLabel":"\u{1F4C1} \u5DE5\u4F5C\u76EE\u5F55","yeaft.session.create.sessionLabel":"\u{1F4AC} \u6B64\u76EE\u5F55\u4E0B\u7684 session","yeaft.session.create.noWorkDirs":"\u8FD8\u6CA1\u6709\u4EFB\u4F55\u4F1A\u8BDD \u2014 \u5728\u4E0A\u65B9\u9009\u62E9\u6216\u8F93\u5165\u5DE5\u4F5C\u76EE\u5F55\u5F00\u59CB\u3002","yeaft.session.create.back":"\u8FD4\u56DE","yeaft.session.create.creating":"\u521B\u5EFA\u4E2D\u2026","yeaft.session.create.submit":"\u521B\u5EFA","yeaft.plugins.title":"\u63D2\u4EF6","yeaft.plugins.subtitle":"\u9009\u62E9\u6B64 Agent \u5411\u4F1A\u8BDD\u63D0\u4F9B\u54EA\u4E9B\u5DE5\u5177\u3001\u6280\u80FD\u548C MCP \u670D\u52A1\u5668\u3002","yeaft.plugins.agentLabel":"Agent","yeaft.plugins.overviewLabel":"\u63D2\u4EF6\u53EF\u7528\u6027\u6982\u89C8","yeaft.plugins.noAgent":"\u672A\u9009\u62E9 Agent","yeaft.plugins.allAvailable":"\u5DF2\u542F\u7528\u5168\u90E8\u53EF\u7528\u80FD\u529B\u3002","yeaft.plugins.selectedSummary":"\u5DF2\u542F\u7528 {count} \u9879\u80FD\u529B\u3002","yeaft.plugins.enabledLabel":"\u5DF2\u542F\u7528","yeaft.plugins.useAll":"\u4F7F\u7528\u5168\u90E8\u53EF\u7528\u9879","yeaft.plugins.loading":"\u6B63\u5728\u52A0\u8F7D\u63D2\u4EF6\u2026","yeaft.plugins.empty":"\u6B64 Agent \u6CA1\u6709\u53EF\u914D\u7F6E\u7684\u63D2\u4EF6\u3002","yeaft.plugins.loadError":"\u52A0\u8F7D\u63D2\u4EF6\u5931\u8D25\uFF1A{error}","yeaft.plugins.upgradeRequired":"\u6B64 Agent \u4E0D\u652F\u6301\u63D2\u4EF6\u3002\u8BF7\u5347\u7EA7\u5E76\u91CD\u542F\u8BE5 Agent\u3002","yeaft.plugins.retry":"\u91CD\u8BD5","yeaft.plugins.searchPlaceholder":"\u641C\u7D22\u5DE5\u5177\u3001\u6280\u80FD\u548C MCP \u670D\u52A1\u5668","yeaft.plugins.resultCount":"{count} \u4E2A\u7ED3\u679C","yeaft.plugins.categoryLabel":"\u63D2\u4EF6\u5206\u7C7B","yeaft.plugins.all":"\u5168\u90E8","yeaft.plugins.noMatchesTitle":"\u6CA1\u6709\u5339\u914D\u7684\u63D2\u4EF6","yeaft.plugins.noMatchesBody":"\u8BF7\u5C1D\u8BD5\u5176\u4ED6\u641C\u7D22\u8BCD\u6216\u5206\u7C7B\u3002","yeaft.plugins.toolDescription":"Agent \u5185\u7F6E\u80FD\u529B","yeaft.plugins.skillDescription":"\u53EF\u590D\u7528\u7684 Agent \u5DE5\u4F5C\u6D41","yeaft.plugins.mcpDescription":"\u53EF\u63D0\u4F9B {count} \u4E2A\u5DE5\u5177","yeaft.plugins.unsavedChanges":"\u6709\u672A\u4FDD\u5B58\u7684\u4FEE\u6539","yeaft.plugins.tools":"\u5DE5\u5177","yeaft.plugins.skills":"\u6280\u80FD","yeaft.plugins.mcpServers":"MCP \u670D\u52A1\u5668","yeaft.plugins.toolsCount":"\u4E2A\u5DE5\u5177","yeaft.plugins.manageSkills":"\u7BA1\u7406\u6280\u80FD","yeaft.plugins.manageSkillsDescription":"\u4E3A\u6B64 Agent \u6216\u5F53\u524D\u9879\u76EE\u521B\u5EFA\u53EF\u590D\u7528\u6280\u80FD\u3002\u9879\u76EE\u7EA7\u6280\u80FD\u4F1A\u8986\u76D6\u540C\u540D\u7528\u6237\u7EA7\u6280\u80FD\u3002","yeaft.plugins.createSkill":"\u521B\u5EFA\u6280\u80FD","yeaft.plugins.removeSkill":"\u79FB\u9664","yeaft.plugins.confirmRemoveSkill":"\u79FB\u9664\u6280\u80FD\u201C{name}\u201D\uFF1F\u8FD9\u53EA\u4F1A\u5220\u9664\u8BE5\u5C42\u7EA7\u4E2D\u7684\u539F\u751F\u6280\u80FD\u3002","yeaft.plugins.skillManagementUpgradeRequired":"\u6B64 Agent \u5FC5\u987B\u5347\u7EA7\u540E\u624D\u80FD\u521B\u5EFA\u6216\u79FB\u9664\u6280\u80FD\u3002","yeaft.plugins.skillManagementVersionUnknown":"\u6B64 Agent \u5C1A\u672A\u4E0A\u62A5\u6280\u80FD\u7BA1\u7406\u652F\u6301\u3002\u8BF7\u5347\u7EA7\u5E76\u91CD\u542F\u540E\u518D\u521B\u5EFA\u6216\u79FB\u9664\u6280\u80FD\u3002","yeaft.plugins.skillScope":"\u5C42\u7EA7","yeaft.plugins.userScope":"\u7528\u6237\u7EA7","yeaft.plugins.projectScope":"\u9879\u76EE\u7EA7","yeaft.plugins.userScopeDescription":"\u5BF9\u8BE5 Agent \u8FD0\u884C\u7684\u6240\u6709\u9879\u76EE\u53EF\u7528\u3002","yeaft.plugins.projectScopeDescription":"\u53EA\u5BF9\u5F53\u524D\u9879\u76EE\u53EF\u7528\uFF0C\u5E76\u8986\u76D6\u540C\u540D\u7528\u6237\u7EA7\u6280\u80FD\u3002","yeaft.plugins.projectScopeUnavailable":"\u8BF7\u9009\u62E9\u5E26\u9879\u76EE\u76EE\u5F55\u7684 Session\uFF0C\u624D\u80FD\u7BA1\u7406\u9879\u76EE\u7EA7\u6280\u80FD\u3002","yeaft.plugins.skillName":"\u540D\u79F0","yeaft.plugins.skillDescriptionLabel":"\u8BF4\u660E","yeaft.plugins.skillTrigger":"\u89E6\u53D1\u8BCD\uFF08\u53EF\u9009\uFF09","yeaft.plugins.skillInstructions":"\u6307\u4EE4","yeaft.plugins.resetSkillForm":"\u91CD\u7F6E","yeaft.plugins.skillTier.bundled":"\u5185\u7F6E \xB7 \u53EA\u8BFB","yeaft.plugins.skillTier.user":"\u7528\u6237\u7EA7","yeaft.plugins.skillTier.project":"\u9879\u76EE\u7EA7","yeaft.plugins.skillTier.project-claude":"Claude \u9879\u76EE \xB7 \u53EA\u8BFB","yeaft.plugins.skillTier.project-codex":"Codex \u9879\u76EE \xB7 \u53EA\u8BFB","yeaft.onboarding.ariaLabel":"Yeaft \u4E0A\u624B\u8BF4\u660E","yeaft.onboarding.topbarTitle":"\u5F00\u59CB\u4F7F\u7528 Yeaft","yeaft.onboarding.eyebrow":"Yeaft \u4E0A\u624B\u6307\u5357","yeaft.onboarding.title":"\u5148\u8FDE\u63A5 Agent\uFF0C\u518D\u5F00\u59CB\u4F1A\u8BDD","yeaft.onboarding.subtitle":"\u5728\u8D1F\u8D23\u6267\u884C\u5DE5\u5177\u7684\u673A\u5668\u4E0A\u76F4\u63A5\u8FD0\u884C\u4E0B\u9762\u7684\u547D\u4EE4\u3002agent secret \u5982\u679C\u4E0D\u5B58\u5728\uFF0C\u4F1A\u81EA\u52A8\u4E3A\u5F53\u524D\u8D26\u53F7\u751F\u6210\u3002","yeaft.onboarding.createSession":"\u521B\u5EFA\u6216\u6062\u590D Session","yeaft.onboarding.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.debugTitle":"\u8C03\u8BD5\u8F68\u8FF9","settings.llm.debugDesc":"\u6309 Agent \u5F00\u542F\u9010\u8F6E\u8C03\u8BD5\u8F68\u8FF9\u6536\u96C6\uFF08\u7CFB\u7EDF\u63D0\u793A\u8BCD\u3001LLM \u8C03\u7528\u3001\u5DE5\u5177\u8F7D\u8377\uFF09\u3002","settings.llm.enableDebug":"\u542F\u7528\u8C03\u8BD5\u8F68\u8FF9","settings.llm.save":"\u4FDD\u5B58\u66F4\u6539","settings.llm.saving":"\u4FDD\u5B58\u4E2D...","settings.llm.saved":"\u914D\u7F6E\u5DF2\u4FDD\u5B58","settings.llm.savedRefreshWarning":"\u914D\u7F6E\u5DF2\u4FDD\u5B58\uFF0C\u4F46\u5B9E\u65F6\u6A21\u578B\u76EE\u5F55\u5237\u65B0\u5931\u8D25\uFF1A{error}","settings.llm.unsavedChanges":"\u6709\u672A\u4FDD\u5B58\u7684\u66F4\u6539","settings.llm.confirmRemoveProvider":"\u786E\u5B9A\u79FB\u9664\u6B64\u670D\u52A1\u5546\uFF1F","settings.llm.setupTitle":"\u8FDE\u63A5\u6A21\u578B","settings.llm.setupDesc":"\u63A8\u8350\u4F7F\u7528 GitHub Copilot\uFF1B\u4E5F\u53EF\u4EE5\u6DFB\u52A0\u81EA\u5DF1\u7684 API \u670D\u52A1\u5546\u3002","settings.llm.providerSectionHint":"\u53EA\u4FDD\u7559\u8FDE\u63A5\u6A21\u578B\u5FC5\u9700\u7684\u4FE1\u606F\u3002","settings.tabs.dashboard":"\u4EEA\u8868\u677F","settings.dashboard.totalUsers":"\u603B\u7528\u6237\u6570","settings.dashboard.onlineUsers":"\u5728\u7EBF\u7528\u6237","settings.dashboard.activeUsers":"\u6D3B\u8DC3\u7528\u6237","settings.dashboard.onlineAgents":"\u5728\u7EBFAgent","settings.dashboard.totalSessions":"\u603B\u4F1A\u8BDD\u6570","settings.dashboard.todayActive":"\u4ECA\u65E5\u6D3B\u8DC3","settings.dashboard.todayMessages":"\u4ECA\u65E5\u6D88\u606F","settings.dashboard.todayUserTurns":"\u4ECA\u65E5\u7528\u6237 Turn","settings.dashboard.totalTokens":"\u603B Token","settings.dashboard.tokenAccuracy":"\u6765\u81EA\u6A21\u578B\u670D\u52A1\u5546\u8FD4\u56DE\u7684\u5B9E\u9645\u7528\u91CF\uFF1B\u4ECE\u542F\u7528\u6309\u7528\u6237 Token \u7EDF\u8BA1\u7684\u7248\u672C\u5F00\u59CB\u7D2F\u8BA1\uFF0C\u4E14\u4E0D\u5305\u542B\u5FC3\u8DF3\u3002","settings.dashboard.agentTurns":"Agent Turn","settings.dashboard.agentSessions":"Agent Session","settings.dashboard.turns":"Turn","settings.dashboard.tokens":"Token","settings.dashboard.inputTokens":"\u8F93\u5165","settings.dashboard.outputTokens":"\u8F93\u51FA","settings.dashboard.cacheTokens":"\u7F13\u5B58","settings.dashboard.today":"\u4ECA\u5929","settings.dashboard.thisWeek":"\u672C\u5468","settings.dashboard.thisMonth":"\u672C\u6708","settings.dashboard.all":"\u5168\u90E8","settings.dashboard.general":"\u5E38\u89C4","settings.dashboard.detailed":"\u8BE6\u7EC6\u4FE1\u606F","settings.dashboard.users":"\u7528\u6237","settings.dashboard.agents":"Agent","settings.dashboard.time":"\u65F6\u95F4","settings.dashboard.active":"\u6D3B\u8DC3","settings.dashboard.inactive":"\u672A\u6D3B\u8DC3","settings.dashboard.activeOnly":"\u4EC5\u6D3B\u8DC3","settings.dashboard.inactiveOnly":"\u4EC5\u672A\u6D3B\u8DC3","settings.dashboard.userUsage":"\u7528\u6237\u7528\u91CF","settings.dashboard.refresh":"\u5237\u65B0","settings.dashboard.name":"\u540D\u79F0","settings.dashboard.messages":"\u6D88\u606F\u6570","settings.dashboard.userTurns":"\u7528\u6237 Turn \u6570","settings.dashboard.sessions":"\u4F1A\u8BDD\u6570","settings.dashboard.requests":"\u8BF7\u6C42\u6570","settings.dashboard.traffic":"\u6D41\u91CF","settings.dashboard.lastTurnCompleted":"\u6700\u540E Turn \u7ED3\u675F\u65F6\u95F4","settings.dashboard.status":"\u72B6\u6001","settings.dashboard.latency":"\u5EF6\u8FDF","settings.dashboard.version":"\u7248\u672C","settings.dashboard.owner":"\u6240\u6709\u8005","settings.dashboard.role":"\u89D2\u8272","settings.dashboard.agent":"Agent","settings.dashboard.online":"\u5728\u7EBF","settings.dashboard.offline":"\u79BB\u7EBF","settings.dashboard.noAgents":"\u6682\u65E0\u6CE8\u518C Agent","settings.dashboard.noUserData":"\u6682\u65E0\u7528\u6237\u6570\u636E","settings.dashboard.noOnlineUsers":"\u6682\u65E0\u5728\u7EBF\u7528\u6237","settings.dashboard.loading":"\u52A0\u8F7D\u4E2D...","settings.dashboard.error":"\u6570\u636E\u52A0\u8F7D\u5931\u8D25","settings.dashboard.ago":"{time}\u524D","settings.dashboard.loadMore":"\u52A0\u8F7D\u66F4\u591A\uFF08\u5269\u4F59 {remaining} \u6761\uFF09","workbench.title":"Workbench","workbench.openItems":"\u5DF2\u6253\u5F00\u7684 Workbench \u9879\u76EE","workbench.addItem":"\u6DFB\u52A0 Workbench \u9879\u76EE","workbench.addItemHint":"\u4F7F\u7528 + \u6253\u5F00\u6587\u4EF6\u3001\u7EC8\u7AEF\u3001Git \u6216\u6D4F\u89C8\u5668\u3002","workbench.closeItem":"\u5173\u95ED {name}","workbench.chooseCapability":"\u9009\u62E9\u80FD\u529B","workbench.chooseCapabilityHint":"\u9009\u62E9\u4E00\u4E2A\u5DE5\u5177\u5F00\u59CB\u4F7F\u7528\uFF1B\u5DF2\u6253\u5F00\u7684\u5DE5\u5177\u4F1A\u4FDD\u7559\u5728\u6807\u7B7E\u9875\u4E2D\u3002","workbench.terminal":"\u7EC8\u7AEF","workbench.terminalDescription":"\u5728\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55\u8FD0\u884C\u547D\u4EE4\u5E76\u7BA1\u7406\u7EC8\u7AEF\u5206\u5C4F\u3002","workbench.git":"Git","workbench.gitDescription":"\u67E5\u770B\u4ED3\u5E93\u72B6\u6001\u3001\u4EE3\u7801\u5DEE\u5F02\u548C\u53D8\u66F4\u6587\u4EF6\u3002","workbench.files":"\u6587\u4EF6","workbench.filesDescription":"\u6D4F\u89C8\u3001\u9884\u89C8\u548C\u7F16\u8F91\u6240\u9009 Agent \u4E0A\u7684\u6587\u4EF6\u3002","workbench.browser":"\u6D4F\u89C8\u5668","workbench.browserDescription":"\u901A\u8FC7\u5B9E\u65F6 WebRTC \u753B\u9762\u67E5\u770B Agent \u672C\u5730\u6D4F\u89C8\u5668\u3002","workbench.available":"\u53EF\u7528","workbench.enableRequired":"\u9700\u8981\u542F\u7528","workbench.unavailable":"\u5F53\u524D Agent \u4E0D\u53EF\u7528","workbench.capabilityUnavailable":"\u6240\u9009 Agent \u672A\u63D0\u4F9B\u6B64\u80FD\u529B\u3002","workbench.browserUnavailable":"\u6D4F\u89C8\u5668\u5DF2\u88AB\u7BA1\u7406\u5458\u5173\u95ED\uFF0C\u6216\u5F53\u524D Agent \u4E0D\u652F\u6301\u3002\u8BF7\u5347\u7EA7 Agent\uFF0C\u6216\u8BA9\u7BA1\u7406\u5458\u5F00\u542F\u6D4F\u89C8\u5668\u8DEF\u7531\u3002","workbench.browserReadyHint":"\u8F93\u5165\u5730\u5740\u4EE5\u542F\u52A8\u9694\u79BB\u7684 Agent \u672C\u5730\u6D4F\u89C8\u5668\u3002\u70B9\u51FB\u5B9E\u65F6\u753B\u9762\u540E\u53EF\u4F7F\u7528\u9F20\u6807\u548C\u952E\u76D8\u4EA4\u4E92\u3002","workbench.browserStart":"\u542F\u52A8\u6D4F\u89C8\u5668","workbench.browserAddressLabel":"\u6D4F\u89C8\u5668\u5730\u5740","workbench.browserAddressPlaceholder":"example.com","workbench.browserAddressInvalid":"\u8BF7\u8F93\u5165\u6709\u6548\u7684 HTTP \u6216 HTTPS \u5730\u5740\u3002","workbench.browserInteractionUnavailable":"\u6D4F\u89C8\u5668\u8F93\u5165\u94FE\u8DEF\u5C1A\u672A\u8FDE\u63A5\uFF0C\u8BF7\u7B49\u5F85 WebRTC \u8FDE\u63A5\u540E\u91CD\u8BD5\u3002","workbench.browserGo":"\u524D\u5F80","workbench.browserStarting":"\u6B63\u5728\u542F\u52A8 Agent \u672C\u5730\u6D4F\u89C8\u5668\u2026","workbench.browserConnecting":"\u6B63\u5728\u8FDE\u63A5\u5B9E\u65F6 WebRTC \u753B\u9762\u2026","workbench.browserIceServersMissing":"\u6D4F\u89C8\u5668\u753B\u9762\u65E0\u6CD5\u8FDE\u63A5\u5F53\u524D Agent\uFF0C\u4E14 Server \u672A\u914D\u7F6E STUN \u6216 TURN \u670D\u52A1\u3002\u8BF7\u8BA9\u7BA1\u7406\u5458\u914D\u7F6E Browser ICE/TURN \u540E\u91CD\u8BD5\u3002","workbench.browserIceConnectionFailed":"\u6D4F\u89C8\u5668 WebRTC \u8FDE\u63A5\u5931\u8D25\u3002\u8BF7\u68C0\u67E5\u5DF2\u914D\u7F6E\u7684 TURN \u670D\u52A1\u662F\u5426\u80FD\u88AB Web \u6D4F\u89C8\u5668\u548C Agent \u540C\u65F6\u8BBF\u95EE\uFF0C\u7136\u540E\u91CD\u8BD5\u3002","workbench.browserPeerAttachTimeout":"\u8FDE\u63A5\u6D4F\u89C8\u5668 WebRTC \u753B\u9762\u8D85\u65F6\u3002\u8BF7\u68C0\u67E5 Browser ICE/TURN \u8FDE\u901A\u6027\uFF0C\u7136\u540E\u91CD\u8BD5\u3002","workbench.browserEnd":"\u7ED3\u675F\u6D4F\u89C8\u5668","workbench.browserVideoLabel":"Agent \u6D4F\u89C8\u5668\u5B9E\u65F6\u753B\u9762","workbench.browserInputLabel":"\u6D4F\u89C8\u5668\u952E\u76D8\u8F93\u5165","workbench.browserStatusConnecting":"\u8FDE\u63A5\u4E2D","workbench.browserProtocolUnavailable":"\u5F53\u524D Server \u8FDE\u63A5\u4E0D\u652F\u6301 Browser Runtime \u534F\u8BAE\u3002","workbench.browserChecking":"\u6B63\u5728\u68C0\u67E5\u6240\u9009 Agent \u7684 Browser Runtime\u2026","workbench.browserPlatformUnsupported":"\u6240\u9009 Agent \u65E0\u6CD5\u8FD0\u884C\u5F53\u524D Browser Runtime \u6570\u636E\u94FE\u8DEF\u3002","workbench.browserSetupTitle":"\u542F\u7528\u6D4F\u89C8\u5668","workbench.browserOptionalInstall":"\u6D4F\u89C8\u5668\u9700\u8981\u5728\u5F53\u524D Agent \u5B89\u88C5\u56FA\u5B9A\u7248\u672C Chrome for Testing\u3002\u542F\u7528\u540E\u5C06\u4E0B\u8F7D\u7EA6 {size}\uFF0C\u6821\u9A8C\u5E76\u5B89\u88C5\u7248\u672C {build}\uFF0C\u7136\u540E\u68C0\u67E5\u5A92\u4F53\u94FE\u8DEF\u3002","workbench.browserInstallDiskNote":"\u70B9\u51FB\u201C\u542F\u7528\u6D4F\u89C8\u5668\u201D\u524D\u4E0D\u4F1A\u4E0B\u8F7D\u4EFB\u4F55\u5185\u5BB9\uFF1B\u6D4F\u89C8\u5668\u6587\u4EF6\u53EA\u5B58\u653E\u5728\u5F53\u524D Agent instance \u7684\u6570\u636E\u76EE\u5F55\u3002","workbench.browserInstallAction":"\u542F\u7528\u6D4F\u89C8\u5668\uFF08{size}\uFF09","workbench.browserInstalling":"\u6B63\u5728\u542F\u7528\u6D4F\u89C8\u5668\uFF1A\u4E0B\u8F7D\u5E76\u6821\u9A8C Chrome for Testing {build}\u2026","workbench.browserInstallKeepOpen":"\u53EF\u4EE5\u79BB\u5F00\u6B64\u9762\u677F\u3002\u518D\u6B21\u6253\u5F00\u6D4F\u89C8\u5668\u4F1A\u6062\u590D\u663E\u793A\u5F53\u524D\u5B89\u88C5\u72B6\u6001\uFF0C\u4E0D\u4F1A\u91CD\u590D\u4E0B\u8F7D\u3002","workbench.browserInstallProgressLabel":"\u6D4F\u89C8\u5668\u4E0B\u8F7D\u8FDB\u5EA6","workbench.browserInstallProgress":"\u5DF2\u4E0B\u8F7D {downloaded} / {total}","workbench.browserInstalledEnable":"\u6D4F\u89C8\u5668\u6587\u4EF6\u5DF2\u7ECF\u5B89\u88C5\u3002\u542F\u7528\u6D4F\u89C8\u5668\u5E76\u68C0\u67E5\u5A92\u4F53\u94FE\u8DEF\u5373\u53EF\u4F7F\u7528\u3002","workbench.browserEnableAction":"\u542F\u7528\u6D4F\u89C8\u5668","workbench.browserEnabling":"\u6B63\u5728\u5B8C\u6210\u8BBE\u7F6E\u5E76\u68C0\u67E5\u5A92\u4F53\u94FE\u8DEF\u2026","workbench.browserStatusInstalling":"\u5B89\u88C5\u4E2D","workbench.browserStatusProbing":"\u63A2\u6D4B\u4E2D","workbench.backToCapabilities":"\u8FD4\u56DE\u80FD\u529B\u5217\u8868","workbench.closeCapability":"\u5173\u95ED\u5F53\u524D\u80FD\u529B","workbench.maximize":"\u6700\u5927\u5316\u9762\u677F","workbench.restore":"\u8FD8\u539F\u9762\u677F","workbench.collapse":"\u6536\u8D77\u9762\u677F","theme.switchToLight":"\u5207\u6362\u5230\u6D45\u8272\u4E3B\u9898","theme.switchToDark":"\u5207\u6362\u5230\u6DF1\u8272\u4E3B\u9898","theme.toLight":"\u5207\u6362\u5230\u6D45\u8272\u4E3B\u9898","theme.toDark":"\u5207\u6362\u5230\u6DF1\u8272\u4E3B\u9898","terminal.splitH":"\u6C34\u5E73\u5206\u5C4F\uFF08\u5DE6\u53F3\uFF09","terminal.splitV":"\u5782\u76F4\u5206\u5C4F\uFF08\u4E0A\u4E0B\uFF09","terminal.close":"\u5173\u95ED\u5F53\u524D\u7EC8\u7AEF","terminal.autoCreate":"\u6253\u5F00\u7EC8\u7AEF\u80FD\u529B\u65F6\u5C06\u81EA\u52A8\u521B\u5EFA\u7EC8\u7AEF","terminal.xtermError":"xterm.js \u672A\u52A0\u8F7D\uFF0C\u8BF7\u5237\u65B0\u9875\u9762","terminal.xtermNotLoaded":"xterm.js \u672A\u52A0\u8F7D\uFF0C\u8BF7\u5237\u65B0\u9875\u9762","terminal.mountError":"\u7EC8\u7AEF\u5BB9\u5668\u6302\u8F7D\u5931\u8D25","terminal.mountFailed":"\u7EC8\u7AEF\u5BB9\u5668\u6302\u8F7D\u5931\u8D25","terminal.createError":"\u7EC8\u7AEF\u521B\u5EFA\u5931\u8D25","terminal.createFailed":"\u7EC8\u7AEF\u521B\u5EFA\u5931\u8D25","terminal.error":"\u7EC8\u7AEF\u9519\u8BEF","git.selectFolder":"\u9009\u62E9\u6587\u4EF6\u5939","git.repoPath":"\u8F93\u5165 Git \u4ED3\u5E93\u8DEF\u5F84...","git.repoPathPlaceholder":"\u8F93\u5165 Git \u4ED3\u5E93\u8DEF\u5F84...","git.workDir":"Git \u5DE5\u4F5C\u76EE\u5F55","git.loadStatus":"\u52A0\u8F7D Git \u72B6\u6001","git.loading":"\u52A0\u8F7D Git \u72B6\u6001...","git.loadingStatus":"\u52A0\u8F7D Git \u72B6\u6001...","git.clean":"\u5DE5\u4F5C\u533A\u5E72\u51C0\uFF0C\u65E0\u53D8\u66F4","git.cleanWorkDir":"\u5DE5\u4F5C\u533A\u5E72\u51C0\uFF0C\u65E0\u53D8\u66F4","git.selectAgent":"\u9009\u62E9 Agent \u540E\u52A0\u8F7D Git \u72B6\u6001","git.selectAgentFirst":"\u9009\u62E9 Agent \u540E\u52A0\u8F7D Git \u72B6\u6001","git.diffOnly":"\u53EA\u770B\u5DEE\u5F02","git.fullFile":"\u770B\u5168\u6587","git.zoomIn":"\u653E\u5927\u5B57\u4F53","git.zoomOut":"\u7F29\u5C0F\u5B57\u4F53","git.loadingDiff":"\u52A0\u8F7D Diff...","git.clickToView":"\u70B9\u51FB\u6587\u4EF6\u67E5\u770B\u5DEE\u5F02","git.clickFileToView":"\u70B9\u51FB\u6587\u4EF6\u67E5\u770B\u5DEE\u5F02","git.selectRepo":"\u9009\u62E9 Git \u4ED3\u5E93","git.noDiff":"(\u65E0\u5DEE\u5F02)","git.binaryFile":"(\u4E8C\u8FDB\u5236\u6587\u4EF6)","files.notLoaded":"\u672A\u52A0\u8F7D","files.newFile":"\u65B0\u5EFA\u6587\u4EF6","files.newFolder":"\u65B0\u5EFA\u6587\u4EF6\u5939","files.openFolder":"\u6253\u5F00\u6587\u4EF6\u5939","files.showTree":"\u663E\u793A\u6587\u4EF6\u5939","files.hideTree":"\u9690\u85CF\u6587\u4EF6\u5939","files.deleteSelected":"\u5220\u9664\u9009\u4E2D","files.moveSelected":"\u79FB\u52A8\u9009\u4E2D","files.enterPath":"\u8F93\u5165\u8DEF\u5F84...","files.searchFiles":"\u641C\u7D22\u6587\u4EF6... (Ctrl+P)","files.noMatch":"\u65E0\u5339\u914D\u7ED3\u679C","files.searching":"\u641C\u7D22\u4E2D...","files.loadingTree":"\u52A0\u8F7D\u4E2D...","files.emptyDir":"\u7A7A\u76EE\u5F55","files.loadingFile":"\u52A0\u8F7D\u6587\u4EF6...","files.searchPlaceholder":"\u641C\u7D22...","files.replacePlaceholder":"\u66FF\u6362...","files.replace":"\u66FF\u6362","files.replaceAll":"\u5168\u90E8","files.replaceCurrent":"\u66FF\u6362\u5F53\u524D","files.replaceAllTitle":"\u5168\u90E8\u66FF\u6362","files.clickToView":"\u70B9\u51FB\u6587\u4EF6\u67E5\u770B\u5185\u5BB9","files.selectFolder":"\u9009\u62E9\u6587\u4EF6\u5939","files.enterFolderName":"\u8F93\u5165\u6587\u4EF6\u5939\u540D...","files.enterFileName":"\u8F93\u5165\u6587\u4EF6\u540D...","files.moveTarget":"\u8F93\u5165\u76EE\u6807\u76EE\u5F55\u8DEF\u5F84...","files.moveItems":"\u5C06 {count} \u4E2A\u9879\u76EE\u79FB\u52A8\u5230\u6307\u5B9A\u76EE\u5F55","files.workDir":"\u5DE5\u4F5C\u76EE\u5F55: {dir}","files.enterDirPath":"\u8F93\u5165\u76EE\u5F55\u8DEF\u5F84...","files.unsavedConfirm":'"{name}" \u6709\u672A\u4FDD\u5B58\u7684\u4FEE\u6539\uFF0C\u786E\u5B9A\u5173\u95ED\uFF1F',"files.unsavedBatchConfirm":"{count} \u4E2A\u6587\u4EF6\u6709\u672A\u4FDD\u5B58\u7684\u4FEE\u6539\uFF0C\u786E\u5B9A\u5173\u95ED\uFF1F","files.showOpenTabs":"\u663E\u793A\u5DF2\u6253\u5F00\u7684\u6587\u4EF6","files.closeTab":"\u5173\u95ED {name}","files.closeTabAction":"\u5173\u95ED","files.closeOtherTabs":"\u5173\u95ED\u5176\u4ED6","files.closeTabsToLeft":"\u5173\u95ED\u5DE6\u4FA7","files.closeTabsToRight":"\u5173\u95ED\u53F3\u4FA7","files.closeAllTabs":"\u5168\u90E8\u5173\u95ED","files.deleteConfirm":'\u786E\u5B9A\u8981\u5220\u9664 "{name}" \u5417\uFF1F',"files.deleteDirHint":"\uFF08\u5C06\u5220\u9664\u6587\u4EF6\u5939\u53CA\u5176\u6240\u6709\u5185\u5BB9\uFF09","files.deleteSelectedConfirm":"\u786E\u5B9A\u8981\u5220\u9664\u9009\u4E2D\u7684 {count} \u4E2A\u9879\u76EE\u5417\uFF1F\u6B64\u64CD\u4F5C\u4E0D\u53EF\u64A4\u9500\u3002","files.findPrev":"\u4E0A\u4E00\u4E2A (Shift+Enter)","files.findNext":"\u4E0B\u4E00\u4E2A (Enter)","files.caseSensitive":"\u533A\u5206\u5927\u5C0F\u5199","files.regex":"\u6B63\u5219\u8868\u8FBE\u5F0F","files.unsaved":"\u672A\u4FDD\u5B58","files.clearSelection":"\u6E05\u9664\u9009\u62E9","files.rename":"\u91CD\u547D\u540D","files.copyHere":"\u590D\u5236","files.moveTo":"\u79FB\u52A8\u5230...","files.download":"\u4E0B\u8F7D","files.enterNewName":"\u8F93\u5165\u65B0\u540D\u79F0...","files.loadingPreview":"\u52A0\u8F7D\u9884\u89C8\u4E2D...","files.previewTooLarge":"\u8BE5\u6587\u4EF6\u5927\u5C0F\u4E3A {size} MB\uFF0C\u8D85\u8FC7 {limit} MB \u7684\u9884\u89C8\u4E0E\u4E0B\u8F7D\u4E0A\u9650\u3002","files.previewLoadFailed":"\u56FE\u7247\u9884\u89C8\u52A0\u8F7D\u5931\u8D25\u3002","files.preview":"\u9884\u89C8","files.edit":"\u7F16\u8F91","files.pptxNotSupported":"PPTX \u672C\u5730\u9884\u89C8\u6682\u4E0D\u652F\u6301\uFF0C\u8BF7\u5728\u8BBE\u7F6E\u4E2D\u5207\u6362\u4E3A Office Online \u6A21\u5F0F\u3002","files.officePreviewMode":"Office \u9884\u89C8\u6A21\u5F0F","files.officeOnline":"Office Online","files.localRender":"\u672C\u5730\u6E32\u67D3","proxy.port":"\u7AEF\u53E3","proxy.label":"\u6807\u7B7E","proxy.add":"\u6DFB\u52A0\u7AEF\u53E3\u6620\u5C04","proxy.addPort":"\u6DFB\u52A0\u7AEF\u53E3\u6620\u5C04","proxy.enable":"\u70B9\u51FB\u542F\u7528","proxy.clickEnable":"\u70B9\u51FB\u542F\u7528","proxy.disable":"\u70B9\u51FB\u7981\u7528","proxy.clickDisable":"\u70B9\u51FB\u7981\u7528","proxy.openNewTab":"\u5728\u65B0\u6807\u7B7E\u9875\u6253\u5F00","proxy.openInBrowser":"\u5728\u65B0\u6807\u7B7E\u9875\u6253\u5F00","proxy.noMappings":"\u6682\u65E0\u7AEF\u53E3\u6620\u5C04","proxy.noPorts":"\u6682\u65E0\u7AEF\u53E3\u6620\u5C04","proxy.hint":"\u6DFB\u52A0\u7AEF\u53E3\u540E\uFF0C\u53EF\u901A\u8FC7\u4EE3\u7406 URL \u8BBF\u95EE agent \u673A\u5668\u4E0A\u7684\u672C\u5730\u670D\u52A1","proxy.noPortsHint":"\u6DFB\u52A0\u7AEF\u53E3\u540E\uFF0C\u53EF\u901A\u8FC7\u4EE3\u7406 URL \u8BBF\u95EE agent \u673A\u5668\u4E0A\u7684\u672C\u5730\u670D\u52A1","proxy.selectAgent":"\u8BF7\u5148\u9009\u62E9\u4E00\u4E2A Agent","store.selectAgent":"\u8BF7\u5148\u9009\u62E9\u4E00\u4E2A Agent","store.creatingConv":"\u6B63\u5728\u521B\u5EFA\u4F1A\u8BDD...","store.loadingHistory":"\u6B63\u5728\u52A0\u8F7D\u4F1A\u8BDD\u5386\u53F2...","store.executionCancelled":"\u6267\u884C\u5DF2\u53D6\u6D88","store.loginFailed":"\u767B\u5F55\u5931\u8D25","store.convClosed":"\u4F1A\u8BDD\u5DF2\u5173\u95ED","store.convCreated":"\u65B0\u4F1A\u8BDD\u5DF2\u521B\u5EFA [{agent}]\uFF0C\u5DE5\u4F5C\u76EE\u5F55: {workDir}","store.convResumed":"\u5DF2\u6062\u590D\u4F1A\u8BDD [{agent}]: {sessionId}","roleplay.creating":"\u6B63\u5728\u521B\u5EFA \u89D2\u8272\u626E\u6F14 \u4F1A\u8BDD...","roleplay.working":"\u5DE5\u4F5C\u4E2D","roleplay.selectTeam":"\u9009\u62E9\u56E2\u961F\u6A21\u677F","roleplay.teamDev":"\u8F6F\u4EF6\u5F00\u53D1","roleplay.teamCustom":"\u81EA\u5B9A\u4E49","roleplay.editRoles":"\u7F16\u8F91\u89D2\u8272","roleplay.roleName":"\u89D2\u8272\u6807\u8BC6","roleplay.roleDisplayName":"\u663E\u793A\u540D\u79F0","roleplay.roleIcon":"\u56FE\u6807","roleplay.roleDesc":"\u89D2\u8272\u63CF\u8FF0","roleplay.rolePrompt":"\u89D2\u8272 Prompt","roleplay.removeRole":"\u79FB\u9664\u89D2\u8272","roleplay.addRole":"\u6DFB\u52A0\u89D2\u8272","roleplay.start":"\u542F\u52A8 \u89D2\u8272\u626E\u6F14","roleplay.sidebarTitle":"\u89D2\u8272\u626E\u6F14","roleplay.configTitle":"\u89D2\u8272\u626E\u6F14","roleplay.newSession":"\u65B0\u5EFA \u89D2\u8272\u626E\u6F14","roleplay.emptyHint":"\u53D1\u9001\u6D88\u606F\u5F00\u59CB\u591A\u89D2\u8272\u534F\u4F5C","roleplay.askingYou":"\u6B63\u5728\u63D0\u95EE","roleplay.language":"\u8BED\u8A00","roleplay.rolePreview":"\u89D2\u8272\u914D\u7F6E","roleplay.noAgents":"\u6CA1\u6709\u5728\u7EBF\u7684 Agent","roleplay.inputPlaceholder":"\u8F93\u5165\u6D88\u606F\u2026 \u4F7F\u7528 @ \u63D0\u53CA\u89D2\u8272","roleplay.existingSessions":"\u5DF2\u6709\u56E2\u961F","roleplay.restore":"\u6062\u590D","roleplay.restoring":"\u6B63\u5728\u6062\u590D \u89D2\u8272\u626E\u6F14 \u4F1A\u8BDD...","roleplay.createNew":"\u521B\u5EFA\u65B0\u56E2\u961F","expertPanel.title":"\u5E2E\u5E2E\u56E2","expertPanel.search":"\u641C\u7D22\u89D2\u8272\u6216 Action...","expertPanel.noResults":"\u6CA1\u6709\u5339\u914D\u7ED3\u679C","expertPanel.clearAll":"\u6E05\u7A7A","expertPanel.persona":"\u89D2\u8272\u4EBA\u8BBE","expertPanel.template":"\u6709\u8F93\u5165\u65F6 \xB7 \u6D88\u606F\u524D\u7F00","expertPanel.templateHint":"\u7528\u6237\u5199\u4E86\u6587\u5B57\u65F6\uFF1A\u6B64\u524D\u7F00 + \u7528\u6237\u6587\u5B57 = \u6700\u7EC8\u53D1\u9001\u5185\u5BB9","expertPanel.defaultMsg":"\u65E0\u8F93\u5165\u65F6 \xB7 \u5B8C\u6574 Prompt","expertPanel.defaultMsgHint":"\u7528\u6237\u4E0D\u5199\u6587\u5B57\u76F4\u63A5\u53D1\u9001\u65F6\uFF0C\u4F7F\u7528\u6B64\u5B8C\u6574 prompt","expertPanel.loading":"\u6B63\u5728\u52A0\u8F7D\u89D2\u8272\u5B9A\u4E49...","expertPanel.viewPrompt":"\u67E5\u770B\u63D0\u793A\u8BCD","expertPanel.customRoles":"\u81EA\u5B9A\u4E49\u89D2\u8272","expertPanel.addRole":"\u6DFB\u52A0\u89D2\u8272","expertPanel.editRole":"\u7F16\u8F91\u89D2\u8272","expertPanel.deleteRole":"\u5220\u9664\u89D2\u8272","expertPanel.noCustomRoles":"\u6682\u65E0\u81EA\u5B9A\u4E49\u89D2\u8272","expertPanel.createFirst":"\u521B\u5EFA\u7B2C\u4E00\u4E2A\u81EA\u5B9A\u4E49\u89D2\u8272","expertPanel.noActions":"\u6682\u65E0 Action","expertPanel.deleteConfirm":'\u786E\u5B9A\u8981\u5220\u9664\u89D2\u8272 "{name}" \u5417\uFF1F\u6B64\u64CD\u4F5C\u4E0D\u53EF\u64A4\u9500\u3002',"expertPanel.deleteConfirmBtn":"\u5220\u9664","expertEditor.createTitle":"\u521B\u5EFA\u81EA\u5B9A\u4E49\u89D2\u8272","expertEditor.editTitle":"\u7F16\u8F91\u81EA\u5B9A\u4E49\u89D2\u8272","expertEditor.basicInfo":"\u57FA\u672C\u4FE1\u606F","expertEditor.roleName":"\u89D2\u8272\u540D\u79F0","expertEditor.roleNamePlaceholder":"\u5982\uFF1A\u6570\u636E\u5206\u6790\u5E08","expertEditor.roleTitle":"\u804C\u79F0","expertEditor.roleTitlePlaceholder":"\u5982\uFF1A\u9AD8\u7EA7\u6570\u636E\u5206\u6790\u5E08","expertEditor.fullName":"\u5168\u540D","expertEditor.fullNamePlaceholder":"\u53EF\u9009","expertEditor.titleEn":"\u82F1\u6587\u804C\u79F0","expertEditor.titleEnPlaceholder":"\u53EF\u9009","expertEditor.rolePrompt":"\u89D2\u8272 Prompt","expertEditor.messagePrefix":"\u6D88\u606F\u524D\u7F00\uFF08\u4E2D\u6587\uFF09","expertEditor.messagePrefixPlaceholder":"\u5982\uFF1A\u4F5C\u4E3A\u4E00\u540D\u8D44\u6DF1\u6570\u636E\u5206\u6790\u5E08\uFF0C","expertEditor.messagePrefixEn":"\u6D88\u606F\u524D\u7F00\uFF08\u82F1\u6587\uFF09","expertEditor.messagePrefixEnPlaceholder":"As a senior data analyst, ","expertEditor.actions":"Actions","expertEditor.addAction":"\u6DFB\u52A0 Action","expertEditor.removeAction":"\u79FB\u9664","expertEditor.actionName":"Action \u540D\u79F0","expertEditor.actionNamePlaceholder":"\u5982\uFF1A\u6570\u636E\u5206\u6790","expertEditor.actionNameEn":"\u82F1\u6587\u540D\u79F0","expertEditor.actionNameEnPlaceholder":"\u53EF\u9009","expertEditor.messageTemplate":"\u6709\u8F93\u5165\u65F6 \xB7 \u6D88\u606F\u524D\u7F00\uFF08\u4E2D\u6587\uFF09","expertEditor.messageTemplatePlaceholder":"\u7528\u6237\u5199\u4E86\u6587\u5B57\u65F6\uFF0C\u62FC\u5728\u7528\u6237\u6587\u5B57\u524D\u9762\u53D1\u9001","expertEditor.messageTemplateEn":"\u6709\u8F93\u5165\u65F6 \xB7 \u6D88\u606F\u524D\u7F00\uFF08\u82F1\u6587\uFF09","expertEditor.messageTemplateEnPlaceholder":"Prepended to user text when user types something","expertEditor.defaultMessage":"\u65E0\u8F93\u5165\u65F6 \xB7 \u5B8C\u6574 Prompt\uFF08\u4E2D\u6587\uFF09","expertEditor.defaultMessagePlaceholder":"\u7528\u6237\u4E0D\u5199\u6587\u5B57\u76F4\u63A5\u53D1\u9001\u65F6\uFF0C\u4F7F\u7528\u6B64\u5B8C\u6574\u5185\u5BB9","expertEditor.defaultMessageEn":"\u65E0\u8F93\u5165\u65F6 \xB7 \u5B8C\u6574 Prompt\uFF08\u82F1\u6587\uFF09","expertEditor.defaultMessageEnPlaceholder":"Used as-is when user sends without typing","expertEditor.cancel":"\u53D6\u6D88","expertEditor.save":"\u4FDD\u5B58","expertEditor.saving":"\u4FDD\u5B58\u4E2D...","subAgentPanel.title":"\u5B50\u4EE3\u7406","subAgentPanel.back":"\u8FD4\u56DE\u5217\u8868","subAgentPanel.running":"\u8FD0\u884C\u4E2D","subAgentPanel.completed":"\u5DF2\u5B8C\u6210","subAgentPanel.waitingMessages":"\u7B49\u5F85\u6D88\u606F...","subAgentPanel.toolCount":"{count} \u4E2A\u5DE5\u5177","subAgentPanel.toolSummary":"\u5DF2\u5B8C\u6210 {count} \u6B21\u5DE5\u5177\u8C03\u7528","subAgentPanel.empty":"\u6682\u65E0\u5B50\u4EE3\u7406","subAgentPanel.emptyHint":"\u5F53 Claude \u59D4\u6D3E\u4EFB\u52A1\u65F6\uFF0C\u5B50\u4EE3\u7406\u4F1A\u5728\u8FD9\u91CC\u663E\u793A","splitScreen.split":"\u5206\u5C4F","splitScreen.closePane":"\u5173\u95ED\u6B64\u9762\u677F","splitScreen.newChat":"\u65B0\u5EFA Chat","splitScreen.noSessions":"\u6682\u65E0\u4F1A\u8BDD","splitScreen.splitToPanel":"\u5728\u65B0\u9762\u677F\u4E2D\u6253\u5F00","splitScreen.selectFromSidebar":"\u4ECE\u5DE6\u4FA7\u9009\u62E9\u5BF9\u8BDD","yeaft.vp.library":"\u89D2\u8272\u5E93","yeaft.vp.createFirst":"+ \u521B\u5EFA\u4F60\u7684\u7B2C\u4E00\u4E2A\u89D2\u8272","yeaft.vp.empty.aria":"\u5C1A\u65E0\u89D2\u8272","yeaft.vp.avatar.aria":"{name} \u5934\u50CF","yeaft.vp.speaker.stateCauseAria":"\u72B6\u6001\u53D8\u66F4\uFF1A{cause}","yeaft.vp.status.thinking":"\u6B63\u5728\u601D\u8003\u2026","yeaft.vp.status.tool":"\u6B63\u5728\u4F7F\u7528 {name}","yeaft.vp.status.done":"\u5B8C\u6210 \xB7 {count} \u4E2A\u5DE5\u5177","yeaft.vp.status.aborted":"\u5DF2\u4E2D\u6B62","yeaft.vp.crud.title":"\u89D2\u8272\u5E93","yeaft.vp.crud.close":"\u5173\u95ED","yeaft.vp.crud.addNew":"+ \u65B0\u5EFA\u89D2\u8272","yeaft.vp.crud.empty":"\u8FD8\u6CA1\u6709\u89D2\u8272\u3002\u521B\u5EFA\u7B2C\u4E00\u4E2A\u89D2\u8272\u5F00\u59CB\u534F\u4F5C\u5427\u3002","yeaft.vp.crud.edit":"\u7F16\u8F91","yeaft.vp.crud.delete":"\u5220\u9664","yeaft.vp.crud.deleteConfirm":'\u5220\u9664 "{name}"\uFF1F\u4F1A\u4E00\u5E76\u5220\u9664\u78C1\u76D8\u4E0A\u7684 role.md \u6587\u4EF6\u3002',"yeaft.vp.crud.form.create":"\u521B\u5EFA\u89D2\u8272","yeaft.vp.crud.form.update":"\u7F16\u8F91\u89D2\u8272","yeaft.vp.crud.form.vpId":"\u89D2\u8272 ID","yeaft.vp.crud.form.vpId.tooltip":"\u53EA\u80FD\u7528\u5B57\u6BCD\u3001\u6570\u5B57\u3001- \u548C _\uFF0C\u4E0D\u80FD\u4EE5 _ \u5F00\u5934\uFF0C\u4E0D\u80FD\u662F\u7EAF\u6570\u5B57\uFF0C\u4E0D\u80FD\u7528\u4FDD\u7559\u540D\uFF1Aall / user / system / everyone\u3002","yeaft.vp.crud.form.displayName":"\u663E\u793A\u540D\uFF08\u82F1\u6587\uFF09","yeaft.vp.crud.form.displayNameZh":"\u663E\u793A\u540D\uFF08\u4E2D\u6587\uFF09","yeaft.vp.crud.form.description":"\u80FD\u529B\u63CF\u8FF0\uFF08\u82F1\u6587\uFF09","yeaft.vp.crud.form.descriptionZh":"\u80FD\u529B\u63CF\u8FF0\uFF08\u4E2D\u6587\uFF09","yeaft.vp.crud.form.descriptionPlaceholder":"\u4F8B\u5982\uFF1AAPI design, migration planning, and compatibility reviews","yeaft.vp.crud.form.descriptionZhPlaceholder":"\u4F8B\u5982\uFF1AAPI \u8BBE\u8BA1\u3001\u8FC1\u79FB\u89C4\u5212\u4E0E\u517C\u5BB9\u6027\u8BC4\u5BA1","yeaft.vp.crud.form.role":"\u804C\u4F4D","yeaft.vp.crud.form.rolePlaceholder":"\u4F8B\u5982\uFF1A\u4EA7\u54C1\u7ECF\u7406","yeaft.vp.crud.form.traits":"\u7279\u8D28\u6807\u7B7E","yeaft.vp.crud.form.traitsHint":"\u7528\u82F1\u6587\u9017\u53F7\u5206\u9694\u7684\u77ED\u6807\u7B7E\uFF08\u4F8B\u5982\uFF1A\u597D\u5947, \u52A1\u5B9E\uFF09\u3002","yeaft.vp.crud.form.modelHint":"\u6A21\u578B\u504F\u597D","yeaft.vp.crud.form.modelHint.none":"\u2014 \u9ED8\u8BA4 \u2014","yeaft.vp.crud.form.modelHint.primary":"\u4E3B\u6A21\u578B","yeaft.vp.crud.form.modelHint.fast":"\u5FEB\u6A21\u578B","yeaft.vp.crud.form.persona":"\u4EBA\u8BBE\uFF08Markdown\uFF09","yeaft.vp.crud.form.personaPlaceholder":"\u63CF\u8FF0\u8FD9\u4E2A\u89D2\u8272\u5982\u4F55\u601D\u8003\u3001\u8868\u8FBE\u3001\u505A\u51B3\u7B56\u2026\u2026","yeaft.vp.crud.form.submit":"\u4FDD\u5B58","yeaft.vp.crud.form.cancel":"\u53D6\u6D88","yeaft.vp.crud.form.ok":"\u683C\u5F0F\u6B63\u786E","yeaft.vp.crud.form.idLocked":"\u521B\u5EFA\u540E\u89D2\u8272 ID \u4E0D\u53EF\u4FEE\u6539\u3002","yeaft.vp.crud.saving":"\u4FDD\u5B58\u4E2D\u2026\u2026","yeaft.vp.crud.saveFailed":"\u4FDD\u5B58\u5931\u8D25\uFF1A{error}","yeaft.vp.crud.deleteFailed":"\u5220\u9664\u5931\u8D25\uFF1A{error}","yeaft.vp.crud.viewPrompt":"\u67E5\u770B prompt","yeaft.vp.crud.view.title":"VP \u63D0\u793A\u8BCD","yeaft.vp.crud.view.personaEmpty":"\uFF08\u672A\u5B9A\u4E49 persona \u6B63\u6587\uFF0C\u53EA\u6709\u57FA\u7840\u5143\u6570\u636E\uFF09","yeaft.vp.crud.view.back":"\u8FD4\u56DE","yeaft.vp.crud.view.editFromHere":"\u7F16\u8F91\u8BE5 VP","yeaft.vp.crud.view.removed":"\u8BE5 VP \u5DF2\u5728\u522B\u5904\u88AB\u5220\u9664\uFF0C\u8FD4\u56DE\u5217\u8868\u3002","yeaft.vp.crud.stockBadge":"\u9884\u88C5","yeaft.vp.crud.stockReadOnly":"\u9884\u88C5 VP \u968F agent \u51FA\u5382\uFF0C\u4E0D\u80FD\u7F16\u8F91\u6216\u5220\u9664\u3002","yeaft.vp.idError.empty_or_non_string":"\u89D2\u8272 ID \u4E0D\u80FD\u4E3A\u7A7A\u3002","yeaft.vp.idError.too_long":"\u89D2\u8272 ID \u592A\u957F\uFF08\u6700\u591A 40 \u5B57\u7B26\uFF09\u3002","yeaft.vp.idError.illegal_character":'\u53EA\u80FD\u4F7F\u7528\u5B57\u6BCD\u3001\u6570\u5B57\u3001"-" \u548C "_"\u3002',"yeaft.vp.idError.underscore_prefix_reserved":'\u89D2\u8272 ID \u4E0D\u80FD\u4EE5 "_" \u5F00\u5934\uFF08\u9884\u7559\u7ED9\u7CFB\u7EDF\u89D2\u8272\uFF09\u3002',"yeaft.vp.idError.pure_digits":"\u89D2\u8272 ID \u4E0D\u80FD\u662F\u7EAF\u6570\u5B57\u3002","yeaft.vp.idError.reserved":"\u89D2\u8272 ID \u4E0D\u80FD\u7528\u4FDD\u7559\u540D\uFF08all / user / system / everyone\uFF09\u3002","yeaft.vp.idError.duplicate":"\u5DF2\u7ECF\u5B58\u5728\u540C ID \u7684\u89D2\u8272\u3002","yeaft.vp.idError.not_found":"\u8BE5 VP \u4E0D\u5B58\u5728\uFF0C\u53EF\u80FD\u5DF2\u88AB\u5220\u9664\u3002","yeaft.vp.idError.stock_readonly":"\u9884\u88C5 VP \u4E0D\u80FD\u7F16\u8F91\u6216\u5220\u9664\u3002","yeaft.vp.idError.unknown":"\u53D1\u751F\u672A\u77E5\u9519\u8BEF\uFF0C\u8BF7\u91CD\u8BD5\u3002","yeaft.vp.reason.personaEdit":"\u4EBA\u8BBE\u5DF2\u66F4\u65B0","yeaft.vp.reason.traitsEdit":"\u7279\u5F81\u5DF2\u66F4\u65B0","yeaft.vp.reason.manualReload":"\u5DF2\u91CD\u65B0\u8F7D\u5165","yeaft.vp.reason.fileRemoved":"\u5DF2\u79FB\u9664","yeaft.vp.reason.toast.updated":"{name}\uFF1A{reason}","yeaft.vp.reason.toast.removed":"{name} \u5DF2\u88AB\u79FB\u9664","yeaft.message.timeAria":"\u53D1\u9001\u4E8E {time}","yeaft.message.llmCall":"{count} \u6B21 LLM \u8C03\u7528","yeaft.message.llmCalls":"{count} \u6B21 LLM \u8C03\u7528","yeaft.message.tokenUsage":"\u603B\u8BA1 {total} \xB7 \u8F93\u5165 {input} \xB7 \u8F93\u51FA {output}","yeaft.user.youLabel":"\u6211","yeaft.session.sidebarTitle":"\u4F1A\u8BDD","yeaft.session.sidebarAria":"\u4F1A\u8BDD\u5217\u8868","yeaft.session.newButton":"+ \u65B0\u5EFA\u4F1A\u8BDD","yeaft.session.newButtonAria":"\u521B\u5EFA\u65B0\u4F1A\u8BDD","yeaft.session.empty":"\u6682\u65E0\u4F1A\u8BDD\u3002","yeaft.session.membersCount":"{count} \u4F4D\u6210\u5458","yeaft.session.oneMember":"1 \u4F4D\u6210\u5458","yeaft.session.noMembers":"\u7A7A\u4F1A\u8BDD \u2014 \u8BF7\u9080\u8BF7 VP","yeaft.session.defaultBadge":"\u9ED8\u8BA4","yeaft.session.defaultName":"\u9ED8\u8BA4\u4F1A\u8BDD","yeaft.session.moreActions":"\u66F4\u591A\u64CD\u4F5C","yeaft.session.archive":"\u5F52\u6863","yeaft.session.archiveConfirm":"\u5F52\u6863\u300C{name}\u300D\uFF1F\u7A0D\u540E\u53EF\u4ECE\u78C1\u76D8\u6062\u590D\u3002","yeaft.session.archivingEllipsis":"\u5F52\u6863\u4E2D\u2026","yeaft.session.delete":"\u5220\u9664","yeaft.session.deleteConfirm":"\u5220\u9664\u300C{name}\u300D\uFF1F\u5C06\u6C38\u4E45\u5220\u9664\u8BE5\u4F1A\u8BDD\u53CA\u5176\u6240\u6709\u6570\u636E\uFF0C\u6B64\u64CD\u4F5C\u4E0D\u53EF\u64A4\u9500\u3002","yeaft.session.deletingEllipsis":"\u5220\u9664\u4E2D\u2026","yeaft.session.rename":"\u91CD\u547D\u540D","yeaft.session.copyCurrent":"\u4ECE\u5F53\u524D\u4F1A\u8BDD\u590D\u5236","yeaft.session.copyFailed":"\u65E0\u6CD5\u590D\u5236\u4F1A\u8BDD\uFF1A{message}","yeaft.session.openSettings":"\u8BBE\u7F6E","yeaft.session.removeFromList":"\u79FB\u9664","yeaft.session.manageMembers":"\u7BA1\u7406\u6210\u5458","yeaft.session.memberCount.one":"1 \u4F4D\u6210\u5458","yeaft.session.memberCount.other":"{count} \u4F4D\u6210\u5458","yeaft.session.renamePrompt":"\u4E3A\u300C{name}\u300D\u8F93\u5165\u65B0\u540D\u79F0\uFF1A","yeaft.session.renamingEllipsis":"\u91CD\u547D\u540D\u4E2D\u2026","yeaft.session.editModal.renameTitle":"\u91CD\u547D\u540D\u4F1A\u8BDD","yeaft.session.editModal.renameBody":"\u4E3A\u300C{name}\u300D\u9009\u62E9\u4E00\u4E2A\u65B0\u540D\u79F0\u3002","yeaft.session.editModal.renameSubmit":"\u4FDD\u5B58","yeaft.session.editModal.archiveTitle":"\u5F52\u6863\u4F1A\u8BDD","yeaft.session.editModal.archiveBody":"\u5F52\u6863\u300C{name}\u300D\uFF1F\u7A0D\u540E\u53EF\u4ECE\u78C1\u76D8\u6062\u590D\u3002","yeaft.session.editModal.archiveSubmit":"\u5F52\u6863","yeaft.session.editModal.deleteTitle":"\u5220\u9664\u4F1A\u8BDD","yeaft.session.editModal.deleteBody":"\u5220\u9664\u300C{name}\u300D\uFF1F\u5C06\u6C38\u4E45\u5220\u9664\u8BE5\u4F1A\u8BDD\u53CA\u5176\u6240\u6709\u6570\u636E\uFF0C\u6B64\u64CD\u4F5C\u4E0D\u53EF\u64A4\u9500\u3002","yeaft.session.editModal.deleteSubmit":"\u5220\u9664","yeaft.session.editModal.newNameLabel":"\u65B0\u540D\u79F0","yeaft.session.editModal.cancel":"\u53D6\u6D88","yeaft.session.editModal.close":"\u5173\u95ED","yeaft.session.error.invalid_name":"\u4F1A\u8BDD\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A\u3002","yeaft.session.error.duplicate":"\u8BE5\u4F1A\u8BDD id \u5DF2\u5B58\u5728\u3002","yeaft.session.error.not_found":"\u672A\u627E\u5230\u8BE5\u4F1A\u8BDD\u3002","yeaft.session.error.session_running":"\u8BF7\u7B49\u5F85\u5F53\u524D\u56DE\u590D\u5B8C\u6210\u540E\u518D\u590D\u5236\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.triageSummary":"Triage \u6458\u8981","workCenter.actionFlow":"Action \u6D41\u7A0B","workCenter.viewActions":"\u67E5\u770B Actions","workCenter.actionsPanel":"Actions","workCenter.closeActions":"\u5173\u95ED Actions","workCenter.actionCount":"{count} \u4E2A Action","workCenter.noActionSummary":"\u6682\u65E0\u6458\u8981","workCenter.actionProgress":"{completed} / {total} \u4E2A Action","workCenter.currentAction":"\u5F53\u524D Action","workCenter.expandActions":"\u5C55\u5F00 Action","workCenter.collapseActions":"\u6536\u8D77","workCenter.actionObjective":"\u8FD9\u6B21\u8981\u505A\u4EC0\u4E48","workCenter.actionApproach":"\u51C6\u5907\u600E\u4E48\u505A","workCenter.actionExpectedOutcome":"\u671F\u5F85\u7684\u7ED3\u679C","workCenter.dependencies":"\u6765\u6E90 Action","workCenter.actionResult":"\u6700\u65B0\u7ED3\u679C","workCenter.currentProgress":"\u5F53\u524D\u8FDB\u5EA6","workCenter.actionMessages":"\u6D88\u606F","workCenter.loops":"\u4E2A Loop","workCenter.tools":"\u6B21\u5DE5\u5177\u8C03\u7528","workCenter.noActionMessages":"\u8FD8\u6CA1\u6709\u6D88\u606F\u3002","workCenter.actionDetails":"Action \u8BE6\u60C5","workCenter.selectAction":"\u9009\u62E9\u4E00\u4E2A Action","workCenter.backToWorkItems":"\u5DE5\u4F5C\u9879","workCenter.backToActions":"\u8FD4\u56DE Actions","workCenter.you":"\u4F60","workCenter.noRequestDetails":"\u8FD9\u4E2A Action \u6682\u65F6\u6CA1\u6709\u53EF\u7528\u7684\u6267\u884C\u8BB0\u5F55\u3002","workCenter.loadingRequests":"\u6B63\u5728\u52A0\u8F7D\u6267\u884C\u8BB0\u5F55\u2026","workCenter.loadingRequestDetail":"\u6B63\u5728\u52A0\u8F7D\u5DE5\u5177\u8BC1\u636E\u2026","workCenter.requestDetailUnavailable":"\u5DE5\u5177\u8BC1\u636E\u6682\u4E0D\u53EF\u7528\uFF0C\u8BF7\u91CD\u8BD5\u3002","workCenter.noRequestLoops":"\u8FD9\u6B21\u6267\u884C\u6CA1\u6709\u4FDD\u7559\u4E0B\u53EF\u5C55\u793A\u7684 Loop\u3002","workCenter.requestDetailTruncated":"\u6267\u884C\u5185\u5BB9\u8F83\u5927\uFF1A{summarized} \u4E2A Loop \u663E\u793A\u6458\u8981\uFF0C\u53E6\u6709 {omitted} \u4E2A\u8F83\u65E9 Loop \u672A\u663E\u793A\u3002","workCenter.loopDetailTruncated":"\u8FD9\u4E2A Loop \u5185\u5BB9\u8F83\u5927\uFF0C\u5F53\u524D\u663E\u793A\u4FDD\u7559\u4E0B\u6765\u7684\u5DE5\u5177\u8BC1\u636E\u3002","workCenter.loadEarlierMessages":"\u52A0\u8F7D\u66F4\u65E9\u6D88\u606F","workCenter.loadingEarlierMessages":"\u6B63\u5728\u52A0\u8F7D\u66F4\u65E9\u6D88\u606F\u2026","workCenter.unknownModel":"\u672A\u77E5\u6A21\u578B","workCenter.loop":"Loop","workCenter.actionBrief":"\u4EFB\u52A1\u8BF4\u660E","workCenter.executionSummary":"\u6267\u884C\u6458\u8981","workCenter.toolParameters":"\u8C03\u7528\u53C2\u6570","workCenter.toolResult":"\u6267\u884C\u7ED3\u679C","workCenter.noToolCalls":"\u8FD9\u4E2A Loop \u6CA1\u6709\u5DE5\u5177\u8C03\u7528\u3002","workCenter.actionInputPlaceholder":"\u8865\u5145\u4E0A\u4E0B\u6587\u3001\u56DE\u7B54\u95EE\u9898\u6216\u8C03\u6574\u8FD9\u4E2A Action","workCenter.actionInputResumeHint":"\u4F60\u7684\u8F93\u5165\u4F1A\u5E26\u7740\u65B0\u589E\u4E0A\u4E0B\u6587\u7EE7\u7EED\u8FD9\u4E2A Action\u3002","workCenter.waitingQuestionTitle":"\u9700\u8981\u4F60\u7684\u56DE\u7B54","workCenter.actionInputRetryHint":"\u8865\u5145\u4FEE\u6B63\u8BF4\u660E\u6216\u6587\u4EF6\u540E\uFF0C\u4F7F\u7528\u65B0\u4E0A\u4E0B\u6587\u91CD\u65B0\u6267\u884C\u8FD9\u4E2A Action\u3002","workCenter.actionInputContinueHint":"\u8FD9\u91CC\u53EA\u76F4\u63A5\u5E72\u9884\u5F53\u524D Action\u3002","workCenter.actionFailedTitle":"\u8FD9\u4E2A Action \u4E3A\u4EC0\u4E48\u5931\u8D25","workCenter.actionClosedTitle":"\u8FD9\u4E2A Action \u4E3A\u4EC0\u4E48\u88AB\u5173\u95ED","workCenter.failedAt":"\u5931\u8D25\u65F6\u95F4","workCenter.closedAt":"\u5173\u95ED\u65F6\u95F4","workCenter.actionFailureRecovery":"\u5728\u5DE5\u4F5C\u9879\u8F93\u5165\u6846\u4E2D\u9009\u62E9\u6B64 Action\uFF0C\u518D\u53D1\u9001\u4FEE\u6B63\u8BF4\u660E\u3002","workCenter.sendInput":"\u53D1\u9001\u7ED9 Action","workCenter.sendingInput":"\u6B63\u5728\u53D1\u9001\u2026","workCenter.retryAction":"\u91CD\u8BD5 Action","workCenter.sendAndRetryAction":"\u53D1\u9001\u5E76\u91CD\u8BD5 Action","workCenter.coordinatorDecision.guide_actions":"\u5DF2\u66F4\u65B0 Action \u6307\u4EE4","workCenter.coordinatorDecision.replan":"\u5DF2\u66F4\u65B0\u76EE\u6807\u6216\u8BA1\u5212","workCenter.coordinatorDecision.request_human":"\u9700\u8981\u4EBA\u5DE5\u8865\u5145\u4FE1\u606F","workCenter.conversation":"\u5BF9\u8BDD","workCenter.contentPane":"\u5185\u5BB9","workCenter.workItemPanes":"\u5DE5\u4F5C\u9879\u9762\u677F","workCenter.coordinator":"\u534F\u8C03\u8005","workCenter.coordinatorTargetHint":"\u5DE5\u4F5C\u9879\u89C4\u5212\u4E0E\u534F\u8C03","workCenter.composerTarget":"\u6D88\u606F\u76EE\u6807","workCenter.targetUnavailable":"\u6240\u9009 Action \u5DF2\u4E0D\u53EF\u7528","workCenter.targetUnavailableHelp":"\u53D1\u9001\u524D\u8BF7\u9009\u62E9\u5176\u4ED6\u76EE\u6807\uFF1B\u7CFB\u7EDF\u6CA1\u6709\u91CD\u5B9A\u5411\u8FD9\u4EFD\u8349\u7A3F\u3002","workCenter.sendToCoordinatorInstead":"\u6539\u53D1\u7ED9 Coordinator","workCenter.sendToTarget":"\u53D1\u9001\u7ED9 {target}","workCenter.answerWithTarget":"\u5728\u5BF9\u8BDD\u8F93\u5165\u6846\u4E2D\u9009\u62E9\u76F8\u5173\u76EE\u6807\uFF0C\u7136\u540E\u56DE\u590D\u3002","workCenter.conversationThinking":"\u5904\u7406\u4E2D\u2026","workCenter.conversationReadOnly":"\u8FD9\u4E2A\u5DE5\u4F5C\u9879\u5DF2\u5173\u95ED\uFF0C\u5BF9\u8BDD\u8BB0\u5F55\u4ECD\u53EF\u67E5\u770B\u3002","workCenter.conversationPlaceholder":"\u7EE7\u7EED\u8BA8\u8BBA\u8FD9\u4E2A\u5DE5\u4F5C\u9879","workCenter.sendMessage":"\u53D1\u9001\u6D88\u606F","workCenter.messageSpeakerRole":"{name} \xB7 {role}","workCenter.originalRequest":"\u539F\u59CB\u9700\u6C42","workCenter.actionMessageScopeTitle":"\u7ED9\u8FD9\u4E2A Action \u53D1\u6D88\u606F","workCenter.actionMessageScope":"\u6D88\u606F\u53EA\u53D1\u9001\u7ED9\u5F53\u524D Action\u3002","workCenter.actionConversation":"\u5BF9\u8BDD","workCenter.actionConversationWith":"Action \u6267\u884C\u8005","workCenter.actionViews":"Action \u89C6\u56FE","workCenter.actionExecutor":"\u6267\u884C\u8005","workCenter.actionExecutorPending":"\u7B49\u5F85\u5206\u914D\u6267\u884C\u8005","workCenter.actionInformation":"Action \u4FE1\u606F","workCenter.messageExecutor":"\u7ED9 {name} \u53D1\u6D88\u606F","workCenter.actionChatPlaceholder":"\u5728\u5BF9\u8BDD\u8F93\u5165\u6846\u4E2D\u7ED9 {name} \u53D1\u6D88\u606F","workCenter.statusLabel":"\u72B6\u6001","workCenter.llmRequestsLabel":"LLM \u8BF7\u6C42","workCenter.loopsLabel":"Loops","workCenter.toolsLabel":"\u5DE5\u5177","workCenter.tokensLabel":"Tokens","workCenter.workItemMessagePlaceholder":"\u8865\u5145\u6574\u4E2A Work Item \u7684\u65B9\u5411\u6216\u7EA6\u675F","workCenter.sendWorkItemMessage":"\u53D1\u9001\u7ED9 Work Item","workCenter.fromSession":"\u4ECE\u5F53\u524D Session \u521B\u5EFA\u5DE5\u4F5C\u9879","workCenter.llmRequestCount":"{count} \u6B21 LLM \u8BF7\u6C42","workCenter.loopCount":"{count} \u6B21 Loop","workCenter.toolCount":"{count} \u4E2A\u5DE5\u5177","workCenter.tokenCount":"{count} tokens","workCenter.tokenBreakdown":"\u8F93\u5165 {input} / \u8F93\u51FA {output} / \u7F13\u5B58 {cache}","workCenter.guidance":"\u7ED9\u5F53\u524D Action \u8865\u5145\u63D0\u793A","workCenter.guidanceHint":"\u8865\u5145\u7EA6\u675F\uFF0C\u6216\u8C03\u6574\u5F53\u524D Action \u7684\u6267\u884C\u65B9\u5411","workCenter.guidanceRestartHint":"\u53D1\u9001\u540E\u4F1A\u4F7F\u7528\u65B0\u63D0\u793A\u91CD\u542F\u5F53\u524D Action\u3002","workCenter.sendGuidance":"\u53D1\u9001\u63D0\u793A","workCenter.reuseMemory":"\u4F7F\u7528\u76F8\u5173 Agent memory \u548C\u6B64\u9879\u76EE\u7684\u5DF2\u5B8C\u6210\u5DE5\u4F5C","workCenter.reuseMemoryHelp":"\u5305\u62EC\u53D7 scope \u7EA6\u675F\u7684 Agent memory\uFF0C\u4EE5\u53CA canonical \u9879\u76EE\u76EE\u5F55\u76F8\u540C\u7684\u5DF2\u5B8C\u6210 Work Item \u7ED3\u6784\u5316\u6458\u8981\u548C\u8BC1\u636E\uFF1B\u4E0D\u4F1A\u590D\u7528\u539F\u59CB\u5DE5\u5177\u8F93\u51FA\u3002","workCenter.resumeAnswer":"\u56DE\u7B54\u7B49\u5F85\u4E2D\u7684\u95EE\u9898","workCenter.resumeAnswerHint":"\u63D0\u4F9B\u7EE7\u7EED\u6267\u884C\u6240\u9700\u7684\u4FE1\u606F","workCenter.answerInActionDetail":"\u5728\u5BF9\u8BDD\u8F93\u5165\u6846\u4E2D\u5C06\u76EE\u6807\u8BBE\u4E3A\u5F53\u524D Action\uFF0C\u7136\u540E\u56DE\u590D\u3002","workCenter.selectPrompt":"\u9009\u62E9\u4E00\u4E2A\u5DE5\u4F5C\u9879\uFF0C\u67E5\u770B\u5B83\u7684\u6D41\u7A0B\u3002","workCenter.createHint":"\u63CF\u8FF0\u4F60\u9700\u8981\u4EC0\u4E48\uFF0CCoordinator \u4F1A\u6301\u7EED\u521B\u5EFA\u5F53\u524D\u5FC5\u8981\u7684 Actions\uFF0C\u76F4\u5230\u9A8C\u6536\u6761\u4EF6\u5F97\u5230\u9A8C\u8BC1\u3002","workCenter.requirement":"\u9700\u6C42","workCenter.requirementHint":"\u7528\u81EA\u7136\u8BED\u8A00\u63CF\u8FF0\u95EE\u9898\u3001\u671F\u671B\u7ED3\u679C\u548C\u5FC5\u8981\u7EA6\u675F","workCenter.requirementHelp":"Coordinator \u4F1A\u5B8C\u5584\u76EE\u6807\u4E0E\u9A8C\u6536\u6761\u4EF6\uFF0C\u5E76\u968F\u7740\u8BC1\u636E\u4EA7\u751F\u52A8\u6001\u521B\u5EFA Actions\u3002","workCenter.titleField":"\u6807\u9898","workCenter.titleHint":"\u7B80\u77ED\u3001\u660E\u786E\u5730\u63CF\u8FF0\u9884\u671F\u7ED3\u679C","workCenter.goalHint":"\u8BF4\u660E Agent \u5FC5\u987B\u4EA4\u4ED8\u7684\u6700\u7EC8\u7ED3\u679C","workCenter.criteriaHint":"\u6BCF\u884C\u4E00\u6761\u9A8C\u6536\u6761\u4EF6","workCenter.attachments":"\u9644\u4EF6","workCenter.outputs":"\u4EA7\u51FA","workCenter.deliveryTarget":"\u4EA4\u4ED8\u76EE\u6807","workCenter.deliveryTargetAsk":"\u4EA4\u4ED8\u524D\u8BE2\u95EE\u6211","workCenter.deliveryTargetFiles":"\u5DE5\u4F5C\u76EE\u5F55\u4E2D\u7684\u6587\u4EF6","workCenter.deliveryTargetPr":"\u521B\u5EFA\u62C9\u53D6\u8BF7\u6C42","workCenter.deliveryTargetMerge":"\u5408\u5E76\u5DF2\u6279\u51C6\u7684\u62C9\u53D6\u8BF7\u6C42","workCenter.deliveryTargetHelp":"\u8FD9\u662F\u5B8C\u6210\u8FB9\u754C\uFF0C\u4E0D\u4EE3\u8868\u53EF\u4EE5\u7ED5\u8FC7\u8BC4\u5BA1\u6216\u5408\u5E76\u7B56\u7565\u3002","workCenter.attachmentsHelp":"\u56FE\u7247\u3001PDF \u548C\u6587\u672C\u6587\u4EF6\u4F1A\u6301\u7EED\u7ED1\u5B9A\u5230\u6B64 Work Item\uFF0C\u5E76\u63D0\u4F9B\u7ED9\u6BCF\u4E2A Action\u3002","workCenter.attachmentsUnsupported":"\u6240\u9009 Agent \u4E0D\u652F\u6301 Work Item \u9644\u4EF6\u3002","workCenter.addAttachments":"\u6DFB\u52A0\u6587\u4EF6","workCenter.attachmentsUploading":"\u4E0A\u4F20\u4E2D\u2026","workCenter.attachmentsUploadFailed":"\u9644\u4EF6\u4E0A\u4F20\u5931\u8D25","workCenter.pendingEnvelopeLocked":"\u6709\u4E00\u6761\u672A\u786E\u8BA4\u8BF7\u6C42\u5DF2\u9501\u5B9A\u5230\u539F\u59CB\u8EAB\u4EFD\u3002","workCenter.replacePendingAttachments":"\u66FF\u6362\u9644\u4EF6","workCenter.discardPendingEnvelope":"\u653E\u5F03\u5F85\u786E\u8BA4\u8BF7\u6C42","workCenter.pendingEnvelopeChanged":"\u5F85\u786E\u8BA4\u8BF7\u6C42\u5DF2\u53D8\u5316\uFF0C\u8BF7\u91CD\u65B0\u6253\u5F00\u8BE5\u5DE5\u4F5C\u9879\u540E\u518D\u8BD5\u3002","workCenter.removeAttachment":"\u4ECE\u8349\u7A3F\u4E2D\u79FB\u9664","workCenter.previewAttachment":"\u6253\u5F00\u9644\u4EF6","workCenter.openAttachmentNamed":"\u6253\u5F00\u9644\u4EF6 {name}","workCenter.openingAttachment":"\u6B63\u5728\u6253\u5F00\u9644\u4EF6\u2026","workCenter.attachmentPreviewFailed":"\u65E0\u6CD5\u6253\u5F00\u9644\u4EF6\uFF0C\u8BF7\u91CD\u8BD5\u3002","workCenter.attachmentOpenBlocked":"\u6D4F\u89C8\u5668\u963B\u6B62\u4E86\u9644\u4EF6\u7A97\u53E3\uFF0C\u8BF7\u5141\u8BB8\u5F39\u51FA\u7A97\u53E3\u540E\u91CD\u8BD5\u3002","workCenter.execution":"\u6267\u884C\u65B9\u5F0F","workCenter.executionHint":"\u9009\u62E9\u5DE5\u4F5C\u9879\u5728\u54EA\u91CC\u6267\u884C\uFF0C\u4EE5\u53CA\u521B\u5EFA\u540E\u662F\u5426\u7ACB\u5373\u5F00\u59CB\u3002","workCenter.workDir":"\u5DE5\u4F5C\u76EE\u5F55","workCenter.workDirHint":"\u9009\u62E9\u4E00\u4E2A\u5DF2\u5B58\u5728\u7684\u9879\u76EE\u76EE\u5F55","workCenter.chooseFolder":"\u9009\u62E9\u6587\u4EF6\u5939","workCenter.workDirPickerHelp":"\u4ECE\u5F53\u524D Agent \u7684\u771F\u5B9E\u76EE\u5F55\u4E2D\u9009\u62E9\u5DF2\u5B58\u5728\u7684\u6587\u4EF6\u5939\u3002","workCenter.folderPickerHint":"\u9009\u62E9\u8FD9\u4E2A\u5DE5\u4F5C\u9879\u53EF\u4EE5\u8BFB\u53D6\u548C\u4FEE\u6539\u7684\u9879\u76EE\u76EE\u5F55\u3002","workCenter.folderPickerSelectionHint":"\u53CC\u51FB\u8FDB\u5165\u76EE\u5F55\uFF0C\u6216\u9009\u4E2D\u76EE\u5F55\u540E\u786E\u8BA4\u3002","workCenter.startImmediately":"\u7ACB\u5373\u5F00\u59CB","workCenter.startImmediatelyHint":"\u5173\u95ED\u540E\u5C06\u521B\u5EFA\u4E3A\u8349\u7A3F\uFF0C\u786E\u8BA4\u65E0\u8BEF\u540E\u518D\u5F00\u59CB\u3002","workCenter.creating":"\u521B\u5EFA\u4E2D\u2026","workCenter.create":"\u521B\u5EFA","workCenter.status.draft":"\u8349\u7A3F","workCenter.status.ready":"\u5F85\u6267\u884C","workCenter.status.running":"\u6267\u884C\u4E2D","workCenter.status.waiting":"\u7B49\u5F85\u4E2D","workCenter.status.needs_attention":"\u9700\u8981\u5904\u7406","workCenter.status.done":"\u5DF2\u5B8C\u6210","workCenter.status.cancelled":"\u5DF2\u53D6\u6D88","workCenter.status.completed":"\u5DF2\u5B8C\u6210","workCenter.status.failed":"\u5931\u8D25","workCenter.status.closed":"\u5DF2\u5173\u95ED","workCenter.status.superseded":"\u5DF2\u66FF\u4EE3","workCenter.action.triage":"\u5206\u6790","workCenter.action.implement":"\u5B9E\u73B0","workCenter.action.review":"\u8BC4\u5BA1","workCenter.action.integrate":"\u96C6\u6210","workCenter.action.deliver":"\u4EA4\u4ED8","workCenter.action.test":"\u6D4B\u8BD5","workCenter.action.research":"\u7814\u7A76","workCenter.action.design":"\u8BBE\u8BA1","workCenter.action.diagnose":"\u8BCA\u65AD","workCenter.action.migrate":"\u8FC1\u79FB","workCenter.action.document":"\u6587\u6863","workCenter.action.operate":"\u8FD0\u7EF4","workCenter.action.write":"\u5199\u4F5C","workCenter.action.create_vp":"\u521B\u5EFA VP","workCenter.action.custom":"\u81EA\u5B9A\u4E49","workCenter.assignment.auto":"\u4F7F\u7528\u4EFB\u52A1\u6D41\u7B56\u7565","workCenter.model.inherit":"\u4F7F\u7528\u4EFB\u52A1\u6D41\u6A21\u578B","workCenter.model.defaultProvider":"\u9ED8\u8BA4 Provider","workCenter.planPreview":"\u6267\u884C\u8BA1\u5212","workCenter.planPreviewHelp":"\u6839\u636E\u5F53\u524D Agent \u7684 VP \u6C60\u548C\u6A21\u578B\u8BBE\u7F6E\u5B9E\u65F6\u89E3\u6790\u3002","workCenter.settings.title":"\u5DE5\u4F5C\u4E2D\u5FC3\u8BBE\u7F6E","workCenter.settings.subtitle":"\u914D\u7F6E Coordinator\uFF0C\u4EE5\u53CA AI \u52A8\u6001\u89C4\u5212\u4F7F\u7528\u7684 Action \u63D0\u793A\u8BCD\u3001\u6A21\u578B\u548C effort\u3002","workCenter.settings.workflow":"\u4EFB\u52A1\u6D41","workCenter.settings.workflowHelp":"Coordinator \u4F1A\u9488\u5BF9\u4EFB\u52A1\u52A8\u6001\u9009\u62E9 Action \u548C\u6267\u884C\u8005\u3002","workCenter.settings.aiWorkflowHelp":"Coordinator \u53EA\u521B\u5EFA\u5F53\u524D\u5FC5\u8981\u7684\u4EFB\u52A1\u4E13\u5C5E Action\u3002\u5185\u7F6E Action \u7B56\u7565\u662F\u53EF\u590D\u7528\u6A21\u677F\uFF1B\u9700\u8981\u65F6 Coordinator \u53EF\u4EE5\u521B\u5EFA\u7CBE\u786E\u7684\u9886\u57DF\u7C7B\u578B\u3002","workCenter.settings.globalInstructions":"Agent \u5168\u5C40\u6307\u4EE4","workCenter.settings.globalInstructionsHint":"\u4F8B\u5982\uFF1A\u9075\u5FAA\u4ED3\u5E93\u53D1\u5E03\u6D41\u7A0B\u3001\u5FC5\u987B\u72EC\u7ACB\u8BC4\u5BA1\uFF0C\u672A\u7ECF\u660E\u786E\u6279\u51C6\u4E0D\u5F97\u521B\u5EFA\u90E8\u7F72 tag\u3002","workCenter.settings.globalInstructionsHelp":"\u4FDD\u5B58\u5728 Agent \u7EA7\uFF0C\u5E76\u51BB\u7ED3\u8FDB\u6BCF\u4E2A\u65B0 Work Item\uFF1B\u5BF9 triage \u548C\u6240\u6709\u751F\u6210\u7684 Action \u751F\u6548\uFF0C\u4F18\u5148\u7EA7\u4F4E\u4E8E Work Item \u5951\u7EA6\u53CA\u7CFB\u7EDF/\u5DE5\u5177\u5B89\u5168\u89C4\u5219\u3002\u5DF2\u6709 Work Item \u4FDD\u7559\u539F\u5FEB\u7167\u3002","workCenter.settings.actionPolicies":"\u5185\u7F6E Action \u7B56\u7565","workCenter.settings.actionPoliciesHelp":"\u8FD9\u4E9B\u662F\u53EF\u590D\u7528\u7684\u6267\u884C\u57FA\u7EBF\uFF0C\u4E0D\u662F\u56FA\u5B9A\u5DE5\u4F5C\u6D41\u3002\u672A\u77E5\u7684\u9886\u57DF Action \u7C7B\u578B\u4F1A\u4F7F\u7528\u201C\u81EA\u5B9A\u4E49\u201D\u7B56\u7565\uFF0C\u5E76\u4FDD\u7559 triage \u751F\u6210\u7684\u7C7B\u578B\u548C\u4EFB\u52A1\u76EE\u6807\u3002","workCenter.settings.dynamicInstructionHelp":"AI \u4F1A\u52A0\u5165 Work Item \u5951\u7EA6\u3001\u5168\u5C40\u6307\u4EE4\u3001\u524D\u5E8F Action \u4E0A\u4E0B\u6587\u3001memory \u548C\u4EFB\u52A1\u4E13\u5C5E\u76EE\u6807\uFF1B\u8FD9\u91CC\u5B9A\u4E49\u8BE5 Action \u7C7B\u578B\u7684\u53EF\u590D\u7528\u884C\u4E3A\u3002","workCenter.settings.models":"\u6A21\u578B","workCenter.settings.modelsHelp":"Provider \u548C\u51ED\u8BC1\u4ECD\u7531 Agent LLM \u8BBE\u7F6E\u7BA1\u7406\uFF1B\u5DE5\u4F5C\u4E2D\u5FC3\u53EA\u9009\u62E9\u53EF\u7528\u6A21\u578B\u3002","workCenter.settings.dynamicModelsHelp":"Coordinator \u4E0E\u5B9E\u9645\u6267\u884C Action \u7684\u6A21\u578B\u53EF\u4EE5\u5206\u522B\u914D\u7F6E\u3002","workCenter.settings.coordinatorModel":"Coordinator","workCenter.settings.coordinatorModelHelp":"\u7528\u4E8E Work Item \u5BF9\u8BDD\u3001\u4FEE\u6539\u76EE\u6807\u548C\u91CD\u65B0\u89C4\u5212\uFF1B\u4E0D\u4F1A\u6267\u884C\u9879\u76EE\u5DE5\u5177\u3002","workCenter.settings.allActions":"\u6240\u6709 Action \u7684\u515C\u5E95\u7B56\u7565","workCenter.settings.maxConcurrentActions":"\u6700\u5927\u5E76\u53D1 Action \u6570","workCenter.settings.maxConcurrentActionsHelp":"\u9ED8\u8BA4 3\u3002\u975E Git\u3001\u810F\u5DE5\u4F5C\u533A\u3001\u5171\u4EAB\u526F\u4F5C\u7528\u548C\u96C6\u6210 Action \u4ECD\u4F1A\u4E32\u884C\u6267\u884C\u3002","workCenter.workItemType":"\u7C7B\u578B","workCenter.typeAuto":"Auto \u2014 \u7531 LLM \u63A8\u65AD","workCenter.typeHelp":"\u53EF\u9009\u62E9\u4EFB\u52A1\u7C7B\u522B\uFF0C\u4E5F\u53EF\u8BA9 AI \u81EA\u52A8\u63A8\u65AD\uFF1B\u5177\u4F53 Actions \u59CB\u7EC8\u7531 AI \u89C4\u5212\u3002","workCenter.planning":"\u89C4\u5212\u4E2D","workCenter.aiPlan":"Coordinator \u9A71\u52A8\u6267\u884C","workCenter.aiPlanHelp":"Coordinator \u4F1A\u4F9D\u636E\u5F53\u524D\u8BC1\u636E\u9009\u62E9\u4E0B\u4E00\u6279 Action \u548C\u6267\u884C\u8005\uFF0C\u4E0D\u518D\u9884\u5148\u751F\u6210\u5DE5\u4F5C\u6D41\u56FE\uFF1B\u6A21\u578B\u4E0E effort \u7531 Work Center \u8BBE\u7F6E\u63A7\u5236\u3002","workCenter.settings.manageProviders":"\u7BA1\u7406 Agent \u6A21\u578B","workCenter.settings.assignment":"VP \u9009\u62E9","workCenter.settings.assignment.auto":"\u4ECE\u5168\u90E8 VP \u81EA\u52A8\u9009\u62E9","workCenter.settings.assignment.pool":"\u5019\u9009\u6C60","workCenter.settings.assignment.fixed":"\u56FA\u5B9A VP","workCenter.settings.capability":"\u6240\u9700\u80FD\u529B","workCenter.settings.vp":"Virtual Person","workCenter.settings.poolMembers":"\u5019\u9009 VP","workCenter.settings.modelPolicy":"\u6A21\u578B\u7B56\u7565","workCenter.settings.model.inherit":"\u7EE7\u627F VP \u504F\u597D","workCenter.settings.model.primary":"Agent \u4E3B\u6A21\u578B","workCenter.settings.model.fast":"Agent \u5FEB\u6A21\u578B","workCenter.settings.model.specific":"\u6307\u5B9A\u6A21\u578B","workCenter.settings.model":"\u6A21\u578B","workCenter.settings.effort":"\u63A8\u7406\u5F3A\u5EA6","workCenter.settings.effortDefault":"\u6A21\u578B\u9ED8\u8BA4\u503C","workCenter.settings.effortHelp":"\u8986\u76D6\u6240\u9009\u6A21\u578B\u7684\u9ED8\u8BA4\u63A8\u7406\u5F3A\u5EA6\uFF0C\u5E76\u7528\u4E8E\u6240\u6709 Work Center Action\u3002","workCenter.settings.effortChooseModelHelp":"\u9009\u62E9 Agent \u4E3B\u6A21\u578B\u3001\u5FEB\u6A21\u578B\u6216\u6307\u5B9A\u6A21\u578B\u540E\u53EF\u914D\u7F6E\u63A8\u7406\u5F3A\u5EA6\uFF1B\u7EE7\u627F VP \u504F\u597D\u65F6\u4F7F\u7528\u5404 VP \u6A21\u578B\u7684\u9ED8\u8BA4\u503C\u3002","workCenter.settings.effortUnsupportedHelp":"\u6240\u9009\u6A21\u578B\u4E0D\u63D0\u4F9B\u53EF\u914D\u7F6E\u7684\u63A8\u7406\u5F3A\u5EA6\uFF0C\u56E0\u6B64\u4F7F\u7528\u6A21\u578B\u9ED8\u8BA4\u503C\u3002","workCenter.settings.saving":"\u4FDD\u5B58\u4E2D\u2026","workCenter.settings.reload":"\u91CD\u65B0\u52A0\u8F7D\u8BBE\u7F6E","workCenter.settings.conflict":"\u8BBE\u7F6E\u5DF2\u5728\u5176\u4ED6\u4F4D\u7F6E\u66F4\u65B0\uFF0C\u8BF7\u91CD\u65B0\u52A0\u8F7D\u540E\u518D\u4FDD\u5B58\u3002","workCenter.settings.upgradeRequired":"\u5F53\u524D Agent \u7248\u672C\u65E0\u6CD5\u4FDD\u5B58\u5DE5\u4F5C\u4E2D\u5FC3\u8BBE\u7F6E\u3002\u8FD9\u91CC\u4EE5\u53EA\u8BFB\u65B9\u5F0F\u663E\u793A\u5F53\u524D\u503C\uFF1B\u5347\u7EA7 Agent \u540E\u5373\u53EF\u7F16\u8F91\u5E76\u4FDD\u5B58\u3002","workCenter.settings.saveNotConfirmed":"Agent \u672A\u786E\u8BA4\u672C\u6B21\u63D0\u4EA4\u7684\u63D0\u793A\u8BCD\u548C\u6A21\u578B\u7B56\u7565\u3002\u8BBE\u7F6E\u7A97\u53E3\u4E0D\u4F1A\u5173\u95ED\uFF1B\u8BF7\u91CD\u65B0\u52A0\u8F7D\u6216\u5347\u7EA7 Agent \u540E\u518D\u8BD5\u3002","workCenter.settings.addWorkflow":"\u590D\u5236\u4EFB\u52A1\u6D41","workCenter.settings.removeWorkflow":"\u5220\u9664","workCenter.settings.newWorkflow":"\u4EFB\u52A1\u6D41 {index}","workCenter.settings.workflowName":"\u4EFB\u52A1\u6D41\u540D\u79F0","workCenter.settings.newStage":"\u65B0\u9636\u6BB5","workCenter.settings.addStage":"\u6DFB\u52A0\u9636\u6BB5","workCenter.settings.removeStage":"\u5220\u9664\u9636\u6BB5","workCenter.settings.moveUp":"\u4E0A\u79FB\u9636\u6BB5","workCenter.settings.moveDown":"\u4E0B\u79FB\u9636\u6BB5","workCenter.settings.stageType":"\u9636\u6BB5\u7C7B\u578B","workCenter.settings.reviewReturnStage":"\u8981\u6C42\u4FEE\u6539\u65F6\u9000\u56DE\u9636\u6BB5","workCenter.settings.instruction":"\u9636\u6BB5 Prompt","workCenter.settings.instructionHint":"\u5B9A\u4E49\u8FD9\u4E2A\u9636\u6BB5\u5177\u4F53\u8981\u505A\u4EC0\u4E48\u3002","workCenter.settings.instructionHelp":"\u8FD0\u884C\u65F6\u4F1A\u81EA\u52A8\u52A0\u5165 Work Item \u7684\u76EE\u6807\u3001\u9A8C\u6536\u6807\u51C6\u548C\u53EF\u590D\u7528\u4E0A\u4E0B\u6587\u3002","workCenter.settings.instructionReset":"\u6062\u590D\u9ED8\u8BA4\u503C"}});var xf,Tf=W(()=>{Hl();Bl();xf={...wf,...Sf,"quickSend.composer.label":"Quick send","quickSend.composer.send":"Quick send {number}: {name}","common.loading":"Loading...","common.confirm":"OK","common.apply":"Apply","common.cancel":"Cancel","common.delete":"Delete","common.copy":"Copy","common.copied":"Copied","common.close":"Close","common.refresh":"Refresh","common.open":"Open","common.save":"Save","common.saving":"Saving...","common.search":"Search","common.back":"Back","common.noSubdirectories":"No subdirectories","common.drives":"Drives","common.rootDir":"Root","common.comma":", ","common.select":"Select","common.retry":"Retry","mermaid.export":"Export","mermaid.exportMd":"Export MD","mermaid.exportPng":"Export PNG","mermaid.exportJpg":"Export JPG","login.subtitle":"Yeaft Web Code Agent","login.username":"Username","login.password":"Password","login.login":"Login","login.loggingIn":"Logging in...","login.enterUsername":"Please enter your username","login.enterPassword":"Please enter your password","login.noAccount":"Don't have an account?","login.registerWithCode":"Register","login.or":"or","login.usePassword":"Sign in with username & password","login.useSso":"Back to single sign-on","login.noProviders":"No third-party sign-in providers are enabled.","login.microsoft":"Sign in with Microsoft","login.github":"Sign in with GitHub","login.google":"Sign in with Google","login.wechat":"Sign in with WeChat","login.alipay":"Sign in with Alipay","login.wechat.mobileUnsupported":"Sign in with WeChat is only available on PC. Please scan the QR code from a desktop browser.","login.alipay.mobileWaiting":"Waiting for you to confirm in the Alipay app\u2026 Once you finish, return to this page and you will be signed in automatically.","login.alipay.relaunch":"Open Alipay again","login.qr.title":"Scan to sign in","login.qr.titleAlipay":"Sign in with Alipay","login.qr.titleWechat":"Sign in with WeChat","login.qr.hint":"Scan the QR code with your phone to authorize.","login.error.enterUsername":"Please enter your username","login.error.enterPassword":"Please enter your password","login.error.enter6Digit":"Please enter a 6-digit code","login.error.enterInviteCode":"Please enter the invite code","login.error.usernameMinLen":"Username must be at least 2 characters","login.error.passwordMinLen":"Password must be at least 6 characters","login.error.passwordMismatch":"Passwords do not match","login.error.enterVerifyCode":"Please enter the verification code","login.error.loginFailed":"Login failed","login.forgot.link":"Forgot password?","login.forgot.title":"Reset your password","login.forgot.emailHint":"Enter the email address on your account. We will send a 6-digit reset code.","login.forgot.sendCode":"Send Reset Code","login.forgot.sending":"Sending...","login.forgot.codeSent":"If the email is on file, a 6-digit reset code has been sent. Enter it below along with your new password.","login.forgot.resetBtn":"Reset Password","login.forgot.resetting":"Resetting...","login.forgot.success":"Password reset. You can now sign in with your new password.","login.forgot.emailInvalid":"Please enter a valid email","login.register.title":"New User Registration","login.register.inviteCode":"Invite Code","login.register.username":"Username","login.register.password":"Password (min 6 characters)","login.register.confirmPassword":"Confirm Password","login.register.email":"Email (optional)","login.register.submit":"Register","login.register.submitting":"Registering...","login.register.back":"Back to Login","login.register.success":"Registration successful, please login","login.register.enterCode":"Please enter the invite code","login.register.usernameMin":"Username must be at least 2 characters","login.register.passwordMin":"Password must be at least 6 characters","login.register.passwordMismatch":"Passwords do not match","login.totp.setupTitle":"Set Up Two-Factor Authentication","login.totp.setupHint":"Scan the QR code below with Microsoft Authenticator or Google Authenticator","login.totp.manualKey":"Or enter the key manually:","login.totp.enterCode":"Enter 6-digit code","login.totp.complete":"Complete Setup","login.totp.verifying":"Verifying...","login.totp.verify":"Verify","login.totp.prompt":"Enter the code from your Authenticator app","login.totp.invalidCode":"Please enter a 6-digit code","login.email.codeSent":"Verification code sent to {email}","login.email.enterCode":"Enter verification code","login.email.verify":"Verify","login.email.verifying":"Verifying...","login.email.enterCodeError":"Please enter the verification code","chat.agent.select":"Select Agent","chat.agent.manage":"Manage Agents","chat.agent.count":"{count} agents","chat.agent.none":"No Agents","chat.agent.restarting":"Restarting","agentSettings.open":"Agent settings","agentSettings.manage":"Manage","agentSettings.eyebrow":"Local runtime","agentSettings.title":"Agent settings","agentSettings.description":"Inspect and configure each connected Agent without mixing runtime controls into account settings.","agentSettings.agentList":"Agent","agentSettings.categories":"Agent setting categories","agentSettings.categories.operations":"Operations","agentSettings.categories.trace":"Trace","agentSettings.categories.llm":"LLM configuration","agentSettings.selectedAgent":"Selected Agent","agentSettings.online":"Online","agentSettings.offline":"Offline","agentSettings.empty":"No Agents are available.","agentSettings.runtime.title":"Runtime","agentSettings.runtime.description":"Identity, workspace, and local background processing.","agentSettings.runtime.version":"Version","agentSettings.runtime.updateAvailable":"Update available: v{version}","agentSettings.runtime.updateUnknown":"Update status unavailable","agentSettings.runtime.workDir":"Working directory","agentSettings.telemetry.title":"Diagnostics","agentSettings.telemetry.saved":"Diagnostics settings saved.","agentSettings.telemetry.loadFailed":"Failed to load diagnostics settings.","agentSettings.telemetry.saveFailed":"Failed to save diagnostics settings.","agentSettings.maintenance.title":"Maintenance","agentSettings.maintenance.description":"These operations interrupt work running on the selected Agent.","agentSettings.maintenance.upgradeFailed":"Agent upgrade failed.","chat.agent.dream":"Dream","chat.agent.dreamHint":"Enable automatic Dream memory processing","chat.agent.restart":"Restart","chat.agent.restartConfirm":`Are you sure you want to restart Agent "{name}"?
|
|
@@ -907,7 +907,7 @@ ${String(e||"").trim()}
|
|
|
907
907
|
</button>
|
|
908
908
|
</div>
|
|
909
909
|
<pre><code${L}>${ee}</code></pre>
|
|
910
|
-
</div>`}),he=I=>I.replace(/<table>([\s\S]*?)<\/table>/g,j=>`<div class="table-scroll-wrapper">${j}</div>`),Ie=I=>{if(!I)return"";typeof I!="string"&&(I=String(I));let j=L=>{let ee=document.createElement("div");return ee.textContent=L,ee.innerHTML};return I.replace(/```(\w*)\n([\s\S]*?)```/g,(L,ee,ge)=>`<div class="code-block-wrapper"><pre><code class="language-${ee}">${j(ge.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>")},z=async()=>{try{await navigator.clipboard.writeText(e.turn.textContent||""),n.value=!0,setTimeout(()=>{n.value=!1},2e3)}catch{}},X=async()=>{try{await navigator.clipboard.writeText(e.turn.textContent||""),r.value=!0,setTimeout(()=>{r.value=!1},2e3)}catch{}},G=()=>{let I=e.turn.textContent||"";if(!I)return;let j=new Blob([I],{type:"text/markdown;charset=utf-8"}),L=URL.createObjectURL(j),ee=document.createElement("a");ee.download=`response-${Date.now()}.md`,ee.href=L,ee.click(),URL.revokeObjectURL(L)},re=async()=>{if(!(l.value||!window.htmlToImage)){l.value=!0;try{let I=c.value;if(!I)return;let j=I.querySelector(".turn-content");if(!j)return;let L=getComputedStyle(document.body).getPropertyValue("--bg-main").trim()||"#ffffff";j.classList.add("screenshot-mode");try{let ge=j.getBoundingClientRect(),xe=await window.htmlToImage.toPng(j,{backgroundColor:L,pixelRatio:3,width:ge.width+64,height:ge.height+64,style:{padding:"32px"},filter:Ne=>!(Ne.classList&&(Ne.classList.contains("turn-header")||Ne.classList.contains("screenshot-btn")))}),Oe=document.createElement("a");Oe.download=`response-${Date.now()}.png`,Oe.href=xe,Oe.click()}finally{j.classList.remove("screenshot-mode")}}catch{}finally{l.value=!1}}};Vue.onMounted(()=>{window.copyCodeBlock||(window.copyCodeBlock=async function(I){let L=I.closest(".code-block-wrapper").querySelector("code");if(L)try{await navigator.clipboard.writeText(L.textContent),I.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(()=>{I.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(I=>{hljs.highlightElement(I),I.dataset.highlighted="true"}),Ft(c.value)})}),Vue.watch(()=>e.turn.textContent,()=>{Vue.nextTick(()=>{typeof hljs<"u"&&document.querySelectorAll("pre code:not([data-highlighted])").forEach(I=>{hljs.highlightElement(I),I.dataset.highlighted="true"}),Ft(c.value)})});let fe=I=>{if(I?.src){let L=ai(I.src,s.effectiveWorkDir||"");return L?p.get(L.path)||"":I.src}if(!I?.fileId)return"";let j=I.previewToken||"";return`/api/preview/${I.fileId}?token=${j}`},Ae=I=>{d.add(I?.assetId||I?.id)},_e=Vue.computed(()=>(Array.isArray(e.turn?.imageMsgs)?e.turn.imageMsgs:[]).map(I=>({image:I,src:fe(I),alt:I?.filename||m("message.imagePreview")})).filter(I=>I.src&&!d.has(I.image?.assetId||I.image?.id))),ce=(I,j)=>{let L=_e.value,ee=L.findIndex(ge=>ge.image===I);ee<0||As(L[ee].src,{alt:L[ee].alt,closeLabel:m("common.close"),zoomOutLabel:m("message.zoomOut"),zoomInLabel:m("message.zoomIn"),resetZoomLabel:m("message.resetZoom"),previousLabel:m("message.previousImage"),nextLabel:m("message.nextImage"),positionLabel:(ge,xe)=>m("message.imagePosition",{current:ge,total:xe}),gallery:L.map(({src:ge,alt:xe})=>({src:ge,alt:xe})),initialIndex:ee,trigger:j})},se=I=>{if(I)try{typeof s.cancelVpTurn=="function"&&s.cancelVpTurn(I)}catch{}},te=()=>{let I=e.turn;return I?typeof I.timestamp=="number"&&I.timestamp>0?I.timestamp:typeof I.createdAt=="number"&&I.createdAt>0?I.createdAt:typeof I.speakerTimestamp=="number"&&I.speakerTimestamp>0?I.speakerTimestamp:null:null},_=Vue.computed(()=>Jt(te())),oe=Vue.computed(()=>{let I=te();if(!I)return"";try{return new Date(I).toLocaleString()}catch{return""}}),E=Vue.computed(()=>$p(e.turn,e.quoteAuthor||m("message.assistant"))),Z=Vue.computed(()=>{let I=typeof e.turn?.model=="string"?e.turn.model.trim():"";if(!I)return"";let j=I.lastIndexOf("/");return j>=0?I.slice(j+1):I}),ue=Vue.computed(()=>{let I=Number.isFinite(e.turn?.inputTokens)?Math.max(0,Math.round(e.turn.inputTokens)):null,j=Number.isFinite(e.turn?.outputTokens)?Math.max(0,Math.round(e.turn.outputTokens)):null,L=Number.isFinite(e.turn?.totalTokens)?Math.max(0,Math.round(e.turn.totalTokens)):I!=null&&j!=null?I+j:null;if(L==null||I==null||j==null||L===0&&I===0&&j===0)return"";let ee=ge=>new Intl.NumberFormat().format(ge);return m("yeaft.message.tokenUsage",{total:ee(L),input:ee(I),output:ee(j)})});return{onStopTurn:se,turnTime:_,turnTimeFull:oe,assistantQuote:E,responseModelMeta:Z,responseTokenMeta:ue,copied:n,fullCopied:r,expanded:o,screenshotting:l,turnRef:c,showToolActions:S,latestTool:b,historyTools:k,latestToolIndex:P,actionTools:w,routeMessages:h,toggleExpand:B,toolExpandedValue:U,updateToolExpanded:F,textSegments:R,progressSegments:J,resultSegments:V,renderSegment:O,onMarkdownClick:M,copyContent:z,copyFullResponse:X,exportMarkdown:G,screenshotContent:re,onAskSubmit:y,imageSrc:fe,failedImages:d,handleImageError:Ae,previewImage:ce,displayedTodos:x}}}});function dc(e){if(!Number.isFinite(e)||e<0)return"";let t=Math.floor(e/1e3)
|
|
910
|
+
</div>`}),he=I=>I.replace(/<table>([\s\S]*?)<\/table>/g,j=>`<div class="table-scroll-wrapper">${j}</div>`),Ie=I=>{if(!I)return"";typeof I!="string"&&(I=String(I));let j=L=>{let ee=document.createElement("div");return ee.textContent=L,ee.innerHTML};return I.replace(/```(\w*)\n([\s\S]*?)```/g,(L,ee,ge)=>`<div class="code-block-wrapper"><pre><code class="language-${ee}">${j(ge.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>")},z=async()=>{try{await navigator.clipboard.writeText(e.turn.textContent||""),n.value=!0,setTimeout(()=>{n.value=!1},2e3)}catch{}},X=async()=>{try{await navigator.clipboard.writeText(e.turn.textContent||""),r.value=!0,setTimeout(()=>{r.value=!1},2e3)}catch{}},G=()=>{let I=e.turn.textContent||"";if(!I)return;let j=new Blob([I],{type:"text/markdown;charset=utf-8"}),L=URL.createObjectURL(j),ee=document.createElement("a");ee.download=`response-${Date.now()}.md`,ee.href=L,ee.click(),URL.revokeObjectURL(L)},re=async()=>{if(!(l.value||!window.htmlToImage)){l.value=!0;try{let I=c.value;if(!I)return;let j=I.querySelector(".turn-content");if(!j)return;let L=getComputedStyle(document.body).getPropertyValue("--bg-main").trim()||"#ffffff";j.classList.add("screenshot-mode");try{let ge=j.getBoundingClientRect(),xe=await window.htmlToImage.toPng(j,{backgroundColor:L,pixelRatio:3,width:ge.width+64,height:ge.height+64,style:{padding:"32px"},filter:Ne=>!(Ne.classList&&(Ne.classList.contains("turn-header")||Ne.classList.contains("screenshot-btn")))}),Oe=document.createElement("a");Oe.download=`response-${Date.now()}.png`,Oe.href=xe,Oe.click()}finally{j.classList.remove("screenshot-mode")}}catch{}finally{l.value=!1}}};Vue.onMounted(()=>{window.copyCodeBlock||(window.copyCodeBlock=async function(I){let L=I.closest(".code-block-wrapper").querySelector("code");if(L)try{await navigator.clipboard.writeText(L.textContent),I.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(()=>{I.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(I=>{hljs.highlightElement(I),I.dataset.highlighted="true"}),Ft(c.value)})}),Vue.watch(()=>e.turn.textContent,()=>{Vue.nextTick(()=>{typeof hljs<"u"&&document.querySelectorAll("pre code:not([data-highlighted])").forEach(I=>{hljs.highlightElement(I),I.dataset.highlighted="true"}),Ft(c.value)})});let fe=I=>{if(I?.src){let L=ai(I.src,s.effectiveWorkDir||"");return L?p.get(L.path)||"":I.src}if(!I?.fileId)return"";let j=I.previewToken||"";return`/api/preview/${I.fileId}?token=${j}`},Ae=I=>{d.add(I?.assetId||I?.id)},_e=Vue.computed(()=>(Array.isArray(e.turn?.imageMsgs)?e.turn.imageMsgs:[]).map(I=>({image:I,src:fe(I),alt:I?.filename||m("message.imagePreview")})).filter(I=>I.src&&!d.has(I.image?.assetId||I.image?.id))),ce=(I,j)=>{let L=_e.value,ee=L.findIndex(ge=>ge.image===I);ee<0||As(L[ee].src,{alt:L[ee].alt,closeLabel:m("common.close"),zoomOutLabel:m("message.zoomOut"),zoomInLabel:m("message.zoomIn"),resetZoomLabel:m("message.resetZoom"),previousLabel:m("message.previousImage"),nextLabel:m("message.nextImage"),positionLabel:(ge,xe)=>m("message.imagePosition",{current:ge,total:xe}),gallery:L.map(({src:ge,alt:xe})=>({src:ge,alt:xe})),initialIndex:ee,trigger:j})},se=I=>{if(I)try{typeof s.cancelVpTurn=="function"&&s.cancelVpTurn(I)}catch{}},te=()=>{let I=e.turn;return I?typeof I.timestamp=="number"&&I.timestamp>0?I.timestamp:typeof I.createdAt=="number"&&I.createdAt>0?I.createdAt:typeof I.speakerTimestamp=="number"&&I.speakerTimestamp>0?I.speakerTimestamp:null:null},_=Vue.computed(()=>Jt(te())),oe=Vue.computed(()=>{let I=te();if(!I)return"";try{return new Date(I).toLocaleString()}catch{return""}}),E=Vue.computed(()=>$p(e.turn,e.quoteAuthor||m("message.assistant"))),Z=Vue.computed(()=>{let I=typeof e.turn?.model=="string"?e.turn.model.trim():"";if(!I)return"";let j=I.lastIndexOf("/");return j>=0?I.slice(j+1):I}),ue=Vue.computed(()=>{let I=Number.isFinite(e.turn?.inputTokens)?Math.max(0,Math.round(e.turn.inputTokens)):null,j=Number.isFinite(e.turn?.outputTokens)?Math.max(0,Math.round(e.turn.outputTokens)):null,L=Number.isFinite(e.turn?.totalTokens)?Math.max(0,Math.round(e.turn.totalTokens)):I!=null&&j!=null?I+j:null;if(L==null||I==null||j==null||L===0&&I===0&&j===0)return"";let ee=ge=>new Intl.NumberFormat().format(ge);return m("yeaft.message.tokenUsage",{total:ee(L),input:ee(I),output:ee(j)})});return{onStopTurn:se,turnTime:_,turnTimeFull:oe,assistantQuote:E,responseModelMeta:Z,responseTokenMeta:ue,copied:n,fullCopied:r,expanded:o,screenshotting:l,turnRef:c,showToolActions:S,latestTool:b,historyTools:k,latestToolIndex:P,actionTools:w,routeMessages:h,toggleExpand:B,toolExpandedValue:U,updateToolExpanded:F,textSegments:R,progressSegments:J,resultSegments:V,renderSegment:O,onMarkdownClick:M,copyContent:z,copyFullResponse:X,exportMarkdown:G,screenshotContent:re,onAskSubmit:y,imageSrc:fe,failedImages:d,handleImageError:Ae,previewImage:ce,displayedTodos:x}}}});function dc(e){if(!Number.isFinite(e)||e<0)return"";let t=Math.floor(e/1e3),s=t%60,n=Math.floor(t/60)%60,r=Math.floor(t/3600);return r>0?`${r}h${n}m${s}s`:t>=60?`${n}m${s}s`:`${s}s`}var fg=W(()=>{});var nr,Do=W(()=>{_o();uo();Zn();fg();Ns();nr={name:"VpTurnBlock",components:{AssistantTurn:sr},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:""},displayNameOverride:{type:String,default:""},canStop:{type:Boolean,default:!0},interactiveSpeaker:{type:Boolean,default:!0}},emits:["toggle-response-collapse","quote","open-debug"],template:`
|
|
911
911
|
<div class="vp-turn-block"
|
|
912
912
|
:class="{ 'vp-turn-block-streaming': turn.isStreaming }"
|
|
913
913
|
:data-turn-id="turn.turnId || ''"
|
|
@@ -7487,7 +7487,7 @@ ${String(e||"").trim()}
|
|
|
7487
7487
|
</div>
|
|
7488
7488
|
</div>
|
|
7489
7489
|
</div>
|
|
7490
|
-
`,data(){return{showAgentDropdown:!1,showSettingsPanel:!1,showAgentSettings:!1,agentSettingsAgentId:null,showConversationModal:!1,unifiedSessionCreateOpen:!1,unifiedSessionCreateProvider:"yeaft",unifiedSessionCreateProject:null,convModalAgent:"",convModalWorkDir:"",convModalProvider:"claude-code",selectedResumeSession:null,historyLoaded:!1,windowWidth:window.innerWidth,folderPickerOpen:!1,folderPickerPath:"",folderPickerEntries:[],folderPickerLoading:!1,folderPickerSelected:"",folderPickerTarget:"",_folderPickerRequestId:null,_folderPickerRequestAgentId:null,serverVersion:"",chatGroupCollapsed:!1,sidebarTab:"chat",editingChatId:null,editingChatName:"",activeSessionMenu:null}},computed:{store(){return Pinia.useChatStore()},restartingAgents(){return Object.fromEntries(Object.entries(this.store.agentOperations||{}).filter(([,e])=>e.restart?.pending))},upgradingAgents(){return Object.fromEntries(Object.entries(this.store.agentOperations||{}).filter(([,e])=>e.upgrade?.pending))},bulkUpgradableAgents(){return typeof this.store.getUpgradableAgents=="function"?this.store.getUpgradableAgents():[]},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=je().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},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&&!this.isConversationHidden(e)))},pinnedChatConversations(){let e=this.store.conversations.filter(t=>t.agentOnline!==!1&&!this.isConversationHidden(t)&&this.store.isSessionPinned(t.id));return this.sortByActivity(e)},unpinnedChatConversations(){return this.sortByActivity(this.store.conversations.filter(e=>e.agentOnline!==!1&&!this.isConversationHidden(e)&&!this.store.isSessionPinned(e.id)))},chatSessionCount(){return this.store.conversations.filter(e=>e.agentOnline!==!1&&!this.isConversationHidden(e)).length}},methods:{isConversationHidden(e){return e?.id?(this.store.hiddenSessionCatalog||[]).some(t=>t?.runtimeProvider===(e.provider||"claude-code")&&t?.routeRef?.sessionId===e.id&&t?.routeRef?.agentId===(e.agentId||this.store.currentAgent||null)):!1},onSidebarCollapse(){Bm({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 nf(e)},isCatalogSessionUnread(e){return e?.runtimeProvider!=="yeaft"?!1:this.store.isYeaftSessionUnread(e.routeRef?.sessionId,e.routeRef?.agentId)},onUnifiedCreate(e="yeaft"){this.unifiedSessionCreateProject=null,this.unifiedSessionCreateProvider=["yeaft","copilot","claude-code"].includes(e)?e:"yeaft",this.unifiedSessionCreateOpen=!0},onUnifiedCreateInProject({project:e}={}){e?.id&&(this.unifiedSessionCreateProject=e,this.unifiedSessionCreateProvider="yeaft",this.unifiedSessionCreateOpen=!0)},closeUnifiedSessionCreate(){this.unifiedSessionCreateOpen=!1,this.unifiedSessionCreateProject=null},async onUnifiedSessionCreated(e){let t=this.unifiedSessionCreateProject;if(this.closeUnifiedSessionCreate(),!t||!e?.id)return;let s=e.agentId||t.legacyAgentId||this.store.currentAgent||null,n=await this.store.mutateProject?.("move_session",{sessionId:e.id,projectId:t.legacyProjectId||t.id},s);if(!n?.ok){let r=n?.error?.message||n?.error?.code||"unknown";await it(this.$t("sidebar.projects.assignFailed",{name:t.name,message:r}))}},async onUnifiedSessionAction({action:e,row:t,title:s,sessions:n}={}){if(!t?.routeRef)return;let{runtimeProvider:r,agentId:i,sessionId:o}=t.routeRef;if(e==="rename")this.store.renameCatalogSession({row:t,title:s});else if(e==="reorder")this.store.reorderCatalogSessions(n);else if(e==="pin")this.store.toggleCatalogSessionPin(t);else if(e==="remove")this.store.hideCatalogSession(t);else if(r==="yeaft"&&e==="copy"){let a=await this.store.copyCatalogSession(t);if(!a?.ok){let l=a?.error?.code||"unknown",c=`yeaft.session.error.${l}`,d=this.$t(c),u=d===c?a?.error?.message||l:d;await it(this.$t("yeaft.session.copyFailed",{message:u}))}}else 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 pa(e,this.$t.bind(this))},selectConversation(e,t){this.store.leaveWorkCenter(),this.store.selectConversation(e,t,{refresh:!0}),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,{refresh:!0}),this.store.closeSessionSidebar();return}this.selectConversation(e.id,e.agentId)},hideSessionFromSidebar(e){if(!e?.id)return;let t=e.provider||"claude-code";this.store.hideCatalogSession({catalogKey:`chat:${e.id}`,runtimeProvider:t,routeRef:{runtimeProvider:t,agentId:e.agentId||this.store.currentAgent||null,sessionId:e.id},title:this.getConversationTitle(e),workDir:e.workDir||"",agentName:e.agentName||"",availability:e.agentOnline===!1?"offline":"online",pinned:this.store.isSessionPinned(e.id)})},closeSession(e,t){this.store.closeSession(e,t)},async deleteConversation(e,t){await Fe(this.$t("chat.delete.confirm"),{destructive:!0})&&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 ya(e)},formatTime(e){return e?new Date(e).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit"}):""},getLastPathSegment(e){return Si(e)},getParentPath(e){if(!e)return"";let t=e.split(/[/\\]/);return t.length<=2?"":t.slice(0,-1).join("/")},handleResize(){this.windowWidth=window.innerWidth},openAgentSettings(e){this.agentSettingsAgentId=e||null,this.showAgentSettings=!0},async restartAgent(e){let s=this.store.agents.find(n=>n.id===e)?.name||e;await Fe(this.$t("chat.agent.restartConfirm",{name:s}))&&this.store.restartAgent(e)},async upgradeAgent(e){let s=this.store.agents.find(n=>n.id===e)?.name||e;await Fe(this.$t("chat.agent.upgradeConfirm",{name:s}))&&this.store.upgradeAgent(e)},async upgradeAllAgents(){let e=this.bulkUpgradableAgents;if(e.length===0)return;let t=Math.max(0,(this.store.agents||[]).length-e.length);await Fe(this.$t("chat.agent.upgradeAllConfirm",{count:e.length,skipped:t}))&&this.store.upgradeAllAgents()},showAgentUpgradeBatchSummary(e){let t=Object.values(e?.results||{}),s=t.filter(i=>i.status==="upgraded").length,n=t.filter(i=>i.status==="already_latest").length,r=t.filter(i=>i.status==="failed").length;it(this.$t("chat.agent.upgradeAllSummary",{upgraded:s,latest:n,failed:r,skipped:e?.skippedCount||0}))},closeFolderPicker(){this.folderPickerOpen=!1,this._folderPickerRequestId=null,this._folderPickerRequestAgentId=null,this._folderPickerTimer&&(clearTimeout(this._folderPickerTimer),this._folderPickerTimer=null)},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(a=>a.id===t),r=s||n?.workDir||"";this.folderPickerPath=r,this.folderPickerEntries=[];let i=`folder-picker-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;this._folderPickerRequestId=i,this._folderPickerRequestAgentId=t;let o=()=>{this.store.sendWsMessage({type:"list_directory",conversationId:"_workdir_picker",directoryPickerScope:"agent",requestId:i,agentId:t,dirPath:r})};o(),this._folderPickerTimer&&clearTimeout(this._folderPickerTimer),this._folderPickerTimer=setTimeout(()=>{this.folderPickerLoading&&this.folderPickerOpen&&o()},5e3)},loadFolderPickerDir(e){let t=this.convModalAgent;if(!t)return;this.folderPickerLoading=!0,this.folderPickerSelected="",this.folderPickerEntries=[];let s=`folder-picker-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;this._folderPickerRequestId=s,this._folderPickerRequestAgentId=t;let n=()=>{this.store.sendWsMessage({type:"list_directory",conversationId:"_workdir_picker",directoryPickerScope:"agent",requestId:s,agentId:t,dirPath:e})};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.closeFolderPicker()}},handleFolderPickerMessage(e){let t=e.detail;!t||t.type!=="directory_listing"||t.conversationId!=="_workdir_picker"||!this.folderPickerOpen||!this._folderPickerRequestId||t.requestId!==this._folderPickerRequestId||this.convModalAgent!==this._folderPickerRequestAgentId||(this._folderPickerTimer&&(clearTimeout(this._folderPickerTimer),this._folderPickerTimer=null),this._folderPickerRequestId=null,this._folderPickerRequestAgentId=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._agentUpgradeAckHandler=e=>{let{success:t,error:s,alreadyLatest:n,version:r,reason:i,currentNode:o,requiredNode:a,batchId:l}=e.detail||{};l||(t?n&&it(this.$t("chat.agent.alreadyLatest",{version:r||""})):i==="node_incompatible"?it(this.$t("chat.agent.nodeIncompatible",{current:o||"?",required:a||"?",version:r||""})):i==="container_image_upgrade_required"?it(this.$t("chat.agent.containerImageUpgradeRequired",{version:r||"?"})):i==="manual_upgrade_required"?it(this.$t("chat.agent.manualUpgradeRequired",{version:r||"?"})):it(`Agent upgrade failed: ${s||"Unknown error"}`))},this._agentUpgradeBatchHandler=e=>this.showAgentUpgradeBatchSummary(e.detail||{}),window.addEventListener("agent-upgrade-ack",this._agentUpgradeAckHandler),window.addEventListener("agent-upgrade-batch-complete",this._agentUpgradeBatchHandler)},beforeUnmount(){document.removeEventListener("click",this._clickOutsideHandler),window.removeEventListener("resize",this.handleResize),window.removeEventListener("workbench-message",this.handleFolderPickerMessage),window.removeEventListener("agent-upgrade-ack",this._agentUpgradeAckHandler),window.removeEventListener("agent-upgrade-batch-complete",this._agentUpgradeBatchHandler),this._folderPickerTimer&&clearTimeout(this._folderPickerTimer)}}});function Um(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((f,g)=>{typeof f=="string"&&f&&!u.has(f)&&u.set(f,g)});let p=[];for(let f of Array.isArray(t)?t:[]){if(!f||!f.id||d&&f.agentId&&!d.has(f.agentId))continue;let g=String(f.id),v=f.agentId?`${f.agentId}${g}`:g;p.push({kind:"session",id:g,raw:f,pinned:!!f.pinned||!f.agentId&&u.has(g),active:l?v===a:g===o,processing:!!f.running||!!f.active||!!f.isRunning||!!f.isActive,_manualOrder:Number.isFinite(f.sortOrder)?f.sortOrder:Number.MAX_SAFE_INTEGER,_activityTime:po(f)})}return p.sort((f,g)=>{if(f.pinned!==g.pinned)return f.pinned?-1:1;if(f._manualOrder!==g._manualOrder)return f._manualOrder-g._manualOrder;if(f._activityTime!==g._activityTime)return g._activityTime-f._activityTime;let v=u.has(f.id)?u.get(f.id):Number.MAX_SAFE_INTEGER,m=u.has(g.id)?u.get(g.id):Number.MAX_SAFE_INTEGER;return v!==m?v-m:f.id.localeCompare(g.id)}),p.map(({_manualOrder:f,_activityTime:g,...v})=>v)}var Km=W(()=>{fo()});var sS,f2,zm,Ym=W(()=>{Ct();Ii();Hc();Bc();Nc();Wc();Uc();Jc();Km();sS=3600*1e3,f2=24*sS,zm={name:"YeaftSidebar",components:{SessionCreateModal:Qs,SidebarModeToggle:aa,SidebarAgentHeader:la,SidebarWorkCenter:ca,SessionSidebarShell:da,UnifiedSessionList:ua},emits:["select-group","select-chat","toggle-sidebar","back","open-settings","open-agent-settings","open-group-settings"],template:`
|
|
7490
|
+
`,data(){return{showAgentDropdown:!1,showSettingsPanel:!1,showAgentSettings:!1,agentSettingsAgentId:null,showConversationModal:!1,unifiedSessionCreateOpen:!1,unifiedSessionCreateProvider:"yeaft",unifiedSessionCreateProject:null,convModalAgent:"",convModalWorkDir:"",convModalProvider:"claude-code",selectedResumeSession:null,historyLoaded:!1,windowWidth:window.innerWidth,folderPickerOpen:!1,folderPickerPath:"",folderPickerEntries:[],folderPickerLoading:!1,folderPickerSelected:"",folderPickerTarget:"",_folderPickerRequestId:null,_folderPickerRequestAgentId:null,serverVersion:"",chatGroupCollapsed:!1,sidebarTab:"chat",editingChatId:null,editingChatName:"",activeSessionMenu:null}},computed:{store(){return Pinia.useChatStore()},restartingAgents(){return Object.fromEntries(Object.entries(this.store.agentOperations||{}).filter(([,e])=>e.restart?.pending))},upgradingAgents(){return Object.fromEntries(Object.entries(this.store.agentOperations||{}).filter(([,e])=>e.upgrade?.pending))},bulkUpgradableAgents(){return typeof this.store.getUpgradableAgents=="function"?this.store.getUpgradableAgents():[]},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=je().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},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&&!this.isConversationHidden(e)))},pinnedChatConversations(){let e=this.store.conversations.filter(t=>t.agentOnline!==!1&&!this.isConversationHidden(t)&&this.store.isSessionPinned(t.id));return this.sortByActivity(e)},unpinnedChatConversations(){return this.sortByActivity(this.store.conversations.filter(e=>e.agentOnline!==!1&&!this.isConversationHidden(e)&&!this.store.isSessionPinned(e.id)))},chatSessionCount(){return this.store.conversations.filter(e=>e.agentOnline!==!1&&!this.isConversationHidden(e)).length}},methods:{isConversationHidden(e){return e?.id?(this.store.hiddenSessionCatalog||[]).some(t=>t?.runtimeProvider===(e.provider||"claude-code")&&t?.routeRef?.sessionId===e.id&&t?.routeRef?.agentId===(e.agentId||this.store.currentAgent||null)):!1},onSidebarCollapse(){Bm({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 nf(e)},isCatalogSessionUnread(e){return e?.runtimeProvider!=="yeaft"?!1:this.store.isYeaftSessionUnread(e.routeRef?.sessionId,e.routeRef?.agentId)},onUnifiedCreate(e="yeaft"){this.unifiedSessionCreateProject=null,this.unifiedSessionCreateProvider=["yeaft","copilot","claude-code"].includes(e)?e:"yeaft",this.unifiedSessionCreateOpen=!0},onUnifiedCreateInProject({project:e}={}){e?.id&&(this.unifiedSessionCreateProject=e,this.unifiedSessionCreateProvider="yeaft",this.unifiedSessionCreateOpen=!0)},closeUnifiedSessionCreate(){this.unifiedSessionCreateOpen=!1,this.unifiedSessionCreateProject=null},async onUnifiedSessionCreated(e){let t=this.unifiedSessionCreateProject;if(this.closeUnifiedSessionCreate(),!t||!e?.id)return;let s=e.agentId||t.legacyAgentId||this.store.currentAgent||null,n=await this.store.mutateProject?.("move_session",{sessionId:e.id,projectId:t.legacyProjectId||t.id},s);if(!n?.ok){let r=n?.error?.message||n?.error?.code||"unknown";await it(this.$t("sidebar.projects.assignFailed",{name:t.name,message:r}))}},async onUnifiedSessionAction({action:e,row:t,title:s,sessions:n}={}){if(!t?.routeRef)return;let{runtimeProvider:r,agentId:i,sessionId:o}=t.routeRef;if(e==="rename")this.store.renameCatalogSession({row:t,title:s});else if(e==="reorder")this.store.reorderCatalogSessions(n);else if(e==="pin")this.store.toggleCatalogSessionPin(t);else if(e==="remove")this.store.hideCatalogSession(t);else if(r==="yeaft"&&e==="copy"){let a=await this.store.copyCatalogSession(t);if(!a?.ok){let l=a?.error?.code||"unknown",c=`yeaft.session.error.${l}`,d=this.$t(c),u=d===c?a?.error?.message||l:d;await it(this.$t("yeaft.session.copyFailed",{message:u}))}}else 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 pa(e,this.$t.bind(this))},selectConversation(e,t){this.store.leaveWorkCenter(),this.store.selectConversation(e,t,{refresh:!0}),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,{refresh:!0}),this.store.closeSessionSidebar();return}this.selectConversation(e.id,e.agentId)},hideSessionFromSidebar(e){if(!e?.id)return;let t=e.provider||"claude-code";this.store.hideCatalogSession({catalogKey:`chat:${e.id}`,runtimeProvider:t,routeRef:{runtimeProvider:t,agentId:e.agentId||this.store.currentAgent||null,sessionId:e.id},title:this.getConversationTitle(e),workDir:e.workDir||"",agentName:e.agentName||"",availability:e.agentOnline===!1?"offline":"online",pinned:this.store.isSessionPinned(e.id)})},closeSession(e,t){this.store.closeSession(e,t)},async deleteConversation(e,t){await Fe(this.$t("chat.delete.confirm"),{destructive:!0})&&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 ya(e)},formatTime(e){return e?new Date(e).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit"}):""},getLastPathSegment(e){return Si(e)},getParentPath(e){if(!e)return"";let t=e.split(/[/\\]/);return t.length<=2?"":t.slice(0,-1).join("/")},handleResize(){this.windowWidth=window.innerWidth},openAgentSettings(e){this.agentSettingsAgentId=e||null,this.showAgentSettings=!0},async restartAgent(e){let s=this.store.agents.find(n=>n.id===e)?.name||e;await Fe(this.$t("chat.agent.restartConfirm",{name:s}))&&this.store.restartAgent(e)},async upgradeAgent(e){let s=this.store.agents.find(n=>n.id===e)?.name||e;await Fe(this.$t("chat.agent.upgradeConfirm",{name:s}))&&this.store.upgradeAgent(e)},async upgradeAllAgents(){let e=this.bulkUpgradableAgents;if(e.length===0)return;let t=Math.max(0,(this.store.agents||[]).length-e.length);await Fe(this.$t("chat.agent.upgradeAllConfirm",{count:e.length,skipped:t}))&&this.store.upgradeAllAgents()},showAgentUpgradeBatchSummary(e){let t=Object.values(e?.results||{}),s=t.filter(i=>i.status==="upgraded").length,n=t.filter(i=>i.status==="already_latest").length,r=t.filter(i=>i.status==="failed").length;it(this.$t("chat.agent.upgradeAllSummary",{upgraded:s,latest:n,failed:r,skipped:e?.skippedCount||0}))},closeFolderPicker(){this.folderPickerOpen=!1,this._folderPickerRequestId=null,this._folderPickerRequestAgentId=null,this._folderPickerTimer&&(clearTimeout(this._folderPickerTimer),this._folderPickerTimer=null)},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(a=>a.id===t),r=s||n?.workDir||"";this.folderPickerPath=r,this.folderPickerEntries=[];let i=`folder-picker-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;this._folderPickerRequestId=i,this._folderPickerRequestAgentId=t;let o=()=>{this.store.sendWsMessage({type:"list_directory",conversationId:"_workdir_picker",directoryPickerScope:"agent",requestId:i,agentId:t,dirPath:r})};o(),this._folderPickerTimer&&clearTimeout(this._folderPickerTimer),this._folderPickerTimer=setTimeout(()=>{this.folderPickerLoading&&this.folderPickerOpen&&o()},5e3)},loadFolderPickerDir(e){let t=this.convModalAgent;if(!t)return;this.folderPickerLoading=!0,this.folderPickerSelected="",this.folderPickerEntries=[];let s=`folder-picker-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;this._folderPickerRequestId=s,this._folderPickerRequestAgentId=t;let n=()=>{this.store.sendWsMessage({type:"list_directory",conversationId:"_workdir_picker",directoryPickerScope:"agent",requestId:s,agentId:t,dirPath:e})};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.closeFolderPicker()}},handleFolderPickerMessage(e){let t=e.detail;!t||t.type!=="directory_listing"||t.conversationId!=="_workdir_picker"||!this.folderPickerOpen||!this._folderPickerRequestId||t.requestId!==this._folderPickerRequestId||this.convModalAgent!==this._folderPickerRequestAgentId||(this._folderPickerTimer&&(clearTimeout(this._folderPickerTimer),this._folderPickerTimer=null),this._folderPickerRequestId=null,this._folderPickerRequestAgentId=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._agentUpgradeAckHandler=e=>{let{success:t,error:s,alreadyLatest:n,version:r,reason:i,currentNode:o,requiredNode:a,batchId:l}=e.detail||{};l||(t?n&&it(this.$t("chat.agent.alreadyLatest",{version:r||""})):i==="node_incompatible"?it(this.$t("chat.agent.nodeIncompatible",{current:o||"?",required:a||"?",version:r||""})):i==="container_image_upgrade_required"?it(this.$t("chat.agent.containerImageUpgradeRequired",{version:r||"?"})):i==="manual_upgrade_required"?it(this.$t("chat.agent.manualUpgradeRequired",{version:r||"?"})):it(`Agent upgrade failed: ${s||"Unknown error"}`))},this._agentUpgradeBatchHandler=e=>this.showAgentUpgradeBatchSummary(e.detail||{}),window.addEventListener("agent-upgrade-ack",this._agentUpgradeAckHandler),window.addEventListener("agent-upgrade-batch-complete",this._agentUpgradeBatchHandler)},beforeUnmount(){document.removeEventListener("click",this._clickOutsideHandler),window.removeEventListener("resize",this.handleResize),window.removeEventListener("workbench-message",this.handleFolderPickerMessage),window.removeEventListener("agent-upgrade-ack",this._agentUpgradeAckHandler),window.removeEventListener("agent-upgrade-batch-complete",this._agentUpgradeBatchHandler),this._folderPickerTimer&&clearTimeout(this._folderPickerTimer)}}});function Um(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((f,g)=>{typeof f=="string"&&f&&!u.has(f)&&u.set(f,g)});let p=[];for(let f of Array.isArray(t)?t:[]){if(!f||!f.id||d&&f.agentId&&!d.has(f.agentId))continue;let g=String(f.id),v=f.agentId?`${f.agentId}${g}`:g;p.push({kind:"session",id:g,raw:f,pinned:!!f.pinned||!f.agentId&&u.has(g),active:l?v===a:g===o,processing:!!f.running||!!f.active||!!f.isRunning||!!f.isActive,_manualOrder:Number.isFinite(f.sortOrder)?f.sortOrder:Number.MAX_SAFE_INTEGER,_activityTime:po(f)})}return p.sort((f,g)=>{if(f.pinned!==g.pinned)return f.pinned?-1:1;if(f._manualOrder!==g._manualOrder)return f._manualOrder-g._manualOrder;if(f._activityTime!==g._activityTime)return g._activityTime-f._activityTime;let v=u.has(f.id)?u.get(f.id):Number.MAX_SAFE_INTEGER,m=u.has(g.id)?u.get(g.id):Number.MAX_SAFE_INTEGER;return v!==m?v-m:f.id.localeCompare(g.id)}),p.map(({_manualOrder:f,_activityTime:g,...v})=>v)}var Km=W(()=>{fo()});var sS,h2,zm,Ym=W(()=>{Ct();Ii();Hc();Bc();Nc();Wc();Uc();Jc();Km();sS=3600*1e3,h2=24*sS,zm={name:"YeaftSidebar",components:{SessionCreateModal:Qs,SidebarModeToggle:aa,SidebarAgentHeader:la,SidebarWorkCenter:ca,SessionSidebarShell:da,UnifiedSessionList:ua},emits:["select-group","select-chat","toggle-sidebar","back","open-settings","open-agent-settings","open-group-settings"],template:`
|
|
7491
7491
|
<SessionSidebarShell class="yeaft-sidebar" :collapsed="collapsed">
|
|
7492
7492
|
<template #collapsed>
|
|
7493
7493
|
<!-- Collapsed Icon Bar \u2014 mirrors Chat's .sidebar-collapsed-bar so the
|
|
@@ -9411,10 +9411,10 @@ ${String(e||"").trim()}
|
|
|
9411
9411
|
</section>
|
|
9412
9412
|
</div>
|
|
9413
9413
|
</Teleport>
|
|
9414
|
-
`}});function wS(e,t,s){if(!Ov.includes(e)||!s?.isAuthenticated||!["yeaft","chat"].includes(t.currentView)||t.workCenterOpen||t.pluginCenterOpen)return!1;if(e==="closeWorkbench")return t.workbenchExpanded===!0;if(t.connectionState!=="connected"||!t.authenticated)return!1;let n=t.agents?.find(o=>o.id===t.currentAgent);if(!n?.online)return!1;if(e==="newSession")return!0;if(t.currentView==="chat"&&(t.isSplitMode||!["admin","pro"].includes(s.role)))return!1;let r=t.activeSessionRoute;if(!dt(r)||r.agentId!==n.id||t.currentAgentInfo?.id!==n.id||t.workbenchRouteProtocolSupported!==!0)return!1;let i=e==="terminal"?"terminal":"file_editor";return t.hasCapability("workbench_session_routes")&&t.hasCapability(i)&&n.capabilities?.includes("workbench_session_routes")===!0&&n.capabilities?.includes(i)===!0}function
|
|
9414
|
+
`}});function wS(e,t,s){if(!Ov.includes(e)||!s?.isAuthenticated||!["yeaft","chat"].includes(t.currentView)||t.workCenterOpen||t.pluginCenterOpen)return!1;if(e==="closeWorkbench")return t.workbenchExpanded===!0;if(t.connectionState!=="connected"||!t.authenticated)return!1;let n=t.agents?.find(o=>o.id===t.currentAgent);if(!n?.online)return!1;if(e==="newSession")return!0;if(t.currentView==="chat"&&(t.isSplitMode||!["admin","pro"].includes(s.role)))return!1;let r=t.activeSessionRoute;if(!dt(r)||r.agentId!==n.id||t.currentAgentInfo?.id!==n.id||t.workbenchRouteProtocolSupported!==!0)return!1;let i=e==="terminal"?"terminal":"file_editor";return t.hasCapability("workbench_session_routes")&&t.hasCapability(i)&&n.capabilities?.includes("workbench_session_routes")===!0&&n.capabilities?.includes(i)===!0}function AS(e,t){for(let s=e;s?.nodeType===1;s=s.parentElement){if(s.hidden||s.getAttribute("aria-hidden")==="true")return!1;let n=t.defaultView?.getComputedStyle(s);if(n?.display==="none"||n?.visibility==="hidden")return!1}return!0}function xS(e,t=globalThis.document){let s=[e?.target,t?.activeElement,...e?.composedPath?.()||[]];return s.some(r=>r?.closest?.(kS))||!s.some(r=>r?.closest?.(IS))&&s.some(r=>r?.closest?.(SS))?!0:[...t?.querySelectorAll(CS)||[]].some(r=>AS(r,t))}function Vv(e,{preferences:t,store:s,auth:n,execute:r,document:i=globalThis.document}){if(xS(e,i))return null;let o=Ov.find(a=>Yo(e,t?.bindings?.[a]));return!o||!wS(o,s,n)||r(o)!==!0?null:(e.preventDefault(),e.stopPropagation(),o)}var Ov,kS,SS,IS,CS,qv=W(()=>{mi();ws();Ov=Object.freeze(["terminal","files","git","newSession","closeWorkbench"]);kS='[contenteditable]:not([contenteditable="false"]), .monaco-editor, .cm-editor, .CodeMirror, .xterm, .terminal-container, iframe',SS='input, textarea, select, [role="textbox"]',IS="[data-message-composer]",CS='[aria-modal="true"], [role="dialog"], dialog[open], .modal-overlay, .settings-overlay, .agent-settings-overlay'});var Fv,Hv=W(()=>{Ii();mi();qv();ws();Fv={name:"UserShortcutsRuntime",components:{SessionCreateModal:Qs},template:`
|
|
9415
9415
|
<SessionCreateModal v-if="sessionCreateOpen" :initial-agent-id="sessionCreateAgentId"
|
|
9416
9416
|
@close="sessionCreateOpen = false" @created="sessionCreateOpen = false" />
|
|
9417
|
-
`,setup(){let e=window.Pinia.useChatStore(),t=window.Pinia.useAuthStore(),{preferences:s,ownerId:n}=ar(),r=Vue.ref(!1),i=Vue.ref(null);Vue.watch([n,()=>e.currentAgent,()=>e.currentView],()=>{r.value=!1},{flush:"sync"});let o=l=>{if(l==="newSession")return i.value=e.currentAgent,r.value=!0,!0;if(l==="closeWorkbench")return e.workbenchExpanded?(e.toggleWorkbench(),!0):!1;let c={capabilityId:l,routeKey:dt(e.activeSessionRoute),accepted:!1};return window.dispatchEvent(new CustomEvent("workbench-open-capability",{detail:c})),c.accepted},a=l=>Vv(l,{preferences:s.value,store:e,auth:t,execute:o});return Vue.onMounted(()=>document.addEventListener("keydown",a)),Vue.onUnmounted(()=>document.removeEventListener("keydown",a)),{sessionCreateOpen:r,sessionCreateAgentId:i}}}});function Nv(){if(Bv)return!1;Bv=!0;let e=null;try{if(e=globalThis.localStorage||null,e?.getItem(td)==="done")return!1}catch{e=null}let t=globalThis.indexedDB;if(!t||typeof t.deleteDatabase!="function"){try{e?.setItem(td,"done")}catch{}return!1}try{let s=t.deleteDatabase(
|
|
9417
|
+
`,setup(){let e=window.Pinia.useChatStore(),t=window.Pinia.useAuthStore(),{preferences:s,ownerId:n}=ar(),r=Vue.ref(!1),i=Vue.ref(null);Vue.watch([n,()=>e.currentAgent,()=>e.currentView],()=>{r.value=!1},{flush:"sync"});let o=l=>{if(l==="newSession")return i.value=e.currentAgent,r.value=!0,!0;if(l==="closeWorkbench")return e.workbenchExpanded?(e.toggleWorkbench(),!0):!1;let c={capabilityId:l,routeKey:dt(e.activeSessionRoute),accepted:!1};return window.dispatchEvent(new CustomEvent("workbench-open-capability",{detail:c})),c.accepted},a=l=>Vv(l,{preferences:s.value,store:e,auth:t,execute:o});return Vue.onMounted(()=>document.addEventListener("keydown",a)),Vue.onUnmounted(()=>document.removeEventListener("keydown",a)),{sessionCreateOpen:r,sessionCreateAgentId:i}}}});function Nv(){if(Bv)return!1;Bv=!0;let e=null;try{if(e=globalThis.localStorage||null,e?.getItem(td)==="done")return!1}catch{e=null}let t=globalThis.indexedDB;if(!t||typeof t.deleteDatabase!="function"){try{e?.setItem(td,"done")}catch{}return!1}try{let s=t.deleteDatabase(TS);return s.onsuccess=()=>{try{e?.setItem(td,"done")}catch{}},s.onerror=()=>{},s.onblocked=()=>{},!0}catch{return!1}}var TS,td,Bv,Wv=W(()=>{TS="yeaft-history-cache",td="yeaft-history-cache-removed-v1",Bv=!1});var RS=Uv(()=>{uo();Lt();Zn();ff();ql();zt();bf();Af();Tf();Pf();jm();Ev();Fc();ic();Lv();Hv();Wv();Nv();window.Pinia={...Pinia,useChatStore:null,useAuthStore:null,useBrowserStore:null};var MS={components:{LoginPage:Mf,ChatPage:Wm,YeaftPage:Dv,AppDialog:$v,UserShortcutsRuntime:Fv},template:`
|
|
9418
9418
|
<AppDialog />
|
|
9419
9419
|
<div v-if="!authStore.initialized" class="auth-bootstrap" aria-busy="true"><span class="session-loading-spinner"></span></div>
|
|
9420
9420
|
<LoginPage v-else-if="!authStore.isAuthenticated" />
|
|
@@ -9423,4 +9423,4 @@ ${String(e||"").trim()}
|
|
|
9423
9423
|
<YeaftPage v-if="chatStore.currentView === 'yeaft'" />
|
|
9424
9424
|
<ChatPage v-else />
|
|
9425
9425
|
</template>
|
|
9426
|
-
`,setup(){let e=wn(),t=je();return e.initTheme(),e.setupVisibilityHandler(),Vue.onMounted(()=>{t.initialize()}),Vue.watch(()=>t.initialized&&t.isAuthenticated,s=>{s&&e.connect()},{immediate:!0}),{authStore:t,chatStore:e}}},ba=Vue.createApp(
|
|
9426
|
+
`,setup(){let e=wn(),t=je();return e.initTheme(),e.setupVisibilityHandler(),Vue.onMounted(()=>{t.initialize()}),Vue.watch(()=>t.initialized&&t.isAuthenticated,s=>{s&&e.connect()},{immediate:!0}),{authStore:t,chatStore:e}}},ba=Vue.createApp(MS),PS=Pinia.createPinia();ba.use(PS);pd(ba,{"zh-CN":Cf,en:xf});yf();window.Pinia.useChatStore=wn;window.Pinia.useAuthStore=je;window.Pinia.useVpStore=ss;window.Pinia.useSessionsStore=pf;window.Pinia.useBrowserStore=vo;ba.component("ToolLine",Po);ba.mount("#app")});export default RS();
|